Ejemplo n.º 1
0
        public static DataTable GetPostsByPage(int siteId, int pageId)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("PostID", typeof(int));
            dataTable.Columns.Add("ItemID", typeof(int));
            dataTable.Columns.Add("ThreadID", typeof(int));
            dataTable.Columns.Add("ModuleID", typeof(int));
            dataTable.Columns.Add("ModuleTitle", typeof(string));
            dataTable.Columns.Add("Subject", typeof(string));
            dataTable.Columns.Add("Post", typeof(string));
            dataTable.Columns.Add("ViewRoles", typeof(string));

            using (IDataReader reader = DBForums.ForumThreadGetPostsByPage(siteId, pageId))
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();
                    row["PostID"]      = reader["PostID"];
                    row["ItemID"]      = reader["ItemID"];
                    row["ModuleID"]    = reader["ModuleID"];
                    row["ThreadID"]    = reader["ThreadID"];
                    row["ModuleTitle"] = reader["ModuleTitle"];
                    row["Subject"]     = reader["Subject"];
                    row["Post"]        = reader["Post"];
                    row["ViewRoles"]   = reader["ViewRoles"];

                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
Ejemplo n.º 2
0
        public bool DeletePost(int postId)
        {
            bool deleted = DBForums.ForumPostDelete(postId);

            if (deleted)
            {
                Forum.DecrementPostCount(this.forumID);
                if (this.totalReplies > 0)
                {
                    DBForums.ForumThreadDecrementReplyStats(this.threadID);
                }
                Forum forum = new Forum(this.forumID);

                this.moduleID = forum.ModuleId;
                this.postID   = postId;

                ContentChangedEventArgs e = new ContentChangedEventArgs();
                e.IsDeleted = true;
                OnContentChanged(e);

                int threadPostCount = ForumThread.GetPostCount(this.threadID);
                if (threadPostCount == 0)
                {
                    ForumThread.Delete(this.threadID);
                    Forum.DecrementThreadCount(this.forumID);
                }

                ResetThreadSequences();
            }


            return(deleted);
        }
Ejemplo n.º 3
0
 private bool IncrementReplyStats()
 {
     return(DBForums.ForumThreadIncrementReplyStats(
                this.threadID,
                this.postUserID,
                this.mostRecentPostDate));
 }
Ejemplo n.º 4
0
        private void ResetThreadSequences()
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("PostID", typeof(int));

            using (IDataReader reader = DBForums.ForumThreadGetPosts(this.threadID))
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();
                    row["PostID"] = reader["PostID"];
                    dataTable.Rows.Add(row);
                }
            }

            int sequence = 1;

            foreach (DataRow row in dataTable.Rows)
            {
                DBForums.ForumPostUpdateThreadSequence(
                    Convert.ToInt32(row["PostID"]),
                    sequence);
                sequence += 1;
            }
        }
Ejemplo n.º 5
0
        private bool CreateThread()
        {
            int newID = -1;

            if (threadGuid == Guid.Empty)
            {
                threadGuid = Guid.NewGuid();
            }

            newID = DBForums.ForumThreadCreate(
                this.forumID,
                this.postSubject,
                this.sortOrder,
                this.isLocked,
                this.postUserID,
                DateTime.UtcNow,
                this.threadGuid,
                this.isQuestion,
                this.includeInSiteMap,
                this.setNoIndexMeta,
                this.pageTitleOverride,
                this.modStatus,
                this.threadType);


            this.threadID = newID;
            Forum.IncrementThreadCount(this.forumID);

            return(newID > -1);
        }
Ejemplo n.º 6
0
        public static bool Delete(int threadId)
        {
            bool status = false;

            ForumThread forumThread = new ForumThread(threadId);

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("PostID", typeof(int));

            using (IDataReader reader = DBForums.ForumThreadGetPosts(threadId))
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();
                    row["PostID"] = reader["PostID"];
                    dataTable.Rows.Add(row);
                }
            }

            foreach (DataRow row in dataTable.Rows)
            {
                forumThread.DeletePost(Convert.ToInt32(row["PostID"]));
            }

            status = DBForums.ForumThreadDelete(threadId);

            return(status);
        }
Ejemplo n.º 7
0
 private bool Update()
 {
     return(DBForums.Update(
                this.itemID,
                this.createdByUserID,
                this.title,
                this.description,
                this.isModerated,
                this.isActive,
                this.sortOrder,
                this.postsPerPage,
                this.threadsPerPage,
                this.allowAnonymousPosts,
                this.rolesThatCanPost,
                this.rolesThatCanModerate,
                this.moderatorNotifyEmail,
                this.includeInGoogleMap,
                this.addNoIndexMeta,
                this.closed,
                this.visible,
                this.requireModeration,
                this.requireModForNotify,
                this.allowTrustedDirectPosts,
                this.allowTrustedDirectNotify));
 }
