MyBB Community Forums

Full Version: Prune old PMs + optimize DB v1.0.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Description

Simple plugin which automatically checks for old read/unread PMs and deletes them automatically + optimizes forum tables in MyBB automatically.
  • read PMs after 30 days
  • unread PMs after 90 days
-> you can set your own values in prunepms.php located in /tasks folder


Thanks to @Jones H and @Euan T @Supryk

Installation
  • Just upload all files into your forum and activate it in the ACP.
  • Add a notice into your private template - tutorial here:
    Do you wanna show a notice for all users inform them about automatic deleting PMs? If yes, please follow these steps:
  • 1) Go to your ACP 
  • 2) Open template group "Private messaging templates" and open "private" template 
  • 3) Find this: 
    {$emptyexportlink}</span>
  • 4) Add after this: 
    <span class="smalltext" style="float: right; color: #000; font-weight: bold; cursor: help;" title="Read PMs will be deleted after 30 days, unread PMs will be deleted after 90 days automatically.">Read PMs will be deleted after 30 days, unread PMs will be deleted after 90 days automatically!</span>
  • 5) Save the template, you are DONE! 
Downloads Support
  • Please write your problems/ideas here in our support thread.
How to update
  • Deactivate plugin
  • Copy and overwrite old files with new ones
  • Activate plugin
IMO tasks should be distributed without plugin files. And tasks can already be turned off independently BTW.

Nice either way.
I didnt know it, I am sorry (my first plugin for mybb). This is an initial release. I wanna add custom settings in the next version.
Very Useful ... Thanks. Wink
(2014-11-12, 05:55 PM)Omar G. Wrote: [ -> ]IMO tasks should be distributed without plugin files. And tasks can already be turned off independently BTW.

Nice either way.
I know about it. I think it is better to handle this over settings which will be added in future (at least add settings for custom time interval). I need to get info howt PMs work in MyBB.
I have 3 questions:
1) Messages in trash bin - are they delete automatically after 30 days? (I am not sure, but mybb does it automatically)
2) Are messages in sent box affected too?
3) What about drafts? Delete them after 60 days automatically? I am not sure if it is possible.
1) Not that I am aware of.
2) With your code, yes they are. Sent items have a value of 2 for the folder column.
3) Drafts have a value of 3 for the folder column.

Regarding the optimize db file: It is going to be a killer to do on large forums. It could easily hang on the user. This is a rare exception where I'd say to break the queries up instead of doing them as one query. Also, it won't work if the table type is Innodb ( while that is not default, it is something that is recommended for large forums. )
Thanks for info. I will add pruning for drafts and items in trash bin is next version.

About DB file - OK, I will look and maybe just add optimization for PMs table, which will be enough.


EDIT: Optimize DB task is changed - optimizes only PM, task and tasklog tables - less resources hungry. I will add support for Innodb
I have one suggestion for you Eldenroot

	$query = $db->simple_select('tasks', 'tid', "file='task_prunepms'", array('limit' => '1'));
    if($db->num_rows($query) == 0)
	{
                require_once MYBB_ROOT."/inc/functions_task.php";
		$new_task = array(
			"title" => "Prune old PMs",
			"description" => "Checks for old PMs and deletes them. /Inbox&Sent&Trash folders/",
			"file" => "task_prunepms",
			"minute" => '1',
			"hour" => '0',
			"day" => '*',
			"month" => '*',
			"weekday" => '*',
			"enabled" => '1',
			"logging" => '1',
		);

			$new_task['nextrun'] = fetch_next_run($new_task);
			$tid = $db->insert_query("tasks", $new_task);

			$cache->update_tasks();
			run_task($tid);
	}

one question less and less code
Good one, thanks! It will be propably added into next version.
Thanks for good plugin


my suggestion:
1- add text on PMs page to warn users about automatically delete.
2- add setting to ignore by user id and group id.
Pages: 1 2 3 4 5