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 /****************************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
18 require(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
20 $fid = intval($_REQUEST['fid']);
22 if (isset($_GET['pid'])) {
23 $pid = intval($_GET['pid']);
25 $pid = intval($_POST['pid']);
27 if (!$pid || !$fid || !valid_forum_user($fid)) {
28 $msg->addError('ITEM_NOT_FOUND');
29 header('Location: ../../../forum/list.php');
33 $sql = "SELECT *, UNIX_TIMESTAMP(date) AS udate FROM ".TABLE_PREFIX."forums_threads WHERE post_id=$pid";
34 $result = mysql_query($sql,$db);
35 if (!($post_row = mysql_fetch_assoc($result))) {
36 $msg->addError('ITEM_NOT_FOUND');
37 header('Location: '.url_rewrite('/mods/_standard/forums/forum/list.php', AT_PRETTY_URL_IS_HEADER));
41 $forum_info = get_forum($fid, $_SESSION['course_id']);
43 $expiry = $post_row['udate'] + $forum_info['mins_to_edit'] * 60;
45 // check if we're either a) an assistant or, b) own this post and within the time allowed:
46 if (!( authenticate(AT_PRIV_FORUMS, AT_PRIV_RETURN)
47 || ($post_row['member_id'] == $_SESSION['member_id'] && ($expiry > time() || isset($_POST['edit_post']) ) )
50 $msg->addError('POST_EDIT_EXPIRE');
51 header('Location: '.url_rewrite('mods/_standard/forums/forum/list.php', AT_PRETTY_URL_IS_HEADER));
55 if ($_POST['cancel']) {
56 $msg->addFeedback('CANCELLED');
57 Header('Location: '.url_rewrite('mods/_standard/forums/forum/view.php?fid='.$_POST['fid'].SEP.'pid='.$_POST['pid'], AT_PRETTY_URL_IS_HEADER));
61 if ($_POST['edit_post']) {
62 $missing_fields = array();
64 // $_POST['subject'] = str_replace('<', '<', trim($_POST['subject']));
65 // $_POST['body'] = str_replace('<', '<', trim($_POST['body']));
66 $_POST['pid'] = intval($_POST['pid']);
68 $_POST['subject'] = $addslashes($_POST['subject']);
69 //If subject > 60,then chop subject
70 $_POST['subject'] = validate_length($_POST['subject'], 60);
72 $_POST['body'] = $addslashes($_POST['body']);
74 if ($_POST['subject'] == '') {
75 $missing_fields[] = _AT('subject');
78 if ($_POST['body'] == '') {
79 $missing_fields[] = _AT('body');
81 if ($missing_fields) {
82 $missing_fields = implode(', ', $missing_fields);
83 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
85 if (!$msg->containsErrors()) {
86 $sql = "UPDATE ".TABLE_PREFIX."forums_threads SET subject='$_POST[subject]', body='$_POST[body]', last_comment=last_comment, date=date WHERE post_id=$_POST[pid]";
87 $result = mysql_query($sql,$db);
89 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
90 if ($_POST['ppid'] == 0) {
91 $_POST['ppid'] = $_POST['pid'];
93 header('Location: '.url_rewrite('mods/_standard/forums/forum/view.php?fid='.$_POST['fid'].SEP.'pid='.$_POST['ppid'], AT_PRETTY_URL_IS_HEADER));
98 $_pages['mods/_standard/forums/forum/index.php?fid='.$fid]['title'] = $forum_info['title'];
99 $_pages['mods/_standard/forums/forum/index.php?fid='.$fid]['parent'] = 'mods/_standard/forums/forum/list.php';
100 $_pages['mods/_standard/forums/forum/index.php?fid='.$fid]['children'] = array('mods/_standard/forums/forum/new_thread.php?fid='.$fid);
102 $_pages['mods/_standard/forums/forum/new_thread.php?fid='.$fid]['title_var'] = 'new_thread';
103 $_pages['mods/_standard/forums/forum/new_thread.php?fid='.$fid]['parent'] = 'mods/_standard/forums/forum/index.php?fid='.$fid;
105 $_pages['mods/_standard/forums/forum/view.php']['title'] = $post_row['subject'];
106 $_pages['mods/_standard/forums/forum/view.php']['parent'] = 'mods/_standard/forums/forum/index.php?fid='.$fid;
108 $_pages['mods/_standard/forums/edit_post.php']['title_var'] = 'edit_post';
109 $_pages['mods/_standard/forums/edit_post.php']['parent'] = 'mods/_standard/forums/forum/index.php?fid='.$fid;
110 $_pages['mods/_standard/forums/edit_post.php']['children'] = array();
113 $onload = 'document.form.subject.focus();';
115 require(AT_INCLUDE_PATH.'header.inc.php');
119 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
120 <input type="hidden" name="edit_post" value="true" />
121 <input type="hidden" name="pid" value="<?php echo $pid; ?>" />
122 <input type="hidden" name="ppid" value="<?php echo $post_row['parent_id']; ?>" />
123 <input type="hidden" name="fid" value="<?php echo $post_row['forum_id']; ?>" />
125 <div class="input-form">
127 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="subject"><?php echo _AT('subject'); ?></label><br />
128 <input type="text" maxlength="80" name="subject" size="36" value="<?php echo stripslashes(htmlspecialchars($post_row['subject'])); ?>" id="subject" />
132 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="body"><?php echo _AT('body'); ?></label><br />
133 <textarea cols="65" name="body" rows="10" id="body"><?php echo AT_print($post_row['body'], 'text.input'); ?></textarea>
137 <small class="spacer"><br />· <?php echo _AT('forum_links'); ?><br />
138 · <?php echo _AT('forum_email_links'); ?><br />
139 · <?php echo _AT('forum_html_disabled'); ?></small>
143 <a href="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); ?>#jumpcodes" title="<?php echo _AT('jump_codes'); ?>"><img src="images/clr.gif" height="1" width="1" alt="<?php echo _AT('jump_codes'); ?>" border="0" /></a><?php require(AT_INCLUDE_PATH.'html/code_picker.inc.php'); ?>
145 <a name="jumpcodes"></a>
148 <div class="row buttons">
149 <input name="submit" type="submit" value=" <?php echo _AT('save'); ?>" accesskey="s" />
150 <input type="submit" name="cancel" value=" <?php echo _AT('cancel'); ?> " />
155 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>