40de412f3f92b8206ecefebccc58f8704fedfe73
[mailer.git] / inc / autopurge / purge-tsks.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/14/2008 *
4  * ===================                          Last change: 09/14/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : purge-tsks.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Automatical purging of outdated mail links       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auto-Loeschung von veralteten Mail-Links         *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Abort if autopurge is not active or disabled by admin
45 if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) {
46         // Abort here
47         return false;
48 } // END - if
49
50 // Check version (must be >= 0.1.9)
51 if ((isExtensionInstalledAndNewer('task', '0.1.9')) && (getConfig('autopurge_tasks') == 'Y')) {
52         // Purge deleted tasks (no notification to admin)
53         SQL_QUERY("DELETE LOW_PRIORITY
54 FROM
55         `{?_MYSQL_PREFIX?}_task_system`
56 WHERE
57         `status`='DELETED' AND
58         `task_created` <= (UNIX_TIMESTAMP() - {?ap_tasks_time?})", __FILE__, __LINE__);
59
60         // Get deleted rows
61         $deletedTasks = SQL_AFFECTEDROWS();
62
63         // Do we need to send a notification?
64         if (($deletedTasks > 0) && (getConfig('ap_tasks_notify') == 'Y')) {
65                 // Send out email to admin
66                 sendAdminNotification(getMessage('AUTOPURGE_ADMIN_TASKS_SUBJECT'), 'admin_autopurge_tsks', $deletedTasks);
67         } // END - if
68 } // END - if
69
70 //
71 ?>