Commit f30bcd12 authored by Robert Lyon's avatar Robert Lyon

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>
parent e50d1613
......@@ -89,7 +89,7 @@ class PluginAuthWebservice extends PluginAuth {
public static function admin_menu_items() {
if (!is_plugin_active('webservice')) {
if (!is_plugin_active('webservice', 'auth')) {
return array();
}
......
......@@ -1597,14 +1597,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
*
* @param string $pluginname Name of plugin
* @param string $type Name of plugin type
* @return bool
*/
function is_plugin_active($pluginname) {
foreach (plugin_types() as $type) {
function is_plugin_active($pluginname, $type = null) {
if ($type) {
if (record_exists($type . '_installed', 'name', $pluginname, 'active', 1)) {
return true;
}
}
else {
log_warn("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;
}
......
......@@ -95,7 +95,7 @@ if (!$restrictedview) {
$javascript = array('paginator', 'lib/pieforms/static/core/pieforms.js');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
if (is_plugin_active('externalvideo')) {
if (is_plugin_active('externalvideo', 'blocktype')) {
$javascript = array_merge($javascript, array((is_https() ? 'https:' : 'http:') . '//cdn.embedly.com/widgets/platform.js'));
}
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......
......@@ -150,7 +150,7 @@ $javascript = array('views', 'tinymce', 'paginator', 'js/jquery/jquery-ui/js/jqu
'lib/pieforms/static/core/pieforms.js','js/jquery/modernizr.custom.js');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
if (is_plugin_active('externalvideo')) {
if (is_plugin_active('externalvideo', 'blocktype')) {
$javascript = array_merge($javascript, array((is_https() ? 'https:' : 'http:') . '//cdn.embedly.com/widgets/platform.js'));
}
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......
......@@ -208,7 +208,7 @@ function releaseview_submit() {
$javascript = array('paginator', 'viewmenu', 'js/collection-navigation.js');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
if (is_plugin_active('externalvideo')) {
if (is_plugin_active('externalvideo', 'blocktype')) {
$javascript = array_merge($javascript, array((is_https() ? 'https:' : 'http:') . '//cdn.embedly.com/widgets/platform.js'));
}
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......
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