[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/feedback/ -> unmapcourse.php (source)

   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.
  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/>.
  16  
  17  /**
  18   * drops records from feedback_sitecourse_map
  19   *
  20   * @author Andreas Grabs
  21   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  22   * @package mod_feedback
  23   */
  24  
  25  require_once("../../config.php");
  26  require_once($CFG->dirroot.'/mod/feedback/lib.php');
  27  
  28  $id = required_param('id', PARAM_INT);
  29  $cmapid = required_param('cmapid', PARAM_INT);
  30  
  31  $url = new moodle_url('/mod/feedback/unmapcourse.php', array('id'=>$id));
  32  if ($cmapid !== '') {
  33      $url->param('cmapid', $cmapid);
  34  }
  35  $PAGE->set_url($url);
  36  
  37  if (! $cm = get_coursemodule_from_id('feedback', $id)) {
  38      print_error('invalidcoursemodule');
  39  }
  40  
  41  if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
  42      print_error('coursemisconf');
  43  }
  44  
  45  if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
  46      print_error('invalidcoursemodule');
  47  }
  48  
  49  $context = context_module::instance($cm->id);
  50  
  51  require_capability('mod/feedback:mapcourse', $context);
  52  
  53  // cleanup all lost entries after deleting courses or feedbacks
  54  feedback_clean_up_sitecourse_map();
  55  
  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');
  61  }
  62  


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1