subqueue.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * List of group members
  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 Group
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2008-2009 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('STATUSNET') && !defined('LACONICA')) {
  30. exit(1);
  31. }
  32. require_once(INSTALLDIR.'/lib/profilelist.php');
  33. /**
  34. * List of group members
  35. *
  36. * @category Group
  37. * @package StatusNet
  38. * @author Evan Prodromou <evan@status.net>
  39. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  40. * @link http://status.net/
  41. */
  42. class SubqueueAction extends GalleryAction
  43. {
  44. protected $needLogin = true;
  45. protected function prepare(array $args=array())
  46. {
  47. parent::prepare($args);
  48. if ($this->scoped->id != $this->target->id) {
  49. // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
  50. $this->clientError(_('You may only approve your own pending subscriptions.'));
  51. }
  52. return true;
  53. }
  54. function title()
  55. {
  56. if ($this->page == 1) {
  57. // TRANS: Title of the first page showing pending subscribers still awaiting approval.
  58. // TRANS: %s is the name of the user.
  59. return sprintf(_('%s subscribers awaiting approval'),
  60. $this->target->getNickname());
  61. } else {
  62. // TRANS: Title of all but the first page showing pending subscribersmembers still awaiting approval.
  63. // TRANS: %1$s is the name of the user, %2$d is the page number of the members list.
  64. return sprintf(_('%1$s subscribers awaiting approval, page %2$d'),
  65. $this->target->getNickname(),
  66. $this->page);
  67. }
  68. }
  69. function showPageNotice()
  70. {
  71. $this->element('p', 'instructions',
  72. // TRANS: Page notice for group members page.
  73. _('A list of users awaiting approval to subscribe to you.'));
  74. }
  75. function showContent()
  76. {
  77. $offset = ($this->page-1) * PROFILES_PER_PAGE;
  78. $limit = PROFILES_PER_PAGE + 1;
  79. $cnt = 0;
  80. $members = $this->target->getRequests($offset, $limit);
  81. if ($members) {
  82. // @fixme change!
  83. $member_list = new SubQueueList($members, $this);
  84. $cnt = $member_list->show();
  85. }
  86. $members->free();
  87. $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
  88. $this->page, 'subqueue',
  89. array('nickname' => $this->target->getNickname())); // urgh
  90. }
  91. }
  92. class SubQueueList extends ProfileList
  93. {
  94. function newListItem($profile)
  95. {
  96. return new SubQueueListItem($profile, $this->action);
  97. }
  98. }
  99. class SubQueueListItem extends ProfileListItem
  100. {
  101. function showActions()
  102. {
  103. $this->startActions();
  104. if (Event::handle('StartProfileListItemActionElements', array($this))) {
  105. $this->showApproveButtons();
  106. Event::handle('EndProfileListItemActionElements', array($this));
  107. }
  108. $this->endActions();
  109. }
  110. function showApproveButtons()
  111. {
  112. $this->out->elementStart('li', 'entity_approval');
  113. $form = new ApproveSubForm($this->out, $this->profile);
  114. $form->show();
  115. $this->out->elementEnd('li');
  116. }
  117. }