From 73af00cb3ac701a8385fc7d7df02553845403bb7 Mon Sep 17 00:00:00 2001 From: quix0r Date: Wed, 23 Jun 2010 13:49:46 +0000 Subject: [PATCH] Simplified some more code: - 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 | 3 +- inc/functions.php | 95 +++++-------------- inc/libs/user_functions.php | 6 +- inc/modules/admin/admin-inc.php | 62 ++++++++++++ inc/modules/admin/what-email_archiv.php | 16 +--- inc/modules/admin/what-email_details.php | 17 ++-- inc/modules/admin/what-list_notifications.php | 5 +- inc/modules/admin/what-list_payouts.php | 2 +- inc/modules/admin/what-list_user.php | 6 +- 9 files changed, 109 insertions(+), 103 deletions(-) diff --git a/inc/extensions/ext-online.php b/inc/extensions/ext-online.php index 1e34115ce7..b1d8b24f11 100644 --- a/inc/extensions/ext-online.php +++ b/inc/extensions/ext-online.php @@ -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()); diff --git a/inc/functions.php b/inc/functions.php index 59f6307c2d..98533a8799 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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 = '
{--TEMPLATE_404--}
-(' . $template . ')
-
-{--TEMPLATE_CONTENT--} -
' . print_r($content, true) . '
-{--TEMPLATE_DATA--} -
' . print_r($DATA, true) . '
-

'; + $ret = '
+ {--TEMPLATE_404--} +
+
+ (' . $template . ') +
+
+ {--TEMPLATE_CONTENT--} +
' . print_r($content, true) . '
+ {--TEMPLATE_DATA--} +
' . print_r($DATA, true) . '
+
'; } 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 . '
-{--TEMPLATE_CONTENT--} -
' . print_r($content, true) . '
-{--TEMPLATE_DATA--} -
' . print_r($DATA, true) . '
-

'; + $newContent = '
+ {--TEMPLATE_404--}: ' . $template . ' +
+
+ {--TEMPLATE_CONTENT--} +
' . print_r($content, true) . '
+ {--TEMPLATE_DATA--} +
' . print_r($DATA, true) . '
+
'; // 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."*
"); + //* DEBUG: */ print('*' . $stamp .'/' . $timestamp . '*
'); // 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 .= '-'; - } else { - // Open anchor tag and add base URL - $NAV .= ''; - } - $NAV .= $page; - if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { - // Is currently selected, so only highlight it - $NAV .= '-'; - } else { - // Close anchor tag - $NAV .= ''; - } - - // 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? diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 012ff2c6b4..6fa424a99f 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -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 .= '-'; } else { @@ -181,7 +181,7 @@ function addPageNavigation ($pages, $offset, $showForm, $colspan, $return=false) $OUT .= ''; } - if ($page < $pages) $OUT .= '|'; + if ($page < $numPages) $OUT .= '|'; } // END - for // Remember the list diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 402b3ed7d7..cff7e7e2dc 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -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 .= '-'; + } else { + // Open anchor tag and add base URL + $NAV .= ''; + } + $NAV .= $page; + if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { + // Is currently selected, so only highlight it + $NAV .= '-'; + } else { + // Close anchor tag + $NAV .= ''; + } + + // 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] ?> diff --git a/inc/modules/admin/what-email_archiv.php b/inc/modules/admin/what-email_archiv.php index d840755cd5..6dd6352fc0 100644 --- a/inc/modules/admin/what-email_archiv.php +++ b/inc/modules/admin/what-email_archiv.php @@ -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'] = '' . $pool['unconfirmed'] . ''; - } // END - if + $pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'], ($pool['max_rec'] - $pool['clicks']), 'mid'); // Prepare data for the row template $content['sw'] = $SW; diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php index 22ca7fb20a..9f0435abfb 100644 --- a/inc/modules/admin/what-email_details.php +++ b/inc/modules/admin/what-email_details.php @@ -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('

'); } // 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; diff --git a/inc/modules/admin/what-list_notifications.php b/inc/modules/admin/what-list_notifications.php index 625df8f4d9..f10a81ac98 100644 --- a/inc/modules/admin/what-list_notifications.php +++ b/inc/modules/admin/what-list_notifications.php @@ -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; diff --git a/inc/modules/admin/what-list_payouts.php b/inc/modules/admin/what-list_payouts.php index 50980e5d69..bef227701f 100644 --- a/inc/modules/admin/what-list_payouts.php +++ b/inc/modules/admin/what-list_payouts.php @@ -155,7 +155,7 @@ LIMIT 1", sendEmail(getUserData('email'), getMessage('MEMBER_PAYOUT_ACCEPTED_SUBJECT'), $message); } else { // Something goes wrong... :-( - $content = implode("
", $ret); + $content = implode('
', $ret); loadTemplate('admin_payout_failed_transfer', false, $content); } } else { diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php index dfc67aa21e..61ace388a9 100644 --- a/inc/modules/admin/what-list_user.php +++ b/inc/modules/admin/what-list_user.php @@ -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 -- 2.39.5