Пример #1
0
 public void AddRange(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     foreach (DesktopModulePermissionInfo permission in DesktopModulePermissions)
     {
         Add(permission);
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetDesktopModulePermissions gets a DesktopModulePermissionCollection
        /// </summary>
        /// <param name="portalDesktopModuleID">The ID of the DesktopModule</param>
        /// <history>
        ///     [cnurse]	01/15/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static DesktopModulePermissionCollection GetDesktopModulePermissions(int portalDesktopModuleID)
        {
            //Get the Tab DesktopModulePermission Dictionary
            Dictionary <int, DesktopModulePermissionCollection> dicDesktopModulePermissions = GetDesktopModulePermissions();

            //Get the Collection from the Dictionary
            DesktopModulePermissionCollection DesktopModulePermissions;
            bool bFound = dicDesktopModulePermissions.TryGetValue(portalDesktopModuleID, out DesktopModulePermissions);

            if (!bFound)
            {
                //Return empty collection
                DesktopModulePermissions = new DesktopModulePermissionCollection();
            }
            return(DesktopModulePermissions);
        }
Пример #3
0
 public bool CompareTo(DesktopModulePermissionCollection objDesktopModulePermissionCollection)
 {
     if (objDesktopModulePermissionCollection.Count != Count)
     {
         return(false);
     }
     InnerList.Sort(new CompareDesktopModulePermissions());
     objDesktopModulePermissionCollection.InnerList.Sort(new CompareDesktopModulePermissions());
     for (int i = 0; i <= Count - 1; i++)
     {
         if (objDesktopModulePermissionCollection[i].DesktopModulePermissionID != this[i].DesktopModulePermissionID || objDesktopModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return(false);
         }
     }
     return(true);
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// FillDesktopModulePermissionDictionary fills a Dictionary of DesktopModulePermissions from a
        /// dataReader
        /// </summary>
        /// <param name="dr">The IDataReader</param>
        /// <history>
        ///     [cnurse]	01/15/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private static Dictionary <int, DesktopModulePermissionCollection> FillDesktopModulePermissionDictionary(IDataReader dr)
        {
            var dic = new Dictionary <int, DesktopModulePermissionCollection>();

            try
            {
                while (dr.Read())
                {
                    //fill business object
                    var desktopModulePermissionInfo = CBO.FillObject <DesktopModulePermissionInfo>(dr, false);

                    //add DesktopModule Permission to dictionary
                    if (dic.ContainsKey(desktopModulePermissionInfo.PortalDesktopModuleID))
                    {
                        //Add DesktopModulePermission to DesktopModulePermission Collection already in dictionary for TabId
                        dic[desktopModulePermissionInfo.PortalDesktopModuleID].Add(desktopModulePermissionInfo);
                    }
                    else
                    {
                        //Create new DesktopModulePermission Collection for DesktopModulePermissionID
                        var collection = new DesktopModulePermissionCollection {
                            desktopModulePermissionInfo
                        };

                        //Add Collection to Dictionary
                        dic.Add(desktopModulePermissionInfo.PortalDesktopModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                CBO.CloseDataReader(dr, true);
            }
            return(dic);
        }
 public DesktopModulePermissionCollection(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     AddRange(DesktopModulePermissions);
 }
 public bool CompareTo(DesktopModulePermissionCollection objDesktopModulePermissionCollection)
 {
     if (objDesktopModulePermissionCollection.Count != Count)
     {
         return false;
     }
     InnerList.Sort(new CompareDesktopModulePermissions());
     objDesktopModulePermissionCollection.InnerList.Sort(new CompareDesktopModulePermissions());
     for (int i = 0; i <= Count - 1; i++)
     {
         if (objDesktopModulePermissionCollection[i].DesktopModulePermissionID != this[i].DesktopModulePermissionID || objDesktopModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return false;
         }
     }
     return true;
 }
 public void AddRange(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     foreach (DesktopModulePermissionInfo permission in DesktopModulePermissions)
     {
         Add(permission);
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// FillDesktopModulePermissionDictionary fills a Dictionary of DesktopModulePermissions from a
        /// dataReader
        /// </summary>
        /// <param name="dr">The IDataReader</param>
        /// <history>
        /// 	[cnurse]	01/15/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private static Dictionary<int, DesktopModulePermissionCollection> FillDesktopModulePermissionDictionary(IDataReader dr)
        {
            var dic = new Dictionary<int, DesktopModulePermissionCollection>();
            try
            {
                while (dr.Read())
                {
                    //fill business object
                    var desktopModulePermissionInfo = CBO.FillObject<DesktopModulePermissionInfo>(dr, false);

                    //add DesktopModule Permission to dictionary
                    if (dic.ContainsKey(desktopModulePermissionInfo.PortalDesktopModuleID))
                    {
                        //Add DesktopModulePermission to DesktopModulePermission Collection already in dictionary for TabId
                        dic[desktopModulePermissionInfo.PortalDesktopModuleID].Add(desktopModulePermissionInfo);
                    }
                    else
                    {
                        //Create new DesktopModulePermission Collection for DesktopModulePermissionID
                        var collection = new DesktopModulePermissionCollection {desktopModulePermissionInfo};

                        //Add Collection to Dictionary
                        dic.Add(desktopModulePermissionInfo.PortalDesktopModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
				//close datareader
                CBO.CloseDataReader(dr, true);
            }
            return dic;
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasDesktopModulePermission checks whether the current user has a specific DesktopModule Permission
 /// </summary>
 /// <param name="objDesktopModulePermissions">The Permissions for the DesktopModule</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 /// 	[cnurse]	01/15/2008   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return PortalSecurity.IsInRoles(objDesktopModulePermissions.ToString(permissionKey));
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetDesktopModulePermissions gets a DesktopModulePermissionCollection
        /// </summary>
        /// <param name="portalDesktopModuleID">The ID of the DesktopModule</param>
        /// <history>
        /// 	[cnurse]	01/15/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static DesktopModulePermissionCollection GetDesktopModulePermissions(int portalDesktopModuleID)
        {
            //Get the Tab DesktopModulePermission Dictionary
            Dictionary<int, DesktopModulePermissionCollection> dicDesktopModulePermissions = GetDesktopModulePermissions();

            //Get the Collection from the Dictionary
            DesktopModulePermissionCollection DesktopModulePermissions;
            bool bFound = dicDesktopModulePermissions.TryGetValue(portalDesktopModuleID, out DesktopModulePermissions);
            if (!bFound)
            {
                //Return empty collection
                DesktopModulePermissions = new DesktopModulePermissionCollection();
            }
            return DesktopModulePermissions;
        }
Пример #11
0
 public DesktopModulePermissionCollection(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     AddRange(DesktopModulePermissions);
 }
Пример #12
0
 private static void ParsePortalDesktopModules(XPathNavigator nav, int portalID)
 {
     string friendlyName = Null.NullString;
     DesktopModuleInfo desktopModule = null;
     foreach (XPathNavigator desktopModuleNav in nav.Select("portalDesktopModule"))
     {
         friendlyName = XmlUtils.GetNodeValue(desktopModuleNav, "friendlyname");
         if (!string.IsNullOrEmpty(friendlyName))
         {
             desktopModule = DesktopModuleController.GetDesktopModuleByFriendlyName(friendlyName);
             if (desktopModule != null)
             {
                 //Parse the permissions
                 DesktopModulePermissionCollection permissions = new DesktopModulePermissionCollection();
                 foreach (XPathNavigator permissionNav in
                     desktopModuleNav.Select("portalDesktopModulePermissions/portalDesktopModulePermission"))
                 {
                     string code = XmlUtils.GetNodeValue(permissionNav, "permissioncode");
                     string key = XmlUtils.GetNodeValue(permissionNav, "permissionkey");
                     DesktopModulePermissionInfo desktopModulePermission = null;
                     ArrayList arrPermissions = new PermissionController().GetPermissionByCodeAndKey(code, key);
                     if (arrPermissions.Count > 0)
                     {
                         PermissionInfo permission = arrPermissions[0] as PermissionInfo;
                         if (permission != null)
                         {
                             desktopModulePermission = new DesktopModulePermissionInfo(permission);
                         }
                     }
                     desktopModulePermission.AllowAccess = bool.Parse(XmlUtils.GetNodeValue(permissionNav, "allowaccess"));
                     string rolename = XmlUtils.GetNodeValue(permissionNav, "rolename");
                     if (!string.IsNullOrEmpty(rolename))
                     {
                         RoleInfo role = TestableRoleController.Instance.GetRole(portalID, r => r.RoleName == rolename);
                         if (role != null)
                         {
                             desktopModulePermission.RoleID = role.RoleID;
                         }
                     }
                     permissions.Add(desktopModulePermission);
                 }
                 DesktopModuleController.AddDesktopModuleToPortal(portalID, desktopModule, permissions, false);
             }
         }
     }
 }
Пример #13
0
        private static void UpgradeToVersion500()
        {
            ArrayList portals = PortalController.Instance.GetPortals();

            //Add Edit Permissions for Admin Tabs to legacy portals
            var permissionController = new PermissionController();
            ArrayList permissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT");
            int permissionId = -1;
            if (permissions.Count == 1)
            {
                var permission = permissions[0] as PermissionInfo;
                if (permission != null)
                {
                    permissionId = permission.PermissionID;
                }

                foreach (PortalInfo portal in portals)
                {
                    var adminTab = TabController.Instance.GetTab(portal.AdminTabId, portal.PortalID, true);
                    if (adminTab != null)
                    {
                        var tabPermission = new TabPermissionInfo { TabID = adminTab.TabID, PermissionID = permissionId, AllowAccess = true, RoleID = portal.AdministratorRoleId };
                        if (!TabPermissionExists(tabPermission, portal.PortalID))
                        {
                            adminTab.TabPermissions.Add(tabPermission);
                        }

                        //Save Tab Permissions to Data Base
                        TabPermissionController.SaveTabPermissions(adminTab);

                        foreach (var childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID))
                        {
                            tabPermission = new TabPermissionInfo { TabID = childTab.TabID, PermissionID = permissionId, AllowAccess = true, RoleID = portal.AdministratorRoleId };
                            if (!TabPermissionExists(tabPermission, portal.PortalID))
                            {
                                childTab.TabPermissions.Add(tabPermission);
                            }
                            //Save Tab Permissions to Data Base
                            TabPermissionController.SaveTabPermissions(childTab);
                        }
                    }
                }
            }

            //Update Host/Admin modules Visibility setting
            bool superTabProcessed = Null.NullBoolean;
            foreach (PortalInfo portal in portals)
            {
                if (!superTabProcessed)
                {
                    //Process Host Tabs
                    foreach (TabInfo childTab in TabController.GetTabsByParent(portal.SuperTabId, Null.NullInteger))
                    {
                        foreach (ModuleInfo tabModule in ModuleController.Instance.GetTabModules(childTab.TabID).Values)
                        {
                            tabModule.Visibility = VisibilityState.None;
                            ModuleController.Instance.UpdateModule(tabModule);
                        }
                    }
                }

                //Process Portal Tabs
                foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID))
                {
                    foreach (ModuleInfo tabModule in ModuleController.Instance.GetTabModules(childTab.TabID).Values)
                    {
                        tabModule.Visibility = VisibilityState.None;
                        ModuleController.Instance.UpdateModule(tabModule);
                    }
                }
            }

            //Upgrade PortalDesktopModules to support new "model"
            permissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY");
            if (permissions.Count == 1)
            {
                var permission = permissions[0] as PermissionInfo;
                if (permission != null)
                {
                    permissionId = permission.PermissionID;
                }
                foreach (PortalInfo portal in portals)
                {
                    foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
                    {
                        if (!desktopModule.IsPremium)
                        {
                            //Parse the permissions
                            var deployPermissions = new DesktopModulePermissionCollection();
                            DesktopModulePermissionInfo deployPermission;

                            // if Not IsAdmin add Registered Users
                            if (!desktopModule.IsAdmin)
                            {
                                deployPermission = new DesktopModulePermissionInfo { PermissionID = permissionId, AllowAccess = true, RoleID = portal.RegisteredRoleId };
                                deployPermissions.Add(deployPermission);
                            }

                            // if Not a Host Module add Administrators
                            const string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                            if (!hostModules.Contains(desktopModule.ModuleName))
                            {
                                deployPermission = new DesktopModulePermissionInfo { PermissionID = permissionId, AllowAccess = true, RoleID = portal.AdministratorRoleId };
                                deployPermissions.Add(deployPermission);
                            }

                            //Add Portal/Module to PortalDesktopModules
                            DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, false);
                        }
                    }

                    DataCache.ClearPortalCache(portal.PortalID, true);
                }
            }

            LegacyUtil.ProcessLegacyModules();
            LegacyUtil.ProcessLegacyLanguages();
            LegacyUtil.ProcessLegacySkins();
            LegacyUtil.ProcessLegacySkinControls();
        }
Пример #14
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasDesktopModulePermission checks whether the current user has a specific DesktopModule Permission
 /// </summary>
 /// <param name="desktopModulePermissions">The Permissions for the DesktopModule</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 /// 	[cnurse]	01/15/2008   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public virtual bool HasDesktopModulePermission(DesktopModulePermissionCollection desktopModulePermissions, string permissionKey)
 {
     return PortalSecurity.IsInRoles(desktopModulePermissions.ToString(permissionKey));
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasDesktopModulePermission checks whether the current user has a specific DesktopModule Permission
 /// </summary>
 /// <param name="objDesktopModulePermissions">The Permissions for the DesktopModule</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// -----------------------------------------------------------------------------
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return(_provider.HasDesktopModulePermission(objDesktopModulePermissions, permissionKey));
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasDesktopModulePermission checks whether the current user has a specific DesktopModule Permission
 /// </summary>
 /// <param name="objDesktopModulePermissions">The Permissions for the DesktopModule</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 ///     [cnurse]	01/15/2008   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objDesktopModulePermissions.ToString(permissionKey)));
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasDesktopModulePermission checks whether the current user has a specific DesktopModule Permission
 /// </summary>
 /// <param name="objDesktopModulePermissions">The Permissions for the DesktopModule</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 /// 	[cnurse]	01/15/2008   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return _provider.HasDesktopModulePermission(objDesktopModulePermissions, permissionKey);
 }
Пример #18
0
        private static void UpgradeToVersion601()
        {
            //List module needs to be available to Portals also
            var pkg = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == "DotNetNuke.Lists");
            if (pkg != null)
            {
                //List package is no longer a system package
                pkg.IsSystemPackage = false;
                PackageController.Instance.SaveExtensionPackage(pkg);

                //List desktop module is no longer premium or admin module
                var desktopModule = DesktopModuleController.GetDesktopModuleByPackageID(pkg.PackageID);
                desktopModule.IsAdmin = false;
                desktopModule.IsPremium = false;
                DesktopModuleController.SaveDesktopModule(desktopModule, false, true);

                var permissionController = new PermissionController();
                ArrayList permissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY");
                if (permissions.Count == 1)
                {
                    var permission = permissions[0] as PermissionInfo;
                    if (permission != null)
                    {
                        foreach (PortalInfo portal in PortalController.Instance.GetPortals())
                        {
                            //ensure desktop module is not present in the portal
                            var pdmi = DesktopModuleController.GetPortalDesktopModule(portal.PortalID, desktopModule.DesktopModuleID);
                            if (pdmi == null)
                            {
                                //Parse the permissions
                                var deployPermissions = new DesktopModulePermissionCollection();
                                var deployPermission = new DesktopModulePermissionInfo { PermissionID = permission.PermissionID, AllowAccess = true, RoleID = portal.AdministratorRoleId };
                                deployPermissions.Add(deployPermission);

                                //Add Portal/Module to PortalDesktopModules
                                DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, true);
                            }
                        }
                    }
                }
            }
        }
Пример #19
0
 public static int AddDesktopModuleToPortal(int portalID, DesktopModuleInfo desktopModule, DesktopModulePermissionCollection permissions, bool clearCache)
 {
     int portalDesktopModuleID = AddDesktopModuleToPortal(portalID, desktopModule.DesktopModuleID, false, clearCache);
     if (portalDesktopModuleID > Null.NullInteger)
     {
         DesktopModulePermissionController.DeleteDesktopModulePermissionsByPortalDesktopModuleID(portalDesktopModuleID);
         foreach (DesktopModulePermissionInfo permission in permissions)
         {
             permission.PortalDesktopModuleID = portalDesktopModuleID;
             DesktopModulePermissionController.AddDesktopModulePermission(permission);
         }
     }
     return portalDesktopModuleID;
 }