Example #1
0
        public IEnumerable<ReplyInfo> GetByParent(TopicInfo topic, int start, int maxrecs)
        {
            string replytable = Config.ForumTablePrefix + "REPLY";
            if (topic.IsArchived)
                replytable = Config.ForumTablePrefix + "A_REPLY";
            List<ReplyInfo> topics = new List<ReplyInfo>();
            List<OleDbParameter> parms = new List<OleDbParameter>();

            StringBuilder over = new StringBuilder();
            over.AppendLine("FROM (((");
            over.AppendFormat("SELECT TOP {0} sub.REPLY_ID, sub.R_DATE ", maxrecs);
            over.AppendLine("FROM  (");
            over.AppendFormat(" SELECT TOP {0} REPLY_ID,R_DATE FROM {1} WHERE TOPIC_ID=@TopicId ORDER BY R_DATE desc", (Math.Max(topic.ReplyCount, maxrecs) - (start * maxrecs)),replytable).AppendLine();
            over.AppendLine(") sub ");
            over.AppendLine(" ORDER BY sub.R_DATE asc");
            over.AppendLine(") RE ");
            over.AppendFormat(" INNER JOIN {0} R on RE.REPLY_ID = R.REPLY_ID) ",replytable).AppendLine();
            over.AppendFormat("LEFT OUTER JOIN {0}MEMBERS EM ON R.R_LAST_EDITBY = EM.MEMBER_ID) ",Config.MemberTablePrefix).AppendLine();
            over.AppendFormat("LEFT OUTER JOIN {0}MEMBERS AS AM ON R.R_AUTHOR = AM.MEMBER_ID ",Config.MemberTablePrefix).AppendLine();

            parms.Add(new OleDbParameter("@TopicId", OleDbType.Numeric) { Value = topic.Id });
            //(TotRows - ((Page_Number - 1) * PageSize)

            using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, " SELECT " + REPLY_COLS + over, parms.ToArray()))
            {
                while (rdr.Read())
                {
                    topics.Add(BoHelper.CopyReplyToBO(rdr));
                }
            }
            return topics;
        }
Example #2
0
        public IEnumerable<ReplyInfo> GetByParent(TopicInfo topic, int start, int maxrecs)
        {
            start = start*maxrecs;

            string replytable = Config.ForumTablePrefix + "REPLY";
            if (topic.IsArchived)
                replytable = Config.ForumTablePrefix + "A_REPLY";

            List<ReplyInfo> topics = new List<ReplyInfo>();
            List<SqlParameter> parms = new List<SqlParameter>();
            string selectOver = "WITH ReplyEntities AS (SELECT ROW_NUMBER() OVER (ORDER BY R_DATE ASC) AS Row, REPLY_ID FROM " + replytable + " WHERE TOPIC_ID=@TopicId) ";
            string selectOverFrom =
                "FROM ReplyEntities RE INNER JOIN " + replytable + " R on RE.REPLY_ID = R.REPLY_ID " +
                "LEFT OUTER JOIN " + Config.MemberTablePrefix + "MEMBERS EM ON R.R_LAST_EDITBY = EM.MEMBER_ID " +
                "LEFT OUTER JOIN " + Config.MemberTablePrefix + "MEMBERS AS AM ON R.R_AUTHOR = AM.MEMBER_ID " +
                "WHERE RE.Row Between @Start AND @MaxRows ORDER BY RE.Row ASC";

            parms.Add(new SqlParameter("@TopicId", SqlDbType.Int) { Value = topic.Id });
            parms.Add(new SqlParameter("@Start", SqlDbType.Int) { Value = start + 1 });
            parms.Add(new SqlParameter("@MaxRows", SqlDbType.VarChar) { Value = start + maxrecs });

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, selectOver + " SELECT " + REPLY_COLS + selectOverFrom, parms.ToArray()))
            {
                while (rdr.Read())
                {
                    topics.Add(BoHelper.CopyReplyToBO(rdr));
                }
            }
            return topics;
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Data != null)
            {
                string[] data = Regex.Split(Data.ToString(), ",", RegexOptions.ExplicitCapture);
                _replyid = Convert.ToInt32(data[0]);
                ReplyInfo reply = Replies.GetReply(_replyid);
                int topicid = reply.TopicId;

                splitTopicId.Value = topicid.ToString();
                if (data.Length > 1)
                    _sortDirection = data[1];
                _topic = Topics.GetTopic(Convert.ToInt32(topicid));
                ddlForum.DataSource = Forums.GetAllForums();
                ddlForum.DataBind();
                if(!IsPostBack)
                    ddlForum.SelectedValue = _topic.ForumId.ToString();
                ddlSort.SelectedValue = _sortDirection;
                switch (_sortDirection)
                {
                    case "asc" :
                        ddlSort.Attributes.Add("onchange",String.Format(
                        "mainScreen.LoadServerControlHtml('Split Topic',{{'pageID':6,'data':'{0},desc'}}, 'methodHandlers.BeginRecieve');return false;", _replyid));
                        break;
                    case "desc" :
                        ddlSort.Attributes.Add("onchange", String.Format(
                        "mainScreen.LoadServerControlHtml('Split Topic',{{'pageID':6,'data':'{0},asc'}}, 'methodHandlers.BeginRecieve');return false;", _replyid));

                        break;
                }
                BindForm();
                StartupScript = "jQuery(\"abbr.timeago\").timeago();";
            }
        }
