2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
20 * @author Andreas Grabs
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22 * @package mod_feedback
25 require_once("../../config.php");
26 require_once("lib.php");
28 $current_tab = 'templates';
30 $id = required_param('id', PARAM_INT
);
31 $deletetempl = optional_param('deletetempl', false, PARAM_INT
);
33 $baseurl = new moodle_url('/mod/feedback/delete_template.php', array('id' => $id));
34 $PAGE->set_url($baseurl);
36 list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
37 $context = context_module
::instance($cm->id
);
39 require_login($course, true, $cm);
40 require_capability('mod/feedback:deletetemplate', $context);
42 $feedback = $PAGE->activityrecord
;
43 $systemcontext = context_system
::instance();
45 // Process template deletion.
48 $template = $DB->get_record('feedback_template', array('id' => $deletetempl), '*', MUST_EXIST
);
50 if ($template->ispublic
) {
51 require_capability('mod/feedback:createpublictemplate', $systemcontext);
52 require_capability('mod/feedback:deletetemplate', $systemcontext);
55 feedback_delete_template($template);
56 redirect($baseurl, get_string('template_deleted', 'feedback'));
59 /// Print the page header
60 $strfeedbacks = get_string("modulenameplural", "feedback");
61 $strfeedback = get_string("modulename", "feedback");
62 $strdeletefeedback = get_string('delete_template', 'feedback');
64 navigation_node
::override_active_url(new moodle_url('/mod/feedback/edit.php',
65 array('id' => $id, 'do_show' => 'templates')));
66 $PAGE->set_heading($course->fullname
);
67 $PAGE->set_title($feedback->name
);
68 echo $OUTPUT->header();
69 echo $OUTPUT->heading(format_string($feedback->name
));
73 // Print the main part of the page.
74 echo $OUTPUT->heading($strdeletefeedback, 3);
76 // First we get the course templates.
77 $templates = feedback_get_template_list($course, 'own');
78 echo $OUTPUT->box_start('coursetemplates');
79 echo $OUTPUT->heading(get_string('course'), 4);
80 $tablecourse = new mod_feedback_templates_table('feedback_template_course_table', $baseurl);
81 $tablecourse->display($templates);
82 echo $OUTPUT->box_end();
83 // Now we get the public templates if it is permitted.
84 if (has_capability('mod/feedback:createpublictemplate', $systemcontext) AND
85 has_capability('mod/feedback:deletetemplate', $systemcontext)) {
86 $templates = feedback_get_template_list($course, 'public');
87 echo $OUTPUT->box_start('publictemplates');
88 echo $OUTPUT->heading(get_string('public', 'feedback'), 4);
89 $tablepublic = new mod_feedback_templates_table('feedback_template_public_table', $baseurl);
90 $tablepublic->display($templates);
91 echo $OUTPUT->box_end();
94 $url = new moodle_url('/mod/feedback/edit.php', array('id' => $id, 'do_show' => 'templates'));
95 echo $OUTPUT->single_button($url, get_string('back'), 'post');
97 echo $OUTPUT->footer();