[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 <[email protected]> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once(dirname(__FILE__) . '/../../../config.php'); 26 require_once($CFG->libdir.'/adminlib.php'); 27 require_once($CFG->libdir.'/tablelib.php'); 28 29 $PAGE->set_url('/admin/tool/task/scheduledtasks.php'); 30 $PAGE->set_context(context_system::instance()); 31 $PAGE->set_pagelayout('admin'); 32 $strheading = get_string('scheduledtasks', 'tool_task'); 33 $PAGE->set_title($strheading); 34 $PAGE->set_heading($strheading); 35 36 require_login(); 37 38 require_capability('moodle/site:config', context_system::instance()); 39 40 $renderer = $PAGE->get_renderer('tool_task'); 41 42 $action = optional_param('action', '', PARAM_ALPHAEXT); 43 $taskname = optional_param('task', '', PARAM_RAW); 44 $task = null; 45 $mform = null; 46 47 if ($taskname) { 48 $task = \core\task\manager::get_scheduled_task($taskname); 49 if (!$task) { 50 print_error('invaliddata'); 51 } 52 } 53 54 if ($action == 'edit') { 55 $PAGE->navbar->add(get_string('edittaskschedule', 'tool_task', $task->get_name())); 56 } 57 58 if ($task) { 59 $mform = new tool_task_edit_scheduled_task_form(null, $task); 60 } 61 62 if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchanges))) { 63 redirect(new moodle_url('/admin/tool/task/scheduledtasks.php')); 64 } else if ($action == 'edit' && empty($CFG->preventscheduledtaskchanges)) { 65 66 if ($data = $mform->get_data()) { 67 68 69 if ($data->resettodefaults) { 70 $defaulttask = \core\task\manager::get_default_scheduled_task($taskname); 71 $task->set_minute($defaulttask->get_minute()); 72 $task->set_hour($defaulttask->get_hour()); 73 $task->set_month($defaulttask->get_month()); 74 $task->set_day_of_week($defaulttask->get_day_of_week()); 75 $task->set_day($defaulttask->get_day()); 76 $task->set_disabled($defaulttask->get_disabled()); 77 $task->set_customised(false); 78 } else { 79 $task->set_minute($data->minute); 80 $task->set_hour($data->hour); 81 $task->set_month($data->month); 82 $task->set_day_of_week($data->dayofweek); 83 $task->set_day($data->day); 84 $task->set_disabled($data->disabled); 85 $task->set_customised(true); 86 } 87 88 try { 89 \core\task\manager::configure_scheduled_task($task); 90 $url = $PAGE->url; 91 $url->params(array('success'=>get_string('changessaved'))); 92 redirect($url); 93 } catch (Exception $e) { 94 $url = $PAGE->url; 95 $url->params(array('error'=>$e->getMessage())); 96 redirect($url); 97 } 98 } else { 99 echo $OUTPUT->header(); 100 echo $OUTPUT->heading(get_string('edittaskschedule', 'tool_task', $task->get_name())); 101 $mform->display(); 102 echo $OUTPUT->footer(); 103 } 104 105 } else { 106 echo $OUTPUT->header(); 107 $error = optional_param('error', '', PARAM_NOTAGS); 108 if ($error) { 109 echo $OUTPUT->notification($error, 'notifyerror'); 110 } 111 $success = optional_param('success', '', PARAM_NOTAGS); 112 if ($success) { 113 echo $OUTPUT->notification($success, 'notifysuccess'); 114 } 115 $tasks = core\task\manager::get_all_scheduled_tasks(); 116 echo $renderer->scheduled_tasks_table($tasks); 117 echo $OUTPUT->footer(); 118 } 119 120 121 122
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |