]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apilistsubscriptions.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / actions / apilistsubscriptions.php
index 480523033bbf9d119cb58bc2b0c1da8d4199c90d..5fe4c378ae40d4c0cc655cc2841fa0bfebd77664 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 class ApiListSubscriptionsAction extends ApiBareAuthAction
 {
     var $lists = array();
@@ -48,12 +46,17 @@ class ApiListSubscriptionsAction 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 (!($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();
 
         return true;
@@ -64,19 +67,11 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction
      *
      * Show the lists
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
-
-        if (empty($this->user)) {
-            // TRANS: Client error displayed trying to perform an action related to a non-existing user.
-            $this->clientError(_('No such user.'), 404, $this->format);
-            return;
-        }
+        parent::handle();
 
         switch($this->format) {
         case 'xml':
@@ -86,13 +81,8 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction
             $this->showJsonLists($this->lists, $this->next_cursor, $this->prev_cursor);
             break;
         default:
-            $this->clientError(
-                // TRANS: Client error displayed when coming across a non-supported API method.
-                _('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.'));
         }
     }
 
@@ -105,19 +95,14 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction
      *
      * @return boolean is read only action?
      */
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         return true;
     }
 
     function getLists()
     {
-        if(empty($this->user)) {
-            return;
-        }
-
-        $profile = $this->user->getProfile();
-        $fn = array($profile, 'getTagSubscriptions');
+        $fn = array($this->target, 'getTagSubscriptions');
         # 20 lists
         list($this->lists, $this->next_cursor, $this->prev_cursor) =
                 Profile_list::getAtCursor($fn, array(), $this->cursor, 20);