@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
| 48 | 48 | // ------------------- Folders & Files ------------------- |
| 49 | 49 | 'release_info' => 'Changelog', |
| 50 | - 'release_file' => XOOPS_URL . "/modules/$moduleDirName/docs/changelog.txt", |
|
| 50 | + 'release_file' => XOOPS_URL."/modules/$moduleDirName/docs/changelog.txt", |
|
| 51 | 51 | |
| 52 | 52 | 'manual' => 'link to manual file', |
| 53 | - 'manual_file' => XOOPS_URL . "/modules/$moduleDirName/docs/install.txt", |
|
| 53 | + 'manual_file' => XOOPS_URL."/modules/$moduleDirName/docs/install.txt", |
|
| 54 | 54 | // images |
| 55 | 55 | 'image' => 'assets/images/logoModule.png', |
| 56 | 56 | 'iconsmall' => 'assets/images/iconsmall.png', |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | 'demo_site_name' => 'XOOPS Demo Site', |
| 69 | 69 | 'support_url' => 'https://xoops.org/modules/newbb/viewforum.php?forum=28/', |
| 70 | 70 | 'support_name' => 'Support Forum', |
| 71 | - 'submit_bug' => 'https://github.com/XoopsModules25x/' . $moduleDirName . '/issues', |
|
| 71 | + 'submit_bug' => 'https://github.com/XoopsModules25x/'.$moduleDirName.'/issues', |
|
| 72 | 72 | 'module_website_url' => 'www.xoops.org', |
| 73 | 73 | 'module_website_name' => 'XOOPS Project', |
| 74 | 74 | // ------------------- Min Requirements ------------------- |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | // ------------------- PayPal --------------------------- |
| 90 | 90 | 'paypal' => [ |
| 91 | 91 | 'business' => '[email protected]', |
| 92 | - 'item_name' => 'Donation : ' . _MI_CHESS_NAME, |
|
| 92 | + 'item_name' => 'Donation : '._MI_CHESS_NAME, |
|
| 93 | 93 | 'amount' => 0, |
| 94 | 94 | 'currency_code' => 'USD', |
| 95 | 95 | ], |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
| 110 | 110 | // ------------------- Tables ---------------------------- |
| 111 | 111 | 'tables' => [ |
| 112 | - $moduleDirName . '_' . 'games', |
|
| 113 | - $moduleDirName . '_' . 'challenges', |
|
| 114 | - $moduleDirName . '_' . 'ratings', |
|
| 112 | + $moduleDirName.'_'.'games', |
|
| 113 | + $moduleDirName.'_'.'challenges', |
|
| 114 | + $moduleDirName.'_'.'ratings', |
|
| 115 | 115 | ], |
| 116 | 116 | ]; |
| 117 | 117 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | if (is_object($xoopsUser)) { |
| 236 | 236 | $modversion['sub'][5]['name'] = _MI_CHESS_SMNAME5; |
| 237 | - $modversion['sub'][5]['url'] = 'player_stats.php?player_uid=' . $xoopsUser->getVar('uid'); |
|
| 237 | + $modversion['sub'][5]['url'] = 'player_stats.php?player_uid='.$xoopsUser->getVar('uid'); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
@@ -30,98 +30,98 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // ------------------- Informations ------------------- // |
| 32 | 32 | $modversion = [ |
| 33 | - 'version' => 2.01, |
|
| 34 | - 'module_status' => 'Alpha 1', |
|
| 35 | - 'release_date' => '2020/05/25', |
|
| 36 | - 'name' => _MI_CHESS, |
|
| 37 | - 'description' => _MI_CHESS_DES, |
|
| 38 | - 'official' => 0, |
|
| 39 | - //1 indicates official XOOPS module supported by XOOPS Dev Team, 0 means 3rd party supported |
|
| 40 | - 'author' => '<a target="_blank" href="http://Dave-L.com/">Dave Lerner</a>, Mamba', |
|
| 41 | - |
|
| 42 | - 'credits' => 'XOOPS Development Team', |
|
| 43 | - 'author_mail' => 'author-email', |
|
| 44 | - 'author_website_url' => 'https://xoops.org', |
|
| 45 | - 'author_website_name' => 'XOOPS', |
|
| 46 | - 'license' => 'GPL 2.0 or later', |
|
| 47 | - 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
|
| 48 | - // ------------------- Folders & Files ------------------- |
|
| 49 | - 'release_info' => 'Changelog', |
|
| 50 | - 'release_file' => XOOPS_URL . "/modules/$moduleDirName/docs/changelog.txt", |
|
| 51 | - |
|
| 52 | - 'manual' => 'link to manual file', |
|
| 53 | - 'manual_file' => XOOPS_URL . "/modules/$moduleDirName/docs/install.txt", |
|
| 54 | - // images |
|
| 55 | - 'image' => 'assets/images/logoModule.png', |
|
| 56 | - 'iconsmall' => 'assets/images/iconsmall.png', |
|
| 57 | - 'iconbig' => 'assets/images/iconbig.png', |
|
| 58 | - 'dirname' => $moduleDirName, |
|
| 59 | - //Frameworks |
|
| 60 | - // 'dirmoduleadmin' => 'Frameworks/moduleclasses/moduleadmin', |
|
| 61 | - // 'sysicons16' => 'Frameworks/moduleclasses/icons/16', |
|
| 62 | - // 'sysicons32' => 'Frameworks/moduleclasses/icons/32', |
|
| 63 | - // Local path icons |
|
| 64 | - 'modicons16' => 'assets/images/icons/16', |
|
| 65 | - 'modicons32' => 'assets/images/icons/32', |
|
| 66 | - //About |
|
| 67 | - 'demo_site_url' => 'https://xoops.org', |
|
| 68 | - 'demo_site_name' => 'XOOPS Demo Site', |
|
| 69 | - 'support_url' => 'https://xoops.org/modules/newbb/viewforum.php?forum=28/', |
|
| 70 | - 'support_name' => 'Support Forum', |
|
| 71 | - 'submit_bug' => 'https://github.com/XoopsModules25x/' . $moduleDirName . '/issues', |
|
| 72 | - 'module_website_url' => 'www.xoops.org', |
|
| 73 | - 'module_website_name' => 'XOOPS Project', |
|
| 74 | - // ------------------- Min Requirements ------------------- |
|
| 75 | - 'min_php' => '7.2', |
|
| 76 | - 'min_xoops' => '2.5.10', |
|
| 77 | - 'min_admin' => '1.2', |
|
| 78 | - 'min_db' => ['mysql' => '5.5'], |
|
| 79 | - // ------------------- Admin Menu ------------------- |
|
| 80 | - 'system_menu' => 1, |
|
| 81 | - 'hasAdmin' => 1, |
|
| 82 | - 'adminindex' => 'admin/index.php', |
|
| 83 | - 'adminmenu' => 'admin/menu.php', |
|
| 84 | - // ------------------- Install/Update ------------------- |
|
| 85 | - 'onInstall' => 'include/install.php', |
|
| 86 | - // 'onInstall' => 'include/oninstall.php', |
|
| 87 | - // 'onUpdate' => 'include/onupdate.php', |
|
| 88 | - // 'onUninstall' => 'include/onuninstall.php', |
|
| 89 | - // ------------------- PayPal --------------------------- |
|
| 90 | - 'paypal' => [ |
|
| 91 | - 'business' => '[email protected]', |
|
| 92 | - 'item_name' => 'Donation : ' . _MI_CHESS_NAME, |
|
| 93 | - 'amount' => 0, |
|
| 94 | - 'currency_code' => 'USD', |
|
| 95 | - ], |
|
| 96 | - // ------------------- Search --------------------------- |
|
| 97 | - 'hasSearch' => 0, |
|
| 98 | - // 'search' => [ |
|
| 99 | - // 'file' => 'include/search.inc.php', |
|
| 100 | - // 'func' => 'pedigree_search', |
|
| 101 | - // ], |
|
| 102 | - // ------------------- Comments ------------------------- |
|
| 103 | - 'hasComments' => 1, |
|
| 104 | - 'comments' => [ |
|
| 105 | - 'itemName' => 'game_id', |
|
| 106 | - 'pageName' => 'game.php', |
|
| 107 | - ], |
|
| 108 | - // ------------------- Mysql ----------------------------- |
|
| 109 | - 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
| 110 | - // ------------------- Tables ---------------------------- |
|
| 111 | - 'tables' => [ |
|
| 112 | - $moduleDirName . '_' . 'games', |
|
| 113 | - $moduleDirName . '_' . 'challenges', |
|
| 114 | - $moduleDirName . '_' . 'ratings', |
|
| 115 | - ], |
|
| 33 | + 'version' => 2.01, |
|
| 34 | + 'module_status' => 'Alpha 1', |
|
| 35 | + 'release_date' => '2020/05/25', |
|
| 36 | + 'name' => _MI_CHESS, |
|
| 37 | + 'description' => _MI_CHESS_DES, |
|
| 38 | + 'official' => 0, |
|
| 39 | + //1 indicates official XOOPS module supported by XOOPS Dev Team, 0 means 3rd party supported |
|
| 40 | + 'author' => '<a target="_blank" href="http://Dave-L.com/">Dave Lerner</a>, Mamba', |
|
| 41 | + |
|
| 42 | + 'credits' => 'XOOPS Development Team', |
|
| 43 | + 'author_mail' => 'author-email', |
|
| 44 | + 'author_website_url' => 'https://xoops.org', |
|
| 45 | + 'author_website_name' => 'XOOPS', |
|
| 46 | + 'license' => 'GPL 2.0 or later', |
|
| 47 | + 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
|
| 48 | + // ------------------- Folders & Files ------------------- |
|
| 49 | + 'release_info' => 'Changelog', |
|
| 50 | + 'release_file' => XOOPS_URL . "/modules/$moduleDirName/docs/changelog.txt", |
|
| 51 | + |
|
| 52 | + 'manual' => 'link to manual file', |
|
| 53 | + 'manual_file' => XOOPS_URL . "/modules/$moduleDirName/docs/install.txt", |
|
| 54 | + // images |
|
| 55 | + 'image' => 'assets/images/logoModule.png', |
|
| 56 | + 'iconsmall' => 'assets/images/iconsmall.png', |
|
| 57 | + 'iconbig' => 'assets/images/iconbig.png', |
|
| 58 | + 'dirname' => $moduleDirName, |
|
| 59 | + //Frameworks |
|
| 60 | + // 'dirmoduleadmin' => 'Frameworks/moduleclasses/moduleadmin', |
|
| 61 | + // 'sysicons16' => 'Frameworks/moduleclasses/icons/16', |
|
| 62 | + // 'sysicons32' => 'Frameworks/moduleclasses/icons/32', |
|
| 63 | + // Local path icons |
|
| 64 | + 'modicons16' => 'assets/images/icons/16', |
|
| 65 | + 'modicons32' => 'assets/images/icons/32', |
|
| 66 | + //About |
|
| 67 | + 'demo_site_url' => 'https://xoops.org', |
|
| 68 | + 'demo_site_name' => 'XOOPS Demo Site', |
|
| 69 | + 'support_url' => 'https://xoops.org/modules/newbb/viewforum.php?forum=28/', |
|
| 70 | + 'support_name' => 'Support Forum', |
|
| 71 | + 'submit_bug' => 'https://github.com/XoopsModules25x/' . $moduleDirName . '/issues', |
|
| 72 | + 'module_website_url' => 'www.xoops.org', |
|
| 73 | + 'module_website_name' => 'XOOPS Project', |
|
| 74 | + // ------------------- Min Requirements ------------------- |
|
| 75 | + 'min_php' => '7.2', |
|
| 76 | + 'min_xoops' => '2.5.10', |
|
| 77 | + 'min_admin' => '1.2', |
|
| 78 | + 'min_db' => ['mysql' => '5.5'], |
|
| 79 | + // ------------------- Admin Menu ------------------- |
|
| 80 | + 'system_menu' => 1, |
|
| 81 | + 'hasAdmin' => 1, |
|
| 82 | + 'adminindex' => 'admin/index.php', |
|
| 83 | + 'adminmenu' => 'admin/menu.php', |
|
| 84 | + // ------------------- Install/Update ------------------- |
|
| 85 | + 'onInstall' => 'include/install.php', |
|
| 86 | + // 'onInstall' => 'include/oninstall.php', |
|
| 87 | + // 'onUpdate' => 'include/onupdate.php', |
|
| 88 | + // 'onUninstall' => 'include/onuninstall.php', |
|
| 89 | + // ------------------- PayPal --------------------------- |
|
| 90 | + 'paypal' => [ |
|
| 91 | + 'business' => '[email protected]', |
|
| 92 | + 'item_name' => 'Donation : ' . _MI_CHESS_NAME, |
|
| 93 | + 'amount' => 0, |
|
| 94 | + 'currency_code' => 'USD', |
|
| 95 | + ], |
|
| 96 | + // ------------------- Search --------------------------- |
|
| 97 | + 'hasSearch' => 0, |
|
| 98 | + // 'search' => [ |
|
| 99 | + // 'file' => 'include/search.inc.php', |
|
| 100 | + // 'func' => 'pedigree_search', |
|
| 101 | + // ], |
|
| 102 | + // ------------------- Comments ------------------------- |
|
| 103 | + 'hasComments' => 1, |
|
| 104 | + 'comments' => [ |
|
| 105 | + 'itemName' => 'game_id', |
|
| 106 | + 'pageName' => 'game.php', |
|
| 107 | + ], |
|
| 108 | + // ------------------- Mysql ----------------------------- |
|
| 109 | + 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
| 110 | + // ------------------- Tables ---------------------------- |
|
| 111 | + 'tables' => [ |
|
| 112 | + $moduleDirName . '_' . 'games', |
|
| 113 | + $moduleDirName . '_' . 'challenges', |
|
| 114 | + $moduleDirName . '_' . 'ratings', |
|
| 115 | + ], |
|
| 116 | 116 | ]; |
| 117 | 117 | |
| 118 | 118 | // ------------------- Help files ------------------- // |
| 119 | 119 | $modversion['help'] = 'page=help'; |
| 120 | 120 | $modversion['helpsection'] = [ |
| 121 | - ['name' => _MI_CHESS_OVERVIEW, 'link' => 'page=help'], |
|
| 122 | - ['name' => _MI_CHESS_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
| 123 | - ['name' => _MI_CHESS_LICENSE, 'link' => 'page=license'], |
|
| 124 | - ['name' => _MI_CHESS_SUPPORT, 'link' => 'page=support'], |
|
| 121 | + ['name' => _MI_CHESS_OVERVIEW, 'link' => 'page=help'], |
|
| 122 | + ['name' => _MI_CHESS_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
| 123 | + ['name' => _MI_CHESS_LICENSE, 'link' => 'page=license'], |
|
| 124 | + ['name' => _MI_CHESS_SUPPORT, 'link' => 'page=support'], |
|
| 125 | 125 | ]; |
| 126 | 126 | |
| 127 | 127 | // Config |
@@ -129,77 +129,77 @@ discard block |
||
| 129 | 129 | $memberHandler = xoops_getHandler('member'); |
| 130 | 130 | $groups = $memberHandler->getGroups(); |
| 131 | 131 | foreach ($groups as $group) { |
| 132 | - if (XOOPS_GROUP_ANONYMOUS != $group->getVar('groupid')) { |
|
| 133 | - $grouparray[$group->getVar('name')] = $group->getVar('groupid'); |
|
| 134 | - } |
|
| 132 | + if (XOOPS_GROUP_ANONYMOUS != $group->getVar('groupid')) { |
|
| 133 | + $grouparray[$group->getVar('name')] = $group->getVar('groupid'); |
|
| 134 | + } |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $modversion['config'][] = [ |
| 138 | - 'name' => 'groups_play', |
|
| 139 | - 'title' => '_MI_CHESS_GROUPS_PLAY', |
|
| 140 | - 'description' => '_MI_CHESS_GROUPS_PLAY_DES', |
|
| 141 | - 'formtype' => 'group_multi', |
|
| 142 | - 'valuetype' => 'array', |
|
| 143 | - 'default' => [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS], |
|
| 138 | + 'name' => 'groups_play', |
|
| 139 | + 'title' => '_MI_CHESS_GROUPS_PLAY', |
|
| 140 | + 'description' => '_MI_CHESS_GROUPS_PLAY_DES', |
|
| 141 | + 'formtype' => 'group_multi', |
|
| 142 | + 'valuetype' => 'array', |
|
| 143 | + 'default' => [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS], |
|
| 144 | 144 | ]; |
| 145 | 145 | |
| 146 | 146 | $modversion['config'][] = [ |
| 147 | - 'name' => 'groups_delete', |
|
| 148 | - 'title' => '_MI_CHESS_GROUPS_DELETE', |
|
| 149 | - 'description' => '_MI_CHESS_GROUPS_DELETE_DES', |
|
| 150 | - 'formtype' => 'group_multi', |
|
| 151 | - 'valuetype' => 'array', |
|
| 152 | - 'default' => [], |
|
| 147 | + 'name' => 'groups_delete', |
|
| 148 | + 'title' => '_MI_CHESS_GROUPS_DELETE', |
|
| 149 | + 'description' => '_MI_CHESS_GROUPS_DELETE_DES', |
|
| 150 | + 'formtype' => 'group_multi', |
|
| 151 | + 'valuetype' => 'array', |
|
| 152 | + 'default' => [], |
|
| 153 | 153 | ]; |
| 154 | 154 | |
| 155 | 155 | $modversion['config'][] = [ |
| 156 | - 'name' => 'allow_setup', |
|
| 157 | - 'title' => '_MI_CHESS_ALLOW_SETUP', |
|
| 158 | - 'description' => '_MI_CHESS_ALLOW_SETUP_DES', |
|
| 159 | - 'formtype' => 'yesno', |
|
| 160 | - 'valuetype' => 'int', |
|
| 161 | - 'default' => 0, |
|
| 156 | + 'name' => 'allow_setup', |
|
| 157 | + 'title' => '_MI_CHESS_ALLOW_SETUP', |
|
| 158 | + 'description' => '_MI_CHESS_ALLOW_SETUP_DES', |
|
| 159 | + 'formtype' => 'yesno', |
|
| 160 | + 'valuetype' => 'int', |
|
| 161 | + 'default' => 0, |
|
| 162 | 162 | ]; |
| 163 | 163 | |
| 164 | 164 | $modversion['config'][] = [ |
| 165 | - 'name' => 'max_items', |
|
| 166 | - 'title' => '_MI_CHESS_MAX_ITEMS', |
|
| 167 | - 'description' => '_MI_CHESS_MAX_ITEMS_DES', |
|
| 168 | - 'formtype' => 'textbox', |
|
| 169 | - 'valuetype' => 'int', |
|
| 170 | - 'default' => 10, |
|
| 165 | + 'name' => 'max_items', |
|
| 166 | + 'title' => '_MI_CHESS_MAX_ITEMS', |
|
| 167 | + 'description' => '_MI_CHESS_MAX_ITEMS_DES', |
|
| 168 | + 'formtype' => 'textbox', |
|
| 169 | + 'valuetype' => 'int', |
|
| 170 | + 'default' => 10, |
|
| 171 | 171 | ]; |
| 172 | 172 | |
| 173 | 173 | $modversion['config'][] = [ |
| 174 | - 'name' => 'rating_system', |
|
| 175 | - 'title' => '_MI_CHESS_RATING_SYSTEM', |
|
| 176 | - 'description' => '_MI_CHESS_RATING_SYSTEM_DES', |
|
| 177 | - 'formtype' => 'select', |
|
| 178 | - 'valuetype' => 'text', |
|
| 179 | - 'options' => [ |
|
| 180 | - _MI_CHESS_RATING_SYSTEM_NONE => 'none', |
|
| 181 | - _MI_CHESS_RATING_SYSTEM_CXR => 'cxr', |
|
| 182 | - _MI_CHESS_RATING_SYSTEM_LINEAR => 'linear', |
|
| 183 | - ], |
|
| 184 | - 'default' => 'cxr', |
|
| 174 | + 'name' => 'rating_system', |
|
| 175 | + 'title' => '_MI_CHESS_RATING_SYSTEM', |
|
| 176 | + 'description' => '_MI_CHESS_RATING_SYSTEM_DES', |
|
| 177 | + 'formtype' => 'select', |
|
| 178 | + 'valuetype' => 'text', |
|
| 179 | + 'options' => [ |
|
| 180 | + _MI_CHESS_RATING_SYSTEM_NONE => 'none', |
|
| 181 | + _MI_CHESS_RATING_SYSTEM_CXR => 'cxr', |
|
| 182 | + _MI_CHESS_RATING_SYSTEM_LINEAR => 'linear', |
|
| 183 | + ], |
|
| 184 | + 'default' => 'cxr', |
|
| 185 | 185 | ]; |
| 186 | 186 | |
| 187 | 187 | $modversion['config'][] = [ |
| 188 | - 'name' => 'initial_rating', |
|
| 189 | - 'title' => '_MI_CHESS_INITIAL_RATING', |
|
| 190 | - 'description' => '_MI_CHESS_INITIAL_RATING_DES', |
|
| 191 | - 'formtype' => 'textbox', |
|
| 192 | - 'valuetype' => 'int', |
|
| 193 | - 'default' => 1200, |
|
| 188 | + 'name' => 'initial_rating', |
|
| 189 | + 'title' => '_MI_CHESS_INITIAL_RATING', |
|
| 190 | + 'description' => '_MI_CHESS_INITIAL_RATING_DES', |
|
| 191 | + 'formtype' => 'textbox', |
|
| 192 | + 'valuetype' => 'int', |
|
| 193 | + 'default' => 1200, |
|
| 194 | 194 | ]; |
| 195 | 195 | |
| 196 | 196 | $modversion['config'][] = [ |
| 197 | - 'name' => 'allow_unrated_games', |
|
| 198 | - 'title' => '_MI_CHESS_ALLOW_UNRATED', |
|
| 199 | - 'description' => '_MI_CHESS_ALLOW_UNRATED_DES', |
|
| 200 | - 'formtype' => 'yesno', |
|
| 201 | - 'valuetype' => 'int', |
|
| 202 | - 'default' => 1, |
|
| 197 | + 'name' => 'allow_unrated_games', |
|
| 198 | + 'title' => '_MI_CHESS_ALLOW_UNRATED', |
|
| 199 | + 'description' => '_MI_CHESS_ALLOW_UNRATED_DES', |
|
| 200 | + 'formtype' => 'yesno', |
|
| 201 | + 'valuetype' => 'int', |
|
| 202 | + 'default' => 1, |
|
| 203 | 203 | ]; |
| 204 | 204 | |
| 205 | 205 | // Menu |
@@ -214,83 +214,83 @@ discard block |
||
| 214 | 214 | // Conditional menu items |
| 215 | 215 | global $xoopsModule, $xoopsModuleConfig, $xoopsUser; |
| 216 | 216 | if (is_object($xoopsModule) && 'chess' == $xoopsModule->getVar('dirname')) { |
| 217 | - // Display create-game menu item if current user has the play-chess right. |
|
| 217 | + // Display create-game menu item if current user has the play-chess right. |
|
| 218 | 218 | |
| 219 | - if (!empty($xoopsModuleConfig['groups_play']) && is_array($xoopsModuleConfig['groups_play']) |
|
| 220 | - && (in_array(XOOPS_GROUP_ANONYMOUS, $xoopsModuleConfig['groups_play']) |
|
| 221 | - || (is_object($xoopsUser) && count(array_intersect($xoopsUser->getGroups(), $xoopsModuleConfig['groups_play'])) > 0))) { |
|
| 222 | - $modversion['sub'][3]['name'] = _MI_CHESS_SMNAME3; |
|
| 223 | - $modversion['sub'][3]['url'] = 'create.php'; |
|
| 224 | - } |
|
| 219 | + if (!empty($xoopsModuleConfig['groups_play']) && is_array($xoopsModuleConfig['groups_play']) |
|
| 220 | + && (in_array(XOOPS_GROUP_ANONYMOUS, $xoopsModuleConfig['groups_play']) |
|
| 221 | + || (is_object($xoopsUser) && count(array_intersect($xoopsUser->getGroups(), $xoopsModuleConfig['groups_play'])) > 0))) { |
|
| 222 | + $modversion['sub'][3]['name'] = _MI_CHESS_SMNAME3; |
|
| 223 | + $modversion['sub'][3]['url'] = 'create.php'; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - // Display ratings menu item if ratings system is enabled. |
|
| 226 | + // Display ratings menu item if ratings system is enabled. |
|
| 227 | 227 | |
| 228 | - if ('none' != $xoopsModuleConfig['rating_system']) { |
|
| 229 | - $modversion['sub'][4]['name'] = _MI_CHESS_SMNAME4; |
|
| 230 | - $modversion['sub'][4]['url'] = 'ratings.php'; |
|
| 231 | - } |
|
| 228 | + if ('none' != $xoopsModuleConfig['rating_system']) { |
|
| 229 | + $modversion['sub'][4]['name'] = _MI_CHESS_SMNAME4; |
|
| 230 | + $modversion['sub'][4]['url'] = 'ratings.php'; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - // Display my-games menu item if current user is logged in. |
|
| 233 | + // Display my-games menu item if current user is logged in. |
|
| 234 | 234 | |
| 235 | - if (is_object($xoopsUser)) { |
|
| 236 | - $modversion['sub'][5]['name'] = _MI_CHESS_SMNAME5; |
|
| 237 | - $modversion['sub'][5]['url'] = 'player_stats.php?player_uid=' . $xoopsUser->getVar('uid'); |
|
| 238 | - } |
|
| 235 | + if (is_object($xoopsUser)) { |
|
| 236 | + $modversion['sub'][5]['name'] = _MI_CHESS_SMNAME5; |
|
| 237 | + $modversion['sub'][5]['url'] = 'player_stats.php?player_uid=' . $xoopsUser->getVar('uid'); |
|
| 238 | + } |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Page Awareness |
| 242 | 242 | $modversion['pages'][] = [ |
| 243 | - ['name' => _MI_CHESS_SMNAME1, 'url' => 'help.php'], |
|
| 244 | - ['name' => _MI_CHESS_SMNAME2, 'url' => 'index.php'], |
|
| 245 | - ['name' => _MI_CHESS_SMNAME3, 'url' => 'create.php'], |
|
| 246 | - ['name' => _MI_CHESS_SMNAME4, 'url' => 'ratings.php'], |
|
| 247 | - ['name' => _MI_CHESS_SMNAME5, 'url' => 'player_stats.php'], |
|
| 243 | + ['name' => _MI_CHESS_SMNAME1, 'url' => 'help.php'], |
|
| 244 | + ['name' => _MI_CHESS_SMNAME2, 'url' => 'index.php'], |
|
| 245 | + ['name' => _MI_CHESS_SMNAME3, 'url' => 'create.php'], |
|
| 246 | + ['name' => _MI_CHESS_SMNAME4, 'url' => 'ratings.php'], |
|
| 247 | + ['name' => _MI_CHESS_SMNAME5, 'url' => 'player_stats.php'], |
|
| 248 | 248 | ]; |
| 249 | 249 | |
| 250 | 250 | // Templates |
| 251 | 251 | $modversion['templates'] = [ |
| 252 | - ['file' => 'chess_games.tpl', 'description' => _MI_CHESS_INDEX], |
|
| 253 | - ['file' => 'chess_game_main.tpl', 'description' => _MI_CHESS_GAME], |
|
| 254 | - ['file' => 'chess_game_moveform.tpl', 'description' => _MI_CHESS_MOVE_FORM], |
|
| 255 | - ['file' => 'chess_game_promote_popup.tpl', 'description' => _MI_CHESS_PROMOTE_POPUP], |
|
| 256 | - ['file' => 'chess_game_board.tpl', 'description' => _MI_CHESS_BOARD], |
|
| 257 | - ['file' => 'chess_game_prefsform.tpl', 'description' => _MI_CHESS_PREFS_FORM], |
|
| 258 | - ['file' => 'chess_game_arbitrateform.tpl', 'description' => _MI_CHESS_ARBITER_FORM], |
|
| 259 | - ['file' => 'chess_help.tpl', 'description' => _MI_CHESS_HELP], |
|
| 260 | - ['file' => 'chess_ratings.tpl', 'description' => _MI_CHESS_RATINGS], |
|
| 261 | - ['file' => 'chess_player_stats.tpl', 'description' => _MI_CHESS_PLAYER_STATS], |
|
| 252 | + ['file' => 'chess_games.tpl', 'description' => _MI_CHESS_INDEX], |
|
| 253 | + ['file' => 'chess_game_main.tpl', 'description' => _MI_CHESS_GAME], |
|
| 254 | + ['file' => 'chess_game_moveform.tpl', 'description' => _MI_CHESS_MOVE_FORM], |
|
| 255 | + ['file' => 'chess_game_promote_popup.tpl', 'description' => _MI_CHESS_PROMOTE_POPUP], |
|
| 256 | + ['file' => 'chess_game_board.tpl', 'description' => _MI_CHESS_BOARD], |
|
| 257 | + ['file' => 'chess_game_prefsform.tpl', 'description' => _MI_CHESS_PREFS_FORM], |
|
| 258 | + ['file' => 'chess_game_arbitrateform.tpl', 'description' => _MI_CHESS_ARBITER_FORM], |
|
| 259 | + ['file' => 'chess_help.tpl', 'description' => _MI_CHESS_HELP], |
|
| 260 | + ['file' => 'chess_ratings.tpl', 'description' => _MI_CHESS_RATINGS], |
|
| 261 | + ['file' => 'chess_player_stats.tpl', 'description' => _MI_CHESS_PLAYER_STATS], |
|
| 262 | 262 | ]; |
| 263 | 263 | // Blocks |
| 264 | 264 | $modversion['blocks'][] = [ |
| 265 | - 'file' => 'blocks.php', |
|
| 266 | - 'name' => _MI_CHESS_GAMES, |
|
| 267 | - 'description' => _MI_CHESS_GAMES_DES, |
|
| 268 | - 'show_func' => 'b_chess_games_show', |
|
| 269 | - // options: maximum number of games to display | 1=show games in play only/2=show concluded games only/3=show both | 1=show rated games only/2=show rated and unrated games |
|
| 270 | - 'options' => '4|3', |
|
| 271 | - 'edit_func' => 'b_chess_games_edit', |
|
| 272 | - 'template' => 'chess_block_games.tpl', |
|
| 265 | + 'file' => 'blocks.php', |
|
| 266 | + 'name' => _MI_CHESS_GAMES, |
|
| 267 | + 'description' => _MI_CHESS_GAMES_DES, |
|
| 268 | + 'show_func' => 'b_chess_games_show', |
|
| 269 | + // options: maximum number of games to display | 1=show games in play only/2=show concluded games only/3=show both | 1=show rated games only/2=show rated and unrated games |
|
| 270 | + 'options' => '4|3', |
|
| 271 | + 'edit_func' => 'b_chess_games_edit', |
|
| 272 | + 'template' => 'chess_block_games.tpl', |
|
| 273 | 273 | ]; |
| 274 | 274 | |
| 275 | 275 | $modversion['blocks'][] = [ |
| 276 | - 'file' => 'blocks.php', |
|
| 277 | - 'name' => _MI_CHESS_CHALLENGES, |
|
| 278 | - 'description' => _MI_CHESS_CHALLENGES_DES, |
|
| 279 | - 'show_func' => 'b_chess_challenges_show', |
|
| 280 | - // options: maximum number of challenges to display | 1=show open challenges only/2=show individual challenges only/3=show both |
|
| 281 | - 'options' => '4|3', |
|
| 282 | - 'edit_func' => 'b_chess_challenges_edit', |
|
| 283 | - 'template' => 'chess_block_challenges.tpl', |
|
| 276 | + 'file' => 'blocks.php', |
|
| 277 | + 'name' => _MI_CHESS_CHALLENGES, |
|
| 278 | + 'description' => _MI_CHESS_CHALLENGES_DES, |
|
| 279 | + 'show_func' => 'b_chess_challenges_show', |
|
| 280 | + // options: maximum number of challenges to display | 1=show open challenges only/2=show individual challenges only/3=show both |
|
| 281 | + 'options' => '4|3', |
|
| 282 | + 'edit_func' => 'b_chess_challenges_edit', |
|
| 283 | + 'template' => 'chess_block_challenges.tpl', |
|
| 284 | 284 | ]; |
| 285 | 285 | $modversion['blocks'][] = [ |
| 286 | - 'file' => 'blocks.php', |
|
| 287 | - 'name' => _MI_CHESS_PLAYERS, |
|
| 288 | - 'description' => _MI_CHESS_PLAYERS_DES, |
|
| 289 | - 'show_func' => 'b_chess_players_show', |
|
| 290 | - // options: maximum number of players to display | 1=show non-provisional ratings only/2=show all ratings |
|
| 291 | - 'options' => '4|1', |
|
| 292 | - 'edit_func' => 'b_chess_players_edit', |
|
| 293 | - 'template' => 'chess_block_players.tpl', |
|
| 286 | + 'file' => 'blocks.php', |
|
| 287 | + 'name' => _MI_CHESS_PLAYERS, |
|
| 288 | + 'description' => _MI_CHESS_PLAYERS_DES, |
|
| 289 | + 'show_func' => 'b_chess_players_show', |
|
| 290 | + // options: maximum number of players to display | 1=show non-provisional ratings only/2=show all ratings |
|
| 291 | + 'options' => '4|1', |
|
| 292 | + 'edit_func' => 'b_chess_players_edit', |
|
| 293 | + 'template' => 'chess_block_players.tpl', |
|
| 294 | 294 | ]; |
| 295 | 295 | |
| 296 | 296 | // Notification |
@@ -299,68 +299,68 @@ discard block |
||
| 299 | 299 | $modversion['notification']['lookup_func'] = 'chess_notify_item_info'; |
| 300 | 300 | |
| 301 | 301 | $modversion['notification']['category'][] = [ |
| 302 | - 'name' => 'game', |
|
| 303 | - 'title' => _MI_CHESS_NCAT_GAME, |
|
| 304 | - 'description' => _MI_CHESS_NCAT_GAME_DES, |
|
| 305 | - 'subscribe_from' => 'game.php', |
|
| 306 | - 'item_name' => 'game_id', |
|
| 307 | - 'allow_bookmark' => 1, |
|
| 302 | + 'name' => 'game', |
|
| 303 | + 'title' => _MI_CHESS_NCAT_GAME, |
|
| 304 | + 'description' => _MI_CHESS_NCAT_GAME_DES, |
|
| 305 | + 'subscribe_from' => 'game.php', |
|
| 306 | + 'item_name' => 'game_id', |
|
| 307 | + 'allow_bookmark' => 1, |
|
| 308 | 308 | ]; |
| 309 | 309 | |
| 310 | 310 | $modversion['notification']['category'][] = [ |
| 311 | - 'name' => 'global', |
|
| 312 | - 'title' => _MI_CHESS_NCAT_GLOBAL, |
|
| 313 | - 'description' => _MI_CHESS_NCAT_GLOBAL_DES, |
|
| 314 | - 'subscribe_from' => ['index.php', 'game.php'], |
|
| 311 | + 'name' => 'global', |
|
| 312 | + 'title' => _MI_CHESS_NCAT_GLOBAL, |
|
| 313 | + 'description' => _MI_CHESS_NCAT_GLOBAL_DES, |
|
| 314 | + 'subscribe_from' => ['index.php', 'game.php'], |
|
| 315 | 315 | ]; |
| 316 | 316 | |
| 317 | 317 | $modversion['notification']['event'][] = [ |
| 318 | - 'name' => 'notify_game_move', |
|
| 319 | - 'category' => 'game', |
|
| 320 | - 'title' => _MI_CHESS_NEVT_MOVE, |
|
| 321 | - 'caption' => _MI_CHESS_NEVT_MOVE_CAP, |
|
| 322 | - 'description' => _MI_CHESS_NEVT_MOVE_DES, |
|
| 323 | - 'mail_template' => 'notify_game_move', |
|
| 324 | - 'mail_subject' => _MI_CHESS_NEVT_MOVE_SUB, |
|
| 318 | + 'name' => 'notify_game_move', |
|
| 319 | + 'category' => 'game', |
|
| 320 | + 'title' => _MI_CHESS_NEVT_MOVE, |
|
| 321 | + 'caption' => _MI_CHESS_NEVT_MOVE_CAP, |
|
| 322 | + 'description' => _MI_CHESS_NEVT_MOVE_DES, |
|
| 323 | + 'mail_template' => 'notify_game_move', |
|
| 324 | + 'mail_subject' => _MI_CHESS_NEVT_MOVE_SUB, |
|
| 325 | 325 | ]; |
| 326 | 326 | |
| 327 | 327 | $modversion['notification']['event'][] = [ |
| 328 | - 'name' => 'notify_challenge_user', |
|
| 329 | - 'category' => 'global', |
|
| 330 | - 'title' => _MI_CHESS_NEVT_CHAL_USER, |
|
| 331 | - 'caption' => _MI_CHESS_NEVT_CHAL_USER_CAP, |
|
| 332 | - 'description' => _MI_CHESS_NEVT_CHAL_USER_DES, |
|
| 333 | - 'mail_template' => 'notify_challenge_user', |
|
| 334 | - 'mail_subject' => _MI_CHESS_NEVT_CHAL_USER_SUB, |
|
| 328 | + 'name' => 'notify_challenge_user', |
|
| 329 | + 'category' => 'global', |
|
| 330 | + 'title' => _MI_CHESS_NEVT_CHAL_USER, |
|
| 331 | + 'caption' => _MI_CHESS_NEVT_CHAL_USER_CAP, |
|
| 332 | + 'description' => _MI_CHESS_NEVT_CHAL_USER_DES, |
|
| 333 | + 'mail_template' => 'notify_challenge_user', |
|
| 334 | + 'mail_subject' => _MI_CHESS_NEVT_CHAL_USER_SUB, |
|
| 335 | 335 | ]; |
| 336 | 336 | |
| 337 | 337 | $modversion['notification']['event'][] = [ |
| 338 | - 'name' => 'notify_challenge_open', |
|
| 339 | - 'category' => 'global', |
|
| 340 | - 'title' => _MI_CHESS_NEVT_CHAL_OPEN, |
|
| 341 | - 'caption' => _MI_CHESS_NEVT_CHAL_OPEN_CAP, |
|
| 342 | - 'description' => _MI_CHESS_NEVT_CHAL_OPEN_DES, |
|
| 343 | - 'mail_template' => 'notify_challenge_open', |
|
| 344 | - 'mail_subject' => _MI_CHESS_NEVT_CHAL_OPEN_SUB, |
|
| 338 | + 'name' => 'notify_challenge_open', |
|
| 339 | + 'category' => 'global', |
|
| 340 | + 'title' => _MI_CHESS_NEVT_CHAL_OPEN, |
|
| 341 | + 'caption' => _MI_CHESS_NEVT_CHAL_OPEN_CAP, |
|
| 342 | + 'description' => _MI_CHESS_NEVT_CHAL_OPEN_DES, |
|
| 343 | + 'mail_template' => 'notify_challenge_open', |
|
| 344 | + 'mail_subject' => _MI_CHESS_NEVT_CHAL_OPEN_SUB, |
|
| 345 | 345 | ]; |
| 346 | 346 | |
| 347 | 347 | $modversion['notification']['event'][] = [ |
| 348 | - 'name' => 'notify_accept_challenge', |
|
| 349 | - 'category' => 'global', |
|
| 350 | - 'title' => _MI_CHESS_NEVT_ACPT_CHAL, |
|
| 351 | - 'caption' => _MI_CHESS_NEVT_ACPT_CHAL_CAP, |
|
| 352 | - 'description' => _MI_CHESS_NEVT_ACPT_CHAL_DES, |
|
| 353 | - 'mail_template' => 'notify_accept_challenge', |
|
| 354 | - 'mail_subject' => _MI_CHESS_NEVT_ACPT_CHAL_SUB, |
|
| 348 | + 'name' => 'notify_accept_challenge', |
|
| 349 | + 'category' => 'global', |
|
| 350 | + 'title' => _MI_CHESS_NEVT_ACPT_CHAL, |
|
| 351 | + 'caption' => _MI_CHESS_NEVT_ACPT_CHAL_CAP, |
|
| 352 | + 'description' => _MI_CHESS_NEVT_ACPT_CHAL_DES, |
|
| 353 | + 'mail_template' => 'notify_accept_challenge', |
|
| 354 | + 'mail_subject' => _MI_CHESS_NEVT_ACPT_CHAL_SUB, |
|
| 355 | 355 | ]; |
| 356 | 356 | |
| 357 | 357 | $modversion['notification']['event'][] = [ |
| 358 | - 'name' => 'notify_request_arbitration', |
|
| 359 | - 'category' => 'global', |
|
| 360 | - 'title' => _MI_CHESS_NEVT_RQST_ARBT, |
|
| 361 | - 'caption' => _MI_CHESS_NEVT_RQST_ARBT_CAP, |
|
| 362 | - 'description' => _MI_CHESS_NEVT_RQST_ARBT_DES, |
|
| 363 | - 'mail_template' => 'notify_request_arbitration', |
|
| 364 | - 'mail_subject' => _MI_CHESS_NEVT_RQST_ARBT_SUB, |
|
| 365 | - 'admin_only' => 1, |
|
| 358 | + 'name' => 'notify_request_arbitration', |
|
| 359 | + 'category' => 'global', |
|
| 360 | + 'title' => _MI_CHESS_NEVT_RQST_ARBT, |
|
| 361 | + 'caption' => _MI_CHESS_NEVT_RQST_ARBT_CAP, |
|
| 362 | + 'description' => _MI_CHESS_NEVT_RQST_ARBT_DES, |
|
| 363 | + 'mail_template' => 'notify_request_arbitration', |
|
| 364 | + 'mail_subject' => _MI_CHESS_NEVT_RQST_ARBT_SUB, |
|
| 365 | + 'admin_only' => 1, |
|
| 366 | 366 | ]; |
@@ -32,121 +32,121 @@ |
||
| 32 | 32 | $helper->loadLanguage('common'); |
| 33 | 33 | |
| 34 | 34 | switch ($op) { |
| 35 | - case 'load': |
|
| 36 | - if (\Xmf\Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
| 37 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 38 | - redirect_header('../admin/index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - loadSampleData(); |
|
| 42 | - } else { |
|
| 43 | - xoops_cp_header(); |
|
| 44 | - |
|
| 45 | - xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 46 | - |
|
| 47 | - xoops_cp_footer(); |
|
| 48 | - } |
|
| 49 | - break; |
|
| 50 | - case 'save': |
|
| 51 | - saveSampleData(); |
|
| 52 | - break; |
|
| 35 | + case 'load': |
|
| 36 | + if (\Xmf\Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
| 37 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 38 | + redirect_header('../admin/index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + loadSampleData(); |
|
| 42 | + } else { |
|
| 43 | + xoops_cp_header(); |
|
| 44 | + |
|
| 45 | + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 46 | + |
|
| 47 | + xoops_cp_footer(); |
|
| 48 | + } |
|
| 49 | + break; |
|
| 50 | + case 'save': |
|
| 51 | + saveSampleData(); |
|
| 52 | + break; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // XMF TableLoad for SAMPLE data |
| 56 | 56 | |
| 57 | 57 | function loadSampleData() |
| 58 | 58 | { |
| 59 | - global $xoopsConfig; |
|
| 59 | + global $xoopsConfig; |
|
| 60 | 60 | |
| 61 | - $moduleDirName = basename(dirname(__DIR__)); |
|
| 61 | + $moduleDirName = basename(dirname(__DIR__)); |
|
| 62 | 62 | |
| 63 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 63 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 64 | 64 | |
| 65 | - $utility = new Chess\Utility(); |
|
| 65 | + $utility = new Chess\Utility(); |
|
| 66 | 66 | |
| 67 | - $configurator = new Common\Configurator(); |
|
| 67 | + $configurator = new Common\Configurator(); |
|
| 68 | 68 | |
| 69 | - $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
|
| 69 | + $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
|
| 70 | 70 | |
| 71 | - $language = 'english/'; |
|
| 71 | + $language = 'english/'; |
|
| 72 | 72 | |
| 73 | - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 74 | - $language = $xoopsConfig['language'] . '/'; |
|
| 75 | - } |
|
| 73 | + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 74 | + $language = $xoopsConfig['language'] . '/'; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - foreach ($tables as $table) { |
|
| 78 | - $tabledata = \Xmf\Yaml::readWrapped($language . $table . '.yml'); |
|
| 77 | + foreach ($tables as $table) { |
|
| 78 | + $tabledata = \Xmf\Yaml::readWrapped($language . $table . '.yml'); |
|
| 79 | 79 | |
| 80 | - if (is_array($tabledata)) { |
|
| 81 | - \Xmf\Database\TableLoad::truncateTable($table); |
|
| 80 | + if (is_array($tabledata)) { |
|
| 81 | + \Xmf\Database\TableLoad::truncateTable($table); |
|
| 82 | 82 | |
| 83 | - \Xmf\Database\TableLoad::loadTableFromArray($table, $tabledata); |
|
| 84 | - } |
|
| 85 | - } |
|
| 83 | + \Xmf\Database\TableLoad::loadTableFromArray($table, $tabledata); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - // --- COPY test folder files --------------- |
|
| 87 | + // --- COPY test folder files --------------- |
|
| 88 | 88 | |
| 89 | - if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { |
|
| 90 | - // $file = dirname(__DIR__) . '/testdata/images/'; |
|
| 89 | + if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { |
|
| 90 | + // $file = dirname(__DIR__) . '/testdata/images/'; |
|
| 91 | 91 | |
| 92 | - foreach (array_keys($configurator->copyTestFolders) as $i) { |
|
| 93 | - $src = $configurator->copyTestFolders[$i][0]; |
|
| 92 | + foreach (array_keys($configurator->copyTestFolders) as $i) { |
|
| 93 | + $src = $configurator->copyTestFolders[$i][0]; |
|
| 94 | 94 | |
| 95 | - $dest = $configurator->copyTestFolders[$i][1]; |
|
| 95 | + $dest = $configurator->copyTestFolders[$i][1]; |
|
| 96 | 96 | |
| 97 | - $utility::rcopy($src, $dest); |
|
| 98 | - } |
|
| 99 | - } |
|
| 97 | + $utility::rcopy($src, $dest); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
| 101 | + redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | function saveSampleData() |
| 105 | 105 | { |
| 106 | - global $xoopsConfig; |
|
| 106 | + global $xoopsConfig; |
|
| 107 | 107 | |
| 108 | - $moduleDirName = basename(dirname(__DIR__)); |
|
| 108 | + $moduleDirName = basename(dirname(__DIR__)); |
|
| 109 | 109 | |
| 110 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 110 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 111 | 111 | |
| 112 | - $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
|
| 112 | + $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
|
| 113 | 113 | |
| 114 | - $language = 'english/'; |
|
| 114 | + $language = 'english/'; |
|
| 115 | 115 | |
| 116 | - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 117 | - $language = $xoopsConfig['language'] . '/'; |
|
| 118 | - } |
|
| 116 | + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 117 | + $language = $xoopsConfig['language'] . '/'; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - $languageFolder = __DIR__ . '/' . $language; |
|
| 120 | + $languageFolder = __DIR__ . '/' . $language; |
|
| 121 | 121 | |
| 122 | - if (!file_exists($languageFolder . '/')) { |
|
| 123 | - Utility::createFolder($languageFolder . '/'); |
|
| 124 | - } |
|
| 122 | + if (!file_exists($languageFolder . '/')) { |
|
| 123 | + Utility::createFolder($languageFolder . '/'); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
| 126 | + $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
| 127 | 127 | |
| 128 | - Utility::createFolder($exportFolder); |
|
| 128 | + Utility::createFolder($exportFolder); |
|
| 129 | 129 | |
| 130 | - foreach ($tables as $table) { |
|
| 131 | - \Xmf\Database\TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
| 132 | - } |
|
| 130 | + foreach ($tables as $table) { |
|
| 131 | + \Xmf\Database\TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
| 134 | + redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | function exportSchema() |
| 138 | 138 | { |
| 139 | - $moduleDirName = basename(dirname(__DIR__)); |
|
| 140 | - |
|
| 141 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 142 | - |
|
| 143 | - try { |
|
| 144 | - // TODO set exportSchema |
|
| 145 | - // $migrate = new Chess\Migrate($moduleDirName); |
|
| 146 | - // $migrate->saveCurrentSchema(); |
|
| 147 | - // |
|
| 148 | - // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
|
| 149 | - } catch (\Throwable $e) { |
|
| 150 | - exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
| 151 | - } |
|
| 139 | + $moduleDirName = basename(dirname(__DIR__)); |
|
| 140 | + |
|
| 141 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 142 | + |
|
| 143 | + try { |
|
| 144 | + // TODO set exportSchema |
|
| 145 | + // $migrate = new Chess\Migrate($moduleDirName); |
|
| 146 | + // $migrate->saveCurrentSchema(); |
|
| 147 | + // |
|
| 148 | + // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
|
| 149 | + } catch (\Throwable $e) { |
|
| 150 | + exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
| 151 | + } |
|
| 152 | 152 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | use XoopsModules\Chess\Common; |
| 20 | 20 | use XoopsModules\Chess\Utility; |
| 21 | 21 | |
| 22 | -require_once dirname(__DIR__, 3) . '/include/cp_header.php'; |
|
| 23 | -require dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 22 | +require_once dirname(__DIR__, 3).'/include/cp_header.php'; |
|
| 23 | +require dirname(__DIR__).'/preloads/autoloader.php'; |
|
| 24 | 24 | |
| 25 | 25 | $op = \Xmf\Request::getCmd('op', ''); |
| 26 | 26 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } else { |
| 43 | 43 | xoops_cp_header(); |
| 44 | 44 | |
| 45 | - xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 45 | + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'ADD_SAMPLEDATA_OK')), constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM'), true); |
|
| 46 | 46 | |
| 47 | 47 | xoops_cp_footer(); |
| 48 | 48 | } |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $language = 'english/'; |
| 72 | 72 | |
| 73 | - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 74 | - $language = $xoopsConfig['language'] . '/'; |
|
| 73 | + if (is_dir(__DIR__.'/'.$xoopsConfig['language'])) { |
|
| 74 | + $language = $xoopsConfig['language'].'/'; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | foreach ($tables as $table) { |
| 78 | - $tabledata = \Xmf\Yaml::readWrapped($language . $table . '.yml'); |
|
| 78 | + $tabledata = \Xmf\Yaml::readWrapped($language.$table.'.yml'); |
|
| 79 | 79 | |
| 80 | 80 | if (is_array($tabledata)) { |
| 81 | 81 | \Xmf\Database\TableLoad::truncateTable($table); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
| 101 | + redirect_header('../admin/index.php', 1, constant('CO_'.$moduleDirNameUpper.'_'.'SAMPLEDATA_SUCCESS')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | function saveSampleData() |
@@ -113,25 +113,25 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $language = 'english/'; |
| 115 | 115 | |
| 116 | - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 117 | - $language = $xoopsConfig['language'] . '/'; |
|
| 116 | + if (is_dir(__DIR__.'/'.$xoopsConfig['language'])) { |
|
| 117 | + $language = $xoopsConfig['language'].'/'; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $languageFolder = __DIR__ . '/' . $language; |
|
| 120 | + $languageFolder = __DIR__.'/'.$language; |
|
| 121 | 121 | |
| 122 | - if (!file_exists($languageFolder . '/')) { |
|
| 123 | - Utility::createFolder($languageFolder . '/'); |
|
| 122 | + if (!file_exists($languageFolder.'/')) { |
|
| 123 | + Utility::createFolder($languageFolder.'/'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
| 126 | + $exportFolder = $languageFolder.'/Exports-'.date('Y-m-d-H-i-s').'/'; |
|
| 127 | 127 | |
| 128 | 128 | Utility::createFolder($exportFolder); |
| 129 | 129 | |
| 130 | 130 | foreach ($tables as $table) { |
| 131 | - \Xmf\Database\TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
| 131 | + \Xmf\Database\TableLoad::saveTableToYamlFile($table, $exportFolder.$table.'.yml'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
| 134 | + redirect_header('../admin/index.php', 1, constant('CO_'.$moduleDirNameUpper.'_'.'SAMPLEDATA_SUCCESS')); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | function exportSchema() |
@@ -147,6 +147,6 @@ discard block |
||
| 147 | 147 | // |
| 148 | 148 | // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
| 149 | 149 | } catch (\Throwable $e) { |
| 150 | - exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
| 150 | + exit(constant('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA_ERROR')); |
|
| 151 | 151 | } |
| 152 | 152 | } |
@@ -22,9 +22,9 @@ |
||
| 22 | 22 | define('_MD_CHESS_LABEL_GAMETYPE_OPEN', 'Open challenge'); |
| 23 | 23 | define('_MD_CHESS_LABEL_GAMETYPE_USER', 'Individual challenge'); |
| 24 | 24 | define('_MD_CHESS_LABEL_GAMETYPE_SELF', 'Self-play'); |
| 25 | -define('_MD_CHESS_MENU_GAMETYPE_OPEN', _MD_CHESS_LABEL_GAMETYPE_OPEN . ' - anyone can accept your challenge'); |
|
| 26 | -define('_MD_CHESS_MENU_GAMETYPE_USER', _MD_CHESS_LABEL_GAMETYPE_USER . ' - only the specified user can accept your challenge'); |
|
| 27 | -define('_MD_CHESS_MENU_GAMETYPE_SELF', _MD_CHESS_LABEL_GAMETYPE_SELF . ' - play against yourself (for learning or testing)'); |
|
| 25 | +define('_MD_CHESS_MENU_GAMETYPE_OPEN', _MD_CHESS_LABEL_GAMETYPE_OPEN.' - anyone can accept your challenge'); |
|
| 26 | +define('_MD_CHESS_MENU_GAMETYPE_USER', _MD_CHESS_LABEL_GAMETYPE_USER.' - only the specified user can accept your challenge'); |
|
| 27 | +define('_MD_CHESS_MENU_GAMETYPE_SELF', _MD_CHESS_LABEL_GAMETYPE_SELF.' - play against yourself (for learning or testing)'); |
|
| 28 | 28 | |
| 29 | 29 | // opponent |
| 30 | 30 | define('_MD_CHESS_LABEL_OPPONENT', 'Opponent'); |
@@ -22,9 +22,9 @@ |
||
| 22 | 22 | define('_MD_CHESS_LABEL_GAMETYPE_OPEN', 'Offene Herausforderung'); |
| 23 | 23 | define('_MD_CHESS_LABEL_GAMETYPE_USER', 'Persönliche Herausforderung'); |
| 24 | 24 | define('_MD_CHESS_LABEL_GAMETYPE_SELF', 'Spiel gegen sich selbst'); |
| 25 | -define('_MD_CHESS_MENU_GAMETYPE_OPEN', _MD_CHESS_LABEL_GAMETYPE_OPEN . ' - Jeder kann die Herausforderung annehmen'); |
|
| 26 | -define('_MD_CHESS_MENU_GAMETYPE_USER', _MD_CHESS_LABEL_GAMETYPE_USER . ' - nur der herausgeforderte Benutzer kann die Herausforderung annehmen'); |
|
| 27 | -define('_MD_CHESS_MENU_GAMETYPE_SELF', _MD_CHESS_LABEL_GAMETYPE_SELF . ' - Partie mit sich selbst spielen'); |
|
| 25 | +define('_MD_CHESS_MENU_GAMETYPE_OPEN', _MD_CHESS_LABEL_GAMETYPE_OPEN.' - Jeder kann die Herausforderung annehmen'); |
|
| 26 | +define('_MD_CHESS_MENU_GAMETYPE_USER', _MD_CHESS_LABEL_GAMETYPE_USER.' - nur der herausgeforderte Benutzer kann die Herausforderung annehmen'); |
|
| 27 | +define('_MD_CHESS_MENU_GAMETYPE_SELF', _MD_CHESS_LABEL_GAMETYPE_SELF.' - Partie mit sich selbst spielen'); |
|
| 28 | 28 | |
| 29 | 29 | // opponent |
| 30 | 30 | define('_MD_CHESS_LABEL_OPPONENT', 'Gegner'); |
@@ -4,39 +4,39 @@ |
||
| 4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
| 5 | 5 | */ |
| 6 | 6 | spl_autoload_register( |
| 7 | - static function ($class) { |
|
| 8 | - // project-specific namespace prefix |
|
| 7 | + static function ($class) { |
|
| 8 | + // project-specific namespace prefix |
|
| 9 | 9 | |
| 10 | - $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); |
|
| 10 | + $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); |
|
| 11 | 11 | |
| 12 | - // base directory for the namespace prefix |
|
| 12 | + // base directory for the namespace prefix |
|
| 13 | 13 | |
| 14 | - $baseDir = dirname(__DIR__) . '/class/'; |
|
| 14 | + $baseDir = dirname(__DIR__) . '/class/'; |
|
| 15 | 15 | |
| 16 | - // does the class use the namespace prefix? |
|
| 16 | + // does the class use the namespace prefix? |
|
| 17 | 17 | |
| 18 | - $len = mb_strlen($prefix); |
|
| 18 | + $len = mb_strlen($prefix); |
|
| 19 | 19 | |
| 20 | - if (0 !== strncmp($prefix, $class, $len)) { |
|
| 21 | - return; |
|
| 22 | - } |
|
| 20 | + if (0 !== strncmp($prefix, $class, $len)) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - // get the relative class name |
|
| 24 | + // get the relative class name |
|
| 25 | 25 | |
| 26 | - $relativeClass = mb_substr($class, $len); |
|
| 26 | + $relativeClass = mb_substr($class, $len); |
|
| 27 | 27 | |
| 28 | - // replace the namespace prefix with the base directory, replace namespace |
|
| 28 | + // replace the namespace prefix with the base directory, replace namespace |
|
| 29 | 29 | |
| 30 | - // separators with directory separators in the relative class name, append |
|
| 30 | + // separators with directory separators in the relative class name, append |
|
| 31 | 31 | |
| 32 | - // with .php |
|
| 32 | + // with .php |
|
| 33 | 33 | |
| 34 | - $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; |
|
| 34 | + $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; |
|
| 35 | 35 | |
| 36 | - // if the file exists, require it |
|
| 36 | + // if the file exists, require it |
|
| 37 | 37 | |
| 38 | - if (file_exists($file)) { |
|
| 39 | - require $file; |
|
| 40 | - } |
|
| 41 | - } |
|
| 38 | + if (file_exists($file)) { |
|
| 39 | + require $file; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | ); |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
| 5 | 5 | */ |
| 6 | 6 | spl_autoload_register( |
| 7 | - static function ($class) { |
|
| 7 | + static function($class) { |
|
| 8 | 8 | // project-specific namespace prefix |
| 9 | 9 | |
| 10 | - $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); |
|
| 10 | + $prefix = 'XoopsModules\\'.ucfirst(basename(dirname(__DIR__))); |
|
| 11 | 11 | |
| 12 | 12 | // base directory for the namespace prefix |
| 13 | 13 | |
| 14 | - $baseDir = dirname(__DIR__) . '/class/'; |
|
| 14 | + $baseDir = dirname(__DIR__).'/class/'; |
|
| 15 | 15 | |
| 16 | 16 | // does the class use the namespace prefix? |
| 17 | 17 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | // with .php |
| 33 | 33 | |
| 34 | - $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; |
|
| 34 | + $file = $baseDir.str_replace('\\', '/', $relativeClass).'.php'; |
|
| 35 | 35 | |
| 36 | 36 | // if the file exists, require it |
| 37 | 37 | |
@@ -28,6 +28,6 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public static function eventCoreIncludeCommonEnd($args) |
| 30 | 30 | { |
| 31 | - require __DIR__ . '/autoloader.php'; |
|
| 31 | + require __DIR__.'/autoloader.php'; |
|
| 32 | 32 | } |
| 33 | 33 | } |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class ChessCorePreload extends \XoopsPreloadItem |
| 24 | 24 | { |
| 25 | - // to add PSR-4 autoloader |
|
| 26 | - /** |
|
| 27 | - * @param $args |
|
| 28 | - */ |
|
| 29 | - public static function eventCoreIncludeCommonEnd($args) |
|
| 30 | - { |
|
| 31 | - require __DIR__ . '/autoloader.php'; |
|
| 32 | - } |
|
| 25 | + // to add PSR-4 autoloader |
|
| 26 | + /** |
|
| 27 | + * @param $args |
|
| 28 | + */ |
|
| 29 | + public static function eventCoreIncludeCommonEnd($args) |
|
| 30 | + { |
|
| 31 | + require __DIR__ . '/autoloader.php'; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -50,86 +50,86 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function chess_ratings_adj_cxr($white_rating, $white_games, $black_rating, $black_games, $pgn_result) |
| 52 | 52 | { |
| 53 | - // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 53 | + // compute score: +1 for win, 0 for draw, -1 for loss |
|
| 54 | 54 | |
| 55 | - switch ($pgn_result) { |
|
| 56 | - case '1-0': |
|
| 57 | - $S = 1; |
|
| 58 | - break; |
|
| 59 | - case '1/2-1/2': |
|
| 60 | - default: // should not occur |
|
| 61 | - $S = 0; |
|
| 62 | - break; |
|
| 63 | - case '0-1': |
|
| 64 | - $S = -1; |
|
| 65 | - break; |
|
| 66 | - } |
|
| 55 | + switch ($pgn_result) { |
|
| 56 | + case '1-0': |
|
| 57 | + $S = 1; |
|
| 58 | + break; |
|
| 59 | + case '1/2-1/2': |
|
| 60 | + default: // should not occur |
|
| 61 | + $S = 0; |
|
| 62 | + break; |
|
| 63 | + case '0-1': |
|
| 64 | + $S = -1; |
|
| 65 | + break; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - if (($white_games < 5 && $black_games < 5) || ($white_games > 5 && $black_games > 5)) { |
|
| 69 | - // Formula 1: Rnew = Rold + (S x 21) + (Ropponent - Rold) / 25 |
|
| 68 | + if (($white_games < 5 && $black_games < 5) || ($white_games > 5 && $black_games > 5)) { |
|
| 69 | + // Formula 1: Rnew = Rold + (S x 21) + (Ropponent - Rold) / 25 |
|
| 70 | 70 | |
| 71 | - $w_new = ($S * 21) + ($black_rating - $white_rating) / 25; |
|
| 71 | + $w_new = ($S * 21) + ($black_rating - $white_rating) / 25; |
|
| 72 | 72 | |
| 73 | - $b_new = (-$S * 21) + ($white_rating - $black_rating) / 25; |
|
| 74 | - } elseif ($white_games > 5 && $black_games < 5) { |
|
| 75 | - // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 73 | + $b_new = (-$S * 21) + ($white_rating - $black_rating) / 25; |
|
| 74 | + } elseif ($white_games > 5 && $black_games < 5) { |
|
| 75 | + // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 76 | 76 | |
| 77 | - $w_new = ($S * 6) + ($black_rating - $white_rating) / 100; |
|
| 77 | + $w_new = ($S * 6) + ($black_rating - $white_rating) / 100; |
|
| 78 | 78 | |
| 79 | - // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 79 | + // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 80 | 80 | |
| 81 | - $b_new = ($white_rating / 5) + ($S * -80) - ($black_rating / 5); |
|
| 82 | - } else { |
|
| 83 | - // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 81 | + $b_new = ($white_rating / 5) + ($S * -80) - ($black_rating / 5); |
|
| 82 | + } else { |
|
| 83 | + // Formula 2: Rnew = Rold + (S x 6) + (Ropponent - Rold) / 100 |
|
| 84 | 84 | |
| 85 | - $b_new = ($S * 6) + ($white_rating - $black_rating) / 100; |
|
| 85 | + $b_new = ($S * 6) + ($white_rating - $black_rating) / 100; |
|
| 86 | 86 | |
| 87 | - // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 87 | + // Formula 3: Rnew = (4/5) x Rold + (1/5) x Ropponent + (S x 80) |
|
| 88 | 88 | |
| 89 | - $w_new = ($black_rating / 5) + ($S * -80) - ($white_rating / 5); |
|
| 90 | - } |
|
| 89 | + $w_new = ($black_rating / 5) + ($S * -80) - ($white_rating / 5); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - // Rule R1: The winning rated player must gain at least two points. |
|
| 92 | + // Rule R1: The winning rated player must gain at least two points. |
|
| 93 | 93 | |
| 94 | - // Rule R2: The losing rated player must lose at least two points. |
|
| 94 | + // Rule R2: The losing rated player must lose at least two points. |
|
| 95 | 95 | |
| 96 | - if (abs($w_new) < 2) { |
|
| 97 | - $w_new = $S * 2; |
|
| 98 | - } |
|
| 96 | + if (abs($w_new) < 2) { |
|
| 97 | + $w_new = $S * 2; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - if (abs($b_new) < 2) { |
|
| 101 | - $b_new = $S * -2; |
|
| 102 | - } |
|
| 100 | + if (abs($b_new) < 2) { |
|
| 101 | + $b_new = $S * -2; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - // Rule R3: The rated player must not gain nor lose more than 41 points. |
|
| 104 | + // Rule R3: The rated player must not gain nor lose more than 41 points. |
|
| 105 | 105 | |
| 106 | - if (abs($w_new) > 41) { |
|
| 107 | - $w_new = $S * 41; |
|
| 108 | - } |
|
| 106 | + if (abs($w_new) > 41) { |
|
| 107 | + $w_new = $S * 41; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - if (abs($b_new) > 41) { |
|
| 111 | - $b_new = $S * -41; |
|
| 112 | - } |
|
| 110 | + if (abs($b_new) > 41) { |
|
| 111 | + $b_new = $S * -41; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - if (1 == $S) { |
|
| 115 | - if ($white_games < 5 && $w_new < 0) { |
|
| 116 | - $w_new = 2; |
|
| 117 | - } |
|
| 114 | + if (1 == $S) { |
|
| 115 | + if ($white_games < 5 && $w_new < 0) { |
|
| 116 | + $w_new = 2; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if ($black_games < 5 && $b_new > 0) { |
|
| 120 | - $b_new = -2; |
|
| 121 | - } |
|
| 122 | - } elseif (-1 == $S) { |
|
| 123 | - if ($white_games < 5 && $w_new > 0) { |
|
| 124 | - $w_new = -2; |
|
| 125 | - } |
|
| 119 | + if ($black_games < 5 && $b_new > 0) { |
|
| 120 | + $b_new = -2; |
|
| 121 | + } |
|
| 122 | + } elseif (-1 == $S) { |
|
| 123 | + if ($white_games < 5 && $w_new > 0) { |
|
| 124 | + $w_new = -2; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - if ($black_games < 5 && $b_new < 0) { |
|
| 128 | - $b_new = 2; |
|
| 129 | - } |
|
| 130 | - } |
|
| 127 | + if ($black_games < 5 && $b_new < 0) { |
|
| 128 | + $b_new = 2; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - return [$white_rating + $w_new, $black_rating + $b_new]; |
|
| 132 | + return [$white_rating + $w_new, $black_rating + $b_new]; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -139,5 +139,5 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | function chess_ratings_num_provisional_games_cxr() |
| 141 | 141 | { |
| 142 | - return 5; |
|
| 142 | + return 5; |
|
| 143 | 143 | } |
@@ -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 | } |
@@ -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"); |
@@ -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 | } |