/// <summary> /// SaveTabData saves the Tab to the Database /// </summary> /// <param name="action">The action to perform "edit" or "add"</param> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> public int SaveTabData(string action) { EventLogController objEventLog = new EventLogController(); string strIcon = ctlIcon.Url; TabController objTabs = new TabController(); TabInfo objTab = new TabInfo(); objTab.TabID = TabId; objTab.PortalID = PortalId; objTab.TabName = txtTabName.Text; objTab.Title = txtTitle.Text; objTab.Description = txtDescription.Text; objTab.KeyWords = txtKeyWords.Text; objTab.IsVisible = !chkHidden.Checked; objTab.DisableLink = chkDisableLink.Checked; objTab.ParentId = int.Parse(cboTab.SelectedItem.Value); objTab.IconFile = strIcon; objTab.IsDeleted = false; objTab.Url = ctlURL.Url; objTab.TabPermissions = dgPermissions.Permissions; objTab.SkinSrc = ctlSkin.SkinSrc; objTab.ContainerSrc = ctlContainer.SkinSrc; objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName); if (!String.IsNullOrEmpty(txtStartDate.Text)) { objTab.StartDate = Convert.ToDateTime(txtStartDate.Text); } else { objTab.StartDate = Null.NullDate; } if (!String.IsNullOrEmpty(txtEndDate.Text)) { objTab.EndDate = Convert.ToDateTime(txtEndDate.Text); } else { objTab.EndDate = Null.NullDate; } int refreshInt; if (txtRefreshInterval.Text.Length > 0 && Int32.TryParse(txtRefreshInterval.Text, out refreshInt)) { objTab.RefreshInterval = Convert.ToInt32(txtRefreshInterval.Text); } objTab.PageHeadText = txtPageHeadText.Text; if (action == "edit") { // trap circular tab reference if (objTab.TabID != int.Parse(cboTab.SelectedItem.Value) && !IsCircularReference(int.Parse(cboTab.SelectedItem.Value))) { objTabs.UpdateTab(objTab); objEventLog.AddLog(objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_UPDATED); } } else // add or copy { objTab.TabID = objTabs.AddTab(objTab); objEventLog.AddLog(objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_CREATED); if (int.Parse(cboCopyPage.SelectedItem.Value) != -1) { ModuleController objModules = new ModuleController(); foreach (DataGridItem objDataGridItem in grdModules.Items) { CheckBox chkModule = (CheckBox)objDataGridItem.FindControl("chkModule"); if (chkModule.Checked) { int intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]); //RadioButton optNew = (RadioButton)objDataGridItem.FindControl( "optNew" ); RadioButton optCopy = (RadioButton)objDataGridItem.FindControl("optCopy"); RadioButton optReference = (RadioButton)objDataGridItem.FindControl("optReference"); TextBox txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle"); ModuleInfo objModule = objModules.GetModule(intModuleID, Int32.Parse(cboCopyPage.SelectedItem.Value), false); if (objModule != null) { if (!optReference.Checked) { objModule.ModuleID = Null.NullInteger; } objModule.TabID = objTab.TabID; objModule.ModuleTitle = txtCopyTitle.Text; objModule.ModuleID = objModules.AddModule(objModule); if (optCopy.Checked) { if (!String.IsNullOrEmpty(objModule.BusinessControllerClass)) { object objObject = Reflection.CreateObject(objModule.BusinessControllerClass, objModule.BusinessControllerClass); if (objObject is IPortable) { try { string Content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID)); if (!String.IsNullOrEmpty(Content)) { ((IPortable)objObject).ImportModule(objModule.ModuleID, Content, objModule.Version, UserInfo.UserID); } } catch (Exception exc) { // the export/import operation failed Exceptions.ProcessModuleLoadException(this, exc); } } } } } } } } else { // create the page from a template if (cboTemplate.SelectedItem != null) { if (!String.IsNullOrEmpty(cboTemplate.SelectedItem.Value)) { // open the XML file try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(cboTemplate.SelectedItem.Value); PortalController objPortals = new PortalController(); objPortals.ParsePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), objTab.PortalID, objTab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable()); } catch { // error opening page template } } } } } // url tracking UrlController objUrls = new UrlController(); objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow); return(objTab.TabID); }