/** * For now, loads plugins directly * * @todo Add proper plugin handler that launches plugins in an admin-defined order and activates them on admin request * @package Elgg * @subpackage Core */ function load_plugins() { global $CONFIG; if (!empty($CONFIG->pluginspath)) { // See if we have cached values for things $cached_view_paths = elgg_filepath_cache_load(); if ($cached_view_paths) { $CONFIG->views = unserialize($cached_view_paths); } // temporary disable all plugins if there is a file called 'disabled' in the plugin dir if (file_exists($CONFIG->pluginspath . "disabled")) { return; } $plugins = get_plugin_list(); if (sizeof($plugins)) { foreach ($plugins as $mod) { if (is_plugin_enabled($mod)) { if (file_exists($CONFIG->pluginspath . $mod)) { if (!(include $CONFIG->pluginspath . $mod . "/start.php")) { throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod)); } if (!$cached_view_paths) { if (is_dir($CONFIG->pluginspath . $mod . "/views")) { if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) { while ($viewtype = readdir($handle)) { if (!in_array($viewtype, array('.', '..', '.svn', 'CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) { autoregister_views("", $CONFIG->pluginspath . $mod . "/views/" . $viewtype, $CONFIG->pluginspath . $mod . "/views/", $viewtype); } } } } } if (is_dir($CONFIG->pluginspath . $mod . "/languages")) { register_translations($CONFIG->pluginspath . $mod . "/languages/"); } } } } } // Cache results if (!$cached_view_paths) { elgg_filepath_cache_save(serialize($CONFIG->views)); } } }
/** * Loads all active plugins in the order specified in the tool admin panel. * * @note This is called on every page load. If a plugin is active and problematic, it * will be disabled and a visible error emitted. This does not check the deps system because * that was too slow. * * @return bool */ function elgg_load_plugins() { global $CONFIG; $plugins_path = elgg_get_plugins_path(); $start_flags = ELGG_PLUGIN_INCLUDE_START | ELGG_PLUGIN_REGISTER_VIEWS | ELGG_PLUGIN_REGISTER_LANGUAGES | ELGG_PLUGIN_REGISTER_CLASSES; if (!$plugins_path) { return false; } // temporary disable all plugins if there is a file called 'disabled' in the plugin dir if (file_exists("{$plugins_path}/disabled")) { return false; } // Load view caches if available $cached_view_paths = elgg_filepath_cache_load('views'); $cached_view_types = elgg_filepath_cache_load('view_types'); $cached_view_info = is_string($cached_view_paths) && is_string($cached_view_types); if ($cached_view_info) { $CONFIG->views = unserialize($cached_view_paths); $CONFIG->view_types = unserialize($cached_view_types); // don't need to register views $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS; } $return = true; $plugins = elgg_get_plugins('active'); if ($plugins) { foreach ($plugins as $plugin) { try { $plugin->start($start_flags); } catch (Exception $e) { $plugin->deactivate(); $msg = elgg_echo('PluginException:CannotStart', array($plugin->getID(), $plugin->guid, $e->getMessage())); register_error($msg); $return = false; continue; } } } // Cache results if (!$cached_view_info) { elgg_filepath_cache_save('views', serialize($CONFIG->views)); elgg_filepath_cache_save('view_types', serialize($CONFIG->view_types)); } return $return; }