From c9aa85b87d412ce701779a36cac35ad38ae68c44 Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Mon, 22 Apr 2024 17:56:57 +0200 Subject: [PATCH] fix: corrected check for active FAQs and News --- .../src/phpMyFAQ/Controller/Frontend/CommentController.php | 6 +++--- phpmyfaq/src/phpMyFAQ/Notification.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/phpmyfaq/src/phpMyFAQ/Controller/Frontend/CommentController.php b/phpmyfaq/src/phpMyFAQ/Controller/Frontend/CommentController.php index 2c25b448f2..807c820d20 100644 --- a/phpmyfaq/src/phpMyFAQ/Controller/Frontend/CommentController.php +++ b/phpmyfaq/src/phpMyFAQ/Controller/Frontend/CommentController.php @@ -55,7 +55,6 @@ public function create(Request $request): JsonResponse $faq = new Faq($this->configuration); $comment = new Comments($this->configuration); - $category = new Category($this->configuration); $stopWords = new StopWords($this->configuration); $session = new Session($this->configuration); $session->setCurrentUser($user); @@ -111,7 +110,7 @@ public function create(Request $request): JsonResponse if ( !empty($username) && !empty($mailer) && !empty($commentText) && $stopWords->checkBannedWord($commentText) && - $comment->isCommentAllowed($id, $languageCode, $type) && !$faq->isActive($id, $languageCode, $type) + $comment->isCommentAllowed($id, $languageCode, $type) && $faq->isActive($id, $languageCode, $type) ) { $session->userTracking('save_comment', $id); $commentEntity = new Comment(); @@ -121,11 +120,12 @@ public function create(Request $request): JsonResponse ->setUsername($username) ->setEmail($mailer) ->setComment(nl2br(strip_tags((string) $commentText))) - ->setDate($request->server->get('tim')); + ->setDate($request->server->get('REQUEST_TIME')); if ($comment->create($commentEntity)) { $notification = new Notification($this->configuration); if ('faq' == $type) { + $faq->getRecord($id); $notification->sendFaqCommentNotification($faq, $commentEntity); } else { $news = new News($this->configuration); diff --git a/phpmyfaq/src/phpMyFAQ/Notification.php b/phpmyfaq/src/phpMyFAQ/Notification.php index d5cc39ac13..fdd763c053 100644 --- a/phpmyfaq/src/phpMyFAQ/Notification.php +++ b/phpmyfaq/src/phpMyFAQ/Notification.php @@ -125,7 +125,8 @@ public function sendFaqCommentNotification(Faq $faq, Comment $comment): void { $category = new Category($this->configuration); $emailTo = $this->configuration->getAdminEmail(); - if ($faq->faqRecord['email'] != '') { + + if ($faq->faqRecord['email'] !== '') { $emailTo = $faq->faqRecord['email']; }