mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 01:09:21 +02:00
* show user avatar (outfit) in forum posts
* show user position (group) in forum posts * replaced forum actions links (move, remove, edit, quote) with images * redirect directly to the thread on user login (on new reply) * fixed account login redirect with special chars (like '&' and '?')
This commit is contained in:
parent
c2574235ea
commit
544375378f
4
TODO
4
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)
|
||||
|
BIN
images/icons/comment_add.png
Normal file
BIN
images/icons/comment_add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 530 B |
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
$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 '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($threads[0]['section']) . '">'.$sections[$threads[0]['section']]['name'].'</a> >> <b>'.$thread_name['post_topic'].'</b>';
|
||||
echo '<br /><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/forum/post.gif" border="0" /></a><br /><br />Page: '.$links_to_pages.'<br /><table width="100%"><tr bgcolor="'.$config['lightborder'].'" width="100%"><td colspan="2"><font size="4"><b>'.htmlspecialchars($thread_name['post_topic']).'</b></font><font size="1"><br />by ' . getPlayerLink($thread_name['name']) . '</font></td></tr><tr bgcolor="'.$config['vdarkborder'].'"><td width="200"><font color="white" size="1"><b>Author</b></font></td><td> </td></tr>';
|
||||
$player = $ots->createObject('Player');
|
||||
foreach($threads as $thread)
|
||||
}
|
||||
|
||||
$groups = new OTS_Groups_List();
|
||||
foreach($posts as &$post)
|
||||
{
|
||||
$player->load($thread['player_id']);
|
||||
$post['player'] = new OTS_Player();
|
||||
$player = $post['player'];
|
||||
$player->load($post['player_id']);
|
||||
if(!$player->isLoaded()) {
|
||||
error('Forum error: Player not loaded.');
|
||||
die();
|
||||
}
|
||||
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td valign="top">' . getPlayerLink($thread['name']) . '<br /><br /><font size="1">Profession: '.$config['vocations'][$player->getVocation()].'<br />Level: '.$thread['level'].'<br />';
|
||||
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 <a href="'.getGuildLink($guild->getName(), false).'">'.$guild->getName().'</a><br />';
|
||||
$post['guildRank'] = $rank->getName().' of <a href="'.getGuildLink($guild->getName(), false).'">'.$guild->getName().'</a>';
|
||||
}
|
||||
$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 '<br />Posts: '.(int) $posts['posts'].'<br /></font></td><td valign="top">'.Forum::showPost(($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($canEditForum ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'], $bb_code).'</td></tr>
|
||||
<tr bgcolor="'.getStyle($number_of_rows++).'"><td><font size="1">'.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 '<br />Edited by moderator';
|
||||
else
|
||||
echo '<br />Edited by '.$thread['name'];
|
||||
echo '<br />on '.date('d.m.y H:i:s', $thread['edit_date']);
|
||||
}
|
||||
echo '</font></td><td>';
|
||||
if(Forum::isModerator())
|
||||
if($thread['first_post'] != $thread['id'])
|
||||
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove post of '.$thread['name'].'?\')"><font color="red">REMOVE POST</font></a>';
|
||||
else
|
||||
{
|
||||
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<br/><a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">REMOVE THREAD</font></a>';
|
||||
if($post['last_edit_aid'] != $post['author_aid']) {
|
||||
$post['edited_by'] = 'moderator';
|
||||
}
|
||||
if($logged && ($thread['account_id'] == $account_logged->getId() || Forum::isModerator()))
|
||||
echo '<br/><a href="?subtopic=forum&action=edit_post&id='.$thread['id'].'">EDIT POST</a>';
|
||||
if($logged)
|
||||
echo '<br/><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"e='.$thread['id'].'">Quote</a>';
|
||||
echo '</td></tr>';
|
||||
else {
|
||||
$post['edited_by'] = $player->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</table><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/forum/post.gif" border="0" /></a>';
|
||||
|
||||
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');
|
||||
|
@ -31,6 +31,6 @@
|
||||
// Automatic redirect
|
||||
setTimeout ("automaticRedirect()", 1000);
|
||||
function automaticRedirect() {
|
||||
window.location = "{{ redirect }}";
|
||||
window.location = "{{ redirect|raw }}";
|
||||
}
|
||||
</script>
|
75
system/templates/forum.show_thread.html.twig
Normal file
75
system/templates/forum.show_thread.html.twig
Normal file
@ -0,0 +1,75 @@
|
||||
<a href="{{ getLink('forum') }}">Boards</a> >> <a href="{{ getLink('forum/board/' ~ section.id) }}">{{ section.name }}</a> >> <b>{{ thread_starter.post_topic }}</b>
|
||||
<br/><br/>
|
||||
<a href="?subtopic=forum&action=new_post&thread_id={{ thread_id }}"><img src="images/forum/post.gif" border="0" /></a><br/>
|
||||
<br/>
|
||||
Page: {{ links_to_pages|raw }}<br/>
|
||||
<table width="100%">
|
||||
<tr bgcolor="{{ config.lightborder }}" width="100%">
|
||||
<td colspan="2">
|
||||
<font size="4"><b>{{ thread_starter.post_topic }}</b></font>
|
||||
<font size="1"><br/>
|
||||
by {{ author_link|raw }}</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
<td width="200">
|
||||
<font color="white" size="1"><b>Author</b></font>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
{% set i = 0 %}
|
||||
{% for post in posts %}
|
||||
<tr bgcolor="{{ getStyle(i) }}">
|
||||
{% set i = i + 1 %}
|
||||
<td valign="top">{{ post.player_link|raw }}<br/>
|
||||
{% if post.outfit is defined %}
|
||||
<img style="margin-left:{% if post.player.getLookType() in [75, 266, 302] %}-0px;margin-top:-0px;width:64px;height:64px;{% else %}-60px;margin-top:-60px;width:128px;height:128px;{% endif %}" src="{{ post.outfit }}" alt="player outfit"/>
|
||||
<br />
|
||||
{% endif %}
|
||||
<font size="1">
|
||||
{% if post.group is defined and post.group|lower != 'player' %}
|
||||
Position: {{ post.group }}<br />
|
||||
{% endif %}
|
||||
|
||||
Profession: {{ post.vocation }}<br />
|
||||
Level: {{ post.player.getLevel() }} <br />
|
||||
{% if post.guildRank is defined %}
|
||||
{{ guildRank }}<br />
|
||||
{% endif %}
|
||||
<br />Posts: {{ post.author_posts_count }}<br />
|
||||
</font>
|
||||
</td>
|
||||
<td valign="top">{{ post.content|raw }} </td></tr>
|
||||
<tr bgcolor="{{ getStyle(i) }}">
|
||||
<td>
|
||||
<font size="1">{{ post.date|date('d.m.y H:i:s') }}
|
||||
{% if post.edited_by is defined %}
|
||||
<br />Edited by {{ post.edited_by }}
|
||||
<br />on {{ post.edit_date|date('d.m.y H:i:s') }}
|
||||
{% endif %}
|
||||
</font>
|
||||
</td>
|
||||
<td>
|
||||
{% if is_moderator %}
|
||||
{% if post.first_post != post.id %}
|
||||
<a href="?subtopic=forum&action=remove_post&id={{ post.id }}" title="Remove Post" onclick="return confirm('Are you sure you want remove post of {{ post.player.getName() }}?')"><img src="images/del.png"/></a>
|
||||
{% else %}
|
||||
<a href="?subtopic=forum&action=move_thread&id={{ post.id }}"><img src="images/icons/arrow_right.gif"/></a>
|
||||
<a href="?subtopic=forum&action=remove_post&id={{ post.id }}" title="Remove Thread" target="_blank" onclick="return confirm('Are you sure you want remove thread > {{ post.post_topic}} <?')"><img src="images/del.png"/></a>
|
||||
{% endif %}
|
||||
{% if logged and (post.player.getAccount().getId() == account_logged.getId() or is_moderator) %}
|
||||
<a href="?subtopic=forum&action=edit_post&id={{ post.id }}" title="Edit Post" target="_blank">
|
||||
<img src="images/edit.png"/></a>
|
||||
{% endif %}
|
||||
{% if logged %}
|
||||
<a href="?subtopic=forum&action=new_post&thread_id={{ thread_id }}"e={{ post.id }}" title="Quote Post"><img src="images/icons/comment_add.png"/></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% set i = i + 1 %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br/>
|
||||
<a href="?subtopic=forum&action=new_post&thread_id={{ thread_id }}"><img src="images/forum/post.gif" border="0" /></a>
|
Loading…
x
Reference in New Issue
Block a user