From 792b62874e13214dc12480acd2cf4a40b3292d79 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 6 Jan 2016 00:18:10 +0100 Subject: [PATCH] Require Profile for Profile->getLists --- actions/apilists.php | 2 +- actions/peopletagautocomplete.php | 2 +- actions/peopletagsbyuser.php | 4 ++-- classes/Profile.php | 6 ++---- lib/listsnav.php | 4 +--- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/actions/apilists.php b/actions/apilists.php index 4134577e09..0b241638ad 100644 --- a/actions/apilists.php +++ b/actions/apilists.php @@ -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) diff --git a/actions/peopletagautocomplete.php b/actions/peopletagautocomplete.php index 86d63545dc..c239c03bfb 100644 --- a/actions/peopletagautocomplete.php +++ b/actions/peopletagautocomplete.php @@ -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()) { diff --git a/actions/peopletagsbyuser.php b/actions/peopletagsbyuser.php index 8b3a91917a..4a04ea2fbb 100644 --- a/actions/peopletagsbyuser.php +++ b/actions/peopletagsbyuser.php @@ -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; } diff --git a/classes/Profile.php b/classes/Profile.php index 69b78e27d5..467a2601d9 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -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(); diff --git a/lib/listsnav.php b/lib/listsnav.php index d550233ef5..71e994094c 100644 --- a/lib/listsnav.php +++ b/lib/listsnav.php @@ -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()