]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apilistmember.php
Require Profile for Profile->getLists
[quix0rs-gnu-social.git] / actions / apilistmember.php
index 18d6ea370b73d7bdd90074331ee6da80cd06db72..92cbc9a3d291c27c2ad1acaeaa4db07ddf96e8c5 100644 (file)
@@ -30,8 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Action handler for Twitter list_memeber methods
  *
@@ -42,7 +40,6 @@ require_once INSTALLDIR . '/lib/apibareauth.php';
  * @link     http://status.net/
  * @see      ApiBareAuthAction
  */
-
 class ApiListMemberAction extends ApiBareAuthAction
 {
     /**
@@ -59,22 +56,21 @@ class ApiListMemberAction extends ApiBareAuthAction
      *
      * @return boolean success flag
      */
-
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
-        $this->user = $this->getTargetUser($this->arg('id'));
+        $this->target = $this->getTargetProfile($this->arg('id'));
         $this->list = $this->getTargetList($this->arg('user'), $this->arg('list_id'));
 
         if (empty($this->list)) {
-            $this->clientError(_('Not found'), 404, $this->format);
-            return false;
+            // TRANS: Client error displayed when referring to a non-existing list.
+            $this->clientError(_('List not found.'), 404);
         }
 
-        if (empty($this->user)) {
-            $this->clientError(_('No such user'), 404, $this->format);
-            return false;
+        if (!($this->target instanceof Profile)) {
+            // TRANS: Client error displayed when referring to a non-existing user.
+            $this->clientError(_('No such user.'), 404);
         }
         return true;
     }
@@ -84,25 +80,21 @@ class ApiListMemberAction extends ApiBareAuthAction
      *
      * @return boolean success flag
      */
-
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
+        parent::handle();
 
         $arr = array('tagger' => $this->list->tagger,
                       'tag' => $this->list->tag,
-                      'tagged' => $this->user->id);
+                      'tagged' => $this->target->id);
         $ptag = Profile_tag::pkeyGet($arr);
 
         if(empty($ptag)) {
-            $this->clientError(
-                _('The specified user is not a member of this list'),
-                400,
-                $this->format
-            );
+            // TRANS: Client error displayed when referring to a non-list member.
+            $this->clientError(_('The specified user is not a member of this list.'));
         }
 
-        $user = $this->twitterUserArray($this->user->getProfile(), true);
+        $user = $this->twitterUserArray($this->target, true);
 
         switch($this->format) {
         case 'xml':
@@ -112,12 +104,8 @@ class ApiListMemberAction extends ApiBareAuthAction
             $this->showSingleJsonUser($user);
             break;
         default:
-            $this->clientError(
-                _('API method not found.'),
-                404,
-                $this->format
-            );
-            break;
+            // TRANS: Client error displayed when coming across a non-supported API method.
+            $this->clientError(_('API method not found.'), 404);
         }
         return true;
     }