See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Web cron single task 19 * 20 * This script runs a single scheduled task from the web UI. 21 * 22 * @package tool_task 23 * @copyright 2016 The Open University 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 define('NO_OUTPUT_BUFFERING', true); 28 29 require('../../../config.php'); 30 31 require_once($CFG->libdir.'/cronlib.php'); 32 33 // Allow execution of single task. This requires login and has different rules. 34 $taskname = required_param('task', PARAM_RAW_TRIMMED); 35 36 // Basic security checks. 37 require_admin(); 38 $context = context_system::instance(); 39 40 if (!get_config('tool_task', 'enablerunnow')) { 41 print_error('nopermissions', 'error', '', get_string('runnow', 'tool_task')); 42 } 43 44 // Check input parameter against all existing tasks (this ensures it isn't possible to 45 // create some kind of security problem by specifying a class that isn't a task or whatever). 46 $task = \core\task\manager::get_scheduled_task($taskname); 47 if (!$task) { 48 print_error('cannotfindinfo', 'error', $taskname); 49 } 50 51 // Start output. 52 $PAGE->set_url(new moodle_url('/admin/tool/task/schedule_task.php')); 53 $PAGE->set_context($context); 54 $PAGE->navbar->add(get_string('scheduledtasks', 'tool_task'), new moodle_url('/admin/tool/task/scheduledtasks.php')); 55 $PAGE->navbar->add(s($task->get_name())); 56 echo $OUTPUT->header(); 57 echo $OUTPUT->heading($task->get_name()); 58 59 // The initial request just shows the confirmation page; we don't do anything further unless 60 // they confirm. 61 if (!optional_param('confirm', 0, PARAM_INT)) { 62 echo $OUTPUT->confirm(get_string('runnow_confirm', 'tool_task', $task->get_name()), 63 new single_button(new moodle_url('/admin/tool/task/schedule_task.php', 64 ['task' => $taskname, 'confirm' => 1, 'sesskey' => sesskey()]), 65 get_string('runnow', 'tool_task')), 66 new single_button(new moodle_url('/admin/tool/task/scheduledtasks.php', 67 ['lastchanged' => get_class($task)]), 68 get_string('cancel'), false)); 69 echo $OUTPUT->footer(); 70 exit; 71 } 72 73 // Action requires session key. 74 require_sesskey(); 75 76 // Prepare to handle output via mtrace. 77 echo html_writer::start_tag('pre'); 78 require ('lib.php'); 79 $CFG->mtrace_wrapper = 'tool_task_mtrace_wrapper'; 80 81 // Run the specified task (this will output an error if it doesn't exist). 82 \core\task\manager::run_from_cli($task); 83 84 echo html_writer::end_tag('pre'); 85 86 $output = $PAGE->get_renderer('tool_task'); 87 88 // Re-run the specified task (this will output an error if it doesn't exist). 89 echo $OUTPUT->single_button(new moodle_url('/admin/tool/task/schedule_task.php', 90 array('task' => $taskname, 'confirm' => 1, 'sesskey' => sesskey())), 91 get_string('runagain', 'tool_task')); 92 echo $output->link_back(get_class($task)); 93 94 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body