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;
 }
Esempio n. 2
0
        /// <summary>
        /// AddAdminPage adds an Admin Tab Page
        /// </summary>
        ///	<param name="Portal">The Portal</param>
        ///	<param name="TabName">The Name to give this new Tab</param>
        ///	<param name="TabIconFile">The Icon for this new Tab</param>
        ///	<param name="IsVisible">A flag indicating whether the tab is visible</param>
        private static TabInfo AddAdminPage(PortalInfo Portal, string TabName, string TabIconFile, bool IsVisible)
        {
            TabController objTabController = new TabController();
            TabInfo AdminPage = objTabController.GetTab(Portal.AdminTabId, Portal.PortalID, false);

            TabPermissionCollection objTabPermissions = new TabPermissionCollection();
            AddPagePermission(ref objTabPermissions, "View", Convert.ToInt32(Portal.AdministratorRoleId));

            //Call AddPage with parentTab = AdminPage & RoleId = AdministratorRoleId
            return AddPage(AdminPage, TabName, TabIconFile, IsVisible, objTabPermissions, true);
        }
 public static bool HasTabPermission( TabPermissionCollection objTabPermissions, string PermissionKey )
 {
     PortalSettings _PortalSettings = PortalController.GetCurrentPortalSettings();
     foreach( TabPermissionInfo objTabPermission in objTabPermissions )
     {
         if( objTabPermission.PermissionKey == PermissionKey && PortalSecurity.IsInRoles( objTabPermission.RoleName ) )
         {
             return true;
         }
     }
     return false;
 }
        public bool CompareTo(TabPermissionCollection objTabPermissionCollection)
        {
            if (objTabPermissionCollection.Count != this.Count)
            {
                return false;
            }
            InnerList.Sort(new CompareTabPermissions());
            objTabPermissionCollection.InnerList.Sort(new CompareTabPermissions());

            
            int i = 0;
            foreach (TabPermissionInfo objTabPermission in objTabPermissionCollection)
            {
                if (objTabPermissionCollection[i].TabPermissionID != this[i].TabPermissionID || objTabPermissionCollection[i].AllowAccess != this[i].AllowAccess)
                {
                    return false;
                }
                i++;
            }
            return true;
        }
