Esempio n. 1
0
 public static int AddForum(ForumInfo forum)
 {
     if (forum == null)
         return -1;
     IForum dal = Factory<IForum>.Create("Forum");
     return dal.Add(forum);
 }
Esempio n. 2
0
        public int Add(ForumInfo forum)
        {
            if (!String.IsNullOrEmpty(forum.Url))
                forum.Type = 1;
            List<OleDbParameter> parms = new List<OleDbParameter>();

            string strsql = "INSERT INTO " + Config.ForumTablePrefix + "FORUM " +
                                  "(CAT_ID,F_STATUS,F_MAIL,F_SUBJECT,F_URL,F_DESCRIPTION,F_TOPICS,F_COUNT,F_LAST_POST,F_PASSWORD_NEW,F_PRIVATEFORUMS " +
                                  ",F_TYPE,F_IP,F_LAST_POST_AUTHOR,F_A_TOPICS,F_A_COUNT,F_MODERATION,F_SUBSCRIPTION,F_ORDER,F_L_ARCHIVE,F_ARCHIVE_SCHED " +
                                  ",F_L_DELETE,F_DELETE_SCHED,F_DEFAULTDAYS,F_COUNT_M_POSTS,F_LAST_POST_TOPIC_ID,F_LAST_POST_REPLY_ID,F_POLLS) " +
                                  "VALUES ";
            const string strvalues = "(@CatId,@Status,0,@Subject,@Url, @Description,0,0,NULL, @Password,0," +
                                     "@Type,'127.0.0.1', NULL, 0, 0, @Moderation, @Subscription,@Order,'',30," +
                                     "'',365,30,@CountPosts,NULL,NULL,@Polls)";

            parms.Add(new OleDbParameter("@CatId", OleDbType.Numeric) { Value = forum.CatId });
            parms.Add(new OleDbParameter("@Status", OleDbType.Numeric) { Value = forum.Status });
            parms.Add(new OleDbParameter("@Subject", OleDbType.VarChar) { Value = forum.Subject });
            parms.Add(new OleDbParameter("@Url", OleDbType.VarChar) { Value = forum.Url.ConvertDBNull("") });
            parms.Add(new OleDbParameter("@Description", OleDbType.VarChar) { Value = forum.Description });
            parms.Add(new OleDbParameter("@Password", OleDbType.VarChar) { Value = forum.Password.ConvertDBNull("") });
            parms.Add(new OleDbParameter("@Type", OleDbType.Numeric) { Value = forum.Type });
            parms.Add(new OleDbParameter("@Moderation", OleDbType.Numeric) { Value = forum.ModerationLevel });
            parms.Add(new OleDbParameter("@Subscription", OleDbType.Numeric) { Value = forum.SubscriptionLevel });
            parms.Add(new OleDbParameter("@Order", OleDbType.Numeric) { Value = forum.Order });
            parms.Add(new OleDbParameter("@CountPosts", OleDbType.Numeric) { Value = forum.UpdatePostCount });
            parms.Add(new OleDbParameter("@Polls", OleDbType.Numeric) { Value = forum.AllowPolls });

            return SqlHelper.ExecuteInsertQuery(SqlHelper.ConnString, CommandType.Text, strsql + strvalues, parms.ToArray());
        }
Esempio n. 3
0
        public void Delete(ForumInfo forum)
        {
            string strSql = "DELETE FROM " + Config.ForumTablePrefix + "FORUM WHERE FORUM_ID=@ForumId ";

            EmptyForum(forum.Id);

            OleDbParameter forumid = new OleDbParameter("@ForumId", OleDbType.Numeric) { Value = forum.Id };
            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, forumid);
        }
