Example #1
0
        /// <summary>
        /// The init quoted reply.
        /// </summary>
        /// <param name="message">
        /// The current TypedMessage. 
        /// </param>
        private void InitQuotedReply(TypedMessageList message)
        {
            var messageContent = message.Message;

            if (this.Get<YafBoardSettings>().RemoveNestedQuotes)
            {
                messageContent = this.Get<IFormatMessage>().RemoveNestedQuotes(messageContent);
            }

            if (this._forumEditor.UsesHTML && message.Flags.IsBBCode)
            {
                // If the message is in YafBBCode but the editor uses HTML, convert the message text to HTML
                messageContent = this.Get<IBBCode>().ConvertBBCodeToHtmlForEdit(messageContent);
            }

            if (this._forumEditor.UsesBBCode && message.Flags.IsHtml)
            {
                // If the message is in HTML but the editor uses YafBBCode, convert the message text to BBCode
                messageContent = this.Get<IBBCode>().ConvertHtmltoBBCodeForEdit(messageContent);
            }

            // Ensure quoted replies have bad words removed from them
            messageContent = this.Get<IBadWordReplace>().Replace(messageContent);

            // Remove HIDDEN Text
            messageContent = this.Get<IFormatMessage>().RemoveHiddenBBCodeContent(messageContent);

            // Quote the original message
            this._forumEditor.Text +=
                "[quote={0};{1}]{2}[/quote]\n\n".FormatWith(
                    this.Get<IUserDisplayName>().GetName(message.UserID.ToType<int>()),
                    message.MessageID,
                    messageContent).TrimStart();
        }
Example #2
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this._messageRow = null;

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m") != null)
            {
                int messageId;
                if (!int.TryParse(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m"), out messageId))
                {
                    YafBuildLink.RedirectInfoPage(InfoMessage.Invalid);
                }

                this._messageRow = CommonDb.MessageList(PageContext.PageModuleID, messageId).FirstOrDefault();

                // first message should not be deleted
                if (this._messageRow == null || (int)this._messageRow.Position <= 0)
                {
                    YafBuildLink.RedirectInfoPage(InfoMessage.Invalid);
                }

                if (!this.PageContext.ForumModeratorAccess && this.PageContext.PageUserID != this._messageRow.UserID)
                {
                    YafBuildLink.AccessDenied();
                }
            }

            this._forumFlags = this._messageRow.ForumFlags;
            this._topicFlags = this._messageRow.TopicFlags;
            this._ownerUserId = (int)this._messageRow.UserID;
            this._isModeratorChanged = this.PageContext.PageUserID != this._ownerUserId;

            if (this.PageContext.PageForumID == 0)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("t") == null
                && !this.PageContext.ForumPostAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("t") != null
                && !this.PageContext.ForumReplyAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            // setup page links
            this.PageLinks.AddLink(this.Get<YafBoardSettings>().Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                this.PageContext.PageCategoryName,
                YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            this.PageLinks.AddForumLinks(this.PageContext.PageForumID);

            this.EraseMessage.Checked = false;
            this.ViewState["delAll"] = false;
            this.EraseRow.Visible = false;
            this.DeleteReasonRow.Visible = false;
            this.LinkedPosts.Visible = false;
            this.ReasonEditor.Attributes.Add("style", "width:100%");
            this.Cancel.Text = this.GetText("Cancel");

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m") == null)
            {
                return;
            }

            // delete message...
            this.PreviewRow.Visible = true;

            DataTable tempdb = CommonDb.message_getRepliesList(
                PageContext.PageModuleID,
                this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m"));

            if (tempdb.Rows.Count > 0 && (this.PageContext.ForumModeratorAccess || this.PageContext.IsAdmin))
            {
                this.LinkedPosts.Visible = true;
                this.LinkedPosts.DataSource = tempdb;
                this.LinkedPosts.DataBind();
            }

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("action").ToLower() == "delete")
            {
                this.Title.Text = this.GetText("EDIT"); // GetText("EDIT");
                this.Delete.Text = this.GetText("DELETE"); // "GetText("Save");

                if (this.PageContext.IsAdmin)
                {
                    this.EraseRow.Visible = true;
                }
            }
            else
            {
                this.Title.Text = this.GetText("EDIT");
                this.Delete.Text = this.GetText("UNDELETE"); // "GetText("Save");
            }

            this.Subject.Text = Convert.ToString(this._messageRow.Topic);
            this.DeleteReasonRow.Visible = true;
            this.ReasonEditor.Text = Convert.ToString(this._messageRow.DeleteReason);

            // populate the message preview with the message datarow...
            this.MessagePreview.Message = this._messageRow.Message;
            this.MessagePreview.MessageFlags = this._messageRow.Flags;
        }