MDL-55980 Scheduled tasks: Run individual scheduled tasks from web
[moodle.git] / admin / tool / task / renderer.php
index 076f092..575aa66 100644 (file)
@@ -104,11 +104,19 @@ class tool_task_renderer extends plugin_renderer_base {
                 $nextrun = $asap;
             }
 
+            $runnow = '';
+            if (!$disabled && get_config('tool_task', 'enablerunnow')) {
+                $runnow = html_writer::div(html_writer::link(
+                        new moodle_url('/admin/tool/task/schedule_task.php',
+                            array('task' => get_class($task))),
+                        get_string('runnow', 'tool_task')), 'task-runnow');
+            }
+
             $row = new html_table_row(array(
                         $namecell,
                         $componentcell,
                         new html_table_cell($editlink),
-                        new html_table_cell($lastrun),
+                        new html_table_cell($lastrun . $runnow),
                         new html_table_cell($nextrun),
                         new html_table_cell($task->get_minute()),
                         new html_table_cell($task->get_hour()),
@@ -133,4 +141,14 @@ class tool_task_renderer extends plugin_renderer_base {
         $table->data = $data;
         return html_writer::table($table);
     }
+
+    /**
+     * Renders a link back to the scheduled tasks page (used from the 'run now' screen).
+     *
+     * @return string HTML code
+     */
+    public function link_back() {
+        return $this->render_from_template('tool_task/link_back',
+                array('url' => new moodle_url('/admin/tool/task/scheduledtasks.php')));
+    }
 }