protected void Page_Load(object sender, EventArgs e) { if (Post == null) { return; } PageBase page = (PageBase)Page; PostPanel.CssClass = this.CssClass; if (Post is ReplyInfo) { ReplyInfo reply = (ReplyInfo)Post; popuplink.Text = String.Format("<a href='{0}' title='{1}'>{2}</a>", reply.AuthorProfileLink, String.Format(Resources.webResources.lblViewProfile, reply.AuthorName), reply.AuthorName); AuthorProfile.AuthorId = reply.AuthorId; msgBody.Text = reply.Message.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); editedByLbl.Text = String.Format("Edited by {0} - ", reply.EditorName); litEditDate.Text = SnitzTime.TimeAgoTag(reply.LastEditDate, page.IsAuthenticated, page.Member); sigDiv.Visible = Config.AllowSignatures && reply.AuthorViewSig && reply.UseSignatures && !String.IsNullOrEmpty(reply.AuthorSignature); litSig.Text = reply.AuthorSignature; editbyDiv.Visible = (reply.LastEditDate.HasValue && reply.LastEditDate.Value != DateTime.MinValue) && Config.ShowEditBy; } buttonBar.ReplyDeleteClicked += ReplyDeleteClicked; hypGoUp.Visible = Alternate; }
private void PopulateData() { int activemembers = new SnitzMembershipProvider().GetNumberOfUsersOnline(); int totalsessions = Convert.ToInt32(Application["SessionCount"]); int dailySessions = Convert.ToInt32(Application["DailyCount"]); var dSession = String.Format("{0} visitor(s) today", dailySessions); int anonusers = totalsessions - activemembers; GetCounts(); if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name)) { lblLastVisit.Text = webResources.lblStatsLastVisit; lblLastVisit.Text += SnitzTime.TimeAgoTag(_page.LastVisitDateTime, true, _page.Member); } else { lblLastVisit.Visible = false; } string newmemberlink = String.Format(PROFILE_URL, _stats.NewestMember, String.Format(webResources.lblViewProfile, _stats.NewestMember)); lblNewestMember.Text = string.Format(webResources.lblStatsNewMember, newmemberlink); lblMemberStats.Text = string.Format(webResources.lblStatsMembers, _activeMembers, Common.TranslateNumerals(_memberCount), Common.TranslateNumerals(_totalPostCount), GetLastPost(), GetLastPostAuthor()); lblTopicStats.Text = string.Format(webResources.lblStatsTopics, Common.TranslateNumerals(_topicCount), _stats.ActiveTopicCount); lblArchiveStats.Text = string.Format(webResources.lblStatsArchive, Common.TranslateNumerals(_archiveTopicCount + _archiveReplyCount), Common.TranslateNumerals(_archiveTopicCount)); lblActiveSessions.Text = extras.GuestLabel + anonusers; string[] onlineusers = new SnitzMembershipProvider().GetOnlineUsers(); var remains = onlineusers.Except(Config.AnonMembers); lblActiveUsers.Text = string.Format(webResources.lblStatsMembersOnline, String.Join(",", remains.ToArray())) + "<br/>" + dSession; }
protected void BindRepeater(object sender, RepeaterItemEventArgs e) { Literal test = (Literal)e.Item.FindControl("lastposttime"); if (test != null) { test.Text = SnitzTime.TimeAgoTag(((TopicInfo)e.Item.DataItem).LastPostDate, ThisPage.IsAuthenticated, ThisPage.Member); } }
protected void Page_Load(object sender, EventArgs e) { if (!Request.Path.EndsWith("register.aspx")) { PageBase page = (PageBase)Page; login = (System.Web.UI.WebControls.Login)LoginView1.FindControl("Login1"); if (HttpContext.Current.User.Identity.IsAuthenticated) { LoginName Lname = (LoginName)LoginView1.FindControl("ln2"); Literal lit = (Literal)LoginView1.FindControl("Literal1"); string separator = _skinid == "LoginTop" ? @" " : @"<br/>"; lit.Text = separator; string lastloggedOn = SnitzTime.TimeAgoTag(page.LastVisitDateTime, page.IsAuthenticated, page.Member); if (Lname != null) { Lname.FormatString = String.Format(Resources.webResources.lblLoggedOn, HttpContext.Current.User.Identity.Name, separator, lastloggedOn); } } else { if (login != null) { Label uL = (Label)login.FindControl("UserNameLabel"); if (uL != null) { uL.Text = Resources.webResources.lblUsername; } uL = (Label)login.FindControl("PasswordLabel"); if (uL != null) { uL.Text = Resources.webResources.lblPassword; } CheckBox cbx = (CheckBox)login.FindControl("RememberMe"); if (cbx != null) { cbx.Text = Resources.webResources.lblRememberMe; } } } if (login != null) { RequiredFieldValidator rfv1 = (RequiredFieldValidator)login.FindControl("UserNameRequired"); rfv1.Text = Resources.webResources.ErrNoUsername; RequiredFieldValidator rfv2 = (RequiredFieldValidator)login.FindControl("PasswordRequired"); rfv2.Text = Resources.webResources.ErrNoPassword; } } }
protected void Page_Load(object sender, EventArgs e) { if (Post == null) { return; } PageBase page = (PageBase)Page; PostPanel.CssClass = this.CssClass; TopicInfo topic = (TopicInfo)Post; lblSubject.Text = topic.Subject; msgBody.Text = topic.Message.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); litDate.Text = SnitzTime.TimeAgoTag(topic.Date, page.IsAuthenticated, page.Member); litAuthor.Text = topic.AuthorProfilePopup; ProfileCommon prof = ProfileCommon.GetUserProfile(topic.AuthorName); var author = Members.GetAuthor(topic.AuthorId); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = author.Email }; if (author.AvatarUrl != "" && author.AvatarUrl.StartsWith("http:")) { avatar.DefaultImage = author.AvatarUrl; } phAvatar.Controls.Add(avatar); } else { SnitzMembershipUser mu = (SnitzMembershipUser)Membership.GetUser(author.Username); Literal avatar = new Literal { Text = author.AvatarImg }; if (mu != null && mu.IsActive && !(Config.AnonMembers.Contains(mu.UserName))) { avatar.Text = avatar.Text.Replace("'avatar'", "'avatar online'"); } phAvatar.Controls.Add(avatar); } litViews.Text = String.Format("viewed {0} times", topic.Views); blgDay.Text = topic.Date.Day.ToString(); blgMonth.Text = topic.Date.ToString("MMM"); hBookmark.OnClientClick = "confirmBookMark('Do you want to bookmark this Blog entry?'," + topic.Id + ",-1);return false;"; hComments.Text = String.Format("{0} {1}", topic.ReplyCount, webResources.lblComments); }
private string GetLastPost() { const string url = "<a href=\"/Content/Forums/topic.aspx?TOPIC={0}&whichpage=-1#{1}\">{2}</a>"; TopicInfo lastpost = _stats.LastPost; if (lastpost == null) { return(String.Empty); } if (lastpost.LastPostDate != null) { string lastpostDate = SnitzTime.TimeAgoTag(lastpost.LastPostDate.Value, ((PageBase)Page).IsAuthenticated, _page.Member); return(String.Format(url, lastpost.Id, lastpost.LastReplyId, lastpostDate)); } return(String.Empty); }
protected void Page_Load(object sender, EventArgs e) { if (Post == null) { return; } PageBase page = (PageBase)Page; PostPanel.CssClass = this.CssClass; ReplyInfo reply = (ReplyInfo)Post; msgBody.Text = reply.Message.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); litDate.Text = SnitzTime.TimeAgoTag(reply.Date, page.IsAuthenticated, page.Member); litAuthor.Text = reply.AuthorProfilePopup; ProfileCommon prof = ProfileCommon.GetUserProfile(reply.AuthorName); var author = Members.GetAuthor(reply.AuthorId); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = author.Email }; if (author.AvatarUrl != "" && author.AvatarUrl.StartsWith("http:")) { avatar.DefaultImage = author.AvatarUrl; } avatar.CssClass = "avatar"; phAvatar.Controls.Add(avatar); } else { SnitzMembershipUser mu = (SnitzMembershipUser)Membership.GetUser(author.Username); Literal avatar = new Literal { Text = author.AvatarImg }; if (mu != null && mu.IsActive && !(Config.AnonMembers.Contains(mu.UserName))) { avatar.Text = avatar.Text.Replace("'avatar'", "'avatar online'"); } phAvatar.Controls.Add(avatar); } }
protected void ViewSentMessage(object sender, EventArgs e) { var lnk = (LinkButton)sender; PrivateMessageInfo pm = Snitz.BLL.PrivateMessages.GetMessage(Convert.ToInt32(lnk.CommandArgument)); pm.FromMember = Snitz.BLL.Members.GetMember(pm.FromMemberId); if (pm.FromMember.ProfileData != null && pm.FromMember.ProfileData.Gravatar == 1) { string avatar = String.Format("{0}/Avatars/{1}", Common.GetSiteRoot(), String.IsNullOrEmpty(pm.FromMember.Avatar) ? "default.gif" : pm.FromMember.Avatar); var gravatar = new Gravatar { Email = pm.FromMember.Email }; if (avatar != "") { gravatar.DefaultImage = avatar; } phAvatar.Controls.Add(gravatar); } else { var avatar = new Literal { Text = pm.FromMember.AvatarUrl }; phAvatar.Controls.Add(avatar); } PMViews.ActiveViewIndex = 2; pmRecipients.Text = "To: " + pm.ToMemberName; pmFrom.Text = String.Format("<a href=\"/Account/profile.aspx?user={0}\">{0}</a>", pm.FromMemberName); pmTitle.Text = pm.FromMember.Title; pmCountry.Text = pm.FromMember.Country; pmPostcount.Text = pm.FromMember.PostCount.ToString(); pmDate.Text = SnitzTime.TimeAgoTag(pm.Sent, true, pm.FromMember); pmSubject.Visible = true; pmSubject.Text = pm.Subject; pmBody.Text = pm.Message.ParseTags(); SetButtonDisplay(); ButtonReply.Visible = false; ButtonReplyQuote.Visible = false; ButtonForward.Visible = false; ButtonDelete.Visible = false; }
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; } }
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 RepForumItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; string imagedir = Config.ImageDirectory; if ((item.ItemType == ListItemType.Header)) { if (!IsAuthenticated) { var buttonColH = (HtmlTableCell)item.FindControl("adminBtnH"); var pCountH = (HtmlTableCell)item.FindControl("pCountH"); if (buttonColH != null) { buttonColH.Visible = false; pCountH.ColSpan = 2; } } } if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem)) { var forum = (ForumInfo)item.DataItem; var lockIcon = item.FindControl("ForumLock") as ImageButton; var unlockIcon = item.FindControl("ForumUnLock") as ImageButton; var delIcon = item.FindControl("ForumDelete") as ImageButton; var editIcon = item.FindControl("ForumEdit") as ImageButton; var subscribe = item.FindControl("ForumSub") as ImageButton; var unsubscribe = item.FindControl("ForumUnSub") as ImageButton; var empty = item.FindControl("ForumEmpty") as ImageButton; var archive = item.FindControl("ArchiveForum") as ImageButton; var newIcon = item.FindControl("hypNewTopic") as HyperLink; var viewarchive = item.FindControl("hypViewArchive") as HyperLink; var popuplink = item.FindControl("popuplink") as Literal; var ldate = (Literal)item.FindControl("lDate"); var iconPh = (PlaceHolder)item.FindControl("Ticons"); var imgLastPost = (Image)item.FindControl("imgLastPost"); var repeater = (RepeaterItem)item.Parent.Controls[0]; var header = repeater.FindControl("fTableHeader"); if (imgLastPost != null) { imgLastPost.ImageUrl = imagedir + "page_go.png"; } if (forum.Type == 1) //External link { header.Visible = false; var link = (HyperLink)item.FindControl("forumLink"); var linkcol = (HtmlTableCell)item.FindControl("linkCol"); var tCount = (HtmlTableCell)item.FindControl("tCount"); var pCount = (HtmlTableCell)item.FindControl("pCount"); var lastpost = (HtmlTableCell)item.FindControl("lastpost"); var buttonCol = (HtmlTableCell)item.FindControl("adminBtn"); link.NavigateUrl = forum.Url; link.Target = "_blank"; linkcol.ColSpan = 4; tCount.Visible = false; pCount.Visible = false; lastpost.Visible = false; archive.Visible = false; if (iconPh != null) { var img = new Image { ID = "imgTopicIcon", ImageUrl = imagedir + "message/weblink.png", AlternateText = "", EnableViewState = false }; iconPh.Controls.Add(img); } if (!IsAuthenticated) { buttonCol.Visible = false; linkcol.ColSpan = 5; return; } } header.Visible = true; if (ldate != null) { var offset = 0.0; if (Member != null) { offset = Member.TimeOffset; } if (forum.LastPostDate.HasValue && !(forum.LastPostDate.Value == DateTime.MinValue)) { ldate.Text = SnitzTime.TimeAgoTag(forum.LastPostDate.Value, IsAuthenticated, Member); } } bool isForumModerator = Moderators.IsUserForumModerator(HttpContext.Current.User.Identity.Name, forum.Id); if (popuplink != null) { string title = String.Format(webResources.lblViewProfile, "$1"); popuplink.Text = forum.LastPostAuthorId != null?Regex.Replace(forum.LastPostAuthorPopup, @"\[!(.*)!]", title) : ""; } if (archive != null) { archive.Visible = archive.Visible && (forum.Type != 1) && Config.Archive; archive.ImageUrl = imagedir + "/admin/archive.png"; archive.OnClientClick = "confirmPostBack('Do you want to archive posts in this Forum?','ForumArchive'," + forum.Id + ");return false;"; } if (IsAuthenticated) { if (subscribe != null) { subscribe.ImageUrl = imagedir + "/admin/subscribe.png"; subscribe.Visible = IsAuthenticated && forum.SubscriptionLevel == (int)Enumerators.Subscription.ForumSubscription; subscribe.Visible = subscribe.Visible && (forum.Type != 1); subscribe.OnClientClick = "confirmForumSubscribe('Do you want to subscribe to new posts in the Forum?'," + forum.Id + ",false);return false;"; } if (unsubscribe != null) { unsubscribe.Visible = false; unsubscribe.ImageUrl = imagedir + "/admin/unsubscribe.png"; if (subscribe.Visible) { if (Members.IsSubscribedToForum(Member.Id, forum.Id)) { subscribe.Visible = false; unsubscribe.Visible = true; } } unsubscribe.Visible = unsubscribe.Visible && (forum.Type != 1); unsubscribe.OnClientClick = "confirmForumSubscribe('Do you want to remove your subscription for this Forum?'," + forum.Id + ",true);return false;"; } if (newIcon != null) { newIcon.Visible = IsAuthenticated; newIcon.ImageUrl = imagedir + "/admin/document.png"; newIcon.Visible = newIcon.Visible && forum.Status != (int)Enumerators.PostStatus.Closed; newIcon.Visible = newIcon.Visible || (IsAdministrator || isForumModerator); newIcon.NavigateUrl = string.Format("~/Content/Forums/post.aspx?method=topic&FORUM={0}&CAT={1}", forum.Id, forum.CatId); newIcon.Visible = newIcon.Visible && (forum.Type != 1); } if (viewarchive != null) { viewarchive.ImageUrl = imagedir + "/admin/newwindow.png"; viewarchive.Visible = forum.ArchivedTopicCount > 0; viewarchive.NavigateUrl = string.Format("~/Content/Forums/forum.aspx?FORUM={0}&ARCHIVE=1", forum.Id); viewarchive.Visible = viewarchive.Visible && (forum.Type != 1); } if (lockIcon != null) { lockIcon.ImageUrl = imagedir + "/admin/lock.png"; lockIcon.Visible = ((IsAdministrator || isForumModerator) && (forum.Status == (int)Enumerators.PostStatus.Open)); lockIcon.Visible = lockIcon.Visible && (forum.Type != 1); lockIcon.OnClientClick = "confirmPostBack('Do you want to lock the Forum?','ForumLock'," + forum.Id + ");return false;"; } if (unlockIcon != null) { unlockIcon.ImageUrl = imagedir + "/admin/unlock.png"; unlockIcon.Visible = ((IsAdministrator || isForumModerator) && (forum.Status == (int)Enumerators.PostStatus.Closed)); unlockIcon.Visible = unlockIcon.Visible && (forum.Type != 1); unlockIcon.OnClientClick = "confirmPostBack('Do you want to unlock the Forum?','ForumUnLock'," + forum.Id + ");return false;"; } if (delIcon != null) { delIcon.ImageUrl = imagedir + "/admin/trash.png"; delIcon.Visible = IsAdministrator; delIcon.OnClientClick = "confirmPostBack('Do you want to delete the Forum?','ForumDelete'," + forum.Id + ");return false;"; } if (editIcon != null) { editIcon.ImageUrl = imagedir + "/admin/properties.png"; editIcon.OnClientClick = string.Format( "mainScreen.LoadServerControlHtml('Edit Properties',{{'pageID':8,'data':'{0},{1},{2}'}}, 'methodHandlers.BeginRecieve');return false;", forum.Id, forum.CatId, forum.Type); editIcon.Visible = (IsAdministrator || isForumModerator); } if (empty != null) { empty.ImageUrl = imagedir + "/admin/folderX.png"; empty.Visible = empty.Visible && (forum.Type != 1); empty.OnClientClick = "confirmPostBack('Do you want to delete all the posts in the Forum?','ForumEmpty'," + forum.Id + ");return false;"; } } else { var buttonCol = (HtmlTableCell)item.FindControl("adminBtn"); var pCount = (HtmlTableCell)item.FindControl("pCount"); buttonCol.Visible = false; pCount.ColSpan = 2; } } }
private void SetUpButtons() { if (Post == null) { return; } string modtext = ""; TopicApprove.Visible = false; //TopicHold.Visible = false; hReplyQuote.Visible = false; hEdit.Visible = false; ViewIP.Visible = false; TopicDelete.Visible = false; SplitTopic.Visible = false; PageBase page = (PageBase)Page; bool _isadmin = page.IsAdministrator; bool newerreplies = false; _topicid = page.TopicId != null ? page.TopicId.Value : Convert.ToInt32(Session["TOPIC"]); _topic = Topics.GetTopic(_topicid); _isTopicLocked = _topic.Status == (int)Enumerators.PostStatus.Closed; _forum = Forums.GetForum(_topic.ForumId); _topicid = _topic.Id; bool _isForumModerator = Moderators.IsUserForumModerator(HttpContext.Current.User.Identity.Name, _forum.Id); if (_post is TopicInfo) { if (Cache["M" + _topic.AuthorId] == null) { _author = Members.GetAuthor(_topic.AuthorId); Cache.Insert("M" + _topic.AuthorId, _author, null, DateTime.Now.AddMinutes(10d), System.Web.Caching.Cache.NoSlidingExpiration); } else { _author = (AuthorInfo)Cache["M" + _topic.AuthorId]; } ThisId = _topic.Id; if (_topic.ReplyCount > 0) { newerreplies = true; } _posttype = "TOPICS"; _postdate = _topic.Date; _ip = _topic.PosterIp; if (_isadmin || _isForumModerator) { TopicApprove.Visible = (_topic.Status == (int)Enumerators.PostStatus.UnModerated || _topic.Status == (int)Enumerators.PostStatus.OnHold); TopicApprove.OnClientClick = string.Format( "mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1}'}}, 'methodHandlers.BeginRecieve');return false;", false, _topic.Id); //TopicHold.Visible = _topic.Status == Enumerators.PostStatus.UnModerated; } if (_topic.Status == (int)Enumerators.PostStatus.UnModerated || _topic.Status == (int)Enumerators.PostStatus.OnHold) { _unmoderated = true; modtext = String.Format("<span class=\"moderation\">{0}</span>", webResources.lblRequireModeration); if (_topic.Status == (int)Enumerators.PostStatus.OnHold) { modtext = String.Format("<span class=\"moderation\">!!{0}!!</span>", webResources.OnHold); } } SplitTopic.Visible = false; hEdit.Text = webResources.lblEditTopic; hEdit.ToolTip = webResources.lblEditTopic; TopicDelete.AlternateText = webResources.lblDelTopic; TopicDelete.OnClientClick = "confirmPostBack('Do you want to delete the Topic?','DeleteTopic'," + ThisId + ");return false;"; imgPosticon.OnClientClick = "confirmBookMark('Do you want to bookmark the Topic?'," + ThisId + ",-1); return false;"; } else if (_post is ReplyInfo) { ReplyInfo reply = (ReplyInfo)_post; _author = Members.GetAuthor(reply.AuthorId); ThisId = reply.Id; if (_topic.LastReplyId != reply.Id) { newerreplies = true; } _posttype = "REPLY"; _postdate = reply.Date; _ip = reply.PosterIp; if (_isadmin || _isForumModerator) { TopicApprove.Visible = (reply.Status == (int)Enumerators.PostStatus.UnModerated || reply.Status == (int)Enumerators.PostStatus.OnHold); TopicApprove.OnClientClick = string.Format( "mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1},{2}'}}, 'methodHandlers.BeginRecieve');return false;", false, "", reply.Id); //TopicHold.Visible = reply.Status == Enumerators.PostStatus.UnModerated; } if (reply.Status == (int)Enumerators.PostStatus.UnModerated || reply.Status == (int)Enumerators.PostStatus.OnHold) { _unmoderated = true; modtext = String.Format("<span class=\"moderation\">{0}</span>", webResources.lblRequireModeration); if (reply.Status == (int)Enumerators.PostStatus.OnHold) { modtext = String.Format("<span class=\"moderation\">!!{0}!!</span>", webResources.OnHold); } } TopicDelete.AlternateText = webResources.lblDelReply; SplitTopic.CommandArgument = ThisId.ToString(); hEdit.ToolTip = webResources.lblEditReply; hEdit.Text = webResources.lblEditReply; TopicDelete.OnClientClick = "confirmPostBack('Do you want to delete the Reply?','DeleteReply'," + ThisId + ");return false;"; imgPosticon.OnClientClick = "confirmBookMark('Do you want to bookmark the Reply?'," + ThisId + "," + page.CurrentPage + ");return false;"; SplitTopic.Visible = _isForumModerator || _isadmin; SplitTopic.OnClientClick = String.Format( "mainScreen.LoadServerControlHtml('Split Topic',{{'pageID':6,'data':'{0},asc'}}, 'methodHandlers.BeginRecieve');return false;", reply.Id); } TopicDelete.Visible = (currentUser.ToLower() == _author.Username.ToLower() && !newerreplies); TopicDelete.Visible = TopicDelete.Visible || (_isForumModerator || _isadmin); imgPosticon.AlternateText = String.Format("#{0}", ThisId); date.Text = _unmoderated ? modtext : SnitzTime.TimeAgoTag(_postdate, page.IsAuthenticated, page.Member); ViewIP.Visible = _isadmin && Config.LogIP; ViewIP.OnClientClick = string.Format( "mainScreen.LoadServerControlHtml('IP Lookup',{{'pageID':4,'data':'{0}'}}, 'methodHandlers.BeginRecieve');return false;", _ip); hEdit.NavigateUrl = string.Format("~/Content/Forums/post.aspx?method=edit&type={0}&id={1}&TOPIC={2}", _posttype, ThisId, _topicid); hEdit.Visible = (currentUser.ToLower() == _author.Username.ToLower() && !newerreplies); hEdit.Visible = hEdit.Visible && !(_isTopicLocked || _forum.Status == (int)Enumerators.PostStatus.Closed); // but not if it is locked hEdit.Visible = hEdit.Visible || _isForumModerator || _isadmin; //override for admins/moderator hReplyQuote.Visible = page.IsAuthenticated && !(_isTopicLocked || _forum.Status == (int)Enumerators.PostStatus.Closed); hReplyQuote.Visible = hReplyQuote.Visible || (_isForumModerator || _isadmin); hReplyQuote.NavigateUrl = String.Format("~/Content/Forums/post.aspx?method=quote&type={0}&id={1}&TOPIC={2}", _posttype, ThisId, _topicid); }