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