diff --git a/app/Http/Controllers/Admin/PhotoCommentController.php b/app/Http/Controllers/Admin/PhotoCommentController.php index 59b02ee..bac407a 100644 --- a/app/Http/Controllers/Admin/PhotoCommentController.php +++ b/app/Http/Controllers/Admin/PhotoCommentController.php @@ -42,6 +42,44 @@ class PhotoCommentController extends Controller $request->session()->flash('success', trans_choice('admin.bulk_comments_deleted', $commentsActioned, ['number' => $commentsActioned])); } + else if ($request->has('bulk_approve')) + { + /** @var PhotoComment $comment */ + foreach ($comments as $comment) + { + // Mark as approved + $comment->approved_at = new \DateTime(); + $comment->approved_user_id = $this->getUser()->id; + + // The comment may have already been rejected - remove the data if so + $comment->rejected_at = null; + $comment->rejected_user_id = null; + + $comment->save(); + $commentsActioned++; + } + + $request->session()->flash('success', trans_choice('admin.bulk_comments_approved', $commentsActioned, ['number' => $commentsActioned])); + } + else if ($request->has('bulk_reject')) + { + /** @var PhotoComment $comment */ + foreach ($comments as $comment) + { + // Mark as rejected + $comment->rejected_at = new \DateTime(); + $comment->rejected_user_id = $this->getUser()->id; + + // The comment may have already been approved - remove the data if so + $comment->approved_at = null; + $comment->approved_user_id = null; + + $comment->save(); + $commentsActioned++; + } + + $request->session()->flash('success', trans_choice('admin.bulk_comments_approved', $commentsActioned, ['number' => $commentsActioned])); + } return redirect(route('comments.index')); } @@ -80,6 +118,34 @@ class PhotoCommentController extends Controller 'comment_ids' => $commentIDs ]); } + else if ($request->has('bulk_approve')) + { + if (count($commentIDs) == 1) + { + // Single comment selected - redirect to the single approve page + return redirect(route('comments.approve', ['id' => $commentIDs[0]])); + } + + // Show the view to confirm the approval + return Theme::render('admin.bulk_approve_comments', [ + 'comment_count' => count($commentIDs), + 'comment_ids' => $commentIDs + ]); + } + else if ($request->has('bulk_reject')) + { + if (count($commentIDs) == 1) + { + // Single comment selected - redirect to the single reject page + return redirect(route('comments.reject', ['id' => $commentIDs[0]])); + } + + // Show the view to confirm the rejection + return Theme::render('admin.bulk_reject_comments', [ + 'comment_count' => count($commentIDs), + 'comment_ids' => $commentIDs + ]); + } // Unrecognised action - simply redirect back to the index page return redirect(route('comments.index')); diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 92bd876..e1546be 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -61,6 +61,9 @@ return [ 'anonymous_users' => 'Anonymous (not logged in)', 'approve_comment' => 'Approve comment by :author_name', 'approve_comment_confirm' => 'Are you sure you want to approve this comment by ":author_name"?', + 'approve_comments' => 'Approve :number comments', + 'approve_comments_confirm' => 'Are you sure you want to approve these :number comments?', + 'bulk_comments_approved' => ':number comment was approved successfully.|:number comments were approved successfully.', 'bulk_comments_deleted' => ':number comment was deleted successfully.|:number comments were deleted successfully.', 'bulk_photos_changed' => ':number photo was updated successfully.|:number photos were updated successfully.', 'cannot_delete_own_user_account' => 'It is not possible to delete your own user account. Please ask another administrator to delete it for you.', @@ -163,7 +166,7 @@ return [ 'list_albums_title' => 'Albums', 'list_comments_intro' => 'Comments are messages left on your photos by visitors and users.', 'list_comments_status' => [ - 'all' => '- All -', + 'all' => '(All comments)', 'approved' => 'Approved', 'pending' => 'Pending moderation', 'rejected' => 'Rejected', @@ -233,6 +236,8 @@ return [ 'redirects_text' => 'To access this album using different addresses, you can use redirects. This is useful when you have moved the album to a different parent and the old address no longer works.', 'reject_comment' => 'Reject comment by :author_name', 'reject_comment_confirm' => 'Are you sure you want to reject this comment by ":author_name"?', + 'reject_comments' => 'Reject :number comments', + 'reject_comments_confirm' => 'Are you sure you want to reject these :number comments?', 'replace_image_message' => 'If your photo isn\'t quite perfect, don\'t worry - just upload a new image using the field below and we\'ll replace it.', 'replace_image_title' => 'Replace photo', 'save_changes_heading' => 'Save changes', diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index cffb9e4..e6339e7 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -11,6 +11,7 @@ return [ 'album_view_label' => 'View as:', 'apply_action' => 'Apply', 'approve_action' => 'Approve', + 'approve_selected_action' => 'Approve selected', 'bulk_edit_photos_label' => 'Bulk edit selected photos:', 'bulk_edit_photos_placeholder' => 'Select an action', 'cancel_action' => 'Cancel', @@ -50,6 +51,7 @@ return [ 'realname_label' => 'Your name:', 'register_action' => 'Create account', 'reject_action' => 'Reject', + 'reject_selected_action' => 'Reject selected', 'remember_me_label' => 'Remember me', 'remove_action' => 'Remove', 'review_photo_comment_action' => 'Approve/reject comment', diff --git a/resources/lang/en/navigation.php b/resources/lang/en/navigation.php index 1c50af9..9e4daba 100644 --- a/resources/lang/en/navigation.php +++ b/resources/lang/en/navigation.php @@ -27,6 +27,7 @@ return [ 'labels' => 'Labels', 'metadata_upgrade' => 'Update Photo Metadata', 'reject_comment' => 'Reject comment', + 'reject_comments' => 'Reject comments', 'settings' => 'Settings', 'storage' => 'Storage', 'users' => 'Users' diff --git a/resources/views/themes/base/admin/bulk_approve_comments.blade.php b/resources/views/themes/base/admin/bulk_approve_comments.blade.php new file mode 100644 index 0000000..c2a8c39 --- /dev/null +++ b/resources/views/themes/base/admin/bulk_approve_comments.blade.php @@ -0,0 +1,37 @@ +@extends(Theme::viewName('layout')) +@section('title', trans('admin.approve_comments', ['number' => $comment_count])) + +@section('breadcrumb') + + + + +@endsection + +@section('content') +
+
+
+
+
@yield('title')
+
+

@lang('admin.approve_comments_confirm', ['number' => $comment_count])

+ +
+
+ {{ csrf_field() }} + + @foreach ($comment_ids as $comment_id) + + @endforeach + + @lang('forms.cancel_action') + +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/themes/base/admin/bulk_reject_comments.blade.php b/resources/views/themes/base/admin/bulk_reject_comments.blade.php new file mode 100644 index 0000000..d753a52 --- /dev/null +++ b/resources/views/themes/base/admin/bulk_reject_comments.blade.php @@ -0,0 +1,37 @@ +@extends(Theme::viewName('layout')) +@section('title', trans('admin.reject_comments', ['number' => $comment_count])) + +@section('breadcrumb') + + + + +@endsection + +@section('content') +
+
+
+
+
@yield('title')
+
+

@lang('admin.reject_comments_confirm', ['number' => $comment_count])

+ +
+
+ {{ csrf_field() }} + + @foreach ($comment_ids as $comment_id) + + @endforeach + + @lang('forms.cancel_action') + +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/themes/base/admin/list_comments.blade.php b/resources/views/themes/base/admin/list_comments.blade.php index 33c0d4f..0920fac 100644 --- a/resources/views/themes/base/admin/list_comments.blade.php +++ b/resources/views/themes/base/admin/list_comments.blade.php @@ -83,7 +83,11 @@ -
+
+
+ + +