Esempio n. 4
0
        public void AppendItems(System.Text.StringBuilder oBuilder, ForumInfo forum)
        {
            foreach (TopicInfo row in Forums.GetForumTopics(forum.Id,0,10).OrderByDescending(t => t.LastPostDate))
            {
                int topicId = row.Id;
                TopicInfo topic = Topics.GetTopic(topicId);
                string sTitle = topic.Subject;
                string sGuid = string.Format("{0}Content/Forums/Topic/{1}", Config.ForumUrl, topicId);
                string sLink = string.Format("{0}Content/Forums/topic.aspx?TOPIC={1}&amp;whichpage=-1", Config.ForumUrl, topicId);
                if (topic.LastReplyId > 0)
                    sLink += "#" + topic.LastReplyId;

                string sDescription = topic.Message; //topic.Message.Length > 512 ? topic.Message.Substring(0, 512) + " ... " : topic.Message;
                string sPubDate = topic.LastPostDate.Value.ToISO8601Date(false,null);
                string author = topic.AuthorName;
                if (topic.LastReplyId > 0)
                {
                    if (topic.LastReplyId != null)
                    {
                        ReplyInfo rep = Replies.GetReply((int) topic.LastReplyId);
                        author = rep.AuthorName;
                        sDescription = rep.Message;  //rep.Message.Length > 256 ? rep.Message.Substring(0, 256) + " ... " : rep.Message;
                    }
                }

                oBuilder.Append("<item>");
                oBuilder.Append("<category>");
                oBuilder.Append(forum.Subject.WrapCData());
                oBuilder.Append("</category>");
                oBuilder.Append("<title>");
                oBuilder.Append(sTitle.WrapCData());
                oBuilder.Append("</title>");
                oBuilder.Append("<author>");
                oBuilder.Append(author);
                oBuilder.Append("</author>");
                oBuilder.Append("<link>");
                oBuilder.Append(sLink);
                oBuilder.Append("</link>");
                oBuilder.Append("<guid isPermaLink=\"true\">");
                oBuilder.Append(sGuid);
                oBuilder.Append("</guid>");
                oBuilder.Append("<description>");
                oBuilder.Append(sDescription.ParseTags().WrapCData());
                oBuilder.Append("</description>");
                oBuilder.Append("<pubDate>");
                oBuilder.Append(sPubDate);
                oBuilder.Append("</pubDate>");
                oBuilder.Append("</item>");

            }
        }
Esempio n. 5
0
        public static ForumInfo CopyForumToBO(SqlDataReader rdr)
        {
            //"F.FORUM_ID,F.CAT_ID,F.F_STATUS,F.F_SUBJECT,F.F_URL,F.F_TOPICS" +
            //",F.F_COUNT,F.F_LAST_POST,F.F_PRIVATEFORUMS,F.F_TYPE,F.F_LAST_POST_AUTHOR,F.F_A_TOPICS,F.F_A_COUNT,F.F_MODERATION" +
            //",F.F_SUBSCRIPTION,F.F_ORDER, F.F_COUNT_M_POSTS,F.F_LAST_POST_TOPIC_ID,F.F_LAST_POST_REPLY_ID,F.F_POLLS,F.F_DESCRIPTION" +
            //",F.F_L_ARCHIVE,F.F_ARCHIVE_SCHED,T.T_SUBJECT,M.M_NAME ";
            ForumInfo forum = new ForumInfo
            {
                Id = rdr.GetInt32(0),
                CatId = rdr.GetInt32(1),
                Status = rdr.GetInt16(2),
                Subject = rdr.SafeGetString(3),
                Url = rdr.SafeGetString(4),
                TopicCount = rdr.GetInt32(5),
                PostCount = rdr.GetInt32(6),
                LastPostDate = rdr.GetSnitzDate(7),
                AuthType = rdr.SafeGetInt32(8),
                Type = rdr.GetInt16(9),
                LastPostAuthorId = rdr.SafeGetInt32(10),
                ArchivedTopicCount = rdr.SafeGetInt32(11),
                ArchivedPostCount = rdr.SafeGetInt32(12),
                ModerationLevel = rdr.SafeGetInt32(13),
                SubscriptionLevel = rdr.SafeGetInt32(14),
                Order = rdr.GetInt32(15),
                UpdatePostCount = rdr.GetInt16(16) == 1,
                LastPostTopicId = rdr.SafeGetInt32(17),
                LastPostReplyId = rdr.SafeGetInt32(18),
                AllowPolls = rdr.GetInt32(19) == 1,
                Description = rdr.SafeGetString(20),
                LastArchived = rdr.GetSnitzDate(21),
                ArchiveFrequency = rdr.SafeGetInt32(22),
                LastPostSubject = rdr.SafeGetString(23),
                LastPostAuthorName = rdr.SafeGetString(24)
            };

            return forum;
        }
