New wrapper functions introduced
[mailer.git] / inc / reset / reset_profile.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/24/2009 *
4  * ===================                          Last change: 06/20/2010 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : reset_profile.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Sends out notifications to keep profiles updated *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Sendet Erinnerngen aus, damit die Profile        *
12  *                     von den Mitgliedern aktuell gehalten werden      *
13  * -------------------------------------------------------------------- *
14  * $Revision::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
18  * Needs to be in all Files and every File needs "svn propset           *
19  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
20  * -------------------------------------------------------------------- *
21  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
22  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
23  * For more information visit: http://www.mxchange.org                  *
24  *                                                                      *
25  * This program is free software; you can redistribute it and/or modify *
26  * it under the terms of the GNU General Public License as published by *
27  * the Free Software Foundation; either version 2 of the License, or    *
28  * (at your option) any later version.                                  *
29  *                                                                      *
30  * This program is distributed in the hope that it will be useful,      *
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
33  * GNU General Public License for more details.                         *
34  *                                                                      *
35  * You should have received a copy of the GNU General Public License    *
36  * along with this program; if not, write to the Free Software          *
37  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
38  * MA  02110-1301  USA                                                  *
39  ************************************************************************/
40
41 // Some security stuff...
42 if (!defined('__SECURITY')) {
43         die();
44 } elseif ((!isHtmlOutputMode()) || (!isResetModeEnabled())) {
45         // Do not execute when script is in CSS mode or no daily reset
46         return;
47 } elseif (!isExtensionActive('profile')) {
48         logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
49         return;
50 }
51
52 if ((getConfig('send_prof_update') == 'Y') && (getConfig('profile_update') > 0) && (getConfig('resend_profile_update'))) {
53         // Load personal data
54         $result = SQL_QUERY('SELECT `userid`, `email`, `last_update`, `joined`
55 FROM
56         `{?_MYSQL_PREFIX?}_user_data`
57 WHERE
58         (`last_update` < (UNIX_TIMESTAMP() - {?profile_update?}) AND
59         `last_update` > 0 AND
60         `last_profile_sent` < (UNIX_TIMESTAMP() - {?resend_profile_update?}))
61 OR
62         (`last_update` = 0 AND `last_profile_sent` = 0 AND `joined` < (UNIX_TIMESTAMP() - {?profile_update?}))
63 ORDER BY
64         `userid` ASC', __FILE__, __LINE__);
65
66         // Do we have some notifications to sent?
67         if (!SQL_HASZERONUMS($result)) {
68                 // We need to send-out notifications...
69                 while ($content = SQL_FETCHARRAY($result)) {
70                         // Translate timestamp
71                         $content['joined'] = generateDateTime($content['joined'], 0);
72
73                         if (round($content['last_update']) == '0') {
74                                 // Has never changed his accont
75                                 $content['last_update'] = '{--PROFILE_NEVER_CHANGED--}';
76                         } else {
77                                 // Has changed his account
78                                 $content['last_update'] = generateDateTime($content['last_update'], 0);
79                         }
80
81                         // Load email template and send mail away
82                         $message = loadEmailTemplate('profile-updte', $content, bigintval($content['userid']));
83                         sendEmail($content['email'], '{--PROFILE_OUTDATED--}', $message);
84
85                         // Update profile data
86                         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `last_profile_sent`=UNIX_TIMESTAMP(), `notified`='Y' WHERE `userid`=%s LIMIT 1",
87                                 array(bigintval($content['userid'])), __FILE__, __LINE__);
88                 } // END - while
89         } // END - if
90
91         // Free result
92         SQL_FREERESULT($result);
93 }
94
95 // [EOF]
96 ?>