diff --git a/admin/tool/task/lang/en/tool_task.php b/admin/tool/task/lang/en/tool_task.php index 493fa1dea90..6b4410e27b8 100644 --- a/admin/tool/task/lang/en/tool_task.php +++ b/admin/tool/task/lang/en/tool_task.php @@ -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:
'; $string['taskscheduledayofweek'] = 'Day of week'; diff --git a/admin/tool/task/renderer.php b/admin/tool/task/renderer.php index f32c9e0025e..360ec9e8622 100644 --- a/admin/tool/task/renderer.php +++ b/admin/tool/task/renderer.php @@ -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; diff --git a/admin/tool/task/scheduledtasks.php b/admin/tool/task/scheduledtasks.php index 2b38300e9ea..768d4bc0065 100644 --- a/admin/tool/task/scheduledtasks.php +++ b/admin/tool/task/scheduledtasks.php @@ -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()) { diff --git a/config-dist.php b/config-dist.php index 47ffb73416f..c182b8741c8 100644 --- a/config-dist.php +++ b/config-dist.php @@ -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