Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 * Scheduled task admin pages. 19 * 20 * @package tool_task 21 * @copyright 2013 Damyon Wiese <damyon@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once(__DIR__ . '/../../../config.php'); 26 require_once($CFG->libdir.'/adminlib.php'); 27 require_once($CFG->libdir.'/tablelib.php'); 28 29 admin_externalpage_setup('scheduledtasks'); 30 31 $action = optional_param('action', '', PARAM_ALPHAEXT); 32 $taskname = optional_param('task', '', PARAM_RAW); 33 $lastchanged = optional_param('lastchanged', '', PARAM_RAW); 34 35 $task = null; 36 $mform = null; 37 38 if ($taskname) { 39 $task = \core\task\manager::get_scheduled_task($taskname); 40 if (!$task) { 41 print_error('invaliddata'); 42 } 43 } 44 45 if ($action == 'edit') { 46 $PAGE->navbar->add(get_string('edittaskschedule', 'tool_task', $task->get_name())); 47 } 48 49 if ($task) { 50 $mform = new tool_task_edit_scheduled_task_form(null, $task); 51 $nexturl = new moodle_url($PAGE->url, ['lastchanged' => $taskname]); 52 } 53 54 $renderer = $PAGE->get_renderer('tool_task'); 55 56 if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchanges) || $task->is_overridden())) { 57 redirect($nexturl); 58 } else if ($action == 'edit' && empty($CFG->preventscheduledtaskchanges)) { 59 60 if ($data = $mform->get_data()) { 61 if ($data->resettodefaults) { 62 $defaulttask = \core\task\manager::get_default_scheduled_task($taskname); 63 $task->set_minute($defaulttask->get_minute()); 64 $task->set_hour($defaulttask->get_hour()); 65 $task->set_month($defaulttask->get_month()); 66 $task->set_day_of_week($defaulttask->get_day_of_week()); 67 $task->set_day($defaulttask->get_day()); 68 $task->set_disabled($defaulttask->get_disabled()); 69 $task->set_customised(false); 70 } else { 71 $task->set_minute($data->minute); 72 $task->set_hour($data->hour); 73 $task->set_month($data->month); 74 $task->set_day_of_week($data->dayofweek); 75 $task->set_day($data->day); 76 $task->set_disabled($data->disabled); 77 $task->set_customised(true); 78 } 79 80 try { 81 \core\task\manager::configure_scheduled_task($task); 82 redirect($nexturl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS); 83 } catch (Exception $e) { 84 redirect($nexturl, $e->getMessage(), null, \core\output\notification::NOTIFY_ERROR); 85 } 86 } else { 87 echo $OUTPUT->header(); 88 echo $OUTPUT->heading(get_string('edittaskschedule', 'tool_task', $task->get_name())); 89 echo html_writer::div('\\' . get_class($task), 'task-class text-ltr'); 90 echo html_writer::div(get_string('fromcomponent', 'tool_task', 91 $renderer->component_name($task->get_component()))); 92 $mform->display(); 93 echo $OUTPUT->footer(); 94 } 95 96 } else { 97 echo $OUTPUT->header(); 98 if (!get_config('core', 'cron_enabled')) { 99 echo $renderer->cron_disabled(); 100 } 101 $tasks = core\task\manager::get_all_scheduled_tasks(); 102 echo $renderer->scheduled_tasks_table($tasks, $lastchanged); 103 echo $OUTPUT->footer(); 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body