Commit 80f10a5c authored by Robert Lyon's avatar Robert Lyon Committed by Aaron Wells

Bug 1609112: Pass the plugin type to is_plugin_active()

So that we can differentiate between plugin types that have the same
plugin name, eg comment artefact vs comment blocktype

behatnotneeded

Change-Id: I0f7ffe6da3f7a4ff88cf625a1010c6d2012932d0
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit f30bcd12)
parent b781374e
...@@ -89,7 +89,7 @@ class PluginAuthWebservice extends PluginAuth { ...@@ -89,7 +89,7 @@ class PluginAuthWebservice extends PluginAuth {
public static function admin_menu_items() { public static function admin_menu_items() {
if (!is_plugin_active('webservice')) { if (!is_plugin_active('webservice', 'auth')) {
return array(); return array();
} }
return array( return array(
......
...@@ -1509,14 +1509,23 @@ function safe_require_plugin($plugintype, $pluginname, $filename='lib.php', $fun ...@@ -1509,14 +1509,23 @@ function safe_require_plugin($plugintype, $pluginname, $filename='lib.php', $fun
* Check to see if a particular plugin is installed and is active by plugin name * Check to see if a particular plugin is installed and is active by plugin name
* *
* @param string $pluginname Name of plugin * @param string $pluginname Name of plugin
* @param string $type Name of plugin type
* @return bool * @return bool
*/ */
function is_plugin_active($pluginname) { function is_plugin_active($pluginname, $type = null) {
foreach (plugin_types() as $type) { if ($type) {
if (record_exists($type . '_installed', 'name', $pluginname, 'active', 1)) { if (record_exists($type . '_installed', 'name', $pluginname, 'active', 1)) {
return true; return true;
} }
} }
else {
log_debug("Calling 'is_plugin_active()' without specifying plugin 'type'. This function may return incorrect results. Please update your 'is_plugin_active()' calls.");
foreach (plugin_types() as $type) {
if (record_exists($type . '_installed', 'name', $pluginname, 'active', 1)) {
return true;
}
}
}
return false; return false;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment