/// <Summary>UpdateRequiredFields updates which fields are required</Summary> private void UpdateRequiredFields() { if (chkCountry.Checked == false) { chkRegion.Checked = false; } PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addressstreet", (chkStreet.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addresscity", (chkCity.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addresscountry", (chkCountry.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addressregion", (chkRegion.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addresspostal", (chkPostal.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addresstelephone", (chkTelephone.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addresscell", (chkCell.Checked ? "" : "N").ToString()); PortalSettings.UpdatePortalSetting(PortalSettings.PortalId, "addressfax", (chkFax.Checked ? "" : "N").ToString()); ShowRequiredFields(); }
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); }
private void EditTable_UpdateControl(object sender, Rainbow.Configuration.SettingsTableEventArgs e) { SettingsTable edt = (SettingsTable)sender; PortalSettings.UpdatePortalSetting(edt.ObjectID, e.CurrentItem.EditControl.ID, e.CurrentItem.Value); }
private void EditTable_UpdateControl(object sender, SettingsTableEventArgs e) { PortalSettings.UpdatePortalSetting(portalSettings.PortalID, e.CurrentItem.EditControl.ID, e.CurrentItem.Value); }
private void EditTable_UpdateControl(object sender, SettingsTableEventArgs e) { PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalID, ((ISettingItem)e.CurrentItem).EditControl.ID, ((ISettingItem)e.CurrentItem).Value.ToString()); }
public void UpdatePortalSetting(int portalId, string key, string value) { PortalSettings.UpdatePortalSetting(portalId, key, value); }
/// <summary> /// Handles the UpdateControl event of the EditTable control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:Appleseed.Framework.Web.UI.WebControls.SettingsTableEventArgs"/> instance containing the event data.</param> private void EditTable_UpdateControl(object sender, SettingsTableEventArgs e) { SettingsTable edt = (SettingsTable)sender; PortalSettings.UpdatePortalSetting(edt.ObjectID, ((ISettingItem)e.CurrentItem).EditControl.ID, ((ISettingItem)e.CurrentItem).Value.ToString()); }
public void UpdateModule(ModuleInfo objModule) { // update module DataProvider.Instance().UpdateModule(objModule.ModuleID, objModule.ModuleTitle, objModule.AllTabs, objModule.Header, objModule.Footer, objModule.StartDate, objModule.EndDate, objModule.InheritViewPermissions, objModule.IsDeleted); // update module permissions ModulePermissionController objModulePermissionController = new ModulePermissionController(); ModulePermissionCollection objCurrentModulePermissions; objCurrentModulePermissions = objModulePermissionController.GetModulePermissionsCollectionByModuleID(objModule.ModuleID, objModule.TabID); if (!objCurrentModulePermissions.CompareTo(objModule.ModulePermissions)) { objModulePermissionController.DeleteModulePermissionsByModuleID(objModule.ModuleID); foreach (ModulePermissionInfo objModulePermission in objModule.ModulePermissions) { objModulePermission.ModuleID = objModule.ModuleID; if (objModule.InheritViewPermissions && objModulePermission.PermissionKey == "VIEW") { objModulePermissionController.DeleteModulePermission(objModulePermission.ModulePermissionID); } else { if (objModulePermission.AllowAccess) { objModulePermissionController.AddModulePermission(objModulePermission, objModule.TabID); } } } } if (!Null.IsNull(objModule.TabID)) { // update tabmodule DataProvider.Instance().UpdateTabModule(objModule.TabID, objModule.ModuleID, objModule.ModuleOrder, objModule.PaneName, objModule.CacheTime, objModule.Alignment, objModule.Color, objModule.Border, objModule.IconFile, (int)objModule.Visibility, objModule.ContainerSrc, objModule.DisplayTitle, objModule.DisplayPrint, objModule.DisplaySyndicate); // update module order in pane UpdateModuleOrder(objModule.TabID, objModule.ModuleID, objModule.ModuleOrder, objModule.PaneName); // set the default module if (objModule.IsDefaultModule) { PortalSettings.UpdatePortalSetting(objModule.PortalID, "defaultmoduleid", objModule.ModuleID.ToString()); PortalSettings.UpdatePortalSetting(objModule.PortalID, "defaulttabid", objModule.TabID.ToString()); } // apply settings to all desktop modules in portal if (objModule.AllModules) { TabController objTabs = new TabController(); foreach (KeyValuePair <int, TabInfo> tabPair in objTabs.GetTabsByPortal(objModule.PortalID)) { TabInfo objTab = tabPair.Value; if (!objTab.IsAdminTab) { foreach (KeyValuePair <int, ModuleInfo> modulePair in GetTabModules(objTab.TabID)) { ModuleInfo objTargetModule = modulePair.Value; DataProvider.Instance().UpdateTabModule(objTargetModule.TabID, objTargetModule.ModuleID, objTargetModule.ModuleOrder, objTargetModule.PaneName, objModule.CacheTime, objModule.Alignment, objModule.Color, objModule.Border, objModule.IconFile, (int)objModule.Visibility, objModule.ContainerSrc, objModule.DisplayTitle, objModule.DisplayPrint, objModule.DisplaySyndicate); } } } } } ClearCache(objModule.TabID); }