Example #4
0
        public int Add(TopicInfo topic)
        {
            StringBuilder insertSql = new StringBuilder();
            insertSql.AppendFormat("INSERT INTO {0}TOPICS",Config.ForumTablePrefix).AppendLine();
            insertSql.Append("(CAT_ID,FORUM_ID,T_STATUS,T_SUBJECT,T_MESSAGE,T_AUTHOR,T_LAST_POST_AUTHOR,T_REPLIES,T_VIEW_COUNT,T_DATE,T_LAST_POST,T_IP,T_STICKY,T_SIG,T_UREPLIES) VALUES ( ");
            insertSql.AppendLine("@CatId,");
            insertSql.AppendLine("@ForumId,");
            insertSql.AppendLine("@Status,");
            insertSql.AppendLine("@Subject,");
            insertSql.AppendLine("@Message,");
            insertSql.AppendLine("@AuthorId,");
            insertSql.AppendLine("@AuthorId,");
            insertSql.AppendLine("0,0,"); //reply + view count
            insertSql.AppendLine("@Date,");
            insertSql.AppendLine("@Date,");
            insertSql.AppendLine("@PostersIP,");
            insertSql.AppendLine("@Sticky,");
            insertSql.AppendLine("@UseSig,");
            insertSql.AppendLine("0 );"); //unmoderated post count
            insertSql.AppendLine(" SELECT SCOPE_IDENTITY();"); //Get the inserted topic Id

            List<SqlParameter> parms = new List<SqlParameter>
                {
                    new SqlParameter("@CatId", SqlDbType.Int) {Value = topic.CatId},
                    new SqlParameter("@ForumId", SqlDbType.Int) {Value = topic.ForumId},
                    new SqlParameter("@Status", SqlDbType.Int) {Value = topic.Status},
                    new SqlParameter("@Subject", SqlDbType.NVarChar) {Value = topic.Subject},
                    new SqlParameter("@Message", SqlDbType.NVarChar) {Value = topic.Message},
                    new SqlParameter("@AuthorId", SqlDbType.Int) {Value = topic.AuthorId},
                    new SqlParameter("@Date", SqlDbType.VarChar) {Value = topic.Date.ToString("yyyyMMddHHmmss")},
                    new SqlParameter("@PostersIP", SqlDbType.VarChar) {Value = topic.PosterIp},
                    new SqlParameter("@Sticky", SqlDbType.Bit) {Value = topic.IsSticky},
                    new SqlParameter("@UseSig", SqlDbType.Bit) {Value = topic.UseSignatures}
                };

            int topicid = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, insertSql.ToString(), parms.ToArray()));
            topic.Id = topicid;
            new Forum().UpdateLastForumPost(topic);
            new Member().UpdateLastMemberPost(topic);
            return topicid;
        }
Example #5
0
 public static bool IsArchived(TopicInfo topic)
 {
     return false;
     //todo
 }
Example #6
0
        protected void TopicViewItemCommand(object sender, FormViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {

                case "prev" :
                    _topic = Topics.GetNextPrevTopic(_topic.Id, "prev");
                    if (Session["TOPIC"].ToString() != _topic.Id.ToString())
                        Response.Redirect("~/Content/Forums/topic.aspx?TOPIC=" + _topic.Id, true);
                    break;
                case "next" :
                    _topic = Topics.GetNextPrevTopic(_topic.Id, "next");
                    if (Session["TOPIC"].ToString() != _topic.Id.ToString())
                        Response.Redirect("~/Content/Forums/topic.aspx?TOPIC=" + _topic.Id, true);
                    break;
            }
        }
