]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2858: is_plugin_enabled() is deprecated by elgg_is_active_plugin() instead...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Feb 2011 20:48:34 +0000 (20:48 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Feb 2011 20:48:34 +0000 (20:48 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8081 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggPlugin.php
engine/lib/deprecated-1.8.php
engine/lib/plugins.php

index ec28c80646d0b95d7948bc79d58b3de16c871417..1e737f28e2980777805fff5e1b766566c98d3b24 100644 (file)
@@ -499,12 +499,13 @@ class ElggPlugin extends ElggObject {
 
                if ($site_guid) {
                        $site = get_entity($site_guid);
-
-                       if (!($site instanceof ElggSite)) {
-                               return false;
-                       }
                } else {
-                       $site = get_config('site');
+                       $site_guid = get_config('site');
+                       $site = get_entity($site_guid);
+               }
+
+               if (!($site instanceof ElggSite)) {
+                       return false;
                }
 
                return check_entity_relationship($this->guid, 'active_plugin', $site->guid);
index bf474abc2bc8430fc85cdc0c0779276eb09f390c..67e1501736eaae712c7ae61e2e72fcf4b749ee65 100644 (file)
@@ -1718,23 +1718,8 @@ function disable_plugin($plugin, $site_guid = 0) {
  * @return bool
  */
 function is_plugin_enabled($plugin, $site_guid = 0) {
-       elgg_deprecated_notice('is_plugin_enabled() was deprecated by ElggPlugin->isActive()', 1.8);
-
-       $plugin = sanitise_string($plugin);
-
-       $site_guid = (int) $site_guid;
-       if (!$site_guid) {
-               $site = get_config('site');
-               $site_guid = $site->guid;
-       }
-
-       try {
-               $plugin = new ElggPlugin($plugin);
-       } catch(Exception $e) {
-               return false;
-       }
-
-       return $plugin->isActive($site_guid);
+       elgg_deprecated_notice('is_plugin_enabled() was deprecated by elgg_is_active_plugin()', 1.8);
+       return elgg_is_active_plugin($plugin, $site_guid);
 }
 
 /**
index f8177a5f796ca6476d502e33e8ea5f266ff3e8ee..26ec2c72673971f72cf3a5d9e0d65acdf05a6db6 100644 (file)
@@ -242,6 +242,33 @@ function elgg_get_max_plugin_priority() {
        return 1;
 }
 
+/**
+ * Returns if a plugin is active for a current site.
+ *
+ * @param string $plugin_id The plugin ID
+ * @param int    $site_guid The site guid
+ * @return bool
+ */
+function elgg_is_active_plugin($plugin_id, $site_guid = null) {
+       if ($site_guid) {
+               $site = get_entity($site_guid);
+       } else {
+               $site = elgg_get_site_entity();
+       }
+
+       if (!($site instanceof ElggSite)) {
+               return false;
+       }
+
+       $plugin = elgg_get_plugin_from_id($plugin_id);
+
+       if (!$plugin) {
+               return false;
+       }
+
+       return $plugin->isActive($site->guid);
+}
+
 /**
  * Loads all active plugins in the order specified in the tool admin panel.
  *