MDL-41437 fix non-functional message processor uninstall
[moodle.git] / admin / message.php
CommitLineData
75c34c23 1<?php
2f2137fc
RK
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/>.
75c34c23
RK
16
17/**
18 * Message outputs configuration page
19 *
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
23 */
60bbe768
RK
24require_once(dirname(__FILE__) . '/../config.php');
25require_once($CFG->dirroot . '/message/lib.php');
75c34c23 26require_once($CFG->libdir.'/adminlib.php');
bde002b8 27require_once($CFG->libdir.'/pluginlib.php');
75c34c23
RK
28
29// This is an admin page
30admin_externalpage_setup('managemessageoutputs');
31
32// Require site configuration capability
bf006d2c 33require_capability('moodle/site:config', context_system::instance());
75c34c23
RK
34
35// Get the submitted params
36$disable = optional_param('disable', 0, PARAM_INT);
37$enable = optional_param('enable', 0, PARAM_INT);
3f9d9e28
RK
38
39$headingtitle = get_string('managemessageoutputs', 'message');
75c34c23
RK
40
41if (!empty($disable) && confirm_sesskey()) {
42 if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
43 print_error('outputdoesnotexist', 'message');
44 }
45 $DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
bde002b8 46 plugin_manager::reset_caches();
75c34c23
RK
47}
48
3f9d9e28 49if (!empty($enable) && confirm_sesskey()) {
75c34c23
RK
50 if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
51 print_error('outputdoesnotexist', 'message');
52 }
53 $DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
bde002b8 54 plugin_manager::reset_caches();
75c34c23
RK
55}
56
a707a0b4 57if ($disable || $enable) {
75c34c23
RK
58 $url = new moodle_url('message.php');
59 redirect($url);
60}
61// Page settings
bf006d2c 62$PAGE->set_context(context_system::instance());
75c34c23
RK
63
64// Grab the renderer
65$renderer = $PAGE->get_renderer('core', 'message');
66
67// Display the manage message outputs interface
68$processors = get_message_processors();
69$messageoutputs = $renderer->manage_messageoutputs($processors);
70
71// Display the page
72echo $OUTPUT->header();
3f9d9e28 73echo $OUTPUT->heading($headingtitle);
75c34c23 74echo $messageoutputs;
a707a0b4 75echo $OUTPUT->footer();