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); }
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); }
private bool IncrementReplyStats() { return(DBForums.ForumThreadIncrementReplyStats( this.threadID, this.postUserID, this.mostRecentPostDate)); }
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; } }
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); }
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); }
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)); }
public bool Subscribe(int userId) { if (DBForums.ForumSubscriptionExists(this.itemID, userId)) { return(true); } return(DBForums.AddSubscriber(this.itemID, userId, Guid.NewGuid())); }
public static IDataReader GetSubscriberPage( int forumId, int pageNumber, int pageSize, out int totalPages) { return(DBForums.GetSubscriberPage( forumId, pageNumber, pageSize, out totalPages)); }
public static IDataReader GetPageByUser( int userId, int siteId, int pageNumber, int pageSize, out int totalPages) { return(DBForums.GetThreadPageByUser( userId, siteId, pageNumber, pageSize, out totalPages)); }
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); }
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); }
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); }
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"]); } } }
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); }
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); }
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); }
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); }
public static bool DecrementPostCount(int forumId) { return(DBForums.DecrementPostCount(forumId)); }
/// <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)); }
public static bool IsSubscribed(int forumId, int userId) { return(DBForums.ForumSubscriptionExists(forumId, userId)); }
public static bool DeleteBySite(int siteId) { return(DBForums.DeleteBySite(siteId)); }
public static bool DeleteByModule(int moduleId) { return(DBForums.DeleteByModule(moduleId)); }
public static bool Delete(int itemId) { return(DBForums.Delete(itemId)); }
public static bool IncrementThreadCount(int forumId) { return(DBForums.IncrementThreadCount(forumId)); }
public static bool DeleteSubscription(int subscriptionId) { return(DBForums.DeleteSubscription(subscriptionId)); }
public static bool IncrementPostCount(int forumId, int mostRecentPostUserId, DateTime mostRecentPostDate) { return(DBForums.IncrementPostCount(forumId, mostRecentPostUserId, mostRecentPostDate)); }
public static IDataReader GetForums(int moduleId, int userId) { return(DBForums.GetForums(moduleId, userId)); }
public IDataReader GetPostsForRss() { return(DBForums.ForumThreadGetPostsForRss(SiteId, PageId, ModuleId, ItemId, ThreadId, MaximumDays)); }
public static bool RecalculatePostStats(int forumId) { //implemented for PostgreSQL. --Dean 9/11/05 return(DBForums.RecalculatePostStats(forumId)); }