Added some styles to make role descriptions a bit smaller MDL-6923
[moodle.git] / course / delete.php
blobc0f6fc332fafaeb71f7d0fefc42a205955b1dd9f
1 <?php // $Id$
2 // Admin-only code to delete a course utterly
4 require_once("../config.php");
6 $id = required_param('id', PARAM_INT); // course id
7 $delete = optional_param('delete', '', PARAM_ALPHANUM); // delete confirmation hash
9 require_login();
11 require_capability('moodle/course:delete', get_context_instance(CONTEXT_SYSTEM, SITEID));
13 if (!$site = get_site()) {
14 error("Site not found!");
17 $strdeletecourse = get_string("deletecourse");
18 $stradministration = get_string("administration");
19 $strcategories = get_string("categories");
21 if (! $course = get_record("course", "id", $id)) {
22 error("Course ID was incorrect (can't find it)");
25 $category = get_record("course_categories", "id", $course->category);
27 if (! $delete) {
28 $strdeletecheck = get_string("deletecheck", "", $course->shortname);
29 $strdeletecoursecheck = get_string("deletecoursecheck");
32 print_header("$site->shortname: $strdeletecheck", $site->fullname,
33 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
34 "<a href=\"index.php\">$strcategories</a> -> ".
35 "<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
36 "$strdeletecheck");
38 notice_yesno("$strdeletecoursecheck<br /><br />$course->fullname ($course->shortname)",
39 "delete.php?id=$course->id&amp;delete=".md5($course->timemodified)."&amp;sesskey=$USER->sesskey",
40 "category.php?id=$course->category");
42 print_footer($course);
43 exit;
46 if ($delete != md5($course->timemodified)) {
47 error("The check variable was wrong - try again");
50 if (!confirm_sesskey()) {
51 error(get_string('confirmsesskeybad', 'error'));
54 // OK checks done, delete the course now.
56 add_to_log(SITEID, "course", "delete", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
58 $strdeletingcourse = get_string("deletingcourse", "", $course->shortname);
60 print_header("$site->shortname: $strdeletingcourse", $site->fullname,
61 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
62 "<a href=\"index.php\">$strcategories</a> -> ".
63 "<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
64 "$strdeletingcourse");
66 print_heading($strdeletingcourse);
68 delete_course($course->id);
69 fix_course_sortorder(); //update course count in catagories
71 print_heading( get_string("deletedcourse", "", $course->shortname) );
73 print_continue("category.php?id=$course->category");
75 print_footer();