Ejemplo n.º 8
0
        public bool Subscribe(int userId)
        {
            if (DBForums.ForumSubscriptionExists(this.itemID, userId))
            {
                return(true);
            }

            return(DBForums.AddSubscriber(this.itemID, userId, Guid.NewGuid()));
        }
Ejemplo n.º 9
0
 public static IDataReader GetSubscriberPage(
     int forumId,
     int pageNumber,
     int pageSize,
     out int totalPages)
 {
     return(DBForums.GetSubscriberPage(
                forumId,
                pageNumber,
                pageSize,
                out totalPages));
 }
Ejemplo n.º 10
0
 public static IDataReader GetPageByUser(
     int userId,
     int siteId,
     int pageNumber,
     int pageSize,
     out int totalPages)
 {
     return(DBForums.GetThreadPageByUser(
                userId,
                siteId,
                pageNumber,
                pageSize,
                out totalPages));
 }
Ejemplo n.º 11
0
        private bool CreatePost()
        {
            int  newID    = -1;
            bool approved = false;

            if (
                (ConfigurationManager.AppSettings["PostsApprovedByDefault"] != null) &&
                (string.Equals(ConfigurationManager.AppSettings["PostsApprovedByDefault"], "true", StringComparison.InvariantCultureIgnoreCase))
                )
            {
                approved = true;
            }

            this.mostRecentPostDate = DateTime.UtcNow;

            if (postGuid == Guid.Empty)
            {
                postGuid = Guid.NewGuid();
            }

            newID = DBForums.ForumPostCreate(
                this.threadID,
                this.postSubject,
                this.postMessage,
                approved,
                this.PostUserId,
                this.mostRecentPostDate,
                this.postGuid,
                this.approvedBy,
                this.approvedUtc,
                this.userIp,
                this.notificationSent,
                this.postModStatus);

            this.postID = newID;
            Forum.IncrementPostCount(this.forumID, this.postUserID, this.mostRecentPostDate);
            SiteUser.IncrementTotalPosts(this.postUserID);
            //IndexHelper.IndexItem(this);

            bool result = (newID > -1);

            //if (result)
            //{
            //    ContentChangedEventArgs e = new ContentChangedEventArgs();
            //    OnContentChanged(e);
            //}

            return(result);
        }
Ejemplo n.º 12
0
        public static int GetUserIdForSubscription(Guid subGuid)
        {
            int userId = -1;

            using (IDataReader reader = DBForums.ForumThreadGetSubscriber(subGuid))
            {
                if (reader.Read())
                {
                    userId = Convert.ToInt32(reader["UserID"]);
                }
            }


            return(userId);
        }
Ejemplo n.º 13
0
        public DataTable GetPostIdList()
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("PostID", typeof(int));

            using (IDataReader reader = DBForums.ForumThreadGetPosts(this.threadID))
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();
                    row["PostID"] = reader["PostID"];
                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
Ejemplo n.º 14
0
        private void GetPost(int postId)
        {
            using (IDataReader reader = DBForums.ForumThreadGetPost(postId))
            {
                if (reader.Read())
                {
                    this.postID      = Convert.ToInt32(reader["PostID"]);
                    this.postUserID  = Convert.ToInt32(reader["UserID"]);
                    this.postSubject = reader["Subject"].ToString();
                    this.postMessage = reader["Post"].ToString();


                    this.isApproved    = Convert.ToBoolean(reader["Approved"]);
                    this.postSortOrder = Convert.ToInt32(reader["SortOrder"]);
                    currentPostDate    = Convert.ToDateTime(reader["PostDate"]);

                    if (reader["PostGuid"] != DBNull.Value)
                    {
                        this.postGuid = new Guid(reader["PostGuid"].ToString());
                    }

                    if (reader["AnswerVotes"] != DBNull.Value)
                    {
                        this.answerVotes = Convert.ToInt32(reader["AnswerVotes"]);
                    }

                    if (reader["ApprovedBy"] != DBNull.Value)
                    {
                        this.approvedBy = new Guid(reader["ApprovedBy"].ToString());
                    }

                    if (reader["ApprovedUtc"] != DBNull.Value)
                    {
                        this.approvedUtc = Convert.ToDateTime(reader["ApprovedUtc"]);
                    }

                    this.userIp = reader["UserIp"].ToString();

                    notificationSent = Convert.ToBoolean(reader["NotificationSent"]);
                    postModStatus    = Convert.ToInt32(reader["ModStatus"]);
                }
            }
        }
Ejemplo n.º 15
0
        public int Post()
        {
            bool newThread = (this.threadID < 0);

            if (newThread)
            {
                this.CreateThread();
            }

            if (this.postID > -1)
            {
                this.UpdatePost();
            }
            else
            {
                this.CreatePost();
                if (!newThread)
                {
                    this.IncrementReplyStats();
                }
            }

            if (this.subscribeUserToThread)
            {
                if (!DBForums.ForumSubscriptionExists(this.forumID, this.postUserID))
                {
                    DBForums.ForumThreadAddSubscriber(this.threadID, this.postUserID, Guid.NewGuid());
                }
            }

            if (this.postID > -1)
            {
                ContentChangedEventArgs e = new ContentChangedEventArgs();
                OnContentChanged(e);
            }


            return(this.postID);
        }
