Skip to content

Commit 1c48b70

Browse files
authored
Add option to make the smart albums only consider photos of the user (#3879)
1 parent ba8a92d commit 1c48b70

24 files changed

+85
-3
lines changed

app/SmartAlbums/BaseSmartAlbum.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Illuminate\Contracts\Container\BindingResolutionException;
3131
use Illuminate\Database\Eloquent\Builder;
3232
use Illuminate\Pagination\LengthAwarePaginator;
33+
use Illuminate\Support\Facades\Auth;
3334

3435
/**
3536
* Class BaseSmartAlbum.
@@ -107,6 +108,10 @@ public function photos(): Builder
107108
if (!Configs::getValueAsBool('SA_override_visibility')) {
108109
return $this->photo_query_policy
109110
->applySearchabilityFilter(query: $base_query, origin: null, include_nsfw: !Configs::getValueAsBool('hide_nsfw_in_smart_albums'))
111+
->when(
112+
Configs::getValueAsBool('enable_smart_album_per_owner') && Auth::check(),
113+
fn (Builder $query) => $query->where('photos.owner_id', '=', Auth::id())
114+
)
110115
->where($this->smart_photo_condition);
111116
}
112117

app/SmartAlbums/UnsortedAlbum.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
use App\Enum\SmartAlbumType;
1313
use App\Exceptions\ConfigurationKeyMissingException;
1414
use App\Exceptions\Internal\FrameworkException;
15+
use App\Models\Configs;
1516
use App\Models\Photo;
1617
use Illuminate\Database\Eloquent\Builder;
18+
use Illuminate\Support\Facades\Auth;
1719

1820
class UnsortedAlbum extends BaseSmartAlbum
1921
{
@@ -45,7 +47,7 @@ public static function getInstance(): self
4547
*/
4648
public function photos(): Builder
4749
{
48-
if ($this->public_permissions !== null) {
50+
if ($this->public_permissions !== null && (!Auth::check() || !Configs::getValueAsBool('enable_smart_album_per_owner'))) {
4951
return Photo::query()->leftJoin(PA::PHOTO_ALBUM, 'photos.id', '=', PA::PHOTO_ID)->with(['size_variants', 'statistics', 'palette', 'tags'])
5052
->where($this->smart_photo_condition);
5153
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* SPDX-License-Identifier: MIT
5+
* Copyright (c) 2017-2018 Tobias Reich
6+
* Copyright (c) 2018-2025 LycheeOrg.
7+
*/
8+
9+
use App\Models\Extensions\BaseConfigMigration;
10+
11+
return new class() extends BaseConfigMigration {
12+
public const MOD_GALLERY = 'Smart Albums';
13+
14+
/**
15+
* @return array<int,array{key:string,value:string,is_secret:bool,cat:string,type_range:string,description:string,order?:int,not_on_docker?:bool,is_expert?:bool}>
16+
*/
17+
public function getConfigs(): array
18+
{
19+
return [
20+
[
21+
'key' => 'enable_smart_album_per_owner',
22+
'value' => '0',
23+
'cat' => self::MOD_GALLERY,
24+
'type_range' => self::BOOL,
25+
'description' => 'Only display pictures owned by the user in smart albums.',
26+
'details' => 'This setting is only applied to logged-in users.',
27+
'is_secret' => false,
28+
'is_expert' => false,
29+
'order' => 12,
30+
'not_on_docker' => false,
31+
'level' => 0,
32+
],
33+
];
34+
}
35+
};

lang/ar/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
303303
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
304304
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
305+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
305306
],
306307
'details' => [
307308
'version' => '',
@@ -598,5 +599,6 @@
598599
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
599600
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
600601
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
602+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
601603
],
602604
];

lang/cz/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
303303
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
304304
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
305+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
305306
],
306307
'details' => [
307308
'version' => '',
@@ -598,5 +599,6 @@
598599
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
599600
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
600601
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
602+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
601603
],
602604
];

lang/de/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
301301
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
302302
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
303+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
303304
],
304305
'details' => [
305306
'version' => '',
@@ -596,5 +597,6 @@
596597
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
597598
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
598599
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
600+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
599601
],
600602
];

lang/el/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
303303
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
304304
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
305+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
305306
],
306307
'details' => [
307308
'version' => '',
@@ -598,5 +599,6 @@
598599
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
599600
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
600601
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
602+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
601603
],
602604
];

lang/en/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
303303
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
304304
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
305+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
305306
],
306307
'details' => [
307308
'version' => '',
@@ -598,5 +599,6 @@
598599
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
599600
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
600601
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
602+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
601603
],
602604
];

lang/es/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
303303
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
304304
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
305+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
305306
],
306307
'details' => [
307308
'version' => '',
@@ -598,5 +599,6 @@
598599
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
599600
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
600601
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
602+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
601603
],
602604
];

lang/fa/all_settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
'deduplicate_pinned_albums' => 'Deduplicate featured albums.',
303303
'desktop_dock_full_transparency_enabled' => 'Enable dock full transparency for desktop.',
304304
'mobile_dock_full_transparency_enabled' => 'Enable dock transparency for mobile,',
305+
'enable_smart_album_per_owner' => 'Only display pictures owned by the user in smart albums.',
305306
],
306307
'details' => [
307308
'version' => '',
@@ -598,5 +599,6 @@
598599
'deduplicate_pinned_albums' => 'Featured albums will only appear once on the main gallery page.',
599600
'desktop_dock_full_transparency_enabled' => 'On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
600601
'mobile_dock_full_transparency_enabled' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions on top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
602+
'enable_smart_album_per_owner' => 'This setting is only applied to logged-in users. "Smart album visibility overrides" must be disabled for this to take effect.',
601603
],
602604
];

0 commit comments

Comments
 (0)