Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Purge PMs?

Quote Reply
Purge PMs?
Will it be possible to purge PMs in a future update?

Jason
Quote Reply
Re: [wickedmoon] Purge PMs? In reply to
It is a feature that will be included eventually, however I cannot give you a specific time frame on it. You could do it in the meantime with a GForum global, such as:

Code:
return unless $IN->param('purge_messages') and GT::Template->tags->{current_user_status} == 3;
my $deleted = $DB->table('Message')->delete(
GT::SQL::Condition->new(
msg_time => '<' => time - 90 * 24*60*60,
msg_keep => '=' => 0
)
);
return { messages_purged => defined($deleted), messages_deleted => $deleted };

Change 90 to the number of days before which you want to purge. You could comment out the 'msgs_keep' line if you want it to purge even messages that have been marked as "kept". Then in a template (perhaps on the main page), do something like:

Code:
<%if current_user_status == 3%>
<%global_name%>
<%if messages_purged%>
<%messages_delete%> messages purged
<%else%>
<a href="gforum.cgi?do=<%this_do%>;purge_messages=1;<%hidden_query%>">Purge private messages</a>
<%endif%>
<%endif%>

Now, when you're logged in as an administrator, you can click the "Purge private messages" link to perform a purge.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Purge PMs? In reply to
Code:
sub { return unless $IN->param('purge_messages') and GT::Template->tags->{current_user_status} == 3;
my $deleted = $DB->table('Message')->delete(
GT::SQL::Condition->new(
msg_time => '<' => time - 90 * 24*60*60,
msg_keep => '=' => 0
)
);
return { messages_purged => defined($deleted), messages_deleted => $deleted }; }

I entered the above as a Global Var. Is this right? I named it purge_pm and put this into one of the templates:

Code:
<%if current_user_status == 3%> <%purge_pm%> <%if messages_purged%> <%messages_delete%> messages purged <%else%> <a href="gforum.cgi?do=<%this_do%>;purge_messages=1;<%hidden_query%>">Purge private messages</a> <%endif%> <%endif%>

Should this have worked? With my own pm's, I'm still seeing messages in there from last year.

Jason