Ejemplo n.º 16
0
        public bool UpdateThread()
        {
            bool result = false;

            result = DBForums.ForumThreadUpdate(
                this.threadID,
                this.forumID,
                this.subject,
                this.sortOrder,
                this.isLocked,
                this.isQuestion,
                this.includeInSiteMap,
                this.setNoIndexMeta,
                this.pageTitleOverride,
                this.modStatus,
                this.threadType,
                this.assignedTo,
                this.lockedBy,
                this.lockedReason,
                this.lockedUtc);

            if (this.forumID != this.origForumID)
            {
                Forum.DecrementThreadCount(this.origForumID);
                Forum.IncrementThreadCount(this.forumID);

                ForumThreadMovedArgs e = new ForumThreadMovedArgs();
                e.ForumId         = forumID;
                e.OriginalForumId = origForumID;
                OnThreadMoved(e);


                Forum.RecalculatePostStats(this.origForumID);
                Forum.RecalculatePostStats(this.forumID);
            }

            return(result);
        }
Ejemplo n.º 17
0
        private bool Create()
        {
            int newID = -1;

            if (forumGuid == Guid.Empty)
            {
                forumGuid = Guid.NewGuid();
            }

            newID = DBForums.Create(
                this.forumGuid,
                this.moduleID,
                this.createdByUserID,
                this.title,
                this.description,
                this.isModerated,
                this.isActive,
                this.sortOrder,
                this.postsPerPage,
                this.threadsPerPage,
                this.allowAnonymousPosts,
                this.rolesThatCanPost,
                this.rolesThatCanModerate,
                this.moderatorNotifyEmail,
                this.includeInGoogleMap,
                this.addNoIndexMeta,
                this.closed,
                this.visible,
                this.requireModeration,
                this.requireModForNotify,
                this.allowTrustedDirectPosts,
                this.allowTrustedDirectNotify);

            this.itemID = newID;

            return(newID > -1);
        }
Ejemplo n.º 18
0
        public bool UpdatePost()
        {
            bool result = false;

            result = DBForums.ForumPostUpdate(
                this.postID,
                this.postSubject,
                this.postMessage,
                this.postSortOrder,
                this.isApproved,
                this.approvedBy,
                this.approvedUtc,
                this.notificationSent,
                this.postModStatus);

            //IndexHelper.IndexItem(this);
            //if (result)
            //{
            //    ContentChangedEventArgs e = new ContentChangedEventArgs();
            //    OnContentChanged(e);
            //}

            return(result);
        }
Ejemplo n.º 19
0
 public static bool DecrementPostCount(int forumId)
 {
     return(DBForums.DecrementPostCount(forumId));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// passing in -1 for userId will update the stats of all users.
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static bool UpdateUserStats(int userId)
 {
     return(DBForums.UpdateUserStats(userId));
 }
Ejemplo n.º 21
0
 public static bool IsSubscribed(int forumId, int userId)
 {
     return(DBForums.ForumSubscriptionExists(forumId, userId));
 }
Ejemplo n.º 22
0
 public static bool DeleteBySite(int siteId)
 {
     return(DBForums.DeleteBySite(siteId));
 }
Ejemplo n.º 23
0
 public static bool DeleteByModule(int moduleId)
 {
     return(DBForums.DeleteByModule(moduleId));
 }
Ejemplo n.º 24
0
 public static bool Delete(int itemId)
 {
     return(DBForums.Delete(itemId));
 }
Ejemplo n.º 25
0
 public static bool IncrementThreadCount(int forumId)
 {
     return(DBForums.IncrementThreadCount(forumId));
 }
Ejemplo n.º 26
0
 public static bool DeleteSubscription(int subscriptionId)
 {
     return(DBForums.DeleteSubscription(subscriptionId));
 }
Ejemplo n.º 27
0
 public static bool IncrementPostCount(int forumId, int mostRecentPostUserId, DateTime mostRecentPostDate)
 {
     return(DBForums.IncrementPostCount(forumId, mostRecentPostUserId, mostRecentPostDate));
 }
Ejemplo n.º 28
0
 public static IDataReader GetForums(int moduleId, int userId)
 {
     return(DBForums.GetForums(moduleId, userId));
 }
Ejemplo n.º 29
0
 public IDataReader GetPostsForRss()
 {
     return(DBForums.ForumThreadGetPostsForRss(SiteId, PageId, ModuleId, ItemId, ThreadId, MaximumDays));
 }
Ejemplo n.º 30
0
 public static bool RecalculatePostStats(int forumId)
 {
     //implemented for PostgreSQL. --Dean 9/11/05
     return(DBForums.RecalculatePostStats(forumId));
 }