123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
- class User_followeveryone_prefs extends Managed_DataObject
- {
- public $__table = 'user_followeveryone_prefs';
- public $user_id;
- public $followeveryone;
- public $created;
- public $modified;
- public static function schemaDef()
- {
- return array(
- 'fields' => array(
- 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
- 'followeveryone' => array('type' => 'int', 'default' => 1, 'size' => 'tiny', 'description' => 'whether to follow everyone'),
- 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
- 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
- ),
- 'primary key' => array('user_id'),
- 'foreign keys' => array(
- 'user_followeveryone_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
- ),
- );
- }
- static function followEveryone($user_id)
- {
- $ufep = self::getKV('user_id', $user_id);
- if (empty($ufep)) {
- return true;
- } else {
- return (bool)$ufep->followeveryone;
- }
- }
- static function savePref($user_id, $followEveryone)
- {
- $ufep = self::getKV('user_id', $user_id);
- if (empty($ufep)) {
- $ufep = new User_followeveryone_prefs();
- $ufep->user_id = $user_id;
- $ufep->followeveryone = $followEveryone;
- $ufep->insert();
- } else {
- $orig = clone($ufep);
- $ufep->followeveryone = $followEveryone;
- $ufep->update();
- }
- return true;
- }
- }
|