From 5547fd7895086461ac701d3d455ba8862698fbe1 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 8 Jan 2018 10:41:33 +0100 Subject: [PATCH] * added new forum option: "Enable HTML" * will be by default enabled for newses * fixed bbcode parsing --- common.php | 2 +- install/includes/schema.sql | 1 + system/libs/forum.php | 26 ++++++++++++++++----- system/migrations/21.php | 14 +++++++++++ system/pages/forum.php | 2 +- system/pages/forum/edit_post.php | 26 ++++++++++++--------- system/pages/forum/new_post.php | 18 +++++++------- system/pages/forum/new_thread.php | 11 +++++---- system/pages/forum/show_thread.php | 9 ++----- system/templates/forum.edit_post.html.twig | 12 +++++++--- system/templates/forum.new_post.html.twig | 12 +++++++++- system/templates/forum.new_thread.html.twig | 14 +++++++++-- 12 files changed, 102 insertions(+), 45 deletions(-) create mode 100644 system/migrations/21.php diff --git a/common.php b/common.php index 2fdab191..c8c33a26 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.7.7-dev'); -define('DATABASE_VERSION', 20); +define('DATABASE_VERSION', 21); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/install/includes/schema.sql b/install/includes/schema.sql index 46a1cfa9..87c754d9 100644 --- a/install/includes/schema.sql +++ b/install/includes/schema.sql @@ -109,6 +109,7 @@ CREATE TABLE `myaac_forum` `post_text` text NOT NULL, `post_topic` varchar(255) NOT NULL DEFAULT '', `post_smile` tinyint(1) NOT NULL default '0', + `post_html` tinyint(1) NOT NULL default '0', `post_date` int(20) NOT NULL default '0', `last_edit_aid` int(20) NOT NULL default '0', `edit_date` int(20) NOT NULL default '0', diff --git a/system/libs/forum.php b/system/libs/forum.php index b5588992..c501d9b0 100644 --- a/system/libs/forum.php +++ b/system/libs/forum.php @@ -37,7 +37,20 @@ class Forum { global $db; $thread_id = 0; - if($db->insert(TABLE_PREFIX . 'forum', array('first_post' => 0, 'last_post' => time(), 'section' => $section_id, 'replies' => 0, 'views' => 0, 'author_aid' => isset($account_id) ? $account_id : 0, 'author_guid' => isset($player_id) ? $player_id : 0, 'post_text' => $body, 'post_topic' => $title, 'post_smile' => 0, 'post_date' => time(), 'last_edit_aid' => 0, 'edit_date' => 0, 'post_ip' => $_SERVER['REMOTE_ADDR']))) { + if($db->insert(TABLE_PREFIX . 'forum', array( + 'first_post' => 0, + 'last_post' => time(), + 'section' => $section_id, + 'replies' => 0, + 'views' => 0, + 'author_aid' => isset($account_id) ? $account_id : 0, + 'author_guid' => isset($player_id) ? $player_id : 0, + 'post_text' => $body, 'post_topic' => $title, + 'post_smile' => 0, 'post_html' => 1, + 'post_date' => time(), + 'last_edit_aid' => 0, 'edit_date' => 0, + 'post_ip' => $_SERVER['REMOTE_ADDR'] + ))) { $thread_id = $db->lastInsertId(); $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id); } @@ -45,7 +58,7 @@ class Forum return $thread_id; } - static public function add_post($thread_id, $section, $author_aid, $author_guid, $post_text, $post_topic, $smile) + static public function add_post($thread_id, $section, $author_aid, $author_guid, $post_text, $post_topic, $smile, $html) { global $db; $db->insert(TABLE_PREFIX . 'forum', array( @@ -56,6 +69,7 @@ class Forum 'post_text' => $post_text, 'post_topic' => $post_topic, 'post_smile' => $smile, + 'post_html' => $html, 'post_date' => time(), 'post_ip' => $_SERVER['REMOTE_ADDR'] )); @@ -232,18 +246,18 @@ class Forum foreach($tags as $search => $replace) $text = preg_replace($search, $replace, $text); - return ($smiles == 0 ? Forum::parseSmiles($text) : $text); + return ($smiles ? Forum::parseSmiles($text) : $text); } - public static function showPost($topic, $text, $smiles, $bb_code = true) + public static function showPost($topic, $text, $smiles = true, $html = false) { - if(!$bb_code) { + if($html) { return '' . $topic . '
' . $text; } $post = ''; if(!empty($topic)) - $post .= ''.($smiles == 0 ? self::parseSmiles($topic) : $topic).'
'; + $post .= ''.($smiles ? self::parseSmiles($topic) : $topic).'
'; $post .= self::parseBBCode(nl2br($text), $smiles); return $post; diff --git a/system/migrations/21.php b/system/migrations/21.php new file mode 100644 index 00000000..f5c6d87c --- /dev/null +++ b/system/migrations/21.php @@ -0,0 +1,14 @@ +query("ALTER TABLE `" . TABLE_PREFIX . "forum` ADD `post_html` TINYINT(1) NOT NULL DEFAULT 0 AFTER `post_smile`;"); + +$query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX . "forum_boards` WHERE `name` LIKE " . $db->quote('News') . " LIMIT 1;"); +if($query->rowCount() == 0) { + return; // don't make anything +} + +$query = $query->fetch(); +$id = $query['id']; + +// update all forum threads with is_html = 1 +$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `post_html` = 1 WHERE `section` = " . $id . " AND `id` = `first_post`;"); \ No newline at end of file diff --git a/system/pages/forum.php b/system/pages/forum.php index 68407dd2..0b82e01a 100644 --- a/system/pages/forum.php +++ b/system/pages/forum.php @@ -172,7 +172,7 @@ if(empty($action)) return; } - +$errors = array(); if($action == 'show_board' || $action == 'show_thread') { require(PAGES . 'forum/' . $action . '.php'); diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php index 27df2d1e..03e9f6dc 100644 --- a/system/pages/forum/edit_post.php +++ b/system/pages/forum/edit_post.php @@ -18,14 +18,14 @@ if(Forum::canPost($account_logged)) return; } - $thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `id`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch(); + $thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `post_html`, `id`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch(); if(isset($thread['id'])) { $first_post = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch(); echo 'Boards >> '.$sections[$thread['section']]['name'].' >> '.$first_post['post_topic'].' >> Edit post'; if(Forum::hasAccess($thread['section'] && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator()))) { - $char_id = $post_topic = $text = $smile = null; + $char_id = $post_topic = $text = $smile = $html = null; $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll(); $saved = false; if(isset($_REQUEST['save'])) @@ -33,9 +33,10 @@ if(Forum::canPost($account_logged)) $text = stripslashes(trim($_REQUEST['text'])); $char_id = (int) $_REQUEST['char_id']; $post_topic = stripslashes(trim($_REQUEST['topic'])); - $smile = (int) $_REQUEST['smile']; + $smile = isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0; + $html = isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0; $lenght = 0; - for($i = 0; $i <= strlen($post_topic); $i++) + for($i = 0; $i < strlen($post_topic); $i++) { if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126) $lenght++; @@ -43,12 +44,11 @@ if(Forum::canPost($account_logged)) if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post']) $errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.'; $lenght = 0; - for($i = 0; $i <= strlen($text); $i++) + for($i = 0; $i < strlen($text); $i++) { if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126) $lenght++; } - if($lenght < 1 || strlen($text) > 15000) $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.'; if($char_id == 0) @@ -56,7 +56,7 @@ if(Forum::canPost($account_logged)) if(empty($post_topic) && $thread['id'] == $thread['first_post']) $errors[] = 'Thread topic can\'t be empty.'; - $player_on_account == false; + $player_on_account = false; if(count($errors) == 0) { @@ -71,7 +71,7 @@ if(Forum::canPost($account_logged)) $saved = true; if($account_logged->getId() != $thread['author_aid']) $char_id = $thread['author_guid']; - $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']); + $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".$smile.", `post_html` = ".$html.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']); $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch(); $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1; header('Location: ' . getForumThreadLink($thread['first_post'], $_page)); @@ -83,6 +83,7 @@ if(Forum::canPost($account_logged)) $char_id = (int) $thread['author_guid']; $post_topic = $thread['post_topic']; $smile = (int) $thread['post_smile']; + $html = (int) $thread['post_html']; } if(!$saved) @@ -94,9 +95,12 @@ if(Forum::canPost($account_logged)) 'post_id' => $post_id, 'players' => $players_from_account, 'player_id' => $char_id, - 'topic' => htmlspecialchars($post_topic), - 'text' => htmlspecialchars($text), - 'smile' => $smile + 'post_topic' => $canEdit ? $post_topic : htmlspecialchars($post_topic), + 'post_text' => $canEdit ? $text : htmlspecialchars($text), + 'post_smile' => $smile > 0, + 'post_html' => $html > 0, + 'html' => $html, + 'canEdit' => $canEdit )); } } diff --git a/system/pages/forum/new_post.php b/system/pages/forum/new_post.php index e26ba1ef..08fe6dab 100644 --- a/system/pages/forum/new_post.php +++ b/system/pages/forum/new_post.php @@ -27,7 +27,8 @@ if(Forum::canPost($account_logged)) $text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL; $char_id = (int) (isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0); $post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : ''; - $smile = (int) (isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0); + $smile = (isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0); + $html = (isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0); $saved = false; if(isset($_REQUEST['quote'])) { @@ -72,7 +73,7 @@ if(Forum::canPost($account_logged)) if(count($errors) == 0) { $saved = true; - Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), (int) $char_id, $text, $post_topic, (int) $smile, time(), $_SERVER['REMOTE_ADDR']); + Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), (int) $char_id, $text, $post_topic, $smile, $html, time(), $_SERVER['REMOTE_ADDR']); $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id); $post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch(); $_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1; @@ -86,15 +87,12 @@ if(Forum::canPost($account_logged)) if(!empty($errors)) echo $twig->render('error_box.html.twig', array('errors' => $errors)); - $threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid` 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` DESC LIMIT 5")->fetchAll(); + $threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`post_html`, `" . TABLE_PREFIX . "forum`.`author_aid` 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` DESC LIMIT 5")->fetchAll(); foreach($threads as &$thread) { $player_account = new OTS_Account(); $player_account->load($thread['author_aid']); if($player_account->isLoaded()) { - // check if its news written in tinymce - $hasAccess = $player_account->hasFlag(FLAG_CONTENT_NEWS) || $player_account->isSuperAdmin(); - $bb_code = ($thread['post_text'] == strip_tags($thread['post_text'])) || !$hasAccess; - $thread['post'] = Forum::showPost(($hasAccess ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($hasAccess ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'], $bb_code); + $thread['post'] = Forum::showPost(($thread['post_html'] > 0 ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($thread['post_html'] > 0 ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'] == 0, $thread['post_html'] > 0); } } @@ -104,9 +102,11 @@ if(Forum::canPost($account_logged)) 'players' => $players_from_account, 'post_topic' => $post_topic, 'post_text' => $text, - 'post_smile' => $smile, + 'post_smile' => $smile > 0, + 'post_html' => $html > 0, 'topic' => $thread['post_topic'], - 'threads' => $threads + 'threads' => $threads, + 'canEdit' => $canEdit )); } } diff --git a/system/pages/forum/new_thread.php b/system/pages/forum/new_thread.php index bede96e7..cb0d70cb 100644 --- a/system/pages/forum/new_thread.php +++ b/system/pages/forum/new_thread.php @@ -24,7 +24,8 @@ if(Forum::canPost($account_logged)) $text = isset($_REQUEST['text']) ? stripslashes($_REQUEST['text']) : ''; $char_id = (int)(isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0); $post_topic = isset($_REQUEST['topic']) ? stripslashes($_REQUEST['topic']) : ''; - $smile = (int)(isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0); + $smile = (isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0); + $html = (isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0); $saved = false; if (isset($_REQUEST['save'])) { $errors = array(); @@ -68,7 +69,7 @@ if(Forum::canPost($account_logged)) } if (count($errors) == 0) { $saved = true; - $db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')"); + $db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile`, `post_html` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . (int)$html . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')"); $thread_id = $db->lastInsertId(); $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id); header('Location: ' . getForumThreadLink($thread_id)); @@ -85,8 +86,10 @@ if(Forum::canPost($account_logged)) 'players' => $players_from_account, 'post_player_id' => $char_id, 'post_thread' => $post_topic, - 'text' => $text, - 'smiles_enabled' => $smile > 0 + 'post_text' => $text, + 'post_smile' => $smile > 0, + 'post_html' => $html > 0, + 'canEdit' => $canEdit )); } } diff --git a/system/pages/forum/show_thread.php b/system/pages/forum/show_thread.php index fed562f9..d1ea243b 100644 --- a/system/pages/forum/show_thread.php +++ b/system/pages/forum/show_thread.php @@ -33,7 +33,7 @@ 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(); +$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`.`post_html`, `" . 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'])) $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'].''; @@ -56,14 +56,9 @@ foreach($threads as $thread) if($guild->isLoaded()) echo $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()); $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).' + echo '
Posts: '.(int) $posts['posts'].'
'.Forum::showPost(($thread['post_html'] > 0 ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($thread['post_html'] > 0 ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'] == 0, $thread['post_html'] > 0).' '.date('d.m.y H:i:s', $thread['post_date']); if($thread['edit_date'] > 0) { diff --git a/system/templates/forum.edit_post.html.twig b/system/templates/forum.edit_post.html.twig index ab8bdc18..2976fd7e 100644 --- a/system/templates/forum.edit_post.html.twig +++ b/system/templates/forum.edit_post.html.twig @@ -22,21 +22,27 @@ Topic: - (Optional) + (Optional) Message:
You can use:
[player]Nick[/player]
[url]http://address.com/[/url]
[img]http://images.com/images3.gif[/img]
[code]Code[/code]
[b]Text[/b]
[i]Text[/i]
[u]Text[/u]
and smileys:
;) , :) , :D , :( , :rolleyes:
:cool: , :eek: , :o , :p
-
(Max. 15,000 letters) +
(Max. 15,000 letters) Options: + {% if canEdit %} +
+ + {% endif %} diff --git a/system/templates/forum.new_post.html.twig b/system/templates/forum.new_post.html.twig index ef969c8e..69fb5a65 100644 --- a/system/templates/forum.new_post.html.twig +++ b/system/templates/forum.new_post.html.twig @@ -28,7 +28,17 @@ Options: - + + + {% if canEdit %} +
+ + {% endif %} +
diff --git a/system/templates/forum.new_thread.html.twig b/system/templates/forum.new_thread.html.twig index 7f362459..3143e9fb 100644 --- a/system/templates/forum.new_thread.html.twig +++ b/system/templates/forum.new_thread.html.twig @@ -25,11 +25,21 @@ Message:
You can use:
[player]Nick[/player]
[url]http://address.com/[/url]
[img]http://images.com/images3.gif[/img]
[code]Code[/code]
[b]Text[/b]
[i]Text[/i]
[u]Text[/u]
and smileys:
;) , :) , :D , :( , :rolleyes:
:cool: , :eek: , :o , :p
-
(Max. 15,000 letters) +
(Max. 15,000 letters) Options: - + + + {% if canEdit %} +
+ + {% endif %} +