Retool group join queue list ajax forms to use two buttons in one form, making it more ajax-submit-friendly. Needs util.js fixes for AJAX submission input buttons...

This commit is contained in:
Brion Vibber 2011-03-23 14:56:51 -07:00
parent 2b901894c2
commit 265f9af6f7
3 changed files with 28 additions and 20 deletions

View File

@ -119,6 +119,15 @@ class ApprovegroupAction extends Action
if (empty($this->request)) { if (empty($this->request)) {
$this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403); $this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403);
} }
$this->approve = (bool)$this->arg('approve');
$this->cancel = (bool)$this->arg('cancel');
if (!$this->approve && !$this->cancel) {
$this->clientError(_('Internal error: received neither cancel nor abort.'));
}
if ($this->approve && $this->cancel) {
$this->clientError(_('Internal error: received both cancel and abort.'));
}
return true; return true;
} }
@ -136,7 +145,11 @@ class ApprovegroupAction extends Action
parent::handle($args); parent::handle($args);
try { try {
if ($this->approve) {
$this->profile->completeJoinGroup($this->group); $this->profile->completeJoinGroup($this->group);
} elseif ($this->cancel) {
$this->profile->cancelJoinGroup($this->group);
}
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_ERROR, "Exception canceling group sub: " . $e->getMessage()); common_log(LOG_ERROR, "Exception canceling group sub: " . $e->getMessage());
// TRANS: Server error displayed when cancelling a queued group join request fails. // TRANS: Server error displayed when cancelling a queued group join request fails.
@ -149,14 +162,17 @@ class ApprovegroupAction extends Action
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8'); $this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head'); $this->elementStart('head');
// TRANS: Title for leave group page after leaving. // TRANS: Title for leave group page after group join request is approved/disapproved.
$this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'), $this->element('title', null, sprintf(_m('TITLE','%1$s\'s request for %2$s'),
$this->profile->nickname, $this->profile->nickname,
$this->group->nickname)); $this->group->nickname));
$this->elementEnd('head'); $this->elementEnd('head');
$this->elementStart('body'); $this->elementStart('body');
$jf = new JoinForm($this, $this->group); if ($this->approve) {
$jf->show(); $this->element('p', 'success', _m('Join request approved.'));
} elseif ($this->cancel) {
$this->element('p', 'success', _m('Join request canceled.'));
}
$this->elementEnd('body'); $this->elementEnd('body');
$this->elementEnd('html'); $this->elementEnd('html');
} else { } else {

View File

@ -174,26 +174,17 @@ class GroupQueueListItem extends GroupMemberListItem
{ {
$this->startActions(); $this->startActions();
if (Event::handle('StartProfileListItemActionElements', array($this))) { if (Event::handle('StartProfileListItemActionElements', array($this))) {
$this->showApproveButton(); $this->showApproveButtons();
$this->showCancelButton();
Event::handle('EndProfileListItemActionElements', array($this)); Event::handle('EndProfileListItemActionElements', array($this));
} }
$this->endActions(); $this->endActions();
} }
function showApproveButton() function showApproveButtons()
{ {
$this->out->elementStart('li', 'entity_join'); $this->out->elementStart('li', 'entity_approval');
$form = new ApproveGroupForm($this->out, $this->group, $this->profile); $form = new ApproveGroupForm($this->out, $this->group, $this->profile);
$form->show(); $form->show();
$this->out->elementEnd('li'); $this->out->elementEnd('li');
} }
function showCancelButton()
{
$this->out->elementStart('li', 'entity_leave');
$bf = new CancelGroupForm($this->out, $this->group, $this->profile);
$bf->show();
$this->out->elementEnd('li');
}
} }

View File

@ -79,7 +79,7 @@ class ApproveGroupForm extends Form
function id() function id()
{ {
return 'group-cancel-' . $this->group->id; return 'group-queue-' . $this->group->id;
} }
/** /**
@ -90,7 +90,7 @@ class ApproveGroupForm extends Form
function formClass() function formClass()
{ {
return 'form_group_join ajax'; return 'form_group_queue ajax';
} }
/** /**
@ -117,6 +117,7 @@ class ApproveGroupForm extends Form
function formActions() function formActions()
{ {
$this->out->submit('submit', _('Approve')); $this->out->submit('approve', _('Accept'));
$this->out->submit('cancel', _('Reject'));
} }
} }