private static ModulePermissionCollection FillModulePermissionCollection( IDataReader dr ) { ModulePermissionCollection arr = new ModulePermissionCollection(); try { while( dr.Read() ) { // fill business object ModulePermissionInfo obj = FillModulePermissionInfo( dr, false ); // add to collection arr.Add( obj ); } } catch( Exception exc ) { Exceptions.LogException( exc ); } finally { // close datareader if( dr != null ) { dr.Close(); } } return arr; }
private static ModulePermissionCollection FillModulePermissionCollection(IDataReader dr) { ModulePermissionCollection arr = new ModulePermissionCollection(); try { while (dr.Read()) { // fill business object ModulePermissionInfo obj = FillModulePermissionInfo(dr, false); // add to collection arr.Add(obj); } } catch (Exception exc) { Exceptions.LogException(exc); } finally { // close datareader if (dr != null) { dr.Close(); } } return(arr); }
public static bool HasModulePermission(int moduleID, int TabId, string PermissionKey) { ModulePermissionController objModulePermissionController = new ModulePermissionController(); ModulePermissionCollection objModulePermissions = objModulePermissionController.GetModulePermissionsCollectionByModuleID(moduleID, TabId); return(HasModulePermission(objModulePermissions, PermissionKey)); }
/// ----------------------------------------------------------------------------- /// <summary> /// SaveModulePermissions updates a Module's permissions /// </summary> /// <param name="objModule">The Module to update</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- public virtual void SaveModulePermissions(ModuleInfo objModule) { if (objModule.ModulePermissions != null) { ModulePermissionCollection modulePermissions = ModulePermissionController.GetModulePermissions(objModule.ModuleID, objModule.TabID); if (!modulePermissions.CompareTo(objModule.ModulePermissions)) { dataProvider.DeleteModulePermissionsByModuleID(objModule.ModuleID); foreach (ModulePermissionInfo objModulePermission in objModule.ModulePermissions) { if (objModule.InheritViewPermissions && objModulePermission.PermissionKey == "VIEW") { dataProvider.DeleteModulePermission(objModulePermission.ModulePermissionID); } else { dataProvider.AddModulePermission(objModule.ModuleID, objModulePermission.PermissionID, objModulePermission.RoleID, objModulePermission.AllowAccess, objModulePermission.UserID, UserController.GetCurrentUserInfo().UserID); } } } } }
public void AddRange(ModulePermissionCollection modulePermissions) { foreach (ModulePermissionInfo permission in modulePermissions) { Add(permission); } }
public string GetModulePermissionsByModuleID(ModuleInfo objModule, string permissionKey) { //Create a Module Permission Collection from the ArrayList var modulePermissions = new ModulePermissionCollection(objModule); //Return the permission string for permissions with specified TabId return(modulePermissions.ToString(permissionKey)); }
public static bool HasModulePermission(ModulePermissionCollection objModulePermissions, string PermissionKey) { foreach (ModulePermissionInfo objPermission in objModulePermissions) { if (objPermission.PermissionKey == PermissionKey && PortalSecurity.IsInRoles(objPermission.RoleName)) { return(true); } } return(false); }
public static bool HasModulePermission( ModulePermissionCollection objModulePermissions, string PermissionKey ) { foreach( ModulePermissionInfo objPermission in objModulePermissions ) { if( objPermission.PermissionKey == PermissionKey && PortalSecurity.IsInRoles( objPermission.RoleName ) ) { return true; } } return false; }
public string GetModulePermissions(ModulePermissionCollection modulePermissions, string PermissionKey) { string strRoles = ";"; foreach (ModulePermissionInfo objModulePermission in modulePermissions) { if (objModulePermission.AllowAccess && objModulePermission.PermissionKey == PermissionKey) { strRoles += objModulePermission.RoleName + ";"; } } return(strRoles); }
public string GetModulePermissionsByModuleID(ModuleInfo objModule, string PermissionKey) { ModulePermissionCollection objModPerms = objModule.ModulePermissions; string strRoles = ";"; foreach (ModulePermissionInfo objModulePermission in objModPerms) { if (objModulePermission.AllowAccess && objModulePermission.PermissionKey == PermissionKey) { strRoles += objModulePermission.RoleName + ";"; } } return(strRoles); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetModulePermissions gets a ModulePermissionCollection /// </summary> /// <param name="moduleID">The ID of the module</param> /// <param name="tabID">The ID of the tab</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- public virtual ModulePermissionCollection GetModulePermissions(int moduleID, int tabID) { //Get the Tab ModulePermission Dictionary Dictionary <int, ModulePermissionCollection> dicModulePermissions = GetModulePermissions(tabID); //Get the Collection from the Dictionary ModulePermissionCollection modulePermissions; bool bFound = dicModulePermissions.TryGetValue(moduleID, out modulePermissions); if (!bFound) { //Return empty collection modulePermissions = new ModulePermissionCollection(); } return(modulePermissions); }
public bool CompareTo(ModulePermissionCollection objModulePermissionCollection) { if (objModulePermissionCollection.Count != Count) { return(false); } InnerList.Sort(new CompareModulePermissions()); objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions()); for (int i = 0; i <= Count - 1; i++) { if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess) { return(false); } } return(true); }
private static Dictionary <int, ModulePermissionCollection> FillModulePermissionDictionary(IDataReader dr) { Dictionary <int, ModulePermissionCollection> dic = new Dictionary <int, ModulePermissionCollection>(); try { while (dr.Read()) { // fill business object ModulePermissionInfo obj = FillModulePermissionInfo(dr, false); // add Module Permission to dictionary if (dic.ContainsKey(obj.ModuleID)) { //Add ModulePermission to ModulePermission Collection already in dictionary for TabId dic[obj.ModuleID].Add(obj); } else { //Create new ModulePermission Collection for ModuleId ModulePermissionCollection collection = new ModulePermissionCollection(); //Add Permission to Collection collection.Add(obj); //Add Collection to Dictionary dic.Add(obj.ModuleID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { // close datareader if (dr != null) { dr.Close(); } } return(dic); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetModulePermissionsCallBack gets a Dictionary of ModulePermissionCollections by /// Module from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- private object GetModulePermissionsCallBack(CacheItemArgs cacheItemArgs) { var tabID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetModulePermissionsByTabID(tabID); var dic = new Dictionary <int, ModulePermissionCollection>(); try { while (dr.Read()) { //fill business object var modulePermissionInfo = CBO.FillObject <ModulePermissionInfo>(dr, false); //add Module Permission to dictionary if (dic.ContainsKey(modulePermissionInfo.ModuleID)) { dic[modulePermissionInfo.ModuleID].Add(modulePermissionInfo); } else { //Create new ModulePermission Collection for ModuleId var collection = new ModulePermissionCollection { modulePermissionInfo }; //Add Permission to Collection //Add Collection to Dictionary dic.Add(modulePermissionInfo.ModuleID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return(dic); }
private bool IsDeniedModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { bool isDenied = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (PortalSecurity.IsDenied(modulePermissions.ToString(permission))) { isDenied = true; break; } } } else { isDenied = PortalSecurity.IsDenied(modulePermissions.ToString(permissionKey)); } return(isDenied); }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <param name="modulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// ----------------------------------------------------------------------------- public virtual bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { bool hasPermission = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (PortalSecurity.IsInRoles(modulePermissions.ToString(permission))) { hasPermission = true; break; } } } else { hasPermission = PortalSecurity.IsInRoles(modulePermissions.ToString(permissionKey)); } return(hasPermission); }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return /// true if the user has any one of the permissions.</remarks> /// <param name="modulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// <history> /// [cnurse] 01/15/2008 Documented /// </history> /// ----------------------------------------------------------------------------- public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { bool hasPermission = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (Provider.HasModulePermission(modulePermissions, permission)) { hasPermission = true; break; } } } else { hasPermission = Provider.HasModulePermission(modulePermissions, permissionKey); } return(hasPermission); }
public bool CompareTo(ModulePermissionCollection objModulePermissionCollection) { if (objModulePermissionCollection.Count != this.Count) { return false; } InnerList.Sort(new CompareModulePermissions()); objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions()); ModulePermissionInfo objModulePermission; int i = 0; foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModulePermissionCollection) { objModulePermission = tempLoopVar_objModulePermission; if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess) { return false; } i++; } return true; }
public bool CompareTo(ModulePermissionCollection objModulePermissionCollection) { if (objModulePermissionCollection.Count != this.Count) { return(false); } InnerList.Sort(new CompareModulePermissions()); objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions()); ModulePermissionInfo objModulePermission; int i = 0; foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModulePermissionCollection) { objModulePermission = tempLoopVar_objModulePermission; if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess) { return(false); } i++; } return(true); }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <param name="modulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// ----------------------------------------------------------------------------- public virtual bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { bool hasPermission = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (PortalSecurity.IsInRoles(modulePermissions.ToString(permission))) { hasPermission = true; break; } } } else { hasPermission = PortalSecurity.IsInRoles(modulePermissions.ToString(permissionKey)); } return hasPermission; }
private bool IsDeniedModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { bool isDenied = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (PortalSecurity.IsDenied(modulePermissions.ToString(permission))) { isDenied = true; break; } } } else { isDenied = PortalSecurity.IsDenied(modulePermissions.ToString(permissionKey)); } return isDenied; }
private void Create_Click(object sender, EventArgs e) { var ps = new Security.PortalSecurity(); txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting); txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup); txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting); txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup); if (RoleController.Instance.GetRoleByName(PortalId, txtGroupName.Text) != null) { lblInvalidGroupName.Visible = true; return; } var modRoles = new List<RoleInfo>(); var modUsers = new List<UserInfo>(); foreach (ModulePermissionInfo modulePermissionInfo in ModulePermissionController.GetModulePermissions(ModuleId, TabId)) { if (modulePermissionInfo.PermissionKey == "MODGROUP" && modulePermissionInfo.AllowAccess) { if (modulePermissionInfo.RoleID > int.Parse(Globals.glbRoleNothing)) { modRoles.Add(RoleController.Instance.GetRoleById(PortalId, modulePermissionInfo.RoleID)); } else if (modulePermissionInfo.UserID > Null.NullInteger) { modUsers.Add(UserController.GetUserById(PortalId, modulePermissionInfo.UserID)); } } } var roleInfo = new RoleInfo() { PortalID = PortalId, RoleName = txtGroupName.Text, Description = txtDescription.Text, SecurityMode = SecurityMode.SocialGroup, Status = RoleStatus.Approved, IsPublic = rdAccessTypePublic.Checked }; var userRoleStatus = RoleStatus.Pending; if (GroupModerationEnabled) { roleInfo.Status = RoleStatus.Pending; userRoleStatus = RoleStatus.Pending; } else { userRoleStatus = RoleStatus.Approved; } var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(ModuleId, -1), typeof(ModulePermissionInfo))); if (ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP")) { roleInfo.Status = RoleStatus.Approved; userRoleStatus = RoleStatus.Approved; } roleInfo.RoleGroupID = DefaultRoleGroupId; roleInfo.RoleID = RoleController.Instance.AddRole(roleInfo); roleInfo = RoleController.Instance.GetRoleById(PortalId, roleInfo.RoleID); var groupUrl = Globals.NavigateURL(GroupViewTabId, "", new String[] {"groupid=" + roleInfo.RoleID.ToString()}); if (groupUrl.StartsWith("http://") || groupUrl.StartsWith("https://")) { const int startIndex = 8; // length of https:// groupUrl = groupUrl.Substring(groupUrl.IndexOf("/", startIndex, StringComparison.InvariantCultureIgnoreCase)); } roleInfo.Settings.Add("URL", groupUrl); roleInfo.Settings.Add("GroupCreatorName", UserInfo.DisplayName); roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString()); RoleController.Instance.UpdateRoleSettings(roleInfo, true); if (inpFile.PostedFile != null && inpFile.PostedFile.ContentLength > 0) { IFileManager _fileManager = FileManager.Instance; IFolderManager _folderManager = FolderManager.Instance; var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory); IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID); if (groupFolder == null) { groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID); } if (groupFolder != null) { var fileName = Path.GetFileName(inpFile.PostedFile.FileName); var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true); roleInfo.IconFile = "FileID=" + fileInfo.FileId; RoleController.Instance.UpdateRole(roleInfo); } } var notifications = new Notifications(); RoleController.Instance.AddUserRole(PortalId, UserId, roleInfo.RoleID, userRoleStatus, true, Null.NullDate, Null.NullDate); if (roleInfo.Status == RoleStatus.Pending) { //Send notification to Group Moderators to approve/reject group. notifications.AddGroupNotification(Constants.GroupPendingNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles, modUsers); } else { //Send notification to Group Moderators informing of new group. notifications.AddGroupNotification(Constants.GroupCreatedNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles, modUsers); //Add entry to journal. GroupUtilities.CreateJournalEntry(roleInfo, UserInfo); } Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() })); }
public static bool HasEditPermissions(ModulePermissionCollection objModulePermissions) { return ModulePermissionController.HasModulePermission(objModulePermissions, "EDIT"); }
public ModulePermissionCollection(ModulePermissionCollection modulePermissions) { AddRange(modulePermissions); }
public bool CompareTo(ModulePermissionCollection objModulePermissionCollection) { if (objModulePermissionCollection.Count != Count) { return false; } InnerList.Sort(new CompareModulePermissions()); objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions()); for (int i = 0; i <= Count - 1; i++) { if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess) { return false; } } return true; }
public void ModulePermissionController_HasModuleAccess_SecurityLevelView_Is_False_For_User_Without_View_Role() { CreateUser(false, new List<string>() { "RoleWithoutViewPermission" }); var modulePermissionCollection = new ModulePermissionCollection(); AddModulePermission(modulePermissionCollection, "View", Convert.ToInt32(SetupPortalSettings().AdministratorRoleId)); var module = new ModuleInfo {InheritViewPermissions = false, ModulePermissions = modulePermissionCollection}; Assert.IsFalse(ModulePermissionController.HasModuleAccess(SecurityAccessLevel.View, "", module)); }
protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align) { TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions; PermissionController objPermissionController = new PermissionController(); ModuleController objModules = new ModuleController(); ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController(); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); int intIndex; try { DesktopModuleController objDesktopModules = new DesktopModuleController(); ArrayList arrDM = objDesktopModules.GetDesktopModulesByPortal(PortalSettings.PortalId); bool isSelectable = false; for (int intloop = 0; intloop < arrDM.Count; intloop++) { if (((DesktopModuleInfo)(arrDM[intloop])).DesktopModuleID == desktopModuleId) { isSelectable = true; break; } } if (isSelectable == false) { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } int UserId = -1; if (Request.IsAuthenticated) { UserInfo objUserInfo = UserController.GetCurrentUserInfo(); UserId = objUserInfo.UserID; } ArrayList arrModuleDefinitions = objModuleDefinitions.GetModuleDefinitions(desktopModuleId); for (intIndex = 0; intIndex < arrModuleDefinitions.Count; intIndex++) { ModuleDefinitionInfo objModuleDefinition = (ModuleDefinitionInfo)(arrModuleDefinitions[intIndex]); ModuleInfo objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.PortalId); objModule.PortalID = PortalSettings.PortalId; objModule.TabID = PortalSettings.ActiveTab.TabID; objModule.ModuleOrder = position; if (String.IsNullOrEmpty(title)) { objModule.ModuleTitle = objModuleDefinition.FriendlyName; } else { objModule.ModuleTitle = title; } objModule.ModuleTitle = title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; objModule.CacheTime = objModuleDefinition.DefaultCacheTime; // initialize module permissions ModulePermissionCollection objModulePermissions = new ModulePermissionCollection(); objModule.ModulePermissions = objModulePermissions; objModule.InheritViewPermissions = false; // get the default module view permissions ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); // get the permissions from the page foreach (TabPermissionInfo objTabPermission in objTabPermissions) { // get the system module permissions for the permissionkey ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); // loop through the system module permissions int j; for (j = 0; j < arrSystemModulePermissions.Count; j++) { // create the module permission PermissionInfo objSystemModulePermission = (PermissionInfo)(arrSystemModulePermissions[j]); ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objSystemModulePermission, objTabPermission.RoleID); // add the permission to the collection if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess) { objModulePermissions.Add(objModulePermission); } // ensure that every EDIT permission which allows access also provides VIEW permission if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess) { ModulePermissionInfo objModuleViewperm = new ModulePermissionInfo(); objModuleViewperm.ModuleID = objModulePermission.ModuleID; objModuleViewperm.PermissionID = ((PermissionInfo)(arrSystemModuleViewPermissions[0])).PermissionID; objModuleViewperm.RoleID = objModulePermission.RoleID; objModuleViewperm.PermissionKey = "VIEW"; objModuleViewperm.AllowAccess = true; if (!(objModulePermissions.Contains(objModuleViewperm))) { objModulePermissions.Add(objModuleViewperm); } } } //Get the custom Module Permissions, Assume that roles with Edit Tab Permissions //are automatically assigned to the Custom Module Permissions if (objTabPermission.PermissionKey == "EDIT") { ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID); // loop through the custom module permissions for (j = 0; j < arrCustomModulePermissions.Count; j++) { // create the module permission PermissionInfo objCustomModulePermission = (PermissionInfo)(arrCustomModulePermissions[j]); ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objCustomModulePermission, objTabPermission.RoleID); // add the permission to the collection if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess) { objModulePermissions.Add(objModulePermission); } } } } switch (permissionType) { case ViewPermissionType.View: objModule.InheritViewPermissions = true; break; case ViewPermissionType.Edit: objModule.ModulePermissions = objModulePermissions; break; } objModule.AllTabs = false; objModule.Visibility = VisibilityState.Maximized; objModule.Alignment = align; objModules.AddModule(objModule); objEventLog.AddLog(objModule, PortalSettings, UserId, "", Services.Log.EventLog.EventLogController.EventLogType.MODULE_CREATED); } }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return /// true if the user has any one of the permissions.</remarks> /// <param name="modulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// <history> /// [cnurse] 01/15/2008 Documented /// </history> /// ----------------------------------------------------------------------------- public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { bool hasPermission = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (Provider.HasModulePermission(modulePermissions, permission)) { hasPermission = true; break; } } } else { hasPermission = Provider.HasModulePermission(modulePermissions, permissionKey); } return hasPermission; }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <param name="objModulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- public virtual bool HasModulePermission(ModulePermissionCollection objModulePermissions, string permissionKey) { return(PortalSecurity.IsInRoles(objModulePermissions.ToString(permissionKey))); }
public ModulePermissionCollection GetModulePermissionsCollectionByModuleID( ArrayList arrModulePermissions, int moduleID ) { ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection( arrModulePermissions, moduleID ); return objModulePermissionCollection; }
private static Dictionary<int, ModulePermissionCollection> FillModulePermissionDictionary( IDataReader dr ) { Dictionary<int, ModulePermissionCollection> dic = new Dictionary<int, ModulePermissionCollection>(); try { while( dr.Read() ) { // fill business object ModulePermissionInfo obj = FillModulePermissionInfo( dr, false ); // add Module Permission to dictionary if( dic.ContainsKey( obj.ModuleID ) ) { //Add ModulePermission to ModulePermission Collection already in dictionary for TabId dic[obj.ModuleID].Add( obj ); } else { //Create new ModulePermission Collection for ModuleId ModulePermissionCollection collection = new ModulePermissionCollection(); //Add Permission to Collection collection.Add( obj ); //Add Collection to Dictionary dic.Add( obj.ModuleID, collection ); } } } catch( Exception exc ) { Exceptions.LogException( exc ); } finally { // close datareader if( dr != null ) { dr.Close(); } } return dic; }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <param name="modulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- public virtual bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { return PortalSecurity.IsInRoles(modulePermissions.ToString(permissionKey)); }
public ModulePermissionCollection GetModulePermissionsCollectionByModuleID(ArrayList arrModulePermissions, int moduleID) { ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection(arrModulePermissions, moduleID); return(objModulePermissionCollection); }
public static bool HasModulePermission(int moduleID, string permissionKey) { var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(moduleID, -1), typeof(ModulePermissionInfo))); return(HasModulePermission(objModulePermissions, permissionKey)); }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission /// </summary> /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return /// true if the user has any one of the permissions.</remarks> /// <param name="modulePermissions">The Permissions for the Module</param> /// <param name="permissionKey">The Permission to check</param> /// ----------------------------------------------------------------------------- public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { return _provider.HasModulePermission(modulePermissions, permissionKey); }
private static void AddModulePermission(ModulePermissionCollection permissions, string key, int roleId) { var permissionController = new PermissionController(); var permission = (PermissionInfo)permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", key)[0]; var modulePermission = new ModulePermissionInfo { PermissionID = permission.PermissionID, RoleID = roleId, AllowAccess = true }; permissions.Add(modulePermission); }
public string GetModulePermissions(ModulePermissionCollection modulePermissions, string permissionKey) { return modulePermissions.ToString(permissionKey); }
public string GetModulePermissionsByModuleID(ModuleInfo objModule, string permissionKey) { //Create a Module Permission Collection from the ArrayList var modulePermissions = new ModulePermissionCollection(objModule); //Return the permission string for permissions with specified TabId return modulePermissions.ToString(permissionKey); }
private void ParseModulePermissions( XmlNodeList nodeModulePermissions, int PortalId, int ModuleID ) { RoleController objRoleController = new RoleController(); RoleInfo objRole = null; ModulePermissionCollection objModulePermissions = new ModulePermissionCollection(); ModulePermissionController objModulePermissionController = new ModulePermissionController(); PermissionController objPermissionController = new PermissionController(); PermissionInfo objPermission = null; ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection(); int PermissionID = 0; ArrayList arrPermissions = null; int i = 0; string PermissionKey = null; string PermissionCode = null; string RoleName = null; int RoleID = 0; bool AllowAccess = false; foreach( XmlNode node in nodeModulePermissions ) { PermissionKey = XmlUtils.GetNodeValue( node, "permissionkey", "" ); PermissionCode = XmlUtils.GetNodeValue( node, "permissioncode", "" ); RoleName = XmlUtils.GetNodeValue( node, "rolename", "" ); AllowAccess = XmlUtils.GetNodeValueBoolean( node, "allowaccess", false ); RoleID = int.MinValue; if( RoleName == Globals.glbRoleAllUsersName ) { RoleID = Convert.ToInt32( Globals.glbRoleAllUsers ); } else if( RoleName == Globals.glbRoleUnauthUserName ) { RoleID = Convert.ToInt32( Globals.glbRoleUnauthUser ); } else { objRole = objRoleController.GetRoleByName( PortalId, RoleName ); if( objRole != null ) { RoleID = objRole.RoleID; } } if( RoleID != int.MinValue ) { PermissionID = -1; arrPermissions = objPermissionController.GetPermissionByCodeAndKey( PermissionCode, PermissionKey ); for( i = 0; i < arrPermissions.Count; i++ ) { objPermission = (PermissionInfo)( arrPermissions[i] ); PermissionID = objPermission.PermissionID; } // if role was found add, otherwise ignore if( PermissionID != -1 ) { ModulePermissionInfo objModulePermission = new ModulePermissionInfo(); objModulePermission.ModuleID = ModuleID; objModulePermission.PermissionID = PermissionID; objModulePermission.RoleID = RoleID; objModulePermission.AllowAccess = Convert.ToBoolean( XmlUtils.GetNodeValue( node, "allowaccess", "false" ) ); objModulePermissionController.AddModulePermission( objModulePermission ); } } } }
public static bool HasModulePermission(int moduleID, string permissionKey) { var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(moduleID, -1), typeof (ModulePermissionInfo))); return HasModulePermission(objModulePermissions, permissionKey); }
/// ----------------------------------------------------------------------------- /// <summary> /// HasModulePermission checks whether the current user has a specific Module Permission. /// </summary> /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return /// true if the user has any one of the permissions.</remarks> /// <param name="modulePermissions">The Permissions for the Module.</param> /// <param name="permissionKey">The Permission to check.</param> /// <returns></returns> /// ----------------------------------------------------------------------------- public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey) { return(_provider.HasModulePermission(modulePermissions, permissionKey)); }
public string GetModulePermissions( ModulePermissionCollection modulePermissions, string PermissionKey ) { string strRoles = ";"; foreach( ModulePermissionInfo objModulePermission in modulePermissions ) { if( objModulePermission.AllowAccess && objModulePermission.PermissionKey == PermissionKey ) { strRoles += objModulePermission.RoleName + ";"; } } return strRoles; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetModulePermissionsCallBack gets a Dictionary of ModulePermissionCollections by /// Module from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- private object GetModulePermissionsCallBack(CacheItemArgs cacheItemArgs) { var tabID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetModulePermissionsByTabID(tabID); var dic = new Dictionary<int, ModulePermissionCollection>(); try { while (dr.Read()) { //fill business object var modulePermissionInfo = CBO.FillObject<ModulePermissionInfo>(dr, false); //add Module Permission to dictionary if (dic.ContainsKey(modulePermissionInfo.ModuleID)) { dic[modulePermissionInfo.ModuleID].Add(modulePermissionInfo); } else { //Create new ModulePermission Collection for ModuleId var collection = new ModulePermissionCollection {modulePermissionInfo}; //Add Permission to Collection //Add Collection to Dictionary dic.Add(modulePermissionInfo.ModuleID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return dic; }
public string GetModulePermissions(ModulePermissionCollection modulePermissions, string permissionKey) { return(modulePermissions.ToString(permissionKey)); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetModulePermissions gets a ModulePermissionCollection /// </summary> /// <param name="moduleID">The ID of the module</param> /// <param name="tabID">The ID of the tab</param> /// ----------------------------------------------------------------------------- public virtual ModulePermissionCollection GetModulePermissions(int moduleID, int tabID) { //Get the Tab ModulePermission Dictionary Dictionary<int, ModulePermissionCollection> dictionary = GetModulePermissions(tabID); //Get the Collection from the Dictionary ModulePermissionCollection modulePermissions; bool found = dictionary.TryGetValue(moduleID, out modulePermissions); if (!found) { //Return empty collection modulePermissions = new ModulePermissionCollection(); } return modulePermissions; }
private bool IsMod() { var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(_moduleId, -1), typeof(ModulePermissionInfo))); return ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP"); }
public static bool HasModulePermission(int moduleID, string PermissionKey) { ModulePermissionCollection objModulePermissions = FillModulePermissionCollection(DataProvider.Instance().GetModulePermissionsByModuleID(moduleID, -1)); return(HasModulePermission(objModulePermissions, PermissionKey)); }