A major bugfix for extension registration, ext-coupon does now purge coupons:
authorRoland Häder <roland@mxchange.org>
Tue, 5 Jul 2011 02:48:41 +0000 (02:48 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 5 Jul 2011 02:48:41 +0000 (02:48 +0000)
- Fixed registration of extensions with update/register dependencies, they
  were not executed before the actual selected extension was registered
- Purging of coupons added (was not yet implemented) with details of every purged coupon
- Fixed some language strings for link titles (again)
- TODOs.txt updated

12 files changed:
.gitattributes
DOCS/TODOs.txt
inc/extensions-functions.php
inc/extensions/ext-autopurge.php
inc/extensions/ext-coupon.php
inc/extensions/ext-rewrite.php
inc/language/coupon_de.php
inc/language/de.php
inc/purge/purge-coupon.php [new file with mode: 0644]
inc/template-functions.php
templates/de/emails/admin/admin_coupon_purge.tpl [new file with mode: 0644]
templates/de/emails/admin/admin_coupon_purge_row.tpl [new file with mode: 0644]

index 5b6d0608692ef7d0f1aeff251ec03d0c7dc04ef6..f58a98d39653b482f96470863c243b9f78061b5a 100644 (file)
@@ -724,6 +724,7 @@ inc/pool/pool-bonus.php svneol=native#text/plain
 inc/pool/pool-user.php svneol=native#text/plain
 inc/purge/.htaccess svneol=native#text/plain
 inc/purge/purge- svneol=native#text/plain
+inc/purge/purge-coupon.php svneol=native#text/plain
 inc/purge/purge-general.php svneol=native#text/plain
 inc/purge/purge-inact.php svneol=native#text/plain
 inc/purge/purge-mails.php svneol=native#text/plain
@@ -788,6 +789,8 @@ templates/de/emails/admin/admin_autopurge_unconfirmed.tpl svneol=native#text/pla
 templates/de/emails/admin/admin_coupon.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_coupon_cashed.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_coupon_code.tpl svneol=native#text/plain
+templates/de/emails/admin/admin_coupon_purge.tpl svneol=native#text/plain
+templates/de/emails/admin/admin_coupon_purge_row.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_del_surfbar_urls.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_edit_surfbar_urls.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_extension_deactivated.tpl svneol=native#text/plain
index e1382d6dfcc6331606364aa546730302e6f94ec4..2f29fb7158bb848183fc7947959c42b10764550b 100644 (file)
@@ -41,9 +41,9 @@
 ./inc/extensions/ext-yoomedia.php:121:         // @TODO Can this be moved into a database table?
 ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y');
 ./inc/extensions-functions.php:155:    // @TODO Do we still need this? setExtensionUpdateNotes('');
-./inc/extensions-functions.php:1943:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable'
-./inc/extensions-functions.php:424:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
-./inc/extensions-functions.php:559:            // @TODO Extension is loaded, what next?
+./inc/extensions-functions.php:1947:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable'
+./inc/extensions-functions.php:425:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
+./inc/extensions-functions.php:562:            // @TODO Extension is loaded, what next?
 ./inc/filter/bonus_filter.php:56:              // @TODO This query isn't right, it will only update if the user was for a longer time away!
 ./inc/filter/cache_filter.php:92:              // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal.
 ./inc/functions.php:1223:                      // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
index 53619443ea04258c5da03a41596399a1f92d5847..430fd659b7eddd25d4a460f6fe03ce7873352d65 100644 (file)
@@ -179,7 +179,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal
 }
 
 // Registers an extension and possible update dependencies
-function registerExtension ($ext_name, $taskId, $dry_run = false) {
+function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates = false) {
        // Set current extension name
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $taskId . ',dry_run=' . intval($dry_run) . ' - ENTERED!');
        setCurrentExtensionName($ext_name);
@@ -197,9 +197,10 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
        } // END - if
 
        // When this extension is already in registration/update phase, all is fine