Example #7
0
        private static void SendSubscriptions(Enumerators.Subscription subType, TopicInfo topic, ReplyInfo reply,HttpContext context)
        {
            int replyid = -1;
            int authorid = topic.AuthorId;
            int[] memberids = { };
            StringBuilder Message = new StringBuilder("<html><body>Hello {0}");
            string strSubject = String.Empty;
            HttpContext.Current = context;
            if (reply != null)
            {
                replyid = reply.Id;
                authorid = reply.AuthorId;
            }
            Message.Append("<br/><p>");

            ISubscription dal = Factory<ISubscription>.Create("Subscription");
            switch (subType)
            {
                case Enumerators.Subscription.ForumSubscription:

                    memberids = dal.GetForumSubscriptionList(topic.ForumId);

                    if (memberids.Length > 0)
                    {
                        strSubject = Config.ForumTitle.Replace("&trade;", "").Replace("&copy;", "") + " - New posting";

                        Message.AppendFormat(
                            "{0} has posted to the forum {1} at {2} that you requested notification on.",
                            topic.AuthorName, topic.Forum.Subject, Config.ForumTitle);
                    }
                    break;
                case Enumerators.Subscription.TopicSubscription:

                    memberids = dal.GetTopicSubscriptionList(topic.Id);

                    if (memberids.Length > 0)
                    {
                        strSubject = Config.ForumTitle.Replace("&trade;", "").Replace("&copy;", "") + " - Reply to a posting";
                        Message.AppendFormat("{0} has replied to a topic on <b>{1}</b> that you requested notification to.", reply.AuthorName, Config.ForumTitle);
                    }

                    break;
            }
            Message.AppendFormat(" Regarding the subject - {0}.", topic.Subject);
            Message.Append("<br/>");
            Message.Append("<br/>");
            Message.AppendFormat("You can view the posting <a href=\"{0}Content/Forums/topic.aspx?whichpage=-1&TOPIC={1}", Config.ForumUrl, topic.Id);
            if (replyid > 0)
                Message.AppendFormat("#{0}", replyid);
            Message.Append("\">here</a>");
            Message.Append("</p></body></html>");
            foreach (int id in memberids)
            {
                MemberInfo member = Members.GetMember(id);
                //don't send the author notification of their own posts
                if (id == authorid)
                    continue;
                SnitzEmail email = new SnitzEmail
                {
                    subject = strSubject,
                    msgBody = String.Format(Message.ToString(), member.Username),
                    toUser = new MailAddress(member.Email, member.Username),
                    IsHtml = true,
                    FromUser = "******"
                };
                email.Send();
            }
        }
Example #8
0
        public static TopicInfo CopyTopicToBO(SqlDataReader rdr)
        {
            TopicInfo topic;
            try
            {
                topic = new TopicInfo
            {
                Id = rdr.GetInt32(0),
                CatId = rdr.GetInt32(1),
                ForumId = rdr.GetInt32(2),
                Status = rdr.GetInt16(3),
                Subject = rdr.SafeGetString(4),
                AuthorId = rdr.GetInt32(5),
                ReplyCount = rdr.GetInt32(6),
                Views = rdr.GetInt32(7),
                LastPostDate = rdr.SafeGetString(8).ToDateTime(),
                Date = rdr.SafeGetString(9).ToDateTime().Value,
                PosterIp = rdr.SafeGetString(10),
                LastPostAuthorId = rdr.SafeGetInt32(11),
                IsSticky = rdr.GetInt16(12) == 1,
                LastEditDate = rdr.SafeGetString(13).ToDateTime(),
                LastEditedById = rdr.SafeGetInt32(14),
                UseSignatures = rdr.GetInt16(15) == 1,
                LastReplyId = rdr.SafeGetInt32(16),
                UnModeratedReplies = rdr.GetInt32(17),
                Message = rdr.SafeGetString(18)

            };
                if (rdr.FieldCount > 19)
                {
                    topic.LastPostAuthorName = rdr.SafeGetString(19);
                    topic.AuthorName = rdr.SafeGetString(20);
                    topic.EditorName = rdr.SafeGetString(21);
                    if (rdr.FieldCount > 22)
                    {
                        topic.AuthorViewSig = rdr.GetInt16(22) == 1;
                        topic.AuthorSignature = rdr.SafeGetString(23);
                    }
                }
            }
            catch (System.Exception)
            {
                return null;
            }

            return topic;
        }
Example #9
0
 public IEnumerable<ReplyInfo> GetReplies(TopicInfo topic, int startrec, int maxrecs)
 {
     throw new NotImplementedException();
 }
