]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/repeat.php
Some files got updated coding style
[quix0rs-gnu-social.git] / actions / repeat.php
index 869c2ddd4ee1851c073586789020768b64eb56a0..c926d85095e4df75080b6baea13c958a7ed3e53d 100644 (file)
@@ -45,53 +45,31 @@ class RepeatAction extends Action
     var $user = null;
     var $notice = null;
 
-    function prepare($args)
+    protected $needLogin = true;
+
+    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;
-        }
-
-        if ($this->user->id == $this->notice->profile_id) {
-            // TRANS: Client error displayed when trying to repeat an own notice.
-            $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)) {
-            // TRANS: Client error displayed when trying to repeat an already repeated notice.
-            $this->clientError(_('You already repeated that notice.'));
-            return false;
         }
 
         return true;
@@ -104,9 +82,11 @@ 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');
@@ -120,7 +100,7 @@ class RepeatAction extends Action
                                 // TRANS: Confirmation text after repeating a notice.
                                 _('Repeated!'));
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             // @todo FIXME!
         }