/// <summary> /// The AddPage_Click server event handler is used /// to add a new tab for this portal /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="T:System.EventArgs"/> instance containing the event data. /// </param> /// <remarks> /// </remarks> protected void AddPageClick(object sender, EventArgs e) { if (this.Settings["TAB_VERSION"] == null) { return; } if (this.Settings["TAB_VERSION"].ToString().ToLowerInvariant() == "true") { // Use Old Version // New tabs go to the end of the list var t = new PageItem { // Just in case it comes to be empty Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; this.PortalPages.Add(t); // write tab to database var tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order); // Reset the order numbers for the tabs within the list this.OrderPages(); // Clear SiteMaps Cache AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches(); // Redirect to edit page // 3_aug_2004 Cory Isakson added returntabid so that PageLayout could return to the tab it was called from. // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09) this.Response.Redirect( HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Pages/PageLayout.aspx", t.ID, "mID=" + this.ModuleID + "&returntabid=" + this.Page.PageID)); } else { // Redirect to New Form - Mike Stone 19/12/2004 this.Response.Redirect( HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Pages/AddPage.aspx", "mID=" + this.ModuleID + "&returntabid=" + this.Page.PageID)); } }
/// <summary> /// The AddPage_Click server event handler is used /// to add a new tab for this portal /// </summary> /// <param name="Sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void AddPage_Click(Object Sender, EventArgs e) { if (Settings["TAB_VERSION"] != null) { if (Settings["TAB_VERSION"].ToString() == "True") // Use Old Version { // New tabs go to the end of the list PageItem t = new PageItem(); t.Name = General.GetString("TAB_NAME", "New Page Name"); //Just in case it comes to be empty t.ID = -1; t.Order = 990000; portalPages.Add(t); // write tab to database PagesDB tabs = new PagesDB(); t.ID = tabs.AddPage(portalSettings.PortalID, t.Name, t.Order); // Reset the order numbers for the tabs within the list OrderPages(); //Clear SiteMaps Cache RainbowSiteMapProvider.ClearAllRainbowSiteMapCaches(); // Redirect to edit page // 3_aug_2004 Cory Isakson added returntabid so that PageLayout could return to the tab it was called from. // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09) Response.Redirect( HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx", t.ID, "mID=" + ModuleID.ToString() + "&returntabid=" + Page.PageID)); } else { // Redirect to New Form - Mike Stone 19/12/2004 Response.Redirect( HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/AddPage.aspx", "mID=" + ModuleID.ToString() + "&returntabid=" + Page.PageID)); } } }
public JsonResult create(string pageid, string pagename) { try { if ((UserProfile.isCurrentUserAdmin) || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_CREATION)) { pageid = pageid.Trim('"'); PagesDB db = new PagesDB(); this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID); var t = new PageItem { Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; if (!string.IsNullOrEmpty(pagename)) { t.Name = pagename; } this.PortalPages.Add(t); var tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order); db.UpdatePageParent(t.ID, Convert.ToInt32(pageid), this.PortalSettings.PortalID); this.OrderPages(); return(Json("")); } else { string errorMessage = General.GetString("ACCESS_DENIED", "You don't have permissin to add new page", this); return(Json(new { error = true, errorMess = errorMessage })); } } catch (Exception) { string errorMessage = General.GetString("ADD_NEW_PAGE_FAILED", "Failed to add new Page", this); return(Json(new { error = true, errorMess = errorMessage })); } }
public JsonResult create(int id) { PagesDB db = new PagesDB(); this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID); var t = new PageItem { Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; this.PortalPages.Add(t); var tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order); db.UpdatePageParent(t.ID, id, this.PortalSettings.PortalID); this.OrderPages(); //JsonResult treeData = GetTreeData(); return(Json("")); }
public JsonResult Clone(int id, int parentId) { try { var generalModuleDef = Guid.Parse("F9F9C3A4-6E16-43B4-B540-984DDB5F1CD2"); object[] queryargs = { generalModuleDef, PortalSettings.PortalID }; int moduleDefinition; try { moduleDefinition = new rb_ModuleDefinitions().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID; } catch (Exception e) { // Shortcut module doesn't exist in current Portal var modules = new ModulesDB(); modules.UpdateModuleDefinitions( generalModuleDef, PortalSettings.PortalID, true); moduleDefinition = new rb_ModuleSettings().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID; } var db = new PagesDB(); PortalPages = db.GetPagesFlat(PortalSettings.PortalID); var t = new PageItem { Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; PortalPages.Add(t); var tabs = new PagesDB(); t.ID = tabs.AddPage(PortalSettings.PortalID, t.Name, t.Order); db.UpdatePageParent(t.ID, parentId, PortalSettings.PortalID); OrderPages(); //JsonResult treeData = GetTreeData(); // Coping Modules var pagesModules = new rb_Modules().All(where : "TabID = @0", args: id); foreach (var module in pagesModules) { var m = new ModuleItem(); m.Title = module.ModuleTitle; m.ModuleDefID = moduleDefinition; m.Order = module.ModuleOrder; // save to database var mod = new ModulesDB(); m.ID = mod.AddModule( t.ID, m.Order, module.PaneName, module.ModuleTitle, m.ModuleDefID, 0, module.AuthorizedEditRoles, module.AuthorizedViewRoles, module.AuthorizedAddRoles, module.AuthorizedDeleteRoles, module.AuthorizedPropertiesRoles, module.AuthorizedMoveModuleRoles, module.AuthorizedDeleteModuleRoles, false, PortalSecurity.GetDeleteModulePermissions(module.ModuleID), false, false, false); var settings = new rb_ModuleSettings(); settings.Insert(new { ModuleID = m.ID, SettingName = "LinkedModule", SettingValue = module.ModuleID }); } return(Json(new { pageId = t.ID })); } catch (Exception e) { ErrorHandler.Publish(LogLevel.Error, e); Response.StatusCode = 500; return(Json("")); } }
/// <summary> /// Creates the portal. /// </summary> /// <param name="templateID">The template ID.</param> /// <param name="templateAlias">The template alias.</param> /// <param name="portalAlias">The portal alias.</param> /// <param name="portalName">Name of the portal.</param> /// <param name="portalPath">The portal path.</param> /// <returns></returns> private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName, string portalPath) { int newPortalID; PortalsDB portals = new PortalsDB(); PagesDB tabs = new PagesDB(); 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(); // TODO: Is this still valid? Admin user will be created the first time the portal is accessed //if (!Config.UseSingleUserBase) //{ // // TODO: multiple portals still not supported // Guid userID; // // 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("admin", 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["PageID"]; tab.newID = tabs.AddPage(newPortalID, myReader["PageName"].ToString(), Int32.Parse(myReader["PageOrder"].ToString())); templateTabs.Add(tab); } myReader.Close(); //Clear SiteMaps Cache RainbowSiteMapProvider.ClearAllRainbowSiteMapCaches(); // 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 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["PageID"]) { newTabID = tab.newID; } if (tab.oldID == Int32.Parse("0" + myReader["ParentPageID"])) { newParentTabID = tab.newID; } } if (newParentTabID == -1) { newParentTabID = 0; } // Update the Tab in the new portal tabs.UpdatePage(newPortalID, newTabID, newParentTabID, myReader["PageName"].ToString(), Int32.Parse(myReader["PageOrder"].ToString()), myReader["AuthorizedRoles"].ToString(), myReader["MobilePageName"].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 = GetPageModules(Int32.Parse(myReader["PageID"].ToString()), my2ndConnection); object myValue; while (result.Read()) { ModuleSettings m = new ModuleSettings(); m.ModuleID = (int)result["ModuleID"]; m.ModuleDefID = (int)result["ModuleDefID"]; m.PageID = 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 = PortalSecurity.GetViewPermissions(ModuleID); } try { // New tabs go to the end of the list PageItem t = new PageItem(); t.Name = TabTitleTextBox.Text; t.ID = -1; t.Order = 990000; // Get Parent Tab Id Convert only once used many times var parentTabID = int.Parse(parentTabDropDown.SelectedValue); // write tab to database PagesDB tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, parentTabID, t.Name, t.Order, viewPermissionRoles, cb_ShowMobile.Checked, tb_MobileTabName.Text); CurrentCache.RemoveAll("_TabNavigationSettings_"); AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches(); //Jump to Page option string returnTab = string.Empty; if (rbl_JumpToTab.SelectedValue.ToString() == "Yes") { // Redirect to New Page/Tab - Mike Stone 30/12/2004 // modified by Hongwei Shen 9/25/2005 // returnTab = HttpUrlBuilder.BuildUrl(""~/"+HttpUrlBuilder.DefaultPage", t.ID, "SelectedTabID=" + t.ID.ToString()); string newPage = "~/" + t.Name.Trim().Replace(" ", "_") + ".aspx"; returnTab = HttpUrlBuilder.BuildUrl(newPage, t.ID); } 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. // Modified by Hongwei Shen 9/25/2005 to fix: QueryString["tabID"] maybe null. // returnTab = HttpUrlBuilder.BuildUrl("~/"+HttpUrlBuilder.DefaultPage, int.Parse(Request.QueryString["tabID"]), "SelectedTabID=" + t.ID.ToString()); returnTab = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, PageID, "SelectedTabID=" + t.ID.ToString()); } Response.Redirect(returnTab); } catch (Exception ex) { moduleError.Visible = true; ErrorHandler.Publish(LogLevel.Error, "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 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 = PortalSecurity.GetViewPermissions(ModuleID); } try { // New tabs go to the end of the list PageItem t = new PageItem(); t.Name = TabTitleTextBox.Text; t.ID = -1; t.Order = 990000; // Get Parent Tab Id Convert only once used many times int parentTabID = int.Parse(parentTabDropDown.SelectedValue); // write tab to database PagesDB tabs = new PagesDB(); //t.ID = tabs.AddTab(portalSettings.PortalID, t.Name, viewPermissionRoles, t.Order); // Changed to use new method in TabsDB.cs now all parms are possible // By Mike Stone ([email protected]) - 30/12/2004 t.ID = tabs.AddPage(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.Framework.Settings.Cache.Key.TabSettings(parentTabID)); // Copied to here 29/12/2004 by Mike Stone CurrentCache.RemoveAll("_TabNavigationSettings_"); //Debug.WriteLine("************* Remove " + Key.TabSettings(parentTabID)); //Clear SiteMaps Cache RainbowSiteMapProvider.ClearAllRainbowSiteMapCaches(); //Jump to Page option string returnTab = string.Empty; if (rbl_JumpToTab.SelectedValue.ToString() == "Yes") { // Redirect to New Page/Tab - Mike Stone 30/12/2004 // modified by Hongwei Shen 9/25/2005 // returnTab = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", t.ID, "SelectedTabID=" + t.ID.ToString()); string newPage = "~/" + t.Name.Trim().Replace(" ", "_") + ".aspx"; returnTab = HttpUrlBuilder.BuildUrl(newPage, t.ID); } 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. // Modified by Hongwei Shen 9/25/2005 to fix: QueryString["tabID"] maybe null. // returnTab = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", int.Parse(Request.QueryString["tabID"]), "SelectedTabID=" + t.ID.ToString()); returnTab = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", PageID, "SelectedTabID=" + t.ID.ToString()); } Response.Redirect(returnTab); } catch (Exception ex) { moduleError.Visible = true; ErrorHandler.Publish(LogLevel.Error, "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); } }