MDL-70230 admin: add setting sched. task status

When defining settings that are used by scheduled tasks,
it is also useful, or even needed, to know the status
of that scheduled task to have the whole big picture of
that part of the system.

Based on the admin_setting_description, this new setting
reports its name, its status, a link to the configuration.

When adding a new setting of this type, the user can add
an extra description field to complete the whole meaning.
This commit is contained in:
Jordi Pujol Ahulló 2020-11-16 16:54:45 +01:00
parent 411150a424
commit 9c4510a358
7 changed files with 171 additions and 8 deletions

View file

@ -76,7 +76,7 @@ class tool_task_renderer extends plugin_renderer_base {
$data = [];
$yes = get_string('yes');
$no = get_string('no');
$canruntasks = \core\task\manager::is_runnable();
$canruntasks = \core\task\manager::is_runnable() && get_config('tool_task', 'enablerunnow');
foreach ($tasks as $task) {
$classname = get_class($task);
$defaulttask = \core\task\manager::get_default_scheduled_task($classname, false);
@ -108,14 +108,11 @@ class tool_task_renderer extends plugin_renderer_base {
}
$namecell = new html_table_cell($namecellcontent);
$namecell->header = true;
$plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component());
$plugindisabled = $plugininfo && $plugininfo->is_enabled() === false &&
!$task->get_run_if_component_disabled();
$disabled = $plugindisabled || $task->get_disabled();
$namecell->id = scheduled_task::get_html_id($classname);
$runnow = '';
if (!$plugindisabled && get_config('tool_task', 'enablerunnow') && $canruntasks ) {
$canrunthistask = $canruntasks && $task->can_run();
if ($canrunthistask) {
$runnow = html_writer::div(html_writer::link(
new moodle_url('/admin/tool/task/schedule_task.php',
['task' => $classname]),
@ -147,7 +144,7 @@ class tool_task_renderer extends plugin_renderer_base {
new html_table_cell($customised)]);
$classes = [];
if ($disabled) {
if (!$task->is_enabled()) {
$classes[] = 'disabled';
}
if (get_class($task) == $lastchanged) {

View file

@ -15,3 +15,7 @@
#page-admin-tool-task-scheduledtasks .task-clearfaildelay {
font-size: 0.75em;
}
#page-admin-tool-task-scheduledtasks :target {
scroll-margin-top: 60px;
}