private static FolderPermissionCollection FillFolderPermissionCollection(IDataReader dr) { FolderPermissionCollection arr = new FolderPermissionCollection(); try { while (dr.Read()) { // fill business object FolderPermissionInfo obj = FillFolderPermissionInfo(dr, false); // add to collection arr.Add(obj); } } catch (Exception exc) { Exceptions.LogException(exc); } finally { // close datareader if (dr != null) { dr.Close(); } } return arr; }
internal FolderInfo(bool initialiseEmptyPermissions) { FolderID = Null.NullInteger; UniqueId = Guid.NewGuid(); VersionGuid = Guid.NewGuid(); WorkflowID = Null.NullInteger; if (initialiseEmptyPermissions) { _folderPermissions = new FolderPermissionCollection(); } }
private static bool CopyPermissionsToSubfoldersRecursive(IFolderInfo folder, FolderPermissionCollection newPermissions) { bool clearCache = Null.NullBoolean; IEnumerable <IFolderInfo> childFolders = FolderManager.Instance.GetFolders(folder); foreach (var f in childFolders) { if (CanAdminFolder((FolderInfo)f)) { f.FolderPermissions.Clear(); f.FolderPermissions.AddRange(newPermissions); SaveFolderPermissions(f); clearCache = true; } clearCache = CopyPermissionsToSubfoldersRecursive(f, newPermissions) || clearCache; } return(clearCache); }
public bool CompareTo(FolderPermissionCollection objFolderPermissionCollection) { if (objFolderPermissionCollection.Count != this.Count) { return(false); } this.InnerList.Sort(new CompareFolderPermissions()); objFolderPermissionCollection.InnerList.Sort(new CompareFolderPermissions()); for (int i = 0; i <= this.Count - 1; i++) { if (objFolderPermissionCollection[i].FolderPermissionID != this[i].FolderPermissionID || objFolderPermissionCollection[i].AllowAccess != this[i].AllowAccess) { return(false); } } return(true); }
public bool CompareTo(FolderPermissionCollection objFolderPermissionCollection) { if (objFolderPermissionCollection.Count != this.Count) { return false; } InnerList.Sort(new CompareFolderPermissions()); objFolderPermissionCollection.InnerList.Sort(new CompareFolderPermissions()); FolderPermissionInfo objFolderPermission; int i = 0; foreach (FolderPermissionInfo tempLoopVar_objFolderPermission in objFolderPermissionCollection) { objFolderPermission = tempLoopVar_objFolderPermission; if (objFolderPermissionCollection[i].FolderPermissionID != this[i].FolderPermissionID || objFolderPermissionCollection[i].AllowAccess != this[i].AllowAccess) { return false; } i++; } return true; }
public virtual FolderPermissionCollection GetFolderPermissionsCollectionByFolder(int PortalID, string Folder) { string dictionaryKey = Folder; if (string.IsNullOrEmpty(dictionaryKey)) { dictionaryKey = "[PortalRoot]"; } //Get the Portal FolderPermission Dictionary Dictionary <string, FolderPermissionCollection> dicFolderPermissions = GetFolderPermissions(PortalID); //Get the Collection from the Dictionary FolderPermissionCollection folderPermissions; bool bFound = dicFolderPermissions.TryGetValue(dictionaryKey, out folderPermissions); if (!bFound) { //Return empty collection folderPermissions = new FolderPermissionCollection(); } return(folderPermissions); }
public bool CompareTo(FolderPermissionCollection objFolderPermissionCollection) { if (objFolderPermissionCollection.Count != this.Count) { return(false); } InnerList.Sort(new CompareFolderPermissions()); objFolderPermissionCollection.InnerList.Sort(new CompareFolderPermissions()); FolderPermissionInfo objFolderPermission; int i = 0; foreach (FolderPermissionInfo tempLoopVar_objFolderPermission in objFolderPermissionCollection) { objFolderPermission = tempLoopVar_objFolderPermission; if (objFolderPermissionCollection[i].FolderPermissionID != this[i].FolderPermissionID || objFolderPermissionCollection[i].AllowAccess != this[i].AllowAccess) { return(false); } i++; } return(true); }
public static bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey) { bool hasPermission = provider.HasFolderPermission(objFolderPermissions, "WRITE"); if (!hasPermission) { if (PermissionKey.Contains(",")) { foreach (string permission in PermissionKey.Split(',')) { if (provider.HasFolderPermission(objFolderPermissions, permission)) { hasPermission = true; break; } } } else { hasPermission = provider.HasFolderPermission(objFolderPermissions, PermissionKey); } } return(hasPermission); }
public virtual FolderPermissionCollection GetFolderPermissionsCollectionByFolder(int PortalID, string Folder) { string dictionaryKey = Folder; if (string.IsNullOrEmpty(dictionaryKey)) { dictionaryKey = "[PortalRoot]"; } //Get the Portal FolderPermission Dictionary Dictionary<string, FolderPermissionCollection> dicFolderPermissions = GetFolderPermissions(PortalID); //Get the Collection from the Dictionary FolderPermissionCollection folderPermissions; bool bFound = dicFolderPermissions.TryGetValue(dictionaryKey, out folderPermissions); if (!bFound) { //Return empty collection folderPermissions = new FolderPermissionCollection(); } return folderPermissions; }
private object GetFolderPermissionsCallBack(CacheItemArgs cacheItemArgs) { var PortalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetFolderPermissionsByPortal(PortalID); var dic = new Dictionary<string, FolderPermissionCollection>(); try { while (dr.Read()) { //fill business object var folderPermissionInfo = CBO.FillObject<FolderPermissionInfo>(dr, false); string dictionaryKey = folderPermissionInfo.FolderPath; if (string.IsNullOrEmpty(dictionaryKey)) { dictionaryKey = "[PortalRoot]"; } //add Folder Permission to dictionary if (dic.ContainsKey(dictionaryKey)) { //Add FolderPermission to FolderPermission Collection already in dictionary for FolderPath dic[dictionaryKey].Add(folderPermissionInfo); } else { //Create new FolderPermission Collection for TabId var collection = new FolderPermissionCollection {folderPermissionInfo}; //Add Permission to Collection //Add Collection to Dictionary dic.Add(dictionaryKey, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return dic; }
/// <summary> /// Copies the permissions to subfolders. /// </summary> /// <param name="folder">The parent folder.</param> /// <param name="newPermissions">The new permissions.</param> public static void CopyPermissionsToSubfolders(IFolderInfo folder, FolderPermissionCollection newPermissions) { bool clearCache = CopyPermissionsToSubfoldersRecursive(folder, newPermissions); if (clearCache) { DataCache.ClearFolderCache(folder.PortalID); } }
public static bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey) { FolderPermissionCollection m = objFolderPermissions; for (int i = 0; i < m.Count; i++) { FolderPermissionInfo mp; mp = m[i]; if (mp.PermissionKey == PermissionKey && PortalSecurity.IsInRoles(mp.RoleName)) { return true; } } return false; }
public FolderPermissionCollection GetFolderPermissionsByFolder(ArrayList arrFolderPermissions, string FolderPath) { FolderPermissionCollection p = new FolderPermissionCollection(); for (int i = 0; i < arrFolderPermissions.Count; i++) { FolderPermissionInfo objFolderPermission = (FolderPermissionInfo)arrFolderPermissions[i]; if (objFolderPermission.FolderPath == FolderPath) { p.Add(objFolderPermission); } } return p; }
public FolderPermissionCollection GetFolderPermissionsCollectionByFolderPath(ArrayList arrFolderPermissions, string FolderPath) { var objFolderPermissionCollection = new FolderPermissionCollection(arrFolderPermissions, FolderPath); return(objFolderPermissionCollection); }
public string GetFolderPermissionsByFolderPath(ArrayList arrFolderPermissions, string FolderPath, string PermissionKey) { //Create a Folder Permission Collection from the ArrayList var folderPermissions = new FolderPermissionCollection(arrFolderPermissions, FolderPath); //Return the permission string for permissions with specified FolderPath return folderPermissions.ToString(PermissionKey); }
private static bool CopyPermissionsToSubfoldersRecursive(IFolderInfo folder, FolderPermissionCollection newPermissions) { bool clearCache = Null.NullBoolean; IEnumerable<IFolderInfo> childFolders = FolderManager.Instance.GetFolders(folder); foreach (FolderInfo f in childFolders) { if (CanAdminFolder(f)) { f.FolderPermissions.Clear(); f.FolderPermissions.AddRange(newPermissions); SaveFolderPermissions(f); clearCache = true; } clearCache = CopyPermissionsToSubfoldersRecursive(f, newPermissions) || clearCache; } return clearCache; }
public static bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey) { bool hasPermission = provider.HasFolderPermission(objFolderPermissions, "WRITE"); if (!hasPermission) { if (PermissionKey.Contains(",")) { foreach (string permission in PermissionKey.Split(',')) { if (provider.HasFolderPermission(objFolderPermissions, permission)) { hasPermission = true; break; } } } else { hasPermission = provider.HasFolderPermission(objFolderPermissions, PermissionKey); } } return hasPermission; }
public virtual bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey) { return PortalSecurity.IsInRoles(objFolderPermissions.ToString(PermissionKey)); }
/// <summary> /// Parses folder permissions /// </summary> /// <param name="nodeFolderPermissions">Node for folder permissions</param> /// <param name="PortalID">PortalId of new portal</param> /// <param name="FolderId">FolderId of folder being processed</param> /// <history> /// [cnurse] 11/09/2004 Created /// </history> private void ParseFolderPermissions( XmlNodeList nodeFolderPermissions, int PortalID, int FolderId, string folderPath ) { FolderPermissionCollection objFolderPermissions = new FolderPermissionCollection(); PermissionController objPermissionController = new PermissionController(); PermissionInfo objPermission = null; FolderPermissionController objFolderPermissionController = new FolderPermissionController(); RoleController objRoleController = new RoleController(); RoleInfo objRole = null; int RoleID = 0; int PermissionID = 0; string PermissionKey = null; string PermissionCode = null; string RoleName = null; bool AllowAccess = false; ArrayList arrPermissions = null; int i = 0; foreach( XmlNode xmlFolderPermission in nodeFolderPermissions ) { PermissionKey = XmlUtils.GetNodeValue( xmlFolderPermission, "permissionkey", "" ); PermissionCode = XmlUtils.GetNodeValue( xmlFolderPermission, "permissioncode", "" ); RoleName = XmlUtils.GetNodeValue( xmlFolderPermission, "rolename", "" ); AllowAccess = XmlUtils.GetNodeValueBoolean( xmlFolderPermission, "allowaccess", false ); arrPermissions = objPermissionController.GetPermissionByCodeAndKey( PermissionCode, PermissionKey ); for( i = 0; i < arrPermissions.Count; i++ ) { objPermission = (PermissionInfo)( arrPermissions[i] ); PermissionID = objPermission.PermissionID; } 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 role was found add, otherwise ignore if( RoleID != int.MinValue ) { if( AllowAccess ) { FileSystemUtils.SetFolderPermission( PortalID, FolderId, PermissionID, RoleID, folderPath ); } } } }
/// ----------------------------------------------------------------------------- /// <summary> /// SaveFolderPermissions updates a Folder's permissions /// </summary> /// <param name="folder">The Folder to update</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- public virtual void SaveFolderPermissions(IFolderInfo folder) { if ((folder.FolderPermissions != null)) { FolderPermissionCollection folderPermissions = GetFolderPermissionsCollectionByFolder(folder.PortalID, folder.FolderPath); //Ensure that if role/user has been given a permission that is not Read/Browse then they also need Read/Browse var permController = new PermissionController(); ArrayList permArray = permController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "READ"); PermissionInfo readPerm = null; if (permArray.Count == 1) { readPerm = permArray[0] as PermissionInfo; } PermissionInfo browsePerm = null; permArray = permController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "BROWSE"); if (permArray.Count == 1) { browsePerm = permArray[0] as PermissionInfo; } var additionalPermissions = new FolderPermissionCollection(); foreach (FolderPermissionInfo folderPermission in folder.FolderPermissions) { if (folderPermission.PermissionKey != "BROWSE" && folderPermission.PermissionKey != "READ") { //Try to add Read permission var newFolderPerm = new FolderPermissionInfo(readPerm) { FolderID = folderPermission.FolderID, RoleID = folderPermission.RoleID, UserID = folderPermission.UserID, AllowAccess = folderPermission.AllowAccess }; additionalPermissions.Add(newFolderPerm); //Try to add Browse permission newFolderPerm = new FolderPermissionInfo(browsePerm) { FolderID = folderPermission.FolderID, RoleID = folderPermission.RoleID, UserID = folderPermission.UserID, AllowAccess = folderPermission.AllowAccess }; additionalPermissions.Add(newFolderPerm); } } foreach (FolderPermissionInfo folderPermission in additionalPermissions) { folder.FolderPermissions.Add(folderPermission, true); } if (!folderPermissions.CompareTo(folder.FolderPermissions)) { dataProvider.DeleteFolderPermissionsByFolderPath(folder.PortalID, folder.FolderPath); foreach (FolderPermissionInfo folderPermission in folder.FolderPermissions) { dataProvider.AddFolderPermission(folder.FolderID, folderPermission.PermissionID, folderPermission.RoleID, folderPermission.AllowAccess, folderPermission.UserID, UserController.GetCurrentUserInfo().UserID); } } } }
public virtual bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey) { return(PortalSecurity.IsInRoles(objFolderPermissions.ToString(PermissionKey))); }
/// ----------------------------------------------------------------------------- /// <summary> /// SaveFolderPermissions updates a Folder's permissions /// </summary> /// <param name="folder">The Folder to update</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- public virtual void SaveFolderPermissions(IFolderInfo folder) { if ((folder.FolderPermissions != null)) { //Ensure that if role/user has been given a permission that is not Read/Browse then they also need Read/Browse var permController = new PermissionController(); ArrayList permArray = permController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "READ"); PermissionInfo readPerm = null; if (permArray.Count == 1) { readPerm = permArray[0] as PermissionInfo; } PermissionInfo browsePerm = null; permArray = permController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "BROWSE"); if (permArray.Count == 1) { browsePerm = permArray[0] as PermissionInfo; } var additionalPermissions = new FolderPermissionCollection(); foreach (FolderPermissionInfo folderPermission in folder.FolderPermissions) { if (folderPermission.PermissionKey != "BROWSE" && folderPermission.PermissionKey != "READ" && folderPermission.AllowAccess) { //Try to add Read permission var newFolderPerm = new FolderPermissionInfo(readPerm) { FolderID = folderPermission.FolderID, RoleID = folderPermission.RoleID, UserID = folderPermission.UserID, AllowAccess = true }; additionalPermissions.Add(newFolderPerm); //Try to add Browse permission newFolderPerm = new FolderPermissionInfo(browsePerm) { FolderID = folderPermission.FolderID, RoleID = folderPermission.RoleID, UserID = folderPermission.UserID, AllowAccess = true }; additionalPermissions.Add(newFolderPerm); } } foreach (FolderPermissionInfo folderPermission in additionalPermissions) { folder.FolderPermissions.Add(folderPermission, true); } dataProvider.DeleteFolderPermissionsByFolderPath(folder.PortalID, folder.FolderPath); foreach (FolderPermissionInfo folderPermission in folder.FolderPermissions) { dataProvider.AddFolderPermission(folder.FolderID, folderPermission.PermissionID, folderPermission.RoleID, folderPermission.AllowAccess, folderPermission.UserID, UserController.Instance.GetCurrentUserInfo().UserID); } } }
public void AddRange(FolderPermissionCollection folderPermissions) { foreach (FolderPermissionInfo permission in folderPermissions) { List.Add(permission); } }
public FolderPermissionCollection GetFolderPermissionsCollectionByFolderPath(ArrayList arrFolderPermissions, string FolderPath) { var objFolderPermissionCollection = new FolderPermissionCollection(arrFolderPermissions, FolderPath); return objFolderPermissionCollection; }
public bool CompareTo(FolderPermissionCollection objFolderPermissionCollection) { if (objFolderPermissionCollection.Count != Count) { return false; } InnerList.Sort(new CompareFolderPermissions()); objFolderPermissionCollection.InnerList.Sort(new CompareFolderPermissions()); for (int i = 0; i <= Count - 1; i++) { if (objFolderPermissionCollection[i].FolderPermissionID != this[i].FolderPermissionID || objFolderPermissionCollection[i].AllowAccess != this[i].AllowAccess) { return false; } } return true; }
public FolderPermissionCollection(FolderPermissionCollection folderPermissions) { AddRange(folderPermissions); }