예제 #1
0
        private TabPermissionCollection FillTabPermissionCollection(IDataReader dr)
        {
            TabPermissionCollection arr = new TabPermissionCollection();

            try
            {
                TabPermissionInfo obj = null;
                while (dr.Read())
                {
                    // fill business object
                    obj = FillTabPermissionInfo(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 TabPermissionCollection FillTabPermissionCollection( IDataReader dr )
 {
     TabPermissionCollection arr = new TabPermissionCollection();
     try
     {
         TabPermissionInfo obj = null;
         while( dr.Read() )
         {
             // fill business object
             obj = FillTabPermissionInfo( dr, false );
             // add to collection
             arr.Add( obj );
         }
     }
     catch( Exception exc )
     {
         Exceptions.LogException( exc );
     }
     finally
     {
         // close datareader
         if( dr != null )
         {
             dr.Close();
         }
     }
     return arr;
 }
예제 #3
0
        public TabPermissionCollection GetTabPermissionsByTabID(ArrayList arrTabPermissions, int TabID)
        {
            TabPermissionCollection p = new TabPermissionCollection();
            int i = 0;

            for (i = 0; i < arrTabPermissions.Count; i++)
            {
                TabPermissionInfo objTabPermission = (TabPermissionInfo)(arrTabPermissions[i]);
                if (objTabPermission.TabID == TabID)
                {
                    p.Add(objTabPermission);
                }
            }
            return(p);
        }
예제 #4
0
        private Dictionary <int, TabPermissionCollection> FillTabPermissionDictionary(IDataReader dr)
        {
            Dictionary <int, TabPermissionCollection> dic = new Dictionary <int, TabPermissionCollection>();

            try
            {
                TabPermissionInfo obj = null;
                while (dr.Read())
                {
                    // fill business object
                    obj = FillTabPermissionInfo(dr, false);

                    // add Tab Permission to dictionary
                    if (dic.ContainsKey(obj.TabID))
                    {
                        //Add TabPermission to TabPermission Collection already in dictionary for TabId
                        dic[obj.TabID].Add(obj);
                    }
                    else
                    {
                        //Create new TabPermission Collection for TabId
                        TabPermissionCollection collection = new TabPermissionCollection();

                        //Add Permission to Collection
                        collection.Add(obj);

                        //Add Collection to Dictionary
                        dic.Add(obj.TabID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                // close datareader
                if (dr != null)
                {
                    dr.Close();
                }
            }
            return(dic);
        }
예제 #5
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPagePermission adds a TabPermission to a TabPermission Collection
        /// </summary>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        ///	<param name="key">The Permission key</param>
        ///	<param name="roleId">The role given the permission</param>
        /// <history>
        /// 	[cnurse]	11/11/2004	created 
        /// </history>
        /// -----------------------------------------------------------------------------
        private static void AddPagePermission(TabPermissionCollection permissions, string key, int roleId)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddPagePermission:" + key);
            var permissionController = new PermissionController();
            var permission = (PermissionInfo)permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", key)[0];

            var tabPermission = new TabPermissionInfo { PermissionID = permission.PermissionID, RoleID = roleId, AllowAccess = true };

            permissions.Add(tabPermission);
        }
        private Dictionary<int, TabPermissionCollection> FillTabPermissionDictionary( IDataReader dr )
        {
            Dictionary<int, TabPermissionCollection> dic = new Dictionary<int, TabPermissionCollection>();
            try
            {
                TabPermissionInfo obj = null;
                while( dr.Read() )
                {
                    // fill business object
                    obj = FillTabPermissionInfo( dr, false );

                    // add Tab Permission to dictionary
                    if( dic.ContainsKey( obj.TabID ) )
                    {
                        //Add TabPermission to TabPermission Collection already in dictionary for TabId
                        dic[obj.TabID].Add( obj );
                    }
                    else
                    {
                        //Create new TabPermission Collection for TabId
                        TabPermissionCollection collection = new TabPermissionCollection();

                        //Add Permission to Collection
                        collection.Add( obj );

                        //Add Collection to Dictionary
                        dic.Add( obj.TabID, collection );
                    }
                }
            }
            catch( Exception exc )
            {
                Exceptions.LogException( exc );
            }
            finally
            {
                // close datareader
                if( dr != null )
                {
                    dr.Close();
                }
            }
            return dic;
        }
 public TabPermissionCollection GetTabPermissionsByTabID( ArrayList arrTabPermissions, int TabID )
 {
     TabPermissionCollection p = new TabPermissionCollection();
     int i = 0;
     for( i = 0; i < arrTabPermissions.Count; i++ )
     {
         TabPermissionInfo objTabPermission = (TabPermissionInfo)( arrTabPermissions[i] );
         if( objTabPermission.TabID == TabID )
         {
             p.Add( objTabPermission );
         }
     }
     return p;
 }
예제 #8
0
        /// <summary>
        /// Parses tab permissions
        /// </summary>
        /// <param name="nodeTabPermissions">Node for tab permissions</param>
        /// <param name="objPortal">Portal object of new portal</param>
        /// <param name="TabId">TabId of tab being processed</param>
        /// <param name="IsAdminTemplate">Flag to indicate if we are parsing admin template</param>
        /// <history>
        /// 	[Vicenç]	15/10/2004	Created
        /// </history>
        private TabPermissionCollection ParseTabPermissions( XmlNodeList nodeTabPermissions, PortalInfo objPortal, int TabId, bool IsAdminTemplate )
        {
            TabPermissionCollection objTabPermissions = new TabPermissionCollection();
            PermissionController objPermissionController = new PermissionController();
            PermissionInfo objPermission = null;
            TabPermissionInfo objTabPermission = null;
            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 xmlTabPermission in nodeTabPermissions )
            {
                PermissionKey = XmlUtils.GetNodeValue( xmlTabPermission, "permissionkey", "" );
                PermissionCode = XmlUtils.GetNodeValue( xmlTabPermission, "permissioncode", "" );
                RoleName = XmlUtils.GetNodeValue( xmlTabPermission, "rolename", "" );
                AllowAccess = XmlUtils.GetNodeValueBoolean( xmlTabPermission, "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( objPortal.PortalID, RoleName );
                    if( objRole != null )
                    {
                        RoleID = objRole.RoleID;
                    }
                    else
                    {
                        // if parsing admin.template and role administrators redefined, use portal.administratorroleid
                        if( IsAdminTemplate && RoleName.ToLower() == "administrators" )
                        {
                            RoleID = objPortal.AdministratorRoleId;
                        }
                    }
                }

                // if role was found add, otherwise ignore
                if( RoleID != int.MinValue )
                {
                    objTabPermission = new TabPermissionInfo();
                    objTabPermission.TabID = TabId;
                    objTabPermission.PermissionID = PermissionID;
                    objTabPermission.RoleID = RoleID;
                    objTabPermission.AllowAccess = AllowAccess;
                    objTabPermissions.Add( objTabPermission );
                }
            }
            return objTabPermissions;
        }
예제 #9
0
        /// <summary>
        /// AddPagePermission adds a TabPermission to a TabPermission Collection
        /// </summary>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        ///	<param name="key">The Permission key</param>
        ///	<param name="roleId">The role given the permission</param>
        private static void AddPagePermission(ref TabPermissionCollection permissions, string key, int roleId)
        {
            PermissionController objPermissionController = new PermissionController();
            PermissionInfo objPermission = (PermissionInfo)objPermissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", key)[0];

            TabPermissionInfo objTabPermission = new TabPermissionInfo();
            objTabPermission.PermissionID = objPermission.PermissionID;
            objTabPermission.RoleID = roleId;
            objTabPermission.AllowAccess = true;
            permissions.Add(objTabPermission);
        }
예제 #10
0
파일: Upgrade.cs 프로젝트: biganth/Curt
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPagePermission adds a TabPermission to a TabPermission Collection
        /// </summary>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        ///	<param name="key">The Permission key</param>
        ///	<param name="roleId">The role given the permission</param>
        /// <history>
        /// 	[cnurse]	11/11/2004	created 
        /// </history>
        /// -----------------------------------------------------------------------------
        private static void AddPagePermission(TabPermissionCollection permissions, string key, int roleId)
        {
            var permissionController = new PermissionController();
            var permission = (PermissionInfo) permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", key)[0];

            var tabPermission = new TabPermissionInfo {PermissionID = permission.PermissionID, RoleID = roleId, AllowAccess = true};

            permissions.Add(tabPermission);
        }