/// <summary> /// The post reply handle new post. /// </summary> /// <returns> /// Returns the Message Id. /// </returns> protected Message PostReplyHandleNewTopic() { if (!this.PageBoardContext.ForumPostAccess) { this.Get <LinkBuilder>().AccessDenied(); } // Check if Forum is Moderated var isForumModerated = this.CheckForumModerateStatus(this.PageBoardContext.PageForum, true); // If Forum is Moderated if (isForumModerated) { this.spamApproved = false; } // Bypass Approval if Admin or Moderator if (this.PageBoardContext.IsAdmin || this.PageBoardContext.ForumModeratorAccess) { this.spamApproved = true; } // make message flags var messageFlags = new MessageFlags { IsHtml = this.forumEditor.UsesHTML, IsBBCode = this.forumEditor.UsesBBCode, IsPersistent = this.PostOptions1.PersistentChecked, IsApproved = this.spamApproved }; // Save to Db var newTopic = this.GetRepository <Topic>().SaveNew( this.PageBoardContext.PageForum, HtmlHelper.StripHtml(this.TopicSubjectTextBox.Text.Trim()), string.Empty, HtmlHelper.StripHtml(this.TopicStylesTextBox.Text.Trim()), HtmlHelper.StripHtml(this.TopicDescriptionTextBox.Text.Trim()), HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(this.forumEditor.Text)), this.PageBoardContext.PageUser, this.Priority.SelectedValue.ToType <short>(), this.PageBoardContext.IsGuest ? this.From.Text : this.PageBoardContext.PageUser.Name, this.PageBoardContext.IsGuest ? this.From.Text : this.PageBoardContext.PageUser.DisplayName, this.Get <HttpRequestBase>().GetUserRealIPAddress(), DateTime.UtcNow, messageFlags, out var message); message.Topic = newTopic; this.UpdateWatchTopic(this.PageBoardContext.PageUserID, newTopic.ID); return(message); }
/// <summary> /// Handles verification of the PostReply. Adds java script message if there is a problem. /// </summary> /// <returns> /// true if everything is verified /// </returns> protected bool IsPostReplyVerified() { // To avoid posting whitespace(s) or empty messages var postedMessage = HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(this.forumEditor.Text.Trim())); if (postedMessage.IsNotSet()) { this.PageBoardContext.Notify(this.GetText("ISEMPTY"), MessageTypes.warning); return(false); } // No need to check whitespace if they are actually posting something if (this.PageBoardContext.BoardSettings.MaxPostSize > 0 && this.forumEditor.Text.Length >= this.PageBoardContext.BoardSettings.MaxPostSize) { this.PageBoardContext.Notify(this.GetText("ISEXCEEDED"), MessageTypes.warning); return(false); } // Check if the Entered Guest Username is not too long if (this.FromRow.Visible && this.From.Text.Trim().Length > 100) { this.PageBoardContext.Notify(this.GetText("GUEST_NAME_TOOLONG"), MessageTypes.warning); this.From.Text = this.From.Text.Substring(100); return(false); } if (this.SubjectRow.Visible && this.TopicSubjectTextBox.Text.IsNotSet()) { this.PageBoardContext.Notify(this.GetText("NEED_SUBJECT"), MessageTypes.warning); return(false); } if (!this.Get <IPermissions>().Check(this.PageBoardContext.BoardSettings.AllowCreateTopicsSameName) && this.GetRepository <Topic>().CheckForDuplicate(this.TopicSubjectTextBox.Text.Trim()) && !this.EditMessageId.HasValue) { this.PageBoardContext.Notify(this.GetText("SUBJECT_DUPLICATE"), MessageTypes.warning); return(false); } if ((!this.PageBoardContext.IsGuest || !this.PageBoardContext.BoardSettings.EnableCaptchaForGuests) && (!this.PageBoardContext.BoardSettings.EnableCaptchaForPost || this.PageBoardContext.PageUser.UserFlags.IsCaptchaExcluded) || CaptchaHelper.IsValid(this.tbCaptcha.Text.Trim())) { return(true); } this.PageBoardContext.Notify(this.GetText("BAD_CAPTCHA"), MessageTypes.danger); return(false); }
/// <summary> /// The post reply handle edit post. /// </summary> /// <returns> /// Returns the Message Id /// </returns> protected Tuple <Topic, Message, User, Forum> PostReplyHandleEditPost() { if (!this.PageBoardContext.ForumEditAccess) { this.Get <LinkBuilder>().AccessDenied(); } var subjectSave = string.Empty; var descriptionSave = string.Empty; var stylesSave = string.Empty; if (this.TopicSubjectTextBox.Enabled) { subjectSave = this.TopicSubjectTextBox.Text; } if (this.TopicDescriptionTextBox.Enabled) { descriptionSave = this.TopicDescriptionTextBox.Text; } if (this.TopicStylesTextBox.Enabled) { stylesSave = this.TopicStylesTextBox.Text; } // Mek Suggestion: This should be removed, resetting flags on edit is a bit lame. // Ederon : now it should be better, but all this code around forum/topic/message flags needs revamp // retrieve message flags var messageFlags = new MessageFlags(this.editedMessage.Item2.Flags) { IsHtml = this .forumEditor .UsesHTML, IsBBCode = this .forumEditor .UsesBBCode, IsPersistent = this .PostOptions1 .PersistentChecked }; this.editedMessage.Item2.Flags = messageFlags.BitValue; var isModeratorChanged = this.PageBoardContext.PageUserID != this.ownerUserId; this.GetRepository <Message>().Update( this.Priority.SelectedValue.ToType <short>(), HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(this.forumEditor.Text)), descriptionSave.Trim(), string.Empty, stylesSave.Trim(), subjectSave.Trim(), this.HtmlEncode(this.ReasonEditor.Text), isModeratorChanged, this.PageBoardContext.IsAdmin || this.PageBoardContext.ForumModeratorAccess, this.editedMessage, this.PageBoardContext.PageUserID); // Update Topic Tags?! if (this.TagsHolder.Visible) { this.GetRepository <TopicTag>().Delete(x => x.TopicID == this.PageBoardContext.PageTopicID); this.GetRepository <TopicTag>().AddTagsToTopic(this.TagsValue.Value, this.PageBoardContext.PageTopicID); } this.UpdateWatchTopic(this.PageBoardContext.PageUserID, this.PageBoardContext.PageTopicID); // remove cache if it exists... this.Get <IDataCache>() .Remove(string.Format(Constants.Cache.FirstPostCleaned, this.PageBoardContext.PageBoardID, this.PageBoardContext.PageTopicID)); return(this.editedMessage); }