mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'wip-MDL-35260-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
3c9b489820
14 changed files with 432 additions and 13 deletions
131
admin/courseformats.php
Normal file
131
admin/courseformats.php
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
<?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/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the admin to enable, disable and uninstall course formats
|
||||||
|
*
|
||||||
|
* @package core_admin
|
||||||
|
* @copyright 2012 Marina Glancy
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('../config.php');
|
||||||
|
require_once($CFG->libdir.'/adminlib.php');
|
||||||
|
require_once($CFG->libdir.'/pluginlib.php');
|
||||||
|
|
||||||
|
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||||
|
$formatname = required_param('format', PARAM_PLUGIN);
|
||||||
|
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||||
|
|
||||||
|
$syscontext = context_system::instance();
|
||||||
|
$PAGE->set_url('/admin/courseformats.php');
|
||||||
|
$PAGE->set_context($syscontext);
|
||||||
|
|
||||||
|
require_login();
|
||||||
|
require_capability('moodle/site:config', $syscontext);
|
||||||
|
require_sesskey();
|
||||||
|
|
||||||
|
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
|
||||||
|
|
||||||
|
$allplugins = plugin_manager::instance()->get_plugins();
|
||||||
|
$formatplugins = $allplugins['format'];
|
||||||
|
$sortorder = array_flip(array_keys($formatplugins));
|
||||||
|
|
||||||
|
if (!isset($formatplugins[$formatname])) {
|
||||||
|
print_error('courseformatnotfound', 'error', $return, $formatname);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($action) {
|
||||||
|
case 'disable':
|
||||||
|
if ($formatplugins[$formatname]->is_enabled()) {
|
||||||
|
if (get_config('moodlecourse', 'format') === $formatname) {
|
||||||
|
print_error('cannotdisableformat', 'error', $return);
|
||||||
|
}
|
||||||
|
set_config('disabled', 1, 'format_'. $formatname);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'enable':
|
||||||
|
if (!$formatplugins[$formatname]->is_enabled()) {
|
||||||
|
unset_config('disabled', 'format_'. $formatname);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'up':
|
||||||
|
if ($sortorder[$formatname]) {
|
||||||
|
$currentindex = $sortorder[$formatname];
|
||||||
|
$seq = array_keys($formatplugins);
|
||||||
|
$seq[$currentindex] = $seq[$currentindex-1];
|
||||||
|
$seq[$currentindex-1] = $formatname;
|
||||||
|
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'down':
|
||||||
|
if ($sortorder[$formatname] < count($sortorder)-1) {
|
||||||
|
$currentindex = $sortorder[$formatname];
|
||||||
|
$seq = array_keys($formatplugins);
|
||||||
|
$seq[$currentindex] = $seq[$currentindex+1];
|
||||||
|
$seq[$currentindex+1] = $formatname;
|
||||||
|
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'uninstall':
|
||||||
|
echo $OUTPUT->header();
|
||||||
|
echo $OUTPUT->heading(get_string('courseformats', 'moodle'));
|
||||||
|
|
||||||
|
$coursecount = $DB->count_records('course', array('format' => $formatname));
|
||||||
|
if ($coursecount) {
|
||||||
|
// Check that default format is set. It will be used to convert courses
|
||||||
|
// using this format
|
||||||
|
$defaultformat = get_config('moodlecourse', 'format');
|
||||||
|
$defaultformat = $formatplugins[get_config('moodlecourse', 'format')];
|
||||||
|
if (!$defaultformat) {
|
||||||
|
echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin'));
|
||||||
|
echo $OUTPUT->footer();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$format = $formatplugins[$formatname];
|
||||||
|
$deleteurl = $format->get_uninstall_url();
|
||||||
|
if (!$deleteurl) {
|
||||||
|
// somebody was trying to cheat and type non-existing link
|
||||||
|
echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname));
|
||||||
|
echo $OUTPUT->footer();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$confirm) {
|
||||||
|
if ($coursecount) {
|
||||||
|
$message = get_string('formatuninstallwithcourses', 'admin',
|
||||||
|
(object)array('count' => $coursecount, 'format' => $format->displayname,
|
||||||
|
'defaultformat' => $defaultformat->displayname));
|
||||||
|
} else {
|
||||||
|
$message = get_string('formatuninstallconfirm', 'admin', $format->displayname);
|
||||||
|
}
|
||||||
|
$deleteurl->param('confirm', 1);
|
||||||
|
echo $OUTPUT->confirm($message, $deleteurl, $return);
|
||||||
|
} else {
|
||||||
|
$a = new stdClass();
|
||||||
|
$a->plugin = $format->displayname;
|
||||||
|
$a->directory = $format->rootdir;
|
||||||
|
uninstall_plugin('format', $formatname);
|
||||||
|
echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess');
|
||||||
|
echo $OUTPUT->continue_button($return);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $OUTPUT->footer();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
redirect($return);
|
|
@ -15,9 +15,10 @@ if ($hassiteconfig
|
||||||
/// NOTE: these settings must be applied after all other settings because they depend on them
|
/// NOTE: these settings must be applied after all other settings because they depend on them
|
||||||
///main course settings
|
///main course settings
|
||||||
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
|
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
|
||||||
$courseformats = get_plugin_list('format');
|
require_once($CFG->dirroot.'/course/lib.php');
|
||||||
|
$courseformats = get_sorted_course_formats(true);
|
||||||
$formcourseformats = array();
|
$formcourseformats = array();
|
||||||
foreach ($courseformats as $courseformat => $courseformatdir) {
|
foreach ($courseformats as $courseformat) {
|
||||||
$formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
|
$formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
|
||||||
}
|
}
|
||||||
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks',$formcourseformats));
|
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks',$formcourseformats));
|
||||||
|
|
|
@ -20,6 +20,15 @@ if ($hassiteconfig) {
|
||||||
// hidden script for converting journals to online assignments (or something like that) linked from elsewhere
|
// hidden script for converting journals to online assignments (or something like that) linked from elsewhere
|
||||||
$ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
|
$ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
|
||||||
|
|
||||||
|
// course formats
|
||||||
|
$ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
|
||||||
|
$temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
|
||||||
|
$temp->add(new admin_setting_manageformats());
|
||||||
|
$ADMIN->add('formatsettings', $temp);
|
||||||
|
foreach ($allplugins['format'] as $format) {
|
||||||
|
$format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
|
||||||
|
}
|
||||||
|
|
||||||
// blocks
|
// blocks
|
||||||
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
|
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
|
||||||
$ADMIN->add('blocksettings', new admin_page_manageblocks());
|
$ADMIN->add('blocksettings', new admin_page_manageblocks());
|
||||||
|
|
|
@ -113,11 +113,20 @@ class course_edit_form extends moodleform {
|
||||||
$mform->hardFreeze('summary_editor');
|
$mform->hardFreeze('summary_editor');
|
||||||
}
|
}
|
||||||
|
|
||||||
$courseformats = get_plugin_list('format');
|
$courseformats = get_sorted_course_formats(true);
|
||||||
$formcourseformats = array();
|
$formcourseformats = array();
|
||||||
foreach ($courseformats as $courseformat => $formatdir) {
|
foreach ($courseformats as $courseformat) {
|
||||||
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
|
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
|
||||||
}
|
}
|
||||||
|
if (isset($course->format)) {
|
||||||
|
$course->format = course_get_format($course)->get_format(); // replace with default if not found
|
||||||
|
if (!in_array($course->format, $courseformats)) {
|
||||||
|
// this format is disabled. Still display it in the dropdown
|
||||||
|
$formcourseformats[$course->format] = get_string('withdisablednote', 'moodle',
|
||||||
|
get_string('pluginname', 'format_'.$course->format));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('select', 'format', get_string('format'), $formcourseformats);
|
$mform->addElement('select', 'format', get_string('format'), $formcourseformats);
|
||||||
$mform->addHelpButton('format', 'format');
|
$mform->addHelpButton('format', 'format');
|
||||||
$mform->setDefault('format', $courseconfig->format);
|
$mform->setDefault('format', $courseconfig->format);
|
||||||
|
|
|
@ -339,9 +339,21 @@ class format_legacy extends format_base {
|
||||||
if ($oldcourse !== null) {
|
if ($oldcourse !== null) {
|
||||||
$data = (array)$data;
|
$data = (array)$data;
|
||||||
$oldcourse = (array)$oldcourse;
|
$oldcourse = (array)$oldcourse;
|
||||||
foreach ($this->course_format_options() as $key => $unused) {
|
$options = $this->course_format_options();
|
||||||
if (array_key_exists($key, $oldcourse) && !array_key_exists($key, $data)) {
|
foreach ($options as $key => $unused) {
|
||||||
$data[$key] = $oldcourse[$key];
|
if (!array_key_exists($key, $data)) {
|
||||||
|
if (array_key_exists($key, $oldcourse)) {
|
||||||
|
$data[$key] = $oldcourse[$key];
|
||||||
|
} else if ($key === 'numsections') {
|
||||||
|
// If previous format does not have the field 'numsections' and this one does,
|
||||||
|
// and $data['numsections'] is not set fill it with the maximum section number from the DB
|
||||||
|
$maxsection = $DB->get_field_sql('SELECT max(section) from {course_sections}
|
||||||
|
WHERE course = ?', array($this->courseid));
|
||||||
|
if ($maxsection) {
|
||||||
|
// If there are no sections, or just default 0-section, 'numsections' will be set to default
|
||||||
|
$data['numsections'] = $maxsection;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,13 +97,21 @@ abstract class format_base {
|
||||||
if ($format === 'site') {
|
if ($format === 'site') {
|
||||||
return $format;
|
return $format;
|
||||||
}
|
}
|
||||||
$plugins = get_plugin_list('format'); // TODO MDL-35260 filter only enabled
|
$plugins = get_sorted_course_formats();
|
||||||
if (isset($plugins[$format])) {
|
if (in_array($format, $plugins)) {
|
||||||
return $format;
|
return $format;
|
||||||
}
|
}
|
||||||
// Else return default format
|
// Else return default format
|
||||||
$defaultformat = reset($plugins); // TODO MDL-35260 get default format from config
|
$defaultformat = get_config('moodlecourse', 'format');
|
||||||
debugging('Format plugin format_'.$format.' is not found or is not enabled. Using default format_'.$defaultformat, DEBUG_DEVELOPER);
|
if (!in_array($defaultformat, $plugins)) {
|
||||||
|
// when default format is not set correctly, use the first available format
|
||||||
|
$defaultformat = reset($plugins);
|
||||||
|
}
|
||||||
|
static $warningprinted = array();
|
||||||
|
if (empty($warningprinted[$format])) {
|
||||||
|
debugging('Format plugin format_'.$format.' is not found. Using default format_'.$defaultformat, DEBUG_DEVELOPER);
|
||||||
|
$warningprinted[$format] = true;
|
||||||
|
}
|
||||||
return $defaultformat;
|
return $defaultformat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ format.
|
||||||
functions callback_XXXX_request_key() are no longer used (where XXXX is the course format name)
|
functions callback_XXXX_request_key() are no longer used (where XXXX is the course format name)
|
||||||
* functions get_generic_section_name(), get_all_sections(), add_mod_to_section(), get_all_mods()
|
* functions get_generic_section_name(), get_all_sections(), add_mod_to_section(), get_all_mods()
|
||||||
are deprecated. See their phpdocs in lib/deprecatedlib.php on how to replace them
|
are deprecated. See their phpdocs in lib/deprecatedlib.php on how to replace them
|
||||||
|
* Course formats may now have their settings.php file as the most of other plugin types
|
||||||
|
|
||||||
=== 2.3 ===
|
=== 2.3 ===
|
||||||
|
|
||||||
|
|
|
@ -4512,6 +4512,35 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the sorted list of available course formats, filtered by enabled if necessary
|
||||||
|
*
|
||||||
|
* @param bool $enabledonly return only formats that are enabled
|
||||||
|
* @return array array of sorted format names
|
||||||
|
*/
|
||||||
|
function get_sorted_course_formats($enabledonly = false) {
|
||||||
|
global $CFG;
|
||||||
|
$formats = get_plugin_list('format');
|
||||||
|
|
||||||
|
if (!empty($CFG->format_plugins_sortorder)) {
|
||||||
|
$order = explode(',', $CFG->format_plugins_sortorder);
|
||||||
|
$order = array_merge(array_intersect($order, array_keys($formats)),
|
||||||
|
array_diff(array_keys($formats), $order));
|
||||||
|
} else {
|
||||||
|
$order = array_keys($formats);
|
||||||
|
}
|
||||||
|
if (!$enabledonly) {
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
$sortedformats = array();
|
||||||
|
foreach ($order as $formatname) {
|
||||||
|
if (!get_config('format_'.$formatname, 'disabled')) {
|
||||||
|
$sortedformats[] = $formatname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $sortedformats;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to use for the specified course (with section)
|
* The URL to use for the specified course (with section)
|
||||||
*
|
*
|
||||||
|
|
|
@ -95,6 +95,7 @@ $string['calendarexportsalt'] = 'Calendar export salt';
|
||||||
$string['calendarsettings'] = 'Calendar';
|
$string['calendarsettings'] = 'Calendar';
|
||||||
$string['calendar_weekend'] = 'Weekend days';
|
$string['calendar_weekend'] = 'Weekend days';
|
||||||
$string['cannotdeletemodfilter'] = 'You cannot uninstall the \'{$a->filter}\' because it is part of the \'{$a->module}\' module.';
|
$string['cannotdeletemodfilter'] = 'You cannot uninstall the \'{$a->filter}\' because it is part of the \'{$a->module}\' module.';
|
||||||
|
$string['cannotuninstall'] = '{$a} can not be uninstalled.';
|
||||||
$string['cfgwwwrootslashwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. You have included a \'/\' character at the end. Please remove it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
|
$string['cfgwwwrootslashwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. You have included a \'/\' character at the end. Please remove it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
|
||||||
$string['cfgwwwrootwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. It does not match the URL you are using to access this page. Please correct it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
|
$string['cfgwwwrootwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. It does not match the URL you are using to access this page. Please correct it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
|
||||||
$string['clamfailureonupload'] = 'On clam AV failure';
|
$string['clamfailureonupload'] = 'On clam AV failure';
|
||||||
|
@ -417,6 +418,7 @@ $string['debugstringids_desc'] = 'This option is designed to help translators. W
|
||||||
$string['debugvalidators'] = 'Show validator links';
|
$string['debugvalidators'] = 'Show validator links';
|
||||||
$string['defaultcity'] = 'Default city';
|
$string['defaultcity'] = 'Default city';
|
||||||
$string['defaultcity_help'] = 'A city entered here will be the default city when creating new user accounts.';
|
$string['defaultcity_help'] = 'A city entered here will be the default city when creating new user accounts.';
|
||||||
|
$string['defaultformatnotset'] = 'Error determining default course format. Please check site settings.';
|
||||||
$string['defaulthomepage'] = 'Default home page for users';
|
$string['defaulthomepage'] = 'Default home page for users';
|
||||||
$string['defaultrequestcategory'] = 'Default category for course requests';
|
$string['defaultrequestcategory'] = 'Default category for course requests';
|
||||||
$string['defaultsettinginfo'] = 'Default: {$a}';
|
$string['defaultsettinginfo'] = 'Default: {$a}';
|
||||||
|
@ -533,6 +535,9 @@ $string['forceloginforprofileimage'] = 'Force users to login to view user pictur
|
||||||
$string['forceloginforprofileimage_help'] = 'If enabled, users must login in order to view user profile pictures and the default user picture will be used in all notification emails.';
|
$string['forceloginforprofileimage_help'] = 'If enabled, users must login in order to view user profile pictures and the default user picture will be used in all notification emails.';
|
||||||
$string['forceloginforprofiles'] = 'Force users to login for profiles';
|
$string['forceloginforprofiles'] = 'Force users to login for profiles';
|
||||||
$string['forcetimezone'] = 'Force default timezone';
|
$string['forcetimezone'] = 'Force default timezone';
|
||||||
|
$string['formatuninstallwithcourses'] = 'There are {$a->count} courses using {$a->format}. Their format will be changed to {$a->defaultformat} (default format for this site). Some format-specific data may be lost. Are you sure you want to proceed?';
|
||||||
|
$string['formatuninstallconfirm'] = '{$a} will be uninstalled. No courses currently use it. Continue?';
|
||||||
|
$string['formatuninstalled'] = 'All data associated with the format plugin \'{$a->plugin}\' has been deleted from the database. To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||||
$string['frontpage'] = 'Front page';
|
$string['frontpage'] = 'Front page';
|
||||||
$string['frontpagebackup'] = 'Front page backup';
|
$string['frontpagebackup'] = 'Front page backup';
|
||||||
$string['frontpagedefaultrole'] = 'Default frontpage role';
|
$string['frontpagedefaultrole'] = 'Default frontpage role';
|
||||||
|
@ -641,6 +646,8 @@ $string['longtimewarning'] = '<b>Please note that this process can take a long t
|
||||||
$string['maintenancemode'] = 'In maintenance mode';
|
$string['maintenancemode'] = 'In maintenance mode';
|
||||||
$string['maintfileopenerror'] = 'Error opening maintenance files!';
|
$string['maintfileopenerror'] = 'Error opening maintenance files!';
|
||||||
$string['maintinprogress'] = 'Maintenance is in progress...';
|
$string['maintinprogress'] = 'Maintenance is in progress...';
|
||||||
|
$string['manageformats'] = 'Manage course formats';
|
||||||
|
$string['manageformatsgotosettings'] = 'Default format can be changed in {$a}';
|
||||||
$string['managelang'] = 'Manage';
|
$string['managelang'] = 'Manage';
|
||||||
$string['managelicenses'] = 'Manage licences';
|
$string['managelicenses'] = 'Manage licences';
|
||||||
$string['manageqbehaviours'] = 'Manage question behaviours';
|
$string['manageqbehaviours'] = 'Manage question behaviours';
|
||||||
|
|
|
@ -65,6 +65,7 @@ $string['cannotdeletefile'] = 'Cannot delete this file';
|
||||||
$string['cannotdeleterole'] = 'It cannot be deleted, because {$a}';
|
$string['cannotdeleterole'] = 'It cannot be deleted, because {$a}';
|
||||||
$string['cannotdeleterolewithid'] = 'Could not delete role with ID {$a}';
|
$string['cannotdeleterolewithid'] = 'Could not delete role with ID {$a}';
|
||||||
$string['cannotdeletethisrole'] = 'You cannot delete this role because it is used by the system, or because it is the last role with administrator capabilities.';
|
$string['cannotdeletethisrole'] = 'You cannot delete this role because it is used by the system, or because it is the last role with administrator capabilities.';
|
||||||
|
$string['cannotdisableformat'] = 'You can not disable the default format';
|
||||||
$string['cannotdownloadcomponents'] = 'Cannot download components';
|
$string['cannotdownloadcomponents'] = 'Cannot download components';
|
||||||
$string['cannotdownloadlanguageupdatelist'] = 'Cannot download list of language updates from download.moodle.org';
|
$string['cannotdownloadlanguageupdatelist'] = 'Cannot download list of language updates from download.moodle.org';
|
||||||
$string['cannotdownloadzipfile'] = 'Cannot download ZIP file';
|
$string['cannotdownloadzipfile'] = 'Cannot download ZIP file';
|
||||||
|
|
|
@ -297,7 +297,7 @@ $string['coursecompletions'] = 'Course completions';
|
||||||
$string['coursecreators'] = 'Course creator';
|
$string['coursecreators'] = 'Course creator';
|
||||||
$string['coursecreatorsdescription'] = 'Course creators can create new courses.';
|
$string['coursecreatorsdescription'] = 'Course creators can create new courses.';
|
||||||
$string['coursedisplay'] = 'Course layout';
|
$string['coursedisplay'] = 'Course layout';
|
||||||
$string['coursedisplay_help'] = 'This setting determines whether the whole course is displayed on one page or split over several pages. The setting has no affect on certain course formats, such as SCORM format.';
|
$string['coursedisplay_help'] = 'This setting determines whether the whole course is displayed on one page or split over several pages.';
|
||||||
$string['coursedisplay_single'] = 'Show all sections on one page';
|
$string['coursedisplay_single'] = 'Show all sections on one page';
|
||||||
$string['coursedisplay_multi'] = 'Show one section per page';
|
$string['coursedisplay_multi'] = 'Show one section per page';
|
||||||
$string['coursedeleted'] = 'Deleted course {$a}';
|
$string['coursedeleted'] = 'Deleted course {$a}';
|
||||||
|
@ -1805,6 +1805,7 @@ $string['whattocallzip'] = 'What do you want to call the zip file?';
|
||||||
$string['whattodo'] = 'What to do';
|
$string['whattodo'] = 'What to do';
|
||||||
$string['windowclosing'] = 'This window should close automatically. If not, please close it now.';
|
$string['windowclosing'] = 'This window should close automatically. If not, please close it now.';
|
||||||
$string['withchosenfiles'] = 'With chosen files';
|
$string['withchosenfiles'] = 'With chosen files';
|
||||||
|
$string['withdisablednote'] = '{$a} (disabled)';
|
||||||
$string['withoutuserdata'] = 'without user data';
|
$string['withoutuserdata'] = 'without user data';
|
||||||
$string['withselectedusers'] = 'With selected users...';
|
$string['withselectedusers'] = 'With selected users...';
|
||||||
$string['withselectedusers_help'] = '* Send message - For sending a message to one or more participants
|
$string['withselectedusers_help'] = '* Send message - For sending a message to one or more participants
|
||||||
|
|
151
lib/adminlib.php
151
lib/adminlib.php
|
@ -266,6 +266,16 @@ function uninstall_plugin($type, $name) {
|
||||||
// Delete block
|
// Delete block
|
||||||
$DB->delete_records('block', array('id'=>$block->id));
|
$DB->delete_records('block', array('id'=>$block->id));
|
||||||
}
|
}
|
||||||
|
} else if ($type === 'format') {
|
||||||
|
if (($defaultformat = get_config('moodlecourse', 'format')) && $defaultformat !== $name) {
|
||||||
|
$courses = $DB->get_records('course', array('format' => $name), 'id');
|
||||||
|
$data = (object)array('id' => null, 'format' => $defaultformat);
|
||||||
|
foreach ($courses as $record) {
|
||||||
|
$data->id = $record->id;
|
||||||
|
update_course($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$DB->delete_records('course_format_options', array('format' => $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform clean-up task common for all the plugin/subplugin types
|
// perform clean-up task common for all the plugin/subplugin types
|
||||||
|
@ -5897,6 +5907,147 @@ class admin_setting_managelicenses extends admin_setting {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Course formats manager. Allows to enable/disable formats and jump to settings
|
||||||
|
*/
|
||||||
|
class admin_setting_manageformats extends admin_setting {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls parent::__construct with specific arguments
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->nosave = true;
|
||||||
|
parent::__construct('formatsui', new lang_string('manageformats', 'core_admin'), '', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always returns true
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
public function get_setting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always returns true
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
public function get_defaultsetting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always returns '' and doesn't write anything
|
||||||
|
*
|
||||||
|
* @param mixed $data string or array, must not be NULL
|
||||||
|
* @return string Always returns ''
|
||||||
|
*/
|
||||||
|
public function write_setting($data) {
|
||||||
|
// do not write any setting
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search to find if Query is related to format plugin
|
||||||
|
*
|
||||||
|
* @param string $query The string to search for
|
||||||
|
* @return bool true for related false for not
|
||||||
|
*/
|
||||||
|
public function is_related($query) {
|
||||||
|
if (parent::is_related($query)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$allplugins = plugin_manager::instance()->get_plugins();
|
||||||
|
$formats = $allplugins['format'];
|
||||||
|
foreach ($formats as $format) {
|
||||||
|
if (strpos($format->component, $query) !== false ||
|
||||||
|
strpos(textlib::strtolower($format->displayname), $query) !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return XHTML to display control
|
||||||
|
*
|
||||||
|
* @param mixed $data Unused
|
||||||
|
* @param string $query
|
||||||
|
* @return string highlight
|
||||||
|
*/
|
||||||
|
public function output_html($data, $query='') {
|
||||||
|
global $CFG, $OUTPUT;
|
||||||
|
$return = '';
|
||||||
|
$return = $OUTPUT->heading(new lang_string('courseformats'), 3, 'main');
|
||||||
|
$return .= $OUTPUT->box_start('generalbox formatsui');
|
||||||
|
|
||||||
|
$allplugins = plugin_manager::instance()->get_plugins();
|
||||||
|
$formats = $allplugins['format'];
|
||||||
|
|
||||||
|
// display strings
|
||||||
|
$txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default', 'delete'));
|
||||||
|
$txt->updown = "$txt->up/$txt->down";
|
||||||
|
|
||||||
|
$table = new html_table();
|
||||||
|
$table->head = array($txt->name, $txt->enable, $txt->updown, $txt->delete, $txt->settings);
|
||||||
|
$table->align = array('left', 'center', 'center', 'center', 'center');
|
||||||
|
$table->width = '90%';
|
||||||
|
$table->attributes['class'] = 'manageformattable generaltable';
|
||||||
|
$table->data = array();
|
||||||
|
|
||||||
|
$cnt = 0;
|
||||||
|
$defaultformat = get_config('moodlecourse', 'format');
|
||||||
|
$spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'icon'));
|
||||||
|
foreach ($formats as $format) {
|
||||||
|
$url = new moodle_url('/admin/courseformats.php',
|
||||||
|
array('sesskey' => sesskey(), 'format' => $format->name));
|
||||||
|
$isdefault = '';
|
||||||
|
if ($format->is_enabled()) {
|
||||||
|
$strformatname = html_writer::tag('span', $format->displayname);
|
||||||
|
if ($defaultformat === $format->name) {
|
||||||
|
$hideshow = $txt->default;
|
||||||
|
} else {
|
||||||
|
$hideshow = html_writer::link($url->out(false, array('action' => 'disable')),
|
||||||
|
$OUTPUT->pix_icon('i/hide', $txt->disable, 'moodle', array('class' => 'icon')));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$strformatname = html_writer::tag('span', $format->displayname, array('class' => 'dimmed_text'));
|
||||||
|
$hideshow = html_writer::link($url->out(false, array('action' => 'enable')),
|
||||||
|
$OUTPUT->pix_icon('i/show', $txt->enable, 'moodle', array('class' => 'icon')));
|
||||||
|
}
|
||||||
|
$updown = '';
|
||||||
|
if ($cnt) {
|
||||||
|
$updown .= html_writer::link($url->out(false, array('action' => 'up')),
|
||||||
|
$OUTPUT->pix_icon('t/up', $txt->up, 'moodle')). ' ';
|
||||||
|
} else {
|
||||||
|
$updown .= $spacer;
|
||||||
|
}
|
||||||
|
if ($cnt < count($formats) - 1) {
|
||||||
|
$updown .= ' '.html_writer::link($url->out(false, array('action' => 'down')),
|
||||||
|
$OUTPUT->pix_icon('t/down', $txt->down, 'moodle'));
|
||||||
|
} else {
|
||||||
|
$updown .= $spacer;
|
||||||
|
}
|
||||||
|
$cnt++;
|
||||||
|
$settings = '';
|
||||||
|
if ($format->get_settings_url()) {
|
||||||
|
$settings = html_writer::link($format->get_settings_url(), $txt->settings);
|
||||||
|
}
|
||||||
|
$uninstall = '';
|
||||||
|
if ($defaultformat !== $format->name) {
|
||||||
|
$uninstall = html_writer::link($format->get_uninstall_url(), $txt->delete);
|
||||||
|
}
|
||||||
|
$table->data[] =array($strformatname, $hideshow, $updown, $uninstall, $settings);
|
||||||
|
}
|
||||||
|
$return .= html_writer::table($table);
|
||||||
|
$link = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'coursesettings')), new lang_string('coursesettings'));
|
||||||
|
$return .= html_writer::tag('p', get_string('manageformatsgotosettings', 'admin', $link));
|
||||||
|
$return .= $OUTPUT->box_end();
|
||||||
|
return highlight($query, $return);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special class for filter administration.
|
* Special class for filter administration.
|
||||||
|
|
|
@ -4572,7 +4572,8 @@ function delete_course($courseorid, $showfeedback = true) {
|
||||||
// which should know about this updated property, as this event is meant to pass the full course record
|
// which should know about this updated property, as this event is meant to pass the full course record
|
||||||
$course->timemodified = time();
|
$course->timemodified = time();
|
||||||
|
|
||||||
$DB->delete_records("course", array("id"=>$courseid));
|
$DB->delete_records("course", array("id" => $courseid));
|
||||||
|
$DB->delete_records("course_format_options", array("courseid" => $courseid));
|
||||||
|
|
||||||
//trigger events
|
//trigger events
|
||||||
$course->context = $context; // you can not fetch context in the event because it was already deleted
|
$course->context = $context; // you can not fetch context in the event because it was already deleted
|
||||||
|
|
|
@ -3362,3 +3362,61 @@ class plugininfo_webservice extends plugininfo_base {
|
||||||
array('sesskey' => sesskey(), 'action' => 'uninstall', 'webservice' => $this->name));
|
array('sesskey' => sesskey(), 'action' => 'uninstall', 'webservice' => $this->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for course formats
|
||||||
|
*/
|
||||||
|
class plugininfo_format extends plugininfo_base {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gathers and returns the information about all plugins of the given type
|
||||||
|
*
|
||||||
|
* @param string $type the name of the plugintype, eg. mod, auth or workshopform
|
||||||
|
* @param string $typerootdir full path to the location of the plugin dir
|
||||||
|
* @param string $typeclass the name of the actually called class
|
||||||
|
* @return array of plugintype classes, indexed by the plugin name
|
||||||
|
*/
|
||||||
|
public static function get_plugins($type, $typerootdir, $typeclass) {
|
||||||
|
global $CFG;
|
||||||
|
$formats = parent::get_plugins($type, $typerootdir, $typeclass);
|
||||||
|
require_once($CFG->dirroot.'/course/lib.php');
|
||||||
|
$order = get_sorted_course_formats();
|
||||||
|
$sortedformats = array();
|
||||||
|
foreach ($order as $formatname) {
|
||||||
|
$sortedformats[$formatname] = $formats[$formatname];
|
||||||
|
}
|
||||||
|
return $sortedformats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_settings_section_name() {
|
||||||
|
return 'formatsetting' . $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
|
||||||
|
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // in case settings.php wants to refer to them
|
||||||
|
$ADMIN = $adminroot; // also may be used in settings.php
|
||||||
|
$section = $this->get_settings_section_name();
|
||||||
|
|
||||||
|
$settings = null;
|
||||||
|
if ($hassiteconfig && file_exists($this->full_path('settings.php'))) {
|
||||||
|
$settings = new admin_settingpage($section, $this->displayname,
|
||||||
|
'moodle/site:config', $this->is_enabled() === false);
|
||||||
|
include($this->full_path('settings.php')); // this may also set $settings to null
|
||||||
|
}
|
||||||
|
if ($settings) {
|
||||||
|
$ADMIN->add($parentnodename, $settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_enabled() {
|
||||||
|
return !get_config($this->component, 'disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_uninstall_url() {
|
||||||
|
if ($this->name !== get_config('moodlecourse', 'format') && $this->name !== 'site') {
|
||||||
|
return new moodle_url('/admin/courseformats.php',
|
||||||
|
array('sesskey' => sesskey(), 'action' => 'uninstall', 'format' => $this->name));
|
||||||
|
}
|
||||||
|
return parent::get_uninstall_url();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue