Merge photo comments feature #114

Merged
aheathershaw merged 28 commits from feature/4-commenting-on-photos into master 2018-10-05 23:37:26 +01:00
Showing only changes of commit 90c7591c31 - Show all commits

View File

@ -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)
{
$isPrivate = (strtolower($request->get('is_private')) == 'on');
$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, [
'created_at' => new \DateTime(),
'updated_at' => new \DateTime()
]);
}
$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()
]);
}
}