PDA

View Full Version : Administrative and Maintenance Tools - Prune Private Messages - Age Based


djbaxter
03-16-2007, 10:00 PM
I recommend that anyone interested in this add-on install Periodic Prune PMs (https://vborg.vbsupport.ru/showthread.php?t=179879) instead.

WORKAROUND:I have been unable to find the time to update this or to fix the incorrect counts problem. For those having this issue, use one of the "Send PM to all members" add-ons and send a message similar to the following:

To update PM counts to the correct value, simply delete this message. vBulletin will automatically then reset your PM count correctly.

I've also just discovered this new add-on for vBulletin 3.7x: Periodic Prune Pms [Cron Job - Fully Controllable] (https://vborg.vbsupport.ru/showthread.php?t=138946).


WARNING: I have discovered that, at present, the individual PM counts (user.pmtotal and user.pmunread) are not updated by this script and therefore running the script will leave members with inaccurate PM counts. I am currently seeking a way to fix this.


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 https://vborg.vbsupport.ru/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.

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:

$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):

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.

djbaxter
03-17-2007, 01:33 PM
I have not yet figured out how to make this a product for upload. Any help in doing this would be appreciated.

projectego
03-17-2007, 02:01 PM
I'll definitely install this once it becomes a product. ;)

SaN-DeeP
03-17-2007, 03:32 PM
Thanks for the release, I have this installed but having a product for same will be great.

Garamond
03-17-2007, 03:35 PM
Looks promising! :up:

djbaxter
03-17-2007, 06:09 PM
I just realized there is an issue with user.pmtotal and user.pmumread counts. The current script does not update those.

Can this be done automatically through a MySQL update query?

Ekshi
03-18-2007, 05:01 AM
Nice mod thank you.

djbaxter
03-18-2007, 06:16 PM
WORKAROUND TO PM COUNTS ISSUE: Update the counts from your Admin CP, especially thread and post counts. This seems to fix the PM counts as well.

I'm still looking for a way to automate this.

Shazz
03-18-2007, 06:21 PM
Maintenance > Update Counters

djbaxter
03-18-2007, 06:33 PM
Maintenance > Update Counters

Yes, that did seem to do it. Any ideas on how to automate this from within the script, after it deletes the old PMs?

Shazz
03-18-2007, 06:39 PM
*Edit NVM
Im working on it now..

hal05
03-18-2007, 07:15 PM
Worked great, installed!

NFLfbJunkie
03-19-2007, 12:29 PM
Will this MOD delete any private messages that are saved in created pm folders?

djbaxter
03-19-2007, 12:39 PM
I'm not 100% certain but, unless they are stored in the database somewhere other than the pm and pmtext tables, the answer is probably yes.

Endurer
03-19-2007, 01:45 PM
Cool! Digitalpoint forums have this on their board and I would love to have it.

Shazz
03-21-2007, 05:52 AM
Schdule task time for some reason never wants to update this
have to always click *Run now*
Tested on 2 sites and not working :(

* Shazz uninstalls

djbaxter
03-21-2007, 11:33 AM
How did you determine it's not running? Please note it's not writing to a log file.

Shazz
03-21-2007, 01:10 PM
How did you determine it's not running? Please note it's not writing to a log file.

Its easily to tell by how schedule task time dosen't update automatically.

djbaxter
03-21-2007, 01:24 PM
Hmmm.... okay. You can still run it manually for now - we're working on a new version of this, in any case.

PossumX
03-21-2007, 11:44 PM
Would you consider adding an option to exclude certain usergroups, by ID #? This would allow the Admin and Moderators (and others if chosen) to be immune from the pruning activity, which is appropriate on many forums, and would be worth the control level, in my opinion.

djbaxter
03-22-2007, 12:59 AM
Would you consider adding an option to exclude certain usergroups, by ID #? This would allow the Admin and Moderators (and others if chosen) to be immune from the pruning activity, which is appropriate on many forums, and would be worth the control level, in my opinion.

Sounds like a good idea, if I can figure out how to do that.

If anyone would like to have input on this or any other issue, I will happily acknowledge and share credit. :)

a1whs.com
03-22-2007, 06:25 AM
Sounds like a good idea, if I can figure out how to do that.

If anyone would like to have input on this or any other issue, I will happily acknowledge and share credit. :)

U will figure it out baxter like always. Waiting for that option before i put this on my forums :)

