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 require (AT_INCLUDE_PATH.'../mods/_standard/links/lib/links.inc.php');
\r
19 if (!manage_links()) {
\r
20 $msg->addError('ACCESS_DENIED');
\r
21 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
\r
25 $cat_id = intval($_REQUEST['cat_id']);
\r
27 if (isset($_POST['submit_no'])) {
\r
28 $msg->addFeedback('CANCELLED');
\r
29 header('Location: categories.php');
\r
31 } else if (isset($_POST['submit_yes'])) {
\r
32 /* delete has been confirmed, delete this category */
\r
33 $owner_type = intval($_POST['owner_type']);
\r
34 $owner_id = intval($_POST['owner_id']);
\r
35 //OR get_cat_info() again incase data has ben tampered?
\r
37 if (!links_authenticate($owner_type, $owner_id)) {
\r
38 $msg->addError('ACCESS_DENIED');
\r
39 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/categories.php');
\r
43 //check if there are sub cats within this cat, or links
\r
44 $sql = "SELECT C.cat_id, L.link_id FROM ".TABLE_PREFIX."links_categories C, ".TABLE_PREFIX."links L WHERE C.parent_id=$cat_id OR L.cat_id=$cat_id";
\r
45 $result = mysql_query($sql, $db);
\r
46 if (mysql_num_rows($result) == 0) {
\r
47 $sql = "DELETE FROM ".TABLE_PREFIX."links_categories WHERE owner_id=$owner_id AND owner_type=$owner_type AND cat_id=$cat_id";
\r
48 $result = mysql_query($sql, $db);
\r
49 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
51 $msg->addError('LINK_CAT_NOT_EMPTY');
\r
54 header('Location: categories.php');
\r
58 require(AT_INCLUDE_PATH.'header.inc.php');
\r
60 $row = get_cat_info($cat_id);
\r
63 $msg->printErrors('ITEM_NOT_FOUND');
\r
65 $hidden_vars['cat_name']= $row['name'];
\r
66 $hidden_vars['cat_id'] = $row['cat_id'];
\r
67 $hidden_vars['owner_type'] = $row['owner_type'];
\r
68 $hidden_vars['owner_id'] = $row['owner_id'];
\r
70 $confirm = array('DELETE_CATEGORY', AT_print($row['name'], 'links_categories.name'));
\r
71 $msg->addConfirm($confirm, $hidden_vars);
\r
73 $msg->printConfirm();
\r
76 require(AT_INCLUDE_PATH.'footer.inc.php');
\r