diff --git a/admin/tool/task/classes/edit_scheduled_task_form.php b/admin/tool/task/classes/edit_scheduled_task_form.php index d59710c46e9..21d251875bb 100644 --- a/admin/tool/task/classes/edit_scheduled_task_form.php +++ b/admin/tool/task/classes/edit_scheduled_task_form.php @@ -38,10 +38,15 @@ class tool_task_edit_scheduled_task_form extends moodleform { /** @var \core\task\scheduled_task $task */ $task = $this->_customdata; + $plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component()); + $plugindisabled = $plugininfo && $plugininfo->is_enabled() === false && !$task->get_run_if_component_disabled(); + $lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : get_string('never'); $nextrun = $task->get_next_run_time(); - if ($task->get_disabled()) { - $nextrun = get_string('disabled', 'tool_task'); + if ($plugindisabled) { + $nextrun = get_string('plugindisabled', 'tool_task'); + } else if ($task->get_disabled()) { + $nextrun = get_string('taskdisabled', 'tool_task'); } else if ($nextrun > time()) { $nextrun = userdate($nextrun); } else { diff --git a/admin/tool/task/cli/schedule_task.php b/admin/tool/task/cli/schedule_task.php index 62b0ad984cc..3476c1df235 100644 --- a/admin/tool/task/cli/schedule_task.php +++ b/admin/tool/task/cli/schedule_task.php @@ -72,8 +72,13 @@ if ($options['list']) { . $task->get_day_of_week(); $nextrun = $task->get_next_run_time(); - if ($task->get_disabled()) { - $nextrun = get_string('disabled', 'tool_task'); + $plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component()); + $plugindisabled = $plugininfo && $plugininfo->is_enabled() === false && !$task->get_run_if_component_disabled(); + + if ($plugindisabled) { + $nextrun = get_string('plugindisabled', 'tool_task'); + } else if ($task->get_disabled()) { + $nextrun = get_string('taskdisabled', 'tool_task'); } else if ($nextrun > time()) { $nextrun = userdate($nextrun); } else { diff --git a/admin/tool/task/lang/en/tool_task.php b/admin/tool/task/lang/en/tool_task.php index 6b4410e27b8..fa6fe776885 100644 --- a/admin/tool/task/lang/en/tool_task.php +++ b/admin/tool/task/lang/en/tool_task.php @@ -33,11 +33,13 @@ $string['edittaskschedule'] = 'Edit task schedule: {$a}'; $string['faildelay'] = 'Fail delay'; $string['lastruntime'] = 'Last run'; $string['nextruntime'] = 'Next run'; +$string['plugindisabled'] = 'Plugin disabled'; $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['taskdisabled'] = 'Task disabled'; $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 360ec9e8622..93975af5ee4 100644 --- a/admin/tool/task/renderer.php +++ b/admin/tool/task/renderer.php @@ -60,18 +60,10 @@ class tool_task_renderer extends plugin_renderer_base { $no = get_string('no'); $never = get_string('never'); $asap = get_string('asap', 'tool_task'); - $disabled = get_string('disabled', 'tool_task'); + $disabledstr = get_string('taskdisabled', 'tool_task'); + $plugindisabledstr = get_string('plugindisabled', 'tool_task'); foreach ($tasks as $task) { $customised = $task->is_customised() ? $no : $yes; - $lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : $never; - $nextrun = $task->get_next_run_time(); - if ($task->get_disabled()) { - $nextrun = $disabled; - } else if ($nextrun > time()) { - $nextrun = userdate($nextrun); - } else { - $nextrun = $asap; - } 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()))); @@ -83,6 +75,7 @@ class tool_task_renderer extends plugin_renderer_base { $namecell->header = true; $component = $task->get_component(); + $plugininfo = null; list($type, $plugin) = core_component::normalize_component($component); if ($type === 'core') { $componentcell = new html_table_cell(get_string('corecomponent', 'tool_task')); @@ -95,6 +88,21 @@ class tool_task_renderer extends plugin_renderer_base { } } + $lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : $never; + $nextrun = $task->get_next_run_time(); + $disabled = false; + if ($plugininfo && $plugininfo->is_enabled() === false && !$task->get_run_if_component_disabled()) { + $disabled = true; + $nextrun = $plugindisabledstr; + } else if ($task->get_disabled()) { + $disabled = true; + $nextrun = $disabledstr; + } else if ($nextrun > time()) { + $nextrun = userdate($nextrun); + } else { + $nextrun = $asap; + } + $row = new html_table_row(array( $namecell, $componentcell, @@ -109,7 +117,7 @@ class tool_task_renderer extends plugin_renderer_base { new html_table_cell($task->get_fail_delay()), new html_table_cell($customised))); - if ($task->get_disabled()) { + if ($disabled) { $row->attributes['class'] = 'disabled'; } $data[] = $row; diff --git a/lib/classes/task/manager.php b/lib/classes/task/manager.php index 1f34954b041..5c6bef2d19b 100644 --- a/lib/classes/task/manager.php +++ b/lib/classes/task/manager.php @@ -505,7 +505,6 @@ class manager { if ($plugininfo) { if (($plugininfo->is_enabled() === false) && !$task->get_run_if_component_disabled()) { - mtrace($task->get_name().' skipped - the component '.$task->get_component().' is disabled'); $lock->release(); continue; }