Esempio n. 6
0
        public static ForumInfo CopyForumToBO(SqlDataReader rdr)
        {
            ForumInfo forum = new ForumInfo
            {
                Id = rdr.GetInt32(0),
                CatId = rdr.GetInt32(1),
                Status = rdr.GetInt16(2),
                Subject = rdr.SafeGetString(3),
                Url = rdr.SafeGetString(4),
                TopicCount = rdr.GetInt32(5),
                PostCount = rdr.GetInt32(6),
                LastPostDate = rdr.SafeGetString(7).ToDateTime(),
                AuthType = rdr.SafeGetInt32(8),
                Type = rdr.GetInt16(9),
                LastPostAuthorId = rdr.SafeGetInt32(10),
                ArchivedTopicCount = rdr.SafeGetInt32(11),
                ArchivedPostCount = rdr.SafeGetInt32(12),
                ModerationLevel = rdr.SafeGetInt32(13),
                SubscriptionLevel = rdr.SafeGetInt32(14),
                Order = rdr.GetInt32(15),
                UpdatePostCount = rdr.GetInt16(16) == 1,
                LastPostTopicId = rdr.SafeGetInt32(17),
                LastPostReplyId = rdr.SafeGetInt32(18),
                AllowPolls = rdr.GetInt32(19) == 1,
                Description = rdr.SafeGetString(20),
                LastPostSubject = rdr.SafeGetString(21),
                LastPostAuthorName = rdr.SafeGetString(22)
            };

            //if (forum.LastPostAuthorId != null)
            //{
            //    var author = new PostAuthor().GetAuthor(forum.LastPostAuthorId.Value);
            //    forum.LastPostAuthor = author;
            //}
            return forum;
        }
Esempio n. 7
0
        private void SetupPage(ForumInfo forum)
        {
            CategoryInfo cat = Categories.GetCategory(forum.CatId);

            hdnForumId.Value = forum.Id.ToString();

            tbxSubject.Text = forum.Subject;
            tbxBody.Text = forum.Description;
            tbxOrder.Text = forum.Order.ToString();
            ddlCat.DataSource = Categories.GetCategories();
            ddlCat.DataValueField = "Id";
            ddlCat.DataTextField = "Name";
            ddlCat.DataBind();
            ddlCat.SelectedValue = _catid.ToString();

            if (_forumtype == 1)
            {
                pnlOptions.Visible = false;
                pnlAuth.Visible = false;
                tbxUrl.Text = forum.Url;
                pnlUrl.Visible = true;
                return;
            }
            pnlUrl.Visible = false;
            tbxUrl.Text = "";

            tbxPassword.Text = forum.Password;

            if (forum.UpdatePostCount.HasValue)
                cbxCountPost.Checked = forum.UpdatePostCount.Value;
            cbxAllowPolls.Checked = forum.AllowPolls;

            cbxBugReport.Checked = (forum.Type == (int)Enumerators.ForumType.BugReports);
            cbxBlogPosts.Checked = (forum.Type == (int) Enumerators.ForumType.BlogPosts);
            if (Config.Moderation)
            {
                if (forum.ModerationLevel != null) ddlMod.SelectedValue = ((int) forum.ModerationLevel).ToString();
            }
            else
            {
                lblMod.Enabled = false;
                ddlMod.Enabled = false;
                ddlMod.SelectedValue = "0";
            }
            #region Subscriptions
            if (Config.SubscriptionLevel > 0 && cat.SubscriptionLevel > 0)
            {
                ddlSub.Items.Clear();
                ddlSub.Items.Add(new ListItem("No Subscriptions Allowed","0"));
                if(cat.SubscriptionLevel < (int)Enumerators.CategorySubscription.TopicSubscription)
                {
                        ddlSub.Items.Add(new ListItem("Forum Subscriptions Allowed", "1"));
                }
                ddlSub.Items.Add(new ListItem("Topic Subscriptions Allowed", "2"));
                ddlSub.SelectedValue = forum.SubscriptionLevel.ToString();

            }
            else
            {
                lblSub.Enabled = false;
                ddlSub.Enabled = false;
                ddlSub.Items.Clear();
                ddlSub.Items.Add(new ListItem("No Subscriptions Allowed", "0"));
                ddlSub.SelectedValue = "0";
            }
            #endregion

            if (forum.Id > 0)
            {
                string[] roleList = Forums.GetForumRoles(forum.Id);
                ListView2.DataSource = roleList;
                ListView2.DataBind();
                hdnRoleList.Value = String.Join(",",roleList);
                lvModerator.DataSource = Forums.GetForumModerators(forum.Id);
                lvModerator.DataBind();
            }
            ddlRole.DataSource = new SnitzRoleProvider().GetAllRoles();
            ddlRole.DataBind();
            ddlModUsers.DataSource = Forums.GetAvailableModerators(forum.Id);
            ddlModUsers.DataValueField = "MemberId";
            ddlModUsers.DataTextField = "Name";
            ddlModUsers.DataBind();
        }
