X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Frepeat.php;h=501570ebf0f7d6c6e9ba08cdd0760196ec8354b0;hb=15140867f14bc37cba25b6a76d1bb938a5af8687;hp=333e1cd02eacac5de47b128b8f7a97dde4e5f146;hpb=12588b1cf73fad7d0a76a29a46ec355150eaa54e;p=quix0rs-gnu-social.git diff --git a/actions/repeat.php b/actions/repeat.php index 333e1cd02e..501570ebf0 100644 --- a/actions/repeat.php +++ b/actions/repeat.php @@ -27,9 +27,7 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Repeat action @@ -40,45 +38,35 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://status.net/ */ -class RepeatAction extends Action +class RepeatAction extends FormAction { - var $user = null; - var $notice = null; + protected $needPost = true; // At least for now, until repeat interface is available + + protected $notice = null; // Notice that is being repeated. + protected $repeat = null; // The resulting repeat object/notice. - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->user = common_current_user(); - - if (empty($this->user)) { - // TRANS: Client error displayed when trying to repeat a notice while not logged in. - $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; + $this->clientError(_('Notice not found.')); } - $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; + $this->repeat = $this->notice->repeat($this->scoped, 'web'); + if (!$this->repeat instanceof Notice) { + // TRANS: Error when unable to repeat a notice for unknown reason. + $this->clientError(_('Could not repeat notice for unknown reason. Please contact the webmaster!')); } return true; @@ -91,25 +79,11 @@ class RepeatAction extends Action * * @return void */ - function handle($args) + protected function showContent() { - $repeat = $this->notice->repeat($this->user->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'); - } else { - // @todo FIXME! - } + $this->element('p', array('id' => 'repeat_response', + 'class' => 'repeated'), + // TRANS: Confirmation text after repeating a notice. + _('Repeated!')); } }