subqueue.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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('GNUSOCIAL')) { exit(1); }
  30. /**
  31. * List of group members
  32. *
  33. * @category Group
  34. * @package StatusNet
  35. * @author Evan Prodromou <evan@status.net>
  36. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  37. * @link http://status.net/
  38. */
  39. class SubqueueAction extends GalleryAction
  40. {
  41. protected $needLogin = true;
  42. protected function prepare(array $args=array())
  43. {
  44. parent::prepare($args);
  45. if (!$this->target->sameAs($this->scoped)) {
  46. // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
  47. throw new ClientException(_('You may only approve your own pending subscriptions.'));
  48. }
  49. return true;
  50. }
  51. function title()
  52. {
  53. if ($this->page == 1) {
  54. // TRANS: Title of the first page showing pending subscribers still awaiting approval.
  55. // TRANS: %s is the name of the user.
  56. return sprintf(_('%s subscribers awaiting approval'),
  57. $this->target->getNickname());
  58. } else {
  59. // TRANS: Title of all but the first page showing pending subscribersmembers still awaiting approval.
  60. // TRANS: %1$s is the name of the user, %2$d is the page number of the members list.
  61. return sprintf(_('%1$s subscribers awaiting approval, page %2$d'),
  62. $this->target->getNickname(),
  63. $this->page);
  64. }
  65. }
  66. function showPageNotice()
  67. {
  68. $this->element('p', 'instructions',
  69. // TRANS: Page notice for group members page.
  70. _('A list of users awaiting approval to subscribe to you.'));
  71. }
  72. function showContent()
  73. {
  74. $offset = ($this->page-1) * PROFILES_PER_PAGE;
  75. $limit = PROFILES_PER_PAGE + 1;
  76. $cnt = 0;
  77. try {
  78. $subqueue = $this->target->getRequests($offset, $limit);
  79. } catch (NoResultException $e) {
  80. // TRANS: If no pending subscription requests are found
  81. $this->element('div', null, _m('You have no pending subscription requests.'));
  82. return;
  83. }
  84. $list = new SubQueueList($subqueue, $this);
  85. $cnt = $list->show();
  86. $subqueue->free();
  87. $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
  88. $this->page, 'subqueue',
  89. array('nickname' => $this->target->getNickname())); // urgh
  90. }
  91. }