exit; } if (isset($_GET['topic'])) { $topic = intval($_GET['topic']); } else { $topic = ''; } $myrow = Database::get()->querySingle("SELECT id, name FROM forum WHERE id = ?d AND course_id = ?d", $forum, $course_id); $forum_name = $myrow->name; $forum_id = $myrow->id; $is_member = false; $group_id = init_forum_group_info($forum_id); $pageName = $langNewTopic; $navigation[] = array('url' => "index.php?course={$course_code}", 'name' => $langForums); $navigation[] = array('url' => "viewforum.php?course={$course_code}&forum={$forum_id}", 'name' => q($forum_name)); if (!does_exists($forum_id, "forum")) { $tool_content .= "<div class='alert alert-danger'>{$langErrorPost}</div>"; draw($tool_content, 2); exit; } if (!isset($_POST['submit'])) { $dynbar = array(array('title' => $langBack, 'url' => "viewforum.php?course={$course_code}&forum={$forum_id}", 'icon' => 'fa-reply', 'level' => 'primary-label')); $tool_content .= action_bar($dynbar); } if (isset($_POST['submit'])) { $subject = trim($_POST['subject']); $message = trim($_POST['message']); if (empty($message) or empty($subject)) { header("Location: viewforum.php?course={$course_code}&forum={$forum_id}&empty=true"); exit; }
} list(, $myrow) = each($rowQ1); $forum_name = $myrow['forum_name']; $forum_access = $myrow['forum_access']; $forum_type = $myrow['forum_type']; $mod = $myrow['forum_moderator']; if ($forum_type == 1 and $Forum_passwd != $myrow['forum_pass']) { header("Location: forum.php"); } if ($forum_access == 9) { header("Location: forum.php"); } if (is_locked($topic)) { forumerror('0025'); } if (!does_exists($forum, "forum") || !does_exists($topic, "topic")) { forumerror('0026'); } settype($submitS, 'string'); settype($stop, 'integer'); if ($submitS) { if ($message == '') { $stop = 1; } if (!isset($user)) { if ($forum_access == 0) { $userdata = array("uid" => 1); $modo = ""; include "header.php"; } else { if ($username == "" or $password == "") {
} } else { $parent_post = 0; } $myrow = Database::get()->querySingle("SELECT f.name, t.title, t.locked\n FROM forum f, forum_topic t\n WHERE f.id = {$forum}\n AND t.id = {$topic}\n AND t.forum_id = f.id\n AND f.course_id = ?d", $course_id); $forum_name = $myrow->name; $topic_title = $myrow->title; $topic_locked = $myrow->locked; $forum_id = $forum; $is_member = false; $group_id = init_forum_group_info($forum_id); $pageName = $langReply; $navigation[] = array('url' => "index.php?course={$course_code}", 'name' => $langForums); $navigation[] = array('url' => "viewforum.php?course={$course_code}&forum={$forum_id}", 'name' => q($forum_name)); $navigation[] = array('url' => "viewtopic.php?course={$course_code}&topic={$topic}&forum={$forum_id}", 'name' => q($topic_title)); if (!does_exists($forum, "forum") || !does_exists($topic, "topic") || !$parent_post_ok) { $tool_content .= $langErrorTopicSelect; draw($tool_content, 2, null, $head_content); exit; } if ($topic_locked == 1) { $tool_content .= "<div class='alert alert-warning'>{$langErrorTopicLocked}</div>"; draw($tool_content, 2, null, $head_content); exit; } if (isset($_POST['submit'])) { $message = $_POST['message']; $poster_ip = $_SERVER['REMOTE_ADDR']; $parent_post = $_POST['parent_post']; if (trim($message) == '') { $tool_content .= "\n <div class='alert alert-warning'>{$langEmptyMsg}</div>\n <p class='back'>« {$langClick} <a href='newtopic.php?course={$course_code}&forum={$forum_id}'>{$langHere}</a> {$langReturnTopic}</p>";
$Mmod = false; for ($i = 0; $i < count($moderator); $i++) { if ($userdata[1] == $moderator[$i]) { $Mmod = true; break; } } $userdata = get_userdata($userdata[1]); } if ($myrow['forum_type'] == 1 and $Forum_passwd != $myrow['forum_pass']) { header("Location: forum.php"); } if ($forum_access == 9) { header("Location: forum.php"); } if (!does_exists($forum, "forum")) { forumerror('0030'); } // Forum ARBRE if ($myrow['arbre']) { $hrefX = "viewtopicH.php"; } else { $hrefX = "viewtopic.php"; } settype($submitS, 'string'); settype($stop, 'integer'); if ($submitS) { if ($message == '') { $stop = 1; } if ($subject == '') {
foreach ($result as $result_row) { $forum_id = $result_row->forum_id; $forum_name = $result_row->forum_name; $cat_title = $result_row->cat_title; if ($forum_id == $current_forum_id) { $tool_content .= "<option value='{$forum_id}' selected>" . q($forum_name) . " (" . q($cat_title) . ")</option>"; } else { $tool_content .= "<option value='{$forum_id}'>" . q($forum_name) . " (" . q($cat_title) . ")</option>"; } } $tool_content .= "</select></div>\n </div>\n <div class='form-group'>\n <div class='col-sm-8 col-sm-offset-4'>\n <input class='btn btn-primary' type='submit' value='{$langModify}'>\n </div>\n </div>\n </fieldset>\n </form></div>"; } } elseif (isset($_GET['forumtopicsave'])) { $topic_id = intval($_GET['topic_id']); $new_forum = intval($_POST['forum_id']); if (does_exists($topic_id, 'topic')) { //topic belongs to the course and new forum is not a group forum $result = Database::get()->querySingle("SELECT `forum_id`, `num_replies`, `last_post_id` FROM `forum_topic` WHERE `id` = ?d", $topic_id); $current_forum_id = $result->forum_id; $num_replies = $result->num_replies; $last_post_id = $result->last_post_id; if ($current_forum_id != $new_forum) { Database::get()->query("UPDATE `forum_topic` SET `forum_id` = ?d WHERE `id` = ?d", $new_forum, $topic_id); Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_FORUMTOPIC, $topic_id); $result = Database::get()->querySingle("SELECT `last_post_id`, MAX(`topic_time`) FROM `forum_topic` WHERE `forum_id`=?d", $new_forum); $last_post_id = $result->last_post_id; Database::get()->query("UPDATE `forum` SET `num_topics` = `num_topics`+1, `num_posts` = `num_posts`+?d, `last_post_id` = ?d\n WHERE id = ?d", $num_replies + 1, $last_post_id, $new_forum); $result = Database::get()->querySingle("SELECT `last_post_id`, MAX(`topic_time`) FROM `forum_topic` WHERE `forum_id`=?d", $current_forum_id); if ($result) { $last_post_id = $result->last_post_id; } else {
} $tool_content .= "</select></div> </div> <div class='form-group'> <div class='col-sm-8 col-sm-offset-4'> <input class='btn btn-primary' type='submit' value='$langModify'> </div> </div> </fieldset> </form></div>"; } } elseif (isset($_GET['forumtopicsave'])) { $topic_id = intval($_GET['topic_id']); $new_forum = intval($_POST['forum_id']); if (does_exists($topic_id, 'topic')) {//topic belongs to the course and new forum is not a group forum $result = Database::get()->querySingle("SELECT `forum_id`, `num_replies`, `last_post_id` FROM `forum_topic` WHERE `id` = ?d", $topic_id); $current_forum_id = $result->forum_id; $num_replies = $result->num_replies; $last_post_id = $result->last_post_id; if ($current_forum_id != $new_forum) { Database::get()->query("UPDATE `forum_topic` SET `forum_id` = ?d WHERE `id` = ?d", $new_forum, $topic_id); Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_FORUMTOPIC, $topic_id); $result = Database::get()->querySingle("SELECT `last_post_id`, MAX(`topic_time`) FROM `forum_topic` WHERE `forum_id`=?d",$new_forum); $last_post_id = $result->last_post_id; Database::get()->query("UPDATE `forum` SET `num_topics` = `num_topics`+1, `num_posts` = `num_posts`+?d, `last_post_id` = ?d WHERE id = ?d",$num_replies+1, $last_post_id, $new_forum);