示例#1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (Session["CurrentProfile"] != null)
                Session.Remove("CurrentProfile");
            ForumTable.PageSize = Config.TopicPageSize;

            if (ForumId != null)
            {
                IsForumModerator = Moderators.IsUserForumModerator(HttpContext.Current.User.Identity.Name, ForumId.Value);
                RowCount = Forums.GetForum(ForumId.Value).TopicCount;
            }
            if (IsAdministrator || IsForumModerator)
            {
                ddlShowTopicDays.Items.Add(new ListItem("Unmoderated Posts", "999"));
            }
            if (stickystate.Value != "")
                Collapsed = stickystate.Value;

            _topicPager = (GridPager)LoadControl("~/UserControls/GridPager.ascx");
            _topicPager.PagerStyle = Enumerators.PagerType.Linkbutton;
            _topicPager.UserControlLinkClick += PagerLinkClick;
            _topicPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.MemberPageSize);

            topicUPD.Triggers.Add(new AsyncPostBackTrigger {ControlID = ddlShowTopicDays.UniqueID, EventName="SelectedIndexChanged"});
            if (Request.QueryString["ARCHIVE"] != null)
            {
                if (Request.QueryString["ARCHIVE"] == "1")
                {
                    TopicODS.TypeName = "Snitz.BLL.Archive";
                    _archiveView = 1;
                }
            }
            else
            {
                TopicODS.TypeName = "Snitz.BLL.Forums";
                _archiveView = 0;
            }
            if (Config.TopicAvatar)
            {
                FolderImg.Visible = false;
            }
        }
示例#2
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     CurrentPage = 0;
     if (Session["CurrentProfile"] != null)
         Session.Remove("CurrentProfile");
     Page.Title = string.Format(webResources.ttlSearchPage, Config.ForumTitle);
     if (webResources.TextDirection == "rtl")
         pageCSS.Attributes.Add("href", "/css/" + Page.Theme + "/searchrtl.css");
     else
         pageCSS.Attributes.Add("href", "/css/" + Page.Theme + "/search.css");
     tbxDateCalendarExtender.Format = Config.DateFormat;
     ddlForum.DataSource = SnitzCachedLists.GetCachedForumList(true);
     ddlForum.DataTextField = "Name";
     ddlForum.DataValueField = "Id";
     ddlForum.DataBind();
     //Grid pager setup
     _replyPager = (GridPager)LoadControl("~/UserControls/GridPager.ascx");
     _replyPager.PagerStyle = Enumerators.PagerType.Linkbutton;
     _replyPager.UserControlLinkClick += PagerLinkClick;
 }
示例#3
0
        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;
            }
        }
示例#4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.PageScriptManager.Services.Add(new ServiceReference("~/CommonFunc.asmx"));
            if (Session["CurrentProfile"] != null)
                Session.Remove("CurrentProfile");
            editorCSS.Attributes.Add("href", "/css/" + Page.Theme + "/editor.css");
            jsshareCSS.Attributes.Add("href", "/css/" + Page.Theme + "/jsShare.css");

            if (TopicId == null)
                throw new HttpException(404, "Topic not found");

            if (Request.QueryString["ARCHIVE"] != null)
            {
                if (Request.QueryString["ARCHIVE"] == "1")
                {
                    ArchiveView = 1;
                }
            }
            else
            {
                ArchiveView = 0;
            }
            try
            {
                if (TopicId != null)
                {
                    if (Session["TOPIC"] == null)
                        Session.Add("TOPIC", TopicId);
                    else
                        Session["TOPIC"] = TopicId;

                    string skip = "";
                    if (!String.IsNullOrEmpty(Request.Params["dir"]))
                    {
                        skip = Request.Params["dir"];
                    }
                    _topic = Topics.GetTopic(TopicId.Value);
                    _forum = Forums.GetForum(_topic.ForumId);
                    if (_forum.Type == (int) Enumerators.ForumType.BlogPosts)
                    {
                        MinWeblog.MemberId = _topic.AuthorId;
                        MinWeblog.ForumId = _topic.ForumId;
                        MinWeblog.Visible = true;
                    }
                    else
                    {
                        MinWeblog.Visible = false;
                    }
                    if (skip != "")
                    {
                        _topic = Topics.GetNextPrevTopic(_topic.Id, skip);
                        TopicId = _topic.Id;
                    }
                    _topic.Author = Members.GetAuthor(_topic.AuthorId);
                    //Grid pager setup
                    ReplyPager = (GridPager) LoadControl("~/UserControls/GridPager.ascx");
                    ReplyPager.PagerStyle = Enumerators.PagerType.Linkbutton;
                    ReplyPager.UserControlLinkClick += PagerLinkClick;
                    RowCount = _topic.ReplyCount;
                    ReplyPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.TopicPageSize);

                    Page.Title = string.Format(webResources.ttlTopicPage, _topic.Subject.CleanForumCodeTags(), Config.ForumTitle);
                    string pagedescription = _topic.Message.CleanForumCodeTags();
                    metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", HttpUtility.HtmlEncode(pagedescription.Substring(0, Math.Min(160, pagedescription.Length))));

                }
            }
            catch (Exception)
            {
                throw new HttpException(404, "Topic not found");
            }

            var meta = new HtmlMeta();
            meta.Attributes.Add("name", "description");
            meta.Attributes.Add("content", _topic.Subject);
            Page.Header.Controls.Add(meta);

            if (User.Identity.IsAuthenticated)
            {
                if ((Config.ShowQuickReply && _topic.Status != (int)Enumerators.PostStatus.Closed && _topic.Forum.Status != (int)Enumerators.PostStatus.Closed) || IsAdministrator)
                {
                    var qr = (QuickReply)Page.LoadControl("~/UserControls/QuickReply.ascx"); //loading the user control dynamically
                    qr.thisTopic = _topic;
                    QRPlaceHolder.Controls.Add(qr);
                }
            }
            PopulateObject populate = PopulateData;
            ReplyPager.UpdateIndex = populate;
            pager.Controls.Add(ReplyPager);
        }