diff --git a/TODO b/TODO
index b77e1d81..befd3b34 100644
--- a/TODO
+++ b/TODO
@@ -16,10 +16,6 @@
* hooks
* fieldExist and tableExist functions
* Menus in templates
- * forum:
- * show position of the player
- * replace forum actions links for admin (move, remove) with images
- * redirect directly to the thread on user login
* characters: edit in admin panel option
* move highscores to twig
* $db->hasTable(table) + $db->hasColumn(table, column)
diff --git a/images/icons/comment_add.png b/images/icons/comment_add.png
new file mode 100644
index 00000000..75e78ded
Binary files /dev/null and b/images/icons/comment_add.png differ
diff --git a/system/pages/forum.php b/system/pages/forum.php
index 68407dd2..b133a41a 100644
--- a/system/pages/forum.php
+++ b/system/pages/forum.php
@@ -181,7 +181,12 @@ if($action == 'show_board' || $action == 'show_thread')
if(!$logged)
{
- header('Location: ' . BASE_URL . '?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=forum'));
+ $extra_url = '';
+ if($action == 'new_post' && isset($_GET['thread_id'])) {
+ $extra_url = '&action=new_post&thread_id=' . $_GET['thread_id'];
+ }
+
+ header('Location: ' . BASE_URL . '?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=forum' . $extra_url));
return;
}
diff --git a/system/pages/forum/show_thread.php b/system/pages/forum/show_thread.php
index 317557a6..1a10e400 100644
--- a/system/pages/forum/show_thread.php
+++ b/system/pages/forum/show_thread.php
@@ -13,14 +13,14 @@ defined('MYAAC') or die('Direct access not allowed!');
$links_to_pages = '';
$thread_id = (int) $_REQUEST['id'];
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
-$thread_name = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`section` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`id` = `" . TABLE_PREFIX . "forum`.`first_post` AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` LIMIT 1")->fetch();
+$thread_starter = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`section` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`id` = `" . TABLE_PREFIX . "forum`.`first_post` AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` LIMIT 1")->fetch();
-if(empty($thread_name['name'])) {
+if(empty($thread_starter['name'])) {
echo 'Thread with this ID does not exits.';
return;
}
-if(!Forum::hasAccess($thread_name['section'])) {
+if(!Forum::hasAccess($thread_starter['section'])) {
echo "You don't have access to view this thread.";
return;
}
@@ -33,60 +33,77 @@ for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']
else
$links_to_pages .= ''.($i + 1).' ';
}
-$threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `players`.`account_id`, `players`.`vocation`" . (fieldExist('promotion', 'players') ? ", `players`.`promotion`" : "") . ", `players`.`level`, `" . TABLE_PREFIX . "forum`.`id`,`" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`section`,`" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`last_edit_aid`, `" . TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
-if(isset($threads[0]['name']))
+$posts = $db->query("SELECT `players`.`id` as `player_id`, `" . TABLE_PREFIX . "forum`.`id`,`" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`section`,`" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date` AS `date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`last_edit_aid`, `" . TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
+if(isset($posts[0]['player_id'])) {
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
-echo 'Boards >> '.$sections[$threads[0]['section']]['name'].' >> '.$thread_name['post_topic'].'';
-echo '
Page: '.$links_to_pages.'
| '.htmlspecialchars($thread_name['post_topic']).' by ' . getPlayerLink($thread_name['name']) . ' | |
| Author | |
| ' . getPlayerLink($thread['name']) . ' Profession: '.$config['vocations'][$player->getVocation()].' Level: '.$thread['level'].' '; + if($config['characters']['outfit']) { + $post['outfit'] = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); + } + + $groupName = ''; + $group = $player->getGroup(); + if($group->isLoaded()) { + $groupName = $group->getName(); + } + $post['group'] = $groupName; + $post['player_link'] = getPlayerLink($player->getName()); + + $post['vocation'] = 'Unknown'; + if(isset($config['vocations'][$player->getVocation()])) { + $post['vocation'] = $config['vocations'][$player->getVocation()]; + } + $rank = $player->getRank(); if($rank->isLoaded()) { $guild = $rank->getGuild(); if($guild->isLoaded()) - echo $rank->getName().' of '.$guild->getName().' '; + $post['guildRank'] = $rank->getName().' of '.$guild->getName().''; } $player_account = $player->getAccount(); $canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin(); // check if its news written in tinymce - $bb_code = ($thread['post_text'] == strip_tags($thread['post_text'])) || (!$player_account->hasFlag(FLAG_CONTENT_NEWS) && !$player_account->isSuperAdmin()); + $bb_code = ($post['post_text'] == strip_tags($post['post_text'])) || (!$player_account->hasFlag(FLAG_CONTENT_NEWS) && !$player_account->isSuperAdmin()); - $posts = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $thread['account_id'])->fetch(); - echo ' Posts: '.(int) $posts['posts'].' | '.Forum::showPost(($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($canEditForum ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'], $bb_code).' |
| '.date('d.m.y H:i:s', $thread['post_date']);
- if($thread['edit_date'] > 0)
+ $post['content'] = Forum::showPost(($canEditForum ? $post['post_topic'] : htmlspecialchars($post['post_topic'])), ($canEditForum ? $post['post_text'] : htmlspecialchars($post['post_text'])), $post['post_smile'], $bb_code);
+
+ $query = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $player_account->getId())->fetch();
+ $post['author_posts_count'] = (int)$query['posts'];
+
+ if($post['edit_date'] > 0)
{
- if($thread['last_edit_aid'] != $thread['author_aid'])
- echo ' Edited by moderator'; - else - echo ' Edited by '.$thread['name']; - echo ' on '.date('d.m.y H:i:s', $thread['edit_date']); - } - echo ' | ';
- if(Forum::isModerator())
- if($thread['first_post'] != $thread['id'])
- echo 'REMOVE POST';
- else
- {
- echo '[MOVE]';
- echo ' REMOVE THREAD'; + if($post['last_edit_aid'] != $post['author_aid']) { + $post['edited_by'] = 'moderator'; } - if($logged && ($thread['account_id'] == $account_logged->getId() || Forum::isModerator())) - echo ' EDIT POST'; - if($logged) - echo ' Quote'; - echo ' |
';
+
+echo $twig->render('forum.show_thread.html.twig', array(
+ 'thread_id' => $thread_id,
+ 'posts' => $posts,
+ 'links_to_pages' => $links_to_pages,
+ 'author_link' => getPlayerLink($thread_starter['name']),
+ 'section' => array('id' => $posts[0]['section'], 'name' => $sections[$posts[0]['section']]['name']),
+ 'thread_starter' => $thread_starter,
+ 'is_moderator' => Forum::isModerator()
+));
+
echo $twig->render('forum.fullscreen.html.twig');
diff --git a/system/templates/account.redirect.html.twig b/system/templates/account.redirect.html.twig
index ac439308..16b8d7ba 100644
--- a/system/templates/account.redirect.html.twig
+++ b/system/templates/account.redirect.html.twig
@@ -31,6 +31,6 @@
// Automatic redirect
setTimeout ("automaticRedirect()", 1000);
function automaticRedirect() {
- window.location = "{{ redirect }}";
+ window.location = "{{ redirect|raw }}";
}
\ No newline at end of file
diff --git a/system/templates/forum.show_thread.html.twig b/system/templates/forum.show_thread.html.twig
new file mode 100644
index 00000000..46c159e9
--- /dev/null
+++ b/system/templates/forum.show_thread.html.twig
@@ -0,0 +1,75 @@
+Boards >> {{ section.name }} >> {{ thread_starter.post_topic }}
+
|
+ {{ thread_starter.post_topic }}
+ + by {{ author_link|raw }} + |
+ |
| + Author + | ++ |
| {{ post.player_link|raw }} + {% if post.outfit is defined %} + + {% endif %} + + {% if post.group is defined and post.group|lower != 'player' %} + Position: {{ post.group }} + {% endif %} + + Profession: {{ post.vocation }} + Level: {{ post.player.getLevel() }} + {% if post.guildRank is defined %} + {{ guildRank }} + {% endif %} + Posts: {{ post.author_posts_count }} + + |
+ {{ post.content|raw }} |
|
+ {{ post.date|date('d.m.y H:i:s') }}
+ {% if post.edited_by is defined %}
+ Edited by {{ post.edited_by }} + on {{ post.edit_date|date('d.m.y H:i:s') }} + {% endif %} + + |
+
+ {% if is_moderator %}
+ {% if post.first_post != post.id %}
+
+ {% else %}
+
+ {% endif %}
+ {% if logged and (post.player.getAccount().getId() == account_logged.getId() or is_moderator) %}
+
+
+ {% endif %}
+ {% if logged %}
+ |
+
\ No newline at end of file