From 419c2cd5b3be9b83823a835258c17f69590788cb Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 12 Sep 2014 21:13:01 +0200 Subject: [PATCH] Some fixes/improvements - added getter getGroup() for https://bugz.foocorp.net/T44 - added type-hints in method signatures --------------------------------------------------------- WARNING: Some plugins attempt to get a property 'group' from (basicly) a Menu class which does NOT have such property. This badly needs fixing. --------------------------------------------------------- Signed-off-by: Roland Haeder --- lib/groupaction.php | 5 ++++ lib/menu.php | 6 ++--- lib/peopletaggroupnav.php | 2 +- lib/searchgroupnav.php | 2 +- lib/subgroupnav.php | 3 ++- .../GroupFavorited/GroupFavoritedPlugin.php | 6 ++--- .../GroupPrivateMessagePlugin.php | 24 +++++++++---------- 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/lib/groupaction.php b/lib/groupaction.php index a0141a83b9..5d11e6acdd 100644 --- a/lib/groupaction.php +++ b/lib/groupaction.php @@ -284,6 +284,11 @@ class GroupAction extends Action return $options; } + + function getGroup() + { + return $this->group; + } } class GroupAdminSection extends ProfileSection diff --git a/lib/menu.php b/lib/menu.php index 281ef7797b..27503aa06b 100644 --- a/lib/menu.php +++ b/lib/menu.php @@ -56,7 +56,7 @@ class Menu extends Widget * * @param Action $action current action, used for output */ - function __construct($action=null) + function __construct(Action $action=null) { parent::__construct($action); @@ -104,7 +104,7 @@ class Menu extends Widget } } - function item($actionName, $args, $label, $description, $id=null, $cls=null) + function item($actionName, array $args, $label, $description, $id=null, $cls=null) { if (empty($id)) { $id = $this->menuItemID($actionName, $args); @@ -120,7 +120,7 @@ class Menu extends Widget $cls); } - function isCurrent($actionName, $args) + function isCurrent($actionName, array $args) { if ($actionName != $this->actionName) { return false; diff --git a/lib/peopletaggroupnav.php b/lib/peopletaggroupnav.php index bbfe4eca7e..212a90586b 100644 --- a/lib/peopletaggroupnav.php +++ b/lib/peopletaggroupnav.php @@ -61,7 +61,7 @@ class PeopletagGroupNav extends Widget * * @param Action $action current action, used for output */ - function __construct($action=null) + function __construct(Action $action=null) { parent::__construct($action); $this->action = $action; diff --git a/lib/searchgroupnav.php b/lib/searchgroupnav.php index 40fe6a6375..8481380acf 100644 --- a/lib/searchgroupnav.php +++ b/lib/searchgroupnav.php @@ -51,7 +51,7 @@ class SearchGroupNav extends Menu * * @param Action $action current action, used for output */ - function __construct($action=null, $q = null) + function __construct(Action $action=null, $q = null) { parent::__construct($action); $this->q = $q; diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index 9fc5cd9e09..40447dd41a 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -50,8 +50,9 @@ class SubGroupNav extends Menu * Construction * * @param Action $action current action, used for output + * @param User $user Current user or NULL if "guest" */ - function __construct($action=null, $user=null) + function __construct(Action $action=null, User $user=null) { parent::__construct($action); $this->user = $user; diff --git a/plugins/GroupFavorited/GroupFavoritedPlugin.php b/plugins/GroupFavorited/GroupFavoritedPlugin.php index 944a725105..90a1fe5ca0 100644 --- a/plugins/GroupFavorited/GroupFavoritedPlugin.php +++ b/plugins/GroupFavorited/GroupFavoritedPlugin.php @@ -32,7 +32,7 @@ class GroupFavoritedPlugin extends Plugin * @param Net_URL_Mapper $m path-to-action mapper * @return boolean hook return */ - function onRouterInitialized($m) + function onRouterInitialized(Net_URL_Mapper $m) { $m->connect('group/:nickname/favorited', array('action' => 'groupfavorited'), @@ -41,7 +41,7 @@ class GroupFavoritedPlugin extends Plugin return true; } - function onEndGroupGroupNav(GroupNav $nav) + function onEndGroupGroupNav(Menu $nav) { $action_name = $nav->action->trimmed('action'); $nickname = $nav->group->nickname; @@ -65,7 +65,7 @@ class GroupFavoritedPlugin extends Plugin * * @return boolean hook value */ - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $url = 'http://status.net/wiki/Plugin:GroupFavorited'; diff --git a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php index 28a1ab989e..0788161dd3 100644 --- a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php +++ b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php @@ -101,7 +101,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @see Action */ - function onEndGroupGroupNav($groupnav) + function onEndGroupGroupNav(Menu $groupnav) { $action = $groupnav->action; $group = $groupnav->group; @@ -146,7 +146,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @param GroupEditForm $form form being shown */ - function onEndGroupEditFormData($form) + function onEndGroupEditFormData(GroupEditForm $form) { $gps = null; @@ -187,19 +187,19 @@ class GroupPrivateMessagePlugin extends Plugin return true; } - function onEndGroupSaveForm($action) + function onEndGroupSaveForm(GroupAction $action) { $gps = null; - if (!empty($action->group)) { - $gps = Group_privacy_settings::getKV('group_id', $action->group->id); + if (!empty($action->getGroup())) { + $gps = Group_privacy_settings::getKV('group_id', $action->getGroup()->id); } $orig = null; if (empty($gps)) { $gps = new Group_privacy_settings(); - $gps->group_id = $action->group->id; + $gps->group_id = $action->getGroup()->id; } else { $orig = clone($gps); } @@ -230,7 +230,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @return boolean hook value */ - function onStartInterpretCommand($cmd, $arg, $user, &$result) + function onStartInterpretCommand($cmd, $arg, User $user, &$result) { if ($cmd == 'd' || $cmd == 'dm') { @@ -264,7 +264,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @return boolean hook value */ - function onEndGroupActionsList($widget, $group) + function onEndGroupActionsList(Widget $widget, User_group $group) { $cur = common_current_user(); $action = $widget->out; @@ -299,7 +299,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @param */ - function onStartNoticeSave(&$notice) { + function onStartNoticeSave(Notice &$notice) { // Look for group tags // FIXME: won't work for remote groups // @fixme if Notice::saveNew is refactored so we can just pull its list @@ -378,7 +378,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @return boolean hook value */ - function onEndGroupProfileElements($action, $group) + function onEndGroupProfileElements(Action $action, User_group $group) { $gps = Group_privacy_settings::forGroup($group); @@ -390,10 +390,10 @@ class GroupPrivateMessagePlugin extends Plugin return true; } - function onStartShowExportData($action) + function onStartShowExportData(GroupAction $action) { if ($action instanceof ShowgroupAction) { - $gps = Group_privacy_settings::forGroup($action->group); + $gps = Group_privacy_settings::forGroup($action->getGroup()); if ($gps->allow_privacy == Group_privacy_settings::ALWAYS) { return false;