r20151018.1
This commit is contained in:
parent
8284c0d9af
commit
b5043980d9
7 changed files with 137 additions and 22 deletions
|
@ -277,6 +277,25 @@ class Forum
|
|||
|
||||
}
|
||||
|
||||
// Get a forum ID from a topic ID
|
||||
public static function getForumIdFromTopicId($id)
|
||||
{
|
||||
|
||||
// Get the topic
|
||||
$topic = Database::fetch('topics', false, [
|
||||
'topic_id' => [$id, '='],
|
||||
]);
|
||||
|
||||
// Return false if nothing was returned
|
||||
if (empty($topic)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the forum id
|
||||
return $topic['forum_id'];
|
||||
|
||||
}
|
||||
|
||||
// Get a topic ID from a post ID
|
||||
public static function getTopicIdFromPostId($id)
|
||||
{
|
||||
|
@ -346,8 +365,55 @@ class Forum
|
|||
}
|
||||
|
||||
// Creating a new post
|
||||
public static function createPost($subject, $text, $enableMD, $enableSig, $forum, $type = 0, $status = 0, $topic = 0)
|
||||
public static function createPost($poster, $title, $text, $forum, $topic = 0, $parse = 0, $signature = 0, $emotes = 0, $type = 0, $status = 0)
|
||||
{
|
||||
|
||||
// Check if we're replying to a thread
|
||||
$getThread = Database::fetch('topics', false, ['topic_id' => [$topic, '=']]);
|
||||
|
||||
// If nothing was returned create a new thread
|
||||
if (!$getThread) {
|
||||
// Insert the required data
|
||||
Database::insert('topics', [
|
||||
'forum_id' => $forum,
|
||||
'topic_title' => $title,
|
||||
'topic_time' => time(),
|
||||
'topic_status' => $status,
|
||||
'topic_type' => $type,
|
||||
]);
|
||||
|
||||
// Fetch the last insert
|
||||
$getThread = Database::fetch('topics', false, null, ['topic_id', true]);
|
||||
}
|
||||
|
||||
// Insert the post
|
||||
Database::insert('posts', [
|
||||
'topic_id' => $getThread['topic_id'],
|
||||
'forum_id' => $getThread['forum_id'],
|
||||
'poster_id' => $poster,
|
||||
'post_time' => time(),
|
||||
'post_parse' => $parse,
|
||||
'post_signature' => $signature,
|
||||
'post_emotes' => $emotes,
|
||||
'post_subject' => $title,
|
||||
'post_text' => $text,
|
||||
]);
|
||||
|
||||
// Fetch the last insert
|
||||
$getPost = Database::fetch('posts', false, null, ['post_id', true]);
|
||||
|
||||
// Update the topic with the last details
|
||||
Database::update('topics', [
|
||||
[
|
||||
'topic_last_reply' => time(),
|
||||
],
|
||||
[
|
||||
'topic_id' => [$getPost['topic_id'], '='],
|
||||
],
|
||||
]);
|
||||
|
||||
// Return success
|
||||
return [1, 'SUCCESS', $getPost['forum_id'], $getPost['topic_id'], $getPost['post_id']];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<td class="forumLastColumn">
|
||||
<div>
|
||||
{% if forum.last_post.post_id %}
|
||||
<a href="{{ urls.format('FORUM_THREAD', [forum.last_post.topic_id]) }}" class="default">{{ forum.last_post.post_subject }}</a><br /><span title="{{ forum.last_post.post_time|date(sakura.dateFormat) }}">{{ forum.last_post.elapsed }}</span> by {% if forum.last_poster.data.user_id %}<a href="{{ urls.format('USER_PROFILE', [forum.last_poster.data.user_id]) }}" class="default" style="color: {{ forum.last_poster.colour }}; text-shadow: 0 0 5px {% if forum.last_poster.colour != 'inherit' %}{{ forum.last_poster.colour }}{% else %}#222{% endif %};">{{ forum.last_poster.data.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ urls.format('FORUM_POST', [forum.last_poster.post.post_id]) }}#p{{ forum.last_poster.post.post_id }}" class="default fa fa-tag"></a>
|
||||
<a href="{{ urls.format('FORUM_THREAD', [forum.last_post.topic_id]) }}" class="default">{{ forum.last_post.post_subject }}</a><br /><span title="{{ forum.last_post.post_time|date(sakura.dateFormat) }}">{{ forum.last_post.elapsed }}</span> by {% if forum.last_poster.data.user_id %}<a href="{{ urls.format('USER_PROFILE', [forum.last_poster.data.user_id]) }}" class="default" style="color: {{ forum.last_poster.colour }}; text-shadow: 0 0 5px {% if forum.last_poster.colour != 'inherit' %}{{ forum.last_poster.colour }}{% else %}#222{% endif %};">{{ forum.last_poster.data.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ urls.format('FORUM_POST', [forum.last_post.post.post_id]) }}#p{{ forum.last_poster.post.post_id }}" class="default fa fa-tag"></a>
|
||||
{% else %}
|
||||
There are no posts in this forum.<br />
|
||||
{% endif %}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{% block content %}
|
||||
<div class="content">
|
||||
<div class="content-column forum posting">
|
||||
<form method="post" action="{{ sakura.currentPage }}">
|
||||
<form id="forumPostingForm" method="post" action="{{ sakura.currentPage }}">
|
||||
<div class="head">Forum / Posting</div>
|
||||
<div class="posting-subject">
|
||||
<input type="text" class="inputStyling" name="subject" placeholder="Subject" />
|
||||
|
@ -44,21 +44,26 @@
|
|||
</div>
|
||||
<div>
|
||||
<label for="parseMode">Parsing Mode:</label>
|
||||
<select>
|
||||
<option>None</option>
|
||||
<option selected="selected">BBCodes</option>
|
||||
<option>Markdown</option>
|
||||
<select id="parseMode" name="parseMode">
|
||||
<option value="0">None</option>
|
||||
<option value="1" selected="selected">BBCodes</option>
|
||||
<option value="2">Markdown</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<hr class="default" />
|
||||
<div class="posting-buttons">
|
||||
<input class="inputStyling" type="submit" name="preview" value="Preview" />
|
||||
<input class="inputStyling" type="submit" name="preview" value="Preview" disabled="disabled" />
|
||||
<input class="inputStyling" type="submit" name="post" value="Post" />
|
||||
<input class="inputStyling" type="submit" name="cancel" value="Cancel" />
|
||||
<input class="inputStyling" type="button" onclick="history.go(-1);" value="Cancel" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
window.addEventListener("load", function() {
|
||||
prepareAjaxForm('forumPostingForm', 'Making post...');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
</form>
|
||||
<script type="text/javascript">
|
||||
window.addEventListener("load", function() {
|
||||
|
||||
prepareAjaxForm('editProfileForm', 'Updating Profile...');
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -281,7 +281,6 @@ if (isset($_REQUEST['mode'])) {
|
|||
) :
|
||||
Templates::render('global/information.tpl', $renderData);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
// Add page specific things
|
||||
|
|
|
@ -1704,6 +1704,15 @@ button.inputStyling:active {
|
|||
transition: text-shadow .2s, box-shadow .2s;
|
||||
}
|
||||
|
||||
input[type="submit"][disabled=disabled].inputStyling,
|
||||
input[type="button"][disabled=disabled].inputStyling,
|
||||
input[type="reset"][disabled=disabled].inputStyling,
|
||||
button[disabled=disabled].inputStyling {
|
||||
background: linear-gradient(180deg, #858585 0%, #858585 50%, #787878 50%) #858585 !important;
|
||||
box-shadow: inset #222 0 0 1px !important;
|
||||
text-shadow: #888 0 0 2px !important;
|
||||
}
|
||||
|
||||
input[type="text"].inputStyling,
|
||||
input[type="password"].inputStyling,
|
||||
input[type="date"].inputStyling,
|
||||
|
|
|
@ -10,18 +10,56 @@ namespace Sakura;
|
|||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sakura.php';
|
||||
|
||||
// Set location
|
||||
$locId = isset($_GET['f']) ?
|
||||
$_GET['f'] :
|
||||
$topicId = isset($_GET['t']) ?
|
||||
$_GET['t'] :
|
||||
(
|
||||
isset($_GET['t']) ?
|
||||
$_GET['t'] :
|
||||
(
|
||||
isset($_GET['p']) ?
|
||||
Forum::getTopicIdFromPostId($_GET['p']) :
|
||||
0
|
||||
)
|
||||
);
|
||||
$locMode = isset($_GET['f']) ? 'f' : (isset($_GET['t']) || isset($_GET['p']) ? 't' : null);
|
||||
|
||||
$forumId = isset($_GET['f']) ?
|
||||
$_GET['f'] :
|
||||
Forum::getForumIdFromTopicId($topicId);
|
||||
|
||||
$mode = isset($_GET['f']) ? 'f' : (isset($_GET['t']) || isset($_GET['p']) ? 't' : null);
|
||||
|
||||
// Check if a post is being made
|
||||
if (isset($_POST['post'])) {
|
||||
// Set post mode
|
||||
switch($_POST['parseMode']) {
|
||||
case '1':
|
||||
$parse = '1';
|
||||
break;
|
||||
case '2':
|
||||
$parse = '2';
|
||||
break;
|
||||
default:
|
||||
$parse = '0';
|
||||
}
|
||||
|
||||
// Attempt to make the post
|
||||
$makePost = Forum::createPost($currentUser->data['user_id'], $_POST['subject'], $_POST['text'], $forumId, $topicId, $parse);
|
||||
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$makePost[3]]),
|
||||
'message' => 'Made the post!',
|
||||
'success' => $makePost[0],
|
||||
|
||||
];
|
||||
|
||||
// Print page contents or if the AJAX request is set only display the render data
|
||||
print isset($_REQUEST['ajax']) ?
|
||||
(
|
||||
$renderData['page']['message'] . '|' .
|
||||
$renderData['page']['success'] . '|' .
|
||||
$renderData['page']['redirect']
|
||||
) :
|
||||
Templates::render('global/information.tpl', $renderData);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Set additional render data
|
||||
$renderData = array_merge($renderData, [
|
||||
|
|
Reference in a new issue