Example #10
0
        private void InitialiseVariablesFromParams()
        {
            _action = Request.Params["method"].ToLower();

            if (Request.Params["id"] != null)
                _recId = Int32.Parse(Request.Params["id"]);
            if (Request.Params["type"] != null)
                _type = Request.Params["type"].ToLower();

            if (ForumId != null)
            {
                _inModeratedList = Moderators.IsUserForumModerator(User.Identity.Name, ForumId.Value);
                _forum = Forums.GetForum(ForumId.Value);
                if (_forum.Type == 3 && String.IsNullOrEmpty(Message.Text) && _action == "topic")
                {
                        var file = new StreamReader(Server.MapPath(Config.CultureSpecificDataDirectory + "bugtemplate.txt"));
                        Message.Text = file.ReadToEnd();
                        file.Close();
                        file.Dispose();
                }
            }
            if (TopicId != null)
            {
                _thisTopic = Topics.GetTopic(TopicId.Value);
                if (IsModerator)
                    _inModeratedList = Moderators.IsUserForumModerator(User.Identity.Name, _thisTopic.ForumId);
                _topicLocked = _thisTopic.Status == (int)Enumerators.PostStatus.Closed;
            }
            else if (_type == "topics")
            {
                TopicId = Int32.Parse(Request.Params["id"]);
                _thisTopic = Topics.GetTopic(TopicId.Value);
                if (IsModerator)
                {
                    _inModeratedList = Moderators.IsUserForumModerator(User.Identity.Name, _thisTopic.ForumId);
                }
                _topicLocked = _thisTopic.Status == (int)Enumerators.PostStatus.Closed;
            }
            if (IsAdministrator) //bypass moderation for administrators
                _inModeratedList = true;
            switch (_action)
            {
                case "topic":
                    Page.Title = Config.ForumTitle + ": "  + Resources.webResources.lblNewTopic;
                    break;
                case "reply":
                case "quote":
                    Page.Title = Config.ForumTitle + ": " + Resources.webResources.lblReplyToTopic;
                    break;
                case "edit":
                    switch (_type)
                    {
                        case "reply":
                            Page.Title = Config.ForumTitle + ": " + Resources.webResources.lblEditReply;
                            break;
                        case "topics":
                            Page.Title = Config.ForumTitle + ": " + Resources.webResources.lblEditTopic;
                            break;
                    }
                    break;
            }
        }