-       if ((isExtensionRegistrationRunning($ext_name)) || (isExtensionUpdateRunning($ext_name))) {
+       if ((isExtensionRegistrationRunning($ext_name)) || ((isExtensionUpdateRunning($ext_name)) && ($ignoreUpdates === false))) {
                // Then abort here with 'true' becaus it is fine
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in registration/update phase, all fine.');
+               ///* BUG: */ debug_report_bug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId=' . $taskId . ',dry_run=' . intval($dry_run) . ' - Please investigate!');
                return true;
        } // END - if
 
@@ -239,11 +240,11 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
 
        // Init variables
        $ret = false;
-       $test = false;
+       $processResult = false;
        initIncludePool('extension');
 
        // By default we have no failures
-       setExtensionReportsFailure(false);
+       enableExtensionReportingFailure();
 
        // Does this extension exists?
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
@@ -287,17 +288,17 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
                                // Extension version set? If empty the extension is not registered
                                if (empty($ext_ver)) {
                                        // Extension not registered so far so first load task's id...
-                                       $task = determineExtensionTaskId($ext_update);
+                                       $taskId = determineExtensionTaskId($ext_update);
 
                                        // Entry found?
-                                       if ($task > 0) {
+                                       if ($taskId > 0) {
                                                // Try to register the extension
-                                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ':ext_update=' . $ext_update . ',taskId=' . $task);
-                                               $test = registerExtension($ext_update, $task, isExtensionDryRun(), false);
+                                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ',taskId=' . $taskId . ',isExtensionDryRun()=' . isExtensionDryRun());
+                                               $processResult = registerExtension($ext_update, $taskId, isExtensionDryRun(), true);
 
                                                // Reset extension name
                                                setCurrentExtensionName($ext_name);
-                                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',test=' . intval($test));
+                                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ',processResult=' . intval($processResult));
                                        } // END - if
                                } elseif ($ext_ver != getCurrentExtensionVersion()) {
                                        // Ok, update this extension now
@@ -312,14 +313,14 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
                                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',currVer=' . getCurrentExtensionVersion());
 
                                        // All okay!
-                                       $test = true;
+                                       $processResult = true;
                                } else {
                                        // Nothing to register / update before...
-                                       $test = true;
+                                       $processResult = true;
                                }
                        } else {
                                // Required file for update does not exists!
-                               $test = true;
+                               $processResult = true;
                                // But this is fine for the first time...
                        }
 
@@ -330,19 +331,19 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
                // Is there no update?
                if (countExtensionUpdateDependencies(getCurrentExtensionName()) == 0) {
                        // Then test is passed!
-                       $test = true;
+                       $processResult = true;
                } // END - if
 
                // Switch back to register mode
                setExtensionMode('register');
 
                // Remains true if extension registration reports no failures
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',test=' . intval($test));
-               $test = (($test === true) && (getExtensionReportsFailure() === false));
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',test=' . intval($test));
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',processResult=' . intval($processResult));
+               $processResult = (($processResult === true) && (isExtensionReportingFailure() === false));
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',processResult=' . intval($processResult));
 
                // Does everthing before wents ok?
-               if ($test === true) {
+               if ($processResult === true) {
                        // "Dry-run-mode" activated?
                        if ((isExtensionDryRun() === false) && (!isExtensionOnRemovalList())) {
                                // Init SQLs and transfer ext->generic
@@ -409,14 +410,14 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
                        $ret = false;
                }
        } elseif (($taskId > 0) && (getCurrentExtensionName() != '')) {
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
                // Remove task from system when id and extension's name is valid
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
                        array(bigintval($taskId)), __FUNCTION__, __LINE__);
        }
 
        // Return status code
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',test=' . intval($test) . ' - EXIT!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',processResult=' . intval($processResult) . ' - EXIT!');
        return $ret;
 }
 
@@ -424,7 +425,9 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
 // @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
 function doExtensionSqls ($ext_id, $load_mode) {
        // This shall never do a non-admin user!
-       if (!isAdmin()) return false;
+       if (!isAdmin()) {
+               return false;
+       } // END - if
 
        // Get extension's name
        $ext_name = getExtensionName($ext_id);
@@ -663,7 +666,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
        // Is this extension update already running?
        if (isExtensionUpdateRunning($ext_name)) {
                // This is fine but needs logging ATM
-               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, all fine.');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, all fine.');
                return true;
        } // END - if
 
