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