/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { Guid unsubscribeGuid = QueryHelper.GetGuid("unsubscribe", Guid.Empty); if (unsubscribeGuid != Guid.Empty) { ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(unsubscribeGuid); if (fsi != null) { ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi.SubscriptionID); lblInfoText.Visible = true; lblInfoText.Text = UnsubscriptionText; } else { lblInfoText.Visible = true; lblInfoText.Text = UnsuccessfulUnsubscriptionText; lblInfoText.CssClass = "ErrorLabel"; return; } } else { Visible = false; } } }
protected override void OnPreRender(EventArgs e) { if (!displayControlPerformed) { plcList.Visible = listVisible; subscriptionList.Visible = listVisible; if (listVisible) { subscriptionList.ReloadData(); } } // Ensure breadcrumbs items int subscriptionId = ValidationHelper.GetInteger(ViewState["SubscriptionID"], 0); if ((subscriptionId > 0) && String.IsNullOrEmpty(ucBreadcrumbs.Items[1].Text)) { ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if (fsi != null) { SetBreadcrumbsItem(fsi.SubscriptionEmail); } } base.OnPreRender(e); }
protected void Page_Load(object sender, EventArgs e) { // Forums Guid subGuid = QueryHelper.GetGuid("subGuid", Guid.Empty); if (subGuid != Guid.Empty) { ForumSubscriptionInfo fsi = null; if (subGuid != Guid.Empty) { fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subGuid); } else { lblError.Visible = true; lblError.Text = GetString("Forum.UnsubscribeUnsuccessfull"); return; } if (fsi != null) { ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi.SubscriptionID); lblInfo.Visible = true; lblInfo.Text = GetString("Unsubscribe.Unsubscribed"); } else { lblError.Visible = true; lblError.Text = GetString("forum.invalidsubscribeid"); } } }
/// <summary> /// OK click handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check banned IP if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { lblError.Visible = true; lblError.Text = GetString("General.BannedIP"); return; } // Check input fields string result = new Validator().NotEmpty(txtEmail.Text, rfvEmailRequired.ErrorMessage).IsRegularExp(txtEmail.Text, @"^([\w0-9_-]+(\.[\w0-9_-]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$", rfvEmail.ErrorMessage).Result; if (result == "") { // For selected forum and only if subscribtion is enabled if ((ForumContext.CurrentForum != null) && ((ForumContext.CurrentState == ForumStateEnum.SubscribeToPost) || (ForumContext.CurrentState == ForumStateEnum.NewSubscription))) { // Check permissions if (!this.IsAvailable(ForumContext.CurrentForum, ForumActionType.SubscribeToForum)) { lblError.Visible = true; lblError.Text = GetString("ForumNewPost.PermissionDenied"); return; } // Create new subscribtion ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(); fsi.SubscriptionForumID = ForumContext.CurrentForum.ForumID; fsi.SubscriptionEmail = HTMLHelper.HTMLEncode(txtEmail.Text.Trim()); fsi.SubscriptionGUID = Guid.NewGuid(); if (ForumContext.CurrentSubscribeThread != null) { fsi.SubscriptionPostID = ForumContext.CurrentSubscribeThread.PostId; } if (CMSContext.CurrentUser != null) { fsi.SubscriptionUserID = CMSContext.CurrentUser.UserID; } // Check whethger user is not subscribed if (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), fsi.SubscriptionForumID, fsi.SubscriptionPostID)) { lblError.Text = GetString("ForumSubscibe.SubscriptionExists"); lblError.Visible = true; return; } ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(fsi); LogSubscriptionActivity(fsi, ForumContext.CurrentForum); } } URLHelper.Redirect(ClearURL()); }
/// <summary> /// Checks if current user has subscribed given post. /// </summary> /// <param name="postId">ID of forum post</param> /// <returns>true if user has subscriptions for given post, false if not</returns> private bool CheckSubscription(int postId) { DataSet ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + MembershipContext.AuthenticatedUser.UserID + ") AND (SubscriptionPostID = " + postId + ")", null, 0, "SubscriptionID"); if (DataHelper.DataSourceIsEmpty(ds)) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { this.Title = "Forums - Edit subscription"; string currentForumSubscription = ""; ForumSubscriptionInfo forumSubscriptionObj = new ForumSubscriptionInfo(); int subscriptionId = QueryHelper.GetInteger("subscriptionid", 0); this.subscriptionEdit.SubscriptionID = subscriptionId; this.subscriptionEdit.OnSaved += new EventHandler(subscriptionEdit_OnSaved); this.subscriptionEdit.IsLiveSite = false; // get forumSubscription id from querystring if (subscriptionId > 0) { forumSubscriptionObj = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); currentForumSubscription = HTMLHelper.HTMLEncode(forumSubscriptionObj.SubscriptionEmail); // initializes page title control string[,] tabs = new string[2, 3]; tabs[0, 0] = GetString("ForumSubscription_Edit.ItemListLink"); tabs[0, 1] = "~/CMSModules/Groups/Tools/Forums/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumSubscriptionObj.SubscriptionForumID; tabs[0, 2] = ""; tabs[1, 0] = (string.IsNullOrEmpty(currentForumSubscription)) ? GetString("ForumSubscription_List.NewItemCaption") : currentForumSubscription; tabs[1, 1] = ""; tabs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = tabs; } else { forumId = ValidationHelper.GetInteger(Request.QueryString["forumid"], 0); if (forumId == 0) { return; } this.subscriptionEdit.ForumID = forumId; // initializes page title control string[,] tabs = new string[2, 3]; tabs[0, 0] = GetString("ForumSubscription_Edit.ItemListLink"); tabs[0, 1] = "~/CMSModules/Groups/Tools/Forums/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumId.ToString(); tabs[0, 2] = ""; tabs[1, 0] = (string.IsNullOrEmpty(currentForumSubscription)) ? GetString("ForumSubscription_List.NewItemCaption") : currentForumSubscription; tabs[1, 1] = ""; tabs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = tabs; this.CurrentMaster.Title.TitleText = GetString("forumsubscription_edit.newitemcaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Forums_ForumSubscription/new.png"); } this.subscriptionEdit.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(subscriptionEdit_OnCheckPermissions); }
protected void Page_Load(object sender, EventArgs e) { Title = "Forums - Edit subscription"; string currentForumSubscription = ""; int subscriptionId = QueryHelper.GetInteger("subscriptionid", 0); subscriptionEdit.SubscriptionID = subscriptionId; subscriptionEdit.OnSaved += subscriptionEdit_OnSaved; subscriptionEdit.IsLiveSite = false; // get forumSubscription id from querystring if (subscriptionId > 0) { ForumSubscriptionInfo forumSubscriptionObj = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); currentForumSubscription = HTMLHelper.HTMLEncode(forumSubscriptionObj.SubscriptionEmail); // Initialize breadcrumbs PageBreadcrumbs.Items.Add(new BreadcrumbItem { Text = GetString("ForumSubscription_Edit.ItemListLink"), RedirectUrl = ResolveUrl("~/CMSModules/Groups/Tools/Forums/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumSubscriptionObj.SubscriptionForumID), }); PageBreadcrumbs.Items.Add(new BreadcrumbItem { Text = (string.IsNullOrEmpty(currentForumSubscription)) ? GetString("ForumSubscription_List.NewItemCaption") : currentForumSubscription, }); } else { forumId = QueryHelper.GetInteger("forumid", 0); if (forumId == 0) { return; } subscriptionEdit.ForumID = forumId; // Initialize breadcrumbs PageBreadcrumbs.Items.Add(new BreadcrumbItem { Text = GetString("ForumSubscription_Edit.ItemListLink"), RedirectUrl = ResolveUrl("~/CMSModules/Groups/Tools/Forums/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumId), }); PageBreadcrumbs.Items.Add(new BreadcrumbItem { Text = (string.IsNullOrEmpty(currentForumSubscription)) ? GetString("ForumSubscription_List.NewItemCaption") : currentForumSubscription, }); PageTitle.TitleText = GetString("forumsubscription_edit.newitemcaption"); } subscriptionEdit.OnCheckPermissions += subscriptionEdit_OnCheckPermissions; }
protected void Page_Load(object sender, EventArgs e) { Title = "Forums - Edit subscription"; subscriptionId = QueryHelper.GetInteger("subscriptionid", 0); subscriptionEdit.SubscriptionID = subscriptionId; subscriptionEdit.OnSaved += new EventHandler(subscriptionEdit_OnSaved); subscriptionEdit.IsLiveSite = false; string currentForumSubscription = ""; ForumSubscriptionInfo forumSubscriptionObj = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); // get forumSubscription id from querystring if (forumSubscriptionObj != null) { currentForumSubscription = HTMLHelper.HTMLEncode(forumSubscriptionObj.SubscriptionEmail); // Initialize breadcrumbs PageBreadcrumbs.Items.Add(new BreadcrumbItem() { Text = GetString("ForumSubscription_Edit.ItemListLink"), RedirectUrl = ResolveUrl("~/CMSModules/Forums/Tools/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumSubscriptionObj.SubscriptionForumID), }); PageBreadcrumbs.Items.Add(new BreadcrumbItem() { Text = currentForumSubscription, }); } else { forumId = QueryHelper.GetInteger("forumid", 0); if (forumId == 0) { return; } subscriptionEdit.ForumID = forumId; isNewItem = true; // Initialize breadcrumbs PageBreadcrumbs.Items.Add(new BreadcrumbItem() { Text = GetString("ForumSubscription_Edit.ItemListLink"), RedirectUrl = ResolveUrl("~/CMSModules/Forums/Tools/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumId), }); PageBreadcrumbs.Items.Add(new BreadcrumbItem() { Text = GetString("ForumSubscription_Edit.NewItemCaption"), }); } ForumContext.CheckSite(0, forumId, 0); }
private void subscriptionEdit_OnSaved(object sender, EventArgs e) { int subscriptionId = ValidationHelper.GetInteger(ViewState["SubscriptionID"], 0); if (subscriptionId > 0) { ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if (fsi != null) { SetBreadcrumbsItem(fsi.SubscriptionEmail); } } }
protected void Page_Load(object sender, EventArgs e) { this.Title = "Forums - Edit subscription"; subscriptionId = QueryHelper.GetInteger("subscriptionid", 0); this.subscriptionEdit.SubscriptionID = subscriptionId; this.subscriptionEdit.OnSaved += new EventHandler(subscriptionEdit_OnSaved); this.subscriptionEdit.IsLiveSite = false; string currentForumSubscription = ""; ForumSubscriptionInfo forumSubscriptionObj = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); // get forumSubscription id from querystring if (forumSubscriptionObj != null) { currentForumSubscription = HTMLHelper.HTMLEncode(forumSubscriptionObj.SubscriptionEmail); // initializes page title control string[,] tabs = new string[2, 3]; tabs[0, 0] = GetString("ForumSubscription_Edit.ItemListLink"); tabs[0, 1] = "~/CMSModules/Forums/Tools/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumSubscriptionObj.SubscriptionForumID; tabs[0, 2] = ""; tabs[1, 0] = currentForumSubscription; tabs[1, 1] = ""; tabs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = tabs; } else { forumId = QueryHelper.GetInteger("forumid", 0); if (forumId == 0) { return; } this.subscriptionEdit.ForumID = forumId; this.isNewItem = true; // Initializes page title control string[,] tabs = new string[2, 3]; tabs[0, 0] = GetString("ForumSubscription_Edit.ItemListLink"); tabs[0, 1] = "~/CMSModules/Forums/Tools/Subscriptions/ForumSubscription_List.aspx?forumid=" + forumId.ToString(); tabs[0, 2] = ""; tabs[1, 0] = GetString("ForumSubscription_Edit.NewItemCaption"); tabs[1, 1] = ""; tabs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = tabs; } ForumContext.CheckSite(0, forumId, 0); }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.forums", CMSAdminControl.PERMISSION_MODIFY)) { return; } string errorMessage = new Validator().NotEmpty(txtSubscriptionEmail.Text, GetString("ForumSubscription_Edit.EnterSomeEmail")).Result; if (errorMessage == "") { // Check that e-mail is not already subscribed if (ForumSubscriptionInfoProvider.IsSubscribed(txtSubscriptionEmail.Text.Trim(), this.mForumId, 0)) { lblError.Visible = true; lblError.Text = GetString("ForumSubscibe.SubscriptionExists"); return; } if (SubscriptionObj == null) { SubscriptionObj = new ForumSubscriptionInfo(); SubscriptionObj.SubscriptionForumID = this.mForumId; SubscriptionObj.SubscriptionGUID = Guid.NewGuid(); } SubscriptionObj.SubscriptionEmail = txtSubscriptionEmail.Text.Trim(); if (ValidationHelper.IsEmail(SubscriptionObj.SubscriptionEmail)) { ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(SubscriptionObj, chkSendConfirmationEmail.Checked, null, null); this.SubscriptionID = SubscriptionObj.SubscriptionID; lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); this.RaiseOnSaved(); } else { lblError.Visible = true; lblError.Text = GetString("ForumSubscription_Edit.EmailIsNotValid"); } } else { lblError.Visible = true; lblError.Text = errorMessage; } }
protected void subscriptionNew_OnSaved(object sender, EventArgs e) { int subscriptionId = subscriptionNew.SubscriptionID; ViewState["SubscriptionID"] = subscriptionId; ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if (fsi != null) { SetBreadcrumbsItem(fsi.SubscriptionEmail); } subscriptionEdit.SubscriptionID = subscriptionId; DisplayControl("edit"); }
protected void subscriptionNew_OnSaved(object sender, EventArgs e) { int subscriptionId = subscriptionNew.SubscriptionID; ViewState["SubscriptionID"] = subscriptionId; ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if (fsi != null) { lblEditBack.Text = breadCrumbsSeparator + HTMLHelper.HTMLEncode(fsi.SubscriptionEmail); } subscriptionEdit.SubscriptionID = subscriptionId; DisplayControl("edit"); }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } string errorMessage = new Validator().NotEmpty(txtSubscriptionEmail.Text, GetString("ForumSubscription_Edit.EnterSomeEmail")).Result; if (errorMessage == "") { // Check that e-mail is not already subscribed if (ForumSubscriptionInfoProvider.IsSubscribed(txtSubscriptionEmail.Text.Trim(), mForumId, 0)) { ShowError(GetString("ForumSubscibe.SubscriptionExists")); return; } if (SubscriptionObj.SubscriptionID <= 0) { SubscriptionObj.SubscriptionForumID = mForumId; SubscriptionObj.SubscriptionGUID = Guid.NewGuid(); } SubscriptionObj.SubscriptionEmail = txtSubscriptionEmail.Text.Trim(); if (ValidationHelper.IsEmail(SubscriptionObj.SubscriptionEmail)) { ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(SubscriptionObj, chkSendConfirmationEmail.Checked, null, null); SubscriptionID = SubscriptionObj.SubscriptionID; ShowChangesSaved(); RaiseOnSaved(); } else { ShowError(GetString("ForumSubscription_Edit.EmailIsNotValid")); } } else { ShowError(errorMessage); } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void gridElem_OnAction(string actionName, object actionArgument) { switch (actionName.ToLower()) { case "delete": if (!CheckPermissions("cms.forums", CMSAdminControl.PERMISSION_MODIFY)) { return; } // Delete ForumSubscriptionInfo object from database ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(Convert.ToInt32(actionArgument), chkSendConfirmationEmail.Checked); break; } this.RaiseOnAction(actionName, actionArgument); }
/// <summary> /// Checks if current user has subscribed given post. /// </summary> /// <param name="postId">ID of forum post</param> /// <returns>true if user has subscriptions for given post, false if not</returns> private bool CheckSubscription() { if (UserID != MembershipContext.AuthenticatedUser.UserID) { // Check permissions if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return(false); } } DataSet ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + MembershipContext.AuthenticatedUser.UserID + ") AND (SubscriptionPostID = " + PostID + ") AND (ISNULL(SubscriptionApproved, 1) = 1)", null, 0, "SubscriptionID"); if (!DataHelper.DataSourceIsEmpty(ds)) { return(true); } return(false); }
/// <summary> /// Handles the Click event of the btnApprove control. /// </summary> protected void btnUnsubscribe_Click(object sender, EventArgs e) { if (UserID != MembershipContext.AuthenticatedUser.UserID) { // Check permissions if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } } DataSet ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + UserID + ") AND (SubscriptionPostID = " + PostID + ") AND (ISNULL(SubscriptionApproved, 1) = 1)", null, 0, "SubscriptionID"); if (!DataHelper.DataSourceIsEmpty(ds)) { ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(ds.Tables[0].Rows[0]); ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi); RefreshParentWindow(); } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // check 'Read' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.forums", "Modify")) { RedirectToCMSDeskAccessDenied("cms.forums", "Modify"); } string errorMessage = new Validator().NotEmpty(txtSubscriptionEmail.Text, GetString("ForumSubscription_Edit.EnterSomeEmail")).Result; if (errorMessage == "") { ForumSubscriptionInfo subscription = new ForumSubscriptionInfo(); if (subscription == null) { lblError.Visible = true; lblError.Text = GetString("ForumSubscription_Edit.SubscriptionDoesNotExist"); return; } subscription.SubscriptionEmail = txtSubscriptionEmail.Text.Trim(); if (ValidationHelper.IsEmail(subscription.SubscriptionEmail)) { subscription.SubscriptionForumID = forumId; ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(subscription); URLHelper.Redirect("ForumSubscription_Edit.aspx?subscriptionid=" + Convert.ToString(subscription.SubscriptionID) + "&saved=1"); } else { lblError.Visible = true; lblError.Text = GetString("ForumSubscription_Edit.EmailIsNotValid"); } } else { lblError.Visible = true; lblError.Text = errorMessage; } }
/// <summary> /// On action event handling. /// </summary> /// <param name="actionName">Name of the action</param> /// <param name="actionArgument">Value of the action</param> void forumSubscriptions_OnAction(string actionName, object actionArgument) { int id = ValidationHelper.GetInteger(actionArgument, 0); DataSet ds = null; if (actionName.ToLowerCSafe() == "forumunsubscribe") { ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + UserID + ") AND (SubscriptionForumID = " + id + ") AND (SubscriptionPostID IS NULL) AND (ISNULL(SubscriptionApproved, 1) = 1) ", null, 0, "SubscriptionID"); } else { ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + UserID + ") AND (SubscriptionPostID = " + id + ") AND (ISNULL(SubscriptionApproved, 1) = 1)", null, 0, "SubscriptionID"); } ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(ds.Tables[0].Rows[0]); switch (actionName.ToLowerCSafe()) { case "forumunsubscribe": case "postunsubscribe": if (RaiseOnCheckPermissions(PERMISSION_MANAGE, this)) { if (StopProcessing) { return; } } try { ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi); } catch (Exception ex) { ShowError(ex.Message); } break; } }
/// <summary> /// Handles the Click event of the btnApprove control. /// </summary> protected void btnUnsubscribe_Click(object sender, EventArgs e) { if (UserID != MembershipContext.AuthenticatedUser.UserID) { // Check permissions if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } } var query = new ObjectQuery <ForumSubscriptionInfo>().Where(new WhereCondition().WhereNull("SubscriptionApproved").Or().WhereEquals("SubscriptionApproved", 1)).And().WhereEquals("SubscriptionUserID", UserID).And().WhereEquals("SubscriptionPostID", PostID).Column("SubscriptionID").TopN(1); ForumSubscriptionInfo fsi = query.FirstOrDefault(); if (fsi != null) { ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi); RefreshParentWindow(); } }
/// <summary> /// Redirect to the unsubscription page if current url contains valid unbscription informations. /// </summary> protected void EnsureUnsubscription() { Guid unsubGuid = QueryHelper.GetGuid("unsubscribe", Guid.Empty); if (unsubGuid != Guid.Empty) { int forumId = QueryHelper.GetInteger("forumid", 0); if (forumId > 0) { ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(unsubGuid); if (fsi != null) { ForumInfo fi = ForumInfoProvider.GetForumInfo(forumId); if ((fi != null) && (fsi.SubscriptionForumID == fi.ForumID)) { URLHelper.Redirect("~/CMSModules/Forums/CMSPages/unsubscribe.aspx?subGuid=" + unsubGuid.ToString()); } } } } }
/// <summary> /// Edit subscription handler. /// </summary> protected void subscriptionList_OnAction(object sender, CommandEventArgs e) { switch (e.CommandName.ToLower()) { case "edit": int subscriptionId = ValidationHelper.GetInteger(e.CommandArgument, 0); this.subscriptionEdit.SubscriptionID = subscriptionId; ViewState["SubscriptionID"] = subscriptionId; ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if (fsi != null) { this.lblEditBack.Text = breadCrumbsSeparator + HTMLHelper.HTMLEncode(fsi.SubscriptionEmail); } DisplayControl("edit"); break; } }
/// <summary> /// Edit subscription handler. /// </summary> protected void subscriptionList_OnAction(object sender, CommandEventArgs e) { switch (e.CommandName.ToLowerCSafe()) { case "edit": int subscriptionId = ValidationHelper.GetInteger(e.CommandArgument, 0); subscriptionEdit.SubscriptionID = subscriptionId; ViewState["SubscriptionID"] = subscriptionId; ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if (fsi != null) { SetBreadcrumbsItem(fsi.SubscriptionEmail); } DisplayControl("edit"); break; } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } if (!String.IsNullOrWhiteSpace(txtSubscriptionEmail.Text)) { // Check that e-mail is not already subscribed if (ForumSubscriptionInfoProvider.IsSubscribed(txtSubscriptionEmail.Text.Trim(), mForumId, 0)) { ShowError(GetString("ForumSubscibe.SubscriptionExists")); return; } if (SubscriptionObj.SubscriptionID <= 0) { SubscriptionObj.SubscriptionForumID = mForumId; SubscriptionObj.SubscriptionGUID = Guid.NewGuid(); } if (!txtSubscriptionEmail.IsValid()) { ShowError(GetString("ForumSubscription_Edit.EmailIsNotValid")); return; } SubscriptionObj.SubscriptionEmail = txtSubscriptionEmail.Text.Trim(); ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(SubscriptionObj, chkSendConfirmationEmail.Checked, null, null); SubscriptionID = SubscriptionObj.SubscriptionID; ShowChangesSaved(); RaiseOnSaved(); } else { ShowError(GetString("ForumSubscription_Edit.EnterSomeEmail")); } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void gridElem_OnAction(string actionName, object actionArgument) { int subscriptionId = ValidationHelper.GetInteger(actionArgument, 0); switch (actionName.ToLowerCSafe()) { case "delete": if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } // Delete ForumSubscriptionInfo object from database ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(subscriptionId, chkSendConfirmationEmail.Checked); break; case "approve": if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } // Approve ForumSubscriptionInfo object ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId); if ((fsi != null) && !fsi.SubscriptionApproved) { fsi.SubscriptionApproved = true; ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(fsi); if (chkSendConfirmationEmail.Checked) { ForumSubscriptionInfoProvider.SendConfirmationEmail(fsi, true, null, null); } } break; } RaiseOnAction(actionName, actionArgument); }
/// <summary> /// Btn OK handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } if (editPi == null) { editPi = ForumPostInfoProvider.GetForumPostInfo(EditPostID); } // Sets the current or parent post id int subscibePostId = 0; if (editPi != null) { editPi.PostLastEdit = DateTime.Now; editPi.PostIsAnswer = ValidationHelper.GetInteger(txtPostIsAnswer.Text, editPi.PostIsAnswer); editPi.PostIsNotAnswer = ValidationHelper.GetInteger(txtPostIsNotAnswer.Text, editPi.PostIsNotAnswer); } else { // Create new post editPi = new ForumPostInfo(); // Set as reply if (replyPi != null) { editPi.PostParentID = replyPi.PostId; subscibePostId = replyPi.PostId; } editPi.PostUserID = CMSContext.CurrentUser.UserID; editPi.PostForumID = fi.ForumID; editPi.PostTime = DateTime.Now; editPi.PostApproved = true; editPi.PostApprovedByUserID = CMSContext.CurrentUser.UserID; } #region "Security" string result = new Validator().NotEmpty(txtSubject.Text, rfvSubject.ErrorMessage).NotEmpty(txtUserName, rfvUserName.ErrorMessage).Result; // Check if is some text in TextArea or in HTMLEditor if (result == "") { if (fi.ForumHTMLEditor) { if (htmlTemplateBody.ResolvedValue.Trim() == "") { result = rfvText.ErrorMessage; } editPi.PostText = htmlTemplateBody.ResolvedValue; } else { if (DiscussionMacroHelper.RemoveTags(ucBBEditor.Text).Trim() == "") { result = rfvText.ErrorMessage; } editPi.PostText = ucBBEditor.Text; } } if ((fi.ForumRequireEmail || chkSubscribe.Checked || (txtEmail.Text != String.Empty)) && result == "") { result = new Validator().IsEmail(txtEmail.Text, rfvEmail.ErrorMessage).Result; if (!String.IsNullOrEmpty(result)) { ShowError(result); if (chkSubscribe.Checked && String.IsNullOrEmpty(txtEmail.Text)) { ShowError(GetString("Forums.Emailsubscribe")); } Visible = true; return; } } #endregion // Check subscriptions if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(txtEmail.Text)) && (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), editPi.PostForumID, subscibePostId))) { // Post of the forum is already subscribed to this email -> show an error result = GetString("Forums.EmailAlreadySubscribed"); chkSubscribe.Checked = false; } if (String.IsNullOrEmpty(result)) { if (fi.ForumType == 0) { editPi.PostType = (radTypeQuestion.Checked) ? 1 : 0; } editPi.PostUserName = TextHelper.LimitLength(txtUserName.Text, POST_USERNAME_LENGTH, ""); editPi.PostSubject = TextHelper.LimitLength(txtSubject.Text, POST_SUBJECT_LENGTH, ""); editPi.PostUserMail = txtEmail.Text; editPi.PostUserSignature = txtSignature.Text; ForumPostInfoProvider.SetForumPostInfo(editPi); EditPostID = editPi.PostId; #region "Subscription" if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(editPi.PostUserMail))) { ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(); fsi.SubscriptionForumID = ForumID; fsi.SubscriptionEmail = editPi.PostUserMail; fsi.SubscriptionPostID = editPi.PostId; fsi.SubscriptionUserID = CMSContext.CurrentUser.UserID; fsi.SubscriptionGUID = Guid.NewGuid(); ForumSubscriptionInfoProvider.Subscribe(fsi, DateTime.Now, true, true); } #endregion ClearForm(); if (OnInsertPost != null) { OnInsertPost(this, null); } RaiseOnSaved(); } else { ShowError(result); return; } }
/// <summary> /// Check that subscription hash is valid and subscription didn't expire /// </summary> /// <param name="subscriptionHash">Subscription hash to check</param> /// <param name="requestTime">Date time of subscription request</param> /// <param name="checkOnly">Indicates if only check will be performed</param> private void CheckAndSubscribe(string subscriptionHash, string requestTime, bool checkOnly) { // Get date and time DateTime datetime = DateTimeHelper.ZERO_TIME; // Get date and time if (!string.IsNullOrEmpty(requestTime)) { try { datetime = DateTimeUrlFormatter.Parse(requestTime); } catch { DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed"))); return; } } // Initialize opt-in result OptInApprovalResultEnum result = OptInApprovalResultEnum.NotFound; // Check only data consistency if (checkOnly) { if (SubscriptionObject != null) { // Validate hash result = ForumSubscriptionInfoProvider.ValidateHash(SubscriptionObject, subscriptionHash, SiteContext.CurrentSiteName, datetime); if ((result == OptInApprovalResultEnum.Success) && (SubscriptionObject.SubscriptionApproved)) { result = OptInApprovalResultEnum.NotFound; } } } else { // Try to approve subscription result = ForumSubscriptionInfoProvider.ApproveSubscription(SubscriptionObject, mSubscriptionHash, false, SiteContext.CurrentSiteName, datetime); } // Process result switch (result) { // Approving subscription was successful case OptInApprovalResultEnum.Success: if (!checkOnly) { ShowInfo(DataHelper.GetNotEmpty(SuccessfulConfirmationText, GetString("general.subscription_approval"))); ForumSubscriptionInfoProvider.LogSubscriptionActivity(SubscriptionObject, null, QueryHelper.GetInteger("cid", 0), QueryHelper.GetInteger("siteid", 0), QueryHelper.GetText("url", ""), QueryHelper.GetInteger("docid", 0), QueryHelper.GetText("camp", ""), true); Service.Resolve <ICurrentContactMergeService>().UpdateCurrentContactEmail(SubscriptionObject.SubscriptionEmail, MembershipContext.AuthenticatedUser); } break; // Subscription was already approved case OptInApprovalResultEnum.Failed: DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed"))); break; case OptInApprovalResultEnum.TimeExceeded: ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(SubscriptionObject); DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_timeexceeded"))); break; // Subscription not found default: DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_invalid"))); break; } }
/// <summary> /// OK click hadler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { #region "Security" // Check whether forum exists if (ForumContext.CurrentForum == null) { return; } // Check security bool securityCheck = true; switch (ForumContext.CurrentState) { case ForumStateEnum.NewThread: securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.NewThread); break; case ForumStateEnum.ReplyToPost: securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.Reply); break; case ForumStateEnum.EditPost: securityCheck = ForumContext.CurrentPost != null && IsAvailable(ForumContext.CurrentPost, ForumActionType.Edit); break; } if (!securityCheck) { ShowError(GetString("ForumNewPost.PermissionDenied")); return; } #region "Captcha" // Check security code if is required if ((ForumContext.CurrentForum.ForumUseCAPTCHA) && (!SecurityCode1.IsValid()) && (ForumContext.CurrentState != ForumStateEnum.EditPost)) { ShowError(GetString("ForumNewPost.InvalidCaptcha")); return; } #endregion #region "Email field" // Create instance of validator Validator validator = new Validator(); // Check whether email is valid string result = validator.IsEmail(txtEmail.Text, rfvEmail.ErrorMessage).Result; // Check whether email is present with correct format if email is required // or when subscribtion to current post is checked if ((ForumContext.CurrentForum.ForumRequireEmail || chkSubscribe.Checked) && (!String.IsNullOrEmpty(result))) { ShowError(result); return; } // Check if email is added if is in correct format if ((txtEmail.Text.Trim() != "") && (!String.IsNullOrEmpty(result))) { ShowError(rfvEmail.ErrorMessage); return; } #endregion #region "Subject" // Check whether subject is filled if (txtSubject.Text.Trim() == "") { ShowError(rfvSubject.ErrorMessage); return; } #endregion #region "Text" validator = new Validator(); // Check post text in HTML editor or text area if (!ForumContext.CurrentForum.ForumHTMLEditor) { // Check whether post text is added in text area if ((result = validator.NotEmpty(DiscussionMacroHelper.RemoveTags(ucBBEditor.Text), rfvText.ErrorMessage).Result) != "") { ShowError(result); return; } } else { // Check whether post text is added in HTML editor if ((result = validator.NotEmpty(htmlTemplateBody.ResolvedValue, rfvText.ErrorMessage).Result) != "") { ShowError(result); return; } } #endregion #region "User name" // Check whether user name is filled if user name field is visible if (ForumContext.CurrentForum.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ((ForumContext.CurrentForum != null) && (ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, ForumContext.CommunityGroupID)))) { validator = new Validator(); if (!String.IsNullOrEmpty(result = validator.NotEmpty(txtUserName.Text, rfvUserName.ErrorMessage).Result)) { ShowError(result); return; } } #endregion #endregion #region "Forum post properties" bool newPost = false; // Current forum info object ForumInfo fi = ForumContext.CurrentForum; // Forum post info object ForumPostInfo fp = null; // Get forum post info with dependence on current state if (ForumContext.CurrentState == ForumStateEnum.EditPost) { // Get existing object fp = ForumContext.CurrentPost; fp.PostLastEdit = DateTime.Now; } else { // Create new forum post info object fp = new ForumPostInfo(); newPost = true; } #region "Ad-hoc forum" if (IsAdHocForum && (ForumContext.CurrentForum.ForumID == 0)) { if (DocumentContext.CurrentDocument == null) { ShowError(GetString("forums.documentdoesnotexist")); return; } fi.ForumGroupID = ForumGroupInfoProvider.GetAdHocGroupInfo(SiteID).GroupID; fi.ForumName = "AdHoc-" + Guid.NewGuid(); fi.ForumDisplayName = TextHelper.LimitLength(DocumentContext.CurrentDocument.GetDocumentName(), POST_USERNAME_LENGTH, String.Empty); fi.ForumOpen = true; fi.ForumModerated = false; fi.ForumAccess = 040000; fi.ForumThreads = 0; fi.ForumPosts = 0; fi.ForumLogActivity = LogActivity; ForumInfoProvider.SetForumInfo(fi); ForumContext.CurrentForum.ForumID = fi.ForumID; ForumContext.ForumID = fi.ForumID; ForumID = fi.ForumID; } #endregion // Post forum fp.PostForumID = ForumContext.CurrentForum.ForumID; // Get forum post info with dependence on current state if (ForumContext.CurrentState != ForumStateEnum.EditPost) { // Post time fp.PostTime = DateTime.Now; // User IP address fp.PostInfo.IPAddress = RequestContext.UserHostAddress; // User agent fp.PostInfo.Agent = Request.UserAgent; // Post user id if (!MembershipContext.AuthenticatedUser.IsPublic()) { fp.PostUserID = MembershipContext.AuthenticatedUser.UserID; } // Post signature fp.PostUserSignature = txtSignature.Text; } // Post subject fp.PostSubject = txtSubject.Text; // Post user email fp.PostUserMail = txtEmail.Text; // Post type int forumType = ForumContext.CurrentForum.ForumType; if (forumType == 0) { if (ForumContext.CurrentReplyThread == null) { // New thread - use type which user chosen fp.PostType = (radTypeDiscussion.Checked ? 0 : 1); } else { // Reply - use parent type fp.PostType = ForumContext.CurrentReplyThread.PostType; } } else { // Fixed type - use the forum setting fp.PostType = forumType - 1; } bool newThread = (ForumContext.CurrentReplyThread == null); // Set username if change name is allowed if (fi.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ForumContext.UserIsModerator(fp.PostForumID, ForumContext.CommunityGroupID)) { fp.PostUserName = TextHelper.LimitLength(txtUserName.Text, POST_USERNAME_LENGTH, ""); } else { // Get forum post info with dependence on current state if (ForumContext.CurrentState != ForumStateEnum.EditPost) { fp.PostUserName = UserName; } } // Post parent id -> reply to if (ForumContext.CurrentReplyThread != null) { fp.PostParentID = ForumContext.CurrentReplyThread.PostId; // Check max relative level if ((MaxRelativeLevel > -1) && (ForumContext.CurrentReplyThread.PostLevel >= MaxRelativeLevel)) { ShowError(GetString("Forums.MaxRelativeLevelError")); return; } } // Get post text from HTML editor if is enabled fp.PostText = ForumContext.CurrentForum.ForumHTMLEditor ? htmlTemplateBody.ResolvedValue : ucBBEditor.Text; // Approve post if forum is not moderated if (newPost) { if (!ForumContext.CurrentForum.ForumModerated) { fp.PostApproved = true; } else { if (ForumContext.UserIsModerator(fp.PostForumID, CommunityGroupID)) { fp.PostApproved = true; fp.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID; } } } // If signature is enabled then if (EnableSignature) { fp.PostUserSignature = MembershipContext.AuthenticatedUser.UserSignature; } #endregion if (!BadWordInfoProvider.CanUseBadWords(MembershipContext.AuthenticatedUser, SiteContext.CurrentSiteName)) { // Prepare columns to check Dictionary <string, int> columns = new Dictionary <string, int>(); columns.Add("PostText", 0); columns.Add("PostSubject", 450); columns.Add("PostUserSignature", 0); columns.Add("PostUserName", 200); // Perform bad words check string badMessage = BadWordsHelper.CheckBadWords(fp, columns, "PostApproved", "PostApprovedByUserID", fp.PostText, MembershipContext.AuthenticatedUser.UserID, () => { return(ValidatePost(fp)); }); if (String.IsNullOrEmpty(badMessage)) { if (!ValidatePost(fp)) { badMessage = GetString("ForumNewPost.EmptyBadWord"); } } if (!String.IsNullOrEmpty(badMessage)) { ShowError(badMessage); return; } } // Flood protection if (FloodProtectionHelper.CheckFlooding(SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { ShowError(GetString("General.FloodProtection")); return; } // Check banned ip if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { ShowError(GetString("General.BannedIP")); return; } string baseUrl = ForumContext.CurrentForum.ForumBaseUrl; if (String.IsNullOrEmpty(baseUrl)) { baseUrl = FriendlyBaseURL; } string unsubscriptionUrl = ForumContext.CurrentForum.ForumUnsubscriptionUrl; if (String.IsNullOrEmpty(unsubscriptionUrl)) { unsubscriptionUrl = UnsubscriptionURL; } // USe parent post id for new post int subscibePostId = newPost ? fp.PostParentID : fp.PostId; // Check subscriptions if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(txtEmail.Text)) && (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), fp.PostForumID, subscibePostId))) { // Post of the forum is already subscribed to this email -> show an error chkSubscribe.Checked = false; ShowError(GetString("Forums.EmailAlreadySubscribed")); return; } // Save post object ForumPostInfoProvider.SetForumPostInfo(fp, baseUrl, unsubscriptionUrl); LogPostActivity(fp, fi); #region "Subscription" // If subscribe is checked create new subscription to the current post if ((chkSubscribe.Checked) && (!ForumSubscriptionInfoProvider.IsSubscribed(fp.PostUserMail, fp.PostForumID, fp.PostId))) { // Create new subscription info object ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(); // Set info properties fsi.SubscriptionForumID = fp.PostForumID; fsi.SubscriptionEmail = fp.PostUserMail; fsi.SubscriptionPostID = fp.PostId; fsi.SubscriptionUserID = fp.PostUserID; fsi.SubscriptionGUID = Guid.NewGuid(); // Save subscription ForumSubscriptionInfoProvider.Subscribe(fsi, DateTime.Now, true, true); if (fsi.SubscriptionApproved) { LogSubscriptionActivity(fsi, fi); } } #endregion bool moderationRequired = false; if ((!fp.PostApproved) && (!ForumContext.UserIsModerator(fp.PostForumID, CommunityGroupID))) { moderationRequired = true; if (OnModerationRequired != null) { OnModerationRequired(this, null); } } // Keep current user info CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser; if (currentUser.IsAuthenticated() && chkAttachFile.Checked && (currentUser.IsGlobalAdministrator || ForumContext.CurrentForum.AllowAttachFiles != SecurityAccessEnum.Nobody)) { // Redirect to the post attachments string attachmentUrl = GetURL(fp, ForumActionType.Attachment); if (moderationRequired) { attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "moderated", "1"); } URLHelper.Redirect(attachmentUrl); } else { if (!StopProcessing) { // Redirect back to the forum or forum thread URLHelper.Redirect(ClearURL()); } } }
/// <summary> /// Check that subscription hash is valid and subscription didn't expire /// </summary> /// <param name="subscriptionHash">Subscription hash to check</param> /// <param name="requestTime">Date time of subscription request</param> /// <param name="checkOnly">Indicates if only check will be performed</param> private void CheckAndSubscribe(string subscriptionHash, string requestTime, bool checkOnly) { // Get date and time DateTime datetime = DateTimeHelper.ZERO_TIME; // Get date and time if (!string.IsNullOrEmpty(requestTime)) { try { datetime = DateTime.ParseExact(requestTime, SecurityHelper.EMAIL_CONFIRMATION_DATETIME_FORMAT, null); } catch { DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed"))); return; } } // Initialize opt-in result OptInApprovalResultEnum result = OptInApprovalResultEnum.NotFound; // Check only data consistency if (checkOnly) { if (SubscriptionObject != null) { // Validate hash result = ForumSubscriptionInfoProvider.ValidateHash(SubscriptionObject, subscriptionHash, SiteContext.CurrentSiteName, datetime); if ((result == OptInApprovalResultEnum.Success) && (SubscriptionObject.SubscriptionApproved)) { result = OptInApprovalResultEnum.NotFound; } } } else { // Try to approve subscription result = ForumSubscriptionInfoProvider.ApproveSubscription(SubscriptionObject, mSubscriptionHash, false, SiteContext.CurrentSiteName, datetime); } // Process result switch (result) { // Approving subscription was successful case OptInApprovalResultEnum.Success: if (!checkOnly) { ShowInfo(DataHelper.GetNotEmpty(SuccessfulConfirmationText, GetString("general.subscription_approval"))); ForumSubscriptionInfoProvider.LogSubscriptionActivity(SubscriptionObject, null, QueryHelper.GetInteger("cid", 0), QueryHelper.GetInteger("siteid", 0), QueryHelper.GetText("url", ""), QueryHelper.GetInteger("docid", 0), QueryHelper.GetText("camp", ""), PredefinedActivityType.SUBSCRIPTION_FORUM_POST, true); } break; // Subscription was already approved case OptInApprovalResultEnum.Failed: DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed"))); break; case OptInApprovalResultEnum.TimeExceeded: ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(SubscriptionObject); DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_timeexceeded"))); break; // Subscription not found default: case OptInApprovalResultEnum.NotFound: DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_invalid"))); break; } }
/// <summary> /// OK click handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check banned IP if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { ShowError(GetString("General.BannedIP")); return; } // Check input fields string result = new Validator().NotEmpty(txtEmail.Text, rfvEmailRequired.ErrorMessage).IsRegularExp(txtEmail.Text, @"^([\w0-9_-]+(\.[\w0-9_-]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$", rfvEmail.ErrorMessage).Result; if (result == "") { // For selected forum and only if subscription is enabled if ((ForumContext.CurrentForum != null) && ((ForumContext.CurrentState == ForumStateEnum.SubscribeToPost) || (ForumContext.CurrentState == ForumStateEnum.NewSubscription))) { // Check permissions if (!IsAvailable(ForumContext.CurrentForum, ForumActionType.SubscribeToForum)) { ShowError(GetString("ForumNewPost.PermissionDenied")); return; } // Create new subscription ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(); fsi.SubscriptionForumID = ForumContext.CurrentForum.ForumID; fsi.SubscriptionEmail = HTMLHelper.HTMLEncode(txtEmail.Text.Trim()); fsi.SubscriptionGUID = Guid.NewGuid(); if (ForumContext.CurrentSubscribeThread != null) { fsi.SubscriptionPostID = ForumContext.CurrentSubscribeThread.PostId; } if (MembershipContext.AuthenticatedUser != null) { fsi.SubscriptionUserID = MembershipContext.AuthenticatedUser.UserID; } // Check whether user is not subscribed if (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), fsi.SubscriptionForumID, fsi.SubscriptionPostID)) { ShowError(GetString("ForumSubscibe.SubscriptionExists")); return; } ForumSubscriptionInfoProvider.Subscribe(fsi, DateTime.Now, true, true); if (fsi.SubscriptionApproved) { ShowConfirmation(GetString("blog.subscription.beensubscribed")); LogSubscriptionActivity(fsi, ForumContext.CurrentForum); } else { string confirmation = GetString("general.subscribed.doubleoptin"); int optInInterval = ForumGroupInfoProvider.DoubleOptInInterval(SiteContext.CurrentSiteName); if (optInInterval > 0) { confirmation += "<br />" + string.Format(GetString("general.subscription_timeintervalwarning"), optInInterval); } ShowConfirmation(confirmation); } } } URLHelper.Redirect(ClearURL()); }