• Quote of the Day
    "Our job in this lifetime is not to shape ourselves into some ideal we imagine we ought to be,
    but to find out who we already are and become it."
    Steven Pressfield, posted by David Baxter

David Baxter

Administrator
Joined
Mar 26, 2004
Messages
38,186
Points
113
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

Administrator
Joined
Mar 26, 2004
Messages
38,186
Points
113
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.
 

sister-ray

Member
Joined
Oct 9, 2005
Messages
2,017
Points
36
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
Joined
Jul 19, 2005
Messages
7,475
Points
36
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?
 
Joined
Oct 14, 2004
Messages
8,529
Points
48
Uh oh. I would have liked to download some of my old ones too, but I can't find them. :(
 

David Baxter

Administrator
Joined
Mar 26, 2004
Messages
38,186
Points
113
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.
 

David Baxter

Administrator
Joined
Mar 26, 2004
Messages
38,186
Points
113
Hmmm... this may be more complicated than I thought... Can you live without those messages?
 
Joined
Oct 14, 2004
Messages
8,529
Points
48
It's ok with me. I think I have emails of the ones I would have wanted to save. I think. :)
 

Halo

Member
Joined
Jul 19, 2005
Messages
7,475
Points
36
I don't have backups of them but no biggie...I think that I can survive without them :)
 

Halo

Member
Joined
Jul 19, 2005
Messages
7,475
Points
36
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

Administrator
Joined
Mar 26, 2004
Messages
38,186
Points
113
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.
 

sister-ray

Member
Joined
Oct 9, 2005
Messages
2,017
Points
36
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:)
 

David Baxter

Administrator
Joined
Mar 26, 2004
Messages
38,186
Points
113
Ok, thanks, guys.

Ladybug, can you check again please?

Anyone else seeing bad PM counts? Please report it here.
 

braveheart

Member
Joined
May 8, 2005
Messages
1,485
Points
36
4 + 3 don't = 12, does it? *scratches head*

if not, then my pm count is out.

I'm not too fussed though.
 
Joined
Jun 11, 2006
Messages
5,390
Points
36
mine still wasn't up to date, so i thought maybe deleting a message will fix it. i deleted an old pm and my counts are now correct.
 

Latest posts


Top Bottom