Skip to content

Commit

Permalink
fix: corrected check for active FAQs and News
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Apr 22, 2024
1 parent dec6b9b commit c9aa85b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion phpmyfaq/src/phpMyFAQ/Notification.php
Expand Up @@ -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'];
}

Expand Down

0 comments on commit c9aa85b

Please sign in to comment.