예제 #1
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();
        }
예제 #2
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);
                            }
                        }
                    }
                }
            }
        }
예제 #3
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);
             }
         }
     }
 }