public bool FoundBannedPassword(string inputString) { const string listName = "BannedPasswords"; var listController = new ListController(); PortalSettings settings = PortalController.GetCurrentPortalSettings(); IEnumerable<ListEntryInfo> listEntryHostInfos = listController.GetListEntryInfoItems(listName, "", Null.NullInteger); IEnumerable<ListEntryInfo> listEntryPortalInfos = listController.GetListEntryInfoItems(listName + "-" + settings.PortalId, "", settings.PortalId); IEnumerable<ListEntryInfo> query2 = listEntryHostInfos.Where(test => test.Text == inputString); IEnumerable<ListEntryInfo> query3 = listEntryPortalInfos.Where(test => test.Text == inputString); if (query2.Any() || query3.Any()) { return true; } return false; }
/// <summary> /// Select a list in dropdownlist /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectListIndexChanged(object sender, EventArgs e) { var ctlLists = new ListController(); if (!String.IsNullOrEmpty(ddlSelectList.SelectedValue)) { ListInfo selList = GetList(ddlSelectList.SelectedItem.Value, false); { ddlSelectParent.Enabled = true; ddlSelectParent.DataSource = ctlLists.GetListEntryInfoItems(selList.Name, selList.ParentKey); ddlSelectParent.DataTextField = "DisplayName"; ddlSelectParent.DataValueField = "EntryID"; ddlSelectParent.DataBind(); } } else { ddlSelectParent.Enabled = false; ddlSelectParent.Items.Clear(); } }
void OnItemChanged(object sender, PropertyEditorEventArgs e) { var regionContainer = ControlUtilities.FindControl<Control>(Parent, "Region", true); if (regionContainer != null) { var regionControl = ControlUtilities.FindFirstDescendent<DNNRegionEditControl>(regionContainer); if (regionControl != null) { var listController = new ListController(); var countries = listController.GetListEntryInfoItems("Country"); foreach (var checkCountry in countries) { if (checkCountry.Text == e.StringValue) { var attributes = new object[1]; attributes[0] = new ListAttribute("Region", "Country." + checkCountry.Value, ListBoundField.Text, ListBoundField.Text); regionControl.CustomAttributes = attributes; break; } } } } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/15/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); cmdDisplay.Click += OnDisplayClick; try { //If this is the first visit to the page, bind the role data to the datalist if (Page.IsPostBack == false) { var strSiteLogStorage = "D"; if (!string.IsNullOrEmpty(Host.SiteLogStorage)) { strSiteLogStorage = Host.SiteLogStorage; } if (strSiteLogStorage == "F") { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FileSystem", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); cmdDisplay.Visible = false; } else { switch (PortalSettings.SiteLogHistory) { case -1: //unlimited break; case 0: UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("LogDisabled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); break; default: UI.Skins.Skin.AddModuleMessage(this, string.Format(Localization.GetString("LogHistory", LocalResourceFile), PortalSettings.SiteLogHistory), ModuleMessage.ModuleMessageType.YellowWarning); break; } cmdDisplay.Visible = true; } var ctlList = new ListController(); var colSiteLogReports = ctlList.GetListEntryInfoItems("Site Log Reports"); cboReportType.DataSource = colSiteLogReports; cboReportType.DataBind(); cboReportType.SelectedIndex = 0; diStartDate.SelectedDate = DefaultBeginDate; diEndDate.SelectedDate = DefaultEndDate; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); jQuery.RequestDnnPluginsRegistration(); cboBillingFrequency.SelectedIndexChanged += OnBillingFrequencyIndexChanged; cboTrialFrequency.SelectedIndexChanged += OnTrialFrequencyIndexChanged; cmdDelete.Click += OnDeleteClick; cmdManage.Click += OnManageClick; cmdUpdate.Click += OnUpdateClick; txtRSVPCode.TextChanged += OnRsvpCodeChanged; try { if ((Request.QueryString["RoleID"] != null)) { _roleID = Int32.Parse(Request.QueryString["RoleID"]); } var objPortalInfo = PortalController.Instance.GetPortal(PortalSettings.PortalId); if ((objPortalInfo == null || string.IsNullOrEmpty(objPortalInfo.ProcessorUserId))) { //Warn users about fee based roles if we have a Processor Id lblProcessorWarning.Visible = true; } else { divServiceFee.Visible = true; divBillingPeriod.Visible = true; divTrialFee.Visible = true; divTrialPeriod.Visible = true; } if (Page.IsPostBack == false) { cmdCancel.NavigateUrl = Globals.NavigateURL(); var ctlList = new ListController(); var colFrequencies = ctlList.GetListEntryInfoItems("Frequency", ""); cboBillingFrequency.DataSource = colFrequencies; cboBillingFrequency.DataBind(); cboBillingFrequency.FindItemByValue("N").Selected = true; cboTrialFrequency.DataSource = colFrequencies; cboTrialFrequency.DataBind(); cboTrialFrequency.FindItemByValue("N").Selected = true; securityModeList.Items.Clear(); foreach (var enumValue in Enum.GetValues(typeof(SecurityMode))) { var enumName = Enum.GetName(typeof(SecurityMode), enumValue); var enumItem = new ListItem(enumName, ((int)enumValue).ToString(CultureInfo.InvariantCulture)); securityModeList.AddItem(enumItem.Text, enumItem.Value); } statusList.Items.Clear(); foreach (var enumValue in Enum.GetValues(typeof(RoleStatus))) { var enumName = Enum.GetName(typeof(RoleStatus), enumValue); var enumItem = new ListItem(enumName, ((int)enumValue).ToString(CultureInfo.InvariantCulture)); statusList.AddItem(enumItem.Text, enumItem.Value); } BindGroups(); ctlIcon.FileFilter = Globals.glbImageFileTypes; if (_roleID != -1) { var role = RoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == _roleID); if (role != null) { lblRoleName.Visible = role.IsSystemRole; txtRoleName.Visible = !role.IsSystemRole; valRoleName.Enabled = !role.IsSystemRole; lblRoleName.Text = role.RoleName; txtRoleName.Text = role.RoleName; txtDescription.Text = role.Description; if (cboRoleGroups.FindItemByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)) != null) { cboRoleGroups.ClearSelection(); cboRoleGroups.FindItemByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)).Selected = true; } if (!String.IsNullOrEmpty(role.BillingFrequency)) { if (role.ServiceFee > 0) { txtServiceFee.Text = role.ServiceFee.ToString("N2", CultureInfo.CurrentCulture); txtBillingPeriod.Text = role.BillingPeriod.ToString(CultureInfo.InvariantCulture); if (cboBillingFrequency.FindItemByValue(role.BillingFrequency) != null) { cboBillingFrequency.ClearSelection(); cboBillingFrequency.FindItemByValue(role.BillingFrequency).Selected = true; } } } if (!String.IsNullOrEmpty(role.TrialFrequency)) { if (role.TrialFee > 0) { txtTrialFee.Text = role.TrialFee.ToString("N2", CultureInfo.CurrentCulture); txtTrialPeriod.Text = role.TrialPeriod.ToString(CultureInfo.InvariantCulture); if (cboTrialFrequency.FindItemByValue(role.TrialFrequency) != null) { cboTrialFrequency.ClearSelection(); cboTrialFrequency.FindItemByValue(role.TrialFrequency).Selected = true; } } } if (securityModeList.FindItemByValue(Convert.ToString((int)role.SecurityMode)) != null) { securityModeList.ClearSelection(); securityModeList.FindItemByValue(Convert.ToString((int)role.SecurityMode)).Selected = true; } if (statusList.FindItemByValue(Convert.ToString((int)role.Status)) != null) { statusList.ClearSelection(); statusList.FindItemByValue(Convert.ToString((int)role.Status)).Selected = true; } chkIsPublic.Checked = role.IsPublic; chkAutoAssignment.Checked = role.AutoAssignment; txtRSVPCode.Text = role.RSVPCode; if (!String.IsNullOrEmpty(txtRSVPCode.Text)) { lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?rsvp=" + txtRSVPCode.Text + "&portalid=" + PortalId; } ctlIcon.Url = role.IconFile; UpdateFeeTextBoxes(); cmdManage.Visible = role.Status == RoleStatus.Approved; } else //security violation attempt to access item not related to this Module { Response.Redirect(Globals.NavigateURL("Security Roles")); } if (role.IsSystemRole) //disable controls if it's a system role { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SystemRoleWarning.Text", LocalResourceFile), ModuleMessage.ModuleMessageType.BlueInfo); ActivateControls(false); } if (_roleID == PortalSettings.RegisteredRoleId) { cmdManage.Visible = false; } } else { cmdDelete.Visible = false; cmdManage.Visible = false; lblRoleName.Visible = false; txtRoleName.Visible = true; statusList.SelectedIndex = 1; //select default role group id if (Request.QueryString["RoleGroupID"] != null) { var roleGroupID = Request.QueryString["RoleGroupID"]; if (cboRoleGroups.FindItemByValue(roleGroupID) != null) { cboRoleGroups.ClearSelection(); cboRoleGroups.FindItemByValue(roleGroupID).Selected = true; } } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private void BindPaymentProcessor(PortalInfo portal) { var listController = new ListController(); currencyCombo.DataSource = listController.GetListEntryInfoItems("Currency", ""); var currency = portal.Currency; if (String.IsNullOrEmpty(currency)) { currency = "USD"; } currencyCombo.DataBind(currency); processorCombo.DataSource = listController.GetListEntryInfoItems("Processor", ""); processorCombo.DataBind(); processorCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", ""); processorCombo.Select(Host.PaymentProcessor, true); // use sandbox? var usePayPalSandbox = Boolean.Parse(PortalController.GetPortalSetting("paypalsandbox", portal.PortalID, "false")); chkPayPalSandboxEnabled.Checked = usePayPalSandbox; if (usePayPalSandbox) { processorLink.NavigateUrl = "https://developer.paypal.com"; } else { processorLink.NavigateUrl = Globals.AddHTTP(processorCombo.SelectedItem.Value); } txtUserId.Text = portal.ProcessorUserId; txtPassword.Attributes.Add("value", portal.ProcessorPassword); // return url after payment or on cancel string strPayPalReturnURL = PortalController.GetPortalSetting("paypalsubscriptionreturn", portal.PortalID, Null.NullString); txtPayPalReturnURL.Text = strPayPalReturnURL; string strPayPalCancelURL = PortalController.GetPortalSetting("paypalsubscriptioncancelreturn", portal.PortalID, Null.NullString); txtPayPalCancelURL.Text = strPayPalCancelURL; }
///----------------------------------------------------------------------------- /// <summary> /// Removes profanity words in the provided input string. /// </summary> /// <remarks> /// The words to search could be defined in two different places: /// 1) In an external file. (NOT IMPLEMENTED) /// 2) In System/Site lists. /// The name of the System List is "ProfanityFilter". The name of the list in each portal is composed using the following rule: /// "ProfanityFilter-" + PortalID. /// </remarks> /// <param name="inputString">The string to search the words in.</param> /// <param name="configType">The type of configuration.</param> /// <param name="configSource">The external file to search the words. Ignored when configType is ListController.</param> /// <param name="filterScope">When using ListController configType, this parameter indicates which list(s) to use.</param> /// <returns>The original text with the profanity words removed.</returns> ///----------------------------------------------------------------------------- public string Remove(string inputString, ConfigType configType, string configSource, FilterScope filterScope) { switch (configType) { case ConfigType.ListController: const RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Singleline; const string listName = "ProfanityFilter"; var listController = new ListController(); PortalSettings settings; IEnumerable<ListEntryInfo> listEntryHostInfos; IEnumerable<ListEntryInfo> listEntryPortalInfos; switch (filterScope) { case FilterScope.SystemList: listEntryHostInfos = listController.GetListEntryInfoItems(listName, "", Null.NullInteger); inputString = listEntryHostInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + removeItem.Text + @"\b", string.Empty, options)); break; case FilterScope.SystemAndPortalList: settings = PortalController.GetCurrentPortalSettings(); listEntryHostInfos = listController.GetListEntryInfoItems(listName, "", Null.NullInteger); listEntryPortalInfos = listController.GetListEntryInfoItems(listName + "-" + settings.PortalId, "", settings.PortalId); inputString = listEntryHostInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + removeItem.Text + @"\b", string.Empty, options)); inputString = listEntryPortalInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + removeItem.Text + @"\b", string.Empty, options)); break; case FilterScope.PortalList: settings = PortalController.GetCurrentPortalSettings(); listEntryPortalInfos = listController.GetListEntryInfoItems(listName + "-" + settings.PortalId, "", settings.PortalId); inputString = listEntryPortalInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + removeItem.Text + @"\b", string.Empty, options)); break; } break; case ConfigType.ExternalFile: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException("configType"); } return inputString; }
/// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 10/08/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected override void OnLoad(EventArgs e) { base.OnLoad(e); cboCountry.SelectedIndexChanged += OnCountryIndexChanged; chkCell.CheckedChanged += OnCellCheckChanged; chkCity.CheckedChanged += OnCityCheckChanged; chkCountry.CheckedChanged += OnCountryCheckChanged; chkFax.CheckedChanged += OnFaxCheckChanged; chkPostal.CheckedChanged += OnPostalCheckChanged; chkRegion.CheckedChanged += OnRegionCheckChanged; chkStreet.CheckedChanged += OnStreetCheckChanged; chkTelephone.CheckedChanged += OnTelephoneCheckChanged; try { valStreet.ErrorMessage = Localization.GetString("StreetRequired", Localization.GetResourceFile(this, MyFileName)); valCity.ErrorMessage = Localization.GetString("CityRequired", Localization.GetResourceFile(this, MyFileName)); valCountry.ErrorMessage = Localization.GetString("CountryRequired", Localization.GetResourceFile(this, MyFileName)); valPostal.ErrorMessage = Localization.GetString("PostalRequired", Localization.GetResourceFile(this, MyFileName)); valTelephone.ErrorMessage = Localization.GetString("TelephoneRequired", Localization.GetResourceFile(this, MyFileName)); valCell.ErrorMessage = Localization.GetString("CellRequired", Localization.GetResourceFile(this, MyFileName)); valFax.ErrorMessage = Localization.GetString("FaxRequired", Localization.GetResourceFile(this, MyFileName)); if (!Page.IsPostBack) { txtStreet.TabIndex = Convert.ToInt16(StartTabIndex); txtUnit.TabIndex = Convert.ToInt16(StartTabIndex + 1); txtCity.TabIndex = Convert.ToInt16(StartTabIndex + 2); cboCountry.TabIndex = Convert.ToInt16(StartTabIndex + 3); cboRegion.TabIndex = Convert.ToInt16(StartTabIndex + 4); txtRegion.TabIndex = Convert.ToInt16(StartTabIndex + 5); txtPostal.TabIndex = Convert.ToInt16(StartTabIndex + 6); txtTelephone.TabIndex = Convert.ToInt16(StartTabIndex + 7); txtCell.TabIndex = Convert.ToInt16(StartTabIndex + 8); txtFax.TabIndex = Convert.ToInt16(StartTabIndex + 9); //<tam:note modified to test Lists //Dim objRegionalController As New RegionalController //cboCountry.DataSource = objRegionalController.GetCountries //<this test using method 2: get empty collection then get each entry list on demand & store into cache var ctlEntry = new ListController(); var entryCollection = ctlEntry.GetListEntryInfoItems("Country"); cboCountry.DataSource = entryCollection; cboCountry.DataBind(); cboCountry.Items.Insert(0, new ListItem("<" + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + ">", "")); switch (_countryData.ToLower()) { case "text": if (String.IsNullOrEmpty(_country)) { cboCountry.SelectedIndex = 0; } else { if (cboCountry.Items.FindByText(_country) != null) { cboCountry.ClearSelection(); cboCountry.Items.FindByText(_country).Selected = true; } } break; case "value": if (cboCountry.Items.FindByValue(_country) != null) { cboCountry.ClearSelection(); cboCountry.Items.FindByValue(_country).Selected = true; } break; } Localize(); if (cboRegion.Visible) { switch (_regionData.ToLower()) { case "text": if (String.IsNullOrEmpty(_region)) { cboRegion.SelectedIndex = 0; } else { if (cboRegion.Items.FindByText(_region) != null) { cboRegion.Items.FindByText(_region).Selected = true; } } break; case "value": if (cboRegion.Items.FindByValue(_region) != null) { cboRegion.Items.FindByValue(_region).Selected = true; } break; } } else { txtRegion.Text = _region; } txtStreet.Text = _street; txtUnit.Text = _unit; txtCity.Text = _city; txtPostal.Text = _postal; txtTelephone.Text = _telephone; txtCell.Text = _cell; txtFax.Text = _fax; divStreet.Visible = _showStreet; divUnit.Visible = _showUnit; divCity.Visible = _showCity; divCountry.Visible = _showCountry; divRegion.Visible = _showRegion; divPostal.Visible = _showPostal; divTelephone.Visible = _showTelephone; divCell.Visible = _showCell; divFax.Visible = _showFax; if (TabPermissionController.CanAdminPage()) { chkStreet.Visible = true; chkCity.Visible = true; chkCountry.Visible = true; chkRegion.Visible = true; chkPostal.Visible = true; chkTelephone.Visible = true; chkCell.Visible = true; chkFax.Visible = true; } ViewState["ModuleId"] = Convert.ToString(_moduleId); ViewState["LabelColumnWidth"] = _labelColumnWidth; ViewState["ControlColumnWidth"] = _controlColumnWidth; ShowRequiredFields(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public ActionResult GetCountries() { var controller = new ListController(); var list = controller.GetListEntryInfoItems("Country"); var tempList = list.Select(x => new { x.Text, x.Value }).ToList(); var noneText = DotNetNuke.Services.Localization.Localization.GetString( "None_Specified", DotNetNuke.Services.Localization.Localization.SharedResourceFile); tempList.Insert(0, new { Text = "<" + noneText + ">", Value = "" }); return Json(tempList); }
/// <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> /// CreateEditor creates the control collection. /// </summary> /// <history> /// [cnurse] 05/08/2006 created /// </history> /// ----------------------------------------------------------------------------- protected override void CreateEditor() { CategoryDataField = "PropertyCategory"; EditorDataField = "DataType"; NameDataField = "PropertyName"; RequiredDataField = "Required"; ValidationExpressionDataField = "ValidationExpression"; ValueDataField = "PropertyValue"; VisibleDataField = "Visible"; VisibilityDataField = "ProfileVisibility"; LengthDataField = "Length"; base.CreateEditor(); foreach (FieldEditorControl editor in Fields) { //Check whether Field is readonly string fieldName = editor.Editor.Name; ProfilePropertyDefinitionCollection definitions = editor.DataSource as ProfilePropertyDefinitionCollection; ProfilePropertyDefinition definition = definitions[fieldName]; if (definition != null && definition.ReadOnly && (editor.Editor.EditMode == PropertyEditorMode.Edit)) { PortalSettings ps = PortalController.GetCurrentPortalSettings(); if (!PortalSecurity.IsInRole(ps.AdministratorRoleName)) { editor.Editor.EditMode = PropertyEditorMode.View; } } //We need to wire up the RegionControl to the CountryControl if (editor.Editor is DNNRegionEditControl) { ListEntryInfo country = null; foreach (FieldEditorControl checkEditor in Fields) { if (checkEditor.Editor is DNNCountryEditControl) { var countryEdit = (DNNCountryEditControl) checkEditor.Editor; var objListController = new ListController(); var countries = objListController.GetListEntryInfoItems("Country"); foreach (ListEntryInfo checkCountry in countries) { if (checkCountry.Text == Convert.ToString(countryEdit.Value)) { country = checkCountry; break; } } } } //Create a ListAttribute for the Region string countryKey; if (country != null) { countryKey = "Country." + country.Value; } else { countryKey = "Country.Unknown"; } var attributes = new object[1]; attributes[0] = new ListAttribute("Region", countryKey, ListBoundField.Text, ListBoundField.Text); editor.Editor.CustomAttributes = attributes; } } }
private string ParseRegionSaveSetting() { var ctlList = new ListController(); var value = string.Empty; var listItem = from i in ctlList.GetListEntryInfoItems("Region", string.Concat("Country.", cboCountry.SelectedValue), PortalId) select i; value = listItem.Any() ? cboRegion.SelectedValue : txtRegion.Text.Trim(); return value; }
private void ParseRegionLoadSetting() { if (string.IsNullOrEmpty(GetSetting(FeatureController.KEY_REGION)) == false) { LoadRegions(cboCountry.SelectedValue); var ctlList = new ListController(); var value = GetSetting(FeatureController.KEY_REGION); var listItem = from i in ctlList.GetListEntryInfoItems("Region", string.Concat("Country.", GetSetting(FeatureController.KEY_COUNTRY)), PortalId) select i; if (listItem.Any()) { cboRegion.Items.FindByValue(value).Selected = true; ToggleRegion(RegionState.DropDownList); } else { txtRegion.Text = value; ToggleRegion(RegionState.TextBox); } } else { // default state ToggleRegion(RegionState.TextBox); } }
private void LoadRegions(string CountryId) { var ctlList = new ListController(); IEnumerable<ListEntryInfo> regions = null; regions = ctlList.GetListEntryInfoItems("Region", string.Concat("Country.", CountryId), PortalId); if (regions != null && regions.Any()) { cboRegion.DataSource = regions; cboRegion.DataTextField = "Text"; cboRegion.DataValueField = "Value"; cboRegion.DataBind(); cboRegion.Items.Insert(0, new ListItem("---")); ToggleRegion(RegionState.DropDownList); } else { ToggleRegion(RegionState.TextBox); } }
private void LoadCountries() { var ctlList = new ListController(); cboCountry.DataSource = ctlList.GetListEntryInfoItems("Country", string.Empty, PortalId); cboCountry.DataTextField = "Text"; cboCountry.DataValueField = "Value"; cboCountry.DataBind(); cboCountry.Items.Insert(0,new ListItem("---")); }
private IEnumerable<ListEntryInfo> ListsTextLocalized(string listname) { ListController listcontroller = new ListController(); IEnumerable<ListEntryInfo> listEntryInfoCol = null; listEntryInfoCol = listcontroller.GetListEntryInfoItems(listname); foreach (ListEntryInfo li in listEntryInfoCol) { li.Text = Localization.GetString(li.Value, "~/App_GlobalResources/List_" + listname + "." + (Page as DotNetNuke.Framework.PageBase).PageCulture.Name + ".resx"); } return listEntryInfoCol; }
/// <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> /// Localize correctly sets up the control for US/Canada/Other Countries /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 10/08/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> private void Localize() { var countryCode = cboCountry.SelectedItem.Value; var ctlEntry = new ListController(); //listKey in format "Country.US:Region" var listKey = "Country." + countryCode; var entryCollection = ctlEntry.GetListEntryInfoItems("Region", listKey); if (entryCollection.Any()) { cboRegion.Visible = true; txtRegion.Visible = false; { cboRegion.Items.Clear(); cboRegion.DataSource = entryCollection; cboRegion.DataBind(); cboRegion.Items.Insert(0, new ListItem("<" + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + ">", "")); } if (countryCode.ToLower() == "us") { valRegion1.Enabled = true; valRegion2.Enabled = false; valRegion1.ErrorMessage = Localization.GetString("StateRequired", Localization.GetResourceFile(this, MyFileName)); plRegion.Text = Localization.GetString("plState", Localization.GetResourceFile(this, MyFileName)); plRegion.HelpText = Localization.GetString("plState.Help", Localization.GetResourceFile(this, MyFileName)); plPostal.Text = Localization.GetString("plZip", Localization.GetResourceFile(this, MyFileName)); plPostal.HelpText = Localization.GetString("plZip.Help", Localization.GetResourceFile(this, MyFileName)); } else { valRegion1.ErrorMessage = Localization.GetString("ProvinceRequired", Localization.GetResourceFile(this, MyFileName)); plRegion.Text = Localization.GetString("plProvince", Localization.GetResourceFile(this, MyFileName)); plRegion.HelpText = Localization.GetString("plProvince.Help", Localization.GetResourceFile(this, MyFileName)); plPostal.Text = Localization.GetString("plPostal", Localization.GetResourceFile(this, MyFileName)); plPostal.HelpText = Localization.GetString("plPostal.Help", Localization.GetResourceFile(this, MyFileName)); } valRegion1.Enabled = true; valRegion2.Enabled = false; } else { cboRegion.ClearSelection(); cboRegion.Visible = false; txtRegion.Visible = true; valRegion1.Enabled = false; valRegion2.Enabled = true; valRegion2.ErrorMessage = Localization.GetString("RegionRequired", Localization.GetResourceFile(this, MyFileName)); plRegion.Text = Localization.GetString("plRegion", Localization.GetResourceFile(this, MyFileName)); plRegion.HelpText = Localization.GetString("plRegion.Help", Localization.GetResourceFile(this, MyFileName)); plPostal.Text = Localization.GetString("plPostal", Localization.GetResourceFile(this, MyFileName)); plPostal.HelpText = Localization.GetString("plPostal.Help", Localization.GetResourceFile(this, MyFileName)); } var reqRegion = PortalController.GetPortalSettingAsBoolean("addressregion", PortalSettings.PortalId, true); if (reqRegion) { valRegion1.Enabled = false; valRegion2.Enabled = false; } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); jQuery.RequestDnnPluginsRegistration(); cboBillingFrequency.SelectedIndexChanged += OnBillingFrequencyIndexChanged; cboTrialFrequency.SelectedIndexChanged += OnTrialFrequencyIndexChanged; cmdDelete.Click += OnDeleteClick; cmdManage.Click += OnManageClick; cmdUpdate.Click += OnUpdateClick; txtRSVPCode.TextChanged += OnRsvpCodeChanged; try { if ((Request.QueryString["RoleID"] != null)) { _roleID = Int32.Parse(Request.QueryString["RoleID"]); } var objPortalController = new PortalController(); var objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId); if ((objPortalInfo == null || string.IsNullOrEmpty(objPortalInfo.ProcessorUserId))) { //Warn users about fee based roles if we have a Processor Id lblProcessorWarning.Visible = true; } else { divServiceFee.Visible = true; divBillingPeriod.Visible = true; divTrialFee.Visible = true; divTrialPeriod.Visible = true; } if (Page.IsPostBack == false) { cmdCancel.NavigateUrl = Globals.NavigateURL(); var objUser = new RoleController(); var ctlList = new ListController(); var colFrequencies = ctlList.GetListEntryInfoItems("Frequency", ""); cboBillingFrequency.DataSource = colFrequencies; cboBillingFrequency.DataBind(); cboBillingFrequency.Items.FindByValue("N").Selected = true; cboTrialFrequency.DataSource = colFrequencies; cboTrialFrequency.DataBind(); cboTrialFrequency.Items.FindByValue("N").Selected = true; BindGroups(); ctlIcon.FileFilter = Globals.glbImageFileTypes; if (_roleID != -1) { lblRoleName.Visible = true; txtRoleName.Visible = false; valRoleName.Enabled = false; var objRoleInfo = objUser.GetRole(_roleID, PortalSettings.PortalId); if (objRoleInfo != null) { lblRoleName.Text = objRoleInfo.RoleName; txtDescription.Text = objRoleInfo.Description; if (cboRoleGroups.Items.FindByValue(objRoleInfo.RoleGroupID.ToString()) != null) { cboRoleGroups.ClearSelection(); cboRoleGroups.Items.FindByValue(objRoleInfo.RoleGroupID.ToString()).Selected = true; } if (objRoleInfo.BillingFrequency != "N") { txtServiceFee.Text = objRoleInfo.ServiceFee.ToString("N2", CultureInfo.CurrentCulture); txtBillingPeriod.Text = objRoleInfo.BillingPeriod.ToString(); if (cboBillingFrequency.Items.FindByValue(objRoleInfo.BillingFrequency) != null) { cboBillingFrequency.ClearSelection(); cboBillingFrequency.Items.FindByValue(objRoleInfo.BillingFrequency).Selected = true; } } if (objRoleInfo.TrialFrequency != "N") { txtTrialFee.Text = objRoleInfo.TrialFee.ToString("N2", CultureInfo.CurrentCulture); txtTrialPeriod.Text = objRoleInfo.TrialPeriod.ToString(); if (cboTrialFrequency.Items.FindByValue(objRoleInfo.TrialFrequency) != null) { cboTrialFrequency.ClearSelection(); cboTrialFrequency.Items.FindByValue(objRoleInfo.TrialFrequency).Selected = true; } } chkIsPublic.Checked = objRoleInfo.IsPublic; chkAutoAssignment.Checked = objRoleInfo.AutoAssignment; txtRSVPCode.Text = objRoleInfo.RSVPCode; if (!String.IsNullOrEmpty(txtRSVPCode.Text)) { lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?rsvp=" + txtRSVPCode.Text + "&portalid=" + PortalId; } ctlIcon.Url = objRoleInfo.IconFile; UpdateFeeTextBoxes(); } else //security violation attempt to access item not related to this Module { Response.Redirect(Globals.NavigateURL("Security Roles")); } if (_roleID == PortalSettings.AdministratorRoleId || _roleID == PortalSettings.RegisteredRoleId) { cmdDelete.Visible = false; ActivateControls(false); } if (_roleID == PortalSettings.RegisteredRoleId) { cmdManage.Visible = false; } } else { cmdDelete.Visible = false; cmdManage.Visible = false; lblRoleName.Visible = false; txtRoleName.Visible = true; //select default role group id if(Request.QueryString["RoleGroupID"] != null) { var roleGroupID = Request.QueryString["RoleGroupID"]; if (cboRoleGroups.Items.FindByValue(roleGroupID) != null) { cboRoleGroups.ClearSelection(); cboRoleGroups.Items.FindByValue(roleGroupID).Selected = true; } } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }