MDL-48383 task: Indicate when a task will not run if plugin is disabled
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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:<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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user