adding some strings
[moodle-linuxchix.git] / course / delete.php
blob418047f231527c9bc669dc6ac0a6a2a0b665e202
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 if (!can_delete_course($id)) {
12 error('You do not have the permission to delete this course.');
15 if (!$site = get_site()) {
16 error("Site not found!");
19 $strdeletecourse = get_string("deletecourse");
20 $stradministration = get_string("administration");
21 $strcategories = get_string("categories");
23 if (! $course = get_record("course", "id", $id)) {
24 error("Course ID was incorrect (can't find it)");
27 $category = get_record("course_categories", "id", $course->category);
29 if (! $delete) {
30 $strdeletecheck = get_string("deletecheck", "", $course->shortname);
31 $strdeletecoursecheck = get_string("deletecoursecheck");
34 print_header("$site->shortname: $strdeletecheck", $site->fullname,
35 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
36 "<a href=\"index.php\">$strcategories</a> -> ".
37 "<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
38 "$strdeletecheck");
40 notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($course->fullname) .
41 " (" . format_string($course->shortname) . ")",
42 "delete.php?id=$course->id&amp;delete=".md5($course->timemodified)."&amp;sesskey=$USER->sesskey",
43 "category.php?id=$course->category");
45 print_footer($course);
46 exit;
49 if ($delete != md5($course->timemodified)) {
50 error("The check variable was wrong - try again");
53 if (!confirm_sesskey()) {
54 error(get_string('confirmsesskeybad', 'error'));
57 // OK checks done, delete the course now.
59 add_to_log(SITEID, "course", "delete", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
61 $strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname));
63 print_header("$site->shortname: $strdeletingcourse", $site->fullname,
64 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
65 "<a href=\"index.php\">$strcategories</a> -> ".
66 "<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
67 "$strdeletingcourse");
69 print_heading($strdeletingcourse);
71 delete_course($course->id);
72 fix_course_sortorder(); //update course count in catagories
74 // MDL-9983
75 events_trigger('course_deleted', $course);
77 print_heading( get_string("deletedcourse", "", format_string($course->shortname)) );
79 print_continue("category.php?id=$course->category");
81 print_footer();