public static WebItemSecurityObject Create(string id, WebItemManager webItemManager) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id"); } var itemId = Guid.Empty; if (32 <= id.Length) { itemId = new Guid(id); } else { var w = webItemManager .GetItemsAll() .FirstOrDefault(i => id.Equals(i.GetSysName(), StringComparison.InvariantCultureIgnoreCase)); if (w != null) { itemId = w.ID; } } return(new WebItemSecurityObject(itemId, webItemManager)); }
public void SetProductAdministrator(Guid productid, Guid userid, bool administrator) { if (productid == Guid.Empty) { productid = ASC.Core.Users.Constants.GroupAdmin.ID; } if (administrator) { if (UserManager.IsUserInGroup(userid, ASC.Core.Users.Constants.GroupVisitor.ID)) { throw new SecurityException("Collaborator can not be an administrator"); } if (productid == WebItemManager.PeopleProductID) { foreach (var ace in GetPeopleModuleActions(userid)) { AuthorizationManager.AddAce(ace); } } UserManager.AddUserIntoGroup(userid, productid); } else { if (productid == ASC.Core.Users.Constants.GroupAdmin.ID) { var groups = new List <Guid> { WebItemManager.MailProductID }; groups.AddRange(WebItemManager.GetItemsAll().OfType <IProduct>().Select(p => p.ID)); foreach (var id in groups) { UserManager.RemoveUserFromGroup(userid, id); } } if (productid == ASC.Core.Users.Constants.GroupAdmin.ID || productid == WebItemManager.PeopleProductID) { foreach (var ace in GetPeopleModuleActions(userid)) { AuthorizationManager.RemoveAce(ace); } } UserManager.RemoveUserFromGroup(userid, productid); } WebItemSecurityCache.Publish(TenantManager.GetCurrentTenant().TenantId); }
public IEnumerable<UserInfo> GetProductAdministrators(Guid productid) { var groups = new List<Guid>(); if (productid == Guid.Empty) { groups.Add(ASC.Core.Users.Constants.GroupAdmin.ID); groups.AddRange(WebItemManager.GetItemsAll().OfType<IProduct>().Select(p => p.ID)); groups.Add(WebItemManager.MailProductID); } else { groups.Add(productid); } var users = Enumerable.Empty<UserInfo>(); foreach (var id in groups) { users = users.Union(UserManager.GetUsersByGroup(id)); } return users.ToList(); }