Require Profile for Profile->getLists
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 5 Jan 2016 23:18:10 +0000 (00:18 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 5 Jan 2016 23:18:10 +0000 (00:18 +0100)
actions/apilists.php
actions/peopletagautocomplete.php
actions/peopletagsbyuser.php
classes/Profile.php
lib/listsnav.php

index 4134577e099d27a2b4c9aa9368df8aba5f466e24..0b241638ad6c8fd61616efb2fdfd2ab8691c02f7 100644 (file)
@@ -185,7 +185,7 @@ class ApiListsAction extends ApiBareAuthAction
 
         list($this->lists,
              $this->next_cursor,
-             $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->auth_user), $cursor, $count);
+             $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->scoped), $cursor, $count);
     }
 
     function isReadOnly($args)
index 86d63545dcb0b4ed2aa4040e78aef8e8ebf9899e..c239c03bfb0d3d9c1c4321ba798b1911f7396b42 100644 (file)
@@ -68,7 +68,7 @@ class PeopletagautocompleteAction extends Action
         }
 
         $profile = $this->user->getProfile();
-        $tags = $profile->getLists(common_current_user());
+        $tags = $profile->getLists($this->scoped);
 
         $this->tags = array();
         while ($tags->fetch()) {
index 8b3a91917a5f0611b7fbebbc8b847edba393e67f..4a04ea2fbbf8c0d4e1f703e4d6d29cac96896087 100644 (file)
@@ -116,7 +116,7 @@ class PeopletagsbyuserAction extends Action
 
         $user = common_current_user();
         if ($this->arg('public')) {
-            $this->tags = $this->tagger->getLists(false, $offset, $limit);
+            $this->tags = $this->tagger->getLists(null, $offset, $limit);
         } else if ($this->arg('private')) {
             if (empty($user)) {
                 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
@@ -130,7 +130,7 @@ class PeopletagsbyuserAction extends Action
                 $this->clientError(_('You cannot view others\' private lists'), 403);
             }
         } else {
-            $this->tags = $this->tagger->getLists(common_current_user(), $offset, $limit);
+            $this->tags = $this->tagger->getLists($this->scoped, $offset, $limit);
         }
         return true;
     }
index 69b78e27d5f8827fa30e12a9b3b3486b7bb4e8e2..467a2601d9e87f703e391cf64e206e3a496296ee 100644 (file)
@@ -381,7 +381,7 @@ class Profile extends Managed_DataObject
         return false;
     }
 
-    function getLists($auth_user, $offset=0, $limit=null, $since_id=0, $max_id=0)
+    function getLists(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
     {
         $ids = array();
 
@@ -421,9 +421,7 @@ class Profile extends Managed_DataObject
             self::cacheSet($keypart, implode(',', $ids));
         }
 
-        $showPrivate = (($auth_user instanceof User ||
-                            $auth_user instanceof Profile) &&
-                        $auth_user->id === $this->id);
+        $showPrivate = $this->sameAs($scoped);
 
         $lists = array();
 
index d550233ef5810864ee482df053c4b4b68f2e1c22..71e994094cbadde9870c5a9953d4db857f1f35de 100644 (file)
@@ -49,9 +49,7 @@ class ListsNav extends MoreMenu
         parent::__construct($out);
         $this->profile = $profile;
 
-        $user = common_current_user();
-
-        $this->lists = $profile->getLists($user);
+        $this->lists = $profile->getLists(Profile::current());
     }
 
     function tag()