Esempio n. 8
0
 public static void MoveForumPosts(ForumInfo forum)
 {
     IForum dal = Factory<IForum>.Create("Forum");
     dal.MoveForumPosts(forum.Id, forum.CatId);
 }
Esempio n. 9
0
        public void Update(ForumInfo forum)
        {
            List<OleDbParameter> parms = new List<OleDbParameter>();
            StringBuilder strSql = new StringBuilder();
            strSql.AppendFormat("UPDATE {0}FORUM SET ", Config.ForumTablePrefix).AppendLine();
            strSql.AppendLine("CAT_ID=@CatId,");
            strSql.AppendLine("F_STATUS=@Status,");
            strSql.AppendLine("F_SUBJECT=@Subject,");
            strSql.AppendLine("F_URL=@Url,");
            strSql.AppendLine("F_DESCRIPTION=@Description,");
            strSql.AppendLine("F_PASSWORD_NEW=@Password,");
            strSql.AppendLine("F_TYPE=@Type,");
            strSql.AppendLine("F_MODERATION=@Moderation,");
            strSql.AppendLine("F_SUBSCRIPTION=@Subscription,");
            strSql.AppendLine("F_ORDER=@Order,");
            strSql.AppendLine("F_COUNT_M_POSTS=@CountPosts,");
            strSql.AppendLine("F_POLLS=@Polls");
            strSql.AppendLine("WHERE FORUM_ID=@ForumId");

            parms.Add(new OleDbParameter("@ForumId", OleDbType.Numeric) { Value = forum.Id });
            parms.Add(new OleDbParameter("@CatId", OleDbType.Numeric) { Value = forum.CatId });
            parms.Add(new OleDbParameter("@Status", OleDbType.Numeric) { Value = forum.Status });
            parms.Add(new OleDbParameter("@Subject", OleDbType.VarChar) { Value = forum.Subject });
            parms.Add(new OleDbParameter("@Url", OleDbType.VarChar) { Value = forum.Url.ConvertDBNull(), IsNullable = true });
            parms.Add(new OleDbParameter("@Description", OleDbType.VarChar) { Value = forum.Description });
            parms.Add(new OleDbParameter("@Password", OleDbType.VarChar) { Value = forum.Password.ConvertDBNull(), IsNullable = true });
            parms.Add(new OleDbParameter("@Type", OleDbType.Numeric) { Value = forum.Type });
            parms.Add(new OleDbParameter("@Moderation", OleDbType.Numeric) { Value = forum.ModerationLevel });
            parms.Add(new OleDbParameter("@Subscription", OleDbType.Numeric) { Value = forum.SubscriptionLevel });
            parms.Add(new OleDbParameter("@Order", OleDbType.Numeric) { Value = forum.Order });
            parms.Add(new OleDbParameter("@CountPosts", OleDbType.Numeric) { Value = forum.UpdatePostCount });
            parms.Add(new OleDbParameter("@Polls", OleDbType.Numeric) { Value = forum.AllowPolls });

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parms.ToArray());
        }
Esempio n. 10
0
        public IEnumerable<KeyValuePair<int, string>> GetAllowedForumList(MemberInfo member, List<int> roleList, bool isadmin)
        {
            List<KeyValuePair<int, string>> forums = new List<KeyValuePair<int, string>>();
            //return (from role in this.ForumRoles where role.Forum_id == forumid select role.Role_Id).ToList();
            string SqlStr = "SELECT FORUM_ID,F_SUBJECT FROM " + Config.ForumTablePrefix + "FORUM ORDER BY F_SUBJECT";

            //Execute a query to read the products
            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, SqlStr, null))
            {
                while (rdr.Read())
                {
                    forums.Add(new KeyValuePair<int, string>(rdr.GetInt32(0),rdr.GetString(1)));
                }
            }

            List<KeyValuePair<int, string>> allowedForums = new List<KeyValuePair<int, string>>();
            foreach (var forum in forums)
            {
                ForumInfo f = new ForumInfo
                {
                    Id = forum.Key,
                    AllowedRoles = new List<int>(new Forum().AllowedRoles(forum.Key))
                };
                if (f.AllowedRoles.Count == 0)
                    allowedForums.Add(forum);
                else
                {
                    if (f.AllowedRoles.Any(role => roleList.Contains(role) || isadmin))
                    {
                        allowedForums.Add(forum);
                    }
                }
            }

            return allowedForums;
        }
