| Conditions | 5 |
| Paths | 4 |
| Total Lines | 59 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | 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 |
||
| 58 | function xoops_module_install_extcal(\XoopsModule $xoopsModule) |
||
| 59 | { |
||
| 60 | require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
||
| 61 | |||
| 62 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 63 | |||
| 64 | /** @var Helper $helper */ /** @var Utility $utility */ |
||
| 65 | /** @var Common\Configurator $configurator */ |
||
| 66 | $helper = Helper::getInstance(); |
||
| 67 | $utility = new Utility(); |
||
| 68 | $configurator = new Common\Configurator(); |
||
| 69 | // Load language files |
||
| 70 | $helper->loadLanguage('admin'); |
||
| 71 | $helper->loadLanguage('modinfo'); |
||
| 72 | |||
| 73 | $moduleId = $xoopsModule->getVar('mid'); |
||
| 74 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 75 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 76 | |||
| 77 | /* |
||
| 78 | * Default public category permission mask |
||
| 79 | */ |
||
| 80 | |||
| 81 | // Access right |
||
| 82 | $grouppermHandler->addRight($moduleDirName . '_perm_mask', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
|
|
|||
| 83 | $grouppermHandler->addRight($moduleDirName . '_perm_mask', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 84 | $grouppermHandler->addRight($moduleDirName . '_perm_mask', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
| 85 | |||
| 86 | // Can submit |
||
| 87 | $grouppermHandler->addRight($moduleDirName . '_perm_mask', 2, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 88 | |||
| 89 | // Auto approve |
||
| 90 | $grouppermHandler->addRight($moduleDirName . '_perm_mask', 4, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 91 | |||
| 92 | // Can Edit |
||
| 93 | $grouppermHandler->addRight($moduleDirName . '_perm_mask', 8, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 94 | |||
| 95 | // --- CREATE FOLDERS --------------- |
||
| 96 | if (count($configurator->uploadFolders) > 0) { |
||
| 97 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 98 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 99 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | // --- COPY blank.png FILES --------------- |
||
| 104 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 105 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 106 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 107 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 108 | $utility::copyFile($file, $dest); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | //delete .html entries from the tpl table |
||
| 113 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
| 114 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 115 | |||
| 116 | return true; |
||
| 117 | } |
||
| 118 |