diff --git a/app/Helpers/ConfigHelper.php b/app/Helpers/ConfigHelper.php index da56781..e24c6cd 100644 --- a/app/Helpers/ConfigHelper.php +++ b/app/Helpers/ConfigHelper.php @@ -113,7 +113,8 @@ class ConfigHelper 'hotlink_protection' => false, 'items_per_page' => 12, 'items_per_page_admin' => 10, - 'photo_comments_require_login' => true, + 'moderate_anonymous_users' => true, + 'moderate_known_users' => true, 'photo_comments_thread_depth' => 3, 'public_statistics' => true, 'recaptcha_enabled_registration' => false, diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index 8019d6e..16aa63e 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -236,7 +236,8 @@ class DefaultController extends Controller 'allow_self_registration', 'enable_visitor_hits', 'hotlink_protection', - 'photo_comments_require_login', + 'moderate_anonymous_users', + 'moderate_known_users', 'recaptcha_enabled_registration', 'remove_copyright', 'require_email_verification', diff --git a/app/Http/Controllers/Gallery/PhotoCommentController.php b/app/Http/Controllers/Gallery/PhotoCommentController.php index e02ee50..3a1802d 100644 --- a/app/Http/Controllers/Gallery/PhotoCommentController.php +++ b/app/Http/Controllers/Gallery/PhotoCommentController.php @@ -157,6 +157,20 @@ class PhotoCommentController extends Controller $isAutoApproved = true; } + // Auto-approve the comment if settings allow + if ($user->isAnonymous() && !UserConfig::get('moderate_anonymous_users')) + { + $comment->approved_at = new \DateTime(); + $comment->approved_user_id = null; // we don't have a user ID to set! + $isAutoApproved = true; + } + else if (!$user->isAnonymous() && !UserConfig::get('moderate_known_users')) + { + $comment->approved_at = new \DateTime(); + $comment->approved_user_id = $user->id; + $isAutoApproved = true; + } + $comment->save(); if ($isAutoApproved) diff --git a/app/PhotoComment.php b/app/PhotoComment.php index da3cf9c..0e705cd 100644 --- a/app/PhotoComment.php +++ b/app/PhotoComment.php @@ -48,20 +48,12 @@ class PhotoComment extends Model public function isApproved() { - return ( - !is_null($this->approved_user_id) && - !is_null($this->approved_at) && - is_null($this->rejected_user_id) && - is_null($this->rejected_at) - ); + return (!is_null($this->approved_at) && is_null($this->rejected_at)); } public function isModerated() { - return ( - (!is_null($this->approved_user_id) && !is_null($this->approved_at)) || - (!is_null($this->rejected_user_id) && !is_null($this->rejected_at)) - ); + return (!is_null($this->approved_at) || !is_null($this->rejected_at)); } public function parent() diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 6353b65..9bfc27e 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -222,6 +222,7 @@ return [ 'analytics_enable_visitor_hits' => 'Enable built-in visitor hit tracking', 'analytics_enable_visitor_hits_description' => 'Visitor hits to the public gallery will be recorded in the Blue Twilight database, allowing for analysis such as the most popular album/photo.', 'analytics_tab' => 'Analytics', + 'comments_moderation' => 'Moderation', 'comments_tab' => 'Comments', 'permissions_cache' => 'Permissions Cache', 'permissions_cache_intro' => 'Blue Twilight maintains the permissions each user has to albums in the database. If you feel these aren\'t correct based on what\'s configured, you can rebuild the cache by clicking the button below.', diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index 0e0e7b8..ada0a0c 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -61,6 +61,10 @@ return [ 'settings_photo_comments_require_login_help' => 'If this option is enabled, users must login before they can post comments.', 'settings_hotlink_protection' => 'Prevent hot-linking to images', 'settings_hotlink_protection_help' => 'With this option enabled, direct linking to images is not allowed. Photos can only be viewed through Blue Twilight.', + 'settings_moderate_anonymous_users' => 'Moderate comments from unknown users', + 'settings_moderate_anonymous_users_help' => 'If this option is enabled, comments posted by unknown users must be moderated before being displayed.', + 'settings_moderate_known_users' => 'Moderate comments from logged-in users', + 'settings_moderate_known_users_help' => 'If this option is enabled, comments posted by logged-in users must be moderated before being displayed.', 'settings_restrict_originals_download' => 'Restrict access to original images', 'settings_restrict_originals_download_help' => 'With this option enabled, only the photo\'s owner can download the original high-resolution images.', 'settings_social_facebook_app_id' => 'Facebook App ID:', diff --git a/resources/views/themes/base/admin/settings.blade.php b/resources/views/themes/base/admin/settings.blade.php index 2ba7565..ef09e81 100644 --- a/resources/views/themes/base/admin/settings.blade.php +++ b/resources/views/themes/base/admin/settings.blade.php @@ -496,14 +496,6 @@ -
- - -
-
@@ -515,6 +507,29 @@
@endif + +
+
+ + @lang('admin.settings.comments_moderation') + +
+ +
+ + +
+ +
+ + +