Merge branch 'MDL-32780-CLEAN' of git://github.com/netspotau/moodle-mod_assign
[moodle.git] / admin / message.php
blob45d9026c14ea56c82a61308a737f9199b1761bdf
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');
28 // This is an admin page
29 admin_externalpage_setup('managemessageoutputs');
31 // Require site configuration capability
32 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
34 // Get the submitted params
35 $disable = optional_param('disable', 0, PARAM_INT);
36 $enable = optional_param('enable', 0, PARAM_INT);
37 $uninstall = optional_param('uninstall', 0, PARAM_INT);
38 $confirm = optional_param('confirm', false, PARAM_BOOL);
40 $headingtitle = get_string('managemessageoutputs', 'message');
42 if (!empty($disable) && confirm_sesskey()) {
43 if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
44 print_error('outputdoesnotexist', 'message');
46 $DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
49 if (!empty($enable) && confirm_sesskey()) {
50 if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
51 print_error('outputdoesnotexist', 'message');
53 $DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
56 if (!empty($uninstall) && confirm_sesskey()) {
57 echo $OUTPUT->header();
58 echo $OUTPUT->heading($headingtitle);
60 if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
61 print_error('outputdoesnotexist', 'message');
64 $processorname = get_string('pluginname', 'message_'.$processor->name);
66 if (!$confirm) {
67 echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
68 echo $OUTPUT->footer();
69 exit;
71 } else {
72 message_processor_uninstall($processor->name);
73 $a = new stdClass();
74 $a->processor = $processorname;
75 $a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
76 notice(get_string('processordeletefiles', 'message', $a), 'message.php');
80 if ($disable || $enable || $uninstall) {
81 $url = new moodle_url('message.php');
82 redirect($url);
84 // Page settings
85 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
87 // Grab the renderer
88 $renderer = $PAGE->get_renderer('core', 'message');
90 // Display the manage message outputs interface
91 $processors = get_message_processors();
92 $messageoutputs = $renderer->manage_messageoutputs($processors);
94 // Display the page
95 echo $OUTPUT->header();
96 echo $OUTPUT->heading($headingtitle);
97 echo $messageoutputs;
98 echo $OUTPUT->footer();