Esempio n. 11
0
        public IEnumerable<int> GetAllowedForumIds(List<int> roleList, bool isadmin)
        {
            List<int> forums = new List<int>();
            //return (from role in this.ForumRoles where role.Forum_id == forumid select role.Role_Id).ToList();
            string SqlStr = "SELECT FORUM_ID FROM " + Config.ForumTablePrefix + "FORUM";

            //Execute a query to read the forums
            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, SqlStr, null))
            {
                while (rdr.Read())
                {
                    forums.Add(rdr.GetInt32(0));
                }
            }
            List<int> allowedForums = new List<int>();
            foreach (int forum in forums)
            {
                ForumInfo f = new ForumInfo {Id = forum, AllowedRoles = new List<int>(new Forum().AllowedRoles(forum))};
                if (f.AllowedRoles.Count == 0)
                    allowedForums.Add(forum);
                else
                {
                    if (f.AllowedRoles.Any(role => roleList.Contains(role) || isadmin))
                    {
                        allowedForums.Add(f.Id);
                    }
                }
            }

            return allowedForums;
        }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentPage == -1)
                CurrentPage = 0;

            if (ForumId != null)
            {
                _currentForum = Forums.GetForum(ForumId.Value);
                if (_currentForum == null) throw new ArgumentException("Invalid Forum ID");
                if(_currentForum.Type == 1)
                {
                    Response.Redirect(_currentForum.Url,true);
                }

                fLogin.forum = _currentForum;
                if (!IsPostBack)
                {
                    if (IsAuthenticated)
                    {

                        //do we have access to this forum
                        if (!Forums.IsUserInForumRole(Member.Username, ForumId.Value))
                        {
                            if (Session[session] == null || Session[session].ToString() != ForumId.ToString())
                            {

                                if (_currentForum.Password != null &&
                                    !String.IsNullOrEmpty(_currentForum.Password.Trim()))
                                {
                                    if (Session[session] == null || Session[session].ToString() == "")
                                    {
                                        var mp = (ModalPopupExtender) fLogin.FindControl("popup");
                                        var masterPage = this.Page.Master;
                                        if (masterPage != null)
                                        {
                                            var cph = (ContentPlaceHolder) masterPage.FindControl("CPM");

                                            cph.Visible = false;
                                        }
                                        mp.Show();
                                    }
                                    else
                                    {
                                        if (Session[session].ToString() != ForumId.ToString())
                                            throw new SecurityException("You are not authorised to view this forum");
                                    }
                                }
                            }
                        }else
                        {
                            Session[session] = ForumId.ToString();
                        }
                    }

                }
                _currentForum.Roles = Forums.GetForumRoles(_currentForum.Id).ToList();
                if (!IsAuthenticated && (_currentForum.Roles.Count > 0 && !_currentForum.Roles.Contains("All")))
                {
                    //if (Session[session] == null || Session[session].ToString() != ForumId.ToString())
                        throw new SecurityException("You must be logged in to view this forum");
                }
                Session["IsAdminOrModerator"] = IsAdministrator || IsForumModerator;

                populate = PopulateData;

                //phPager.Controls.Add(_topicPager);

                Page.Title = string.Format(webResources.ttlForumPage, _currentForum.Subject,  Config.ForumTitle);
                lblHotTopic.Text = string.Format(webResources.lblHotTopics, Config.HotTopicNum);
                string pagedescription = _currentForum.Description.CleanForumCodeTags();
                metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", pagedescription);

            }
            else
            {
                //Response.Redirect("error.aspx?msg=errInvalidForumId", true);
                throw new HttpException(404,"Forum not found");
            }
            InitializeStickyCollapse();

            if (Request.Params["whichpage"] != null)
            {
                try
                {
                    //_topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1;
                    _topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1;
                }
                catch (Exception)
                {
                    //Response.Redirect("error.aspx?msg=errInvalidPageNumber",true);
                    throw new HttpException(404, "forum page not found");
                }

            }

            if (!IsPostBack)
            {
                //create CacheKeyDependency if it does not exists
                if (Cache[TopicODS.CacheKeyDependency] == null || (int)Cache[TopicODS.CacheKeyDependency] != ForumId)
                {
                    object obj = ForumId;
                    Cache[TopicODS.CacheKeyDependency] = obj;
                }
                BindData();
            }
            if (Page.IsPostBack)
            {
                string postbackbtn = Request.Form["__EVENTTARGET"];
                string argument = Request.Form["__EVENTARGUMENT"];
                int id;
                switch (postbackbtn)
                {
                    case "LockTopic":
                        id = Convert.ToInt32(argument);
                        LockTopic(id);
                        break;
                    case "UnLockTopic":
                        id = Convert.ToInt32(argument);
                        UnLockTopic(id);
                        break;
                    case "DeleteTopic":
                        id = Convert.ToInt32(argument);
                        DeleteTopic(id);
                        break;
                    case "StickTopic":
                        id = Convert.ToInt32(argument);
                        StickTopic(id);
                        break;
                    case "UnStickTopic":
                        id = Convert.ToInt32(argument);
                        UnStickTopic(id);
                        break;
                }
            }
        }
