private void LoadSelection(bool force) { currentValues = string.Empty; var sb = GetSubscriber(); if (sb != null) { // Get selected newsletters DataSet ds = SubscriberNewsletterInfoProvider.GetEnabledSubscriberNewsletters().WhereEquals("SubscriberID", sb.SubscriberID).Column("NewsletterID"); if (!DataHelper.DataSourceIsEmpty(ds)) { currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "NewsletterID")); } if (!RequestHelper.IsPostBack() || force) { // Load selected newsletters usNewsletters.Value = currentValues; } } }
/// <summary> /// Load data. /// </summary> public void LoadData() { if (StopProcessing) { // Hide control Visible = false; } else { SetContext(); // Get specified user if used instead of current user UserInfo ui = null; if (UserID > 0) { ui = UserInfoProvider.GetUserInfo(UserID); } else { ui = MembershipContext.AuthenticatedUser; } // Get specified site ID instead of current site ID int siteId = 0; if (SiteID > 0) { siteId = SiteID; } else { siteId = SiteContext.CurrentSiteID; } usNewsletters.WhereCondition = "NewsletterSiteID = " + siteId; usNewsletters.OnSelectionChanged += new EventHandler(usNewsletters_OnSelectionChanged); usNewsletters.IsLiveSite = IsLiveSite; userIsIdentified = (ui != null) && (!ui.IsPublic()) && (ValidationHelper.IsEmail(ui.Email) || ValidationHelper.IsEmail(ui.UserName)); if (userIsIdentified) { usNewsletters.Visible = true; // Try to get subscriber info with specified e-mail sb = SubscriberInfoProvider.GetSubscriberInfo(ui.Email, siteId); if (sb == null) { // Try to get subscriber info according to user info sb = SubscriberInfoProvider.GetSubscriberInfo(UserInfo.OBJECT_TYPE, ui.UserID, siteId); } // Get user e-mail address if (sb != null) { subscriberEmail = sb.SubscriberEmail; // Get selected newsletters DataSet ds = SubscriberNewsletterInfoProvider.GetEnabledSubscriberNewsletters().WhereEquals("SubscriberID", sb.SubscriberID).Column("NewsletterID"); if (!DataHelper.DataSourceIsEmpty(ds)) { currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "NewsletterID")); } // Load selected newsletters if (!RequestHelper.IsPostBack() || !string.IsNullOrEmpty(DataHelper.GetNewItemsInList(SelectorValue, currentValues))) { usNewsletters.Value = currentValues; } } // Try to get email address from user data if (string.IsNullOrEmpty(subscriberEmail)) { if (ValidationHelper.IsEmail(ui.Email)) { subscriberEmail = ui.Email; } else if (ValidationHelper.IsEmail(ui.UserName)) { subscriberEmail = ui.UserName; } } } else { usNewsletters.Visible = false; if ((UserID > 0) && (MembershipContext.AuthenticatedUser.UserID == UserID)) { ShowInformation(GetString("MySubscriptions.CannotIdentify")); } else { ShowInformation(GetString("MySubscriptions.CannotIdentifyUser")); } } ReleaseContext(); } }