2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /****************************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../../include/');
\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 admin_authenticate(AT_ADMIN_PRIV_CATEGORIES);
\r
19 if (isset($_POST['submit_no'])) {
\r
20 $msg->addFeedback('CANCELLED');
\r
21 header('Location: course_categories.php');
\r
23 } else if (isset($_POST['submit_yes'])) {
\r
24 /* delete has been confirmed, delete this category */
\r
25 $cat_id = intval($_POST['cat_id']);
\r
27 if (!is_array($categories[$cat_id]['children'])) {
\r
28 $sql = "DELETE FROM ".TABLE_PREFIX."course_cats WHERE cat_id=$cat_id";
\r
29 $result = mysql_query($sql, $db);
\r
31 write_to_log(AT_ADMIN_LOG_DELETE, 'course_cats', mysql_affected_rows($db), $sql);
\r
33 $sql = "UPDATE ".TABLE_PREFIX."courses SET cat_id=0 WHERE cat_id=$cat_id";
\r
34 $result = mysql_query($sql, $db);
\r
36 write_to_log(AT_ADMIN_LOG_DELETE, 'courses', mysql_affected_rows($db), $sql);
\r
38 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
39 header('Location: course_categories.php');
\r
44 require(AT_INCLUDE_PATH.'header.inc.php');
\r
46 $_GET['cat_id'] = intval($_GET['cat_id']);
\r
48 $sql = "SELECT * FROM ".TABLE_PREFIX."course_cats WHERE cat_id=$_GET[cat_id]";
\r
49 $result = mysql_query($sql,$db);
\r
51 if (mysql_num_rows($result) == 0) {
\r
52 $msg->printErrors('ITEM_NOT_FOUND');
\r
54 $row = mysql_fetch_assoc($result);
\r
56 $hidden_vars['cat_name']= $row['cat_name'];
\r
57 $hidden_vars['cat_id'] = $row['cat_id'];
\r
59 $confirm = array('DELETE_CATEGORY', AT_print($row['cat_name'], 'course_cats.cat_name'));
\r
60 $msg->addConfirm($confirm, $hidden_vars);
\r
62 $msg->printConfirm();
\r
65 require(AT_INCLUDE_PATH.'footer.inc.php');
\r