| Conditions | 7 |
| Paths | 8 |
| Total Lines | 58 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 declare(strict_types=1); |
||
| 51 | function xoops_module_install_xhelp(\XoopsModule $module): bool |
||
| 52 | { |
||
| 53 | require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
||
| 54 | |||
| 55 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 56 | |||
| 57 | $helper = Xhelp\Helper::getInstance(); |
||
| 58 | $utility = new Xhelp\Utility(); |
||
| 59 | $configurator = new Xhelp\Common\Configurator(); |
||
| 60 | |||
| 61 | // Load language files |
||
| 62 | $helper->loadLanguage('admin'); |
||
| 63 | $helper->loadLanguage('modinfo'); |
||
| 64 | |||
| 65 | // default Permission Settings ---------------------- |
||
| 66 | $moduleId = $module->getVar('mid'); |
||
| 67 | |||
| 68 | //$moduleName = $module->getVar('name'); |
||
| 69 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 70 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 71 | // access rights ------------------------------------------ |
||
| 72 | $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
|
|
|||
| 73 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 74 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 75 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 76 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
| 77 | |||
| 78 | // --- CREATE FOLDERS --------------- |
||
| 79 | if (count($configurator->uploadFolders) > 0) { |
||
| 80 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 81 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 82 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 83 | } |
||
| 84 | } |
||
| 85 | // --- COPY blank.png FILES --------------- |
||
| 86 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 87 | $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 88 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 89 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 90 | $utility::copyFile($file, $dest); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | // --- COPY test folder files --------------- |
||
| 95 | if (count($configurator->copyTestFolders) > 0) { |
||
| 96 | // $file = \dirname(__DIR__) . '/testdata/images/'; |
||
| 97 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
| 98 | $src = $configurator->copyTestFolders[$i][0]; |
||
| 99 | $dest = $configurator->copyTestFolders[$i][1]; |
||
| 100 | $utility::rcopy($src, $dest); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | //delete .html entries from the tpl table |
||
| 105 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
| 106 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 107 | |||
| 108 | return true; |
||
| 109 | } |
||
| 110 |