From 3900a739b92cf8560ad318fe1106afb9bf8f4fe8 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Fri, 10 Jul 2015 22:54:14 +0200 Subject: [PATCH] Forgotten migrations of ->profile and ->user to ->getTarget() GalleryAction extends ProfileAction which no longer uses ->profile and ->user --- actions/subscriptions.php | 6 ++---- actions/usergroups.php | 16 +++++++-------- plugins/SearchSub/actions/searchsubs.php | 26 ++++++++++-------------- plugins/TagSub/actions/tagsubs.php | 26 ++++++++++-------------- 4 files changed, 32 insertions(+), 42 deletions(-) diff --git a/actions/subscriptions.php b/actions/subscriptions.php index 231a697230..b5734b3747 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -28,9 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * A list of the user's subscriptions @@ -60,7 +58,7 @@ class SubscriptionsAction extends GalleryAction function showPageNotice() { - if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) { + if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) { $this->element('p', null, // TRANS: Page notice for page with an overview of all subscriptions // TRANS: of the logged in user's own profile. diff --git a/actions/usergroups.php b/actions/usergroups.php index fd112ba8ec..d4756dffb5 100644 --- a/actions/usergroups.php +++ b/actions/usergroups.php @@ -52,12 +52,12 @@ class UsergroupsAction extends GalleryAction if ($this->page == 1) { // TRANS: Page title for first page of groups for a user. // TRANS: %s is a nickname. - return sprintf(_('%s groups'), $this->user->nickname); + return sprintf(_('%s groups'), $this->getTarget()->getNickname()); } else { // TRANS: Page title for all but the first page of groups for a user. // TRANS: %1$s is a nickname, %2$d is a page number. return sprintf(_('%1$s groups, page %2$d'), - $this->user->nickname, + $this->getTarget()->getNickname(), $this->page); } } @@ -82,14 +82,14 @@ class UsergroupsAction extends GalleryAction $offset = ($this->page-1) * GROUPS_PER_PAGE; $limit = GROUPS_PER_PAGE + 1; - $groups = $this->user->getGroups($offset, $limit); + $groups = $this->getTarget()->getGroups($offset, $limit); if ($groups instanceof User_group) { - $gl = new GroupList($groups, $this->user, $this); + $gl = new GroupList($groups, $this->getTarget(), $this); $cnt = $gl->show(); $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, $this->page, 'usergroups', - array('nickname' => $this->user->nickname)); + array('nickname' => $this->getTarget()->getNickname())); } else { $this->showEmptyListMessage(); } @@ -102,11 +102,11 @@ class UsergroupsAction extends GalleryAction { // TRANS: Text on group page for a user that is not a member of any group. // TRANS: %s is a user nickname. - $message = sprintf(_('%s is not a member of any group.'), $this->user->nickname) . ' '; + $message = sprintf(_('%s is not a member of any group.'), $this->getTarget()->getNickname()) . ' '; if (common_logged_in()) { $current_user = common_current_user(); - if ($this->user->id === $current_user->id) { + if ($this->scoped->sameAs($this->getTarget())) { // TRANS: Text on group page for a user that is not a member of any group. This message contains // TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed. $message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.'); @@ -119,7 +119,7 @@ class UsergroupsAction extends GalleryAction function showProfileBlock() { - $block = new AccountProfileBlock($this, $this->profile); + $block = new AccountProfileBlock($this, $this->getTarget()); $block->show(); } } diff --git a/plugins/SearchSub/actions/searchsubs.php b/plugins/SearchSub/actions/searchsubs.php index 54563ed0e7..fd89075032 100644 --- a/plugins/SearchSub/actions/searchsubs.php +++ b/plugins/SearchSub/actions/searchsubs.php @@ -28,9 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * A list of the user's subscriptions @@ -48,20 +46,19 @@ class SearchSubsAction extends GalleryAction if ($this->page == 1) { // TRANS: Header for subscriptions overview for a user (first page). // TRANS: %s is a user nickname. - return sprintf(_m('%s\'s search subscriptions'), $this->user->nickname); + return sprintf(_m('%s\'s search subscriptions'), $this->getTarget()->getNickname()); } else { // TRANS: Header for subscriptions overview for a user (not first page). // TRANS: %1$s is a user nickname, %2$d is the page number. return sprintf(_m('%1$s\'s search subscriptions, page %2$d'), - $this->user->nickname, + $this->getTarget()->getNickname(), $this->page); } } function showPageNotice() { - $user = common_current_user(); - if ($user && ($user->id == $this->profile->id)) { + if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) { $this->element('p', null, // TRANS: Page notice for page with an overview of all search subscriptions // TRANS: of the logged in user's own profile. @@ -71,7 +68,7 @@ class SearchSubsAction extends GalleryAction // TRANS: Page notice for page with an overview of all subscriptions of a user other // TRANS: than the logged in user. %s is the user nickname. sprintf(_m('%s has subscribed to receive all notices on this site matching the following searches:'), - $this->profile->nickname)); + $this->getTarget()->getNickname())); } } @@ -86,12 +83,12 @@ class SearchSubsAction extends GalleryAction $cnt = 0; $searchsub = new SearchSub(); - $searchsub->profile_id = $this->user->id; + $searchsub->profile_id = $this->getTarget()->getID(); $searchsub->limit($limit, $offset); $searchsub->find(); if ($searchsub->N) { - $list = new SearchSubscriptionsList($searchsub, $this->user, $this); + $list = new SearchSubscriptionsList($searchsub, $this->getTarget(), $this); $cnt = $list->show(); if (0 == $cnt) { $this->showEmptyListMessage(); @@ -102,7 +99,7 @@ class SearchSubsAction extends GalleryAction $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'searchsubs', - array('nickname' => $this->user->nickname)); + array('nickname' => $this->getTarget()->getNickname())); Event::handle('EndShowTagSubscriptionsContent', array($this)); @@ -112,8 +109,7 @@ class SearchSubsAction extends GalleryAction function showEmptyListMessage() { if (common_logged_in()) { - $current_user = common_current_user(); - if ($this->user->id === $current_user->id) { + if ($this->scoped->sameAs($this->getTarget())) { // TRANS: Search subscription list text when the logged in user has no search subscriptions. $message = _m('You are not subscribed to any text searches right now. You can push the "Subscribe" button ' . 'on any notice text search to automatically receive any public messages on this site that match that ' . @@ -121,13 +117,13 @@ class SearchSubsAction extends GalleryAction } else { // TRANS: Search subscription list text when looking at the subscriptions for a of a user other // TRANS: than the logged in user that has no search subscriptions. %s is the user nickname. - $message = sprintf(_m('%s is not subscribed to any searches.'), $this->user->nickname); + $message = sprintf(_m('%s is not subscribed to any searches.'), $this->getTarget()->getNickname()); } } else { // TRANS: Subscription list text when looking at the subscriptions for a of a user that has none // TRANS: as an anonymous user. %s is the user nickname. - $message = sprintf(_m('%s is not subscribed to any searches.'), $this->user->nickname); + $message = sprintf(_m('%s is not subscribed to any searches.'), $this->getTarget()->getNickname()); } $this->elementStart('div', 'guide'); diff --git a/plugins/TagSub/actions/tagsubs.php b/plugins/TagSub/actions/tagsubs.php index be195250f6..1e927b4fd1 100644 --- a/plugins/TagSub/actions/tagsubs.php +++ b/plugins/TagSub/actions/tagsubs.php @@ -28,9 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * A list of the user's subscriptions @@ -48,20 +46,19 @@ class TagSubsAction extends GalleryAction if ($this->page == 1) { // TRANS: Header for subscriptions overview for a user (first page). // TRANS: %s is a user nickname. - return sprintf(_m('%s\'s tag subscriptions'), $this->user->nickname); + return sprintf(_m('%s\'s tag subscriptions'), $this->getTarget()->getNickname()); } else { // TRANS: Header for subscriptions overview for a user (not first page). // TRANS: %1$s is a user nickname, %2$d is the page number. return sprintf(_m('%1$s\'s tag subscriptions, page %2$d'), - $this->user->nickname, + $this->getTarget()->getNickname(), $this->page); } } function showPageNotice() { - $user = common_current_user(); - if ($user && ($user->id == $this->profile->id)) { + if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) { $this->element('p', null, // TRANS: Page notice for page with an overview of all tag subscriptions // TRANS: of the logged in user's own profile. @@ -71,7 +68,7 @@ class TagSubsAction extends GalleryAction // TRANS: Page notice for page with an overview of all subscriptions of a user other // TRANS: than the logged in user. %s is the user nickname. sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'), - $this->profile->nickname)); + $this->getTarget()->getNickname())); } } @@ -86,12 +83,12 @@ class TagSubsAction extends GalleryAction $cnt = 0; $tagsub = new TagSub(); - $tagsub->profile_id = $this->user->id; + $tagsub->profile_id = $this->getTarget()->getID(); $tagsub->limit($limit, $offset); $tagsub->find(); if ($tagsub->N) { - $list = new TagSubscriptionsList($tagsub, $this->user, $this); + $list = new TagSubscriptionsList($tagsub, $this->getTarget(), $this); $cnt = $list->show(); if (0 == $cnt) { $this->showEmptyListMessage(); @@ -102,7 +99,7 @@ class TagSubsAction extends GalleryAction $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'tagsubs', - array('nickname' => $this->user->nickname)); + array('nickname' => $this->getTarget()->getNickname())); Event::handle('EndShowTagSubscriptionsContent', array($this)); @@ -112,8 +109,7 @@ class TagSubsAction extends GalleryAction function showEmptyListMessage() { if (common_logged_in()) { - $current_user = common_current_user(); - if ($this->user->id === $current_user->id) { + if ($this->scoped->sameAs($this->getTarget())) { // TRANS: Tag subscription list text when the logged in user has no tag subscriptions. $message = _m('You are not listening to any hash tags right now. You can push the "Subscribe" button ' . 'on any hashtag page to automatically receive any public messages on this site that use that ' . @@ -121,13 +117,13 @@ class TagSubsAction extends GalleryAction } else { // TRANS: Tag subscription list text when looking at the subscriptions for a of a user other // TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname. - $message = sprintf(_m('%s is not following any tags.'), $this->user->nickname); + $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname()); } } else { // TRANS: Subscription list text when looking at the subscriptions for a of a user that has none // TRANS: as an anonymous user. %s is the user nickname. - $message = sprintf(_m('%s is not following any tags.'), $this->user->nickname); + $message = sprintf(_m('%s is not following any tags.'), $this->getTarget()->getNickname()); } $this->elementStart('div', 'guide'); -- 2.39.5