protected void CmdUpdateClick(object sender, EventArgs e)
        {
            //Often times grid stays but node is not selected (e.g. when node is deleted or update page is clicked)
            if (ctlPages.SelectedNode == null)
                return;

            var intTab = Convert.ToInt32(ctlPages.SelectedNode.Value);
            var tabcontroller = new TabController();
            var tab = tabcontroller.GetTab(intTab, PortalId, true);
            this.Page.Validate();
            if (!this.Page.IsValid)
                return;
            if (tab != null && TabPermissionController.CanManagePage(tab))
            {
                tab.TabName = txtName.Text;
                tab.Title = txtTitle.Text;
                tab.Description = txtDescription.Text;
                tab.KeyWords = txtKeywords.Text;
                tab.IsVisible = chkVisible.Checked;
                tab.DisableLink = chkDisabled.Checked;

                tab.IsDeleted = false;
                tab.Url = ctlURL.Url;
                tabcontroller.UpdateTabSetting(tab.TabID, "LinkNewWindow", ctlURL.NewWindow.ToString());
                tabcontroller.UpdateTabSetting(tab.TabID, "AllowIndex", chkAllowIndex.Checked.ToString());

                tab.SkinSrc = drpSkin.SelectedValue;
                tab.ContainerSrc = drpContainer.SelectedValue;
                tab.TabPath = Globals.GenerateTabPath(tab.ParentId, tab.TabName);

                tab.TabPermissions.Clear();
                if (tab.PortalID != Null.NullInteger)
                {
                    tab.TabPermissions.AddRange(dgPermissions.Permissions);
                }

                //All validations have been done in the Page.Validate()

                //Check for invalid
                if (!IsValidTabName(tab.TabName))
                {
                    return;
                }

                //Validate Tab Path
                if (!IsValidTabPath(tab, tab.TabPath))
                {
                    return;
                }

                tab.RefreshInterval = txtRefresh.Text == "" ? Null.NullInteger : Convert.ToInt32(txtRefresh.Text);

                tab.SiteMapPriority = float.Parse(txtSitemapPriority.Text);
                tab.PageHeadText = txtMeta.Text;
                tab.IsSecure = chkSecure.Checked;
                tab.PermanentRedirect = chkPermanentRedirect.Checked;

                var iconFile = ctlIcon.Url;
                var iconFileLarge = ctlIconLarge.Url;

                tab.IconFile = iconFile;
                tab.IconFileLarge = iconFileLarge;

                tab.Terms.Clear();
                tab.Terms.AddRange(termsSelector.Terms);

                tabcontroller.UpdateTab(tab);
                ShowSuccessMessage(string.Format(Localization.GetString("TabUpdated", LocalResourceFile), tab.TabName));

                BindTree();

                //keep the tab selected
                SelectedNode = intTab.ToString(CultureInfo.InvariantCulture);
                ctlPages.FindNodeByValue(SelectedNode).Selected = true;
                ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes();
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   UpdateWorkFlow updates the currently active Workflow
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="WorkFlowType">The type of workflow (Module | Page | Site)</param>
        /// <param name = "WorkflowID">The ID of the Workflow</param>
        /// <param name="ObjectID">The ID of the object to apply the update to (depends on WorkFlowType)</param>
        /// <param name="ReplaceExistingSettings">Should existing settings be overwritten?</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateWorkflow(int ObjectID, string WorkFlowType, int WorkflowID, bool ReplaceExistingSettings)
        {
            var tabController = new TabController();
            var moduleController = new ModuleController();

            switch (WorkFlowType)
            {
                case "Module":
                    moduleController.UpdateModuleSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                    break;
                case "Page":
                    tabController.UpdateTabSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                    if (ReplaceExistingSettings)
                    {
                        //Get All Modules on the current Tab
                        foreach (var kvp in moduleController.GetTabModules(ObjectID))
                        {
                            ClearModuleSettings(kvp.Value);
                        }
                    }
                    break;
                case "Site":
                    PortalController.UpdatePortalSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                    if (ReplaceExistingSettings)
                    {
                        //Get All Tabs aon the Site
                        foreach (var kvp in tabController.GetTabsByPortal(ObjectID))
                        {
                            tabController.DeleteTabSetting(kvp.Value.TabID, "WorkFlowID");
                        }
                        //Get All Modules in the current Site
                        foreach (ModuleInfo objModule in moduleController.GetModules(ObjectID))
                        {
                            ClearModuleSettings(objModule);
                        }
                    }
                    break;
            }
        }
 private void UpdateTabSettings(int tabId)
 {
     var t = new TabController();
     t.UpdateTabSetting(tabId, "CacheProvider", cboCacheProvider.SelectedValue);
     t.UpdateTabSetting(tabId, "CacheDuration", txtCacheDuration.Text);
     t.UpdateTabSetting(tabId, "CacheIncludeExclude", rblCacheIncludeExclude.SelectedValue);
     t.UpdateTabSetting(tabId, "IncludeVaryBy", txtIncludeVaryBy.Text);
     t.UpdateTabSetting(tabId, "ExcludeVaryBy", txtExcludeVaryBy.Text);
     t.UpdateTabSetting(tabId, "MaxVaryByCount", txtMaxVaryByCount.Text);
 }
Exemple #4
0
		private static void CopyGettingStartedStyles()
		{
			//copy getting started css to portals folder.
			var hostGettingStartedFile = string.Format("{0}GettingStarted.css", Globals.HostMapPath);
			var tabController = new TabController();
			foreach (PortalInfo portal in new PortalController().GetPortals())
			{

				if (File.Exists(hostGettingStartedFile))
				{
					var portalFile = portal.HomeDirectoryMapPath + "GettingStarted.css";
					if (!File.Exists(portalFile))
					{
						File.Copy(hostGettingStartedFile, portalFile);
					}
				}

				//update the getting started page to have this custom style sheet.
				var gettingStartedTabId = PortalController.GetPortalSettingAsInteger("GettingStartedTabId", portal.PortalID, Null.NullInteger);
				if (gettingStartedTabId > Null.NullInteger)
				{
                    // check if tab exists
				    if (tabController.GetTab(gettingStartedTabId, portal.PortalID, true) != null)
				    {
				        tabController.UpdateTabSetting(gettingStartedTabId, "CustomStylesheet", "GettingStarted.css");
				    }
				}
			}
		}
Exemple #5
0
        //todo: Settings
        //Public Function SaveTabInfoObject(ByVal newTab As DotNetNuke.Entities.Tabs.TabInfo, ByVal relativeToTab As DotNetNuke.Entities.Tabs.TabInfo, ByVal location As TabRelativeLocation, ByVal templateMapPath As String, ByVal tabSettings As Hashtable) As Integer
        public static int SaveTabInfoObject(TabInfo tab, TabInfo relativeToTab, TabRelativeLocation location, string templateMapPath)
        {
            TabController tabCtrl = new TabController();

            //Validation:
            //Tab name is required
            //Tab name is invalid
            if ((tab.TabName == string.Empty))
            {
                throw new DotNetNukeException("Page name is required.", DotNetNukeErrorCode.PageNameRequired);
            }
            else if ((Regex.IsMatch(tab.TabName, "^LPT[1-9]$|^COM[1-9]$", RegexOptions.IgnoreCase)))
            {
                throw new DotNetNukeException("Page name is invalid.", DotNetNukeErrorCode.PageNameInvalid);
            }
            else if ((Regex.IsMatch(HtmlUtils.StripNonWord(tab.TabName, false), "^AUX$|^CON$|^NUL$|^SITEMAP$|^LINKCLICK$|^KEEPALIVE$|^DEFAULT$|^ERRORPAGE$", RegexOptions.IgnoreCase)))
            {
                throw new DotNetNukeException("Page name is invalid.", DotNetNukeErrorCode.PageNameInvalid);
            }
            else if ((Validate_IsCircularReference(tab.PortalID, tab.TabID)))
            {
                throw new DotNetNukeException("Cannot move page to that location.", DotNetNukeErrorCode.PageCircularReference);
            }

            bool usingDefaultLanguage = (tab.CultureCode == PortalSettings.Current.DefaultLanguage) || tab.CultureCode == null;

            if (PortalSettings.Current.ContentLocalizationEnabled)
            {
                if ((!usingDefaultLanguage))
                {
                    TabInfo defaultLanguageSelectedTab = tab.DefaultLanguageTab;

                    if ((defaultLanguageSelectedTab == null))
                    {
                        //get the siblings from the selectedtab and iterate through until you find a sibbling with a corresponding defaultlanguagetab
                        //if none are found get a list of all the tabs from the default language and then select the last one
                        var selectedTabSibblings = tabCtrl.GetTabsByPortal(tab.PortalID).WithCulture(tab.CultureCode, true).AsList();
                        foreach (TabInfo sibling in selectedTabSibblings)
                        {
                            TabInfo siblingDefaultTab = sibling.DefaultLanguageTab;
                            if (((siblingDefaultTab != null)))
                            {
                                defaultLanguageSelectedTab = siblingDefaultTab;
                                break;
                            }
                        }

                        //still haven't found it
                        if ((defaultLanguageSelectedTab == null))
                        {
                            var defaultLanguageTabs = tabCtrl.GetTabsByPortal(tab.PortalID).WithCulture(PortalSettings.Current.DefaultLanguage, true).AsList();
                            defaultLanguageSelectedTab = defaultLanguageTabs[defaultLanguageTabs.Count];
                            //get the last tab
                        }
                    }

                    relativeToTab = defaultLanguageSelectedTab;
                }
            }


            if ((location != TabRelativeLocation.NOTSET))
            {
                //Check Host tab - don't allow adding before or after
                if ((IsHostConsolePage(relativeToTab) && (location == TabRelativeLocation.AFTER || location == TabRelativeLocation.BEFORE)))
                {
                    throw new DotNetNukeException("You cannot add or move pages before or after the Host tab.", DotNetNukeErrorCode.HostBeforeAfterError);
                }

                TabInfo parentTab = GetParentTab(relativeToTab, location);
                string permissionList = "ADD,COPY,EDIT,MANAGE";
                //Check permissions for Page Editors when moving or inserting
                if ((!PortalSecurity.IsInRole("Administrators")))
                {
                    if (((parentTab == null) || !TabPermissionController.HasTabPermission(parentTab.TabPermissions, permissionList)))
                    {
                        throw new DotNetNukeException("You do not have permissions to add or move pages to this location. You can only add or move pages as children of pages you can edit.",
                                                      DotNetNukeErrorCode.PageEditorPermissionError);
                    }
                }

                if (((parentTab != null)))
                {
                    tab.ParentId = parentTab.TabID;
                    tab.Level = parentTab.Level + 1;
                }
                else
                {
                    tab.ParentId = Null.NullInteger;
                    tab.Level = 0;
                }
            }

            if ((tab.TabID > Null.NullInteger && tab.TabID == tab.ParentId))
            {
                throw new DotNetNukeException("Parent page is invalid.", DotNetNukeErrorCode.ParentTabInvalid);
            }

            tab.TabPath = Globals.GenerateTabPath(tab.ParentId, tab.TabName);
            //check whether have conflict between tab path and portal alias.
            if(TabController.IsDuplicateWithPortalAlias(PortalSettings.Current.PortalId, tab.TabPath))
            {
                throw new DotNetNukeException("The page path is duplicate with a site alias", DotNetNukeErrorCode.DuplicateWithAlias);
            }

            try
            {
                if ((tab.TabID < 0))
                {
                    if ((tab.TabPermissions.Count == 0 && tab.PortalID != Null.NullInteger))
                    {
                        //Give admin full permission
                        ArrayList permissions = PermissionController.GetPermissionsByTab();

                        foreach (PermissionInfo permission in permissions)
                        {
                            TabPermissionInfo newTabPermission = new TabPermissionInfo();
                            newTabPermission.PermissionID = permission.PermissionID;
                            newTabPermission.PermissionKey = permission.PermissionKey;
                            newTabPermission.PermissionName = permission.PermissionName;
                            newTabPermission.AllowAccess = true;
                            newTabPermission.RoleID = PortalSettings.Current.AdministratorRoleId;
                            tab.TabPermissions.Add(newTabPermission);
                        }
                    }

                    PortalSettings _PortalSettings = PortalController.GetCurrentPortalSettings();

                    if (_PortalSettings.ContentLocalizationEnabled)
                    {
                        Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(tab.PortalID);
                        tab.CultureCode = defaultLocale.Code;
                    }
                    else
                    {
                        tab.CultureCode = Null.NullString;
                    }

                    if ((location == TabRelativeLocation.AFTER && (relativeToTab != null)))
                    {
                        tab.TabID = tabCtrl.AddTabAfter(tab, relativeToTab.TabID);
                    }
                    else if ((location == TabRelativeLocation.BEFORE && (relativeToTab != null)))
                    {
                        tab.TabID = tabCtrl.AddTabBefore(tab, relativeToTab.TabID);
                    }
                    else
                    {
                        tab.TabID = tabCtrl.AddTab(tab);
                    }

                    if (_PortalSettings.ContentLocalizationEnabled)
                    {
                        tabCtrl.CreateLocalizedCopies(tab);
                    }

                    tabCtrl.UpdateTabSetting(tab.TabID, "CacheProvider", "");
                    tabCtrl.UpdateTabSetting(tab.TabID, "CacheDuration", "");
                    tabCtrl.UpdateTabSetting(tab.TabID, "CacheIncludeExclude", "0");
                    tabCtrl.UpdateTabSetting(tab.TabID, "IncludeVaryBy", "");
                    tabCtrl.UpdateTabSetting(tab.TabID, "ExcludeVaryBy", "");
                    tabCtrl.UpdateTabSetting(tab.TabID, "MaxVaryByCount", "");
                }
                else
                {
                    tabCtrl.UpdateTab(tab);

                    if ((location == TabRelativeLocation.AFTER && (relativeToTab != null)))
                    {
                        tabCtrl.MoveTabAfter(tab, relativeToTab.TabID);
                    }
                    else if ((location == TabRelativeLocation.BEFORE && (relativeToTab != null)))
                    {
                        tabCtrl.MoveTabBefore(tab, relativeToTab.TabID);
                    }
                }
            }
            catch (Exception ex)
            {
                DnnLog.Error(ex);

                if (ex.Message.StartsWith("Page Exists"))
                {
                    throw new DotNetNukeException(ex.Message, DotNetNukeErrorCode.PageExists);
                }
            }

            // create the page from a template
            if ((!string.IsNullOrEmpty(templateMapPath)))
            {
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    xmlDoc.Load(templateMapPath);
                    TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), tab.PortalID, tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable());
                    
                    //save tab permissions
                    DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), tab);
                }
                catch (Exception ex)
                {
                    Exceptions.LogException(ex);
                    throw new DotNetNukeException("Unable to process page template.", ex, DotNetNukeErrorCode.DeserializePanesFailed);
                }
            }

            //todo: reload tab from db or send back tabid instead?
            return tab.TabID;
        }
 private void UpdateTabSettings(int tabId)
 {
     var t = new TabController();
     t.UpdateTabSetting(tabId, "CacheProvider", cboCacheProvider.SelectedValue);
     t.UpdateTabSetting(tabId, "CacheDuration", txtCacheDuration.Text);
     t.UpdateTabSetting(tabId, "CacheIncludeExclude", rblCacheIncludeExclude.SelectedValue);
     t.UpdateTabSetting(tabId, "IncludeVaryBy", txtIncludeVaryBy.Text);
     t.UpdateTabSetting(tabId, "ExcludeVaryBy", txtExcludeVaryBy.Text);
     t.UpdateTabSetting(tabId, "MaxVaryByCount", txtMaxVaryByCount.Text);
     t.UpdateTabSetting(tabId, "LinkNewWindow", ctlURL.NewWindow.ToString());
     t.UpdateTabSetting(tabId, "AllowIndex", chkAllowIndex.Checked.ToString());
 }