moodle/course/delete.php

87 lines
3.3 KiB
PHP
Raw Normal View History

2004-09-12 12:21:27 +00:00
<?php // $Id$
// Admin-only code to delete a course utterly
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot . '/course/lib.php');
$id = required_param('id', PARAM_INT); // course id
$delete = optional_param('delete', '', PARAM_ALPHANUM); // delete confirmation hash
$PAGE->set_url('course/delete.php', array('id' => $id));
require_login();
2007-02-16 08:46:55 +00:00
if (!can_delete_course($id)) {
print_error('cannotdeletecourse');
2007-02-16 08:46:55 +00:00
}
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$strdeletecourse = get_string("deletecourse");
$stradministration = get_string("administration");
$strcategories = get_string("categories");
2008-06-01 18:12:24 +00:00
if (! $course = $DB->get_record("course", array("id"=>$id))) {
print_error("invalidcourseid");
}
2008-06-01 18:12:24 +00:00
$category = $DB->get_record("course_categories", array("id"=>$course->category));
$navlinks = array();
if (! $delete) {
2002-08-04 02:10:00 +00:00
$strdeletecheck = get_string("deletecheck", "", $course->shortname);
$strdeletecoursecheck = get_string("deletecoursecheck");
$navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
$navlinks[] = array('name' => $strcategories, 'link' => "index.php", 'type' => 'misc');
$navlinks[] = array('name' => $category->name, 'link' => "category.php?id=$course->category", 'type' => 'misc');
$navlinks[] = array('name' => $strdeletecheck, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$site->shortname: $strdeletecheck", $site->fullname, $navigation);
notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($course->fullname) .
" (" . format_string($course->shortname) . ")",
2009-01-20 23:53:34 +00:00
"delete.php?id=$course->id&amp;delete=".md5($course->timemodified)."&amp;sesskey=".sesskey(),
2003-08-09 02:10:05 +00:00
"category.php?id=$course->category");
print_footer();
exit;
}
if ($delete != md5($course->timemodified)) {
print_error("invalidmd5");
}
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', 'error');
}
// 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)");
$strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname));
$navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
$navlinks[] = array('name' => $strcategories, 'link' => "index.php", 'type' => 'misc');
$navlinks[] = array('name' => $category->name, 'link' => "category.php?id=$course->category", 'type' => 'misc');
$navlinks[] = array('name' => $strdeletingcourse, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$site->shortname: $strdeletingcourse", $site->fullname, $navigation);
echo $OUTPUT->heading($strdeletingcourse);
delete_course($course);
fix_course_sortorder(); //update course count in catagories
echo $OUTPUT->heading( get_string("deletedcourse", "", format_string($course->shortname)) );
2003-08-09 02:10:05 +00:00
print_continue("category.php?id=$course->category");
print_footer();
?>