]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1457. Added optional status param for get_installed_plugins()
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 1 Dec 2010 22:35:19 +0000 (22:35 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 1 Dec 2010 22:35:19 +0000 (22:35 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7488 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/plugins.php

index 258a48fb57a2d01015fbb7b116d53fd978f6b363..7624b1768d7cde8521b548e25543b6615dc4e6a3 100644 (file)
@@ -276,7 +276,7 @@ function load_plugin_manifest($plugin) {
        $xml_file = get_config('pluginspath') . "$plugin/manifest.xml";
 
        try {
-               $manifest = new ElggPluginManifest($xml_file);
+               $manifest = new ElggPluginManifest($xml_file, $plugin);
        } catch(Exception $e) {
                return false;
        }
@@ -579,9 +579,10 @@ function clear_all_plugin_settings($plugin_name = "") {
 /**
  * Return an array of installed plugins.
  *
+ * @param string $status any|enabled|disabled
  * @return array
  */
-function get_installed_plugins() {
+function get_installed_plugins($status = 'any') {
        global $CONFIG;
 
        $installed_plugins = array();
@@ -594,8 +595,29 @@ function get_installed_plugins() {
                        if (!$manifest = load_plugin_manifest($mod)) {
                                continue;
                        }
+
+                       $enabled = is_plugin_enabled($mod);
+
+                       switch ($status) {
+                               case 'enabled':
+                                       if ($enabled != true) {
+                                               continue 2;
+                                       }
+                                       break;
+
+                               case 'disabled':
+                                       if ($enabled == true) {
+                                               continue 2;
+                                       }
+                                       break;
+
+                               case 'any':
+                               default:
+                                       break;
+                       }
+
                        $installed_plugins[$mod] = array();
-                       $installed_plugins[$mod]['active'] = is_plugin_enabled($mod);
+                       $installed_plugins[$mod]['active'] = $enabled;
                        $installed_plugins[$mod]['manifest'] = $manifest;
                }
        }