From c1eb7d4f52cea550b342fe0339e35c666d4c8d2b Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 6 Feb 2023 19:35:00 +0100 Subject: [PATCH] fix news adding, rename const to NEWS_* --- admin/pages/news.php | 10 +++++----- system/libs/news.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/admin/pages/news.php b/admin/pages/news.php index 620da469..65a26132 100644 --- a/admin/pages/news.php +++ b/admin/pages/news.php @@ -23,8 +23,8 @@ if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) { header('X-XSS-Protection:0'); // some constants, used mainly by database (cannot by modified without schema changes) -define('TITLE_LIMIT', 100); -define('BODY_LIMIT', 65535); // maximum news body length +define('NEWS_TITLE_LIMIT', 100); +define('NEWS_BODY_LIMIT', 65535); // maximum news body length define('ARTICLE_TEXT_LIMIT', 300); define('ARTICLE_IMAGE_LIMIT', 100); @@ -43,12 +43,12 @@ if(!empty($action)) $forum_section = isset($_REQUEST['forum_section']) ? $_REQUEST['forum_section'] : null; $errors = array(); - if($action == 'add') { + if($action == 'new') { if(isset($forum_section) && $forum_section != '-1') { $forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors); } - if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) { + if(isset($p_title) && News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) { $p_title = $body = $comments = $article_text = $article_image = ''; $type = $category = $player_id = 0; @@ -115,7 +115,7 @@ if($action == 'edit' || $action == 'new') { $twig->display('admin.news.form.html.twig', array( 'action' => $action, 'news_link' => getLink(PAGE), - 'news_link_form' => '?p=news&action=' . ($action == 'edit' ? 'edit' : 'add'), + 'news_link_form' => '?p=news&action=' . ($action == 'edit' ? 'edit' : 'new'), 'news_id' => isset($id) ? $id : null, 'title' => isset($p_title) ? $p_title : '', 'body' => isset($body) ? escapeHtml($body) : '', diff --git a/system/libs/news.php b/system/libs/news.php index a9131e02..b0f17158 100644 --- a/system/libs/news.php +++ b/system/libs/news.php @@ -8,12 +8,12 @@ class News $errors[] = 'Please fill all inputs.'; return false; } - if(strlen($title) > TITLE_LIMIT) { - $errors[] = 'News title cannot be longer than ' . TITLE_LIMIT . ' characters.'; + if(strlen($title) > NEWS_TITLE_LIMIT) { + $errors[] = 'News title cannot be longer than ' . NEWS_TITLE_LIMIT . ' characters.'; return false; } - if(strlen($body) > BODY_LIMIT) { - $errors[] = 'News content cannot be longer than ' . BODY_LIMIT . ' characters.'; + if(strlen($body) > NEWS_BODY_LIMIT) { + $errors[] = 'News content cannot be longer than ' . NEWS_BODY_LIMIT . ' characters.'; return false; } if(strlen($article_text) > ARTICLE_TEXT_LIMIT) { @@ -138,4 +138,4 @@ class News } } } -} \ No newline at end of file +}