Conditions | 5 |
Paths | 4 |
Total Lines | 58 |
Code Lines | 29 |
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 |
||
53 | function xoops_module_install_wflinks(\XoopsModule $module) |
||
|
|||
54 | { |
||
55 | require_once dirname(__DIR__, 3) . '/mainfile.php'; |
||
56 | |||
57 | // require_once dirname(__DIR__) . '/class/Utility.php'; |
||
58 | |||
59 | $moduleDirName = basename(dirname(__DIR__)); |
||
60 | /** @var Wflinks\Helper $helper */ |
||
61 | $helper = Wflinks\Helper::getInstance(); |
||
62 | |||
63 | // Load language files |
||
64 | $helper->loadLanguage('admin'); |
||
65 | $helper->loadLanguage('modinfo'); |
||
66 | |||
67 | $utility = new \XoopsModules\Wflinks\Utility(); |
||
68 | |||
69 | $configurator = new Wflinks\Common\Configurator(); |
||
70 | |||
71 | // default Permission Settings ---------------------- |
||
72 | global $xoopsModule; |
||
73 | $moduleId = $xoopsModule->getVar('mid'); |
||
74 | // $moduleId2 = $helper->getModule()->mid(); |
||
75 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
76 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
77 | // access rights ------------------------------------------ |
||
78 | $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
79 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
80 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
81 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
82 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
83 | |||
84 | // --- CREATE FOLDERS --------------- |
||
85 | if (count($configurator->uploadFolders) > 0) { |
||
86 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
87 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
88 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | // --- COPY blank.png FILES --------------- |
||
93 | if (count($configurator->copyBlankFiles) > 0) { |
||
94 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
95 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
96 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
97 | $utility::copyFile($file, $dest); |
||
98 | } |
||
99 | } |
||
100 | |||
101 | // --- COPY FLAGS FILES --------------- |
||
102 | $source = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/EXTRA/htdocs/uploads/flags'; |
||
103 | $dest = XOOPS_UPLOAD_PATH . '/flags'; |
||
104 | $utility::rcopy($source, $dest); |
||
105 | |||
106 | //delete .html entries from the tpl table |
||
107 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
108 | $GLOBALS['xoopsDB']->queryF($sql); |
||
109 | |||
110 | return true; |
||
111 | } |
||
112 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.