private static void UpgradeToVersion620() { //add host (system) profanityfilter list const string listName = "ProfanityFilter"; var listController = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = Null.NullInteger; entry.PortalID = Null.NullInteger; entry.ListName = listName; entry.Value = "ReplaceWithNothing"; entry.Text = "FindThisText"; entry.SystemList = true; } listController.AddListEntry(entry); //add same list to each portal foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { entry.PortalID = portal.PortalID; entry.SystemList = false; entry.ListName = listName + "-" + portal.PortalID; listController.AddListEntry(entry); //also create default social relationship entries for the portal RelationshipController.Instance.CreateDefaultRelationshipsForPortal(portal.PortalID); } //Convert old Messages to new schema ConvertOldMessages(); //Replace old Messaging module on User Profile with new ReplaceMessagingModule(); //Move Photo Property to the end of the propert list. MovePhotoProperty(); //Update Child Portal's Default Page UpdateChildPortalsDefaultPage(); //Add core notification types AddCoreNotificationTypesFor620(); //Console module should not be IPortable var consoleModule = DesktopModuleController.GetDesktopModuleByModuleName("Console", Null.NullInteger); consoleModule.SupportedFeatures = 0; consoleModule.BusinessControllerClass = ""; DesktopModuleController.SaveDesktopModule(consoleModule, false, false); }
private static void UpgradeToVersion710() { //create a placeholder entry - uses the most common 5 character password (seed list is 6 characters and above) const string listName = "BannedPasswords"; var listController = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = Null.NullInteger; entry.PortalID = Null.NullInteger; entry.ListName = listName; entry.Value = "12345"; entry.Text = "Placeholder"; entry.SystemList = false; } //add list to each portal and update primary alias foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { entry.PortalID = portal.PortalID; entry.SystemList = false; entry.ListName = listName + "-" + portal.PortalID; listController.AddListEntry(entry); var defaultAlias = PortalController.GetPortalSetting("DefaultPortalAlias", portal.PortalID, String.Empty); if (!String.IsNullOrEmpty(defaultAlias)) { foreach (var alias in PortalAliasController.Instance.GetPortalAliasesByPortalId(portal.PortalID).Where(alias => alias.HTTPAlias == defaultAlias)) { alias.IsPrimary = true; PortalAliasController.Instance.UpdatePortalAlias(alias); } } } // Add File Content Type var typeController = new ContentTypeController(); var contentTypeFile = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault(); if (contentTypeFile == null) { typeController.AddContentType(new ContentType { ContentType = "File" }); } var fileContentType = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault(); //only perform following for an existing installation upgrading if (Globals.Status == Globals.UpgradeStatus.Upgrade) { UpdateFoldersForParentId(); ImportDocumentLibraryCategories(); ImportDocumentLibraryCategoryAssoc(fileContentType); } //Add 404 Log var logTypeInfo = new LogTypeInfo { LogTypeKey = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(), LogTypeFriendlyName = "HTTP Error Code 404 Page Not Found", LogTypeDescription = "", LogTypeCSSClass = "OperationFailure", LogTypeOwner = "DotNetNuke.Logging.EventLogType" }; LogController.Instance.AddLogType(logTypeInfo); //Add LogType var logTypeConf = new LogTypeConfigInfo { LoggingIsActive = true, LogTypeKey = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(), KeepMostRecent = "100", NotificationThreshold = 1, NotificationThresholdTime = 1, NotificationThresholdTimeType = LogTypeConfigInfo.NotificationThresholdTimeTypes.Seconds, MailFromAddress = Null.NullString, MailToAddress = Null.NullString, LogTypePortalID = "*" }; LogController.Instance.AddLogTypeConfigInfo(logTypeConf); UninstallPackage("DotNetNuke.SearchInput"); //enable password strength meter for new installs only HostController.Instance.Update("EnableStrengthMeter", Globals.Status == Globals.UpgradeStatus.Install ? "Y" : "N"); //Add IP filter log type var logTypeFilterInfo = new LogTypeInfo { LogTypeKey = EventLogController.EventLogType.IP_LOGIN_BANNED.ToString(), LogTypeFriendlyName = "HTTP Error Code 403.6 forbidden ip address rejected", LogTypeDescription = "", LogTypeCSSClass = "OperationFailure", LogTypeOwner = "DotNetNuke.Logging.EventLogType" }; LogController.Instance.AddLogType(logTypeFilterInfo); //Add LogType var logTypeFilterConf = new LogTypeConfigInfo { LoggingIsActive = true, LogTypeKey = EventLogController.EventLogType.IP_LOGIN_BANNED.ToString(), KeepMostRecent = "100", NotificationThreshold = 1, NotificationThresholdTime = 1, NotificationThresholdTimeType = LogTypeConfigInfo.NotificationThresholdTimeTypes.Seconds, MailFromAddress = Null.NullString, MailToAddress = Null.NullString, LogTypePortalID = "*" }; LogController.Instance.AddLogTypeConfigInfo(logTypeFilterConf); int tabID = TabController.GetTabByTabPath(Null.NullInteger, "//Host//SearchAdmin", Null.NullString); if (tabID > Null.NullInteger) { TabController.Instance.DeleteTab(tabID, Null.NullInteger); } var modDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Search Admin"); if (modDef != null) AddAdminPages("Search Admin", "Manage search settings associated with DotNetNuke's search capability.", "~/Icons/Sigma/Search_16x16_Standard.png", "~/Icons/Sigma/Search_32x32_Standard.png", true, modDef.ModuleDefID, "Search Admin", ""); CopyGettingStartedStyles(); }
/// <summary> /// Handles cmdSaveEntry.Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList) /// </remarks> protected void OnSaveEntryClick(object sender, EventArgs e) { String entryValue; String entryText; if (UserInfo.IsSuperUser) { entryValue = txtEntryValue.Text; entryText = txtEntryText.Text; } else { var ps = new PortalSecurity(); entryValue = ps.InputFilter(txtEntryValue.Text, PortalSecurity.FilterFlag.NoScripting); entryText = ps.InputFilter(txtEntryText.Text, PortalSecurity.FilterFlag.NoScripting); } var listController = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = Null.NullInteger; entry.PortalID = ListPortalID; entry.ListName = ListName; entry.Value = entryValue; entry.Text = entryText; } if (Page.IsValid) { Mode = "ListEntries"; switch (cmdSaveEntry.CommandName.ToLower()) { case "update": entry.ParentKey = SelectedList.ParentKey; entry.EntryID = Int16.Parse(txtEntryID.Text); bool canUpdate = true; foreach (var curEntry in listController.GetListEntryInfoItems(SelectedList.Name, entry.ParentKey, entry.PortalID)) { if (entry.EntryID != curEntry.EntryID) //not the same item we are trying to update { if (entry.Value == curEntry.Value && entry.Text == curEntry.Text) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); canUpdate = false; break; } } } if (canUpdate) { listController.UpdateListEntry(entry); DataBind(); } break; case "saveentry": if (SelectedList != null) { entry.ParentKey = SelectedList.ParentKey; entry.ParentID = SelectedList.ParentID; entry.Level = SelectedList.Level; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } if (listController.AddListEntry(entry) == Null.NullInteger) //entry already found in database { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } DataBind(); break; case "savelist": if (ddlSelectParent.SelectedIndex != -1) { int parentID = Int32.Parse(ddlSelectParent.SelectedItem.Value); ListEntryInfo parentEntry = listController.GetListEntryInfo(parentID); entry.ParentID = parentID; entry.DefinitionID = parentEntry.DefinitionID; entry.Level = parentEntry.Level + 1; entry.ParentKey = parentEntry.Key; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } if (listController.AddListEntry(entry) == Null.NullInteger) //entry already found in database { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } else { SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName; Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey)); } break; } } }
/// <summary> /// Handles cmdSaveEntry.Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList) /// </remarks> protected void OnSaveEntryClick(object sender, EventArgs e) { String entryValue; String entryText; if (UserInfo.IsSuperUser) { entryValue = txtEntryValue.Text; entryText = txtEntryText.Text; } else { var ps = new PortalSecurity(); entryValue = ps.InputFilter(txtEntryValue.Text, PortalSecurity.FilterFlag.NoScripting); entryText = ps.InputFilter(txtEntryText.Text, PortalSecurity.FilterFlag.NoScripting); } var listController = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = Null.NullInteger; entry.PortalID = ListPortalID; entry.ListName = txtEntryName.Text; entry.Value = entryValue; entry.Text = entryText; } if (Page.IsValid) { Mode = "ListEntries"; switch (cmdSaveEntry.CommandName.ToLower()) { case "update": entry.ParentKey = SelectedList.ParentKey; entry.EntryID = Int16.Parse(txtEntryID.Text); bool canUpdate = true; foreach (var curEntry in listController.GetListEntryInfoItems(SelectedList.Name, entry.ParentKey, entry.PortalID)) { if (entry.EntryID != curEntry.EntryID) //not the same item we are trying to update { if (entry.Value == curEntry.Value && entry.Text == curEntry.Text) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); canUpdate = false; break; } } } if (canUpdate) { listController.UpdateListEntry(entry); DataBind(); } break; case "saveentry": if (SelectedList != null) { entry.ParentKey = SelectedList.ParentKey; entry.ParentID = SelectedList.ParentID; entry.Level = SelectedList.Level; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } if (listController.AddListEntry(entry) == Null.NullInteger) //entry already found in database { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } DataBind(); break; case "savelist": if (ddlSelectParent.SelectedIndex != -1) { int parentID = Int32.Parse(ddlSelectParent.SelectedItem.Value); ListEntryInfo parentEntry = listController.GetListEntryInfo(parentID); entry.ParentID = parentID; entry.DefinitionID = parentEntry.DefinitionID; entry.Level = parentEntry.Level + 1; entry.ParentKey = parentEntry.Key; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } if (listController.AddListEntry(entry) == Null.NullInteger) //entry already found in database { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } else { SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName; Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey)); } break; } } }
/// <summary> /// Handles cmdSaveEntry.Click /// </summary> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList) /// </remarks> /// <history> /// [tamttt] 20/10/2004 Created /// </history> protected void cmdSaveEntry_Click(object sender, EventArgs e) { ListController ctlLists = new ListController(); ListEntryInfo entry = new ListEntryInfo(); entry.ListName = txtEntryName.Text; entry.Value = txtEntryValue.Text; entry.Text = txtEntryText.Text; switch (cmdSaveEntry.CommandName.ToLower()) { case "update": entry.ParentKey = txtParentKey.Text; entry.EntryID = Int16.Parse(txtEntryID.Text); ctlLists.UpdateListEntry(entry); InitList(); EnableView(true); //BindListInfo() BindGrid(); break; case "saveentry": entry.ParentKey = txtParentKey.Text; if (EnableSortOrder) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } ctlLists.AddListEntry(entry); InitList(); BindListInfo(); BindTree(); BindGrid(); break; case "savelist": string strKey = ""; string strText = ""; if (ddlSelectParent.SelectedIndex != -1) { strKey = ddlSelectParent.SelectedItem.Value; strText = ddlSelectParent.SelectedItem.Text; entry.ParentKey = strKey; strKey += ":"; strText += ":"; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } ctlLists.AddListEntry(entry); strKey += this.txtEntryName.Text; strText += this.txtEntryName.Text; SelectedKey = strKey; SelectedText = strText; BindTree(); InitList(); BindListInfo(); BindGrid(); //Response.Redirect(NavigateURL(TabId)) break; } }
/// <summary> /// Creates the portal. /// </summary> /// <param name="portalName">Name of the portal.</param> /// <param name="adminUser">The obj admin user.</param> /// <param name="description">The description.</param> /// <param name="keyWords">The key words.</param> /// <param name="template"> </param> /// <param name="homeDirectory">The home directory.</param> /// <param name="portalAlias">The portal alias.</param> /// <param name="serverPath">The server path.</param> /// <param name="childPath">The child path.</param> /// <param name="isChildPortal">if set to <c>true</c> means the portal is child portal.</param> /// <returns>Portal id.</returns> public int CreatePortal(string portalName, UserInfo adminUser, string description, string keyWords, PortalTemplateInfo template, string homeDirectory, string portalAlias, string serverPath, string childPath, bool isChildPortal) { string message = Null.NullString; int administratorId = Null.NullInteger; //Attempt to create a new portal int portalId = CreatePortal(portalName, homeDirectory); string templatePath, templateFile; PrepareLocalizedPortalTemplate(template, out templatePath, out templateFile); string mergedTemplatePath = Path.Combine(templatePath, templateFile); if (portalId != -1) { if (String.IsNullOrEmpty(homeDirectory)) { homeDirectory = "Portals/" + portalId; } string mappedHomeDirectory = String.Format(Globals.ApplicationMapPath + "\\" + homeDirectory + "\\").Replace("/", "\\"); message += CreateProfileDefinitions(portalId, mergedTemplatePath); if (message == Null.NullString) { //add administrator try { adminUser.PortalID = portalId; UserCreateStatus createStatus = UserController.CreateUser(ref adminUser); if (createStatus == UserCreateStatus.Success) { administratorId = adminUser.UserID; //reload the UserInfo as when it was first created, it had no portal id and therefore //used host profile definitions adminUser = UserController.GetUserById(adminUser.PortalID, adminUser.UserID); } else { message += UserController.GetUserCreateStatus(createStatus); } } catch (Exception Exc) { Logger.Error(Exc); message += Localization.GetString("CreateAdminUser.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(message); } if (String.IsNullOrEmpty(message) && administratorId > 0) { try { //the upload directory may already exist if this is a new DB working with a previously installed application if (Directory.Exists(mappedHomeDirectory)) { Globals.DeleteFolderRecursive(mappedHomeDirectory); } } catch (Exception Exc) { Logger.Error(Exc); message += Localization.GetString("DeleteUploadFolder.Error") + Exc.Message + Exc.StackTrace; } //Set up Child Portal if (message == Null.NullString) { if (isChildPortal) { message = CreateChildPortalFolder(childPath); } } else { throw new Exception(message); } if (message == Null.NullString) { try { //create the upload directory for the new portal Directory.CreateDirectory(mappedHomeDirectory); //ensure that the Templates folder exists string templateFolder = String.Format("{0}Templates", mappedHomeDirectory); if (!Directory.Exists(templateFolder)) { Directory.CreateDirectory(templateFolder); } //ensure that the Users folder exists string usersFolder = String.Format("{0}Users", mappedHomeDirectory); if (!Directory.Exists(usersFolder)) { Directory.CreateDirectory(usersFolder); } //copy the default page template CopyPageTemplate("Default.page.template", mappedHomeDirectory); // process zip resource file if present if (File.Exists(template.ResourceFilePath)) { ProcessResourceFileExplicit(mappedHomeDirectory, template.ResourceFilePath); } //copy getting started css into portal's folder. var hostGettingStartedFile = string.Format("{0}GettingStarted.css", Globals.HostMapPath); if (File.Exists(hostGettingStartedFile)) { var portalFile = mappedHomeDirectory + "GettingStarted.css"; if (!File.Exists(portalFile)) { File.Copy(hostGettingStartedFile, portalFile); } } } catch (Exception Exc) { Logger.Error(Exc); message += Localization.GetString("ChildPortal.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(message); } if (message == Null.NullString) { try { FolderMappingController.Instance.AddDefaultFolderTypes(portalId); } catch (Exception Exc) { Logger.Error(Exc); message += Localization.GetString("DefaultFolderMappings.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(message); } LocaleCollection newPortalLocales = null; if (message == Null.NullString) { try { ParseTemplate(portalId, templatePath, templateFile, administratorId, PortalTemplateModuleAction.Replace, true, out newPortalLocales); } catch (Exception Exc) { Logger.Error(Exc); message += Localization.GetString("PortalTemplate.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(message); } if (message == Null.NullString) { var portal = GetPortal(portalId); portal.Description = description; portal.KeyWords = keyWords; portal.UserTabId = TabController.GetTabByTabPath(portal.PortalID, "//UserProfile", portal.CultureCode); if (portal.UserTabId == -1) { portal.UserTabId = TabController.GetTabByTabPath(portal.PortalID, "//ActivityFeed", portal.CultureCode); } portal.SearchTabId = TabController.GetTabByTabPath(portal.PortalID, "//SearchResults", portal.CultureCode); UpdatePortalInfo(portal); adminUser.Profile.PreferredLocale = portal.DefaultLanguage; var portalSettings = new PortalSettings(portal); adminUser.Profile.PreferredTimeZone = portalSettings.TimeZone; UserController.UpdateUser(portal.PortalID, adminUser); DesktopModuleController.AddDesktopModulesToPortal(portalId); AddPortalAlias(portalId, portalAlias); if (newPortalLocales != null) { foreach (Locale newPortalLocale in newPortalLocales.AllValues) { Localization.AddLanguageToPortal(portalId, newPortalLocale.LanguageId, false); } } try { RelationshipController.Instance.CreateDefaultRelationshipsForPortal(portalId); } catch (Exception Exc) { Logger.Error(Exc); } //add profanity list to new portal try { const string listName = "ProfanityFilter"; var listController = new ListController(); var entry = new ListEntryInfo(); entry.PortalID = portalId; entry.SystemList = false; entry.ListName = listName + "-" + portalId; listController.AddListEntry(entry); } catch (Exception Exc) { Logger.Error(Exc); } //add banned password list to new portal try { const string listName = "BannedPasswords"; var listController = new ListController(); var entry = new ListEntryInfo(); entry.PortalID = portalId; entry.SystemList = false; entry.ListName = listName + "-" + portalId; listController.AddListEntry(entry); } catch (Exception Exc) { Logger.Error(Exc); } // Add default workflows try { ContentWorkflowController.Instance.CreateDefaultWorkflows(portalId); } catch (Exception ex) { Logger.Error(ex); } ServicesRoutingManager.ReRegisterServiceRoutesWhileSiteIsRunning(); try { var objEventLogInfo = new LogInfo(); objEventLogInfo.BypassBuffering = true; objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(); objEventLogInfo.LogProperties.Add(new LogDetailInfo("Install Portal:", portalName)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("FirstName:", adminUser.FirstName)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("LastName:", adminUser.LastName)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("Username:"******"Email:", adminUser.Email)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("Description:", description)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("Keywords:", keyWords)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("Template:", template.TemplateFilePath)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("TemplateCulture:", template.CultureCode)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("HomeDirectory:", homeDirectory)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("PortalAlias:", portalAlias)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("ServerPath:", serverPath)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("ChildPath:", childPath)); objEventLogInfo.LogProperties.Add(new LogDetailInfo("IsChildPortal:", isChildPortal.ToString())); var eventLog = new EventLogController(); eventLog.AddLog(objEventLogInfo); } catch (Exception exc) { Logger.Error(exc); } } else { throw new Exception(message); } } else { DeletePortalInfo(portalId); portalId = -1; throw new Exception(message); } } else { message += Localization.GetString("CreatePortal.Error"); throw new Exception(message); } return portalId; }
/// ----------------------------------------------------------------------------- /// <summary> /// Handles cmdSaveEntry.Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList) /// </remarks> /// <history> /// [tamttt] 20/10/2004 Created /// [cnurse] 01/30/2007 Extracted to separte user control /// </history> /// ----------------------------------------------------------------------------- protected void OnSaveEntryClick(object sender, EventArgs e) { var ctlLists = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = Null.NullInteger; entry.PortalID = ListPortalID; entry.ListName = txtEntryName.Text; entry.Value = txtEntryValue.Text; entry.Text = txtEntryText.Text; } if (Page.IsValid) { Mode = "ListEntries"; switch (cmdSaveEntry.CommandName.ToLower()) { case "update": entry.ParentKey = SelectedList.ParentKey; entry.EntryID = Int16.Parse(txtEntryID.Text); ctlLists.UpdateListEntry(entry); DataBind(); break; case "saveentry": if (SelectedList != null) { entry.ParentKey = SelectedList.ParentKey; entry.ParentID = SelectedList.ParentID; entry.Level = SelectedList.Level; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } ctlLists.AddListEntry(entry); DataBind(); break; case "savelist": if (ddlSelectParent.SelectedIndex != -1) { int parentID = Int32.Parse(ddlSelectParent.SelectedItem.Value); ListEntryInfo parentEntry = ctlLists.GetListEntryInfo(parentID); entry.ParentID = parentID; entry.DefinitionID = parentEntry.DefinitionID; entry.Level = parentEntry.Level + 1; entry.ParentKey = parentEntry.Key; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } ctlLists.AddListEntry(entry); SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName; Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey)); break; } } }
/// <summary> /// Handles cmdSaveEntry.Click /// </summary> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList) /// </remarks> /// <history> /// [tamttt] 20/10/2004 Created /// </history> protected void cmdSaveEntry_Click( object sender, EventArgs e ) { ListController ctlLists = new ListController(); ListEntryInfo entry = new ListEntryInfo(); entry.ListName = txtEntryName.Text; entry.Value = txtEntryValue.Text; entry.Text = txtEntryText.Text; switch (cmdSaveEntry.CommandName.ToLower()) { case "update": entry.ParentKey = txtParentKey.Text; entry.EntryID = Int16.Parse(txtEntryID.Text); ctlLists.UpdateListEntry(entry); InitList(); EnableView(true); //BindListInfo() BindGrid(); break; case "saveentry": entry.ParentKey = txtParentKey.Text; if (EnableSortOrder) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } ctlLists.AddListEntry(entry); InitList(); BindListInfo(); BindTree(); BindGrid(); break; case "savelist": string strKey = ""; string strText = ""; if (ddlSelectParent.SelectedIndex != -1) { strKey = ddlSelectParent.SelectedItem.Value; strText = ddlSelectParent.SelectedItem.Text; entry.ParentKey = strKey; strKey += ":"; strText += ":"; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } ctlLists.AddListEntry(entry); strKey += this.txtEntryName.Text; strText += this.txtEntryName.Text; SelectedKey = strKey; SelectedText = strText; BindTree(); InitList(); BindListInfo(); BindGrid(); //Response.Redirect(NavigateURL(TabId)) break; } }
/// ----------------------------------------------------------------------------- /// <summary> /// Handles cmdSaveEntry.Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList) /// </remarks> /// <history> /// [tamttt] 20/10/2004 Created /// [cnurse] 01/30/2007 Extracted to separte user control /// </history> /// ----------------------------------------------------------------------------- protected void OnSaveEntryClick(object sender, EventArgs e) { var ctlLists = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = Null.NullInteger; entry.PortalID = ListPortalID; entry.ListName = txtEntryName.Text; entry.Value = txtEntryValue.Text; entry.Text = txtEntryText.Text; } if (Page.IsValid) { Mode = "ListEntries"; switch (cmdSaveEntry.CommandName.ToLower()) { case "update": entry.ParentKey = SelectedList.ParentKey; entry.EntryID = Int16.Parse(txtEntryID.Text); ctlLists.UpdateListEntry(entry); DataBind(); break; case "saveentry": if (SelectedList != null) { entry.ParentKey = SelectedList.ParentKey; entry.ParentID = SelectedList.ParentID; entry.Level = SelectedList.Level; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } //save the list as system list when its edit by host user. entry.SystemList = ListPortalID == Null.NullInteger; ctlLists.AddListEntry(entry); DataBind(); break; case "savelist": if (ddlSelectParent.SelectedIndex != -1) { int parentID = Int32.Parse(ddlSelectParent.SelectedItem.Value); ListEntryInfo parentEntry = ctlLists.GetListEntryInfo(parentID); entry.ParentID = parentID; entry.DefinitionID = parentEntry.DefinitionID; entry.Level = parentEntry.Level + 1; entry.ParentKey = parentEntry.Key; } if (chkEnableSortOrder.Checked) { entry.SortOrder = 1; } else { entry.SortOrder = 0; } //save the list as system list when its edit by host user. entry.SystemList = ListPortalID == Null.NullInteger; ctlLists.AddListEntry(entry); SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName; Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey)); break; } } }