2004-09-12 12:21:27 +00:00
|
|
|
<?php // $Id$
|
2002-08-11 15:41:54 +00:00
|
|
|
// Admin-only code to delete a course utterly
|
2002-08-03 04:44:35 +00:00
|
|
|
|
2005-05-16 19:38:21 +00:00
|
|
|
require_once("../config.php");
|
2002-08-03 04:44:35 +00:00
|
|
|
|
2006-03-07 19:36:13 +00:00
|
|
|
$id = required_param('id', PARAM_INT); // course id
|
|
|
|
$delete = optional_param('delete', '', PARAM_ALPHANUM); // delete confirmation hash
|
2002-08-03 04:44:35 +00:00
|
|
|
|
|
|
|
require_login();
|
|
|
|
|
2007-02-16 08:46:55 +00:00
|
|
|
if (!can_delete_course($id)) {
|
|
|
|
error('You do not have the permission to delete this course.');
|
|
|
|
}
|
2002-08-03 04:44:35 +00:00
|
|
|
|
2002-08-08 15:51:23 +00:00
|
|
|
if (!$site = get_site()) {
|
|
|
|
error("Site not found!");
|
|
|
|
}
|
|
|
|
|
|
|
|
$strdeletecourse = get_string("deletecourse");
|
|
|
|
$stradministration = get_string("administration");
|
2003-08-09 16:53:30 +00:00
|
|
|
$strcategories = get_string("categories");
|
2002-08-03 04:44:35 +00:00
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course ID was incorrect (can't find it)");
|
|
|
|
}
|
|
|
|
|
2003-08-09 16:53:30 +00:00
|
|
|
$category = get_record("course_categories", "id", $course->category);
|
|
|
|
|
2002-08-03 04:44:35 +00:00
|
|
|
if (! $delete) {
|
2002-08-04 02:10:00 +00:00
|
|
|
$strdeletecheck = get_string("deletecheck", "", $course->shortname);
|
2002-08-11 15:41:54 +00:00
|
|
|
$strdeletecoursecheck = get_string("deletecoursecheck");
|
2003-08-09 16:53:30 +00:00
|
|
|
|
|
|
|
|
2005-05-16 19:38:21 +00:00
|
|
|
print_header("$site->shortname: $strdeletecheck", $site->fullname,
|
2003-08-09 02:10:05 +00:00
|
|
|
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
|
2003-08-09 16:53:30 +00:00
|
|
|
"<a href=\"index.php\">$strcategories</a> -> ".
|
|
|
|
"<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
|
2003-08-09 02:10:05 +00:00
|
|
|
"$strdeletecheck");
|
2002-08-08 15:51:23 +00:00
|
|
|
|
2007-02-28 06:25:22 +00:00
|
|
|
notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($course->fullname) .
|
|
|
|
" (" . format_string($course->shortname) . ")",
|
2004-10-08 17:58:38 +00:00
|
|
|
"delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=$USER->sesskey",
|
2003-08-09 02:10:05 +00:00
|
|
|
"category.php?id=$course->category");
|
2005-08-03 01:24:29 +00:00
|
|
|
|
|
|
|
print_footer($course);
|
2002-08-03 04:44:35 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($delete != md5($course->timemodified)) {
|
|
|
|
error("The check variable was wrong - try again");
|
|
|
|
}
|
|
|
|
|
2004-10-08 17:58:38 +00:00
|
|
|
if (!confirm_sesskey()) {
|
|
|
|
error(get_string('confirmsesskeybad', 'error'));
|
|
|
|
}
|
|
|
|
|
2002-08-03 04:44:35 +00:00
|
|
|
// OK checks done, delete the course now.
|
2005-03-14 02:39:39 +00:00
|
|
|
|
|
|
|
add_to_log(SITEID, "course", "delete", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
|
|
|
|
|
2007-02-28 06:25:22 +00:00
|
|
|
$strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname));
|
2002-08-08 15:51:23 +00:00
|
|
|
|
2005-05-16 19:38:21 +00:00
|
|
|
print_header("$site->shortname: $strdeletingcourse", $site->fullname,
|
2003-08-09 02:10:05 +00:00
|
|
|
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
|
2003-08-09 16:53:30 +00:00
|
|
|
"<a href=\"index.php\">$strcategories</a> -> ".
|
|
|
|
"<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
|
2003-08-09 02:10:05 +00:00
|
|
|
"$strdeletingcourse");
|
2002-08-08 15:51:23 +00:00
|
|
|
|
|
|
|
print_heading($strdeletingcourse);
|
2002-08-03 04:44:35 +00:00
|
|
|
|
2006-03-02 11:58:43 +00:00
|
|
|
delete_course($course->id);
|
2006-06-07 14:05:44 +00:00
|
|
|
fix_course_sortorder(); //update course count in catagories
|
2005-04-26 16:05:52 +00:00
|
|
|
|
2007-02-28 06:25:22 +00:00
|
|
|
print_heading( get_string("deletedcourse", "", format_string($course->shortname)) );
|
2002-08-03 04:44:35 +00:00
|
|
|
|
2003-08-09 02:10:05 +00:00
|
|
|
print_continue("category.php?id=$course->category");
|
2002-08-03 04:44:35 +00:00
|
|
|
|
|
|
|
print_footer();
|
|
|
|
|
|
|
|
?>
|