@@ -42,31 +42,31 @@ discard block |
||
| 42 | 42 | //------------- Test Data ---------------------------- |
| 43 | 43 | |
| 44 | 44 | if ($helper->getConfig('displaySampleButton')) { |
| 45 | - $yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
|
| 45 | + $yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
|
| 46 | 46 | |
| 47 | - $config = loadAdminConfig($yamlFile); |
|
| 47 | + $config = loadAdminConfig($yamlFile); |
|
| 48 | 48 | |
| 49 | - $displaySampleButton = $config['displaySampleButton']; |
|
| 49 | + $displaySampleButton = $config['displaySampleButton']; |
|
| 50 | 50 | |
| 51 | - if (1 == $displaySampleButton) { |
|
| 52 | - xoops_loadLanguage('admin/modulesadmin', 'system'); |
|
| 51 | + if (1 == $displaySampleButton) { |
|
| 52 | + xoops_loadLanguage('admin/modulesadmin', 'system'); |
|
| 53 | 53 | |
| 54 | - require_once dirname(__DIR__) . '/testdata/index.php'; |
|
| 54 | + require_once dirname(__DIR__) . '/testdata/index.php'; |
|
| 55 | 55 | |
| 56 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
|
| 56 | + $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
|
| 57 | 57 | |
| 58 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
|
| 58 | + $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
|
| 59 | 59 | |
| 60 | - // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
|
| 60 | + // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
|
| 61 | 61 | |
| 62 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
| 63 | - } else { |
|
| 64 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
| 62 | + $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
| 63 | + } else { |
|
| 64 | + $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
| 65 | 65 | |
| 66 | - $displaySampleButton = $config['displaySampleButton']; |
|
| 67 | - } |
|
| 66 | + $displaySampleButton = $config['displaySampleButton']; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $adminObject->displayButton('left', ''); |
|
| 69 | + $adminObject->displayButton('left', ''); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | //------------- End Test Data ---------------------------- |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function loadAdminConfig($yamlFile) |
| 81 | 81 | { |
| 82 | - return \Xmf\Yaml::readWrapped($yamlFile); |
|
| 82 | + return \Xmf\Yaml::readWrapped($yamlFile); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | function hideButtons($yamlFile) |
| 89 | 89 | { |
| 90 | - $app['displaySampleButton'] = 0; |
|
| 90 | + $app['displaySampleButton'] = 0; |
|
| 91 | 91 | |
| 92 | - \Xmf\Yaml::save($app, $yamlFile); |
|
| 92 | + \Xmf\Yaml::save($app, $yamlFile); |
|
| 93 | 93 | |
| 94 | - redirect_header('index.php', 0, ''); |
|
| 94 | + redirect_header('index.php', 0, ''); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | function showButtons($yamlFile) |
| 101 | 101 | { |
| 102 | - $app['displaySampleButton'] = 1; |
|
| 102 | + $app['displaySampleButton'] = 1; |
|
| 103 | 103 | |
| 104 | - \Xmf\Yaml::save($app, $yamlFile); |
|
| 104 | + \Xmf\Yaml::save($app, $yamlFile); |
|
| 105 | 105 | |
| 106 | - redirect_header('index.php', 0, ''); |
|
| 106 | + redirect_header('index.php', 0, ''); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $op = \Xmf\Request::getString('op', 0, 'GET'); |
| 110 | 110 | |
| 111 | 111 | switch ($op) { |
| 112 | - case 'hide_buttons': |
|
| 113 | - hideButtons($yamlFile); |
|
| 114 | - break; |
|
| 115 | - case 'show_buttons': |
|
| 116 | - showButtons($yamlFile); |
|
| 117 | - break; |
|
| 112 | + case 'hide_buttons': |
|
| 113 | + hideButtons($yamlFile); |
|
| 114 | + break; |
|
| 115 | + case 'show_buttons': |
|
| 116 | + showButtons($yamlFile); |
|
| 117 | + break; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | echo $utility::getServerStats(); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | use XoopsModules\Chess\Common; |
| 21 | 21 | |
| 22 | -require __DIR__ . '/admin_header.php'; |
|
| 22 | +require __DIR__.'/admin_header.php'; |
|
| 23 | 23 | // Display Admin header |
| 24 | 24 | xoops_cp_header(); |
| 25 | 25 | $adminObject = \Xmf\Module\Admin::getInstance(); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | //------------- Test Data ---------------------------- |
| 43 | 43 | |
| 44 | 44 | if ($helper->getConfig('displaySampleButton')) { |
| 45 | - $yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
|
| 45 | + $yamlFile = dirname(__DIR__).'/config/admin.yml'; |
|
| 46 | 46 | |
| 47 | 47 | $config = loadAdminConfig($yamlFile); |
| 48 | 48 | |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | if (1 == $displaySampleButton) { |
| 52 | 52 | xoops_loadLanguage('admin/modulesadmin', 'system'); |
| 53 | 53 | |
| 54 | - require_once dirname(__DIR__) . '/testdata/index.php'; |
|
| 54 | + require_once dirname(__DIR__).'/testdata/index.php'; |
|
| 55 | 55 | |
| 56 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
|
| 56 | + $adminObject->addItemButton(constant('CO_'.$moduleDirNameUpper.'_'.'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
|
| 57 | 57 | |
| 58 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
|
| 58 | + $adminObject->addItemButton(constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
|
| 59 | 59 | |
| 60 | 60 | // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
| 61 | 61 | |
| 62 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
| 62 | + $adminObject->addItemButton(constant('CO_'.$moduleDirNameUpper.'_'.'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
| 63 | 63 | } else { |
| 64 | - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
| 64 | + $adminObject->addItemButton(constant('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
| 65 | 65 | |
| 66 | 66 | $displaySampleButton = $config['displaySampleButton']; |
| 67 | 67 | } |
@@ -119,4 +119,4 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | echo $utility::getServerStats(); |
| 121 | 121 | |
| 122 | -require __DIR__ . '/admin_footer.php'; |
|
| 122 | +require __DIR__.'/admin_footer.php'; |
|
@@ -34,45 +34,45 @@ |
||
| 34 | 34 | |
| 35 | 35 | $pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); |
| 36 | 36 | if (is_object($helper->getModule())) { |
| 37 | - // $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 37 | + // $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 38 | 38 | |
| 39 | - $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); |
|
| 39 | + $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $adminmenu[] = [ |
| 43 | - 'title' => _MI_CHESS_MENU_HOME, |
|
| 44 | - 'link' => 'admin/index.php', |
|
| 45 | - 'icon' => $pathIcon32 . '/home.png', |
|
| 43 | + 'title' => _MI_CHESS_MENU_HOME, |
|
| 44 | + 'link' => 'admin/index.php', |
|
| 45 | + 'icon' => $pathIcon32 . '/home.png', |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | $adminmenu[] = [ |
| 49 | - 'title' => _MI_CHESS_ADMENU1, |
|
| 50 | - 'link' => 'admin/main.php?op=suspended_games', |
|
| 51 | - 'icon' => $pathIcon32 . '/alert.png', |
|
| 49 | + 'title' => _MI_CHESS_ADMENU1, |
|
| 50 | + 'link' => 'admin/main.php?op=suspended_games', |
|
| 51 | + 'icon' => $pathIcon32 . '/alert.png', |
|
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | 54 | $adminmenu[] = [ |
| 55 | - 'title' => _MI_CHESS_ADMENU2, |
|
| 56 | - 'link' => 'admin/main.php?op=active_games', |
|
| 57 | - 'icon' => $pathIcon32 . '/button_ok.png', |
|
| 55 | + 'title' => _MI_CHESS_ADMENU2, |
|
| 56 | + 'link' => 'admin/main.php?op=active_games', |
|
| 57 | + 'icon' => $pathIcon32 . '/button_ok.png', |
|
| 58 | 58 | ]; |
| 59 | 59 | |
| 60 | 60 | $adminmenu[] = [ |
| 61 | - 'title' => _MI_CHESS_ADMENU3, |
|
| 62 | - 'link' => 'admin/main.php?op=challenges', |
|
| 63 | - 'icon' => $pathIcon32 . '/cash_stack.png', |
|
| 61 | + 'title' => _MI_CHESS_ADMENU3, |
|
| 62 | + 'link' => 'admin/main.php?op=challenges', |
|
| 63 | + 'icon' => $pathIcon32 . '/cash_stack.png', |
|
| 64 | 64 | ]; |
| 65 | 65 | |
| 66 | 66 | if (is_object($helper->getModule()) && $helper->getConfig('displayDeveloperTools')) { |
| 67 | - $adminmenu[] = [ |
|
| 68 | - 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE'), |
|
| 69 | - 'link' => 'admin/migrate.php', |
|
| 70 | - 'icon' => $pathIcon32 . '/database_go.png', |
|
| 71 | - ]; |
|
| 67 | + $adminmenu[] = [ |
|
| 68 | + 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE'), |
|
| 69 | + 'link' => 'admin/migrate.php', |
|
| 70 | + 'icon' => $pathIcon32 . '/database_go.png', |
|
| 71 | + ]; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $adminmenu[] = [ |
| 75 | - 'title' => _MI_CHESS_MENU_ABOUT, |
|
| 76 | - 'link' => 'admin/about.php', |
|
| 77 | - 'icon' => $pathIcon32 . '/about.png', |
|
| 75 | + 'title' => _MI_CHESS_MENU_ABOUT, |
|
| 76 | + 'link' => 'admin/about.php', |
|
| 77 | + 'icon' => $pathIcon32 . '/about.png', |
|
| 78 | 78 | ]; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
| 26 | 26 | // ------------------------------------------------------------------------ // |
| 27 | 27 | |
| 28 | -include dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 28 | +include dirname(__DIR__).'/preloads/autoloader.php'; |
|
| 29 | 29 | |
| 30 | 30 | $moduleDirName = basename(dirname(__DIR__)); |
| 31 | 31 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
@@ -42,37 +42,37 @@ discard block |
||
| 42 | 42 | $adminmenu[] = [ |
| 43 | 43 | 'title' => _MI_CHESS_MENU_HOME, |
| 44 | 44 | 'link' => 'admin/index.php', |
| 45 | - 'icon' => $pathIcon32 . '/home.png', |
|
| 45 | + 'icon' => $pathIcon32.'/home.png', |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | $adminmenu[] = [ |
| 49 | 49 | 'title' => _MI_CHESS_ADMENU1, |
| 50 | 50 | 'link' => 'admin/main.php?op=suspended_games', |
| 51 | - 'icon' => $pathIcon32 . '/alert.png', |
|
| 51 | + 'icon' => $pathIcon32.'/alert.png', |
|
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | 54 | $adminmenu[] = [ |
| 55 | 55 | 'title' => _MI_CHESS_ADMENU2, |
| 56 | 56 | 'link' => 'admin/main.php?op=active_games', |
| 57 | - 'icon' => $pathIcon32 . '/button_ok.png', |
|
| 57 | + 'icon' => $pathIcon32.'/button_ok.png', |
|
| 58 | 58 | ]; |
| 59 | 59 | |
| 60 | 60 | $adminmenu[] = [ |
| 61 | 61 | 'title' => _MI_CHESS_ADMENU3, |
| 62 | 62 | 'link' => 'admin/main.php?op=challenges', |
| 63 | - 'icon' => $pathIcon32 . '/cash_stack.png', |
|
| 63 | + 'icon' => $pathIcon32.'/cash_stack.png', |
|
| 64 | 64 | ]; |
| 65 | 65 | |
| 66 | 66 | if (is_object($helper->getModule()) && $helper->getConfig('displayDeveloperTools')) { |
| 67 | 67 | $adminmenu[] = [ |
| 68 | - 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE'), |
|
| 68 | + 'title' => constant('CO_'.$moduleDirNameUpper.'_'.'ADMENU_MIGRATE'), |
|
| 69 | 69 | 'link' => 'admin/migrate.php', |
| 70 | - 'icon' => $pathIcon32 . '/database_go.png', |
|
| 70 | + 'icon' => $pathIcon32.'/database_go.png', |
|
| 71 | 71 | ]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $adminmenu[] = [ |
| 75 | 75 | 'title' => _MI_CHESS_MENU_ABOUT, |
| 76 | 76 | 'link' => 'admin/about.php', |
| 77 | - 'icon' => $pathIcon32 . '/about.png', |
|
| 77 | + 'icon' => $pathIcon32.'/about.png', |
|
| 78 | 78 | ]; |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | xoops_cp_header(); |
| 51 | 51 | |
| 52 | 52 | switch ($op) { |
| 53 | - case 'suspended_games': |
|
| 54 | - chess_admin_suspended_games(); |
|
| 55 | - break; |
|
| 56 | - case 'active_games': |
|
| 57 | - chess_admin_active_games(); |
|
| 58 | - break; |
|
| 59 | - case 'challenges': |
|
| 60 | - chess_admin_challenges(); |
|
| 61 | - break; |
|
| 62 | - default: |
|
| 63 | - chess_admin_menu(); |
|
| 64 | - break; |
|
| 53 | + case 'suspended_games': |
|
| 54 | + chess_admin_suspended_games(); |
|
| 55 | + break; |
|
| 56 | + case 'active_games': |
|
| 57 | + chess_admin_active_games(); |
|
| 58 | + break; |
|
| 59 | + case 'challenges': |
|
| 60 | + chess_admin_challenges(); |
|
| 61 | + break; |
|
| 62 | + default: |
|
| 63 | + chess_admin_menu(); |
|
| 64 | + break; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | xoops_cp_footer(); |
@@ -72,30 +72,30 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function chess_admin_menu() |
| 74 | 74 | { |
| 75 | - global $xoopsModule; |
|
| 75 | + global $xoopsModule; |
|
| 76 | 76 | |
| 77 | - echo ' |
|
| 77 | + echo ' |
|
| 78 | 78 | <h4> ' . _AM_CHESS_CONF . ' </h4>' |
| 79 | - // <table width='100%' border='0' cellspacing='1' class='outer'> |
|
| 80 | - // <tr> |
|
| 81 | - // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=suspended_games'>" . _AM_CHESS_SUSPENDED_GAMES . '</a> |
|
| 82 | - // <td>' . _AM_CHESS_SUSPENDED_GAMES_DES . "</td> |
|
| 83 | - // </tr> |
|
| 84 | - // <tr> |
|
| 85 | - // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=active_games'>" . _AM_CHESS_ACTIVE_GAMES . '</a> |
|
| 86 | - // <td>' . _AM_CHESS_ACTIVE_GAMES_DES . "</td> |
|
| 87 | - // </tr> |
|
| 88 | - // <tr> |
|
| 89 | - // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=challenges'>" . _AM_CHESS_CHALLENGES . '</a> |
|
| 90 | - // <td>' . _AM_CHESS_CHALLENGES_DES . "</td> |
|
| 91 | - // </tr> |
|
| 92 | - // <tr> |
|
| 93 | - // <td><a href='" . XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $xoopsModule->getVar('mid') . "'>" . _AM_CHESS_PREFS . '</a> |
|
| 94 | - // <td>' . _AM_CHESS_PREFS_DESC . '</td> |
|
| 95 | - // </tr> |
|
| 96 | - // </table> |
|
| 97 | - //' |
|
| 98 | - ; |
|
| 79 | + // <table width='100%' border='0' cellspacing='1' class='outer'> |
|
| 80 | + // <tr> |
|
| 81 | + // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=suspended_games'>" . _AM_CHESS_SUSPENDED_GAMES . '</a> |
|
| 82 | + // <td>' . _AM_CHESS_SUSPENDED_GAMES_DES . "</td> |
|
| 83 | + // </tr> |
|
| 84 | + // <tr> |
|
| 85 | + // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=active_games'>" . _AM_CHESS_ACTIVE_GAMES . '</a> |
|
| 86 | + // <td>' . _AM_CHESS_ACTIVE_GAMES_DES . "</td> |
|
| 87 | + // </tr> |
|
| 88 | + // <tr> |
|
| 89 | + // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=challenges'>" . _AM_CHESS_CHALLENGES . '</a> |
|
| 90 | + // <td>' . _AM_CHESS_CHALLENGES_DES . "</td> |
|
| 91 | + // </tr> |
|
| 92 | + // <tr> |
|
| 93 | + // <td><a href='" . XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $xoopsModule->getVar('mid') . "'>" . _AM_CHESS_PREFS . '</a> |
|
| 94 | + // <td>' . _AM_CHESS_PREFS_DESC . '</td> |
|
| 95 | + // </tr> |
|
| 96 | + // </table> |
|
| 97 | + //' |
|
| 98 | + ; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -103,103 +103,103 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function chess_admin_suspended_games() |
| 105 | 105 | { |
| 106 | - global $start, $max_items_to_display, $op, $xoopsDB, $xoopsModule; |
|
| 106 | + global $start, $max_items_to_display, $op, $xoopsDB, $xoopsModule; |
|
| 107 | 107 | |
| 108 | - $memberHandler = xoops_getHandler('member'); |
|
| 108 | + $memberHandler = xoops_getHandler('member'); |
|
| 109 | 109 | |
| 110 | - // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator, |
|
| 110 | + // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator, |
|
| 111 | 111 | |
| 112 | - // and one with a limit clause to get the data for display on the current page. |
|
| 112 | + // and one with a limit clause to get the data for display on the current page. |
|
| 113 | 113 | |
| 114 | - // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this. |
|
| 114 | + // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this. |
|
| 115 | 115 | |
| 116 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 116 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 117 | 117 | |
| 118 | - $result = $xoopsDB->query("SELECT COUNT(*) FROM $games_table WHERE suspended != ''"); |
|
| 118 | + $result = $xoopsDB->query("SELECT COUNT(*) FROM $games_table WHERE suspended != ''"); |
|
| 119 | 119 | |
| 120 | - [$num_rows] = $xoopsDB->fetchRow($result); |
|
| 120 | + [$num_rows] = $xoopsDB->fetchRow($result); |
|
| 121 | 121 | |
| 122 | - $xoopsDB->freeRecordSet($result); |
|
| 122 | + $xoopsDB->freeRecordSet($result); |
|
| 123 | 123 | |
| 124 | - // Sort by date-suspended in ascending order, so that games that were suspended the earliest will be displayed |
|
| 124 | + // Sort by date-suspended in ascending order, so that games that were suspended the earliest will be displayed |
|
| 125 | 125 | |
| 126 | - // at the top, and can more easily be arbitrated on a first-come first-serve basis. |
|
| 126 | + // at the top, and can more easily be arbitrated on a first-come first-serve basis. |
|
| 127 | 127 | |
| 128 | - // Note that the suspended column begins with the date-suspended in the format 'YYYY-MM-DD HH:MM:SS', so the sorting |
|
| 128 | + // Note that the suspended column begins with the date-suspended in the format 'YYYY-MM-DD HH:MM:SS', so the sorting |
|
| 129 | 129 | |
| 130 | - // will work as desired. |
|
| 130 | + // will work as desired. |
|
| 131 | 131 | |
| 132 | - $result = $xoopsDB->query( |
|
| 133 | - trim( |
|
| 134 | - " |
|
| 132 | + $result = $xoopsDB->query( |
|
| 133 | + trim( |
|
| 134 | + " |
|
| 135 | 135 | SELECT game_id, white_uid, black_uid, UNIX_TIMESTAMP(start_date) AS start_date, suspended |
| 136 | 136 | FROM $games_table |
| 137 | 137 | WHERE suspended != '' |
| 138 | 138 | ORDER BY suspended |
| 139 | 139 | LIMIT $start, $max_items_to_display |
| 140 | 140 | " |
| 141 | - ) |
|
| 142 | - ); |
|
| 141 | + ) |
|
| 142 | + ); |
|
| 143 | 143 | |
| 144 | - if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 145 | - echo '<h3>' . _AM_CHESS_SUSPENDED_GAMES . "</h3>\n"; |
|
| 144 | + if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 145 | + echo '<h3>' . _AM_CHESS_SUSPENDED_GAMES . "</h3>\n"; |
|
| 146 | 146 | |
| 147 | - while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 148 | - $user_white = $memberHandler->getUser($row['white_uid']); |
|
| 147 | + while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 148 | + $user_white = $memberHandler->getUser($row['white_uid']); |
|
| 149 | 149 | |
| 150 | - $username_white = is_object($user_white) ? $user_white->getVar('uname') : '(open)'; |
|
| 150 | + $username_white = is_object($user_white) ? $user_white->getVar('uname') : '(open)'; |
|
| 151 | 151 | |
| 152 | - $user_black = $memberHandler->getUser($row['black_uid']); |
|
| 152 | + $user_black = $memberHandler->getUser($row['black_uid']); |
|
| 153 | 153 | |
| 154 | - $username_black = is_object($user_black) ? $user_black->getVar('uname') : '(open)'; |
|
| 154 | + $username_black = is_object($user_black) ? $user_black->getVar('uname') : '(open)'; |
|
| 155 | 155 | |
| 156 | - $date = $row['start_date'] ? date('Y.m.d', $row['start_date']) : 'not yet started'; |
|
| 156 | + $date = $row['start_date'] ? date('Y.m.d', $row['start_date']) : 'not yet started'; |
|
| 157 | 157 | |
| 158 | - $title_text = _AM_CHESS_GAME . " #{$row['game_id']} $username_white " . _AM_CHESS_VS . " $username_black ($date)"; |
|
| 158 | + $title_text = _AM_CHESS_GAME . " #{$row['game_id']} $username_white " . _AM_CHESS_VS . " $username_black ($date)"; |
|
| 159 | 159 | |
| 160 | - $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 160 | + $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 161 | 161 | |
| 162 | - [$date, $suspender_uid, $type, $explain] = explode('|', $row['suspended']); |
|
| 162 | + [$date, $suspender_uid, $type, $explain] = explode('|', $row['suspended']); |
|
| 163 | 163 | |
| 164 | - switch ($type) { |
|
| 165 | - case 'arbiter_suspend': |
|
| 166 | - $type_display = _AM_CHESS_SUSP_TYPE_ARBITER; |
|
| 167 | - break; |
|
| 168 | - case 'want_arbitration': |
|
| 169 | - $type_display = _AM_CHESS_SUSP_TYPE_PLAYER; |
|
| 170 | - break; |
|
| 171 | - default: |
|
| 172 | - $type_display = _AM_CHESS_ERROR; |
|
| 173 | - break; |
|
| 174 | - } |
|
| 164 | + switch ($type) { |
|
| 165 | + case 'arbiter_suspend': |
|
| 166 | + $type_display = _AM_CHESS_SUSP_TYPE_ARBITER; |
|
| 167 | + break; |
|
| 168 | + case 'want_arbitration': |
|
| 169 | + $type_display = _AM_CHESS_SUSP_TYPE_PLAYER; |
|
| 170 | + break; |
|
| 171 | + default: |
|
| 172 | + $type_display = _AM_CHESS_ERROR; |
|
| 173 | + break; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - $suspender_user = $memberHandler->getUser($suspender_uid); |
|
| 176 | + $suspender_user = $memberHandler->getUser($suspender_uid); |
|
| 177 | 177 | |
| 178 | - $suspender_username = is_object($suspender_user) ? $suspender_user->getVar('uname') : _AM_CHESS_UNKNOWN_USER; |
|
| 178 | + $suspender_username = is_object($suspender_user) ? $suspender_user->getVar('uname') : _AM_CHESS_UNKNOWN_USER; |
|
| 179 | 179 | |
| 180 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_WHEN_SUSPENDED . ':', formatTimestamp(strtotime($date)))); |
|
| 180 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_WHEN_SUSPENDED . ':', formatTimestamp(strtotime($date)))); |
|
| 181 | 181 | |
| 182 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENDED_BY . ':', $suspender_username)); |
|
| 182 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENDED_BY . ':', $suspender_username)); |
|
| 183 | 183 | |
| 184 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_TYPE . ':', $type_display)); |
|
| 184 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_TYPE . ':', $type_display)); |
|
| 185 | 185 | |
| 186 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_REASON . ':', $explain)); |
|
| 186 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_REASON . ':', $explain)); |
|
| 187 | 187 | |
| 188 | - $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
|
| 188 | + $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
|
| 189 | 189 | |
| 190 | - $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', 1)); |
|
| 190 | + $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', 1)); |
|
| 191 | 191 | |
| 192 | - $form->display(); |
|
| 193 | - } |
|
| 192 | + $form->display(); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
|
| 195 | + $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
|
| 196 | 196 | |
| 197 | - echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 198 | - } else { |
|
| 199 | - echo '<h3>' . _AM_CHESS_NO_SUSPENDED_GAMES . "</h3>\n"; |
|
| 200 | - } |
|
| 197 | + echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 198 | + } else { |
|
| 199 | + echo '<h3>' . _AM_CHESS_NO_SUSPENDED_GAMES . "</h3>\n"; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - $xoopsDB->freeRecordSet($result); |
|
| 202 | + $xoopsDB->freeRecordSet($result); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -207,69 +207,69 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | function chess_admin_active_games() |
| 209 | 209 | { |
| 210 | - global $start, $max_items_to_display, $op, $xoopsDB, $xoopsModule; |
|
| 210 | + global $start, $max_items_to_display, $op, $xoopsDB, $xoopsModule; |
|
| 211 | 211 | |
| 212 | - $memberHandler = xoops_getHandler('member'); |
|
| 212 | + $memberHandler = xoops_getHandler('member'); |
|
| 213 | 213 | |
| 214 | - // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator, |
|
| 214 | + // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator, |
|
| 215 | 215 | |
| 216 | - // and one with a limit clause to get the data for display on the current page. |
|
| 216 | + // and one with a limit clause to get the data for display on the current page. |
|
| 217 | 217 | |
| 218 | - // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this. |
|
| 218 | + // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this. |
|
| 219 | 219 | |
| 220 | - $games_table = $xoopsDB->prefix('chess_games'); |
|
| 220 | + $games_table = $xoopsDB->prefix('chess_games'); |
|
| 221 | 221 | |
| 222 | - $result = $xoopsDB->query("SELECT COUNT(*) FROM $games_table WHERE pgn_result = '*' and suspended = ''"); |
|
| 222 | + $result = $xoopsDB->query("SELECT COUNT(*) FROM $games_table WHERE pgn_result = '*' and suspended = ''"); |
|
| 223 | 223 | |
| 224 | - [$num_rows] = $xoopsDB->fetchRow($result); |
|
| 224 | + [$num_rows] = $xoopsDB->fetchRow($result); |
|
| 225 | 225 | |
| 226 | - $xoopsDB->freeRecordSet($result); |
|
| 226 | + $xoopsDB->freeRecordSet($result); |
|
| 227 | 227 | |
| 228 | - $result = $xoopsDB->query( |
|
| 229 | - trim( |
|
| 230 | - " |
|
| 228 | + $result = $xoopsDB->query( |
|
| 229 | + trim( |
|
| 230 | + " |
|
| 231 | 231 | SELECT game_id, white_uid, black_uid, UNIX_TIMESTAMP(start_date) AS start_date, GREATEST(create_date,start_date,last_date) AS most_recent_date |
| 232 | 232 | FROM $games_table |
| 233 | 233 | WHERE pgn_result = '*' and suspended = '' |
| 234 | 234 | ORDER BY most_recent_date DESC |
| 235 | 235 | LIMIT $start, $max_items_to_display |
| 236 | 236 | " |
| 237 | - ) |
|
| 238 | - ); |
|
| 237 | + ) |
|
| 238 | + ); |
|
| 239 | 239 | |
| 240 | - if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 241 | - echo '<h3>' . _AM_CHESS_ACTIVE_GAMES . "</h3>\n"; |
|
| 240 | + if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 241 | + echo '<h3>' . _AM_CHESS_ACTIVE_GAMES . "</h3>\n"; |
|
| 242 | 242 | |
| 243 | - while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 244 | - $user_white = $memberHandler->getUser($row['white_uid']); |
|
| 243 | + while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 244 | + $user_white = $memberHandler->getUser($row['white_uid']); |
|
| 245 | 245 | |
| 246 | - $username_white = is_object($user_white) ? $user_white->getVar('uname') : '(open)'; |
|
| 246 | + $username_white = is_object($user_white) ? $user_white->getVar('uname') : '(open)'; |
|
| 247 | 247 | |
| 248 | - $user_black = $memberHandler->getUser($row['black_uid']); |
|
| 248 | + $user_black = $memberHandler->getUser($row['black_uid']); |
|
| 249 | 249 | |
| 250 | - $username_black = is_object($user_black) ? $user_black->getVar('uname') : '(open)'; |
|
| 250 | + $username_black = is_object($user_black) ? $user_black->getVar('uname') : '(open)'; |
|
| 251 | 251 | |
| 252 | - $date = $row['start_date'] ? date('Y.m.d', $row['start_date']) : 'not yet started'; |
|
| 252 | + $date = $row['start_date'] ? date('Y.m.d', $row['start_date']) : 'not yet started'; |
|
| 253 | 253 | |
| 254 | - $title_text = _AM_CHESS_GAME . " #{$row['game_id']} $username_white " . _AM_CHESS_VS . " $username_black ($date)"; |
|
| 254 | + $title_text = _AM_CHESS_GAME . " #{$row['game_id']} $username_white " . _AM_CHESS_VS . " $username_black ($date)"; |
|
| 255 | 255 | |
| 256 | - $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 256 | + $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 257 | 257 | |
| 258 | - $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
|
| 258 | + $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
|
| 259 | 259 | |
| 260 | - $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', 1)); |
|
| 260 | + $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', 1)); |
|
| 261 | 261 | |
| 262 | - $form->display(); |
|
| 263 | - } |
|
| 262 | + $form->display(); |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
|
| 265 | + $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
|
| 266 | 266 | |
| 267 | - echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 268 | - } else { |
|
| 269 | - echo '<h3>' . _AM_CHESS_NO_ACTIVE_GAMES . "</h3>\n"; |
|
| 270 | - } |
|
| 267 | + echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 268 | + } else { |
|
| 269 | + echo '<h3>' . _AM_CHESS_NO_ACTIVE_GAMES . "</h3>\n"; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $xoopsDB->freeRecordSet($result); |
|
| 272 | + $xoopsDB->freeRecordSet($result); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -277,66 +277,66 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | function chess_admin_challenges() |
| 279 | 279 | { |
| 280 | - global $start, $max_items_to_display, $op, $xoopsDB, $xoopsModule; |
|
| 280 | + global $start, $max_items_to_display, $op, $xoopsDB, $xoopsModule; |
|
| 281 | 281 | |
| 282 | - $memberHandler = xoops_getHandler('member'); |
|
| 282 | + $memberHandler = xoops_getHandler('member'); |
|
| 283 | 283 | |
| 284 | - // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator, |
|
| 284 | + // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator, |
|
| 285 | 285 | |
| 286 | - // and one with a limit clause to get the data for display on the current page. |
|
| 286 | + // and one with a limit clause to get the data for display on the current page. |
|
| 287 | 287 | |
| 288 | - // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this. |
|
| 288 | + // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this. |
|
| 289 | 289 | |
| 290 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 290 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 291 | 291 | |
| 292 | - $result = $xoopsDB->query("SELECT COUNT(*) FROM $challenges_table"); |
|
| 292 | + $result = $xoopsDB->query("SELECT COUNT(*) FROM $challenges_table"); |
|
| 293 | 293 | |
| 294 | - [$num_rows] = $xoopsDB->fetchRow($result); |
|
| 294 | + [$num_rows] = $xoopsDB->fetchRow($result); |
|
| 295 | 295 | |
| 296 | - $xoopsDB->freeRecordSet($result); |
|
| 296 | + $xoopsDB->freeRecordSet($result); |
|
| 297 | 297 | |
| 298 | - $result = $xoopsDB->query( |
|
| 299 | - trim( |
|
| 300 | - " |
|
| 298 | + $result = $xoopsDB->query( |
|
| 299 | + trim( |
|
| 300 | + " |
|
| 301 | 301 | SELECT challenge_id, game_type, color_option, player1_uid, player2_uid, UNIX_TIMESTAMP(create_date) AS create_date |
| 302 | 302 | FROM $challenges_table |
| 303 | 303 | ORDER BY create_date DESC |
| 304 | 304 | LIMIT $start, $max_items_to_display |
| 305 | 305 | " |
| 306 | - ) |
|
| 307 | - ); |
|
| 306 | + ) |
|
| 307 | + ); |
|
| 308 | 308 | |
| 309 | - if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 310 | - echo '<h3>' . _AM_CHESS_CHALLENGES . "</h3>\n"; |
|
| 309 | + if ($xoopsDB->getRowsNum($result) > 0) { |
|
| 310 | + echo '<h3>' . _AM_CHESS_CHALLENGES . "</h3>\n"; |
|
| 311 | 311 | |
| 312 | - while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 313 | - $user_player1 = $memberHandler->getUser($row['player1_uid']); |
|
| 312 | + while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
| 313 | + $user_player1 = $memberHandler->getUser($row['player1_uid']); |
|
| 314 | 314 | |
| 315 | - $username_player1 = is_object($user_player1) ? $user_player1->getVar('uname') : '?'; |
|
| 315 | + $username_player1 = is_object($user_player1) ? $user_player1->getVar('uname') : '?'; |
|
| 316 | 316 | |
| 317 | - $user_player2 = $memberHandler->getUser($row['player2_uid']); |
|
| 317 | + $user_player2 = $memberHandler->getUser($row['player2_uid']); |
|
| 318 | 318 | |
| 319 | - $username_player2 = is_object($user_player2) ? $user_player2->getVar('uname') : '(open)'; |
|
| 319 | + $username_player2 = is_object($user_player2) ? $user_player2->getVar('uname') : '(open)'; |
|
| 320 | 320 | |
| 321 | - $date = date('Y.m.d', $row['create_date']); |
|
| 321 | + $date = date('Y.m.d', $row['create_date']); |
|
| 322 | 322 | |
| 323 | - $title_text = _AM_CHESS_CHALLENGE . " #{$row['challenge_id']} $username_player1 " . _AM_CHESS_CHALLENGED . ": $username_player2 (" . _AM_CHESS_CREATED . " $date)"; |
|
| 323 | + $title_text = _AM_CHESS_CHALLENGE . " #{$row['challenge_id']} $username_player1 " . _AM_CHESS_CHALLENGED . ": $username_player2 (" . _AM_CHESS_CREATED . " $date)"; |
|
| 324 | 324 | |
| 325 | - $form = new XoopsThemeForm($title_text, "challenge_{$row['challenge_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/create.php?challenge_id={$row['challenge_id']}", 'post', true); |
|
| 325 | + $form = new XoopsThemeForm($title_text, "challenge_{$row['challenge_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/create.php?challenge_id={$row['challenge_id']}", 'post', true); |
|
| 326 | 326 | |
| 327 | - $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
|
| 327 | + $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
|
| 328 | 328 | |
| 329 | - $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', 1)); |
|
| 329 | + $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', 1)); |
|
| 330 | 330 | |
| 331 | - $form->display(); |
|
| 332 | - } |
|
| 331 | + $form->display(); |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
|
| 334 | + $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
|
| 335 | 335 | |
| 336 | - echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 337 | - } else { |
|
| 338 | - echo '<h3>' . _AM_CHESS_NO_CHALLENGES . "</h3>\n"; |
|
| 339 | - } |
|
| 336 | + echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 337 | + } else { |
|
| 338 | + echo '<h3>' . _AM_CHESS_NO_CHALLENGES . "</h3>\n"; |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - $xoopsDB->freeRecordSet($result); |
|
| 341 | + $xoopsDB->freeRecordSet($result); |
|
| 342 | 342 | } |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | /**#@+ |
| 36 | 36 | */ |
| 37 | -require_once __DIR__ . '/admin_header.php'; |
|
| 38 | -require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
| 39 | -require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
| 40 | -require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php'; |
|
| 37 | +require_once __DIR__.'/admin_header.php'; |
|
| 38 | +require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
| 39 | +require_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
| 40 | +require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php'; |
|
| 41 | 41 | |
| 42 | 42 | // user input |
| 43 | 43 | $op = chess_sanitize(@$_GET['op']); |
| 44 | -$start = (int)@$_GET['start']; // offset of first row of table to display (default to 0) |
|
| 44 | +$start = (int) @$_GET['start']; // offset of first row of table to display (default to 0) |
|
| 45 | 45 | |
| 46 | 46 | // get maximum number of items to display on a page, and constrain it to a reasonable value |
| 47 | 47 | $max_items_to_display = chess_moduleConfig('max_items'); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | global $xoopsModule; |
| 76 | 76 | |
| 77 | 77 | echo ' |
| 78 | - <h4> ' . _AM_CHESS_CONF . ' </h4>' |
|
| 78 | + <h4> ' . _AM_CHESS_CONF.' </h4>' |
|
| 79 | 79 | // <table width='100%' border='0' cellspacing='1' class='outer'> |
| 80 | 80 | // <tr> |
| 81 | 81 | // <td><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/admin/index.php?op=suspended_games'>" . _AM_CHESS_SUSPENDED_GAMES . '</a> |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | 144 | if ($xoopsDB->getRowsNum($result) > 0) { |
| 145 | - echo '<h3>' . _AM_CHESS_SUSPENDED_GAMES . "</h3>\n"; |
|
| 145 | + echo '<h3>'._AM_CHESS_SUSPENDED_GAMES."</h3>\n"; |
|
| 146 | 146 | |
| 147 | 147 | while (false !== ($row = $xoopsDB->fetchArray($result))) { |
| 148 | 148 | $user_white = $memberHandler->getUser($row['white_uid']); |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $date = $row['start_date'] ? date('Y.m.d', $row['start_date']) : 'not yet started'; |
| 157 | 157 | |
| 158 | - $title_text = _AM_CHESS_GAME . " #{$row['game_id']} $username_white " . _AM_CHESS_VS . " $username_black ($date)"; |
|
| 158 | + $title_text = _AM_CHESS_GAME." #{$row['game_id']} $username_white "._AM_CHESS_VS." $username_black ($date)"; |
|
| 159 | 159 | |
| 160 | - $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 160 | + $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 161 | 161 | |
| 162 | 162 | [$date, $suspender_uid, $type, $explain] = explode('|', $row['suspended']); |
| 163 | 163 | |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $suspender_username = is_object($suspender_user) ? $suspender_user->getVar('uname') : _AM_CHESS_UNKNOWN_USER; |
| 179 | 179 | |
| 180 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_WHEN_SUSPENDED . ':', formatTimestamp(strtotime($date)))); |
|
| 180 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_WHEN_SUSPENDED.':', formatTimestamp(strtotime($date)))); |
|
| 181 | 181 | |
| 182 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENDED_BY . ':', $suspender_username)); |
|
| 182 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENDED_BY.':', $suspender_username)); |
|
| 183 | 183 | |
| 184 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_TYPE . ':', $type_display)); |
|
| 184 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_TYPE.':', $type_display)); |
|
| 185 | 185 | |
| 186 | - $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_REASON . ':', $explain)); |
|
| 186 | + $form->addElement(new XoopsFormLabel(_AM_CHESS_SUSPENSION_REASON.':', $explain)); |
|
| 187 | 187 | |
| 188 | 188 | $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
| 189 | 189 | |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
| 196 | 196 | |
| 197 | - echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 197 | + echo '<div align="center">'.$pagenav->renderNav()." </div>\n"; |
|
| 198 | 198 | } else { |
| 199 | - echo '<h3>' . _AM_CHESS_NO_SUSPENDED_GAMES . "</h3>\n"; |
|
| 199 | + echo '<h3>'._AM_CHESS_NO_SUSPENDED_GAMES."</h3>\n"; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $xoopsDB->freeRecordSet($result); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | if ($xoopsDB->getRowsNum($result) > 0) { |
| 241 | - echo '<h3>' . _AM_CHESS_ACTIVE_GAMES . "</h3>\n"; |
|
| 241 | + echo '<h3>'._AM_CHESS_ACTIVE_GAMES."</h3>\n"; |
|
| 242 | 242 | |
| 243 | 243 | while (false !== ($row = $xoopsDB->fetchArray($result))) { |
| 244 | 244 | $user_white = $memberHandler->getUser($row['white_uid']); |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | $date = $row['start_date'] ? date('Y.m.d', $row['start_date']) : 'not yet started'; |
| 253 | 253 | |
| 254 | - $title_text = _AM_CHESS_GAME . " #{$row['game_id']} $username_white " . _AM_CHESS_VS . " $username_black ($date)"; |
|
| 254 | + $title_text = _AM_CHESS_GAME." #{$row['game_id']} $username_white "._AM_CHESS_VS." $username_black ($date)"; |
|
| 255 | 255 | |
| 256 | - $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 256 | + $form = new XoopsThemeForm($title_text, "game_{$row['game_id']}", XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/game.php?game_id={$row['game_id']}", 'post', true); |
|
| 257 | 257 | |
| 258 | 258 | $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
| 259 | 259 | |
@@ -264,9 +264,9 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
| 266 | 266 | |
| 267 | - echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 267 | + echo '<div align="center">'.$pagenav->renderNav()." </div>\n"; |
|
| 268 | 268 | } else { |
| 269 | - echo '<h3>' . _AM_CHESS_NO_ACTIVE_GAMES . "</h3>\n"; |
|
| 269 | + echo '<h3>'._AM_CHESS_NO_ACTIVE_GAMES."</h3>\n"; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | $xoopsDB->freeRecordSet($result); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | ); |
| 308 | 308 | |
| 309 | 309 | if ($xoopsDB->getRowsNum($result) > 0) { |
| 310 | - echo '<h3>' . _AM_CHESS_CHALLENGES . "</h3>\n"; |
|
| 310 | + echo '<h3>'._AM_CHESS_CHALLENGES."</h3>\n"; |
|
| 311 | 311 | |
| 312 | 312 | while (false !== ($row = $xoopsDB->fetchArray($result))) { |
| 313 | 313 | $user_player1 = $memberHandler->getUser($row['player1_uid']); |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | $date = date('Y.m.d', $row['create_date']); |
| 322 | 322 | |
| 323 | - $title_text = _AM_CHESS_CHALLENGE . " #{$row['challenge_id']} $username_player1 " . _AM_CHESS_CHALLENGED . ": $username_player2 (" . _AM_CHESS_CREATED . " $date)"; |
|
| 323 | + $title_text = _AM_CHESS_CHALLENGE." #{$row['challenge_id']} $username_player1 "._AM_CHESS_CHALLENGED.": $username_player2 ("._AM_CHESS_CREATED." $date)"; |
|
| 324 | 324 | |
| 325 | - $form = new XoopsThemeForm($title_text, "challenge_{$row['challenge_id']}", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/create.php?challenge_id={$row['challenge_id']}", 'post', true); |
|
| 325 | + $form = new XoopsThemeForm($title_text, "challenge_{$row['challenge_id']}", XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/create.php?challenge_id={$row['challenge_id']}", 'post', true); |
|
| 326 | 326 | |
| 327 | 327 | $form->addElement(new XoopsFormButton('', 'submit', _AM_CHESS_ARBITRATE_SUBMIT, 'submit')); |
| 328 | 328 | |
@@ -333,9 +333,9 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $pagenav = new XoopsPageNav($num_rows, $max_items_to_display, $start, 'start', "op=$op"); |
| 335 | 335 | |
| 336 | - echo '<div align="center">' . $pagenav->renderNav() . " </div>\n"; |
|
| 336 | + echo '<div align="center">'.$pagenav->renderNav()." </div>\n"; |
|
| 337 | 337 | } else { |
| 338 | - echo '<h3>' . _AM_CHESS_NO_CHALLENGES . "</h3>\n"; |
|
| 338 | + echo '<h3>'._AM_CHESS_NO_CHALLENGES."</h3>\n"; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | $xoopsDB->freeRecordSet($result); |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | $pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); |
| 21 | 21 | |
| 22 | -echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '</div>'; |
|
| 22 | +echo "<div class='adminfooter'>\n"." <div style='text-align: center;'>\n"." <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n"." </div>\n".' '._AM_MODULEADMIN_ADMIN_FOOTER."\n".'</div>'; |
|
| 23 | 23 | |
| 24 | 24 | xoops_cp_footer(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | #var_dump($_REQUEST);#*#DEBUG# |
| 57 | 57 | |
| 58 | 58 | if (!chess_can_play()) { |
| 59 | - redirect_header(XOOPS_URL . '/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 59 | + redirect_header(XOOPS_URL . '/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // user input |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | // If form-submit, check security token. |
| 89 | 89 | if (($submit_challenge1 || $submit_challenge2 || $submit_challenge3 || $submit_accept || $submit_delete || $show_arbiter_ctrl) && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) { |
| 90 | - redirect_header( |
|
| 91 | - XOOPS_URL . '/modules/chess/', |
|
| 92 | - _CHESS_REDIRECT_DELAY_FAILURE, |
|
| 93 | - _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
|
| 94 | - ); |
|
| 90 | + redirect_header( |
|
| 91 | + XOOPS_URL . '/modules/chess/', |
|
| 92 | + _CHESS_REDIRECT_DELAY_FAILURE, |
|
| 93 | + _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
|
| 94 | + ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // If rating feature disabled, force ratings to off. |
| 98 | 98 | if ('none' == chess_moduleConfig('rating_system')) { |
| 99 | - $rated = 0; |
|
| 99 | + $rated = 0; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
@@ -105,87 +105,87 @@ discard block |
||
| 105 | 105 | $is_arbiter = is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid')); |
| 106 | 106 | |
| 107 | 107 | if ($cancel_challenge1) { |
| 108 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 108 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 109 | 109 | } elseif ($cancel_challenge2) { |
| 110 | - chess_show_create_form1($gametype); |
|
| 110 | + chess_show_create_form1($gametype); |
|
| 111 | 111 | } elseif ($cancel_challenge3) { |
| 112 | - if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 113 | - chess_show_create_form2($gametype, $fen); |
|
| 114 | - } else { |
|
| 115 | - chess_show_create_form1($gametype, $fen); |
|
| 116 | - } |
|
| 112 | + if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 113 | + chess_show_create_form2($gametype, $fen); |
|
| 114 | + } else { |
|
| 115 | + chess_show_create_form1($gametype, $fen); |
|
| 116 | + } |
|
| 117 | 117 | } elseif ($cancel_accept) { |
| 118 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 118 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 119 | 119 | } elseif ($submit_challenge1) { |
| 120 | - $fen_error = chess_fen_error($fen); |
|
| 121 | - |
|
| 122 | - if (!empty($fen_error)) { |
|
| 123 | - chess_show_create_form1($gametype, $fen, _MD_CHESS_FEN_INVALID . ': ' . $fen_error); |
|
| 124 | - } elseif (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 125 | - chess_show_create_form2($gametype, $fen); |
|
| 126 | - } else { |
|
| 127 | - chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated); |
|
| 128 | - } |
|
| 120 | + $fen_error = chess_fen_error($fen); |
|
| 121 | + |
|
| 122 | + if (!empty($fen_error)) { |
|
| 123 | + chess_show_create_form1($gametype, $fen, _MD_CHESS_FEN_INVALID . ': ' . $fen_error); |
|
| 124 | + } elseif (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 125 | + chess_show_create_form2($gametype, $fen); |
|
| 126 | + } else { |
|
| 127 | + chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated); |
|
| 128 | + } |
|
| 129 | 129 | } elseif ($submit_challenge2) { |
| 130 | - if (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 131 | - if (empty($opponent)) { |
|
| 132 | - chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_MISSING); |
|
| 133 | - } elseif (!$opponent_uid) { |
|
| 134 | - chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_INVALID); |
|
| 135 | - } elseif ($opponent_uid == $uid) { |
|
| 136 | - chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_SELF); |
|
| 137 | - } else { |
|
| 138 | - chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated); |
|
| 139 | - } |
|
| 140 | - } else { |
|
| 141 | - chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated); |
|
| 142 | - } |
|
| 130 | + if (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 131 | + if (empty($opponent)) { |
|
| 132 | + chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_MISSING); |
|
| 133 | + } elseif (!$opponent_uid) { |
|
| 134 | + chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_INVALID); |
|
| 135 | + } elseif ($opponent_uid == $uid) { |
|
| 136 | + chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_SELF); |
|
| 137 | + } else { |
|
| 138 | + chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated); |
|
| 139 | + } |
|
| 140 | + } else { |
|
| 141 | + chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated); |
|
| 142 | + } |
|
| 143 | 143 | } elseif ($submit_challenge3) { |
| 144 | - if (_CHESS_GAMETYPE_OPEN == $gametype) { |
|
| 145 | - chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move); |
|
| 146 | - |
|
| 147 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 148 | - } elseif (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 149 | - if (empty($opponent)) { |
|
| 150 | - chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_MISSING); |
|
| 151 | - } elseif (!$opponent_uid) { |
|
| 152 | - chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_INVALID); |
|
| 153 | - } elseif ($opponent_uid == $uid) { |
|
| 154 | - chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_SELF); |
|
| 155 | - } else { |
|
| 156 | - chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move, $opponent_uid); |
|
| 157 | - |
|
| 158 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 159 | - } |
|
| 160 | - } elseif (_CHESS_GAMETYPE_SELF == $gametype) { |
|
| 161 | - $game_id = chess_create_game($uid, $uid, $fen, $rated); |
|
| 162 | - |
|
| 163 | - redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 164 | - } else { |
|
| 165 | - chess_show_create_form1($gametype, $fen, _MD_CHESS_GAMETYPE_INVALID); |
|
| 166 | - } |
|
| 144 | + if (_CHESS_GAMETYPE_OPEN == $gametype) { |
|
| 145 | + chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move); |
|
| 146 | + |
|
| 147 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 148 | + } elseif (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 149 | + if (empty($opponent)) { |
|
| 150 | + chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_MISSING); |
|
| 151 | + } elseif (!$opponent_uid) { |
|
| 152 | + chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_INVALID); |
|
| 153 | + } elseif ($opponent_uid == $uid) { |
|
| 154 | + chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_SELF); |
|
| 155 | + } else { |
|
| 156 | + chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move, $opponent_uid); |
|
| 157 | + |
|
| 158 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 159 | + } |
|
| 160 | + } elseif (_CHESS_GAMETYPE_SELF == $gametype) { |
|
| 161 | + $game_id = chess_create_game($uid, $uid, $fen, $rated); |
|
| 162 | + |
|
| 163 | + redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 164 | + } else { |
|
| 165 | + chess_show_create_form1($gametype, $fen, _MD_CHESS_GAMETYPE_INVALID); |
|
| 166 | + } |
|
| 167 | 167 | } elseif ($submit_accept) { |
| 168 | - chess_accept_challenge($challenge_id, $coloroption, $notify_move); |
|
| 168 | + chess_accept_challenge($challenge_id, $coloroption, $notify_move); |
|
| 169 | 169 | } elseif ($submit_delete) { |
| 170 | - if ($confirm_delete) { |
|
| 171 | - if ($is_arbiter || chess_is_challenger($challenge_id)) { |
|
| 172 | - chess_delete_challenge($challenge_id); |
|
| 173 | - |
|
| 174 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED); |
|
| 175 | - } else { |
|
| 176 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 177 | - } |
|
| 178 | - } else { |
|
| 179 | - chess_show_delete_form($challenge_id, $show_arbiter_ctrl && $is_arbiter, _MD_CHESS_NO_CONFIRM_DELETE); |
|
| 180 | - } |
|
| 170 | + if ($confirm_delete) { |
|
| 171 | + if ($is_arbiter || chess_is_challenger($challenge_id)) { |
|
| 172 | + chess_delete_challenge($challenge_id); |
|
| 173 | + |
|
| 174 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED); |
|
| 175 | + } else { |
|
| 176 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 177 | + } |
|
| 178 | + } else { |
|
| 179 | + chess_show_delete_form($challenge_id, $show_arbiter_ctrl && $is_arbiter, _MD_CHESS_NO_CONFIRM_DELETE); |
|
| 180 | + } |
|
| 181 | 181 | } elseif ($challenge_id) { |
| 182 | - if (($show_arbiter_ctrl && $is_arbiter) || chess_is_challenger($challenge_id)) { |
|
| 183 | - chess_show_delete_form($challenge_id, $show_arbiter_ctrl && $is_arbiter); |
|
| 184 | - } else { |
|
| 185 | - chess_show_accept_form($challenge_id); |
|
| 186 | - } |
|
| 182 | + if (($show_arbiter_ctrl && $is_arbiter) || chess_is_challenger($challenge_id)) { |
|
| 183 | + chess_show_delete_form($challenge_id, $show_arbiter_ctrl && $is_arbiter); |
|
| 184 | + } else { |
|
| 185 | + chess_show_accept_form($challenge_id); |
|
| 186 | + } |
|
| 187 | 187 | } else { |
| 188 | - chess_show_create_form1($gametype); |
|
| 188 | + chess_show_create_form1($gametype); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
@@ -200,41 +200,41 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function chess_show_create_form1($gametype = _CHESS_GAMETYPE_OPEN, $fen = '', $error_msg = '') |
| 202 | 202 | { |
| 203 | - $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form1', 'create.php', 'post', true); |
|
| 203 | + $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form1', 'create.php', 'post', true); |
|
| 204 | 204 | |
| 205 | - if ($error_msg) { |
|
| 206 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 207 | - } |
|
| 205 | + if ($error_msg) { |
|
| 206 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - $menu_gametype = new XoopsFormSelect(_MD_CHESS_LABEL_GAMETYPE . ':', 'gametype', $gametype, 1, false); |
|
| 209 | + $menu_gametype = new XoopsFormSelect(_MD_CHESS_LABEL_GAMETYPE . ':', 'gametype', $gametype, 1, false); |
|
| 210 | 210 | |
| 211 | - $menu_gametype->addOption(_CHESS_GAMETYPE_OPEN, _MD_CHESS_MENU_GAMETYPE_OPEN); |
|
| 211 | + $menu_gametype->addOption(_CHESS_GAMETYPE_OPEN, _MD_CHESS_MENU_GAMETYPE_OPEN); |
|
| 212 | 212 | |
| 213 | - $menu_gametype->addOption(_CHESS_GAMETYPE_USER, _MD_CHESS_MENU_GAMETYPE_USER); |
|
| 213 | + $menu_gametype->addOption(_CHESS_GAMETYPE_USER, _MD_CHESS_MENU_GAMETYPE_USER); |
|
| 214 | 214 | |
| 215 | - $menu_gametype->addOption(_CHESS_GAMETYPE_SELF, _MD_CHESS_MENU_GAMETYPE_SELF); |
|
| 215 | + $menu_gametype->addOption(_CHESS_GAMETYPE_SELF, _MD_CHESS_MENU_GAMETYPE_SELF); |
|
| 216 | 216 | |
| 217 | - $form->addElement($menu_gametype); |
|
| 217 | + $form->addElement($menu_gametype); |
|
| 218 | 218 | |
| 219 | - if (chess_moduleConfig('allow_setup')) { |
|
| 220 | - $form->addElement(new XoopsFormLabel('', ' ')); |
|
| 219 | + if (chess_moduleConfig('allow_setup')) { |
|
| 220 | + $form->addElement(new XoopsFormLabel('', ' ')); |
|
| 221 | 221 | |
| 222 | - $form->addElement(new XoopsFormLabel('', _MD_CHESS_LABEL_FEN_EXPLAIN)); |
|
| 222 | + $form->addElement(new XoopsFormLabel('', _MD_CHESS_LABEL_FEN_EXPLAIN)); |
|
| 223 | 223 | |
| 224 | - $form->addElement(new XoopsFormText(_MD_CHESS_LABEL_FEN_SETUP . ':', 'fen', 80, _CHESS_TEXTBOX_FEN_MAXLEN, $fen)); |
|
| 225 | - } |
|
| 224 | + $form->addElement(new XoopsFormText(_MD_CHESS_LABEL_FEN_SETUP . ':', 'fen', 80, _CHESS_TEXTBOX_FEN_MAXLEN, $fen)); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - $form->addElement(new XoopsFormLabel(' ', ' ')); |
|
| 227 | + $form->addElement(new XoopsFormLabel(' ', ' ')); |
|
| 228 | 228 | |
| 229 | - $buttons = new XoopsFormElementTray(''); |
|
| 229 | + $buttons = new XoopsFormElementTray(''); |
|
| 230 | 230 | |
| 231 | - $buttons->addElement(new XoopsFormButton('', 'submit_challenge1', _MD_CHESS_CREATE_SUBMIT, 'submit')); |
|
| 231 | + $buttons->addElement(new XoopsFormButton('', 'submit_challenge1', _MD_CHESS_CREATE_SUBMIT, 'submit')); |
|
| 232 | 232 | |
| 233 | - $buttons->addElement(new XoopsFormButton('', 'cancel_challenge1', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 233 | + $buttons->addElement(new XoopsFormButton('', 'cancel_challenge1', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 234 | 234 | |
| 235 | - $form->addElement($buttons); |
|
| 235 | + $form->addElement($buttons); |
|
| 236 | 236 | |
| 237 | - $form->display(); |
|
| 237 | + $form->display(); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -249,69 +249,69 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function chess_show_create_form2($gametype, $fen, $coloroption = _CHESS_COLOROPTION_OPPONENT, $opponent_uid = 0, $rated = 1, $error_msg = '') |
| 251 | 251 | { |
| 252 | - $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form2', 'create.php', 'post', true); |
|
| 252 | + $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form2', 'create.php', 'post', true); |
|
| 253 | 253 | |
| 254 | - $form->addElement(new XoopsFormHidden('gametype', $gametype)); |
|
| 254 | + $form->addElement(new XoopsFormHidden('gametype', $gametype)); |
|
| 255 | 255 | |
| 256 | - $form->addElement(new XoopsFormHidden('fen', $fen)); |
|
| 256 | + $form->addElement(new XoopsFormHidden('fen', $fen)); |
|
| 257 | 257 | |
| 258 | - if ($error_msg) { |
|
| 259 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ':', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 260 | - } |
|
| 258 | + if ($error_msg) { |
|
| 259 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ':', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $memberHandler = xoops_getHandler('member'); |
|
| 262 | + $memberHandler = xoops_getHandler('member'); |
|
| 263 | 263 | |
| 264 | - $opponent_user = $memberHandler->getUser($opponent_uid); |
|
| 264 | + $opponent_user = $memberHandler->getUser($opponent_uid); |
|
| 265 | 265 | |
| 266 | - $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
|
| 266 | + $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
|
| 267 | 267 | |
| 268 | - if (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 269 | - $form->addElement( |
|
| 270 | - new XoopsFormText( |
|
| 271 | - _MD_CHESS_LABEL_OPPONENT . ':', 'opponent', _CHESS_TEXTBOX_OPPONENT_SIZE, _CHESS_TEXTBOX_OPPONENT_MAXLEN, $opponent_username |
|
| 272 | - ) |
|
| 273 | - ); |
|
| 274 | - } |
|
| 268 | + if (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 269 | + $form->addElement( |
|
| 270 | + new XoopsFormText( |
|
| 271 | + _MD_CHESS_LABEL_OPPONENT . ':', 'opponent', _CHESS_TEXTBOX_OPPONENT_SIZE, _CHESS_TEXTBOX_OPPONENT_MAXLEN, $opponent_username |
|
| 272 | + ) |
|
| 273 | + ); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', $coloroption); |
|
| 276 | + $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', $coloroption); |
|
| 277 | 277 | |
| 278 | - $radio_color->addOption(_CHESS_COLOROPTION_OPPONENT, _MD_CHESS_RADIO_COLOR_OPPONENT); |
|
| 278 | + $radio_color->addOption(_CHESS_COLOROPTION_OPPONENT, _MD_CHESS_RADIO_COLOR_OPPONENT); |
|
| 279 | 279 | |
| 280 | - $radio_color->addOption(_CHESS_COLOROPTION_RANDOM, _MD_CHESS_RADIO_COLOR_RANDOM); |
|
| 280 | + $radio_color->addOption(_CHESS_COLOROPTION_RANDOM, _MD_CHESS_RADIO_COLOR_RANDOM); |
|
| 281 | 281 | |
| 282 | - $radio_color->addOption(_CHESS_COLOROPTION_WHITE, _MD_CHESS_RADIO_COLOR_WHITE); |
|
| 282 | + $radio_color->addOption(_CHESS_COLOROPTION_WHITE, _MD_CHESS_RADIO_COLOR_WHITE); |
|
| 283 | 283 | |
| 284 | - $radio_color->addOption(_CHESS_COLOROPTION_BLACK, _MD_CHESS_RADIO_COLOR_BLACK); |
|
| 284 | + $radio_color->addOption(_CHESS_COLOROPTION_BLACK, _MD_CHESS_RADIO_COLOR_BLACK); |
|
| 285 | 285 | |
| 286 | - $form->addElement($radio_color); |
|
| 286 | + $form->addElement($radio_color); |
|
| 287 | 287 | |
| 288 | - if ('none' !== chess_moduleConfig('rating_system')) { |
|
| 289 | - if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 290 | - if (chess_moduleConfig('allow_unrated_games')) { |
|
| 291 | - $radio_rated = new XoopsFormRadio(_MD_CHESS_RATED_GAME . ':', 'rated', $rated); |
|
| 288 | + if ('none' !== chess_moduleConfig('rating_system')) { |
|
| 289 | + if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 290 | + if (chess_moduleConfig('allow_unrated_games')) { |
|
| 291 | + $radio_rated = new XoopsFormRadio(_MD_CHESS_RATED_GAME . ':', 'rated', $rated); |
|
| 292 | 292 | |
| 293 | - $radio_rated->addOption(1, _YES); |
|
| 293 | + $radio_rated->addOption(1, _YES); |
|
| 294 | 294 | |
| 295 | - $radio_rated->addOption(0, _NO); |
|
| 295 | + $radio_rated->addOption(0, _NO); |
|
| 296 | 296 | |
| 297 | - $form->addElement($radio_rated); |
|
| 298 | - } else { |
|
| 299 | - $form->addElement(new XoopsFormHidden('rated', $rated)); |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - } else { |
|
| 303 | - $form->addElement(new XoopsFormHidden('rated', 0)); |
|
| 304 | - } |
|
| 297 | + $form->addElement($radio_rated); |
|
| 298 | + } else { |
|
| 299 | + $form->addElement(new XoopsFormHidden('rated', $rated)); |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + } else { |
|
| 303 | + $form->addElement(new XoopsFormHidden('rated', 0)); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - $buttons = new XoopsFormElementTray(''); |
|
| 306 | + $buttons = new XoopsFormElementTray(''); |
|
| 307 | 307 | |
| 308 | - $buttons->addElement(new XoopsFormButton('', 'submit_challenge2', _MD_CHESS_CREATE_SUBMIT, 'submit')); |
|
| 308 | + $buttons->addElement(new XoopsFormButton('', 'submit_challenge2', _MD_CHESS_CREATE_SUBMIT, 'submit')); |
|
| 309 | 309 | |
| 310 | - $buttons->addElement(new XoopsFormButton('', 'cancel_challenge2', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 310 | + $buttons->addElement(new XoopsFormButton('', 'cancel_challenge2', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 311 | 311 | |
| 312 | - $form->addElement($buttons); |
|
| 312 | + $form->addElement($buttons); |
|
| 313 | 313 | |
| 314 | - $form->display(); |
|
| 314 | + $form->display(); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -325,124 +325,124 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | function chess_show_create_form3($gametype, $fen, $coloroption, $opponent_uid, $rated) |
| 327 | 327 | { |
| 328 | - $memberHandler = xoops_getHandler('member'); |
|
| 328 | + $memberHandler = xoops_getHandler('member'); |
|
| 329 | 329 | |
| 330 | - $opponent_user = $memberHandler->getUser($opponent_uid); |
|
| 330 | + $opponent_user = $memberHandler->getUser($opponent_uid); |
|
| 331 | 331 | |
| 332 | - $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
|
| 332 | + $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
|
| 333 | 333 | |
| 334 | - $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form3', 'create.php', 'post', true); |
|
| 334 | + $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form3', 'create.php', 'post', true); |
|
| 335 | 335 | |
| 336 | - $form->addElement(new XoopsFormHidden('gametype', $gametype)); |
|
| 336 | + $form->addElement(new XoopsFormHidden('gametype', $gametype)); |
|
| 337 | 337 | |
| 338 | - $form->addElement(new XoopsFormHidden('fen', $fen)); |
|
| 338 | + $form->addElement(new XoopsFormHidden('fen', $fen)); |
|
| 339 | 339 | |
| 340 | - $form->addElement(new XoopsFormHidden('opponent', $opponent_username)); |
|
| 340 | + $form->addElement(new XoopsFormHidden('opponent', $opponent_username)); |
|
| 341 | 341 | |
| 342 | - $form->addElement(new XoopsFormHidden('coloroption', $coloroption)); |
|
| 342 | + $form->addElement(new XoopsFormHidden('coloroption', $coloroption)); |
|
| 343 | 343 | |
| 344 | - $form->addElement(new XoopsFormHidden('rated', $rated)); |
|
| 344 | + $form->addElement(new XoopsFormHidden('rated', $rated)); |
|
| 345 | 345 | |
| 346 | - $form->addElement(new XoopsFormLabel('', '<div class="confirmMsg">' . _MD_CHESS_GAME_CONFIRM . '</div>')); |
|
| 346 | + $form->addElement(new XoopsFormLabel('', '<div class="confirmMsg">' . _MD_CHESS_GAME_CONFIRM . '</div>')); |
|
| 347 | 347 | |
| 348 | - switch ($gametype) { |
|
| 349 | - case _CHESS_GAMETYPE_OPEN: |
|
| 350 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_OPEN; |
|
| 351 | - break; |
|
| 352 | - case _CHESS_GAMETYPE_USER: |
|
| 353 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER; |
|
| 354 | - break; |
|
| 355 | - case _CHESS_GAMETYPE_SELF: |
|
| 356 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
|
| 357 | - break; |
|
| 358 | - default: |
|
| 359 | - $label_gametype = _MD_CHESS_LABEL_ERROR; |
|
| 360 | - break; |
|
| 361 | - } |
|
| 348 | + switch ($gametype) { |
|
| 349 | + case _CHESS_GAMETYPE_OPEN: |
|
| 350 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_OPEN; |
|
| 351 | + break; |
|
| 352 | + case _CHESS_GAMETYPE_USER: |
|
| 353 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER; |
|
| 354 | + break; |
|
| 355 | + case _CHESS_GAMETYPE_SELF: |
|
| 356 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
|
| 357 | + break; |
|
| 358 | + default: |
|
| 359 | + $label_gametype = _MD_CHESS_LABEL_ERROR; |
|
| 360 | + break; |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 363 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 364 | 364 | |
| 365 | - if (!empty($fen)) { |
|
| 366 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $fen)); |
|
| 367 | - } |
|
| 365 | + if (!empty($fen)) { |
|
| 366 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $fen)); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - if (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 370 | - $memberHandler = xoops_getHandler('member'); |
|
| 369 | + if (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 370 | + $memberHandler = xoops_getHandler('member'); |
|
| 371 | 371 | |
| 372 | - $opponent_user = $memberHandler->getUser($opponent_uid); |
|
| 372 | + $opponent_user = $memberHandler->getUser($opponent_uid); |
|
| 373 | 373 | |
| 374 | - $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
|
| 374 | + $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
|
| 375 | 375 | |
| 376 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $opponent_username)); |
|
| 377 | - } |
|
| 376 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $opponent_username)); |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 380 | - switch ($coloroption) { |
|
| 381 | - case _CHESS_COLOROPTION_OPPONENT: |
|
| 382 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_OPPONENT; |
|
| 383 | - break; |
|
| 384 | - case _CHESS_COLOROPTION_RANDOM: |
|
| 385 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_RANDOM; |
|
| 386 | - break; |
|
| 387 | - case _CHESS_COLOROPTION_WHITE: |
|
| 388 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_WHITE; |
|
| 389 | - break; |
|
| 390 | - case _CHESS_COLOROPTION_BLACK: |
|
| 391 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_BLACK; |
|
| 392 | - break; |
|
| 393 | - default: |
|
| 394 | - $label_coloroption = _MD_CHESS_LABEL_ERROR; |
|
| 395 | - break; |
|
| 396 | - } |
|
| 379 | + if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
|
| 380 | + switch ($coloroption) { |
|
| 381 | + case _CHESS_COLOROPTION_OPPONENT: |
|
| 382 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_OPPONENT; |
|
| 383 | + break; |
|
| 384 | + case _CHESS_COLOROPTION_RANDOM: |
|
| 385 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_RANDOM; |
|
| 386 | + break; |
|
| 387 | + case _CHESS_COLOROPTION_WHITE: |
|
| 388 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_WHITE; |
|
| 389 | + break; |
|
| 390 | + case _CHESS_COLOROPTION_BLACK: |
|
| 391 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_BLACK; |
|
| 392 | + break; |
|
| 393 | + default: |
|
| 394 | + $label_coloroption = _MD_CHESS_LABEL_ERROR; |
|
| 395 | + break; |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 398 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 399 | 399 | |
| 400 | - if ('none' != chess_moduleConfig('rating_system')) { |
|
| 401 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $rated ? _YES : _NO)); |
|
| 402 | - } |
|
| 400 | + if ('none' != chess_moduleConfig('rating_system')) { |
|
| 401 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $rated ? _YES : _NO)); |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - // Determine whether current user is subscribed to receive a notification when his challenge is accepted. |
|
| 404 | + // Determine whether current user is subscribed to receive a notification when his challenge is accepted. |
|
| 405 | 405 | |
| 406 | - global $xoopsModule, $xoopsUser; |
|
| 406 | + global $xoopsModule, $xoopsUser; |
|
| 407 | 407 | |
| 408 | - $uid = $xoopsUser->getVar('uid'); |
|
| 408 | + $uid = $xoopsUser->getVar('uid'); |
|
| 409 | 409 | |
| 410 | - $mid = $xoopsModule->getVar('mid'); |
|
| 410 | + $mid = $xoopsModule->getVar('mid'); |
|
| 411 | 411 | |
| 412 | - $notificationHandler = xoops_getHandler('notification'); |
|
| 412 | + $notificationHandler = xoops_getHandler('notification'); |
|
| 413 | 413 | |
| 414 | - $is_subscribed = 0 != $notificationHandler->isSubscribed('global', 0, 'notify_accept_challenge', $mid, $uid); |
|
| 414 | + $is_subscribed = 0 != $notificationHandler->isSubscribed('global', 0, 'notify_accept_challenge', $mid, $uid); |
|
| 415 | 415 | |
| 416 | - // Display checkbox with checked-state reflecting subscription status. |
|
| 416 | + // Display checkbox with checked-state reflecting subscription status. |
|
| 417 | 417 | |
| 418 | - $checked_value = 1; |
|
| 418 | + $checked_value = 1; |
|
| 419 | 419 | |
| 420 | - $checkbox_notify_acpt_chal = new XoopsFormCheckBox('', 'notify_accept', $is_subscribed ? $checked_value : null); |
|
| 420 | + $checkbox_notify_acpt_chal = new XoopsFormCheckBox('', 'notify_accept', $is_subscribed ? $checked_value : null); |
|
| 421 | 421 | |
| 422 | - $checkbox_notify_acpt_chal->addOption($checked_value, _MD_CHESS_NEVT_ACPT_CHAL_CAP); |
|
| 422 | + $checkbox_notify_acpt_chal->addOption($checked_value, _MD_CHESS_NEVT_ACPT_CHAL_CAP); |
|
| 423 | 423 | |
| 424 | - $form->addElement($checkbox_notify_acpt_chal); |
|
| 424 | + $form->addElement($checkbox_notify_acpt_chal); |
|
| 425 | 425 | |
| 426 | - // Display checkbox, initially checked. |
|
| 426 | + // Display checkbox, initially checked. |
|
| 427 | 427 | |
| 428 | - $checked_value = 1; |
|
| 428 | + $checked_value = 1; |
|
| 429 | 429 | |
| 430 | - $checkbox_notify_move = new XoopsFormCheckBox('', 'notify_move', $checked_value); |
|
| 430 | + $checkbox_notify_move = new XoopsFormCheckBox('', 'notify_move', $checked_value); |
|
| 431 | 431 | |
| 432 | - $checkbox_notify_move->addOption($checked_value, _MD_CHESS_NEVT_MOVE_CAP); |
|
| 432 | + $checkbox_notify_move->addOption($checked_value, _MD_CHESS_NEVT_MOVE_CAP); |
|
| 433 | 433 | |
| 434 | - $form->addElement($checkbox_notify_move); |
|
| 435 | - } |
|
| 434 | + $form->addElement($checkbox_notify_move); |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | - $buttons = new XoopsFormElementTray(''); |
|
| 437 | + $buttons = new XoopsFormElementTray(''); |
|
| 438 | 438 | |
| 439 | - $buttons->addElement(new XoopsFormButton('', 'submit_challenge3', _MD_CHESS_CREATE_SUBMIT, 'submit')); |
|
| 439 | + $buttons->addElement(new XoopsFormButton('', 'submit_challenge3', _MD_CHESS_CREATE_SUBMIT, 'submit')); |
|
| 440 | 440 | |
| 441 | - $buttons->addElement(new XoopsFormButton('', 'cancel_challenge3', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 441 | + $buttons->addElement(new XoopsFormButton('', 'cancel_challenge3', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 442 | 442 | |
| 443 | - $form->addElement($buttons); |
|
| 443 | + $form->addElement($buttons); |
|
| 444 | 444 | |
| 445 | - $form->display(); |
|
| 445 | + $form->display(); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -452,125 +452,125 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | function chess_show_accept_form($challenge_id) |
| 454 | 454 | { |
| 455 | - global $xoopsDB, $xoopsUser; |
|
| 455 | + global $xoopsDB, $xoopsUser; |
|
| 456 | 456 | |
| 457 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 457 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 458 | 458 | |
| 459 | - $result = $xoopsDB->query( |
|
| 460 | - trim( |
|
| 461 | - " |
|
| 459 | + $result = $xoopsDB->query( |
|
| 460 | + trim( |
|
| 461 | + " |
|
| 462 | 462 | SELECT game_type, fen, color_option, player1_uid, player2_uid, UNIX_TIMESTAMP(create_date) as create_date, is_rated |
| 463 | 463 | FROM $challenges_table |
| 464 | 464 | WHERE challenge_id = '$challenge_id' |
| 465 | 465 | " |
| 466 | - ) |
|
| 467 | - ); |
|
| 466 | + ) |
|
| 467 | + ); |
|
| 468 | 468 | |
| 469 | - if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 470 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 471 | - } |
|
| 469 | + if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 470 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | - $row = $xoopsDB->fetchArray($result); |
|
| 473 | + $row = $xoopsDB->fetchArray($result); |
|
| 474 | 474 | |
| 475 | - $xoopsDB->freeRecordSet($result); |
|
| 475 | + $xoopsDB->freeRecordSet($result); |
|
| 476 | 476 | |
| 477 | - $form = new XoopsThemeForm(_MD_CHESS_ACCEPT_FORM, 'accept_form', 'create.php', 'post', true); |
|
| 477 | + $form = new XoopsThemeForm(_MD_CHESS_ACCEPT_FORM, 'accept_form', 'create.php', 'post', true); |
|
| 478 | 478 | |
| 479 | - $form->addElement(new XoopsFormHidden('challenge_id', $challenge_id)); |
|
| 479 | + $form->addElement(new XoopsFormHidden('challenge_id', $challenge_id)); |
|
| 480 | 480 | |
| 481 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm'))); |
|
| 481 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm'))); |
|
| 482 | 482 | |
| 483 | - $memberHandler = xoops_getHandler('member'); |
|
| 483 | + $memberHandler = xoops_getHandler('member'); |
|
| 484 | 484 | |
| 485 | - switch ($row['game_type']) { |
|
| 486 | - case _CHESS_GAMETYPE_OPEN: |
|
| 487 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_OPEN; |
|
| 488 | - break; |
|
| 489 | - case _CHESS_GAMETYPE_USER: |
|
| 490 | - $player2_user = $memberHandler->getUser($row['player2_uid']); |
|
| 491 | - $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?'; |
|
| 492 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username; |
|
| 493 | - break; |
|
| 494 | - case _CHESS_GAMETYPE_SELF: |
|
| 495 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
|
| 496 | - break; |
|
| 497 | - default: |
|
| 498 | - $label_gametype = _MD_CHESS_LABEL_ERROR; |
|
| 499 | - break; |
|
| 500 | - } |
|
| 485 | + switch ($row['game_type']) { |
|
| 486 | + case _CHESS_GAMETYPE_OPEN: |
|
| 487 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_OPEN; |
|
| 488 | + break; |
|
| 489 | + case _CHESS_GAMETYPE_USER: |
|
| 490 | + $player2_user = $memberHandler->getUser($row['player2_uid']); |
|
| 491 | + $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?'; |
|
| 492 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username; |
|
| 493 | + break; |
|
| 494 | + case _CHESS_GAMETYPE_SELF: |
|
| 495 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
|
| 496 | + break; |
|
| 497 | + default: |
|
| 498 | + $label_gametype = _MD_CHESS_LABEL_ERROR; |
|
| 499 | + break; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 502 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 503 | 503 | |
| 504 | - $player1_user = $memberHandler->getUser($row['player1_uid']); |
|
| 504 | + $player1_user = $memberHandler->getUser($row['player1_uid']); |
|
| 505 | 505 | |
| 506 | - $player1_username = is_object($player1_user) ? $player1_user->getVar('uname') : '?'; |
|
| 506 | + $player1_username = is_object($player1_user) ? $player1_user->getVar('uname') : '?'; |
|
| 507 | 507 | |
| 508 | - $form->addElement( |
|
| 509 | - new XoopsFormLabel( |
|
| 510 | - _MD_CHESS_LABEL_CHALLENGER . ':', "<a href='" . XOOPS_URL . "/modules/chess/player_stats.php?player_uid={$row['player1_uid']}'>$player1_username</a>" |
|
| 511 | - ) |
|
| 512 | - ); |
|
| 508 | + $form->addElement( |
|
| 509 | + new XoopsFormLabel( |
|
| 510 | + _MD_CHESS_LABEL_CHALLENGER . ':', "<a href='" . XOOPS_URL . "/modules/chess/player_stats.php?player_uid={$row['player1_uid']}'>$player1_username</a>" |
|
| 511 | + ) |
|
| 512 | + ); |
|
| 513 | 513 | |
| 514 | - $player2_username = $xoopsUser ? $xoopsUser->getVar('uname') : '?'; |
|
| 514 | + $player2_username = $xoopsUser ? $xoopsUser->getVar('uname') : '?'; |
|
| 515 | 515 | |
| 516 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $player2_username)); |
|
| 516 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $player2_username)); |
|
| 517 | 517 | |
| 518 | - if (!empty($row['fen'])) { |
|
| 519 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen'])); |
|
| 520 | - } |
|
| 518 | + if (!empty($row['fen'])) { |
|
| 519 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen'])); |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | - if (_CHESS_COLOROPTION_OPPONENT == $row['color_option']) { |
|
| 523 | - $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', _CHESS_COLOROPTION_RANDOM); |
|
| 522 | + if (_CHESS_COLOROPTION_OPPONENT == $row['color_option']) { |
|
| 523 | + $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', _CHESS_COLOROPTION_RANDOM); |
|
| 524 | 524 | |
| 525 | - $radio_color->addOption(_CHESS_COLOROPTION_RANDOM, _MD_CHESS_RADIO_COLOR_RANDOM); |
|
| 525 | + $radio_color->addOption(_CHESS_COLOROPTION_RANDOM, _MD_CHESS_RADIO_COLOR_RANDOM); |
|
| 526 | 526 | |
| 527 | - $radio_color->addOption(_CHESS_COLOROPTION_WHITE, _MD_CHESS_RADIO_COLOR_WHITE); |
|
| 527 | + $radio_color->addOption(_CHESS_COLOROPTION_WHITE, _MD_CHESS_RADIO_COLOR_WHITE); |
|
| 528 | 528 | |
| 529 | - $radio_color->addOption(_CHESS_COLOROPTION_BLACK, _MD_CHESS_RADIO_COLOR_BLACK); |
|
| 529 | + $radio_color->addOption(_CHESS_COLOROPTION_BLACK, _MD_CHESS_RADIO_COLOR_BLACK); |
|
| 530 | 530 | |
| 531 | - $form->addElement($radio_color); |
|
| 532 | - } else { |
|
| 533 | - switch ($row['color_option']) { |
|
| 534 | - case _CHESS_COLOROPTION_RANDOM: |
|
| 535 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_RANDOM; |
|
| 536 | - break; |
|
| 537 | - case _CHESS_COLOROPTION_WHITE: |
|
| 538 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_BLACK; // player1 white, player2 black |
|
| 539 | - break; |
|
| 540 | - case _CHESS_COLOROPTION_BLACK: |
|
| 541 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_WHITE; // player1 black, player2 white |
|
| 542 | - break; |
|
| 543 | - default: |
|
| 544 | - $label_coloroption = _MD_CHESS_LABEL_ERROR; |
|
| 545 | - break; |
|
| 546 | - } |
|
| 531 | + $form->addElement($radio_color); |
|
| 532 | + } else { |
|
| 533 | + switch ($row['color_option']) { |
|
| 534 | + case _CHESS_COLOROPTION_RANDOM: |
|
| 535 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_RANDOM; |
|
| 536 | + break; |
|
| 537 | + case _CHESS_COLOROPTION_WHITE: |
|
| 538 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_BLACK; // player1 white, player2 black |
|
| 539 | + break; |
|
| 540 | + case _CHESS_COLOROPTION_BLACK: |
|
| 541 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_WHITE; // player1 black, player2 white |
|
| 542 | + break; |
|
| 543 | + default: |
|
| 544 | + $label_coloroption = _MD_CHESS_LABEL_ERROR; |
|
| 545 | + break; |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 549 | - } |
|
| 548 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - if ('none' != chess_moduleConfig('rating_system')) { |
|
| 552 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO)); |
|
| 553 | - } |
|
| 551 | + if ('none' != chess_moduleConfig('rating_system')) { |
|
| 552 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO)); |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - // Display notification-subscribe checkbox, initially checked. |
|
| 555 | + // Display notification-subscribe checkbox, initially checked. |
|
| 556 | 556 | |
| 557 | - $checked_value = 1; |
|
| 557 | + $checked_value = 1; |
|
| 558 | 558 | |
| 559 | - $checkbox_notify_move = new XoopsFormCheckBox('', 'notify_move', $checked_value); |
|
| 559 | + $checkbox_notify_move = new XoopsFormCheckBox('', 'notify_move', $checked_value); |
|
| 560 | 560 | |
| 561 | - $checkbox_notify_move->addOption($checked_value, _MD_CHESS_NEVT_MOVE_CAP); |
|
| 561 | + $checkbox_notify_move->addOption($checked_value, _MD_CHESS_NEVT_MOVE_CAP); |
|
| 562 | 562 | |
| 563 | - $form->addElement($checkbox_notify_move); |
|
| 563 | + $form->addElement($checkbox_notify_move); |
|
| 564 | 564 | |
| 565 | - $tray = new XoopsFormElementTray(''); |
|
| 565 | + $tray = new XoopsFormElementTray(''); |
|
| 566 | 566 | |
| 567 | - $tray->addElement(new XoopsFormButton('', 'submit_accept', _MD_CHESS_CREATE_ACCEPT, 'submit')); |
|
| 567 | + $tray->addElement(new XoopsFormButton('', 'submit_accept', _MD_CHESS_CREATE_ACCEPT, 'submit')); |
|
| 568 | 568 | |
| 569 | - $tray->addElement(new XoopsFormButton('', 'cancel_accept', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 569 | + $tray->addElement(new XoopsFormButton('', 'cancel_accept', _MD_CHESS_CREATE_CANCEL, 'submit')); |
|
| 570 | 570 | |
| 571 | - $form->addElement($tray); |
|
| 571 | + $form->addElement($tray); |
|
| 572 | 572 | |
| 573 | - $form->display(); |
|
| 573 | + $form->display(); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
@@ -582,114 +582,114 @@ discard block |
||
| 582 | 582 | */ |
| 583 | 583 | function chess_show_delete_form($challenge_id, $show_arbiter_ctrl, $error_msg = '') |
| 584 | 584 | { |
| 585 | - global $xoopsDB; |
|
| 585 | + global $xoopsDB; |
|
| 586 | 586 | |
| 587 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 587 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 588 | 588 | |
| 589 | - $result = $xoopsDB->query( |
|
| 590 | - trim( |
|
| 591 | - " |
|
| 589 | + $result = $xoopsDB->query( |
|
| 590 | + trim( |
|
| 591 | + " |
|
| 592 | 592 | SELECT game_type, fen, color_option, player1_uid, player2_uid, UNIX_TIMESTAMP(create_date) as create_date, is_rated |
| 593 | 593 | FROM $challenges_table |
| 594 | 594 | WHERE challenge_id = '$challenge_id' |
| 595 | 595 | " |
| 596 | - ) |
|
| 597 | - ); |
|
| 596 | + ) |
|
| 597 | + ); |
|
| 598 | 598 | |
| 599 | - if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 600 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 601 | - } |
|
| 599 | + if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 600 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - $row = $xoopsDB->fetchArray($result); |
|
| 603 | + $row = $xoopsDB->fetchArray($result); |
|
| 604 | 604 | |
| 605 | - $xoopsDB->freeRecordSet($result); |
|
| 605 | + $xoopsDB->freeRecordSet($result); |
|
| 606 | 606 | |
| 607 | - $form = new XoopsThemeForm(_MD_CHESS_DELETE_FORM, 'delete_form', 'create.php', 'post', true); |
|
| 607 | + $form = new XoopsThemeForm(_MD_CHESS_DELETE_FORM, 'delete_form', 'create.php', 'post', true); |
|
| 608 | 608 | |
| 609 | - $form->addElement(new XoopsFormHidden('challenge_id', $challenge_id)); |
|
| 609 | + $form->addElement(new XoopsFormHidden('challenge_id', $challenge_id)); |
|
| 610 | 610 | |
| 611 | - if ($show_arbiter_ctrl) { |
|
| 612 | - $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', $show_arbiter_ctrl)); |
|
| 613 | - } |
|
| 611 | + if ($show_arbiter_ctrl) { |
|
| 612 | + $form->addElement(new XoopsFormHidden('show_arbiter_ctrl', $show_arbiter_ctrl)); |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - if ($error_msg) { |
|
| 616 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 617 | - } |
|
| 615 | + if ($error_msg) { |
|
| 616 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm'))); |
|
| 619 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm'))); |
|
| 620 | 620 | |
| 621 | - $memberHandler = xoops_getHandler('member'); |
|
| 621 | + $memberHandler = xoops_getHandler('member'); |
|
| 622 | 622 | |
| 623 | - switch ($row['game_type']) { |
|
| 624 | - case _CHESS_GAMETYPE_OPEN: |
|
| 625 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_OPEN; |
|
| 626 | - break; |
|
| 627 | - case _CHESS_GAMETYPE_USER: |
|
| 628 | - $player2_user = $memberHandler->getUser($row['player2_uid']); |
|
| 629 | - $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?'; |
|
| 630 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username; |
|
| 631 | - break; |
|
| 632 | - case _CHESS_GAMETYPE_SELF: |
|
| 633 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
|
| 634 | - break; |
|
| 635 | - default: |
|
| 636 | - $label_gametype = _MD_CHESS_LABEL_ERROR; |
|
| 637 | - break; |
|
| 638 | - } |
|
| 623 | + switch ($row['game_type']) { |
|
| 624 | + case _CHESS_GAMETYPE_OPEN: |
|
| 625 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_OPEN; |
|
| 626 | + break; |
|
| 627 | + case _CHESS_GAMETYPE_USER: |
|
| 628 | + $player2_user = $memberHandler->getUser($row['player2_uid']); |
|
| 629 | + $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?'; |
|
| 630 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username; |
|
| 631 | + break; |
|
| 632 | + case _CHESS_GAMETYPE_SELF: |
|
| 633 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
|
| 634 | + break; |
|
| 635 | + default: |
|
| 636 | + $label_gametype = _MD_CHESS_LABEL_ERROR; |
|
| 637 | + break; |
|
| 638 | + } |
|
| 639 | 639 | |
| 640 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 640 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 641 | 641 | |
| 642 | - $player1_user = $memberHandler->getUser($row['player1_uid']); |
|
| 642 | + $player1_user = $memberHandler->getUser($row['player1_uid']); |
|
| 643 | 643 | |
| 644 | - $player1_username = is_object($player1_user) ? $player1_user->getVar('uname') : '?'; |
|
| 644 | + $player1_username = is_object($player1_user) ? $player1_user->getVar('uname') : '?'; |
|
| 645 | 645 | |
| 646 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_CHALLENGER . ':', $player1_username)); |
|
| 646 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_CHALLENGER . ':', $player1_username)); |
|
| 647 | 647 | |
| 648 | - if (!empty($row['fen'])) { |
|
| 649 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen'])); |
|
| 650 | - } |
|
| 648 | + if (!empty($row['fen'])) { |
|
| 649 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen'])); |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | - switch ($row['color_option']) { |
|
| 653 | - case _CHESS_COLOROPTION_OPPONENT: |
|
| 654 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_OPPONENT; |
|
| 655 | - break; |
|
| 656 | - case _CHESS_COLOROPTION_RANDOM: |
|
| 657 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_RANDOM; |
|
| 658 | - break; |
|
| 659 | - case _CHESS_COLOROPTION_WHITE: |
|
| 660 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_WHITE; |
|
| 661 | - break; |
|
| 662 | - case _CHESS_COLOROPTION_BLACK: |
|
| 663 | - $label_coloroption = _MD_CHESS_RADIO_COLOR_BLACK; |
|
| 664 | - break; |
|
| 665 | - default: |
|
| 666 | - $label_coloroption = _MD_CHESS_LABEL_ERROR; |
|
| 667 | - break; |
|
| 668 | - } |
|
| 652 | + switch ($row['color_option']) { |
|
| 653 | + case _CHESS_COLOROPTION_OPPONENT: |
|
| 654 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_OPPONENT; |
|
| 655 | + break; |
|
| 656 | + case _CHESS_COLOROPTION_RANDOM: |
|
| 657 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_RANDOM; |
|
| 658 | + break; |
|
| 659 | + case _CHESS_COLOROPTION_WHITE: |
|
| 660 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_WHITE; |
|
| 661 | + break; |
|
| 662 | + case _CHESS_COLOROPTION_BLACK: |
|
| 663 | + $label_coloroption = _MD_CHESS_RADIO_COLOR_BLACK; |
|
| 664 | + break; |
|
| 665 | + default: |
|
| 666 | + $label_coloroption = _MD_CHESS_LABEL_ERROR; |
|
| 667 | + break; |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 670 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 671 | 671 | |
| 672 | - if ('none' != chess_moduleConfig('rating_system')) { |
|
| 673 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO)); |
|
| 674 | - } |
|
| 672 | + if ('none' != chess_moduleConfig('rating_system')) { |
|
| 673 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO)); |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | - // Display confirm-delete checkbox, initially unchecked. |
|
| 676 | + // Display confirm-delete checkbox, initially unchecked. |
|
| 677 | 677 | |
| 678 | - $checked_value = 1; |
|
| 678 | + $checked_value = 1; |
|
| 679 | 679 | |
| 680 | - $checkbox_confirm_delete = new XoopsFormCheckBox('', 'confirm_delete', !$checked_value); |
|
| 680 | + $checkbox_confirm_delete = new XoopsFormCheckBox('', 'confirm_delete', !$checked_value); |
|
| 681 | 681 | |
| 682 | - $checkbox_confirm_delete->addOption($checked_value, _MD_CHESS_CONFIRM_DELETE); |
|
| 682 | + $checkbox_confirm_delete->addOption($checked_value, _MD_CHESS_CONFIRM_DELETE); |
|
| 683 | 683 | |
| 684 | - $tray = new XoopsFormElementTray(''); |
|
| 684 | + $tray = new XoopsFormElementTray(''); |
|
| 685 | 685 | |
| 686 | - $tray->addElement(new XoopsFormButton('', 'submit_delete', _MD_CHESS_CREATE_DELETE, 'submit')); |
|
| 686 | + $tray->addElement(new XoopsFormButton('', 'submit_delete', _MD_CHESS_CREATE_DELETE, 'submit')); |
|
| 687 | 687 | |
| 688 | - $tray->addElement($checkbox_confirm_delete); |
|
| 688 | + $tray->addElement($checkbox_confirm_delete); |
|
| 689 | 689 | |
| 690 | - $form->addElement($tray); |
|
| 690 | + $form->addElement($tray); |
|
| 691 | 691 | |
| 692 | - $form->display(); |
|
| 692 | + $form->display(); |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -702,100 +702,100 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | function chess_accept_challenge($challenge_id, $coloroption, $notify_move_player2 = false) |
| 704 | 704 | { |
| 705 | - global $xoopsDB, $xoopsUser; |
|
| 705 | + global $xoopsDB, $xoopsUser; |
|
| 706 | 706 | |
| 707 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 707 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 708 | 708 | |
| 709 | - $result = $xoopsDB->query( |
|
| 710 | - trim( |
|
| 711 | - " |
|
| 709 | + $result = $xoopsDB->query( |
|
| 710 | + trim( |
|
| 711 | + " |
|
| 712 | 712 | SELECT game_type, fen, color_option, notify_move_player1, player1_uid, player2_uid, UNIX_TIMESTAMP(create_date) as create_date, is_rated |
| 713 | 713 | FROM $challenges_table |
| 714 | 714 | WHERE challenge_id = '$challenge_id' |
| 715 | 715 | " |
| 716 | - ) |
|
| 717 | - ); |
|
| 718 | - |
|
| 719 | - if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 720 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 721 | - } |
|
| 722 | - |
|
| 723 | - $row = $xoopsDB->fetchArray($result); |
|
| 724 | - |
|
| 725 | - $xoopsDB->freeRecordSet($result); |
|
| 726 | - |
|
| 727 | - $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; |
|
| 728 | - |
|
| 729 | - if (_CHESS_GAMETYPE_USER == $row['game_type'] && $uid != $row['player2_uid']) { |
|
| 730 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_WRONG_PLAYER2); |
|
| 731 | - } elseif ($uid == $row['player1_uid']) { |
|
| 732 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_SAME_PLAYER2); |
|
| 733 | - } |
|
| 734 | - |
|
| 735 | - switch ($row['color_option']) { |
|
| 736 | - case _CHESS_COLOROPTION_OPPONENT: |
|
| 737 | - switch ($coloroption) { |
|
| 738 | - default: |
|
| 739 | - case _CHESS_COLOROPTION_RANDOM: |
|
| 740 | - if (1 == random_int(1, 2)) { |
|
| 741 | - $white_uid = $row['player1_uid']; |
|
| 742 | - $black_uid = $uid; |
|
| 743 | - } else { |
|
| 744 | - $white_uid = $uid; |
|
| 745 | - $black_uid = $row['player1_uid']; |
|
| 746 | - } |
|
| 747 | - break; |
|
| 748 | - case _CHESS_COLOROPTION_WHITE: |
|
| 749 | - $white_uid = $uid; |
|
| 750 | - $black_uid = $row['player1_uid']; |
|
| 751 | - break; |
|
| 752 | - case _CHESS_COLOROPTION_BLACK: |
|
| 753 | - $white_uid = $row['player1_uid']; |
|
| 754 | - $black_uid = $uid; |
|
| 755 | - break; |
|
| 756 | - } |
|
| 757 | - break; |
|
| 758 | - default: |
|
| 759 | - case _CHESS_COLOROPTION_RANDOM: |
|
| 760 | - if (1 == random_int(1, 2)) { |
|
| 761 | - $white_uid = $row['player1_uid']; |
|
| 762 | - |
|
| 763 | - $black_uid = $uid; |
|
| 764 | - } else { |
|
| 765 | - $white_uid = $uid; |
|
| 766 | - |
|
| 767 | - $black_uid = $row['player1_uid']; |
|
| 768 | - } |
|
| 769 | - break; |
|
| 770 | - case _CHESS_COLOROPTION_WHITE: |
|
| 771 | - $white_uid = $row['player1_uid']; |
|
| 772 | - $black_uid = $uid; |
|
| 773 | - break; |
|
| 774 | - case _CHESS_COLOROPTION_BLACK: |
|
| 775 | - $white_uid = $uid; |
|
| 776 | - $black_uid = $row['player1_uid']; |
|
| 777 | - break; |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - $game_id = chess_create_game($white_uid, $black_uid, $row['fen'], $row['is_rated'], $row['notify_move_player1'] ? $row['player1_uid'] : 0, $notify_move_player2); |
|
| 781 | - |
|
| 782 | - $xoopsDB->query("DELETE FROM $challenges_table WHERE challenge_id = '$challenge_id'"); |
|
| 783 | - |
|
| 784 | - if ($xoopsDB->errno()) { |
|
| 785 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - // Notify player 1 that his challenge has been accepted (if he has subscribed to the notification). |
|
| 789 | - |
|
| 790 | - $player2_username = $xoopsUser ? $xoopsUser->getVar('uname') : '*unknown*'; |
|
| 791 | - |
|
| 792 | - $notificationHandler = xoops_getHandler('notification'); |
|
| 793 | - |
|
| 794 | - $extra_tags = ['CHESS_PLAYER' => $player2_username, 'CHESS_GAME_ID' => $game_id]; |
|
| 795 | - |
|
| 796 | - $notificationHandler->triggerEvent('global', 0, 'notify_accept_challenge', $extra_tags, [$row['player1_uid']]); |
|
| 797 | - |
|
| 798 | - redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 716 | + ) |
|
| 717 | + ); |
|
| 718 | + |
|
| 719 | + if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 720 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 721 | + } |
|
| 722 | + |
|
| 723 | + $row = $xoopsDB->fetchArray($result); |
|
| 724 | + |
|
| 725 | + $xoopsDB->freeRecordSet($result); |
|
| 726 | + |
|
| 727 | + $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; |
|
| 728 | + |
|
| 729 | + if (_CHESS_GAMETYPE_USER == $row['game_type'] && $uid != $row['player2_uid']) { |
|
| 730 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_WRONG_PLAYER2); |
|
| 731 | + } elseif ($uid == $row['player1_uid']) { |
|
| 732 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_SAME_PLAYER2); |
|
| 733 | + } |
|
| 734 | + |
|
| 735 | + switch ($row['color_option']) { |
|
| 736 | + case _CHESS_COLOROPTION_OPPONENT: |
|
| 737 | + switch ($coloroption) { |
|
| 738 | + default: |
|
| 739 | + case _CHESS_COLOROPTION_RANDOM: |
|
| 740 | + if (1 == random_int(1, 2)) { |
|
| 741 | + $white_uid = $row['player1_uid']; |
|
| 742 | + $black_uid = $uid; |
|
| 743 | + } else { |
|
| 744 | + $white_uid = $uid; |
|
| 745 | + $black_uid = $row['player1_uid']; |
|
| 746 | + } |
|
| 747 | + break; |
|
| 748 | + case _CHESS_COLOROPTION_WHITE: |
|
| 749 | + $white_uid = $uid; |
|
| 750 | + $black_uid = $row['player1_uid']; |
|
| 751 | + break; |
|
| 752 | + case _CHESS_COLOROPTION_BLACK: |
|
| 753 | + $white_uid = $row['player1_uid']; |
|
| 754 | + $black_uid = $uid; |
|
| 755 | + break; |
|
| 756 | + } |
|
| 757 | + break; |
|
| 758 | + default: |
|
| 759 | + case _CHESS_COLOROPTION_RANDOM: |
|
| 760 | + if (1 == random_int(1, 2)) { |
|
| 761 | + $white_uid = $row['player1_uid']; |
|
| 762 | + |
|
| 763 | + $black_uid = $uid; |
|
| 764 | + } else { |
|
| 765 | + $white_uid = $uid; |
|
| 766 | + |
|
| 767 | + $black_uid = $row['player1_uid']; |
|
| 768 | + } |
|
| 769 | + break; |
|
| 770 | + case _CHESS_COLOROPTION_WHITE: |
|
| 771 | + $white_uid = $row['player1_uid']; |
|
| 772 | + $black_uid = $uid; |
|
| 773 | + break; |
|
| 774 | + case _CHESS_COLOROPTION_BLACK: |
|
| 775 | + $white_uid = $uid; |
|
| 776 | + $black_uid = $row['player1_uid']; |
|
| 777 | + break; |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + $game_id = chess_create_game($white_uid, $black_uid, $row['fen'], $row['is_rated'], $row['notify_move_player1'] ? $row['player1_uid'] : 0, $notify_move_player2); |
|
| 781 | + |
|
| 782 | + $xoopsDB->query("DELETE FROM $challenges_table WHERE challenge_id = '$challenge_id'"); |
|
| 783 | + |
|
| 784 | + if ($xoopsDB->errno()) { |
|
| 785 | + trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + // Notify player 1 that his challenge has been accepted (if he has subscribed to the notification). |
|
| 789 | + |
|
| 790 | + $player2_username = $xoopsUser ? $xoopsUser->getVar('uname') : '*unknown*'; |
|
| 791 | + |
|
| 792 | + $notificationHandler = xoops_getHandler('notification'); |
|
| 793 | + |
|
| 794 | + $extra_tags = ['CHESS_PLAYER' => $player2_username, 'CHESS_GAME_ID' => $game_id]; |
|
| 795 | + |
|
| 796 | + $notificationHandler->triggerEvent('global', 0, 'notify_accept_challenge', $extra_tags, [$row['player1_uid']]); |
|
| 797 | + |
|
| 798 | + redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -806,23 +806,23 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | function chess_is_challenger($challenge_id) |
| 808 | 808 | { |
| 809 | - global $xoopsDB, $xoopsUser; |
|
| 809 | + global $xoopsDB, $xoopsUser; |
|
| 810 | 810 | |
| 811 | - $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 811 | + $challenges_table = $xoopsDB->prefix('chess_challenges'); |
|
| 812 | 812 | |
| 813 | - $result = $xoopsDB->query("SELECT player1_uid FROM $challenges_table WHERE challenge_id = '$challenge_id'"); |
|
| 813 | + $result = $xoopsDB->query("SELECT player1_uid FROM $challenges_table WHERE challenge_id = '$challenge_id'"); |
|
| 814 | 814 | |
| 815 | - if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 816 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 817 | - } |
|
| 815 | + if ($xoopsDB->getRowsNum($result) < 1) { |
|
| 816 | + redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 817 | + } |
|
| 818 | 818 | |
| 819 | - $row = $xoopsDB->fetchArray($result); |
|
| 819 | + $row = $xoopsDB->fetchArray($result); |
|
| 820 | 820 | |
| 821 | - $xoopsDB->freeRecordSet($result); |
|
| 821 | + $xoopsDB->freeRecordSet($result); |
|
| 822 | 822 | |
| 823 | - $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
| 823 | + $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
| 824 | 824 | |
| 825 | - return $uid == $row['player1_uid']; |
|
| 825 | + return $uid == $row['player1_uid']; |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
@@ -838,27 +838,27 @@ discard block |
||
| 838 | 838 | */ |
| 839 | 839 | function chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move_player1, $opponent_uid = 0) |
| 840 | 840 | { |
| 841 | - #$where = __CLASS__ . '::' . __FUNCTION__;#*#DEBUG# |
|
| 841 | + #$where = __CLASS__ . '::' . __FUNCTION__;#*#DEBUG# |
|
| 842 | 842 | |
| 843 | - #echo "In $where\n";#*#DEBUG# |
|
| 843 | + #echo "In $where\n";#*#DEBUG# |
|
| 844 | 844 | |
| 845 | - global $xoopsUser; |
|
| 845 | + global $xoopsUser; |
|
| 846 | 846 | |
| 847 | - $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
| 847 | + $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
| 848 | 848 | |
| 849 | - $myts = MyTextSanitizer::getInstance(); |
|
| 849 | + $myts = MyTextSanitizer::getInstance(); |
|
| 850 | 850 | |
| 851 | - $fen_q = $myts->addSlashes($fen); |
|
| 851 | + $fen_q = $myts->addSlashes($fen); |
|
| 852 | 852 | |
| 853 | - #trigger_error("inserting new game'", E_USER_NOTICE);#*#DEBUG# |
|
| 853 | + #trigger_error("inserting new game'", E_USER_NOTICE);#*#DEBUG# |
|
| 854 | 854 | |
| 855 | - global $xoopsDB; |
|
| 855 | + global $xoopsDB; |
|
| 856 | 856 | |
| 857 | - $table = $xoopsDB->prefix('chess_challenges'); |
|
| 857 | + $table = $xoopsDB->prefix('chess_challenges'); |
|
| 858 | 858 | |
| 859 | - $xoopsDB->query( |
|
| 860 | - trim( |
|
| 861 | - " |
|
| 859 | + $xoopsDB->query( |
|
| 860 | + trim( |
|
| 861 | + " |
|
| 862 | 862 | INSERT INTO $table |
| 863 | 863 | SET |
| 864 | 864 | game_type = '$gametype', |
@@ -870,36 +870,36 @@ discard block |
||
| 870 | 870 | create_date = NOW(), |
| 871 | 871 | is_rated = '$rated' |
| 872 | 872 | " |
| 873 | - ) |
|
| 874 | - ); |
|
| 873 | + ) |
|
| 874 | + ); |
|
| 875 | 875 | |
| 876 | - if ($xoopsDB->errno()) { |
|
| 877 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 878 | - } |
|
| 876 | + if ($xoopsDB->errno()) { |
|
| 877 | + trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | - $challenge_id = $xoopsDB->getInsertId(); |
|
| 880 | + $challenge_id = $xoopsDB->getInsertId(); |
|
| 881 | 881 | |
| 882 | - $notificationHandler = xoops_getHandler('notification'); |
|
| 882 | + $notificationHandler = xoops_getHandler('notification'); |
|
| 883 | 883 | |
| 884 | - // Update the challenger's subscription for receiving a notification when the challenge is accepted. |
|
| 884 | + // Update the challenger's subscription for receiving a notification when the challenge is accepted. |
|
| 885 | 885 | |
| 886 | - if ($notify_accept) { |
|
| 887 | - $notificationHandler->subscribe('global', 0, 'notify_accept_challenge'); |
|
| 888 | - } else { |
|
| 889 | - $notificationHandler->unsubscribe('global', 0, 'notify_accept_challenge'); |
|
| 890 | - } |
|
| 886 | + if ($notify_accept) { |
|
| 887 | + $notificationHandler->subscribe('global', 0, 'notify_accept_challenge'); |
|
| 888 | + } else { |
|
| 889 | + $notificationHandler->unsubscribe('global', 0, 'notify_accept_challenge'); |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - // Notify any subscribers that a challenge has been offered. |
|
| 892 | + // Notify any subscribers that a challenge has been offered. |
|
| 893 | 893 | |
| 894 | - $player1_username = $xoopsUser ? $xoopsUser->getVar('uname') : '*unknown*'; |
|
| 894 | + $player1_username = $xoopsUser ? $xoopsUser->getVar('uname') : '*unknown*'; |
|
| 895 | 895 | |
| 896 | - $extra_tags = ['CHESS_CHALLENGER' => $player1_username, 'CHESS_CHALLENGE_ID' => $challenge_id]; |
|
| 896 | + $extra_tags = ['CHESS_CHALLENGER' => $player1_username, 'CHESS_CHALLENGE_ID' => $challenge_id]; |
|
| 897 | 897 | |
| 898 | - if (_CHESS_GAMETYPE_OPEN == $gametype) { |
|
| 899 | - $notificationHandler->triggerEvent('global', 0, 'notify_challenge_open', $extra_tags); |
|
| 900 | - } elseif (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 901 | - $notificationHandler->triggerEvent('global', 0, 'notify_challenge_user', $extra_tags, [$opponent_uid]); |
|
| 902 | - } |
|
| 898 | + if (_CHESS_GAMETYPE_OPEN == $gametype) { |
|
| 899 | + $notificationHandler->triggerEvent('global', 0, 'notify_challenge_open', $extra_tags); |
|
| 900 | + } elseif (_CHESS_GAMETYPE_USER == $gametype) { |
|
| 901 | + $notificationHandler->triggerEvent('global', 0, 'notify_challenge_user', $extra_tags, [$opponent_uid]); |
|
| 902 | + } |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
@@ -909,15 +909,15 @@ discard block |
||
| 909 | 909 | */ |
| 910 | 910 | function chess_delete_challenge($challenge_id) |
| 911 | 911 | { |
| 912 | - global $xoopsDB; |
|
| 912 | + global $xoopsDB; |
|
| 913 | 913 | |
| 914 | - $table = $xoopsDB->prefix('chess_challenges'); |
|
| 914 | + $table = $xoopsDB->prefix('chess_challenges'); |
|
| 915 | 915 | |
| 916 | - $xoopsDB->query("DELETE FROM $table WHERE challenge_id='$challenge_id'"); |
|
| 916 | + $xoopsDB->query("DELETE FROM $table WHERE challenge_id='$challenge_id'"); |
|
| 917 | 917 | |
| 918 | - if ($xoopsDB->errno()) { |
|
| 919 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 920 | - } |
|
| 918 | + if ($xoopsDB->errno()) { |
|
| 919 | + trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 920 | + } |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -934,33 +934,33 @@ discard block |
||
| 934 | 934 | */ |
| 935 | 935 | function chess_create_game($white_uid, $black_uid, $fen, $rated, $notify_move_player1_uid = 0, $notify_move_player2 = false) |
| 936 | 936 | { |
| 937 | - #$where = __CLASS__ . '::' . __FUNCTION__;#*#DEBUG# |
|
| 937 | + #$where = __CLASS__ . '::' . __FUNCTION__;#*#DEBUG# |
|
| 938 | 938 | |
| 939 | - #echo "In $where\n";#*#DEBUG# |
|
| 939 | + #echo "In $where\n";#*#DEBUG# |
|
| 940 | 940 | |
| 941 | - #var_dump('white_uid', $white_uid, 'black_uid', $black_uid);#*#DEBUG# |
|
| 941 | + #var_dump('white_uid', $white_uid, 'black_uid', $black_uid);#*#DEBUG# |
|
| 942 | 942 | |
| 943 | - $chessgame = new Chess\ChessGame($fen); |
|
| 943 | + $chessgame = new Chess\ChessGame($fen); |
|
| 944 | 944 | |
| 945 | - empty($chessgame->error) or trigger_error('chessgame invalid', E_USER_ERROR); |
|
| 945 | + empty($chessgame->error) or trigger_error('chessgame invalid', E_USER_ERROR); |
|
| 946 | 946 | |
| 947 | - $gamestate = $chessgame->gamestate(); |
|
| 947 | + $gamestate = $chessgame->gamestate(); |
|
| 948 | 948 | |
| 949 | - is_array($gamestate) or trigger_error('gamestate invalid', E_USER_ERROR); |
|
| 949 | + is_array($gamestate) or trigger_error('gamestate invalid', E_USER_ERROR); |
|
| 950 | 950 | |
| 951 | - #trigger_error("inserting new game'", E_USER_NOTICE);#*#DEBUG# |
|
| 951 | + #trigger_error("inserting new game'", E_USER_NOTICE);#*#DEBUG# |
|
| 952 | 952 | |
| 953 | - $myts = MyTextSanitizer::getInstance(); |
|
| 953 | + $myts = MyTextSanitizer::getInstance(); |
|
| 954 | 954 | |
| 955 | - $fen_q = $myts->addSlashes($fen); |
|
| 955 | + $fen_q = $myts->addSlashes($fen); |
|
| 956 | 956 | |
| 957 | - global $xoopsDB; |
|
| 957 | + global $xoopsDB; |
|
| 958 | 958 | |
| 959 | - $table = $xoopsDB->prefix('chess_games'); |
|
| 959 | + $table = $xoopsDB->prefix('chess_games'); |
|
| 960 | 960 | |
| 961 | - $xoopsDB->query( |
|
| 962 | - trim( |
|
| 963 | - " |
|
| 961 | + $xoopsDB->query( |
|
| 962 | + trim( |
|
| 963 | + " |
|
| 964 | 964 | INSERT INTO $table |
| 965 | 965 | SET |
| 966 | 966 | white_uid = '$white_uid', |
@@ -979,30 +979,30 @@ discard block |
||
| 979 | 979 | pgn_movetext = '{$gamestate['pgn_movetext']}', |
| 980 | 980 | is_rated = '$rated' |
| 981 | 981 | " |
| 982 | - ) |
|
| 983 | - ); |
|
| 982 | + ) |
|
| 983 | + ); |
|
| 984 | 984 | |
| 985 | - if ($xoopsDB->errno()) { |
|
| 986 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 987 | - } |
|
| 985 | + if ($xoopsDB->errno()) { |
|
| 986 | + trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 987 | + } |
|
| 988 | 988 | |
| 989 | - $game_id = $xoopsDB->getInsertId(); |
|
| 989 | + $game_id = $xoopsDB->getInsertId(); |
|
| 990 | 990 | |
| 991 | - $notificationHandler = xoops_getHandler('notification'); |
|
| 991 | + $notificationHandler = xoops_getHandler('notification'); |
|
| 992 | 992 | |
| 993 | - // If requested, subscribe the challenger to receive a notification when a new move is made. |
|
| 993 | + // If requested, subscribe the challenger to receive a notification when a new move is made. |
|
| 994 | 994 | |
| 995 | - if ($notify_move_player1_uid) { |
|
| 996 | - $notificationHandler->subscribe('game', $game_id, 'notify_game_move', null, null, $notify_move_player1_uid); |
|
| 997 | - } |
|
| 995 | + if ($notify_move_player1_uid) { |
|
| 996 | + $notificationHandler->subscribe('game', $game_id, 'notify_game_move', null, null, $notify_move_player1_uid); |
|
| 997 | + } |
|
| 998 | 998 | |
| 999 | - // If requested, subscribe the accepter to receive a notification when a new move is made. |
|
| 999 | + // If requested, subscribe the accepter to receive a notification when a new move is made. |
|
| 1000 | 1000 | |
| 1001 | - if ($notify_move_player2) { |
|
| 1002 | - $notificationHandler->subscribe('game', $game_id, 'notify_game_move'); |
|
| 1003 | - } |
|
| 1001 | + if ($notify_move_player2) { |
|
| 1002 | + $notificationHandler->subscribe('game', $game_id, 'notify_game_move'); |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | - return $game_id; |
|
| 1005 | + return $game_id; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /** |
@@ -1013,15 +1013,15 @@ discard block |
||
| 1013 | 1013 | */ |
| 1014 | 1014 | function chess_fen_error($fen) |
| 1015 | 1015 | { |
| 1016 | - if (!empty($fen)) { |
|
| 1017 | - $chessgame = new Chess\ChessGame($fen); |
|
| 1016 | + if (!empty($fen)) { |
|
| 1017 | + $chessgame = new Chess\ChessGame($fen); |
|
| 1018 | 1018 | |
| 1019 | - $fen_error = $chessgame->error; |
|
| 1020 | - } else { |
|
| 1021 | - $fen_error = ''; |
|
| 1022 | - } |
|
| 1019 | + $fen_error = $chessgame->error; |
|
| 1020 | + } else { |
|
| 1021 | + $fen_error = ''; |
|
| 1022 | + } |
|
| 1023 | 1023 | |
| 1024 | - return $fen_error; |
|
| 1024 | + return $fen_error; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | /** |
@@ -1034,9 +1034,9 @@ discard block |
||
| 1034 | 1034 | */ |
| 1035 | 1035 | function chess_opponent_uid($username) |
| 1036 | 1036 | { |
| 1037 | - $uid = chess_uname_to_uid($username); |
|
| 1037 | + $uid = chess_uname_to_uid($username); |
|
| 1038 | 1038 | |
| 1039 | - $can_play = $uid > 0 ? chess_can_play($uid) : false; |
|
| 1039 | + $can_play = $uid > 0 ? chess_can_play($uid) : false; |
|
| 1040 | 1040 | |
| 1041 | - return $can_play ? $uid : 0; |
|
| 1041 | + return $can_play ? $uid : 0; |
|
| 1042 | 1042 | } |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | /**#@+ |
| 48 | 48 | */ |
| 49 | -require_once dirname(__DIR__, 2) . '/mainfile.php'; |
|
| 49 | +require_once dirname(__DIR__, 2).'/mainfile.php'; |
|
| 50 | 50 | $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching |
| 51 | -require_once XOOPS_ROOT_PATH . '/header.php'; |
|
| 52 | -require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
| 53 | -require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php'; |
|
| 54 | -require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php'; |
|
| 51 | +require_once XOOPS_ROOT_PATH.'/header.php'; |
|
| 52 | +require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
| 53 | +require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php'; |
|
| 54 | +require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php'; |
|
| 55 | 55 | |
| 56 | 56 | #var_dump($_REQUEST);#*#DEBUG# |
| 57 | 57 | |
| 58 | 58 | if (!chess_can_play()) { |
| 59 | - redirect_header(XOOPS_URL . '/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 59 | + redirect_header(XOOPS_URL.'/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // user input |
| 63 | 63 | //$gametype = chess_sanitize(@$_POST['gametype']); |
| 64 | 64 | //$opponent = chess_sanitize(trim(@$_POST['opponent']), _CHESS_USERNAME_ALLOWED_CHARACTERS); |
| 65 | 65 | $gametype = Request::getCmd('gametype', '', 'POST'); |
| 66 | -$opponent = preg_replace('/[^' . _CHESS_USERNAME_ALLOWED_CHARACTERS . ']/i', '', Request::getString('opponent', '', 'POST')); |
|
| 66 | +$opponent = preg_replace('/[^'._CHESS_USERNAME_ALLOWED_CHARACTERS.']/i', '', Request::getString('opponent', '', 'POST')); |
|
| 67 | 67 | $opponent = trim($opponent); |
| 68 | 68 | $opponent_uid = !empty($opponent) ? chess_opponent_uid($opponent) : 0; |
| 69 | 69 | //$fen = chess_moduleConfig('allow_setup') ? chess_sanitize(trim(@$_POST['fen']), 'A-Za-z0-9 /-') : ''; |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | // If form-submit, check security token. |
| 89 | 89 | if (($submit_challenge1 || $submit_challenge2 || $submit_challenge3 || $submit_accept || $submit_delete || $show_arbiter_ctrl) && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) { |
| 90 | 90 | redirect_header( |
| 91 | - XOOPS_URL . '/modules/chess/', |
|
| 91 | + XOOPS_URL.'/modules/chess/', |
|
| 92 | 92 | _CHESS_REDIRECT_DELAY_FAILURE, |
| 93 | - _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
|
| 93 | + _MD_CHESS_TOKEN_ERROR.'<br>'.implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
|
| 94 | 94 | ); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $is_arbiter = is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid')); |
| 106 | 106 | |
| 107 | 107 | if ($cancel_challenge1) { |
| 108 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 108 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 109 | 109 | } elseif ($cancel_challenge2) { |
| 110 | 110 | chess_show_create_form1($gametype); |
| 111 | 111 | } elseif ($cancel_challenge3) { |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | chess_show_create_form1($gametype, $fen); |
| 116 | 116 | } |
| 117 | 117 | } elseif ($cancel_accept) { |
| 118 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 118 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK); |
|
| 119 | 119 | } elseif ($submit_challenge1) { |
| 120 | 120 | $fen_error = chess_fen_error($fen); |
| 121 | 121 | |
| 122 | 122 | if (!empty($fen_error)) { |
| 123 | - chess_show_create_form1($gametype, $fen, _MD_CHESS_FEN_INVALID . ': ' . $fen_error); |
|
| 123 | + chess_show_create_form1($gametype, $fen, _MD_CHESS_FEN_INVALID.': '.$fen_error); |
|
| 124 | 124 | } elseif (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
| 125 | 125 | chess_show_create_form2($gametype, $fen); |
| 126 | 126 | } else { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | if (_CHESS_GAMETYPE_OPEN == $gametype) { |
| 145 | 145 | chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move); |
| 146 | 146 | |
| 147 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 147 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 148 | 148 | } elseif (_CHESS_GAMETYPE_USER == $gametype) { |
| 149 | 149 | if (empty($opponent)) { |
| 150 | 150 | chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_MISSING); |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | } else { |
| 156 | 156 | chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move, $opponent_uid); |
| 157 | 157 | |
| 158 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 158 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 159 | 159 | } |
| 160 | 160 | } elseif (_CHESS_GAMETYPE_SELF == $gametype) { |
| 161 | 161 | $game_id = chess_create_game($uid, $uid, $fen, $rated); |
| 162 | 162 | |
| 163 | - redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 163 | + redirect_header(XOOPS_URL."/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 164 | 164 | } else { |
| 165 | 165 | chess_show_create_form1($gametype, $fen, _MD_CHESS_GAMETYPE_INVALID); |
| 166 | 166 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | if ($is_arbiter || chess_is_challenger($challenge_id)) { |
| 172 | 172 | chess_delete_challenge($challenge_id); |
| 173 | 173 | |
| 174 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED); |
|
| 174 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED); |
|
| 175 | 175 | } else { |
| 176 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 176 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM); |
|
| 177 | 177 | } |
| 178 | 178 | } else { |
| 179 | 179 | chess_show_delete_form($challenge_id, $show_arbiter_ctrl && $is_arbiter, _MD_CHESS_NO_CONFIRM_DELETE); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | chess_show_create_form1($gametype); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | -require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
| 191 | +require_once XOOPS_ROOT_PATH.'/footer.php'; |
|
| 192 | 192 | /**#@-*/ |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form1', 'create.php', 'post', true); |
| 204 | 204 | |
| 205 | 205 | if ($error_msg) { |
| 206 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 206 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR.': ', '<div class="errorMsg">'.$error_msg.'</div>')); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $menu_gametype = new XoopsFormSelect(_MD_CHESS_LABEL_GAMETYPE . ':', 'gametype', $gametype, 1, false); |
|
| 209 | + $menu_gametype = new XoopsFormSelect(_MD_CHESS_LABEL_GAMETYPE.':', 'gametype', $gametype, 1, false); |
|
| 210 | 210 | |
| 211 | 211 | $menu_gametype->addOption(_CHESS_GAMETYPE_OPEN, _MD_CHESS_MENU_GAMETYPE_OPEN); |
| 212 | 212 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | $form->addElement(new XoopsFormLabel('', _MD_CHESS_LABEL_FEN_EXPLAIN)); |
| 223 | 223 | |
| 224 | - $form->addElement(new XoopsFormText(_MD_CHESS_LABEL_FEN_SETUP . ':', 'fen', 80, _CHESS_TEXTBOX_FEN_MAXLEN, $fen)); |
|
| 224 | + $form->addElement(new XoopsFormText(_MD_CHESS_LABEL_FEN_SETUP.':', 'fen', 80, _CHESS_TEXTBOX_FEN_MAXLEN, $fen)); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $form->addElement(new XoopsFormLabel(' ', ' ')); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $form->addElement(new XoopsFormHidden('fen', $fen)); |
| 257 | 257 | |
| 258 | 258 | if ($error_msg) { |
| 259 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ':', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 259 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR.':', '<div class="errorMsg">'.$error_msg.'</div>')); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $memberHandler = xoops_getHandler('member'); |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | if (_CHESS_GAMETYPE_USER == $gametype) { |
| 269 | 269 | $form->addElement( |
| 270 | 270 | new XoopsFormText( |
| 271 | - _MD_CHESS_LABEL_OPPONENT . ':', 'opponent', _CHESS_TEXTBOX_OPPONENT_SIZE, _CHESS_TEXTBOX_OPPONENT_MAXLEN, $opponent_username |
|
| 271 | + _MD_CHESS_LABEL_OPPONENT.':', 'opponent', _CHESS_TEXTBOX_OPPONENT_SIZE, _CHESS_TEXTBOX_OPPONENT_MAXLEN, $opponent_username |
|
| 272 | 272 | ) |
| 273 | 273 | ); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', $coloroption); |
|
| 276 | + $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR.':', 'coloroption', $coloroption); |
|
| 277 | 277 | |
| 278 | 278 | $radio_color->addOption(_CHESS_COLOROPTION_OPPONENT, _MD_CHESS_RADIO_COLOR_OPPONENT); |
| 279 | 279 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | if ('none' !== chess_moduleConfig('rating_system')) { |
| 289 | 289 | if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
| 290 | 290 | if (chess_moduleConfig('allow_unrated_games')) { |
| 291 | - $radio_rated = new XoopsFormRadio(_MD_CHESS_RATED_GAME . ':', 'rated', $rated); |
|
| 291 | + $radio_rated = new XoopsFormRadio(_MD_CHESS_RATED_GAME.':', 'rated', $rated); |
|
| 292 | 292 | |
| 293 | 293 | $radio_rated->addOption(1, _YES); |
| 294 | 294 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $form->addElement(new XoopsFormHidden('rated', $rated)); |
| 345 | 345 | |
| 346 | - $form->addElement(new XoopsFormLabel('', '<div class="confirmMsg">' . _MD_CHESS_GAME_CONFIRM . '</div>')); |
|
| 346 | + $form->addElement(new XoopsFormLabel('', '<div class="confirmMsg">'._MD_CHESS_GAME_CONFIRM.'</div>')); |
|
| 347 | 347 | |
| 348 | 348 | switch ($gametype) { |
| 349 | 349 | case _CHESS_GAMETYPE_OPEN: |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | break; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 363 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE.':', $label_gametype)); |
|
| 364 | 364 | |
| 365 | 365 | if (!empty($fen)) { |
| 366 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $fen)); |
|
| 366 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP.':', $fen)); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | if (_CHESS_GAMETYPE_USER == $gametype) { |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : ''; |
| 375 | 375 | |
| 376 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $opponent_username)); |
|
| 376 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT.':', $opponent_username)); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) { |
@@ -395,10 +395,10 @@ discard block |
||
| 395 | 395 | break; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 398 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR.':', $label_coloroption)); |
|
| 399 | 399 | |
| 400 | 400 | if ('none' != chess_moduleConfig('rating_system')) { |
| 401 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $rated ? _YES : _NO)); |
|
| 401 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME.':', $rated ? _YES : _NO)); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // Determine whether current user is subscribed to receive a notification when his challenge is accepted. |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | ); |
| 468 | 468 | |
| 469 | 469 | if ($xoopsDB->getRowsNum($result) < 1) { |
| 470 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 470 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | $row = $xoopsDB->fetchArray($result); |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | $form->addElement(new XoopsFormHidden('challenge_id', $challenge_id)); |
| 480 | 480 | |
| 481 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm'))); |
|
| 481 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED.':', formatTimestamp($row['create_date'], 'm'))); |
|
| 482 | 482 | |
| 483 | 483 | $memberHandler = xoops_getHandler('member'); |
| 484 | 484 | |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | case _CHESS_GAMETYPE_USER: |
| 490 | 490 | $player2_user = $memberHandler->getUser($row['player2_uid']); |
| 491 | 491 | $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?'; |
| 492 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username; |
|
| 492 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER.': '.$player2_username; |
|
| 493 | 493 | break; |
| 494 | 494 | case _CHESS_GAMETYPE_SELF: |
| 495 | 495 | $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | break; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 502 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE.':', $label_gametype)); |
|
| 503 | 503 | |
| 504 | 504 | $player1_user = $memberHandler->getUser($row['player1_uid']); |
| 505 | 505 | |
@@ -507,20 +507,20 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | $form->addElement( |
| 509 | 509 | new XoopsFormLabel( |
| 510 | - _MD_CHESS_LABEL_CHALLENGER . ':', "<a href='" . XOOPS_URL . "/modules/chess/player_stats.php?player_uid={$row['player1_uid']}'>$player1_username</a>" |
|
| 510 | + _MD_CHESS_LABEL_CHALLENGER.':', "<a href='".XOOPS_URL."/modules/chess/player_stats.php?player_uid={$row['player1_uid']}'>$player1_username</a>" |
|
| 511 | 511 | ) |
| 512 | 512 | ); |
| 513 | 513 | |
| 514 | 514 | $player2_username = $xoopsUser ? $xoopsUser->getVar('uname') : '?'; |
| 515 | 515 | |
| 516 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $player2_username)); |
|
| 516 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT.':', $player2_username)); |
|
| 517 | 517 | |
| 518 | 518 | if (!empty($row['fen'])) { |
| 519 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen'])); |
|
| 519 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP.':', $row['fen'])); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | if (_CHESS_COLOROPTION_OPPONENT == $row['color_option']) { |
| 523 | - $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', _CHESS_COLOROPTION_RANDOM); |
|
| 523 | + $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR.':', 'coloroption', _CHESS_COLOROPTION_RANDOM); |
|
| 524 | 524 | |
| 525 | 525 | $radio_color->addOption(_CHESS_COLOROPTION_RANDOM, _MD_CHESS_RADIO_COLOR_RANDOM); |
| 526 | 526 | |
@@ -545,11 +545,11 @@ discard block |
||
| 545 | 545 | break; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 548 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR.':', $label_coloroption)); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | if ('none' != chess_moduleConfig('rating_system')) { |
| 552 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO)); |
|
| 552 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME.':', $row['is_rated'] ? _YES : _NO)); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | // Display notification-subscribe checkbox, initially checked. |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | ); |
| 598 | 598 | |
| 599 | 599 | if ($xoopsDB->getRowsNum($result) < 1) { |
| 600 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 600 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | $row = $xoopsDB->fetchArray($result); |
@@ -613,10 +613,10 @@ discard block |
||
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | if ($error_msg) { |
| 616 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>')); |
|
| 616 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR.': ', '<div class="errorMsg">'.$error_msg.'</div>')); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm'))); |
|
| 619 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED.':', formatTimestamp($row['create_date'], 'm'))); |
|
| 620 | 620 | |
| 621 | 621 | $memberHandler = xoops_getHandler('member'); |
| 622 | 622 | |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | case _CHESS_GAMETYPE_USER: |
| 628 | 628 | $player2_user = $memberHandler->getUser($row['player2_uid']); |
| 629 | 629 | $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?'; |
| 630 | - $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username; |
|
| 630 | + $label_gametype = _MD_CHESS_LABEL_GAMETYPE_USER.': '.$player2_username; |
|
| 631 | 631 | break; |
| 632 | 632 | case _CHESS_GAMETYPE_SELF: |
| 633 | 633 | $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF; |
@@ -637,16 +637,16 @@ discard block |
||
| 637 | 637 | break; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype)); |
|
| 640 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE.':', $label_gametype)); |
|
| 641 | 641 | |
| 642 | 642 | $player1_user = $memberHandler->getUser($row['player1_uid']); |
| 643 | 643 | |
| 644 | 644 | $player1_username = is_object($player1_user) ? $player1_user->getVar('uname') : '?'; |
| 645 | 645 | |
| 646 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_CHALLENGER . ':', $player1_username)); |
|
| 646 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_CHALLENGER.':', $player1_username)); |
|
| 647 | 647 | |
| 648 | 648 | if (!empty($row['fen'])) { |
| 649 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen'])); |
|
| 649 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP.':', $row['fen'])); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | switch ($row['color_option']) { |
@@ -667,10 +667,10 @@ discard block |
||
| 667 | 667 | break; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption)); |
|
| 670 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR.':', $label_coloroption)); |
|
| 671 | 671 | |
| 672 | 672 | if ('none' != chess_moduleConfig('rating_system')) { |
| 673 | - $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO)); |
|
| 673 | + $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME.':', $row['is_rated'] ? _YES : _NO)); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // Display confirm-delete checkbox, initially unchecked. |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | ); |
| 718 | 718 | |
| 719 | 719 | if ($xoopsDB->getRowsNum($result) < 1) { |
| 720 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 720 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | $row = $xoopsDB->fetchArray($result); |
@@ -727,9 +727,9 @@ discard block |
||
| 727 | 727 | $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; |
| 728 | 728 | |
| 729 | 729 | if (_CHESS_GAMETYPE_USER == $row['game_type'] && $uid != $row['player2_uid']) { |
| 730 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_WRONG_PLAYER2); |
|
| 730 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_WRONG_PLAYER2); |
|
| 731 | 731 | } elseif ($uid == $row['player1_uid']) { |
| 732 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_SAME_PLAYER2); |
|
| 732 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_SAME_PLAYER2); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | switch ($row['color_option']) { |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | $xoopsDB->query("DELETE FROM $challenges_table WHERE challenge_id = '$challenge_id'"); |
| 783 | 783 | |
| 784 | 784 | if ($xoopsDB->errno()) { |
| 785 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 785 | + trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | // Notify player 1 that his challenge has been accepted (if he has subscribed to the notification). |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | |
| 796 | 796 | $notificationHandler->triggerEvent('global', 0, 'notify_accept_challenge', $extra_tags, [$row['player1_uid']]); |
| 797 | 797 | |
| 798 | - redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 798 | + redirect_header(XOOPS_URL."/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | $result = $xoopsDB->query("SELECT player1_uid FROM $challenges_table WHERE challenge_id = '$challenge_id'"); |
| 814 | 814 | |
| 815 | 815 | if ($xoopsDB->getRowsNum($result) < 1) { |
| 816 | - redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 816 | + redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | $row = $xoopsDB->fetchArray($result); |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | ); |
| 875 | 875 | |
| 876 | 876 | if ($xoopsDB->errno()) { |
| 877 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 877 | + trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | $challenge_id = $xoopsDB->getInsertId(); |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | $xoopsDB->query("DELETE FROM $table WHERE challenge_id='$challenge_id'"); |
| 917 | 917 | |
| 918 | 918 | if ($xoopsDB->errno()) { |
| 919 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 919 | + trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 920 | 920 | } |
| 921 | 921 | } |
| 922 | 922 | |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | ); |
| 983 | 983 | |
| 984 | 984 | if ($xoopsDB->errno()) { |
| 985 | - trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR); |
|
| 985 | + trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | $game_id = $xoopsDB->getInsertId(); |
@@ -26,72 +26,72 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Helper extends \Xmf\Module\Helper |
| 28 | 28 | { |
| 29 | - public $debug; |
|
| 29 | + public $debug; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param bool $debug |
|
| 33 | - */ |
|
| 34 | - public function __construct($debug = false) |
|
| 35 | - { |
|
| 36 | - $this->debug = $debug; |
|
| 31 | + /** |
|
| 32 | + * @param bool $debug |
|
| 33 | + */ |
|
| 34 | + public function __construct($debug = false) |
|
| 35 | + { |
|
| 36 | + $this->debug = $debug; |
|
| 37 | 37 | |
| 38 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 38 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 39 | 39 | |
| 40 | - parent::__construct($moduleDirName); |
|
| 41 | - } |
|
| 40 | + parent::__construct($moduleDirName); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param bool $debug |
|
| 45 | - * |
|
| 46 | - * @return \XoopsModules\Chess\Helper |
|
| 47 | - */ |
|
| 48 | - public static function getInstance($debug = false) |
|
| 49 | - { |
|
| 50 | - static $instance; |
|
| 43 | + /** |
|
| 44 | + * @param bool $debug |
|
| 45 | + * |
|
| 46 | + * @return \XoopsModules\Chess\Helper |
|
| 47 | + */ |
|
| 48 | + public static function getInstance($debug = false) |
|
| 49 | + { |
|
| 50 | + static $instance; |
|
| 51 | 51 | |
| 52 | - if (null === $instance) { |
|
| 53 | - $instance = new static($debug); |
|
| 54 | - } |
|
| 52 | + if (null === $instance) { |
|
| 53 | + $instance = new static($debug); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return $instance; |
|
| 57 | - } |
|
| 56 | + return $instance; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return string |
|
| 61 | - */ |
|
| 62 | - public function getDirname() |
|
| 63 | - { |
|
| 64 | - return $this->dirname; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * @return string |
|
| 61 | + */ |
|
| 62 | + public function getDirname() |
|
| 63 | + { |
|
| 64 | + return $this->dirname; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Get an Object Handler |
|
| 69 | - * |
|
| 70 | - * @param string $name name of handler to load |
|
| 71 | - * |
|
| 72 | - * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
|
| 73 | - */ |
|
| 74 | - public function getHandler($name) |
|
| 75 | - { |
|
| 76 | - $ret = false; |
|
| 67 | + /** |
|
| 68 | + * Get an Object Handler |
|
| 69 | + * |
|
| 70 | + * @param string $name name of handler to load |
|
| 71 | + * |
|
| 72 | + * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
|
| 73 | + */ |
|
| 74 | + public function getHandler($name) |
|
| 75 | + { |
|
| 76 | + $ret = false; |
|
| 77 | 77 | |
| 78 | - $class = __NAMESPACE__ . '\\' . $name . 'Handler'; |
|
| 78 | + $class = __NAMESPACE__ . '\\' . $name . 'Handler'; |
|
| 79 | 79 | |
| 80 | - if (!\class_exists($class)) { |
|
| 81 | - throw new \RuntimeException("Class '$class' not found"); |
|
| 82 | - } |
|
| 80 | + if (!\class_exists($class)) { |
|
| 81 | + throw new \RuntimeException("Class '$class' not found"); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** @var \XoopsMySQLDatabase $db */ |
|
| 84 | + /** @var \XoopsMySQLDatabase $db */ |
|
| 85 | 85 | |
| 86 | - $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 86 | + $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 87 | 87 | |
| 88 | - $helper = self::getInstance(); |
|
| 88 | + $helper = self::getInstance(); |
|
| 89 | 89 | |
| 90 | - $ret = new $class($db, $helper); |
|
| 90 | + $ret = new $class($db, $helper); |
|
| 91 | 91 | |
| 92 | - $this->addLog("Getting handler '{$name}'"); |
|
| 92 | + $this->addLog("Getting handler '{$name}'"); |
|
| 93 | 93 | |
| 94 | - return $ret; |
|
| 95 | - } |
|
| 94 | + return $ret; |
|
| 95 | + } |
|
| 96 | 96 | } |
| 97 | 97 | //require dirname(dirname(__DIR__)) . '/mainfile.php'; |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | { |
| 76 | 76 | $ret = false; |
| 77 | 77 | |
| 78 | - $class = __NAMESPACE__ . '\\' . $name . 'Handler'; |
|
| 78 | + $class = __NAMESPACE__.'\\'.$name.'Handler'; |
|
| 79 | 79 | |
| 80 | 80 | if (!\class_exists($class)) { |
| 81 | 81 | throw new \RuntimeException("Class '$class' not found"); |
@@ -27,5 +27,5 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class Utility extends Common\SysUtility |
| 29 | 29 | { |
| 30 | - //--------------- Custom module methods ----------------------------- |
|
| 30 | + //--------------- Custom module methods ----------------------------- |
|
| 31 | 31 | } |
@@ -77,47 +77,47 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | \xoops_load('XoopsFormLoader'); |
| 79 | 79 | |
| 80 | - $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); |
|
| 80 | + $form = new \XoopsThemeForm(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); |
|
| 81 | 81 | |
| 82 | 82 | $form->setExtra('enctype="multipart/form-data"'); |
| 83 | 83 | |
| 84 | - $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); |
|
| 84 | + $recipient = new \XoopsFormText(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); |
|
| 85 | 85 | |
| 86 | 86 | $recipient->setExtra('disabled="disabled"'); |
| 87 | 87 | |
| 88 | 88 | $form->addElement($recipient); |
| 89 | 89 | |
| 90 | - $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); |
|
| 90 | + $your_name = new \XoopsFormText(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_NAME'), 'your_name', 50, 255, $this->name); |
|
| 91 | 91 | |
| 92 | - $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"'); |
|
| 92 | + $your_name->setExtra('placeholder="'.\constant('CO_'.$moduleDirNameUpper.'_'.'FB_NAME_PLACEHOLER').'"'); |
|
| 93 | 93 | |
| 94 | 94 | $form->addElement($your_name); |
| 95 | 95 | |
| 96 | - $your_site = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site); |
|
| 96 | + $your_site = new \XoopsFormText(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_SITE'), 'your_site', 50, 255, $this->site); |
|
| 97 | 97 | |
| 98 | - $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"'); |
|
| 98 | + $your_site->setExtra('placeholder="'.\constant('CO_'.$moduleDirNameUpper.'_'.'FB_SITE_PLACEHOLER').'"'); |
|
| 99 | 99 | |
| 100 | 100 | $form->addElement($your_site); |
| 101 | 101 | |
| 102 | - $your_mail = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email); |
|
| 102 | + $your_mail = new \XoopsFormText(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_MAIL'), 'your_mail', 50, 255, $this->email); |
|
| 103 | 103 | |
| 104 | - $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"'); |
|
| 104 | + $your_mail->setExtra('placeholder="'.\constant('CO_'.$moduleDirNameUpper.'_'.'FB_MAIL_PLACEHOLER').'"'); |
|
| 105 | 105 | |
| 106 | 106 | $form->addElement($your_mail); |
| 107 | 107 | |
| 108 | - $fbtypeSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type); |
|
| 108 | + $fbtypeSelect = new \XoopsFormSelect(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE'), 'fb_type', $this->type); |
|
| 109 | 109 | |
| 110 | 110 | $fbtypeSelect->addOption('', ''); |
| 111 | 111 | |
| 112 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION')); |
|
| 112 | + $fbtypeSelect->addOption(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_SUGGESTION'), \constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_SUGGESTION')); |
|
| 113 | 113 | |
| 114 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS')); |
|
| 114 | + $fbtypeSelect->addOption(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_BUGS'), \constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_BUGS')); |
|
| 115 | 115 | |
| 116 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL')); |
|
| 116 | + $fbtypeSelect->addOption(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_TESTIMONIAL'), \constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_TESTIMONIAL')); |
|
| 117 | 117 | |
| 118 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES')); |
|
| 118 | + $fbtypeSelect->addOption(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_FEATURES'), \constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_FEATURES')); |
|
| 119 | 119 | |
| 120 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS')); |
|
| 120 | + $fbtypeSelect->addOption(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_OTHERS'), \constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_OTHERS')); |
|
| 121 | 121 | |
| 122 | 122 | $form->addElement($fbtypeSelect, true); |
| 123 | 123 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | $editorConfigs['editor'] = $config['general_editor']; |
| 151 | 151 | |
| 152 | - $editor = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); |
|
| 152 | + $editor = new \XoopsFormEditor(\constant('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); |
|
| 153 | 153 | |
| 154 | 154 | $form->addElement($editor, true); |
| 155 | 155 | |
@@ -28,135 +28,135 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class ModuleFeedback extends \XoopsObject |
| 30 | 30 | { |
| 31 | - public $name = ''; |
|
| 32 | - public $email = ''; |
|
| 33 | - public $site = ''; |
|
| 34 | - public $type = ''; |
|
| 35 | - public $content = ''; |
|
| 31 | + public $name = ''; |
|
| 32 | + public $email = ''; |
|
| 33 | + public $site = ''; |
|
| 34 | + public $type = ''; |
|
| 35 | + public $content = ''; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Constructor |
|
| 39 | - * |
|
| 40 | - * @param null |
|
| 41 | - */ |
|
| 42 | - public function __construct() |
|
| 43 | - { |
|
| 44 | - } |
|
| 37 | + /** |
|
| 38 | + * Constructor |
|
| 39 | + * |
|
| 40 | + * @param null |
|
| 41 | + */ |
|
| 42 | + public function __construct() |
|
| 43 | + { |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @static function &getInstance |
|
| 48 | - * |
|
| 49 | - * @param null |
|
| 50 | - */ |
|
| 51 | - public static function getInstance() |
|
| 52 | - { |
|
| 53 | - static $instance = false; |
|
| 46 | + /** |
|
| 47 | + * @static function &getInstance |
|
| 48 | + * |
|
| 49 | + * @param null |
|
| 50 | + */ |
|
| 51 | + public static function getInstance() |
|
| 52 | + { |
|
| 53 | + static $instance = false; |
|
| 54 | 54 | |
| 55 | - if (!$instance) { |
|
| 56 | - $instance = new self(); |
|
| 57 | - } |
|
| 58 | - } |
|
| 55 | + if (!$instance) { |
|
| 56 | + $instance = new self(); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @public function getFormFeedback: |
|
| 62 | - * provide form for sending a feedback to module author |
|
| 63 | - * @param bool $action |
|
| 64 | - * @return \XoopsThemeForm |
|
| 65 | - */ |
|
| 66 | - public function getFormFeedback($action = false) |
|
| 67 | - { |
|
| 68 | - if (false === $action) { |
|
| 69 | - $action = $_SERVER['REQUEST_URI']; |
|
| 70 | - } |
|
| 60 | + /** |
|
| 61 | + * @public function getFormFeedback: |
|
| 62 | + * provide form for sending a feedback to module author |
|
| 63 | + * @param bool $action |
|
| 64 | + * @return \XoopsThemeForm |
|
| 65 | + */ |
|
| 66 | + public function getFormFeedback($action = false) |
|
| 67 | + { |
|
| 68 | + if (false === $action) { |
|
| 69 | + $action = $_SERVER['REQUEST_URI']; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 72 | + $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 73 | 73 | |
| 74 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 74 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 75 | 75 | |
| 76 | - // Get Theme Form |
|
| 76 | + // Get Theme Form |
|
| 77 | 77 | |
| 78 | - \xoops_load('XoopsFormLoader'); |
|
| 78 | + \xoops_load('XoopsFormLoader'); |
|
| 79 | 79 | |
| 80 | - $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); |
|
| 80 | + $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); |
|
| 81 | 81 | |
| 82 | - $form->setExtra('enctype="multipart/form-data"'); |
|
| 82 | + $form->setExtra('enctype="multipart/form-data"'); |
|
| 83 | 83 | |
| 84 | - $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); |
|
| 84 | + $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); |
|
| 85 | 85 | |
| 86 | - $recipient->setExtra('disabled="disabled"'); |
|
| 86 | + $recipient->setExtra('disabled="disabled"'); |
|
| 87 | 87 | |
| 88 | - $form->addElement($recipient); |
|
| 88 | + $form->addElement($recipient); |
|
| 89 | 89 | |
| 90 | - $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); |
|
| 90 | + $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); |
|
| 91 | 91 | |
| 92 | - $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"'); |
|
| 92 | + $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"'); |
|
| 93 | 93 | |
| 94 | - $form->addElement($your_name); |
|
| 94 | + $form->addElement($your_name); |
|
| 95 | 95 | |
| 96 | - $your_site = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site); |
|
| 96 | + $your_site = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site); |
|
| 97 | 97 | |
| 98 | - $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"'); |
|
| 98 | + $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"'); |
|
| 99 | 99 | |
| 100 | - $form->addElement($your_site); |
|
| 100 | + $form->addElement($your_site); |
|
| 101 | 101 | |
| 102 | - $your_mail = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email); |
|
| 102 | + $your_mail = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email); |
|
| 103 | 103 | |
| 104 | - $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"'); |
|
| 104 | + $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"'); |
|
| 105 | 105 | |
| 106 | - $form->addElement($your_mail); |
|
| 106 | + $form->addElement($your_mail); |
|
| 107 | 107 | |
| 108 | - $fbtypeSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type); |
|
| 108 | + $fbtypeSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type); |
|
| 109 | 109 | |
| 110 | - $fbtypeSelect->addOption('', ''); |
|
| 110 | + $fbtypeSelect->addOption('', ''); |
|
| 111 | 111 | |
| 112 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION')); |
|
| 112 | + $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION')); |
|
| 113 | 113 | |
| 114 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS')); |
|
| 114 | + $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS')); |
|
| 115 | 115 | |
| 116 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL')); |
|
| 116 | + $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL')); |
|
| 117 | 117 | |
| 118 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES')); |
|
| 118 | + $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES')); |
|
| 119 | 119 | |
| 120 | - $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS')); |
|
| 120 | + $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS')); |
|
| 121 | 121 | |
| 122 | - $form->addElement($fbtypeSelect, true); |
|
| 122 | + $form->addElement($fbtypeSelect, true); |
|
| 123 | 123 | |
| 124 | - $editorConfigs = []; |
|
| 124 | + $editorConfigs = []; |
|
| 125 | 125 | |
| 126 | - $editorConfigs['name'] = 'fb_content'; |
|
| 126 | + $editorConfigs['name'] = 'fb_content'; |
|
| 127 | 127 | |
| 128 | - $editorConfigs['value'] = $this->content; |
|
| 128 | + $editorConfigs['value'] = $this->content; |
|
| 129 | 129 | |
| 130 | - $editorConfigs['rows'] = 5; |
|
| 130 | + $editorConfigs['rows'] = 5; |
|
| 131 | 131 | |
| 132 | - $editorConfigs['cols'] = 40; |
|
| 132 | + $editorConfigs['cols'] = 40; |
|
| 133 | 133 | |
| 134 | - $editorConfigs['width'] = '100%'; |
|
| 134 | + $editorConfigs['width'] = '100%'; |
|
| 135 | 135 | |
| 136 | - $editorConfigs['height'] = '400px'; |
|
| 136 | + $editorConfigs['height'] = '400px'; |
|
| 137 | 137 | |
| 138 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 138 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 139 | 139 | |
| 140 | - $moduleHandler = \xoops_getHandler('module'); |
|
| 140 | + $moduleHandler = \xoops_getHandler('module'); |
|
| 141 | 141 | |
| 142 | - $module = $moduleHandler->getByDirname('system'); |
|
| 142 | + $module = $moduleHandler->getByDirname('system'); |
|
| 143 | 143 | |
| 144 | - /** @var \XoopsConfigHandler $configHandler */ |
|
| 144 | + /** @var \XoopsConfigHandler $configHandler */ |
|
| 145 | 145 | |
| 146 | - $configHandler = \xoops_getHandler('config'); |
|
| 146 | + $configHandler = \xoops_getHandler('config'); |
|
| 147 | 147 | |
| 148 | - $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 148 | + $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 149 | 149 | |
| 150 | - $editorConfigs['editor'] = $config['general_editor']; |
|
| 150 | + $editorConfigs['editor'] = $config['general_editor']; |
|
| 151 | 151 | |
| 152 | - $editor = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); |
|
| 152 | + $editor = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); |
|
| 153 | 153 | |
| 154 | - $form->addElement($editor, true); |
|
| 154 | + $form->addElement($editor, true); |
|
| 155 | 155 | |
| 156 | - $form->addElement(new \XoopsFormHidden('op', 'send')); |
|
| 156 | + $form->addElement(new \XoopsFormHidden('op', 'send')); |
|
| 157 | 157 | |
| 158 | - $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); |
|
| 158 | + $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); |
|
| 159 | 159 | |
| 160 | - return $form; |
|
| 161 | - } |
|
| 160 | + return $form; |
|
| 161 | + } |
|
| 162 | 162 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | //check for minimum XOOPS version |
| 44 | 44 | $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
| 45 | 45 | if (null === $requiredVer) { |
| 46 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 46 | + $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $success = true; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | if (\version_compare($currentVer, $requiredVer, '<')) { |
| 52 | 52 | $success = false; |
| 53 | 53 | |
| 54 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
| 54 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $success; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | if (false !== $reqVer && '' !== $reqVer && !\is_array($reqVer)) { |
| 89 | 89 | if (\version_compare($verNum, $reqVer, '<')) { |
| 90 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 90 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 91 | 91 | |
| 92 | 92 | $success = false; |
| 93 | 93 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $update = ''; |
| 115 | 115 | |
| 116 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
| 116 | + $repository = 'XoopsModules25x/'.$moduleDirName; |
|
| 117 | 117 | |
| 118 | 118 | // $repository = 'XoopsModules25x/publisher'; //for testing only |
| 119 | 119 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if (false === $curlReturn) { |
| 137 | 137 | \trigger_error(\curl_error($curlHandle)); |
| 138 | 138 | } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
| 139 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
| 139 | + \trigger_error('Repository Not Found: '.$infoReleasesUrl); |
|
| 140 | 140 | } else { |
| 141 | 141 | $file = \json_decode($curlReturn, false); |
| 142 | 142 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $prerelease = $file[0]->prerelease; |
| 148 | 148 | |
| 149 | 149 | if ('master' !== $latestVersionLink) { |
| 150 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
| 150 | + $update = \constant('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION').$latestVersion; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | //"PHP-standardized" version |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $latestVersion = \str_replace('final', '', mb_strtolower($latestVersion)); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $moduleVersion = $helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'); |
|
| 163 | + $moduleVersion = $helper->getModule()->getInfo('version').'_'.$helper->getModule()->getInfo('module_status'); |
|
| 164 | 164 | |
| 165 | 165 | //"PHP-standardized" version |
| 166 | 166 | |
@@ -19,170 +19,170 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | trait VersionChecks |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Verifies XOOPS version meets minimum requirements for this module |
|
| 24 | - * @static |
|
| 25 | - * |
|
| 26 | - * @param null|string $requiredVer |
|
| 27 | - * @return bool true if meets requirements, false if not |
|
| 28 | - */ |
|
| 29 | - public static function checkVerXoops(?\XoopsModule $module = null, $requiredVer = null) |
|
| 30 | - { |
|
| 31 | - $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 22 | + /** |
|
| 23 | + * Verifies XOOPS version meets minimum requirements for this module |
|
| 24 | + * @static |
|
| 25 | + * |
|
| 26 | + * @param null|string $requiredVer |
|
| 27 | + * @return bool true if meets requirements, false if not |
|
| 28 | + */ |
|
| 29 | + public static function checkVerXoops(?\XoopsModule $module = null, $requiredVer = null) |
|
| 30 | + { |
|
| 31 | + $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 32 | 32 | |
| 33 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 33 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 34 | 34 | |
| 35 | - if (null === $module) { |
|
| 36 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 37 | - } |
|
| 35 | + if (null === $module) { |
|
| 36 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - \xoops_loadLanguage('admin', $moduleDirName); |
|
| 39 | + \xoops_loadLanguage('admin', $moduleDirName); |
|
| 40 | 40 | |
| 41 | - \xoops_loadLanguage('common', $moduleDirName); |
|
| 41 | + \xoops_loadLanguage('common', $moduleDirName); |
|
| 42 | 42 | |
| 43 | - //check for minimum XOOPS version |
|
| 44 | - $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
|
| 45 | - if (null === $requiredVer) { |
|
| 46 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 47 | - } |
|
| 43 | + //check for minimum XOOPS version |
|
| 44 | + $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
|
| 45 | + if (null === $requiredVer) { |
|
| 46 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $success = true; |
|
| 49 | + $success = true; |
|
| 50 | 50 | |
| 51 | - if (\version_compare($currentVer, $requiredVer, '<')) { |
|
| 52 | - $success = false; |
|
| 51 | + if (\version_compare($currentVer, $requiredVer, '<')) { |
|
| 52 | + $success = false; |
|
| 53 | 53 | |
| 54 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
| 55 | - } |
|
| 54 | + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - return $success; |
|
| 58 | - } |
|
| 57 | + return $success; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Verifies PHP version meets minimum requirements for this module |
|
| 62 | - * @static |
|
| 63 | - * |
|
| 64 | - * @return bool true if meets requirements, false if not |
|
| 65 | - */ |
|
| 66 | - public static function checkVerPhp(?\XoopsModule $module = null) |
|
| 67 | - { |
|
| 68 | - $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 60 | + /** |
|
| 61 | + * Verifies PHP version meets minimum requirements for this module |
|
| 62 | + * @static |
|
| 63 | + * |
|
| 64 | + * @return bool true if meets requirements, false if not |
|
| 65 | + */ |
|
| 66 | + public static function checkVerPhp(?\XoopsModule $module = null) |
|
| 67 | + { |
|
| 68 | + $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 69 | 69 | |
| 70 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 70 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 71 | 71 | |
| 72 | - if (null === $module) { |
|
| 73 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 74 | - } |
|
| 72 | + if (null === $module) { |
|
| 73 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - \xoops_loadLanguage('admin', $moduleDirName); |
|
| 76 | + \xoops_loadLanguage('admin', $moduleDirName); |
|
| 77 | 77 | |
| 78 | - \xoops_loadLanguage('common', $moduleDirName); |
|
| 78 | + \xoops_loadLanguage('common', $moduleDirName); |
|
| 79 | 79 | |
| 80 | - // check for minimum PHP version |
|
| 80 | + // check for minimum PHP version |
|
| 81 | 81 | |
| 82 | - $success = true; |
|
| 82 | + $success = true; |
|
| 83 | 83 | |
| 84 | - $verNum = \PHP_VERSION; |
|
| 84 | + $verNum = \PHP_VERSION; |
|
| 85 | 85 | |
| 86 | - $reqVer = &$module->getInfo('min_php'); |
|
| 86 | + $reqVer = &$module->getInfo('min_php'); |
|
| 87 | 87 | |
| 88 | - if (false !== $reqVer && '' !== $reqVer && !\is_array($reqVer)) { |
|
| 89 | - if (\version_compare($verNum, $reqVer, '<')) { |
|
| 90 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 88 | + if (false !== $reqVer && '' !== $reqVer && !\is_array($reqVer)) { |
|
| 89 | + if (\version_compare($verNum, $reqVer, '<')) { |
|
| 90 | + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 91 | 91 | |
| 92 | - $success = false; |
|
| 93 | - } |
|
| 94 | - } |
|
| 92 | + $success = false; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - return $success; |
|
| 97 | - } |
|
| 96 | + return $success; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * compares current module version with latest GitHub release |
|
| 101 | - * @static |
|
| 102 | - * @param \Xmf\Module\Helper $helper |
|
| 103 | - * @param string|null $source |
|
| 104 | - * @param string|null $default |
|
| 105 | - * |
|
| 106 | - * @return string|array info about the latest module version, if newer |
|
| 107 | - */ |
|
| 108 | - public static function checkVerModule($helper, $source = 'github', $default = 'master') |
|
| 109 | - { |
|
| 110 | - $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 99 | + /** |
|
| 100 | + * compares current module version with latest GitHub release |
|
| 101 | + * @static |
|
| 102 | + * @param \Xmf\Module\Helper $helper |
|
| 103 | + * @param string|null $source |
|
| 104 | + * @param string|null $default |
|
| 105 | + * |
|
| 106 | + * @return string|array info about the latest module version, if newer |
|
| 107 | + */ |
|
| 108 | + public static function checkVerModule($helper, $source = 'github', $default = 'master') |
|
| 109 | + { |
|
| 110 | + $moduleDirName = \basename(dirname(__DIR__, 2)); |
|
| 111 | 111 | |
| 112 | - $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 112 | + $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
| 113 | 113 | |
| 114 | - $update = ''; |
|
| 114 | + $update = ''; |
|
| 115 | 115 | |
| 116 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
| 116 | + $repository = 'XoopsModules25x/' . $moduleDirName; |
|
| 117 | 117 | |
| 118 | - // $repository = 'XoopsModules25x/publisher'; //for testing only |
|
| 118 | + // $repository = 'XoopsModules25x/publisher'; //for testing only |
|
| 119 | 119 | |
| 120 | - $ret = ''; |
|
| 120 | + $ret = ''; |
|
| 121 | 121 | |
| 122 | - $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
|
| 122 | + $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
|
| 123 | 123 | |
| 124 | - if ('github' === $source) { |
|
| 125 | - if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
| 126 | - \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
|
| 124 | + if ('github' === $source) { |
|
| 125 | + if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
| 126 | + \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
|
| 127 | 127 | |
| 128 | - \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
|
| 128 | + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
|
| 129 | 129 | |
| 130 | - \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); |
|
| 130 | + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); |
|
| 131 | 131 | |
| 132 | - \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
|
| 132 | + \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
|
| 133 | 133 | |
| 134 | - $curlReturn = \curl_exec($curlHandle); |
|
| 134 | + $curlReturn = \curl_exec($curlHandle); |
|
| 135 | 135 | |
| 136 | - if (false === $curlReturn) { |
|
| 137 | - \trigger_error(\curl_error($curlHandle)); |
|
| 138 | - } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
| 139 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
| 140 | - } else { |
|
| 141 | - $file = \json_decode($curlReturn, false); |
|
| 136 | + if (false === $curlReturn) { |
|
| 137 | + \trigger_error(\curl_error($curlHandle)); |
|
| 138 | + } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
| 139 | + \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
| 140 | + } else { |
|
| 141 | + $file = \json_decode($curlReturn, false); |
|
| 142 | 142 | |
| 143 | - $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
|
| 143 | + $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
|
| 144 | 144 | |
| 145 | - $latestVersion = $file[0]->tag_name; |
|
| 145 | + $latestVersion = $file[0]->tag_name; |
|
| 146 | 146 | |
| 147 | - $prerelease = $file[0]->prerelease; |
|
| 147 | + $prerelease = $file[0]->prerelease; |
|
| 148 | 148 | |
| 149 | - if ('master' !== $latestVersionLink) { |
|
| 150 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
| 151 | - } |
|
| 149 | + if ('master' !== $latestVersionLink) { |
|
| 150 | + $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - //"PHP-standardized" version |
|
| 153 | + //"PHP-standardized" version |
|
| 154 | 154 | |
| 155 | - $latestVersion = mb_strtolower($latestVersion); |
|
| 155 | + $latestVersion = mb_strtolower($latestVersion); |
|
| 156 | 156 | |
| 157 | - if (false !== mb_strpos($latestVersion, 'final')) { |
|
| 158 | - $latestVersion = \str_replace('_', '', mb_strtolower($latestVersion)); |
|
| 157 | + if (false !== mb_strpos($latestVersion, 'final')) { |
|
| 158 | + $latestVersion = \str_replace('_', '', mb_strtolower($latestVersion)); |
|
| 159 | 159 | |
| 160 | - $latestVersion = \str_replace('final', '', mb_strtolower($latestVersion)); |
|
| 161 | - } |
|
| 160 | + $latestVersion = \str_replace('final', '', mb_strtolower($latestVersion)); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $moduleVersion = $helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'); |
|
| 163 | + $moduleVersion = $helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'); |
|
| 164 | 164 | |
| 165 | - //"PHP-standardized" version |
|
| 165 | + //"PHP-standardized" version |
|
| 166 | 166 | |
| 167 | - $moduleVersion = \str_replace(' ', '', mb_strtolower($moduleVersion)); |
|
| 167 | + $moduleVersion = \str_replace(' ', '', mb_strtolower($moduleVersion)); |
|
| 168 | 168 | |
| 169 | - // $moduleVersion = '1.0'; //for testing only |
|
| 169 | + // $moduleVersion = '1.0'; //for testing only |
|
| 170 | 170 | |
| 171 | - // $moduleDirName = 'publisher'; //for testing only |
|
| 171 | + // $moduleDirName = 'publisher'; //for testing only |
|
| 172 | 172 | |
| 173 | - if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { |
|
| 174 | - $ret = []; |
|
| 173 | + if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { |
|
| 174 | + $ret = []; |
|
| 175 | 175 | |
| 176 | - $ret[] = $update; |
|
| 176 | + $ret[] = $update; |
|
| 177 | 177 | |
| 178 | - $ret[] = $latestVersionLink; |
|
| 179 | - } |
|
| 180 | - } |
|
| 178 | + $ret[] = $latestVersionLink; |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - \curl_close($curlHandle); |
|
| 183 | - } |
|
| 184 | - } |
|
| 182 | + \curl_close($curlHandle); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - return $ret; |
|
| 187 | - } |
|
| 186 | + return $ret; |
|
| 187 | + } |
|
| 188 | 188 | } |