private void BindModules() { DotNetNuke.Entities.Modules.ModuleController mc = new ModuleController(); ArrayList existMods = mc.GetModulesByDefinition(this.PortalId, "GIBS - FlexMLS"); foreach (DotNetNuke.Entities.Modules.ModuleInfo mi in existMods) { if (!mi.IsDeleted) { DotNetNuke.Entities.Tabs.TabController tabController = new DotNetNuke.Entities.Tabs.TabController(); DotNetNuke.Entities.Tabs.TabInfo tabInfo = tabController.GetTab(mi.TabID, this.PortalId); string strPath = tabInfo.TabName.ToString(); ListItem objListItem = new ListItem(); objListItem.Value = mi.TabID.ToString(); // TabID & ModuleID + "-" + mi.ModuleID.ToString() objListItem.Text = strPath + " -> " + mi.ModuleTitle.ToString(); ddlViewListing.Items.Add(objListItem); } } ddlViewListing.Items.Insert(0, new ListItem(Localization.GetString("SelectModule", this.LocalResourceFile), "-1")); }
public override void LoadSettings() { try { if (!Page.IsPostBack) { TabController tabCtrl = new TabController(); var currentTab = tabCtrl.GetTab(TabId, PortalId, true); foreach (var module in currentTab.ChildModules) { var modInfo = module.Value as ModuleInfo; if (modInfo.ModuleDefinition.DefinitionName == "QuickDocsPro") { ddlQDPModule.Items.Add(new ListItem(modInfo.ModuleControl.ControlTitle, modInfo.ModuleID.ToString())); } } if ((string)TabModuleSettings["QDPModule"] != null) { ddlQDPModule.Items.FindByValue((string)TabModuleSettings["QDPModule"].ToString()).Selected = true; } } } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
private void BindData() { using (var dt = new DataTable()) { dt.Columns.Add(new DataColumn("TabId", typeof (Int32))); dt.Columns.Add(new DataColumn("ContentKey", typeof (String))); dt.Columns.Add(new DataColumn("Title", typeof (String))); dt.Columns.Add(new DataColumn("Description", typeof (String))); dt.Columns.Add(new DataColumn("PubDate", typeof (DateTime))); var results = new ContentController().GetContentItemsByTerm(_tagQuery).ToList(); var tabController = new TabController(); if (_tagQuery.Length > 0) { foreach (var item in results) { var dr = dt.NewRow(); dr["TabId"] = item.TabID; dr["ContentKey"] = item.ContentKey; dr["Title"] = item.Content; //get tab info and use the tab description, if tab is deleted then ignore the item. var tab = tabController.GetTab(item.TabID, PortalId, false); if(tab != null) { if (tab.IsDeleted) { continue; } dr["Title"] = string.IsNullOrEmpty(tab.Title) ? tab.TabName : tab.Title; dr["Description"] = tab.Description; } else { dr["Description"] = item.Content.Length > 1000 ? item.Content.Substring(0, 1000) : item.Content; } dr["PubDate"] = item.CreatedOnDate; dt.Rows.Add(dr); } } //Bind Search Results Grid var dv = new DataView(dt); dgResults.DataSource = dv; dgResults.DataBind(); if (results.Count == 0) { dgResults.Visible = false; lblMessage.Text = string.Format(Localization.GetString("NoResults", LocalResourceFile), _tagQuery); } else { lblMessage.Text = string.Format(Localization.GetString("Results", LocalResourceFile), _tagQuery); } } }
//This method is copied from user skin object private int FindMessageTab() { var tabController = new TabController(); var moduleController = new ModuleController(); //On brand new install the new Message Center Module is on the child page of User Profile Page //On Upgrade to 6.2.0, the Message Center module is on the User Profile Page var profileTab = tabController.GetTab(PortalSettings.UserTabId, PortalSettings.PortalId, false); if (profileTab != null) { var childTabs = tabController.GetTabsByPortal(profileTab.PortalID).DescendentsOf(profileTab.TabID); foreach (TabInfo tab in childTabs) { foreach (KeyValuePair<int, ModuleInfo> kvp in moduleController.GetTabModules(tab.TabID)) { var module = kvp.Value; if (module.DesktopModule.FriendlyName == "Message Center") { return tab.TabID; } } } } //default to User Profile Page return PortalSettings.UserTabId; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var controller = new TabController(); lblHomePage.Text = controller.GetTab(ModuleContext.PortalSettings.HomeTabId, ModuleContext.PortalId,false).TabName; if (!IsPostBack) BindSettingControls(); }
private string ResolvePageLink(int linkId, string defaultValue) { var tabController = new TabController(); var tabInfo = tabController.GetTab(linkId); if (tabInfo == null) return defaultValue; return tabInfo.TabPath; }
void configmodule() { string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/"; DotNetNuke.Entities.Tabs.TabController TC = new DotNetNuke.Entities.Tabs.TabController(); TabInfo TI = TC.GetTab(TabId, PortalId); url.Value = TI.FullUrl; }
protected void CmdAddPageClick(object sender, EventArgs e) { var tabCtrl = new TabController(); int selectedTabID = Int32.Parse(PageLst.SelectedValue); TabInfo selectedTab = tabCtrl.GetTab(selectedTabID, PortalSettings.ActiveTab.PortalID, false); var tabLocation = (TabRelativeLocation) Enum.Parse(typeof (TabRelativeLocation), LocationLst.SelectedValue); TabInfo newTab = RibbonBarManager.InitTabInfoObject(selectedTab, tabLocation); string templateFile = string.Empty; if ((!string.IsNullOrEmpty(TemplateLst.SelectedValue))) { templateFile = Path.Combine(PortalSettings.HomeDirectoryMapPath, "Templates\\" + TemplateLst.SelectedValue); } newTab.TabName = Name.Text; newTab.IsVisible = IncludeInMenu.Checked; string errMsg = string.Empty; try { RibbonBarManager.SaveTabInfoObject(newTab, selectedTab, tabLocation, templateFile); } catch (DotNetNukeException ex) { Exceptions.LogException(ex); errMsg = (ex.ErrorCode != DotNetNukeErrorCode.NotSet) ? GetString("Err." + ex.ErrorCode) : ex.Message; } catch (Exception ex) { Exceptions.LogException(ex); errMsg = ex.Message; } //Clear the Tab's Cached modules DataCache.ClearModuleCache(PortalSettings.ActiveTab.TabID); //Update Cached Tabs as TabPath may be needed before cache is cleared TabInfo tempTab; if (new TabController().GetTabsByPortal(PortalSettings.ActiveTab.PortalID).TryGetValue(newTab.TabID, out tempTab)) { tempTab.TabPath = newTab.TabPath; } if ((string.IsNullOrEmpty(errMsg))) { Response.Redirect(Globals.NavigateURL(newTab.TabID)); } else { errMsg = string.Format("<p>{0}</p><p>{1}</p>", GetString("Err.Header"), errMsg); Web.UI.Utilities.RegisterAlertOnPageLoad(this, new MessageWindowParameters(errMsg) { Title = GetString("Err.Title")}); } }
/// <summary> /// AddAdminPage adds an Admin Tab Page /// </summary> /// <param name="Portal">The Portal</param> /// <param name="TabName">The Name to give this new Tab</param> /// <param name="TabIconFile">The Icon for this new Tab</param> /// <param name="IsVisible">A flag indicating whether the tab is visible</param> private static TabInfo AddAdminPage(PortalInfo Portal, string TabName, string TabIconFile, bool IsVisible) { TabController objTabController = new TabController(); TabInfo AdminPage = objTabController.GetTab(Portal.AdminTabId, Portal.PortalID, false); TabPermissionCollection objTabPermissions = new TabPermissionCollection(); AddPagePermission(ref objTabPermissions, "View", Convert.ToInt32(Portal.AdministratorRoleId)); //Call AddPage with parentTab = AdminPage & RoleId = AdministratorRoleId return AddPage(AdminPage, TabName, TabIconFile, IsVisible, objTabPermissions, true); }
public override bool HasViewPermission(SearchResult searchResult) { var viewable = true; if (searchResult.TabId > 0) { var tabController = new TabController(); var tab = tabController.GetTab(searchResult.TabId, searchResult.PortalId, false); viewable = tab != null && !tab.IsDeleted && TabPermissionController.CanViewPage(tab); } return viewable; }
public override string GetDocUrl(SearchResult searchResult) { var url = Localization.Localization.GetString("SEARCH_NoLink"); var tabController = new TabController(); var tab = tabController.GetTab(searchResult.TabId, searchResult.PortalId, false); if (TabPermissionController.CanViewPage(tab)) { url = TestableGlobals.Instance.NavigateURL(searchResult.TabId, string.Empty, searchResult.QueryString); } return url; }
public static List<ListItem> GetModuleList(string ModuleName) { List<ListItem> lst = new List<ListItem>(); PortalSettings portalSettings = PortalController.GetCurrentPortalSettings(); List<TabInfo> objTabs = TabController.GetPortalTabs(portalSettings.PortalId, -1, true, true); var objTabController = new TabController(); var objDesktopModuleController = new DesktopModuleController(); var objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByModuleName(ModuleName); if (objDesktopModuleInfo == null) { objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByName(ModuleName); if (objDesktopModuleInfo == null) { return lst; } } foreach (TabInfo objTab in objTabs.Where(tab => !tab.IsDeleted)) { ModuleController objModules = new ModuleController(); foreach (KeyValuePair<int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID)) { ModuleInfo objModule = pair.Value; if (objModule.IsDeleted) { continue; } if (objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID) { continue; } string strPath = objTab.TabName; TabInfo objTabSelected = objTab; while (objTabSelected.ParentId != Null.NullInteger) { objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false); if (objTabSelected == null) { break; } strPath = string.Format("{0} -> {1}", objTabSelected.TabName, strPath); } var objListItem = new ListItem { Value = objModule.ModuleID.ToString(), Text = string.Format("{0} -> {1}", strPath, objModule.ModuleTitle) }; lst.Add(objListItem); } } return lst; }
/// <summary> /// BindData loads the Controls with Tab Data from the Database /// </summary> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> public void BindData() { TabController objTabs = new TabController(); TabInfo objTab = objTabs.GetTab( TabId, PortalId, false ); //Load TabControls LoadTabControls( objTab ); if( objTab != null ) { if( strAction != "copy" ) { txtTabName.Text = objTab.TabName; txtTitle.Text = objTab.Title; txtDescription.Text = objTab.Description; txtKeyWords.Text = objTab.KeyWords; ctlURL.Url = objTab.Url; } ctlIcon.Url = objTab.IconFile; if( cboTab.Items.FindByValue( objTab.ParentId.ToString() ) != null ) { cboTab.Items.FindByValue( objTab.ParentId.ToString() ).Selected = true; } chkHidden.Checked = ! objTab.IsVisible; chkDisableLink.Checked = objTab.DisableLink; ctlSkin.SkinSrc = objTab.SkinSrc; ctlContainer.SkinSrc = objTab.ContainerSrc; if( ! Null.IsNull( objTab.StartDate ) ) { txtStartDate.Text = objTab.StartDate.ToShortDateString(); } if( ! Null.IsNull( objTab.EndDate ) ) { txtEndDate.Text = objTab.EndDate.ToShortDateString(); } if( objTab.RefreshInterval != Null.NullInteger ) { txtRefreshInterval.Text = objTab.RefreshInterval.ToString(); } txtPageHeadText.Text = objTab.PageHeadText; } // copy page options cboCopyPage.DataSource = LoadPortalTabs(); cboCopyPage.DataBind(); cboCopyPage.Items.Insert( 0, new ListItem( "<" + Localization.GetString( "None_Specified" ) + ">", "-1" ) ); rowModules.Visible = false; }
public string UpgradeModule(string Version) { try { switch (Version) { case "06.02.00": var portalController = new PortalController(); var moduleController = new ModuleController(); var tabController = new TabController(); var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Message Center"); if (moduleDefinition != null) { var portals = portalController.GetPortals(); foreach (PortalInfo portal in portals) { if (portal.UserTabId > Null.NullInteger) { //Find TabInfo var tab = tabController.GetTab(portal.UserTabId, portal.PortalID, true); if (tab != null) { foreach (var module in moduleController.GetTabModules(portal.UserTabId).Values) { if (module.DesktopModule.FriendlyName == "Messaging") { //Delete the Module from the Modules list moduleController.DeleteTabModule(module.TabID, module.ModuleID, false); //Add new module to the page Upgrade.AddModuleToPage(tab, moduleDefinition.ModuleDefID, "Message Center", "", true); break; } } } } } } break; } return "Success"; } catch (Exception exc) { Logger.Error(exc); return "Failed"; } }
/// <summary> /// ViewTab redirects to the Tab/Page for the currently selected tab/page /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/9/2004 Created /// </history> private void ViewTab() { if( lstTabs.SelectedIndex != - 1 ) { TabController objTabs = new TabController(); TabInfo objTab = objTabs.GetTab( ( (TabInfo)arrPortalTabs[lstTabs.SelectedIndex] ).TabID ); if( objTab != null ) { if( objTab.DisableLink ) { UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "ViewTabMessage", this.LocalResourceFile ), ModuleMessageType.YellowWarning ); } else { Response.Redirect( Globals.NavigateURL( objTab.TabID ), true ); } } } }
private void BindBeforeAfterTabControls() { TabInfo parentTab = null; var noneSpecified = "<" + Localization.GetString("None_Specified") + ">"; if (cboParentTab.SelectedItem != null) { var parentTabID = Int32.Parse(cboParentTab.SelectedItem.Value); var controller = new TabController(); parentTab = controller.GetTab(parentTabID, PortalId, false); } List<TabInfo> listTabs = parentTab != null ? new TabController().GetTabsByPortal(parentTab.PortalID).WithParentId(parentTab.TabID) : new TabController().GetTabsByPortal(PortalId).WithParentId(Null.NullInteger); listTabs = TabController.GetPortalTabs(listTabs, Null.NullInteger, true, noneSpecified, false, false, false, false, true); cboPositionTab.DataSource = listTabs; cboPositionTab.DataBind(); rbInsertPosition.Items.Clear(); rbInsertPosition.Items.Add(new ListItem(Localization.GetString("InsertBefore", LocalResourceFile), "Before")); rbInsertPosition.Items.Add(new ListItem(Localization.GetString("InsertAfter", LocalResourceFile), "After")); rbInsertPosition.Items.Add(new ListItem(Localization.GetString("InsertAtEnd", LocalResourceFile), "AtEnd")); rbInsertPosition.SelectedValue = "After"; }
public override bool HasViewPermission(SearchResult searchResult) { var viewable = false; if (searchResult.ModuleId > 0) { //Get All related tabIds from moduleId (while minimizing DB access; using caching) var tabController = new TabController(); var moduleId = searchResult.ModuleId; // The next call has over 30% performance enhancement over the above one var tabModules = tabController.GetTabsByPortal(searchResult.PortalId).Values .SelectMany(tabinfo => tabinfo.ChildModules.Where(kv => kv.Key == moduleId)).Select(m => m.Value); foreach (ModuleInfo module in tabModules) { var tab = tabController.GetTab(module.TabID, searchResult.PortalId, false); if (!module.IsDeleted && !tab.IsDeleted && TabPermissionController.CanViewPage(tab)) { //Check If authorised to View Module if (ModulePermissionController.CanViewModule(module)) { //Verify against search document permissions if (string.IsNullOrEmpty(searchResult.Permissions) || PortalSecurity.IsInRoles(searchResult.Permissions)) { viewable = true; if (string.IsNullOrEmpty(searchResult.Url)) { searchResult.Url = TestableGlobals.Instance.NavigateURL(module.TabID, string.Empty, searchResult.QueryString); } break; } } } } } else { viewable = true; } return viewable; }
private static void AddHostPage(int parentId, string tabPath, string moduleFriendlyName, string tabName, string tabDescription, string smallIcon, string largeIcon, bool isVisible = true) { var tabController = new TabController(); var moduleController = new ModuleController(); TabInfo hostTab; // Get the module definition var moduleDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(moduleFriendlyName); // Add pages var tabId = TabController.GetTabByTabPath(Null.NullInteger, tabPath, Null.NullString); if (tabId == Null.NullInteger) { //Add host page hostTab = Upgrade.AddHostPage(tabName, tabDescription, smallIcon, largeIcon, isVisible); hostTab.ParentId = parentId; tabController.UpdateTab(hostTab); //Add module to page Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true); } else { hostTab = tabController.GetTab(tabId, Null.NullInteger, false); foreach ( var kvp in moduleController.GetTabModules(tabId) .Where(kvp => kvp.Value.DesktopModule.ModuleName == moduleFriendlyName)) { // Remove previous module instance moduleController.DeleteTabModule(tabId, kvp.Value.ModuleID, false); break; } //Add module to page Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true); } }
public void AddHostPage(int parentId, string tabPath, string moduleFriendlyName, string tabName, string tabDescription, string smallIcon, string largeIcon) { var tabController = new TabController(); var moduleController = new ModuleController(); TabInfo hostTab; //Get web servers module ModuleDefinitionInfo moduleDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(moduleFriendlyName); //Add Pages under Advanced Features Tab int tabId = TabController.GetTabByTabPath(Null.NullInteger, tabPath, Null.NullString); if (tabId == Null.NullInteger) { //Add host page hostTab = Upgrade.AddHostPage(tabName, tabDescription, smallIcon, largeIcon, true); hostTab.ParentId = parentId; tabController.UpdateTab(hostTab); //Add module to page Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true); } else { hostTab = tabController.GetTab(tabId, Null.NullInteger, false); foreach (var kvp in moduleController.GetTabModules(tabId)) { if (kvp.Value.DesktopModule.ModuleName == "ProfessionalPreview") { //Preview module so hard delete moduleController.DeleteTabModule(tabId, kvp.Value.ModuleID, false); break; } } //Add module to page Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true); } }
private void LoadData(int tabId) { Exists = false; if (_lang != "") { _portalId = PortalSettings.Current.PortalId; var objTabCtrl = new DotNetNuke.Entities.Tabs.TabController(); TabInfo = objTabCtrl.GetTab(tabId, _portalId, true); if (TabInfo != null) { var objCtrl = new NBrightDataController(); DataRecord = objCtrl.GetByGuidKey(_portalId, -1, "PL", tabId.ToString("")); if (DataRecord == null) { DataRecord = AddNew(); // add new record. } if (_lang == "") { _lang = Utils.GetCurrentCulture(); } if (DataRecord != null) { Exists = true; DataRecord.GUIDKey = TabInfo.TabID.ToString(""); DataLangRecord = objCtrl.GetDataLang(DataRecord.ItemID, _lang); if (DataLangRecord == null) // rebuild langauge if we have a missing lang record { Validate(); DataLangRecord = objCtrl.GetDataLang(DataRecord.ItemID, _lang); DataLangRecord.GUIDKey = TabInfo.TabID.ToString(""); } Info = objCtrl.Get(DataRecord.ItemID, _lang); Save(); } } } }
private string ResolvePageLink(int id, string defaultValue) { var tabController = new TabController(); // 2016-03-03 before issue #710 //var tabInfo = tabController.GetTab(linkId); //if (tabInfo == null) // return defaultValue; //return tabInfo.TabPath; //ownerPortalSettings = SxcInstance. var tabInfo = tabController.GetTab(id); if (tabInfo == null) return defaultValue; var portalSettings = PortalSettings.Current; // Get full PortalSettings (with portal alias) if module sharing is active if (PortalSettings.Current != null && PortalSettings.Current.PortalId != tabInfo.PortalID) //{ portalSettings = new PortalSettings(tabInfo.PortalID); //var portalAlias = ownerPortalSettings.PrimaryAlias ?? TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(tabInfo.PortalID).First(); //portalSettings = new PortalSettings(id, portalAlias); //} if(portalSettings == null) return defaultValue; // var tabInfo = tabController.GetTab(id, portalSettings.PortalId, false); // if (tabInfo == null) return defaultValue; if (tabInfo.CultureCode != "" && tabInfo.CultureCode != PortalSettings.Current.CultureCode) { var cultureTabInfo = tabController.GetTabByCulture(tabInfo.TabID, tabInfo.PortalID, LocaleController.Instance.GetLocale(PortalSettings.Current.CultureCode)); if (cultureTabInfo != null) tabInfo = cultureTabInfo; } // Exception in AdvancedURLProvider because ownerPortalSettings.PortalAlias is null return Globals.NavigateURL(tabInfo.TabID, portalSettings, "", new string[] {});// + urlParams; }
protected void OnCreatePagesClick(object sender, EventArgs e) { if (!PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)) return; var strValue = txtBulk.Text; strValue = strValue.Replace("\r", "\n"); strValue = strValue.Replace(Environment.NewLine, "\n"); strValue = strValue.Replace("\n" + "\n", "\n").Trim(); if (!IsValidTabName(strValue)) { return; } var pages = strValue.Split(char.Parse("\n")); var parentId = Convert.ToInt32(((LinkButton)sender).CommandArgument); var tabController = new TabController(); var rootTab = tabController.GetTab(parentId, PortalId, true); var tabs = new List<TabInfo>(); foreach (var strLine in pages) { var oTab = new TabInfo { TabName = strLine }; if (strLine.StartsWith(">")) { oTab.Level = strLine.LastIndexOf(">", StringComparison.Ordinal) + 1; } else { oTab.Level = 0; } tabs.Add(oTab); } var currentIndex = -1; foreach (var oTab in tabs) { currentIndex += 1; try { oTab.TabID = oTab.TabName.StartsWith(">") == false ? CreateTabFromParent(rootTab, oTab.TabName, parentId) : CreateTabFromParent(rootTab, oTab.TabName.Replace(">", ""), GetParentTabId(tabs, currentIndex, oTab.Level - 1)); } catch (Exception ex) { ShowErrorMessage(ex.ToString()); //Instrumentation.Logger.Error(ex); --this code shows unexpected results. } } var tabId = Convert.ToInt32(tabs[0].TabID); if (tabId == Null.NullInteger) { tabId = parentId; } txtBulk.Text = string.Empty; BindTreeAndShowTab(tabId); }
protected void CtlPagesNodeEdit(object sender, RadTreeNodeEditEventArgs e) { var objTabController = new TabController(); var objTab = objTabController.GetTab(int.Parse(e.Node.Value), PortalId, false); if (objTab != null && TabPermissionController.CanManagePage(objTab)) { //Check for invalid if (!IsValidTabName(e.Text) || !IsValidTabPath(objTab, Globals.GenerateTabPath(objTab.ParentId, e.Text))) { e.Node.Text = objTab.TabName; e.Text = objTab.TabName; } else { objTab.TabName = e.Text; objTabController.UpdateTab(objTab); } BindTreeAndShowTab(objTab.TabID); } }
protected void CtlPagesContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e) { SelectedNode = e.Node.Value; var tabController = new TabController(); var portalId = rblMode.SelectedValue == "H" ? Null.NullInteger : PortalId; var objTab = tabController.GetTab(int.Parse(e.Node.Value), portalId, false); switch (e.MenuItem.Value.ToLower()) { case "makehome": if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)) { var portalController = new PortalController(); PortalInfo portalInfo = portalController.GetPortal(PortalId); portalInfo.HomeTabId = objTab.TabID; PortalSettings.HomeTabId = objTab.TabID; portalController.UpdatePortalInfo(portalInfo); DataCache.ClearPortalCache(PortalId, false); BindTreeAndShowTab(objTab.TabID); ShowSuccessMessage(string.Format(Localization.GetString("TabMadeHome", LocalResourceFile), objTab.TabName)); } break; case "view": Response.Redirect(objTab.FullUrl); break; case "edit": if (TabPermissionController.CanManagePage(objTab)) { var editUrl = Globals.NavigateURL(objTab.TabID, "Tab", "action=edit", "returntabid=" + TabId); // Prevent PageSettings of the current page in a popup if SSL is enabled and enforced, which causes redirection/javascript broswer security issues. if (PortalSettings.EnablePopUps && !(objTab.TabID == TabId && (PortalSettings.SSLEnabled && PortalSettings.SSLEnforced))) { editUrl = UrlUtils.PopUpUrl(editUrl, this, PortalSettings, true, false); var script = string.Format("<script type=\"text/javascript\">{0}</script>", editUrl); ClientAPI.RegisterStartUpScript(Page, "EditInPopup", script); } else { Response.Redirect(editUrl, true); } } break; case "delete": if (TabPermissionController.CanDeletePage(objTab)) { tabController.SoftDeleteTab(objTab.TabID, PortalSettings); BindTree(); //keep the parent tab selected if (objTab.ParentId != Null.NullInteger) { SelectedNode = objTab.ParentId.ToString(CultureInfo.InvariantCulture); ctlPages.FindNodeByValue(SelectedNode).Selected = true; ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes(); BindTab(objTab.ParentId); } else { pnlDetails.Visible = false; } ShowSuccessMessage(string.Format(Localization.GetString("TabDeleted", LocalResourceFile), objTab.TabName)); } break; case "add": if ((objTab!= null && TabPermissionController.CanAddPage(objTab)) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))) { pnlBulk.Visible = true; btnBulkCreate.CommandArgument = e.Node.Value; ctlPages.FindNodeByValue(e.Node.Value).Selected = true; txtBulk.Focus(); pnlDetails.Visible = false; //Response.Redirect(NavigateURL(objTab.TabID, "Tab", "action=add", "returntabid=" & TabId.ToString), True) } break; case "hide": if (TabPermissionController.CanManagePage(objTab)) { objTab.IsVisible = false; tabController.UpdateTab(objTab); BindTreeAndShowTab(objTab.TabID); ShowSuccessMessage(string.Format(Localization.GetString("TabHidden", LocalResourceFile), objTab.TabName)); } break; case "show": if (TabPermissionController.CanManagePage(objTab)) { objTab.IsVisible = true; tabController.UpdateTab(objTab); BindTreeAndShowTab(objTab.TabID); ShowSuccessMessage(string.Format(Localization.GetString("TabShown", LocalResourceFile), objTab.TabName)); } break; case "disable": if (TabPermissionController.CanManagePage(objTab)) { objTab.DisableLink = true; tabController.UpdateTab(objTab); BindTreeAndShowTab(objTab.TabID); ShowSuccessMessage(string.Format(Localization.GetString("TabDisabled", LocalResourceFile), objTab.TabName)); } break; case "enable": if (TabPermissionController.CanManagePage(objTab)) { objTab.DisableLink = false; tabController.UpdateTab(objTab); BindTreeAndShowTab(objTab.TabID); ShowSuccessMessage(string.Format(Localization.GetString("TabEnabled", LocalResourceFile), objTab.TabName)); } break; } }
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(); } }
private void PerformDragAndDrop(RadTreeViewDropPosition dropPosition, RadTreeNode sourceNode, RadTreeNode destNode) { var tabController = new TabController(); var sourceTab = tabController.GetTab(int.Parse(sourceNode.Value), PortalId, false); var targetTab = tabController.GetTab(int.Parse(destNode.Value), PortalId, false); switch (dropPosition) { case RadTreeViewDropPosition.Over: if (!(sourceNode.IsAncestorOf(destNode))) { if (MoveTabToParent(sourceTab, targetTab)) { sourceNode.Owner.Nodes.Remove(sourceNode); destNode.Nodes.Add(sourceNode); } } break; case RadTreeViewDropPosition.Above: if (MoveTab(sourceTab, targetTab, Position.Above)) { sourceNode.Owner.Nodes.Remove(sourceNode); destNode.InsertBefore(sourceNode); } break; case RadTreeViewDropPosition.Below: if (MoveTab(sourceTab, targetTab, Position.Below)) { sourceNode.Owner.Nodes.Remove(sourceNode); destNode.InsertAfter(sourceNode); } break; } }
private bool IsValidTabPath(TabInfo tab, string newTabPath) { var valid = true; //get default culture if the tab's culture is null var cultureCode = tab.CultureCode; if (string.IsNullOrEmpty(cultureCode)) { cultureCode = PortalSettings.DefaultLanguage; } //Validate Tab Path var tabID = TabController.GetTabByTabPath(tab.PortalID, newTabPath, cultureCode); if (tabID != Null.NullInteger && tabID != tab.TabID) { var controller = new TabController(); var existingTab = controller.GetTab(tabID, tab.PortalID, false); if (existingTab != null && existingTab.IsDeleted) ShowErrorMessage(Localization.GetString("TabRecycled", LocalResourceFile)); else ShowErrorMessage(Localization.GetString("TabExists", LocalResourceFile)); valid = false; } //check whether have conflict between tab path and portal alias. if (TabController.IsDuplicateWithPortalAlias(tab.PortalID, newTabPath)) { ShowErrorMessage(Localization.GetString("PathDuplicateWithAlias", LocalResourceFile)); valid = false; } return valid; }
private void BindTree() { ctlPages.Nodes.Clear(); var rootNode = new RadTreeNode(); var strParent = "-1"; if (Settings["ParentPageFilter"] != null) { strParent = Convert.ToString(Settings["ParentPageFilter"]); } if (strParent == "-1") { rootNode.Text = PortalSettings.PortalName; rootNode.ImageUrl = IconPortal; rootNode.Value = Null.NullInteger.ToString(CultureInfo.InvariantCulture); rootNode.Expanded = true; rootNode.AllowEdit = false; rootNode.EnableContextMenu = true; rootNode.Attributes.Add("isPortalRoot", "True"); AddAttributes(ref rootNode, null); } else { var tabController = new TabController(); var parent = tabController.GetTab(Convert.ToInt32(strParent), -1, false); if (parent != null) { rootNode.Text = parent.TabName; rootNode.ImageUrl = IconPortal; rootNode.Value = parent.TabID.ToString(CultureInfo.InvariantCulture); rootNode.Expanded = true; rootNode.EnableContextMenu = true; rootNode.PostBack = false; } } foreach (var tab in Tabs) { if (TabPermissionController.CanViewPage(tab)) { if (strParent != "-1") { if (tab.ParentId == Convert.ToInt32(strParent)) { var node = new RadTreeNode { Text = string.Format("{0} {1}", tab.TabName, GetNodeStatusIcon(tab)), Value = tab.TabID.ToString(CultureInfo.InvariantCulture), AllowEdit = true, ImageUrl = GetNodeIcon(tab) }; AddAttributes(ref node, tab); AddChildNodes(node); rootNode.Nodes.Add(node); } } else { if (tab.Level == 0) { var node = new RadTreeNode { Text = string.Format("{0} {1}", tab.TabName, GetNodeStatusIcon(tab)), Value = tab.TabID.ToString(CultureInfo.InvariantCulture), AllowEdit = true, ImageUrl = GetNodeIcon(tab) }; AddAttributes(ref node, tab); AddChildNodes(node); rootNode.Nodes.Add(node); } } } } ctlPages.Nodes.Add(rootNode); //AttachContextMenu(ctlPages) if (SelectedNode != null) { if (!Page.IsPostBack) { try { ctlPages.FindNodeByValue(SelectedNode).Selected = true; ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes(); var tabid = Convert.ToInt32(SelectedNode); BindTab(tabid); pnlBulk.Visible = false; } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } } } }
public static string BuildTabPathWithReplacement(TabInfo tab, FriendlyUrlOptions options, Guid parentTraceId) { string path = ""; if ((tab.ParentId > -1)) { var tc = new TabController(); TabInfo parentTab = tc.GetTab(tab.ParentId, tab.PortalID, false); //822 : don't assume parent tab is going to exist - database might be corrupted //896 : check to make sure tabid and parentid are different - or stack overflow occurs with terminal loop if (parentTab != null && parentTab.TabID != tab.TabID) { path = BuildTabPathWithReplacement(parentTab, options, parentTraceId); } } bool modified; path = AppendToTabPath(path, tab, options, out modified); return path; }
private static void ClearPermissionCache(int tabId) { var objTabs = new TabController(); var objTab = objTabs.GetTab(tabId, Null.NullInteger, false); DataCache.ClearTabPermissionsCache(objTab.PortalID); }
private void BindTab(int tabId) { pnlBulk.Visible = false; var tabController = new TabController(); var tab = tabController.GetTab(tabId, PortalId, true); if (tab != null) { //check for manage permissions if (!TabPermissionController.CanManagePage(tab)) { pnlDetails.Visible = false; return; } pnlDetails.Visible = true; SelectedNode = tabId.ToString(CultureInfo.InvariantCulture); //Bind TabPermissionsGrid to TabId dgPermissions.TabID = tab.TabID; dgPermissions.DataBind(); var returnUrl = Globals.NavigateURL(TabId, string.Empty, "edittabid=" + tabId, "isHost=" + (rblMode.SelectedValue == "H")); cmdMore.NavigateUrl = ModuleContext.NavigateUrl(tabId, "", false, "ctl=Tab", "action=edit", "returnurl=" + returnUrl); txtTitle.Text = tab.Title; txtName.Text = tab.TabName; chkVisible.Checked = tab.IsVisible; txtSitemapPriority.Text = tab.SiteMapPriority.ToString(); txtDescription.Text = tab.Description; txtKeywords.Text = tab.KeyWords; txtMeta.Text = tab.PageHeadText; if (tab.RefreshInterval != Null.NullInteger) { txtRefresh.Text = tab.RefreshInterval.ToString(); } drpSkin.SelectedValue = tab.SkinSrc; drpContainer.SelectedValue = tab.ContainerSrc; ctlURL.Url = tab.Url; if (string.IsNullOrEmpty(tab.Url)) { ctlURL.UrlType = "N"; } bool newWindow = false; if (tab.TabSettings["LinkNewWindow"] != null && Boolean.TryParse((string)tab.TabSettings["LinkNewWindow"], out newWindow) && newWindow) { ctlURL.NewWindow = newWindow; } chkPermanentRedirect.Checked = tab.PermanentRedirect; txtKeywords.Text = tab.KeyWords; txtDescription.Text = tab.Description; chkDisabled.Checked = tab.DisableLink; if (tab.TabID == PortalSettings.AdminTabId || tab.TabID == PortalSettings.SplashTabId || tab.TabID == PortalSettings.HomeTabId || tab.TabID == PortalSettings.LoginTabId || tab.TabID == PortalSettings.UserTabId || tab.TabID == PortalSettings.SuperTabId) { chkDisabled.Enabled = false; } if (PortalSettings.SSLEnabled) { chkSecure.Enabled = true; chkSecure.Checked = tab.IsSecure; } else { chkSecure.Enabled = false; chkSecure.Checked = tab.IsSecure; } var allowIndex = false; chkAllowIndex.Checked = !tab.TabSettings.ContainsKey("AllowIndex") || !bool.TryParse(tab.TabSettings["AllowIndex"].ToString(), out allowIndex) || allowIndex; ctlIcon.Url = tab.IconFileRaw; ctlIconLarge.Url = tab.IconFileLargeRaw; ShowPermissions(!tab.IsSuperTab && TabPermissionController.CanAdminPage()); termsSelector.PortalId = tab.PortalID; termsSelector.Terms = tab.Terms; termsSelector.DataBind(); grdModules.Rebind(); } }
protected IEnumerable<ModuleInfo> GetSearchModules(int portalId, bool allModules) { var tabController = new TabController(); var moduleController = new ModuleController(); var businessControllers = new Hashtable(); var searchModuleIds = new HashSet<int>(); var searchModules = new List<ModuleInfo>(); //Only get modules that are set to be Indexed. var modules = moduleController.GetSearchModules(portalId).Cast<ModuleInfo>().Where(m => m.TabModuleSettings["AllowIndex"] == null || bool.Parse(m.TabModuleSettings["AllowIndex"].ToString())); foreach (var module in modules.Where(module => !searchModuleIds.Contains(module.ModuleID))) { try { var tab = tabController.GetTab(module.TabID, portalId, false); //Only index modules on tabs that are set to be Indexed. if (tab.TabSettings["AllowIndex"] == null || (tab.TabSettings["AllowIndex"] != null && bool.Parse(tab.TabSettings["AllowIndex"].ToString()))) { //Check if the business controller is in the Hashtable var controller = businessControllers[module.DesktopModule.BusinessControllerClass]; if (!String.IsNullOrEmpty(module.DesktopModule.BusinessControllerClass)) { //If nothing create a new instance if (controller == null) { //Add to hashtable controller = Reflection.CreateObject(module.DesktopModule.BusinessControllerClass, module.DesktopModule.BusinessControllerClass); businessControllers.Add(module.DesktopModule.BusinessControllerClass, controller); } } //Check if module inherits from ModuleSearchBase or include all modules to index module metadata. if (controller is ModuleSearchBase || allModules) searchModules.Add(module); } } catch (Exception ex) { Logger.Error(ex); ThrowLogError(module, ex); } finally { searchModuleIds.Add(module.ModuleID); } } return searchModules; }
private int CreateTabFromParent(TabInfo objRoot, string tabName, int parentId) { var tab = new TabInfo { PortalID = PortalId, TabName = tabName, ParentId = parentId, Title = "", Description = "", KeyWords = "", IsVisible = true, DisableLink = false, IconFile = "", IconFileLarge = "", IsDeleted = false, Url = "", SkinSrc = "", ContainerSrc = "", CultureCode = Null.NullString }; if (objRoot != null) { tab.IsVisible = objRoot.IsVisible; tab.DisableLink = objRoot.DisableLink; tab.SkinSrc = objRoot.SkinSrc; tab.ContainerSrc = objRoot.ContainerSrc; } var portalSettings = PortalController.GetCurrentPortalSettings(); if (portalSettings.ContentLocalizationEnabled) { tab.CultureCode = LocaleController.Instance.GetDefaultLocale(tab.PortalID).Code; } var controller = new TabController(); var parentTab = controller.GetTab(parentId, -1, false); if (parentTab != null) { tab.PortalID = parentTab.PortalID; tab.ParentId = parentTab.TabID; if (parentTab.IsSuperTab) ShowPermissions(false); } else { //return Null.NullInteger; tab.PortalID = PortalId; tab.ParentId = Null.NullInteger; } tab.TabPath = Globals.GenerateTabPath(tab.ParentId, tab.TabName); //Check for invalid if (!IsValidTabName(tab.TabName)) { return Null.NullInteger; } //Validate Tab Path if (!IsValidTabPath(tab, tab.TabPath)) { return Null.NullInteger; } //Inherit permissions from parent tab.TabPermissions.Clear(); if (tab.PortalID != Null.NullInteger && objRoot != null) { tab.TabPermissions.AddRange(objRoot.TabPermissions); } else if (tab.PortalID != Null.NullInteger) { //Give admin full permission ArrayList permissions = PermissionController.GetPermissionsByTab(); foreach (PermissionInfo permission in permissions) { var newTabPermission = new TabPermissionInfo { PermissionID = permission.PermissionID, PermissionKey = permission.PermissionKey, PermissionName = permission.PermissionName, AllowAccess = true, RoleID = PortalSettings.Current.AdministratorRoleId }; tab.TabPermissions.Add(newTabPermission); } } //Inherit other information from Parent if (objRoot != null) { tab.Terms.Clear(); tab.StartDate = objRoot.StartDate; tab.EndDate = objRoot.EndDate; tab.RefreshInterval = objRoot.RefreshInterval; tab.SiteMapPriority = objRoot.SiteMapPriority; tab.PageHeadText = objRoot.PageHeadText; tab.IsSecure = objRoot.IsSecure; tab.PermanentRedirect = objRoot.PermanentRedirect; } var ctrl = new TabController(); tab.TabID = ctrl.AddTab(tab); ApplyDefaultTabTemplate(tab); //create localized tabs if content localization is enabled if (portalSettings.ContentLocalizationEnabled) { ctrl.CreateLocalizedCopies(tab); } ShowSuccessMessage(string.Format(Localization.GetString("TabCreated", LocalResourceFile), tab.TabName)); return tab.TabID; }