protected string GetThreadedRow([NotNull] object o) { var row = (DataRow)o; int messageId = (int)row["MessageID"]; if (!this.IsThreaded || this.CurrentMessage == messageId) { return(string.Empty); } var html = new StringBuilder(); // Threaded string brief = StringHelper.RemoveMultipleWhitespace( BBCodeHelper.StripBBCode(HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(row["Message"].ToString())))); brief = StringHelper.Truncate(this.Get <YafBadWordReplace>().Replace(brief), 100); brief = YafFormatMessage.AddSmiles(brief); if (brief.IsNotSet()) { brief = "..."; } html.AppendFormat(@"<tr class=""post""><td colspan=""3"" style=""white-space:nowrap;"">"); html.AppendFormat(this.GetIndentImage(row["Indent"])); string avatarUrl = this.Get <YafAvatars>().GetAvatarUrlForUser(row.Field <int>("UserID")); if (avatarUrl.IsNotSet()) { avatarUrl = "{0}images/noavatar.gif".FormatWith(YafForumInfo.ForumClientFileRoot); } html.Append(@"<span class=""threadedRowCollapsed"">"); html.AppendFormat(@"<img src=""{0}"" alt="""" class=""avatarimage"" />", avatarUrl); html.AppendFormat(@"<a href=""{0}"" class=""threadUrl"">{1}</a>", YafBuildLink.GetLink(ForumPages.posts, "m={0}#post{0}", messageId), brief); html.Append(" ("); html.Append( new UserLink() { ID = "UserLinkForRow{0}".FormatWith(messageId), UserID = row.Field <int>("UserID") }. RenderToString()); html.AppendFormat(" - {0})</span>", new DisplayDateTime() { DateTime = row["Posted"], Format = DateTimeFormat.BothTopic }. RenderToString()); html.AppendFormat("</td></tr>"); return(html.ToString()); }
/// <summary> /// The get print body. /// </summary> /// <param name="o"> /// The o. /// </param> /// <returns> /// The get print body. /// </returns> protected string GetPrintBody(object o) { var row = (DataRow)o; string message = row["Message"].ToString(); message = YafFormatMessage.FormatMessage(message, new MessageFlags(Convert.ToInt32(row["Flags"]))); return(message); }
/// <summary> /// The bind data. /// </summary> private void BindData() { if (!this.shoutBoxPlaceHolder.Visible) { return; } var shoutBoxMessages = (DataTable)this.PageContext.Cache[this.CacheKey]; if (shoutBoxMessages == null) { shoutBoxMessages = DB.shoutbox_getmessages( this.PageContext.PageBoardID, this.PageContext.BoardSettings.ShoutboxShowMessageCount, this.PageContext.BoardSettings.UseStyledNicks); // Set colorOnly parameter to false, as we get all color info from data base if (this.PageContext.BoardSettings.UseStyledNicks) { new StyleTransform(this.PageContext.Theme).DecodeStyleByTable(ref shoutBoxMessages, false); } var flags = new MessageFlags { IsBBCode = true, IsHtml = false }; for (int i = 0; i < shoutBoxMessages.Rows.Count; i++) { string formattedMessage = YafFormatMessage.FormatMessage( shoutBoxMessages.Rows[i]["Message"].ToString(), flags); // Extra Formating not needed already done tru YafFormatMessage.FormatMessage //formattedMessage = FormatHyperLink(formattedMessage); shoutBoxMessages.Rows[i]["Message"] = formattedMessage; } // cache for 30 seconds -- could cause problems on web farm configurations. this.PageContext.Cache.Add(this.CacheKey, shoutBoxMessages, DateTime.UtcNow.AddSeconds(30)); } this.shoutBoxRepeater.DataSource = shoutBoxMessages; if (this.PageContext.BoardSettings.ShowShoutboxSmiles) { this.smiliesRepeater.DataSource = DB.smiley_listunique(this.PageContext.PageBoardID); } }
/// <summary> /// The do search_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> /// <exception cref="ApplicationException"> /// </exception> private void DoSearch_Click([NotNull] object sender, [NotNull] EventArgs e) { if (string.IsNullOrEmpty(this.search.Text)) { return; } if (this.search.Text.Length <= 3) { this.PageContext.AddLoadMessage(this.PageContext.Localization.GetText("SEARCHLONGER")); return; } IList <string> highlightWords = new List <string> { this.search.Text }; List <YafHelpContent> searchlist = this.helpContents.FindAll( check => check.HelpContent.ToLower().Contains(this.search.Text.ToLower()) || check.HelpTitle.ToLower().Contains(this.search.Text.ToLower())); foreach (YafHelpContent item in searchlist) { item.HelpContent = YafFormatMessage.SurroundWordList( item.HelpContent, highlightWords, @"<span class=""highlight"">", @"</span>"); item.HelpTitle = YafFormatMessage.SurroundWordList( item.HelpTitle, highlightWords, @"<span class=""highlight"">", @"</span>"); } if (searchlist.Count.Equals(0)) { this.PageContext.AddLoadMessage(this.PageContext.Localization.GetText("NORESULTS")); return; } this.HelpList.DataSource = searchlist; this.HelpList.DataBind(); this.SearchHolder.Visible = false; this.HelpList.Visible = true; }
protected string FormatMessage(object messageText, object messageID) { string formattedMessage = messageText.ToString(); string strMessageId = messageID.ToString(); //split message if (formattedMessage.IndexOf("===") >= 0) { formattedMessage = Regex.Split(formattedMessage, "===")[0]; formattedMessage += string.Format("<a href=\"forum.aspx?g=posts&t={0}\">{1}</a>", strMessageId, SharedWeb.Utils.GetText("HPSAGA_FRONTPAGENEWS", "ReadMore")); } MessageFlags messageFlags = new MessageFlags(); messageFlags.IsBBCode = true; formattedMessage = YafFormatMessage.FormatMessage(formattedMessage, messageFlags); return(formattedMessage); }
/// <summary> /// The init quoted reply. /// </summary> /// <param name="currentRow"> /// The current row. /// </param> /// <param name="message"> /// The message. /// </param> /// <param name="messageFlags"> /// The message flags. /// </param> private void InitQuotedReply(DataRow currentRow, string message, MessageFlags messageFlags) { if (this.PageContext.BoardSettings.RemoveNestedQuotes) { message = YafFormatMessage.RemoveNestedQuotes(message); } // If the message being quoted in YafBBCode but the editor uses HTML, convert the message text to HTML if (messageFlags.IsBBCode && this._forumEditor.UsesHTML) { message = YafBBCode.ConvertBBCodeToHtmlForEdit(message); } // Ensure quoted replies have bad words removed from them message = this.Get <YafBadWordReplace>().Replace(message); // Quote the original message this._forumEditor.Text = "[quote={0};{1}]{2}[/quote]\n".FormatWith(this.PageContext.UserDisplayName.GetName(currentRow.Field <int>("UserID")), currentRow.Field <int>("MessageID"), message).TrimStart(); }
/// <summary> /// Format message. /// </summary> /// <param name="row"> /// Message data row. /// </param> /// <returns> /// Formatted string with escaped HTML markup and formatted YafBBCode. /// </returns> protected string FormatMessage(DataRowView row) { // get message flags var messageFlags = new MessageFlags(row["Flags"]); // message string msg; // format message? if (messageFlags.NotFormatted) { // just encode it for HTML output msg = HtmlEncode(row["Message"].ToString()); } else { // fully format message (YafBBCode, smilies) msg = YafFormatMessage.FormatMessage(row["Message"].ToString(), messageFlags, Convert.ToBoolean(row["IsModeratorChanged"])); } // return formatted message return(msg); }
/// <summary> /// Adds meta data: description and keywords to the page header. /// </summary> /// <param name="firstMessage"> /// first message in the topic /// </param> private void AddMetaData([NotNull] object firstMessage) { if (firstMessage.IsNullOrEmptyDBField()) { return; } if (this.Page.Header != null && this.PageContext.BoardSettings.AddDynamicPageMetaTags) { YafFormatMessage.MessageCleaned message = YafFormatMessage.GetCleanedTopicMessage( firstMessage, this.PageContext.PageTopicID); var meta = this.Page.Header.FindControlType <HtmlMeta>(); if (message.MessageTruncated.IsSet()) { HtmlMeta descriptionMeta; string content = "{0}: {1}".FormatWith(this._topic["Topic"], message.MessageTruncated); if (meta.Any(x => x.Name.Equals("description"))) { // use existing... descriptionMeta = meta.Where(x => x.Name.Equals("description")).FirstOrDefault(); if (descriptionMeta != null) { descriptionMeta.Content = content; this.Page.Header.Controls.Remove(descriptionMeta); descriptionMeta = ControlHelper.MakeMetaDiscriptionControl(content); // add to the header... this.Page.Header.Controls.Add(descriptionMeta); } } else { descriptionMeta = ControlHelper.MakeMetaDiscriptionControl(content); // add to the header... this.Page.Header.Controls.Add(descriptionMeta); } } if (message.MessageKeywords.Count > 0) { HtmlMeta keywordMeta; var keywordStr = message.MessageKeywords.Where(x => x.IsSet()).ToList().ToDelimitedString(","); if (meta.Any(x => x.Name.Equals("keywords"))) { // use existing... keywordMeta = meta.Where(x => x.Name.Equals("keywords")).FirstOrDefault(); keywordMeta.Content = keywordStr; this.Page.Header.Controls.Remove(keywordMeta); // add to the header... this.Page.Header.Controls.Add(keywordMeta); } else { keywordMeta = ControlHelper.MakeMetaKeywordsControl(keywordStr); // add to the header... this.Page.Header.Controls.Add(keywordMeta); } } } }
/// <summary> /// The is input verified. /// </summary> /// <returns> /// The is input verified. /// </returns> protected bool IsInputVerified() { if (Convert.ToInt32(this.PollGroupListDropDown.SelectedIndex) <= 0) { if (this.Question.Text.Trim().Length == 0) { YafContext.Current.AddLoadMessage(YafContext.Current.Localization.GetText("POLLEDIT", "NEED_QUESTION")); return(false); } // If it's admin or moderator we don't check tags if (!PageContext.IsAdmin || PageContext.IsForumModerator) { string tagPoll = YafFormatMessage.CheckHtmlTags(this.Question.Text.Trim(), PageContext.BoardSettings.AcceptedHeadersHTML, ','); if (tagPoll.IsSet()) { this.PageContext.AddLoadMessage(tagPoll); return(false); } } int notNullcount = 0; foreach (RepeaterItem ri in this.ChoiceRepeater.Items) { string value = ((TextBox)ri.FindControl("PollChoice")).Text.Trim(); if (!string.IsNullOrEmpty(value)) { notNullcount++; // If it's admin or moderator we don't check tags if (!PageContext.IsAdmin || PageContext.IsForumModerator) { string tagChoice = YafFormatMessage.CheckHtmlTags(value, PageContext.BoardSettings.AcceptedHeadersHTML, ','); if (tagChoice.IsSet()) { this.PageContext.AddLoadMessage(tagChoice); return(false); } } } } if (notNullcount < 2) { YafContext.Current.AddLoadMessage(YafContext.Current.Localization.GetText("POLLEDIT", "NEED_CHOICES")); return(false); } int dateVerified = 0; if (!int.TryParse(this.PollExpire.Text.Trim(), out dateVerified) && (this.PollExpire.Text.Trim().IsSet())) { YafContext.Current.AddLoadMessage(YafContext.Current.Localization.GetText("POLLEDIT", "EXPIRE_BAD")); return(false); } // Set default value if (this.PollExpire.Text.Trim().IsNotSet() && this.IsClosedBoundCheckBox.Checked) { this.PollExpire.Text = "1"; } } return(true); }
/// <summary> /// The create message details. /// </summary> protected void CreateMessageDetails() { var sb = new StringBuilder(); if (!this.PostData.PostDeleted) { if (Convert.ToDateTime(this.DataRow["Edited"]) > Convert.ToDateTime(this.DataRow["Posted"]).AddSeconds(this.PageContext.BoardSettings.EditTimeOut)) { string editedText = this.Get <YafDateTime>().FormatDateTimeShort(Convert.ToDateTime(this.DataRow["Edited"])); // vzrus: Guests doesn't have right to view change history this.MessageHistoryHolder.Visible = true; if (HttpContext.Current.Server.HtmlDecode(Convert.ToString(this.DataRow["EditReason"])) != string.Empty) { // reason was specified this.messageHistoryLink.Title += " | {0}: {1}".FormatWith(this.PageContext.Localization.GetText("EDIT_REASON"), YafFormatMessage.RepairHtml((string)this.DataRow["EditReason"], true)); } else { this.messageHistoryLink.Title += " {0}: {1}".FormatWith(this.PageContext.Localization.GetText("EDIT_REASON"), this.PageContext.Localization.GetText("EDIT_REASON_NA")); } // message has been edited // show, why the post was edited or deleted? string whoChanged = Convert.ToBoolean(this.DataRow["IsModeratorChanged"]) ? this.PageContext.Localization.GetText("EDITED_BY_MOD") : this.PageContext.Localization.GetText("EDITED_BY_USER"); this.messageHistoryLink.InnerHtml = @"<span class=""editedinfo"" title=""{2}"">{0} {1}</span>".FormatWith(this.PageContext.Localization.GetText("EDITED"), whoChanged, editedText + this.messageHistoryLink.Title); this.messageHistoryLink.HRef = YafBuildLink.GetLink(ForumPages.messagehistory, "m={0}", DataRow["MessageID"]); } } else { string deleteText = string.Empty; if (HttpContext.Current.Server.HtmlDecode(Convert.ToString(this.DataRow["DeleteReason"])) != String.Empty) { // reason was specified deleteText = YafFormatMessage.RepairHtml((string)this.DataRow["DeleteReason"], true); } else { // reason was not specified deleteText = this.PageContext.Localization.GetText("EDIT_REASON_NA"); } sb.AppendFormat( @" | <span class=""editedinfo"" title=""{1}"">{0}</span>", this.PageContext.Localization.GetText("EDIT_REASON"), deleteText); } // display admin only info if (this.PageContext.IsAdmin || (this.PageContext.BoardSettings.AllowModeratorsViewIPs && this.PageContext.IsModerator)) { // We should show IP this.IPSpan1.Visible = true; this.IPLink1.HRef = this.PageContext.BoardSettings.IPInfoPageURL.FormatWith(this.DataRow["IP"].ToString()); this.IPLink1.Title = this.PageContext.Localization.GetText("COMMON", "TT_IPDETAILS"); this.IPLink1.InnerText = this.HtmlEncode(this.DataRow["IP"].ToString()); sb.Append(' '); } if (sb.Length > 0) { this.MessageDetails.Visible = true; this.MessageDetails.Text = @"<span class=""MessageDetails"">" + sb.ToString() + @"</span>"; } }
/// <summary> /// Handles page load event. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load(object sender, EventArgs e) { // if user isn't authenticated, redirect him to login page if (User == null || YafContext.Current.IsGuest) { RedirectNoAccess(); } // set attributes of editor this._editor.BaseDir = YafForumInfo.ForumClientFileRoot + "editors"; this._editor.StyleSheet = YafContext.Current.Theme.BuildThemePath("theme.css"); // this needs to be done just once, not during postbacks if (!IsPostBack) { // create page links this.CreatePageLinks(); // localize button labels this.FindUsers.Text = GetText("FINDUSERS"); this.AllUsers.Text = GetText("ALLUSERS"); this.Clear.Text = GetText("CLEAR"); // only administrators can send messages to all users this.AllUsers.Visible = YafContext.Current.IsAdmin; if (this.Request.QueryString.GetFirstOrDefault("p").IsSet()) { // PM is a reply or quoted reply (isQuoting) // to the given message id "p" bool isQuoting = Request.QueryString.GetFirstOrDefault("q") == "1"; // get quoted message DataRow row = DB.pmessage_list(Security.StringToLongOrRedirect(Request.QueryString.GetFirstOrDefault("p"))).GetFirstRow(); // there is such a message if (row != null) { // get message sender/recipient var toUserId = (int)row["ToUserID"]; var fromUserId = (int)row["FromUserID"]; // verify access to this PM if (toUserId != YafContext.Current.PageUserID && fromUserId != YafContext.Current.PageUserID) { YafBuildLink.AccessDenied(); } // handle subject var subject = (string)row["Subject"]; if (!subject.StartsWith("Re: ")) { subject = string.Format("Re: {0}", subject); } this.PmSubjectTextBox.Text = subject; string displayName = PageContext.UserDisplayName.GetName(fromUserId); // set "To" user and disable changing... this.To.Text = displayName; this.To.Enabled = false; this.FindUsers.Enabled = false; this.AllUsers.Enabled = false; if (isQuoting) { // PM is a quoted reply string body = row["Body"].ToString(); if (YafContext.Current.BoardSettings.RemoveNestedQuotes) { body = YafFormatMessage.RemoveNestedQuotes(body); } // Ensure quoted replies have bad words removed from them body = this.Get <YafBadWordReplace>().Replace(body); // Quote the original message body = "[QUOTE={0}]{1}[/QUOTE]".FormatWith(displayName, body); // we don't want any whitespaces at the beginning of message this._editor.Text = body.TrimStart(); } } } else if (this.Request.QueryString.GetFirstOrDefault("u").IsSet() && this.Request.QueryString.GetFirstOrDefault("r").IsSet()) { // We check here if the user have access to the option if (PageContext.IsModerator || PageContext.IsForumModerator) { // PM is being sent to a predefined user int toUser; int reportMessage; if (Int32.TryParse(this.Request.QueryString.GetFirstOrDefault("u"), out toUser) && Int32.TryParse(this.Request.QueryString.GetFirstOrDefault("r"), out reportMessage)) { // get quoted message DataRow messagesRow = DB.message_listreporters( Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("r")).ToType <int>(), Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u")).ToType <int>()).GetFirstRow(); // there is such a message // message info should be always returned as 1 row if (messagesRow != null) { // handle subject this.PmSubjectTextBox.Text = this.GetText("REPORTED_SUBJECT"); string displayName = PageContext.UserDisplayName.GetName(messagesRow.Field <int>("UserID")); // set "To" user and disable changing... this.To.Text = displayName; this.To.Enabled = false; this.FindUsers.Enabled = false; this.AllUsers.Enabled = false; // Parse content with delimiter '|' string[] quoteList = messagesRow.Field <string>("ReportText").Split('|'); // Quoted replies should have bad words in them // Reply to report PM is always a quoted reply // Quote the original message in a cycle for (int i = 0; i < quoteList.Length; i++) { // Add quote codes quoteList[i] = "[QUOTE={0}]{1}[/QUOTE]".FormatWith(displayName, quoteList[i]); // Replace DateTime delimiter '??' by ': ' // we don't want any whitespaces at the beginning of message this._editor.Text = quoteList[i].Replace("??", ": ") + this._editor.Text.TrimStart(); } } } } } else if (this.Request.QueryString.GetFirstOrDefault("u").IsSet()) { // PM is being send as a reply to a reported post // find user int toUserId; if (Int32.TryParse(Request.QueryString.GetFirstOrDefault("u"), out toUserId)) { DataRow currentRow = DB.user_list(YafContext.Current.PageBoardID, toUserId, true).GetFirstRow(); if (currentRow != null) { this.To.Text = PageContext.UserDisplayName.GetName(currentRow.Field <int>("UserID")); this.To.Enabled = false; // Simon: Disable for admins DisablePMs = RoleMembershipHelper.IsUserInRole(this.To.Text, "Administrators"); // hide find user/all users buttons this.FindUsers.Enabled = false; this.AllUsers.Enabled = false; } } } else { // Blank PM // multi-receiver info is relevant only when sending blank PM if (YafContext.Current.BoardSettings.PrivateMessageMaxRecipients > 1) { // format localized string this.MultiReceiverInfo.Text = "<br />{0}<br />{1}".FormatWith(YafContext.Current.Localization.GetText("MAX_RECIPIENT_INFO").FormatWith(YafContext.Current.BoardSettings.PrivateMessageMaxRecipients), YafContext.Current.Localization.GetText("MULTI_RECEIVER_INFO")); // display info this.MultiReceiverInfo.Visible = true; } } } }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Save_Click(object sender, EventArgs e) { string body = this._sig.Text; // find forbidden BBcodes in signature string detectedBbCode = YafFormatMessage.BBCodeForbiddenDetector(body, this._allowedBbcodes, ','); if (!string.IsNullOrEmpty(detectedBbCode) && detectedBbCode != "ALL") { this.PageContext.AddLoadMessage( this.PageContext.Localization.GetTextFormatted("SIGNATURE_BBCODE_WRONG", detectedBbCode)); return; } if (detectedBbCode == "ALL") { this.PageContext.AddLoadMessage(this.PageContext.Localization.GetText("BBCODE_FORBIDDEN")); return; } // find forbidden HTMLTags in signature if (!this.PageContext.IsAdmin) { string detectedHtmlTag = YafFormatMessage.CheckHtmlTags(body, this._allowedHtml, ','); if (detectedHtmlTag.IsSet()) { this.PageContext.AddLoadMessage(detectedHtmlTag); return; } } // body = YafFormatMessage.RepairHtml(this,body,false); if (this._sig.Text.Length > 0) { if (this._sig.Text.Length <= this._allowedNumberOfCharacters) { DB.user_savesignature(this.CurrentUserID, this.Get <YafBadWordReplace>().Replace(body)); } else { this.PageContext.AddLoadMessage( this.PageContext.Localization.GetTextFormatted("SIGNATURE_MAX", this._allowedNumberOfCharacters)); return; } } else { DB.user_savesignature(this.CurrentUserID, DBNull.Value); } // clear the cache for this user... UserMembershipHelper.ClearCacheForUserId(this.CurrentUserID); if (this.InAdminPages) { this.BindData(); } else { this.DoRedirect(); } }
/// <summary> /// The method creates YafSyndicationFeed for posts. /// </summary> /// <param name="feed">The YafSyndicationFeed.</param> /// <param name="feedType">The FeedType.</param> /// <param name="atomFeedByVar">The Atom feed checker.</param> /// <param name="topicId">The TopicID</param> private void GetPostsFeed(ref YafSyndicationFeed feed, YafRssFeeds feedType, bool atomFeedByVar, int topicId) { var syndicationItems = new List <SyndicationItem>(); using ( DataTable dt = DB.post_list( topicId, 0, this.PageContext.BoardSettings.ShowDeletedMessages, false)) { // convert to linq... var rowList = dt.AsEnumerable().OrderByDescending(x => x.Field <DateTime>("Posted")); // see if the deleted messages need to be edited out...) if (this.PageContext.BoardSettings.ShowDeletedMessages && !this.PageContext.BoardSettings.ShowDeletedMessagesToAll && !this.PageContext.IsAdmin && !this.PageContext.IsForumModerator) { // remove posts that are deleted and do not belong to this user... rowList = rowList.Where(x => !(x.Field <bool>("IsDeleted") && x.Field <int>("UserID") != this.PageContext.PageUserID)).OrderByDescending(y => (y.Field <DateTime>("Posted"))); } // last page posts var dataRows = rowList.Take(PageContext.BoardSettings.PostsPerPage); var altItem = false; // load the missing message test this.Get <YafDBBroker>().LoadMessageText(dataRows); string urlAlphaNum = FormatUrlForFeed(BaseUrlBuilder.BaseUrl); feed = new YafSyndicationFeed("{0}{1} - {2}".FormatWith(this.PageContext.Localization.GetText("PROFILE", "TOPIC"), this.PageContext.PageTopicName, PageContext.BoardSettings.PostsPerPage), feedType, atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt(), urlAlphaNum); foreach (var row in dataRows) { DateTime posted = Convert.ToDateTime(row["Edited"]) + this.Get <YafDateTime>().TimeOffset; if (syndicationItems.Count <= 0) { feed.Authors.Add(SyndicationItemExtensions.NewSyndicationPerson(String.Empty, Convert.ToInt64(row["UserID"]))); feed.LastUpdatedTime = DateTime.UtcNow + this.Get <YafDateTime>().TimeOffset; } List <SyndicationLink> attachementLinks = null; // if the user doesn't have download access we simply don't show enclosure links. if (PageContext.ForumDownloadAccess) { attachementLinks = GetMediaLinks(row["MessageID"].ToType <int>()); } feed.Contributors.Add(SyndicationItemExtensions.NewSyndicationPerson(String.Empty, Convert.ToInt64(row["UserID"]))); syndicationItems.AddSyndicationItem( row["Subject"].ToString(), YafFormatMessage.FormatSyndicationMessage(row["Message"].ToString(), new MessageFlags(row["Flags"]), altItem, 4000), null, YafBuildLink.GetLinkNotEscaped(ForumPages.posts, true, "m={0}#post{0}", row["MessageID"]), "urn:{0}:ft{1}:st{2}:meid{3}:{4}".FormatWith( urlAlphaNum, feedType, atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt(), row["MessageID"], PageContext.PageBoardID), posted, feed, attachementLinks); // used to format feeds altItem = !altItem; } feed.Items = syndicationItems; } }
/// <summary> /// The method to return latest topic content to display in a feed. /// </summary> /// <param name="link">A linkt to an active topic.</param> /// <param name="imgUrl">A latest topic icon Url.</param> /// <param name="imgAlt">A latest topic icon Alt text.</param> /// <param name="linkName">A latest topic displayed link name</param> /// <param name="text">An active topic first message content/partial content.</param> /// <param name="flags"></param> /// <returns>An Html formatted first message content string.</returns> private static string GetPostLatestContent(string link, string imgUrl, string imgAlt, string linkName, string text, int flags, bool altItem) { text = YafFormatMessage.FormatSyndicationMessage(text, new MessageFlags(flags), altItem, 4000); return(@"{0}<table><tr><td><a href=""{1}"" ><img src=""{2}"" alt =""{3}"" title =""{3}"" /> {4}</a></td></tr><table>".FormatWith(text, link, imgUrl, imgAlt, linkName)); }
/// <summary> /// Handles the PostReply click including: Replying, Editing and New post. /// </summary> /// <param name="sender"> /// </param> /// <param name="e"> /// </param> protected void PostReply_Click(object sender, EventArgs e) { if (!this.IsPostReplyVerified()) { return; } if (this.IsPostReplyDelay()) { return; } // Check if the topic name is not too long if (YafContext.Current.BoardSettings.MaxWordLength > 0 && this.TopicSubjectTextBox.Text.Trim().AreAnyWordsOverMaxLength(YafContext.Current.BoardSettings.MaxWordLength)) { this.PageContext.AddLoadMessage( this.GetTextFormatted("TOPICNAME_TOOLONG", this.PageContext.BoardSettings.MaxWordLength)); return; } // vzrus: Common users should not use HTML tags in a topic header if not allowed if (!(PageContext.IsModerator || PageContext.IsForumModerator || PageContext.IsAdmin)) { string tag = YafFormatMessage.CheckHtmlTags(this.TopicSubjectTextBox.Text, PageContext.BoardSettings.AcceptedHeadersHTML, ','); if (tag.IsSet()) { this.PageContext.AddLoadMessage(tag); return; } } // update the last post time... YafContext.Current.Get <YafSession>().LastPost = DateTime.UtcNow.AddSeconds(30); long messageId = 0; long newTopic = 0; if (this.TopicID != null) { // Reply to topic messageId = this.PostReplyHandleReplyToTopic(); newTopic = (long)this.TopicID; } else if (this.EditMessageID != null) { // Edit existing post messageId = this.PostReplyHandleEditPost(); } else { // New post messageId = this.PostReplyHandleNewPost(out newTopic); } // Check if message is approved bool isApproved = false; using (DataTable dt = DB.message_list(messageId)) { foreach (DataRow row in dt.Rows) { isApproved = row["Flags"].BinaryAnd(MessageFlags.Flags.IsApproved); } } // vzrus^ the poll access controls are enabled and this is a new topic - we add the variables string attachp = string.Empty; string retforum = string.Empty; if (this.PageContext.ForumPollAccess && this.PostOptions1.PollOptionVisible && newTopic > 0) { // new topic poll token attachp = "&t={0}".FormatWith(newTopic); // new return forum poll token retforum = "&f={0}".FormatWith(this.PageContext.PageForumID); } // Create notification emails if (isApproved) { this.Get <YafSendNotification>().ToWatchingUsers(messageId.ToType <int>()); if (this.PageContext.ForumUploadAccess && this.PostOptions1.AttachChecked) { // 't' variable is required only for poll and this is a attach poll token for attachments page if (!this.PostOptions1.PollChecked) { attachp = string.Empty; } // redirect to the attachment page... YafBuildLink.Redirect(ForumPages.attachments, "m={0}{1}", messageId, attachp); } else { if (attachp.IsNotSet() || (!this.PostOptions1.PollChecked)) { // regular redirect... YafBuildLink.Redirect(ForumPages.posts, "m={0}&#post{0}", messageId); } else { // poll edit redirect... YafBuildLink.Redirect(ForumPages.polledit, "{0}", attachp); } } } else // Not Approved { if (PageContext.BoardSettings.EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get <YafSendNotification>().ToModeratorsThatMessageNeedsApproval(this.PageContext.PageForumID, (int)messageId); } // 't' variable is required only for poll and this is a attach poll token for attachments page if (!this.PostOptions1.PollChecked) { attachp = string.Empty; } if (this.PostOptions1.AttachChecked && this.PageContext.ForumUploadAccess) { // redirect to the attachment page... YafBuildLink.Redirect(ForumPages.attachments, "m={0}&ra=1{1}{2}", messageId, attachp, retforum); } else { // Tell user that his message will have to be approved by a moderator // PageContext.AddLoadMessage("Since you posted to a moderated forum, a forum moderator must approve your post before it will become visible."); string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (attachp.Length <= 0) { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } else { YafBuildLink.Redirect(ForumPages.polledit, "&ra=1{0}{1}", attachp, retforum); } if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } } } }