]> git.mxchange.org Git - mailer.git/commitdiff
Simplified some more code:
authorquix0r <quix0r@mxchange.org>
Wed, 23 Jun 2010 13:49:46 +0000 (13:49 +0000)
committerquix0r <quix0r@mxchange.org>
Wed, 23 Jun 2010 13:49:46 +0000 (13:49 +0000)
- addEmailNavigation() is now located in admin-inc.php because only admin
  actions will make use of it
- Same function simplified, if only one page should be made navigateable, the
  function returns an empty string
- There was another unencapsulated what=list_unconfirmed

inc/extensions/ext-online.php
inc/functions.php
inc/libs/user_functions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-email_archiv.php
inc/modules/admin/what-email_details.php
inc/modules/admin/what-list_notifications.php
inc/modules/admin/what-list_payouts.php
inc/modules/admin/what-list_user.php

index 1e34115ce70e50179f92cae818c34cefae415696..b1d8b24f1174855b177314447b477499d90916bf 100644 (file)
@@ -116,7 +116,8 @@ KEY `admin_member` (`is_admin`,`is_member`)
                                break;
 
                        case '0.0.5': // SQL queries for v0.0.5
-                               addGuestMenuSql('online',NULL,'Jetzt Online','Y','N',2);
+                               // Add guest menu
+                               addGuestMenuSql('online', NULL, 'Jetzt Online', 'Y', 'N', 2);
 
                                // Register filter
                                registerFilter('init', 'UPDATE_ONLINE_LIST', false, true, getExtensionDryRun());
