diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index 16aa63e..fb6bcdf 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -16,6 +16,7 @@ use App\Http\Requests\SaveSettingsRequest; use App\Label; use App\Mail\TestMailConfig; use App\Photo; +use App\PhotoComment; use App\Services\GiteaService; use App\Services\GithubService; use App\Services\PhotoService; @@ -140,6 +141,7 @@ class DefaultController extends Controller $photoCount = Photo::all()->count(); $groupCount = Group::all()->count(); $labelCount = Label::all()->count(); + $commentCount = PhotoComment::whereNotNull('approved_at')->count(); $userCount = User::where('is_activated', true)->count(); $minMetadataVersion = Photo::min('metadata_version'); @@ -157,6 +159,7 @@ class DefaultController extends Controller return Theme::render('admin.index', [ 'album_count' => $albumCount, 'app_version' => config('app.version'), + 'comment_count' => $commentCount, 'group_count' => $groupCount, 'label_count' => $labelCount, 'memory_limit' => ini_get('memory_limit'), diff --git a/app/Http/Controllers/Admin/PhotoCommentController.php b/app/Http/Controllers/Admin/PhotoCommentController.php new file mode 100644 index 0000000..a22be69 --- /dev/null +++ b/app/Http/Controllers/Admin/PhotoCommentController.php @@ -0,0 +1,32 @@ +middleware('auth'); + View::share('is_admin', true); + } + + public function index() + { + $this->authorizeAccessToAdminPanel(); + + $comments = PhotoComment::with('photo') + ->with('photo.album') + ->orderBy('created_at', 'desc') + ->paginate(UserConfig::get('items_per_page')); + + return Theme::render('admin.list_comments', [ + 'comments' => $comments + ]); + } +} \ No newline at end of file diff --git a/app/PhotoComment.php b/app/PhotoComment.php index 0e705cd..f78f134 100644 --- a/app/PhotoComment.php +++ b/app/PhotoComment.php @@ -61,6 +61,11 @@ class PhotoComment extends Model return $this->belongsTo(PhotoComment::class, 'parent_comment_id'); } + public function photo() + { + return $this->belongsTo(Photo::class); + } + public function textAsHtml() { $start = '
'; diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index d37e63a..556dfa2 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -54,6 +54,10 @@ class AuthServiceProvider extends ServiceProvider { return $this->userHasAdminPermission($user, 'manage-albums'); }); + Gate::define('admin:manage-comments', function ($user) + { + return $this->userHasAdminPermission($user, 'manage-comments'); + }); Gate::define('admin:manage-groups', function ($user) { return $this->userHasAdminPermission($user, 'manage-groups'); diff --git a/database/seeds/PermissionsSeeder.php b/database/seeds/PermissionsSeeder.php index 927c7e8..e5e5494 100644 --- a/database/seeds/PermissionsSeeder.php +++ b/database/seeds/PermissionsSeeder.php @@ -72,6 +72,14 @@ class PermissionsSeeder extends Seeder 'is_default' => false, 'sort_order' => 0 ]); + + // admin:manage-comments = controls if photo comments can be managed + DatabaseSeeder::createOrUpdate('permissions', [ + 'section' => 'admin', + 'description' => 'manage-comments', + 'is_default' => false, + 'sort_order' => 0 + ]); } private function seedAlbumPermissions() diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 9bfc27e..902b250 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -62,6 +62,7 @@ return [ 'cannot_remove_own_admin' => 'You cannot remove your own administrator permissions. Please ask another administrator to remove the administrator permissions for you.', 'change_album_message' => 'Please select the album to move the photo(s) to:', 'change_album_title' => 'Move photo(s) to another album', + 'comment_summary' => ':album_name / :photo_name', 'create_album' => 'Create a photo album', 'create_album_intro' => 'Photo albums contain individual photographs together in the same way as a physical photo album or memory book.', 'create_album_intro2' => 'Complete the form below to create a photo album.', @@ -136,6 +137,8 @@ return [ 'list_albums' => 'Go to your albums', 'list_albums_intro' => 'Albums contain collections of individual photographs in the same way as a physical photo album or memory book.', 'list_albums_title' => 'Albums', + 'list_comments_intro' => 'Comments are messages left on your photos by visitors and users.', + 'list_comments_title' => 'Comments', 'list_groups_intro' => 'Organise your users into categories or types by using groups. You can assign permissions on albums to groups of users to make administration and management easier.', 'list_groups_title' => 'Groups', 'list_labels_intro' => 'Organise your photos differently using labels. Assign one or more labels to your photos and your visitors can view all photos with a specific tag in a single view.', @@ -254,6 +257,7 @@ return [ 'statistics_prefs_saved_message' => 'The statistics preferences were saved successfully.', 'stats_widget' => [ 'albums' => 'album|albums', + 'comments' => 'comment|comments', 'groups' => 'group|groups', 'labels' => 'label|labels', 'panel_header' => 'Statistics', diff --git a/resources/lang/en/navigation.php b/resources/lang/en/navigation.php index 28ce905..ff51105 100644 --- a/resources/lang/en/navigation.php +++ b/resources/lang/en/navigation.php @@ -4,6 +4,7 @@ return [ 'about' => 'About', 'admin' => 'Admin', 'albums' => 'Albums', + 'comments' => 'Comments', 'create_album' => 'Create album', 'create_group' => 'Create group', 'create_storage' => 'Create storage', diff --git a/resources/lang/en/permissions.php b/resources/lang/en/permissions.php index e32aeaf..9633200 100644 --- a/resources/lang/en/permissions.php +++ b/resources/lang/en/permissions.php @@ -4,6 +4,7 @@ return [ 'access' => 'Access the administration panel', 'configure' => 'Configure the application', 'manage-albums' => 'Manage photo albums', + 'manage-comments' => 'Manage comments', 'manage-groups' => 'Manage user groups', 'manage-labels' => 'Manage photo labels', 'manage-storage' => 'Manage storage locations', diff --git a/resources/views/themes/base/admin/edit_group.blade.php b/resources/views/themes/base/admin/edit_group.blade.php index c26f343..899c506 100644 --- a/resources/views/themes/base/admin/edit_group.blade.php +++ b/resources/views/themes/base/admin/edit_group.blade.php @@ -87,6 +87,10 @@ 'permission' => Theme::getPermission($all_permissions, 'admin', 'manage-labels') ]) + @include(Theme::viewName('partials.permission_checkbox'), [ + 'permission' => Theme::getPermission($all_permissions, 'admin', 'manage-comments') + ]) + @include(Theme::viewName('partials.permission_checkbox'), [ 'permission' => Theme::getPermission($all_permissions, 'admin', 'manage-users') ]) diff --git a/resources/views/themes/base/admin/list_comments.blade.php b/resources/views/themes/base/admin/list_comments.blade.php new file mode 100644 index 0000000..229d4ba --- /dev/null +++ b/resources/views/themes/base/admin/list_comments.blade.php @@ -0,0 +1,54 @@ +@extends(Theme::viewName('layout')) +@section('title', trans('admin.list_comments_title')) + +@section('breadcrumb') +
@lang('admin.no_comments_text')
+ +
+
+ {{ $comment->name }} {!! $comment->textAsHtml() !!}+ |
+ + @lang('forms.delete_action') + | +