]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/AnonymousFave/anondisfavor.php
More info for a proper, fancy-url lighttpd setup
[quix0rs-gnu-social.git] / plugins / AnonymousFave / anondisfavor.php
index 9fd56fdc3240b3c2f2564924f9602b4b4ab5cace..e5ae09679dfc2d50f4598ac5a73fd1258fa068ad 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Anonymous disfavor action
  *
@@ -54,28 +53,22 @@ class AnonDisfavorAction extends RedirectingAction
     {
         parent::handle($args);
 
-        $anon = $_SESSION['anon_nickname'];
-
-        $profile = Profile::staticGet('nickname', $anon);
-
-        if (empty($profile)) {
-            common_debug(
-                "AnonDisFavorAction - Anon user tried to disfave a notice but doesn't have a profile."
-            );
-        }
+        $profile = AnonymousFavePlugin::getAnonProfile();
 
         if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
             $this->clientError(
+                // TRANS: Client error.
                 _m('Could not disfavor notice! Please make sure your browser has cookies enabled.')
             );
             return;
         }
 
         $id     = $this->trimmed('notice');
-        $notice = Notice::staticGet($id);
+        $notice = Notice::getKV($id);
         $token  = $this->trimmed('token-' . $notice->id);
 
         if (!$token || $token != common_session_token()) {
+            // TRANS: Client error.
             $this->clientError(_m('There was a problem with your session token. Try again, please.'));
             return;
         }
@@ -85,6 +78,7 @@ class AnonDisfavorAction extends RedirectingAction
         $fave->notice_id = $notice->id;
 
         if (!$fave->find(true)) {
+            // TRANS: Client error.
             $this->clientError(_m('This notice is not a favorite!'));
             return;
         }
@@ -93,6 +87,7 @@ class AnonDisfavorAction extends RedirectingAction
 
         if (!$result) {
             common_log_db_error($fave, 'DELETE', __FILE__);
+            // TRANS: Server error.
             $this->serverError(_m('Could not delete favorite.'));
             return;
         }
@@ -102,6 +97,7 @@ class AnonDisfavorAction extends RedirectingAction
         if ($this->boolean('ajax')) {
             $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
+            // TRANS: Title.
             $this->element('title', null, _m('Add to favorites'));
             $this->elementEnd('head');
             $this->elementStart('body');
@@ -129,4 +125,3 @@ class AnonDisfavorAction extends RedirectingAction
         }
     }
 }
-