From 2138c3b3392c7823b32c434e2a829aa73a182f23 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:07:10 -0400 Subject: [PATCH] a hook for showing the default local nav --- EVENTS.txt | 8 ++++++++ lib/defaultlocalnav.php | 33 +++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 1494a9c890..b328785e7b 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1139,3 +1139,11 @@ StartNoticeWhoGets: Called at start of inbox delivery prep; plugins can schedule EndNoticeWhoGets: Called at end of inbox delivery prep; plugins can filter out profiles from receiving inbox delivery here. Be aware that output can be cached or used several times, so should remain idempotent. - $notice Notice - &$ni: in/out array mapping profile IDs to constants: NOTICE_INBOX_SOURCE_SUB etc + +StartDefaultLocalNav: When showing the default local nav +- $menu: the menu +- $user: current user + +EndDefaultLocalNav: When showing the default local nav +- $menu: the menu +- $user: current user diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index a61ebbb585..1201ae7468 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -48,25 +48,30 @@ class DefaultLocalNav extends Menu { function show() { - $this->action->elementStart('ul', array('id' => 'nav_local_default')); - $user = common_current_user(); - if (!empty($user)) { - $pn = new PersonalGroupNav($this->action); - // TRANS: Menu item in default local navigation panel. - $this->submenu(_m('MENU','Home'), $pn); - } + $this->action->elementStart('ul', array('id' => 'nav_local_default')); - $bn = new PublicGroupNav($this->action); - // TRANS: Menu item in default local navigation panel. - $this->submenu(_m('MENU','Public'), $bn); + if (Event::handle('StartDefaultLocalNav', array($this, $user))) { - if (!empty($user)) { - $sn = new GroupsNav($this->action, $user); - if ($sn->haveGroups()) { - $this->submenu(_m('MENU', 'Groups'), $sn); + if (!empty($user)) { + $pn = new PersonalGroupNav($this->action); + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU','Home'), $pn); } + + $bn = new PublicGroupNav($this->action); + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU','Public'), $bn); + + if (!empty($user)) { + $sn = new GroupsNav($this->action, $user); + if ($sn->haveGroups()) { + $this->submenu(_m('MENU', 'Groups'), $sn); + } + } + + Event::handle('EndDefaultLocalNav', array($this, $user)); } $this->action->elementEnd('ul');