Esempio n. 13
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;
            }
        }
Esempio n. 14
0
        private void EditTopic()
        {
            #region check for changes to poll

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

            if (pollregex.IsMatch(Message.Text))
            {
                string topicPoll = pollregex.Match(Message.Text).Value;
                if (topicPoll == "" || topicPoll == "remove")
                {
                    if (_thisTopic.PollId.HasValue) Polls.DeleteTopicPoll(_thisTopic.PollId.Value);
                }
                else if (_thisTopic.Forum.AllowPolls)
                {
                    var answers = new Regex(@"\[\*=(?<sort>[0-9]+)](?<answer>.+?)\[/\*]",
                        RegexOptions.Singleline | RegexOptions.ExplicitCapture);
                    string question = "";
                    var choices = new SortedList<int, string>();

                    MatchCollection mc = pollregex.Matches(topicPoll);
                    if (mc.Count > 0)
                    {
                        foreach (Match m in mc)
                        {
                            question = m.Groups["question"].Value;
                            string answer = m.Groups["answers"].Value;

                            MatchCollection ans = answers.Matches(answer);
                            foreach (Match match in ans)
                            {
                                choices.Add(Convert.ToInt32(match.Groups["sort"].Value), match.Groups["answer"].Value);
                            }
                        }
                        if (_thisTopic.PollId.HasValue)
                            Polls.UpdateTopicPoll(_thisTopic.PollId.Value, question, choices);
                    }
                }
                Message.Text = pollregex.Replace(Message.Text, "");
            }

            #endregion

            int oldforumId = _thisTopic.ForumId;
            Topics.Update(_thisTopic.Id, Message.Text, tbxSubject.Text, Member, IsAdministrator, cbxSig.Checked);
            if (ForumDropDown.SelectedValue != oldforumId.ToString() && ForumDiv.Visible)
            {
                //move the topic
                int forumid = Convert.ToInt32(ForumDropDown.SelectedValue);
                Topics.ChangeTopicForum(_thisTopic.Id, forumid);
                Snitz.BLL.Admin.UpdateForumCounts();
                object obj = -1;
                Cache["RefreshKey"] = obj;
                _thisTopic.Author = Members.GetAuthor(_thisTopic.AuthorId);

                if (Config.MoveNotify && _thisTopic.Author.Status != 0)
                {
                    _forum = Forums.GetForum(forumid);
                    string mailFile = ConfigurationManager.AppSettings["TopicMoveEmail"];
                    string strSubject = "Sent From " + Regex.Replace(Config.ForumTitle, @"&\w+;", "") + ": Topic move notification";

                    var builder = new UriBuilder("http",
                        Request.Url.DnsSafeHost,
                        Request.Url.Port, Page.ResolveUrl("~/Content/Forums/forum.aspx"), string.Format("?FORUM={0}", _forum.Id));

                    var file = new StreamReader(mailFile);
                    string msgBody = file.ReadToEnd();
                    msgBody = msgBody.Replace("<%UserName%>", _thisTopic.AuthorName);
                    msgBody = msgBody.Replace("<%ForumUrl%>", Config.ForumTitle);
                    msgBody = msgBody.Replace("<%TopicSubject%>", _thisTopic.Subject);
                    msgBody = msgBody.Replace("<%MovedTo%>", _forum.Subject);
                    msgBody = msgBody.Replace("<%URL%>", builder.Uri.AbsoluteUri);

                    var mailsender = new SnitzEmail
                    {
                        toUser = new MailAddress(_thisTopic.Author.Email, _thisTopic.AuthorName),
                        FromUser = "******",
                        subject = strSubject,
                        IsHtml = true,
                        msgBody = msgBody
                    };
                    mailsender.Send();
                }
            }
            if (cbxLock.Checked && _inModeratedList)
                Topics.SetTopicStatus(_thisTopic.Id, (int) Enumerators.PostStatus.Closed);
            if (_inModeratedList)
                Topics.MakeSticky(_thisTopic.Id, cbxSticky.Checked);

            if (pingSiteMap)
            {
                Ping("");
            }
            InvalidateForumCache();
            Response.Redirect("/Content/Forums/topic.aspx?TOPIC=" + _thisTopic.Id);
        }
