]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use an event to signal that IM settings are available
authorEvan Prodromou <evan@status.net>
Wed, 21 Sep 2011 19:15:59 +0000 (15:15 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 21 Sep 2011 19:15:59 +0000 (15:15 -0400)
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
lib/implugin.php
lib/settingsnav.php

index 922b79a865ea24d0bb85ce7347f2717a68525883..8358bed0b7dc75b505937eb7dc0afb344d02bb9f 100644 (file)
@@ -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!
+
index 5badf5343317d4572be8c2ac4fb57509fb945b65..a0378603916e01d36ff0bf486c63111dfe4a8b13 100644 (file)
@@ -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'))
index 362691a0d4b5ec71b153e1eee0215a24490e839f..67d5c35314a60e726e847288c3777f34a7f63293 100644 (file)
@@ -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'),