]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Local_group.php
b895103d1675452a7c59da35635dcb6c71523d83
[quix0rs-gnu-social.git] / classes / Local_group.php
1 <?php
2 /**
3  * Table Definition for local_group
4  */
5
6 class Local_group extends Managed_DataObject
7 {
8     ###START_AUTOCODE
9     /* the code below is auto generated do not remove the above tag */
10
11     public $__table = 'local_group';                     // table name
12     public $group_id;                        // int(4)  primary_key not_null
13     public $nickname;                        // varchar(64)  unique_key
14     public $created;                         // datetime   not_null default_0000-00-00%2000%3A00%3A00
15     public $modified;                        // timestamp   not_null default_CURRENT_TIMESTAMP
16
17     /* Static get */
18     function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Local_group',$k,$v); }
19
20     /* the code above is auto generated do not remove the tag below */
21     ###END_AUTOCODE
22
23     public static function schemaDef()
24     {
25         return array(
26             'description' => 'Record for a user group on the local site, with some additional info not in user_group',
27             'fields' => array(
28                 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'),
29                 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'),
30
31                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
32                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
33             ),
34             'primary key' => array('group_id'),
35             'foreign keys' => array(
36                 'local_group_group_id_fkey' => array('user_group', array('group_id' => 'id')),
37             ),
38             'unique keys' => array(
39                 'local_group_nickname_key' => array('nickname'),
40             ),
41         );
42     }
43
44     function setNickname($nickname)
45     {
46         $this->decache();
47         $qry = 'UPDATE local_group set nickname = "'.$this->escape($nickname).'" where group_id = ' . $this->group_id;
48
49         $result = $this->query($qry);
50
51         if ($result) {
52             $this->nickname = $nickname;
53             $this->fixupTimestamps();
54             $this->encache();
55         } else {
56             common_log_db_error($local, 'UPDATE', __FILE__);
57             // TRANS: Server exception thrown when updating a local group fails.
58             throw new ServerException(_('Could not update local group.'));
59         }
60
61         return $result;
62     }
63 }