3 * Table Definition for local_group
6 class Local_group extends Managed_DataObject
9 /* the code below is auto generated do not remove the above tag */
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
17 /* the code above is auto generated do not remove the tag below */
20 public static function schemaDef()
23 'description' => 'Record for a user group on the local site, with some additional info not in user_group',
25 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'),
26 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'),
28 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
29 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
31 'primary key' => array('group_id'),
32 'foreign keys' => array(
33 'local_group_group_id_fkey' => array('user_group', array('group_id' => 'id')),
35 'unique keys' => array(
36 'local_group_nickname_key' => array('nickname'),
41 public function getProfile()
43 return $this->getGroup()->getProfile();
46 public function getGroup()
48 $group = new User_group();
49 $group->id = $this->group_id;
51 if (!$group instanceof User_group) {
52 common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
53 throw new NoSuchGroupException(array('id' => $this->group_id));
58 function setNickname($nickname)
61 $qry = 'UPDATE local_group set nickname = "'.$this->escape($nickname).'" where group_id = ' . $this->group_id;
63 $result = $this->query($qry);
66 $this->nickname = $nickname;
67 $this->fixupTimestamps();
70 common_log_db_error($local, 'UPDATE', __FILE__);
71 // TRANS: Server exception thrown when updating a local group fails.
72 throw new ServerException(_('Could not update local group.'));