MDL-40918 mod_lti: replaced 'view' and 'view all' add_to_log calls with events
[moodle.git] / mod / feedback / unmapcourse.php
blob145258b3d6ce03b1afdf8192804066f2f2c8b94e
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 * drops records from feedback_sitecourse_map
20 * @author Andreas Grabs
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22 * @package feedback
25 require_once("../../config.php");
26 require_once($CFG->dirroot.'/mod/feedback/lib.php');
28 $id = required_param('id', PARAM_INT);
29 $cmapid = required_param('cmapid', PARAM_INT);
31 $url = new moodle_url('/mod/feedback/unmapcourse.php', array('id'=>$id));
32 if ($cmapid !== '') {
33 $url->param('cmapid', $cmapid);
35 $PAGE->set_url($url);
37 if (! $cm = get_coursemodule_from_id('feedback', $id)) {
38 print_error('invalidcoursemodule');
41 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
42 print_error('coursemisconf');
45 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
46 print_error('invalidcoursemodule');
49 $context = context_module::instance($cm->id);
51 require_capability('mod/feedback:mapcourse', $context);
53 // cleanup all lost entries after deleting courses or feedbacks
54 feedback_clean_up_sitecourse_map();
56 if ($DB->delete_records('feedback_sitecourse_map', array('id'=>$cmapid))) {
57 $mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id'=>$id));
58 redirect ($mapurl->out(false));
59 } else {
60 print_error('cannotunmap', 'feedback');