require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
require_login();
require_capability('moodle/site:config', context_system::instance());
set_config('registerauth', '');
}
\core\session\manager::gc(); // Remove stale sessions.
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
break;
case 'enable':
set_config('auth', implode(',', $authsenabled));
}
\core\session\manager::gc(); // Remove stale sessions.
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
break;
case 'down':
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
- require_once($CFG->libdir.'/pluginlib.php');
admin_externalpage_setup('manageblocks');
print_error('blockdoesnotexist', 'error');
}
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages
}
print_error('blockdoesnotexist', 'error');
}
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages
}
$table = new flexible_table('admin-blocks-compatible');
- $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'uninstall', 'settings'));
- $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $struninstall, $strsettings));
+ $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
+ $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strsettings, $struninstall));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'admintable blockstable generaltable');
$table->set_attribute('id', 'compatibleblockstable');
}
}
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$blockname, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
} else {
$uninstall = '';
} else {
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.sesskey().'" title="'.$strshow.'">'.
'<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a>';
- $class = ' class="dimmed_text"'; // Leading space required!
+ $class = 'dimmed_text';
}
if ($dbversion == $plugin->version) {
}
$row = array(
- '<span'.$class.'>'.$strblockname.'</span>',
+ $strblockname,
$blocklist,
- '<span'.$class.'>'.$version.'</span>',
+ $version,
$visible,
$undeletable,
+ $settings,
$uninstall,
- $settings
);
- $table->add_data($row);
+ $table->add_data($row, $class);
}
$table->print_html();
$table->setup();
foreach ($incompatible as $block) {
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$block->name, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
} else {
$uninstall = '';
}
// Test plugin dependencies.
-require_once($CFG->libdir . '/pluginlib.php');
$failed = array();
-if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
cli_error(get_string('pluginschecktodo', 'admin'));
}
}
// Test plugin dependencies.
-require_once($CFG->libdir . '/pluginlib.php');
$failed = array();
-if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
cli_error(get_string('pluginschecktodo', 'admin'));
}
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
require_once($CFG->libdir.'/clilib.php'); // cli only functions
require_once($CFG->libdir.'/environmentlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
// now get cli options
list($options, $unrecognized) = cli_get_params(
// Test plugin dependencies.
$failed = array();
-if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
cli_error(get_string('pluginschecktodo', 'admin'));
}
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);
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
-$formatplugins = plugin_manager::instance()->get_plugins_of_type('format');
+$formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
$sortorder = array_flip(array_keys($formatplugins));
if (!isset($formatplugins[$formatname])) {
print_error('cannotdisableformat', 'error', $return);
}
set_config('disabled', 1, 'format_'. $formatname);
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
}
break;
case 'enable':
if (!$formatplugins[$formatname]->is_enabled()) {
unset_config('disabled', 'format_'. $formatname);
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
}
break;
case 'up':
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
$action = required_param('action', PARAM_ALPHANUMEXT);
$editor = required_param('editor', PARAM_PLUGIN);
}
set_config('texteditors', implode(',', $active_editors));
-plugin_manager::reset_caches();
+core_plugin_manager::reset_caches();
if ($return) {
redirect ($returnurl);
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
$action = required_param('action', PARAM_ALPHANUMEXT);
$enrol = required_param('enrol', PARAM_PLUGIN);
case 'disable':
unset($enabled[$enrol]);
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$syscontext->mark_dirty(); // resets all enrol caches
break;
$enabled = array_keys($enabled);
$enabled[] = $enrol;
set_config('enrol_plugins_enabled', implode(',', $enabled));
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$syscontext->mark_dirty(); // resets all enrol caches
break;
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
- if (!$return = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) {
+ if (!$return = core_plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol, 'manage')) {
$return = new moodle_url('/admin/plugins.php');
}
echo $OUTPUT->continue_button($return);
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/adminlib.php');
- require_once($CFG->libdir . '/pluginlib.php');
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
$filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
// Reset caches and return
if ($action) {
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
reset_text_filters_cache();
redirect($returnurl);
}
$table = new html_table();
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
- get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
+ get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
$table->attributes['class'] = 'admintable generaltable';
$table->id = 'filterssetting';
function filters_action_url($filterpath, $action) {
if ($action === 'delete') {
- return new moodle_url('/admin/plugins.php', array('sesskey'=>sesskey(), 'uninstall'=>'filter_'.$filterpath));
+ return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
}
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
}
}
// Delete
- $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
+ $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('uninstallplugin', 'core_admin') . '</a>';
return $row;
}
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
-require_once($CFG->libdir.'/pluginlib.php'); // available updates notifications
$id = optional_param('id', '', PARAM_TEXT);
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
// check plugin dependencies
$failed = array();
- if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+ if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
$PAGE->set_title($strinstallation);
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
// check plugin dependencies first
$failed = array();
- if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+ if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
die();
}
if ($fetchupdates) {
// no sesskey support guaranteed here
if (empty($CFG->disableupdatenotifications)) {
- available_update_checker::instance()->fetch();
+ \core\update\checker::instance()->fetch();
}
redirect($reloadurl);
}
- $deployer = available_update_deployer::instance();
+ $deployer = \core\update\deployer::instance();
if ($deployer->enabled()) {
$deployer->initialize($reloadurl, $reloadurl);
}
}
- echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
+ echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
$version, $showallplugins, $reloadurl,
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
die();
if ($fetchupdates) {
// no sesskey support guaranteed here
- available_update_checker::instance()->fetch();
+ \core\update\checker::instance()->fetch();
redirect($PAGE->url);
}
$output = $PAGE->get_renderer('core', 'admin');
- $deployer = available_update_deployer::instance();
+ $deployer = \core\update\deployer::instance();
if ($deployer->enabled()) {
$deployer->initialize($PAGE->url, $PAGE->url);
// check plugin dependencies first
$failed = array();
- if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+ if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
die();
}
unset($failed);
// dependencies check passed, let's rock!
- echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
+ echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
$version, $showallplugins,
new moodle_url($PAGE->url),
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
redirect('upgradesettings.php');
}
+// Return to original page that started the plugin uninstallation if necessary.
+if (isset($SESSION->pluginuninstallreturn)) {
+ $return = $SESSION->pluginuninstallreturn;
+ unset($SESSION->pluginuninstallreturn);
+ if ($return) {
+ redirect($return);
+ }
+}
+
// Everything should now be set up, and the user is an admin
// Print default admin page with notifications.
$maintenancemode = !empty($CFG->maintenance_enabled);
// Available updates for Moodle core
-$updateschecker = available_update_checker::instance();
+$updateschecker = \core\update\checker::instance();
$availableupdates = array();
$availableupdates['core'] = $updateschecker->get_update_info('core',
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
// Available updates for contributed plugins
-$pluginman = plugin_manager::instance();
+$pluginman = core_plugin_manager::instance();
foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
foreach ($plugintypeinstances as $pluginname => $plugininfo) {
if (!empty($plugininfo->availableupdates)) {
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
admin_externalpage_setup('managelocalplugins');
foreach ($plugins as $plugin => $name) {
$uninstall = '';
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('local_'.$plugin)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('local_'.$plugin, 'manage')) {
$uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
}
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot . '/message/lib.php');
require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
// This is an admin page
admin_externalpage_setup('managemessageoutputs');
print_error('outputdoesnotexist', 'message');
}
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
}
if (!empty($enable) && confirm_sesskey()) {
print_error('outputdoesnotexist', 'message');
}
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
}
if ($disable || $enable) {
require_once('../course/lib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
- require_once($CFG->libdir.'/pluginlib.php');
// defines
define('MODULE_TABLE','module_administration_table');
FROM {course_modules}
WHERE visibleold=1 AND module=?)",
array($module->id));
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages
}
FROM {course_modules}
WHERE visible=1 AND module=?)",
array($module->id));
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages
}
// construct the flexible table ready to display
$table = new flexible_table(MODULE_TABLE);
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'uninstall', 'settings'));
- $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $struninstall, $strsettings));
+ $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strsettings, $struninstall));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
$table->set_attribute('id', 'modules');
- $table->set_attribute('class', 'generaltable');
+ $table->set_attribute('class', 'admintable generaltable');
$table->setup();
foreach ($modules as $module) {
}
$uninstall = '';
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('mod_'.$module->name)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('mod_'.$module->name, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
}
} else {
$visible = "<a href=\"modules.php?show=$module->name&sesskey=".sesskey()."\" title=\"$strshow\">".
"<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"$strshow\" /></a>";
- $class = ' class="dimmed_text"';
+ $class = 'dimmed_text';
}
if ($module->name == "forum") {
$uninstall = "";
$version = get_config('mod_'.$module->name, 'version');
$table->add_data(array(
- '<span'.$class.'>'.$strmodulename.'</span>',
+ $strmodulename,
$countlink,
- '<span'.$class.'>'.$version.'</span>',
+ $version,
$visible,
+ $settings,
$uninstall,
- $settings
- ));
+ ), $class);
}
$table->print_html();
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
admin_externalpage_setup('manageplagiarismplugins');
}
// uninstall link.
$uninstall = '';
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $txt->uninstall);
}
$table->data[] = array($displayname, $version, $uninstall, $settings);
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/filelib.php');
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
$updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
$contribonly = optional_param('contribonly', false, PARAM_BOOL);
-$uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
-$delete = optional_param('delete', '', PARAM_COMPONENT);
-$confirmed = optional_param('confirm', false, PARAM_BOOL);
+$uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
+$delete = optional_param('delete', '', PARAM_COMPONENT);
+$confirmed = optional_param('confirm', false, PARAM_BOOL);
+$return = optional_param('return', 'overview', PARAM_ALPHA);
// NOTE: do not use admin_externalpage_setup() here because it loads
// full admin tree which is not possible during uninstallation.
$syscontext = context_system::instance();
require_capability('moodle/site:config', $syscontext);
-$pluginman = plugin_manager::instance();
+$pluginman = core_plugin_manager::instance();
if ($uninstall) {
require_sesskey();
// Make sure we know the plugin.
if (is_null($pluginfo)) {
throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $uninstall),
- 'plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
+ 'core_plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
}
$pluginname = $pluginman->plugin_name($pluginfo->component);
if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '',
array('plugin' => $pluginfo->component),
- 'plugin_manager::can_uninstall_plugin() returned false');
+ 'core_plugin_manager::can_uninstall_plugin() returned false');
}
if (!$confirmed) {
- $continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
- echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl);
+ $continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1, 'return'=>$return));
+ $cancelurl = $pluginfo->get_return_url_after_uninstall($return);
+ echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl, $cancelurl);
exit();
} else {
+ $SESSION->pluginuninstallreturn = $pluginfo->get_return_url_after_uninstall($return);
$progress = new progress_trace_buffer(new text_progress_trace(), false);
$pluginman->uninstall_plugin($pluginfo->component, $progress);
$progress->finished();
// Make sure we know the plugin.
if (is_null($pluginfo)) {
throw new moodle_exception('err_removing_unknown_plugin', 'core_plugin', '', array('plugin' => $delete),
- 'plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
+ 'core_plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
}
$pluginname = $pluginman->plugin_name($pluginfo->component);
if (!is_null($pluginfo->versiondb)) {
throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '',
array('plugin' => $pluginfo->component, 'versiondb' => $pluginfo->versiondb),
- 'plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
+ 'core_plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
}
// Make sure the folder is removable.
/** @var core_admin_renderer $output */
$output = $PAGE->get_renderer('core', 'admin');
-$checker = available_update_checker::instance();
+$checker = \core\update\checker::instance();
// Filtering options.
$options = array(
redirect(new moodle_url($PAGE->url, $options));
}
-$deployer = available_update_deployer::instance();
+$deployer = \core\update\deployer::instance();
if ($deployer->enabled()) {
$myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
$deployer->initialize($myurl, new moodle_url('/admin'));
require_once($CFG->libdir . '/portfoliolib.php');
require_once($CFG->libdir . '/portfolio/forms.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
$portfolio = optional_param('pf', '', PARAM_ALPHANUMEXT);
$action = optional_param('action', '', PARAM_ALPHA);
} else {
portfolio_static_function($plugin, 'create_instance', $plugin, $fromform->name, $fromform);
}
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$savedstr = get_string('instancesaved', 'portfolio');
redirect($baseurl, $savedstr, 1);
exit;
$instance->set('visible', $visible);
$instance->save();
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$return = true;
} else if ($action == 'delete') {
$instance = portfolio_instance($portfolio);
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/tablelib.php');
// Check permissions.
$thispageurl = new moodle_url('/admin/qbehaviours.php');
$behaviours = core_component::get_plugin_list('qbehaviour');
-$pluginmanager = plugin_manager::instance();
+$pluginmanager = core_plugin_manager::instance();
// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql_menu("
$disabledbehaviours[] = $disable;
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
}
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
redirect($thispageurl);
}
unset($disabledbehaviours[$key]);
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
}
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
redirect($thispageurl);
}
redirect($thispageurl);
}
-// Delete.
-if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
- // Check it is OK to delete this question type.
- if ($delete == 'missing') {
- print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
- }
-
- if (!isset($behaviours[$delete]) && !get_config('qbehaviour_' . $delete, 'version')) {
- print_error('unknownbehaviour', 'question', $thispageurl, $delete);
- }
-
- $behaviourname = $sortedbehaviours[$delete];
- if ($counts[$delete] > 0) {
- print_error('cannotdeletebehaviourinuse', 'question', $thispageurl, $behaviourname);
- }
- if ($needed[$delete] > 0) {
- print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
- }
-
- // If not yet confirmed, display a confirmation message.
- if (!optional_param('confirm', '', PARAM_BOOL)) {
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
- echo $OUTPUT->confirm(
- get_string('deletebehaviourareyousuremessage', 'question', $behaviourname),
- new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
- $thispageurl);
- echo $OUTPUT->footer();
- exit;
- }
-
- // Do the deletion.
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
-
- // Remove this behaviour from configurations where it might appear.
- if (($key = array_search($delete, $disabledbehaviours)) !== false) {
- unset($disabledbehaviours[$key]);
- set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
- }
- $behaviourorder = array_keys($sortedbehaviours);
- if (($key = array_search($delete, $behaviourorder)) !== false) {
- unset($behaviourorder[$key]);
- set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
- }
-
- // Then uninstall the plugin.
- uninstall_plugin('qbehaviour', $delete);
-
- // Display a message.
- $a = new stdClass();
- $a->behaviour = $behaviourname;
- $a->directory = core_component::get_plugin_directory('qbehaviour', $delete);
- echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
- echo $OUTPUT->continue_button($thispageurl);
- echo $OUTPUT->footer();
- exit;
-}
-
// End of process actions ==================================================
// Print the page heading.
$table = new flexible_table('qbehaviouradmintable');
$table->define_baseurl($thispageurl);
$table->define_columns(array('behaviour', 'numqas', 'version', 'requires',
- 'available', 'delete'));
+ 'available', 'uninstall'));
$table->define_headers(array(get_string('behaviour', 'question'), get_string('numqas', 'question'),
get_string('version'), get_string('requires', 'admin'),
- get_string('availableq', 'question'), get_string('delete')));
+ get_string('availableq', 'question'), get_string('uninstallplugin', 'core_admin')));
$table->set_attribute('id', 'qbehaviours');
-$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->set_attribute('class', 'generaltable admintable');
$table->setup();
// Add a row for each question type.
if ($needed[$behaviour]) {
$row[] = '';
} else {
- $row[] = html_writer::link(new moodle_url($thispageurl,
- array('delete' => $behaviour, 'sesskey' => sesskey())), get_string('delete'),
+ $uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qbehaviour_'.$behaviour, 'manage');
+ if ($uninstallurl) {
+ $row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
array('title' => get_string('uninstallbehaviour', 'question')));
+ }
}
$table->add_data($row, $rowclass);
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/tablelib.php');
// Check permissions.
$thispageurl = new moodle_url('/admin/qtypes.php');
$qtypes = question_bank::get_all_qtypes();
-$pluginmanager = plugin_manager::instance();
+$pluginmanager = core_plugin_manager::instance();
// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql("
redirect($thispageurl);
}
-// Delete.
-if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
- // Check it is OK to delete this question type.
- if ($delete == 'missingtype') {
- print_error('cannotdeletemissingqtype', 'question', $thispageurl);
- }
-
- if (!isset($qtypes[$delete]) && !get_config('qtype_' . $delete, 'version')) {
- print_error('unknownquestiontype', 'question', $thispageurl, $delete);
- }
-
- $qtypename = $qtypes[$delete]->local_name();
- if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
- print_error('cannotdeleteqtypeinuse', 'question', $thispageurl, $qtypename);
- }
-
- if ($needed[$delete] > 0) {
- print_error('cannotdeleteqtypeneeded', 'question', $thispageurl, $qtypename);
- }
-
- // If not yet confirmed, display a confirmation message.
- if (!optional_param('confirm', '', PARAM_BOOL)) {
- $qtypename = $qtypes[$delete]->local_name();
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
- echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename),
- new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
- $thispageurl);
- echo $OUTPUT->footer();
- exit;
- }
-
- // Do the deletion.
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
-
- // Delete any questoin configuration records mentioning this plugin.
- unset_config($delete . '_disabled', 'question');
- unset_config($delete . '_sortorder', 'question');
-
- // Then uninstall the plugin.
- uninstall_plugin('qtype', $delete);
-
- $a = new stdClass();
- $a->qtype = $qtypename;
- $a->directory = $qtypes[$delete]->plugin_dir();
- echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
- echo $OUTPUT->continue_button($thispageurl);
- echo $OUTPUT->footer();
- exit;
-}
-
// End of process actions ==================================================
// Print the page heading.
$table = new flexible_table('qtypeadmintable');
$table->define_baseurl($thispageurl);
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
- 'availableto', 'delete', 'settings'));
+ 'availableto', 'uninstall', 'settings'));
$table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'),
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
- get_string('delete'), get_string('settings')));
+ get_string('settings'), get_string('uninstallplugin', 'core_admin')));
$table->set_attribute('id', 'qtypes');
$table->set_attribute('class', 'admintable generaltable');
$table->setup();
$icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
$row[] = $icons;
- // Delete link, if available.
- if ($needed[$qtypename]) {
- $row[] = '';
- } else {
- $row[] = html_writer::link(new moodle_url($thispageurl,
- array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'),
- array('title' => get_string('uninstallqtype', 'question')));
- }
-
// Settings link, if available.
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
if ($settings instanceof admin_externalpage) {
$row[] = '';
}
+ // Uninstall link, if available.
+ if ($needed[$qtypename]) {
+ $row[] = '';
+ } else {
+ $uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qtype_'.$qtypename, 'manage');
+ if ($uninstallurl) {
+ $row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
+ array('title' => get_string('uninstallqtype', 'question')));
+ }
+ }
+
$table->add_data($row, $rowclass);
}
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir . '/pluginlib.php');
/**
* Standard HTML output renderer for core_admin subsystem
$output .= $this->header();
$output .= $this->heading(get_string('pluginscheck', 'admin'));
$output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
- $output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
+ $output .= $this->plugins_check_table(core_plugin_manager::instance(), $version, array('xdep' => true));
$output .= $this->warning(get_string('pluginschecktodo', 'admin'));
$output .= $this->continue_button($reloadurl);
/**
* Display the upgrade page that lists all the plugins that require attention.
- * @param plugin_manager $pluginman provides information about the plugins.
- * @param available_update_checker $checker provides information about available updates.
+ * @param core_plugin_manager $pluginman provides information about the plugins.
+ * @param \core\update\checker $checker provides information about available updates.
* @param int $version the version of the Moodle code from version.php.
* @param bool $showallplugins
* @param moodle_url $reloadurl
* @param moodle_url $continueurl
* @return string HTML to output.
*/
- public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
+ public function upgrade_plugin_check_page(core_plugin_manager $pluginman, \core\update\checker $checker,
$version, $showallplugins, $reloadurl, $continueurl) {
global $CFG;
/**
* Prints a page with a summary of plugin deployment to be confirmed.
*
- * @param available_update_deployer $deployer
- * @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
+ * @param \core\update\deployer $deployer
+ * @param array $data deployer's data package as returned by {@link \core\update\deployer::submitted_data()}
* @return string
*/
- public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {
+ public function upgrade_plugin_confirm_deploy_page(\core\update\deployer $deployer, array $data) {
if (!$deployer->initialized()) {
throw new coding_exception('Unable to render a page for non-initialized deployer.');
* @param bool $dbproblems warn db has problems
* @param bool $maintenancemode warn in maintenance mode
* @param bool $buggyiconvnomb warn iconv problems
- * @param array|null $availableupdates array of available_update_info objects or null
+ * @param array|null $availableupdates array of \core\update\info objects or null
* @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
*
* @return string HTML to output.
* bool contribonly - show only contributed extensions
* bool updatesonly - show only plugins with an available update
*
- * @param plugin_manager $pluginman
- * @param available_update_checker $checker
+ * @param core_plugin_manager $pluginman
+ * @param \core\update\checker $checker
* @param array $options filtering options
* @return string HTML to output.
*/
- public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker, array $options = array()) {
+ public function plugin_management_page(core_plugin_manager $pluginman, \core\update\checker $checker, array $options = array()) {
global $CFG;
$output = '';
/**
* Display a page to confirm the plugin uninstallation.
*
- * @param plugin_manager $pluginman
- * @param plugininfo_base $pluginfo
+ * @param core_plugin_manager $pluginman
+ * @param \core\plugininfo\base $pluginfo
* @param moodle_url $continueurl URL to continue after confirmation
+ * @param moodle_url $cancelurl URL to to go if cancelled
* @return string
*/
- public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugininfo_base $pluginfo, moodle_url $continueurl) {
+ public function plugin_uninstall_confirm_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, moodle_url $continueurl, moodle_url $cancelurl) {
$output = '';
$pluginname = $pluginman->plugin_name($pluginfo->component);
$output .= $this->output->header();
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
- $output .= $this->output->confirm($confirm, $continueurl, $this->page->url);
+ $output .= $this->output->confirm($confirm, $continueurl, $cancelurl);
$output .= $this->output->footer();
return $output;
/**
* Display a page with results of plugin uninstallation and offer removal of plugin files.
*
- * @param plugin_manager $pluginman
- * @param plugininfo_base $pluginfo
+ * @param core_plugin_manager $pluginman
+ * @param \core\plugininfo\base $pluginfo
* @param progress_trace_buffer $progress
* @param moodle_url $continueurl URL to continue to remove the plugin folder
* @return string
*/
- public function plugin_uninstall_results_removable_page(plugin_manager $pluginman, plugininfo_base $pluginfo,
+ public function plugin_uninstall_results_removable_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo,
progress_trace_buffer $progress, moodle_url $continueurl) {
$output = '';
/**
* Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
*
- * @param plugin_manager $pluginman
- * @param plugininfo_base $pluginfo
+ * @param core_plugin_manager $pluginman
+ * @param \core\plugininfo\base $pluginfo
* @param progress_trace_buffer $progress
* @return string
*/
- public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
+ public function plugin_uninstall_results_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, progress_trace_buffer $progress) {
$output = '';
$pluginname = $pluginfo->component;
* The structure of the $updates param has changed since 2.4. It contains not only updates
* for the core itself, but also for all other installed plugins.
*
- * @param array|null $updates array of (string)component => array of available_update_info objects or null
+ * @param array|null $updates array of (string)component => array of \core\update\info objects or null
* @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
* @return string
*/
/**
* Helper method to render the information about the available Moodle update
*
- * @param available_update_info $updateinfo information about the available Moodle core update
+ * @param \core\update\info $updateinfo information about the available Moodle core update
*/
- protected function moodle_available_update_info(available_update_info $updateinfo) {
+ protected function moodle_available_update_info(\core\update\info $updateinfo) {
$boxclasses = 'moodleupdateinfo';
$info = array();
* (bool)full = false: whether to display up-to-date plugins, too
* (bool)xdep = false: display the plugins with unsatisified dependecies only
*
- * @param plugin_manager $pluginman provides information about the plugins.
+ * @param core_plugin_manager $pluginman provides information about the plugins.
* @param int $version the version of the Moodle code from version.php.
* @param array $options rendering options
* @return string HTML code
*/
- public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
+ public function plugins_check_table(core_plugin_manager $pluginman, $version, array $options = array()) {
global $CFG;
$plugininfo = $pluginman->get_plugins();
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
$statusisboring = in_array($statuscode, array(
- plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
+ core_plugin_manager::PLUGIN_STATUS_NODB, core_plugin_manager::PLUGIN_STATUS_UPTODATE));
$coredependency = $plugin->is_core_dependency_satisfied($version);
$otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
/**
* Formats the information that needs to go in the 'Requires' column.
- * @param plugininfo_base $plugin the plugin we are rendering the row for.
- * @param plugin_manager $pluginman provides data on all the plugins.
+ * @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
+ * @param core_plugin_manager $pluginman provides data on all the plugins.
* @param string $version
* @return string HTML code
*/
- protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
+ protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) {
$requires = array();
if (!empty($plugin->versionrequires)) {
/**
* Prints an overview about the plugins - number of installed, number of extensions etc.
*
- * @param plugin_manager $pluginman provides information about the plugins
+ * @param core_plugin_manager $pluginman provides information about the plugins
* @param array $options filtering options
* @return string as usually
*/
- public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
+ public function plugins_overview_panel(core_plugin_manager $pluginman, array $options = array()) {
global $CFG;
$plugininfo = $pluginman->get_plugins();
foreach ($plugininfo as $type => $plugins) {
foreach ($plugins as $name => $plugin) {
- if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
+ if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
continue;
}
$numtotal++;
*
* This default implementation renders all plugins into one big table.
*
- * @param plugin_manager $pluginman provides information about the plugins.
+ * @param core_plugin_manager $pluginman provides information about the plugins.
* @param array $options filtering options
* @return string HTML code
*/
- public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
+ public function plugins_control_panel(core_plugin_manager $pluginman, array $options = array()) {
global $CFG;
$plugininfo = $pluginman->get_plugins();
);
foreach ($plugininfo as $type => $plugins) {
-
- $header = new html_table_cell($pluginman->plugintype_name_plural($type));
+ $heading = $pluginman->plugintype_name_plural($type);
+ $pluginclass = core_plugin_manager::resolve_plugininfo_class($type);
+ if ($manageurl = $pluginclass::get_manage_url()) {
+ $heading = html_writer::link($manageurl, $heading);
+ }
+ $header = new html_table_cell(html_writer::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
$header->header = true;
$header->colspan = array_sum($table->headspan);
$header = new html_table_row(array($header));
}
$status = $plugin->get_status();
$row->attributes['class'] .= ' status-'.$status;
- if ($status === plugin_manager::PLUGIN_STATUS_MISSING) {
+ if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
- } else if ($status === plugin_manager::PLUGIN_STATUS_NEW) {
+ } else if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
$msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
} else {
$msg = '';
}
$settings = new html_table_cell($settings);
- if ($pluginman->can_uninstall_plugin($plugin->component)) {
- $uninstallurl = $plugin->get_uninstall_url();
+ if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component, 'overview')) {
$uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
} else {
$uninstall = '';
* The passed objects always provides at least the 'version' property containing
* the (higher) version of the plugin available.
*
- * @param available_update_info $updateinfo information about the available update for the plugin
+ * @param \core\update\info $updateinfo information about the available update for the plugin
*/
- protected function plugin_available_update_info(available_update_info $updateinfo) {
+ protected function plugin_available_update_info(\core\update\info $updateinfo) {
$boxclasses = 'pluginupdateinfo';
$info = array();
$box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
$box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
- $deployer = available_update_deployer::instance();
+ $deployer = \core\update\deployer::instance();
if ($deployer->initialized()) {
$impediments = $deployer->deployment_impediments($updateinfo);
if (empty($impediments)) {
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
admin_externalpage_setup('managereports');
$table->define_headers(array(get_string('plugin'), get_string('version'), $struninstall));
$table->define_baseurl($PAGE->url);
$table->set_attribute('id', 'reportplugins');
-$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->set_attribute('class', 'admintable generaltable');
$table->setup();
$plugins = array();
foreach ($plugins as $plugin => $name) {
$uninstall = '';
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('report_'.$plugin)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('report_'.$plugin, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
}
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->dirroot . '/repository/lib.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
$repository = optional_param('repos', '', PARAM_ALPHANUMEXT);
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
}
if ($success) {
// configs saved
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
redirect($baseurl);
} else {
print_error('instancenotsaved', 'repository', $baseurl);
print_error('invalidplugin', 'repository', '', $repository);
}
$repositorytype->update_visibility(true);
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$return = true;
} else if ($action == 'hide') {
if (!confirm_sesskey()) {
print_error('invalidplugin', 'repository', '', $repository);
}
$repositorytype->update_visibility(false);
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$return = true;
} else if ($action == 'delete') {
$repositorytype = repository::get_type_by_typename($repository);
}
if ($repositorytype->delete($downloadcontents)) {
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
redirect($baseurl);
} else {
print_error('instancenotdeleted', 'repository', $baseurl);
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->dirroot . '/repository/lib.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
require_sesskey();
$data = data_submitted();
}
if ($success) {
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
redirect($parenturl);
} else {
print_error('instancenotsaved', 'repository', $parenturl);
} else if (!empty($hide)) {
$instance = repository::get_type_by_typename($hide);
$instance->hide();
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
$return = true;
} else if (!empty($delete)) {
$instance = repository::get_instance($delete);
if ($sure) {
if ($instance->delete($downloadcontents)) {
$deletedstr = get_string('instancedeleted', 'repository');
- plugin_manager::reset_caches();
+ core_plugin_manager::reset_caches();
redirect($parenturl, $deletedstr, 3);
} else {
print_error('instancenotdeleted', 'repository', $parenturl);
$contextid = required_param('contextid', PARAM_INT);
$roleid = optional_param('roleid', 0, PARAM_INT);
+$returnto = optional_param('return', null, PARAM_ALPHANUMEXT);
list($context, $course, $cm) = get_context_info_array($contextid);
// Print the form.
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
+ if ($returnto !== null) {
+ $assignurl->param('return', $returnto);
+ }
?>
<form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
// Print a form to swap roles, and a link back to the all roles list.
echo '<div class="backlink">';
- $select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
+ $newroleurl = new moodle_url($PAGE->url);
+ if ($returnto !== null) {
+ $newroleurl->param('return', $returnto);
+ }
+ $select = new single_select($newroleurl, 'roleid', $nameswithcounts, $roleid, null);
$select->label = get_string('assignanotherrole', 'core_role');
echo $OUTPUT->render($select);
$backurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
+ if ($returnto !== null) {
+ $backurl->param('return', $returnto);
+ }
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
echo '</div>';
foreach ($assignableroles as $roleid => $notused) {
$roleusers = '';
if (0 < $assigncounts[$roleid] && $assigncounts[$roleid] <= MAX_USERS_TO_LIST_PER_ROLE) {
- $roleusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname');
+ $userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
+ $roleusers = get_role_users($roleid, $context, false, $userfields);
if (!empty($roleusers)) {
$strroleusers = array();
foreach ($roleusers as $user) {
}
} else if ($assigncounts[$roleid] > MAX_USERS_TO_LIST_PER_ROLE) {
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
+ if ($returnto !== null) {
+ $assignurl->param('return', $returnto);
+ }
$roleholdernames[$roleid] = '<a href="'.$assignurl.'">'.$strmorethanmax.'</a>';
} else {
$roleholdernames[$roleid] = '';
foreach ($assignableroles as $roleid => $rolename) {
$description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
+ if ($returnto !== null) {
+ $assignurl->param('return', $returnto);
+ }
$row = array('<a href="'.$assignurl.'">'.$rolename.'</a>',
$description, $assigncounts[$roleid]);
if ($showroleholders) {
echo html_writer::table($table);
if ($context->contextlevel > CONTEXT_USER) {
+
+ if ($context->contextlevel === CONTEXT_COURSECAT && $returnto === 'management') {
+ $url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
+ } else {
+ $url = $context->get_url();
+ }
+
echo html_writer::start_tag('div', array('class'=>'backlink'));
- echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
+ echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
echo html_writer::end_tag('div');
}
}
$allow = optional_param('allow', 0, PARAM_BOOL);
$unprohibit = optional_param('unprohibit', 0, PARAM_BOOL);
$prohibit = optional_param('prohibit', 0, PARAM_BOOL);
+$return = optional_param('return', null, PARAM_ALPHANUMEXT);
list($context, $course, $cm) = get_context_info_array($contextid);
if ($context->contextlevel > CONTEXT_USER) {
+
+ if ($context->contextlevel === CONTEXT_COURSECAT && $return === 'management') {
+ $url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
+ } else {
+ $url = $context->get_url();
+ }
+
echo html_writer::start_tag('div', array('class'=>'backlink'));
- echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
+ echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
echo html_writer::end_tag('div');
}
<?php
-
-// This file defines settingpages and externalpages under the "courses" category
-
-if ($hassiteconfig
- or has_capability('moodle/backup:backupcourse', $systemcontext)
- or has_capability('moodle/category:manage', $systemcontext)
- or has_capability('moodle/course:create', $systemcontext)
- or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
-
- $ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/manage.php',
- array('moodle/category:manage', 'moodle/course:create')));
+// 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 defines settingpages and externalpages under the "courses" category
+ *
+ * @package core
+ * @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$capabilities = array(
+ 'moodle/backup:backupcourse',
+ 'moodle/category:manage',
+ 'moodle/course:create',
+ 'moodle/site:approvecourse'
+);
+if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
+ // Speedup for non-admins, add all caps used on this page.
+ $ADMIN->add('courses',
+ new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
+ $CFG->wwwroot . '/course/management.php',
+ array('moodle/category:manage', 'moodle/course:create')
+ )
+ );
+ $ADMIN->add('courses',
+ new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
+ new moodle_url('/course/editcategory.php', array('parent' => 0)),
+ array('moodle/category:manage')
+ )
+ );
// Course Default Settings Page.
// NOTE: these settings must be applied after all other settings because they depend on them.
-
// Main course settings.
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
require_once($CFG->dirroot.'/course/lib.php');
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
1, $choices));
-
// Course format.
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
-
// Appearance.
$temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
-
// Files and uploads.
$temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
new lang_string('coursehelpmaximumupload'), key($choices), $choices));
-
// Completion tracking.
$temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
-
// Groups.
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
$choices = array();
$temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
$ADMIN->add('courses', $temp);
-/// Pending course requests.
+ // Pending course requests.
if (!empty($CFG->enablecourserequests)) {
$ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
}
- // Add a category for backups
+ // Add a category for backups.
$ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
// Create a page for general backups configuration and defaults.
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
-
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
$ADMIN->add('backups', $temp);
-
-} // end of speedup
+}
<?php
-
-/*
- * Please note that is file is always loaded last - it means that you can inject entries into other categories too.
- */
+// 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/>.
+
+/**
+ * Load all plugins into the admin tree.
+ *
+* Please note that is file is always loaded last - it means that you can inject entries into other categories too.
+*
+* @package core
+* @copyright 2007 Petr Skoda {@link http://skodak.org}
+* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+*/
if ($hassiteconfig) {
- require_once("$CFG->libdir/pluginlib.php");
- $allplugins = plugin_manager::instance()->get_plugins();
-
$ADMIN->add('modules', new admin_page_pluginsoverview());
// activity modules
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
$ADMIN->add('modsettings', new admin_page_managemods());
- foreach ($allplugins['mod'] as $module) {
- if (!$module->is_updated()) {
- continue;
- }
- $module->load_settings($ADMIN, 'modsettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('mod') as $plugin) {
+ /** @var \core\plugininfo\mod $plugin */
+ $plugin->load_settings($ADMIN, 'modsettings', $hassiteconfig);
}
// course formats
$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) {
- if (!$format->is_updated()) {
- continue;
- }
- $format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('format') as $plugin) {
+ /** @var \core\plugininfo\format $plugin */
+ $plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
}
// blocks
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
$ADMIN->add('blocksettings', new admin_page_manageblocks());
- foreach ($allplugins['block'] as $block) {
- if (!$block->is_updated()) {
- continue;
- }
- $block->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('block') as $plugin) {
+ /** @var \core\plugininfo\block $plugin */
+ $plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
}
// message outputs
$ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
$ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
$ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
- foreach ($allplugins['message'] as $processor) {
- if (!$processor->is_updated()) {
- continue;
- }
- $processor->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('message') as $plugin) {
+ /** @var \core\plugininfo\message $plugin */
+ $plugin->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
}
// authentication plugins
$temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
$ADMIN->add('authsettings', $temp);
- foreach ($allplugins['auth'] as $auth) {
- if (!$auth->is_updated()) {
- continue;
- }
- $auth->load_settings($ADMIN, 'authsettings', $hassiteconfig);
+ $temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
+ $ADMIN->add('authsettings', $temp);
+
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('auth') as $plugin) {
+ /** @var \core\plugininfo\auth $plugin */
+ $plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
}
// Enrolment plugins
$temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
$temp->add(new admin_setting_manageenrols());
$ADMIN->add('enrolments', $temp);
- foreach($allplugins['enrol'] as $enrol) {
- if (!$enrol->is_updated()) {
- continue;
- }
- $enrol->load_settings($ADMIN, 'enrolments', $hassiteconfig);
+
+ $temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
+ $ADMIN->add('enrolments', $temp);
+
+ foreach(core_plugin_manager::instance()->get_plugins_of_type('enrol') as $plugin) {
+ /** @var \core\plugininfo\enrol $plugin */
+ $plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
}
$temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
$temp->add(new admin_setting_manageeditors());
$ADMIN->add('editorsettings', $temp);
- foreach ($allplugins['editor'] as $editor) {
- if (!$editor->is_updated()) {
- continue;
- }
- $editor->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('editor') as $plugin) {
+ /** @var \core\plugininfo\editor $plugin */
+ $plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
}
/// License types
}
$ADMIN->add('filtersettings', $temp);
- foreach ($allplugins['filter'] as $filter) {
- if (!$filter->is_updated()) {
- continue;
- }
- $filter->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('filter') as $plugin) {
+ /** @var \core\plugininfo\filter $plugin */
+ $plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
}
$temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
$temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
$temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
+ $temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
$ADMIN->add('repositorysettings', $temp);
$ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
- foreach ($allplugins['repository'] as $repositorytype) {
- if (!$repositorytype->is_updated()) {
- continue;
- }
- $repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('repository') as $plugin) {
+ /** @var \core\plugininfo\repository $plugin */
+ $plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
}
/// Web services
'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
$ADMIN->add('webservicesettings', $temp);
/// links to protocol pages
- foreach ($allplugins['webservice'] as $webservice) {
- if (!$webservice->is_updated()) {
- continue;
- }
- $webservice->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('webservice') as $plugin) {
+ /** @var \core\plugininfo\webservice $plugin */
+ $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
}
/// manage token page link
$ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
// Question type settings
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
- if (!$hassiteconfig) {
- require_once("$CFG->libdir/pluginlib.php");
- $allplugins = plugin_manager::instance()->get_plugins();
- }
// Question behaviour settings.
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
// Settings for particular question types.
- foreach ($allplugins['qtype'] as $qtype) {
- if (!$qtype->is_updated()) {
- continue;
- }
- $qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('qtype') as $plugin) {
+ /** @var \core\plugininfo\qtype $plugin */
+ $plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
}
}
$ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
$CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
- foreach ($allplugins['plagiarism'] as $plugin) {
- if (!$plugin->is_updated()) {
- continue;
- }
+ foreach (core_plugin_manager::instance()->get_plugins_of_type('plagiarism') as $plugin) {
+ /** @var \core\plugininfo\plagiarism $plugin */
$plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
}
}
$CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
}
-// Now add various admin tools
-foreach (core_component::get_plugin_list('tool') as $plugin => $plugindir) {
- $settings_path = "$plugindir/settings.php";
- if (file_exists($settings_path)) {
- include($settings_path);
- }
+// Now add various admin tools.
+foreach (core_plugin_manager::instance()->get_plugins_of_type('tool') as $plugin) {
+ /** @var \core\plugininfo\tool $plugin */
+ $plugin->load_settings($ADMIN, null, $hassiteconfig);
}
// Now add the Cache plugins
$CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
}
-// extend settings for each local plugin. Note that their settings may be in any part of the
-// settings tree and may be visible not only for administrators. We can not use $allplugins here
-foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
- $settings_path = "$plugindir/settings.php";
- if (file_exists($settings_path)) {
- include($settings_path);
- continue;
- }
+// Extend settings for each local plugin. Note that their settings may be in any part of the
+// settings tree and may be visible not only for administrators.
+foreach (core_plugin_manager::instance()->get_plugins_of_type('local') as $plugin) {
+ /** @var \core\plugininfo\local $plugin */
+ $plugin->load_settings($ADMIN, null, $hassiteconfig);
}
$temp->add(new admin_setting_configtext('minpasswordupper', new lang_string('minpasswordupper', 'admin'), new lang_string('configminpasswordupper', 'admin'), 1, PARAM_INT));
$temp->add(new admin_setting_configtext('minpasswordnonalphanum', new lang_string('minpasswordnonalphanum', 'admin'), new lang_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT));
$temp->add(new admin_setting_configtext('maxconsecutiveidentchars', new lang_string('maxconsecutiveidentchars', 'admin'), new lang_string('configmaxconsecutiveidentchars', 'admin'), 0, PARAM_INT));
+ $pwresetoptions = array(
+ 300 => new lang_string('numminutes', '', 5),
+ 900 => new lang_string('numminutes', '', 15),
+ 1800 => new lang_string('numminutes', '', 30),
+ 2700 => new lang_string('numminutes', '', 45),
+ 3600 => new lang_string('numminutes', '', 60),
+ 7200 => new lang_string('numminutes', '', 120),
+ 14400 => new lang_string('numminutes', '', 240)
+ );
+ $adminsetting = new admin_setting_configselect(
+ 'pwresettime',
+ new lang_string('passwordresettime','admin'),
+ new lang_string('configpasswordresettime','admin'),
+ 1800,
+ $pwresetoptions);
+ $temp->add($adminsetting);
$temp->add(new admin_setting_configcheckbox('groupenrolmentkeypolicy', new lang_string('groupenrolmentkeypolicy', 'admin'), new lang_string('groupenrolmentkeypolicy_desc', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('disableuserimages', new lang_string('disableuserimages', 'admin'), new lang_string('configdisableuserimages', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', new lang_string('emailchangeconfirmation', 'admin'), new lang_string('configemailchangeconfirmation', 'admin'), 1));
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/upgradelib.php');
require_once($CFG->libdir.'/clilib.php');
-require_once($CFG->libdir.'/pluginlib.php');
require_once($CFG->libdir.'/installlib.php');
require_once($CFG->libdir.'/testing/classes/test_lock.php');
And I log in as "admin"
And I follow "Course 1"
When I click on "Move this to the dock" "button" in the "Administration" "block"
- Then I should not see "Question bank"
+ Then I should not see "Question bank" in the "region-pre" "region"
And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element"
@javascript
| Course 1 | C1 | 0 |
And I log in as "admin"
When I click on "Move this to the dock" "button" in the "Administration" "block"
- Then I should not see "Turn editing on"
+ Then I should not see "Turn editing on" in the "region-pre" "region"
And I follow "Cat 3"
And I should see "Course 1"
And I should see "Course 2"
- And I select "Cat 1 / Cat 2" from "Course categories:"
+ And I follow "Cat 2"
And I should see "No courses in this category"
- And I select "Miscellaneous" from "Course categories:"
+ And I follow "Miscellaneous"
And I should see "Course 3"
@javascript
And I follow "Admin User"
And I follow "Edit profile"
When I fill in "First name" with "Field value"
- And I select "Use standard web forms" from "When editing text"
+ And I select "Plain text area" from "Text editor"
And I check "Unmask"
Then the "First name" field should match "Field value" value
- And the "When editing text" select box should contain "Use standard web forms"
+ And the "Text editor" select box should contain "Plain text area"
And the "Unmask" checkbox should be checked
And I uncheck "Unmask"
And the "Unmask" checkbox should not be checked
Then I should see "Close the quiz"
And I should see "Group mode"
And I should see "Grouping"
- And I should not see "Show more..."
+ And I should not see "Show more..." in the "region-main-box" "region"
And I should see "Show less..."
function tool_dbtransfer_create_maintenance_file() {
global $CFG;
- register_shutdown_function('tool_dbtransfer_maintenance_callback');
+ core_shutdown_manager::register_function('tool_dbtransfer_maintenance_callback');
$options = new stdClass();
$options->trusted = false;
*/
public function get_plugin_types_menu() {
global $CFG;
- require_once($CFG->libdir.'/pluginlib.php');
- $pluginman = plugin_manager::instance();
+ $pluginman = core_plugin_manager::instance();
$menu = array('' => get_string('choosedots'));
foreach (array_keys($pluginman->get_plugin_types()) as $plugintype) {
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/upgradelib.php');
require_once($CFG->libdir.'/clilib.php');
-require_once($CFG->libdir.'/pluginlib.php');
require_once($CFG->libdir.'/installlib.php');
if ($unrecognized) {
'variant' => 1,
'maxmark' => {$question->maxmark},
'minfraction' => 0,
+ 'maxfraction' => 1,
'flagged' => 0,
'questionsummary' => '',
'rightanswer' => '',
/**
* Get the directory of the object to restore.
*
- * @return string|false subdirectory in $CFG->tempdir/backup/...
+ * @return string|false|null subdirectory in $CFG->tempdir/backup/..., false when an error occured
+ * and null when there is simply nothing.
*/
protected function get_restore_content_dir() {
$backupfile = null;
$this->error($key, $message);
}
return false;
+ } else if ($dir === false) {
+ // We want to return null when nothing was wrong, but nothing was found.
+ $dir = null;
}
if (empty($dir) && !empty($this->importoptions['restoredir'])) {
$this->enrolmentdata = tool_uploadcourse_helper::get_enrolment_data($this->rawdata);
// Restore data.
- // TODO log warnings.
+ // TODO Speed up things by not really extracting the backup just yet, but checking that
+ // the backup file or shortname passed are valid. Extraction should happen in proceed().
$this->restoredata = $this->get_restore_content_dir();
+ if ($this->restoredata === false) {
+ return false;
+ }
// We can only reset courses when allowed and we are updating the course.
if ($this->importoptions['reset'] || $this->options['reset']) {
$deleted = 0;
$errors = 0;
+ // We will most certainly need extra time and memory to process big files.
+ @set_time_limit(0);
+ raise_memory_limit(MEMORY_EXTRA);
+
// Loop over the CSV lines.
while ($line = $this->cir->next()) {
$this->linenb++;
}
$tracker->start();
+ // We might need extra time and memory depending on the number of rows to preview.
+ @set_time_limit(0);
+ raise_memory_limit(MEMORY_EXTRA);
+
// Loop over the CSV lines.
$preview = array();
while (($line = $this->cir->next()) && $rows > $this->linenb) {
set_time_limit(0);
}
+ public function test_restore_invalid_file() {
+ $this->resetAfterTest();
+
+ // Restore from a non-existing file should not be allowed.
+ $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+ $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+ $data = array('shortname' => 'A1', 'backupfile' => '/lead/no/where',
+ 'category' => 1, 'fullname' => 'A1');
+ $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+ $this->assertFalse($co->prepare());
+ $this->assertArrayHasKey('cannotreadbackupfile', $co->get_errors());
+
+ // Restore from an invalid file should not be allowed.
+ $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+ $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+ $data = array('shortname' => 'A1', 'backupfile' => __FILE__,
+ 'category' => 1, 'fullname' => 'A1');
+ $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+
+ $this->assertFalse($co->prepare());
+ $this->assertArrayHasKey('invalidbackupfile', $co->get_errors());
+
+ // Zip packer throws a debugging message, this assertion is only here to prevent
+ // the message from being displayed.
+ $this->assertDebuggingCalled();
+ }
+
+ public function test_restore_invalid_course() {
+ $this->resetAfterTest();
+
+ // Restore from an invalid file should not be allowed.
+ $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+ $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+ $data = array('shortname' => 'A1', 'templatecourse' => 'iamnotavalidcourse',
+ 'category' => 1, 'fullname' => 'A1');
+ $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+ $this->assertFalse($co->prepare());
+ $this->assertArrayHasKey('coursetorestorefromdoesnotexist', $co->get_errors());
+ }
+
/**
* Testing the reset on groups, group members and enrolments.
*/
$PRF_FIELDS = array();
-if ($prof_fields = $DB->get_records('user_info_field')) {
- foreach ($prof_fields as $prof_field) {
- $PRF_FIELDS[] = 'profile_field_'.$prof_field->shortname;
+if ($proffields = $DB->get_records('user_info_field')) {
+ foreach ($proffields as $key => $proffield) {
+ $profilefieldname = 'profile_field_'.$proffield->shortname;
+ $PRF_FIELDS[] = $profilefieldname;
+ // Re-index $proffields with key as shortname. This will be
+ // used while checking if profile data is key and needs to be converted (eg. menu profile field)
+ $proffields[$profilefieldname] = $proffield;
+ unset($proffields[$key]);
}
}
-unset($prof_fields);
if (empty($iid)) {
$mform1 = new admin_uploaduser_form1();
if (isset($formdata->$field)) {
// process templates
$user->$field = uu_process_template($formdata->$field, $user);
+
+ // Form contains key and later code expects value.
+ // Convert key to value for required profile fields.
+ require_once($CFG->dirroot.'/user/profile/field/'.$proffields[$field]->datatype.'/field.class.php');
+ $profilefieldclass = 'profile_field_'.$proffields[$field]->datatype;
+ $profilefield = new $profilefieldclass($proffields[$field]->id);
+ if (method_exists($profilefield, 'convert_external_data')) {
+ $user->$field = $profilefield->edit_save_data_preprocess($user->$field, null);
+ }
+
$formdefaults[$field] = true;
}
}
}
if ($rid) {
- // find duration
- $timeend = 0;
+ // Find duration and/or enrol status.
+ $timeend = 0;
+ $status = null;
+
+ if (isset($user->{'enrolstatus'.$i})) {
+ $enrolstatus = trim($user->{'enrolstatus'.$i});
+ if ($enrolstatus == '') {
+ $status = null;
+ } else if ($enrolstatus === (string)ENROL_USER_ACTIVE) {
+ $status = ENROL_USER_ACTIVE;
+ } else if ($enrolstatus === (string)ENROL_USER_SUSPENDED) {
+ $status = ENROL_USER_SUSPENDED;
+ } else {
+ debugging('Unknown enrolment status.');
+ }
+ }
+
if (!empty($user->{'enrolperiod'.$i})) {
$duration = (int)$user->{'enrolperiod'.$i} * 60*60*24; // convert days to seconds
if ($duration > 0) { // sanity check
$timeend = $today + $manualcache[$courseid]->enrolperiod;
}
- $manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend);
+ $manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend, $status);
$a = new stdClass();
$a->course = $shortname;
// hack: somebody wrote uppercase in csv file, but the system knows only lowercase profile field
$newfield = $lcfield;
- } else if (preg_match('/^(cohort|course|group|type|role|enrolperiod)\d+$/', $lcfield)) {
+ } else if (preg_match('/^(cohort|course|group|type|role|enrolperiod|enrolstatus)\d+$/', $lcfield)) {
// special fields for enrolments
$newfield = $lcfield;
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
- $editors = editors_get_enabled();
- if (count($editors) > 1) {
- $choices = array();
- $choices['0'] = get_string('texteditor');
- $choices['1'] = get_string('htmleditor');
- $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
- $mform->setDefault('htmleditor', 1);
- } else {
- $mform->addElement('hidden', 'htmleditor');
- $mform->setDefault('htmleditor', 1);
- $mform->setType('htmleditor', PARAM_INT);
- }
-
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
$mform->setType('city', PARAM_TEXT);
if (empty($CFG->defaultcity)) {
$table->define_headers(array(get_string('plugin'), get_string('version'), $struninstall));
$table->define_baseurl($PAGE->url);
$table->set_attribute('id', 'toolplugins');
-$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->set_attribute('class', 'admintable generaltable');
$table->setup();
$plugins = array();
foreach ($plugins as $plugin => $name) {
$uninstall = '';
- if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('tool_'.$plugin)) {
+ if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('tool_'.$plugin, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
}
$plugin->version = 2013052100; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2013050100; // Requires this Moodle version
$plugin->component = 'auth_cas'; // Full name of the plugin (used for diagnostics)
+
+$plugin->dependencies = array('auth_ldap' => 2013052100);
}
}
+ /**
+ * Connect to external database.
+ *
+ * @return ADOConnection
+ */
function db_init() {
// Connect to the external database (forcing new connection).
$authdb = ADONewConnection($this->config->type);
}
return $text;
}
+
+ /**
+ * Test if settings are ok, print info to output.
+ * @private
+ */
+ public function test_settings() {
+ global $CFG, $OUTPUT;
+
+ // NOTE: this is not localised intentionally, admins are supposed to understand English at least a bit...
+
+ raise_memory_limit(MEMORY_HUGE);
+
+ if (empty($this->config->table)) {
+ echo $OUTPUT->notification('External table not specified.', 'notifyproblem');
+ return;
+ }
+
+ if (empty($this->config->fielduser)) {
+ echo $OUTPUT->notification('External user field not specified.', 'notifyproblem');
+ return;
+ }
+
+ $olddebug = $CFG->debug;
+ $olddisplay = ini_get('display_errors');
+ ini_set('display_errors', '1');
+ $CFG->debug = DEBUG_DEVELOPER;
+ $olddebugauthdb = $this->config->debugauthdb;
+ $this->config->debugauthdb = 1;
+ error_reporting($CFG->debug);
+
+ $adodb = $this->db_init();
+
+ if (!$adodb or !$adodb->IsConnected()) {
+ $this->config->debugauthdb = $olddebugauthdb;
+ $CFG->debug = $olddebug;
+ ini_set('display_errors', $olddisplay);
+ error_reporting($CFG->debug);
+ ob_end_flush();
+
+ echo $OUTPUT->notification('Cannot connect the database.', 'notifyproblem');
+ return;
+ }
+
+ $rs = $adodb->Execute("SELECT *
+ FROM {$this->config->table}
+ WHERE {$this->config->fielduser} <> 'random_unlikely_username'"); // Any unlikely name is ok here.
+
+ if (!$rs) {
+ echo $OUTPUT->notification('Can not read external table.', 'notifyproblem');
+
+ } else if ($rs->EOF) {
+ echo $OUTPUT->notification('External table is empty.', 'notifyproblem');
+ $rs->close();
+
+ } else {
+ $fields_obj = $rs->FetchObj();
+ $columns = array_keys((array)$fields_obj);
+
+ echo $OUTPUT->notification('External table contains following columns:<br />'.implode(', ', $columns), 'notifysuccess');
+ $rs->close();
+ }
+
+ $adodb->Close();
+
+ $this->config->debugauthdb = $olddebugauthdb;
+ $CFG->debug = $olddebug;
+ ini_set('display_errors', $olddisplay);
+ error_reporting($CFG->debug);
+ ob_end_flush();
+ }
}
--- /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/>.
+
+/**
+ * Test auth settings.
+ *
+ * @package core_auth
+ * @copyright 2013 Petr Skoda {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require(__DIR__.'../../config.php');
+require_once("$CFG->libdir/adminlib.php");
+
+$auth = optional_param('auth', '', PARAM_RAW);
+if (!core_component::is_valid_plugin_name('auth', $auth)) {
+ $auth = '';
+} else if (!file_exists("$CFG->dirroot/auth/$auth/auth.php")) {
+ $auth = '';
+}
+
+require_login();
+require_capability('moodle/site:config', context_system::instance());
+
+navigation_node::override_active_url(new moodle_url('/admin/settings.php', array('section'=>'manageauths')));
+admin_externalpage_setup('authtestsettings');
+
+$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
+
+echo $OUTPUT->header();
+
+if (!$auth) {
+ $options = array();
+ $plugins = core_component::get_plugin_list('auth');
+ foreach ($plugins as $name => $fulldir) {
+ $plugin = get_auth_plugin($name);
+ if (!$plugin or !method_exists($plugin, 'test_settings')) {
+ continue;
+ }
+ $options[$name] = get_string('pluginname', 'auth_'.$name);
+ }
+
+ if (!$options) {
+ redirect($returnurl);
+ }
+
+ echo $OUTPUT->heading(get_string('testsettings', 'core_auth'));
+
+ $url = new moodle_url('/auth/test_settings.php', array('sesskey'=>sesskey()));
+ echo $OUTPUT->single_select($url, 'auth', $options);
+
+ echo $OUTPUT->footer();
+}
+
+$plugin = get_auth_plugin($auth);
+if (!$plugin or !method_exists($plugin, 'test_settings')) {
+ redirect($returnurl);
+}
+
+echo $OUTPUT->heading(get_string('testsettingsheading', 'core_auth', get_string('pluginname', 'auth_'.$auth)));
+
+$plugin->test_settings();
+
+echo $OUTPUT->continue_button($returnurl);
+echo $OUTPUT->footer();
backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id);
}
$backup = new backup_ui($bc);
-$backup->process();
-$PAGE->set_title($heading.': '.$backup->get_stage_name());
+$PAGE->set_title($heading);
$PAGE->set_heading($heading);
-$PAGE->navbar->add($backup->get_stage_name());
$renderer = $PAGE->get_renderer('core','backup');
echo $OUTPUT->header();
+
+// Prepare a progress bar which can display optionally during long-running
+// operations while setting up the UI.
+$slowprogress = new core_backup_display_progress_if_slow(get_string('preparingui', 'backup'));
+
+$previous = optional_param('previous', false, PARAM_BOOL);
+if ($backup->get_stage() == backup_ui::STAGE_SCHEMA && !$previous) {
+ // After schema stage, we are probably going to get to the confirmation stage,
+ // The confirmation stage has 2 sets of progress, so this is needed to prevent
+ // it showing 2 progress bars.
+ $twobars = true;
+ $slowprogress->start_progress('', 2);
+} else {
+ $twobars = false;
+}
+$backup->get_controller()->set_progress($slowprogress);
+$backup->process();
+
if ($backup->enforce_changed_dependencies()) {
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
+$loghtml = '';
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
- // Display an extra progress bar so that we can show the progress first.
+ // Display an extra backup step bar so that we can show the 'processing' step first.
echo html_writer::start_div('', array('id' => 'executionprogress'));
echo $renderer->progress_bar($backup->get_progress_bar());
$backup->get_controller()->set_progress(new core_backup_display_progress());
+
+ // Prepare logger and add to end of chain.
+ $logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
+ $backup->get_controller()->add_logger($logger);
+
+ // Carry out actual backup.
$backup->execute();
+
+ // Get HTML from logger.
+ $loghtml = $logger->get_html();
+
+ // Hide the progress display and first backup step bar (the 'finished' step will show next).
echo html_writer::end_div();
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
} else {
$backup->save_controller();
}
+// Displaying UI can require progress reporting, so do it here before outputting
+// the backup stage bar (as part of the existing progress bar, if required).
+$ui = $backup->display($renderer);
+if ($twobars) {
+ $slowprogress->end_progress();
+}
+
echo $renderer->progress_bar($backup->get_progress_bar());
-echo $backup->display($renderer);
+
+echo $ui;
$backup->destroy();
unset($backup);
-echo $OUTPUT->footer();
\ No newline at end of file
+
+// Display log data if there was any.
+if ($loghtml != '') {
+ echo $renderer->log_display($loghtml);
+}
+
+echo $OUTPUT->footer();
function cssparser($html = true) {
// Register "destructor"
- register_shutdown_function(array(&$this, "finalize"));
+ core_shutdown_manager::register_function(array(&$this, "finalize"));
$this->html = ($html != false);
$this->Clear();
}
*
* TODO: Finish phpdocs
*/
-class backup_controller extends backup implements loggable {
+class backup_controller extends base_controller {
protected $backupid; // Unique identificator for this backup
protected $executiontime; // epoch time when we want the backup to be executed (requires cron to run)
protected $destination; // Destination chain object (fs_moodle, fs_os, db, email...)
- protected $logger; // Logging chain object (moodle, inline, fs, db, syslog)
-
- /**
- * @var core_backup_progress Progress reporting object.
- */
- protected $progress;
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
return $this->plan;
}
- public function get_logger() {
- return $this->logger;
- }
-
- /**
- * Gets the progress reporter, which can be used to report progress within
- * the backup or restore process.
- *
- * @return core_backup_progress Progress reporting object
- */
- public function get_progress() {
- return $this->progress;
- }
-
- /**
- * Sets the progress reporter.
- *
- * @param core_backup_progress $progress Progress reporting object
- */
- public function set_progress(core_backup_progress $progress) {
- $this->progress = $progress;
- }
-
/**
* Executes the backup
* @return void Throws and exception of completes
return $this->plan->get_results();
}
- public function log($message, $level, $a = null, $depth = null, $display = false) {
- backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
- }
-
/**
* Save controller information
*
--- /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/>.
+
+/**
+ * Base class with shared stuff between backup controller and restore
+ * controller.
+ *
+ * @package core_backup
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class base_controller extends backup implements loggable {
+ /**
+ * @var core_backup_progress Progress reporting object.
+ */
+ protected $progress;
+
+ /**
+ * @var base_logger Logging chain object (moodle, inline, fs, db, syslog)
+ */
+ protected $logger;
+
+ /**
+ * Gets the progress reporter, which can be used to report progress within
+ * the backup or restore process.
+ *
+ * @return core_backup_progress Progress reporting object
+ */
+ public function get_progress() {
+ return $this->progress;
+ }
+
+ /**
+ * Sets the progress reporter.
+ *
+ * @param core_backup_progress $progress Progress reporting object
+ */
+ public function set_progress(core_backup_progress $progress) {
+ $this->progress = $progress;
+ }
+
+ /**
+ * Gets first logger in logging chain.
+ *
+ * @return base_logger Logger
+ */
+ public function get_logger() {
+ return $this->logger;
+ }
+
+ /**
+ * Inserts a new logger at end of logging chain.
+ *
+ * @param base_logger $logger New logger to add
+ */
+ public function add_logger(base_logger $logger) {
+ $existing = $this->logger;
+ while ($existing->get_next()) {
+ $existing = $existing->get_next();
+ }
+ $existing->set_next($logger);
+ }
+
+ /**
+ * Logs data to the logger chain.
+ *
+ * @see loggable::log()
+ */
+ public function log($message, $level, $a = null, $depth = null, $display = false) {
+ backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
+ }
+}
\ No newline at end of file
*
* TODO: Finish phpdocs
*/
-class restore_controller extends backup implements loggable {
+class restore_controller extends base_controller {
protected $tempdir; // Directory under tempdir/backup awaiting restore
protected $restoreid; // Unique identificator for this restore
protected $execution; // inmediate/delayed
protected $executiontime; // epoch time when we want the restore to be executed (requires cron to run)
- protected $logger; // Logging chain object (moodle, inline, fs, db, syslog)
-
- /**
- * @var core_backup_progress Progress reporting object.
- */
- protected $progress;
-
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
/**
return $this->info;
}
- public function get_logger() {
- return $this->logger;
- }
-
- /**
- * Gets the progress reporter, which can be used to report progress within
- * the backup or restore process.
- *
- * @return core_backup_progress Progress reporting object
- */
- public function get_progress() {
- return $this->progress;
- }
-
- /**
- * Sets the progress reporter.
- *
- * @param core_backup_progress $progress Progress reporting object
- */
- public function set_progress(core_backup_progress $progress) {
- $this->progress = $progress;
- }
-
public function execute_plan() {
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
return $this->precheck;
}
- public function log($message, $level, $a = null, $depth = null, $display = false) {
- backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
- }
-
/**
* Save controller information
*
$progress->start_progress('', 2);
$backup->get_controller()->set_progress($progress);
+ // Prepare logger for backup.
+ $logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
+ $backup->get_controller()->add_logger($logger);
+
// First execute the backup
$backup->execute();
$backup->destroy();
// (the precheck and then the actual restore).
$progress->start_progress('Restore process', 2);
$rc->set_progress($progress);
+
+ // Set logger for restore.
+ $rc->add_logger($logger);
+
// Convert the backup if required.... it should NEVER happed
if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
$rc->convert();
}
echo $OUTPUT->notification(get_string('importsuccess', 'backup'), 'notifysuccess');
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
+
+ // Get and display log data if there was any.
+ $loghtml = $logger->get_html();
+ if ($loghtml != '') {
+ echo $renderer->log_display($loghtml);
+ }
+
echo $OUTPUT->footer();
die();
$qas = new backup_nested_element($nameprefix . 'question_attempts');
$qa = new backup_nested_element($nameprefix . 'question_attempt', array('id'), array(
- 'slot', 'behaviour', 'questionid', 'maxmark', 'minfraction',
+ 'slot', 'behaviour', 'questionid', 'maxmark', 'minfraction', 'maxfraction',
'flagged', 'questionsummary', 'rightanswer', 'responsesummary',
'timemodified'));
'confirmed', 'policyagreed', 'deleted',
'lang', 'theme', 'timezone', 'firstaccess',
'lastaccess', 'lastlogin', 'currentlogin',
- 'mailformat', 'maildigest', 'maildisplay', 'htmleditor',
+ 'mailformat', 'maildigest', 'maildisplay',
'autosubscribe', 'trackforums', 'timecreated',
'timemodified', 'trustbitmask');
$info['original_system_contextid'] = context_system::instance()->id;
// Get more information from controller
- list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($this->get_backupid());
+ list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information(
+ $this->get_backupid(), $this->get_task()->get_progress());
// Define elements
$has_file_references = backup_controller_dbops::backup_includes_file_references($this->get_backupid());
// Perform storage and return it (TODO: shouldn't be array but proper result object)
return array(
- 'backup_destination' => backup_helper::store_backup_file($this->get_backupid(), $zipfile),
+ 'backup_destination' => backup_helper::store_backup_file($this->get_backupid(), $zipfile,
+ $this->task->get_progress()),
'include_file_references_to_external_content' => $has_file_references
);
}
protected function define_execution() {
global $DB;
- $this->log('processing file aliases queue', backup::LOG_INFO);
+ $this->log('processing file aliases queue', backup::LOG_DEBUG);
$fs = get_file_storage();
$data->questionid = $question->newitemid;
$data->timemodified = $this->apply_date_offset($data->timemodified);
+ if (!property_exists($data, 'maxfraction')) {
+ $data->maxfraction = 1;
+ }
+
$newitemid = $DB->insert_record('question_attempts', $data);
$this->set_mapping($nameprefix . 'question_attempt', $oldid, $newitemid);
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
+$loghtml = '';
if (!$restore->is_independent()) {
// Use a temporary (disappearing) progress bar to show the precheck progress if any.
$precheckprogress = new core_backup_display_progress_if_slow(get_string('preparingdata', 'backup'));
// Show the current restore state (header with bolded item).
echo $renderer->progress_bar($restore->get_progress_bar());
// Start displaying the actual progress bar percentage.
- $restore->get_controller()->set_progress(new core_backup_display_progress(true));
+ $restore->get_controller()->set_progress(new core_backup_display_progress());
+ // Prepare logger.
+ $logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
+ $restore->get_controller()->add_logger($logger);
// Do actual restore.
$restore->execute();
+ // Get HTML from logger.
+ $loghtml = $logger->get_html();
// Hide this section because we are now going to make the page show 'finished'.
echo html_writer::end_div();
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
echo $restore->display($renderer);
$restore->destroy();
unset($restore);
+
+// Display log data if there was any.
+if ($loghtml != '') {
+ echo $renderer->log_display($loghtml);
+}
+
echo $OUTPUT->footer();
/**
* Get details information for main moodle_backup.xml file, extracting it from
- * the specified controller
+ * the specified controller.
+ *
+ * If you specify the progress monitor, this will start a new progress section
+ * to track progress in processing (in case this task takes a long time).
+ *
+ * @param string $backupid Backup ID
+ * @param core_backup_progress $progress Optional progress monitor
*/
- public static function get_moodle_backup_information($backupid) {
+ public static function get_moodle_backup_information($backupid,
+ core_backup_progress $progress = null) {
+
+ // Start tracking progress if required (for load_controller).
+ if ($progress) {
+ $progress->start_progress('get_moodle_backup_information', 2);
+ }
$detailsinfo = array(); // Information details
$contentsinfo= array(); // Information about backup contents
$settingsinfo= array(); // Information about backup settings
$bc = self::load_controller($backupid); // Load controller
+ // Note that we have loaded controller.
+ if ($progress) {
+ $progress->progress(1);
+ }
+
// Details info
$detailsinfo['id'] = $bc->get_id();
$detailsinfo['backup_id'] = $bc->get_backupid();
$contentsinfo['sections'] = array();
$contentsinfo['course'] = array();
+ // Get tasks and start nested progress.
+ $tasks = $bc->get_plan()->get_tasks();
+ if ($progress) {
+ $progress->start_progress('get_moodle_backup_information', count($tasks));
+ $done = 1;
+ }
+
// Contents info (extract information from tasks)
- foreach ($bc->get_plan()->get_tasks() as $task) {
+ foreach ($tasks as $task) {
if ($task instanceof backup_activity_task) { // Activity task
list($contentinfo, $settings) = self::get_root_backup_information($task);
$settingsinfo = array_merge($settingsinfo, $settings);
}
+
+ // Report task handled.
+ if ($progress) {
+ $progress->progress($done++);
+ }
}
$bc->destroy(); // Always need to destroy controller to handle circular references
+ // Finish progress reporting.
+ if ($progress) {
+ $progress->end_progress();
+ $progress->end_progress();
+ }
+
return array(array((object)$detailsinfo), $contentsinfo, $settingsinfo);
}
$status = $DB->insert_record('user_preferences', $preference);
}
}
+ // Special handling for htmleditor which was converted to a preference.
+ if (isset($user->htmleditor)) {
+ if ($user->htmleditor == 0) {
+ $preference = new stdClass();
+ $preference->userid = $newuserid;
+ $preference->name = 'htmleditor';
+ $preference->value = 'textarea';
+ $status = $DB->insert_record('user_preferences', $preference);
+ }
+ }
// Create user files in pool (profile, icon, private) by context
restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
*
* Note: the $filepath is deleted if the backup file is created successfully
*
+ * If you specify the progress monitor, this will start a new progress section
+ * to track progress in processing (in case this task takes a long time).
+ *
* @param int $backupid
* @param string $filepath zip file containing the backup
+ * @param core_backup_progress $progress Optional progress monitor
* @return stored_file if created, null otherwise
*
* @throws moodle_exception in case of any problems
*/
- static public function store_backup_file($backupid, $filepath) {
+ static public function store_backup_file($backupid, $filepath, core_backup_progress $progress = null) {
global $CFG;
// First of all, get some information from the backup_controller to help us decide
- list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($backupid);
+ list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information(
+ $backupid, $progress);
// Extract useful information to decide
$hasusers = (bool)$sinfo['users']->value; // Backup has users
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
+require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
require_once($CFG->dirroot . '/backup/util/progress/core_backup_null_progress.class.php');
require_once($CFG->dirroot . '/backup/util/progress/core_backup_display_progress.class.php');
+require_once($CFG->dirroot . '/backup/util/progress/core_backup_display_progress_if_slow.class.php');
require_once($CFG->dirroot . '/backup/util/settings/setting_dependency.class.php');
require_once($CFG->dirroot . '/backup/util/settings/base_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/plan/backup_step.class.php');
require_once($CFG->dirroot . '/backup/util/plan/backup_structure_step.class.php');
require_once($CFG->dirroot . '/backup/util/plan/backup_execution_step.class.php');
+require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');
require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php');
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
+require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
require_once($CFG->dirroot . '/backup/util/plan/restore_structure_step.class.php');
require_once($CFG->dirroot . '/backup/util/plan/restore_execution_step.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_plan_builder.class.php');
+require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');
require_once($CFG->dirroot . '/backup/controller/restore_controller.class.php');
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
--- /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/>.
+
+/**
+ * Logger that stores HTML log data in memory, ready for later display.
+ *
+ * @package core_backup
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_backup_html_logger extends base_logger {
+ /**
+ * @var string HTML output
+ */
+ protected $html = '';
+
+ protected function action($message, $level, $options = null) {
+ $prefix = $this->get_prefix($level, $options);
+ $depth = isset($options['depth']) ? $options['depth'] : 0;
+ $this->html .= $prefix . str_repeat(' ', $depth) .
+ s($message) . '<br/>' . PHP_EOL;
+ return true;
+ }
+
+ /**
+ * Gets the full HTML content of the log.
+ *
+ * @return string HTML content of log
+ */
+ public function get_html() {
+ return $this->html;
+ }
+}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_ui_stage_schema extends backup_ui_stage {
+ /**
+ * @var int Maximum number of settings to add to form at once
+ */
+ const MAX_SETTINGS_BATCH = 1000;
+
/**
* Schema stage constructor
* @param backup_moodleform $ui
$courseheading = false;
$add_settings = array();
$dependencies = array();
+
+ // Track progress through each stage.
+ $progress = $this->ui->get_controller()->get_progress();
+ $progress->start_progress('Initialise stage form', 3);
+
+ // Get settings for all tasks.
+ $progress->start_progress('', count($tasks));
+ $done = 1;
foreach ($tasks as $task) {
if (!($task instanceof backup_root_task)) {
if (!$courseheading) {
}
}
}
+ // Update progress.
+ $progress->progress($done++);
}
- $form->add_settings($add_settings);
+ $progress->end_progress();
+
+ // Add settings for tasks in batches of up to 1000. Adding settings
+ // in larger batches improves performance, but if it takes too long,
+ // we won't be able to update the progress bar so the backup might
+ // time out. 1000 is chosen to balance this.
+ $numsettings = count($add_settings);
+ $progress->start_progress('', ceil($numsettings / self::MAX_SETTINGS_BATCH));
+ $start = 0;
+ $done = 1;
+ while($start < $numsettings) {
+ $length = min(self::MAX_SETTINGS_BATCH, $numsettings - $start);
+ $form->add_settings(array_slice($add_settings, $start, $length));
+ $start += $length;
+ $progress->progress($done++);
+ }
+ $progress->end_progress();
+
+ $progress->start_progress('', count($dependencies));
+ $done = 1;
foreach ($dependencies as $depsetting) {
$form->add_dependencies($depsetting);
+ $progress->progress($done++);
}
+ $progress->end_progress();
+
+ // End overall progress through creating form.
+ $progress->end_progress();
$this->stageform = $form;
}
return $this->stageform;
}
}
- foreach ($this->ui->get_tasks() as $task) {
+ // Track progress through tasks.
+ $progress = $this->ui->get_controller()->get_progress();
+ $tasks = $this->ui->get_tasks();
+ $progress->start_progress('initialise_stage_form', count($tasks));
+ $done = 1;
+
+ foreach ($tasks as $task) {
if ($task instanceof backup_root_task) {
// If its a backup root add a root settings heading to group nicely
$form->add_heading('rootsettings', get_string('rootsettings', 'backup'));
$form->add_fixed_setting($setting, $task);
}
}
+ // Update progress.
+ $progress->progress($done++);
}
+ $progress->end_progress();
$this->stageform = $form;
}
return $this->stageform;
}
return html_writer::tag('div', join(get_separator(), $items), array('class'=>'backup_progress clearfix'));
}
+
+ /**
+ * The backup and restore pages may display a log (if any) in a scrolling box.
+ *
+ * @param string $loghtml Log content in HTML format
+ * @return string HTML content that shows the log
+ */
+ public function log_display($loghtml) {
+ global $OUTPUT;
+ $out = html_writer::start_div('backup_log');
+ $out .= $OUTPUT->heading(get_string('backuplog', 'backup'));
+ $out .= html_writer::start_div('backup_log_contents');
+ $out .= $loghtml;
+ $out .= html_writer::end_div();
+ $out .= html_writer::end_div();
+ return $out;
+ }
+
/**
* Prints a dependency notification
* @param string $message
$outcome = new stdClass();
$outcome->code = $result;
$outcome->response = get_string('error:backpacknotavailable', 'badges') . $OUTPUT->help_icon('backpackavailability', 'badges');
+
+echo $OUTPUT->header();
echo json_encode($outcome);
die();
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
+define('AJAX_SCRIPT', true);
+
require_once(dirname(dirname(__FILE__)) . '/config.php');
if (empty($CFG->enablebadges)) {
$json = $assertion->get_badge_assertion();
}
-header('Content-type: application/json; charset=utf-8');
+echo $OUTPUT->header();
echo json_encode($json);
require_login();
$PAGE->set_url('/badges/backpackconnect.php');
$PAGE->set_context(context_system::instance());
+echo $OUTPUT->header();
// Use PHP input filtering as there is no PARAM type for
// the type of cleaning that is required (ASCII chars 32-127 only).
// In courseset, print out only the ones that were already selected.
foreach ($this->params as $p) {
if ($course = $DB->get_record('course', array('id' => $p['course']))) {
+ $coursecontext = context_course::instance($course->id);
$param = array(
'id' => $course->id,
'checked' => true,
- 'name' => ucfirst($course->fullname),
+ 'name' => ucfirst(format_string($course->fullname, true, array('context' => $coursecontext))),
'error' => false
);
navigation_node::override_active_url(new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)));
} else {
require_login($course);
+ $coursecontext = context_course::instance($course->id);
$title = get_string('coursebadges', 'badges');
- $PAGE->set_context(context_course::instance($course->id));
+ $PAGE->set_context($coursecontext);
$PAGE->set_pagelayout('course');
- $PAGE->set_heading($course->fullname . ': ' . $hdr);
+ $PAGE->set_heading(format_string($course->fullname, true, array('context' => $coursecontext)) . ': ' . $hdr);
navigation_node::override_active_url(
new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_COURSE, 'id' => $course->id))
);
if (($type == BADGE_TYPE_COURSE) && ($course = $DB->get_record('course', array('id' => $courseid)))) {
require_login($course);
- $PAGE->set_context(context_course::instance($course->id));
+ $coursecontext = context_course::instance($course->id);
+ $PAGE->set_context($coursecontext);
$PAGE->set_pagelayout('course');
$PAGE->set_url('/badges/newbadge.php', array('type' => $type, 'id' => $course->id));
- $PAGE->set_heading($course->fullname . ": " . $title);
- $PAGE->set_title($course->fullname . ": " . $title);
+ $heading = format_string($course->fullname, true, array('context' => $coursecontext)) . ": " . $title;
+ $PAGE->set_heading($heading);
+ $PAGE->set_title($heading);
} else {
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
// Local badges.
$localhtml = html_writer::start_tag('fieldset', array('id' => 'issued-badge-table', 'class' => 'generalbox'));
- $localhtml .= html_writer::tag('legend',
- $this->output->heading_with_help(get_string('localbadges', 'badges', $SITE->fullname), 'localbadgesh', 'badges'));
+ $heading = get_string('localbadges', 'badges', format_string($SITE->fullname, true, array('context' => context_system::instance())));
+ $localhtml .= html_writer::tag('legend', $this->output->heading_with_help($heading, 'localbadgesh', 'badges'));
if ($badges->badges) {
$table = new html_table();
$table->attributes['class'] = 'statustable';
$PAGE->set_heading($title);
} else {
require_login($course);
- $title = $course->fullname . ': ' . get_string('coursebadges', 'badges');
+ $coursename = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
+ $title = $coursename . ': ' . get_string('coursebadges', 'badges');
$PAGE->set_context(context_course::instance($course->id));
$PAGE->set_pagelayout('course');
$PAGE->set_heading($title);
<?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/>.
+/**
+ * Handles displaying the calendar block.
+ *
+ * @package block_calendar_month
+ * @copyright 2004 Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class block_calendar_month extends block_base {
- function init() {
+
+ /**
+ * Initialise the block.
+ */
+ public function init() {
$this->title = get_string('pluginname', 'block_calendar_month');
}
- function preferred_width() {
+ /**
+ * Return preferred_width.
+ *
+ * @return int
+ */
+ public function preferred_width() {
return 210;
}
- function get_content() {
- global $USER, $CFG, $SESSION;
- $cal_m = optional_param( 'cal_m', 0, PARAM_INT );
- $cal_y = optional_param( 'cal_y', 0, PARAM_INT );
+ /**
+ * Return the content of this block.
+ *
+ * @return stdClass the content
+ */
+ public function get_content() {
+ global $CFG;
+
+ $calm = optional_param('cal_m', 0, PARAM_INT);
+ $caly = optional_param('cal_y', 0, PARAM_INT);
+ $time = optional_param('time', 0, PARAM_INT);
require_once($CFG->dirroot.'/calendar/lib.php');
- if ($this->content !== NULL) {
+ if ($this->content !== null) {
return $this->content;
}
+ // If a day, month and year were passed then convert it to a timestamp. If these were passed then we can assume
+ // the day, month and year are passed as Gregorian, as no where in core should we be passing these values rather
+ // than the time. This is done for BC.
+ if (!empty($calm) && (!empty($caly))) {
+ $time = make_timestamp($caly, $calm, 1);
+ } else if (empty($time)) {
+ $time = time();
+ }
+
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
list($courses, $group, $user) = calendar_set_filters($filtercourse);
if ($issite) {
- // For the front page
- $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'frontpage', $courseid);
- // No filters for now
+ // For the front page.
+ $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'frontpage', $courseid, $time);
+ // No filters for now.
} else {
- // For any other course
- $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'course', $courseid);
+ // For any other course.
+ $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'course', $courseid, $time);
$this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
$this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
}
<?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.
+//
+// Moo