Merge photo comments feature #114
@ -660,21 +660,41 @@ class AlbumController extends Controller
|
||||
$album->generateUrlPath();
|
||||
$album->save();
|
||||
|
||||
// Link all default permissions to anonymous users (if a public album)
|
||||
if (!$album->is_permissions_inherited)
|
||||
{
|
||||
// Link the default permissions (if a public album)
|
||||
$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 */
|
||||
foreach (Permission::where(['section' => 'album', 'is_default' => true])->get() as $permission)
|
||||
{
|
||||
$album->anonymousPermissions()->attach($permission->id, [
|
||||
$album->anonymousPermissions()->attach($permission->permission_id, [
|
||||
'created_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