Album Permissions
I'm working on a new control and want to upload images to an album for all users. I have tried this code to programatically set the permission to allow everyone manage permissions so they can upload images:
var album = App.WorkWith()
.Album(
this
.ImageAlbum)
.Get();
LibrariesManager manager = LibrariesManager.GetManager();
manager.BreakPermiossionsInheritance(album);
var roleId = SecurityManager.ApplicationRoles[
"Everyone"
].Id;
Telerik.Sitefinity.Security.Model.Permission permissionForEveryone = album.GetActivePermissions().Where(p => p.PrincipalId == roleId && p.ObjectId == album.Id).FirstOrDefault();
if
(permissionForEveryone ==
null
)
permissionForEveryone = manager.CreatePermission(SecurityConstants.Sets.Image.Manage, album.Id, roleId);
album.Permissions.Add(permissionForEveryone);
permissionForEveryone.GrantActions(
true
, SecurityConstants.Sets.Image.View);
manager.SaveChanges();
I have found and fixed the problem; there was a logic error in my code that I didn't see before I posted this question.