4436919855dfca3c121fd34babb3cff8a16acc9d
[atutor.git] / docs / mods / _core / properties / admin / delete_course.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 define('AT_INCLUDE_PATH', '../../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_COURSES);
17
18 $course = intval($_REQUEST['course']);
19
20 if (isset($_POST['submit_no'])) {
21         $msg->addFeedback('CANCELLED');
22         header('Location: ../../courses/admin/courses.php');
23         exit;
24 } else if (isset($_POST['step']) && ($_POST['step'] == 2) && isset($_POST['submit_yes'])) {
25         require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
26         require(AT_INCLUDE_PATH.'../mods/_core/properties/lib/delete_course.inc.php');
27
28         delete_course($course, $entire_course = true, $rel_path = '../'); // delete the course
29         cache_purge('system_courses','system_courses'); // purge the system_courses cache (if successful)
30         
31         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
32         header('Location: ../../courses/admin/courses.php');
33         exit;
34 }
35
36 require(AT_INCLUDE_PATH.'header.inc.php'); 
37
38 if (!isset($_POST['step'])) {
39         $hidden_vars['step']   = 1;
40         $hidden_vars['course'] = $course;
41         $msg->addConfirm(array('DELETE_COURSE_1', $system_courses[$course]['title']), $hidden_vars);
42         $msg->printConfirm();
43 } else if ($_POST['step'] == 1) {
44         $hidden_vars['step']   = 2;
45         $hidden_vars['course'] = $course;
46         $msg->addConfirm(array('DELETE_COURSE_2', $system_courses[$course]['title']), $hidden_vars);
47         $msg->printConfirm();
48 }
49
50 require(AT_INCLUDE_PATH.'footer.inc.php'); 
51 ?>