Esempio n. 5
0
        private TabInfo CreatePage(TabInfo tab, int portalId, int parentTabId, string tabName, bool includeInMenu)
        {
            int id = -1;
            var tc = new TabController();
            var tPermissions = new TabPermissionCollection();
            var newTab = new TabInfo();
            if ((tab != null))
            {
                foreach (TabPermissionInfo t in tab.TabPermissions)
                {
                    var tNew = new TabPermissionInfo
                                   {
                                       AllowAccess = t.AllowAccess,
                                       DisplayName = t.DisplayName,
                                       ModuleDefID = t.ModuleDefID,
                                       PermissionCode = t.PermissionCode,
                                       PermissionID = t.PermissionID,
                                       PermissionKey = t.PermissionKey,
                                       PermissionName = t.PermissionName,
                                       RoleID = t.RoleID,
                                       RoleName = t.RoleName,
                                       TabID = -1,
                                       TabPermissionID = -1,
                                       UserID = t.UserID,
                                       Username = t.Username
                                   };
                    newTab.TabPermissions.Add(t);
                }
            }
            newTab.ParentId = parentTabId;
            newTab.PortalID = portalId;
            newTab.TabName = tabName;
            newTab.Title = tabName;
            newTab.IsVisible = includeInMenu;
            newTab.SkinSrc = "[G]Skins/DarkKnight/2-Column-Right-SocialProfile-Mega-Menu.ascx";
            id = tc.AddTab(newTab);
            tab = tc.GetTab(id, portalId, true);

            return tab;
        }
 public string GetTabPermissions(TabPermissionCollection tabPermissions, string permissionKey)
 {
     return(tabPermissions.ToString(permissionKey));
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasTabPermission checks whether the current user has a specific Tab 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="tabPermissions">The Permissions for the Tab</param>
 /// <param name="permissionKey">The Permission(s) to check</param>
 /// -----------------------------------------------------------------------------
 public static bool HasTabPermission(TabPermissionCollection tabPermissions, string permissionKey)
 {
     return(_provider.HasTabPermission(tabPermissions, permissionKey));
 }
Esempio n. 8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPage adds a Tab Page
        /// </summary>
        /// <remarks>
        /// Adds a Tab to a parentTab
        /// </remarks>
        ///	<param name="parentTab">The Parent Tab</param>
        ///	<param name="tabName">The Name to give this new Tab</param>
        /// <param name="description">Description.</param>
        ///	<param name="tabIconFile">The Icon for this new Tab</param>
        /// <param name="tabIconFileLarge">The Large Icon for this new Tab</param>
        ///	<param name="isVisible">A flag indicating whether the tab is visible</param>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        /// <param name="isAdmin">Is an admin page</param>
        /// <history>
        /// 	[cnurse]	11/11/2004	created 
        /// </history>
        /// -----------------------------------------------------------------------------
        private static TabInfo AddPage(TabInfo parentTab, string tabName, string description, string tabIconFile, string tabIconFileLarge, bool isVisible, TabPermissionCollection permissions, bool isAdmin)
        {
            int parentId = Null.NullInteger;
            int portalId = Null.NullInteger;

            if ((parentTab != null))
            {
                parentId = parentTab.TabID;
                portalId = parentTab.PortalID;
            }


            return AddPage(portalId, parentId, tabName, description, tabIconFile, tabIconFileLarge, isVisible, permissions, isAdmin);
        }
Esempio n. 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>
        /// <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 bool IsDeniedTabPermission(TabPermissionCollection tabPermissions, string permissionKey)
 {
     bool isDenied = Null.NullBoolean;
     if (permissionKey.Contains(","))
     {
         foreach (string permission in permissionKey.Split(','))
         {
             if (PortalSecurity.IsDenied(tabPermissions.ToString(permission)))
             {
                 isDenied = true;
                 break;
             }
         }
     }
     else
     {
         isDenied = PortalSecurity.IsDenied(tabPermissions.ToString(permissionKey));
     }
     return isDenied;
 }
Esempio n. 11
0
 /// <summary>
 /// Copies the permissions to children.
 /// </summary>
 /// <param name="parentTab">The parent tab.</param>
 /// <param name="newPermissions">The new permissions.</param>
 public static void CopyPermissionsToChildren(TabInfo parentTab, TabPermissionCollection newPermissions)
 {
     bool clearCache = Null.NullBoolean;
     List<TabInfo> childTabs =
         new TabController().GetTabsByPortal(parentTab.PortalID).DescendentsOf(parentTab.TabID);
     foreach (TabInfo tab in childTabs)
     {
         if (TabPermissionController.CanAdminPage(tab))
         {
             tab.TabPermissions.Clear();
             tab.TabPermissions.AddRange(newPermissions);
             TabPermissionController.SaveTabPermissions(tab);
             UpdateTabVersion(tab.TabID);
             clearCache = true;
         }
     }
     if (clearCache)
     {
         DataCache.ClearTabsCache(childTabs[0].PortalID);
     }
 }
Esempio n. 12
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasTabPermission checks whether the current user has a specific Tab Permission
 /// </summary>
 /// <param name="objTabPermissions">The Permissions for the Tab</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 ///     [cnurse]	04/15/2009   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public virtual bool HasTabPermission(TabPermissionCollection objTabPermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objTabPermissions.ToString(permissionKey)));
 }
