Example #1
0
        protected virtual PostDetails GetPostFromReader(IDataReader reader, bool readBody)
        {
            PostDetails post = new PostDetails(
                (int)reader["PostID"],
                (DateTime)reader["AddedDate"],
                reader["AddedBy"].ToString(),
                reader["AddedByIP"].ToString(),
                (int)reader["ForumID"],
                reader["ForumTitle"].ToString(),
                (int)reader["ParentPostID"],
                reader["Title"].ToString(),
                null,
                (bool)reader["Approved"],
                (bool)reader["Closed"],
                (int)reader["ViewCount"],
                (int)reader["ReplyCount"],
                (DateTime)reader["LastPostDate"],
                reader["LastPostBy"].ToString());

            if (readBody)
            {
                post.Body = reader["Body"].ToString();
            }

            return(post);
        }
Example #2
0
 public abstract int InsertPost(PostDetails post);
Example #3
0
 public abstract bool UpdatePost(PostDetails post);
Example #4
0
 /// <summary>
 /// Returns a Post object filled with the data taken from the input PostDetails
 /// </summary>
 private static Post GetPostFromPostDetails(PostDetails record)
 {
     if (record == null)
     return null;
      else
      {
     return new Post(record.ID, record.AddedDate, record.AddedBy, record.AddedByIP,
        record.ForumID, record.ForumTitle, record.ParentPostID, record.Title,
        record.Body, record.Approved, record.Closed, record.ViewCount,
        record.ReplyCount, record.LastPostBy, record.LastPostDate);
      }
 }
Example #5
0
        /// <summary>
        /// Updates an existing post
        /// </summary>
        public static bool UpdatePost(int id, string title, string body)
        {
            title = BizObject.ConvertNullToEmptyString(title);
             body = BizObject.ConvertNullToEmptyString(body);

             PostDetails record = new PostDetails(id, DateTime.Now, "", "", 0, "", 0,
            title, body, true, false, 0, 0, DateTime.Now, "");
             bool ret = SiteProvider.Forums.UpdatePost(record);

             BizObject.PurgeCacheItems("forums_unapprovedposts");
             BizObject.PurgeCacheItems("forums_threads");
             BizObject.PurgeCacheItems("forums_threadcount");
             BizObject.PurgeCacheItems("forums_thread_" + id.ToString());
             BizObject.PurgeCacheItems("forums_post_" + id.ToString());
             return ret;
        }
Example #6
0
        /// <summary>
        /// Creates a new post
        /// </summary>
        public static int InsertPost(int forumID, int parentPostID, 
            string title, string body, bool closed)
        {
            title = BizObject.ConvertNullToEmptyString(title);
             body = BizObject.ConvertNullToEmptyString(body);

             // if the target forum is moderated, the current user must be an
             // admin, editor or moderator to insert the post in approved status
             bool approved = true;
             Forum forum = Forum.GetForumByID(forumID);
             if (forum.Moderated)
             {
            if (!BizObject.CurrentUser.IsInRole("Administrators") &&
               !BizObject.CurrentUser.IsInRole("Editors") &&
               !BizObject.CurrentUser.IsInRole("Moderators"))
               approved = false;
             }

             PostDetails record = new PostDetails(0, DateTime.Now, BizObject.CurrentUserName, BizObject.CurrentUserIP,
            forumID, "", parentPostID, title, body, approved, closed, 0, 0, DateTime.Now, BizObject.CurrentUserName);
             int ret = SiteProvider.Forums.InsertPost(record);

             if (approved)
             {
            BizObject.PurgeCacheItems("forums_threads");
            BizObject.PurgeCacheItems("forums_thread_" + parentPostID.ToString());
            BizObject.PurgeCacheItems("forums_threadcount");
             }
             else
            BizObject.PurgeCacheItems("forums_unapprovedposts");

             return ret;
        }
 public abstract bool UpdatePost(PostDetails post);
 public abstract int InsertPost(PostDetails post);
        protected virtual PostDetails GetPostFromReader(IDataReader reader, bool readBody)
        {
            PostDetails post = new PostDetails(
            (int)reader["PostID"],
            (DateTime)reader["AddedDate"],
            reader["AddedBy"].ToString(),
            reader["AddedByIP"].ToString(),
            (int)reader["ForumID"],
            reader["ForumTitle"].ToString(),
            (int)reader["ParentPostID"],
            reader["Title"].ToString(),
            null,
            (bool)reader["Approved"],
            (bool)reader["Closed"],
            (int)reader["ViewCount"],
            (int)reader["ReplyCount"],
            (DateTime)reader["LastPostDate"],
            reader["LastPostBy"].ToString());

             if (readBody)
            post.Body = reader["Body"].ToString();

             return post;
        }