/// <summary> /// The BindData helper method is used to update the tab's /// layout panes with the current configuration information /// </summary> private void BindData() { // Populate the "ParentTab" Data TabsDB t = new TabsDB(); SqlDataReader dr = t.GetTabsParent(portalSettings.PortalID, TabID); parentTabDropDown.DataSource = dr; parentTabDropDown.DataBind(); dr.Close(); //by Manu, fixed bug 807858 //Preselects current tab as parent // Comment out old code for Grischa Brockhaus // int currentTab = this.portalSettings.ActiveTab.TabID; // if (parentTabDropDown.Items.FindByValue(parentTabDropDown.ToString()) != null) // parentTabDropDown.Items.FindByValue(parentTabDropDown.ToString()).Selected = true; // Changes for Grischa Brockhaus copied by Mike Stone 7/1/2005 int currentTab = this.portalSettings.ActiveTab.TabID; if (parentTabDropDown.Items.FindByValue(currentTab.ToString()) != null) { parentTabDropDown.Items.FindByValue(currentTab.ToString()).Selected = true; } // Translate if (parentTabDropDown.Items.FindByText(" ROOT_LEVEL") != null) { parentTabDropDown.Items.FindByText(" ROOT_LEVEL").Text = Esperantus.Localize.GetString("ROOT_LEVEL", "Root Level", parentTabDropDown); } }
/// <summary> /// The SaveTabData helper method is used to persist the /// current tab settings to the database. /// </summary> private int SaveTabData() { // Construct Authorized User Roles string string authorizedRoles = ""; // added by Jonathan Fong 05/08/2004 to support LDAP // www.gt.com.au bool useMemberList = HttpContext.Current.User is System.Security.Principal.WindowsPrincipal; useMemberList |= System.Configuration.ConfigurationSettings.AppSettings["LDAPLogin"] != null ? true : false; if (useMemberList) { authorizedRoles = memRoles.Members; } else { foreach (ListItem item in authRoles.Items) { if (item.Selected == true) { authorizedRoles = authorizedRoles + item.Text + ";"; } } } // Add Tab info in the database int NewTabID = new TabsDB().AddTab(portalSettings.PortalID, Int32.Parse(parentTab.SelectedItem.Value), tabName.Text, 990000, authorizedRoles, showMobile.Checked, mobileTabName.Text); // Update custom settings in the database EditTable.UpdateControls(); return(NewTabID); }
/// <summary> /// The DeleteBtn_Click server event handler is used to delete /// the selected tab from the portal /// </summary> override protected void OnDelete() { base.OnDelete(); if (tabList.SelectedIndex > -1) { try { // must delete from database too TabItem t = (TabItem)portalTabs[tabList.SelectedIndex]; TabsDB tabs = new TabsDB(); tabs.DeleteTab(t.ID); // remove item from list portalTabs.RemoveAt(tabList.SelectedIndex); #region GBS Fix RBM-203 if (tabList.SelectedIndex > 0) { t = (TabItem)portalTabs[tabList.SelectedIndex - 1]; } #endregion // reorder list OrderTabs(); // Redirect to self page to refresh Response.Redirect(Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", TabID, "SelectedTabID=" + t.ID)); } catch (System.Data.SqlClient.SqlException) { Controls.Add(new LiteralControl("<br><span class='Error'>" + Esperantus.Localize.GetString("TAB_DELETE_FAILED", "Failed to delete Tab", this) + "<br>")); } } }
/// <summary> /// The OrderTabs helper method is used to reset /// the display order for tabs within the portal /// </summary> private void OrderTabs() { int i = 1; // sort the arraylist portalTabs.Sort(); // renumber the order and save to database foreach (TabItem t in portalTabs) { // number the items 1, 3, 5, etc. to provide an empty order // number when moving items up and down in the list. t.Order = i; i += 2; // rewrite tab to database TabsDB tabs = new TabsDB(); // 12/16/2002 Start - Cory Isakson tabs.UpdateTabOrder(t.ID, t.Order); // 12/16/2002 End - Cory Isakson } //gbs: Invalidate cache, fix for bug RBM-220 Rainbow.Settings.Cache.CurrentCache.RemoveAll("_TabNavigationSettings_"); }
/// <summary> /// The AddTab_Click server event handler is used /// to add a new tab for this portal /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private void AddTab_Click(Object Sender, EventArgs e) { // EHN: Adding support for new form that only hits db after user // commits by clicking the save button. // Mike Stone - 19/12/2004 if (Settings["TAB_VERSION"] != null) { if (Settings["TAB_VERSION"].ToString() == "True") // Use Old Version { // New tabs go to the end of the list TabItem t = new TabItem(); t.Name = Esperantus.Localize.GetString("TAB_NAME", "New Tab Name"); //Just in case it comes to be empty t.ID = -1; t.Order = 990000; portalTabs.Add(t); // write tab to database TabsDB tabs = new TabsDB(); t.ID = tabs.AddTab(portalSettings.PortalID, t.Name, t.Order); // Reset the order numbers for the tabs within the list OrderTabs(); // Redirect to edit page // 3_aug_2004 Cory Isakson added returntabid so that TabLayout could return to the tab it was called from. // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09) Response.Redirect(Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopModules/Tabs/TabLayout.aspx", t.ID, "mID=" + ModuleID.ToString() + "&returntabid=" + Page.TabID)); } else { // Redirect to New Form - Mike Stone 19/12/2004 Response.Redirect(Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopModules/Tabs/AddTab.aspx", "mID=" + ModuleID.ToString() + "&returntabid=" + Page.TabID)); } } }
private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName, string portalPath) { int newPortalID; PortalsDB portals = new PortalsDB(); TabsDB tabs = new TabsDB(); ModulesDB modules = new ModulesDB(); UsersDB users = new UsersDB(); // create an Array to stores modules ID and GUID for finding them later ArrayList templateModules = new ArrayList(); moduleTemplate module; // create an Array to stores tabs ID for finding them later ArrayList templateTabs = new ArrayList(); tabTemplate tab; // Create a new portal newPortalID = portals.AddPortal(portalAlias, portalName, portalPath); // Open the connection to the PortalTemplates Database SqlConnection myConnection = GetConnection(); SqlConnection my2ndConnection = GetConnection(); SqlConnection my3rdConnection = GetConnection(); myConnection.Open(); my2ndConnection.Open(); my3rdConnection.Open(); // get module definitions and save them in the new portal SqlDataReader myReader = GetTemplateModuleDefinitions(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { module.id = (int)myReader["ModuleDefID"]; module.GuidID = GetGeneralModuleDefinitionByName(myReader["FriendlyName"].ToString(), my2ndConnection); try { // save module definitions in the new portal modules.UpdateModuleDefinitions(module.GuidID, newPortalID, true); // Save the modules into a list for finding them later templateModules.Add(module); } catch { // tried to add a Module thas doesn´t exists in this implementation of the portal } } myReader.Close(); if (!PortalSettings.UseSingleUserBase) { int roleID; int userID; int adminRoleID = 0; // get roles and save them in the new portal myReader = GetPortalRoles(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { roleID = users.AddRole(newPortalID, myReader["RoleName"].ToString()); if (myReader["RoleName"].ToString() == "Admins") { adminRoleID = roleID; } } myReader.Close(); // Create the "admin" User for the new portal string AdminEmail = "*****@*****.**"; userID = users.AddUser("admin", AdminEmail, "admin", newPortalID); // Create a new row in a many to many table (userroles) // giving the "admins" role to the "admin" user users.AddUserRole(adminRoleID, userID); } // Get all the Tabs in the Template Portal, store IDs in a list for finding them later // and create the Tabs in the new Portal myReader = GetTabsByPortal(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { // Save the tabs into a list for finding them later tab.oldID = (int)myReader["TabID"]; tab.newID = tabs.AddTab(newPortalID, myReader["TabName"].ToString(), Int32.Parse(myReader["TabOrder"].ToString())); templateTabs.Add(tab); } myReader.Close(); // now I have to get them again to set up the ParentID for each Tab myReader = GetTabsByPortal(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { // Find the news TabID and ParentTabID System.Collections.IEnumerator myEnumerator = templateTabs.GetEnumerator(); int newTabID = -1; int newParentTabID = -1; while (myEnumerator.MoveNext() && (newTabID == -1 || newParentTabID == -1)) { tab = (tabTemplate)myEnumerator.Current; if (tab.oldID == (int)myReader["TabID"]) { newTabID = tab.newID; } if (tab.oldID == Int32.Parse("0" + myReader["ParentTabID"])) { newParentTabID = tab.newID; } } if (newParentTabID == -1) { newParentTabID = 0; } // Update the Tab in the new portal tabs.UpdateTab(newPortalID, newTabID, newParentTabID, myReader["TabName"].ToString(), Int32.Parse(myReader["TabOrder"].ToString()), myReader["AuthorizedRoles"].ToString(), myReader["MobileTabName"].ToString(), (bool)myReader["ShowMobile"]); // Finally use GetPortalSettings to access each Tab and its Modules in the Template Portal // and create them in the new Portal SqlDataReader result; try { result = GetTabModules(Int32.Parse(myReader["TabID"].ToString()), my2ndConnection); object myValue; while (result.Read()) { ModuleSettings m = new ModuleSettings(); m.ModuleID = (int)result["ModuleID"]; m.ModuleDefID = (int)result["ModuleDefID"]; m.TabID = newTabID; m.PaneName = (string)result["PaneName"]; m.ModuleTitle = (string)result["ModuleTitle"]; myValue = result["AuthorizedEditRoles"]; m.AuthorizedEditRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedViewRoles"]; m.AuthorizedViewRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedAddRoles"]; m.AuthorizedAddRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedDeleteRoles"]; m.AuthorizedDeleteRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedPropertiesRoles"]; m.AuthorizedPropertiesRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedMoveModuleRoles"]; m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedDeleteModuleRoles"]; m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedPublishingRoles"]; m.AuthorizedPublishingRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["SupportWorkflow"]; m.SupportWorkflow = !Convert.IsDBNull(myValue) ? (bool)myValue : false; myValue = result["AuthorizedApproveRoles"]; m.AuthorizedApproveRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["WorkflowState"]; m.WorkflowStatus = !Convert.IsDBNull(myValue) ? (WorkflowState)(0 + (byte)myValue) : WorkflowState.Original; try { myValue = result["SupportCollapsable"]; } catch { myValue = DBNull.Value; } m.SupportCollapsable = DBNull.Value != myValue ? (bool)myValue : false; try { myValue = result["ShowEveryWhere"]; } catch { myValue = DBNull.Value; } m.ShowEveryWhere = DBNull.Value != myValue ? (bool)myValue : false; m.CacheTime = int.Parse(result["CacheTime"].ToString()); m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString()); myValue = result["ShowMobile"]; m.ShowMobile = !Convert.IsDBNull(myValue) ? (bool)myValue : false; // Find the new ModuleDefID assigned to the module in the new portal myEnumerator = templateModules.GetEnumerator(); int newModuleDefID = 0; while (myEnumerator.MoveNext() && newModuleDefID == 0) { module = (moduleTemplate)myEnumerator.Current; if (module.id == m.ModuleDefID) { newModuleDefID = modules.GetModuleDefinitionByGuid(newPortalID, module.GuidID); } } if (newModuleDefID > 0) { // add the module to the new tab int newModuleID = modules.AddModule(newTabID, m.ModuleOrder, m.PaneName, m.ModuleTitle, newModuleDefID, m.CacheTime, m.AuthorizedEditRoles, m.AuthorizedViewRoles, m.AuthorizedAddRoles, m.AuthorizedDeleteRoles, m.AuthorizedPropertiesRoles, m.AuthorizedMoveModuleRoles, m.AuthorizedDeleteModuleRoles, m.ShowMobile, m.AuthorizedPublishingRoles, m.SupportWorkflow, m.ShowEveryWhere, m.SupportCollapsable); // At the end, get all ModuleSettings and save them in the new module SqlDataReader dr = GetModuleSettings(m.ModuleID, my3rdConnection); while (dr.Read()) { ModuleSettings.UpdateModuleSetting(newModuleID, dr["SettingName"].ToString(), dr["SettingValue"].ToString()); } dr.Close(); } } result.Close(); } catch { // Error? ignore Tab ... } } myReader.Close(); // Set the CustomSettings of the New Portal based in the Template Portal myReader = GetPortalCustomSettings(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { PortalSettings.UpdatePortalSetting(newPortalID, myReader["SettingName"].ToString(), myReader["SettingValue"].ToString()); } myReader.Close(); // close the conections myConnection.Close(); myConnection.Dispose(); my2ndConnection.Close(); my2ndConnection.Dispose(); my3rdConnection.Close(); my3rdConnection.Dispose(); // Create paths portals.CreatePortalPath(portalPath); return(newPortalID); }
/// <summary> /// The AddTabButton_Click server event handler /// on this page is used to add a new portal module /// into the tab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddTabButton_Click(Object sender, EventArgs e) { if (Page.IsValid) { // Hide error message in case there was a previous error. moduleError.Visible = false; // This allows the user to pick what type of people can view the module being added. // If Authorised Roles is selected from the dropdown then every role that has view permission for the // Add Role module will be added to the view permissions of the module being added. string viewPermissionRoles = PermissionDropDown.SelectedValue.ToString(); if (viewPermissionRoles == "Authorised Roles") { viewPermissionRoles = Rainbow.Security.PortalSecurity.GetViewPermissions(this.ModuleID); } try { // New tabs go to the end of the list TabItem t = new TabItem(); t.Name = TabTitleTextBox.Text; t.ID = -1; t.Order = 990000; // Get Parent Tab Id Convert only once used many times int parentTabID = int.Parse(this.parentTabDropDown.SelectedValue); // write tab to database TabsDB tabs = new TabsDB(); //t.ID = tabs.AddTab(portalSettings.PortalID, t.Name, viewPermissionRoles, t.Order); // Changed to use new method in TabsDB.cs now all parms are posible // By Mike Stone ([email protected]) - 30/12/2004 t.ID = tabs.AddTab(portalSettings.PortalID, parentTabID, t.Name, t.Order, viewPermissionRoles, cb_ShowMobile.Checked, tb_MobileTabName.Text); //TODO.. the only way to update a parent id is throught update :S // Changed to AddTab method now supports the parm // Mike Stone - 30/12/2004 //tabs.UpdateTab(portalSettings.PortalID, t.ID, parentTabID, t.Name, t.Order, viewPermissionRoles, t.Name, false); //Invalidate cache // Changed to access form directly // mike stone - 30/12/2004 // Cache.Remove(Rainbow.Settings.Cache.Key.TabSettings(parentTabID)); // Copied to here 29/12/2004 by Mike Stone Rainbow.Settings.Cache.CurrentCache.RemoveAll("_TabNavigationSettings_"); System.Diagnostics.Debug.WriteLine("************* Remove " + Rainbow.Settings.Cache.Key.TabSettings(parentTabID)); //Jump to Page option string returnTab = string.Empty; if (rbl_JumpToTab.SelectedValue.ToString() == "Yes") { // Redirect to New Page/Tab - Mike Stone 30/12/2004 returnTab = Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", t.ID, "SelectedTabID=" + t.ID.ToString()); } else { // Do NOT Redirect to New Form - Mike Stone 30/12/2004 // I guess every .aspx page needs to have a module tied to it. // or you will get an error about edit access denied. returnTab = Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", int.Parse(Request.QueryString["tabID"]), "SelectedTabID=" + t.ID.ToString()); } Response.Redirect(returnTab); } catch (Exception ex) { moduleError.Visible = true; //Helpers.LogHelper.Logger.Log(Rainbow.Configuration.LogLevel.Error, "There was an error with the Add Tab Module while trying to add a new tab.",ex); Rainbow.Configuration.ErrorHandler.HandleException("There was an error with the Add Tab Module while trying to add a new tab.", ex); return; } // Reload page to pick up changes Response.Redirect(Request.RawUrl, false); } }
/// <summary> /// The BindData helper method is used to update the tab's /// layout panes with the current configuration information /// </summary> private void BindData() { TabSettings tab = portalSettings.ActiveTab; // Populate Tab Names, etc. tabName.Text = "New Tab"; mobileTabName.Text = ""; showMobile.Checked = false; // Populate the "ParentTab" Data TabsDB t = new TabsDB(); SqlDataReader dr = t.GetTabsParent(portalSettings.PortalID, TabID); parentTab.DataSource = dr; parentTab.DataBind(); dr.Close(); //by Manu, fixed bug 807858 // added by Jonathan Fong 05/08/2004 to support LDAP // www.gt.com.au bool useMemberList = HttpContext.Current.User is System.Security.Principal.WindowsPrincipal; useMemberList |= System.Configuration.ConfigurationSettings.AppSettings["LDAPLogin"] != null ? true : false; if (useMemberList) { memRoles.Visible = true; authRoles.Visible = false; memRoles.Members = tab.AuthorizedRoles; } else { // Populate checkbox list with all security roles for this portal // and "check" the ones already configured for this tab UsersDB users = new UsersDB(); SqlDataReader roles = users.GetPortalRoles(portalSettings.PortalID); // Clear existing items in checkboxlist authRoles.Items.Clear(); ListItem allItem = new ListItem(); allItem.Text = "All Users"; if (tab.AuthorizedRoles.LastIndexOf("All Users") > -1) { allItem.Selected = true; } authRoles.Items.Add(allItem); // Authenticated user role added // 15 nov 2002 - by manudea ListItem authItem = new ListItem(); authItem.Text = "Authenticated Users"; if (tab.AuthorizedRoles.LastIndexOf("Authenticated Users") > -1) { authItem.Selected = true; } authRoles.Items.Add(authItem); // end authenticated user role added while (roles.Read()) { ListItem item = new ListItem(); item.Text = (string)roles["RoleName"]; item.Value = roles["RoleID"].ToString(); if ((tab.AuthorizedRoles.LastIndexOf(item.Text)) > -1) { item.Selected = true; } authRoles.Items.Add(item); } roles.Close(); //by Manu, fixed bug 807858 } }
/// <summary> /// The BindData helper method is used to update the tab's /// layout panes with the current configuration information /// </summary> private void BindData() { TabSettings tab = portalSettings.ActiveTab; // Populate Tab Names, etc. tabName.Text = tab.TabName; mobileTabName.Text = tab.MobileTabName; showMobile.Checked = tab.ShowMobile; // Populate the "ParentTab" Data TabsDB t = new TabsDB(); SqlDataReader dr = t.GetTabsParent(portalSettings.PortalID, TabID); parentTab.DataSource = dr; parentTab.DataBind(); dr.Close(); //by Manu, fixed bug 807858 if (parentTab.Items.FindByValue(tab.ParentTabID.ToString()) != null) { parentTab.Items.FindByValue(tab.ParentTabID.ToString()).Selected = true; } // Translate if (parentTab.Items.FindByText(" ROOT_LEVEL") != null) { parentTab.Items.FindByText(" ROOT_LEVEL").Text = Esperantus.Localize.GetString("ROOT_LEVEL", "Root Level", parentTab); } // added by Jonathan Fong 05/08/2004 to support LDAP // www.gt.com.au bool useMemberList = HttpContext.Current.User is System.Security.Principal.WindowsPrincipal; useMemberList |= System.Configuration.ConfigurationSettings.AppSettings["LDAPLogin"] != null ? true : false; if (useMemberList) { memRoles.Visible = true; authRoles.Visible = false; memRoles.Members = tab.AuthorizedRoles; } else { // Populate checkbox list with all security roles for this portal // and "check" the ones already configured for this tab UsersDB users = new UsersDB(); SqlDataReader roles = users.GetPortalRoles(portalSettings.PortalID); // Clear existing items in checkboxlist authRoles.Items.Clear(); ListItem allItem = new ListItem(); allItem.Text = "All Users"; if (tab.AuthorizedRoles.LastIndexOf("All Users") > -1) { allItem.Selected = true; } authRoles.Items.Add(allItem); // Authenticated user role added // 15 nov 2002 - by manudea ListItem authItem = new ListItem(); authItem.Text = "Authenticated Users"; if (tab.AuthorizedRoles.LastIndexOf("Authenticated Users") > -1) { authItem.Selected = true; } authRoles.Items.Add(authItem); // end authenticated user role added while (roles.Read()) { ListItem item = new ListItem(); item.Text = (string)roles["RoleName"]; item.Value = roles["RoleID"].ToString(); if ((tab.AuthorizedRoles.LastIndexOf(item.Text)) > -1) { item.Selected = true; } authRoles.Items.Add(item); } roles.Close(); //by Manu, fixed bug 807858 } // Populate the "Add Module" Data ModulesDB m = new ModulesDB(); SqlDataReader drCurrentModuleDefinitions = m.GetCurrentModuleDefinitions(portalSettings.PortalID); try { while (drCurrentModuleDefinitions.Read()) { if (PortalSecurity.IsInRoles("Admins") == true || !(bool.Parse(drCurrentModuleDefinitions["Admin"].ToString()))) { moduleType.Items.Add(new ListItem(drCurrentModuleDefinitions["FriendlyName"].ToString(), drCurrentModuleDefinitions["ModuleDefID"].ToString())); } } } finally { drCurrentModuleDefinitions.Close(); } // Populate Right Hand Module Data rightList = GetModules("RightPane"); rightPane.DataBind(); // Populate Content Pane Module Data contentList = GetModules("ContentPane"); contentPane.DataBind(); // Populate Left Hand Pane Module Data leftList = GetModules("LeftPane"); leftPane.DataBind(); }