From: Roland Häder Date: Wed, 21 Jul 2010 00:55:07 +0000 (+0000) Subject: Our convention says if(-else) blocks should not be put in one line X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=537df432292cb0aa63070479258e3e84b182a28b;p=mailer.git Our convention says if(-else) blocks should not be put in one line --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index fd4a6008d4..1afabe3353 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -46,7 +46,7 @@ ./inc/functions.php:1577: // @TODO Are these convertions still required? ./inc/functions.php:1595:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:178:// @TODO Rewrite this to an extension 'smtp' -./inc/functions.php:2248: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2251: // @TODO This is still very static, rewrite it somehow ./inc/gen_sql_patches.php:96:// @TODO Rewrite this to a filter ./inc/install-functions.php:63: // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); ./inc/language/de.php:1127:// @TODO Rewrite these two constants @@ -65,10 +65,10 @@ ./inc/libs/doubler_functions.php:46:// @TODO Lame description ./inc/libs/doubler_functions.php:94: // @TODO Can't this be moved into EL? ./inc/libs/mailid_functions.php:49: // @TODO Rewrite this to a dynamic include or so -./inc/libs/rallye_functions.php:700:// @TODO This function does not load min_users, min_prices, please encapsulate loading rallye data with e.g. getRallyeDataFromId() -./inc/libs/rallye_functions.php:765: $EXPIRE = 3; // @TODO The hard-coded value... -./inc/libs/rallye_functions.php:851:// @TODO Please document this function -./inc/libs/rallye_functions.php:907: // Load count @TODO Can't we rewrite this to our API? +./inc/libs/rallye_functions.php:704:// @TODO This function does not load min_users, min_prices, please encapsulate loading rallye data with e.g. getRallyeDataFromId() +./inc/libs/rallye_functions.php:769: $EXPIRE = 3; // @TODO The hard-coded value... +./inc/libs/rallye_functions.php:855:// @TODO Please document this function +./inc/libs/rallye_functions.php:911: // Load count @TODO Can't we rewrite this to our API? ./inc/libs/refback_functions.php:61: // @TODO Try to rewrite the following unset() ./inc/libs/register_functions.php:292: // @TODO Rewrite these all to a single filter ./inc/libs/register_functions.php:365: // @TODO Rewrite this to a filter @@ -117,7 +117,7 @@ ./inc/modules/admin/what-del_email.php:61: // @TODO Unused: cat_id, payment_id ./inc/modules/admin/what-edit_user.php:20: * @TODO Add support for ext-country * ./inc/modules/admin/what-email_stats.php:48:// @TODO Unused at the moment -./inc/modules/admin/what-extensions.php:359: // @TODO Rewrite this to a filter +./inc/modules/admin/what-extensions.php:364: // @TODO Rewrite this to a filter ./inc/modules/admin/what-guest_add.php:131: // @TODO This can be somehow rewritten to a function ./inc/modules/admin/what-guest_add.php:69: // @TODO Cant this be rewritten? ./inc/modules/admin/what-guest_add.php:82: // @TODO This can be somehow rewritten to a function @@ -172,11 +172,11 @@ ./inc/modules/member/what-unconfirmed.php:143: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/order.php:76: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:69: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1168: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1415: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1513: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1880: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1924:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1171: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1418: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1516: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1883: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1927:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:370: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:46:// @TODO Can we cache this? ./inc/reset/reset_beg.php:51:// @TODO This should be converted in a daily beg rallye diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index 605a83ba1d..d5f5e03171 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -157,10 +157,13 @@ PRIMARY KEY (`id`) addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `beg_rallye` ENUM('Y','N') NOT NULL DEFAULT 'N'"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `beg_points` FLOAT(21,5) UNSIGNED NOT NULL DEFAULT 0.00000"); - $VIS = 'N'; $LOCKED = 'Y'; - if (isExtensionActive('beg')) { $VIS = 'Y'; $LOCKED = 'N'; } + $visible = 'N'; $locked = 'Y'; + if (isExtensionActive('beg')) { + $visible = 'Y'; + $locked = 'N'; + } // END - if - addMemberMenuSql('main','beg2','Bettel-Rallye',$VIS,$LOCKED,7); + addMemberMenuSql('main','beg2','Bettel-Rallye', $visible, $locked, 7); addAdminMenuSql('user','list_beg','Bettel-Rallye','Listet alle Teilnehmer der monatlichen Bettel-Rallye auf.','12'); // Update notes (these will be set as task text!) diff --git a/inc/functions.php b/inc/functions.php index 944d0281ee..740dccbd1b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1623,7 +1623,10 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // Read from source file $line = fgets ($fp, 1024); - if (strpos($line, $search) > -1) { $next = '0'; $found = true; } + if (strpos($line, $search) > -1) { + $next = '0'; + $found = true; + } // END - if if ($next > -1) { if ($next === $seek) { diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index c9a781a360..ca7e60fb54 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -293,7 +293,11 @@ LIMIT 1", // List only users with at least one ref! //* DEBUG: */ debugOutput('*'.$cnt.'/'.$content['userid'].'/'.$content['curr_points'].'/'.$refpoints.'*'); - if (($cnt > 0) && ($refpoints > $content['curr_points'])) { $userid = $content['userid']; } else { $cnt = ''; } + if (($cnt > 0) && ($refpoints > $content['curr_points'])) { + $userid = $content['userid']; + } else { + $cnt = ''; + } // Save values to array $DATA['userid'][] = $userid; diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index 9df38198ab..b3cc40546d 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -63,10 +63,15 @@ if (isGetRequestParameterSet('reg_ext')) { loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_EXTENSION_ALWAYS_ACTIVE', getExtensionName($taskId))); } else { // De/activate extension - $ACT = 'N'; setExtensionMode('deactivate'); - if ($active != 'Y') { $ACT = 'Y'; setExtensionMode('activate'); } + $active = 'N'; setExtensionMode('deactivate'); + if ($active != 'Y') { + $active = 'Y'; + setExtensionMode('activate'); + } // END - if + + // Update database SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s AND `ext_active`='%s' LIMIT 1", - array($ACT, bigintval($taskId), $active), __FILE__, __LINE__); + array($active, bigintval($taskId), $active), __FILE__, __LINE__); // Run embeded SQL commands doExtensionSqls($taskId, getExtensionMode()); diff --git a/inc/modules/admin/what-list_rallyes.php b/inc/modules/admin/what-list_rallyes.php index d60526728a..c4344ab7fe 100644 --- a/inc/modules/admin/what-list_rallyes.php +++ b/inc/modules/admin/what-list_rallyes.php @@ -251,7 +251,10 @@ ORDER BY $br = ''; // Output row - if (($row['curr_points'] > 0) && ($cnt > 0)) { $bl = ''; $br = ''; } + if (($row['curr_points'] > 0) && ($cnt > 0)) { + $bl = ''; + $br = ''; + } // END - if // Get user points $points = countSumTotalData($row['userid'], 'user_points', 'points', 'userid', false, " AND `ref_depth`=1 LIMIT 1"); diff --git a/inc/modules/admin/what-lock_user.php b/inc/modules/admin/what-lock_user.php index fbc3d8bfff..2bf2bbee0d 100644 --- a/inc/modules/admin/what-lock_user.php +++ b/inc/modules/admin/what-lock_user.php @@ -48,7 +48,7 @@ addMenuDescription('admin', __FILE__); // Is a userid set? if (isGetRequestParameterSet('userid')) { // Action not performed by default - $ACT = false; + $isActive = false; // Load user's data if (fetchUserData(getRequestParameter('userid'))) { @@ -76,7 +76,7 @@ if (isGetRequestParameterSet('userid')) { // Prepare message $message = getMaskedMessage('USER_ACCOUNT_LOCKED', bigintval(getRequestParameter('userid'))); - $ACT = true; + $isActive = true; } elseif ((isPostRequestParameterSet('unlock')) && (getUserData('status') == 'LOCKED')) { // Ok, unlock the account! if (isExtensionInstalledAndNewer('user', '0.3.5')) { @@ -111,10 +111,10 @@ LIMIT 1", // Prepare message $message = getMaskedMessage('USER_ACCOUNT_UNLOCKED', bigintval(getRequestParameter('userid'))); - $ACT = true; + $isActive = true; } elseif (isFormSent('del')) { // Delete the account - $ACT = true; + $isActive = true; loadIncludeOnce('inc/modules/admin/what-del_user.php'); } elseif (isPostRequestParameterSet('no')) { // Do not lock him... @@ -158,7 +158,7 @@ LIMIT 1", if (!empty($url)) { // Reload and die... redirectToUrl($url); - } elseif ($ACT) { + } elseif ($isActive) { // An action was performed... if (!empty($message)) { loadTemplate('admin_settings_saved', false, '
' . $message . '
'); diff --git a/inc/modules/admin/what-optimize.php b/inc/modules/admin/what-optimize.php index 68724755f3..48f1cdfbe7 100644 --- a/inc/modules/admin/what-optimize.php +++ b/inc/modules/admin/what-optimize.php @@ -57,17 +57,16 @@ foreach ($DATA['tables'] as $row_array) { // Fixes a bug which causes a parser error on eval'd code if (empty($row_array[1])) $row_array[1] = 'NONE'; - // Get optimization status - $REP = '{--OPTIMIZE_STATUS_' . str_replace('__', '_', str_replace(',', '', str_replace('+', '', str_replace("'", '', str_replace(' ', '_', strtoupper($row_array[1])))))) . '--}'; - - $OPT = '{--OPTIMIZE_STATUS_UNSUPPORTED--}'; + // Get repair/optimization status + $repairStatus = '{--OPTIMIZE_STATUS_' . str_replace('__', '_', str_replace(',', '', str_replace('+', '', str_replace("'", '', str_replace(' ', '_', strtoupper($row_array[1])))))) . '--}'; + $optimizeStatus = '{--OPTIMIZE_STATUS_UNSUPPORTED--}'; if ($row_array[4] > 0) { - $OPT = '{--OPTIMIZE_STATUS_OPTIMIZED--}'; + $optimizeStatus = '{--OPTIMIZE_STATUS_OPTIMIZED--}'; $B1 = ''; $B2 = ''; $gain_tabs++; } elseif (count(explode(' ', $row_array[2])) == 0) { - $OPT = '{--OPTIMIZE_STATUS_' . strtoupper($row_array[2]) . '--}'; + $optimizeStatus = '{--OPTIMIZE_STATUS_' . strtoupper($row_array[2]) . '--}'; } // Prepare data for the row template @@ -75,8 +74,8 @@ foreach ($DATA['tables'] as $row_array) { 'b1' => $B1, 'b2' => $B2, 'tpl' => $row_array[0], - 'rep' => $REP, - 'opt' => $OPT, + 'rep' => $repairStatus, + 'opt' => $optimizeStatus, 'sum' => $row_array[3], 'sav' => $row_array[4], ); @@ -85,12 +84,14 @@ foreach ($DATA['tables'] as $row_array) { $OUT .= loadTemplate('admin_optimize_row', true, $content); } // END - foreach +// Transfer main data +$content = $DATA; + // Remember rows $content['rows'] = $OUT; // Transfer data to $content for template -$content = merge_array($content, $DATA); -$content['now_optimized'] = $gain_tabs; +$content['now_optimized'] = $gain_tabs; // Load main template loadTemplate('admin_optimize', false, $content); diff --git a/inc/modules/admin/what-repair_amnu.php b/inc/modules/admin/what-repair_amnu.php index c9fc15ea22..d0e58e66d4 100644 --- a/inc/modules/admin/what-repair_amnu.php +++ b/inc/modules/admin/what-repair_amnu.php @@ -45,46 +45,46 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addMenuDescription('admin', __FILE__); -$ACTIONS = array(); +$actions = array(); // First fix all main menus (what = '')... $result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); -$cnt = '0'; $REP = '0'; +$cnt = '0'; $repairedWeights = '0'; while ($content = SQL_FETCHARRAY($result_fix)) { // Store act value for later usage in sorting sub menus - $ACTIONS[] = $content['action']; + $actions[] = $content['action']; // Fix weight SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET sort=%s WHERE `id`=%s LIMIT 1", - array($cnt, $content['id']), __FILE__, __LINE__); - $REP += SQL_AFFECTEDROWS(); + array($cnt, $content['id']), __FILE__, __LINE__); + $repairedWeights += SQL_AFFECTEDROWS(); // Count one up $cnt++; -} +} // END - while // Set logout weight to 999 SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__); // Now sort every each menu -foreach ($ACTIONS as $action) { +foreach ($actions as $action) { $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", array($action), __FILE__, __LINE__); $cnt = 1; while ($content = SQL_FETCHARRAY($result_fix)) { // Fix weight SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1", - array($cnt, $content['id']), __FILE__, __LINE__); - $REP += SQL_AFFECTEDROWS(); + array($cnt, $content['id']), __FILE__, __LINE__); + $repairedWeights += SQL_AFFECTEDROWS(); // Count one up $cnt++; - } -} + } // END - while +} // END - foreach // Repair finished -if ($REP > 0) { - $message = getMaskedMessage('ADMIN_REPAIR_ENTRIES_FIXED', $REP); +if ($repairedWeights > 0) { + $message = getMaskedMessage('ADMIN_REPAIR_ENTRIES_FIXED', $repairedWeights); } else { $message = '{--ADMIN_REPAIR_NOTHING_FIXED--}'; } diff --git a/inc/modules/admin/what-repair_gmnu.php b/inc/modules/admin/what-repair_gmnu.php index a817e85a83..cff162ad9d 100644 --- a/inc/modules/admin/what-repair_gmnu.php +++ b/inc/modules/admin/what-repair_gmnu.php @@ -45,20 +45,21 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addMenuDescription('admin', __FILE__); -$ACTIONS = array(); +$actions = array(); + // First fix all main menus (what = '')... $result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); -$cnt = '0'; $REP = '0'; +$cnt = '0'; $repairedWeights = '0'; while ($content = SQL_FETCHARRAY($result_fix)) { // Store act value for later usage in sorting sub menus - $ACTIONS[] = $content['action']; + $actions[] = $content['action']; // Fix weight $result_sort = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`='%s WHERE `id`=%s' LIMIT 1", array($cnt, $content['id']), __FILE__, __LINE__); // Get updated rows - $REP += SQL_AFFECTEDROWS(); + $repairedWeights += SQL_AFFECTEDROWS(); // Count one up $cnt++; @@ -68,7 +69,7 @@ while ($content = SQL_FETCHARRAY($result_fix)) { $result_sort = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET sort='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__); // Now sort every each menu -foreach ($ACTIONS as $action) { +foreach ($actions as $action) { $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", array($action), __FILE__, __LINE__); $cnt = 1; @@ -76,16 +77,16 @@ foreach ($ACTIONS as $action) { // Fix weight SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1", array($cnt, $content['id']), __FILE__, __LINE__); - $REP += SQL_AFFECTEDROWS(); + $repairedWeights += SQL_AFFECTEDROWS(); // Count one up $cnt++; - } -} + } // END - while +} // END - foreach // Repair finished -if ($REP > 0) { - $message = getMaskedMessage('ADMIN_REPAIR_ENTRIES_FIXED', $REP); +if ($repairedWeights > 0) { + $message = getMaskedMessage('ADMIN_REPAIR_ENTRIES_FIXED', $repairedWeights); } else { $message = '{--ADMIN_REPAIR_NOTHING_FIXED--}'; } diff --git a/inc/modules/admin/what-repair_mmnu.php b/inc/modules/admin/what-repair_mmnu.php index 374e1cb8f8..6fb1109272 100644 --- a/inc/modules/admin/what-repair_mmnu.php +++ b/inc/modules/admin/what-repair_mmnu.php @@ -45,29 +45,29 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addMenuDescription('admin', __FILE__); -$ACTIONS = array(); +$actions = array(); // First fix all main menus (what = '')... $result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); -$cnt = '0'; $REP = '0'; +$cnt = '0'; $repairedWeights = '0'; while ($content = SQL_FETCHARRAY($result_fix)) { // Store action value for later usage in sorting sub menus - $ACTIONS[] = $content['action']; + $actions[] = $content['action']; // Fix weight SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1", array($cnt, $content['id']), __FILE__, __LINE__); - $REP += SQL_AFFECTEDROWS(); + $repairedWeights += SQL_AFFECTEDROWS(); // Count one up $cnt++; -} +} // END - while // Set logout weight to 999 SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__); // Now sort every each menu -foreach ($ACTIONS as $action) { +foreach ($actions as $action) { $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", array($action), __FILE__, __LINE__); $cnt = 1; @@ -75,16 +75,16 @@ foreach ($ACTIONS as $action) { // Fix weight SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort=%s WHERE `id`=%s LIMIT 1", array($cnt, $content['id']), __FILE__, __LINE__); - $REP += SQL_AFFECTEDROWS(); + $repairedWeights += SQL_AFFECTEDROWS(); // Count one up $cnt++; - } -} + } // END - while +} // END - foreach // Repair finished -if ($REP > 0) { - $message = getMaskedMessage('ADMIN_REPAIR_ENTRIES_FIXED', $REP); +if ($repairedWeights > 0) { + $message = getMaskedMessage('ADMIN_REPAIR_ENTRIES_FIXED', $repairedWeights); } else { $message = '{--ADMIN_REPAIR_NOTHING_FIXED--}'; } diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 43de04889b..af1420e77e 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -872,7 +872,10 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ if ($stats_id > 0) { // Only when we got a real stats id continue searching for the entry $type = 'NORMAL'; $rowName = 'stats_id'; - if ($bonus) { $type = 'BONUS'; $rowName = 'bonus_id'; } + if ($bonus) { + $type = 'BONUS'; + $rowName = 'bonus_id'; + } // END - if // Try to look the entry up $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE %s='%s' AND `userid`=%s AND link_type='%s' LIMIT 1", @@ -891,8 +894,8 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ // Free memory SQL_FREERESULT($result); - } - } + } // END - if + } // END - if // Return status for sending routine return $ret;