Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/feedback/unmapcourse.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00025 require_once("../../config.php");
00026 require_once($CFG->dirroot.'/mod/feedback/lib.php');
00027 
00028 $id = required_param('id', PARAM_INT);
00029 $cmapid = required_param('cmapid', PARAM_INT);
00030 
00031 $url = new moodle_url('/mod/feedback/unmapcourse.php', array('id'=>$id));
00032 if ($cmapid !== '') {
00033     $url->param('cmapid', $cmapid);
00034 }
00035 $PAGE->set_url($url);
00036 
00037 if (! $cm = get_coursemodule_from_id('feedback', $id)) {
00038     print_error('invalidcoursemodule');
00039 }
00040 
00041 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
00042     print_error('coursemisconf');
00043 }
00044 
00045 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
00046     print_error('invalidcoursemodule');
00047 }
00048 
00049 if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
00050         print_error('badcontext');
00051 }
00052 
00053 require_capability('mod/feedback:mapcourse', $context);
00054 
00055 // cleanup all lost entries after deleting courses or feedbacks
00056 feedback_clean_up_sitecourse_map();
00057 
00058 if ($DB->delete_records('feedback_sitecourse_map', array('id'=>$cmapid))) {
00059     $mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id'=>$id));
00060     redirect ($mapurl->out(false));
00061 } else {
00062     print_error('cannotunmap', 'feedback');
00063 }
00064 
 All Data Structures Namespaces Files Functions Variables Enumerations