From 820a65d753f3103901bec03a93588044670684fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 14 Dec 2008 16:22:11 +0000 Subject: [PATCH] Minor rewrites to brackets, admin welcome page rewritten to use GET_TOTAL_DATA() --- inc/databases.php | 2 +- inc/libs/task_functions.php | 74 +++++++++++----------------------- inc/libs/user_functions.php | 79 ++++++++++++++++--------------------- 3 files changed, 58 insertions(+), 97 deletions(-) diff --git a/inc/databases.php b/inc/databases.php index d795eabe19..8fb5e3fa42 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "628"); +define('CURR_SVN_REVISION', "629"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index fbdea104d5..6e8bb48ccb 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -50,18 +50,19 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) global $_CONFIG; // Init variables/arrays - $EXTRAS = ""; $OUT = ""; $SQLs = array(); $WHATs = array(); $DESCRs = array(); $TITLEs = array(); + $EXTRAS = ""; + $OUT = ""; + $SQLs = array(); + $WHATs = array(); + $DESCRs = array(); + $TITLEs = array(); // Chheck for new extensions and updates $JOBS_DONE = OUTPUT_STANDARD_OVERVIEW($result_main); if (!$JOBS_DONE) { // New extensions or updates found - $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND status='NEW' AND task_type='EXTENSION_UPDATE'", - array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__); - - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA(GET_ADMIN_ID(get_session('admin_login')), "task_system", "id", "assigned_admin", true, " AND status='NEW' AND task_type='EXTENSION_UPDATE'"); if ($value > 0) { define('__TASK_UPDATE_VALUE', "".$value.""); @@ -76,9 +77,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // First check for all account status seperately // // Confirmed accounts - $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true); if ($value > 0) { define('__CONFIRMED_VALUE', "".$value.""); @@ -87,9 +86,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) } // Unconfirmed accounts - $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='UNCONFIRMED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("UNCONFIRMED", "user_data", "userid", "status", true); if ($value > 0) { define('__UNCONFIRMED_VALUE', "".$value.""); @@ -98,9 +95,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) } // And locked accounts - $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='LOCKED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("LOCKED", "user_data", "userid", "status", true); if ($value > 0) { define('__LOCKED_VALUE', "".$value.""); @@ -111,9 +106,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Unassigned tasks // - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='0' AND status != 'DELETED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("0", "task_system", "id", "assigned_admin", true, " AND `status` != 'DELETED'"); if ($value > 0) { define('__TASK_NEW_VALUE', "".$value.""); @@ -124,9 +117,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Closed tasks // - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'CLOSED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("CLOSED", "task_system", "id", "status", true); if ($value > 0) { define('__TASK_CLOSED_VALUE', "".$value.""); @@ -137,9 +128,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Deleted tasks // - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'DELETED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("DELETED", "task_system", "id", "status", true); if ($value > 0) { define('__TASK_DELETED_VALUE', "".$value.""); @@ -150,10 +139,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Solved tasks // - $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'SOLVED' AND assigned_admin='%s'", - array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("DELETED", "task_system", "id", "status", true, sprintf(" AND assigned_admin=%s", GET_ADMIN_ID(get_session('admin_login')))); if ($value > 0) { define('__TASK_SOLVED_VALUE', "".$value.""); @@ -164,10 +150,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Your tasks // - $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'", - array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA(GET_ADMIN_ID(get_session('admin_login')), "task_system", "id", "assigned_admin", true, " AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'"); if ($value > 0) { define('__TASK_YOUR_VALUE', "".$value.""); @@ -178,9 +161,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Mails waiting to be approved // - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='ADMIN'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("ADMIN", "pool", "id", "data_type", true); if ($value > 0) { define('__MAIL_ADMIN_VALUE', "".$value.""); @@ -191,9 +172,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Unfinished mail orders // - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='TEMP'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("TEMP", "pool", "id", "data_type", true); if ($value > 0) { define('__MAIL_TEMP_VALUE', "".$value.""); @@ -204,9 +183,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // // Sent mail orders // - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='SEND'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + $value = GET_TOTAL_DATA("SEND", "pool", "id", "data_type", true); if ($value > 0) { define('__MAIL_SEND_VALUE', "".$value.""); @@ -218,9 +195,8 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // Autopurged mails // if (EXT_IS_ACTIVE("autopurge")) { - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + // Get auto-purged mails + $value = GET_TOTAL_DATA("DELETED", "pool", "id", "data_type", true); if ($value > 0) { define('__MAIL_DELETED_VALUE', "".$value.""); @@ -232,9 +208,8 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // Autopurged bonus mails // if (GET_EXT_VERSION("bonus") >= "0.1.8") { - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='DELETED'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + // Get auto-purged bonus mails + $value = GET_TOTAL_DATA("DELETED", "bonus", "id", "data_type", true); if ($value > 0) { define('__MAIL_BONUS_AP_VALUE', "".$value.""); @@ -255,9 +230,8 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // Sent bonus mails // if (GET_EXT_VERSION("bonus") >= "0.1.8") { - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND' AND is_notify='N'", __FILE__, __LINE__); - $value = SQL_NUMROWS($result); - SQL_FREERESULT($result); + // Get sent bonus mails (but not notifications) + $value = GET_TOTAL_DATA("SEND", "bonus", "id", "data_type", true, " AND is_notify='N'"); if ($value > 0) { define('__MAIL_BONUS_SEND_VALUE', "".$value.""); diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 3ec514966f..d00650cfbd 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -38,8 +38,7 @@ if (!defined('__SECURITY')) { } // Add links for selecting some users -function alpha($sortby, $colspan, $return=false) -{ +function alpha($sortby, $colspan, $return=false) { global $_CONFIG; if (empty($_GET['offset'])) $_GET['offset'] = 0; $ADD = "&page=".SQL_ESCAPE($_GET['page'])."&offset=".SQL_ESCAPE($_GET['offset']); @@ -49,48 +48,39 @@ function alpha($sortby, $colspan, $return=false) $alphabet = array(_ALL2,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",_OTHERS); $num = count($alphabet) - 1; $OUT = ""; - while (list($counter, $ltr) = each($alphabet)) - { - if ($_GET['letter'] == $ltr) - { + while (list($counter, $ltr) = each($alphabet)) { + if ($_GET['letter'] == $ltr) { // Current letter is letter from URL $OUT .= "".$ltr.""; - } - else - { + } else { // Output link to letter $OUT .= "".$ltr.""; } - if ((($counter / $_CONFIG['user_alpha']) == round($counter / $_CONFIG['user_alpha'])) && ($counter > 0)) - { + + if ((($counter / $_CONFIG['user_alpha']) == round($counter / $_CONFIG['user_alpha'])) && ($counter > 0)) { $OUT .= " ]
[ "; - } - elseif ( $counter != $num ) - { + } elseif ( $counter != $num ) { $OUT .= " | "; } - } + } // END - while + define('__ALPHA_LIST', $OUT); // Load template $OUT = LOAD_TEMPLATE("admin_list_user_alpha", true); - if ($return) - { + if ($return) { // Return generated code return $OUT; - } - else - { + } else { // Output generated code OUTPUT_HTML($OUT); } } // Add links for sorting -function SortLinks($letter, $sortby, $colspan, $return=false) -{ +function SortLinks($letter, $sortby, $colspan, $return=false) { $OUT = ""; if (empty($_GET['offset'])) $_GET['offset'] = 0; if (empty($_GET['page'])) $_GET['page'] = 0; @@ -124,26 +114,23 @@ function SortLinks($letter, $sortby, $colspan, $return=false) } else { $OUT .= "".$title." | "; } - } + } // END - foreach + define('__SORT_LIST', substr($OUT, 0, -13)); // Load template $OUT = LOAD_TEMPLATE("admin_list_user_sort", true); - if ($return) - { + if ($return) { // Return code return $OUT; - } - else - { + } else { // Output code OUTPUT_HTML($OUT); } } // Add page navigation -function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false) -{ +function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false) { if (!$show_form) { // Empty row define('__FORM_HEADER', " "); @@ -178,50 +165,50 @@ function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false) // Letter and so on $OUT .= "&letter=".SQL_ESCAPE($_GET['letter'])."&sortby=".SQL_ESCAPE($_GET['sortby'])."&page=".$page."&offset=".$offset."\">"; } + $OUT .= $page; - if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1"))) - { + + if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1"))) { $OUT .= "-"; - } - else - { + } else { $OUT .= ""; } + if ($page < $PAGES) $OUT .= " | "; - } + } // END - for + define('__PAGENAV_LIST', $OUT); // Load template $OUT = LOAD_TEMPLATE("admin_list_user_pagenav", true); - if ($return) - { + if ($return) { // Return code return $OUT; - } - else - { + } else { // Output code OUTPUT_HTML($OUT); } } // Create email link to user's account -function USER_CREATE_EMAIL_LINK($email, $mod="admin") -{ +function USER_CREATE_EMAIL_LINK($email, $mod="admin") { + // Show contact link only if user is confirmed by default $locked = " AND status='CONFIRMED'"; + + // But admins shall always see it if (IS_ADMIN()) $locked = ""; + $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE email='%s'".$locked." LIMIT 1", array($email), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + if (SQL_NUMROWS($result) == 1) { // Load userid list($uid) = SQL_FETCHROW($result); // Rewrite email address to contact link $email = URL."/modules.php?module=".$mod."&what=user_contct&u_id=".bigintval($uid); - } + } // END - if // Free memory SQL_FREERESULT($result); -- 2.39.5