usergroups.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * User groups information
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Personal
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @author Sarven Capadisli <csarven@status.net>
  26. * @copyright 2008-2009 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET') && !defined('LACONICA')) {
  31. exit(1);
  32. }
  33. require_once INSTALLDIR.'/lib/grouplist.php';
  34. /**
  35. * User groups page
  36. *
  37. * Show the groups a user belongs to
  38. *
  39. * @category Personal
  40. * @package StatusNet
  41. * @author Evan Prodromou <evan@status.net>
  42. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  43. * @link http://status.net/
  44. */
  45. class UsergroupsAction extends GalleryAction
  46. {
  47. function title()
  48. {
  49. if ($this->page == 1) {
  50. // TRANS: Page title for first page of groups for a user.
  51. // TRANS: %s is a nickname.
  52. return sprintf(_('%s groups'), $this->user->nickname);
  53. } else {
  54. // TRANS: Page title for all but the first page of groups for a user.
  55. // TRANS: %1$s is a nickname, %2$d is a page number.
  56. return sprintf(_('%1$s groups, page %2$d'),
  57. $this->user->nickname,
  58. $this->page);
  59. }
  60. }
  61. function showContent()
  62. {
  63. $this->elementStart('p', array('id' => 'new_group'));
  64. $this->element('a', array('href' => common_local_url('newgroup'),
  65. 'class' => 'more'),
  66. // TRANS: Link text on group page to create a new group.
  67. _('Create a new group'));
  68. $this->elementEnd('p');
  69. $this->elementStart('p', array('id' => 'group_search'));
  70. $this->element('a', array('href' => common_local_url('groupsearch'),
  71. 'class' => 'more'),
  72. // TRANS: Link text on group page to search for groups.
  73. _('Search for more groups'));
  74. $this->elementEnd('p');
  75. if (Event::handle('StartShowUserGroupsContent', array($this))) {
  76. $offset = ($this->page-1) * GROUPS_PER_PAGE;
  77. $limit = GROUPS_PER_PAGE + 1;
  78. $groups = $this->user->getGroups($offset, $limit);
  79. if ($groups instanceof User_group) {
  80. $gl = new GroupList($groups, $this->user, $this);
  81. $cnt = $gl->show();
  82. $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
  83. $this->page, 'usergroups',
  84. array('nickname' => $this->user->nickname));
  85. } else {
  86. $this->showEmptyListMessage();
  87. }
  88. Event::handle('EndShowUserGroupsContent', array($this));
  89. }
  90. }
  91. function showEmptyListMessage()
  92. {
  93. // TRANS: Text on group page for a user that is not a member of any group.
  94. // TRANS: %s is a user nickname.
  95. $message = sprintf(_('%s is not a member of any group.'), $this->user->nickname) . ' ';
  96. if (common_logged_in()) {
  97. $current_user = common_current_user();
  98. if ($this->user->id === $current_user->id) {
  99. // TRANS: Text on group page for a user that is not a member of any group. This message contains
  100. // TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed.
  101. $message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.');
  102. }
  103. }
  104. $this->elementStart('div', 'guide');
  105. $this->raw(common_markup_to_html($message));
  106. $this->elementEnd('div');
  107. }
  108. function showProfileBlock()
  109. {
  110. $block = new AccountProfileBlock($this, $this->profile);
  111. $block->show();
  112. }
  113. }