public bool SaveSetting(IPermissionSet setting) { ForumPermissionSetNodeCollection tempNodes = new ForumPermissionSetNodeCollection(); bool haveAdd = false; foreach (ForumPermissionSetNode node in Nodes) { if (node.NodeID == setting.NodeID) { tempNodes.Add((ForumPermissionSetNode)setting); haveAdd = true; } else tempNodes.Add(node); } if (haveAdd == false) { tempNodes.Add((ForumPermissionSetNode)setting); } ForumPermissionSet permissionSet = new ForumPermissionSet(); permissionSet.Nodes = tempNodes; return SettingManager.SaveSettings(permissionSet); }
public FoxSecIdentity(int id, string loginName, string firstName, string lastName, string email, string authenticationType, IPermissionSet permissions, IMenuSet menues, int roleId, int?roleTypeId, string roleName, int?companyId, string hostName) : base(loginName, authenticationType) { Id = id; FirstName = firstName; LastName = lastName; Email = email; Permissions = permissions; Menues = menues; RoleId = roleId; RoleTypeId = roleTypeId.HasValue ? roleTypeId.Value : (int)FixedRoleType.DepartmentManager; RoleName = roleName; CompanyId = companyId; HostName = hostName; IsBuildingAdmin = IsSuperAdmin = IsCompanyManager = IsCommonUser = IsDepartmentManager = false; IsBuildingAdmin = RoleTypeId == (int)FixedRoleType.Administrator; IsCompanyManager = RoleTypeId == (int)FixedRoleType.CompanyManager; IsCommonUser = RoleTypeId == (int)FixedRoleType.User; IsDepartmentManager = RoleTypeId == (int)FixedRoleType.DepartmentManager; IsSuperAdmin = RoleTypeId == (int)FixedRoleType.SuperAdmin; }
public bool SaveSetting(IPermissionSet setting) { ForumPermissionSetNodeCollection tempNodes = new ForumPermissionSetNodeCollection(); bool haveAdd = false; foreach (ForumPermissionSetNode node in Nodes) { if (node.NodeID == setting.NodeID) { tempNodes.Add((ForumPermissionSetNode)setting); haveAdd = true; } else { tempNodes.Add(node); } } if (haveAdd == false) { tempNodes.Add((ForumPermissionSetNode)setting); } ForumPermissionSet permissionSet = new ForumPermissionSet(); permissionSet.Nodes = tempNodes; return(SettingManager.SaveSettings(permissionSet)); }
public void TogglePermission(int index) { IPermissionSet ps = GetPermissionSet(); ps[index.AsEnum <Permission>()] = !ps[index.AsEnum <Permission>()]; ApplyPermissions(); }
public static List <IPermissionSet> GetPermissionSets() { Type allSettingsType = typeof(AllSettings); List <IPermissionSet> permissionSets = new List <IPermissionSet>(); FieldInfo[] fieldInfos = allSettingsType.GetFields(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo propertyInfo in fieldInfos) { if (ReflectionUtil.HasInterface(propertyInfo.FieldType, typeof(IPermissionSet))) { IPermissionSet permissionSet = (IPermissionSet)propertyInfo.GetValue(AllSettings.Current); permissionSets.Add(permissionSet); } else if (ReflectionUtil.HasInterface(propertyInfo.FieldType, typeof(IPermissionSetWithNode))) { IPermissionSet permissionSet = ((IPermissionSetWithNode)propertyInfo.GetValue(AllSettings.Current)).GetNode(0); permissionSets.Add(permissionSet); } } return(permissionSets); }
public static IPermissionSet Merge(IPermissionSet left, IPermissionSet right) { var result = new PermissionSet(left.GetByteArray()); foreach (var permission in left) { result[permission.Key] = result[permission.Key] || right[permission.Key]; } return(result); }
public void AssignPermissions(IEnumerable <int> permissionIndexes) { if (Permissions != null) { Array.Clear(Permissions, 0, Permissions.Length); } IPermissionSet ps = GetPermissionSet(); permissionIndexes.ForEach(index => ps[index.AsEnum <Permission>()] = true); ApplyPermissions(); }
private void SavePermission() { m_Success = false; MessageDisplay msgDisplay = CreateMessageDisplay(); if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true") { try { if (PermissionSetWithNode == null) { msgDisplay.AddError(new InvalidParamError("type").Message); } else { PermissionSetWithNode.DeleteSetting(NodeID); BbsRouter.JumpToUrl(Request.RawUrl, "success=true"); } } catch (Exception ex) { msgDisplay.AddError(ex.Message); } return; } IPermissionSet permissionSet = (IPermissionSet)Activator.CreateInstance(PermissionSet.GetType()); BackendPermissions.ActionWithTarget action; if (permissionSet.IsManagement) { action = BackendPermissions.ActionWithTarget.Setting_Permission_Manager; } else { action = BackendPermissions.ActionWithTarget.Setting_Permissions_User; } foreach (Role role in RoleSettings.Roles) { List <PermissionItem> permissionItems = new List <PermissionItem>(); foreach (PermissionItem item in PermissionSet.GetPermissionItems(role)) { PermissionItem newItem = item.Clone(); if (AllSettings.Current.BackendPermissions.Can(My, action, role)) { #region 设置新值 string itemValue = _Request.Get(item.InputName, Method.Post); switch (itemValue) { case "d": newItem.IsDeny = true; break; case "a": newItem.IsAllow = true; break; case "n": newItem.IsNotset = true; break; default: break; } #endregion } permissionItems.Add(newItem); } List <PermissionItem> permissionItemsWithTarget = new List <PermissionItem>(); foreach (PermissionItem item in PermissionSet.GetPermissionItemsWithTarget(role)) { PermissionItem newItem = item.Clone(); if (AllSettings.Current.BackendPermissions.Can(My, action, role)) { #region 设置新值 string itemValue = _Request.Get(item.InputName, Method.Post); switch (itemValue) { case "d": newItem.IsDeny = true; break; case "a": newItem.IsAllow = true; break; case "n": newItem.IsNotset = true; break; default: break; } #endregion } permissionItemsWithTarget.Add(newItem); } permissionSet.SetAllPermissionItems(role, permissionItems, permissionItemsWithTarget); } permissionSet.NodeID = NodeID; if (PermissionSet.HasNodeList) { if (PermissionSetWithNode == null) { msgDisplay.AddError(new InvalidParamError("type").Message); } else { PermissionSetWithNode.SaveSetting(permissionSet); BbsRouter.JumpToUrl(Request.RawUrl, "success=true"); } } else { SettingManager.SaveSettings((SettingBase)permissionSet); BbsRouter.JumpToUrl(Request.RawUrl, "success=true"); } }
public void ApplyPermissions() { Permissions = Permissions; _permissionSet = null; }
public IPermissionSet GetPermissionSet() { return(_permissionSet ?? (_permissionSet = new PermissionSet(Permissions))); }