From ad726a15de8ca4f8db713e509337efe88e48c14c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Sep 2011 15:15:59 -0400 Subject: [PATCH] Use an event to signal that IM settings are available Rather than enumerating available classes, define an event that sets a flag indicating that there's an IM plugin available. Implemented in implugin.php, so all IM plugins that use that class should work. Others can hook the event, too. --- EVENTS.txt | 3 +++ lib/implugin.php | 5 +++++ lib/settingsnav.php | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/EVENTS.txt b/EVENTS.txt index 922b79a865..8358bed0b7 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1422,3 +1422,6 @@ StartUpgrade: when starting a site upgrade EndUpgrade: when ending a site upgrade; good place to do your own upgrades +HaveIMPlugin: is there an IM plugin loaded? +- &$haveIMPlugin: set me to true if you're loaded! + diff --git a/lib/implugin.php b/lib/implugin.php index 5badf53433..a037860391 100644 --- a/lib/implugin.php +++ b/lib/implugin.php @@ -620,6 +620,11 @@ abstract class ImPlugin extends Plugin return true; } + function onHaveImPlugin(&$haveImPlugin) { + $haveImPlugin = true; // set flag true (we're loaded, after all!) + return false; // stop looking + } + function initialize() { if( ! common_config('queue', 'enabled')) diff --git a/lib/settingsnav.php b/lib/settingsnav.php index 362691a0d4..67d5c35314 100644 --- a/lib/settingsnav.php +++ b/lib/settingsnav.php @@ -121,7 +121,11 @@ class SettingsNav extends Menu Event::handle('EndAccountSettingsNav', array(&$this->action)); - if (class_exists('XmppPlugin') || class_exists('IrcPlugin') || class_exists('MsnPlugin')) { + $haveImPlugin = false; + + Event::handle('HaveImPlugin', array(&$haveImPlugin)); + + if ($haveImPlugin) { $this->action->menuItem(common_local_url('imsettings'), // TRANS: Menu item in settings navigation panel. _m('MENU','IM'),