]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-list_notifications.php
Fixes and cleanups
[mailer.git] / inc / modules / admin / what-list_notifications.php
index cfee49da761ff398d7acf51f37e98f644e95e15c..d1c7db19efc4e55f83f251962421202f654b063e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/07/2008 *
- * ===============                              Last change: 10/07/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 10/07/2008 *
+ * ===================                          Last change: 10/07/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-list_notifications.php                      *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Alle Benachrichtigungen sehen (Bettel-/Aktiv-R.) *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * For more information visit: http://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 *
  ************************************************************************/
 
 // Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
+} // END - if
 
 // Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+addYouAreHereLink('admin', __FILE__);
 
 // Init variables
-$WHO = _ALL;
-$SQL2 = "";
+$SQL2 = '';
+$result_max = false;
 
 // Set offset an current page to default values
-if (!REQUEST_ISSET_GET(('page')))   REQUEST_GET('page')   = "1";
-if (!REQUEST_ISSET_GET(('offset'))) REQUEST_SET_GET('offset', getConfig('mails_page'));
+if (!isGetRequestElementSet('page'))   setGetRequestElement('page'  , 1);
+if (!isGetRequestElementSet('offset')) setGetRequestElement('offset', getMailsPage());
 
-if ((EXT_IS_ACTIVE("bonus")) && ($WHO == getMessage('_ALL'))) {
+if (isExtensionActive('bonus')) {
        // Bonus mails sent by you
-       //               0     1       2        3        4      5       6          7       8      9         10          11        12
-       $SQL2 = "SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, clicks
-FROM `{!_MYSQL_PREFIX!}_bonus`
-WHERE is_notify='Y'
-ORDER BY timestamp DESC";
+       $SQL2 = "SELECT
+       `id`,`subject`,`text`,`receivers`,`points`,`time`,`data_type`,`timestamp`,`url`,`cat_id`,`target_send`,
+       `mails_sent`,`clicks`, (`mails_sent` - `clicks`) AS `unconfirmed`
+FROM
+       `{?_MYSQL_PREFIX?}_bonus`
+WHERE
+       `is_notify`='Y'
+ORDER BY
+       `timestamp` DESC";
 
        // Check for maximum pages
        $result_max = SQL_QUERY($SQL2, __FILE__, __LINE__);
 } else {
        // Bonus extension required!
+       displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=bonus%}');
 }
 
 // Create limitation line
-$ADD = " LIMIT ".(bigintval(REQUEST_GET('offset')) * bigintval(REQUEST_GET('page')) - bigintval(REQUEST_GET('offset'))).", ".bigintval(REQUEST_GET('offset'));
+$add = ' LIMIT ' . (bigintval(getRequestElement('offset')) * bigintval(getRequestElement('page')) - bigintval(getRequestElement('offset'))) . ', ' . bigintval(getRequestElement('offset'));
 
 // Add limitation
-if (!empty($SQL2)) $SQL2 .= $ADD;
+if (!empty($SQL2)) $SQL2 .= $add;
 
-if ((EXT_IS_ACTIVE("bonus")) && (SQL_NUMROWS($result_max) > 0) && (!empty($SQL2))) {
+if ((isExtensionActive('bonus')) && (!SQL_HASZERONUMS($result_max)) && (!empty($SQL2))) {
        // Run SQL query for notification mails
        $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
 
        // Load bonus mails only when extension is active
-       if (SQL_NUMROWS($result_bonus) > 0) {
+       if (!SQL_HASZERONUMS($result_bonus)) {
                // Calculate pages
-               $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
+               $numPages = round(SQL_NUMROWS($result_bonus) / getMailsPage() + 0.5);
 
                // List emails
-               $OUT = ""; $content = array();
-               while ($bonus = SQL_FETCHARRAY($result_bonus)) {
-                       // Calculate unconfirmed emails
-                       $bonus['unconfirmed'] = $bonus['mails_sent'] - $bonus['clicks'];
-
-                       // Add link?
-                       if ($bonus['unconfirmed'] > 0) {
-                               // Add link to list_unconfirmed what-file
-                               $bonus['unconfirmed'] = "<strong><a href=\"{!URL!}/modules.php?module=admin&amp;what=list_unconfirmed&amp;bid=".$bonus['id']."\">".$bonus['unconfirmed']."</a></strong>";
-                       } // END - if
+               $OUT = ''; $content = array();
+               while ($content = SQL_FETCHARRAY($result_bonus)) {
+                       // Add "unconfirmed-link"
+                       $content['unconfirmed_content'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']);
 
                        // Prepare content
-                       $content = $bonus;
-                       $content['time']        = CREATE_FANCY_TIME($content['time']);
-                       $content['category']    = GET_CATEGORY($content['cat_id']);
-                       $content['receivers']   = str_replace(";", ", ", $content['receivers']);
-                       $content['type']        = TRANSLATE_POOL_TYPE($content['data_type']);
-                       $content['frametester'] = FRAMETESTER($content['url']);
-                       $content['timestamp']   = MAKE_DATETIME($content['timestamp'], "0");
+                       $content['timestamp']   = generateDateTime($content['timestamp'], 0);
 
                        // Load row template
-                       $OUT .= LOAD_TEMPLATE("admin_list_notify_emails_row", true, $content);
-               }
+                       $OUT .= loadTemplate('admin_list_notify_emails_row', true, $content);
+               } // END - if
 
                // Add navigation (without change box but with colspan=3)
-               $content['nav'] = "";
-               if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true);
+               $content['nav'] = addEmailNavigation($numPages, getMailsPage(), false, 3, true);
 
                // Prepare content
                $content['rows'] = $OUT;
 
                // Load main template
-               LOAD_TEMPLATE("admin_list_notify_emails", false, $content);
+               loadTemplate('admin_list_notify_emails', false, $content);
        }
+} elseif ((SQL_NUMROWS($result_max) === 0) && (is_resource($result_max))) {
+       // No notifications found
+       displayMessage('{--ADMIN_NO_NOTIFICATIONS--}');
 }
 
-//
+// [EOF]
 ?>