Sharing: Allow to search for photos in shared albums

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-10-07 21:35:01 +02:00
parent 945d602e17
commit 3d3b1f10c4
4 changed files with 29 additions and 23 deletions

View file

@ -292,6 +292,20 @@
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-if="isRestricted" v-show="$config.feature('places')" to="/states" class="nav-states" @click.stop="">
<v-list-tile-action :title="$gettext('States')">
<v-icon>near_me</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="p-flex-menuitem" @click.stop="">
<translate key="States">States</translate>
<span v-show="config.count.states > 0"
:class="`nav-count ${rtl ? '--rtl' : ''}`">{{ config.count.states | abbreviateCount }}</span>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<template v-if="canSearchPlaces">
<v-list-tile v-if="isMini" v-show="canSearchPlaces && $config.feature('places')" :to="{ name: 'places' }" class="nav-places"
@click.stop="">
@ -330,19 +344,6 @@
</v-list-tile>
</v-list-group>
</template>
<v-list-tile v-else v-show="$config.feature('places')" to="/states" class="nav-states" @click.stop="">
<v-list-tile-action :title="$gettext('States')">
<v-icon>near_me</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="p-flex-menuitem" @click.stop="">
<translate key="States">States</translate>
<span v-show="config.count.states > 0"
:class="`nav-count ${rtl ? '--rtl' : ''}`">{{ config.count.states | abbreviateCount }}</span>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-show="$config.feature('labels')" to="/labels" class="nav-labels" @click.stop="">
<v-list-tile-action :title="$gettext('Labels')">
@ -683,7 +684,7 @@ export default {
appNameSuffix = appNameParts.slice(1, 9).join(" ");
}
const isRestricted= this.$config.deny("photos", "access_library");
const isRestricted = this.$config.deny("photos", "access_library");
return {
canSearchPlaces: this.$config.allow("places", "search"),

View file

@ -81,6 +81,7 @@ export default {
canEdit: this.$config.allow("photos", "update") && this.$config.feature("edit"),
hasPlaces: this.$config.allow("places", "view") && this.$config.feature("places"),
canSearchPlaces: this.$config.allow("places", "search") && this.$config.feature("places"),
canAccessLibrary: this.$config.allow("photos", "access_library"),
subscriptions: [],
listen: false,
dirty: false,
@ -176,7 +177,7 @@ export default {
return;
}
if (this.canSearchPlaces && photo.CellID && photo.CellID !== "zz") {
if (this.canAccessLibrary && photo.CellID && photo.CellID !== "zz") {
this.$router.push({name: "places_query", params: {q: photo.CellID}});
} else if (this.uid) {
this.$router.push({name: "places_scope", params: {s: this.uid, q: photo.CellID}});

View file

@ -122,13 +122,15 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
// Limit results for external users.
if f.Scope == "" && acl.Resources.DenyAll(acl.ResourcePhotos, aclRole, acl.Permissions{acl.AccessAll, acl.AccessLibrary}) {
sharedAlbums := "photos.photo_uid IN (SELECT photo_uid FROM photos_albums WHERE hidden = 0 AND missing = 0 AND album_uid IN (?)) OR "
if sess.IsVisitor() || sess.NotRegistered() {
s = s.Where("photos.published_at > ?", entity.TimeStamp())
s = s.Where(sharedAlbums+"photos.published_at > ?", sess.SharedUIDs(), entity.TimeStamp())
} else if user.BasePath == "" {
s = s.Where("photos.created_by = ? OR photos.published_at > ?", user.UserUID, entity.TimeStamp())
s = s.Where(sharedAlbums+"photos.created_by = ? OR photos.published_at > ?", sess.SharedUIDs(), user.UserUID, entity.TimeStamp())
} else {
s = s.Where("photos.created_by = ? OR photos.published_at > ? OR photos.photo_path = ? OR photos.photo_path LIKE ?",
user.UserUID, entity.TimeStamp(), user.BasePath, user.BasePath+"/%")
s = s.Where(sharedAlbums+"photos.created_by = ? OR photos.published_at > ? OR photos.photo_path = ? OR photos.photo_path LIKE ?",
sess.SharedUIDs(), user.UserUID, entity.TimeStamp(), user.BasePath, user.BasePath+"/%")
}
}
}

View file

@ -121,13 +121,15 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes
// Limit results for external users.
if f.Scope == "" && acl.Resources.DenyAll(acl.ResourcePlaces, aclRole, acl.Permissions{acl.AccessAll, acl.AccessLibrary}) {
sharedAlbums := "photos.photo_uid IN (SELECT photo_uid FROM photos_albums WHERE hidden = 0 AND missing = 0 AND album_uid IN (?)) OR "
if sess.IsVisitor() || sess.NotRegistered() {
s = s.Where("photos.published_at > ?", entity.TimeStamp())
s = s.Where(sharedAlbums+"photos.published_at > ?", sess.SharedUIDs(), entity.TimeStamp())
} else if user.BasePath == "" {
s = s.Where("photos.created_by = ? OR photos.published_at > ?", user.UserUID, entity.TimeStamp())
s = s.Where(sharedAlbums+"photos.created_by = ? OR photos.published_at > ?", sess.SharedUIDs(), user.UserUID, entity.TimeStamp())
} else {
s = s.Where("photos.created_by = ? OR photos.published_at > ? OR photos.photo_path = ? OR photos.photo_path LIKE ?",
user.UserUID, entity.TimeStamp(), user.BasePath, user.BasePath+"/%")
s = s.Where(sharedAlbums+"photos.created_by = ? OR photos.published_at > ? OR photos.photo_path = ? OR photos.photo_path LIKE ?",
sess.SharedUIDs(), user.UserUID, entity.TimeStamp(), user.BasePath, user.BasePath+"/%")
}
}
}