Skip to content
Permalink
Browse files

MDL-33041 (1) Add subplugin support for 'editor' plugins

  • Loading branch information...
sammarshallou authored and skodak committed May 17, 2012
1 parent 87e9331 commit c57fc98b278bb5d1c845581812007c852571a4d6
Showing with 28 additions and 21 deletions.
  1. +5 −4 lib/adminlib.php
  2. +9 −5 lib/moodlelib.php
  3. +14 −12 lib/pluginlib.php
@@ -123,11 +123,12 @@
function uninstall_plugin($type, $name) {
global $CFG, $DB, $OUTPUT;
// recursively uninstall all module subplugins first
if ($type === 'mod') {
if (file_exists("$CFG->dirroot/mod/$name/db/subplugins.php")) {
// recursively uninstall all module/editor subplugins first
if ($type === 'mod' || $type === 'editor') {
$base = get_component_directory($type . '_' . $name);
if (file_exists("$base/db/subplugins.php")) {
$subplugins = array();
include("$CFG->dirroot/mod/$name/db/subplugins.php");
include("$base/db/subplugins.php");
foreach ($subplugins as $subplugintype=>$dir) {
$instances = get_plugin_list($subplugintype);
foreach ($instances as $subpluginname => $notusedpluginpath) {
@@ -7890,11 +7890,12 @@ function get_plugin_types($fullpaths=true) {
'theme' => 'theme', // this is a bit hacky, themes may be in $CFG->themedir too
);
$mods = get_plugin_list('mod');
foreach ($mods as $mod => $moddir) {
if (file_exists("$moddir/db/subplugins.php")) {
$subpluginowners = array_merge(array_values(get_plugin_list('mod')),
array_values(get_plugin_list('editor')));
foreach ($subpluginowners as $ownerdir) {
if (file_exists("$ownerdir/db/subplugins.php")) {
$subplugins = array();
include("$moddir/db/subplugins.php");
include("$ownerdir/db/subplugins.php");
foreach ($subplugins as $subtype=>$dir) {
$info[$subtype] = $dir;
}
@@ -7940,6 +7941,10 @@ function get_plugin_list($plugintype) {
// mod is an exception because we have to call this function from get_plugin_types()
$fulldirs[] = $CFG->dirroot.'/mod';
} else if ($plugintype === 'editor') {
// Exception also needed for editor for same reason.
$fulldirs[] = $CFG->dirroot . '/lib/editor';
} else if ($plugintype === 'theme') {
$fulldirs[] = $CFG->dirroot.'/theme';
// themes are special because they may be stored also in separate directory
@@ -7958,7 +7963,6 @@ function get_plugin_list($plugintype) {
}
$fulldirs[] = $fulldir;
}
$result = array();
foreach ($fulldirs as $fulldir) {
@@ -137,7 +137,7 @@ public function get_plugins($disablecache=false) {
* Returns list of plugins that define their subplugins and the information
* about them from the db/subplugins.php file.
*
* At the moment, only activity modules can define subplugins.
* At the moment, only activity modules and editors can define subplugins.
*
* @param bool $disablecache force reload, cache can be used otherwise
* @return array with keys like 'mod_quiz', and values the data from the
@@ -147,18 +147,20 @@ public function get_subplugins($disablecache=false) {
if ($disablecache or is_null($this->subpluginsinfo)) {
$this->subpluginsinfo = array();
$mods = get_plugin_list('mod');
foreach ($mods as $mod => $moddir) {
$modsubplugins = array();
if (file_exists($moddir . '/db/subplugins.php')) {
include($moddir . '/db/subplugins.php');
foreach ($subplugins as $subplugintype => $subplugintyperootdir) {
$subplugin = new stdClass();
$subplugin->type = $subplugintype;
$subplugin->typerootdir = $subplugintyperootdir;
$modsubplugins[$subplugintype] = $subplugin;
foreach (array('mod', 'editor') as $type) {
$owners = get_plugin_list('type');
foreach ($owners as $component => $ownerdir) {
$componentsubplugins = array();
if (file_exists($ownerdir . '/db/subplugins.php')) {
include($ownerdir . '/db/subplugins.php');
foreach ($subplugins as $subplugintype => $subplugintyperootdir) {
$subplugin = new stdClass();
$subplugin->type = $subplugintype;
$subplugin->typerootdir = $subplugintyperootdir;
$componentsubplugins[$subplugintype] = $subplugin;
}
$this->subpluginsinfo[$type . '_' . $component] = $componentsubplugins;
}
$this->subpluginsinfo['mod_' . $mod] = $modsubplugins;
}
}
}

0 comments on commit c57fc98

Please sign in to comment.
You can’t perform that action at this time.