From a22ce0c57ac5b100d8794633d1fed7acec1f03ea Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sat, 11 Aug 2018 09:20:40 +0100 Subject: [PATCH] #19: Added a check for the user.enable_profile_page column when viewing the profile page. Added link to user's profile page (if enabled) in album footers. Tooltips are now enabled globally. Child album's footer now shows the details as tooltips. --- app/Album.php | 7 ++++++ app/Policies/UserPolicy.php | 3 +-- app/User.php | 14 ++++++++++- .../base/gallery/album_default.blade.php | 18 +------------ .../themes/base/gallery/album_empty.blade.php | 18 +------------ .../base/gallery/album_slideshow.blade.php | 18 +------------ .../views/themes/base/gallery/index.blade.php | 11 +++++++- .../base/gallery/user_profile.blade.php | 10 +------- resources/views/themes/base/layout.blade.php | 2 ++ .../partials/gallery_child_album.blade.php | 25 +++++++++++++++++++ 10 files changed, 62 insertions(+), 64 deletions(-) create mode 100644 resources/views/themes/base/partials/gallery_child_album.blade.php diff --git a/app/Album.php b/app/Album.php index d4c375a..e51259b 100644 --- a/app/Album.php +++ b/app/Album.php @@ -174,6 +174,8 @@ class Album extends Model return $this->hasMany(Photo::class); } + + public function redirects() { return $this->hasMany(AlbumRedirect::class); @@ -231,6 +233,11 @@ class Album extends Model return route('viewAlbum', $this->url_path); } + public function user() + { + return $this->belongsTo(User::class); + } + public function userPermissions() { return $this->belongsToMany(Permission::class, 'album_user_permissions'); diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 5c79201..ea65850 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -31,7 +31,6 @@ class UserPolicy public function view(User $user, User $userBeingAccessed) { - // TODO per-user setting that determines if the page is available - return true; + return $userBeingAccessed->enable_profile_page; } } \ No newline at end of file diff --git a/app/User.php b/app/User.php index ad6af6b..6cf4a92 100644 --- a/app/User.php +++ b/app/User.php @@ -16,7 +16,7 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'is_admin', 'is_activated', 'activation_token' + 'name', 'email', 'password', 'is_admin', 'is_activated', 'activation_token', 'profile_alias' ]; /** @@ -64,4 +64,16 @@ class User extends Authenticatable { return $this->id == -1 && $this->name == 'Anonymous'; } + + public function profileUrl() + { + return route('viewUser', [ + 'idOrAlias' => (!empty($this->profile_alias) ? trim(strtolower($this->profile_alias)) : $this->id) + ]); + } + + public function publicDisplayName() + { + return trim(!empty($this->profile_alias) ? $this->profile_alias : $this->name); + } } diff --git a/resources/views/themes/base/gallery/album_default.blade.php b/resources/views/themes/base/gallery/album_default.blade.php index 4096111..47f0b31 100644 --- a/resources/views/themes/base/gallery/album_default.blade.php +++ b/resources/views/themes/base/gallery/album_default.blade.php @@ -57,23 +57,7 @@
@foreach ($child_albums as $childAlbum) -
-
- - - -
-
+ @include(Theme::viewName('partials.gallery_child_album')); @endforeach
diff --git a/resources/views/themes/base/gallery/album_empty.blade.php b/resources/views/themes/base/gallery/album_empty.blade.php index f497fba..ccad304 100644 --- a/resources/views/themes/base/gallery/album_empty.blade.php +++ b/resources/views/themes/base/gallery/album_empty.blade.php @@ -32,23 +32,7 @@
@foreach ($child_albums as $childAlbum) -
-
- - - -
-
+ @include(Theme::viewName('partials.gallery_child_album')); @endforeach
@endif diff --git a/resources/views/themes/base/gallery/album_slideshow.blade.php b/resources/views/themes/base/gallery/album_slideshow.blade.php index adc8646..d0e35ce 100644 --- a/resources/views/themes/base/gallery/album_slideshow.blade.php +++ b/resources/views/themes/base/gallery/album_slideshow.blade.php @@ -64,23 +64,7 @@
@foreach ($child_albums as $childAlbum) -
-
- - - -
-
+ @include(Theme::viewName('partials.gallery_child_album')); @endforeach
diff --git a/resources/views/themes/base/gallery/index.blade.php b/resources/views/themes/base/gallery/index.blade.php index 4b9455c..ea7dbd9 100644 --- a/resources/views/themes/base/gallery/index.blade.php +++ b/resources/views/themes/base/gallery/index.blade.php @@ -24,7 +24,16 @@ {{ number_format($album->photos_count) }} {{ trans_choice('gallery.photos', $album->photos_count) }} @if ($album->children_count > 0) - {{ number_format($album->children_count) }} {{ trans_choice('gallery.child_albums', $album->children_count) }} + {{ number_format($album->children_count) }} {{ trans_choice('gallery.child_albums', $album->children_count) }} + @endif + + @if (UserConfig::get('social_user_profiles')) + + @can('view', $album->user) + {{ $album->user->publicDisplayName() }} + @else + {{ $album->user->publicDisplayName() }} + @endif @endif diff --git a/resources/views/themes/base/gallery/user_profile.blade.php b/resources/views/themes/base/gallery/user_profile.blade.php index fc4dbb6..df55124 100644 --- a/resources/views/themes/base/gallery/user_profile.blade.php +++ b/resources/views/themes/base/gallery/user_profile.blade.php @@ -104,12 +104,4 @@ -@endsection - -@push ('scripts') - -@endpush \ No newline at end of file +@endsection \ No newline at end of file diff --git a/resources/views/themes/base/layout.blade.php b/resources/views/themes/base/layout.blade.php index 43af545..3f059be 100644 --- a/resources/views/themes/base/layout.blade.php +++ b/resources/views/themes/base/layout.blade.php @@ -126,6 +126,8 @@ { $('.modal-footer', '#quick-upload-modal').html('
'); }); + + $('[data-toggle="tooltip"]').tooltip(); }); @stack('scripts') diff --git a/resources/views/themes/base/partials/gallery_child_album.blade.php b/resources/views/themes/base/partials/gallery_child_album.blade.php new file mode 100644 index 0000000..5e1354f --- /dev/null +++ b/resources/views/themes/base/partials/gallery_child_album.blade.php @@ -0,0 +1,25 @@ +
+
+ + + +
+
\ No newline at end of file