[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/course/ -> delete.php (source)

   1  <?php // $Id: delete.php,v 1.29.2.2 2008/07/06 17:55:56 skodak Exp $
   2        // Admin-only code to delete a course utterly
   3  
   4      require_once("../config.php");
   5  
   6      $id     = required_param('id', PARAM_INT);              // course id
   7      $delete = optional_param('delete', '', PARAM_ALPHANUM); // delete confirmation hash
   8  
   9      require_login();
  10  
  11      if (!can_delete_course($id)) {
  12          error('You do not have the permission to delete this course.');
  13      }
  14  
  15      if (!$site = get_site()) {
  16          error("Site not found!");
  17      }
  18  
  19      $strdeletecourse = get_string("deletecourse");
  20      $stradministration = get_string("administration");
  21      $strcategories = get_string("categories");
  22  
  23      if (! $course = get_record("course", "id", $id)) {
  24          error("Course ID was incorrect (can't find it)");
  25      }
  26  
  27      $category = get_record("course_categories", "id", $course->category);
  28      $navlinks = array();
  29  
  30      if (! $delete) {
  31          $strdeletecheck = get_string("deletecheck", "", $course->shortname);
  32          $strdeletecoursecheck = get_string("deletecoursecheck");
  33  
  34          $navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
  35          $navlinks[] = array('name' => $strcategories, 'link' => "index.php", 'type' => 'misc');
  36          $navlinks[] = array('name' => $category->name, 'link' => "category.php?id=$course->category", 'type' => 'misc');
  37          $navlinks[] = array('name' => $strdeletecheck, 'link' => null, 'type' => 'misc');
  38          $navigation = build_navigation($navlinks);
  39  
  40          print_header("$site->shortname: $strdeletecheck", $site->fullname, $navigation);
  41  
  42          notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($course->fullname) .
  43                       " (" . format_string($course->shortname) . ")",
  44                       "delete.php?id=$course->id&amp;delete=".md5($course->timemodified)."&amp;sesskey=$USER->sesskey",
  45                       "category.php?id=$course->category");
  46  
  47          print_footer($course);
  48          exit;
  49      }
  50  
  51      if ($delete != md5($course->timemodified)) {
  52          error("The check variable was wrong - try again");
  53      }
  54  
  55      if (!confirm_sesskey()) {
  56          print_error('confirmsesskeybad', 'error');
  57      }
  58  
  59      // OK checks done, delete the course now.
  60  
  61      add_to_log(SITEID, "course", "delete", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
  62  
  63      $strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname));
  64  
  65      $navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
  66      $navlinks[] = array('name' => $strcategories, 'link' => "index.php", 'type' => 'misc');
  67      $navlinks[] = array('name' => $category->name, 'link' => "category.php?id=$course->category", 'type' => 'misc');
  68      $navlinks[] = array('name' => $strdeletingcourse, 'link' => null, 'type' => 'misc');
  69      $navigation = build_navigation($navlinks);
  70  
  71      print_header("$site->shortname: $strdeletingcourse", $site->fullname, $navigation);
  72  
  73      print_heading($strdeletingcourse);
  74  
  75      delete_course($course);
  76      fix_course_sortorder(); //update course count in catagories
  77  
  78      print_heading( get_string("deletedcourse", "", format_string($course->shortname)) );
  79  
  80      print_continue("category.php?id=$course->category");
  81  
  82      print_footer();
  83  
  84  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7