diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php
index c11355db5..36cdd3aef 100644
--- a/app/Http/Controllers/PageController.php
+++ b/app/Http/Controllers/PageController.php
@@ -161,13 +161,19 @@ class PageController extends Controller
$page->html = $this->entityRepo->renderPage($page);
$sidebarTree = $this->entityRepo->getBookChildren($page->book);
$pageNav = $this->entityRepo->getPageNav($page->html);
- $page->load(['comments.createdBy']);
+
+ // check if the comment's are enabled
+ $areCommentsEnabled = !setting('app-disable-comments');
+ if ($areCommentsEnabled) {
+ $page->load(['comments.createdBy']);
+ }
Views::add($page);
$this->setPageTitle($page->getShortName());
return view('pages/show', [
'page' => $page,'book' => $page->book,
'current' => $page, 'sidebarTree' => $sidebarTree,
+ 'commentsEnabled' => $areCommentsEnabled,
'pageNav' => $pageNav]);
}
diff --git a/resources/lang/de/settings.php b/resources/lang/de/settings.php
index 2da517292..e9d19e01b 100644
--- a/resources/lang/de/settings.php
+++ b/resources/lang/de/settings.php
@@ -31,6 +31,8 @@ return [
'app_logo_desc' => "Dieses Bild sollte 43px hoch sein.\nGrößere Bilder werden verkleinert.",
'app_primary_color' => 'Primäre Anwendungsfarbe',
'app_primary_color_desc' => "Dies sollte ein HEX Wert sein.\nWenn Sie nicht eingeben, wird die Anwendung auf die Standardfarbe zurückgesetzt.",
+ 'app_disable_comments' => 'Kommentare deaktivieren',
+ 'app_disable_comments_desc' => 'Deaktiviert Kommentare über alle Seiten in der Anwendung. Vorhandene Kommentare werden nicht angezeigt.',
/**
* Registration settings
diff --git a/resources/lang/en/settings.php b/resources/lang/en/settings.php
index 4153055eb..f35c486ad 100755
--- a/resources/lang/en/settings.php
+++ b/resources/lang/en/settings.php
@@ -34,6 +34,8 @@ return [
'app_homepage' => 'Application Homepage',
'app_homepage_desc' => 'Select a page to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
'app_homepage_default' => 'Default homepage view chosen',
+ 'app_disable_comments' => 'Disable comments',
+ 'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.',
/**
* Registration settings
diff --git a/resources/lang/es/settings.php b/resources/lang/es/settings.php
index 9535d3f45..3c3281d28 100644
--- a/resources/lang/es/settings.php
+++ b/resources/lang/es/settings.php
@@ -31,6 +31,8 @@ return [
'app_logo_desc' => 'Esta imagen debería de ser 43px en altura.
Iágenes grandes seán escaladas.',
'app_primary_color' => 'Color primario de la aplicación',
'app_primary_color_desc' => 'Esto debería ser un valor hexadecimal.
Deje el valor vaío para reiniciar al valor por defecto.',
+ 'app_disable_comments' => 'Deshabilitar comentarios',
+ 'app_disable_comments_desc' => 'Deshabilita los comentarios en todas las páginas de la aplicación. Los comentarios existentes no se muestran. ',
/**
* Registration settings
diff --git a/resources/lang/fr/settings.php b/resources/lang/fr/settings.php
index 399afdc9a..2f0163368 100644
--- a/resources/lang/fr/settings.php
+++ b/resources/lang/fr/settings.php
@@ -31,7 +31,8 @@ return [
'app_logo_desc' => 'Cette image doit faire 43px de hauteur.
Les images plus larges seront réduites.',
'app_primary_color' => 'Couleur principale de l\'application',
'app_primary_color_desc' => 'Cela devrait être une valeur hexadécimale.
Laisser vide pour rétablir la couleur par défaut.',
-
+ 'app_disable_comments' => 'Désactiver les commentaires',
+ 'app_disable_comments_desc' => 'Désactive les commentaires sur toutes les pages de l\'application. Les commentaires existants ne sont pas affichés.',
/**
* Registration settings
*/
diff --git a/resources/lang/it/settings.php b/resources/lang/it/settings.php
index d112cbc62..480e9302a 100755
--- a/resources/lang/it/settings.php
+++ b/resources/lang/it/settings.php
@@ -34,11 +34,12 @@ return [
'app_homepage' => 'Homepage Applicazione',
'app_homepage_desc' => 'Seleziona una pagina da mostrare nella home anzichè quella di default. I permessi della pagina sono ignorati per quella selezionata.',
'app_homepage_default' => 'Homepage di default scelta',
+ 'app_disable_comments' => 'Disattiva commenti',
+ 'app_disable_comments_desc' => 'Disabilita i commenti su tutte le pagine nell\'applicazione. I commenti esistenti non sono mostrati. ',
/**
* Registration settings
*/
-
'reg_settings' => 'Impostazioni Registrazione',
'reg_allow' => 'Consentire Registrazione?',
'reg_default_role' => 'Ruolo predefinito dopo la registrazione',
diff --git a/resources/lang/ja/settings.php b/resources/lang/ja/settings.php
index b4cf57aeb..f9c9c5e86 100644
--- a/resources/lang/ja/settings.php
+++ b/resources/lang/ja/settings.php
@@ -31,6 +31,8 @@ return [
'app_logo_desc' => '高さ43pxで表示されます。これを上回る場合、自動で縮小されます。',
'app_primary_color' => 'プライマリカラー',
'app_primary_color_desc' => '16進数カラーコードで入力します。空にした場合、デフォルトの色にリセットされます。',
+ 'app_disable_comments' => 'コメントを無効にする',
+ 'app_disable_comments_desc' => 'アプリケーション内のすべてのページのコメントを無効にします。既存のコメントは表示されません。',
/**
* Registration settings
@@ -108,5 +110,5 @@ return [
'users_social_disconnect' => 'アカウントを接続解除',
'users_social_connected' => '「:socialAccount」がプロフィールに接続されました。',
'users_social_disconnected' => '「:socialAccount」がプロフィールから接続解除されました。'
-
+
];
diff --git a/resources/lang/nl/settings.php b/resources/lang/nl/settings.php
index 7b8adf602..ba73dc7e9 100644
--- a/resources/lang/nl/settings.php
+++ b/resources/lang/nl/settings.php
@@ -31,6 +31,8 @@ return [
'app_logo_desc' => 'De afbeelding moet 43px hoog zijn.
Grotere afbeeldingen worden geschaald.',
'app_primary_color' => 'Applicatie hoofdkleur',
'app_primary_color_desc' => 'Geef een hexadecimale waarde.
Als je niks invult wordt de standaardkleur gebruikt.',
+ 'app_disable_comments' => 'Reacties uitschakelen',
+ 'app_disable_comments_desc' => 'Schakel opmerkingen uit op alle pagina\'s in de applicatie. Bestaande opmerkingen worden niet getoond.',
/**
* Registration settings
diff --git a/resources/lang/pl/settings.php b/resources/lang/pl/settings.php
index 381e5517a..d6f3cca1b 100644
--- a/resources/lang/pl/settings.php
+++ b/resources/lang/pl/settings.php
@@ -31,6 +31,8 @@ return [
'app_logo_desc' => 'Ten obrazek powinien mieć nie więcej niż 43px w pionie.
Większe obrazki będą skalowane w dół.',
'app_primary_color' => 'Podstawowy kolor aplikacji',
'app_primary_color_desc' => 'To powinna być wartość HEX.
Zostaw to pole puste, by powrócić do podstawowego koloru.',
+ 'app_disable_comments' => 'Wyłącz komentarze',
+ 'app_disable_comments_desc' => 'Wyłącz komentarze na wszystkich stronach w aplikacji. Istniejące komentarze nie są pokazywane.',
/**
* Registration settings
diff --git a/resources/lang/pt_BR/settings.php b/resources/lang/pt_BR/settings.php
index 0da798557..77a0e6e39 100644
--- a/resources/lang/pt_BR/settings.php
+++ b/resources/lang/pt_BR/settings.php
@@ -34,6 +34,8 @@ return [
'app_homepage' => 'Página incial',
'app_homepage_desc' => 'Selecione a página para ser usada como página inicial em vez da padrão. Permissões da página serão ignoradas.',
'app_homepage_default' => 'Escolhida página inicial padrão',
+ 'app_disable_comments' => 'Desativar comentários',
+ 'app_disable_comments_desc' => 'Desativar comentários em todas as páginas no aplicativo. Os comentários existentes não são exibidos.',
/**
* Registration settings
diff --git a/resources/lang/ru/settings.php b/resources/lang/ru/settings.php
index 9a9e55fd6..5d2f07ba9 100755
--- a/resources/lang/ru/settings.php
+++ b/resources/lang/ru/settings.php
@@ -34,6 +34,8 @@ return [
'app_homepage' => 'Домашняя страница приложения',
'app_homepage_desc' => 'Выберите страницу, которая будет отображаться на главной странице вместо стандартной. Права на страницы игнорируются для выбранных страниц.',
'app_homepage_default' => 'Выбрана домашняя страница по-умолчанию',
+ 'app_disable_comments' => 'Отключить комментарии',
+ 'app_disable_comments_desc' => 'Отключить комментарии на всех страницах приложения. Существующие комментарии не отображаются.',
/**
* Registration
diff --git a/resources/lang/sk/settings.php b/resources/lang/sk/settings.php
index 4438f8038..521af196e 100644
--- a/resources/lang/sk/settings.php
+++ b/resources/lang/sk/settings.php
@@ -31,6 +31,8 @@ return [
'app_logo_desc' => 'Tento obrázok by mal mať 43px na výšku.
Veľké obrázky budú preškálované na menší rozmer.',
'app_primary_color' => 'Primárna farba pre aplikáciu',
'app_primary_color_desc' => 'Toto by mala byť hodnota v hex tvare.
Nechajte prázdne ak chcete použiť prednastavenú farbu.',
+ 'app_disable_comments' => 'Zakázať komentáre',
+ 'app_disable_comments_desc' => 'Zakázať komentáre na všetkých stránkach aplikácie. Existujúce komentáre sa nezobrazujú.',
/**
* Registration settings
diff --git a/resources/views/pages/show.blade.php b/resources/views/pages/show.blade.php
index 854417962..3e10ac63a 100644
--- a/resources/views/pages/show.blade.php
+++ b/resources/views/pages/show.blade.php
@@ -131,7 +131,7 @@
@include('partials/book-tree', ['book' => $book, 'sidebarTree' => $sidebarTree])
-
+
@stop
@section('body')
@@ -148,10 +148,11 @@
@include('pages/page-display')
-
-
{{ trans('settings.app_secure_images_desc') }}
@include('components.toggle-switch', ['name' => 'setting-app-secure-images', 'value' => setting('app-secure-images')]) +{{ trans('settings.app_disable_comments_desc') }}
+ @include('components.toggle-switch', ['name' => 'setting-app-disable-comments', 'value' => setting('app-disable-comments')]) +{{ trans('settings.app_editor_desc') }}
diff --git a/tests/Entity/CommentSettingTest.php b/tests/Entity/CommentSettingTest.php new file mode 100644 index 000000000..29df8b327 --- /dev/null +++ b/tests/Entity/CommentSettingTest.php @@ -0,0 +1,28 @@ +page = \BookStack\Page::first(); + } + + public function test_comment_disable () { + $this->asAdmin(); + + $this->setSettings(['app-disable-comments' => 'true']); + + $this->asAdmin()->visit($this->page->getUrl()) + ->pageNotHasElement('.comments-list'); + } + + public function test_comment_enable () { + $this->asAdmin(); + + $this->setSettings(['app-disable-comments' => 'false']); + + $this->asAdmin()->visit($this->page->getUrl()) + ->pageHasElement('.comments-list'); + } +} \ No newline at end of file