Esempio n. 13
0
        public virtual bool IsTabPublic(TabPermissionCollection objTabPermissions)
        {
            string roles = objTabPermissions.ToString("VIEW");
            bool hasPublicRole = false;


            if ((roles != null))
            {
                // permissions strings are encoded with Deny permissions at the beginning and Grant permissions at the end for optimal performance
                foreach (string role in roles.Split(new[] { ';' }))
                {
                    if (!string.IsNullOrEmpty(role))
                    {
                        // Deny permission
                        if (role.StartsWith("!"))
                        {
                            string denyRole = role.Replace("!", "");
                            if ((denyRole == Globals.glbRoleUnauthUserName || denyRole == Globals.glbRoleAllUsersName))
                            {
                                hasPublicRole = false;
                                break;
                            }
                            // Grant permission
                        }
                        else
                        {
                            if ((role == Globals.glbRoleUnauthUserName || role == Globals.glbRoleAllUsersName))
                            {
                                hasPublicRole = true;
                                break;
                            }
                        }
                    }
                }
            }

            return hasPublicRole;
        }
 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;
 }
 public TabPermissionCollection GetTabPermissionsCollectionByTabID( ArrayList arrTabPermissions, int TabID )
 {
     TabPermissionCollection objTabPermissionCollection = new TabPermissionCollection( arrTabPermissions, TabID );
     return objTabPermissionCollection;
 }
 public string GetTabPermissions( TabPermissionCollection tabPermissions, string PermissionKey )
 {
     string strRoles = ";";
     foreach( TabPermissionInfo objTabPermission in tabPermissions )
     {
         if( objTabPermission.AllowAccess == true && objTabPermission.PermissionKey == PermissionKey )
         {
             strRoles += objTabPermission.RoleName + ";";
         }
     }
     return strRoles;
 }
Esempio n. 17
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;
        }
