| Conditions | 7 |
| Paths | 16 |
| Total Lines | 287 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 117 | function init_mods( $type ){ |
||
| 118 | |||
| 119 | // GCcollab |
||
| 120 | $plugins_connex = array( |
||
| 121 | 'garbagecollector', |
||
| 122 | 'groups', |
||
| 123 | 'logrotate', |
||
| 124 | 'group_tools', |
||
| 125 | 'blog', |
||
| 126 | 'bookmarks', |
||
| 127 | 'dashboard', |
||
| 128 | 'diagnostics', |
||
| 129 | 'friend_request', |
||
| 130 | 'externalpages', |
||
| 131 | 'file', |
||
| 132 | 'embed', |
||
| 133 | 'group_operators', |
||
| 134 | 'htmlawed', |
||
| 135 | 'invitefriends', |
||
| 136 | 'likes', |
||
| 137 | 'logbrowser', |
||
| 138 | 'gcforums', |
||
| 139 | 'messageboard', |
||
| 140 | 'messages', |
||
| 141 | 'polls', |
||
| 142 | 'profile', |
||
| 143 | 'rename_friends', |
||
| 144 | 'members', |
||
| 145 | 'thewire', |
||
| 146 | 'uservalidationbyemail', |
||
| 147 | 'unvalidatedemailchange', |
||
| 148 | 'widget_manager', |
||
| 149 | 'zaudio', |
||
| 150 | 'custom_index_widgets', |
||
| 151 | 'file_tools', |
||
| 152 | 'event_calendar', |
||
| 153 | 'ideas', |
||
| 154 | 'pages', |
||
| 155 | 'analytics', |
||
| 156 | 'tidypics', |
||
| 157 | 'translation_editor', |
||
| 158 | 'gcProfilePictureBadges', |
||
| 159 | 'upload_users', |
||
| 160 | 'c_email_extensions', |
||
| 161 | 'gcRegistration', |
||
| 162 | 'c_module_dump', |
||
| 163 | 'au_subgroups', |
||
| 164 | 'widget_manager_accessibility', |
||
| 165 | 'b_extended_profile', |
||
| 166 | 'c_members_byDepartment', |
||
| 167 | 'blog_tools', |
||
| 168 | 'ckeditor', |
||
| 169 | 'contactform', |
||
| 170 | 'site_notifications', |
||
| 171 | 'web_services', |
||
| 172 | 'missions_organization', |
||
| 173 | 'missions', |
||
| 174 | 'data_views', |
||
| 175 | 'mt_activity_tabs', |
||
| 176 | 'geds_sync', |
||
| 177 | 'gc_api', |
||
| 178 | 'achievement_badges', |
||
| 179 | 'embed_extender', |
||
| 180 | 'toggle_language', |
||
| 181 | 'cp_notifications', |
||
| 182 | 'login_as', |
||
| 183 | 'thewire_tools', |
||
| 184 | 'mentions', |
||
| 185 | 'GoC_dev_banner', |
||
| 186 | 'questions', |
||
| 187 | 'wet4', |
||
| 188 | 'GC_profileStrength', |
||
| 189 | 'saml_link', |
||
| 190 | 'simplesaml', |
||
| 191 | 'elgg-jsonp', |
||
| 192 | 'machine_translation', |
||
| 193 | 'phpmailer', |
||
| 194 | 'gc_newsfeed', |
||
| 195 | 'gc_onboard', |
||
| 196 | 'gc_splash_page', |
||
| 197 | 'gc_group_layout', |
||
| 198 | 'gcconnex_theme', |
||
| 199 | 'gc_streaming_content', |
||
| 200 | 'multi_file_upload', |
||
| 201 | 'gccollab_stats', |
||
| 202 | 'gc_communities', |
||
| 203 | 'gc_tags', |
||
| 204 | 'gc_elgg_sitemap', |
||
| 205 | ); |
||
| 206 | $plugins_off_connex = array( |
||
| 207 | 'developers', |
||
| 208 | 'oauth_api', |
||
| 209 | 'reportedcontent', |
||
| 210 | 'search', |
||
| 211 | 'tagcloud', |
||
| 212 | 'tasks', |
||
| 213 | 'twitter', |
||
| 214 | 'unvalidated_user_cleanup', |
||
| 215 | 'twitter_api', |
||
| 216 | 'sphinx', |
||
| 217 | 'gc_group_deletion', |
||
| 218 | 'custom_error_page', |
||
| 219 | 'maintenance', |
||
| 220 | 'gc_fedsearch_gsa', |
||
| 221 | 'gc_official_groups', |
||
| 222 | 'apiadmin', |
||
| 223 | 'gc_profile_nudge', |
||
| 224 | 'enhanced_user_search', |
||
| 225 | 'GC_profileStrength_collab', |
||
| 226 | 'b_extended_profile_collab', |
||
| 227 | 'gcRegistration_collab', |
||
| 228 | 'gc_onboard_collab', |
||
| 229 | 'gc_splash_page_collab', |
||
| 230 | 'gccollab_theme', |
||
| 231 | ); |
||
| 232 | |||
| 233 | |||
| 234 | // GCcollab |
||
| 235 | $plugins_collab = array( |
||
| 236 | 'garbagecollector', |
||
| 237 | 'groups', |
||
| 238 | 'logrotate', |
||
| 239 | 'group_tools', |
||
| 240 | 'blog', |
||
| 241 | 'bookmarks', |
||
| 242 | 'dashboard', |
||
| 243 | 'diagnostics', |
||
| 244 | 'friend_request', |
||
| 245 | 'externalpages', |
||
| 246 | 'file', |
||
| 247 | 'embed', |
||
| 248 | 'group_operators', |
||
| 249 | 'htmlawed', |
||
| 250 | 'invitefriends', |
||
| 251 | 'likes', |
||
| 252 | 'logbrowser', |
||
| 253 | 'messageboard', |
||
| 254 | 'messages', |
||
| 255 | 'polls', |
||
| 256 | 'profile', |
||
| 257 | 'rename_friends', |
||
| 258 | 'search', |
||
| 259 | 'members', |
||
| 260 | 'thewire', |
||
| 261 | 'uservalidationbyemail', |
||
| 262 | 'unvalidatedemailchange', |
||
| 263 | 'widget_manager', |
||
| 264 | 'zaudio', |
||
| 265 | 'custom_index_widgets', |
||
| 266 | 'file_tools', |
||
| 267 | 'event_calendar', |
||
| 268 | 'ideas', |
||
| 269 | 'unvalidated_user_cleanup', |
||
| 270 | 'pages', |
||
| 271 | 'analytics', |
||
| 272 | 'tidypics', |
||
| 273 | 'translation_editor', |
||
| 274 | 'gcProfilePictureBadges', |
||
| 275 | 'upload_users', |
||
| 276 | 'c_email_extensions', |
||
| 277 | 'gcRegistration_collab', |
||
| 278 | 'c_module_dump', |
||
| 279 | 'au_subgroups', |
||
| 280 | 'widget_manager_accessibility', |
||
| 281 | 'b_extended_profile', |
||
| 282 | 'b_extended_profile_collab', |
||
| 283 | 'blog_tools', |
||
| 284 | 'ckeditor', |
||
| 285 | 'contactform', |
||
| 286 | 'site_notifications', |
||
| 287 | 'web_services', |
||
| 288 | 'missions_organization', |
||
| 289 | 'missions', |
||
| 290 | 'missions_collab', |
||
| 291 | 'data_views', |
||
| 292 | 'mt_activity_tabs', |
||
| 293 | 'gc_api', |
||
| 294 | 'achievement_badges', |
||
| 295 | 'embed_extender', |
||
| 296 | 'toggle_language', |
||
| 297 | 'cp_notifications', |
||
| 298 | 'login_as', |
||
| 299 | 'thewire_tools', |
||
| 300 | 'mentions', |
||
| 301 | 'GoC_dev_banner', |
||
| 302 | 'etherpad', |
||
| 303 | 'wet4', |
||
| 304 | 'wet4_collab', |
||
| 305 | 'GC_profileStrength', |
||
| 306 | 'GC_profileStrength_collab', |
||
| 307 | 'elgg-jsonp', |
||
| 308 | 'phpmailer', |
||
| 309 | 'gc_onboard', |
||
| 310 | 'gc_onboard_collab', |
||
| 311 | 'gc_newsfeed', |
||
| 312 | 'gc_splash_page', |
||
| 313 | 'gc_splash_page_collab', |
||
| 314 | 'gc_group_layout', |
||
| 315 | 'freshdesk_help', |
||
| 316 | 'gccollab_stats', |
||
| 317 | 'gccollab_theme', |
||
| 318 | 'gc_streaming_content', |
||
| 319 | 'multi_file_upload', |
||
| 320 | 'vroom', |
||
| 321 | 'elgg_solr', |
||
| 322 | 'elgg_recaptcha', |
||
| 323 | 'loginrequired', |
||
| 324 | 'gcRegistration_invitation', |
||
| 325 | 'gc_autosubscribegroup', |
||
| 326 | 'linkedin_profile_importer', |
||
| 327 | 'apiadmin', |
||
| 328 | 'gc_mobile_api', |
||
| 329 | 'gc_communities', |
||
| 330 | 'gc_tags', |
||
| 331 | 'gc_elgg_sitemap', |
||
| 332 | 'thewire_images', |
||
| 333 | ); |
||
| 334 | $plugins_off_collab = array( |
||
| 335 | 'developers', |
||
| 336 | 'gcforums', |
||
| 337 | 'oauth_api', |
||
| 338 | 'reportedcontent', |
||
| 339 | 'tagcloud', |
||
| 340 | 'tasks', |
||
| 341 | 'twitter', |
||
| 342 | 'twitter_api', |
||
| 343 | 'sphinx', |
||
| 344 | 'gcRegistration', |
||
| 345 | 'c_members_byDepartment', |
||
| 346 | 'gc_group_deletion', |
||
| 347 | 'custom_error_page', |
||
| 348 | 'geds_sync', |
||
| 349 | 'questions', |
||
| 350 | 'saml_link', |
||
| 351 | 'simplesaml', |
||
| 352 | 'maintenance', |
||
| 353 | 'machine_translation', |
||
| 354 | 'gcconnex_theme', |
||
| 355 | 'gc_fedsearch_gsa', |
||
| 356 | 'gc_official_groups', |
||
| 357 | 'apiadmin', |
||
| 358 | 'gc_profile_nudge', |
||
| 359 | 'enhanced_user_search', |
||
| 360 | 'pleio', // move to enabled to test with openid |
||
| 361 | ); |
||
| 362 | |||
| 363 | |||
| 364 | // deactivate plugins that are not active in prod, order doesn't matter. |
||
| 365 | // This happens first to ensure we don't run into conflicts when activating mods in the next step |
||
| 366 | $plugins_off = ${"plugins_off_$type"}; |
||
| 367 | foreach ($plugins_off as $key => $id) { |
||
| 368 | $plugin = elgg_get_plugin_from_id($id); |
||
| 369 | |||
| 370 | if (!$plugin) { |
||
| 371 | unset($plugins_off[$key]); |
||
| 372 | continue; |
||
| 373 | } |
||
| 374 | |||
| 375 | if (!$plugin->isActive()){ |
||
| 376 | unset($plugins_off[$key]); |
||
| 377 | continue; |
||
| 378 | } |
||
| 379 | |||
| 380 | $plugin->deactivate(); |
||
| 381 | } |
||
| 382 | |||
| 383 | |||
| 384 | // activate plugins that are not activated on install, arrange those that are |
||
| 385 | $plugins = ${"plugins_$type"}; |
||
| 386 | foreach ($plugins as $key => $id) { |
||
| 387 | $plugin = elgg_get_plugin_from_id($id); |
||
| 388 | |||
| 389 | if (!$plugin) { |
||
| 390 | unset($plugins[$key]); |
||
| 391 | continue; |
||
| 392 | } |
||
| 393 | |||
| 394 | $plugin->setPriority('last'); // move to the end of the list |
||
| 395 | |||
| 396 | if ($plugin->isActive()){ |
||
| 397 | unset($plugins[$key]); |
||
| 398 | continue; |
||
| 399 | } |
||
| 400 | |||
| 401 | $plugin->activate(); |
||
| 402 | } |
||
| 403 | } |
||
| 404 |