Pending subscription requests now work as they should
A slight layout issue with the buttons still persists
This commit is contained in:
parent
b374e5f08b
commit
c19964094b
|
@ -27,11 +27,7 @@
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of group members
|
* List of group members
|
||||||
|
@ -50,9 +46,9 @@ class SubqueueAction extends GalleryAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if ($this->scoped->id != $this->target->id) {
|
if (!$this->target->sameAs($this->scoped)) {
|
||||||
// TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -88,47 +84,21 @@ class SubqueueAction extends GalleryAction
|
||||||
|
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
|
|
||||||
$members = $this->target->getRequests($offset, $limit);
|
try {
|
||||||
|
$subqueue = $this->target->getRequests($offset, $limit);
|
||||||
if ($members) {
|
} catch (NoResultException $e) {
|
||||||
// @fixme change!
|
// TRANS: If no pending subscription requests are found
|
||||||
$member_list = new SubQueueList($members, $this);
|
$this->element('div', null, _m('You have no pending subscription requests.'));
|
||||||
$cnt = $member_list->show();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$members->free();
|
$list = new SubQueueList($subqueue, $this);
|
||||||
|
$cnt = $list->show();
|
||||||
|
|
||||||
|
$subqueue->free();
|
||||||
|
|
||||||
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||||
$this->page, 'subqueue',
|
$this->page, 'subqueue',
|
||||||
array('nickname' => $this->target->getNickname())); // urgh
|
array('nickname' => $this->target->getNickname())); // 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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -682,25 +682,16 @@ class Profile extends Managed_DataObject
|
||||||
*/
|
*/
|
||||||
function getRequests($offset=0, $limit=null)
|
function getRequests($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$qry =
|
// FIXME: mysql only
|
||||||
'SELECT profile.* ' .
|
$subqueue = new Profile();
|
||||||
'FROM profile JOIN subscription_queue '.
|
$subqueue->joinAdd(array('id', 'subscription_queue:subscriber'));
|
||||||
'ON profile.id = subscription_queue.subscriber ' .
|
$subqueue->whereAdd(sprintf('subscription_queue.subscribed = %d', $this->getID()));
|
||||||
'WHERE subscription_queue.subscribed = %d ' .
|
$subqueue->limit($offset, $limit);
|
||||||
'ORDER BY subscription_queue.created DESC ';
|
$subqueue->orderBy('subscription_queue.created', 'DESC');
|
||||||
|
if (!$subqueue->find()) {
|
||||||
if ($limit != null) {
|
throw new NoResultException($subqueue);
|
||||||
if (common_config('db','type') == 'pgsql') {
|
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
}
|
||||||
}
|
return $subqueue;
|
||||||
|
|
||||||
$members = new Profile();
|
|
||||||
|
|
||||||
$members->query(sprintf($qry, $this->id));
|
|
||||||
return $members;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscriptionCount()
|
function subscriptionCount()
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ProfileList extends Widget
|
||||||
/** Action object using us. */
|
/** Action object using us. */
|
||||||
var $action = null;
|
var $action = null;
|
||||||
|
|
||||||
function __construct($profile, $action=null)
|
function __construct($profile, HTMLOutputter $action=null)
|
||||||
{
|
{
|
||||||
parent::__construct($action);
|
parent::__construct($action);
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ class ProfileList extends Widget
|
||||||
return $cnt;
|
return $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newListItem($profile)
|
function newListItem(Profile $target)
|
||||||
{
|
{
|
||||||
return new ProfileListItem($profile, $this->action);
|
return new ProfileListItem($target, $this->action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function maxProfiles()
|
function maxProfiles()
|
||||||
|
|
|
@ -72,7 +72,7 @@ class ProfileListItem extends Widget
|
||||||
function startItem()
|
function startItem()
|
||||||
{
|
{
|
||||||
$this->out->elementStart('li', array('class' => 'profile',
|
$this->out->elementStart('li', array('class' => 'profile',
|
||||||
'id' => 'profile-' . $this->profile->id));
|
'id' => 'profile-' . $this->getTarget()->getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function showProfile()
|
function showProfile()
|
||||||
|
|
11
lib/subqueuelist.php
Normal file
11
lib/subqueuelist.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
|
class SubQueueList extends ProfileList
|
||||||
|
{
|
||||||
|
public function newListItem(Profile $target)
|
||||||
|
{
|
||||||
|
return new SubQueueListItem($target, $this->action);
|
||||||
|
}
|
||||||
|
}
|
24
lib/subqueuelistitem.php
Normal file
24
lib/subqueuelistitem.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
|
class SubQueueListItem extends ProfileListItem
|
||||||
|
{
|
||||||
|
public function showActions()
|
||||||
|
{
|
||||||
|
$this->startActions();
|
||||||
|
if (Event::handle('StartProfileListItemActionElements', array($this))) {
|
||||||
|
$this->showApproveButtons();
|
||||||
|
Event::handle('EndProfileListItemActionElements', array($this));
|
||||||
|
}
|
||||||
|
$this->endActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showApproveButtons()
|
||||||
|
{
|
||||||
|
$this->out->elementStart('li', 'entity_approval');
|
||||||
|
$form = new ApproveSubForm($this->out, $this->profile);
|
||||||
|
$form->show();
|
||||||
|
$this->out->elementEnd('li');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user