From 21b1383c9afdf0b2c620c3c3ae80696039ba2136 Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 24 Oct 2017 15:18:30 +0200 Subject: [PATCH] * update forum post after editing news (when forum post has been created) --- system/pages/news.php | 11 +++++++++-- system/templates/admin.menus.form.html.twig | 2 +- system/templates/news.add.html.twig | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/system/pages/news.php b/system/pages/news.php index 2b29c6ec..31d19377 100644 --- a/system/pages/news.php +++ b/system/pages/news.php @@ -10,6 +10,7 @@ * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); +header('X-XSS-Protection: 0'); if(isset($_GET['archive'])) { @@ -146,7 +147,12 @@ if($canEdit) $player_id = $news['player_id']; } else { - if(News::update($id, $p_title, $body, $type, $category, $player_id, $comments, $errors)) { + if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $errors)) { + // update forum thread if exists + if(isset($forum_section) && Validator::number($forum_section)) { + $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section)); + } + $action = $p_title = $body = $comments = ''; $type = $category = $player_id = 0; } @@ -287,7 +293,8 @@ if(!$news_cached) 'category' => isset($category) ? $category : 0, 'categories' => $categories, 'forum_boards' => getForumBoards(), - 'forum_section' => isset($forum_section) ? $forum_section : null + 'forum_section' => isset($forum_section) ? $forum_section : null, + 'comments' => isset($comments) ? $comments : null )); } diff --git a/system/templates/admin.menus.form.html.twig b/system/templates/admin.menus.form.html.twig index 653d3525..003d255e 100644 --- a/system/templates/admin.menus.form.html.twig +++ b/system/templates/admin.menus.form.html.twig @@ -5,5 +5,5 @@ Please choose template in which you want to edit menu items.
{% endfor %} - + \ No newline at end of file diff --git a/system/templates/news.add.html.twig b/system/templates/news.add.html.twig index c70bce25..9260542c 100644 --- a/system/templates/news.add.html.twig +++ b/system/templates/news.add.html.twig @@ -95,6 +95,8 @@ + {% elseif comments is not null%} + {% endif %} {% set rows = rows + 1 %}