Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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 * 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 $PAGE->navbar->add(get_string('scheduledtasks', 'tool_task'), $PAGE->url); 46 47 if ($action == 'edit') { 48 $PAGE->navbar->add(get_string('edittaskschedule', 'tool_task', $task->get_name())); 49 } 50 51 if ($task) { 52 $mform = new tool_task_edit_scheduled_task_form(null, $task); 53 $nexturl = new moodle_url($PAGE->url, ['lastchanged' => $taskname]); 54 } 55 56 $PAGE->set_primary_active_tab('siteadminnode'); 57 58 $renderer = $PAGE->get_renderer('tool_task'); 59 60 if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchanges) || $task->is_overridden())) { 61 redirect($nexturl); 62 } else if ($action == 'edit' && empty($CFG->preventscheduledtaskchanges)) { 63 64 if ($data = $mform->get_data()) { 65 if ($data->resettodefaults) { 66 $defaulttask = \core\task\manager::get_default_scheduled_task($taskname); 67 $task->set_minute($defaulttask->get_minute()); 68 $task->set_hour($defaulttask->get_hour()); 69 $task->set_month($defaulttask->get_month()); 70 $task->set_day_of_week($defaulttask->get_day_of_week()); 71 $task->set_day($defaulttask->get_day()); 72 $task->set_disabled($defaulttask->get_disabled()); 73 $task->set_customised(false); 74 } else { 75 $task->set_minute($data->minute); 76 $task->set_hour($data->hour); 77 $task->set_month($data->month); 78 $task->set_day_of_week($data->dayofweek); 79 $task->set_day($data->day); 80 $task->set_disabled($data->disabled); 81 $task->set_customised(true); 82 } 83 84 try { 85 \core\task\manager::configure_scheduled_task($task); 86 redirect($nexturl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS); 87 } catch (Exception $e) { 88 redirect($nexturl, $e->getMessage(), null, \core\output\notification::NOTIFY_ERROR); 89 } 90 } else { 91 echo $OUTPUT->header(); 92 echo $OUTPUT->heading(get_string('edittaskschedule', 'tool_task', $task->get_name())); 93 echo html_writer::div('\\' . get_class($task), 'task-class text-ltr'); 94 echo html_writer::div(get_string('fromcomponent', 'tool_task', 95 $renderer->component_name($task->get_component()))); 96 $mform->display(); 97 echo $OUTPUT->footer(); 98 } 99 100 } else { 101 echo $OUTPUT->header(); 102 if (!get_config('core', 'cron_enabled')) { 103 echo $renderer->cron_disabled(); 104 } 105 $tasks = core\task\manager::get_all_scheduled_tasks(); 106 echo $renderer->scheduled_tasks_table($tasks, $lastchanged); 107 echo $OUTPUT->footer(); 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body