index 59f6307c2d1acffe013c6fa968bc7d629caf32b0..98533a8799a6433ba4fcccbf6e4a935a7a905457 100644 (file)
@@ -331,14 +331,18 @@ function loadTemplate ($template, $return = false, $content = array()) {
                        $GLOBALS['template_eval'][$template] = $eval;
                } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) {
                        // Only admins shall see this warning or when installation mode is active
-                       $ret = '<br /><span class="guest_failed">{--TEMPLATE_404--}</span><br />
-(' . $template . ')<br />
-<br />
-{--TEMPLATE_CONTENT--}
-<pre>' . print_r($content, true) . '</pre>
-{--TEMPLATE_DATA--}
-<pre>' . print_r($DATA, true) . '</pre>
-<br /><br />';
+                       $ret = '<div class="para">
+       <span class="guest_failed">{--TEMPLATE_404--}</span>
+</div>
+<div class="para">
+       (' . $template . ')
+</div>
+<div class="para">
+       {--TEMPLATE_CONTENT--}
+       <pre>' . print_r($content, true) . '</pre>
+       {--TEMPLATE_DATA--}
+       <pre>' . print_r($DATA, true) . '</pre>
+</div>';
                } else {
                        // No file!
                        $GLOBALS['template_eval'][$template] = '404';
@@ -504,12 +508,15 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') {
                eval($GLOBALS['tpl_content']);
        } elseif (!empty($template)) {
                // Template file not found!
-               $newContent = '{--TEMPLATE_404--}: ' . $template . '<br />
-{--TEMPLATE_CONTENT--}
-<pre>' . print_r($content, true) . '</pre>
-{--TEMPLATE_DATA--}
-<pre>' . print_r($DATA, true) . '</pre>
-<br /><br />';
+               $newContent = '<div class="para">
+       {--TEMPLATE_404--}: ' . $template . '
+</div>
+<div class="para">
+       {--TEMPLATE_CONTENT--}
+       <pre>' . print_r($content, true) . '</pre>
+       {--TEMPLATE_DATA--}
+       <pre>' . print_r($DATA, true) . '</pre>
+</div>';
 
                // Debug mode not active? Then remove the HTML tags
                if (!isDebugModeEnabled()) $newContent = secureString($newContent);
@@ -1453,7 +1460,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
 
        // Calculate 2-seconds timestamp
        $stamp = round($timestamp);
-       //* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*<br />");
+       //* DEBUG: */ print('*' . $stamp .'/' . $timestamp . '*<br />');
 
        // Do we have a leap year?
        $SWITCH = '0';
@@ -1462,7 +1469,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
        $M2 = date('m', (time() + $timestamp));
 
        // If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
-       if ((floor($TEST) == $TEST) && ($M1 == "02") && ($M2 > "02"))  $SWITCH = getConfig('ONE_DAY');
+       if ((floor($TEST) == $TEST) && ($M1 == '02') && ($M2 > '02'))  $SWITCH = getConfig('ONE_DAY');
 
        // First of all years...
        $Y = abs(floor($timestamp / (31536000 + $SWITCH)));
@@ -1706,62 +1713,6 @@ function createFancyTime ($stamp) {
        return $ret;
 }
 
-// Generates a navigation row for listing emails
-function addEmailNavigation ($PAGES, $offset, $show_form, $colspan, $return=false) {
-       $TOP = '';
-       if ($show_form === false) {
-               $TOP = ' top';
-       } // END - if
-
-       $NAV = '';
-       for ($page = 1; $page <= $PAGES; $page++) {
-               // Is the page currently selected or shall we generate a link to it?
-               if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
-                       // Is currently selected, so only highlight it
-                       $NAV .= '<strong>-';
-               } else {
-                       // Open anchor tag and add base URL
-                       $NAV .= '<a href="{%url=modules.php?module=admin&amp;what=' . getWhat() . '&amp;page=' . $page . '&amp;offset=' . $offset;
-
-                       // Add userid when we shall show all mails from a single member
-                       if ((isGetRequestParameterSet('userid')) && (bigintval(getRequestParameter('userid')) > 0)) $NAV .= '&amp;userid=' . bigintval(getRequestParameter('userid'));
-
-                       // Close open anchor tag
-                       $NAV .= '%}">';
-               }
-               $NAV .= $page;
-               if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
-                       // Is currently selected, so only highlight it
-                       $NAV .= '-</strong>';
-               } else {
-                       // Close anchor tag
-                       $NAV .= '</a>';
-               }
-
-               // Add seperator if we have not yet reached total pages
-               if ($page < $PAGES) {
-                       // Add it
-                       $NAV .= '|';
-               } // END - if
-       } // END - for
-
-       // Define constants only once
-       $content['nav']  = $NAV;
-       $content['span'] = $colspan;
-       $content['top']  = $TOP;
-
-       // Load navigation template
-       $OUT = loadTemplate('admin_email_nav_row', true, $content);
-
-       if ($return === true) {
-               // Return generated HTML-Code
-               return $OUT;
-       } else {
-               // Output HTML-Code
-               outputHtml($OUT);
-       }
-}
-
 // Extract host from script name
 function extractHostnameFromUrl (&$script) {
        // Use default SERVER_URL by default... ;) So?
index 012ff2c6b405016dcbad17e2245f1012d328f2cf..6fa424a99f40ce63c2b3baff3319f14a75ef3da7 100644 (file)
@@ -142,7 +142,7 @@ function addSortLinks ($letter, $sortby, $colspan, $return=false) {
 }
 
 // Add page navigation
-function addPageNavigation ($pages, $offset, $showForm, $colspan, $return=false) {
+function addPageNavigation ($numPages, $offset, $showForm, $colspan, $return=false) {
        // @TODO These two constants are no longer used, maybe we reactivate this code?
        //if ($showForm === true) {
        //      // Load form for changing number of lines
@@ -155,7 +155,7 @@ function addPageNavigation ($pages, $offset, $showForm, $colspan, $return=false)
        //}
 
        $OUT = '';
-       for ($page = 1; $page <= $pages; $page++) {
+       for ($page = 1; $page <= $numPages; $page++) {
                if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
                        $OUT .= '<strong>-';
                } else {
@@ -181,7 +181,7 @@ function addPageNavigation ($pages, $offset, $showForm, $colspan, $return=false)
                        $OUT .= '</a>';
                }
 
-               if ($page < $pages) $OUT .= '|';
+               if ($page < $numPages) $OUT .= '|';
        } // END - for
 
        // Remember the list
index 402b3ed7d7adb31ed149e1496ef69c1be2e350ca..cff7e7e2dc5139a6eaff0a4a6cf67779ed41b1b6 100644 (file)
@@ -1368,5 +1368,67 @@ function generateUnconfirmedAdminLink ($id, $unconfirmed, $type = 'bid') {
        return $OUT;
 }
 
+// Generates a navigation row for listing emails
+function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=false) {
+       // Don't do anything if $numPages is 1
+       if ($numPages == 1) {
+               // Abort here with empty content
+               return '';
+       } // END - if
+
+       $TOP = '';
+       if ($show_form === false) {
+               $TOP = ' top';
+       } // END - if
+
+       $NAV = '';
+       for ($page = 1; $page <= $numPages; $page++) {
+               // Is the page currently selected or shall we generate a link to it?
+               if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
+                       // Is currently selected, so only highlight it
+                       $NAV .= '<strong>-';
+               } else {
+                       // Open anchor tag and add base URL
+                       $NAV .= '<a href="{%url=modules.php?module=admin&amp;what=' . getWhat() . '&amp;page=' . $page . '&amp;offset=' . $offset;
+
+                       // Add userid when we shall show all mails from a single member
+                       if ((isGetRequestParameterSet('userid')) && (bigintval(getRequestParameter('userid')) > 0)) $NAV .= '&amp;userid=' . bigintval(getRequestParameter('userid'));
+
+                       // Close open anchor tag
+                       $NAV .= '%}">';
+               }
+               $NAV .= $page;
+               if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
+                       // Is currently selected, so only highlight it
+                       $NAV .= '-</strong>';
+               } else {
+                       // Close anchor tag
+                       $NAV .= '</a>';
+               }
+
+               // Add seperator if we have not yet reached total pages
+               if ($page < $numPages) {
+                       // Add it
+                       $NAV .= '|';
+               } // END - if
+       } // END - for
+
+       // Define constants only once
+       $content['nav']  = $NAV;
+       $content['span'] = $colspan;
+       $content['top']  = $TOP;
+
+       // Load navigation template
+       $OUT = loadTemplate('admin_email_nav_row', true, $content);
+
+       if ($return === true) {
+               // Return generated HTML-Code
+               return $OUT;
+       } else {
+               // Output HTML-Code
+               outputHtml($OUT);
+       }
+}
+
 // [EOF]
 ?>
