2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
14 define('AT_INCLUDE_PATH', '../../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 include(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
18 authenticate(AT_PRIV_FORUMS);
20 $pid = intval($_REQUEST['pid']);
21 $ppid = intval($_REQUEST['ppid']);
22 $fid = intval($_REQUEST['fid']);
24 if (!valid_forum_user($fid)) {
25 $msg->addError('FORUM_NOT_FOUND');
26 header('Location: list.php');
30 if (isset($_POST['submit_no'])) {
32 $msg->addFeedback('CANCELLED');
34 header('Location: view.php?fid='.$_POST['fid'].SEP.'pid='. ($_POST['ppid'] ? $_POST['ppid'] : $_POST['pid']));
37 header('Location: index.php?fid='.$_POST['fid']);
43 } else if (isset($_POST['submit_yes'])) {
44 // check if they have access
45 if (!valid_forum_user($fid)) {
46 $msg->addError('FORUM_NOT_FOUND');
47 header('Location: list.php');
51 if ($ppid == 0) { /* If deleting an entire post */
52 /* First get number of comments from specific post */
53 $sql = "SELECT * FROM ".TABLE_PREFIX."forums_threads WHERE post_id=$pid AND forum_id=$fid";
54 $result = mysql_query($sql, $db);
55 if (!($row = mysql_fetch_assoc($result))) {
56 $msg->addError('FORUM_NOT_FOUND');
57 header('Location: list.php');
62 /* Decrement count for number of posts and topics*/
63 $sql = "UPDATE ".TABLE_PREFIX."forums SET num_posts=num_posts-1-".$row['num_comments'].", num_topics=num_topics-1, last_post=last_post WHERE forum_id=$fid";
64 $result = mysql_query($sql, $db);
66 $sql = "DELETE FROM ".TABLE_PREFIX."forums_threads WHERE (parent_id=$pid OR post_id=$pid) AND forum_id=$fid";
67 $result = mysql_query($sql, $db);
69 $sql = "DELETE FROM ".TABLE_PREFIX."forums_accessed WHERE post_id=$pid";
70 $result = mysql_query($sql, $db);
72 } else { /* Just deleting a single thread */
73 $sql = "DELETE FROM ".TABLE_PREFIX."forums_threads WHERE post_id=$pid AND forum_id=$fid";
74 $result = mysql_query($sql, $db);
75 if (mysql_affected_rows($db) == 0) {
76 $msg->addError('FORUM_NOT_FOUND');
77 header('Location: list.php');
81 /* Decrement count of comments in forums_threads table*/
82 $sql = "UPDATE ".TABLE_PREFIX."forums_threads SET num_comments=num_comments-1, last_comment=last_comment, date=date WHERE post_id=$ppid";
83 $result = mysql_query($sql, $db);
85 /* Decrement count of posts in forums table */
86 $sql = "UPDATE ".TABLE_PREFIX."forums SET num_posts=num_posts-1, last_post=last_post WHERE forum_id=$fid";
87 $result = mysql_query($sql, $db);
92 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
93 header('Location: view.php?fid='.$fid.SEP.'pid='.$ppid);
96 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
97 header('Location: index.php?fid='.$fid);
102 $_pages['mods/_standard/forums/forum/index.php?fid='.$fid]['title'] = get_forum_name($fid);
103 $_pages['mods/_standard/forums/forum/index.php?fid='.$fid]['parent'] = 'forum/list.php';
104 $_pages['mods/_standard/forums/forum/index.php?fid='.$fid]['children'] = array('mods/_standard/forums/forum/new_thread.php?fid='.$fid);
106 $_pages['mods/_standard/forums/forum/new_thread.php?fid='.$fid]['title_var'] = 'new_thread';
107 $_pages['mods/_standard/forums/forum/new_thread.php?fid='.$fid]['parent'] = 'mods/_standard/forums/forum/index.php?fid='.$fid;
109 $_pages['mods/_standard/forums/forum/view.php']['title'] = $post_row['subject'];
110 $_pages['mods/_standard/forums/forum/view.php']['parent'] = 'forum/index.php?fid='.$fid;
112 $_pages['mods/_standard/forums/forum/delete_thread.php']['title_var'] = 'delete_post';
113 $_pages['mods/_standard/forums/forum/delete_thread.php']['parent'] = 'mods/_standard/forums/forum/index.php?fid='.$fid;
114 $_pages['mods/_standard/forums/forum/delete_thread.php']['children'] = array();
116 require(AT_INCLUDE_PATH.'header.inc.php');
119 $sql = "SELECT * from ".TABLE_PREFIX."forums_threads WHERE post_id = '$pid'";
120 $result = mysql_query($sql, $db);
121 $row = mysql_fetch_assoc($result);
122 $title = AT_print($row['subject'], 'forums_threads.subject');
125 $hidden_vars['fid'] = $_GET['fid'];
126 $hidden_vars['pid'] = $_GET['pid'];
127 $hidden_vars['ppid'] = $_GET['ppid'];
128 $hidden_vars['nest'] = $_GET['nest'];
130 $msg->addConfirm(array('DELETE', $title),$hidden_vars);
131 if (($ppid=='') || ($ppid =='0')) {
135 $msg->printConfirm();
137 require(AT_INCLUDE_PATH.'footer.inc.php');