| Conditions | 5 |
| Paths | 4 |
| Total Lines | 85 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 60 | function xoops_module_install_chess(\XoopsModule $module) |
||
| 61 | { |
||
| 62 | require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
||
| 63 | |||
| 64 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 65 | |||
| 66 | /** @var \XoopsModules\Chess\Helper $helper */ |
||
| 67 | |||
| 68 | /** @var \XoopsModules\Chess\Utility $utility */ |
||
| 69 | |||
| 70 | /** @var \XoopsModules\Chess\Common\Configurator $configurator */ |
||
| 71 | |||
| 72 | $helper = \XoopsModules\Chess\Helper::getInstance(); |
||
| 73 | |||
| 74 | $utility = new \XoopsModules\Chess\Utility(); |
||
| 75 | |||
| 76 | $configurator = new \XoopsModules\Chess\Common\Configurator(); |
||
| 77 | |||
| 78 | // Load language files |
||
| 79 | |||
| 80 | $helper->loadLanguage('admin'); |
||
| 81 | |||
| 82 | $helper->loadLanguage('modinfo'); |
||
| 83 | |||
| 84 | // default Permission Settings ---------------------- |
||
| 85 | |||
| 86 | $moduleId = $module->getVar('mid'); |
||
| 87 | |||
| 88 | //$moduleName = $module->getVar('name'); |
||
| 89 | |||
| 90 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 91 | |||
| 92 | // access rights ------------------------------------------ |
||
| 93 | |||
| 94 | $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
|
|
|||
| 95 | |||
| 96 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 97 | |||
| 98 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 99 | |||
| 100 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 101 | |||
| 102 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
| 103 | |||
| 104 | // --- CREATE FOLDERS --------------- |
||
| 105 | |||
| 106 | if (count($configurator->uploadFolders) > 0) { |
||
| 107 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 108 | |||
| 109 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 110 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | // --- COPY blank.png FILES --------------- |
||
| 115 | |||
| 116 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 117 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 118 | |||
| 119 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 120 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 121 | |||
| 122 | $utility::copyFile($file, $dest); |
||
| 123 | } |
||
| 124 | } |
||
| 125 | |||
| 126 | /* |
||
| 127 | // --- COPY test folder files --------------- |
||
| 128 | if (count($configurator->copyTestFolders) > 0) { |
||
| 129 | // $file = dirname(__DIR__) . '/testdata/images/'; |
||
| 130 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
| 131 | $src = $configurator->copyTestFolders[$i][0]; |
||
| 132 | $dest = $configurator->copyTestFolders[$i][1]; |
||
| 133 | $utility::xcopy($src, $dest); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | */ |
||
| 137 | |||
| 138 | //delete .html entries from the tpl table |
||
| 139 | |||
| 140 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
| 141 | |||
| 142 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 143 | |||
| 144 | return true; |
||
| 145 | } |
||
| 146 |