]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/AnonymousFave/anonfavor.php
Merge branch '1.0.x' into testing
[quix0rs-gnu-social.git] / plugins / AnonymousFave / anonfavor.php
index c972f202e47bfe91a0bca226de1c927fb1e038be..f20d55a8631ebb181f90586b3e312f73a6100553 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Anonyous favor action
  *
@@ -54,18 +53,11 @@ class AnonFavorAction extends RedirectingAction
     {
         parent::handle($args);
 
-        $anon = $_SESSION['anon_nickname'];
-        $profile = Profile::staticGet('nickname', $anon);
-
-        if (empty($profile)) {
-            common_debug(
-                "AnonFavorAction - Anon user tried to fave a notice but doesn't have a profile."
-            );
-        }
+        $profile = AnonymousFavePlugin::getAnonProfile();
 
         if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
-            $this->clientError(
-                _m('Could not favor notice! Please make sure your browser has cookies enabled.')
+            // TRANS: Client error.
+            $this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.')
             );
             return;
         }
@@ -75,18 +67,21 @@ class AnonFavorAction extends RedirectingAction
         $token  = $this->trimmed('token-' . $notice->id);
 
         if (empty($token) || $token != common_session_token()) {
+            // TRANS: Client error.
             $this->clientError(_m('There was a problem with your session token. Try again, please.'));
             return;
         }
 
 
         if ($profile->hasFave($notice)) {
+            // TRANS: Client error.
             $this->clientError(_m('This notice is already a favorite!'));
             return;
         }
         $fave = Fave::addNew($profile, $notice);
 
         if (!$fave) {
+            // TRANS: Server error.
             $this->serverError(_m('Could not create favorite.'));
             return;
         }
@@ -96,6 +91,7 @@ class AnonFavorAction extends RedirectingAction
         if ($this->boolean('ajax')) {
             $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
+            // TRANS: Title.
             $this->element('title', null, _m('Disfavor favorite'));
             $this->elementEnd('head');
             $this->elementStart('body');