Rewrote email if tasks has been purged
authorRoland Häder <roland@mxchange.org>
Sun, 20 Jan 2013 10:50:45 +0000 (10:50 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 20 Jan 2013 10:50:45 +0000 (10:50 +0000)
.gitattributes
inc/functions.php
inc/language/de.php
inc/language/task_de.php
inc/purge/purge-tasks.php
install/tables.sql
templates/de/emails/admin/admin_autopurge_tsks.tpl
templates/de/emails/admin/admin_purge_task.tpl [new file with mode: 0644]
templates/de/emails/admin/admin_purge_task_row.tpl [new file with mode: 0644]
templates/de/html/ext/ext_network.tpl

index 2811791..2298f2b 100644 (file)
@@ -980,6 +980,8 @@ templates/de/emails/admin/admin_newsletter_reset.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_order_normal.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_payout_request.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_payout_request_banner.tpl svneol=native#text/plain
+templates/de/emails/admin/admin_purge_task.tpl svneol=native#text/plain
+templates/de/emails/admin/admin_purge_task_row.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_purge_user_server_name_log.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_purge_user_subid_log.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_rallye_expired.tpl svneol=native#text/plain
index 431a5bc..ef0c2f1 100644 (file)
@@ -2727,9 +2727,18 @@ function translateTaskType ($taskType) {
        return translateGeneric('ADMIN_TASK_TYPE', $taskType);
 }
 
-//-----------------------------------------------------------------------------
-// Automatically re-created functions, all taken from user comments on www.php.net
-//-----------------------------------------------------------------------------
+// "Translates" task status to a human-readable version
+function translateTaskStatus ($taskStatus) {
+       // Return it
+       return translateGeneric('ADMIN_TASK_STATUS', $taskStatus);
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ * Automatically re-created functions, all taken from user comments on
+ * www.php.net
+ *-----------------------------------------------------------------------------
+ */
 if (!function_exists('html_entity_decode')) {
        // Taken from documentation on www.php.net
        function html_entity_decode ($string) {
index cd82b60..709a5ff 100644 (file)
@@ -587,10 +587,17 @@ addMessages(array(
        'ADMIN_ENTER_REDIRECT_URL' => "URL eingeben, wenn abgelehnt werden soll",
        'MEMBER_REFERRAL_BANNER_404' => "Es sind noch keine Werbebanner eingerichtet worden. Bitte verwenden Sie solange Ihren Referral-Link.",
        'ADMIN_ID_404' => "ID <span class=\"data\">%s</span> nicht gefunden.",
+
+       // Columns for listing tasks
        'ADMIN_ASSIGNED_ADMIN' => "Zugewiesener Admin",
+       'ADMIN_ASSIGNED_ADMIN_EMAIL' => "Admin",
        'ADMIN_MEMBER_USERID' => "ID des Mitgliedes",
+       'ADMIN_MEMBER_USERID_EMAIL' => "Mitglied-Id",
        'ADMIN_TASK_TYPE' => "Aufgabenbereich",
+       'ADMIN_TASK_TYPE_EMAIL' => "Aufgabenbereich",
        'ADMIN_TASK_CREATED' => "Aufgabe erstellt",
+       'ADMIN_TASK_CREATED_EMAIL' => "Erstellt",
+
        'ADMIN_NO_ADMIN_ASSIGNED' => "Kein Admin-Login zugewiesen.",
        'ADMIN_UNKNOWN_TASK_TYPE' => "Unbekannter Aufgabentyp <span class=\"data\">%s</span> f&uuml;r Aufgabe <span class=\"data\">%s</span> erkannt.",
        'ADMIN_TASK_SYSTEM_WELCOME' => "Task-Management Ihres {?mt_word2?}",
index 8f0d38b..ee72b0a 100644 (file)
@@ -86,6 +86,16 @@ addMessages(array(
        'ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL_TITLE' => "Es wurden Accounts ohne Werber-Id (refid=0) gefunden.",
        'ADMIN_TASK_LIST_NOTIFICATIONS' => "Alle  Benachrichtigungen",
        'ADMIN_TASK_LIST_NOTIFICATIONS_TITLE' => "Es sind ausgesandte,verg&uuml;tete Benachrichtigungen vorhanden.",
+
+       // Task status
+       'ADMIN_TASK_STATUS_NEW' => "Neu",
+       'ADMIN_TASK_STATUS_OPEN' => "Offen",
+       'ADMIN_TASK_STATUS_SOLVED' => "Erledigt",
+       'ADMIN_TASK_STATUS_CLOSED' => "Geschlossen",
+       'ADMIN_TASK_STATUS_DELETED' => "Gel&ouml;scht",
+       'ADMIN_TASK_STATUS_NULL' => "Null (!)",
+       'ADMIN_TASK_STATUS_EMPTY' => "Leer (!)",
+       'ADMIN_TASK_STATUS_UNKNOWN' => "Unbekannt (%s)",
 ));
 
 // [EOF]
index 0c70c91..5e6b8aa 100644 (file)
@@ -41,29 +41,58 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Abort if autopurge is not active or disabled by admin
-if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) {
+if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive()) || (getConfig('ap_tasks_notify') == 'N')) {
        // Abort here
        return FALSE;
 } // END - if
 
 // Check version (must be >= 0.1.9)
 if ((isExtensionInstalledAndNewer('task', '0.1.9')) && (getConfig('autopurge_tasks') == 'Y')) {
-       // Purge deleted tasks (no notification to admin)
-       SQL_QUERY("DELETE LOW_PRIORITY
+       // Select all tasks that needs purging
+       $result = SQL_QUERY("SELECT
+       `id`,
+       `assigned_admin`,
+       `userid`,
+       `status`,
+       `task_type`,
+       `subject`,
+       `task_created`
 FROM
        `{?_MYSQL_PREFIX?}_task_system`
 WHERE
        `status`='DELETED' AND
        (UNIX_TIMESTAMP() - `task_created`) >= {?ap_tasks_time?}", __FILE__, __LINE__);
 
-       // Get deleted rows
-       $deletedTasks = SQL_AFFECTEDROWS();
-
        // Send out a notification?
-       if (($deletedTasks > 0) && (getConfig('ap_tasks_notify') == 'Y')) {
+       if (!SQL_HASZERONUMS($result)) {
+               // Init output and load all rows
+               $output = ''; $ids = array();
+               while ($row = SQL_FETCHARRAY($result)) {
+                       // "Translate" creation timestamp
+                       $row['task_created'] = generateDateTime($row['task_created'], '1');
+
+                       // Load row template
+                       $output .= loadEmailTemplate('admin_purge_task_row', $row);
+
+                       // Remember id number for deletion
+                       array_push($ids, $row['id']);
+               } // END - while
+
+               // Init content array
+               $content = array(
+                       'count' => SQL_NUMROWS($result),
+                       'rows'  => $output
+               );
+
+               // Delete all tasks
+               SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id` IN (' . implode(', ', $ids) . ')');
+
                // Send out email to admin
-               sendAdminNotification('{--ADMIN_AUTOPURGE_TASKS_SUBJECT--}', 'admin_autopurge_tsks', $deletedTasks);
+               sendAdminNotification('{--ADMIN_AUTOPURGE_TASKS_SUBJECT--}', 'admin_purge_task', $content);
        } // END - if
+
+       // Free result
+       SQL_FREERESULT($result);
 } // END - if
 
 //
index 66c8c9c..0cc24a4 100644 (file)
@@ -186,7 +186,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_task_system` (
   `assigned_admin` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
   `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
   `status` ENUM('NEW','OPEN','SOLVED','CLOSED','DELETED') NOT NULL DEFAULT 'NEW',
-  `task_type` VARCHAR(255)  NOT NULL DEFAULT 'FIRST_USER',
+  `task_type` VARCHAR(255)  NOT NULL DEFAULT 'UNKNOWN',
   `subject` VARCHAR(255) NOT NULL DEFAULT '',
   `text` LONGTEXT NOT NULL,
   `task_created` VARCHAR(10) NOT NULL DEFAULT 0,
index 053dafa..84d1ed3 100644 (file)
@@ -1,8 +1 @@
-Hallo Administrator,
-
-In Ihrem {?mt_word?} wurden $content Aufgaben gel&ouml;scht.
-
-Mit freundlichen Gr&uuml;&szlig;en,
-  Ihr {?MAIN_TITLE?} Script
-
-{?URL?}/admin.php
+@DEPRECATED
diff --git a/templates/de/emails/admin/admin_purge_task.tpl b/templates/de/emails/admin/admin_purge_task.tpl
new file mode 100644 (file)
index 0000000..047ad66
--- /dev/null
@@ -0,0 +1,14 @@
+Hallo Administrator,
+
+In Ihrem {?mt_word?} wurden $content[count] Aufgaben gel&ouml;scht.
+
+--------------------------------------------------------------------------
+ {--ID_SELECT--} | {--ADMIN_ASSIGNED_ADMIN_EMAIL--} | {--ADMIN_MEMBER_USERID_EMAIL--} | {--ADMIN_TASK_INFOS_EMAIL--} | {--ADMIN_TASK_TYPE_EMAIL--} | {--ADMIN_TASK_CREATED_EMAIL--}
+--------------------------------------------------------------------------
+$content[rows]
+--------------------------------------------------------------------------
+
+Mit freundlichen Gr&uuml;&szlig;en,
+  Ihr {?MAIN_TITLE?} Script
+
+{?URL?}/admin.php
diff --git a/templates/de/emails/admin/admin_purge_task_row.tpl b/templates/de/emails/admin/admin_purge_task_row.tpl
new file mode 100644 (file)
index 0000000..746e35c
--- /dev/null
@@ -0,0 +1 @@
+$content[id]  |  {%pipe,convertZeroToNull=$content[assigned_admin]%}  |  {%pipe,convertZeroToNull=$content[userid]%}  |  {%pipe,translateTaskStatus=$content[task_type]%}  |  {%pipe,translateTaskType=$content[task_status]%}  |  $content[task_created]
index e1a77f2..eb5405f 100644 (file)
@@ -37,3 +37,9 @@
         href="http://forum.mxchange.org/topic-462.html" rel="external">in diesem
        Forum</a>. Es wird dann bald im Mailer-Projekt eingebunden.
 </div>
+
+<div class="para">
+       <strong>Vorraussetzungen:</strong> Diese Erweiterunge ben&ouml;tigt iconv,
+       damit die von den Werbenetzwerken verwendeten Zeichens&auml;tze nach UTF-8
+       konvertiert werden k&ouml;nnen.
+</div>