Merge branch 'v2.1'
# Conflicts: # config/app.php
This commit is contained in:
commit
1220e87bc9
@ -70,17 +70,20 @@ class DbHelper
|
|||||||
->leftJoin('permissions AS group_permissions', 'group_permissions.id', '=', 'album_group_permissions.permission_id')
|
->leftJoin('permissions AS group_permissions', 'group_permissions.id', '=', 'album_group_permissions.permission_id')
|
||||||
->leftJoin('permissions AS user_permissions', 'user_permissions.id', '=', 'album_user_permissions.permission_id')
|
->leftJoin('permissions AS user_permissions', 'user_permissions.id', '=', 'album_user_permissions.permission_id')
|
||||||
->leftJoin('user_groups', 'user_groups.group_id', '=', 'album_group_permissions.group_id')
|
->leftJoin('user_groups', 'user_groups.group_id', '=', 'album_group_permissions.group_id')
|
||||||
->where('albums.user_id', $user->id)
|
->where(function($query) use ($user, $permission)
|
||||||
->orWhere([
|
{
|
||||||
['group_permissions.section', 'album'],
|
$query->where('albums.user_id', $user->id)
|
||||||
['group_permissions.description', $permission],
|
->orWhere([
|
||||||
['user_groups.user_id', $user->id]
|
['group_permissions.section', 'album'],
|
||||||
])
|
['group_permissions.description', $permission],
|
||||||
->orWhere([
|
['user_groups.user_id', $user->id]
|
||||||
['user_permissions.section', 'album'],
|
])
|
||||||
['user_permissions.description', $permission],
|
->orWhere([
|
||||||
['album_user_permissions.user_id', $user->id]
|
['user_permissions.section', 'album'],
|
||||||
]);
|
['user_permissions.description', $permission],
|
||||||
|
['album_user_permissions.user_id', $user->id]
|
||||||
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$parentAlbumID = intval($parentAlbumID);
|
$parentAlbumID = intval($parentAlbumID);
|
||||||
|
@ -71,14 +71,14 @@ class AlbumController extends Controller
|
|||||||
else if ($requestedView != 'slideshow')
|
else if ($requestedView != 'slideshow')
|
||||||
{
|
{
|
||||||
$photos = $album->photos()
|
$photos = $album->photos()
|
||||||
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
->orderBy(DB::raw('COALESCE(taken_at, created_at), name, id'))
|
||||||
->paginate(UserConfig::get('items_per_page'));
|
->paginate(UserConfig::get('items_per_page'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The slideshow view needs access to all photos, not paged
|
// The slideshow view needs access to all photos, not paged
|
||||||
$photos = $album->photos()
|
$photos = $album->photos()
|
||||||
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
->orderBy(DB::raw('COALESCE(taken_at, created_at), name, id'))
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,14 +105,40 @@ class PhotoController extends Controller
|
|||||||
// Load the Next/Previous buttons
|
// Load the Next/Previous buttons
|
||||||
$thisPhotoDate = is_null($photo->taken_at) ? $photo->created_at : $photo->taken_at;
|
$thisPhotoDate = is_null($photo->taken_at) ? $photo->created_at : $photo->taken_at;
|
||||||
|
|
||||||
$previousPhoto = $album->photos()
|
// I don't like the idea of using a totally raw SQL query, but it's the only sure-fire way to number the rows
|
||||||
->where(DB::raw('COALESCE(taken_at, created_at)'), '<', $thisPhotoDate)
|
// so we can get the previous/next photos accurately - and we don't have to load all data for the photo objects
|
||||||
->orderBy(DB::raw('COALESCE(taken_at, created_at)'), 'desc')
|
$previousPhoto = null;
|
||||||
->first();
|
$nextPhoto = null;
|
||||||
$nextPhoto = $album->photos()
|
|
||||||
->where(DB::raw('COALESCE(taken_at, created_at)'), '>', $thisPhotoDate)
|
$allAlbumPhotos = DB::select(
|
||||||
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
DB::raw(
|
||||||
->first();
|
'SELECT p.id, (@row_number:=@row_number + 1) AS row_number
|
||||||
|
FROM photos p, (SELECT @row_number:=0) AS t
|
||||||
|
WHERE p.album_id = :album_id
|
||||||
|
ORDER BY COALESCE(p.taken_at, p.created_at), p.name, p.id;'
|
||||||
|
),
|
||||||
|
[
|
||||||
|
'album_id' => $album->id
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
for ($i = 0; $i < count($allAlbumPhotos); $i++)
|
||||||
|
{
|
||||||
|
if ($allAlbumPhotos[$i]->id === $photo->id)
|
||||||
|
{
|
||||||
|
if ($i > 0)
|
||||||
|
{
|
||||||
|
$previousPhoto = Photo::where('id', $allAlbumPhotos[$i - 1]->id)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($i + 1 < count($allAlbumPhotos))
|
||||||
|
{
|
||||||
|
$nextPhoto = Photo::where('id', $allAlbumPhotos[$i + 1]->id)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Record the visit to the photo
|
// Record the visit to the photo
|
||||||
if (UserConfig::get('enable_visitor_hits'))
|
if (UserConfig::get('enable_visitor_hits'))
|
||||||
|
Loading…
Reference in New Issue
Block a user