More threads by David Baxter PhD

David Baxter PhD

Late Founder
I've just released this as version 1.0 and instaleld it here at Psychlinks.

This add-on prunes old private messages based on age, and cleans up message receipts.

The add-on was adapted for vBulletin 3.6x from amykhar's Mass Delete Old Private Messages for vBulletin 2.2x (see http://www.vbulletin.org/forum/showthread.php?t=27421).

Thanks to Jacqueline at the http://www.vbulletin.org forum, and Sarah and Jorrit787 at the http://www.theadminzone.com forum for assistance with the MySQL queries.

This is designed to run as a cron job.

Unzip prunepms.php from the attached file and upload to your ./includes/cron/ folder. Then set up a new scheduled task as Prune PMs with your preferences as to frequency.

The attached prunepms.php file deletes PMs after 60 days:

PHP:
$time = time() - (60 * 24 * 60 * 60); 

 print ("Pruning old private messages... <br/>");
 $query = "DELETE " . TABLE_PREFIX . "pmtext . * , " . TABLE_PREFIX . "pm . * FROM " . TABLE_PREFIX . "pmtext, " . TABLE_PREFIX . "pm  WHERE " . TABLE_PREFIX . "pm.pmtextid = " . TABLE_PREFIX . "pmtext.pmtextid AND " . TABLE_PREFIX . "pmtext.dateline < $time";
 mysql_query($query);

 print("Records deleted: ");
 print (mysql_affected_rows());
 print ("<br/>");

It also deletes ALL PM receipts separately (this is because trying to delete receipts linked to the age-based PMs resulted in PMs without receipts being ignored for deletion):

PHP:
 print ("Pruning private message receipts... <br/>");
 $query = "DELETE " . TABLE_PREFIX . "pmreceipt . * FROM " . TABLE_PREFIX . "pmreceipt WHERE " . TABLE_PREFIX . "pmreceipt.pmid > 0";
 mysql_query($query);

 print("Records deleted: ");
 print (mysql_affected_rows());
 print ("<br/>");

Feel free to personalize these settings for your own requirements.

I'll support this add-on to the extent that I can but be aware I am not expert at either PHP or MySQL.

Additionally, I haven't figured out how to make this a vBulletin product for upload. Anyone who can assist with that will receive full credit here and at vbulletin.org.
 

Attachments

  • prunepms.zip
    722 bytes · Views: 2

David Baxter PhD

Late Founder
Note: No action is required on the part of Psychlinks Forum members.

What this feature does is check once a day for PMs older than 60 days and delete them... just another housekeeping task. :)

If you have PMs you want to keep, download them from the Private Message page.
 
Im glad you posted that no action is required, I didnt understand some of the first post, what is a cron Job:confused: So i do nothing and it just eats my Private Messages after a certain time?
 

Halo

Member
Okay what I don't understand is that what my inbox and sent items are telling me is that I have X number of message which is true however my total still shows the old amount that I had however I can't find where they are. I would have like to download them prior to the prune. Any help with this?
 

David Baxter PhD

Late Founder
My apologies, guys. I wrote this primarily to get rid of old PMs for a number of users who haven't even logged in in months.

I should have alerted people BEFORE I allowed it to run... :(

I did make a backup just prior to the test run. Let me see if I can reload the PMs from that.
 

Halo

Member
But my original question is how come the total doesn't change to reflect what is actually in by inbox and sent items? Is that because you still have them on backup somewhere?
 

David Baxter PhD

Late Founder
No. But certain counts are only updated periodically - I'll have to look into that.

Or maybe there's another variable that needs to be updated when you delete a PM... :panic:

Is that because you still have them on backup somewhere?

The PMs are stored in three tables in the database. When the database is backed up, it produces a single file of about 75 MB at present (which gets bigger with each post and each new member, etc.). To restore them would mean downloading that huge file and parsing it to import/restore only the PM tables. Two problems with that: (1) on dialup it would take forever, and (2) I'm not 100% certain it would not delete any new PMs sent in the meantime, so it could make things a lot worse.

To reassure ALL members, I do not have any normal or easy manner to access anyone's Private Messages, backup or not.

I recently saw that a modification that is available at vbulletin.org to allow Administrators access to Private Messages - I think even the very concept of that is despicable and an invasion of privacy. I can promise each and every one of you and all future and past members that such a modification will NEVER be installed on any forum I have anything to do with. To me that is an issue of ethics and morality and principle; it may even be illegal and if not it should be.

Private Messages, in my opinion, are exactly that: PRIVATE. And they will always remain that way here.
 
I cant help with this as I manually delete old PMs once a month and save the ones I want to my computer, everythings in order on my PMs at the moment:)
 
Replying is not possible. This forum is only available as an archive.
Top