Ejemplo n.º 1
0
 public static void DeserializePanes(XmlNode nodePanes, int PortalId, int TabId, PortalTemplateModuleAction mergeTabs, Hashtable hModules)
 {
     ModuleController objModules = new ModuleController();
     ModuleInfo objModule;
     Dictionary<int, ModuleInfo> dicModules = objModules.GetTabModules(TabId);
     if (mergeTabs == PortalTemplateModuleAction.Replace)
     {
         foreach (KeyValuePair<int, ModuleInfo> kvp in dicModules)
         {
             objModule = kvp.Value;
             objModules.DeleteTabModule(TabId, objModule.ModuleID, false);
         }
     }
     foreach (XmlNode nodePane in nodePanes.ChildNodes)
     {
         if (nodePane.SelectSingleNode("modules") != null)
         {
             foreach (XmlNode nodeModule in nodePane.SelectSingleNode("modules"))
             {
                 ModuleController.DeserializeModule(nodeModule, nodePane, PortalId, TabId, mergeTabs, hModules);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private static int RemoveModule(string DesktopModuleName, string TabName, int ParentId, bool TabRemove)
        {
            TabController objTabs = new TabController();
            ModuleController objModules = new ModuleController();
            TabInfo objTab = objTabs.GetTabByName(TabName, Null.NullInteger, ParentId);
            int intModuleDefId = 0;
            int intCount = 0;

            //Get the Modules on the Tab
            if (objTab != null)
            {
                foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(objTab.TabID))
                {
                    ModuleInfo objModule = kvp.Value;
                    if (objModule.DesktopModule.FriendlyName == DesktopModuleName)
                    {
                        //Delete the Module from the Modules list
                        objModules.DeleteTabModule(objModule.TabID, objModule.ModuleID, false);
                        intModuleDefId = objModule.ModuleDefID;
                    }
                    else
                    {
                        intCount += 1;
                    }
                }

                //If Tab has no modules optionally remove tab
                if (intCount == 0 & TabRemove)
                {
                    objTabs.DeleteTab(objTab.TabID, objTab.PortalID);
                }
            }

            return intModuleDefId;
        }
 public void ParseTemplate(int PortalId, string TemplatePath, string TemplateFile, int AdministratorId, PortalTemplateModuleAction mergeTabs, bool IsNewPortal)
 {
     XmlDocument xmlPortal = new XmlDocument();
     XmlNode node;
     try
     {
         xmlPortal.Load(TemplatePath + TemplateFile);
     }
     catch
     {
     }
     node = xmlPortal.SelectSingleNode("//portal/settings");
     if (node != null && IsNewPortal)
     {
         ParsePortalSettings(node, PortalId);
     }
     node = xmlPortal.SelectSingleNode("//portal/rolegroups");
     if (node != null)
     {
         ParseRoleGroups(node.CreateNavigator(), PortalId, AdministratorId);
     }
     node = xmlPortal.SelectSingleNode("//portal/roles");
     if (node != null)
     {
         ParseRoles(node.CreateNavigator(), PortalId, AdministratorId);
     }
     node = xmlPortal.SelectSingleNode("//portal/portalDesktopModules");
     if (node != null)
     {
         ParsePortalDesktopModules(node.CreateNavigator(), PortalId);
     }
     node = xmlPortal.SelectSingleNode("//portal/folders");
     if (node != null)
     {
         ParseFolders(node, PortalId);
     }
     var objController = new FolderController();
     if (objController.GetFolder(PortalId, "", false) == null)
     {
         int folderid = objController.AddFolder(PortalId, "", (int)Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem, true, false);
         AddFolderPermissions(PortalId, folderid);
     }
     if (objController.GetFolder(PortalId, "Templates/", false) == null)
     {
         int folderid = objController.AddFolder(PortalId, "Templates/", (int)Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem, true, false);
         AddFolderPermissions(PortalId, folderid);
     }
     // force creation of templates folder if not present on template
     if (objController.GetFolder(PortalId, "Users/", false) == null)
     {
         int folderid = objController.AddFolder(PortalId, "Users/", (int)Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem, true, false);
         AddFolderPermissions(PortalId, folderid);
     }
     if (mergeTabs == PortalTemplateModuleAction.Replace)
     {
         var objTabs = new TabController();
         TabInfo objTab;
         foreach (KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal(PortalId))
         {
             objTab = tabPair.Value;
             objTab.TabName = objTab.TabName + "_old";
             objTab.TabPath = Common.Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
             objTab.IsDeleted = true;
             objTabs.UpdateTab(objTab);
             var objModules = new ModuleController();
             ModuleInfo objModule;
             foreach (KeyValuePair<int, ModuleInfo> modulePair in objModules.GetTabModules(objTab.TabID))
             {
                 objModule = modulePair.Value;
                 objModules.DeleteTabModule(objModule.TabID, objModule.ModuleID, false);
             }
         }
     }
     node = xmlPortal.SelectSingleNode("//portal/tabs");
     if (node != null)
     {
         string version = xmlPortal.DocumentElement.GetAttribute("version");
         if (version != "5.0")
         {
             var xmlAdmin = new XmlDocument();
             try
             {
                 xmlAdmin.Load(TemplatePath + "admin.template");
             }
             catch
             {
             }
             XmlNode adminNode = xmlAdmin.SelectSingleNode("//portal/tabs");
             foreach (XmlNode adminTabNode in adminNode.ChildNodes)
             {
                 node.AppendChild(xmlPortal.ImportNode(adminTabNode, true));
             }
         }
         ParseTabs(node, PortalId, false, mergeTabs, IsNewPortal);
     }
 }