X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fblock.php;h=7458caa6ac73200ea50e2be58c3fd97c2f9ac839;hb=cd3cff451f2ac12ebe1b98c6ab643a0e4e931599;hp=11565e20c528d63a4d6920b25180d9ed63a77d9b;hpb=f8883367184e4fd31dc819d5e1257d0eee11eb10;p=quix0rs-gnu-social.git diff --git a/actions/block.php b/actions/block.php index 11565e20c5..7458caa6ac 100644 --- a/actions/block.php +++ b/actions/block.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://status.net/ */ - class BlockAction extends ProfileFormAction { var $profile = null; @@ -54,7 +53,6 @@ class BlockAction extends ProfileFormAction * * @return boolean success flag */ - function prepare($args) { if (!parent::prepare($args)) { @@ -66,8 +64,8 @@ class BlockAction extends ProfileFormAction assert(!empty($cur)); // checked by parent if ($cur->hasBlocked($this->profile)) { + // TRANS: Client error displayed when blocking a user that has already been blocked. $this->clientError(_('You already blocked that user.')); - return false; } return true; @@ -82,18 +80,19 @@ class BlockAction extends ProfileFormAction * * @return void */ - function handle($args) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->arg('no')) { - $this->returnToArgs(); + $this->returnToPrevious(); } elseif ($this->arg('yes')) { $this->handlePost(); - $this->returnToArgs(); + $this->returnToPrevious(); } else { $this->showPage(); } + } else { + $this->showPage(); } } @@ -102,6 +101,7 @@ class BlockAction extends ProfileFormAction } function title() { + // TRANS: Title for block user page. return _('Block user'); } @@ -118,6 +118,12 @@ class BlockAction extends ProfileFormAction */ function areYouSureForm() { + // @fixme if we ajaxify the confirmation form, skip the preview on ajax hits + $profile = new ArrayWrapper(array($this->profile)); + $preview = new ProfileList($profile, $this); + $preview->show(); + + $id = $this->profile->id; $this->elementStart('form', array('id' => 'block-' . $id, 'method' => 'post', @@ -125,8 +131,10 @@ class BlockAction extends ProfileFormAction 'action' => common_local_url('block'))); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); + // TRANS: Legend for block user form. $this->element('legend', _('Block user')); $this->element('p', null, + // TRANS: Explanation of consequences when blocking a user on the block user page. _('Are you sure you want to block this user? '. 'Afterwards, they will be unsubscribed from you, '. 'unable to subscribe to you in the future, and '. @@ -146,14 +154,14 @@ class BlockAction extends ProfileFormAction 'submit form_action-primary', 'no', // TRANS: Submit button title for 'No' when blocking a user. - _('Do not block this user')); + _('Do not block this user.')); $this->submit('form_action-yes', // TRANS: Button label on the user block form. _m('BUTTON','Yes'), 'submit form_action-secondary', 'yes', // TRANS: Submit button title for 'Yes' when blocking a user. - _('Block this user')); + _('Block this user.')); $this->elementEnd('fieldset'); $this->elementEnd('form'); } @@ -176,8 +184,8 @@ class BlockAction extends ProfileFormAction } if (!$result) { + // TRANS: Server error displayed when blocking a user fails. $this->serverError(_('Failed to save block information.')); - return; } } @@ -187,4 +195,38 @@ class BlockAction extends ProfileFormAction $this->autofocus('form_action-yes'); } + /** + * Override for form session token checks; on our first hit we're just + * requesting confirmation, which doesn't need a token. We need to be + * able to take regular GET requests from email! + * + * @throws ClientException if token is bad on POST request or if we have + * confirmation parameters which could trigger something. + */ + function checkSessionToken() + { + if ($_SERVER['REQUEST_METHOD'] == 'POST' || + $this->arg('yes') || + $this->arg('no')) { + + return parent::checkSessionToken(); + } + } + + /** + * If we reached this form without returnto arguments, return to the + * current user's subscription list. + * + * @return string URL + */ + function defaultReturnTo() + { + $user = common_current_user(); + if ($user) { + return common_local_url('subscribers', + array('nickname' => $user->nickname)); + } else { + return common_local_url('public'); + } + } }