aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-08 20:48:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-08 20:48:34 +0000
commit033b7726df3db6a96f2ade8e782709a6602ac3bc (patch)
tree7cf68809593b0547a5a7badf788d1eaa2818cfc2
parentcf13bfcc6ca27f5a73de1542e17cdba3e512b615 (diff)
downloadelgg-033b7726df3db6a96f2ade8e782709a6602ac3bc.tar.gz
elgg-033b7726df3db6a96f2ade8e782709a6602ac3bc.tar.bz2
Fixes #2858: is_plugin_enabled() is deprecated by elgg_is_active_plugin() instead of ElggPlugin::isActive().
git-svn-id: http://code.elgg.org/elgg/trunk@8081 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/classes/ElggPlugin.php11
-rw-r--r--engine/lib/deprecated-1.8.php19
-rw-r--r--engine/lib/plugins.php27
3 files changed, 35 insertions, 22 deletions
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php
index ec28c8064..1e737f28e 100644
--- a/engine/classes/ElggPlugin.php
+++ b/engine/classes/ElggPlugin.php
@@ -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);
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index bf474abc2..67e150173 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -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);
}
/**
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index f8177a5f7..26ec2c726 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -243,6 +243,33 @@ function elgg_get_max_plugin_priority() {
}
/**
+ * 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.
*
* @note This is called on every page load and includes additional checking that plugins