@@ -716,10 +719,10 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
                                                // Is the extension there?
                                                if (isExtensionInstalled($ext_depend)) {
                                                        // Update another extension first!
-                                                       $test = updateExtension($ext_depend, getExtensionVersion($ext_depend), isExtensionDryRun());
+                                                       $processResult = updateExtension($ext_depend, getExtensionVersion($ext_depend), isExtensionDryRun());
                                                } else {
                                                        // Register new extension
-                                                       $test = registerExtension($ext_depend, 0, isExtensionDryRun(), false);
+                                                       $processResult = registerExtension($ext_depend, 0, isExtensionDryRun());
                                                }
                                        } // END - if
                                } // END - foreach
@@ -1305,6 +1308,7 @@ function isExtensionUpdateDependenciesInitialized () {
 // Checks wether an update is already running for given extension
 function isExtensionUpdateRunning ($ext_name) {
        // Current and given extensions means whole array
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ' - ENTERED!');
        if ($ext_name == getCurrentExtensionName()) {
                // Default is not found
                $isRunning = false;
@@ -1316,13 +1320,13 @@ function isExtensionUpdateRunning ($ext_name) {
                        if (($ext1 == $ext_name) || (in_array($ext_name, $depends))) {
                                // Found
                                $isRunning = true;
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext1=' . $ext1 . ',ext_name=' . $ext_name . ',isRunning=' . intval($isRunning));
+                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext1=' . $ext1 . ',ext_name=' . $ext_name . ',isRunning=' . intval($isRunning) . ' - ADDED!');
                                break;
                        } // END - if
                } // END - foreach
 
                // Return result
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ', isRunning=' . intval($isRunning));
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ', isRunning=' . intval($isRunning) . ' - EXIT!');
                return $isRunning;
        } // END - if
 
@@ -1330,7 +1334,7 @@ function isExtensionUpdateRunning ($ext_name) {
        $isRunning = ((isExtensionUpdateDependenciesInitialized()) && (in_array($ext_name, getExtensionRunningUpdates())));
 
        // Return it
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ', isRunning=' . intval($isRunning));
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ', isRunning=' . intval($isRunning) . ' - EXIT!');
        return $isRunning;
 }
 
@@ -1399,12 +1403,12 @@ function incrementExtensionUpdateIterator () {
 }
 
 // Setter for EXT_REPORTS_FAILURE flag