Example #11
0
 public static bool AllowArchive(TopicInfo topic)
 {
     return false;
     //todo
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            SendTopic.Visible = false;
            PrintTopic.Visible = false;
            NewTopic.Visible = false;
            ReplyTopic.Visible = true;
            SubscribeTopic.Visible = false;
            UnSubscribeTopic.Visible = false;

            var page = (PageBase) Page;
            if(page.TopicId.HasValue)
            {
                _topic = Topics.GetTopic(page.TopicId.Value);
                NewTopic.PostBackUrl = string.Format("~/Content/Forums/post.aspx?method=topic&FORUM={0}&CAT={1}", _topic.ForumId, _topic.CatId);
                ReplyTopic.PostBackUrl = string.Format("~/Content/Forums/post.aspx?method=reply&TOPIC={0}", _topic.Id);
                if (_topic.AllowSubscriptions && !_topic.IsArchived)
                {
                    SubscribeTopic.Visible = page.IsAuthenticated;
                    SubscribeTopic.CommandName = "topicsub";
                    SubscribeTopic.CommandArgument = page.TopicId.Value.ToString();

                    if (Members.IsSubscribedToTopic(page.TopicId.Value, page.Member == null ? 0 : page.Member.Id))
                    {
                        UnSubscribeTopic.CommandName = "topicunsub";
                        UnSubscribeTopic.CommandArgument = page.TopicId.Value.ToString();
                        UnSubscribeTopic.Visible = page.IsAuthenticated;
                        SubscribeTopic.Visible = false;
                    }
                }
                SendTopic.Visible = page.IsAuthenticated && Config.SendTopic && Config.UseEmail;
                PrintTopic.Visible = page.IsAuthenticated && Config.PrintTopic;
                SendTopic.Attributes.Add("onclick",
                                     string.Format(
                                         "mainScreen.LoadServerControlHtml('Send Topic',{{'pageID':5,'data':{0}}},'methodHandlers.BeginRecieve');return false;",
                                         _topic.Id));
                PrintTopic.Attributes.Add("onclick",string.Format("javascript:PrintThisPage({0});return false;", _topic.Id));
                if((_topic.Forum.Status == (int)Enumerators.PostStatus.Closed ||
                    _topic.Status == (int)Enumerators.PostStatus.Closed) &&
                    !(page.IsAdministrator))
                {
                    ReplyTopic.Visible = false;
                    NewTopic.Visible = _topic.Forum.Status != (int)Enumerators.PostStatus.Closed;
                }

                ReplyTopic.Visible = ReplyTopic.Visible && _topic.Status != (int)Enumerators.PostStatus.Closed;
                NewTopic.Visible = _topic.Forum.Status == (int)Enumerators.PostStatus.Open;

                ReplyTopic.Visible = ReplyTopic.Visible || (page.Member == null ? 0 : page.Member.Id) == _topic.AuthorId;

                NewTopic.Visible = NewTopic.Visible && page.IsAuthenticated;
                ReplyTopic.Visible = ReplyTopic.Visible && page.IsAuthenticated && !_topic.IsArchived;

            }else
            {
                if(page.ForumId.HasValue)
                {
                    ReplyTopic.Visible = false;
                    ForumInfo forum = Forums.GetForum(page.ForumId.Value);
                    NewTopic.PostBackUrl = string.Format("~/Content/Forums/post.aspx?method=topic&FORUM={0}&CAT={1}", forum.Id, forum.CatId);
                    NewTopic.Visible = page.IsAuthenticated;
                    NewTopic.Visible = NewTopic.Visible && forum.Status != (int)Enumerators.PostStatus.Closed || (page.IsAdministrator || ((ForumPage)Page).IsForumModerator);
                    if (forum.SubscriptionLevel == (int)Enumerators.Subscription.ForumSubscription)
                    {
                        SubscribeTopic.Visible = page.IsAuthenticated;
                        SubscribeTopic.CommandName = "forumsub";
                        SubscribeTopic.CommandArgument = page.ForumId.Value.ToString();

                        if (Members.IsSubscribedToForum(page.Member == null ? 0 : page.Member.Id, page.ForumId.Value))
                        {
                            UnSubscribeTopic.CommandName = "forumunsub";
                            UnSubscribeTopic.CommandArgument = page.ForumId.Value.ToString();
                            UnSubscribeTopic.Visible = page.IsAuthenticated;
                            SubscribeTopic.Visible = false;
                        }
                    }
                }

            }
            if (DisplaySettings != null && DisplaySettings.Length > 0)
            {
                var controls = this.GetAllControls().OfType<LinkButton>().ToList();
                foreach (LinkButton button in controls)
                {
                    if (!DisplaySettings.Contains(button.ID))
                        button.Visible = false;
                }
            }
        }
Example #13
0
        public void MoveReplies(TopicInfo newtopic, List<int> replyids)
        {
            string strSql = "UPDATE " + Config.ForumTablePrefix + "REPLY SET CAT_ID=@CatId, FORUM_ID=@ForumId, TOPIC_ID=@TopicId WHERE REPLY_ID IN ({0}) ";
            int[] values = replyids.ToArray();

            var inparms = values.Select((s, i) => "@p" + i.ToString()).ToArray();
            var inclause = string.Join(",", inparms);
            List<SqlParameter> parms = values.Select((t, i) => new SqlParameter(inparms[i], SqlDbType.Int) {Value = t}).ToList();
            parms.Add(new SqlParameter("@CatId", SqlDbType.Int) { Value = newtopic.CatId });
            parms.Add(new SqlParameter("@ForumId", SqlDbType.Int) { Value = newtopic.ForumId });
            parms.Add(new SqlParameter("@TopicId", SqlDbType.Int) { Value = newtopic.Id });
            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, String.Format(strSql,inclause), parms.ToArray());
        }
    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);
    }
Example #15
0
 public static void Update(TopicInfo topic)
 {
     ITopic dal = Factory<ITopic>.Create("Topic");
     dal.Update(topic);
 }
Example #16
0
 public static int Add(TopicInfo topic)
 {
     ITopic dal = Factory<ITopic>.Create("Topic");
     return dal.Add(topic);
 }
Example #17
0
        public void Delete(TopicInfo topic)
        {
            string strSql = "DELETE FROM " + Config.ForumTablePrefix + "REPLY WHERE TOPIC_ID=@TopicId; DELETE FROM " + Config.ForumTablePrefix + "TOPICS WHERE TOPIC_ID=@TopicId";

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@TopicId", OleDbType.Integer) { Value = topic.Id });
            new AdminFunctions().UpdateForumCounts();
        }
Example #18
0
 public static void Delete(TopicInfo topic)
 {
     Delete(topic.Id);
 }
Example #19
0
 public IEnumerable<ReplyInfo> GetReplies(TopicInfo topic, int startrec, int maxrecs)
 {
     return new Reply().GetByParent(topic, startrec, maxrecs);
 }