Esempio n. 18
0
        public void CopyPermissionsToChildren( ArrayList tabs, TabPermissionCollection newPermissions )
        {
            TabPermissionController objTabPermissionController = new TabPermissionController();

            foreach( TabInfo objTab in tabs )
            {
                TabPermissionCollection objCurrentTabPermissions = objTabPermissionController.GetTabPermissionsCollectionByTabID( objTab.TabID, objTab.PortalID );

                if( !( objCurrentTabPermissions.CompareTo( newPermissions ) ) )
                {
                    objTabPermissionController.DeleteTabPermissionsByTabID( objTab.TabID );

                    foreach( TabPermissionInfo objTabPermission in newPermissions )
                    {
                        if( objTabPermission.AllowAccess )
                        {
                            objTabPermission.TabID = objTab.TabID;
                            objTabPermissionController.AddTabPermission( objTabPermission );
                        }
                    }
                }
            }

            if( tabs.Count > 0 )
            {
                DataCache.ClearTabsCache( ( (TabInfo)( tabs[0] ) ).PortalID );
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasTabPermission checks whether the current user has a specific Tab Permission
 /// </summary>
 /// <param name="tabPermissions">The Permissions for the Tab</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// -----------------------------------------------------------------------------
 public virtual bool HasTabPermission(TabPermissionCollection tabPermissions, string permissionKey)
 {
     bool hasPermission = PortalSecurity.IsInRoles(tabPermissions.ToString("EDIT"));
     if (!hasPermission)
     {
         if (permissionKey.Contains(","))
         {
             foreach (string permission in permissionKey.Split(','))
             {
                 if (PortalSecurity.IsInRoles(tabPermissions.ToString(permission)))
                 {
                     hasPermission = true;
                     break;
                 }
             }
         }
         else
         {
             hasPermission = PortalSecurity.IsInRoles(tabPermissions.ToString(permissionKey));
         }
     }
     return hasPermission;
 }
		public string GetTabPermissions(TabPermissionCollection tabPermissions, string permissionKey)
		{
			return tabPermissions.ToString(permissionKey);
		}
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetTabPermissionsCallBack gets a Dictionary of TabPermissionCollections by
        /// Tab 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 GetTabPermissionsCallBack(CacheItemArgs cacheItemArgs)
        {
            var portalID = (int)cacheItemArgs.ParamList[0];
            var dic = new Dictionary<int, TabPermissionCollection>();

            if (portalID > -1)
            {
                IDataReader dr = dataProvider.GetTabPermissionsByPortal(portalID);
                try
                {
                    while (dr.Read())
                    {
                        //fill business object
                        var tabPermissionInfo = CBO.FillObject<TabPermissionInfo>(dr, false);

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

                            //Add Collection to Dictionary
                            dic.Add(tabPermissionInfo.TabID, collection);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Exceptions.LogException(exc);
                }
                finally
                {
                    //close datareader
                    CBO.CloseDataReader(dr, true);
                }
            }
            return dic;
        }
Esempio n. 22
0
 public void CopyPermissionsToChildren(ArrayList tabs, TabPermissionCollection newPermissions)
 {
     foreach (TabInfo tab in tabs)
     {
         tab.TabPermissions.Clear();
         tab.TabPermissions.AddRange(newPermissions);
         TabPermissionController.SaveTabPermissions(tab);
     }
     if (tabs.Count > 0)
     {
         DataCache.ClearTabsCache(((TabInfo)tabs[0]).PortalID);
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetTabPermissions gets a TabPermissionCollection
        /// </summary>
        /// <param name="tabId">The ID of the tab</param>
        /// <param name="portalId">The ID of the portal</param>
        /// -----------------------------------------------------------------------------
        public virtual TabPermissionCollection GetTabPermissions(int tabId, int portalId)
        {
            //Get the Portal TabPermission Dictionary
            Dictionary<int, TabPermissionCollection> dicTabPermissions = GetTabPermissions(portalId);

            //Get the Collection from the Dictionary
            TabPermissionCollection tabPermissions;
            bool bFound = dicTabPermissions.TryGetValue(tabId, out tabPermissions);
            if (!bFound)
            {
                //Return empty collection
                tabPermissions = new TabPermissionCollection();
            }
            return tabPermissions;
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasTabPermission checks whether the current user has a specific Tab 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="objTabPermissions">The Permissions for the Tab</param>
 /// <param name="permissionKey">The Permission(s) to check</param>
 /// <history>
 /// 	[cnurse]	01/15/2008   Documented
 /// 	[cnurse]	04/22/2009   Added multi-permisison support
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasTabPermission(TabPermissionCollection objTabPermissions, string permissionKey)
 {
     bool hasPermission = provider.HasTabPermission(objTabPermissions, "EDIT");
     if (!hasPermission)
     {
         if (permissionKey.Contains(","))
         {
             foreach (string permission in permissionKey.Split(','))
             {
                 if (provider.HasTabPermission(objTabPermissions, permission))
                 {
                     hasPermission = true;
                     break;
                 }
             }
         }
         else
         {
             hasPermission = provider.HasTabPermission(objTabPermissions, permissionKey);
         }
     }
     return hasPermission;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasTabPermission checks whether the current user has a specific Tab 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="tabPermissions">The Permissions for the Tab</param>
 /// <param name="permissionKey">The Permission(s) to check</param>
 /// -----------------------------------------------------------------------------
 public static bool HasTabPermission(TabPermissionCollection tabPermissions, string permissionKey)
 {
     return _provider.HasTabPermission(tabPermissions, permissionKey);
 }
        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 string GetTabPermissionsByTabID(ArrayList arrTabPermissions, int TabID, string PermissionKey)
		{
			//Create a Tab Permission Collection from the ArrayList
			TabPermissionCollection tabPermissions = new TabPermissionCollection(arrTabPermissions, TabID);

			//Return the permission string for permissions with specified TabId
			return tabPermissions.ToString(PermissionKey);
		}
Esempio n. 28
0
 public TabPermissionCollection(TabPermissionCollection tabPermissions)
 {
     AddRange(tabPermissions);
 }
Esempio n. 29
0
        ///-----------------------------------------------------------------------------
        ///<summary>
        ///  AddAdminPage adds an Admin Tab Page
        ///</summary>
        ///<param name = "portal">The Portal</param>
        ///<param name = "tabName">The Name to give this new Tab</param>
        ///<param name="description"></param>
        ///<param name = "tabIconFile">The Icon for this new Tab</param>
        ///<param name="tabIconFileLarge"></param>
        ///<param name = "isVisible">A flag indicating whether the tab is visible</param>
        ///<history>
        ///  [cnurse]	11/11/2004	created
        ///</history>
        ///-----------------------------------------------------------------------------
        public static TabInfo AddAdminPage(PortalInfo portal, string tabName, string description, string tabIconFile, string tabIconFileLarge, bool isVisible)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddAdminPage:" + tabName);
            TabInfo adminPage = TabController.Instance.GetTab(portal.AdminTabId, portal.PortalID, false);

            if ((adminPage != null))
            {
                var tabPermissionCollection = new TabPermissionCollection();
                AddPagePermission(tabPermissionCollection, "View", Convert.ToInt32(portal.AdministratorRoleId));
                AddPagePermission(tabPermissionCollection, "Edit", Convert.ToInt32(portal.AdministratorRoleId));
                return AddPage(adminPage, tabName, description, tabIconFile, tabIconFileLarge, isVisible, tabPermissionCollection, true);
            }
            return null;
        }
 public void AddRange(TabPermissionCollection tabPermissions)
 {
     foreach (TabPermissionInfo permission in tabPermissions)
     {
         Add(permission);
     }
 }
Esempio n. 31
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPage adds a Tab Page
        /// </summary>
        ///	<param name="portalId">The Id of the Portal</param>
        ///	<param name="parentId">The Id of the Parent Tab</param>
        ///	<param name="tabName">The Name to give this new Tab</param>
        /// <param name="description">Description.</param>
        ///	<param name="tabIconFile">The Icon for this new Tab</param>
        /// <param name="tabIconFileLarge">The large Icon for this new Tab</param>
        ///	<param name="isVisible">A flag indicating whether the tab is visible</param>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        /// <param name="isAdmin">Is and admin page</param>
        /// <history>
        /// 	[cnurse]	11/11/2004	created 
        /// </history>
        /// -----------------------------------------------------------------------------
        private static TabInfo AddPage(int portalId, int parentId, string tabName, string description, string tabIconFile, string tabIconFileLarge, bool isVisible, TabPermissionCollection permissions, bool isAdmin)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddPage:" + tabName);

            TabInfo tab = TabController.Instance.GetTabByName(tabName, portalId, parentId);

            if (tab == null || tab.ParentId != parentId)
            {
                tab = new TabInfo
                          {
                              TabID = Null.NullInteger,
                              PortalID = portalId,
                              TabName = tabName,
                              Title = "",
                              Description = description,
                              KeyWords = "",
                              IsVisible = isVisible,
                              DisableLink = false,
                              ParentId = parentId,
                              IconFile = tabIconFile,
                              IconFileLarge = tabIconFileLarge,
                              IsDeleted = false
                          };
                tab.TabID = TabController.Instance.AddTab(tab, !isAdmin);

                if (((permissions != null)))
                {
                    foreach (TabPermissionInfo tabPermission in permissions)
                    {
                        tab.TabPermissions.Add(tabPermission, true);
                    }
                    TabPermissionController.SaveTabPermissions(tab);
                }
            }
            return tab;
        }
 public bool CompareTo(TabPermissionCollection objTabPermissionCollection)
 {
     if (objTabPermissionCollection.Count != Count)
     {
         return false;
     }
     InnerList.Sort(new CompareTabPermissions());
     objTabPermissionCollection.InnerList.Sort(new CompareTabPermissions());
     for (int i = 0; i <= Count - 1; i++)
     {
         if (objTabPermissionCollection[i].TabPermissionID != this[i].TabPermissionID || objTabPermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return false;
         }
     }
     return true;
 }
Esempio n. 33
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddSearchResults adds a top level Hidden Search Results Page
        /// </summary>
        ///	<param name="moduleDefId">The Module Deinition Id for the Search Results Module</param>
        /// <history>
        /// 	[cnurse]	11/11/2004	created 
        /// </history>
        /// -----------------------------------------------------------------------------
        private static void AddSearchResults(int moduleDefId)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddSearchResults:" + moduleDefId);
            var portals = PortalController.Instance.GetPortals();
            int intPortal;

            //Add Page to Admin Menu of all configured Portals
            for (intPortal = 0; intPortal <= portals.Count - 1; intPortal++)
            {
                var tabPermissions = new TabPermissionCollection();

                var portal = (PortalInfo)portals[intPortal];

                AddPagePermission(tabPermissions, "View", Convert.ToInt32(Globals.glbRoleAllUsers));
                AddPagePermission(tabPermissions, "View", Convert.ToInt32(portal.AdministratorRoleId));
                AddPagePermission(tabPermissions, "Edit", Convert.ToInt32(portal.AdministratorRoleId));

                //Create New Page (or get existing one)
                var tab = AddPage(portal.PortalID, Null.NullInteger, "Search Results", "", "", "", false, tabPermissions, false);

                //Add Module To Page
                AddModuleToPage(tab, moduleDefId, "Search Results", "");
            }
        }
 public TabPermissionCollection(TabPermissionCollection tabPermissions)
 {
     AddRange(tabPermissions);
 }