|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Open Questions Controller |
| 5 | + * |
| 6 | + * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | + * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | + * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | + * |
| 10 | + * @package phpMyFAQ |
| 11 | + * @author Thorsten Rinne <[email protected]> |
| 12 | + * @copyright 2002-2026 phpMyFAQ Team |
| 13 | + * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | + * @link https://www.phpmyfaq.de |
| 15 | + * @since 2002-09-17 |
| 16 | + */ |
| 17 | + |
| 18 | +declare(strict_types=1); |
| 19 | + |
| 20 | +namespace phpMyFAQ\Controller\Frontend; |
| 21 | + |
| 22 | +use phpMyFAQ\Category; |
| 23 | +use phpMyFAQ\Core\Exception; |
| 24 | +use phpMyFAQ\Enums\PermissionType; |
| 25 | +use phpMyFAQ\Helper\QuestionHelper; |
| 26 | +use phpMyFAQ\Translation; |
| 27 | +use Symfony\Component\HttpFoundation\Request; |
| 28 | +use Symfony\Component\HttpFoundation\Response; |
| 29 | +use Symfony\Component\Routing\Attribute\Route; |
| 30 | + |
| 31 | +final class OpenQuestionsController extends AbstractFrontController |
| 32 | +{ |
| 33 | + /** |
| 34 | + * Displays the open questions page. |
| 35 | + * |
| 36 | + * @throws Exception |
| 37 | + * @throws \Exception |
| 38 | + */ |
| 39 | + #[Route(path: '/open-questions.html', name: 'public.open-questions')] |
| 40 | + public function index(Request $request): Response |
| 41 | + { |
| 42 | + $faqSession = $this->container->get('phpmyfaq.user.session'); |
| 43 | + $faqSession->setCurrentUser($this->currentUser); |
| 44 | + $faqSession->userTracking('open_questions', 0); |
| 45 | + |
| 46 | + $category = new Category($this->configuration); |
| 47 | + $questionHelper = new QuestionHelper(); |
| 48 | + $questionHelper->setConfiguration($this->configuration)->setCategory($category); |
| 49 | + |
| 50 | + return $this->render('open-questions.twig', [ |
| 51 | + ...$this->getHeader($request), |
| 52 | + 'title' => sprintf('%s - %s', Translation::get(key: 'msgOpenQuestions'), $this->configuration->getTitle()), |
| 53 | + 'metaDescription' => sprintf( |
| 54 | + Translation::get(key: 'msgOpenQuestionsMetaDesc'), |
| 55 | + $this->configuration->getTitle(), |
| 56 | + ), |
| 57 | + 'pageHeader' => Translation::get(key: 'msgOpenQuestions'), |
| 58 | + 'msgQuestionText' => Translation::get(key: 'msgQuestionText'), |
| 59 | + 'msgDate_User' => Translation::get(key: 'msgDate_User'), |
| 60 | + 'msgQuestion2' => Translation::get(key: 'msgQuestion2'), |
| 61 | + 'openQuestions' => $questionHelper->getOpenQuestions(), |
| 62 | + 'isCloseQuestionEnabled' => $this->configuration->get('records.enableCloseQuestion'), |
| 63 | + 'userHasPermissionToAnswer' => $this->currentUser->perm->hasPermission( |
| 64 | + $this->currentUser->getUserId(), |
| 65 | + PermissionType::FAQ_ADD->value, |
| 66 | + ), |
| 67 | + 'msgQuestionsWaiting' => Translation::get(key: 'msgQuestionsWaiting'), |
| 68 | + 'msgNoQuestionsAvailable' => Translation::get(key: 'msgNoQuestionsAvailable'), |
| 69 | + 'msg2answerFAQ' => Translation::get(key: 'msg2answerFAQ'), |
| 70 | + 'msg2answer' => Translation::get(key: 'msg2answer'), |
| 71 | + ]); |
| 72 | + } |
| 73 | +} |
0 commit comments