Commit a3c1eb6a authored by Nigel McNie's avatar Nigel McNie
Browse files

Add a new function, plugin_types_installed(), which returns only those plugin...

Add a new function, plugin_types_installed(), which returns only those plugin types that are installed.

Use this function when handling events so we don't attempt to send events to plugins that aren't available.
parent 2f51a462
......@@ -827,7 +827,10 @@ function safe_require($plugintype, $pluginname, $filename='lib.php', $function='
}
/**
* This function returns the list of plugintypes we currently care about
* This function returns the list of plugintypes we currently care about.
*
* NOTE: use plugin_types_installed if you just want the installed ones.
*
* @return array of names
*/
function plugin_types() {
......@@ -839,6 +842,22 @@ function plugin_types() {
return $pluginstocheck;
}
/**
* Returns plugin types that are actually installed
*/
function plugin_types_installed() {
static $plugins = array();
if (empty($plugins)) {
require_once('ddl.php');
foreach (plugin_types() as $plugin) {
if (table_exists(new XMLDBTable("{$plugin}_installed"))) {
$plugins[] = $plugin;
}
}
}
return $plugins;
}
/**
* This return returns the names of plugins installed
* for the given plugin type.
......@@ -915,7 +934,7 @@ function handle_event($event, $data) {
activity_set_defaults($data['id']);
}
$plugintypes = plugin_types();
$plugintypes = plugin_types_installed();
foreach ($plugintypes as $name) {
if ($subs = get_records_array($name . '_event_subscription', 'event', $event)) {
foreach ($subs as $sub) {
......
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