protected void ForumTableRowDataBound(object sender, GridViewRowEventArgs e) { string currentUser = HttpContext.Current.User.Identity.Name; if (e.Row.RowType == DataControlRowType.DataRow) { var topic = (TopicInfo)e.Row.DataItem; topic.Forum = Forums.GetForum(topic.ForumId); topic.PollId = Topics.GetTopicPollId(topic.Id); if (Config.TopicAvatar) { e.Row.Cells[0].Controls.Add(GetTopicAuthorIcon(topic.AuthorId)); } e.Row.Cells[0].Controls.Add(GetTopicIcon(topic)); var stickyIcon = e.Row.Cells[ICONCOL].FindControl("Stick") as ImageButton; var unstickyIcon = e.Row.Cells[ICONCOL].FindControl("UnStick") as ImageButton; var lockIcon = e.Row.Cells[ICONCOL].FindControl("TopicLock") as ImageButton; var unlockIcon = e.Row.Cells[ICONCOL].FindControl("TopicUnLock") as ImageButton; var delIcon = e.Row.Cells[ICONCOL].FindControl("TopicDelete") as ImageButton; var approve = e.Row.Cells[ICONCOL].FindControl("TopicApprove") as ImageButton; var subscribe = e.Row.Cells[ICONCOL].FindControl("TopicSub") as ImageButton; var unsubscribe = e.Row.Cells[ICONCOL].FindControl("TopicUnSub") as ImageButton; var editIcon = e.Row.Cells[ICONCOL].FindControl("hypEditTopic") as HyperLink; var replyIcon = e.Row.Cells[ICONCOL].FindControl("hypReplyTopic") as HyperLink; var noArchiveIcon = e.Row.Cells[ICONCOL].FindControl("hypNoArchiveTopic") as HyperLink; var archiveIcon = e.Row.Cells[ICONCOL].FindControl("hypArchiveTopic") as HyperLink; var popuplink = e.Row.Cells[3].FindControl("popuplink") as Literal; var postdate = e.Row.Cells[3].FindControl("postdate") as Literal; var lastpostdate = e.Row.Cells[3].FindControl("lpLnk") as HyperLink; if (popuplink != null) { string title = String.Format(webResources.lblViewProfile, "$1"); popuplink.Text = topic.LastPostAuthorId != null?Regex.Replace(topic.LastPostAuthorPopup, @"\[!(.*)!]", title) : ""; } if (postdate != null) { postdate.Text = SnitzTime.TimeAgoTag(((TopicInfo)e.Row.DataItem).Date, IsAuthenticated, Member); } if (lastpostdate != null) { lastpostdate.Text = SnitzTime.TimeAgoTag(((TopicInfo)e.Row.DataItem).LastPostDate, IsAuthenticated, Member, webResources.lblLastPostJump); } if (subscribe != null) { subscribe.Visible = IsAuthenticated; subscribe.Visible = subscribe.Visible && topic.AllowSubscriptions; subscribe.OnClientClick = "confirmTopicSubscribe('Do you want to be notified when someone posts a reply?'," + topic.Id + ",false);return false;"; } if (unsubscribe != null) { unsubscribe.Visible = false; if (subscribe.Visible) { if (Members.IsSubscribedToTopic(topic.Id, Member.Id)) { subscribe.Visible = false; unsubscribe.Visible = true; } } unsubscribe.OnClientClick = "confirmTopicSubscribe('Do you want to remove notifications from topic?'," + topic.Id + ",true);return false;"; } if (stickyIcon != null) { stickyIcon.Visible = ((IsAdministrator || IsForumModerator) && (!topic.IsSticky) && _archiveView != 1); stickyIcon.OnClientClick = "confirmPostBack('Do you want to make the Topic sticky?','StickTopic'," + topic.Id + ");return false;"; } if (unstickyIcon != null) { unstickyIcon.Visible = ((IsAdministrator || IsForumModerator) && (topic.IsSticky) && _archiveView != 1); unstickyIcon.OnClientClick = "confirmPostBack('Do you want to un-stick the Topic?','UnStickTopic'," + topic.Id + ");return false;"; } if (lockIcon != null) { lockIcon.Visible = ((IsAdministrator || IsForumModerator) && (topic.Status != (int)Enumerators.PostStatus.Closed) && _archiveView != 1); lockIcon.OnClientClick = "confirmPostBack('Do you want to lock the Topic?','LockTopic'," + topic.Id + ");return false;"; } if (unlockIcon != null) { unlockIcon.Visible = ((IsAdministrator || IsForumModerator) && (topic.Status == (int)Enumerators.PostStatus.Closed) && _archiveView != 1); unlockIcon.OnClientClick = "confirmPostBack('Do you want to unlock the Topic?','UnLockTopic'," + topic.Id + ");return false;"; } if (replyIcon != null) { replyIcon.NavigateUrl = "/Content/Forums/post.aspx?method=reply&TOPIC_ID=" + topic.Id; } if (noArchiveIcon != null) { noArchiveIcon.Visible = IsAdministrator && (Topics.IsArchived(topic)) && _archiveView != 1; noArchiveIcon.NavigateUrl = "javascript:openConfirmDialog('pop_archive.aspx?archive=0&ID=" + topic.Id + "')"; } if (archiveIcon != null) { archiveIcon.Visible = IsAdministrator && (Topics.AllowArchive(topic)) && _archiveView != 1; archiveIcon.NavigateUrl = "javascript:openConfirmDialog('pop_archive.aspx?archive=1&ID=" + topic.Id + "')"; } if (delIcon != null) { delIcon.Visible = false; delIcon.OnClientClick = "confirmPostBack('Do you want to delete the Topic?','DeleteTopic'," + topic.Id + ");return false;"; } if (editIcon != null) { editIcon.NavigateUrl = "/Content/Forums/post.aspx?method=edit&type=TOPICS&id=" + topic.Id; editIcon.Visible = false; } if (approve != null) { approve.Visible = false; if (topic.Status == (int)Enumerators.PostStatus.UnModerated || topic.Status == (int)Enumerators.PostStatus.OnHold) { approve.Visible = (IsForumModerator || IsAdministrator); } approve.OnClientClick = string.Format("mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1}'}}, 'methodHandlers.BeginRecieve');return false;", true, topic.Id); } if (!IsAuthenticated) { if (replyIcon != null) { replyIcon.Visible = false; } } if (IsAdministrator || IsForumModerator) { if (replyIcon != null) { replyIcon.Visible = !topic.IsArchived; } if (delIcon != null) { delIcon.Visible = true; } if (editIcon != null) { editIcon.Visible = true; } } else if (topic.Status == (int)Enumerators.PostStatus.Closed || topic.Forum.Status == (int)Enumerators.PostStatus.Closed || topic.IsArchived) { if (replyIcon != null) { replyIcon.Visible = false; } if (delIcon != null) { delIcon.Visible = false; } if (editIcon != null) { editIcon.Visible = false; } } else if (currentUser.ToLower() == topic.AuthorName.ToLower()) { if (delIcon != null) { delIcon.Visible = (topic.ReplyCount == 0); } if (editIcon != null) { editIcon.Visible = true; } } if (currentUser == "") { e.Row.Cells.RemoveAt(ICONCOL); e.Row.Cells[ICONCOL - 1].ColumnSpan = 2; } } else if (e.Row.RowType == DataControlRowType.Header) { if (currentUser == "") { e.Row.Cells.RemoveAt(ICONCOL); e.Row.Cells[ICONCOL - 1].ColumnSpan = 2; } } else if (e.Row.RowType == DataControlRowType.Pager) { _topicPager = (GridPager)e.Row.FindControl("pager"); _topicPager.UpdateIndex = populate; _topicPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.TopicPageSize); _topicPager.CurrentIndex = CurrentPage; } }