]> git.mxchange.org Git - mailer.git/blobdiff - inc/autopurge/purge-inact.php
Extension ext-coupon continued, a lot improvements applied:
[mailer.git] / inc / autopurge / purge-inact.php
index bca267d2e42650ac6cad19ddb6c65a8943dadc99..917ff93dd157f18438735df9bf227c0368a05daf 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -49,14 +47,15 @@ if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) {
 } // END - if
 
 // Shall I look for inactive accounts and autopurge inactive accounts?
-if (getConfig('autopurge_inactive') == 'Y') {
+if (isAutopurgeInactiveEnabled()) {
        // Init SQLs
        initSqls();
 
        // Init exclusion list
        // @TODO Rewrite these if() blocks to a filter
        $EXCLUDE_LIST = '';
-       if (isValidUserId(getConfig('def_refid'))) $EXCLUDE_LIST .= ' AND `userid` != {?def_refid?}';
+       if (isValidUserId(getDefRefid())) $EXCLUDE_LIST .= ' AND `userid` != {?def_refid?}';
+
        // Check for more extensions
        if (isExtensionActive('beg'))     $EXCLUDE_LIST .= ' AND `userid` != {?beg_userid?}';
        if (isExtensionActive('bonus'))   $EXCLUDE_LIST .= ' AND `userid` != {?bonus_userid?}';
@@ -75,9 +74,9 @@ FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
        `status`='CONFIRMED' AND
-       `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_since?})
+       (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_since?}
        " . $EXCLUDE_LIST . "
 ORDER BY
        `userid` ASC", __FILE__, __LINE__);
@@ -126,21 +125,21 @@ FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
        `status`='CONFIRMED' AND
-       `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_time?})
+       (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_time?}
 " . $EXCLUDE_LIST . "
 ORDER BY
        `userid` ASC", __FILE__, __LINE__);
 
        if (!SQL_HASZERONUMS($result_inactive)) {
-               // Prepare variable...
-               $useridsContent = '';
+               // Prepare userid array for admin...
+               $userids = array();
 
                // Delete inactive accounts
                while ($content = SQL_FETCHARRAY($result_inactive)) {
                        // Remember userids for the admin
-                       $useridsContent .= $content['userid'] . ', ';
+                       $useridsContent[] = $content['userid'];
 
                        // Get date/time from timestamp
                        $content['last_online'] = generateDateTime($content['last_online'], 0);
@@ -149,8 +148,8 @@ ORDER BY
                        deleteUserAccount($content['userid'], loadEmailTemplate('member_autopurge_delete', $content['last_online'], ''));
                } // END - while
 
-               // Remove last comma
-               $useridsContent = str_replace(', ', "\n", substr($useridsContent, 0, -2));
+               // Display all userids
+               $useridsContent = implode("\n", $userids);
 
                // Send mail notification to admin
                if (getConfig('ap_in_notify') == 'Y') {