$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();
// 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';
}
// 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 ...", '');
}
}
- 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 ...", '');
}
}
- 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 ...", '');
$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.');
}
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);
$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;
}
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);
/// 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
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();
/// 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");
// 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);
}
// 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);
}
// 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);
}
} // end of speedup
-?>
/// 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;
+ }
+}
\ No newline at end of file
$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);
$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) {
* @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);
}
if (has_capability('moodle/grade:viewall', $context)) {
$reportavailable = true;
} else if (!empty($course->showgrades)) {
- if ($reports = get_list_of_plugins('grade/report')) { // Get all installed reports
+ if ($reports = get_plugin_list('gradereport')) { // Get all installed reports
arsort($reports); // user is last, we want to test it first
- foreach ($reports as $plugin) {
+ foreach ($reports as $plugin => $plugindir) {
if (has_capability('gradereport/'.$plugin.':view', $context)) {
//stop when the first visible plugin is found
$reportavailable = true;
$mform->setHelpButton('summary', array('text2', get_string('helptext')), true);
$mform->setType('summary', PARAM_RAW);
- $courseformats = get_list_of_plugins('course/format');
+ $courseformats = get_plugin_list('format');
$formcourseformats = array();
- foreach ($courseformats as $courseformat) {
- $formcourseformats["$courseformat"] = get_string("format$courseformat","format_$courseformat");
+ foreach ($courseformats as $courseformat => $formatdir) {
+ $formcourseformats["$courseformat"] = get_string("format$courseformat", "format_$courseformat");
if($formcourseformats["$courseformat"]=="[[format$courseformat]]") {
$formcourseformats["$courseformat"] = get_string("format$courseformat");
}
print_header($course->fullname.': '.$strimport, $course->fullname.': '.$strimport, $navigation);
- $directories = get_list_of_plugins('course/import');
+ $imports = get_plugin_list('import');
- foreach ($directories as $directory) {
+ foreach ($imports as $import => $importdir) {
echo '<div class="plugin">';
- include_once($CFG->dirroot.'/course/import/'.$directory.'/mod.php');
+ include($importdir.'/mod.php');
echo '</div>';
}
$navigation = build_navigation($navlinks);
print_header($course->fullname.': '.$strreports, $course->fullname.': '.$strreports, $navigation);
- $directories = get_list_of_plugins('course/report');
+ $reports = get_plugin_list('report');
- foreach ($directories as $directory) {
- $pluginfile = $CFG->dirroot.'/course/report/'.$directory.'/mod.php';
+ foreach ($reports as $report => $reportdirectory) {
+ $pluginfile = $reportdirectory.'/mod.php';
if (file_exists($pluginfile)) {
ob_start();
include($pluginfile); // Fragment for listing
$types = array('report', 'export', 'import');
foreach($types as $type) {
- foreach (get_list_of_plugins('grade/'.$type) as $plugin) {
+ foreach (get_plugin_list('grade'.$type) as $plugin => $plugindir) {
// Include all the settings commands for this plugin if there are any
- if (file_exists($CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lib.php')) {
- require_once($CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lib.php');
+ if (file_exists($plugindir.'/lib.php')) {
+ require_once($plugindir.'/lib.php');
$functionname = 'grade_'.$type.'_'.$plugin.'_settings_definition';
if (function_exists($functionname)) {
$mform->addElement('header', 'grade_'.$type.$plugin, get_string('modulename', 'grade'.$type.'_'.$plugin, NULL));
// report plugins with its special structure
// Get all installed reports
- if ($reports = get_list_of_plugins('grade/report', 'CVS')) {
+ if ($reports = get_plugin_list('gradereport')) {
// Remove ones we can't see
- foreach ($reports as $key => $plugin) {
+ foreach ($reports as $plugin => $unused) {
if (!has_capability('gradereport/'.$plugin.':view', $context)) {
unset($reports[$key]);
}
$reportnames = array();
if (!empty($reports)) {
- foreach ($reports as $plugin) {
+ foreach ($reports as $plugin => $plugindir) {
$pluginstr = get_string('modulename', 'gradereport_'.$plugin);
$url = $url_prefix.'report/'.$plugin.'/index.php?id='.$courseid;
if ($active_type == 'report' and $active_plugin == $plugin ) {
$reportnames[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr);
// Add link to preferences tab if such a page exists
- if (file_exists($CFG->dirroot . '/grade/report/'.$plugin.'/preferences.php')) {
+ if (file_exists($plugindir.'/preferences.php')) {
$pref_url = $url_prefix.'report/'.$plugin.'/preferences.php?id='.$courseid;
$plugin_info['preferences'][$plugin] = new grade_plugin_info($plugin, $pref_url, $pluginstr);
}
}
// standard import plugins
- if ($imports = get_list_of_plugins('grade/import', 'CVS')) { // Get all installed import plugins
- foreach ($imports as $key => $plugin) { // Remove ones we can't see
+ if ($imports = get_plugin_list('gradeimport')) { // Get all installed import plugins
+ foreach ($imports as $plugin => $plugindir) { // Remove ones we can't see
if (!has_capability('gradeimport/'.$plugin.':view', $context)) {
unset($imports[$key]);
}
}
// standard export plugins
- if ($exports = get_list_of_plugins('grade/export', 'CVS')) { // Get all installed export plugins
+ if ($exports = get_plugin_list('gradeexport')) { // Get all installed export plugins
foreach ($exports as $key => $plugin) { // Remove ones we can't see
if (!has_capability('gradeexport/'.$plugin.':view', $context)) {
unset($exports[$key]);
}
$exportnames = array();
if (!empty($exports)) {
- foreach ($exports as $plugin) {
+ foreach ($exports as $plugin => $plugindir) {
$pluginstr = get_string('modulename', 'gradeexport_'.$plugin);
$url = $url_prefix.'export/'.$plugin.'/index.php?id='.$courseid;
if ($active_type == 'export' and $active_plugin == $plugin ) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
/// find all accessible reports
-if ($reports = get_list_of_plugins('grade/report', 'CVS')) { // Get all installed reports
- foreach ($reports as $key => $plugin) { // Remove ones we can't see
- if (!has_capability('gradereport/'.$plugin.':view', $context)) {
- unset($reports[$key]);
- }
+$reports = get_plugin_list('gradereport'); // Get all installed reports
+$reports = array_keys($reports);
+
+foreach ($reports as $plugin => $plugindir) { // Remove ones we can't see
+ if (!has_capability('gradereport/'.$plugin.':view', $context)) {
+ unset($reports[$key]);
}
}
//redirect to last or guessed report
redirect($CFG->wwwroot.'/grade/report/'.$last.'/index.php?id='.$course->id);
-?>
}
/// Ask all the modules if anything needs to be done for this user
- if ($mods = get_list_of_plugins('mod')) {
- foreach ($mods as $mod) {
- include_once($CFG->dirroot.'/mod/'.$mod.'/lib.php');
- $functionname = $mod.'_role_assign';
- if (function_exists($functionname)) {
- $functionname($userid, $context, $roleid);
- }
+ $mods = get_plugin_list('mod');
+ foreach ($mods as $mod => $moddir) {
+ include_once($moddir.'/lib.php');
+ $functionname = $mod.'_role_assign';
+ if (function_exists($functionname)) {
+ $functionname($userid, $context, $roleid);
}
}
if ($select) {
if ($ras = $DB->get_records_select('role_assignments', implode(' AND ', $select), $params)) {
- $mods = get_list_of_plugins('mod');
+ $mods = get_plugin_list('mod');
foreach($ras as $ra) {
$fireevent = false;
/// infinite loop protection when deleting recursively
}
/// Ask all the modules if anything needs to be done for this user
- foreach ($mods as $mod) {
- include_once($CFG->dirroot.'/mod/'.$mod.'/lib.php');
+ foreach ($mods as $mod=>$moddir) {
+ include_once($moddir.'/lib.php');
$functionname = $mod.'_role_unassign';
if (function_exists($functionname)) {
$functionname($ra->userid, $context); // watch out, $context might be NULL if something goes wrong
* capabilities are defined for the component, we simply return an empty array.
*
* @global object
- * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @param string $component full plugin name, examples: 'moodle', 'mod_forum'
* @return array array of capabilities
*/
function load_capability_def($component) {
- global $CFG;
-
- if ($component == 'moodle') {
- $defpath = $CFG->libdir.'/db/access.php';
- $varprefix = 'moodle';
- } else {
- $compparts = explode('/', $component);
-
- if ($compparts[0] == 'report') {
- $defpath = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'block') {
- // Blocks are an exception. Blocks directory is 'blocks', and not
- // 'block'. So we need to jump through hoops.
- $defpath = $CFG->dirroot.'/'.$compparts[0].
- 's/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'format') {
- // Similar to the above, course formats are 'format' while they
- // are stored in 'course/format'.
- $defpath = $CFG->dirroot.'/course/'.$component.'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
+ $defpath = get_component_directory($component).'/db/access.php';
- } else if ($compparts[0] == 'editor') {
- $defpath = $CFG->dirroot.'/lib/editor/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'gradeimport') {
- $defpath = $CFG->dirroot.'/grade/import/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'gradeexport') {
- $defpath = $CFG->dirroot.'/grade/export/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'gradereport') {
- $defpath = $CFG->dirroot.'/grade/report/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'quizreport') {
- $defpath = $CFG->dirroot.'/mod/quiz/report/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else if ($compparts[0] == 'coursereport') {
- $defpath = $CFG->dirroot.'/course/report/'.$compparts[1].'/db/access.php';
- $varprefix = $compparts[0].'_'.$compparts[1];
-
- } else {
- $defpath = $CFG->dirroot.'/'.$component.'/db/access.php';
- $varprefix = str_replace('/', '_', $component);
- }
- }
$capabilities = array();
-
if (file_exists($defpath)) {
require($defpath);
- $capabilities = ${$varprefix.'_capabilities'};
+ $capabilities = ${$component.'_capabilities'};
}
+
return $capabilities;
}
/**
* Gets the capabilities that have been cached in the database for this component.
- *
- * @global object
- * @param string $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @param string $component - examples: 'moodle', 'mod_forum'
* @return array array of capabilities
*/
function get_cached_capabilities($component='moodle') {
global $DB;
-
- if ($component == 'moodle') {
- $storedcaps = $DB->get_records_select('capabilities', "name LIKE ?", array('moodle/%:%'));
-
- } else if ($component == 'local') {
- $storedcaps = $DB->get_records_select('capabilities', "name LIKE ?", array('moodle/local:%'));
-
- } else {
- $storedcaps = $DB->get_records_select('capabilities', "name LIKE ?", array("$component:%"));
- }
-
- return $storedcaps;
+ return $DB->get_records('capabilities', array('component'=>$component));
}
/**
* Returns default capabilities for given legacy role type.
- *
- * @global object
* @param string $legacyrole legacy role name
* @return array
*/
* Reset role capabilitites to default according to selected legacy capability.
* If several legacy caps selected, use the first from get_default_capabilities.
* If no legacy selected, removes all capabilities.
- *
- * @global object
* @param int @roleid
*/
function reset_role_capabilities($roleid) {
return $table_names;
}
-/**
- * Lists all plugin types
- *
- * @global object
- * @return array Array of strings - name=>location
- */
-function get_plugin_types() {
- global $CFG;
-
- return array('mod' => 'mod',
- 'qtype' => 'question/type',
- 'block' => 'blocks',
- 'auth' => 'auth',
- 'enrol' => 'enrol',
- 'format' => 'course/format',
- 'editor' => 'lib/editor',
- 'gradeexport' => 'grade/export',
- 'gradeimport' => 'grade/import',
- 'gradereport' => 'grade/report',
- 'message' => 'message/output',
- 'coursereport' => 'course/report',
- 'report' => $CFG->admin.'/report',
- 'portfolio' => 'portfolio/type',
- 'repository' => 'repository',
-
- // following types a very ugly hacks - we should not make exceptions like this - all plugins should be equal;
- // these plugins may cause problems such as when wanting to uninstall them
- 'quizreport' => 'mod/quiz/report',
- 'assignment_type' => 'mod/assignment/type',
- );
-}
-
/**
* Returns list of all directories where we expect install.xml files
*
$dbdirs[] = $CFG->libdir.'/db';
/// Then, all the ones defined by get_plugin_types()
- if ($plugintypes = get_plugin_types()) {
- foreach ($plugintypes as $plugintype => $pluginbasedir) {
- if ($plugins = get_list_of_plugins($pluginbasedir, 'db')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot . '/' . $pluginbasedir . '/' . $plugin . '/db';
- }
+ $plugintypes = get_plugin_types();
+ foreach ($plugintypes as $plugintype => $pluginbasedir) {
+ if ($plugins = get_plugin_list($plugintype)) {
+ foreach ($plugins as $plugin => $plugindir) {
+ $dbdirs[] = $plugindir.'/db';
}
}
}
-/// Local database changes, if the local folder exists.
- if (file_exists($CFG->dirroot . '/local')) {
- $dbdirs[] = $CFG->dirroot.'/local/db';
- }
-
return $dbdirs;
}
}
$this->choices = array();
- if ($plugins = get_list_of_plugins('grade/export')) {
- foreach($plugins as $plugin) {
+ if ($plugins = get_plugin_list('gradeexport')) {
+ foreach($plugins as $plugin => $unused) {
$this->choices[$plugin] = get_string('modulename', 'gradeexport_'.$plugin);
}
}
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
- foreach (get_list_of_plugins('grade/report') as $plugin) {
- if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php')) {
- require_once($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php');
+ foreach (get_plugin_list('gradereport') as $plugin => $plugindir) {
+ if (file_exists($plugindir.'/lib.php')) {
+ require_once($plugindir.'/lib.php');
$functionname = 'grade_report_'.$plugin.'_profilereport';
if (function_exists($functionname)) {
$this->choices[$plugin] = get_string('modulename', 'gradereport_'.$plugin);
$found = false;
- if ($modules = get_list_of_plugins('enrol')) {
+ if ($modules = get_plugin_list('enrol')) {
$textlib = textlib_get_instance();
- foreach ($modules as $plugin) {
+ foreach ($modules as $plugin => $dir) {
if (strpos($plugin, $query) !== false) {
$found = true;
break;
}
$textlib = textlib_get_instance();
- $authsavailable = get_list_of_plugins('auth');
- foreach ($authsavailable as $auth) {
+ $authsavailable = get_plugin_list('auth');
+ foreach ($authsavailable as $auth => $dir) {
if (strpos($auth, $query) !== false) {
return true;
}
'up', 'down', 'none'));
$txt->updown = "$txt->up/$txt->down";
- $authsavailable = get_list_of_plugins('auth');
+ $authsavailable = get_plugin_list('auth');
get_enabled_auth_plugins(true); // fix the list of enabled auths
if (empty($CFG->auth)) {
$authsenabled = array();
}
}
- foreach ($authsavailable as $auth) {
+ foreach ($authsavailable as $auth => $dir) {
if (array_key_exists($auth, $displayauths)) {
continue; //already in the list
}
}
$textlib = textlib_get_instance();
- $portfolios= get_list_of_plugins('portfolio/type');
- foreach ($portfolios as $p) {
+ $portfolios = get_plugin_list('portfolio');
+ foreach ($portfolios as $p => $dir) {
if (strpos($p, $query) !== false) {
return true;
}
$namestr = get_string('name');
$pluginstr = get_string('plugin', 'portfolio');
- $plugins = get_list_of_plugins('portfolio/type');
+ $plugins = get_plugin_list('portfolio');
+ $plugins = array_keys($plugins);
$instances = portfolio_instances(false, false);
$alreadyplugins = array();
}
require($CFG->dirroot.'/'.$CFG->admin.'/settings/plugins.php');
- if (file_exists($CFG->dirroot.'/local/settings.php')) {
- require($CFG->dirroot.'/local/settings.php');
- }
-
$ADMIN->loaded = true;
}
$plugins_installed['filter'] = array();
$plugins_ondisk = array();
- $plugins_ondisk['mod'] = get_list_of_plugins('mod', 'db');
- $plugins_ondisk['blocks'] = get_list_of_plugins('blocks', 'db');
- $plugins_ondisk['filter'] = get_list_of_plugins('filter', 'db');
+ $plugins_ondisk['mod'] = array_keys(get_plugin_list('mod'));
+ $plugins_ondisk['blocks'] = array_keys(get_plugin_list('block'));
+ $plugins_ondisk['filter'] = array_keys(get_plugin_list('filter'));
$strstandard = get_string('standard');
$strnonstandard = get_string('nonstandard');
}
$textlib = textlib_get_instance();
- $repositories= get_list_of_plugins('repository');
- foreach ($repositories as $p) {
+ $repositories= get_plugin_list('repository');
+ foreach ($repositories as $p => $dir) {
if (strpos($p, $query) !== false) {
return true;
}
$updownstr = get_string('updown', 'repository');
$hiddenstr = get_string('hiddenshow', 'repository');
$deletestr = get_string('delete');
- $plugins = get_list_of_plugins('repository');
+ $plugins = get_plugin_list('repository');
$instances = repository::get_types();
$instancesnumber = count($instances);
$alreadyplugins = array();
$instancehtml .= get_string('addplugin', 'repository');
$instancehtml .= '</h3><ul>';
$addable = 0;
- foreach ($plugins as $p) {
+ foreach ($plugins as $p=>$dir) {
if (!in_array($p, $alreadyplugins)) {
$instancehtml .= '<li><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/repository.php?sesskey='
.sesskey().'&new='.$p.'">'.get_string('add', 'repository')
/// Important errors that an admin ought to know about
'errors' => array (
'capability' => 'moodle/site:config'
- )
+ ),
+ 'instantmessage' => array (
+ ),
+
);
-
-
-
-
-?>
upgrade_main_savepoint($result, 2009061600);
}
+ if ($result && $oldversion < 2009061702) {
+ // standardizing plugin names
+ if ($configs = $DB->get_records_select('config_plugins', "plugin LIKE 'quizreport_%'")) {
+ foreach ($configs as $config) {
+ $config->plugin = str_replace('quizreport_', 'quiz_', $config->plugin);
+ $DB->update_record('config_plugins', $config);
+ }
+ }
+ unset($configs);
+ upgrade_main_savepoint($result, 2009061702);
+ }
+
+ if ($result && $oldversion < 2009061703) {
+ // standardizing plugin names
+ if ($configs = $DB->get_records_select('config_plugins', "plugin LIKE 'assignment_type_%'")) {
+ foreach ($configs as $config) {
+ $config->plugin = str_replace('assignment_type_', 'assignment_', $config->plugin);
+ $DB->update_record('config_plugins', $config);
+ }
+ }
+ unset($configs);
+ upgrade_main_savepoint($result, 2009061703);
+ }
+
+ if ($result && $oldversion < 2009061704) {
+ // change component string in capability records to new "_" format
+ if ($caps = $DB->get_records('capabilities')) {
+ foreach ($caps as $cap) {
+ $cap->component = str_replace('/', '_', $cap->component);
+ $DB->update_record('capabilities', $cap);
+ }
+ }
+ unset($caps);
+ upgrade_main_savepoint($result, 2009061704);
+ }
+
+ if ($result && $oldversion < 2009061705) {
+ // change component string in events_handlers records to new "_" format
+ if ($handlers = $DB->get_records('events_handlers')) {
+ foreach ($handlers as $handler) {
+ $handler->handlermodule = str_replace('/', '_', $handler->handlermodule);
+ $DB->update_record('events_handlers', $handler);
+ }
+ }
+ unset($handlers);
+ upgrade_main_savepoint($result, 2009061705);
+ }
+
+ if ($result && $oldversion < 2009061706) {
+ // change component string in message_providers records to new "_" format
+ if ($mps = $DB->get_records('message_providers')) {
+ foreach ($mps as $mp) {
+ $mp->component = str_replace('/', '_', $mp->component);
+ $DB->update_record('message_providers', $cap);
+ }
+ }
+ unset($caps);
+ upgrade_main_savepoint($result, 2009061706);
+ }
+
return $result;
}
unset($dbtables[$tablename]);
}
- // look for unsupported tables - local custom tables should be in /local/db/install.xml ;-)
+ // look for unsupported tables - local custom tables should be in /local/xxxx/db/install.xml ;-)
// if there is no prefix, we can not say if tale is ours :-(
if ($this->generator->prefix !== '') {
foreach ($dbtables as $tablename=>$unused) {
*/
function get_available_editors() {
$editors = array();
- foreach (get_list_of_plugins('lib/editor') as $editorname) {
+ foreach (get_plugin_list('editor') as $editorname => $dir) {
$editors[$editorname] = get_string('modulename', 'editor_'.$editorname);
}
return $editors;
* @return array of capabilities or empty array if not exists
*/
function events_load_def($component) {
- global $CFG;
-
- if ($component == 'moodle') {
- $defpath = $CFG->libdir.'/db/events.php';
-
- } else if ($component == 'unittest') {
- $defpath = $CFG->libdir.'/simpletest/fixtures/events.php';
-
- } else {
- $compparts = explode('/', $component);
-
- if ($compparts[0] == 'block') {
- // Blocks are an exception. Blocks directory is 'blocks', and not
- // 'block'. So we need to jump through hoops.
- $defpath = $CFG->dirroot.'/blocks/'.$compparts[1].'/db/events.php';
-
- } else if ($compparts[0] == 'format') {
- // Similar to the above, course formats are 'format' while they
- // are stored in 'course/format'.
- $defpath = $CFG->dirroot.'/course/format/'.$compparts[1].'/db/events.php';
-
- } else if ($compparts[0] == 'editor') {
- $defpath = $CFG->dirroot.'/lib/editor/'.$compparts[1].'/db/events.php';
-
- } else if ($compparts[0] == 'gradeimport') {
- $defpath = $CFG->dirroot.'/grade/import/'.$compparts[1].'/db/events.php';
-
- } else if ($compparts[0] == 'gradeexport') {
- $defpath = $CFG->dirroot.'/grade/export/'.$compparts[1].'/db/events.php';
-
- } else if ($compparts[0] == 'gradereport') {
- $defpath = $CFG->dirroot.'/grade/report/'.$compparts[1].'/db/events.php';
- } else if ($compparts[0] == 'portfolio'){
- $defpath = $CFG->dirroot.'/portfolio/type/'.$compparts[1].'/db/events.php';
- } else {
- $defpath = $CFG->dirroot.'/'.$component.'/db/events.php';
- }
- }
+ $defpath = get_component_directory($component).'/db/events.php';
$handlers = array();
* the database.
*
* @global object
- * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @return boolean
*/
function events_update_definition($component='moodle') {
return;
}
- if (!$mods = get_list_of_plugins('mod') ) {
+ if (!$mods = get_plugin_list('mod') ) {
print_error('nomodules', 'debug');
}
- foreach ($mods as $mod) {
+ foreach ($mods as $mod => $fullmod) {
if ($mod == 'NEWMODULE') { // Someone has unzipped the template, ignore it
continue;
}
- $fullmod = $CFG->dirroot.'/mod/'.$mod;
-
// include the module lib once
if (file_exists($fullmod.'/lib.php')) {
// get all instance of the activity
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-/** NO_MOODLE_COOKIES = true */
define('NO_MOODLE_COOKIES', true);
- /** NO_UPGRADE_CHECK = true */
define('NO_UPGRADE_CHECK', true);
include('../config.php');
$output = "// Javascript from Moodle modules\n";
- if ($mods = get_list_of_plugins('mod')) {
- foreach ($mods as $mod) {
- if (is_readable($CFG->dirroot.'/mod/'.$mod.'/javascript.php')) {
- $output .= file_get_contents($CFG->dirroot.'/mod/'.$mod.'/javascript.php');
+ $plugintypes = array('mod', 'filter', 'block');
+ foreach ($plugintypes as $plugintype) {
+ if ($mods = get_plugin_list($plugintype)) {
+ foreach ($mods as $mod => $moddir) {
+ if (is_readable($moddir.'/javascript.php')) {
+ $output .= file_get_contents($moddir.'/javascript.php');
+ }
}
}
}
- if ($filters = get_list_of_plugins('filter')) {
- foreach ($filters as $filter) {
- if (is_readable($CFG->dirroot.'/filter/'.$filter.'/javascript.php')) {
- $output .= file_get_contents($CFG->dirroot.'/filter/'.$filter.'/javascript.php');
- }
- }
- }
-
- if ($blocks = get_list_of_plugins('blocks')) {
- foreach ($blocks as $block) {
- if (is_readable($CFG->dirroot.'/blocks/'.$block.'/javascript.php')) {
- $output .= file_get_contents($CFG->dirroot.'/blocks/'.$block.'/javascript.php');
- }
- }
- }
-
-
$lifetime = '86400';
@header('Content-type: text/javascript');
@header('Pragma: ');
echo $output;
-
-?>
+++ /dev/null
-<?php
-
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * This file provides hooks from moodle core into custom code.
- *
- * Important note
- * --------------
- *
- * If at all possible, the facilities provided here should not be used.
- * Wherever possible, customisations should be written using one of the
- * standard plug-in points like modules, blocks, auth plugins, themes, ...
- *
- * However, sometimes that is just not possible, because of the nature
- * of the change you want to make. In which case the second best plan is
- * to implement your feature in a generally useful way, which can
- * be contributed back to the moodle project so that everyone benefits.
- *
- * But supposing you are forced to implement some nasty hack that only
- * you will ever want, then the local folder is for you. The idea is that
- * instead of scattering your changes throughout the code base, you
- * put them all in a folder called 'local'. Then you won't have to
- * deal with merging problems when you upgrade the rest of your moodle
- * installation.
- *
- *
- * Available hooks
- * ===============
- *
- * These are similar to the module interface, however, not all the the
- * facilities that are available to modules are available to local code (yet).
- * See also http://docs.moodle.org/en/Development:Local_customisation for more
- * information.
- *
- *
- * Local database customisations
- * -----------------------------
- *
- * If your local customisations require changes to the database, use the files:
- *
- * local/version.php
- * local/db/upgrade.php
- * local/db/install.php
- *
- * In the file version.php, set the variable $local_version to a versionstamp
- * value like 2006030300 (a concatenation of year, month, day, serial).
- *
- * In the file upgrade.php, implement the
- * function xmldb_local_upgrade($oldversion) to make the database changes.
- *
- * Note that you don't need to have an install.xml file. Instead,
- * when your moodle instance is first installed, xmldb_local_install() will be called.
- *
- * Please note that modifying of core tables is NOT supported at all!
- *
- * Local capabilities
- * ------------------
- *
- * If your local customisations require their own capabilities, use
- *
- * local/db/access.php
- *
- * You should create an array called $local_capabilities, which looks like:
- *
- * $local_capabilities = array(
- * 'moodle/local:capability' => array(
- * 'captype' => 'read',
- * 'contextlevel' => CONTEXT_SYSTEM,
- * ),
- * );
- *
- * Note that for all local capabilities you add, you'll need to add language strings.
- * Moodle will expect to find them in local/lang/en_utf8/local.php (eg for English)
- * with a key (following the above example) of local:capability
- * See the next section for local language support.
- *
- *
- * Local language support
- * ----------------------
- *
- * Moodle already supports local overriding of any language strings, or the
- * creation of new strings. Just create a folder lang/XX_utf8_local where XX is
- * a language code. Any language files you put in there will be used before
- * the standard files. So, for example, can can create a file
- * lang/en_utf8_local/moodle.php containing
- * $strings['login'] = 'Sign in';
- * and that will change the string 'Login' to 'Sign in'. (See also
- * http://docs.moodle.org/en/Language_editing for another way to achieve this.)
- *
- * This mechanism can also be used to create completely new language files. For
- * example, suppose you have created some code in local/myfeature.php that needs
- * some language strings. You can put those strings in the file
- * lang/en_utf8_local/local_myfeature.php, and then access then using
- * get_string('mystring', 'local_myfeature'). (Note that you do not have to call
- * the file local_myfeature.php, you can call it anything you like, however,
- * the convention of calling lang files for local/ code local_somthing is recommended.)
- *
- * In addition, there is one other mechanism that is available. Strings from the
- * 'local' langauge file (for example get_string('mystring', 'local') will be
- * found if the string is found in the file local/lang/en_utf8/local.php. Since
- * the lang file 'local' is used for a lot of things like capability names, you
- * can use this file for things like that.
- *
- *
- * Local admin menu items
- * ----------------------
- *
- * It is possible to add new items to the admin_tree block.
- * To do this, create a file, local/settings.php
- * which can access the $ADMIN variable directly and add things to it.
- * You might do something like:
- * $ADMIN->add('root', new admin_category($name, $title);
- * $ADMIN->add('foo', new admin_externalpage($name, $title, $url, $cap);
- *
- *
- * Course deletion
- * ---------------
- *
- * To have your local customisations notified when a course is deleted,
- * make a file called
- *
- * local/lib.php
- *
- * In there, implement the function local_delete_course($courseid). This
- * function will then be called whenever the functions remove_course_contents()
- * or delete_course() from moodlelib are called.
- *
- * @package moodlecore
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * Notify local code that a course is being deleted.
- * Look for a function local_delete_course() in a file called
- * local/lib.php andn call it if it is there.
- *
- * @global object
- * @param int $courseid the course that is being deleted.
- * @param bool $showfeedback Whether to display notifications on success.
- * @return bool false if local_delete_course failed, or true if
- * there was noting to do or local_delete_course succeeded.
- */
-function notify_local_delete_course($courseid, $showfeedback) {
- global $CFG;
- $localfile = $CFG->dirroot .'/local/lib.php';
- if (file_exists($localfile)) {
- require_once($localfile);
- if (function_exists('local_delete_course')) {
- if (local_delete_course($courseid)) {
- if ($showfeedback) {
- notify(get_string('deleted') . ' local data');
- }
- } else {
- return false;
- }
- }
- }
- return true;
-}
-?>
/**
* This code updates the message_providers table with the current set of providers
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @param $component - examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @return boolean
*/
function message_update_providers($component='moodle') {
/**
* Loads the messages definitions for the component (from file). If no
* messages are defined for the component, we simply return an empty array.
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @param $component - examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @return array of message providerss or empty array if not exists
*
* INTERNAL - to be used from messagelib only
*/
function message_get_providers_from_file($component) {
- global $CFG;
-
- if ($component == 'moodle') {
- $defpath = $CFG->libdir.'/db/messages.php';
-
- } else if ($component == 'unittest') {
- $defpath = $CFG->libdir.'/simpletest/fixtures/messages.php';
-
- } else {
- $compparts = explode('/', $component);
-
- if ($compparts[0] == 'block') {
- // Blocks are an exception. Blocks directory is 'blocks', and not
- // 'block'. So we need to jump through hoops.
- $defpath = $CFG->dirroot.'/blocks/'.$compparts[1].'/db/messages.php';
-
- } else if ($compparts[0] == 'format') {
- // Similar to the above, course formats are 'format' while they
- // are stored in 'course/format'.
- $defpath = $CFG->dirroot.'/course/format/'.$compparts[1].'/db/messages.php';
-
- } else if ($compparts[0] == 'gradeimport') {
- $defpath = $CFG->dirroot.'/grade/import/'.$compparts[1].'/db/messages.php';
-
- } else if ($compparts[0] == 'gradeexport') {
- $defpath = $CFG->dirroot.'/grade/export/'.$compparts[1].'/db/messages.php';
-
- } else if ($compparts[0] == 'gradereport') {
- $defpath = $CFG->dirroot.'/grade/report/'.$compparts[1].'/db/messages.php';
-
- } else {
- $defpath = $CFG->dirroot.'/'.$component.'/db/messages.php';
- }
- }
+ $defpath = get_component_directory($component).'/db/messages.php';
$messageproviders = array();
/** True if module supports intro editor */
define('FEATURE_MOD_INTRO', 'mod_intro');
+/** True if module supports subplugins */
+define('FEATURE_MOD_SUBPLUGINS', 'mod_subplugins');
/** True if module has default completion */
define('FEATURE_MODEDIT_DEFAULT_COMPLETION', 'modedit_default_completion');
$strdeleted = get_string('deleted');
/// Clean up course formats (iterate through all formats in the even the course format was ever changed)
- $formats = get_list_of_plugins('course/format');
- foreach ($formats as $format) {
+ $formats = get_plugin_list('format');
+ foreach ($formats as $format=>$formatdir) {
$formatdelete = $format.'_course_format_delete_course';
- $formatlib = "$CFG->dirroot/course/format/$format/lib.php";
+ $formatlib = "$formatdir/lib.php";
if (file_exists($formatlib)) {
include_once($formatlib);
if (function_exists($formatdelete)) {
print_error('nomodules', 'debug');
}
-/// Give local code a chance to delete its references to this course.
- require_once($CFG->libdir.'/locallib.php');
- notify_local_delete_course($courseid, $showfeedback);
-
/// Delete course blocks
blocks_delete_all_for_context($context->id);
$dirroot . '/lang/' => '',
$dataroot . '/lang/' => '',
);
- $this->searchplacesbyplugintype = array(
- 'assignment_' => array('mod/assignment/type'),
- 'auth_' => array('auth'),
- 'block_' => array('blocks'),
- 'datafield_' => array('mod/data/field'),
- 'datapreset_' => array('mod/data/preset'),
- 'enrol_' => array('enrol'),
- 'filter_' => array('filter'),
- 'format_' => array('course/format'),
- 'editor_' => array('lib/editor'),
- 'quiz_' => array('mod/quiz/report'),
- 'qtype_' => array('question/type'),
- 'qformat_' => array('question/format'),
- 'report_' => array($admin.'/report', 'course/report'),
- 'repository_'=>array('repository'),
- 'resource_' => array('mod/resource/type'),
- 'gradereport_' => array('grade/report'),
- 'gradeimport_' => array('grade/import'),
- 'gradeexport_' => array('grade/export'),
- 'profilefield_' => array('user/profile/field'),
- 'portfolio_' => array('portfolio/type'),
- '' => array('mod')
- );
+ $this->searchplacesbyplugintype = array(''=>array('mod'));
+ $plugintypes = get_plugin_types(false);
+ foreach ($plugintypes as $plugintype => $dir) {
+ $this->searchplacesbyplugintype[$plugintype.'_'] = array($dir);
+ }
+ unset($this->searchplacesbyplugintype['mod_']);
$this->restore_extra_locations_from_session();
if ($runninginstaller) {
$stringnames = file($dirroot . '/install/stringnames.txt');
foreach ($locations as $location => $ignored) {
$locations[$location] = $module . '/';
}
- if ($module == 'local') {
- $locations[$this->dirroot . '/local/lang/'] = 'local/';
- } else {
- list($type, $plugin) = $this->parse_module_name($module);
- if (isset($this->searchplacesbyplugintype[$type])) {
- foreach ($this->searchplacesbyplugintype[$type] as $location) {
- $locations[$this->dirroot . "/$location/$plugin/lang/"] = $plugin . '/';
- }
+ list($type, $plugin) = $this->parse_module_name($module);
+ if (isset($this->searchplacesbyplugintype[$type])) {
+ foreach ($this->searchplacesbyplugintype[$type] as $location) {
+ $locations[$this->dirroot . "/$location/$plugin/lang/"] = $plugin . '/';
}
}
}
if (!empty($CFG->themelist)) { // use admin's list of themes
$themelist = explode(',', $CFG->themelist);
} else {
- $themelist = get_list_of_plugins("theme");
+ $themelist = array_keys(get_plugin_list("theme"));
}
foreach ($themelist as $key => $theme) {
/// ENVIRONMENT CHECKING ////////////////////////////////////////////////////////////
/**
- * Lists plugin directories within some directory
+ * Return exact path to plugin directory
+ * @param string $plugintype type of plugin
+ * @param string $name name of the plugin
+ * @param bool $fullpaths false means relative paths from dirroot
+ * @return directory path, full or relative to dirroot
+ */
+function get_plugin_directory($plugintype, $name, $fullpaths=true) {
+ if ($plugintype === '') {
+ $plugintype = 'mod';
+ }
+
+ $types = get_plugin_types($fullpaths);
+ if (!array_key_exists($plugintype, $types)) {
+ return null;
+ }
+ $name = clean_param($name, PARAM_SAFEDIR); // just in case ;-)
+
+ return $types[$plugintype].'/'.$name;
+}
+
+/**
+ * Return exact path to plugin directory,
+ * this method support "simpletest_" prefix designed for unit testing.
+ * @param string $component name such as 'moodle', 'mod_forum' or special simpletest value
+ * @param bool $fullpaths false means relative paths from dirroot
+ * @return directory path, full or relative to dirroot
+ */
+function get_component_directory($component, $fullpaths=true) {
+ global $CFG;
+
+ $simpletest = false;
+ if (strpos($component, 'simpletest_') === 0) {
+ $subdir = substr($component, strlen('simpletest_'));
+ return $subdir;
+ }
+ if ($component == 'moodle') {
+ $path = ($fullpaths ? $CFG->libdir : 'lib');
+ } else {
+ list($type, $plugin) = explode('_', $component, 2);
+ $path = get_plugin_directory($type, $plugin, $fullpaths);
+ }
+
+ return $path;
+}
+
+/**
+ * Lists all plugin types
+ * @param bool $fullpaths false means relative paths from dirroot
+ * @return array Array of strings - name=>location
+ */
+function get_plugin_types($fullpaths=true) {
+ global $CFG;
+
+ static $info = null;
+ static $fullinfo = null;
+
+ if (!$info) {
+ $info = array('mod' => 'mod',
+ 'auth' => 'auth',
+ 'enrol' => 'enrol',
+ 'message' => 'message/output',
+ 'block' => 'blocks',
+ 'filter' => 'filter',
+ 'editor' => 'lib/editor',
+ 'format' => 'course/format',
+ 'import' => 'course/import',
+ 'profilefield' => 'user/profile/field',
+ 'report' => $CFG->admin.'/report',
+ 'coursereport' => 'course/report', // must be after system reports
+ 'gradeexport' => 'grade/export',
+ 'gradeimport' => 'grade/import',
+ 'gradereport' => 'grade/report',
+ 'repository' => 'repository',
+ 'portfolio' => 'portfolio/type',
+ 'qtype' => 'question/type',
+ 'qformat' => 'question/format');
+/*
+ $mods = get_plugin_list('mod');
+ foreach ($mods as $mod => $moddir) {
+ if (!$subplugins = plugin_supports('mod', $mod, FEATURE_MOD_SUBPLUGINS, false)) {
+ continue;
+ }
+ foreach ($subplugins as $subtype=>$dir) {
+ $info[$subtype] = $dir;
+ }
+ }
+*/
+ // do not include themes if in non-standard location
+ if ($CFG->themedir === $CFG->dirroot.'/theme') {
+ $info['theme'] = 'theme';
+ }
+
+ // local is always last
+ $info['local'] = 'local';
+
+ $fullinfo = array();
+ foreach ($info as $type => $dir) {
+ $fullinfo[$type] = $CFG->dirroot.'/'.$dir;
+ }
+ $fullinfo['theme'] = $CFG->themedir;
+ }
+
+ return ($fullpaths ? $fullinfo : $info);
+}
+
+/**
+ * Simplified version of get_list_of_plugins()
+ * @param string $plugintype type of plugin
+ * @param bool $fullpaths false means relative paths from dirroot
+ * @return array name=>fulllocation pairs of plugins of given type
+ */
+function get_plugin_list($plugintype, $fullpaths=true) {
+ global $CFG;
+
+ $ignored = array('CVS', '_vti_cnf', 'simpletest', 'db');
+
+ if ($plugintype === '') {
+ $plugintype = 'mod';
+ }
+
+ if ($plugintype === 'mod') {
+ // mod is eán exception because we have to call this function from get_plugin_types()
+ $fulldir = $CFG->dirroot.'/mod';
+ $dir = $fullpaths ? $fulldir : 'mod';
+
+ } else {
+ $fulltypes = get_plugin_types(true);
+ $types = get_plugin_types($fullpaths);
+ if (!array_key_exists($plugintype, $types)) {
+ return array();
+ }
+ $fulldir = $fulltypes[$plugintype];
+ $dir = $types[$plugintype];
+ if (!file_exists($fulldir)) {
+ return array();
+ }
+ }
+
+ $result = array();
+
+ $items = new DirectoryIterator($fulldir);
+ foreach ($items as $item) {
+ if ($item->isDot() or !$item->isDir()) {
+ continue;
+ }
+ $pluginname = $item->getFilename();
+ if (in_array($pluginname, $ignored)) {
+ continue;
+ }
+ if ($pluginname !== clean_param($pluginname, PARAM_SAFEDIR)) {
+ // better ignore plugins with problematic names here
+ continue;
+ }
+ $result[$pluginname] = $dir.'/'.$pluginname;
+ }
+
+ ksort($result);
+ return $result;
+}
+
+/**
+ * Lists plugin-like directories within specified directory
*
- * @global object
- * @param string $plugin dir under we'll look for plugins (defaults to 'mod')
+ * This function was originally used for standar Moodle plugins, please use
+ * new get_plugin_list() now.
+ *
+ * This function is used for general directory listing and backwards compability.
+ *
+ * @param string $directory relatice directory from root
* @param string $exclude dir name to exclude from the list (defaults to none)
* @param string $basedir full path to the base dir where $plugin resides (defaults to $CFG->dirroot)
- * @return array Array of plugins found under the requested parameters
+ * @return array Sorted array of directory names found under the requested parameters
*/
-function get_list_of_plugins($plugin='mod', $exclude='', $basedir='') {
+function get_list_of_plugins($directory='mod', $exclude='', $basedir='') {
global $CFG;
$plugins = array();
if (empty($basedir)) {
-
- # This switch allows us to use the appropiate theme directory - and potentialy alternatives for other plugins
- switch ($plugin) {
- case "theme":
- $basedir = $CFG->themedir;
- break;
-
- default:
- $basedir = $CFG->dirroot .'/'. $plugin;
+ // This switch allows us to use the appropiate theme directory - and potentialy alternatives for other plugins
+ switch ($directory) {
+ case "theme":
+ $basedir = $CFG->themedir;
+ break;
+ default:
+ $basedir = $CFG->dirroot .'/'. $directory;
}
} else {
- $basedir = $basedir .'/'. $plugin;
+ $basedir = $basedir .'/'. $directory;
}
if (file_exists($basedir) && filetype($basedir) == 'dir') {
if ($version > $CFG->version) {
return true;
}
- if ($mods = get_list_of_plugins('mod')) {
- foreach ($mods as $mod) {
- $fullmod = $CFG->dirroot .'/mod/'. $mod;
- $module = new object();
- if (!is_readable($fullmod .'/version.php')) {
- notify('Module "'. $mod .'" is not readable - check permissions');
- continue;
- }
- include_once($fullmod .'/version.php'); # defines $module with version etc
- if ($currmodule = $DB->get_record('modules', array('name'=>$mod))) {
- if ($module->version > $currmodule->version) {
- return true;
- }
+ $mods = get_plugin_list('mod');
+ foreach ($mods as $mod => $fullmod) {
+ $module = new object();
+ if (!is_readable($fullmod .'/version.php')) {
+ notify('Module "'. $mod .'" is not readable - check permissions');
+ continue;
+ }
+ include_once($fullmod .'/version.php'); # defines $module with version etc
+ if ($currmodule = $DB->get_record('modules', array('name'=>$mod))) {
+ if ($module->version > $currmodule->version) {
+ return true;
}
}
}
if (is_string($plugins)) {
$plugins = array($plugins);
} else if (empty($plugins)) {
- $plugins = get_list_of_plugins('portfolio/type');
+ $plugins = get_plugin_list('portfolio');
}
$insane = array();
- foreach ($plugins as $plugin) {
+ foreach ($plugins as $plugin => $dir) {
if ($result = portfolio_static_function($plugin, 'plugin_sanity_check')) {
$insane[$plugin] = $result;
}
// Load the questiontype.php file for each question type
// These files in turn call question_register_questiontype()
// with a new instance of each qtype class.
-$qtypenames = get_list_of_plugins('question/type');
-foreach($qtypenames as $qtypename) {
+$qtypenames = get_plugin_list('qtype');
+foreach($qtypenames as $qtypename => $qdir) {
// Instanciates all plug-in question types
- $qtypefilepath= "$CFG->dirroot/question/type/$qtypename/questiontype.php";
+ $qtypefilepath= "$qdir/questiontype.php";
// echo "Loading $qtypename<br/>"; // Uncomment for debugging
if (is_readable($qtypefilepath)) {
function get_import_export_formats( $type ) {
global $CFG;
- $fileformats = get_list_of_plugins("question/format");
+ $fileformats = get_plugin_list("qformat");
$fileformatname=array();
require_once( "{$CFG->dirroot}/question/format.php" );
- foreach ($fileformats as $key => $fileformat) {
- $format_file = $CFG->dirroot . "/question/format/$fileformat/format.php";
- if (file_exists( $format_file ) ) {
- require_once( $format_file );
+ foreach ($fileformats as $fileformat=>$fdir) {
+ $format_file = "$fdir/format.php";
+ if (file_exists($format_file) ) {
+ require_once($format_file);
}
else {
continue;
$CFG->libdir = $CFG->dirroot .'/lib';
+ if (!isset($CFG->themedir)) {
+ $CFG->themedir = $CFG->dirroot.'/theme';
+ $CFG->themewww = $CFG->wwwroot.'/theme';
+ }
+
require_once($CFG->libdir .'/setuplib.php'); // Functions that MUST be loaded first
/// Time to start counting
/// Load up theme variables (colours etc)
- if (!isset($CFG->themedir)) {
- $CFG->themedir = $CFG->dirroot.'/theme';
- $CFG->themewww = $CFG->wwwroot.'/theme';
- }
$CFG->httpsthemewww = $CFG->themewww;
if (isset($_GET['theme'])) {
$a->pluginname = $plugin;
$a->pluginversion = $pluginversion;
$a->currentmoodle = $currentmoodle;
- $a->requiremoodle = $currentmoodle;
+ $a->requiremoodle = $requiremoodle;
parent::__construct('pluginrequirementsnotmet', 'error', "$CFG->wwwroot/$CFG->admin/index.php", $a);
}
}
* @param bool $allowabort allow user to abort script execution here
* @return void
*/
-function upgrade_plugin_savepoint($result, $version, $type, $dir, $allowabort=true) {
+function upgrade_plugin_savepoint($result, $version, $type, $plugin, $allowabort=true) {
+ $component = $type.'_'.$plugin;
+
if (!$result) {
- throw new upgrade_exception("$type/$dir", $version);
+ throw new upgrade_exception($component, $version);
}
- /// TODO: Check that $type is a correct type - based on get_plugin_types()
- /// TODO: Check that $dir (that perhaps should be named $name) is an existing plugin
-
- $fullname = $type.'_'.$dir;
- $component = $type.'/'.$dir;
-
- $installedversion = get_config($fullname, 'version');
+ $installedversion = get_config($component, 'version');
if ($installedversion >= $version) {
// Something really wrong is going on in the upgrade script
throw new downgrade_exception($component, $installedversion, $version);
}
- set_config('version', $version, $fullname);
+ set_config('version', $version, $component);
upgrade_log(UPGRADE_LOG_NORMAL, $component, 'Upgrade savepoint reached');
// Reset upgrade timeout to default
/**
* Upgrade plugins
- *
- * @global object
- * @global object
* @param string $type The type of plugins that should be updated (e.g. 'enrol', 'qtype')
- * @param string $dir The directory where the plugins are located (e.g. 'question/questiontypes')
- * @param string $return The url to prompt the user to continue to
+ * return void
*/
-function upgrade_plugins($type, $dir, $startcallback, $endcallback, $verbose) {
+function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
global $CFG, $DB;
/// special cases
return upgrade_plugins_blocks($startcallback, $endcallback, $verbose);
}
- $plugs = get_list_of_plugins($dir);
+ $plugs = get_plugin_list($type);
- foreach ($plugs as $plug) {
-
- $fullplug = $CFG->dirroot.'/'.$dir.'/'.$plug;
- $component = $type.'/'.$plug; // standardised plugin name
+ foreach ($plugs as $plug=>$fullplug) {
+ $component = $type.'_'.$plug; // standardised plugin name
if (!is_readable($fullplug.'/version.php')) {
continue;
throw new plugin_defective_exception($component, 'Missing version value in version.php');
}
- $plugin->name = $plug; // The name MUST match the directory
- $plugin->fullname = $type.'_'.$plug; // The name MUST match the directory
+ $plugin->name = $plug;
+ $plugin->fullname = $component;
if (!empty($plugin->requires)) {
function upgrade_plugins_modules($startcallback, $endcallback, $verbose) {
global $CFG, $DB;
- $mods = get_list_of_plugins('mod');
+ $mods = get_plugin_list('mod');
- foreach ($mods as $mod) {
+ foreach ($mods as $mod=>$fullmod) {
if ($mod == 'NEWMODULE') { // Someone has unzipped the template, ignore it
continue;
}
- $fullmod = $CFG->dirroot.'/mod/'.$mod;
- $component = 'mod/'.$mod;
+ $component = 'mod_'.$mod;
if (!is_readable($fullmod.'/version.php')) {
throw new plugin_defective_exception($component, 'Missing version.php');
//Is this a first install
$first_install = null;
- $blocks = get_list_of_plugins('blocks');
+ $blocks = get_plugin_list('block');
- foreach ($blocks as $blockname) {
+ foreach ($blocks as $blockname=>$fullblock) {
if (is_null($first_install)) {
$first_install = ($DB->count_records('block') == 0);
continue;
}
- $fullblock = $CFG->dirroot.'/blocks/'.$blockname;
- $component = 'block/'.$blockname;
+ $component = 'block_'.$blockname;
if (!is_readable($fullblock.'/block_'.$blockname.'.php')) {
throw new plugin_defective_exception('block/'.$blockname, 'Missing main block class file.');
}
// Upgrade various componebts
- events_update_definition($component);
update_capabilities($component);
+ events_update_definition($component);
message_update_providers($component);
$endcallback($component, false, $verbose);
}
}
-/**
- * This function checks to see whether local database customisations are up-to-date
- * by comparing $CFG->local_version to the variable $local_version defined in
- * local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
- * in a file called 'local/db/upgrade.php', and if it's there calls it with the
- * appropiate $oldversion parameter. Then it updates $CFG->local_version.
- *
- * @global object
- * @global object
- */
-function upgrade_local_db($startcallback, $endcallback) {
- global $CFG, $DB;
-
- // if we don't have code version, just return false
- if (!file_exists($CFG->dirroot.'/local/version.php')) {
- return;
- }
-
- $local_version = null;
- require($CFG->dirroot.'/local/version.php'); // Get code versions
-
- if (empty($CFG->local_version)) { // install
- $startcallback('local', true);
-
- if (file_exists($CFG->dirroot.'/local/db/install.php')) {
- require_once($CFG->dirroot.'/local/db/install.php');
- xmldb_local_install();
- }
- set_config('local_version', $local_version);
-
- /// Install various components
- events_update_definition('local');
- update_capabilities('local');
- message_update_providers('local');
-
- $endcallback('local', true);
-
- } else if ($local_version > $CFG->local_version) { // upgrade!
- $startcallback('local', false);
-
- if (file_exists($CFG->dirroot.'/local/db/upgrade.php')) {
- require_once($CFG->dirroot.'/local/db/upgrade.php');
- xmldb_local_upgrade($CFG->local_version);
- }
- set_config('local_version', $local_version);
-
- /// Upgrade various components
- events_update_definition('local');
- update_capabilities('local');
- message_update_providers('local');
-
- $endcallback('local', false);
-
- } else if ($local_version < $CFG->local_version) {
- throw new downgrade_exception('local', $CFG->local_version, $local_version);
- }
-}
-
-
/**
* upgrade logging functions
- *
- * @global object
*/
-
function upgrade_handle_exception($ex, $plugin=null) {
global $CFG;
// Continue with the instalation
events_update_definition('moodle');
message_update_providers('moodle');
- message_update_providers('message');
// Write default settings unconditionlly
admin_apply_default_settings(NULL, true);
print_upgrade_part_start('moodle', false, $verbose);
+ // one time special local migration pre 2.0 upgrade script
+ if ($version < 2007101600) {
+ $pre20upgradefile = "$CFG->dirrot/local/upgrade_pre20.php";
+ if (file_exists($pre20upgradefile)) {
+ set_time_limit(0);
+ require($pre20upgradefile);
+ // reset upgrade timeout to default
+ upgrade_set_timeout();
+ }
+ }
+
$result = xmldb_main_upgrade($CFG->version);
if ($version > $CFG->version) {
// store version if not already there
update_capabilities('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
- message_update_providers('message');
remove_dir($CFG->dataroot . '/cache', true); // flush cache
try {
$plugintypes = get_plugin_types();
foreach ($plugintypes as $type=>$location) {
- upgrade_plugins($type, $location, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
+ upgrade_plugins($type, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
}
} catch (Exception $ex) {
upgrade_handle_exception($ex);
upgrade_handle_exception($ex);
}
}
-
- // Check for local database customisations
- try {
- require_once("$CFG->dirroot/lib/locallib.php");
- upgrade_local_db('print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
- } catch (Exception $ex) {
- upgrade_handle_exception($ex);
- }
}
/**
if ($themename == 'standard') { // Add any standard styles included in any modules
if (!empty($THEME->modsheets)) { // Search for styles.php within activity modules
- if ($mods = get_list_of_plugins('mod')) {
- foreach ($mods as $mod) {
- if (file_exists($CFG->dirroot.'/mod/'.$mod.'/styles.php')) {
- $files[] = array($CFG->dirroot, '/mod/'.$mod.'/styles.php');
- }
+ $mods = get_plugin_list('mod');
+ foreach ($mods as $mod => $moddir) {
+ if (file_exists($moddir.'/styles.php')) {
+ $files[] = array($moddir.'/styles.php');
}
}
}
if (!empty($THEME->blocksheets)) { // Search for styles.php within block modules
- if ($mods = get_list_of_plugins('blocks')) {
- foreach ($mods as $mod) {
- if (file_exists($CFG->dirroot.'/blocks/'.$mod.'/styles.php')) {
- $files[] = array($CFG->dirroot, '/blocks/'.$mod.'/styles.php');
- }
+ $mods = get_plugin_list('blocks');
+ foreach ($mods as $mod => $moddir) {
+ if (file_exists($moddir.'/styles.php')) {
+ $files[] = array($moddir.'/styles.php');
}
}
}
if (!isset($THEME->courseformatsheets) || $THEME->courseformatsheets) { // Search for styles.php in course formats
- if ($mods = get_list_of_plugins('format','',$CFG->dirroot.'/course')) {
- foreach ($mods as $mod) {
- if (file_exists($CFG->dirroot.'/course/format/'.$mod.'/styles.php')) {
- $files[] = array($CFG->dirroot, '/course/format/'.$mod.'/styles.php');
- }
+ $mods = get_plugin_list('format');
+ foreach ($mods as $mod => $moddir) {
+ if (file_exists($moddir.'/styles.php')) {
+ $files[] = array($moddir.'/styles.php');
}
}
}
if (!isset($THEME->gradereportsheets) || $THEME->gradereportsheets) { // Search for styles.php in grade reports
- if ($reports = get_list_of_plugins('grade/report')) {
- foreach ($reports as $report) {
- if (file_exists($CFG->dirroot.'/grade/report/'.$report.'/styles.php')) {
- $files[] = array($CFG->dirroot, '/grade/report/'.$report.'/styles.php');
- }
+ $reports = get_plugin_list('gradereport');
+ foreach ($reports as $report => $reportdir) {
+ if (file_exists($reportdir.'/styles.php')) {
+ $files[] = array($reportdir.'/styles.php');
}
}
}
--- /dev/null
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Readme file for local customisations
+ *
+ * @package local
+ * @copyright 2009 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+Local customisations directory
+==============================
+This directory is the recommended place for local customisations.
+
+Wherever possible, customisations should be written using one of the
+standard plug-in points like modules, blocks, auth plugins, themes, etc.
+
+See also http://docs.moodle.org/en/Development:Local_customisation for more
+information.
+
+
+Directory structure
+-------------------
+This directory has standard plugin structure. All standard plugin features
+are supported. There may be some extra files with special meaning in /local/.
+
+Sample /local/ directory listing:
+/local/nicehack/ - first customisation plugin
+/local/otherhack/ - other customisation plugin
+/local/upgrade_pre20.php - one time upgrade and migration script which is
+ executed before main 2.0 upgrade
+/local/defaults.php - custom admin setting defaults
+
+
+Custom capabilities
+-------------------
+Each plugin may define own capabilities. It is not recommended to define
+capabilities belonging to other plugins here, but it should work too.
+
+/local/nicehack/access.php content
+<?php
+$local_nicehack_capabilities = array(
+ 'local/nicehack:nicecapability' => array(
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_SYSTEM,
+ ),
+);
+?>
+
+
+Custom language strings
+-----------------------
+If customisation needs new strings it is recommended to use normal plugin
+strings.
+
+sample language file /local/nicehack/lang/en_utf8.php
+<?php
+$string['hello'] = 'Hi $a';
+$string['nicehack:nicecapability'] = 'Some capability';
+?>
+
+use of the new string in code
+echo get_string('hello', 'local_nicehack', 'petr');
+
+
+Custom admin menu items
+----------------------
+It is possible to add new items and categories to the admin_tree block.
+I you need to define new admin setting classes put them into separate
+file and require_once() from settings.php
+
+For example if you want to add new external page use following
+/local/nicehack/settings.php
+<?php
+$ADMIN->add('root', new admin_category('tweaks', 'Custom tweaks'));
+$ADMIN->add('tweaks', new admin_externalpage('nicehackery', 'Tweak something',
+ $CFG->wwwroot.'/local/nicehack/setuppage.php'));
+?>
+
+
+Custom event handlers
+---------------------
+Events intended primarily for communication "core --> plugins". (It should not
+be use in opposite direction!) In theory it could be also used for
+"plugin --> plugin" communication too. The list of core events is documented
+in lib/db/events.php
+
+sample files
+/local/nicehack/db/events.php
+$handlers = array (
+ 'user_deleted' => array (
+ 'handlerfile' => '/local/nicehack/lib.php',
+ 'handlerfunction' => 'nicehack_userdeleted_handler',
+ 'schedule' => 'instant'
+ ),
+);
+
+NOTE: events are not yet fulyl implemented in current Moodle 2.0dev.
+
+
+Custom db tables
+----------------
+XMLDB editors is the recommended tool. Please note that modification
+of core table structure is highly discouraged.
+
+If you really really really need to modify core tables you might want to do
+that in install.php and later upgrade.php
+
+List of upgrade related files:
+/local/nicehack/db/install.xml - contains XML definition of new tables
+/local/nicehack/db/install.php - executed after db creation, may be also used
+ for general install code
+/local/nicehack/db/upgrade.php - executed when version changes
+/local/nicehack/version.php - version specification file
+
+
+Customised site defaults
+------------------------
+Different default site settings can be stored in file /local/defaults.php.
+These new defaults are used during installation, upgrade and later are
+displayed as default values in admin settings.
+
+Sample /local/defaults.php file content:
+<?php
+$defaults['moodle']['forcelogin'] = 1;
+$defaults['scorm']['maxgrade'] = 20;
+$defaults['moodlecourse']['numsections'] = 11;
+?>
+
+First bracket contains string from column plugin of config_plugins table.
+Second bracket is the name of setting. In the admin settings UI the plugin and
+name of setting is separated by "|".
+
+Please note that not all settings are converted to admin_tree yet.
+
+
+1.9.x upgrade notes
+-------------------
+1.9.x contains basic support for local hacks placed directly into
+/local/ directory. This old local API is not supported any more in 2.0.
+
+You an use /local/upgrade_pre20.php script for any code that needs to
+be executed before the main upgrade to 2.0.
+
+
+
+Other customisation information
+===============================
+
+Local language pack modifications
+---------------------------------
+Moodle supports other type of local customisation of standard language
+packs. If you want to create your own language pack based on another
+language create new dataroot directory with "_local" suffix, for example
+following file with content changes string "Login" to "Sign in":
+moodledata/lang/en_utf8_local
+<?php
+ $string['login'] = 'Sign in';
+?>
+
+See also http://docs.moodle.org/en/Language_editing
+++ /dev/null
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// Defines message providers (types of messages being sent) //
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.org //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
-
-
-$messageproviders = array (
-
- 'instantmessage' => array (
- )
-
-);
-
-
-?>
global $CFG, $USER, $DB;
/// first execute all crons in plugins
- if ($plugins = get_list_of_plugins('mod/assignment/type')) {
- foreach ($plugins as $plugin) {
- require_once("$CFG->dirroot/mod/assignment/type/$plugin/assignment.class.php");
+ if ($plugins = get_plugin_list('assignment')) {
+ foreach ($plugins as $plugin=>$dir) {
+ require_once("$dir/assignment.class.php");
$assignmentclass = "assignment_$plugin";
$ass = new $assignmentclass();
$ass->cron();
*/
function assignment_types() {
$types = array();
- $names = get_list_of_plugins('mod/assignment/type');
- foreach ($names as $name) {
+ $names = get_plugin_list('assignment');
+ foreach ($names as $name=>$dir) {
$types[$name] = get_string('type'.$name, 'assignment');
}
asort($types);
}
/// Drop-in extra assignment types
- $assignmenttypes = get_list_of_plugins('mod/assignment/type');
+ $assignmenttypes = get_plugin_list('assignment');
+ $assignmenttypes = array_keys($assignmenttypes);
foreach ($assignmenttypes as $assignmenttype) {
if (!empty($CFG->{'assignment_hide_'.$assignmenttype})) { // Not wanted
continue;
$status = array();
- foreach (get_list_of_plugins('mod/assignment/type') as $type) {
- require_once("$CFG->dirroot/mod/assignment/type/$type/assignment.class.php");
+ foreach (get_plugin_list('mod/assignment/type') as $type=>$dir) {
+ require_once("$dir/assignment.class.php");
$assignmentclass = "assignment_$type";
$ass = new $assignmentclass();
$status = array_merge($status, $ass->reset_userdata($data));
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
case FEATURE_GRADE_HAS_GRADE: return true;
case FEATURE_GRADE_OUTCOMES: return true;
+ case FEATURE_MOD_SUBPLUGINS: return array('assignment'=>'mod/assignment/type'); // to be hopefully removed in 2.0
default: return null;
}
// skip restore of plugins that are not installed
static $plugins;
if (!isset($plugins)) {
- $plugins = get_list_of_plugins('mod/assignment/type');
+ $plugins = array_keys(get_plugin_list('assignment'));
}
if (!in_array($assignment->assignmenttype, $plugins)) {
$CFG->chat_use_cache = false;
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output
+global $CHAT_HTMLHEAD;
$CHAT_HTMLHEAD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head></head>\n<body>\n\n".padding(200);
// The HTML head for the message window to start with (with js scrolling)
+global $CHAT_HTMLHEAD_JS;
$CHAT_HTMLHEAD_JS = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><script type="text/javascript">
</head>
<body onBlur="scroll_active = true" onFocus="scroll_active = false">
EOD;
+global $CHAT_HTMLHEAD_JS;
$CHAT_HTMLHEAD_JS .= padding(200);
// The HTML code for standard empty pages (e.g. if a user was kicked out)
+global $CHAT_HTMLHEAD_OUT;
$CHAT_HTMLHEAD_OUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>You are out!</title></head><body></body></html>";
// The HTML head for the message input page
+global $CHAT_HTMLHEAD_MSGINPUT;
$CHAT_HTMLHEAD_MSGINPUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>Message Input</title></head><body>";
// The HTML code for the message input page, with JavaScript
+global $CHAT_HTMLHEAD_MSGINPUT_JS;
$CHAT_HTMLHEAD_MSGINPUT_JS = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
EOD;
// Dummy data that gets output to the browser as needed, in order to make it show output
+global $CHAT_DUMMY_DATA;
$CHAT_DUMMY_DATA = padding(200);
/**
default: return null;
}
}
-
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-/** @global int $COLUMN_HEIGHT */
-$COLUMN_HEIGHT = 300;
+/** @global int $CHOICE_COLUMN_HEIGHT */
+global $CHOICE_COLUMN_HEIGHT;
+$CHOICE_COLUMN_HEIGHT = 300;
define('CHOICE_PUBLISH_ANONYMOUS', '0');
define('CHOICE_PUBLISH_NAMES', '1');
define('CHOICE_DISPLAY_VERTICAL', '1');
/** @global array $CHOICE_PUBLISH */
+global $CHOICE_PUBLISH;
$CHOICE_PUBLISH = array (CHOICE_PUBLISH_ANONYMOUS => get_string('publishanonymous', 'choice'),
CHOICE_PUBLISH_NAMES => get_string('publishnames', 'choice'));
/** @global array $CHOICE_SHOWRESULTS */
+global $CHOICE_SHOWRESULTS;
$CHOICE_SHOWRESULTS = array (CHOICE_SHOWRESULTS_NOT => get_string('publishnot', 'choice'),
CHOICE_SHOWRESULTS_AFTER_ANSWER => get_string('publishafteranswer', 'choice'),
CHOICE_SHOWRESULTS_AFTER_CLOSE => get_string('publishafterclose', 'choice'),
CHOICE_SHOWRESULTS_ALWAYS => get_string('publishalways', 'choice'));
/** @global array $CHOICE_DISPLAY */
+global $CHOICE_DISPLAY;
$CHOICE_DISPLAY = array (CHOICE_DISPLAY_HORIZONTAL => get_string('displayhorizontal', 'choice'),
CHOICE_DISPLAY_VERTICAL => get_string('displayvertical','choice'));
* @return void Output is echo'd
*/
function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish='') {
- global $CFG, $COLUMN_HEIGHT, $FULLSCRIPT;
+ global $CFG, $CHOICE_COLUMN_HEIGHT, $FULLSCRIPT;
print_heading(get_string("responses", "choice"));
if (empty($forcepublish)) { //alow the publish setting to be overridden
if ($choice->showunanswered) {
if ($maxcolumn) {
- $height = $COLUMN_HEIGHT * ((float)$column[0] / (float)$maxcolumn);
+ $height = $CHOICE_COLUMN_HEIGHT * ((float)$column[0] / (float)$maxcolumn);
}
echo "<td style=\"vertical-align:bottom\" align=\"center\" class=\"col0 data\">";
echo "<img src=\"column.png\" height=\"$height\" width=\"49\" alt=\"\" />";
$count = 1;
foreach ($choice->option as $optionid => $optiontext) {
if ($maxcolumn) {
- $height = $COLUMN_HEIGHT * ((float)$column[$optionid] / (float)$maxcolumn);
+ $height = $CHOICE_COLUMN_HEIGHT * ((float)$column[$optionid] / (float)$maxcolumn);
}
echo "<td style=\"vertical-align:bottom\" align=\"center\" class=\"col$count data\">";
echo "<img src=\"column.png\" height=\"$height\" width=\"49\" alt=\"\" />";
default: return null;
}
}
-?>
//-------------------------------------------------------------------------------
- $this->standard_coursemodule_elements($features);
+ $this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
$this->add_action_buttons();
}
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
case FEATURE_GRADE_HAS_GRADE: return true;
case FEATURE_GRADE_OUTCOMES: return true;
+ case FEATURE_MOD_SUBPLUGINS: return array('datafield'=>'mod/data/field', 'datapreset'=>'mod/data/preset');
default: return null;
- }
+ }
}
/**
* @global object
return array($formats, $includedfiles);
}
}
-?>
define('FEEDBACK_RESETFORM_DROP', 'feedback_drop_feedback_');
define('FEEDBACK_MAX_PIX_LENGTH', '400'); //max. Breite des grafischen Balkens in der Auswertung
+global $feedback_names; // not nice
$feedback_names = feedback_load_feedback_items('mod/feedback/item');
-//initialize the feedback-Session
+//initialize the feedback-Session - not nice at all!!
+global $SESSION;
if(!isset($SESSION->feedback) OR !is_object($SESSION->feedback)) {
$SESSION->feedback = new object();
}
return $url;
}
}
-?>
return get_string('modulename', 'forum');
}
}
-
-?>
define("HOTPOT_LOCATION_COURSEFILES", "0");
define("HOTPOT_LOCATION_SITEFILES", "1");
+global $HOTPOT_LOCATION;
$HOTPOT_LOCATION = array (
HOTPOT_LOCATION_COURSEFILES => get_string("coursefiles"),
HOTPOT_LOCATION_SITEFILES => get_string("sitefiles"),
define("HOTPOT_OUTPUTFORMAT_FLASH", "20");
define("HOTPOT_OUTPUTFORMAT_MOBILE", "30");
+global $HOTPOT_OUTPUTFORMAT;
$HOTPOT_OUTPUTFORMAT = array (
HOTPOT_OUTPUTFORMAT_BEST => get_string("outputformat_best", "hotpot"),
HOTPOT_OUTPUTFORMAT_V6_PLUS => get_string("outputformat_v6_plus", "hotpot"),
HOTPOT_OUTPUTFORMAT_FLASH => get_string("outputformat_flash", "hotpot"),
HOTPOT_OUTPUTFORMAT_MOBILE => get_string("outputformat_mobile", "hotpot"),
);
+global $HOTPOT_OUTPUTFORMAT_DIR;
$HOTPOT_OUTPUTFORMAT_DIR = array (
HOTPOT_OUTPUTFORMAT_V6_PLUS => 'v6',
HOTPOT_OUTPUTFORMAT_V6 => 'v6',
define("HOTPOT_NAVIGATION_GIVEUP", "5");
define("HOTPOT_NAVIGATION_NONE", "6");
+global $HOTPOT_NAVIGATION;
$HOTPOT_NAVIGATION = array (
HOTPOT_NAVIGATION_BAR => get_string("navigation_bar", "hotpot"),
HOTPOT_NAVIGATION_FRAME => get_string("navigation_frame", "hotpot"),
define("HOTPOT_TEXTOYS_RHUBARB", "7");
define("HOTPOT_TEXTOYS_SEQUITUR", "8");
+global $HOTPOT_QUIZTYPE;
$HOTPOT_QUIZTYPE = array(
HOTPOT_JCB => 'JCB',
HOTPOT_JCLOZE => 'JCloze',
define("HOTPOT_GRADEMETHOD_FIRST", "3");
define("HOTPOT_GRADEMETHOD_LAST", "4");
+global $HOTPOT_GRADEMETHOD;
$HOTPOT_GRADEMETHOD = array (
HOTPOT_GRADEMETHOD_HIGHEST => get_string("gradehighest", "quiz"),
HOTPOT_GRADEMETHOD_AVERAGE => get_string("gradeaverage", "quiz"),
define("HOTPOT_STATUS_ABANDONED", "3");
define("HOTPOT_STATUS_COMPLETED", "4");
+global $HOTPOT_STATUS;
$HOTPOT_STATUS = array (
HOTPOT_STATUS_INPROGRESS => get_string("inprogress", "hotpot"),
HOTPOT_STATUS_TIMEDOUT => get_string("timedout", "hotpot"),
define("HOTPOT_FEEDBACK_MOODLEFORUM", "3");
define("HOTPOT_FEEDBACK_MOODLEMESSAGING", "4");
+global $HOTPOT_FEEDBACK;
$HOTPOT_FEEDBACK = array (
HOTPOT_FEEDBACK_NONE => get_string("feedbacknone", "hotpot"),
HOTPOT_FEEDBACK_WEBPAGE => get_string("feedbackwebpage", "hotpot"),
function hotpot_reset_course_form_defaults($course) {
return array('reset_hotpot_deleteallattempts' => 1);
}
-?>
default: return null;
}
}
-
-?>
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
case FEATURE_GRADE_HAS_GRADE: return true;
case FEATURE_GRADE_OUTCOMES: return true;
+ case FEATURE_MOD_SUBPLUGINS: return array('quiz'=>'mod/quiz/report');
default: return null;
}
$caps[] = 'moodle/site:accessallgroups';
return $caps;
}
-
}
$reports = $DB->get_records('quiz_report', null, 'displayorder DESC', 'name, capability');
- $reportdirs = get_list_of_plugins("mod/quiz/report");
+ $reportdirs = get_plugin_list("quiz");
//order the reports tab in descending order of displayorder
$reportcaps = array();
if ($reports){
}
//add any other reports on the end
- foreach ($reportdirs as $reportname) {
+ foreach ($reportdirs as $reportname => $reportdir) {
if (!isset($reportcaps[$reportname])) {
$reportcaps[$reportname]= null;
}
// First get a list of quiz reports with there own settings pages. If there none,
// we use a simpler overall menu structure.
$reportsbyname = array();
-if ($reports = get_list_of_plugins('mod/quiz/report')) {
- foreach ($reports as $report) {
- if (file_exists($CFG->dirroot . "/mod/quiz/report/$report/settings.php")) {
+if ($reports = get_plugin_list('quiz')) {
+ foreach ($reports as $report => $reportdir) {
+ if (file_exists("$reportdir/settings.php")) {
$strreportname = get_string($report . 'report', 'quiz_'.$report);
// Deal with reports which are lacking the language string
if ($strreportname[0] == '[') {
}
/// Drop-in extra resource types
- $resourcetypes = get_list_of_plugins('mod/resource/type');
- foreach ($resourcetypes as $resourcetype) {
+ $resourcetypes = get_plugin_list('resource');
+ foreach ($resourcetypes as $resourcetype => $dir) {
if (!empty($CFG->{'resource_hide_'.$resourcetype})) { // Not wanted
continue;
}
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
case FEATURE_GRADE_HAS_GRADE: return false;
case FEATURE_GRADE_OUTCOMES: return false;
+ case FEATURE_MOD_SUBPLUGINS: return array('resource'=>'mod/resource/type'); // to be removed in 2.0
default: return null;
}
}
return $name;
}
-
-?>
default: return null;
}
}
-
* Graph size
* @global int $SURVEY_GHEIGHT
*/
+global $SURVEY_GHEIGHT;
$SURVEY_GHEIGHT = 500;
/**
* Graph size
* @global int $SURVEY_GWIDTH
*/
+global $SURVEY_GWIDTH;
$SURVEY_GWIDTH = 900;
/**
* Question Type
* @global array $SURVEY_QTYPE
*/
+global $SURVEY_QTYPE;
$SURVEY_QTYPE = array (
"-3" => "Virtual Actual and Preferred",
"-2" => "Virtual Preferred",
default: return null;
}
-}
\ No newline at end of file
+}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-/** @global int $wiki_CONSTANT */
-$wiki_CONSTANT = 7; /// for example
-/** @global object $site */
-$site = get_site();
/** @global array $WIKI_TYPES */
+global $WIKI_TYPES;
$WIKI_TYPES = array ('teacher' => get_string('defaultcourseteacher'),
'group' => get_string('groups',"wiki"),
'student' => get_string('defaultcoursestudent') );
default: return null;
}
-}
\ No newline at end of file
+}
//Check name of module
if (!$isblog) {
- $mods = get_list_of_plugins('mod');
+ $mods = get_plugin_list('mod');
+ $mods = array_keys($mods);
if (!in_array(strtolower($modulename), $mods)) {
rss_not_found();
}
print_heading($strthemes);
- $themes = get_list_of_plugins("theme");
+ $themes = get_plugin_list("theme");
$sesskey = sesskey();
echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">\n";
$original_theme = fullclone($THEME);
- foreach ($themes as $theme) {
+ foreach ($themes as $theme => $themedir) {
unset($THEME);
- if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
+ if (!file_exists($themedir.'/config.php')) { // bad folder
continue;
}
- include($CFG->themedir.'/'.$theme.'/config.php');
+ include($themedir.'/config.php');
$readme = '';
$screenshot = '';
$mform->addRule('username', $strrequired, 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
- $modules = get_list_of_plugins('auth');
+ $auths = get_plugin_list('auth');
$auth_options = array();
- foreach ($modules as $module) {
- $auth_options[$module] = auth_get_plugin_title ($module);
+ foreach ($auths as $auth => $unused) {
+ $auth_options[$auth] = auth_get_plugin_title($auth);
}
$mform->addElement('select', 'auth', get_string('chooseauthmethod','auth'), $auth_options);
$mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod','auth')));
case 'lastaccess': return new user_filter_date('lastaccess', get_string('lastaccess'), $advanced, 'lastaccess');
case 'lastlogin': return new user_filter_date('lastlogin', get_string('lastlogin'), $advanced, 'lastlogin');
case 'auth':
- $plugins = get_list_of_plugins('auth');
+ $plugins = get_plugin_list('auth');
$choices = array();
- foreach ($plugins as $auth) {
+ foreach ($plugins as $auth => $unused) {
$choices[$auth] = auth_get_plugin_title ($auth);
}
return new user_filter_simpleselect('auth', get_string('authentication'), $advanced, 'auth', $choices);
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2009061600; // YYYYMMDD = date of the last version bump
+ $version = 2009061706; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20090619)'; // Human-friendly version name