@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | // The language file gets automatically included within this module, |
| 40 | 40 | // but not when viewing the notifications page via notifications.php. |
| 41 | 41 | global $xoopsConfig; |
| 42 | -if (file_exists(XOOPS_ROOT_PATH . "/modules/chess/language/{$xoopsConfig['language']}/main.php")) { |
|
| 43 | - require_once XOOPS_ROOT_PATH . "/modules/chess/language/{$xoopsConfig['language']}/main.php"; |
|
| 42 | +if (file_exists(XOOPS_ROOT_PATH."/modules/chess/language/{$xoopsConfig['language']}/main.php")) { |
|
| 43 | + require_once XOOPS_ROOT_PATH."/modules/chess/language/{$xoopsConfig['language']}/main.php"; |
|
| 44 | 44 | } else { |
| 45 | - require_once XOOPS_ROOT_PATH . '/modules/chess/language/english/main.php'; |
|
| 45 | + require_once XOOPS_ROOT_PATH.'/modules/chess/language/english/main.php'; |
|
| 46 | 46 | } |
| 47 | 47 | /**#@-*/ |
| 48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if ('global' == $category) { |
| 61 | 61 | $item['name'] = 'Chess'; |
| 62 | 62 | |
| 63 | - $item['url'] = XOOPS_URL . '/modules/chess/'; |
|
| 63 | + $item['url'] = XOOPS_URL.'/modules/chess/'; |
|
| 64 | 64 | |
| 65 | 65 | return $item; |
| 66 | 66 | } elseif ('game' == $category) { |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | $date = _MD_CHESS_NA; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $item['name'] = "$username_white " . _MD_CHESS_LABEL_VS . " $username_black ($date)"; |
|
| 107 | + $item['name'] = "$username_white "._MD_CHESS_LABEL_VS." $username_black ($date)"; |
|
| 108 | 108 | |
| 109 | - $item['url'] = XOOPS_URL . '/modules/chess/game.php?game_id=' . $item_id; |
|
| 109 | + $item['url'] = XOOPS_URL.'/modules/chess/game.php?game_id='.$item_id; |
|
| 110 | 110 | |
| 111 | 111 | return $item; |
| 112 | 112 | } |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | // but not when viewing the notifications page via notifications.php. |
| 41 | 41 | global $xoopsConfig; |
| 42 | 42 | if (file_exists(XOOPS_ROOT_PATH . "/modules/chess/language/{$xoopsConfig['language']}/main.php")) { |
| 43 | - require_once XOOPS_ROOT_PATH . "/modules/chess/language/{$xoopsConfig['language']}/main.php"; |
|
| 43 | + require_once XOOPS_ROOT_PATH . "/modules/chess/language/{$xoopsConfig['language']}/main.php"; |
|
| 44 | 44 | } else { |
| 45 | - require_once XOOPS_ROOT_PATH . '/modules/chess/language/english/main.php'; |
|
| 45 | + require_once XOOPS_ROOT_PATH . '/modules/chess/language/english/main.php'; |
|
| 46 | 46 | } |
| 47 | 47 | /**#@-*/ |
| 48 | 48 | |
@@ -57,57 +57,57 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | function chess_notify_item_info($category, $item_id) |
| 59 | 59 | { |
| 60 | - if ('global' == $category) { |
|
| 61 | - $item['name'] = 'Chess'; |
|
| 60 | + if ('global' == $category) { |
|
| 61 | + $item['name'] = 'Chess'; |
|
| 62 | 62 | |
| 63 | - $item['url'] = XOOPS_URL . '/modules/chess/'; |
|
| 63 | + $item['url'] = XOOPS_URL . '/modules/chess/'; |
|
| 64 | 64 | |
| 65 | - return $item; |
|
| 66 | - } elseif ('game' == $category) { |
|
| 67 | - global $xoopsDB; |
|
| 65 | + return $item; |
|
| 66 | + } elseif ('game' == $category) { |
|
| 67 | + global $xoopsDB; |
|
| 68 | 68 | |
| 69 | - $table = $xoopsDB->prefix('chess_games'); |
|
| 69 | + $table = $xoopsDB->prefix('chess_games'); |
|
| 70 | 70 | |
| 71 | - $result = $xoopsDB->query( |
|
| 72 | - trim( |
|
| 73 | - " |
|
| 71 | + $result = $xoopsDB->query( |
|
| 72 | + trim( |
|
| 73 | + " |
|
| 74 | 74 | SELECT white_uid, black_uid, UNIX_TIMESTAMP(start_date) AS start_date |
| 75 | 75 | FROM $table |
| 76 | 76 | WHERE game_id = '$item_id' |
| 77 | 77 | " |
| 78 | - ) |
|
| 79 | - ); |
|
| 78 | + ) |
|
| 79 | + ); |
|
| 80 | 80 | |
| 81 | - $gamedata = $xoopsDB->fetchArray($result); |
|
| 81 | + $gamedata = $xoopsDB->fetchArray($result); |
|
| 82 | 82 | |
| 83 | - $xoopsDB->freeRecordSet($result); |
|
| 83 | + $xoopsDB->freeRecordSet($result); |
|
| 84 | 84 | |
| 85 | - if (false !== $gamedata) { |
|
| 86 | - // get mapping of user IDs to usernames |
|
| 85 | + if (false !== $gamedata) { |
|
| 86 | + // get mapping of user IDs to usernames |
|
| 87 | 87 | |
| 88 | - $criteria = new \Criteria('uid', "({$gamedata['white_uid']}, {$gamedata['black_uid']})", 'IN'); |
|
| 88 | + $criteria = new \Criteria('uid', "({$gamedata['white_uid']}, {$gamedata['black_uid']})", 'IN'); |
|
| 89 | 89 | |
| 90 | - $memberHandler = xoops_getHandler('member'); |
|
| 90 | + $memberHandler = xoops_getHandler('member'); |
|
| 91 | 91 | |
| 92 | - $usernames = $memberHandler->getUserList($criteria); |
|
| 92 | + $usernames = $memberHandler->getUserList($criteria); |
|
| 93 | 93 | |
| 94 | - $username_white = $usernames[$gamedata['white_uid']] ?? _MD_CHESS_NA; |
|
| 94 | + $username_white = $usernames[$gamedata['white_uid']] ?? _MD_CHESS_NA; |
|
| 95 | 95 | |
| 96 | - $username_black = $usernames[$gamedata['black_uid']] ?? _MD_CHESS_NA; |
|
| 96 | + $username_black = $usernames[$gamedata['black_uid']] ?? _MD_CHESS_NA; |
|
| 97 | 97 | |
| 98 | - $date = $gamedata['start_date'] ? date('Y.m.d', $gamedata['start_date']) : _MD_CHESS_NA; |
|
| 99 | - } else { |
|
| 100 | - $username_white = _MD_CHESS_NA; |
|
| 98 | + $date = $gamedata['start_date'] ? date('Y.m.d', $gamedata['start_date']) : _MD_CHESS_NA; |
|
| 99 | + } else { |
|
| 100 | + $username_white = _MD_CHESS_NA; |
|
| 101 | 101 | |
| 102 | - $username_black = _MD_CHESS_NA; |
|
| 102 | + $username_black = _MD_CHESS_NA; |
|
| 103 | 103 | |
| 104 | - $date = _MD_CHESS_NA; |
|
| 105 | - } |
|
| 104 | + $date = _MD_CHESS_NA; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - $item['name'] = "$username_white " . _MD_CHESS_LABEL_VS . " $username_black ($date)"; |
|
| 107 | + $item['name'] = "$username_white " . _MD_CHESS_LABEL_VS . " $username_black ($date)"; |
|
| 108 | 108 | |
| 109 | - $item['url'] = XOOPS_URL . '/modules/chess/game.php?game_id=' . $item_id; |
|
| 109 | + $item['url'] = XOOPS_URL . '/modules/chess/game.php?game_id=' . $item_id; |
|
| 110 | 110 | |
| 111 | - return $item; |
|
| 112 | - } |
|
| 111 | + return $item; |
|
| 112 | + } |
|
| 113 | 113 | } |
@@ -50,105 +50,105 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function xoops_module_pre_update_chess($module, $oldversion) |
| 52 | 52 | { |
| 53 | - global $xoopsDB; |
|
| 53 | + global $xoopsDB; |
|
| 54 | 54 | |
| 55 | - // For downward-compatiblity, in case this function doesn't get called by the module handler. |
|
| 55 | + // For downward-compatiblity, in case this function doesn't get called by the module handler. |
|
| 56 | 56 | |
| 57 | - $GLOBALS['chess_module_pre_update_called'] = true; |
|
| 57 | + $GLOBALS['chess_module_pre_update_called'] = true; |
|
| 58 | 58 | |
| 59 | - if ($oldversion < 102) { // old version < 1.02: direct update not supported. |
|
| 60 | - $docfile = XOOPS_ROOT_PATH . '/modules/chess/docs/INSTALL.TXT'; |
|
| 59 | + if ($oldversion < 102) { // old version < 1.02: direct update not supported. |
|
| 60 | + $docfile = XOOPS_ROOT_PATH . '/modules/chess/docs/INSTALL.TXT'; |
|
| 61 | 61 | |
| 62 | - chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string)$oldversion, $docfile), true); |
|
| 62 | + chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string)$oldversion, $docfile), true); |
|
| 63 | 63 | |
| 64 | - return false; |
|
| 65 | - } elseif ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 66 | - return true; |
|
| 67 | - } |
|
| 64 | + return false; |
|
| 65 | + } elseif ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 66 | + return true; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - // 1.02 <= old version < 1.07: perform update. |
|
| 69 | + // 1.02 <= old version < 1.07: perform update. |
|
| 70 | 70 | |
| 71 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 71 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 72 | 72 | |
| 73 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 73 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 74 | 74 | |
| 75 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 75 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 76 | 76 | |
| 77 | - // Check that ratings table does not already exist. |
|
| 77 | + // Check that ratings table does not already exist. |
|
| 78 | 78 | |
| 79 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_1, $ratings_table)); |
|
| 79 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_1, $ratings_table)); |
|
| 80 | 80 | |
| 81 | - $result = $xoopsDB->query("SHOW TABLES LIKE '$ratings_table'"); |
|
| 81 | + $result = $xoopsDB->query("SHOW TABLES LIKE '$ratings_table'"); |
|
| 82 | 82 | |
| 83 | - if (!$result) { |
|
| 84 | - $mysql_errno = $xoopsDB->errno(); |
|
| 83 | + if (!$result) { |
|
| 84 | + $mysql_errno = $xoopsDB->errno(); |
|
| 85 | 85 | |
| 86 | - $mysql_error = $xoopsDB->error(); |
|
| 86 | + $mysql_error = $xoopsDB->error(); |
|
| 87 | 87 | |
| 88 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string)$mysql_errno, $mysql_error), true); |
|
| 88 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string)$mysql_errno, $mysql_error), true); |
|
| 89 | 89 | |
| 90 | - return false; |
|
| 91 | - } |
|
| 90 | + return false; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 94 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_3, $ratings_table), true); |
|
| 93 | + if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 94 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_3, $ratings_table), true); |
|
| 95 | 95 | |
| 96 | - return false; |
|
| 97 | - } |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - $xoopsDB->freeRecordSet($result); |
|
| 99 | + $xoopsDB->freeRecordSet($result); |
|
| 100 | 100 | |
| 101 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 101 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 102 | 102 | |
| 103 | - // Check database tables. |
|
| 103 | + // Check database tables. |
|
| 104 | 104 | |
| 105 | - chess_set_message($module, _MI_CHESS_CHK_DB_TABLES); |
|
| 105 | + chess_set_message($module, _MI_CHESS_CHK_DB_TABLES); |
|
| 106 | 106 | |
| 107 | - $table_check_messages = chess_check_tables([$challenges_table, $games_table]); |
|
| 107 | + $table_check_messages = chess_check_tables([$challenges_table, $games_table]); |
|
| 108 | 108 | |
| 109 | - if (!empty($table_check_messages)) { |
|
| 110 | - foreach ($table_check_messages as $message) { |
|
| 111 | - chess_set_message($module, $message, true); |
|
| 112 | - } |
|
| 109 | + if (!empty($table_check_messages)) { |
|
| 110 | + foreach ($table_check_messages as $message) { |
|
| 111 | + chess_set_message($module, $message, true); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return false; |
|
| 115 | - } |
|
| 114 | + return false; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 117 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 118 | 118 | |
| 119 | - // Check that values in column pgn_result of games table are in range. |
|
| 119 | + // Check that values in column pgn_result of games table are in range. |
|
| 120 | 120 | |
| 121 | - $pgn_result_values = "'*','1-0','0-1','1/2-1/2'"; |
|
| 121 | + $pgn_result_values = "'*','1-0','0-1','1/2-1/2'"; |
|
| 122 | 122 | |
| 123 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_1, $games_table)); |
|
| 123 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_1, $games_table)); |
|
| 124 | 124 | |
| 125 | - $result = $xoopsDB->query("SELECT COUNT(*) FROM `$games_table` WHERE `pgn_result` NOT IN ($pgn_result_values)"); |
|
| 125 | + $result = $xoopsDB->query("SELECT COUNT(*) FROM `$games_table` WHERE `pgn_result` NOT IN ($pgn_result_values)"); |
|
| 126 | 126 | |
| 127 | - if (!$result) { |
|
| 128 | - $mysql_errno = $xoopsDB->errno(); |
|
| 127 | + if (!$result) { |
|
| 128 | + $mysql_errno = $xoopsDB->errno(); |
|
| 129 | 129 | |
| 130 | - $mysql_error = $xoopsDB->error(); |
|
| 130 | + $mysql_error = $xoopsDB->error(); |
|
| 131 | 131 | |
| 132 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string)$mysql_errno, $mysql_error), true); |
|
| 132 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string)$mysql_errno, $mysql_error), true); |
|
| 133 | 133 | |
| 134 | - return false; |
|
| 135 | - } |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - [$count] = $xoopsDB->fetchRow($result); |
|
| 137 | + [$count] = $xoopsDB->fetchRow($result); |
|
| 138 | 138 | |
| 139 | - if ($count > 0) { |
|
| 140 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_3, 'pgn_result', $games_table, $pgn_result_values), true); |
|
| 139 | + if ($count > 0) { |
|
| 140 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_3, 'pgn_result', $games_table, $pgn_result_values), true); |
|
| 141 | 141 | |
| 142 | - chess_set_message($module, _MI_CHESS_GAMES_TABLE_4, true); |
|
| 142 | + chess_set_message($module, _MI_CHESS_GAMES_TABLE_4, true); |
|
| 143 | 143 | |
| 144 | - return false; |
|
| 145 | - } |
|
| 144 | + return false; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - $xoopsDB->freeRecordSet($result); |
|
| 147 | + $xoopsDB->freeRecordSet($result); |
|
| 148 | 148 | |
| 149 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 149 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 150 | 150 | |
| 151 | - return true; // successful |
|
| 151 | + return true; // successful |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -160,28 +160,28 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | function xoops_module_update_chess($module, $oldversion) |
| 162 | 162 | { |
| 163 | - global $xoopsDB; |
|
| 163 | + global $xoopsDB; |
|
| 164 | 164 | |
| 165 | - // Before proceeding, ensure that pre-update processing has been done, and that all the checks pass. |
|
| 165 | + // Before proceeding, ensure that pre-update processing has been done, and that all the checks pass. |
|
| 166 | 166 | |
| 167 | - // For downward-compatiblity, in case the "pre_update" function doesn't get called by the module handler. |
|
| 167 | + // For downward-compatiblity, in case the "pre_update" function doesn't get called by the module handler. |
|
| 168 | 168 | |
| 169 | - if (!@$GLOBALS['chess_module_pre_update_called'] && !xoops_module_pre_update_chess($module, $oldversion)) { |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 169 | + if (!@$GLOBALS['chess_module_pre_update_called'] && !xoops_module_pre_update_chess($module, $oldversion)) { |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - if ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 174 | - return true; |
|
| 175 | - } |
|
| 173 | + if ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 174 | + return true; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 177 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 178 | 178 | |
| 179 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 179 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 180 | 180 | |
| 181 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 181 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 182 | 182 | |
| 183 | - $queries = [ |
|
| 184 | - "CREATE TABLE `$ratings_table` ( |
|
| 183 | + $queries = [ |
|
| 184 | + "CREATE TABLE `$ratings_table` ( |
|
| 185 | 185 | `player_uid` mediumint(8) unsigned NOT NULL default '0', |
| 186 | 186 | `rating` smallint(6) unsigned NOT NULL default '1200', |
| 187 | 187 | `games_won` smallint(6) unsigned NOT NULL default '0', |
@@ -192,48 +192,48 @@ discard block |
||
| 192 | 192 | KEY `games` (`games_won`,`games_lost`,`games_drawn`) |
| 193 | 193 | ) ENGINE=MyISAM", |
| 194 | 194 | |
| 195 | - "ALTER TABLE `$challenges_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 196 | - "ALTER TABLE `$challenges_table` ADD INDEX `game_type` (`game_type`)", |
|
| 197 | - "ALTER TABLE `$challenges_table` ADD INDEX `player1_uid` (`player1_uid`)", |
|
| 198 | - "ALTER TABLE `$challenges_table` ADD INDEX `player2_uid` (`player2_uid`)", |
|
| 199 | - "ALTER TABLE `$challenges_table` ADD INDEX `create_date` (`create_date`)", |
|
| 200 | - "ALTER TABLE `$challenges_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 195 | + "ALTER TABLE `$challenges_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 196 | + "ALTER TABLE `$challenges_table` ADD INDEX `game_type` (`game_type`)", |
|
| 197 | + "ALTER TABLE `$challenges_table` ADD INDEX `player1_uid` (`player1_uid`)", |
|
| 198 | + "ALTER TABLE `$challenges_table` ADD INDEX `player2_uid` (`player2_uid`)", |
|
| 199 | + "ALTER TABLE `$challenges_table` ADD INDEX `create_date` (`create_date`)", |
|
| 200 | + "ALTER TABLE `$challenges_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 201 | 201 | |
| 202 | - "ALTER TABLE `$games_table` CHANGE `pgn_result` `pgn_result` ENUM('*','0-1','1-0','1/2-1/2') DEFAULT '*' NOT NULL", |
|
| 203 | - "ALTER TABLE `$games_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 204 | - "ALTER TABLE `$games_table` ADD INDEX `white_uid` (`white_uid`)", |
|
| 205 | - "ALTER TABLE `$games_table` ADD INDEX `black_uid` (`black_uid`)", |
|
| 206 | - "ALTER TABLE `$games_table` ADD INDEX `date` (`create_date`,`start_date`,`last_date`)", |
|
| 207 | - "ALTER TABLE `$games_table` ADD INDEX `pgn_result` (`pgn_result`)", |
|
| 208 | - "ALTER TABLE `$games_table` ADD INDEX `suspended_date` (`suspended`(19))", |
|
| 209 | - "ALTER TABLE `$games_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 202 | + "ALTER TABLE `$games_table` CHANGE `pgn_result` `pgn_result` ENUM('*','0-1','1-0','1/2-1/2') DEFAULT '*' NOT NULL", |
|
| 203 | + "ALTER TABLE `$games_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 204 | + "ALTER TABLE `$games_table` ADD INDEX `white_uid` (`white_uid`)", |
|
| 205 | + "ALTER TABLE `$games_table` ADD INDEX `black_uid` (`black_uid`)", |
|
| 206 | + "ALTER TABLE `$games_table` ADD INDEX `date` (`create_date`,`start_date`,`last_date`)", |
|
| 207 | + "ALTER TABLE `$games_table` ADD INDEX `pgn_result` (`pgn_result`)", |
|
| 208 | + "ALTER TABLE `$games_table` ADD INDEX `suspended_date` (`suspended`(19))", |
|
| 209 | + "ALTER TABLE `$games_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 210 | 210 | |
| 211 | - "UPDATE `$games_table` SET `is_rated` = '0' WHERE `white_uid` = `black_uid`", |
|
| 212 | - ]; |
|
| 211 | + "UPDATE `$games_table` SET `is_rated` = '0' WHERE `white_uid` = `black_uid`", |
|
| 212 | + ]; |
|
| 213 | 213 | |
| 214 | - // Update database tables. |
|
| 214 | + // Update database tables. |
|
| 215 | 215 | |
| 216 | - chess_set_message($module, _MI_CHESS_UPDATING_DATABASE); |
|
| 216 | + chess_set_message($module, _MI_CHESS_UPDATING_DATABASE); |
|
| 217 | 217 | |
| 218 | - foreach ($queries as $query) { |
|
| 219 | - chess_set_message($module, "> $query"); |
|
| 218 | + foreach ($queries as $query) { |
|
| 219 | + chess_set_message($module, "> $query"); |
|
| 220 | 220 | |
| 221 | - $result = $xoopsDB->query($query); |
|
| 221 | + $result = $xoopsDB->query($query); |
|
| 222 | 222 | |
| 223 | - if (!$result) { |
|
| 224 | - $mysql_errno = $xoopsDB->errno(); |
|
| 223 | + if (!$result) { |
|
| 224 | + $mysql_errno = $xoopsDB->errno(); |
|
| 225 | 225 | |
| 226 | - $mysql_error = $xoopsDB->error(); |
|
| 226 | + $mysql_error = $xoopsDB->error(); |
|
| 227 | 227 | |
| 228 | - chess_set_message($module, " ... ($mysql_errno) $mysql_error"); |
|
| 228 | + chess_set_message($module, " ... ($mysql_errno) $mysql_error"); |
|
| 229 | 229 | |
| 230 | - return false; |
|
| 231 | - } |
|
| 230 | + return false; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 234 | - } |
|
| 233 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /*** |
|
| 236 | + /*** |
|
| 237 | 237 | * #*#TODO# - Leave this here for now, in case I think of a way to get it to work. |
| 238 | 238 | * # This causes an error about the rating_system module configuration parameter not being defined, |
| 239 | 239 | * # so I added a note in INSTALL.TXT about manually recalculating the ratings after install. |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | * chess_recalc_ratings(); |
| 245 | 245 | ***/ |
| 246 | 246 | |
| 247 | - chess_set_message($module, _MI_CHESS_UPDATE_SUCCESSFUL); |
|
| 247 | + chess_set_message($module, _MI_CHESS_UPDATE_SUCCESSFUL); |
|
| 248 | 248 | |
| 249 | - return true; // successful |
|
| 249 | + return true; // successful |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -257,45 +257,45 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | function chess_check_tables($table_names) |
| 259 | 259 | { |
| 260 | - global $xoopsDB; |
|
| 260 | + global $xoopsDB; |
|
| 261 | 261 | |
| 262 | - $messages = []; |
|
| 262 | + $messages = []; |
|
| 263 | 263 | |
| 264 | - foreach ($table_names as $table_name) { |
|
| 265 | - $query = "CHECK TABLE `$table_name`"; |
|
| 264 | + foreach ($table_names as $table_name) { |
|
| 265 | + $query = "CHECK TABLE `$table_name`"; |
|
| 266 | 266 | |
| 267 | - $result = $xoopsDB->query($query); |
|
| 267 | + $result = $xoopsDB->query($query); |
|
| 268 | 268 | |
| 269 | - if (!$result) { |
|
| 270 | - $mysql_errno = $xoopsDB->errno(); |
|
| 269 | + if (!$result) { |
|
| 270 | + $mysql_errno = $xoopsDB->errno(); |
|
| 271 | 271 | |
| 272 | - $mysql_error = $xoopsDB->error(); |
|
| 272 | + $mysql_error = $xoopsDB->error(); |
|
| 273 | 273 | |
| 274 | - $messages[] = $query; |
|
| 274 | + $messages[] = $query; |
|
| 275 | 275 | |
| 276 | - $messages[] = " ... ($mysql_errno) $mysql_error"; |
|
| 276 | + $messages[] = " ... ($mysql_errno) $mysql_error"; |
|
| 277 | 277 | |
| 278 | - continue; |
|
| 279 | - } |
|
| 278 | + continue; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - // Initialize, in case the real table status fails to get retrieved. |
|
| 281 | + // Initialize, in case the real table status fails to get retrieved. |
|
| 282 | 282 | |
| 283 | - $table_status = '*** STATUS UNKNOWN ***'; |
|
| 283 | + $table_status = '*** STATUS UNKNOWN ***'; |
|
| 284 | 284 | |
| 285 | - // The query may return multiple rows. Only the last row is normally of interest, so only that row is saved. |
|
| 285 | + // The query may return multiple rows. Only the last row is normally of interest, so only that row is saved. |
|
| 286 | 286 | |
| 287 | - while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 288 | - $table_status = $row['Msg_text']; |
|
| 289 | - } |
|
| 287 | + while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 288 | + $table_status = $row['Msg_text']; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - $xoopsDB->freeRecordSet($result); |
|
| 291 | + $xoopsDB->freeRecordSet($result); |
|
| 292 | 292 | |
| 293 | - if ('OK' != $table_status) { |
|
| 294 | - $messages[] = " ... $table_name: $table_status"; |
|
| 295 | - } |
|
| 296 | - } |
|
| 293 | + if ('OK' != $table_status) { |
|
| 294 | + $messages[] = " ... $table_name: $table_status"; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - return $messages; |
|
| 298 | + return $messages; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -310,15 +310,15 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | function chess_load_lang_file($filename, $module = '', $default = 'english') |
| 312 | 312 | { |
| 313 | - $lang = $GLOBALS['xoopsConfig']['language']; |
|
| 313 | + $lang = $GLOBALS['xoopsConfig']['language']; |
|
| 314 | 314 | |
| 315 | - $path = XOOPS_ROOT_PATH . (empty($module) ? '/' : "/modules/$module/") . 'language'; |
|
| 315 | + $path = XOOPS_ROOT_PATH . (empty($module) ? '/' : "/modules/$module/") . 'language'; |
|
| 316 | 316 | |
| 317 | - if (!($ret = @include_once("$path/$lang/$filename.php"))) { |
|
| 318 | - $ret = include_once("$path/$default/$filename.php"); |
|
| 319 | - } |
|
| 317 | + if (!($ret = @include_once("$path/$lang/$filename.php"))) { |
|
| 318 | + $ret = include_once("$path/$default/$filename.php"); |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - return $ret; |
|
| 321 | + return $ret; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -330,13 +330,13 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | function chess_set_message($module, $text = '', $error = false) |
| 332 | 332 | { |
| 333 | - $text = $error ? "<span style='color:#ff0000;background-color:#ffffff;font-weight:bold;'>$text</span>" : $text; |
|
| 333 | + $text = $error ? "<span style='color:#ff0000;background-color:#ffffff;font-weight:bold;'>$text</span>" : $text; |
|
| 334 | 334 | |
| 335 | - // For downward compatibility with XOOPS versions that don't have the method XoopsModule::setMessage. |
|
| 335 | + // For downward compatibility with XOOPS versions that don't have the method XoopsModule::setMessage. |
|
| 336 | 336 | |
| 337 | - if (is_object($module) && method_exists($module, 'setMessage')) { |
|
| 338 | - $module->setMessage($text); |
|
| 339 | - } else { |
|
| 340 | - echo "<code>$text</code><br>\n"; |
|
| 341 | - } |
|
| 337 | + if (is_object($module) && method_exists($module, 'setMessage')) { |
|
| 338 | + $module->setMessage($text); |
|
| 339 | + } else { |
|
| 340 | + echo "<code>$text</code><br>\n"; |
|
| 341 | + } |
|
| 342 | 342 | } |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | $GLOBALS['chess_module_pre_update_called'] = true; |
| 58 | 58 | |
| 59 | 59 | if ($oldversion < 102) { // old version < 1.02: direct update not supported. |
| 60 | - $docfile = XOOPS_ROOT_PATH . '/modules/chess/docs/INSTALL.TXT'; |
|
| 60 | + $docfile = XOOPS_ROOT_PATH.'/modules/chess/docs/INSTALL.TXT'; |
|
| 61 | 61 | |
| 62 | - chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string)$oldversion, $docfile), true); |
|
| 62 | + chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string) $oldversion, $docfile), true); |
|
| 63 | 63 | |
| 64 | 64 | return false; |
| 65 | 65 | } elseif ($oldversion >= 107) { // old version >= 1.07: no action needed. |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $mysql_error = $xoopsDB->error(); |
| 87 | 87 | |
| 88 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string)$mysql_errno, $mysql_error), true); |
|
| 88 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string) $mysql_errno, $mysql_error), true); |
|
| 89 | 89 | |
| 90 | 90 | return false; |
| 91 | 91 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $mysql_error = $xoopsDB->error(); |
| 131 | 131 | |
| 132 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string)$mysql_errno, $mysql_error), true); |
|
| 132 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string) $mysql_errno, $mysql_error), true); |
|
| 133 | 133 | |
| 134 | 134 | return false; |
| 135 | 135 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | { |
| 313 | 313 | $lang = $GLOBALS['xoopsConfig']['language']; |
| 314 | 314 | |
| 315 | - $path = XOOPS_ROOT_PATH . (empty($module) ? '/' : "/modules/$module/") . 'language'; |
|
| 315 | + $path = XOOPS_ROOT_PATH.(empty($module) ? '/' : "/modules/$module/").'language'; |
|
| 316 | 316 | |
| 317 | 317 | if (!($ret = @include_once("$path/$lang/$filename.php"))) { |
| 318 | 318 | $ret = include_once("$path/$default/$filename.php"); |
@@ -41,21 +41,21 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function chess_ratings_adj_linear($white_rating, $white_games, $black_rating, $black_games, $pgn_result) |
| 43 | 43 | { |
| 44 | - // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 45 | - switch ($pgn_result) { |
|
| 46 | - case '1-0': |
|
| 47 | - $S = 1; |
|
| 48 | - break; |
|
| 49 | - case '1/2-1/2': |
|
| 50 | - default: // should not occur |
|
| 51 | - $S = 0; |
|
| 52 | - break; |
|
| 53 | - case '0-1': |
|
| 54 | - $S = -1; |
|
| 55 | - break; |
|
| 56 | - } |
|
| 44 | + // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 45 | + switch ($pgn_result) { |
|
| 46 | + case '1-0': |
|
| 47 | + $S = 1; |
|
| 48 | + break; |
|
| 49 | + case '1/2-1/2': |
|
| 50 | + default: // should not occur |
|
| 51 | + $S = 0; |
|
| 52 | + break; |
|
| 53 | + case '0-1': |
|
| 54 | + $S = -1; |
|
| 55 | + break; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return [$white_rating + $S * 10, $black_rating - $S * 10]; |
|
| 58 | + return [$white_rating + $S * 10, $black_rating - $S * 10]; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function chess_ratings_num_provisional_games_linear() |
| 67 | 67 | { |
| 68 | - return 2; |
|
| 68 | + return 2; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | ?> |
@@ -47,22 +47,22 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function chess_ratings_adj_linear($white_rating, $white_games, $black_rating, $black_games, $pgn_result) |
| 49 | 49 | { |
| 50 | - // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 50 | + // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 51 | 51 | |
| 52 | - switch ($pgn_result) { |
|
| 53 | - case '1-0': |
|
| 54 | - $S = 1; |
|
| 55 | - break; |
|
| 56 | - case '1/2-1/2': |
|
| 57 | - default: // should not occur |
|
| 58 | - $S = 0; |
|
| 59 | - break; |
|
| 60 | - case '0-1': |
|
| 61 | - $S = -1; |
|
| 62 | - break; |
|
| 63 | - } |
|
| 52 | + switch ($pgn_result) { |
|
| 53 | + case '1-0': |
|
| 54 | + $S = 1; |
|
| 55 | + break; |
|
| 56 | + case '1/2-1/2': |
|
| 57 | + default: // should not occur |
|
| 58 | + $S = 0; |
|
| 59 | + break; |
|
| 60 | + case '0-1': |
|
| 61 | + $S = -1; |
|
| 62 | + break; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return [$white_rating + $S * 10, $black_rating - $S * 10]; |
|
| 65 | + return [$white_rating + $S * 10, $black_rating - $S * 10]; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -72,5 +72,5 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function chess_ratings_num_provisional_games_linear() |
| 74 | 74 | { |
| 75 | - return 2; |
|
| 75 | + return 2; |
|
| 76 | 76 | } |
@@ -44,72 +44,72 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | function chess_ratings_adj_cxr($white_rating, $white_games, $black_rating, $black_games, $pgn_result) |
| 46 | 46 | { |
| 47 | - // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 48 | - switch ($pgn_result) { |
|
| 49 | - case '1-0': |
|
| 50 | - $S = 1; |
|
| 51 | - break; |
|
| 52 | - case '1/2-1/2': |
|
| 53 | - default: // should not occur |
|
| 54 | - $S = 0; |
|
| 55 | - break; |
|
| 56 | - case '0-1': |
|
| 57 | - $S = -1; |
|
| 58 | - break; |
|
| 59 | - } |
|
| 47 | + // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 48 | + switch ($pgn_result) { |
|
| 49 | + case '1-0': |
|
| 50 | + $S = 1; |
|
| 51 | + break; |
|
| 52 | + case '1/2-1/2': |
|
| 53 | + default: // should not occur |
|
| 54 | + $S = 0; |
|
| 55 | + break; |
|
| 56 | + case '0-1': |
|
| 57 | + $S = -1; |
|
| 58 | + break; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - if (($white_games < 5 and $black_games < 5) or ($white_games > 5 and $black_games > 5)) { |
|
| 62 | - // Formula 1: Rnew = Rold + (S x 21) + (Ropponent - Rold) / 25 |
|
| 63 | - $w_new = ($S * 21) + ($black_rating - $white_rating) / 25; |
|
| 64 | - $b_new = (-$S * 21) + ($white_rating - $black_rating) / 25; |
|
| 65 | - } elseif ($white_games > 5 and $black_games < 5) { |
|
| 66 | - // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 67 | - $w_new = ($S * 6) + ($black_rating - $white_rating) / 100; |
|
| 61 | + if (($white_games < 5 and $black_games < 5) or ($white_games > 5 and $black_games > 5)) { |
|
| 62 | + // Formula 1: Rnew = Rold + (S x 21) + (Ropponent - Rold) / 25 |
|
| 63 | + $w_new = ($S * 21) + ($black_rating - $white_rating) / 25; |
|
| 64 | + $b_new = (-$S * 21) + ($white_rating - $black_rating) / 25; |
|
| 65 | + } elseif ($white_games > 5 and $black_games < 5) { |
|
| 66 | + // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 67 | + $w_new = ($S * 6) + ($black_rating - $white_rating) / 100; |
|
| 68 | 68 | |
| 69 | - // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 70 | - $b_new = ($white_rating / 5) + ($S * -80) - ($black_rating / 5); |
|
| 71 | - } else { |
|
| 72 | - // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 73 | - $b_new = ($S * 6) + ($white_rating - $black_rating) / 100; |
|
| 69 | + // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 70 | + $b_new = ($white_rating / 5) + ($S * -80) - ($black_rating / 5); |
|
| 71 | + } else { |
|
| 72 | + // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 73 | + $b_new = ($S * 6) + ($white_rating - $black_rating) / 100; |
|
| 74 | 74 | |
| 75 | - // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 76 | - $w_new = ($black_rating / 5) + ($S * -80) - ($white_rating / 5); |
|
| 77 | - } |
|
| 75 | + // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 76 | + $w_new = ($black_rating / 5) + ($S * -80) - ($white_rating / 5); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - // Rule R1: The winning rated player must gain at least two points. |
|
| 80 | - // Rule R2: The losing rated player must lose at least two points. |
|
| 81 | - if (abs($w_new) < 2) { |
|
| 82 | - $w_new = $S * 2; |
|
| 83 | - } |
|
| 84 | - if (abs($b_new) < 2) { |
|
| 85 | - $b_new = $S * -2; |
|
| 86 | - } |
|
| 79 | + // Rule R1: The winning rated player must gain at least two points. |
|
| 80 | + // Rule R2: The losing rated player must lose at least two points. |
|
| 81 | + if (abs($w_new) < 2) { |
|
| 82 | + $w_new = $S * 2; |
|
| 83 | + } |
|
| 84 | + if (abs($b_new) < 2) { |
|
| 85 | + $b_new = $S * -2; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // Rule R3: The rated player must not gain nor lose more than 41 points. |
|
| 89 | - if (abs($w_new) > 41) { |
|
| 90 | - $w_new = $S * 41; |
|
| 91 | - } |
|
| 92 | - if (abs($b_new) > 41) { |
|
| 93 | - $b_new = $S * -41; |
|
| 94 | - } |
|
| 88 | + // Rule R3: The rated player must not gain nor lose more than 41 points. |
|
| 89 | + if (abs($w_new) > 41) { |
|
| 90 | + $w_new = $S * 41; |
|
| 91 | + } |
|
| 92 | + if (abs($b_new) > 41) { |
|
| 93 | + $b_new = $S * -41; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - if (1 == $S) { |
|
| 97 | - if ($white_games < 5 and $w_new < 0) { |
|
| 98 | - $w_new = 2; |
|
| 99 | - } |
|
| 100 | - if ($black_games < 5 and $b_new > 0) { |
|
| 101 | - $b_new = -2; |
|
| 102 | - } |
|
| 103 | - } elseif (-1 == $S) { |
|
| 104 | - if ($white_games < 5 and $w_new > 0) { |
|
| 105 | - $w_new = -2; |
|
| 106 | - } |
|
| 107 | - if ($black_games < 5 and $b_new < 0) { |
|
| 108 | - $b_new = 2; |
|
| 109 | - } |
|
| 110 | - } |
|
| 96 | + if (1 == $S) { |
|
| 97 | + if ($white_games < 5 and $w_new < 0) { |
|
| 98 | + $w_new = 2; |
|
| 99 | + } |
|
| 100 | + if ($black_games < 5 and $b_new > 0) { |
|
| 101 | + $b_new = -2; |
|
| 102 | + } |
|
| 103 | + } elseif (-1 == $S) { |
|
| 104 | + if ($white_games < 5 and $w_new > 0) { |
|
| 105 | + $w_new = -2; |
|
| 106 | + } |
|
| 107 | + if ($black_games < 5 and $b_new < 0) { |
|
| 108 | + $b_new = 2; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - return [$white_rating + $w_new, $black_rating + $b_new]; |
|
| 112 | + return [$white_rating + $w_new, $black_rating + $b_new]; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function chess_ratings_num_provisional_games_cxr() |
| 121 | 121 | { |
| 122 | - return 5; |
|
| 122 | + return 5; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | ?> |
@@ -41,28 +41,28 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function chess_ratings_adj($gid) |
| 43 | 43 | { |
| 44 | - global $xoopsDB; |
|
| 44 | + global $xoopsDB; |
|
| 45 | 45 | |
| 46 | - $rating_system = chess_moduleConfig('rating_system'); |
|
| 46 | + $rating_system = chess_moduleConfig('rating_system'); |
|
| 47 | 47 | |
| 48 | - $init_rating = chess_moduleConfig('initial_rating'); |
|
| 48 | + $init_rating = chess_moduleConfig('initial_rating'); |
|
| 49 | 49 | |
| 50 | - if ('none' == $rating_system) { |
|
| 51 | - return false; |
|
| 52 | - } |
|
| 50 | + if ('none' == $rating_system) { |
|
| 51 | + return false; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - // determine function for calculating new ratings using configured rating system |
|
| 54 | + // determine function for calculating new ratings using configured rating system |
|
| 55 | 55 | |
| 56 | - $func = chess_ratings_get_func_adj($rating_system); |
|
| 56 | + $func = chess_ratings_get_func_adj($rating_system); |
|
| 57 | 57 | |
| 58 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 58 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 59 | 59 | |
| 60 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 60 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 61 | 61 | |
| 62 | - // get the game info |
|
| 62 | + // get the game info |
|
| 63 | 63 | |
| 64 | - $result = $xoopsDB->query( |
|
| 65 | - " |
|
| 64 | + $result = $xoopsDB->query( |
|
| 65 | + " |
|
| 66 | 66 | SELECT |
| 67 | 67 | g.white_uid AS white_uid, g.black_uid AS black_uid, g.pgn_result AS pgn_result, w.rating AS white_rating, b.rating AS black_rating, |
| 68 | 68 | (w.games_won+w.games_lost+w.games_drawn) AS white_games, (b.games_won+b.games_lost+b.games_drawn) AS black_games |
@@ -72,77 +72,77 @@ discard block |
||
| 72 | 72 | WHERE g.game_id = '$gid' AND g.is_rated = '1' AND g.pgn_result != '*' |
| 73 | 73 | AND (w.player_uid IS NULL OR b.player_uid IS NULL OR w.player_uid != b.player_uid) |
| 74 | 74 | " |
| 75 | - ); |
|
| 75 | + ); |
|
| 76 | 76 | |
| 77 | - // check that game exists and is rated |
|
| 77 | + // check that game exists and is rated |
|
| 78 | 78 | |
| 79 | - if (1 != $xoopsDB->getRowsNum($result)) { |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 79 | + if (1 != $xoopsDB->getRowsNum($result)) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $row = $xoopsDB->fetchArray($result); |
|
| 83 | + $row = $xoopsDB->fetchArray($result); |
|
| 84 | 84 | |
| 85 | - $xoopsDB->freeRecordSet($result); |
|
| 85 | + $xoopsDB->freeRecordSet($result); |
|
| 86 | 86 | |
| 87 | - #var_dump($row);#*#DEBUG# |
|
| 87 | + #var_dump($row);#*#DEBUG# |
|
| 88 | 88 | |
| 89 | - // make sure the users are in the players' table |
|
| 89 | + // make sure the users are in the players' table |
|
| 90 | 90 | |
| 91 | - $value_list = []; |
|
| 91 | + $value_list = []; |
|
| 92 | 92 | |
| 93 | - if (!isset($row['white_rating'])) { |
|
| 94 | - $row['white_rating'] = $init_rating; |
|
| 93 | + if (!isset($row['white_rating'])) { |
|
| 94 | + $row['white_rating'] = $init_rating; |
|
| 95 | 95 | |
| 96 | - $row['white_games'] = 0; |
|
| 96 | + $row['white_games'] = 0; |
|
| 97 | 97 | |
| 98 | - $value_list[] = "('{$row['white_uid']}','{$row['white_rating']}')"; |
|
| 99 | - } |
|
| 98 | + $value_list[] = "('{$row['white_uid']}','{$row['white_rating']}')"; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - if (!isset($row['black_rating'])) { |
|
| 102 | - $row['black_rating'] = $init_rating; |
|
| 101 | + if (!isset($row['black_rating'])) { |
|
| 102 | + $row['black_rating'] = $init_rating; |
|
| 103 | 103 | |
| 104 | - $row['black_games'] = 0; |
|
| 104 | + $row['black_games'] = 0; |
|
| 105 | 105 | |
| 106 | - $value_list[] = "('{$row['black_uid']}','{$row['black_rating']}')"; |
|
| 107 | - } |
|
| 106 | + $value_list[] = "('{$row['black_uid']}','{$row['black_rating']}')"; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if (!empty($value_list)) { |
|
| 110 | - $values = implode(',', $value_list); |
|
| 109 | + if (!empty($value_list)) { |
|
| 110 | + $values = implode(',', $value_list); |
|
| 111 | 111 | |
| 112 | - $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating) VALUES $values"); |
|
| 112 | + $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating) VALUES $values"); |
|
| 113 | 113 | |
| 114 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 115 | - } |
|
| 114 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - // calculate new ratings using configured rating system |
|
| 117 | + // calculate new ratings using configured rating system |
|
| 118 | 118 | |
| 119 | - [$white_rating_new, $black_rating_new] = $func($row['white_rating'], $row['white_games'], $row['black_rating'], $row['black_games'], $row['pgn_result']); |
|
| 119 | + [$white_rating_new, $black_rating_new] = $func($row['white_rating'], $row['white_games'], $row['black_rating'], $row['black_games'], $row['pgn_result']); |
|
| 120 | 120 | |
| 121 | - // determine game-count columns to increment |
|
| 121 | + // determine game-count columns to increment |
|
| 122 | 122 | |
| 123 | - [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 123 | + [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 124 | 124 | |
| 125 | - $xoopsDB->query( |
|
| 126 | - " |
|
| 125 | + $xoopsDB->query( |
|
| 126 | + " |
|
| 127 | 127 | UPDATE $ratings_table |
| 128 | 128 | SET rating = '$white_rating_new', $white_col = $white_col + 1 |
| 129 | 129 | WHERE player_uid = '{$row['white_uid']}' |
| 130 | 130 | " |
| 131 | - ); |
|
| 131 | + ); |
|
| 132 | 132 | |
| 133 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 133 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 134 | 134 | |
| 135 | - $xoopsDB->query( |
|
| 136 | - " |
|
| 135 | + $xoopsDB->query( |
|
| 136 | + " |
|
| 137 | 137 | UPDATE $ratings_table |
| 138 | 138 | SET rating = '$black_rating_new', $black_col = $black_col + 1 |
| 139 | 139 | WHERE player_uid = '{$row['black_uid']}' |
| 140 | 140 | " |
| 141 | - ); |
|
| 141 | + ); |
|
| 142 | 142 | |
| 143 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 143 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 144 | 144 | |
| 145 | - return true; |
|
| 145 | + return true; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -152,98 +152,98 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | function chess_recalc_ratings() |
| 154 | 154 | { |
| 155 | - global $xoopsDB; |
|
| 155 | + global $xoopsDB; |
|
| 156 | 156 | |
| 157 | - $rating_system = chess_moduleConfig('rating_system'); |
|
| 157 | + $rating_system = chess_moduleConfig('rating_system'); |
|
| 158 | 158 | |
| 159 | - $init_rating = chess_moduleConfig('initial_rating'); |
|
| 159 | + $init_rating = chess_moduleConfig('initial_rating'); |
|
| 160 | 160 | |
| 161 | - if ('none' == $rating_system) { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 161 | + if ('none' == $rating_system) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - // determine function for calculating new ratings using configured rating system |
|
| 165 | + // determine function for calculating new ratings using configured rating system |
|
| 166 | 166 | |
| 167 | - $func = chess_ratings_get_func_adj($rating_system); |
|
| 167 | + $func = chess_ratings_get_func_adj($rating_system); |
|
| 168 | 168 | |
| 169 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 169 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 170 | 170 | |
| 171 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 171 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 172 | 172 | |
| 173 | - // Nuke the current ratings. #*#TBD# - don't want to empty this table, since there will be other info in it besides ratings (?) |
|
| 173 | + // Nuke the current ratings. #*#TBD# - don't want to empty this table, since there will be other info in it besides ratings (?) |
|
| 174 | 174 | |
| 175 | - $xoopsDB->query("DELETE FROM $ratings_table"); |
|
| 175 | + $xoopsDB->query("DELETE FROM $ratings_table"); |
|
| 176 | 176 | |
| 177 | - // get all games |
|
| 177 | + // get all games |
|
| 178 | 178 | |
| 179 | - $result = $xoopsDB->query( |
|
| 180 | - " |
|
| 179 | + $result = $xoopsDB->query( |
|
| 180 | + " |
|
| 181 | 181 | SELECT white_uid, black_uid, pgn_result |
| 182 | 182 | FROM $games_table |
| 183 | 183 | WHERE is_rated = '1' AND pgn_result != '*' AND white_uid != black_uid |
| 184 | 184 | ORDER BY last_date ASC |
| 185 | 185 | " |
| 186 | - ); |
|
| 186 | + ); |
|
| 187 | 187 | |
| 188 | - $players = []; |
|
| 188 | + $players = []; |
|
| 189 | 189 | |
| 190 | - // process the games |
|
| 190 | + // process the games |
|
| 191 | 191 | |
| 192 | - while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 193 | - #var_dump($row);#*#DEBUG# |
|
| 192 | + while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 193 | + #var_dump($row);#*#DEBUG# |
|
| 194 | 194 | |
| 195 | - if (!isset($players[$row['white_uid']])) { |
|
| 196 | - $players[$row['white_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 197 | - } |
|
| 195 | + if (!isset($players[$row['white_uid']])) { |
|
| 196 | + $players[$row['white_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - if (!isset($players[$row['black_uid']])) { |
|
| 200 | - $players[$row['black_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 201 | - } |
|
| 199 | + if (!isset($players[$row['black_uid']])) { |
|
| 200 | + $players[$row['black_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - $player_white = &$players[$row['white_uid']]; |
|
| 203 | + $player_white = &$players[$row['white_uid']]; |
|
| 204 | 204 | |
| 205 | - $player_black = &$players[$row['black_uid']]; |
|
| 205 | + $player_black = &$players[$row['black_uid']]; |
|
| 206 | 206 | |
| 207 | - // calculate new ratings using configured rating system |
|
| 207 | + // calculate new ratings using configured rating system |
|
| 208 | 208 | |
| 209 | - [$white_rating_new, $black_rating_new] = $func( |
|
| 210 | - $player_white['rating'], |
|
| 211 | - $player_white['games_won'] + $player_white['games_lost'] + $player_white['games_drawn'], |
|
| 212 | - $player_black['rating'], |
|
| 213 | - $player_black['games_won'] + $player_black['games_lost'] + $player_black['games_drawn'], |
|
| 214 | - $row['pgn_result'] |
|
| 215 | - ); |
|
| 209 | + [$white_rating_new, $black_rating_new] = $func( |
|
| 210 | + $player_white['rating'], |
|
| 211 | + $player_white['games_won'] + $player_white['games_lost'] + $player_white['games_drawn'], |
|
| 212 | + $player_black['rating'], |
|
| 213 | + $player_black['games_won'] + $player_black['games_lost'] + $player_black['games_drawn'], |
|
| 214 | + $row['pgn_result'] |
|
| 215 | + ); |
|
| 216 | 216 | |
| 217 | - // determine game-count columns to increment |
|
| 217 | + // determine game-count columns to increment |
|
| 218 | 218 | |
| 219 | - [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 219 | + [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 220 | 220 | |
| 221 | - $player_white['rating'] = $white_rating_new; |
|
| 221 | + $player_white['rating'] = $white_rating_new; |
|
| 222 | 222 | |
| 223 | - ++$player_white[$white_col]; |
|
| 223 | + ++$player_white[$white_col]; |
|
| 224 | 224 | |
| 225 | - $player_black['rating'] = $black_rating_new; |
|
| 225 | + $player_black['rating'] = $black_rating_new; |
|
| 226 | 226 | |
| 227 | - ++$player_black[$black_col]; |
|
| 228 | - } |
|
| 227 | + ++$player_black[$black_col]; |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - $xoopsDB->freeRecordSet($result); |
|
| 230 | + $xoopsDB->freeRecordSet($result); |
|
| 231 | 231 | |
| 232 | - if (!empty($players)) { |
|
| 233 | - $value_list = []; |
|
| 232 | + if (!empty($players)) { |
|
| 233 | + $value_list = []; |
|
| 234 | 234 | |
| 235 | - foreach ($players as $player_uid => $player) { |
|
| 236 | - $value_list[] = "('$player_uid', '{$player['rating']}', '{$player['games_won']}', '{$player['games_lost']}', '{$player['games_drawn']}')"; |
|
| 237 | - } |
|
| 235 | + foreach ($players as $player_uid => $player) { |
|
| 236 | + $value_list[] = "('$player_uid', '{$player['rating']}', '{$player['games_won']}', '{$player['games_lost']}', '{$player['games_drawn']}')"; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - $values = implode(',', $value_list); |
|
| 239 | + $values = implode(',', $value_list); |
|
| 240 | 240 | |
| 241 | - $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating, games_won, games_lost, games_drawn) VALUES $values"); |
|
| 241 | + $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating, games_won, games_lost, games_drawn) VALUES $values"); |
|
| 242 | 242 | |
| 243 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 244 | - } |
|
| 243 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return true; |
|
| 246 | + return true; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -253,25 +253,25 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | function chess_ratings_num_provisional_games() |
| 255 | 255 | { |
| 256 | - $rating_system = chess_moduleConfig('rating_system'); |
|
| 256 | + $rating_system = chess_moduleConfig('rating_system'); |
|
| 257 | 257 | |
| 258 | - if ('none' == $rating_system) { |
|
| 259 | - return 0; |
|
| 260 | - } |
|
| 258 | + if ('none' == $rating_system) { |
|
| 259 | + return 0; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - // determine function for getting number of provisional games using configured rating system |
|
| 262 | + // determine function for getting number of provisional games using configured rating system |
|
| 263 | 263 | |
| 264 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 264 | + $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 265 | 265 | |
| 266 | - file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 266 | + file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 267 | 267 | |
| 268 | - require_once $file; |
|
| 268 | + require_once $file; |
|
| 269 | 269 | |
| 270 | - $func = "chess_ratings_num_provisional_games_{$rating_system}"; |
|
| 270 | + $func = "chess_ratings_num_provisional_games_{$rating_system}"; |
|
| 271 | 271 | |
| 272 | - function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 272 | + function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 273 | 273 | |
| 274 | - return $func(); |
|
| 274 | + return $func(); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -282,17 +282,17 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | function chess_ratings_get_func_adj($rating_system) |
| 284 | 284 | { |
| 285 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 285 | + $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 286 | 286 | |
| 287 | - file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 287 | + file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 288 | 288 | |
| 289 | - require_once $file; |
|
| 289 | + require_once $file; |
|
| 290 | 290 | |
| 291 | - $func = "chess_ratings_adj_{$rating_system}"; |
|
| 291 | + $func = "chess_ratings_adj_{$rating_system}"; |
|
| 292 | 292 | |
| 293 | - function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 293 | + function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 294 | 294 | |
| 295 | - return $func; |
|
| 295 | + return $func; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -307,21 +307,21 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | function chess_ratings_get_columns($pgn_result) |
| 309 | 309 | { |
| 310 | - switch ($pgn_result) { |
|
| 311 | - case '1-0': |
|
| 312 | - $white_col = 'games_won'; |
|
| 313 | - $black_col = 'games_lost'; |
|
| 314 | - break; |
|
| 315 | - case '1/2-1/2': |
|
| 316 | - default: // should not occur |
|
| 317 | - $white_col = 'games_drawn'; |
|
| 318 | - $black_col = 'games_drawn'; |
|
| 319 | - break; |
|
| 320 | - case '0-1': |
|
| 321 | - $white_col = 'games_lost'; |
|
| 322 | - $black_col = 'games_won'; |
|
| 323 | - break; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - return [$white_col, $black_col]; |
|
| 310 | + switch ($pgn_result) { |
|
| 311 | + case '1-0': |
|
| 312 | + $white_col = 'games_won'; |
|
| 313 | + $black_col = 'games_lost'; |
|
| 314 | + break; |
|
| 315 | + case '1/2-1/2': |
|
| 316 | + default: // should not occur |
|
| 317 | + $white_col = 'games_drawn'; |
|
| 318 | + $black_col = 'games_drawn'; |
|
| 319 | + break; |
|
| 320 | + case '0-1': |
|
| 321 | + $white_col = 'games_lost'; |
|
| 322 | + $black_col = 'games_won'; |
|
| 323 | + break; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + return [$white_col, $black_col]; |
|
| 327 | 327 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | /**#@+ |
| 32 | 32 | */ |
| 33 | -require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php'; |
|
| 33 | +require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php'; |
|
| 34 | 34 | /**#@-*/ |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating) VALUES $values"); |
| 113 | 113 | |
| 114 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 114 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // calculate new ratings using configured rating system |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | " |
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 133 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 134 | 134 | |
| 135 | 135 | $xoopsDB->query( |
| 136 | 136 | " |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | " |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 143 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 144 | 144 | |
| 145 | 145 | return true; |
| 146 | 146 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating, games_won, games_lost, games_drawn) VALUES $values"); |
| 242 | 242 | |
| 243 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 243 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | return true; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | // determine function for getting number of provisional games using configured rating system |
| 263 | 263 | |
| 264 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 264 | + $file = XOOPS_ROOT_PATH."/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 265 | 265 | |
| 266 | 266 | file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
| 267 | 267 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | function chess_ratings_get_func_adj($rating_system) |
| 284 | 284 | { |
| 285 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 285 | + $file = XOOPS_ROOT_PATH."/modules/chess/include/ratings_{$rating_system}.php"; |
|
| 286 | 286 | |
| 287 | 287 | file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
| 288 | 288 | |
@@ -40,24 +40,24 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function chess_ratings_adj($gid) |
| 42 | 42 | { |
| 43 | - global $xoopsDB; |
|
| 43 | + global $xoopsDB; |
|
| 44 | 44 | |
| 45 | - $rating_system = chess_moduleConfig('rating_system'); |
|
| 46 | - $init_rating = chess_moduleConfig('initial_rating'); |
|
| 45 | + $rating_system = chess_moduleConfig('rating_system'); |
|
| 46 | + $init_rating = chess_moduleConfig('initial_rating'); |
|
| 47 | 47 | |
| 48 | - if ('none' == $rating_system) { |
|
| 49 | - return false; |
|
| 50 | - } |
|
| 48 | + if ('none' == $rating_system) { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // determine function for calculating new ratings using configured rating system |
|
| 53 | - $func = chess_ratings_get_func_adj($rating_system); |
|
| 52 | + // determine function for calculating new ratings using configured rating system |
|
| 53 | + $func = chess_ratings_get_func_adj($rating_system); |
|
| 54 | 54 | |
| 55 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 56 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 55 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 56 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 57 | 57 | |
| 58 | - // get the game info |
|
| 59 | - $result = $xoopsDB->query( |
|
| 60 | - " |
|
| 58 | + // get the game info |
|
| 59 | + $result = $xoopsDB->query( |
|
| 60 | + " |
|
| 61 | 61 | SELECT |
| 62 | 62 | g.white_uid AS white_uid, g.black_uid AS black_uid, g.pgn_result AS pgn_result, w.rating AS white_rating, b.rating AS black_rating, |
| 63 | 63 | (w.games_won+w.games_lost+w.games_drawn) AS white_games, (b.games_won+b.games_lost+b.games_drawn) AS black_games |
@@ -67,60 +67,60 @@ discard block |
||
| 67 | 67 | WHERE g.game_id = '$gid' AND g.is_rated = '1' AND g.pgn_result != '*' |
| 68 | 68 | AND (w.player_uid IS NULL OR b.player_uid IS NULL OR w.player_uid != b.player_uid) |
| 69 | 69 | " |
| 70 | - ); |
|
| 71 | - |
|
| 72 | - // check that game exists and is rated |
|
| 73 | - if (1 != $xoopsDB->getRowsNum($result)) { |
|
| 74 | - return false; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $row = $xoopsDB->fetchArray($result); |
|
| 78 | - $xoopsDB->freeRecordSet($result); |
|
| 79 | - |
|
| 80 | - #var_dump($row);#*#DEBUG# |
|
| 81 | - // make sure the users are in the players' table |
|
| 82 | - $value_list = []; |
|
| 83 | - if (!isset($row['white_rating'])) { |
|
| 84 | - $row['white_rating'] = $init_rating; |
|
| 85 | - $row['white_games'] = 0; |
|
| 86 | - $value_list[] = "('{$row['white_uid']}','{$row['white_rating']}')"; |
|
| 87 | - } |
|
| 88 | - if (!isset($row['black_rating'])) { |
|
| 89 | - $row['black_rating'] = $init_rating; |
|
| 90 | - $row['black_games'] = 0; |
|
| 91 | - $value_list[] = "('{$row['black_uid']}','{$row['black_rating']}')"; |
|
| 92 | - } |
|
| 93 | - if (!empty($value_list)) { |
|
| 94 | - $values = implode(',', $value_list); |
|
| 95 | - $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating) VALUES $values"); |
|
| 96 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // calculate new ratings using configured rating system |
|
| 100 | - [$white_rating_new, $black_rating_new] = $func($row['white_rating'], $row['white_games'], $row['black_rating'], $row['black_games'], $row['pgn_result']); |
|
| 101 | - |
|
| 102 | - // determine game-count columns to increment |
|
| 103 | - [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 104 | - |
|
| 105 | - $xoopsDB->query( |
|
| 106 | - " |
|
| 70 | + ); |
|
| 71 | + |
|
| 72 | + // check that game exists and is rated |
|
| 73 | + if (1 != $xoopsDB->getRowsNum($result)) { |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $row = $xoopsDB->fetchArray($result); |
|
| 78 | + $xoopsDB->freeRecordSet($result); |
|
| 79 | + |
|
| 80 | + #var_dump($row);#*#DEBUG# |
|
| 81 | + // make sure the users are in the players' table |
|
| 82 | + $value_list = []; |
|
| 83 | + if (!isset($row['white_rating'])) { |
|
| 84 | + $row['white_rating'] = $init_rating; |
|
| 85 | + $row['white_games'] = 0; |
|
| 86 | + $value_list[] = "('{$row['white_uid']}','{$row['white_rating']}')"; |
|
| 87 | + } |
|
| 88 | + if (!isset($row['black_rating'])) { |
|
| 89 | + $row['black_rating'] = $init_rating; |
|
| 90 | + $row['black_games'] = 0; |
|
| 91 | + $value_list[] = "('{$row['black_uid']}','{$row['black_rating']}')"; |
|
| 92 | + } |
|
| 93 | + if (!empty($value_list)) { |
|
| 94 | + $values = implode(',', $value_list); |
|
| 95 | + $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating) VALUES $values"); |
|
| 96 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // calculate new ratings using configured rating system |
|
| 100 | + [$white_rating_new, $black_rating_new] = $func($row['white_rating'], $row['white_games'], $row['black_rating'], $row['black_games'], $row['pgn_result']); |
|
| 101 | + |
|
| 102 | + // determine game-count columns to increment |
|
| 103 | + [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 104 | + |
|
| 105 | + $xoopsDB->query( |
|
| 106 | + " |
|
| 107 | 107 | UPDATE $ratings_table |
| 108 | 108 | SET rating = '$white_rating_new', $white_col = $white_col + 1 |
| 109 | 109 | WHERE player_uid = '{$row['white_uid']}' |
| 110 | 110 | " |
| 111 | - ); |
|
| 112 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 111 | + ); |
|
| 112 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 113 | 113 | |
| 114 | - $xoopsDB->query( |
|
| 115 | - " |
|
| 114 | + $xoopsDB->query( |
|
| 115 | + " |
|
| 116 | 116 | UPDATE $ratings_table |
| 117 | 117 | SET rating = '$black_rating_new', $black_col = $black_col + 1 |
| 118 | 118 | WHERE player_uid = '{$row['black_uid']}' |
| 119 | 119 | " |
| 120 | - ); |
|
| 121 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 120 | + ); |
|
| 121 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 122 | 122 | |
| 123 | - return true; |
|
| 123 | + return true; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,82 +130,82 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | function chess_recalc_ratings() |
| 132 | 132 | { |
| 133 | - global $xoopsDB; |
|
| 133 | + global $xoopsDB; |
|
| 134 | 134 | |
| 135 | - $rating_system = chess_moduleConfig('rating_system'); |
|
| 136 | - $init_rating = chess_moduleConfig('initial_rating'); |
|
| 135 | + $rating_system = chess_moduleConfig('rating_system'); |
|
| 136 | + $init_rating = chess_moduleConfig('initial_rating'); |
|
| 137 | 137 | |
| 138 | - if ('none' == $rating_system) { |
|
| 139 | - return false; |
|
| 140 | - } |
|
| 138 | + if ('none' == $rating_system) { |
|
| 139 | + return false; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - // determine function for calculating new ratings using configured rating system |
|
| 143 | - $func = chess_ratings_get_func_adj($rating_system); |
|
| 142 | + // determine function for calculating new ratings using configured rating system |
|
| 143 | + $func = chess_ratings_get_func_adj($rating_system); |
|
| 144 | 144 | |
| 145 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 146 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 145 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 146 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 147 | 147 | |
| 148 | - // Nuke the current ratings. #*#TBD# - don't want to empty this table, since there will be other info in it besides ratings (?) |
|
| 149 | - $xoopsDB->query("DELETE FROM $ratings_table"); |
|
| 148 | + // Nuke the current ratings. #*#TBD# - don't want to empty this table, since there will be other info in it besides ratings (?) |
|
| 149 | + $xoopsDB->query("DELETE FROM $ratings_table"); |
|
| 150 | 150 | |
| 151 | - // get all games |
|
| 152 | - $result = $xoopsDB->query( |
|
| 153 | - " |
|
| 151 | + // get all games |
|
| 152 | + $result = $xoopsDB->query( |
|
| 153 | + " |
|
| 154 | 154 | SELECT white_uid, black_uid, pgn_result |
| 155 | 155 | FROM $games_table |
| 156 | 156 | WHERE is_rated = '1' AND pgn_result != '*' AND white_uid != black_uid |
| 157 | 157 | ORDER BY last_date ASC |
| 158 | 158 | " |
| 159 | - ); |
|
| 160 | - |
|
| 161 | - $players = []; |
|
| 162 | - |
|
| 163 | - // process the games |
|
| 164 | - while ($row = $xoopsDB->fetchArray($result)) { |
|
| 165 | - #var_dump($row);#*#DEBUG# |
|
| 166 | - if (!isset($players[$row['white_uid']])) { |
|
| 167 | - $players[$row['white_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 168 | - } |
|
| 169 | - if (!isset($players[$row['black_uid']])) { |
|
| 170 | - $players[$row['black_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - $player_white = $players[$row['white_uid']]; |
|
| 174 | - $player_black = $players[$row['black_uid']]; |
|
| 175 | - |
|
| 176 | - // calculate new ratings using configured rating system |
|
| 177 | - [$white_rating_new, $black_rating_new] = $func( |
|
| 178 | - $player_white['rating'], |
|
| 179 | - $player_white['games_won'] + $player_white['games_lost'] + $player_white['games_drawn'], |
|
| 180 | - $player_black['rating'], |
|
| 181 | - $player_black['games_won'] + $player_black['games_lost'] + $player_black['games_drawn'], |
|
| 182 | - $row['pgn_result'] |
|
| 183 | - ); |
|
| 184 | - |
|
| 185 | - // determine game-count columns to increment |
|
| 186 | - [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 187 | - |
|
| 188 | - $player_white['rating'] = $white_rating_new; |
|
| 189 | - ++$player_white[$white_col]; |
|
| 190 | - |
|
| 191 | - $player_black['rating'] = $black_rating_new; |
|
| 192 | - ++$player_black[$black_col]; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - $xoopsDB->freeRecordSet($result); |
|
| 196 | - |
|
| 197 | - if (!empty($players)) { |
|
| 198 | - $value_list = []; |
|
| 199 | - foreach ($players as $player_uid => $player) { |
|
| 200 | - $value_list[] = "('$player_uid', '{$player['rating']}', '{$player['games_won']}', '{$player['games_lost']}', '{$player['games_drawn']}')"; |
|
| 201 | - } |
|
| 202 | - $values = implode(',', $value_list); |
|
| 203 | - |
|
| 204 | - $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating, games_won, games_lost, games_drawn) VALUES $values"); |
|
| 205 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - return true; |
|
| 159 | + ); |
|
| 160 | + |
|
| 161 | + $players = []; |
|
| 162 | + |
|
| 163 | + // process the games |
|
| 164 | + while ($row = $xoopsDB->fetchArray($result)) { |
|
| 165 | + #var_dump($row);#*#DEBUG# |
|
| 166 | + if (!isset($players[$row['white_uid']])) { |
|
| 167 | + $players[$row['white_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 168 | + } |
|
| 169 | + if (!isset($players[$row['black_uid']])) { |
|
| 170 | + $players[$row['black_uid']] = ['rating' => $init_rating, 'games_won' => 0, 'games_lost' => 0, 'games_drawn' => 0]; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + $player_white = $players[$row['white_uid']]; |
|
| 174 | + $player_black = $players[$row['black_uid']]; |
|
| 175 | + |
|
| 176 | + // calculate new ratings using configured rating system |
|
| 177 | + [$white_rating_new, $black_rating_new] = $func( |
|
| 178 | + $player_white['rating'], |
|
| 179 | + $player_white['games_won'] + $player_white['games_lost'] + $player_white['games_drawn'], |
|
| 180 | + $player_black['rating'], |
|
| 181 | + $player_black['games_won'] + $player_black['games_lost'] + $player_black['games_drawn'], |
|
| 182 | + $row['pgn_result'] |
|
| 183 | + ); |
|
| 184 | + |
|
| 185 | + // determine game-count columns to increment |
|
| 186 | + [$white_col, $black_col] = chess_ratings_get_columns($row['pgn_result']); |
|
| 187 | + |
|
| 188 | + $player_white['rating'] = $white_rating_new; |
|
| 189 | + ++$player_white[$white_col]; |
|
| 190 | + |
|
| 191 | + $player_black['rating'] = $black_rating_new; |
|
| 192 | + ++$player_black[$black_col]; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + $xoopsDB->freeRecordSet($result); |
|
| 196 | + |
|
| 197 | + if (!empty($players)) { |
|
| 198 | + $value_list = []; |
|
| 199 | + foreach ($players as $player_uid => $player) { |
|
| 200 | + $value_list[] = "('$player_uid', '{$player['rating']}', '{$player['games_won']}', '{$player['games_lost']}', '{$player['games_drawn']}')"; |
|
| 201 | + } |
|
| 202 | + $values = implode(',', $value_list); |
|
| 203 | + |
|
| 204 | + $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating, games_won, games_lost, games_drawn) VALUES $values"); |
|
| 205 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + return true; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -215,20 +215,20 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | function chess_ratings_num_provisional_games() |
| 217 | 217 | { |
| 218 | - $rating_system = chess_moduleConfig('rating_system'); |
|
| 218 | + $rating_system = chess_moduleConfig('rating_system'); |
|
| 219 | 219 | |
| 220 | - if ('none' == $rating_system) { |
|
| 221 | - return 0; |
|
| 222 | - } |
|
| 220 | + if ('none' == $rating_system) { |
|
| 221 | + return 0; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - // determine function for getting number of provisional games using configured rating system |
|
| 225 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 226 | - file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 227 | - require_once $file; |
|
| 228 | - $func = "chess_ratings_num_provisional_games_{$rating_system}"; |
|
| 229 | - function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 224 | + // determine function for getting number of provisional games using configured rating system |
|
| 225 | + $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 226 | + file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 227 | + require_once $file; |
|
| 228 | + $func = "chess_ratings_num_provisional_games_{$rating_system}"; |
|
| 229 | + function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 230 | 230 | |
| 231 | - return $func(); |
|
| 231 | + return $func(); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | function chess_ratings_get_func_adj($rating_system) |
| 241 | 241 | { |
| 242 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 243 | - file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 244 | - require_once $file; |
|
| 245 | - $func = "chess_ratings_adj_{$rating_system}"; |
|
| 246 | - function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 247 | - return $func; |
|
| 242 | + $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 243 | + file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
|
| 244 | + require_once $file; |
|
| 245 | + $func = "chess_ratings_adj_{$rating_system}"; |
|
| 246 | + function_exists($func) or trigger_error("missing function '$func' for rating system '$rating_system'", E_USER_ERROR); |
|
| 247 | + return $func; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -259,23 +259,23 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | function chess_ratings_get_columns($pgn_result) |
| 261 | 261 | { |
| 262 | - switch ($pgn_result) { |
|
| 263 | - case '1-0': |
|
| 264 | - $white_col = 'games_won'; |
|
| 265 | - $black_col = 'games_lost'; |
|
| 266 | - break; |
|
| 267 | - case '1/2-1/2': |
|
| 268 | - default: // should not occur |
|
| 269 | - $white_col = 'games_drawn'; |
|
| 270 | - $black_col = 'games_drawn'; |
|
| 271 | - break; |
|
| 272 | - case '0-1': |
|
| 273 | - $white_col = 'games_lost'; |
|
| 274 | - $black_col = 'games_won'; |
|
| 275 | - break; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return [$white_col, $black_col]; |
|
| 262 | + switch ($pgn_result) { |
|
| 263 | + case '1-0': |
|
| 264 | + $white_col = 'games_won'; |
|
| 265 | + $black_col = 'games_lost'; |
|
| 266 | + break; |
|
| 267 | + case '1/2-1/2': |
|
| 268 | + default: // should not occur |
|
| 269 | + $white_col = 'games_drawn'; |
|
| 270 | + $black_col = 'games_drawn'; |
|
| 271 | + break; |
|
| 272 | + case '0-1': |
|
| 273 | + $white_col = 'games_lost'; |
|
| 274 | + $black_col = 'games_won'; |
|
| 275 | + break; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return [$white_col, $black_col]; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | ?> |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | /**#@+ |
| 31 | 31 | */ |
| 32 | -require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php'; |
|
| 32 | +require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php'; |
|
| 33 | 33 | /**#@-*/ |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | if (!empty($value_list)) { |
| 94 | 94 | $values = implode(',', $value_list); |
| 95 | 95 | $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating) VALUES $values"); |
| 96 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 96 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // calculate new ratings using configured rating system |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | WHERE player_uid = '{$row['white_uid']}' |
| 110 | 110 | " |
| 111 | 111 | ); |
| 112 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 112 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 113 | 113 | |
| 114 | 114 | $xoopsDB->query( |
| 115 | 115 | " |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | WHERE player_uid = '{$row['black_uid']}' |
| 119 | 119 | " |
| 120 | 120 | ); |
| 121 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 121 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 122 | 122 | |
| 123 | 123 | return true; |
| 124 | 124 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $values = implode(',', $value_list); |
| 203 | 203 | |
| 204 | 204 | $xoopsDB->query("INSERT INTO $ratings_table (player_uid, rating, games_won, games_lost, games_drawn) VALUES $values"); |
| 205 | - $xoopsDB->errno() and trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 205 | + $xoopsDB->errno() and trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return true; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // determine function for getting number of provisional games using configured rating system |
| 225 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 225 | + $file = XOOPS_ROOT_PATH."/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 226 | 226 | file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
| 227 | 227 | require_once $file; |
| 228 | 228 | $func = "chess_ratings_num_provisional_games_{$rating_system}"; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | function chess_ratings_get_func_adj($rating_system) |
| 241 | 241 | { |
| 242 | - $file = XOOPS_ROOT_PATH . "/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 242 | + $file = XOOPS_ROOT_PATH."/modules/chess/include/ratings_{$rating_system}.inc.php"; |
|
| 243 | 243 | file_exists($file) or trigger_error("missing file '$file' for rating system '$rating_system'", E_USER_ERROR); |
| 244 | 244 | require_once $file; |
| 245 | 245 | $func = "chess_ratings_adj_{$rating_system}"; |
@@ -42,47 +42,47 @@ discard block |
||
| 42 | 42 | $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); |
| 43 | 43 | $pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32); |
| 44 | 44 | if (is_object($helper->getModule())) { |
| 45 | - $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
| 45 | + $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
| 46 | 46 | |
| 47 | - $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 47 | + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { |
| 51 | - define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
| 51 | + define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
| 52 | 52 | |
| 53 | - define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 53 | + define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 54 | 54 | |
| 55 | - define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 55 | + define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 56 | 56 | |
| 57 | - define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
| 57 | + define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
| 58 | 58 | |
| 59 | - define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
| 59 | + define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
| 60 | 60 | |
| 61 | - define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
| 61 | + define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
| 62 | 62 | |
| 63 | - define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
| 63 | + define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
| 64 | 64 | |
| 65 | - define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
| 65 | + define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
| 66 | 66 | |
| 67 | - define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
| 68 | - // define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
| 69 | - define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 70 | - define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 71 | - define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', $pathIcon32 . '/xoopsmicrobutton.gif'); |
|
| 67 | + define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
| 68 | + // define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
| 69 | + define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 70 | + define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 71 | + define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', $pathIcon32 . '/xoopsmicrobutton.gif'); |
|
| 72 | 72 | |
| 73 | - define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
| 73 | + define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $icons = [ |
| 77 | - 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
| 78 | - 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
| 79 | - 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
| 80 | - 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
| 81 | - 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
| 82 | - 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
| 83 | - 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
| 84 | - '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
| 85 | - '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
| 77 | + 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
| 78 | + 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
| 79 | + 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
| 80 | + 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
| 81 | + 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
| 82 | + 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
| 83 | + 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
| 84 | + '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
| 85 | + '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
| 86 | 86 | ]; |
| 87 | 87 | |
| 88 | 88 | $debug = false; |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | $myts = \MyTextSanitizer::getInstance(); |
| 92 | 92 | |
| 93 | 93 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
| 94 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 94 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 95 | 95 | |
| 96 | - $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
| 96 | + $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
| 100 | 100 | // Local icons path |
| 101 | 101 | if (is_object($helper->getModule())) { |
| 102 | - $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
| 102 | + $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
| 103 | 103 | |
| 104 | - $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 104 | + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 105 | 105 | |
| 106 | - $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
| 107 | 107 | |
| 108 | - $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
| 108 | + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
| 109 | 109 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | use XoopsModules\Chess; |
| 22 | 22 | |
| 23 | -include dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 23 | +include dirname(__DIR__).'/preloads/autoloader.php'; |
|
| 24 | 24 | |
| 25 | 25 | $moduleDirName = basename(dirname(__DIR__)); |
| 26 | 26 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
@@ -47,42 +47,42 @@ discard block |
||
| 47 | 47 | $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { |
|
| 51 | - define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
| 50 | +if (!defined($moduleDirNameUpper.'_CONSTANTS_DEFINED')) { |
|
| 51 | + define($moduleDirNameUpper.'_DIRNAME', basename(dirname(__DIR__))); |
|
| 52 | 52 | |
| 53 | - define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 53 | + define($moduleDirNameUpper.'_ROOT_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/'); |
|
| 54 | 54 | |
| 55 | - define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 55 | + define($moduleDirNameUpper.'_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/'); |
|
| 56 | 56 | |
| 57 | - define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
| 57 | + define($moduleDirNameUpper.'_URL', XOOPS_URL.'/modules/'.$moduleDirName.'/'); |
|
| 58 | 58 | |
| 59 | - define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
| 59 | + define($moduleDirNameUpper.'_IMAGE_URL', constant($moduleDirNameUpper.'_URL').'/assets/images/'); |
|
| 60 | 60 | |
| 61 | - define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
| 61 | + define($moduleDirNameUpper.'_IMAGE_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/assets/images'); |
|
| 62 | 62 | |
| 63 | - define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
| 63 | + define($moduleDirNameUpper.'_ADMIN_URL', constant($moduleDirNameUpper.'_URL').'/admin/'); |
|
| 64 | 64 | |
| 65 | - define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
| 65 | + define($moduleDirNameUpper.'_ADMIN_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/admin/'); |
|
| 66 | 66 | |
| 67 | - define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
| 67 | + define($moduleDirNameUpper.'_ADMIN', constant($moduleDirNameUpper.'_URL').'/admin/index.php'); |
|
| 68 | 68 | // define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
| 69 | - define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 70 | - define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 71 | - define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', $pathIcon32 . '/xoopsmicrobutton.gif'); |
|
| 69 | + define($moduleDirNameUpper.'_UPLOAD_URL', XOOPS_UPLOAD_URL.'/'.$moduleDirName); // WITHOUT Trailing slash |
|
| 70 | + define($moduleDirNameUpper.'_UPLOAD_PATH', XOOPS_UPLOAD_PATH.'/'.$moduleDirName); // WITHOUT Trailing slash |
|
| 71 | + define($moduleDirNameUpper.'_AUTHOR_LOGOIMG', $pathIcon32.'/xoopsmicrobutton.gif'); |
|
| 72 | 72 | |
| 73 | - define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
| 73 | + define($moduleDirNameUpper.'_CONSTANTS_DEFINED', 1); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $icons = [ |
| 77 | - 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
| 78 | - 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
| 79 | - 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
| 80 | - 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
| 81 | - 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
| 82 | - 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
| 83 | - 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
| 84 | - '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
| 85 | - '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
| 77 | + 'edit' => "<img src='".$pathIcon16."/edit.png' alt="._EDIT."' align='middle'>", |
|
| 78 | + 'delete' => "<img src='".$pathIcon16."/delete.png' alt='"._DELETE."' align='middle'>", |
|
| 79 | + 'clone' => "<img src='".$pathIcon16."/editcopy.png' alt='"._CLONE."' align='middle'>", |
|
| 80 | + 'preview' => "<img src='".$pathIcon16."/view.png' alt='"._PREVIEW."' align='middle'>", |
|
| 81 | + 'print' => "<img src='".$pathIcon16."/printer.png' alt='"._CLONE."' align='middle'>", |
|
| 82 | + 'pdf' => "<img src='".$pathIcon16."/pdf.png' alt='"._CLONE."' align='middle'>", |
|
| 83 | + 'add' => "<img src='".$pathIcon16."/add.png' alt='"._ADD."' align='middle'>", |
|
| 84 | + '0' => "<img src='".$pathIcon16."/0.png' alt='".0."' align='middle'>", |
|
| 85 | + '1' => "<img src='".$pathIcon16."/1.png' alt='".1."' align='middle'>", |
|
| 86 | 86 | ]; |
| 87 | 87 | |
| 88 | 88 | $debug = false; |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | -$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
|
| 99 | +$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL.'/modules/'.$moduleDirName); |
|
| 100 | 100 | // Local icons path |
| 101 | 101 | if (is_object($helper->getModule())) { |
| 102 | 102 | $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
| 103 | 103 | |
| 104 | 104 | $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
| 105 | 105 | |
| 106 | - $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL.'/modules/'.$moduleDirName.'/'.$pathModIcon16); |
|
| 107 | 107 | |
| 108 | 108 | $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
| 109 | 109 | } |
@@ -49,74 +49,74 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | function xoops_module_pre_update_chess(&$module, $oldversion) |
| 51 | 51 | { |
| 52 | - global $xoopsDB; |
|
| 53 | - |
|
| 54 | - // For downward-compatiblity, in case this function doesn't get called by the module handler. |
|
| 55 | - $GLOBALS['chess_module_pre_update_called'] = true; |
|
| 56 | - |
|
| 57 | - if ($oldversion < 102) { // old version < 1.02: direct update not supported. |
|
| 58 | - |
|
| 59 | - $docfile = XOOPS_ROOT_PATH . '/modules/chess/docs/INSTALL.TXT'; |
|
| 60 | - chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string)$oldversion, $docfile), true); |
|
| 61 | - return false; |
|
| 62 | - } elseif ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 63 | - |
|
| 64 | - return true; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // 1.02 <= old version < 1.07: perform update. |
|
| 68 | - |
|
| 69 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 70 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 71 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 72 | - |
|
| 73 | - // Check that ratings table does not already exist. |
|
| 74 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_1, $ratings_table)); |
|
| 75 | - $result = $xoopsDB->query("SHOW TABLES LIKE '$ratings_table'"); |
|
| 76 | - if (!$result) { |
|
| 77 | - $mysql_errno = $xoopsDB->errno(); |
|
| 78 | - $mysql_error = $xoopsDB->error(); |
|
| 79 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string)$mysql_errno, $mysql_error), true); |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 82 | - if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 83 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_3, $ratings_table), true); |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - $xoopsDB->freeRecordSet($result); |
|
| 87 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 88 | - |
|
| 89 | - // Check database tables. |
|
| 90 | - chess_set_message($module, _MI_CHESS_CHK_DB_TABLES); |
|
| 91 | - $table_check_messages = chess_check_tables([$challenges_table, $games_table]); |
|
| 92 | - if (!empty($table_check_messages)) { |
|
| 93 | - foreach ($table_check_messages as $message) { |
|
| 94 | - chess_set_message($module, $message, true); |
|
| 95 | - } |
|
| 96 | - return false; |
|
| 97 | - } |
|
| 98 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 99 | - |
|
| 100 | - // Check that values in column pgn_result of games table are in range. |
|
| 101 | - $pgn_result_values = "'*','1-0','0-1','1/2-1/2'"; |
|
| 102 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_1, $games_table)); |
|
| 103 | - $result = $xoopsDB->query("SELECT COUNT(*) FROM `$games_table` WHERE `pgn_result` NOT IN ($pgn_result_values)"); |
|
| 104 | - if (!$result) { |
|
| 105 | - $mysql_errno = $xoopsDB->errno(); |
|
| 106 | - $mysql_error = $xoopsDB->error(); |
|
| 107 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string)$mysql_errno, $mysql_error), true); |
|
| 108 | - return false; |
|
| 109 | - } |
|
| 110 | - [$count] = $xoopsDB->fetchRow($result); |
|
| 111 | - if ($count > 0) { |
|
| 112 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_3, 'pgn_result', $games_table, $pgn_result_values), true); |
|
| 113 | - chess_set_message($module, _MI_CHESS_GAMES_TABLE_4, true); |
|
| 114 | - return false; |
|
| 115 | - } |
|
| 116 | - $xoopsDB->freeRecordSet($result); |
|
| 117 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 118 | - |
|
| 119 | - return true; // successful |
|
| 52 | + global $xoopsDB; |
|
| 53 | + |
|
| 54 | + // For downward-compatiblity, in case this function doesn't get called by the module handler. |
|
| 55 | + $GLOBALS['chess_module_pre_update_called'] = true; |
|
| 56 | + |
|
| 57 | + if ($oldversion < 102) { // old version < 1.02: direct update not supported. |
|
| 58 | + |
|
| 59 | + $docfile = XOOPS_ROOT_PATH . '/modules/chess/docs/INSTALL.TXT'; |
|
| 60 | + chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string)$oldversion, $docfile), true); |
|
| 61 | + return false; |
|
| 62 | + } elseif ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 63 | + |
|
| 64 | + return true; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // 1.02 <= old version < 1.07: perform update. |
|
| 68 | + |
|
| 69 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 70 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 71 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 72 | + |
|
| 73 | + // Check that ratings table does not already exist. |
|
| 74 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_1, $ratings_table)); |
|
| 75 | + $result = $xoopsDB->query("SHOW TABLES LIKE '$ratings_table'"); |
|
| 76 | + if (!$result) { |
|
| 77 | + $mysql_errno = $xoopsDB->errno(); |
|
| 78 | + $mysql_error = $xoopsDB->error(); |
|
| 79 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string)$mysql_errno, $mysql_error), true); |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | + if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 83 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_3, $ratings_table), true); |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + $xoopsDB->freeRecordSet($result); |
|
| 87 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 88 | + |
|
| 89 | + // Check database tables. |
|
| 90 | + chess_set_message($module, _MI_CHESS_CHK_DB_TABLES); |
|
| 91 | + $table_check_messages = chess_check_tables([$challenges_table, $games_table]); |
|
| 92 | + if (!empty($table_check_messages)) { |
|
| 93 | + foreach ($table_check_messages as $message) { |
|
| 94 | + chess_set_message($module, $message, true); |
|
| 95 | + } |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 99 | + |
|
| 100 | + // Check that values in column pgn_result of games table are in range. |
|
| 101 | + $pgn_result_values = "'*','1-0','0-1','1/2-1/2'"; |
|
| 102 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_1, $games_table)); |
|
| 103 | + $result = $xoopsDB->query("SELECT COUNT(*) FROM `$games_table` WHERE `pgn_result` NOT IN ($pgn_result_values)"); |
|
| 104 | + if (!$result) { |
|
| 105 | + $mysql_errno = $xoopsDB->errno(); |
|
| 106 | + $mysql_error = $xoopsDB->error(); |
|
| 107 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string)$mysql_errno, $mysql_error), true); |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + [$count] = $xoopsDB->fetchRow($result); |
|
| 111 | + if ($count > 0) { |
|
| 112 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_3, 'pgn_result', $games_table, $pgn_result_values), true); |
|
| 113 | + chess_set_message($module, _MI_CHESS_GAMES_TABLE_4, true); |
|
| 114 | + return false; |
|
| 115 | + } |
|
| 116 | + $xoopsDB->freeRecordSet($result); |
|
| 117 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 118 | + |
|
| 119 | + return true; // successful |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -128,25 +128,25 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | function xoops_module_update_chess(&$module, $oldversion) |
| 130 | 130 | { |
| 131 | - global $xoopsDB; |
|
| 131 | + global $xoopsDB; |
|
| 132 | 132 | |
| 133 | - // Before proceeding, ensure that pre-update processing has been done, and that all the checks pass. |
|
| 134 | - // For downward-compatiblity, in case the "pre_update" function doesn't get called by the module handler. |
|
| 135 | - if (!@$GLOBALS['chess_module_pre_update_called'] and !xoops_module_pre_update_chess($module, $oldversion)) { |
|
| 136 | - return false; |
|
| 137 | - } |
|
| 133 | + // Before proceeding, ensure that pre-update processing has been done, and that all the checks pass. |
|
| 134 | + // For downward-compatiblity, in case the "pre_update" function doesn't get called by the module handler. |
|
| 135 | + if (!@$GLOBALS['chess_module_pre_update_called'] and !xoops_module_pre_update_chess($module, $oldversion)) { |
|
| 136 | + return false; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - if ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 140 | - return true; |
|
| 141 | - } |
|
| 139 | + if ($oldversion >= 107) { // old version >= 1.07: no action needed. |
|
| 140 | + return true; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 144 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 145 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 143 | + $ratings_table = $xoopsDB->prefix('chess_ratings'); |
|
| 144 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 145 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 146 | 146 | |
| 147 | - $queries = [ |
|
| 147 | + $queries = [ |
|
| 148 | 148 | |
| 149 | - "CREATE TABLE `$ratings_table` ( |
|
| 149 | + "CREATE TABLE `$ratings_table` ( |
|
| 150 | 150 | `player_uid` mediumint(8) unsigned NOT NULL default '0', |
| 151 | 151 | `rating` smallint(6) unsigned NOT NULL default '1200', |
| 152 | 152 | `games_won` smallint(6) unsigned NOT NULL default '0', |
@@ -157,40 +157,40 @@ discard block |
||
| 157 | 157 | KEY `games` (`games_won`,`games_lost`,`games_drawn`) |
| 158 | 158 | ) TYPE=MyISAM", |
| 159 | 159 | |
| 160 | - "ALTER TABLE `$challenges_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 161 | - "ALTER TABLE `$challenges_table` ADD INDEX `game_type` (`game_type`)", |
|
| 162 | - "ALTER TABLE `$challenges_table` ADD INDEX `player1_uid` (`player1_uid`)", |
|
| 163 | - "ALTER TABLE `$challenges_table` ADD INDEX `player2_uid` (`player2_uid`)", |
|
| 164 | - "ALTER TABLE `$challenges_table` ADD INDEX `create_date` (`create_date`)", |
|
| 165 | - "ALTER TABLE `$challenges_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 166 | - |
|
| 167 | - "ALTER TABLE `$games_table` CHANGE `pgn_result` `pgn_result` ENUM('*','0-1','1-0','1/2-1/2') DEFAULT '*' NOT NULL", |
|
| 168 | - "ALTER TABLE `$games_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 169 | - "ALTER TABLE `$games_table` ADD INDEX `white_uid` (`white_uid`)", |
|
| 170 | - "ALTER TABLE `$games_table` ADD INDEX `black_uid` (`black_uid`)", |
|
| 171 | - "ALTER TABLE `$games_table` ADD INDEX `date` (`create_date`,`start_date`,`last_date`)", |
|
| 172 | - "ALTER TABLE `$games_table` ADD INDEX `pgn_result` (`pgn_result`)", |
|
| 173 | - "ALTER TABLE `$games_table` ADD INDEX `suspended_date` (`suspended`(19))", |
|
| 174 | - "ALTER TABLE `$games_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 175 | - |
|
| 176 | - "UPDATE `$games_table` SET `is_rated` = '0' WHERE `white_uid` = `black_uid`", |
|
| 177 | - ]; |
|
| 178 | - |
|
| 179 | - // Update database tables. |
|
| 180 | - chess_set_message($module, _MI_CHESS_UPDATING_DATABASE); |
|
| 181 | - foreach ($queries as $query) { |
|
| 182 | - chess_set_message($module, "> $query"); |
|
| 183 | - $result = $xoopsDB->query($query); |
|
| 184 | - if (!$result) { |
|
| 185 | - $mysql_errno = $xoopsDB->errno(); |
|
| 186 | - $mysql_error = $xoopsDB->error(); |
|
| 187 | - chess_set_message($module, " ... ($mysql_errno) $mysql_error"); |
|
| 188 | - return false; |
|
| 189 | - } |
|
| 190 | - chess_set_message($module, _MI_CHESS_OK); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /*** |
|
| 160 | + "ALTER TABLE `$challenges_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 161 | + "ALTER TABLE `$challenges_table` ADD INDEX `game_type` (`game_type`)", |
|
| 162 | + "ALTER TABLE `$challenges_table` ADD INDEX `player1_uid` (`player1_uid`)", |
|
| 163 | + "ALTER TABLE `$challenges_table` ADD INDEX `player2_uid` (`player2_uid`)", |
|
| 164 | + "ALTER TABLE `$challenges_table` ADD INDEX `create_date` (`create_date`)", |
|
| 165 | + "ALTER TABLE `$challenges_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 166 | + |
|
| 167 | + "ALTER TABLE `$games_table` CHANGE `pgn_result` `pgn_result` ENUM('*','0-1','1-0','1/2-1/2') DEFAULT '*' NOT NULL", |
|
| 168 | + "ALTER TABLE `$games_table` ADD `is_rated` ENUM('1','0') DEFAULT '1' NOT NULL", |
|
| 169 | + "ALTER TABLE `$games_table` ADD INDEX `white_uid` (`white_uid`)", |
|
| 170 | + "ALTER TABLE `$games_table` ADD INDEX `black_uid` (`black_uid`)", |
|
| 171 | + "ALTER TABLE `$games_table` ADD INDEX `date` (`create_date`,`start_date`,`last_date`)", |
|
| 172 | + "ALTER TABLE `$games_table` ADD INDEX `pgn_result` (`pgn_result`)", |
|
| 173 | + "ALTER TABLE `$games_table` ADD INDEX `suspended_date` (`suspended`(19))", |
|
| 174 | + "ALTER TABLE `$games_table` ADD INDEX `is_rated` (`is_rated`)", |
|
| 175 | + |
|
| 176 | + "UPDATE `$games_table` SET `is_rated` = '0' WHERE `white_uid` = `black_uid`", |
|
| 177 | + ]; |
|
| 178 | + |
|
| 179 | + // Update database tables. |
|
| 180 | + chess_set_message($module, _MI_CHESS_UPDATING_DATABASE); |
|
| 181 | + foreach ($queries as $query) { |
|
| 182 | + chess_set_message($module, "> $query"); |
|
| 183 | + $result = $xoopsDB->query($query); |
|
| 184 | + if (!$result) { |
|
| 185 | + $mysql_errno = $xoopsDB->errno(); |
|
| 186 | + $mysql_error = $xoopsDB->error(); |
|
| 187 | + chess_set_message($module, " ... ($mysql_errno) $mysql_error"); |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 190 | + chess_set_message($module, _MI_CHESS_OK); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /*** |
|
| 194 | 194 | * #*#TODO# - Leave this here for now, in case I think of a way to get it to work. |
| 195 | 195 | * # This causes an error about the rating_system module configuration parameter not being defined, |
| 196 | 196 | * # so I added a note in INSTALL.TXT about manually recalculating the ratings after install. |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | * chess_recalc_ratings(); |
| 202 | 202 | ***/ |
| 203 | 203 | |
| 204 | - chess_set_message($module, _MI_CHESS_UPDATE_SUCCESSFUL); |
|
| 204 | + chess_set_message($module, _MI_CHESS_UPDATE_SUCCESSFUL); |
|
| 205 | 205 | |
| 206 | - return true; // successful |
|
| 206 | + return true; // successful |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,37 +214,37 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | function chess_check_tables($table_names) |
| 216 | 216 | { |
| 217 | - global $xoopsDB; |
|
| 217 | + global $xoopsDB; |
|
| 218 | 218 | |
| 219 | - $messages = []; |
|
| 219 | + $messages = []; |
|
| 220 | 220 | |
| 221 | - foreach ($table_names as $table_name) { |
|
| 222 | - $query = "CHECK TABLE `$table_name`"; |
|
| 223 | - $result = $xoopsDB->query($query); |
|
| 224 | - if (!$result) { |
|
| 225 | - $mysql_errno = $xoopsDB->errno(); |
|
| 226 | - $mysql_error = $xoopsDB->error(); |
|
| 227 | - $messages[] = $query; |
|
| 228 | - $messages[] = " ... ($mysql_errno) $mysql_error"; |
|
| 229 | - continue; |
|
| 230 | - } |
|
| 221 | + foreach ($table_names as $table_name) { |
|
| 222 | + $query = "CHECK TABLE `$table_name`"; |
|
| 223 | + $result = $xoopsDB->query($query); |
|
| 224 | + if (!$result) { |
|
| 225 | + $mysql_errno = $xoopsDB->errno(); |
|
| 226 | + $mysql_error = $xoopsDB->error(); |
|
| 227 | + $messages[] = $query; |
|
| 228 | + $messages[] = " ... ($mysql_errno) $mysql_error"; |
|
| 229 | + continue; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - // Initialize, in case the real table status fails to get retrieved. |
|
| 233 | - $table_status = '*** STATUS UNKNOWN ***'; |
|
| 232 | + // Initialize, in case the real table status fails to get retrieved. |
|
| 233 | + $table_status = '*** STATUS UNKNOWN ***'; |
|
| 234 | 234 | |
| 235 | - // The query may return multiple rows. Only the last row is normally of interest, so only that row is saved. |
|
| 236 | - while ($row = $xoopsDB->fetchArray($result)) { |
|
| 237 | - $table_status = $row['Msg_text']; |
|
| 238 | - } |
|
| 235 | + // The query may return multiple rows. Only the last row is normally of interest, so only that row is saved. |
|
| 236 | + while ($row = $xoopsDB->fetchArray($result)) { |
|
| 237 | + $table_status = $row['Msg_text']; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - $xoopsDB->freeRecordSet($result); |
|
| 240 | + $xoopsDB->freeRecordSet($result); |
|
| 241 | 241 | |
| 242 | - if ('OK' != $table_status) { |
|
| 243 | - $messages[] = " ... $table_name: $table_status"; |
|
| 244 | - } |
|
| 245 | - } |
|
| 242 | + if ('OK' != $table_status) { |
|
| 243 | + $messages[] = " ... $table_name: $table_status"; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - return $messages; |
|
| 247 | + return $messages; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | function chess_load_lang_file($filename, $module = '', $default = 'english') |
| 261 | 261 | { |
| 262 | - $lang = $GLOBALS['xoopsConfig']['language']; |
|
| 263 | - $path = XOOPS_ROOT_PATH . (empty($module) ? '/' : "/modules/$module/") . 'language'; |
|
| 264 | - if (!($ret = @include_once("$path/$lang/$filename.php"))) { |
|
| 265 | - $ret = include_once("$path/$default/$filename.php"); |
|
| 266 | - } |
|
| 267 | - return $ret; |
|
| 262 | + $lang = $GLOBALS['xoopsConfig']['language']; |
|
| 263 | + $path = XOOPS_ROOT_PATH . (empty($module) ? '/' : "/modules/$module/") . 'language'; |
|
| 264 | + if (!($ret = @include_once("$path/$lang/$filename.php"))) { |
|
| 265 | + $ret = include_once("$path/$default/$filename.php"); |
|
| 266 | + } |
|
| 267 | + return $ret; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | function chess_set_message($module, $text = '', $error = false) |
| 278 | 278 | { |
| 279 | - $text = $error ? "<span style='color:#ff0000;background-color:#ffffff;font-weight:bold;'>$text</span>" : $text; |
|
| 280 | - |
|
| 281 | - // For downward compatibility with XOOPS versions that don't have the method XoopsModule::setMessage. |
|
| 282 | - if (is_object($module) and method_exists($module, 'setMessage')) { |
|
| 283 | - $module->setMessage($text); |
|
| 284 | - } else { |
|
| 285 | - echo "<code>$text</code><br />\n"; |
|
| 286 | - } |
|
| 279 | + $text = $error ? "<span style='color:#ff0000;background-color:#ffffff;font-weight:bold;'>$text</span>" : $text; |
|
| 280 | + |
|
| 281 | + // For downward compatibility with XOOPS versions that don't have the method XoopsModule::setMessage. |
|
| 282 | + if (is_object($module) and method_exists($module, 'setMessage')) { |
|
| 283 | + $module->setMessage($text); |
|
| 284 | + } else { |
|
| 285 | + echo "<code>$text</code><br />\n"; |
|
| 286 | + } |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | ?> |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | if ($oldversion < 102) { // old version < 1.02: direct update not supported. |
| 58 | 58 | |
| 59 | - $docfile = XOOPS_ROOT_PATH . '/modules/chess/docs/INSTALL.TXT'; |
|
| 60 | - chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string)$oldversion, $docfile), true); |
|
| 59 | + $docfile = XOOPS_ROOT_PATH.'/modules/chess/docs/INSTALL.TXT'; |
|
| 60 | + chess_set_message($module, sprintf(_MI_CHESS_OLD_VERSION, (string) $oldversion, $docfile), true); |
|
| 61 | 61 | return false; |
| 62 | 62 | } elseif ($oldversion >= 107) { // old version >= 1.07: no action needed. |
| 63 | 63 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | if (!$result) { |
| 77 | 77 | $mysql_errno = $xoopsDB->errno(); |
| 78 | 78 | $mysql_error = $xoopsDB->error(); |
| 79 | - chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string)$mysql_errno, $mysql_error), true); |
|
| 79 | + chess_set_message($module, sprintf(_MI_CHESS_RATINGS_TABLE_2, $ratings_table, (string) $mysql_errno, $mysql_error), true); |
|
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | if ($xoopsDB->getRowsNum($result) > 0) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if (!$result) { |
| 105 | 105 | $mysql_errno = $xoopsDB->errno(); |
| 106 | 106 | $mysql_error = $xoopsDB->error(); |
| 107 | - chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string)$mysql_errno, $mysql_error), true); |
|
| 107 | + chess_set_message($module, sprintf(_MI_CHESS_GAMES_TABLE_2, $games_table, (string) $mysql_errno, $mysql_error), true); |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | [$count] = $xoopsDB->fetchRow($result); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | function chess_load_lang_file($filename, $module = '', $default = 'english') |
| 261 | 261 | { |
| 262 | 262 | $lang = $GLOBALS['xoopsConfig']['language']; |
| 263 | - $path = XOOPS_ROOT_PATH . (empty($module) ? '/' : "/modules/$module/") . 'language'; |
|
| 263 | + $path = XOOPS_ROOT_PATH.(empty($module) ? '/' : "/modules/$module/").'language'; |
|
| 264 | 264 | if (!($ret = @include_once("$path/$lang/$filename.php"))) { |
| 265 | 265 | $ret = include_once("$path/$default/$filename.php"); |
| 266 | 266 | } |