MDL-16438 centralise information about plugins to avoid duplication, includes local customisation conversion to standard plugin structure + fixes for some recent regressions; see tracker for more details and links to docs and forums discussions
This commit is contained in:
@@ -19,9 +19,6 @@ $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$authsavailable = get_list_of_plugins('auth');
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
$authsenabled = array();
|
||||
|
||||
+22
-19
@@ -183,9 +183,9 @@
|
||||
// report includes cron.php with function report_reportname_cron() if it wishes
|
||||
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
|
||||
// actually do anything occasionally.
|
||||
$reports = get_list_of_plugins($CFG->admin.'/report');
|
||||
foreach($reports as $report) {
|
||||
$cronfile = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$report.'/cron.php';
|
||||
$reports = get_plugin_list('report');
|
||||
foreach($reports as $report => $reportdir) {
|
||||
$cronfile = $reportdir.'/cron.php';
|
||||
if (file_exists($cronfile)) {
|
||||
require_once($cronfile);
|
||||
$cronfunction = 'report_'.$report.'_cron';
|
||||
@@ -506,10 +506,10 @@
|
||||
}
|
||||
|
||||
// run gradebook import/export/report cron
|
||||
if ($gradeimports = get_list_of_plugins('grade/import')) {
|
||||
foreach ($gradeimports as $gradeimport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php');
|
||||
if ($gradeimports = get_plugin_list('gradeimport')) {
|
||||
foreach ($gradeimports as $gradeimport => $plugindir) {
|
||||
if (file_exists($plugindir.'/lib.php')) {
|
||||
require_once($plugindir.'/lib.php');
|
||||
$cron_function = 'grade_import_'.$gradeimport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook import function $cron_function ...", '');
|
||||
@@ -519,10 +519,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradeexports = get_list_of_plugins('grade/export')) {
|
||||
foreach ($gradeexports as $gradeexport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php');
|
||||
if ($gradeexports = get_plugin_list('gradeexport')) {
|
||||
foreach ($gradeexports as $gradeexport => $plugindir) {
|
||||
if (file_exists($plugindir.'/lib.php')) {
|
||||
require_once($plugindir.'/lib.php');
|
||||
$cron_function = 'grade_export_'.$gradeexport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook export function $cron_function ...", '');
|
||||
@@ -532,10 +532,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradereports = get_list_of_plugins('grade/report')) {
|
||||
foreach ($gradereports as $gradereport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php');
|
||||
if ($gradereports = get_plugin_list('gradereport')) {
|
||||
foreach ($gradereports as $gradereport => $plugindir) {
|
||||
if (file_exists($plugindir.'/lib.php')) {
|
||||
require_once($plugindir.'/lib.php');
|
||||
$cron_function = 'grade_report_'.$gradereport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook report function $cron_function ...", '');
|
||||
@@ -550,10 +550,13 @@
|
||||
$fs->cron();
|
||||
|
||||
// run any customized cronjobs, if any
|
||||
// looking for functions in lib/local/cron.php
|
||||
if (file_exists($CFG->dirroot.'/local/cron.php')) {
|
||||
mtrace('Processing customized cron script ...', '');
|
||||
include_once($CFG->dirroot.'/local/cron.php');
|
||||
if ($locals = get_plugin_list('local')) {
|
||||
mtrace('Processing customized cron scripts ...', '');
|
||||
foreach ($locals as $local => $localdir) {
|
||||
if (file_exists("$localdir/cron.php")) {
|
||||
include("$localdir/cron.php");
|
||||
}
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -51,9 +51,9 @@
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$modules = get_plugin_list('enrol');
|
||||
$options = array();
|
||||
foreach ($modules as $module) {
|
||||
foreach ($modules as $module => $moduledir) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
@@ -71,12 +71,11 @@
|
||||
$table->width = '700';
|
||||
$table->data = array();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
|
||||
foreach ($modules as $module) {
|
||||
foreach ($modules as $module => $moduledir) {
|
||||
|
||||
// skip if directory is empty
|
||||
if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
|
||||
if (!file_exists("$moduledir/enrol.php")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
unset($options);
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
$modules = get_plugin_list('enrol');
|
||||
foreach ($modules as $module => $enroldir) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
@@ -83,10 +83,9 @@ die;die;die;
|
||||
|
||||
|
||||
/// upgrade all plugins types
|
||||
$upgradedplugins = false;
|
||||
$plugintypes = get_plugin_types();
|
||||
foreach ($plugintypes as $type=>$location) {
|
||||
$upgradedplugins = upgrade_plugins($type, $location) || $upgradedplugins;
|
||||
foreach ($plugintypes as $type => $location) {
|
||||
upgrade_plugins($type);
|
||||
}
|
||||
|
||||
/// Check for changes to RPC functions
|
||||
@@ -95,11 +94,6 @@ die;die;die;
|
||||
upgrade_RPC_functions($return_url); // Return here afterwards
|
||||
}
|
||||
|
||||
/// Check for local database customisations
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/lib/locallib.php");
|
||||
upgrade_local_db($return_url); // Return here afterwards
|
||||
|
||||
/// just make sure upgrade logging is properly terminated
|
||||
upgrade_finished();
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ if ($hassiteconfig
|
||||
/// NOTE: these settings must be applied after all other settings because they depend on them
|
||||
///main course settings
|
||||
$temp = new admin_settingpage('coursesettings', get_string('coursesettings'));
|
||||
$courseformats = get_list_of_plugins('course/format');
|
||||
$courseformats = get_plugin_list('format');
|
||||
$formcourseformats = array();
|
||||
foreach ($courseformats as $courseformat) {
|
||||
foreach ($courseformats as $courseformat => $courseformatdir) {
|
||||
$formcourseformats["$courseformat"] = get_string("format$courseformat","format_$courseformat");
|
||||
if ($formcourseformats["$courseformat"]=="[[format$courseformat]]") {
|
||||
$formcourseformats["$courseformat"] = get_string("format$courseformat");
|
||||
|
||||
@@ -173,12 +173,12 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
// Reports
|
||||
$ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades')));
|
||||
foreach (get_list_of_plugins('grade/report') as $plugin) {
|
||||
foreach (get_plugin_list('gradereport') as $plugin => $plugindir) {
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) {
|
||||
if (file_exists($plugindir.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php');
|
||||
include($plugindir.'/settings.php');
|
||||
}
|
||||
$ADMIN->add('gradereports', $settings);
|
||||
}
|
||||
@@ -186,13 +186,13 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
// Imports
|
||||
$ADMIN->add('grades', new admin_category('gradeimports', get_string('importsettings', 'grades')));
|
||||
foreach (get_list_of_plugins('grade/import') as $plugin) {
|
||||
foreach (get_plugin_list('gradeimport') as $plugin => $plugindir) {
|
||||
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php')) {
|
||||
if (file_exists($plugindir.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php');
|
||||
include($plugindir.'/settings.php');
|
||||
}
|
||||
$ADMIN->add('gradeimports', $settings);
|
||||
}
|
||||
@@ -201,12 +201,12 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
// Exports
|
||||
$ADMIN->add('grades', new admin_category('gradeexports', get_string('exportsettings', 'grades')));
|
||||
foreach (get_list_of_plugins('grade/export') as $plugin) {
|
||||
foreach (get_plugin_list('gradeexport') as $plugin => $plugindir) {
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php')) {
|
||||
if (file_exists($plugindir.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php');
|
||||
include($plugindir.'/settings.php');
|
||||
}
|
||||
$ADMIN->add('gradeexports', $settings);
|
||||
}
|
||||
@@ -214,4 +214,3 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
|
||||
@@ -258,20 +258,30 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
|
||||
/// Now add reports
|
||||
|
||||
foreach (get_list_of_plugins($CFG->admin.'/report') as $plugin) {
|
||||
$settings_path = "$CFG->dirroot/$CFG->admin/report/$plugin/settings.php";
|
||||
foreach (get_plugin_list('report') as $plugin => $plugindir) {
|
||||
$settings_path = "$plugindir/settings.php";
|
||||
if (file_exists($settings_path)) {
|
||||
include($settings_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
$index_path = "$CFG->dirroot/$CFG->admin/report/$plugin/index.php";
|
||||
$index_path = "$plugindir/index.php";
|
||||
if (!file_exists($index_path)) {
|
||||
continue;
|
||||
}
|
||||
// old style 3rd party plugin without settings.php
|
||||
$www_path = "$CFG->dirroot/$CFG->admin/report/$plugin/index.php";
|
||||
$www_path = "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php";
|
||||
$reportname = get_string($plugin, 'report_' . $plugin);
|
||||
$ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, $www_path, 'moodle/site:viewreports'));
|
||||
}
|
||||
|
||||
|
||||
/// Add all local plugins - must be always last!
|
||||
|
||||
foreach (get_plugin_list('local') as $plugin => $plugindir) {
|
||||
$settings_path = "$plugindir/settings.php";
|
||||
if (file_exists($settings_path)) {
|
||||
include($settings_path);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -36,22 +36,22 @@ if ($hassiteconfig
|
||||
$ADMIN->add('authsettings', $temp);
|
||||
|
||||
|
||||
if ($auths = get_list_of_plugins('auth')) {
|
||||
if ($auths = get_plugin_list('auth')) {
|
||||
$authsenabled = get_enabled_auth_plugins();
|
||||
$authbyname = array();
|
||||
|
||||
foreach ($auths as $auth) {
|
||||
foreach ($auths as $auth => $authdir) {
|
||||
$strauthname = auth_get_plugin_title($auth);
|
||||
$authbyname[$strauthname] = $auth;
|
||||
}
|
||||
ksort($authbyname);
|
||||
|
||||
foreach ($authbyname as $strauthname=>$authname) {
|
||||
if (file_exists($CFG->dirroot.'/auth/'.$authname.'/settings.php')) {
|
||||
if (file_exists($authdir.'/settings.php')) {
|
||||
// do not show disabled auths in tree, keep only settings link on manage page
|
||||
$settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !in_array($authname, $authsenabled));
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/auth/'.$authname.'/settings.php');
|
||||
include($authdir.'/settings.php');
|
||||
}
|
||||
// TODO: finish implementation of common settings - locking, etc.
|
||||
$ADMIN->add('authsettings', $settings);
|
||||
|
||||
@@ -159,7 +159,8 @@ if ($formdata = $mform->is_cancelled()) {
|
||||
|
||||
$allowedauths = uu_allowed_auths();
|
||||
$allowedauths = array_keys($allowedauths);
|
||||
$availableauths = get_list_of_plugins('auth');
|
||||
$availableauths = get_plugin_list('auth');
|
||||
$availableauths = array_keys($availableauths);
|
||||
|
||||
$allowedroles = uu_allowed_roles(true);
|
||||
foreach ($allowedroles as $rid=>$rname) {
|
||||
|
||||
@@ -201,23 +201,23 @@ class XMLDBAction {
|
||||
* @param xmldb_structure structure object containing all the info
|
||||
* @return string PHP code to be used to stabilish a savepoint
|
||||
*/
|
||||
function upgrade_savepoint_php ($structure) {
|
||||
function upgrade_savepoint_php($structure) {
|
||||
|
||||
$path = $structure->getPath();
|
||||
|
||||
/// Trim "db" from path
|
||||
$path = dirname($path);
|
||||
|
||||
/// Get all the available plugin types
|
||||
$plugintypes = get_plugin_types();
|
||||
|
||||
/// Get pluginname, plugindir and plugintype
|
||||
$pluginname = basename($path);
|
||||
if ($path == 'lib') { /// exception for lib (not proper plugin)
|
||||
$plugindir = 'lib';
|
||||
$plugintype = 'lib';
|
||||
} else { /// rest of plugins
|
||||
//TODO: this is not nice and may fail, plugintype should be passed around somehow instead
|
||||
$plugintypes = get_plugin_types(false);
|
||||
$plugindir = dirname($path);
|
||||
$plugindir = str_replace('\\', '/', $plugindir);
|
||||
$plugintype = array_search($plugindir, $plugintypes);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user