| Conditions | 21 |
| Paths | > 20000 |
| Total Lines | 118 |
| Code Lines | 55 |
| 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 |
||
| 35 | static function all_hooks($args) |
||
| 36 | { |
||
| 37 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
||
| 38 | |||
| 39 | $appname = 'admin'; |
||
| 40 | $location = is_array($args) ? $args['location'] : $args; |
||
| 41 | |||
| 42 | if ($location == 'sidebox_menu') |
||
| 43 | { |
||
| 44 | // Destination div for folder tree |
||
| 45 | $file[] = array( |
||
| 46 | 'no_lang' => true, |
||
| 47 | // Tree has about 20 leaves (or more) in it, but the sidebox starts |
||
| 48 | // with no content. Set some minimum height to make sure scrolling is triggered. |
||
| 49 | 'text' => '<div id="admin_tree_target" class="admin_tree" style="min-height:20em"/>', |
||
| 50 | 'link' => false, |
||
| 51 | 'icon' => false |
||
| 52 | ); |
||
| 53 | display_sidebox($appname,lang('Admin'),$file); |
||
| 54 | return; |
||
| 55 | } |
||
| 56 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
||
| 57 | { |
||
| 58 | |||
| 59 | if (! $GLOBALS['egw']->acl->check('site_config_acce',1,'admin')) |
||
| 60 | { |
||
| 61 | $file['Site Configuration'] = Egw::link('/index.php','menuaction=admin.admin_config.index&appname=admin&ajax=true'); |
||
| 62 | } |
||
| 63 | |||
| 64 | if (! $GLOBALS['egw']->acl->check('account_access',1,'admin')) |
||
| 65 | { |
||
| 66 | $file['User Accounts'] = array( |
||
| 67 | 'id' => '/accounts', |
||
| 68 | 'icon' => Api\Image::find('addressbook', 'accounts'), |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | |||
| 72 | if (! $GLOBALS['egw']->acl->check('account_access',16,'admin')) |
||
| 73 | { |
||
| 74 | $file['Bulk password reset'] = Egw::link('/index.php','menuaction=admin.admin_passwordreset.index&ajax=true'); |
||
| 75 | } |
||
| 76 | |||
| 77 | if (! $GLOBALS['egw']->acl->check('group_access',1,'admin')) |
||
| 78 | { |
||
| 79 | $file['User Groups'] = array( |
||
| 80 | 'id' => '/groups', |
||
| 81 | 'icon' => Api\Image::find('addressbook', 'group'), |
||
| 82 | 'child' => 1, |
||
| 83 | ); |
||
| 84 | } |
||
| 85 | |||
| 86 | if (! $GLOBALS['egw']->acl->check('global_categorie',1,'admin')) |
||
| 87 | { |
||
| 88 | $file['Global Categories'] = Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=phpgw&ajax=true'); |
||
| 89 | } |
||
| 90 | |||
| 91 | if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin')) |
||
| 92 | { |
||
| 93 | $file['Change Login Screen Message'] = Egw::link('/index.php','menuaction=admin.admin_messages.index'); |
||
| 94 | } |
||
| 95 | |||
| 96 | if (! $GLOBALS['egw']->acl->check('current_sessions',1,'admin')) |
||
| 97 | { |
||
| 98 | $file['View Sessions'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true'); |
||
| 99 | } |
||
| 100 | |||
| 101 | if (! $GLOBALS['egw']->acl->check('access_log_acces',1,'admin')) |
||
| 102 | { |
||
| 103 | $file['View Access Log'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.index&ajax=true'); |
||
| 104 | } |
||
| 105 | |||
| 106 | /* disable old EGroupware error_log, as it is not used anymore |
||
| 107 | if (! $GLOBALS['egw']->acl->check('error_log_access',1,'admin')) |
||
| 108 | { |
||
| 109 | $file['View Error Log'] = Egw::link('/index.php','menuaction=admin.uilog.list_log'); |
||
| 110 | }*/ |
||
| 111 | |||
| 112 | if (! $GLOBALS['egw']->acl->check('applications_acc',16,'admin')) |
||
| 113 | { |
||
| 114 | $file['Clear cache and register hooks'] = array( |
||
| 115 | 'id' => 'admin/clear_cache', |
||
| 116 | 'no_lang' => true, |
||
| 117 | 'link' => "javascript:app.admin.clear_cache();", |
||
| 118 | ); |
||
| 119 | } |
||
| 120 | |||
| 121 | if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin')) |
||
| 122 | { |
||
| 123 | $file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.admin_asyncservice.index'); |
||
| 124 | } |
||
| 125 | |||
| 126 | if (! $GLOBALS['egw']->acl->check('db_backup_access',1,'admin')) |
||
| 127 | { |
||
| 128 | $file['DB backup and restore'] = Egw::link('/index.php','menuaction=admin.admin_db_backup.index'); |
||
| 129 | } |
||
| 130 | |||
| 131 | if (! $GLOBALS['egw']->acl->check('info_access',1,'admin')) |
||
| 132 | { |
||
| 133 | $file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')"; |
||
| 134 | } |
||
| 135 | $file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index&ajax=true'); |
||
| 136 | $file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes&ajax=true'); |
||
| 137 | $file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index'); |
||
| 138 | $file['Changelog and versions'] = Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Framework\\About.index&ajax=true'); |
||
| 139 | |||
| 140 | $file['Submit statistic information'] = Egw::link('/index.php','menuaction=admin.admin_statistics.submit'); |
||
| 141 | |||
| 142 | if ($location == 'admin') |
||
| 143 | { |
||
| 144 | display_section($appname,$file); |
||
| 145 | } |
||
| 146 | else |
||
| 147 | { |
||
| 148 | foreach($file as &$url) |
||
| 149 | { |
||
| 150 | if (is_array($url) && $url['link']) $url = $url['link']; |
||
| 151 | } |
||
| 152 | display_sidebox($appname,lang('Admin'),$file); |
||
| 153 | } |
||
| 271 |