gboyer wrote
ucann:
I would also like to be able to purge off Posts and/or Threads that are "expired". I would like to purge any that are older than 1 month.
Have you found any resolution?
Thanks.
Hi gboyer,
I am working on it now. Basically it is working but I still need to work on it.
My solution is to use a stored procedure called Forum_Post_Delete that comes with the Forum module. This procedure has four variables:
@PostID INT,
@ModID INT,
@Notes NVARCHAR(1024),
@PortalID INT
As I mentioned in my previous post, I only delete threads in a “Buy and Sell” group when their posting date is expired. So there are some conditions in my case which are:
Group ID is fixed – “Buy and Sell” group
Mod ID is fixed – who executes the deletion and who is me
Posting date – variable
To use procedure Forum_Post_Delete needs, you need to determine PostID, and the PostID must be determined by the expired date. The postID can be selected from below SQL statement
SELECT DISTINCT Forum_Threads.ThreadID
FROM Forum_Forums INNER JOIN
Forum_Groups ON Forum_Forums.GroupID = Forum_Groups.GroupID INNER JOIN
Forum_Threads ON Forum_Forums.ForumID = Forum_Threads.ForumID INNER JOIN
Forum_Posts ON Forum_Threads.ThreadID = Forum_Posts.ThreadID
WHERE (Forum_Groups.GroupID = 5) AND (DATEDIFF(day, Forum_Posts.CreatedDate, GETDATE()) >= 14)
GroupID = 5, in my case, because it is fixed.
Then I write my own stored procedure:
ALTER procedure ZZZ_UCCAN_Forum_Thread_Delete
AS
DECLARE @@Thread_ID INT
Set @@Thread_ID = (SELECT DISTINCT Forum_Threads.ThreadID
FROM Forum_Forums INNER JOIN
Forum_Groups ON Forum_Forums.GroupID = Forum_Groups.GroupID INNER JOIN
Forum_Threads ON Forum_Forums.ForumID = Forum_Threads.ForumID INNER JOIN
Forum_Posts ON Forum_Threads.ThreadID = Forum_Posts.ThreadID
WHERE (Forum_Groups.GroupID = 5) AND (DATEDIFF(day, Forum_Posts.CreatedDate, GETDATE()) >= 1))
EXEC Forum_Post_Delete @PostID = @@Thread_ID,@ModID = 64,@Notes="Expired deletion",@PortalID = 0
Hopefully it works for you as well.