]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apilistmembers.php
Merge branch 'fixes/private_scope_on_tags' into social-master
[quix0rs-gnu-social.git] / actions / apilistmembers.php
index c6e92fa61279805ea4af5419aaab237a8843a981..bd78451d5ee76c180d2995ddb996b936647b9ae0 100644 (file)
@@ -39,37 +39,24 @@ class ApiListMembersAction extends ApiListUsersAction
      *
      * @return boolean success
      */
-
     function handlePost()
     {
         if($this->auth_user->id != $this->list->tagger) {
-            $this->clientError(
-                _('You aren\'t allowed to add members to this list'),
-                401,
-                $this->format
-            );
-            return false;
+            // TRANS: Client error displayed when trying to add members to a list without having the right to do so.
+            $this->clientError(_('You are not allowed to add members to this list.'), 401);
         }
 
-        if($this->user === false) {
-            $this->clientError(
-                _('You must specify a member'),
-                400,
-                $this->format
-            );
-            return false;
+        if (!($this->target instanceof Profile)) {
+            // TRANS: Client error displayed when trying to modify list members without specifying them.
+            $this->clientError(_('You must specify a member.'));
         }
 
         $result = Profile_tag::setTag($this->auth_user->id,
-                        $this->user->id, $this->list->tag);
+                        $this->target->id, $this->list->tag);
 
         if(empty($result)) {
-            $this->clientError(
-                _('An error occured.'),
-                500,
-                $this->format
-            );
-            return false;
+            // TRANS: Client error displayed when an unknown error occurs viewing list members.
+            $this->clientError(_('An error occured.'), 500);
         }
 
         switch($this->format) {
@@ -80,13 +67,8 @@ class ApiListMembersAction extends ApiListUsersAction
             $this->showSingleJsonList($this->list);
             break;
         default:
-            $this->clientError(
-                _('API method not found.'),
-                404,
-                $this->format
-            );
-            return false;
-            break;
+            // TRANS: Client error displayed when coming across a non-supported API method.
+            $this->clientError(_('API method not found.'), 404);
         }
     }
 
@@ -95,50 +77,31 @@ class ApiListMembersAction extends ApiListUsersAction
      *
      * @return boolean success
      */
-
     function handleDelete()
     {
         if($this->auth_user->id != $this->list->tagger) {
-            $this->clientError(
-                _('You aren\'t allowed to remove members from this list'),
-                401,
-                $this->format
-            );
-            return false;
+            // TRANS: Client error displayed when trying to remove members from a list without having the right to do so.
+            $this->clientError(_('You are not allowed to remove members from this list.'), 401);
         }
 
-        if($this->user === false) {
-            $this->clientError(
-                _('You must specify a member'),
-                400,
-                $this->format
-            );
-            return false;
+        if (!($this->target instanceof Profile)) {
+            // TRANS: Client error displayed when trying to modify list members without specifying them.
+            $this->clientError(_('You must specify a member.'));
         }
 
         $args = array('tagger' => $this->auth_user->id,
-                      'tagged' => $this->user->id,
+                      'tagged' => $this->target->id,
                       'tag' => $this->list->tag);
         $ptag = Profile_tag::pkeyGet($args);
 
-        if(empty($ptag)) {
-            $this->clientError(
-                _('The user you are trying to remove from the list is not a member'),
-                400,
-                $this->format
-            );
-            return false;
+        if (empty($ptag)) {
+            // TRANS: Client error displayed when trying to remove a list member that is not part of a list.
+            $this->clientError(_('The user you are trying to remove from the list is not a member.'));
         }
 
-        $result = $ptag->delete();
-
-        if(empty($result)) {
-            $this->clientError(
-                _('An error occured.'),
-                500,
-                $this->format
-            );
-            return false;
+        if (!$ptag->delete()) {
+            // TRANS: Client error displayed when an unknown error occurs viewing list members.
+            $this->clientError(_('An error occured.'), 500);
         }
 
         switch($this->format) {
@@ -149,21 +112,16 @@ class ApiListMembersAction extends ApiListUsersAction
             $this->showSingleJsonList($this->list);
             break;
         default:
-            $this->clientError(
-                _('API method not found.'),
-                404,
-                $this->format
-            );
-            return false;
-            break;
+            // TRANS: Client error displayed when coming across a non-supported API method.
+            $this->clientError(_('API method not found.'), 404);
         }
+
         return true;
     }
 
     /**
      * List the members of a list (people tagged)
      */
-
     function getUsers()
     {
         $fn = array($this->list, 'getTagged');