MDL-48383 task: Indicate when a task will not run if plugin is disabled

This commit is contained in:
Frederic Massart
2015-01-22 11:07:52 +08:00
parent da0ef2e4cf
commit 18247eb090
5 changed files with 35 additions and 16 deletions
+19 -11
View File
@@ -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;