#112: Default album permissions are now used when creating a new album that does not inherit permissions, and is not marked as a private album
This commit is contained in:
parent
a5569924be
commit
90c7591c31
@ -660,21 +660,41 @@ class AlbumController extends Controller
|
|||||||
$album->generateUrlPath();
|
$album->generateUrlPath();
|
||||||
$album->save();
|
$album->save();
|
||||||
|
|
||||||
// Link all default permissions to anonymous users (if a public album)
|
// Link the default permissions (if a public album)
|
||||||
if (!$album->is_permissions_inherited)
|
|
||||||
{
|
|
||||||
$isPrivate = (strtolower($request->get('is_private')) == 'on');
|
$isPrivate = (strtolower($request->get('is_private')) == 'on');
|
||||||
|
if (!$album->is_permissions_inherited && !$isPrivate)
|
||||||
|
{
|
||||||
|
$defaultAlbumUserPermissions = AlbumDefaultUserPermission::all();
|
||||||
|
$defaultAlbumGroupPermissions = AlbumDefaultGroupPermission::all();
|
||||||
|
$defaultAnonPermissions = AlbumDefaultAnonymousPermission::all();
|
||||||
|
|
||||||
if (!$isPrivate)
|
/** @var AlbumDefaultAnonymousPermission $permission */
|
||||||
|
foreach ($defaultAnonPermissions as $permission)
|
||||||
{
|
{
|
||||||
/** @var Permission $permission */
|
$album->anonymousPermissions()->attach($permission->permission_id, [
|
||||||
foreach (Permission::where(['section' => 'album', 'is_default' => true])->get() as $permission)
|
|
||||||
{
|
|
||||||
$album->anonymousPermissions()->attach($permission->id, [
|
|
||||||
'created_at' => new \DateTime(),
|
'created_at' => new \DateTime(),
|
||||||
'updated_at' => new \DateTime()
|
'updated_at' => new \DateTime()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var AlbumDefaultGroupPermission $permission */
|
||||||
|
foreach ($defaultAlbumGroupPermissions as $permission)
|
||||||
|
{
|
||||||
|
$album->groupPermissions()->attach($permission->permission_id, [
|
||||||
|
'group_id' => $permission->group_id,
|
||||||
|
'created_at' => new \DateTime(),
|
||||||
|
'updated_at' => new \DateTime()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var AlbumDefaultUserPermission $permission */
|
||||||
|
foreach ($defaultAlbumUserPermissions as $permission)
|
||||||
|
{
|
||||||
|
$album->userPermissions()->attach($permission->permission_id, [
|
||||||
|
'user_id' => $permission->user_id,
|
||||||
|
'created_at' => new \DateTime(),
|
||||||
|
'updated_at' => new \DateTime()
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user