Example #20
0
        private int PostNewTopic()
        {
            string ipaddress = Common.GetIP4Address();
            #region Poll check code
            string topicPoll = String.Empty;

            var poll = new Regex(@"(?<poll>\[poll=\x22(?<question>.+?)\x22](?<answers>.+?)\[\/poll])", RegexOptions.Singleline);

            if (poll.IsMatch(Message.Text))
            {
                //there are poll tags, so store them and remove from the message text
                topicPoll = poll.Match(Message.Text).Value;
                Message.Text = poll.Replace(Message.Text, "");
            }
            #endregion
            var topic = new TopicInfo
                              {
                                  Subject = tbxSubject.Text,
                                  Message = Message.Text,
                                  Date = DateTime.UtcNow,
                                  UseSignatures = cbxSig.Checked,
                                  IsSticky = cbxSticky.Checked,
                                  PosterIp = ipaddress,
                                  Status = (int)Enumerators.PostStatus.Open,
                                  UnModeratedReplies = 0,
                                  AuthorId = Member.Id,
                                  ReplyCount = 0,
                                  Views = 0
                              };
            if (ForumId.HasValue)
            {
                topic.Forum = Forums.GetForum(ForumId.Value);
                topic.ForumId = ForumId.Value;

            }
            if (cbxLock.Checked)
                topic.Status = (int)Enumerators.PostStatus.Closed;
            else if (!_inModeratedList)
            {
                if (topic.Forum.ModerationLevel == (int)Enumerators.Moderation.AllPosts ||
                    topic.Forum.ModerationLevel == (int)Enumerators.Moderation.Topics)
                    topic.Status = (int)Enumerators.PostStatus.UnModerated;
            }
            if (CatId != null) topic.CatId = CatId.Value;
            topic.Id = Topics.Add(topic);
            if (pingSiteMap) { Ping(""); }

            if (topicPoll != String.Empty && topic.Forum.AllowPolls)
                CreatePoll(topicPoll, topic.Id);
            InvalidateForumCache();
            return topic.Id;
        }
Example #21
0
        public void Update(TopicInfo topic)
        {
            List<OleDbParameter> parms = new List<OleDbParameter>
                {

                    new OleDbParameter("@Status", OleDbType.Integer) {Value = topic.Status},
                    new OleDbParameter("@Subject", OleDbType.VarChar) {Value = topic.Subject},
                    new OleDbParameter("@Message", OleDbType.VarChar) {Value = topic.Message},
                    new OleDbParameter("@Sticky", OleDbType.SmallInt) {Value = topic.IsSticky},
                    new OleDbParameter("@UseSig", OleDbType.SmallInt) {Value = topic.UseSignatures},
                    new OleDbParameter("@TopicId", OleDbType.Integer) {Value = topic.Id}
                };

            StringBuilder updateSql = new StringBuilder(" ");
            updateSql.AppendFormat("UPDATE {0}TOPICS SET",Config.ForumTablePrefix).AppendLine();
            updateSql.AppendLine("T_STATUS=@Status,");
            updateSql.AppendLine("T_SUBJECT=@Subject,");
            updateSql.AppendLine("T_MESSAGE=@Message,");
            if (topic.LastEditedById.HasValue)
            {
                updateSql.AppendLine("T_LAST_EDITBY=@EditedBy,");
                updateSql.AppendLine("T_LAST_EDIT=@EditDate,");
                parms.Add(new OleDbParameter("@EditedBy", OleDbType.Integer) { Value = topic.LastEditedById.Value });
                parms.Add(new OleDbParameter("@EditDate", OleDbType.VarChar) { Value = DateTime.UtcNow.ToString("yyyyMMddHHmmss") });

            }
            updateSql.AppendLine("T_STICKY=@Sticky,");
            updateSql.AppendLine("T_SIG=@UseSig ");
            updateSql.AppendLine("WHERE TOPIC_ID=@TopicId");

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, updateSql.ToString(), parms.ToArray());
        }
