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 $_REQUEST['pid'] = intval($_REQUEST['pid']);
21 $_REQUEST['ppid'] = intval($_REQUEST['ppid']);
22 $_REQUEST['fid'] = intval($_REQUEST['fid']);
24 if (!valid_forum_user($_REQUEST['fid'])) {
25 $msg->addError('FORUM_NOT_FOUND');
26 header('Location: list.php');
30 if (isset($_POST['cancel'])) {
31 $msg->addFeedback('CANCELLED');
32 header('Location: index.php?fid='.$_REQUEST['fid']);
35 } else if (isset($_POST['submit'])) {
36 // check if they have access
37 if (!valid_forum_user($_REQUEST['fid']) || !valid_forum_user($_REQUEST['new_fid'])) {
38 $msg->addError('FORUM_NOT_FOUND');
39 header('Location: list.php');
43 if ($_REQUEST['fid'] == $_REQUEST['new_fid']) {
44 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
45 header('Location: index.php?fid='.$_REQUEST['fid']);
49 $sql = "SELECT * FROM ".TABLE_PREFIX."forums_threads WHERE post_id=$_REQUEST[pid] AND forum_id=$_REQUEST[fid]";
50 $result = mysql_query($sql, $db);
51 if (!($row = mysql_fetch_assoc($result))) {
52 $msg->addError('FORUM_NOT_FOUND');
53 header('Location: list.php');
57 /* Decrement count for number of posts and topics*/
58 $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=$_REQUEST[fid]";
59 $result = mysql_query($sql, $db);
61 $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=$_REQUEST[new_fid]";
62 $result = mysql_query($sql, $db);
64 $sql = "UPDATE ".TABLE_PREFIX."forums_threads SET forum_id=$_REQUEST[new_fid], last_comment=last_comment, date=date WHERE (parent_id=$_REQUEST[pid] OR post_id=$_REQUEST[pid]) AND forum_id=$_REQUEST[fid]";
65 $result = mysql_query($sql, $db);
67 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
68 header('Location: index.php?fid='.$_REQUEST['fid']);
72 $_pages['mods/_standard/forums/forum/index.php?fid='.$_REQUEST['fid']]['title'] = get_forum_name($_REQUEST['fid']);
73 $_pages['mods/_standard/forums/forum/index.php?fid='.$_REQUEST['fid']]['parent'] = 'mods/_standard/forums/forum/list.php';
74 $_pages['mods/_standard/forums/forum/index.php?fid='.$_REQUEST['fid']]['children'] = array('mods/_standard/forums/forum/move_thread.php');
76 $_pages['mods/_standard/forums/forum/move_thread.php']['title_var'] = 'move_thread';
77 $_pages['mods/_standard/forums/forum/move_thread.php']['parent'] = 'mods/_standard/forums/forum/index.php?fid='.$_REQUEST['fid'];
78 $_pages['mods/_standard/forums/forum/move_thread.php']['children'] = array();
80 require(AT_INCLUDE_PATH.'header.inc.php');
82 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
83 <input type="hidden" name="fid" value="<?php echo $_REQUEST['fid']; ?>" />
84 <input type="hidden" name="pid" value="<?php echo $_REQUEST['pid']; ?>" />
85 <input type="hidden" name="ppid" value="<?php echo $_REQUEST['ppid']; ?>" />
87 <div class="input-form">
89 <?php echo _AT('move_thread_to');
90 $all_forums = get_forums($_SESSION['course_id']);
92 <ul style="list-style: none">
93 <?php foreach($all_forums['nonshared'] as $row): ?>
95 <input type="radio" name="new_fid" value="<?php echo $row['forum_id']; ?>" id="f<?php echo $row['forum_id']; ?>" <?php if ($row['forum_id'] == $_REQUEST['fid']) { echo 'checked="checked"'; } ?> /><label for="f<?php echo $row['forum_id']; ?>"><?php echo AT_print($row['title'], 'forums.title'); ?></label>
101 <div class="row buttons">
102 <input type="submit" name="submit" value="<?php echo _AT('move'); ?>" />
103 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
108 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>