PossumX
04-04-2007, 02:30 AM
Any updates on this mod? Looking forward to it, but need the ability to exclude Admins and Mods (and any other group # needed).

djbaxter
04-04-2007, 02:47 AM
I'm working on it. My kids and my day job keep getting in the way. :(

PossumX
04-09-2007, 07:23 PM
I'm working on it. My kids and my day job keep getting in the way. :(

Boy, do I hear that. Story of my life.

Shazz
04-09-2007, 08:54 PM
I'm working on it. My kids and my day job keep getting in the way. :(

Take your time...
I have a tweak for the private messages not displaying right. but cron still dosen't run right :(

djbaxter
04-09-2007, 10:54 PM
My current version has a MySQL error... :(

Shazz, would you care to collaborate?

blogtorank
04-14-2007, 01:52 AM
Thanks for a great hack, hell and I was thinking of coming up with something like this, but you took the cake with this one!

:rolleyes: Should I use the search function in here? :D

All the best!

djbaxter
04-14-2007, 02:04 AM
If you can help to debug it, I'd welcome all help. :)

I'll PM the latest buggy version to anyone who can help with debugging. I've been swamped with more pressing projects these last few weeks,

PossumX
05-31-2007, 11:17 PM
I am guessing that this has "died on the vine"

djbaxter
06-01-2007, 01:19 AM
I am guessing that this has "died on the vine"

No, not quite. I just haven't been able to move it back to the top of my priority list yet. But I haven't given up on it.

As stated above, though, if anyone with more time would like to have a look at it, I'd welcome the assistance. I have two versions - the published one which works with some limitations, and a subsequent version which gives me MySQL errors.

blogtorank
08-10-2007, 04:01 PM
No one to pick this ball up?

Does anyone have a better way??

Thanks

Looks like the coder is updating the code for this per his message in green up top of the hack:

WARNING: I have discovered that, at present, the individual PM counts (user.pmtotal and user.pmunread) are not updated by this script and therefore running the script will leave members with inaccurate PM counts. I am currently seeking a way to fix this.

In another words if he supports it, I think he'll fix what you are reporting....

blogtorank
08-10-2007, 04:11 PM
I have tryed this hack and it's not working.
I'm getting

PHP Fatal error: Call to a member function on a non-object in /chroot/home/coinwash/coinwash.com/html/mb/killpms.php on line 6

Is there anyone out there who knows the Fix---Please

Thank you

Sorry for the double post, on this hack how come you are referencing a killpms.php when the hack's file name is only prunepms.php and shouldn't have nothing to do with a "killpms.php" Because only one file is for download here which is prunepms.php...


<?php
// ################################################## ####################
// # Prune Private Messages (based on age) version 1.0 #
// # by djbaxter http://forum.psychlinks.ca March 2007 #
// # #
// # Adapted for vBulletin 3.6x (tested on vBulletin 3.65) #
// # from amykhar's Mass Delete Old Private Messages for vBulletin 2.2x #
// # (see https://vborg.vbsupport.ru/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 #
// ################################################## ####################

error_reporting(E_ALL & ~E_NOTICE);

define("THIS_SCRIPT", "Prune Private Messages");

$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/>");

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/>");

?>

djbaxter
09-07-2007, 05:57 PM
Still not working?

Is this hack working for anyone???

Prune Private Messages

It works (to a degree). It's just not complete.

It will:

1. prune private messages over a certain age if run manually, which you can do from the ACP

It won't:

1. run successfully as a cron job/scheduled task, or at least it doesn't work for all configurations

2. correctly recount stored PMs for members after delteing old PMs

I apologize. I've had a series of issues - medical issues, then a death in the family, then surgery with home recovery and complications. It's still on my to-do list. I just haven't been able to get to it yet.

If anyone would like to take this and make it work the way it should, please feel free. Alternatively, feel free to make suggestions on altering the code.

PoetJA-1975
11-18-2007, 01:32 AM
WARNING: I have discovered that, at present, the individual PM counts (user.pmtotal and user.pmunread) are not updated by this script and therefore running the script will leave members with inaccurate PM counts. I am currently seeking a way to fix this.

WORKAROUND: Update the counts from your Admin CP, especially thread and post counts. This seems to fix the PM counts as well.

Does this workaround work correctly and leave Members with accurate PM counts?
Thanx,

Jacquii.

djbaxter
11-18-2007, 01:47 AM
Does this workaround work correctly and leave Members with accurate PM counts?
Thanx,

Jacquii.

Unfortunately, no.

The first time a member manually deletes a PM, the count is correctly updated. I haven't yet found a way to do it successfully from the Admin CP.

I try to work on a new version periodically as I get time but between work, family, and 4 and a half months recovering from three bouts of surgery this year I haven't yet got to a version which doesn't create some errors.

What's required is that the script correctly updates three variables: one for the PM, one for the PM text, and one for the count decrement.

I have said more than once that if there's anyone out there with more time to devote to the issue, I'll willingly turn over all credit and the current versions I have so far to them.