Esempio n. 15
0
    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);
    }
Esempio n. 16
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);
        }
Esempio n. 17
0
 public IEnumerable<ForumInfo> PrivateForums()
 {
     List<ForumInfo> forumlist = new List<ForumInfo>();
     using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, "SELECT F.FORUM_ID,F.F_PRIVATEFORUMS,F_SUBJECT FROM " + Config.ForumTablePrefix + "FORUM F WHERE COALESCE(F.F_PRIVATEFORUMS,0) > 0", null))
     {
         while (rdr.Read())
         {
             ForumInfo forum = new ForumInfo { Id = rdr.GetInt32(0), PrivateForum = rdr.GetInt32(1), Subject = rdr.GetString(2) };
             forumlist.Add(forum);
         }
         return forumlist;
     }
 }
Esempio n. 18
0
 public static int SaveForum(ForumInfo forum)
 {
     if (forum.Id < 0)
     {
         forum.Id = AddForum(forum);
     }
     else
     {
         UpdateForum(forum);
     }
     return forum.Id;
 }
Esempio n. 19
0
 public static void UpdateForum(ForumInfo forum)
 {
     if (forum == null)
         return;
     IForum dal = Factory<IForum>.Create("Forum");
     dal.Update(forum);
 }
Esempio n. 20
0
        protected void PostMessage(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false;

            switch (_action.ToLower())
            {
                case "topic":
                    Session.Add("LastPostMade", DateTime.UtcNow.ToForumDateStr());
                    int topicid = PostNewTopic();
                    if (_forum.AllowSubscriptions)
                    {
                        var ws = new CommonFunc();
                        ws.ProcessForumSubscriptions(topicid,HttpContext.Current);
                    }
                    Response.Redirect("/Content/Forums/topic.aspx?TOPIC=" + topicid);
                    break;
                case "reply":
                case "quote":
                    Session.Add("LastPostMade", DateTime.UtcNow.ToForumDateStr());

                    int replyid = PostNewReply();
                    var topic = Topics.GetTopic(TopicId.Value);
                    _forum = Forums.GetForum(topic.ForumId);
                    if (_forum.AllowSubscriptions)
                    {
                        var ws = new CommonFunc();
                        ws.ProcessForumSubscriptions(TopicId.Value, HttpContext.Current);
                    }
                    if (topic.AllowSubscriptions)
                    {
                        var ws = new CommonFunc();
                        ws.ProcessTopicSubscriptions(TopicId.Value, replyid, HttpContext.Current);
                    }
                    Response.Redirect("/Content/Forums/topic.aspx?TOPIC=" + TopicId + "&whichpage=-1#" + replyid);
                    break;
                case "edit":
                    switch (_type)
                    {
                        case "reply" :
                            EditReply();
                            break;
                        case "topics":
                            EditTopic();
                            break;
                    }
                    break;
            }
        }
Esempio n. 21
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);
        }