Conditions | 5 |
Paths | 4 |
Total Lines | 134 |
Code Lines | 84 |
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 |
||
51 | function xoops_module_install_yogurt(XoopsModule $module) |
||
52 | { |
||
53 | global $module_id; |
||
54 | $module_id = $module->getVar('mid'); |
||
55 | xoops_loadLanguage('user'); |
||
56 | |||
57 | require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
||
58 | |||
59 | $moduleDirName = basename(dirname(__DIR__)); |
||
60 | |||
61 | // Create registration steps |
||
62 | yogurt_install_addStep(_MI_YOGURT_STEP_BASIC, '', 1, 0); |
||
63 | yogurt_install_addStep(_MI_YOGURT_STEP_COMPLEMENTARY, '', 2, 1); |
||
64 | |||
65 | // Create categories |
||
66 | yogurt_install_addCategory(_MI_YOGURT_CATEGORY_PERSONAL, 1); |
||
67 | yogurt_install_addCategory(_MI_YOGURT_CATEGORY_MESSAGING, 2); |
||
68 | yogurt_install_addCategory(_MI_YOGURT_CATEGORY_SETTINGS, 3); |
||
69 | yogurt_install_addCategory(_MI_YOGURT_CATEGORY_COMMUNITY, 4); |
||
70 | |||
71 | // Add user fields |
||
72 | xoops_loadLanguage('notification'); |
||
73 | xoops_loadLanguage('main', $module->getVar('dirname', 'n')); |
||
74 | include_once $GLOBALS['xoops']->path('include/notification_constants.php'); |
||
75 | $umode_options = array( |
||
76 | 'nest' => _NESTED, |
||
77 | 'flat' => _FLAT, |
||
78 | 'thread' => _THREADED); |
||
79 | $uorder_options = array( |
||
80 | 0 => _OLDESTFIRST, |
||
81 | 1 => _NEWESTFIRST); |
||
82 | $notify_mode_options = array( |
||
83 | XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, |
||
84 | XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, |
||
85 | XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN); |
||
86 | $notify_method_options = array( |
||
87 | XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, |
||
88 | XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, |
||
89 | XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL); |
||
90 | |||
91 | yogurt_install_addField('name', _US_REALNAME, '', 1, 'textbox', 1, 1, 1, array(), 2, 255); |
||
92 | yogurt_install_addField('user_from', _US_LOCATION, '', 1, 'textbox', 1, 2, 1, array(), 2, 255); |
||
93 | yogurt_install_addField('timezone_offset', _US_TIMEZONE, '', 1, 'timezone', 1, 3, 1, array(), 2, 0); |
||
94 | yogurt_install_addField('user_occ', _US_OCCUPATION, '', 1, 'textbox', 1, 4, 1, array(), 2, 255); |
||
95 | yogurt_install_addField('user_intrest', _US_INTEREST, '', 1, 'textbox', 1, 5, 1, array(), 2, 255); |
||
96 | yogurt_install_addField('bio', _US_EXTRAINFO, '', 1, 'textarea', 2, 6, 1, array(), 2, 0); |
||
97 | yogurt_install_addField('user_regdate', _US_MEMBERSINCE, '', 1, 'datetime', 3, 7, 0, array(), 0, 10); |
||
98 | |||
99 | yogurt_install_addField('user_viewemail', _US_ALLOWVIEWEMAIL, '', 3, 'yesno', 3, 1, 1, array(), 2, 1, false); |
||
100 | yogurt_install_addField('attachsig', _US_SHOWSIG, '', 3, 'yesno', 3, 2, 1, array(), 0, 1, false); |
||
101 | yogurt_install_addField('user_mailok', _US_MAILOK, '', 3, 'yesno', 3, 3, 1, array(), 2, 1, false); |
||
102 | yogurt_install_addField('theme', _MD_YOGURT_THEME, '', 3, 'theme', 1, 4, 1, array(), 0, 0, false); |
||
103 | yogurt_install_addField('umode', _US_CDISPLAYMODE, '', 3, 'select', 1, 5, 1, $umode_options, 0, 0, false); |
||
104 | yogurt_install_addField('uorder', _US_CSORTORDER, '', 3, 'select', 3, 6, 1, $uorder_options, 0, 0, false); |
||
105 | yogurt_install_addField('notify_mode', _NOT_NOTIFYMODE, '', 3, 'select', 3, 7, 1, $notify_mode_options, 0, 0, false); |
||
106 | yogurt_install_addField('notify_method', _NOT_NOTIFYMETHOD, '', 3, 'select', 3, 8, 1, $notify_method_options, 0, 0, false); |
||
107 | |||
108 | yogurt_install_addField('url', _MI_YOGURT_URL_TITLE, '', 4, 'textbox', 1, 1, 1, array(), 2, 255); |
||
109 | yogurt_install_addField('posts', _US_POSTS, '', 4, 'textbox', 3, 2, 0, array(), 0, 255); |
||
110 | yogurt_install_addField('rank', _US_RANK, '', 4, 'rank', 3, 3, 2, array(), 0, 0); |
||
111 | yogurt_install_addField('last_login', _US_LASTLOGIN, '', 4, 'datetime', 3, 4, 0, array(), 0, 10); |
||
112 | yogurt_install_addField('user_sig', _US_SIGNATURE, '', 4, 'dhtml', 1, 5, 1, array(), 0, 0); |
||
113 | |||
114 | yogurt_install_initializeProfiles(); |
||
115 | |||
116 | /** @var \XoopsModules\Yogurt\Helper $helper */ /** @var \XoopsModules\Yogurt\Utility $utility */ |
||
117 | /** @var \XoopsModules\Yogurt\Common\Configurator $configurator */ |
||
118 | $helper = Helper::getInstance(); |
||
119 | $utility = new Utility(); |
||
120 | $configurator = new Configurator(); |
||
121 | // Load language files |
||
122 | $helper->loadLanguage('admin'); |
||
123 | $helper->loadLanguage('modinfo'); |
||
124 | |||
125 | // default Permission Settings ---------------------- |
||
126 | |||
127 | $moduleId = $module->getVar('mid'); |
||
128 | //$moduleName = $module->getVar('name'); |
||
129 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
130 | // access rights ------------------------------------------ |
||
131 | $grouppermHandler->addRight( |
||
|
|||
132 | $moduleDirName . '_approve', |
||
133 | 1, |
||
134 | XOOPS_GROUP_ADMIN, |
||
135 | $moduleId |
||
136 | ); |
||
137 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
138 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
139 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
140 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
141 | |||
142 | // --- CREATE FOLDERS --------------- |
||
143 | if (count($configurator->uploadFolders) > 0) { |
||
144 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
145 | foreach ( |
||
146 | array_keys( |
||
147 | $configurator->uploadFolders |
||
148 | ) as $i |
||
149 | ) { |
||
150 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
151 | } |
||
152 | } |
||
153 | |||
154 | // --- COPY blank.png FILES --------------- |
||
155 | if (count($configurator->copyBlankFiles) > 0) { |
||
156 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
157 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
158 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
159 | $utility::copyFile($file, $dest); |
||
160 | } |
||
161 | } |
||
162 | |||
163 | /* |
||
164 | // --- COPY test folder files --------------- |
||
165 | if (count($configurator->copyTestFolders) > 0) { |
||
166 | // $file = dirname(__DIR__) . '/testdata/images/'; |
||
167 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
168 | $src = $configurator->copyTestFolders[$i][0]; |
||
169 | $dest = $configurator->copyTestFolders[$i][1]; |
||
170 | $utility::xcopy($src, $dest); |
||
171 | } |
||
172 | } |
||
173 | */ |
||
174 | |||
175 | //delete .html entries from the tpl table |
||
176 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix( |
||
177 | 'tplfile' |
||
178 | ) . " WHERE `tpl_module` = '" . $module->getVar( |
||
179 | 'dirname', |
||
180 | 'n' |
||
181 | ) . "' AND `tpl_file` LIKE '%.html%'"; |
||
182 | $GLOBALS['xoopsDB']->queryF($sql); |
||
183 | |||
184 | return true; |
||
185 | } |
||
315 |