/// <summary> /// Loads the data. /// </summary> private void LoadData() { // Get the forum post ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(PostID, 0)); ForumInfo fi = null; if (fpi != null) { fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID); } else { return; } if (fi.ForumEnableAdvancedImage) { ltrText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS; } else { ltrText.AllowedControls = "none"; } // Display converted datetime for live site lblDate.Text = CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString(); lblUser.Text = HTMLHelper.HTMLEncode(fpi.PostUserName); lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); DiscussionMacroHelper dmh = new DiscussionMacroHelper(); dmh.EnableBold = fi.ForumEnableFontBold; dmh.EnableItalics = fi.ForumEnableFontItalics; dmh.EnableStrikeThrough = fi.ForumEnableFontStrike; dmh.EnableUnderline = fi.ForumEnableFontUnderline; dmh.EnableCode = fi.ForumEnableCodeSnippet; dmh.EnableColor = fi.ForumEnableFontColor; dmh.EnableImage = fi.ForumEnableImage || fi.ForumEnableAdvancedImage; dmh.EnableQuote = fi.ForumEnableQuote; dmh.EnableURL = fi.ForumEnableURL || fi.ForumEnableAdvancedURL; dmh.MaxImageSideSize = fi.ForumImageMaxSideSize; dmh.QuotePostText = GetString("DiscussionMacroResolver.QuotePostText"); if (fi.ForumHTMLEditor) { dmh.EncodeText = false; dmh.ConvertLineBreaksToHTML = false; } else { dmh.EncodeText = true; dmh.ConvertLineBreaksToHTML = true; } // Resolve the macros and display the post text ltrText.Text = dmh.ResolveMacros(fpi.PostText); }
/// <summary> /// Gets the plain text body of the e-mail message. /// </summary> /// <param name="ei">The e-mail message object</param> /// <returns>Plain-text body</returns> private string GetPlainTextBody(EmailInfo ei) { DiscussionMacroHelper dmh = new DiscussionMacroHelper { ResolveToPlainText = true }; string body = dmh.ResolveMacros(ei.EmailPlainTextBody); body = HTMLHelper.HTMLEncode(body); ltlBodyValue.Visible = true; // Replace line breaks with br tags and modify discussion macros ltlBodyValue.Text = DiscussionMacroHelper.RemoveTags(HTMLHelper.HTMLEncodeLineBreaks(body)); return(body); }
/// <summary> /// Reload data. /// </summary> public override void ReloadData() { ForumPostInfo fpi = null; ForumInfo fi = null; #region "Load data" if (PostData != null) { fpi = new ForumPostInfo(PostData); } if (fpi == null) { fpi = PostInfo; } if (fpi != null) { PostData = fpi.Generalized.DataClass; fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID); } else { return; } #endregion if (fi.ForumEnableAdvancedImage) { ltlText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS; } else { ltlText.AllowedControls = "none"; } lnkUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName); // Display converted datetime for live site lblDate.Text = " (" + CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString() + ")"; lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); DiscussionMacroHelper dmh = new DiscussionMacroHelper(); dmh.EnableBold = fi.ForumEnableFontBold; dmh.EnableItalics = fi.ForumEnableFontItalics; dmh.EnableStrikeThrough = fi.ForumEnableFontStrike; dmh.EnableUnderline = fi.ForumEnableFontUnderline; dmh.EnableCode = fi.ForumEnableCodeSnippet; dmh.EnableColor = fi.ForumEnableFontColor; dmh.EnableImage = fi.ForumEnableImage || fi.ForumEnableAdvancedImage; dmh.EnableQuote = fi.ForumEnableQuote; dmh.EnableURL = fi.ForumEnableURL || fi.ForumEnableAdvancedURL; dmh.MaxImageSideSize = fi.ForumImageMaxSideSize; dmh.QuotePostText = GetString("DiscussionMacroResolver.QuotePostText"); if (fi.ForumHTMLEditor) { dmh.EncodeText = false; dmh.ConvertLineBreaksToHTML = false; } else { dmh.EncodeText = true; dmh.ConvertLineBreaksToHTML = true; } ltlText.Text = "<div class=\"PostText\">" + dmh.ResolveMacros(fpi.PostText) + "</div>"; userAvatar.Text = AvatarImage(fpi); if (DisplayBadgeInfo) { if (fpi.PostUserID > 0) { UserInfo ui = UserInfoProvider.GetUserInfo(fpi.PostUserID); if ((ui != null) && !ui.IsPublic()) { BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(ui.UserSettings.UserBadgeID); if (bi != null) { ltlBadge.Text = "<div class=\"Badge\">" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "</div>"; } } } // Set public badge if no badge is set if (String.IsNullOrEmpty(ltlBadge.Text)) { ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>"; } } if (EnableSignature) { if (fpi.PostUserSignature.Trim() != "") { plcSignature.Visible = true; ltrSignature.Text = HTMLHelper.HTMLEncode(fpi.PostUserSignature); } } if (!DisplayOnly) { string threadId = ForumPostInfoProvider.GetPostRootFromIDPath(ValidationHelper.GetString(GetData(PostData, "PostIdPath"), "")).ToString(); // Reply if (IsAvailable(PostData, ForumActionType.Reply)) { lnkReply.Visible = true; lnkReply.Text = GetString("Forums_WebInterface_ForumPost.replyLinkText"); lnkReply.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Reply), "threadid", threadId); } else { lnkReply.Visible = false; } // Quote if (IsAvailable(PostData, ForumActionType.Quote)) { lnkQuote.Visible = true; lnkQuote.Text = GetString("Forums_WebInterface_ForumPost.quoteLinkText"); lnkQuote.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Quote), "threadid", threadId); } else { lnkQuote.Visible = false; } // Display subscribe link if (IsAvailable(PostData, ForumActionType.SubscribeToPost)) { lnkSubscribe.Visible = true; lnkSubscribe.Text = GetString("Forums_WebInterface_ForumPost.Subscribe"); lnkSubscribe.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.SubscribeToPost), "threadid", threadId); } else { lnkSubscribe.Visible = false; } lnkUserName.CssClass = "PostUserLink"; if (!String.IsNullOrEmpty(fpi.PostUserMail) && (fi.ForumDisplayEmails)) { lnkUserName.NavigateUrl = "mailto:" + HTMLHelper.HTMLEncode(fpi.PostUserMail) + "?subject=" + HTMLHelper.HTMLEncode(fpi.PostSubject); lnkUserName.CssClass = "PostUser"; } } // Display action panel only if reply to link or subscription link are visible plcActions.Visible = ((lnkReply.Visible || lnkSubscribe.Visible || lnkQuote.Visible) & !DisplayOnly); if ((lnkReply.Visible) && (lnkQuote.Visible || lnkSubscribe.Visible)) { lblActionSeparator.Visible = true; } if ((lnkQuote.Visible) && (lnkSubscribe.Visible)) { lblActionSeparator2.Visible = true; } }
/// <summary> /// Gets the plain text body of the e-mail message. /// </summary> /// <param name="ei">The e-mail message object</param> /// <returns>Plain-text body</returns> private string GetPlainTextBody(EmailInfo ei) { DiscussionMacroHelper dmh = new DiscussionMacroHelper { ResolveToPlainText = true }; string body = dmh.ResolveMacros(ei.EmailPlainTextBody); body = HTMLHelper.HTMLEncode(body); ltlBodyValue.Visible = true; // Replace line breaks with br tags and modify discussion macros ltlBodyValue.Text = DiscussionMacroHelper.RemoveTags(HTMLHelper.HTMLEncodeLineBreaks(body)); return body; }
public void ReloadData() { if (StopProcessing) { // Do nothing ucMessageUserButtons.StopProcessing = true; ucUserPicture.StopProcessing = true; } else { ucMessageUserButtons.StopProcessing = false; ucUserPicture.StopProcessing = false; if (Message != null) { // Get current user info currentUserInfo = CMSContext.CurrentUser; // Get message user info if (MessageMode == MessageModeEnum.Inbox) { messageUserInfo = UserInfoProvider.GetUserInfo(Message.MessageSenderUserID); } else { messageUserInfo = UserInfoProvider.GetUserInfo(Message.MessageRecipientUserID); } // Display only to authorized user if ((currentUserInfo.UserID == Message.MessageRecipientUserID) || (currentUserInfo.UserID == Message.MessageSenderUserID) || currentUserInfo.IsGlobalAdministrator) { pnlViewMessage.Visible = true; lblDateCaption.Text = GetString("Messaging.Date"); lblSubjectCaption.Text = GetString("general.subject"); lblFromCaption.Text = (MessageMode == MessageModeEnum.Inbox) ? GetString("Messaging.From") : GetString("Messaging.To"); // Sender exists if (messageUserInfo != null) { ucUserPicture.Visible = true; ucUserPicture.UserID = messageUserInfo.UserID; // Disable message user buttons on live site for hidden or disabled users if (IsLiveSite && !currentUserInfo.IsGlobalAdministrator && (!messageUserInfo.Enabled || messageUserInfo.UserIsHidden)) { ucMessageUserButtons.RelatedUserId = 0; } else { ucMessageUserButtons.RelatedUserId = messageUserInfo.UserID; } lblFrom.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(messageUserInfo.UserName, messageUserInfo.FullName, messageUserInfo.UserNickName, IsLiveSite)); } else { ucMessageUserButtons.RelatedUserId = 0; lblFrom.Text = HTMLHelper.HTMLEncode(Message.MessageSenderNickName); } string body = Message.MessageBody; // Resolve macros DiscussionMacroHelper dmh = new DiscussionMacroHelper(); body = dmh.ResolveMacros(body); lblSubject.Text = HTMLHelper.HTMLEncodeLineBreaks(Message.MessageSubject); if (IsLiveSite) { lblDate.Text = CMSContext.ConvertDateTime(Message.MessageSent, this).ToString(); } else { lblDate.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(Message.MessageSent, currentUserInfo, CMSContext.CurrentSite, out usedTimeZone); } lblBody.Text = body; } } else { lblError.Text = GetString("Messaging.MessageDoesntExist"); lblError.Visible = true; } } }
public void ReloadData() { if (StopProcessing) { // Do nothing ucMessageUserButtons.StopProcessing = true; ucUserPicture.StopProcessing = true; } else { ucMessageUserButtons.StopProcessing = false; ucUserPicture.StopProcessing = false; if (Message != null) { // Get current user info currentUserInfo = CMSContext.CurrentUser; // Get message user info if (MessageMode == MessageModeEnum.Inbox) { messageUserInfo = UserInfoProvider.GetUserInfo(Message.MessageSenderUserID); } else { messageUserInfo = UserInfoProvider.GetUserInfo(Message.MessageRecipientUserID); } // Display only to authorized user if ((currentUserInfo.UserID == Message.MessageRecipientUserID) || (currentUserInfo.UserID == Message.MessageSenderUserID) || currentUserInfo.IsGlobalAdministrator) { pnlViewMessage.Visible = true; lblDateCaption.Text = GetString("Messaging.Date"); lblSubjectCaption.Text = GetString("general.subject"); lblFromCaption.Text = (MessageMode == MessageModeEnum.Inbox) ? GetString("Messaging.From") : GetString("Messaging.To"); // Sender exists if (messageUserInfo != null) { ucUserPicture.Visible = true; ucUserPicture.UserID = messageUserInfo.UserID; // Gravatar support string avType = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSAvatarType"); if (avType == AvatarInfoProvider.USERCHOICE) { avType = messageUserInfo.UserSettings.UserAvatarType; } ucUserPicture.UserAvatarType = avType; // Disable message user buttons on live site for hidden or disabled users if (IsLiveSite && !currentUserInfo.IsGlobalAdministrator && (messageUserInfo.UserIsDisabledManually || messageUserInfo.UserIsHidden)) { ucMessageUserButtons.RelatedUserId = 0; } else { ucMessageUserButtons.RelatedUserId = messageUserInfo.UserID; } lblFrom.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(messageUserInfo.UserName, messageUserInfo.FullName, messageUserInfo.UserNickName, IsLiveSite)); } else { ucMessageUserButtons.RelatedUserId = 0; lblFrom.Text = HTMLHelper.HTMLEncode(Message.MessageSenderNickName); } string body = Message.MessageBody; // Resolve macros DiscussionMacroHelper dmh = new DiscussionMacroHelper(); body = dmh.ResolveMacros(body); lblSubject.Text = HTMLHelper.HTMLEncodeLineBreaks(Message.MessageSubject); if (IsLiveSite) { lblDate.Text = CMSContext.ConvertDateTime(Message.MessageSent, this).ToString(); } else { lblDate.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(Message.MessageSent, currentUserInfo, CMSContext.CurrentSite, out usedTimeZone); } lblBody.Text = body; } } else { ShowError(GetString("Messaging.MessageDoesntExist")); } } }