Conditions | 9 |
Paths | 16 |
Total Lines | 69 |
Code Lines | 31 |
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 |
||
67 | function xoops_module_install_pedigree(\XoopsModule $module) |
||
68 | { |
||
69 | $helper = Helper::getInstance(); |
||
70 | $moduleDirName = $helper->getDirname(); |
||
71 | $configurator = new Configurator(); |
||
72 | |||
73 | // Load language files |
||
74 | $helper->loadLanguage('admin'); |
||
75 | $helper->loadLanguage('modinfo'); |
||
76 | |||
77 | // default Permission Settings ---------------------- |
||
78 | $mid = $module->getVar('mid'); |
||
|
|||
79 | |||
80 | // access rights ------------------------------------------ |
||
81 | $permHandler = new Permission($moduleDirName); |
||
82 | $permHandler->savePermissionForItem($moduleDirName . '_approve', 1, [XOOPS_GROUP_ADMIN]); |
||
83 | $permHandler->savePermissionForItem($moduleDirName . '_submit', 1, [XOOPS_GROUP_ADMIN]); |
||
84 | $permHandler->savePermissionForItem($moduleDirName . '_view', 1, [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]); |
||
85 | |||
86 | //$moduleName = $module->getVar('name'); /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
87 | /* |
||
88 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
89 | // access rights ------------------------------------------ |
||
90 | $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
91 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
92 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
93 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
94 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
95 | */ |
||
96 | // --- CREATE FOLDERS --------------- |
||
97 | if (count($configurator->uploadFolders) > 0) { |
||
98 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
99 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
100 | Utility::createFolder($configurator->uploadFolders[$i]); |
||
101 | } |
||
102 | } |
||
103 | // --- COPY blank.png FILES --------------- |
||
104 | if (count($configurator->copyBlankFiles) > 0) { |
||
105 | $file = $helper->path('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 | // --- COPY blank.png FILES --------------- |
||
113 | if (count($configurator->copyBlankFiles) > 0) { |
||
114 | $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
||
115 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
116 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
117 | Utility::copyFile($file, $dest); |
||
118 | } |
||
119 | } |
||
120 | |||
121 | // --- COPY test folder files --------------- |
||
122 | if (count($configurator->copyTestFolders) > 0) { |
||
123 | //$file = \dirname(__DIR__) . '/testdata/images/'; |
||
124 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
125 | $src = $configurator->copyTestFolders[$i][0]; |
||
126 | $dest = $configurator->copyTestFolders[$i][1]; |
||
127 | Utility::rcopy($src, $dest); |
||
128 | } |
||
129 | } |
||
130 | |||
131 | //delete .html entries from the tpl table |
||
132 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $moduleDirName . "' AND `tpl_file` LIKE '%.html'"; |
||
133 | $GLOBALS['xoopsDB']->queryF($sql); |
||
134 | |||
135 | return true; |
||
136 | } |
||
137 |