Merge branch 'w39_MDL-41208_m26_yui312' of https://github.com/skodak/moodle
[moodle.git] / admin / message.php
blob67a60b08b881294bbca100f42dcf231dc288d263
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.
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/>.
17 /**
18 * Message outputs configuration page
20 * @package message
21 * @copyright 2011 Lancaster University Network Services Limited
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 require_once(dirname(__FILE__) . '/../config.php');
25 require_once($CFG->dirroot . '/message/lib.php');
26 require_once($CFG->libdir.'/adminlib.php');
27 require_once($CFG->libdir.'/pluginlib.php');
29 // This is an admin page
30 admin_externalpage_setup('managemessageoutputs');
32 // Require site configuration capability
33 require_capability('moodle/site:config', context_system::instance());
35 // Get the submitted params
36 $disable = optional_param('disable', 0, PARAM_INT);
37 $enable = optional_param('enable', 0, PARAM_INT);
38 $uninstall = optional_param('uninstall', 0, PARAM_INT);
39 $confirm = optional_param('confirm', false, PARAM_BOOL);
41 $headingtitle = get_string('managemessageoutputs', 'message');
43 if (!empty($disable) && confirm_sesskey()) {
44 if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
45 print_error('outputdoesnotexist', 'message');
47 $DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
48 plugin_manager::reset_caches();
51 if (!empty($enable) && confirm_sesskey()) {
52 if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
53 print_error('outputdoesnotexist', 'message');
55 $DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
56 plugin_manager::reset_caches();
59 if (!empty($uninstall) && confirm_sesskey()) {
60 echo $OUTPUT->header();
61 echo $OUTPUT->heading($headingtitle);
63 if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
64 print_error('outputdoesnotexist', 'message');
67 $processorname = get_string('pluginname', 'message_'.$processor->name);
69 if (!$confirm) {
70 echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
71 echo $OUTPUT->footer();
72 exit;
74 } else {
75 message_processor_uninstall($processor->name);
76 $a = new stdClass();
77 $a->processor = $processorname;
78 $a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
79 notice(get_string('processordeletefiles', 'message', $a), 'message.php');
83 if ($disable || $enable || $uninstall) {
84 $url = new moodle_url('message.php');
85 redirect($url);
87 // Page settings
88 $PAGE->set_context(context_system::instance());
90 // Grab the renderer
91 $renderer = $PAGE->get_renderer('core', 'message');
93 // Display the manage message outputs interface
94 $processors = get_message_processors();
95 $messageoutputs = $renderer->manage_messageoutputs($processors);
97 // Display the page
98 echo $OUTPUT->header();
99 echo $OUTPUT->heading($headingtitle);
100 echo $messageoutputs;
101 echo $OUTPUT->footer();