index d840755cd5622338c1105c38a76e00090e1b3947..6dd6352fc0081741bf47ed0edac74369fa436023 100644 (file)
@@ -72,7 +72,7 @@ $sql .= ' LIMIT ' . (getRequestParameter('offset') * getRequestParameter('page')
 $result = SQL_QUERY($sql, __FILE__, __LINE__);
 
 // Calculate pages
-$pages = round(SQL_NUMROWS($result_maximum) / getConfig('mails_page') + 0.5);
+$numPages = round(SQL_NUMROWS($result_maximum) / getConfig('mails_page') + 0.5);
 
 // Free the result which we don't need
 SQL_FREERESULT($result_maximum);
@@ -81,12 +81,8 @@ if (SQL_NUMROWS($result) > 0) {
        // Mail orders are in pool so we can display them
 
        // Add navigation table rows
-       $content['top_email_nav']    = '';
-       $content['bottom_email_nav'] = '';
-       if ($pages > 1) {
-               $content['top_email_nav']    = addEmailNavigation($pages, getConfig('mails_page'), true , 3, true);
-               $content['bottom_email_nav'] = addEmailNavigation($pages, getConfig('mails_page'), false, 3, true);
-       } // END - if
+       $content['top_email_nav']    = addEmailNavigation($numPages, getConfig('mails_page'), true , 3, true);
+       $content['bottom_email_nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
 
        // List all entries
        $OUT = ''; $SW = 2;
@@ -102,11 +98,7 @@ if (SQL_NUMROWS($result) > 0) {
                SQL_FREERESULT($result_mails);
 
                // Unconfirmed mails
-               $pool['unconfirmed'] = $pool['max_rec'] - $pool['clicks'];
-               if ($pool['unconfirmed'] > 0) {
-                       // Add link to list_unconfirmed what-file
-                       $pool['unconfirmed'] = '<strong><a href="{%url=modules.php?module=admin&amp;what=list_unconfirmed&amp;mid=' . $pool['id'] . '%}">' . $pool['unconfirmed'] . '</a></strong>';
-               } // END - if
+               $pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'],  ($pool['max_rec'] - $pool['clicks']), 'mid');
 
                // Prepare data for the row template
                $content['sw'] = $SW;
index 22ca7fb20afb36c6be8a91286566656502f3e4a0..9f0435abfbe0c703f5a20ece651656dc01453ea4 100644 (file)
@@ -91,6 +91,9 @@ ORDER BY
        $WHO = getMessage('USER_ID') . ': ' . getRequestParameter('userid');
 }
 
+// Init result_bonus
+$result_bonus = false;
+
 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
        // Check for maximum pages
        $result_bonus = SQL_QUERY("SELECT
@@ -137,9 +140,9 @@ $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
 if ((!empty($SQL2)) && ($WHO == getMessage('_ALL'))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
 
 // Calculate pages
-$PAGES = '0';
+$numPages = '0';
 if (isConfigEntrySet('mails_page')) {
-       $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
+       $numPages = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
 } // END - if
 
 // Free result
@@ -176,8 +179,7 @@ if (SQL_NUMROWS($result_list) > 0) {
        SQL_FREERESULT($result_list);
 
        // Add navigation (with change box and colspan=3)
-       $content['nav'] = '';
-       if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
+       $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
 
        // Prepare content
        $content['rows'] = $OUT;
@@ -188,7 +190,7 @@ if (SQL_NUMROWS($result_list) > 0) {
 
        $MAIL = true;
        if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
-               // Check only if bonus extension is active
+               // Only check if bonus extension is active
                if (SQL_NUMROWS($result_bonus) > 0) outputHtml('<br /><br />');
        } // END - if
 }
@@ -197,7 +199,7 @@ if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
        // Load bonus mails only when extension is active
        if (SQL_NUMROWS($result_bonus) > 0) {
                // Calculate pages
-               $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
+               $numPages = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
 
                // List emails
                $OUT = '';
@@ -213,8 +215,7 @@ if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
                } // END - while
 
                // Add navigation (without change box but with colspan=3)
-               $content['nav'] = '';
-               if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
+               $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
 
                // Prepare content
                $content['rows'] = $OUT;
index 625df8f4d9540a6c9d8c636bd6cdd98f3987bdb2..f10a81ac98150f40be9dc229d31f379f7e821212 100644 (file)
@@ -85,7 +85,7 @@ if ((isExtensionActive('bonus')) && (SQL_NUMROWS($result_max) > 0) && (!empty($S
        // Load bonus mails only when extension is active
        if (SQL_NUMROWS($result_bonus) > 0) {
                // Calculate pages
-               $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
+               $numPages = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
 
                // List emails
                $OUT = ''; $content = array();
@@ -101,8 +101,7 @@ if ((isExtensionActive('bonus')) && (SQL_NUMROWS($result_max) > 0) && (!empty($S
                } // END - if
 
                // Add navigation (without change box but with colspan=3)
-               $content['nav'] = '';
-               if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
+               $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
 
                // Prepare content
                $content['rows'] = $OUT;
index 50980e5d691de22c4f53ae5a6c9b077b75c5aacc..bef227701f8ebd4e92dcacb3e21c81817d499f3b 100644 (file)
@@ -155,7 +155,7 @@ LIMIT 1",
                                                sendEmail(getUserData('email'), getMessage('MEMBER_PAYOUT_ACCEPTED_SUBJECT'), $message);
                                        } else {
                                                // Something goes wrong... :-(
-                                               $content = implode("<br />", $ret);
+                                               $content = implode('<br />', $ret);
                                                loadTemplate('admin_payout_failed_transfer', false, $content);
                                        }
                                } else {
index dfc67aa21eb2afda78f0d4e714adc94350850b2d..61ace388a9a9cb568cf3613645feb40265198a43 100644 (file)
@@ -247,7 +247,7 @@ LIMIT 1",
        } // END - if
 
        // Activate the extension please!
-       $PAGES = round(SQL_NUMROWS($result_master) / getConfig('user_limit') + 0.5);
+       $numPages = round(SQL_NUMROWS($result_master) / getConfig('user_limit') + 0.5);
 
        if (!isGetRequestParameterSet('page'))   setGetRequestParameter('page'  , 1);
        if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', getConfig('user_limit'));
@@ -267,8 +267,8 @@ LIMIT 1",
                $templateContent['sort_links'] = addSortLinks(getRequestParameter('letter'), getRequestParameter('sortby'), ($colspan + 1), true);
                $templateContent['page_nav']   = '';
 
-               if ($PAGES > 1) {
-                       $templateContent['page_nav'] = addPageNavigation($PAGES, getConfig('user_limit'), true, $colspan, true);
+               if ($numPages > 1) {
+                       $templateContent['page_nav'] = addPageNavigation($numPages, getConfig('user_limit'), true, $colspan, true);
                } // END - if
 
                // Column with nickname when nickname extension is present