3 * Data class for counting greetings
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2009, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
37 * Data class for counting greetings
39 * We use the DB_DataObject framework for data classes in StatusNet. Each
40 * table maps to a particular data class, making it easier to manipulate
43 * Data classes should extend Memcached_DataObject, the (slightly misnamed)
44 * extension of DB_DataObject that provides caching, internationalization,
45 * and other bits of good functionality to StatusNet-specific data classes.
49 * @author Evan Prodromou <evan@status.net>
50 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
51 * @link http://status.net/
55 class User_followeveryone_prefs extends Managed_DataObject
57 public $__table = 'user_followeveryone_prefs'; // table name
58 public $user_id; // int(4) primary_key not_null
59 public $followeveryone; // tinyint(1)
60 public $created; // datetime() not_null
61 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
63 public static function schemaDef()
67 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
68 'followeveryone' => array('type' => 'int', 'default' => 1, 'size' => 'tiny', 'description' => 'whether to follow everyone'),
69 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
70 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
72 'primary key' => array('user_id'),
73 'foreign keys' => array(
74 'user_followeveryone_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
79 static function followEveryone($user_id)
81 $ufep = self::getKV('user_id', $user_id);
86 return (bool)$ufep->followeveryone;
90 static function savePref($user_id, $followEveryone)
92 $ufep = self::getKV('user_id', $user_id);
95 $ufep = new User_followeveryone_prefs();
96 $ufep->user_id = $user_id;
97 $ufep->followeveryone = $followEveryone;
100 $orig = clone($ufep);
101 $ufep->followeveryone = $followEveryone;