source: moodle/trunk/fuentes/course/delete.php @ 1331

Last change on this file since 1331 was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

File size: 3.6 KB
RevLine 
[136]1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Admin-only code to delete a course utterly.
19 *
20 * @package core_course
21 * @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25require_once(dirname(__FILE__) . '/../config.php');
26require_once($CFG->dirroot . '/course/lib.php');
27
28$id = required_param('id', PARAM_INT); // Course ID.
29$delete = optional_param('delete', '', PARAM_ALPHANUM); // Confirmation hash.
30
31$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
32$coursecontext = context_course::instance($course->id);
33
34require_login();
35
36if ($SITE->id == $course->id || !can_delete_course($id)) {
37    // Can not delete frontpage or don't have permission to delete the course.
38    print_error('cannotdeletecourse');
39}
40
41$categorycontext = context_coursecat::instance($course->category);
42$PAGE->set_url('/course/delete.php', array('id' => $id));
43$PAGE->set_context($categorycontext);
44$PAGE->set_pagelayout('admin');
45navigation_node::override_active_url(new moodle_url('/course/management.php', array('categoryid'=>$course->category)));
46
47$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
48$coursefullname = format_string($course->fullname, true, array('context' => $coursecontext));
49$categoryurl = new moodle_url('/course/management.php', array('categoryid' => $course->category));
50
51// Check if we've got confirmation.
52if ($delete === md5($course->timemodified)) {
53    // We do - time to delete the course.
54    require_sesskey();
55
56    $strdeletingcourse = get_string("deletingcourse", "", $courseshortname);
57
58    $PAGE->navbar->add($strdeletingcourse);
59    $PAGE->set_title("$SITE->shortname: $strdeletingcourse");
60    $PAGE->set_heading($SITE->fullname);
61
62    echo $OUTPUT->header();
63    echo $OUTPUT->heading($strdeletingcourse);
[1331]64    // This might take a while. Raise the execution time limit.
65    core_php_time_limit::raise();
[136]66    // We do this here because it spits out feedback as it goes.
67    delete_course($course);
68    echo $OUTPUT->heading( get_string("deletedcourse", "", $courseshortname) );
69    // Update course count in categories.
70    fix_course_sortorder();
71    echo $OUTPUT->continue_button($categoryurl);
72    echo $OUTPUT->footer();
73    exit; // We must exit here!!!
74}
75
76$strdeletecheck = get_string("deletecheck", "", $courseshortname);
77$strdeletecoursecheck = get_string("deletecoursecheck");
78$message = "{$strdeletecoursecheck}<br /><br />{$coursefullname} ({$courseshortname})";
79
80$continueurl = new moodle_url('/course/delete.php', array('id' => $course->id, 'delete' => md5($course->timemodified)));
[1331]81$continuebutton = new single_button($continueurl, get_string('delete'), 'post');
[136]82
83$PAGE->navbar->add($strdeletecheck);
84$PAGE->set_title("$SITE->shortname: $strdeletecheck");
85$PAGE->set_heading($SITE->fullname);
86echo $OUTPUT->header();
[1331]87echo $OUTPUT->confirm($message, $continuebutton, $categoryurl);
[136]88echo $OUTPUT->footer();
[1331]89exit;
Note: See TracBrowser for help on using the repository browser.