Gazelle/sections/forums/newthread.php

168 lines
6.0 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/*
New post page
This is the page that's loaded if someone wants to make a new topic.
Information to be expected in $_GET:
forumid: The ID of the forum that it's being posted in
*/
$ForumID = $_GET['forumid'];
2013-04-19 08:00:55 +00:00
if (!is_number($ForumID)) {
2011-03-28 14:21:28 +00:00
error(404);
}
$Forum = get_forum_info($ForumID);
2013-04-19 08:00:55 +00:00
if ($Forum === false) {
2011-03-28 14:21:28 +00:00
error(404);
}
2013-04-19 08:00:55 +00:00
if (!check_forumperm($ForumID, 'Write') || !check_forumperm($ForumID, 'Create')) {
error(403);
}
2013-06-27 08:01:06 +00:00
View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic','comments,bbcode,jquery.validate,form_validate');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
<h2><a href="forums.php">Forums</a> &gt; <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$Forum['Name']?></a> &gt; <span id="newthreadtitle">New Topic</span></h2>
<div class="hidden" id="newthreadpreview">
<div class="linkbox">
<div class="center">
2013-03-02 08:00:34 +00:00
<a href="#" onclick="return false;" class="brackets">Report thread</a>
2013-02-09 08:01:01 +00:00
<a href="#" onclick="return false;" class="brackets"><?=!empty($HeavyInfo['AutoSubscribe']) ? 'Unsubscribe' : 'Subscribe'?></a>
2011-03-28 14:21:28 +00:00
</div>
</div>
2013-04-19 08:00:55 +00:00
<? if (check_perms('forums_polls_create')) { ?>
2011-03-28 14:21:28 +00:00
<div class="box thin clear hidden" id="pollpreview">
2013-06-17 08:01:02 +00:00
<div class="head colhead_dark"><strong>Poll</strong> <a href="#" onclick="$('#threadpoll').gtoggle(); return false;" class="brackets">View</a></div>
2011-03-28 14:21:28 +00:00
<div class="pad" id="threadpoll">
<p><strong id="pollquestion"></strong></p>
<div id="pollanswers"></div>
2013-06-15 08:00:45 +00:00
<br /><input type="radio" name="vote" id="answer_0" value="0" /> <label for="answer_0">Blank&#8202;&mdash;&#8202;Show the results!</label><br /><br />
2011-03-28 14:21:28 +00:00
<input type="button" style="float: left;" value="Vote" />
</div>
</div>
2013-04-19 08:00:55 +00:00
<? } ?>
<table class="forum_post box vertical_margin" style="text-align: left;">
2012-10-29 08:00:20 +00:00
<colgroup>
2013-05-01 08:00:16 +00:00
<? if (Users::has_avatars_enabled()) { ?>
2012-10-29 08:00:20 +00:00
<col class="col_avatar" />
2013-04-19 08:00:55 +00:00
<? } ?>
2012-10-29 08:00:20 +00:00
<col class="col_post_body" />
</colgroup>
2011-03-28 14:21:28 +00:00
<tr class="colhead_dark">
2013-05-01 08:00:16 +00:00
<td colspan="<?=Users::has_avatars_enabled() ? 2 : 1 ?>">
2013-04-19 08:00:55 +00:00
<span style="float: left;"><a href="#newthreadpreview">#XXXXXX</a>
2012-10-11 08:00:15 +00:00
by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true, true)?></strong>
2011-03-28 14:21:28 +00:00
Just now
</span>
2013-03-02 08:00:34 +00:00
<span id="barpreview" style="float: right;">
2013-02-09 08:01:01 +00:00
<a href="#newthreadpreview" class="brackets">Report</a>
2011-03-28 14:21:28 +00:00
&nbsp;
<a href="#">&uarr;</a>
</span>
</td>
</tr>
<tr>
2013-05-01 08:00:16 +00:00
<? if (Users::has_avatars_enabled()) { ?>
2011-03-28 14:21:28 +00:00
<td class="avatar" valign="top">
2013-05-01 08:00:16 +00:00
<?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
2011-03-28 14:21:28 +00:00
</td>
2013-05-01 08:00:16 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
<td class="body" valign="top">
2013-03-02 08:00:34 +00:00
<div id="contentpreview" style="text-align: left;"></div>
2011-03-28 14:21:28 +00:00
</td>
</tr>
</table>
</div>
<div class="box pad">
2013-05-21 08:01:09 +00:00
<form class="create_form" name="forum_thread" action="" id="newthreadform" method="post">
2011-03-28 14:21:28 +00:00
<input type="hidden" name="action" value="new" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="forum" value="<?=$ForumID?>" />
2012-09-01 08:00:24 +00:00
<table id="newthreadtext" class="layout">
2011-03-28 14:21:28 +00:00
<tr>
2013-04-19 08:00:55 +00:00
<td class="label">Title:</td>
2013-05-21 08:01:09 +00:00
<td><input id="title" class="required" type="text" name="title" style="width: 98%;" /></td>
2011-03-28 14:21:28 +00:00
</tr>
<tr>
2012-11-06 08:00:20 +00:00
<td class="label">Body:</td>
2013-05-21 08:01:09 +00:00
<td><textarea id="posttext" class="required" style="width: 98%;" onkeyup="resize('posttext');" name="body" cols="90" rows="8"></textarea></td>
2011-03-28 14:21:28 +00:00
</tr>
<tr>
<td></td>
<td>
2013-03-02 08:00:34 +00:00
<input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?> onchange="$('#subscribeboxpreview').raw().checked=this.checked;" />
2011-03-28 14:21:28 +00:00
<label for="subscribebox">Subscribe to topic</label>
</td>
</tr>
2012-05-03 08:00:25 +00:00
<?
2012-11-08 08:00:19 +00:00
if (check_perms('forums_polls_create')) {
2012-05-03 08:00:25 +00:00
?>
2013-01-16 08:00:31 +00:00
<script type="text/javascript">//<![CDATA[
2011-03-28 14:21:28 +00:00
var AnswerCount = 1;
function AddAnswerField() {
2013-04-19 08:00:55 +00:00
if (AnswerCount >= 25) {
return;
}
2011-03-28 14:21:28 +00:00
var AnswerField = document.createElement("input");
AnswerField.type = "text";
AnswerField.id = "answer_"+AnswerCount;
2013-05-21 08:01:09 +00:00
AnswerField.className = "required";
2011-03-28 14:21:28 +00:00
AnswerField.name = "answers[]";
AnswerField.style.width = "90%";
2013-02-18 08:00:22 +00:00
2011-03-28 14:21:28 +00:00
var x = $('#answer_block').raw();
x.appendChild(document.createElement("br"));
x.appendChild(AnswerField);
AnswerCount++;
}
function RemoveAnswerField() {
2013-04-19 08:00:55 +00:00
if (AnswerCount == 1) {
return;
}
2011-03-28 14:21:28 +00:00
var x = $('#answer_block').raw();
2013-04-19 08:00:55 +00:00
for (i = 0; i < 2; i++) {
x.removeChild(x.lastChild);
}
2011-03-28 14:21:28 +00:00
AnswerCount--;
}
2013-01-16 08:00:31 +00:00
//]]>
2011-03-28 14:21:28 +00:00
</script>
<tr>
<td colspan="2" class="center">
2013-02-18 08:00:22 +00:00
<strong>Poll Settings</strong>
2013-06-17 08:01:02 +00:00
<a href="#" onclick="$('#poll_question, #poll_answers').gtoggle(); return false;" class="brackets">View</a>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<tr id="poll_question" class="hidden">
2012-11-06 08:00:20 +00:00
<td class="label">Question:</td>
2013-05-21 08:01:09 +00:00
<td><input type="text" name="question" id="pollquestionfield" class="required" style="width: 98%;" /></td>
2011-03-28 14:21:28 +00:00
</tr>
<tr id="poll_answers" class="hidden">
2012-11-06 08:00:20 +00:00
<td class="label">Answers:</td>
2011-03-28 14:21:28 +00:00
<td id="answer_block">
2013-05-21 08:01:09 +00:00
<input type="text" name="answers[]" class="required" style="width: 90%;" />
2013-02-09 08:01:01 +00:00
<a href="#" onclick="AddAnswerField();return false;" class="brackets">+</a>
2013-02-18 08:00:22 +00:00
<a href="#" onclick="RemoveAnswerField();return false;" class="brackets">&minus;</a>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<? } ?>
</table>
<div id="subscribediv" class="hidden">
2013-04-19 08:00:55 +00:00
<input id="subscribeboxpreview" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : '' ?> />
2011-03-28 14:21:28 +00:00
<label for="subscribebox">Subscribe to topic</label>
</div>
2012-11-14 08:00:19 +00:00
<div id="buttons" class="center">
<input type="button" value="Preview" onclick="Newthread_Preview(1);" id="newthreadpreviewbutton" />
<input type="button" value="Editor" onclick="Newthread_Preview(0);" id="newthreadeditbutton" class="hidden" />
2013-05-21 08:01:09 +00:00
<input type="submit" class="submit" id="submit_button" value="Create thread" />
2012-11-14 08:00:19 +00:00
</div>
2011-03-28 14:21:28 +00:00
</form>
</div>
</div>
2012-10-11 08:00:15 +00:00
<? View::show_footer(); ?>