Example #1
0
    /// <summary>
    /// The initializes the edited post.
    /// </summary>
    /// <param name="currentMessage">
    /// The current message.
    /// </param>
    private void InitEditedPost([NotNull] Tuple <Topic, Message, User, Forum> currentMessage)
    {
        /*if (this.forumEditor.UsesHTML && currentMessage.Flags.IsBBCode)
         * {
         *  // If the message is in YafBBCode but the editor uses HTML, convert the message text to HTML
         *  currentMessage.Message = this.Get<IBBCode>().ConvertBBCodeToHtmlForEdit(currentMessage.Message);
         * }*/

        if (this.forumEditor.UsesBBCode && currentMessage.Item2.MessageFlags.IsHtml)
        {
            // If the message is in HTML but the editor uses YafBBCode, convert the message text to BBCode
            currentMessage.Item2.MessageText = this.Get <IBBCode>().ConvertHtmlToBBCodeForEdit(currentMessage.Item2.MessageText);
        }

        this.forumEditor.Text = BBCodeHelper.DecodeCodeBlocks(currentMessage.Item2.MessageText);

        if (this.forumEditor.UsesHTML && currentMessage.Item2.MessageFlags.IsBBCode)
        {
            this.forumEditor.Text = this.Get <IBBCode>().FormatMessageWithCustomBBCode(
                this.forumEditor.Text,
                currentMessage.Item2.MessageFlags,
                currentMessage.Item2.UserID,
                currentMessage.Item2.ID);
        }

        this.Title.Text = this.GetText("EDIT");
        this.PostReply.TextLocalizedTag  = "SAVE";
        this.PostReply.TextLocalizedPage = "COMMON";

        // add topic link...
        this.PageLinks.AddTopic(this.PageBoardContext.PageTopic.TopicName, this.PageBoardContext.PageTopicID);

        // editing..
        this.PageLinks.AddLink(this.GetText("EDIT"));

        this.TopicSubjectTextBox.Text     = this.Server.HtmlDecode(this.PageBoardContext.PageTopic.TopicName);
        this.TopicDescriptionTextBox.Text = this.Server.HtmlDecode(this.PageBoardContext.PageTopic.Description);

        if (this.PageBoardContext.PageTopic.UserID == currentMessage.Item2.UserID ||
            this.PageBoardContext.ForumModeratorAccess)
        {
            // allow editing of the topic subject
            this.TopicSubjectTextBox.Enabled = true;
        }
        else
        {
            this.TopicSubjectTextBox.Enabled     = false;
            this.TopicDescriptionTextBox.Enabled = false;
        }

        // Allow the Styling of Topic Titles only for Mods or Admins
        if (this.PageBoardContext.BoardSettings.UseStyledTopicTitles &&
            (this.PageBoardContext.ForumModeratorAccess || this.PageBoardContext.IsAdmin))
        {
            this.StyleRow.Visible = true;
        }
        else
        {
            this.StyleRow.Visible           = false;
            this.TopicStylesTextBox.Enabled = false;
        }

        this.TopicStylesTextBox.Text = this.PageBoardContext.PageTopic.Styles;

        this.Priority.SelectedItem.Selected = false;
        this.Priority.Items.FindByValue(this.PageBoardContext.PageTopic.Priority.ToString()).Selected = true;

        this.EditReasonRow.Visible          = true;
        this.ReasonEditor.Text              = this.Server.HtmlDecode(currentMessage.Item2.EditReason);
        this.PostOptions1.PersistentChecked = currentMessage.Item2.MessageFlags.IsPersistent;

        var topicsList = this.GetRepository <TopicTag>().List(this.PageBoardContext.PageTopicID);

        if (topicsList.Any())
        {
            this.TagsValue.Value = topicsList.Select(t => t.Item2.TagName).ToDelimitedString(",");
        }

        // Ederon : 9/9/2007 - moderators can reply in locked topics
        if (this.PageBoardContext.PageTopic.TopicFlags.IsLocked && !this.PageBoardContext.ForumModeratorAccess)
        {
            var urlReferrer = this.Get <HttpRequestBase>().UrlReferrer;

            if (urlReferrer != null)
            {
                this.Get <HttpResponseBase>().Redirect(urlReferrer.ToString());
            }
        }

        this.HandleUploadControls();
    }