]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apilistmemberships.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / actions / apilistmemberships.php
index 635f970e871fb717e9d00b17942f7f968de21ff0..c1aa017deab1d1c35ada2db868df4210ff264092 100644 (file)
@@ -30,8 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Action handler for API method to list lists a user belongs to.
  * (people tags for a user)
@@ -43,7 +41,6 @@ require_once INSTALLDIR . '/lib/apibareauth.php';
  * @link     http://status.net/
  * @see      ApiBareAuthAction
  */
-
 class ApiListMembershipsAction extends ApiBareAuthAction
 {
     var $lists = array();
@@ -60,18 +57,18 @@ class ApiListMembershipsAction extends ApiBareAuthAction
      * @return boolean success flag
      *
      */
-
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
         $this->cursor = (int) $this->arg('cursor', -1);
-        $this->user = $this->getTargetUser($this->arg('user'));
+        $user = $this->getTargetUser($this->arg('user'));
 
-        if (empty($this->user)) {
-            $this->clientError(_('No such user.'), 404, $this->format);
-            return;
+        if (!($user instanceof User)) {
+            // TRANS: Client error displayed trying to perform an action related to a non-existing user.
+            $this->clientError(_('No such user.'), 404);
         }
+        $this->target = $user->getProfile();
 
         $this->getLists();
 
@@ -83,14 +80,11 @@ class ApiListMembershipsAction extends ApiBareAuthAction
      *
      * Show the lists
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
+        parent::handle();
 
         switch($this->format) {
         case 'xml':
@@ -100,12 +94,8 @@ class ApiListMembershipsAction extends ApiBareAuthAction
             $this->showJsonLists($this->lists, $this->next_cursor, $this->prev_cursor);
             break;
         default:
-            $this->clientError(
-                _('API method not found.'),
-                400,
-                $this->format
-            );
-            break;
+            // TRANS: Client error displayed when coming across a non-supported API method.
+            $this->clientError(_('API method not found.'));
         }
     }
 
@@ -118,15 +108,14 @@ class ApiListMembershipsAction extends ApiBareAuthAction
      *
      * @return boolean is read only action?
      */
-
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         return true;
     }
 
     function getLists()
     {
-        $profile = $this->user->getProfile();
+        $profile = $this->target;
         $fn = array($profile, 'getOtherTags');
 
         # 20 lists