Example #22
0
        private Image GetTopicIcon(TopicInfo topic)
        {
            var image = new Image { ID = "imgTopicIcon" };
            string _new = "";
            string hot = "";
            string locked = "";
            string sticky = "";

            if (topic.ReplyCount >= Config.HotTopicNum)
                hot = "Hot";
            switch ((Enumerators.PostStatus)topic.Status)
            {
                case Enumerators.PostStatus.Open:
                    locked = "";
                    image.ToolTip = webResources.lblOldPosts;
                    break;
                case Enumerators.PostStatus.UnModerated:
                    image.AlternateText = webResources.Unmoderatedpost;
                    image.ToolTip = webResources.Unmoderatedpost;
                    break;
                case Enumerators.PostStatus.OnHold:
                    image.AlternateText = webResources.OnHold;
                    image.ToolTip = webResources.OnHold;
                    break;
                default:
                    locked = "Locked";
                    hot = "";
                    image.AlternateText = webResources.lblLockedTopic;
                    image.ToolTip = webResources.lblTopicLocked;
                    break;
            }

            if (topic.IsSticky)
            {
                sticky = "Sticky";
                image.AlternateText = webResources.lblStickyTopic;
                image.ToolTip = locked == "" ? webResources.lblStickyTopic : webResources.lblStickyTopic + ", " + webResources.lblTopicLocked;
            }
            if (topic.LastPostDate > LastVisitDateTime)
            {
                image.AlternateText = webResources.lblNewPosts;
                image.ToolTip = webResources.lblNewPosts;
                _new = "New";
            }
            image.SkinID = "Folder" + _new + hot +  sticky + locked;

            if (topic.Status == (int)Enumerators.PostStatus.UnModerated)
            {
                image.ToolTip = webResources.Unmoderatedpost;
                image.SkinID = "UnModerated";
            }
            if (topic.Status == (int)Enumerators.PostStatus.OnHold)
            {
                image.ToolTip = webResources.TopicOnHold;
                image.SkinID = "OnHold";
            }
            if (topic.UnModeratedReplies > 0)
            {
                image.ToolTip = webResources.UnmoderatedPosts;
                image.SkinID = "UnmoderatedPosts";
            }
            if (topic.PollId > 0)
            {
                image.ToolTip = Polls.lblPoll;
                image.SkinID = "PollFolder";
            }
            if (Config.TopicAvatar)
                image.CssClass = image.CssClass + " icon-overlay";
            image.GenerateEmptyAlternateText = true;
            image.ApplyStyleSheetSkin(Page);
            return image;
        }
Example #23
0
        private void AddDefaultData()
        {
            UpdateProgress(0,"Adding default data<br/>");
            //Add Admin Account
            string aUsername = adminUsername.Value ?? "Admin";
            string adminpassword = adminPassword.Value ?? "P@ssword01!!";
            string adminemail = adminEmail.Value ?? "*****@*****.**";

            MembershipCreateStatus status;
            MembershipUser admin = Membership.GetUser(aUsername);
            if (admin == null || admin.UserName != aUsername)
                admin = Membership.CreateUser(aUsername, adminpassword, adminemail, ".", ".", true, out status);
            Membership.UpdateUser(admin);
            Roles.AddUserToRoles(admin.UserName, new string[] { "Administrator", "Member" });

            var newadmin = "UPDATE FORUM_MEMBERS SET M_TITLE='Forum Administrator', M_SUBSCRIPTION=1,M_LEVEL=3,M_STATUS=1,M_HIDE_EMAIL = 1,M_RECEIVE_EMAIL = 1,M_VOTED = 0 WHERE M_NAME='" + aUsername + "'";
            Snitz.BLL.Admin.ExecuteScript(newadmin);
            Snitz.BLL.Admin.ExecuteScript("INSERT INTO FORUM_TOTALS (P_COUNT,P_A_COUNT,T_COUNT,T_A_COUNT,U_COUNT) VALUES (0,0,0,0,1)");
            CategoryInfo cat = new CategoryInfo();
            ForumInfo forum = new ForumInfo();
            TopicInfo topic = new TopicInfo();
            cat.Id = -1;
            cat.Name = "Snitz .Net Forums";
            cat.Order = 0;
            cat.Status = (int)Enumerators.PostStatus.Open;
            cat.SubscriptionLevel = 0;
            cat.ModerationLevel = 0;

            int catid = Categories.AddCategory(cat);

            forum.CatId = catid;
            forum.Id = -1;
            forum.Status = (int)Enumerators.PostStatus.Open;
            forum.AllowPolls = false;
            forum.Description = "This forum gives you a chance to become more familiar with how this product responds to different features and keeps testing in one place instead of posting tests all over. Happy Posting! [:)]";
            forum.Subject = "Testing Forum";
            forum.SubscriptionLevel = 0;
            forum.ModerationLevel = 0;
            forum.Order = 0;
            forum.PostCount = 0;
            forum.UpdatePostCount = true;

            int forumid = Forums.SaveForum(forum);

            topic.CatId = catid;
            topic.ForumId = forumid;
            topic.Status = 1;
            topic.Message = "Thank you for downloading Snitz Forums 2000. We hope you enjoy this great tool to support your organization!" + 0x13 + 0x10 + 0x13 + 0x10 + "Many thanks go out to John Penfold &lt;[email protected]&gt; and Tim Teal &lt;[email protected]&gt; for the original source code and to all the people of Snitz Forums 2000 at http://forum.snitz.com for continued support of this product.";
            topic.Subject = "Welcome to Snitz .Net Forums";
            topic.AuthorId = (int)admin.ProviderUserKey;
            topic.Date = DateTime.UtcNow;
            topic.PosterIp = "0.0.0.0";

            Topics.Add(topic);
        }
