diff --git a/nginx.conf b/nginx.conf index 742a688f56..5ed8a85886 100644 --- a/nginx.conf +++ b/nginx.conf @@ -129,7 +129,7 @@ server { rewrite admin/api/(.*) /admin/api/index.php last; # Administration pages - rewrite admin/(attachments|backup|configuration|elasticsearch|export|glossary|group|import|instance|instances|password|session-keep-alive|statistics|stopwords|system|tags|update|user) /admin/front.php last; + rewrite admin/(attachments|backup|comments|configuration|elasticsearch|export|glossary|group|import|instance|instances|password|session-keep-alive|statistics|stopwords|system|tags|update|user) /admin/front.php last; # REST API v3.0 and v3.1 rewrite ^api/v3\.[01]/(.*) /api/index.php last; diff --git a/phpmyfaq/.htaccess b/phpmyfaq/.htaccess index 995b5312ce..182e6b55ac 100644 --- a/phpmyfaq/.htaccess +++ b/phpmyfaq/.htaccess @@ -143,7 +143,7 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization" # Administration API RewriteRule ^admin/api/(.*) admin/api/index.php [L,QSA] # Administration pages - RewriteRule ^admin/(attachments|backup|configuration|elasticsearch|export|glossary|group|import|instance|instances|password|session-keep-alive|statistics|stopwords|system|tags|update|user) admin/front.php [L,QSA] + RewriteRule ^admin/(attachments|backup|comments|configuration|elasticsearch|export|glossary|group|import|instance|instances|password|session-keep-alive|statistics|stopwords|system|tags|update|user) admin/front.php [L,QSA] # Private APIs RewriteRule ^api/(autocomplete|bookmark/delete|bookmark/create|user/data/update|user/password/update|user/request-removal|user/remove-twofactor|contact|voting|register|captcha|share|comment/create|faq/create|question/create|webauthn/prepare|webauthn/register|webauthn/prepare-login|webauthn/login) api/index.php [L,QSA] # Setup APIs diff --git a/phpmyfaq/admin/comments.php b/phpmyfaq/admin/comments.php deleted file mode 100644 index a59cc577d4..0000000000 --- a/phpmyfaq/admin/comments.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright 2007-2024 phpMyFAQ Team - * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 - * @link https://www.phpmyfaq.de - * @since 2007-03-04 - */ - -use phpMyFAQ\Comments; -use phpMyFAQ\Configuration; -use phpMyFAQ\Date; -use phpMyFAQ\Entity\CommentType; -use phpMyFAQ\Enums\PermissionType; -use phpMyFAQ\Faq; -use phpMyFAQ\Session\Token; -use phpMyFAQ\Template\Extensions\FaqTwigExtension; -use phpMyFAQ\Template\TwigWrapper; -use phpMyFAQ\User\CurrentUser; -use Twig\Extra\Intl\IntlExtension; - -if (!defined('IS_VALID_PHPMYFAQ')) { - http_response_code(400); - exit(); -} - -$faqConfig = Configuration::getConfigurationInstance(); -$user = CurrentUser::getCurrentUser($faqConfig); -[$currentAdminUser, $currentAdminGroups] = CurrentUser::getCurrentUserGroupId($user); - -$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates'); -$twig->addExtension(new IntlExtension()); -$twig->addExtension(new FaqTwigExtension()); -$template = $twig->loadTemplate('@admin/content/comments.twig'); - -if ($user->perm->hasPermission($user->getUserId(), PermissionType::COMMENT_DELETE->value)) { - $comment = new Comments($faqConfig); - $faq = new Faq($faqConfig); - $date = new Date($faqConfig); - - $faqComments = $comment->getAllComments(); - $newsComments = $comment->getAllComments(CommentType::NEWS); - - $templateVars = [ - 'currentLocale' => $faqConfig->getLanguage()->getLanguage(), - 'faqComments' => $faqComments, - 'newsComments' => $newsComments, - 'csrfToken' => Token::getInstance($container->get('session'))->getTokenString('delete-comment'), - ]; - - echo $template->render($templateVars); -} else { - require __DIR__ . '/no-permission.php'; -} diff --git a/phpmyfaq/admin/header.php b/phpmyfaq/admin/header.php index 0f8755f29d..7d0e50520a 100644 --- a/phpmyfaq/admin/header.php +++ b/phpmyfaq/admin/header.php @@ -80,7 +80,7 @@ 'stickyRecordsHeader' ); $secLevelEntries['content'] .= $adminHelper->addMenuEntry('delquestion', 'question', 'ad_menu_open'); -$secLevelEntries['content'] .= $adminHelper->addMenuEntry('delcomment', 'comments', 'ad_menu_comments'); +$secLevelEntries['content'] .= $adminHelper->addMenuEntry('delcomment', 'comments', 'ad_menu_comments', 'comments'); $secLevelEntries['content'] .= $adminHelper->addMenuEntry( 'addattachment+editattachment+delattachment', 'attachments', @@ -195,8 +195,6 @@ case 'delete-news': case 'question': case 'takequestion': - case 'comments': - case 'attachments': case 'stickyfaqs': $contentPage = true; break; diff --git a/phpmyfaq/admin/index.php b/phpmyfaq/admin/index.php index 4bebca952b..d90db9c1e0 100755 --- a/phpmyfaq/admin/index.php +++ b/phpmyfaq/admin/index.php @@ -270,9 +270,6 @@ case 'question': require 'open-questions.php'; break; - case 'comments': - require 'comments.php'; - break; case 'stickyfaqs': require 'stickyfaqs.php'; break; diff --git a/phpmyfaq/assets/templates/admin/content/comments.twig b/phpmyfaq/assets/templates/admin/content/comments.twig index a6b92891c6..ab5df92201 100644 --- a/phpmyfaq/assets/templates/admin/content/comments.twig +++ b/phpmyfaq/assets/templates/admin/content/comments.twig @@ -1,114 +1,120 @@ -
- - | -
-
-
-
- {{ comment.username }}
-
-
-
-
- {{ comment.date | format_datetime(locale=currentLocale) }}
+
|
+