Closed (fixed)
Project:
Privatemsg
Version:
4.7.x-1.2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Mar 2007 at 20:20 UTC
Updated:
24 Feb 2009 at 15:55 UTC
I think it would be smart to have an option to remove messages completely from the tables after a month because who really needs them. I just fear if my community grows large enough that the space used for messages could be enormous. I see the function _privatemsg_prune() which archives messages after a month. Is there a way to make this simply delete them? Or maybe give admin an option in the settings page?
Thanks
Comments
Comment #1
mindless commentedthe module doesn't do anything with privatemsg_archive table except add data... so, you can delete the contents of the table anytime you like. you can also comment out the one line in privatemsg.module that does INSERT INTO {privatemsg_archive} and now old messages are simply deleted instead of archived.
Comment #2
mstef commented2 concerns..heres the code for that function first..
function _privatemsg_prune() {
// move deleted message older than 1 month to archive table, and optimize table
$result = db_query('SELECT * FROM {privatemsg} WHERE author_del = 1 AND recipient_del = 1 AND timestamp < %d', time() - 3600*24*30);
while ($message = db_fetch_object($result)) {
db_query("INSERT INTO {privatemsg_archive} (id, author, recipient, subject, message, timestamp, hostname, format, folder) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d)", $message->id, $message->author, $message->recipient, $message->subject, $message->message, $message->timestamp, $message->hostname, $message->format, $message->folder);
db_query('DELETE FROM {privatemsg} WHERE id = %d', $message->id);
}
// this is MySQL-specific
if (!strncmp($GLOBALS['db_type'], 'mysql', 5)) {
db_query('OPTIMIZE TABLE {privatemsg}');
}
}
-----
First the comment says '// move deleted message older than 1 month to archive table, and optimize table'
Most importantly, "move deleted message" .. Does that mean messages that are sitting in the inbox after a month are gone, messages that the user PRESSED delete on, read or unread, etc? If it is any message older than one month, then its perfect..
ALSO, just to make sure: I should remove the db_query("INSERT INTO {privatemsg_archive} function in the while loop to achieve this right?
THANKS
Comment #3
mindless commentedYes, that's the right line with {privatemsg_archive}.
Which messages to delete is currently setup to not delete very many.. in the query at the start of "prune":
author_del = 1 AND recipient_del = 1
This portion of the query means only select messages that the recipient has deleted AND the sender has deleted (from their "Sent messages" folder). I don't think many users bother to go into Sent messages and delete stuff, so on most sites probably not many messages make it into the archive.
You can adjust that query as desired.. remove "author_del = 1 AND" to delete msgs older than a month that the receipient has deleted. Also remove "recipient_del = 1 AND" to remove all messages older than a month, deleted or not.
Comment #4
mstef commentedthank you very much
Comment #5
berdirI apologize for pinging the participants, I'm closing out old issues.
Privatemsg already implements some of these features. Please file a
feature request against the latest DRUPAL-6 version if still relevant.