X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Frepeat.php;h=c926d85095e4df75080b6baea13c958a7ed3e53d;hb=418b3c3c53194040022c4b56bd0c0b04fd6fd4d7;hp=2ec641578bcf995a3ec7cd623a2f58298bbc2e65;hpb=880b1b666eeaedee2c9570142b2d0cd56f1d96f1;p=quix0rs-gnu-social.git diff --git a/actions/repeat.php b/actions/repeat.php index 2ec641578b..c926d85095 100644 --- a/actions/repeat.php +++ b/actions/repeat.php @@ -1,5 +1,4 @@ user = common_current_user(); - - if (empty($this->user)) { - $this->clientError(_('Only logged-in users can repeat notices.')); - return false; - } - $id = $this->trimmed('notice'); if (empty($id)) { + // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID. $this->clientError(_('No notice specified.')); - return false; } - $this->notice = Notice::staticGet('id', $id); + $this->notice = Notice::getKV('id', $id); - if (empty($this->notice)) { + if (!($this->notice instanceof Notice)) { + // TRANS: Client error displayed when trying to repeat a non-existing notice. $this->clientError(_('No notice specified.')); - return false; } - if ($this->user->id == $this->notice->profile_id) { - $this->clientError(_('You cannot repeat your own notice.')); - return false; - } - - $token = $this->trimmed('token-'.$id); + $token = $this->trimmed('token-'.$id); if (empty($token) || $token != common_session_token()) { + // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); - return false; - } - - $profile = $this->user->getProfile(); - - if ($profile->hasRepeated($id)) { - $this->clientError(_('You already repeated that notice.')); - return false; } return true; @@ -100,25 +82,27 @@ class RepeatAction extends Action * * @return void */ - function handle($args) + protected function handle() { - $repeat = $this->notice->repeat($this->user->id, 'web'); - + parent::handle(); + $repeat = $this->notice->repeat($this->scoped->id, 'web'); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); + // TRANS: Title after repeating a notice. $this->element('title', null, _('Repeated')); $this->elementEnd('head'); $this->elementStart('body'); $this->element('p', array('id' => 'repeat_response', 'class' => 'repeated'), + // TRANS: Confirmation text after repeating a notice. _('Repeated!')); $this->elementEnd('body'); - $this->elementEnd('html'); + $this->endHTML(); } else { - // FIXME! + // @todo FIXME! } } }