moved code up one level to eliminate the docs subdirectory
[acontent.git] / tests / question_cats_delete.php
1 <?php\r
2 /************************************************************************/\r
3 /* AContent                                                             */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2010                                                   */\r
6 /* Inclusive Design Institute                                           */\r
7 /*                                                                      */\r
8 /* This program is free software. You can redistribute it and/or        */\r
9 /* modify it under the terms of the GNU General Public License          */\r
10 /* as published by the Free Software Foundation.                        */\r
11 /************************************************************************/\r
12 \r
13 $page = 'tests';\r
14 define('TR_INCLUDE_PATH', '../include/');\r
15 require_once(TR_INCLUDE_PATH.'vitals.inc.php');\r
16 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsCategoriesDAO.class.php');\r
17 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsDAO.class.php');\r
18 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');\r
19 \r
20 global $_course_id;\r
21 \r
22 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);\r
23 \r
24 $testsQuestionsCategoriesDAO = new TestsQuestionsCategoriesDAO();\r
25 \r
26 if (isset($_POST['submit_yes'])) {\r
27         $_POST['catid'] = intval($_POST['catid']);\r
28 \r
29         $testsQuestionsDAO = new TestsQuestionsDAO();\r
30         //remove category\r
31         if ($testsQuestionsCategoriesDAO->Delete($_POST['catid']) && $testsQuestionsDAO->UpdateField($_POST['catid'], 'category_id', 0))\r
32         {\r
33                 //set all qestions that use this category to have category=0\r
34                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
35                 header('Location: '.TR_BASE_HREF.'tests/question_cats.php?_course_id='.$_course_id);\r
36                 exit;\r
37         }\r
38 \r
39 } else if (isset($_POST['submit_no'])) {\r
40         $msg->addFeedback('CANCELLED');\r
41         header('Location: '.TR_BASE_HREF.'tests/question_cats.php?_course_id='.$_course_id);\r
42         exit;\r
43 } else if (!isset($_GET['catid'])) {\r
44         require_once(TR_INCLUDE_PATH.'header.inc.php');\r
45         $msg->addError('ITEM_NOT_FOUND');\r
46         $msg->printErrors();\r
47         require_once(TR_INCLUDE_PATH.'footer.inc.php');\r
48         exit;\r
49\r
50 \r
51 require_once(TR_INCLUDE_PATH.'header.inc.php');\r
52 \r
53 $_GET['catid'] = intval($_GET['catid']);\r
54 \r
55 $row = $testsQuestionsCategoriesDAO->get($_GET['catid']);\r
56 \r
57 $hidden_vars['catid'] = $_GET['catid'];\r
58 $hidden_vars['_course_id'] = $_course_id;\r
59 \r
60 $msg->addConfirm(array('DELETE_TEST_CATEGORY', $row['title']), $hidden_vars);\r
61         \r
62 $msg->printConfirm();\r
63 \r
64 require_once(TR_INCLUDE_PATH.'footer.inc.php');\r
65 ?>