From 693f0c676080ea09bc27e28c26a8bf3960e0adf6 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sun, 10 Sep 2017 12:48:48 +0100 Subject: [PATCH] #34: sitemap.xml generator now checks for albums and photos that are accessible to the current user (so anonymous albums aren't included in search engine listings.) --- app/Http/Controllers/Gallery/DefaultController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Gallery/DefaultController.php b/app/Http/Controllers/Gallery/DefaultController.php index 00ec2f9..b05b8e5 100644 --- a/app/Http/Controllers/Gallery/DefaultController.php +++ b/app/Http/Controllers/Gallery/DefaultController.php @@ -51,8 +51,11 @@ class DefaultController extends Controller $lastModifiedPhoto = Photo::orderBy('updated_at', 'desc')->first(); $this->createSitemapNode($xml, $root, route('home'), (is_null($lastModifiedPhoto) ? '' : $lastModifiedPhoto->updated_at), '1.0'); + // Albums the current user is allowed to access + $albumIDs = DbHelper::getAlbumIDsForCurrentUser(); + // Add each album URL - $albums = Album::orderBy('name'); + $albums = Album::whereIn('id', $albumIDs)->orderBy('name'); $albums->chunk(100, function($albumsChunk) use ($xml, $root) { /** @var Album $album */ @@ -64,7 +67,7 @@ class DefaultController extends Controller }); // Add each photo URL - $photos = Photo::orderBy('name'); + $photos = Photo::whereIn('album_id', $albumIDs)->orderBy('name'); $photos->chunk(100, function($tempPhotos) use ($xml, $root) { /** @var Photo $photo */