X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fsubqueue.php;h=e4dcb025135c910844779c3df63583e50ecf39ff;hb=65055044118978383006d52675a230aa09bb3220;hp=b1c914ebda6c0bedf8afe75230e309175d82e0cd;hpb=220b51d8be61e9bd316567f3ad03fffdbc4b7526;p=quix0rs-gnu-social.git diff --git a/actions/subqueue.php b/actions/subqueue.php index b1c914ebda..e4dcb02513 100644 --- a/actions/subqueue.php +++ b/actions/subqueue.php @@ -27,11 +27,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once(INSTALLDIR.'/lib/profilelist.php'); +if (!defined('GNUSOCIAL')) { exit(1); } /** * List of group members @@ -44,22 +40,15 @@ require_once(INSTALLDIR.'/lib/profilelist.php'); */ class SubqueueAction extends GalleryAction { - var $page = null; - - function isReadOnly($args) - { - return true; - } + protected $needLogin = true; - // @todo FIXME: most of this belongs in a base class, sounds common to most group actions? - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $cur = common_current_user(); - if (!$cur || $cur->id != $this->profile->id) { + if (!$this->target->sameAs($this->scoped)) { // TRANS: Client error displayed when trying to approve group applicants without being a group administrator. - $this->clientError(_('You may only approve your own pending subscriptions.')); + throw new ClientException(_('You may only approve your own pending subscriptions.')); } return true; } @@ -70,12 +59,12 @@ class SubqueueAction extends GalleryAction // TRANS: Title of the first page showing pending subscribers still awaiting approval. // TRANS: %s is the name of the user. return sprintf(_('%s subscribers awaiting approval'), - $this->profile->nickname); + $this->target->getNickname()); } else { // TRANS: Title of all but the first page showing pending subscribersmembers still awaiting approval. // TRANS: %1$s is the name of the user, %2$d is the page number of the members list. return sprintf(_('%1$s subscribers awaiting approval, page %2$d'), - $this->profile->nickname, + $this->target->getNickname(), $this->page); } } @@ -95,47 +84,21 @@ class SubqueueAction extends GalleryAction $cnt = 0; - $members = $this->profile->getRequests($offset, $limit); - - if ($members) { - // @fixme change! - $member_list = new SubQueueList($members, $this); - $cnt = $member_list->show(); + try { + $subqueue = $this->target->getRequests($offset, $limit); + } catch (NoResultException $e) { + // TRANS: If no pending subscription requests are found + $this->element('div', null, _m('You have no pending subscription requests.')); + return; } - $members->free(); + $list = new SubQueueList($subqueue, $this); + $cnt = $list->show(); + + $subqueue->free(); $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'subqueue', - array('nickname' => $this->profile->nickname)); // urgh - } -} - -class SubQueueList extends ProfileList -{ - function newListItem($profile) - { - return new SubQueueListItem($profile, $this->action); - } -} - -class SubQueueListItem extends ProfileListItem -{ - function showActions() - { - $this->startActions(); - if (Event::handle('StartProfileListItemActionElements', array($this))) { - $this->showApproveButtons(); - Event::handle('EndProfileListItemActionElements', array($this)); - } - $this->endActions(); - } - - function showApproveButtons() - { - $this->out->elementStart('li', 'entity_approval'); - $form = new ApproveSubForm($this->out, $this->profile); - $form->show(); - $this->out->elementEnd('li'); + array('nickname' => $this->target->getNickname())); // urgh } }