usergroups.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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->getTarget()->getNickname());
  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->getTarget()->getNickname(),
  58. $this->page);
  59. }
  60. }
  61. function showPageNotice()
  62. {
  63. if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
  64. $this->element('p', 'instructions',
  65. // TRANS: Page notice for page with an overview of all subscribed groups
  66. // TRANS: of the logged in user's own profile.
  67. _('These are the groups whose notices '.
  68. 'you listen to.'));
  69. } else {
  70. $this->element('p', 'instructions',
  71. // TRANS: Page notice for page with an overview of all groups a user other
  72. // TRANS: than the logged in user. %s is the user nickname.
  73. sprintf(_('These are the groups whose '.
  74. 'notices %s listens to.'),
  75. $this->target->getNickname()));
  76. }
  77. }
  78. function showContent()
  79. {
  80. if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
  81. $notice =
  82. // TRANS: Page notice of user's groups page.
  83. // TRANS: %%%%action.groupsearch%%%% and %%%%action.newgroup%%%% are URLs. Do not change them.
  84. // TRANS: This message contains Markdown links in the form [link text](link).
  85. sprintf(_('Groups let you find and talk with ' .
  86. 'people of similar interests. ' .
  87. 'You can [search for groups](%%%%action.groups%%%%) in your instance or ' .
  88. '[create a new group](%%%%action.newgroup%%%%). ' .
  89. 'You can also follow groups ' .
  90. 'from other GNU social instances: click on the remote button below ' .
  91. 'and copy the group\'s link. ' .
  92. 'You can find a list of GNU social groups [here](http://skilledtests.com/wiki/List_of_federated_GNU_social_groups)' .
  93. ''));
  94. $this->elementStart('div', 'instructions');
  95. $this->raw(common_markup_to_html($notice));
  96. $this->elementEnd('div');
  97. }
  98. if (Event::handle('StartShowUserGroupsContent', array($this))) {
  99. $offset = ($this->page-1) * GROUPS_PER_PAGE;
  100. $limit = GROUPS_PER_PAGE + 1;
  101. $groups = $this->getTarget()->getGroups($offset, $limit);
  102. if ($groups instanceof User_group) {
  103. $gl = new GroupList($groups, $this->getTarget(), $this);
  104. $cnt = $gl->show();
  105. if (0 == $cnt) {
  106. $this->showEmptyListMessage();
  107. } else {
  108. $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
  109. $this->page, 'usergroups',
  110. array('nickname' => $this->getTarget()->getNickname()));
  111. }
  112. }
  113. Event::handle('EndShowUserGroupsContent', array($this));
  114. }
  115. }
  116. function showEmptyListMessage()
  117. {
  118. // TRANS: Text on group page for a user that is not a member of any group.
  119. // TRANS: %s is a user nickname.
  120. $message = sprintf(_('%s is not a member of any group.'), $this->getTarget()->getNickname()) . ' ';
  121. if (common_logged_in()) {
  122. if ($this->scoped->sameAs($this->getTarget())) {
  123. // TRANS: Text on group page for a user that is not a member of any group. This message contains
  124. // TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed.
  125. $message = _('You are not member of any group yet. After you join a group ' .
  126. 'you can send messages to its members using the ' .
  127. 'syntax "!groupname".');
  128. }
  129. }
  130. $this->elementStart('div', 'guide');
  131. $this->raw(common_markup_to_html($message));
  132. $this->elementEnd('div');
  133. }
  134. function showProfileBlock()
  135. {
  136. $block = new AccountProfileBlock($this, $this->getTarget());
  137. $block->show();
  138. }
  139. }