protected override void OnInit(EventArgs e) { base.OnInit(e); if (drpBadges.Items.Count > 0) { return; } var badges = BadgeInfoProvider.GetBadges().Columns("BadgeDisplayName, BadgeIsAutomatic, BadgeID"); foreach (BadgeInfo badge in badges) { string badgeDisplayName = ResHelper.LocalizeString(badge.BadgeDisplayName); if (badge.BadgeIsAutomatic) { badgeDisplayName += GetString("badge.automatic"); } drpBadges.Items.Add(new ListItem(badgeDisplayName, badge.BadgeID.ToString())); } drpBadges.Items.Insert(0, new ListItem(GetString("general.selectnone"), "0")); }
/// <summary> /// Adds badge to user. Called when the "Add badge to user" button is pressed. /// Expects the CreateBadge method to be run first. /// </summary> private bool AddBadgeToUser() { // Get user object UserInfo user = UserInfoProvider.GetUserInfo(MembershipContext.AuthenticatedUser.UserName); // Get badge object BadgeInfo myBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge"); if ((user != null) && (myBadge != null)) { // Add badge to user settings user.UserSettings.UserBadgeID = myBadge.BadgeID; // Update user object in database UserInfoProvider.SetUserInfo(user); return(true); } return(false); }
/// <summary> /// Gets and bulk updates badges. Called when the "Get and bulk update badges" button is pressed. /// Expects the CreateBadge method to be run first. /// </summary> private bool GetAndBulkUpdateBadges() { // Prepare the parameters string where = "BadgeName LIKE N'MyNewBadge%'"; // Get the data from database var badges = BadgeInfoProvider.GetBadges().Where(where); // Loop through the individual items foreach (BadgeInfo modifyBadge in badges) { // Update the properties modifyBadge.BadgeDisplayName = modifyBadge.BadgeDisplayName.ToUpper(); // Save the changes BadgeInfoProvider.SetBadgeInfo(modifyBadge); } // Return TRUE if any object was found and updated, FALSE otherwise return(badges.Count > 0); }
/// <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> /// OnPrerender check whether. /// </summary> protected override void OnPreRender(EventArgs e) { postTreeElem.Selected = ValidationHelper.GetInteger(hdnSelected.Value, SelectedPost); if ((mSelectedPost == 0) && (RequestHelper.IsAJAXRequest())) { mSelectedPost = postTreeElem.Selected; } if (mSelectedPost > 0) { ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(mSelectedPost); if ((fpi != null) && (ForumContext.CurrentForum != null) && (fpi.PostForumID == ForumContext.CurrentForum.ForumID)) { plcPostPreview.Visible = true; ltlPostSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); ltlPostText.Text = ResolvePostText(fpi.PostText); ltlSignature.Text = GetSignatureArea(fpi, "<div class=\"SignatureArea\">", "</div>"); ltlPostTime.Text = TimeZoneHelper.ConvertToUserTimeZone(fpi.PostTime, false, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite).ToString(); ltlPostUser.Text = "<span class=\"PostUserName\">" + GetUserName(fpi) + "</span>"; ltlAvatar.Text = AvatarImage(fpi); mUnapproved = !fpi.PostApproved ? " Unapproved" : ""; if (ForumContext.CurrentForum.ForumEnableAdvancedImage) { ltlPostText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS; } else { ltlPostText.AllowedControls = "none"; } attachmentDisplayer.ClearData(); attachmentDisplayer.PostID = fpi.PostId; attachmentDisplayer.PostAttachmentCount = fpi.PostAttachmentCount; attachmentDisplayer.ReloadData(); #region "Badge" 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>"; if (!String.IsNullOrEmpty(bi.BadgeImageURL)) { ltlBadge.Text += "<div class=\"BadgeImage\"><img alt=\"" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "\" src=\"" + HTMLHelper.HTMLEncode(GetImageUrl(bi.BadgeImageURL)) + "\" /></div>"; } } } } // Set public badge if no badge is set if (String.IsNullOrEmpty(ltlBadge.Text)) { ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>"; } } #endregion #region "Post actions" // Get the parent thread ID (for reply and quote) int threadId = ForumPostInfoProvider.GetPostRootFromIDPath(fpi.PostIDPath); ltlReply.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.replyLinkText"), "PostActionLink", ForumActionType.Reply, threadId); ltlQuote.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.quoteLinkText"), "PostActionLink", ForumActionType.Quote, threadId); ltlSubscribe.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.Subscribe"), "PostActionLink", ForumActionType.SubscribeToPost, threadId); ltlAnswer.Text = GetLink(fpi, GetString("general.yes"), "ActionLink", ForumActionType.IsAnswer); ltlNotAnswer.Text = GetLink(fpi, GetString("general.no"), "ActionLink", ForumActionType.IsNotAnswer); if (ltlAnswer.Text != String.Empty) { ltlWasHelpful.Text = GetString("Forums_WebInterface_ForumPost.Washelpful") + " "; ltlAnswer.Text += "|"; } ltlAddPostToFavorites.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.AddPostToFavorites"), "ActionLink", ForumActionType.AddPostToFavorites); ltlDelete.Text = GetLink(fpi, GetString("general.delete"), "ActionLink", ForumActionType.Delete); ltlEdit.Text = GetLink(fpi, GetString("general.edit"), "ActionLink", ForumActionType.Edit); ltlAttachments.Text = GetLink(fpi, GetString("general.attachments"), "ActionLink", ForumActionType.Attachment); #endregion // Hide separators if ((ltlReply.Text == "") || (ltlReply.Text != "" && ltlQuote.Text == "")) { plcFirstSeparator.Visible = false; } if ((ltlSubscribe.Text == "") || (ltlSubscribe.Text != "" && ltlQuote.Text == "")) { plcSecondSeparator.Visible = false; } if (ltlReply.Text != "" && ltlSubscribe.Text != "") { plcFirstSeparator.Visible = true; } pnlManage.Visible = (EnableOnSiteManagement && (ForumContext.CurrentForum != null)) ? ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, CommunityGroupID) : false; if (pnlManage.Visible) { ltlApprove.Text = GetLink(fpi, GetString("general.approve"), "ActionLink", ForumActionType.Appprove); ltlApproveAll.Text = GetLink(fpi, GetString("forums.approveall"), "ActionLink", ForumActionType.ApproveAll); ltlReject.Text = GetLink(fpi, GetString("general.reject"), "ActionLink", ForumActionType.Reject); ltlRejectAll.Text = GetLink(fpi, GetString("forums.rejectall"), "ActionLink", ForumActionType.RejectAll); ltlSplit.Text = GetLink(fpi, GetString("forums.splitthread"), "ActionLink", ForumActionType.SplitThread); ltlMove.Text = GetLink(fpi, GetString("forums.movethread"), "ActionLink", ForumActionType.MoveToTheOtherForum, threadId); } } } else { plcPostPreview.Visible = false; } if (ControlsHelper.IsInUpdatePanel(this)) { ControlsHelper.GetUpdatePanel(this).Update(); } base.OnPreRender(e); }
protected void Page_Load(object sender, EventArgs e) { if (this.IsAdHocForum) { plcHeader.Visible = false; } forumEdit.OnPreview += new EventHandler(forumEdit_OnPreview); forumEdit.OnModerationRequired += new EventHandler(forumEdit_OnModerationRequired); // Check whether subscription is for forum or post if (ForumContext.CurrentReplyThread == null) { ltrTitle.Text = GetString("Forums_ForumNewPost_Header.NewThread"); if (ForumContext.CurrentPost != null && ForumContext.CurrentMode == ForumMode.Edit) { ltrTitle.Text = GetString("Forums_ForumNewPost_Header.EditPost"); } } else { plcPreview.Visible = true; ltrTitle.Text = GetString("Forums_ForumNewPost_Header.Reply"); ltrAvatar.Text = AvatarImage(ForumContext.CurrentReplyThread); ltrSubject.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostSubject); if (ForumContext.CurrentForum != null) { if (ForumContext.CurrentForum.ForumEnableAdvancedImage) { ltrText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS; } else { ltrText.AllowedControls = "none"; } ltrText.Text = ResolvePostText(ForumContext.CurrentReplyThread.PostText); } ltrUserName.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostUserName); ltrTime.Text = CMSContext.ConvertDateTime(ForumContext.CurrentReplyThread.PostTime, this).ToString(); UserSettingsInfo usi = UserSettingsInfoProvider.GetUserSettingsInfoByUser(ForumContext.CurrentReplyThread.PostUserID); BadgeInfo bi = null; string badgeName = null; string badgeImageUrl = null; if (usi != null) { bi = BadgeInfoProvider.GetBadgeInfo(usi.UserBadgeID); if (bi != null) { badgeName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName)); badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL); } } ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) + GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + ResolveUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge); } }