-function setExtensionReportsFailure ($reportsFailure) {
+function enableExtensionReportingFailure ($reportsFailure = false) {
        $GLOBALS['ext_reports_failure'] = (bool) $reportsFailure;
 }
 
 // Getter for EXT_REPORTS_FAILURE flag
-function getExtensionReportsFailure () {
+function isExtensionReportingFailure () {
        return $GLOBALS['ext_reports_failure'];
 }
 
index 83d8af65ea1b4509ce549840ebaabe61111b168c..c963ddeb13b0bf5bebdb9d8871b9782fc5991f00 100644 (file)
@@ -56,7 +56,7 @@ switch (getExtensionMode()) {
 
                // SQL commands to run
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` CHANGE `data_type` `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE','DELETED') NOT NULL DEFAULT 'TEMP'");
-               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` CHANGE `data_type` ENUM('NEW','QUEUE','SEND','DELETED') NOT NULL DEFAULT 'NEW'");
+               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus` CHANGE `data_type` `data_type` ENUM('NEW','QUEUE','SEND','DELETED') NOT NULL DEFAULT 'NEW'");
                break;
 
        case 'remove': // Do stuff when removing extension
index 7f9ab18d82718bfb5d3844c7e5cbc363772f183e..369c2eba1f5257de3f9cf7df6f789ec3bfd29e66 100644 (file)
@@ -52,6 +52,7 @@ switch (getExtensionMode()) {
        case 'register': // Do stuff when installtion is running
                // This extension requires an up-to-date ext-user
                addExtensionDependency('user');
+               addExtensionDependency('autopurge');
 
                // Coupon data
                addDropTableSql('coupon_data');
index f752fb7b9810412f0543709c7feb14996311a21d..27a0790558cbf987d7ca29683e1aeb6473364a05 100644 (file)
@@ -53,7 +53,7 @@ switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running
                // Check if mod_rewrite is loadeded
                if (!isApacheModuleLoaded('mod_rewrite')) {
-                       setExtensionReportsFailure(true);
+                       enableExtensionReportingFailure(true);
                        addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
                } // END - if
 
@@ -70,7 +70,7 @@ switch (getExtensionMode()) {
                // Check if mod_rewrite is loadeded
                if (!isApacheModuleLoaded('mod_rewrite')) {
                        SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='rewrite' LIMIT 1", __FILE__, __LINE__);
-                       setExtensionReportsFailure(true);
+                       enableExtensionReportingFailure(true);
                        addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
         } // END - if
 
@@ -148,7 +148,7 @@ switch (getExtensionMode()) {
                        case '0.1.3':
                                // Check if mod_rewrite is loadeded
                                if (!isApacheModuleLoaded('mod_rewrite')) {
-                                       setExtensionReportsFailure(true);
+                                       enableExtensionReportingFailure(true);
                                        //addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
                                } // END - if
                                setExtensionUpdateNotes("Es wird beim Registrieren und aktivieren gepr&uuml;ft, ob im Apache das Modul mod_rewrite geladen wurde. Wenn mod_rewrite nicht gefunden werden konnte, wird abgebrochen.");
@@ -165,9 +165,11 @@ switch (getExtensionMode()) {
        case 'init': // Do stuff when extension is initialized
                // Check if mod_rewrite is loadeded
                if (!isApacheModuleLoaded('mod_rewrite')) {
-                       setExtensionReportsFailure(true);
+                       enableExtensionReportingFailure(true);
                        SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='rewrite' LIMIT 1", __FILE__, __LINE__);
-                       if (!isAdmin()) addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
+                       if (!isAdmin()) {
+                               addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
+                       } // END - if
                } // END - if
                break;
 
index 81493bcf2113f897227ebc21036aa7103bfc6b16..68ab380f8505ccb240230fe688b69354c0a5f44e 100644 (file)
@@ -87,6 +87,7 @@ addMessages(array(
        'MEMBER_COUPON_SUBJECT' => "Gutschein bei {?MAIN_TITLE?}",
        'ADMIN_COUPON_SUBJECT' => "Es wurde ein Gutschein versendet",
        'ADMIN_COUPON_CASHED_SUBJECT' => "Ein Mitglied hat seinen Gutschein eingel&ouml;st",
+       'ADMIN_COUPON_PURGE_SUBJECT' => "Bereinigung von abgelaufenen Gutscheinen",
 
        // Language strings for admin/member
        'COUPON_ID' => "Gutscheinnummer",
index 836611ee0e33f2489eec2c741f76f0bbcde1edbb..4b856018f9ba6a412d4065a39213db0c359e164e 100644 (file)
@@ -1132,8 +1132,8 @@ addMessages(array(
        'ADMIN_STATUS_CHANGED' => "Es wurden <span class=\"data\">%s</span> von <span class=\"data\">%s</span> Eintr&auml;gen ge&auml;ndert.",
 
        // Missing menu entries
-       'ADMIN_MENU_ACTION_404' => "Hauptmen&uuml; <span class=\"data\">%s</span> deaktiviert, da keine Scriptdatei auf dem Server gefunden wurde.",
-       'ADMIN_MENU_WHAT_404' => "Untermen&uuml; <span class=\"data\">%s</span> deaktiviert, da keine Scriptdatei auf dem Server gefunden wurde.",
+       'ADMIN_MENU_ACTION_404' => "Hauptmen&uuml; &#39;%s&#39; deaktiviert, da keine Scriptdatei auf dem Server gefunden wurde.",
+       'ADMIN_MENU_WHAT_404' => "Untermen&uuml; &#39;%s&#39; deaktiviert, da keine Scriptdatei auf dem Server gefunden wurde.",
 
        // Cache messages
        'CACHE_PROBLEMS_DETECTED' => "Probleme mit dem Cache-Subsystem erkannt.",
diff --git a/inc/purge/purge-coupon.php b/inc/purge/purge-coupon.php
new file mode 100644 (file)
index 0000000..4509463
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 07/05/2011 *
+ * ===================                          Last change: 07/05/2011 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : purge-coupon.php                                 *
+ * -------------------------------------------------------------------- *
+ * Short description : Purge expired coupons after some time            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Nach einer Weile angelaufene Gutscheine entf.    *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * 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 *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} elseif (!isExtensionActive('coupon')) {
+       logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
+       return;
+}
+
+// Search for all expired coupons that we can purge
+$result = SQL_QUERY('SELECT
+       `id`,
+       UNIX_TIMESTAMP(`coupon_created`) AS `coupon_created`,
+       UNIX_TIMESTAMP(`coupon_expired`) AS `coupon_expired`,
+       `total_created`,
+       `total_cashed`,
+       `points`,
+       `coupon_description`
+FROM
+       `{?_MYSQL_PREFIX?}_coupon_data`
+WHERE
+       (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`coupon_expired`)) >= {?coupon_autopurge_time?}
+ORDER BY
+       `id` ASC', __FILE__, __LINE__);
+
+// Do we have entries?
+if (SQL_NUMROWS($result) > 0) {
+       // Init variables
+       $out = '';
+       $ids = array();
+
+       // Start purging all
+       while ($content = SQL_FETCHARRAY($result)) {
+               // Add id
+               $ids[] = $content['id'];
+
+               // Translate some data
+               $content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
+               $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
+
+               // Load email row template
+               $out .= loadEmailTemplate('admin_coupon_purge_row', $content);
+       } // END - while
+
+       // Purge all entries
+       SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_coupon_data` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`coupon_expired`)) >= {?coupon_autopurge_time?}', __FILE__, __LINE__);
+
+       // Purge also user entries
+       SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_coupons` WHERE `coupon_id` IN (%s) LIMIT %s",
+               array(
+                       implode(',', $ids),
+                       count($ids)
+               ), __FILE__, __LINE__);
+
+       // Send admin notification
+       sendAdminNotification('{--ADMIN_COUPON_PURGE_SUBJECT--}', 'admin_coupon_purge', $out);
+} // END - if
+
+// Free result
+SQL_FREERESULT($result);
+
+// [EOF]
+?>
index 829c80fea130af34e936297b514061d4897d51ed..f564b4c99cf0c516dc1e883133bab4b5f95b8c78 100644 (file)
@@ -431,7 +431,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadU
                        $content['expiration'] = '{--MAIL_WILL_NEVER_EXPIRE--}';
                } elseif (isConfigEntrySet('auto_purge')) {
                        // Create nice date string
-                       $content['expiration'] = '{%pipe,getAutoPurge,createFancyTime%}';
+                       $content['expiration'] = '{%config,createFancyTime=auto_purge%}';
                } else {
                        // Missing entry
                        $content['expiration'] = '{--MAIL_NO_CONFIG_AUTO_PURGE--}';
diff --git a/templates/de/emails/admin/admin_coupon_purge.tpl b/templates/de/emails/admin/admin_coupon_purge.tpl
new file mode 100644 (file)
index 0000000..77f319c
--- /dev/null
@@ -0,0 +1,12 @@
+Hallo Administrator,
+
+es wurden soeben abgelaufene Gutscheine, die mehr als {%config,createFancyTime=coupon_autopurge_time%} noch gespeichert waren.
+
+Hier sind alle Daten der/des Gutscheine(s):
+$content
+------------------------------------
+
+Mit freundlichen Gr&uuml;&szlig;en,
+  Ihr {?MAIN_TITLE?} Team
+
+{?URL?}/login.php ({?WEBMASTER?})
diff --git a/templates/de/emails/admin/admin_coupon_purge_row.tpl b/templates/de/emails/admin/admin_coupon_purge_row.tpl
new file mode 100644 (file)
index 0000000..a35a532
--- /dev/null
@@ -0,0 +1,10 @@
+------------------------------------
+Gutschein-Id: $content[id]
+Verg&uuml;tung: {%pipe,translateComma=$content[points]%} {?POINTS?}
+Einstellungszeitpunkt: $content[coupon_created]
+Ablaufzeitpunkt: $content[coupon_expired]
+Anzahl erstellt: $content[total_created]
+Anzahl eingel&ouml;st: $content[total_cashed]
+------------------------------------
+Beschreibung/Hinweis:
+$content[coupon_description]