コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: FolderInfo.cs プロジェクト: VegasoftTI/Dnn.Platform
 internal FolderInfo(bool initialiseEmptyPermissions)
 {
     FolderID = Null.NullInteger;
     UniqueId = Guid.NewGuid();
     VersionGuid = Guid.NewGuid();
     WorkflowID = Null.NullInteger;            
     if (initialiseEmptyPermissions)
     {
         _folderPermissions = new FolderPermissionCollection();   
     }            
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        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;
        }
コード例 #11
0
 /// <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);
     }
 }
コード例 #12
0
 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;
 }
コード例 #13
0
        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;
        }
コード例 #14
0
        public FolderPermissionCollection GetFolderPermissionsCollectionByFolderPath(ArrayList arrFolderPermissions, string FolderPath)
        {
            var objFolderPermissionCollection = new FolderPermissionCollection(arrFolderPermissions, FolderPath);

            return(objFolderPermissionCollection);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
 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;
 }
コード例 #17
0
 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;
 }
コード例 #18
0
 public virtual bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey)
 {
     return PortalSecurity.IsInRoles(objFolderPermissions.ToString(PermissionKey));
 }
コード例 #19
0
        /// <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 );
                    }
                }
            }
        }
コード例 #20
0
        /// -----------------------------------------------------------------------------
        /// <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);
                    }
                }
            }
        }
コード例 #21
0
 public virtual bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey)
 {
     return(PortalSecurity.IsInRoles(objFolderPermissions.ToString(PermissionKey)));
 }
コード例 #22
0
        /// -----------------------------------------------------------------------------
        /// <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);
                }                
            }
        }
コード例 #23
0
 public void AddRange(FolderPermissionCollection folderPermissions)
 {
     foreach (FolderPermissionInfo permission in folderPermissions)
     {
         List.Add(permission);
     }
 }
コード例 #24
0
 public FolderPermissionCollection GetFolderPermissionsCollectionByFolderPath(ArrayList arrFolderPermissions, string FolderPath)
 {
     var objFolderPermissionCollection = new FolderPermissionCollection(arrFolderPermissions, FolderPath);
     return objFolderPermissionCollection;
 }
コード例 #25
0
 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;
 }
コード例 #26
0
 public FolderPermissionCollection(FolderPermissionCollection folderPermissions)
 {
     AddRange(folderPermissions);
 }
コード例 #27
0
 public FolderPermissionCollection(FolderPermissionCollection folderPermissions)
 {
     AddRange(folderPermissions);
 }