Group_alias.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Table Definition for group_alias
  4. *
  5. * StatusNet - the distributed open-source microblogging tool
  6. * Copyright (C) 2009, StatusNet, Inc.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
  22. require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
  23. class Group_alias extends Managed_DataObject
  24. {
  25. ###START_AUTOCODE
  26. /* the code below is auto generated do not remove the above tag */
  27. public $__table = 'group_alias'; // table name
  28. public $alias; // varchar(64) primary_key not_null
  29. public $group_id; // int(4) not_null
  30. public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
  31. /* the code above is auto generated do not remove the tag below */
  32. ###END_AUTOCODE
  33. public static function schemaDef()
  34. {
  35. return array(
  36. 'fields' => array(
  37. 'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'),
  38. 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
  39. 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'),
  40. ),
  41. 'primary key' => array('alias'),
  42. 'foreign keys' => array(
  43. 'group_alias_group_id_fkey' => array('user_group', array('group_id' => 'id')),
  44. ),
  45. 'indexes' => array(
  46. 'group_alias_group_id_idx' => array('group_id'),
  47. ),
  48. );
  49. }
  50. public function getProfile()
  51. {
  52. $group = User_group::getKV('id', $this->group_id);
  53. if (!($group instanceof User_group)) {
  54. return null; // TODO: Throw exception when other code is ready
  55. }
  56. return $group->getProfile();
  57. }
  58. }