/// <summary> /// Reloads the form data. /// </summary> public override void ReloadData() { base.ReloadData(); if (MessageID > 0) { messageInfo = BoardMessageInfoProvider.GetBoardMessageInfo(MessageID); if (messageInfo != null) { EditedObject = messageInfo; // Check whether edited message belongs to a board from current site if ((Board != null) && (Board.BoardSiteID != SiteContext.CurrentSiteID)) { EditedObject = null; } // Set textfields and checkboxes txtEmail.Text = messageInfo.MessageEmail; txtMessage.Text = messageInfo.MessageText; txtURL.Text = messageInfo.MessageURL; txtUserName.Text = messageInfo.MessageUserName; chkApproved.Checked = messageInfo.MessageApproved; chkSpam.Checked = messageInfo.MessageIsSpam; lblInserted.Text = TimeZoneMethods.ConvertDateTime(messageInfo.MessageInserted, this).ToString(); } } else { ClearForm(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsAdHocForum) { plcHeader.Visible = false; } // Check whether subscription is for forum or post if (ForumContext.CurrentSubscribeThread == null) { ltrTitle.Text = GetString("ForumSubscription.SubscribeForum"); } else { plcPreview.Visible = true; ltrTitle.Text = GetString("ForumSubscription.SubscribePost"); ltrAvatar.Text = AvatarImage(ForumContext.CurrentSubscribeThread); ltrSubject.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentSubscribeThread.PostSubject); ltrText.Text = ResolvePostText(ForumContext.CurrentSubscribeThread.PostText); ltrUserName.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentSubscribeThread.PostUserName); ltrTime.Text = TimeZoneMethods.ConvertDateTime(ForumContext.CurrentSubscribeThread.PostTime, this).ToString(); } }
protected object inboxGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "messagesendernickname": case "messagesubject": // Avoid XSS return(HTMLHelper.HTMLEncode(Convert.ToString(parameter))); case "messagesent": if (currentUserInfo == null) { currentUserInfo = MembershipContext.AuthenticatedUser; } if (currentSiteInfo == null) { currentSiteInfo = SiteContext.CurrentSite; } DateTime currentDateTime = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (IsLiveSite) { return(TimeZoneMethods.ConvertDateTime(currentDateTime, this)); } else { return(TimeZoneHelper.ConvertToUserTimeZone(currentDateTime, true, currentUserInfo, currentSiteInfo)); } } return(parameter); }
protected string GetDateRead(object messageReadDate) { DateTime messageRead = ValidationHelper.GetDateTime(messageReadDate, DateTimeHelper.ZERO_TIME); if (currentUserInfo == null) { currentUserInfo = MembershipContext.AuthenticatedUser; } if (currentSiteInfo == null) { currentSiteInfo = SiteContext.CurrentSite; } DateTime currentDateTime = ValidationHelper.GetDateTime(messageReadDate, DateTimeHelper.ZERO_TIME); if (messageRead != DateTimeHelper.ZERO_TIME) { if (IsLiveSite) { return(TimeZoneMethods.ConvertDateTime(currentDateTime, this).ToString()); } return(TimeZoneHelper.ConvertToUserTimeZone(currentDateTime, true, currentUserInfo, currentSiteInfo)); } return(GetString("Messaging.OutboxMessageUnread")); }
/// <summary> /// OnPreview handler. /// </summary> protected void forumEdit_OnPreview(object sender, EventArgs e) { // Preview title ltrTitle.Text = GetString("Forums_ForumNewPost_Header.Preview"); // Display placeholder plcPreview.Visible = true; // Post properties ForumPostInfo fpi = sender as ForumPostInfo; if (fpi != null) { ltrAvatar.Text = AvatarImage(fpi); ltrSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); ltrText.Text = ResolvePostText(fpi.PostText); ltrUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName); ltrTime.Text = TimeZoneMethods.ConvertDateTime(fpi.PostTime, this).ToString(); BadgeInfo bi = null; string badgeName = null; string badgeImageUrl = null; bi = BadgeInfoProvider.GetBadgeInfo(MembershipContext.AuthenticatedUser.UserSettings.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=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge); } }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName) { case "remove": if (sender is CMSGridActionButton) { // Get action button CMSGridActionButton deleteBtn = (CMSGridActionButton)sender; deleteBtn.Enabled = friendsManagePermission; return(deleteBtn); } else { return(string.Empty); } case "approve": if (sender is CMSGridActionButton) { // Get action button CMSGridActionButton approveBtn = (CMSGridActionButton)sender; // Get full row view DataRowView drv = UniGridFunctions.GetDataRowView((DataControlFieldCell)approveBtn.Parent); // Add custom reject action approveBtn.OnClientClick = "return FM_Approve_" + ClientID + "('" + drv["FriendID"] + "',null,'" + ApproveDialogUrl + "');"; approveBtn.Enabled = friendsManagePermission; return(approveBtn); } else { return(string.Empty); } case "friendrejectedwhen": if (currentUserInfo == null) { currentUserInfo = MembershipContext.AuthenticatedUser; } if (currentSiteInfo == null) { currentSiteInfo = SiteContext.CurrentSite; } DateTime currentDateTime = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (IsLiveSite) { return(TimeZoneMethods.ConvertDateTime(currentDateTime, this)); } else { return(TimeZoneHelper.ConvertToUserTimeZone(currentDateTime, true, currentUserInfo, currentSiteInfo)); } case "formattedusername": return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), IsLiveSite))); } return(parameter); }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "messageapproved": return(UniGridFunctions.ColoredSpanYesNo(parameter)); case "messageisspam": return(UniGridFunctions.ColoredSpanYesNoReversed(parameter)); case "messagetext": string text = parameter.ToString(); if (text.Length > 30) { text = text.Substring(0, 30) + "..."; } return(HTMLHelper.HTMLEncode(text)); case "messagetooltip": return(HTMLHelper.HTMLEncodeLineBreaks(parameter.ToString())); case "edit": CMSGridActionButton editButton = ((CMSGridActionButton)sender); int boardID = ValidationHelper.GetInteger(((DataRowView)((GridViewRow)parameter).DataItem).Row["BoardID"], 0); string url = "~/CMSModules/MessageBoards/Tools/Messages/Message_Edit.aspx"; if (IsLiveSite) { url = "~/CMSModules/MessageBoards/CMSPages/Message_Edit.aspx"; } editButton.OnClientClick = "modalDialog('" + AuthenticationHelper.ResolveDialogUrl(((EditPageUrl == "") ? url : EditPageUrl)) + "?messageboardid=" + boardID + "&messageId=" + editButton.CommandArgument + "', 'MessageEdit', 800, 535); return false;"; break; case "approve": bool approve = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["MessageApproved"], false); if (!approve) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.approve"); } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; button.ToolTip = GetString("general.reject"); } break; case "messageinserted": return(TimeZoneMethods.ConvertDateTime(ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME), this).ToString()); } return(parameter); }
/// <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 = TimeZoneMethods.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString(); lblUser.Text = HTMLHelper.HTMLEncode(fpi.PostUserName); lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); DiscussionMacroResolver dmh = new DiscussionMacroResolver(); 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> /// Add timezone settings to given time. Return empty string if no time set. /// </summary> /// <param name="time">Time to convert</param> protected string GetConvertedTime(object time) { DateTime dt = ValidationHelper.GetDateTime(time, DateTimeHelper.ZERO_TIME); if (dt == DateTimeHelper.ZERO_TIME) { return(String.Empty); } return(Convert.ToString(TimeZoneMethods.ConvertDateTime(dt, this))); }
protected object gridBoards_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName) { case "enabled": bool enabled = ValidationHelper.GetBoolean(parameter, false); return(UniGridFunctions.ColoredSpanYesNo(enabled)); case "opened": bool opened = IsBoardOpened((DataRowView)parameter); return(UniGridFunctions.ColoredSpanYesNo(opened)); case "moderated": bool moderated = ValidationHelper.GetBoolean(parameter, false); return(UniGridFunctions.ColoredSpanYesNo(moderated)); case "document": DataRowView dr = parameter as DataRowView; if (dr != null) { // If the document path is empty alter it with the default '/' string documentPath = ValidationHelper.GetString(dr["DocumentNamePath"], ""); int siteId = ValidationHelper.GetInteger(dr["NodeSiteID"], 0); SiteInfo site = SiteInfoProvider.GetSiteInfo(siteId); if (string.IsNullOrEmpty(documentPath)) { documentPath = "/"; } if (site.Status == SiteStatusEnum.Running) { int nodeID = ValidationHelper.GetInteger(dr["NodeID"], 0); string culture = ValidationHelper.GetString(dr["DocumentCulture"], ""); return("<a class=\"js-unigrid-action js-viewDocument\"" + "href=\"javascript:void(0)\" " + "data-node-id=\"" + nodeID + "\" " + "data-document-culture=\"" + culture + "\">" + HTMLHelper.HTMLEncode(documentPath) + "</a>"); } } return(""); case "lastpost": DateTime lastPost = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(lastPost == DateTimeHelper.ZERO_TIME ? GetString("general.na") : TimeZoneMethods.ConvertDateTime(lastPost, this).ToString()); default: return(""); } }
protected void Page_Load(object sender, EventArgs e) { CopyValues(forumEdit); if (IsAdHocForum) { plcHeader.Visible = false; } forumEdit.OnPreview += 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); ltrText.Text = ResolvePostText(ForumContext.CurrentReplyThread.PostText); ltrUserName.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostUserName); ltrTime.Text = TimeZoneMethods.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=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge); } }
/// <summary> /// Returns the approval text in format "date (approved by user full name)". /// </summary> /// <param name="date">Date time</param> /// <param name="userId">User id</param> private string GetApprovalInfoText(DateTime date, int userId) { string retval = ""; if (date != DateTimeHelper.ZERO_TIME) { // Get current time retval = TimeZoneMethods.ConvertDateTime(date, this).ToString(); UserInfo ui = UserInfoProvider.GetUserInfo(userId); if (ui != null) { // Add user's full name retval += " (" + HTMLHelper.HTMLEncode(ui.FullName) + ")"; } } return(retval); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { // In design mode is pocessing of control stoped if (StopProcessing) { calItems.StopProcessing = true; } else { // Set properties from Webpart form calItems.CacheItemName = CacheItemName; calItems.CacheDependencies = CacheDependencies; calItems.CacheMinutes = CacheMinutes; calItems.CheckPermissions = CheckPermissions; calItems.ClassNames = ClassNames; calItems.CategoryName = CategoryName; calItems.CombineWithDefaultCulture = CombineWithDefaultCulture; calItems.CultureCode = CultureCode; calItems.MaxRelativeLevel = MaxRelativeLevel; calItems.OrderBy = OrderBy; calItems.Path = Path; calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide; calItems.RelationshipName = RelationshipName; calItems.RelationshipWithNodeGuid = RelationshipWithNodeGuid; calItems.SelectOnlyPublished = SelectOnlyPublished; calItems.SiteName = SiteName; calItems.TransformationName = TransformationName; calItems.WhereCondition = WhereCondition; calItems.DayField = DayField; calItems.FilterName = FilterName; calItems.SelectedColumns = Columns; calItems.HideDefaultDayNumber = HideDefaultDayNumber; calItems.DisplayOnlySingleDayItem = DisplayOnlySingleDayItem; calItems.NoEventTransformationName = NoEventTransformationName; calItems.TodaysDate = TimeZoneMethods.ConvertDateTime(DateTime.Now, this); } }
private void GridView_DataBound(object sender, EventArgs e) { //convert boolean values from DB to user-friendly information strings in the list for (int i = 0; i < gridElem.GridView.Rows.Count; i++) { // Date time string string dateTime = String.Empty; // Change timezone for live site DateTime dt = TimeZoneMethods.ConvertDateTime(ValidationHelper.GetDateTime(gridElem.GridView.Rows[i].Cells[6].Text, DateTimeHelper.ZERO_TIME), this); if (dt != DateTimeHelper.ZERO_TIME) { dateTime = dt.ToString(); } // Set value to the grid gridElem.GridView.Rows[i].Cells[6].Text = dateTime; } }
/// <summary> /// Fills the data into form for specified Group member. /// </summary> private void HandleExistingMember(GroupMemberInfo groupMemberInfo) { if (groupMemberInfo != null) { // Fill controls with data from existing user int userId = ValidationHelper.GetInteger(groupMemberInfo.MemberUserID, 0); UserInfo ui = UserInfoProvider.GetUserInfo(userId); if (ui != null) { lblFullName.Text = HTMLHelper.HTMLEncode(ui.FullName); } txtComment.Text = groupMemberInfo.MemberComment; string approved = GetApprovalInfoText(groupMemberInfo.MemberApprovedWhen, groupMemberInfo.MemberApprovedByUserID); if (String.IsNullOrWhiteSpace(approved)) { rowApproved.Visible = false; } else { lblMemberApproved.Text = approved; rowApproved.Visible = true; } string rejected = GetApprovalInfoText(groupMemberInfo.MemberRejectedWhen, groupMemberInfo.MemberApprovedByUserID); if (String.IsNullOrWhiteSpace(rejected)) { rowRejected.Visible = false; } else { lblMemberRejected.Text = rejected; rowRejected.Visible = true; } lblMemberJoined.Text = TimeZoneMethods.ConvertDateTime(groupMemberInfo.MemberJoined, this).ToString(); } }
/// <summary> /// Fill form with the comment data. /// </summary> protected void LoadCommentData() { // Get comment info from database BlogCommentInfo bci = BlogCommentInfoProvider.GetBlogCommentInfo(mCommentId); if (bci != null) { txtName.Text = bci.CommentUserName; txtUrl.Text = bci.CommentUrl; txtComments.Text = bci.CommentText; txtEmail.Text = bci.CommentEmail; chkApproved.Checked = bci.CommentApproved; chkSpam.Checked = bci.CommentIsSpam; if (PortalContext.ViewMode.IsLiveSite() && (MembershipContext.AuthenticatedUser != null)) { lblInsertedDate.Text = TimeZoneMethods.ConvertDateTime(bci.CommentDate, this).ToString(); } else { lblInsertedDate.Text = bci.CommentDate.ToString(); } } }
/// <summary> /// Reload data. /// </summary> public void LoadData() { if (mCommentsDataRow != null) { // Load comment data BlogCommentInfo bci = new BlogCommentInfo(mCommentsDataRow); if (bci != null) { CommentID = bci.CommentID; // Set user picture if (BlogpPoperties.EnableUserPictures) { userPict.UserID = bci.CommentUserID; userPict.Width = BlogpPoperties.UserPictureMaxWidth; userPict.Height = BlogpPoperties.UserPictureMaxHeight; userPict.Visible = true; userPict.RenderOuterDiv = true; userPict.OuterDivCSSClass = "CommentUserPicture"; // Gravatar support string avType = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSAvatarType"); if (avType == AvatarInfoProvider.USERCHOICE) { UserInfo ui = UserInfoProvider.GetUserInfo(bci.CommentUserID); if (ui != null) { avType = ui.UserSettings.UserAvatarType; } else { avType = AvatarInfoProvider.GRAVATAR; } } userPict.UserEmail = bci.CommentEmail; userPict.UserAvatarType = avType; } else { userPict.Visible = false; } if (!String.IsNullOrEmpty(bci.CommentUrl)) { lnkName.Text = HTMLHelper.HTMLEncode(bci.CommentUserName); lnkName.NavigateUrl = bci.CommentUrl; // Add no follow attribute if it is required if (HTMLHelper.UseNoFollowForUsersLinks(SiteContext.CurrentSiteName)) { lnkName.Attributes.Add("rel", "nofollow"); } lblName.Visible = false; } else { lblName.Text = HTMLHelper.HTMLEncode(bci.CommentUserName); lnkName.Visible = false; } lblText.Text = GetHTMLEncodedCommentText(bci); lblDate.Text = TimeZoneMethods.ConvertDateTime(bci.CommentDate, this).ToString(); string url = "~/CMSModules/Blogs/Controls/Comment_Edit.aspx"; if (IsLiveSite) { url = "~/CMSModules/Blogs/CMSPages/Comment_Edit.aspx"; } lnkEdit.OnClientClick = "EditComment('" + ResolveUrl(url) + "?commentID=" + CommentID + "');return false;"; // Initialize report abuse ucInlineAbuseReport.ReportTitle = ResHelper.GetString("BlogCommentDetail.AbuseReport", SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCulture")) + bci.CommentText; ucInlineAbuseReport.ReportObjectID = CommentID; ucInlineAbuseReport.CMSPanel.Roles = AbuseReportRoles; ucInlineAbuseReport.CMSPanel.SecurityAccess = AbuseReportSecurityAccess; ucInlineAbuseReport.CMSPanel.OwnerID = AbuseReportOwnerID; } } }
/// <summary> /// Reload data. /// </summary> public override void ReloadData() { ForumPostInfo fpi = null; ForumInfo fi; #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 = " (" + TimeZoneMethods.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString() + ")"; lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); DiscussionMacroResolver dmh = new DiscussionMacroResolver(); 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> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { calItems.StopProcessing = true; } else { calItems.ControlContext = repEvent.ControlContext = ControlContext; // Calendar properties calItems.CacheItemName = CacheItemName; calItems.CacheDependencies = CacheDependencies; calItems.CacheMinutes = CacheMinutes; calItems.CheckPermissions = CheckPermissions; calItems.ClassNames = ClassNames; calItems.CombineWithDefaultCulture = CombineWithDefaultCulture; calItems.CultureCode = CultureCode; calItems.MaxRelativeLevel = MaxRelativeLevel; calItems.OrderBy = OrderBy; calItems.WhereCondition = WhereCondition; calItems.Columns = Columns; calItems.Path = Path; calItems.SelectOnlyPublished = SelectOnlyPublished; calItems.SiteName = SiteName; calItems.FilterName = FilterName; calItems.RelationshipName = RelationshipName; calItems.RelationshipWithNodeGuid = RelationshipWithNodeGuid; calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide; calItems.TransformationName = TransformationName; calItems.NoEventTransformationName = NoEventTransformationName; calItems.DayField = DayField; calItems.EventEndField = EventEndField; calItems.HideDefaultDayNumber = HideDefaultDayNumber; calItems.TodaysDate = TimeZoneMethods.ConvertDateTime(DateTime.Now, this); bool detail = false; // If calendar event path is defined event is loaded in accordance to the selected path string eventPath = QueryHelper.GetString("CalendarEventPath", null); if (!String.IsNullOrEmpty(eventPath)) { detail = true; repEvent.Path = eventPath; // Set selected date to specific document TreeNode node = TreeHelper.GetDocument(SiteName, eventPath, CultureCode, CombineWithDefaultCulture, ClassNames, SelectOnlyPublished, CheckPermissions, MembershipContext.AuthenticatedUser); if (node != null) { object value = node.GetValue(DayField); if (ValidationHelper.GetDateTimeSystem(value, DateTimeHelper.ZERO_TIME) != DateTimeHelper.ZERO_TIME) { calItems.TodaysDate = TimeZoneMethods.ConvertDateTime((DateTime)value, this); } } } // By default select current event from current document value PageInfo currentPage = DocumentContext.CurrentPageInfo; if ((currentPage != null) && (ClassNames.ToLowerCSafe().Contains(currentPage.ClassName.ToLowerCSafe()))) { detail = true; repEvent.Path = currentPage.NodeAliasPath; // Set selected date to current document object value = DocumentContext.CurrentDocument.GetValue(DayField); if (ValidationHelper.GetDateTimeSystem(value, DateTimeHelper.ZERO_TIME) != DateTimeHelper.ZERO_TIME) { calItems.TodaysDate = TimeZoneMethods.ConvertDateTime((DateTime)value, this); // Get name of coupled class ID column string idColumn = DocumentContext.CurrentDocument.CoupledClassIDColumn; if (!string.IsNullOrEmpty(idColumn)) { // Set selected item ID and the ID column name so it is possible to highlight specific event in the calendar calItems.SelectedItemIDColumn = idColumn; calItems.SelectedItemID = ValidationHelper.GetInteger(DocumentContext.CurrentDocument.GetValue(idColumn), 0); } } } if (detail) { // Setup the detail repeater repEvent.Visible = true; repEvent.StopProcessing = false; repEvent.SelectedItemTransformationName = EventDetailTransformation; repEvent.ClassNames = ClassNames; repEvent.Columns = Columns; if (!String.IsNullOrEmpty(CacheItemName)) { repEvent.CacheItemName = CacheItemName + "|detail"; } repEvent.CacheDependencies = CacheDependencies; repEvent.CacheMinutes = CacheMinutes; repEvent.CheckPermissions = CheckPermissions; repEvent.CombineWithDefaultCulture = CombineWithDefaultCulture; repEvent.CultureCode = CultureCode; repEvent.SelectOnlyPublished = SelectOnlyPublished; repEvent.SiteName = SiteName; repEvent.WhereCondition = WhereCondition; } } }
/// <summary> /// Item data bound handler. /// </summary> protected void gridItems_ItemDataBound(object sender, DataGridItemEventArgs e) { if (mGlobalNameID != null) { foreach (var globalName in mGlobalNameID) { if (!string.IsNullOrEmpty(globalName)) { Control ctrl = e.Item.FindControl(globalName); if (ctrl != null) { ((HyperLink)ctrl).Text = ((DataRowView)e.Item.DataItem)[globalName].ToString(); int itemId = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue((DataRowView)e.Item.DataItem, "ItemID"), 0); string detailUrl = RequestContext.CurrentURL; // Use current page by default if (!string.IsNullOrEmpty(DetailPagePath)) { detailUrl = DocumentURLProvider.GetUrl(DetailPagePath); } // Add querystring parametr detailUrl = URLHelper.AddParameterToUrl(detailUrl, "id", itemId.ToString()); ((HyperLink)ctrl).NavigateUrl = detailUrl; } } } } // Timezones if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { object dataItem = e.Item.DataItem; if (dataItem.GetType() == typeof(DataRowView)) { // Get data row DataRow dr = ((DataRowView)dataItem).Row; // Get count of columns (depends whether columns are automatically generated) int columnCount = gridItems.AutoGenerateColumns ? dr.Table.Columns.Count : gridItems.Columns.Count; // Go through all grid columns int j = 0; for (int i = 0; i < columnCount; i++) { // Get column of current index object column = gridItems.AutoGenerateColumns ? dr[i] : gridItems.Columns[i]; if (((column.GetType() == typeof(BoundColumn)) && !gridItems.AutoGenerateColumns) || ((column is DateTime) && gridItems.AutoGenerateColumns)) { // Get cell or actual value object cell = gridItems.AutoGenerateColumns ? column : dr[((BoundColumn)column).DataField]; // Apply timezone settings if (cell is DateTime) { e.Item.Cells[j].Text = TimeZoneMethods.ConvertDateTime((DateTime)cell, this).ToString(); } } // DataGrid doesn't show the GUID columns if the columns are autogenerated else if (gridItems.AutoGenerateColumns && (column is Guid)) { --j; } ++j; } } } }
public void ReloadData() { if (StopProcessing) { // Do nothing MessageUserButtonsControl.StopProcessing = true; UserPictureControl.StopProcessing = true; } else { MessageUserButtonsControl.StopProcessing = false; UserPictureControl.StopProcessing = false; if (Message != null) { // Get current user info currentUserInfo = MembershipContext.AuthenticatedUser; // 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) { UserPictureControl.Visible = true; UserPictureControl.UserID = messageUserInfo.UserID; // Gravatar support string avType = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSAvatarType"); if (avType == AvatarInfoProvider.USERCHOICE) { avType = messageUserInfo.UserSettings.UserAvatarType; } UserPictureControl.UserAvatarType = avType; // Disable message user buttons on live site for hidden or disabled users if (IsLiveSite && !currentUserInfo.IsGlobalAdministrator && (messageUserInfo.UserIsDisabledManually || messageUserInfo.UserIsHidden)) { MessageUserButtonsControl.RelatedUserId = 0; } else { MessageUserButtonsControl.RelatedUserId = messageUserInfo.UserID; } lblFrom.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(messageUserInfo.UserName, messageUserInfo.FullName, messageUserInfo.UserNickName, IsLiveSite)); } else { MessageUserButtonsControl.RelatedUserId = 0; lblFrom.Text = HTMLHelper.HTMLEncode(Message.MessageSenderNickName); } string body = Message.MessageBody; // Resolve macros DiscussionMacroResolver dmh = new DiscussionMacroResolver(); body = dmh.ResolveMacros(body); lblSubject.Text = HTMLHelper.HTMLEncodeLineBreaks(Message.MessageSubject); if (IsLiveSite) { lblDate.Text = TimeZoneMethods.ConvertDateTime(Message.MessageSent, this).ToString(); } else { lblDate.Text = TimeZoneHelper.ConvertToUserTimeZone(Message.MessageSent, true, currentUserInfo, SiteContext.CurrentSite); } lblBody.Text = body; } } else { ShowError(GetString("Messaging.MessageDoesntExist")); } } }
/// <summary> /// Handles UniGrid's OnExternalDataBound event. /// </summary> /// <param name="sender">Sender object (image button if it is an external databoud for action button)</param> /// <param name="sourceName">External source name of the column specified in the grid XML</param> /// <param name="parameter">Source parameter (original value of the field)</param> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView row = null; switch (sourceName.ToLowerCSafe()) { case "up": case "down": CMSGridActionButton button = ((CMSGridActionButton)sender); button.Visible = showArrows; break; case "taskprogress": row = (DataRowView)parameter; int progress = ValidationHelper.GetInteger(row["ProjectTaskProgress"], 0); return(ProjectTaskInfoProvider.GenerateProgressHtml(progress, true)); case "projecttaskdisplayname": case "projectdisplayname": string displayname = parameter.ToString(); if (displayname.Length > MAX_TITLE_LENGTH) { return("<span title=\"" + HTMLHelper.HTMLEncode(displayname) + "\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(displayname, MAX_TITLE_LENGTH)) + "</span>"); } else { return(HTMLHelper.HTMLEncode(displayname)); } case "projecttaskdeadline": DateTime dt = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (dt == DateTimeHelper.ZERO_TIME) { return(String.Empty); } return(TimeZoneMethods.ConvertDateTime(dt, this)); case "taskstatus": row = parameter as DataRowView; if (row != null) { string statusName = ValidationHelper.GetString(row["TaskStatusDisplayName"], String.Empty); statusName = HTMLHelper.HTMLEncode(statusName); string iconPath = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["TaskStatusIcon"], String.Empty)); // Get row color rowColor = ValidationHelper.GetString(row["TaskStatusColor"], ""); switch (StatusDisplayType) { // Text case StatusDisplayTypeEnum.Text: return(statusName); // Icon case StatusDisplayTypeEnum.Icon: if (!String.IsNullOrEmpty(iconPath)) { return("<div style=\"text-align:center;\"><img src=\"" + HTMLHelper.HTMLEncode(GetImageUrl(iconPath)) + "\" alt=\"" + statusName + "\" title=\"" + statusName + "\" class=\"StatusImage\" style=\"max-width:50px; max-height: 50px;\" /></div>"); } return(statusName); // Icon and text case StatusDisplayTypeEnum.IconAndText: if (!String.IsNullOrEmpty(iconPath)) { return("<img src=\"" + GetImageUrl(iconPath) + "\" title=\"" + statusName + "\" class=\"StatusImage\" style=\"max-width:50px; max-height: 50px;\" /> " + statusName); } return(statusName); } } return(row.ToString()); case "assigneeformattedfullname": row = (DataRowView)parameter; string assigneeUserName = ValidationHelper.GetString(row["AssigneeUserName"], String.Empty); string assigneeFullName = ValidationHelper.GetString(row["AssigneeFullName"], String.Empty); return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(assigneeUserName, assigneeFullName, IsLiveSite))); case "ownerformattedfullname": row = (DataRowView)parameter; string ownerUserName = ValidationHelper.GetString(row["OwnerUserName"], String.Empty); string ownerFullName = ValidationHelper.GetString(row["OwnerFullName"], String.Empty); return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ownerUserName, ownerFullName, IsLiveSite))); // Display name with link - used in webparts case "linkeddisplayname": row = (DataRowView)parameter; string displayName = ValidationHelper.GetString(row["ProjectTaskDisplayName"], String.Empty); int projectTaskID = ValidationHelper.GetInteger(row["ProjectTaskID"], 0); string url = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSTaskDetailPage"); return(String.Format("<a href=\"{0}\" title=\"{1}\">{2}</a>", url + "?ProjectTaskID=" + projectTaskID, HTMLHelper.HTMLEncode(displayName), HTMLHelper.HTMLEncode(TextHelper.LimitLength(displayName, MAX_TITLE_LENGTH)))); // Display name with link to ajax window case "editlinkdisplayname": row = (DataRowView)parameter; string editDisplayName = ValidationHelper.GetString(row["ProjectTaskDisplayName"], String.Empty); int editProjectTaskID = ValidationHelper.GetInteger(row["ProjectTaskID"], 0); return(String.Format("<a href=\"javascript:" + ControlsHelper.GetPostBackEventReference(this, editProjectTaskID.ToString()) + "\" title=\"{0}\">{1}</a>", HTMLHelper.HTMLEncode(editDisplayName), HTMLHelper.HTMLEncode(TextHelper.LimitLength(editDisplayName, MAX_TITLE_LENGTH)))); } return(parameter); }
protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); DataRowView drv = null; bool modifyPermission = true; string documentCulture = null; switch (sourceName) { case "documentname": drv = parameter as DataRowView; string documentName = null; string encodedDocumentName = null; string documentType = null; documentCulture = ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty); string alias = ValidationHelper.GetString(drv.Row["NodeAlias"], string.Empty); int nodeId = ValidationHelper.GetInteger(drv.Row["NodeID"], 0); int documentId = ValidationHelper.GetInteger(drv.Row["DocumentID"], 0); bool isLinked = (ValidationHelper.GetInteger(drv["NodeLinkedNodeID"], 0) != 0); Guid nodeGuid = ValidationHelper.GetGuid(drv.Row["NodeGUID"], Guid.Empty); string fileDescription = ValidationHelper.GetString(drv.Row["FileDescription"], string.Empty); Guid fileAttachment = ValidationHelper.GetGuid(drv.Row["FileAttachment"], Guid.Empty); // Get permissions flags modifyPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, documentCulture); bool modifyCulturePermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, PreferredCultureCode); bool deletePermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Delete, documentCulture); bool modifyPermissionsPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.ModifyPermissions, documentCulture); bool readPermission = !CheckPermissions || TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Read, documentCulture); if (modifyPermission) { documentName = ValidationHelper.GetString(drv.Row["DocumentName"], string.Empty); documentType = ValidationHelper.GetString(drv.Row["DocumentType"], string.Empty); } else { documentName = ValidationHelper.GetString(drv.Row["PublishedDocumentName"], string.Empty); documentType = ValidationHelper.GetString(drv.Row["PublishedDocumentType"], string.Empty); } encodedDocumentName = HTMLHelper.HTMLEncode(documentName); string fileTypeIcon = UIHelper.GetFileIcon(Page, documentType, tooltip: HTMLHelper.HTMLEncode(documentType)); string flagIcon = null; if (documentCulture.ToLowerCSafe() != PreferredCultureCode.ToLowerCSafe()) { flagIcon = "<img class=\"Icon\" src=\"" + GetFlagIconUrl(documentCulture, "16x16") + "\" alt=\"" + HTMLHelper.HTMLEncode(documentCulture) + "\" />"; } string menuParameter = ScriptHelper.GetString(nodeId + "|" + documentCulture); string attachmentName = encodedDocumentName; string toolTip = UIHelper.GetTooltipAttributes(null, 0, 0, null, null, null, fileDescription, null, 300); // Generate link to open document if (fileAttachment != Guid.Empty) { // Get document URL string attachmentUrl = AuthenticationHelper.ResolveUIUrl(AttachmentURLProvider.GetPermanentAttachmentUrl(nodeGuid, alias)); if (modifyPermission) { attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "latestfordocid", ValidationHelper.GetString(documentId, string.Empty)); attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "hash", ValidationHelper.GetHashString("d" + documentId)); } attachmentUrl = URLHelper.UpdateParameterInUrl(attachmentUrl, "chset", Guid.NewGuid().ToString()); if (!string.IsNullOrEmpty(attachmentUrl)) { attachmentName = "<a href=\"" + HTMLHelper.EncodeForHtmlAttribute(attachmentUrl) + "\" " + toolTip + ">" + encodedDocumentName + "</a> "; } } else { attachmentName = "<span" + toolTip + ">" + encodedDocumentName + "</span>"; } // Add linked flag if (isLinked) { attachmentName += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } bool showContextMenu = readPermission && (modifyPermission || modifyPermissionsPermission || deletePermission || (IsAuthorizedToCreate && modifyCulturePermission)); // Generate row with icons, hover action and context menu StringBuilder contextMenuString = new StringBuilder(); contextMenuString.Append("<table>"); contextMenuString.Append("<tr>"); if (showContextMenu) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + arrowContextMenu.ClientID, menuParameter, false, HtmlTextWriterTag.Td, "ArrowIcon", null)); contextMenuString.Append("<a class=\"btn-unigrid-action\"><i class=\"icon-ellipsis\"></i></a>"); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); } else { contextMenuString.Append("<td class=\"NoIcon\"> </td>"); } if (showContextMenu) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "FileTypeIcon", null)); } else { contextMenuString.Append("<td class=\"FileTypeIcon\">"); } contextMenuString.Append(fileTypeIcon); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); if (showContextMenu) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "RowContent", "width: 100%;")); } else { contextMenuString.Append("<td class=\"RowContent\" style=\"width: 100%;\">"); } contextMenuString.Append(attachmentName); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); if (!string.IsNullOrEmpty(flagIcon)) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "FlagIcon", null)); contextMenuString.Append(flagIcon); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); } contextMenuString.Append(" </tr>"); contextMenuString.Append("</table>"); return(contextMenuString.ToString()); case "modifiedwhen": case "modifiedwhentooltip": if (string.IsNullOrEmpty(parameter.ToString())) { return(string.Empty); } else { // Handle time zones DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (sourceName == "modifiedwhen") { if (IsLiveSite) { return(TimeZoneMethods.ConvertDateTime(modifiedWhen, this)); } else { return(TimeZoneHelper.GetCurrentTimeZoneDateTimeString(modifiedWhen, CurrentUser, CurrentSite, out usedTimeZone)); } } else { if (!IsLiveSite) { if (TimeZoneHelper.TimeZonesEnabled && (usedTimeZone == null)) { TimeZoneHelper.GetCurrentTimeZoneDateTimeString(modifiedWhen, CurrentUser, CurrentSite, out usedTimeZone); } return(TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone)); } else { return(null); } } } case "status": string stepName = string.Empty; string toReturn = string.Empty; // Extract datarow drv = parameter as DataRowView; stepName = GetString("general.dash"); TreeNode node = DocumentHelper.GetDocument(ValidationHelper.GetInteger(drv["DocumentID"], 0), TreeProvider); if (node != null) { var step = node.WorkflowStep; if (step != null) { stepName = step.StepDisplayName; } } // Gain desired values from datarow view int checkedOutByUserId = ValidationHelper.GetInteger(drv["DocumentCheckedOutByUserID"], 0); documentCulture = ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty); modifyPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, documentCulture); // Add 'checked out' icon if ((checkedOutByUserId > 0) && modifyPermission) { toReturn = " " + DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.CheckedOut); } toReturn = stepName + toReturn; return(toReturn); } return(parameter); }
/// <summary> /// Unigrid OnExternalDataBound event. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { GroupMemberStatus status = GroupMemberStatus.Approved; DataRowView drv = null; GridViewRow gvr = null; bool current = false; switch (sourceName.ToLowerCSafe()) { case "memberapprovedwhen": case "memberrejectedwhen": if (parameter != DBNull.Value) { // Get current dateTime return(TimeZoneMethods.ConvertDateTime(Convert.ToDateTime(parameter), this)); } break; case "approve": gvr = parameter as GridViewRow; if (gvr != null) { drv = gvr.DataItem as DataRowView; if (drv != null) { // Check for current user if (IsLiveSite && (MembershipContext.AuthenticatedUser.UserID == ValidationHelper.GetInteger(drv["MemberUserID"], 0))) { current = true; } // Do not allow approve hidden or disabled users bool hiddenOrDisabled = IsUserHiddenOrDisabled(drv); status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0); // Enable or disable Approve button if (!current && (status != GroupMemberStatus.Approved) && !hiddenOrDisabled) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.approve"); button.Enabled = true; } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.approve"); button.Enabled = false; } } } break; case "reject": gvr = parameter as GridViewRow; if (gvr != null) { drv = gvr.DataItem as DataRowView; if (drv != null) { // Check for current user if (IsLiveSite && (MembershipContext.AuthenticatedUser.UserID == ValidationHelper.GetInteger(drv.Row["MemberUserID"], 0))) { current = true; } status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0); // Enable or disable Reject button if (!current && (status != GroupMemberStatus.Rejected)) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; button.ToolTip = GetString("general.reject"); button.Enabled = true; } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; button.ToolTip = GetString("general.reject"); button.Enabled = false; } } } break; case "formattedusername": // Format username return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), IsLiveSite))); case "edit": gvr = parameter as GridViewRow; if (gvr != null) { drv = gvr.DataItem as DataRowView; if (drv != null) { // Do not allow approve hidden or disabled users bool hiddenOrDisabled = IsUserHiddenOrDisabled(drv); // Enable or disable Edit button if (!hiddenOrDisabled) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-edit"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.edit"); button.Enabled = true; } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-edit"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.edit"); button.Enabled = false; } } } break; } return(parameter); }
/// <summary> /// Reload data. /// </summary> public void LoadData() { if (Comment == null) { return; } // Set user picture if (BlogProperties.EnableUserPictures) { userPict.UserID = Comment.CommentUserID; userPict.Width = BlogProperties.UserPictureMaxWidth; userPict.Height = BlogProperties.UserPictureMaxHeight; userPict.Visible = true; userPict.RenderOuterDiv = true; userPict.OuterDivCSSClass = "CommentUserPicture"; // Gravatar support string avType = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CMSAvatarType"); if (avType == AvatarInfoProvider.USERCHOICE) { UserInfo ui = UserInfoProvider.GetUserInfo(Comment.CommentUserID); avType = ui != null ? ui.UserSettings.UserAvatarType : AvatarInfoProvider.GRAVATAR; } userPict.UserEmail = Comment.CommentEmail; userPict.UserAvatarType = avType; } else { userPict.Visible = false; } if (!String.IsNullOrEmpty(Comment.CommentUrl)) { lnkName.Text = HTMLHelper.HTMLEncode(Comment.CommentUserName); lnkName.NavigateUrl = Comment.CommentUrl; // Add no follow attribute if it is required if (HTMLHelper.UseNoFollowForUsersLinks(SiteContext.CurrentSiteName)) { lnkName.Attributes.Add("rel", "nofollow"); } lblName.Visible = false; } else { lblName.Text = HTMLHelper.HTMLEncode(Comment.CommentUserName); lnkName.Visible = false; } lblText.Text = HTMLHelper.HTMLEncodeLineBreaks(Comment.CommentText); lblDate.Text = TimeZoneMethods.ConvertDateTime(Comment.CommentDate, this).ToString(); string url = "~/CMSModules/Blogs/Controls/Comment_Edit.aspx"; if (IsLiveSite) { url = "~/CMSModules/Blogs/CMSPages/Comment_Edit.aspx"; } lnkEdit.OnClientClick = string.Format("EditComment('{0}?commentID={1}'); return false;", ResolveUrl(url), CommentID); lnkDelete.OnClientClick = string.Format("if(ConfirmDelete()) {{ {0}; }} return false;", GetPostBackEventReference("delete")); lnkApprove.OnClientClick = string.Format("{0}; return false;", GetPostBackEventReference("approve")); lnkReject.OnClientClick = string.Format("{0}; return false;", GetPostBackEventReference("reject")); // Initialize report abuse ucInlineAbuseReport.ReportTitle = ResHelper.GetString("BlogCommentDetail.AbuseReport", SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CMSDefaultCulture")) + Comment.CommentText; ucInlineAbuseReport.ReportObjectID = CommentID; ucInlineAbuseReport.CMSPanel.Roles = AbuseReportRoles; ucInlineAbuseReport.CMSPanel.SecurityAccess = AbuseReportSecurityAccess; ucInlineAbuseReport.CMSPanel.OwnerID = AbuseReportOwnerID; }
/// <summary> /// Handles UniGrid's OnExternalDataBound event. /// </summary> /// <param name="sender">Sender object (image button if it is an external databoud for action button)</param> /// <param name="sourceName">External source name of the column specified in the grid XML</param> /// <param name="parameter">Source parameter (original value of the field)</param> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView row = null; switch (sourceName.ToLowerCSafe()) { case "projectdisplayname": string displayname = parameter.ToString(); if (displayname.Length > MAX_TITLE_LENGTH) { return("<span title=\"" + HTMLHelper.HTMLEncode(displayname) + "\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(displayname, MAX_TITLE_LENGTH)) + "</span>"); } else { return(HTMLHelper.HTMLEncode(displayname)); } case "projectprogress": row = (DataRowView)parameter; int progress = ValidationHelper.GetInteger(row["ProjectProgress"], 0); return(ProjectTaskInfoProvider.GenerateProgressHtml(progress, true)); case "statusicon": row = (DataRowView)parameter; string statusText = ValidationHelper.GetString(row["ProjectStatus"], ""); statusText = HTMLHelper.HTMLEncode(statusText); string iconUrl = ValidationHelper.GetString(row["ProjectStatusIcon"], ""); // Get row color rowColor = ValidationHelper.GetString(row["ProjectStatusColor"], ""); if (!String.IsNullOrEmpty(iconUrl)) { return("<div style=\"text-align:center;\"><img alt=\"" + statusText + "\" title=\"" + statusText + "\" src=\"" + HTMLHelper.HTMLEncode(GetImageUrl(iconUrl)) + "\" style=\"max-width:50px; max-height: 50px;\" /></div>"); } return(""); case "ownerfullname": row = (DataRowView)parameter; string userName = ValidationHelper.GetString(row["ProjectOwnerUserName"], String.Empty); string fullName = ValidationHelper.GetString(row["ProjectOwnerFullName"], String.Empty); return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(userName, fullName, IsLiveSite))); case "projectdeadline": DateTime dt = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (dt == DateTimeHelper.ZERO_TIME) { return(String.Empty); } return(TimeZoneMethods.ConvertDateTime(dt, this)); case "linkeddisplayname": row = (DataRowView)parameter; string displayName = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["ProjectDisplayName"], String.Empty)); string path = ValidationHelper.GetString(row["NodeAliasPath"], String.Empty); int projectId = ValidationHelper.GetInteger(row["ProjectID"], 0); if (!String.IsNullOrEmpty(path)) { string target = String.Empty; if (!String.IsNullOrEmpty(ProjectLinkTarget)) { target = " target=\"" + ProjectLinkTarget + "\" "; } path = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(path)); return(String.Format("<a href=\"{1}?projectid={2}\" {3} title=\"{4}\">{0}</a>", TextHelper.LimitLength(displayName, MAX_TITLE_LENGTH), path, projectId, target, HTMLHelper.HTMLEncode(displayName))); } else { return(displayName); } case "editlinkdisplayname": row = (DataRowView)parameter; string editDisplayName = ValidationHelper.GetString(row["ProjectDisplayName"], String.Empty); editDisplayName = TextHelper.LimitLength(editDisplayName, MAX_TITLE_LENGTH); int editProjectTaskID = ValidationHelper.GetInteger(row["ProjectID"], 0); return(String.Format("<a href=\"javascript:" + ControlsHelper.GetPostBackEventReference(this, editProjectTaskID.ToString()) + "\" title=\"{0}\">{1}</a>", HTMLHelper.HTMLEncode(editDisplayName), HTMLHelper.HTMLEncode(TextHelper.LimitLength(editDisplayName, MAX_TITLE_LENGTH)))); } return(parameter); }
/// <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 = TimeZoneMethods.ConvertDateTime(fpi.PostTime, this).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 #region "Extended actions" if ((EnableFriendship || EnableMessaging) && (fpi.PostUserID > 0)) { GenerateActionScripts = true; ltlActions.Text = "<div class=\"PostExtendedActions\">"; if (EnableMessaging) { ltlActions.Text += "<a class=\"SendMessage\" onclick=\"PrivateMessage(" + fpi.PostUserID + "); return false;\" title=\"" + GetString("sendmessage.sendmessage") + "\" href=\"#\"><span>" + GetString("sendmessage.sendmessage") + "</span></a>"; } if (EnableFriendship) { ltlActions.Text += "<a class=\"Friendship\" onclick=\"FriendshipRequest(" + fpi.PostUserID + "); return false;\" title=\"" + GetString("friends.requestfriendship") + "\" href=\"#\"><span>" + GetString("friends.requestfriendship") + "</span></a>"; } ltlActions.Text += "</div>"; } #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); }