Example #24
0
        public string SplitTopic(string jsonform)
        {
            var test = HttpUtility.UrlDecode(jsonform);
            System.Collections.Specialized.NameValueCollection formresult = HttpUtility.ParseQueryString(test);
            var replyIDs = new List<int>();
            foreach (string key in formresult.AllKeys)
            {
                if (key.EndsWith("cbxRow"))
                    replyIDs.Add(Convert.ToInt32(formresult[key]));
            }

            int topicid = Convert.ToInt32(formresult["ctl00$splitTopicId"]);
            int forumId = Convert.ToInt32(formresult["ctl00$ddlForum"]);
            string sort = formresult["ctl00$ddlSort"];

            string subject = formresult["ctl00$tbxSubject"];
            if (String.IsNullOrEmpty(subject))
                return "No subject supplied";

            TopicInfo oldtopic = Topics.GetTopic(topicid);
            ForumInfo forum = Forums.GetForum(forumId);

            if (replyIDs.Count == 0)
                return "No replies selected";
            int lastreplyid = sort == "desc" ? replyIDs[replyIDs.Count - 1] : replyIDs[0];
            ReplyInfo lastreply = Replies.GetReply(lastreplyid);

            //get the reply details
            var topic = new TopicInfo
            {
                Subject = subject,
                Message = lastreply.Message,
                Date = lastreply.Date,
                UseSignatures = lastreply.UseSignatures,
                IsSticky = false,
                PosterIp = lastreply.PosterIp,
                Views = 0,
                ReplyCount = replyIDs.Count - 1,
                Status = (int)Enumerators.PostStatus.Open,
                UnModeratedReplies = 0,
                ForumId = forumId,
                AuthorId = lastreply.AuthorId,
                CatId = forum.CatId
            };

            bool isModeratedForum = forum.ModerationLevel != (int)Enumerators.Moderation.UnModerated;
            if (isModeratedForum)
            {
                if (forum.ModerationLevel == (int)Enumerators.Moderation.AllPosts ||
                    forum.ModerationLevel == (int)Enumerators.Moderation.Topics)
                    topic.Status = (int)Enumerators.PostStatus.UnModerated;
            }

            int newtopicid = Topics.Add(topic);
            //delete the reply used as topic
            Replies.DeleteReply(lastreplyid);
            //move the other replies to this topic
            Replies.MoveReplies(newtopicid, replyIDs);
            //update the original topic count/dates
            Topics.Update(oldtopic.Id);

            Snitz.BLL.Admin.UpdateForumCounts();

            return "Selected replies were moved to a new topic";
        }
Example #25
0
        public static IEnumerable<ReplyInfo> GetRepliesForTopic(TopicInfo topic, int startrec, int maxrecs)
        {
            IReply dal = Factory<IReply>.Create("Reply");

            return dal.GetByParent(topic,startrec,maxrecs);
        }
Example #26
0
        private Image GetTopicIcon(TopicInfo topic)
        {
            var image = new Image { ID = "imgTopicIcon" };
            string _new = "";
            string locked;
            string sticky = "";

            if (topic.LastPostDate > LastVisitDateTime)
            {
                image.AlternateText = webResources.lblNewPosts;
                image.ToolTip = webResources.lblNewPosts;
                _new = "New";
            }

            switch ((Enumerators.PostStatus)topic.Status)
            {
                case Enumerators.PostStatus.Open:
                    locked = "";
                    image.ToolTip = webResources.lblOldPosts;
                    break;

                default:
                    locked = "Locked";
                    image.AlternateText = webResources.lblLockedTopic;
                    image.ToolTip = webResources.lblTopicLocked;
                    break;
            }
            if (topic.IsSticky)
            {
                sticky = "Sticky";
                image.AlternateText = webResources.lblStick;
                image.ToolTip = locked == "" ? webResources.lblStick : webResources.lblStick + " " + webResources.lblTopicLocked;
            }

            image.SkinID = "Folder" + _new + sticky + locked;

            return image;
        }
Example #27
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);
        }