mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-45329 admin_task: Allow scheduled task change prevention
Some hosting providers have a requirement to prevent users making modifications to the configuration of scheduled tasks as doing so may have a negative impact not only on their own site, but also on the performance of other sites (depending on host configuration). For example, if the statistics or automated backup tasks were run every minute, this could have a negative impact for other users).
This commit is contained in:
parent
f500ff4e52
commit
f12f34166d
@ -37,6 +37,7 @@ $string['pluginname'] = 'Scheduled task configuration';
|
||||
$string['resettasktodefaults'] = 'Reset task schedule to defaults';
|
||||
$string['resettasktodefaults_help'] = 'This will discard any local changes and revert the schedule for this task back to its original settings.';
|
||||
$string['scheduledtasks'] = 'Scheduled tasks';
|
||||
$string['scheduledtaskchangesdisabled'] = 'Modifications to the list of scheduled tasks have been prevented in Moodle configuration';
|
||||
$string['taskscheduleday'] = 'Day';
|
||||
$string['taskscheduleday_help'] = 'Day of month field for task schedule. The field uses the same format as unix cron. Some examples are:<br/><ul><li><strong>*</strong> Every day</li><li><strong>*/2</strong> Every 2nd day</li><li><strong>1</strong> The first of every month</li><li><strong>1,15</strong> The first and fifteenth of every month</li></ul>';
|
||||
$string['taskscheduledayofweek'] = 'Day of week';
|
||||
|
@ -39,6 +39,8 @@ class tool_task_renderer extends plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function scheduled_tasks_table($tasks) {
|
||||
global $CFG;
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('name'),
|
||||
get_string('component', 'tool_task'),
|
||||
@ -70,8 +72,12 @@ class tool_task_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$nextrun = $asap;
|
||||
}
|
||||
$configureurl = new moodle_url('/admin/tool/task/scheduledtasks.php', array('action'=>'edit', 'task' => get_class($task)));
|
||||
$editlink = $this->action_icon($configureurl, new pix_icon('t/edit', get_string('edittaskschedule', 'tool_task', $task->get_name())));
|
||||
if (empty($CFG->preventscheduledtaskchanges)) {
|
||||
$configureurl = new moodle_url('/admin/tool/task/scheduledtasks.php', array('action'=>'edit', 'task' => get_class($task)));
|
||||
$editlink = $this->action_icon($configureurl, new pix_icon('t/edit', get_string('edittaskschedule', 'tool_task', $task->get_name())));
|
||||
} else {
|
||||
$editlink = $this->render(new pix_icon('t/locked', get_string('scheduledtaskchangesdisabled', 'tool_task')));
|
||||
}
|
||||
|
||||
$namecell = new html_table_cell($task->get_name() . "\n" . html_writer::tag('span', '\\'.get_class($task), array('class' => 'task-class')));
|
||||
$namecell->header = true;
|
||||
|
@ -59,9 +59,9 @@ if ($task) {
|
||||
$mform = new tool_task_edit_scheduled_task_form(null, $task);
|
||||
}
|
||||
|
||||
if ($mform && $mform->is_cancelled()) {
|
||||
if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchanges))) {
|
||||
redirect(new moodle_url('/admin/tool/task/scheduledtasks.php'));
|
||||
} else if ($action == 'edit') {
|
||||
} else if ($action == 'edit' && empty($CFG->preventscheduledtaskchanges)) {
|
||||
|
||||
if ($data = $mform->get_data()) {
|
||||
|
||||
|
@ -452,6 +452,11 @@ $CFG->admin = 'admin';
|
||||
//
|
||||
// $CFG->disableonclickaddoninstall = true;
|
||||
//
|
||||
// Use the following flag to disable modifications to scheduled tasks
|
||||
// whilst still showing the state of tasks.
|
||||
//
|
||||
// $CFG->preventscheduledtaskchanges = true;
|
||||
//
|
||||
// As of version 2.4 Moodle serves icons as SVG images if the users browser appears
|
||||
// to support SVG.
|
||||
// For those wanting to control the serving of SVG images the following setting can
|
||||
|
Loading…
x
Reference in New Issue
Block a user