protected void ActiveTableRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { var markRead = new ImageButton { SkinID = "MarkRead", ToolTip = webResources.lblMarkAllRead }; markRead.ApplyStyleSheetSkin(Page); markRead.Click += MarkReadClick; e.Row.Cells[0].Controls.Add(markRead); if (_currentUser == "") { e.Row.Cells.RemoveAt(5); } } else if (e.Row.RowType == DataControlRowType.Pager) { _replyPager = (GridPager)e.Row.FindControl("pager"); _replyPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.TopicPageSize); _replyPager.CurrentIndex = CurrentPage; } else if (e.Row.RowType == DataControlRowType.DataRow) { var topic = (TopicInfo)e.Row.DataItem; var lockIcon = e.Row.Cells[3].FindControl("TopicLock") as ImageButton; var unlockIcon = e.Row.Cells[3].FindControl("TopicUnLock") as ImageButton; var delIcon = e.Row.Cells[3].FindControl("TopicDelete") as ImageButton; var subscribe = e.Row.Cells[3].FindControl("TopicSub") as ImageButton; var unsubscribe = e.Row.Cells[3].FindControl("TopicUnSub") as ImageButton; var approve = e.Row.Cells[3].FindControl("TopicApprove") as ImageButton; var editIcon = e.Row.Cells[3].FindControl("hypEditTopic") as HyperLink; var replyIcon = e.Row.Cells[3].FindControl("hypReplyTopic") as HyperLink; var newIcon = e.Row.Cells[3].FindControl("hypNewTopic") as HyperLink; var popuplink = e.Row.Cells[1].FindControl("popuplink") as Literal; var lastpost = e.Row.Cells[1].FindControl("lpLnk") as HyperLink; var postdate = e.Row.Cells[1].FindControl("postdate") as Literal; 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 (lastpost != null) { lastpost.Text = SnitzTime.TimeAgoTag(((TopicInfo)e.Row.DataItem).LastPostDate, IsAuthenticated, Member, webResources.lblLastPostJump); } int replyCount = topic.ReplyCount; int topicId = topic.Id; int forumId = topic.ForumId; int catId = topic.CatId; string authorName = topic.AuthorName; bool inModeratedList = Moderators.IsUserForumModerator(_currentUser, forumId); if (lockIcon != null) { lockIcon.Visible = (IsAdministrator || inModeratedList); lockIcon.OnClientClick = "confirmPostBack('Do you want to lock the Topic?','LockTopic'," + topicId + ");return false;"; } if (delIcon != null) { delIcon.Visible = false; delIcon.OnClientClick = "confirmPostBack('Do you want to delete the Topic?','DeleteTopic'," + topicId + ");return false;"; } if (editIcon != null) { editIcon.Visible = false; } if (approve != null) { approve.Visible = false; if (topic.Status == (int)Enumerators.PostStatus.UnModerated || topic.Status == (int)Enumerators.PostStatus.OnHold) { approve.Visible = (inModeratedList || IsAdministrator); } approve.OnClientClick = string.Format("mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1}'}}, 'methodHandlers.BeginRecieve');return false;", true, topic.Id); } if (subscribe != null) { subscribe.Visible = IsAuthenticated; if (IsAuthenticated) { topic.Forum = Forums.GetForum(topic.ForumId); } subscribe.Visible = subscribe.Visible && topic.AllowSubscriptions; subscribe.OnClientClick = "confirmTopicSubscribe('Do you want to be notified when someone posts a reply?'," + topicId + ",false);return false;"; } if (unsubscribe != null) { unsubscribe.Visible = false; if (subscribe != null && subscribe.Visible) { if (Members.IsSubscribedToTopic(topic.Id, Member == null ? 0 : Member.Id)) { subscribe.Visible = false; unsubscribe.Visible = true; } } unsubscribe.OnClientClick = "confirmTopicSubscribe('Do you want to remove notifications from topic?'," + topicId + ",true);return false;"; } if (Config.TopicAvatar) { e.Row.Cells[0].Controls.Add(GetTopicAuthorIcon(topic.AuthorId)); } e.Row.Cells[0].Controls.Add(GetRecentTopicIcon(topic, replyCount)); if (newIcon != null) { newIcon.Visible = false; } if (lockIcon != null) { lockIcon.Visible = ((IsAdministrator || inModeratedList) && (topic.Status != (int)Enumerators.PostStatus.Closed)); } if (unlockIcon != null) { unlockIcon.Visible = ((IsAdministrator || inModeratedList) && (topic.Status == (int)Enumerators.PostStatus.Closed)); unlockIcon.OnClientClick = "confirmPostBack('Do you want to unlock the Topic?','UnLockTopic'," + topicId + ");return false;"; } if (replyIcon != null) { replyIcon.NavigateUrl = string.Format("/Content/Forums/post.aspx?method=reply&TOPIC={0}&FORUM={1}&CAT={2}", topicId, forumId, catId); } if (topic.Status == (int)Enumerators.PostStatus.Closed || !IsAuthenticated) { if (replyIcon != null) { replyIcon.Visible = false; } } if (IsAdministrator || inModeratedList) { if (replyIcon != null) { replyIcon.Visible = true; } } if (IsAdministrator || inModeratedList) { if (delIcon != null) { delIcon.Visible = true; } if (editIcon != null) { editIcon.Visible = true; } } else if (_currentUser.ToLower() == authorName.ToLower()) { if (replyCount == 0) { if (delIcon != null) { delIcon.Visible = true; } } if (editIcon != null) { editIcon.Visible = true; } } if (editIcon != null) { editIcon.NavigateUrl = string.Format("/Content/Forums/post.aspx?method=edit&type=TOPICS&id={0}&FORUM={1}&CAT={2}", topicId, forumId, catId); } if (_currentUser == "") { if (e.Row.Cells.Count > 2) { e.Row.Cells.RemoveAt(5); //e.Row.Cells[5].ColumnSpan +=1; } } } }
protected void ActiveTableRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { var markRead = new ImageButton { SkinID = "MarkRead", ToolTip = webResources.lblMarkAllRead }; markRead.ApplyStyleSheetSkin(Page); markRead.Click += MarkReadClick; e.Row.Cells[0].Controls.Add(markRead); if (_currentUser == "") { e.Row.Cells.RemoveAt(5); } } else if (e.Row.RowType == DataControlRowType.Pager) { _replyPager = (GridPager)e.Row.FindControl("pager"); _replyPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.TopicPageSize); _replyPager.CurrentIndex = CurrentPage; } else if (e.Row.RowType == DataControlRowType.DataRow) { var topic = (TopicInfo)e.Row.DataItem; var lockIcon = e.Row.Cells[3].FindControl("TopicLock") as ImageButton; var unlockIcon = e.Row.Cells[3].FindControl("TopicUnLock") as ImageButton; var delIcon = e.Row.Cells[3].FindControl("TopicDelete") as ImageButton; var subscribe = e.Row.Cells[3].FindControl("TopicSub") as ImageButton; var unsubscribe = e.Row.Cells[3].FindControl("TopicUnSub") as ImageButton; var approve = e.Row.Cells[3].FindControl("TopicApprove") as ImageButton; var editIcon = e.Row.Cells[3].FindControl("hypEditTopic") as HyperLink; var replyIcon = e.Row.Cells[3].FindControl("hypReplyTopic") as HyperLink; var newIcon = e.Row.Cells[3].FindControl("hypNewTopic") as HyperLink; var popuplink = e.Row.Cells[1].FindControl("popuplink") as Literal; var lastpost = e.Row.Cells[1].FindControl("lpLnk") as HyperLink; var postdate = e.Row.Cells[1].FindControl("postdate") as Literal; 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 (lastpost != null) { lastpost.Text = SnitzTime.TimeAgoTag(((TopicInfo)e.Row.DataItem).LastPostDate, IsAuthenticated, Member, webResources.lblLastPostJump); } int replyCount = topic.ReplyCount; int topicId = topic.Id; int forumId = topic.ForumId; int catId = topic.CatId; string authorName = topic.AuthorName; bool inModeratedList = Moderators.IsUserForumModerator(_currentUser, forumId); if (lockIcon != null) { lockIcon.Visible = (IsAdministrator || inModeratedList); lockIcon.OnClientClick = "confirmPostBack('Do you want to lock the Topic?','LockTopic'," + topicId + ");return false;"; } if (delIcon != null) { delIcon.Visible = false; delIcon.OnClientClick = "confirmPostBack('Do you want to delete the Topic?','DeleteTopic'," + topicId + ");return false;"; } if (editIcon != null) editIcon.Visible = false; if (approve != null) { approve.Visible = false; if (topic.Status == (int)Enumerators.PostStatus.UnModerated || topic.Status == (int)Enumerators.PostStatus.OnHold) approve.Visible = (inModeratedList || IsAdministrator); approve.OnClientClick = string.Format("mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1}'}}, 'methodHandlers.BeginRecieve');return false;", true, topic.Id); } if (subscribe != null) { subscribe.Visible = IsAuthenticated; if (IsAuthenticated) { topic.Forum = Forums.GetForum(topic.ForumId); } subscribe.Visible = subscribe.Visible && topic.AllowSubscriptions; subscribe.OnClientClick = "confirmTopicSubscribe('Do you want to be notified when someone posts a reply?'," + topicId + ",false);return false;"; } if (unsubscribe != null) { unsubscribe.Visible = false; if (subscribe != null && subscribe.Visible) { if (Members.IsSubscribedToTopic(topic.Id, Member == null ? 0 : Member.Id)) { subscribe.Visible = false; unsubscribe.Visible = true; } } unsubscribe.OnClientClick = "confirmTopicSubscribe('Do you want to remove notifications from topic?'," + topicId + ",true);return false;"; } if(Config.TopicAvatar) e.Row.Cells[0].Controls.Add(GetTopicAuthorIcon(topic.AuthorId)); e.Row.Cells[0].Controls.Add(GetRecentTopicIcon(topic, replyCount)); if (newIcon != null) newIcon.Visible = false; if (lockIcon != null) { lockIcon.Visible = ((IsAdministrator || inModeratedList) && (topic.Status != (int)Enumerators.PostStatus.Closed)); } if (unlockIcon != null) { unlockIcon.Visible = ((IsAdministrator || inModeratedList) && (topic.Status == (int)Enumerators.PostStatus.Closed)); unlockIcon.OnClientClick = "confirmPostBack('Do you want to unlock the Topic?','UnLockTopic'," + topicId + ");return false;"; } if (replyIcon != null) replyIcon.NavigateUrl = string.Format("/Content/Forums/post.aspx?method=reply&TOPIC={0}&FORUM={1}&CAT={2}", topicId, forumId, catId); if (topic.Status == (int)Enumerators.PostStatus.Closed || !IsAuthenticated) if (replyIcon != null) replyIcon.Visible = false; if (IsAdministrator || inModeratedList) if (replyIcon != null) replyIcon.Visible = true; if (IsAdministrator || inModeratedList) { if (delIcon != null) delIcon.Visible = true; if (editIcon != null) editIcon.Visible = true; } else if (_currentUser.ToLower() == authorName.ToLower()) { if (replyCount == 0) if (delIcon != null) delIcon.Visible = true; if (editIcon != null) editIcon.Visible = true; } if (editIcon != null) editIcon.NavigateUrl = string.Format("/Content/Forums/post.aspx?method=edit&type=TOPICS&id={0}&FORUM={1}&CAT={2}", topicId, forumId, catId); if (_currentUser == "") { if (e.Row.Cells.Count > 2) { e.Row.Cells.RemoveAt(5); //e.Row.Cells[5].ColumnSpan +=1; } } } }