public IHttpActionResult HandleMultiQuote([NotNull] MultiQuoteButton quoteButton) { var buttonId = quoteButton.ButtonId; var isMultiQuoteButton = quoteButton.IsMultiQuoteButton; var messageId = quoteButton.MessageId; var topicId = quoteButton.TopicId; var buttonCssClass = quoteButton.ButtonCssClass; var yafSession = this.Get <ISession>(); var multiQuote = new MultiQuote { MessageID = messageId, TopicID = topicId }; if (isMultiQuoteButton) { if (yafSession.MultiQuoteIds != null) { if (!yafSession.MultiQuoteIds.Any(m => m.MessageID.Equals(messageId))) { yafSession.MultiQuoteIds.Add(multiQuote); } } else { yafSession.MultiQuoteIds = new List <MultiQuote> { multiQuote }; } buttonCssClass += " Checked"; } else { if (yafSession.MultiQuoteIds != null && yafSession.MultiQuoteIds.Any(m => m.MessageID.Equals(messageId))) { yafSession.MultiQuoteIds.Remove(multiQuote); } buttonCssClass = "MultiQuoteButton"; } return(this.Ok(new ReturnClass { Id = buttonId, NewTitle = buttonCssClass })); }
public YafAlbum.ReturnClass HandleMultiQuote( [NotNull] string buttonId, [NotNull] bool multiquoteButton, [NotNull] int messageId, [NotNull] int topicId, [NotNull] string buttonCssClass) { var yafSession = this.Get <IYafSession>(); var multiQuote = new MultiQuote { MessageID = messageId, TopicID = topicId }; if (multiquoteButton) { if (yafSession.MultiQuoteIds != null) { if (!yafSession.MultiQuoteIds.Any(m => m.MessageID.Equals(messageId))) { yafSession.MultiQuoteIds.Add(multiQuote); } } else { yafSession.MultiQuoteIds = new List <MultiQuote> { multiQuote }; } buttonCssClass += " Checked"; } else { if (yafSession.MultiQuoteIds != null && yafSession.MultiQuoteIds.Any(m => m.MessageID.Equals(messageId))) { yafSession.MultiQuoteIds.Remove(multiQuote); } buttonCssClass = "MultiQuoteButton"; } return(new YafAlbum.ReturnClass { Id = buttonId, NewTitle = buttonCssClass }); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.PageContext.PageForumID == 0) { this.Get <LinkBuilder>().AccessDenied(); } if (this.Get <HttpRequestBase>()["t"] == null && this.Get <HttpRequestBase>()["m"] == null && !this.PageContext.ForumPostAccess) { this.Get <LinkBuilder>().AccessDenied(); } if (this.Get <HttpRequestBase>()["t"] != null && !this.PageContext.ForumReplyAccess) { this.Get <LinkBuilder>().AccessDenied(); } this.topic = this.GetRepository <Topic>().GetById(this.PageContext.PageTopicID); // we reply to a post with a quote if (this.QuotedMessageId.HasValue) { this.quotedMessage = this.GetRepository <Message>().GetMessage(this.QuotedMessageId.Value); if (this.quotedMessage != null) { if (this.Get <HttpRequestBase>().QueryString.Exists("text")) { var quotedMessageText = this.Server.UrlDecode(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("text")); this.quotedMessage.Item2.MessageText = HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(quotedMessageText)); } if (this.quotedMessage.Item2.TopicID != this.PageContext.PageTopicID) { this.Get <LinkBuilder>().AccessDenied(); } if (!this.CanQuotePostCheck(this.topic)) { this.Get <LinkBuilder>().AccessDenied(); } } } this.HandleUploadControls(); this.LastPosts1.TopicID = this.TopicId; if (!this.IsPostBack) { // update options... this.PostOptions1.Visible = !this.PageContext.IsGuest; this.PostOptions1.PersistentOptionVisible = this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess; this.PostOptions1.WatchOptionVisible = !this.PageContext.IsGuest; this.PostOptions1.PollOptionVisible = false; if (!this.PageContext.IsGuest) { this.PostOptions1.WatchChecked = this.PageContext.PageTopicID > 0 ? this.GetRepository <WatchTopic>().Check(this.PageContext.PageUserID, this.PageContext.PageTopicID).HasValue : this.PageContext.User.AutoWatchTopics; } if (this.PageContext.IsGuest && this.PageContext.BoardSettings.EnableCaptchaForGuests || this.PageContext.BoardSettings.EnableCaptchaForPost && !this.PageContext.User.UserFlags.IsCaptchaExcluded) { this.imgCaptcha.ImageUrl = $"{BoardInfo.ForumClientFileRoot}resource.ashx?c=1"; this.tr_captcha1.Visible = true; this.tr_captcha2.Visible = true; } if (this.PageContext.Settings.LockedForum == 0) { this.PageLinks.AddRoot(); this.PageLinks.AddCategory(this.PageContext.PageCategoryName, this.PageContext.PageCategoryID); } this.PageLinks.AddForum(this.PageContext.PageForumID); // check if it's a reply to a topic... this.InitReplyToTopic(); if (this.quotedMessage != null) { if (this.QuotedMessageId.HasValue) { if (this.Get <ISession>().MultiQuoteIds != null) { var quoteId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAs <int>("q"); var multiQuote = new MultiQuote { MessageID = quoteId, TopicID = this.PageContext.PageTopicID }; if ( !this.Get <ISession>() .MultiQuoteIds.Any(m => m.MessageID.Equals(quoteId))) { this.Get <ISession>() .MultiQuoteIds.Add( multiQuote); } var messages = this.GetRepository <Message>().GetByIds( this.Get <ISession>().MultiQuoteIds.Select(i => i.MessageID)); messages.ForEach(this.InitQuotedReply); // Clear Multi-quotes this.Get <ISession>().MultiQuoteIds = null; } else { this.InitQuotedReply(this.quotedMessage.Item2); } } } // form user is only for "Guest" if (this.PageContext.IsGuest) { this.From.Text = this.PageContext.User.DisplayOrUserName(); this.FromRow.Visible = false; } } // Set Poll this.PollId = this.topic.PollID; this.PollList.TopicId = this.TopicId; this.PollList.PollId = this.PollId; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.PageContext.PageForumID == 0) { BuildLink.AccessDenied(); } if (this.Get <HttpRequestBase>()["t"] == null && this.Get <HttpRequestBase>()["m"] == null && !this.PageContext.ForumPostAccess) { BuildLink.AccessDenied(); } if (this.Get <HttpRequestBase>()["t"] != null && !this.PageContext.ForumReplyAccess) { BuildLink.AccessDenied(); } this.topic = this.GetRepository <Topic>().GetById(this.PageContext.PageTopicID); // we reply to a post with a quote if (this.QuotedMessageId.HasValue) { var quotedMessage = this.GetRepository <Message>().GetMessage(this.QuotedMessageId.Value); if (quotedMessage != null) { if (this.Get <HttpRequestBase>().QueryString.Exists("text")) { var quotedMessageText = this.Server.UrlDecode(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("text")); quotedMessage.Item2.MessageText = HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(quotedMessageText)); } if (quotedMessage.Item2.TopicID != this.PageContext.PageTopicID) { BuildLink.AccessDenied(); } if (!this.CanQuotePostCheck(this.topic)) { BuildLink.AccessDenied(); } } this.editOrQuotedMessage = quotedMessage; } else if (this.EditMessageId.HasValue) { var editMessage = this.GetRepository <Message>().GetMessage(this.EditMessageId.Value); if (editMessage != null) { this.ownerUserId = editMessage.Item1.UserID; if (!this.CanEditPostCheck(editMessage.Item2, this.topic)) { BuildLink.AccessDenied(); } } this.editOrQuotedMessage = editMessage; // we edit message and should transfer both the message ID and TopicID for PageLinks. this.PollList.EditMessageId = this.EditMessageId.Value; } this.HandleUploadControls(); if (!this.IsPostBack) { var normal = new ListItem(this.GetText("normal"), "0"); normal.Attributes.Add( "data-content", $"<span class='select2-image-select-icon'><i class='far fa-comment fa-fw text-secondary'></i> {this.GetText("normal")}</span>"); this.Priority.Items.Add(normal); var sticky = new ListItem(this.GetText("sticky"), "1"); sticky.Attributes.Add( "data-content", $"<span class='select2-image-select-icon'><i class='fas fa-thumbtack fa-fw text-secondary'></i> {this.GetText("sticky")}</span>"); this.Priority.Items.Add(sticky); var announcement = new ListItem(this.GetText("announcement"), "2"); announcement.Attributes.Add( "data-content", $"<span class='select2-image-select-icon'><i class='fas fa-bullhorn fa-fw text-secondary'></i> {this.GetText("announcement")}</span>"); this.Priority.Items.Add(announcement); this.Priority.SelectedIndex = 0; // Allow the Styling of Topic Titles only for Mods or Admins if (this.PageContext.BoardSettings.UseStyledTopicTitles && (this.PageContext.ForumModeratorAccess || this.PageContext.IsAdmin)) { this.StyleRow.Visible = true; } else { this.StyleRow.Visible = false; } this.EditReasonRow.Visible = false; this.PriorityRow.Visible = this.PageContext.ForumPriorityAccess; // update options... this.PostOptions1.Visible = !this.PageContext.IsGuest; this.PostOptions1.PersistentOptionVisible = this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess; this.PostOptions1.WatchOptionVisible = !this.PageContext.IsGuest; this.PostOptions1.PollOptionVisible = false; if (!this.PageContext.IsGuest) { this.PostOptions1.WatchChecked = this.PageContext.PageTopicID > 0 ? this.GetRepository <WatchTopic>().Check(this.PageContext.PageUserID, this.PageContext.PageTopicID).HasValue : this.PageContext.User.AutoWatchTopics; } if (this.PageContext.IsGuest && this.PageContext.BoardSettings.EnableCaptchaForGuests || this.PageContext.BoardSettings.EnableCaptchaForPost && !this.PageContext.User.UserFlags.IsCaptchaExcluded) { this.imgCaptcha.ImageUrl = $"{BoardInfo.ForumClientFileRoot}resource.ashx?c=1"; this.tr_captcha1.Visible = true; this.tr_captcha2.Visible = true; } if (this.PageContext.Settings.LockedForum == 0) { this.PageLinks.AddRoot(); this.PageLinks.AddCategory(this.PageContext.PageCategoryName, this.PageContext.PageCategoryID); } this.PageLinks.AddForum(this.PageContext.PageForumID); // check if it's a reply to a topic... this.InitReplyToTopic(); if (this.editOrQuotedMessage != null) { if (this.QuotedMessageId.HasValue) { if (this.Get <ISession>().MultiQuoteIds != null) { var quoteId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("q").ToType <int>(); var multiQuote = new MultiQuote { MessageID = quoteId, TopicID = this.PageContext.PageTopicID }; if ( !this.Get <ISession>() .MultiQuoteIds.Any(m => m.MessageID.Equals(quoteId))) { this.Get <ISession>() .MultiQuoteIds.Add( multiQuote); } var messages = this.GetRepository <Message>().GetByIds( this.Get <ISession>().MultiQuoteIds.Select(i => i.MessageID)); messages.ForEach(this.InitQuotedReply); // Clear Multi-quotes this.Get <ISession>().MultiQuoteIds = null; } else { this.InitQuotedReply(this.editOrQuotedMessage.Item2); } } else if (this.EditMessageId.HasValue) { // editing a message... this.InitEditedPost(this.editOrQuotedMessage.Item2); this.PollList.EditMessageId = this.EditMessageId.Value; } } // form user is only for "Guest" if (this.PageContext.IsGuest) { this.From.Text = this.PageContext.User.DisplayOrUserName(); this.FromRow.Visible = false; } } // Set Poll this.PollId = this.topic.PollID; this.PollList.TopicId = this.TopicId; this.PollList.PollId = this.PollId; }