From 0239f940a0bff457020073362e87ecdae1545c5b Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 17 Oct 2017 17:11:31 +0200 Subject: [PATCH] * moved forum.edit_post to twig templates * fixed forum move thread --- system/pages/forum/edit_post.php | 49 +++++++++++--------- system/templates/forum.edit_post.html.twig | 46 ++++++++++++++++++ system/templates/forum.move_thread.html.twig | 3 +- 3 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 system/templates/forum.edit_post.html.twig diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php index 7edc2162..2bd01350 100644 --- a/system/pages/forum/edit_post.php +++ b/system/pages/forum/edit_post.php @@ -13,14 +13,20 @@ defined('MYAAC') or die('Direct access not allowed!'); if(Forum::canPost($account_logged)) { - $post_id = (int) $_REQUEST['id']; - $thread = $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_date`, `" . 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) $post_id." LIMIT 1")->fetch(); + $post_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : false; + if(!$post_id) { + echo 'Please enter post id.'; + return; + } + + $thread = $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_date`, `" . 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` = ".$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($account_logged->getId() == $thread['author_aid'] || Forum::isModerator()) { + $char_id = $post_topic = $text = $smile = 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'])) @@ -43,13 +49,16 @@ if(Forum::canPost($account_logged)) 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) $errors[] = 'Please select a character.'; if(empty($post_topic) && $thread['id'] == $thread['first_post']) $errors[] = 'Thread topic can\'t be empty.'; + $player_on_account == false; + if(count($errors) == 0) { foreach($players_from_account as $player) @@ -58,8 +67,8 @@ if(Forum::canPost($account_logged)) if(!$player_on_account) $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account'; } - if(count($errors) == 0) - { + + if(count($errors) == 0) { $saved = true; if($account_logged->getId() != $thread['author_aid']) $char_id = $thread['author_guid']; @@ -70,41 +79,35 @@ if(Forum::canPost($account_logged)) echo '
Thank you for editing post.
GO BACK TO LAST THREAD'; } } - else - { + else { $text = $thread['post_text']; $char_id = (int) $thread['author_guid']; $post_topic = $thread['post_topic']; $smile = (int) $thread['post_smile']; } + if(!$saved) { if(!empty($errors)) echo $twig->render('error_box.html.twig', array('errors' => $errors)); - echo '
- -
Edit Post
Character:
Topic: (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)
Options:
'; + echo $twig->render('forum.edit_post.html.twig', array( + 'post_id' => $post_id, + 'players' => $players_from_account, + 'player_id' => $char_id, + 'topic' => htmlspecialchars($post_topic), + 'text' => htmlspecialchars($text), + 'smile' => $smile + )); } } else - echo '
You are not an author of this post.'; + echo '
You are not an author of this post.'; } else - echo '
Post with ID '.$post_id.' doesn\'t exist.'; + echo '
Post with ID '.$post_id.' doesn\'t exist.'; } else - echo '
Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.'; + echo '
Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.'; ?> \ No newline at end of file diff --git a/system/templates/forum.edit_post.html.twig b/system/templates/forum.edit_post.html.twig new file mode 100644 index 00000000..ab8bdc18 --- /dev/null +++ b/system/templates/forum.edit_post.html.twig @@ -0,0 +1,46 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Edit Post +
Character: + +
Topic: (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) +
Options: + +
+
+ +
+
\ No newline at end of file diff --git a/system/templates/forum.move_thread.html.twig b/system/templates/forum.move_thread.html.twig index 45951668..f68534ec 100644 --- a/system/templates/forum.move_thread.html.twig +++ b/system/templates/forum.move_thread.html.twig @@ -8,7 +8,8 @@
-
+ +