| Conditions | 18 |
| Paths | 2808 |
| Total Lines | 113 |
| Code Lines | 58 |
| 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 |
||
| 107 | function get_user_interface() |
||
| 108 | { |
||
| 109 | // copied from bookmarks module. |
||
| 110 | $cat = createobject('phpgwapi.categories','','calendar'); |
||
| 111 | $cats = $cat->return_array('all',0,False,'','cat_name','',True); |
||
| 112 | $cat_ids = array(); |
||
| 113 | foreach($cats as $category) |
||
| 114 | { |
||
| 115 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
||
| 116 | } |
||
| 117 | $this->arguments['category']['options'] = $cat_ids; |
||
| 118 | if (count($cat_ids) > 5) { |
||
| 119 | $this->arguments['category']['multiple'] = 5; |
||
| 120 | } |
||
| 121 | |||
| 122 | if (! isset($GLOBALS['egw']->accounts)) |
||
| 123 | { |
||
| 124 | $GLOBALS['egw']->accounts = new Api\Accounts(); |
||
| 125 | } |
||
| 126 | $this->accounts =& $GLOBALS['egw']->accounts; |
||
| 127 | $search_params=array( |
||
| 128 | 'type' => 'both', |
||
| 129 | 'app' => 'calendar', |
||
| 130 | ); |
||
| 131 | $accounts = $this->accounts->search($search_params); |
||
| 132 | $users = array(); |
||
| 133 | $groups = array(); |
||
| 134 | // sort users and groups separately. |
||
| 135 | if (isset($GLOBALS['sitemgr_info']['anonymous_user'])) |
||
| 136 | { |
||
| 137 | $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'],'account_lid','u'); |
||
| 138 | } |
||
| 139 | else |
||
| 140 | { |
||
| 141 | // sitemgr is not in global variables. Get it. |
||
| 142 | /* |
||
| 143 | * Get possible sitemgr paths from the HTTP_REFERRER in order to unreveal the |
||
| 144 | * anonymous user for the correct site. |
||
| 145 | */ |
||
| 146 | $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/',"/\${1}",$_SERVER['HTTP_REFERER']); |
||
| 147 | // Remove the trailing file- / pathname if any |
||
| 148 | $sitemgr_path = preg_replace('/[^\/]*$/', '', $sitemgr_path); |
||
| 149 | // Add leading slash if it has been lost. |
||
| 150 | if (strncmp('/', $sitemgr_path, 1) != 0) |
||
| 151 | { |
||
| 152 | $sitemgr_path = '/'.$sitemgr_path; |
||
| 153 | } |
||
| 154 | |||
| 155 | // Code adapted from sitemgr-site/index.php |
||
| 156 | $site_urls = array(); |
||
| 157 | $site_urls[] = $sitemgr_path; |
||
| 158 | $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $sitemgr_path; |
||
| 159 | $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $sitemgr_path; |
||
| 160 | |||
| 161 | $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id', |
||
| 162 | array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr')->fetchColumn(),'account_lid','u'); |
||
| 163 | } |
||
| 164 | |||
| 165 | $anon_groups = $this->accounts->memberships($anon_user,true); |
||
| 166 | foreach ($accounts as $entry) |
||
| 167 | { |
||
| 168 | $is_group = false; |
||
| 169 | $has_read_permissions = false; |
||
| 170 | $acl = new Acl($entry['account_id']); |
||
| 171 | $acl->read_repository(); |
||
| 172 | // get the rights for each account to check whether the anon user has read permissions. |
||
| 173 | $rights = $acl->get_rights($anon_user,'calendar'); |
||
| 174 | // also add the anon user if it's his own calendar. |
||
| 175 | if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user)) |
||
| 176 | { |
||
| 177 | $has_read_permissions = true; |
||
| 178 | } |
||
| 179 | else |
||
| 180 | { |
||
| 181 | // scan the groups which pass on permissions to the anon user group member |
||
| 182 | // or ass permissions if this is the anon group's calendar. |
||
| 183 | foreach ($anon_groups as $parent_group) |
||
| 184 | { |
||
| 185 | $rights = $acl->get_rights($parent_group,'calendar'); |
||
| 186 | if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group)) |
||
| 187 | { |
||
| 188 | $has_read_permissions = true; |
||
| 189 | break; |
||
| 190 | } |
||
| 191 | } |
||
| 192 | } |
||
| 193 | if ($has_read_permissions) |
||
| 194 | { |
||
| 195 | // Separate groups from users for improved readability. |
||
| 196 | if ($is_group) |
||
| 197 | { |
||
| 198 | $groups[$entry['account_id']] = $entry['account_lid']; |
||
| 199 | } |
||
| 200 | else |
||
| 201 | { |
||
| 202 | $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
||
| 203 | } |
||
| 204 | } |
||
| 205 | } |
||
| 206 | asort($groups); |
||
| 207 | asort($users); |
||
| 208 | // concat users and groups to the option array. |
||
| 209 | $this->arguments['users']['options'] = $groups + $users; |
||
| 210 | if (count($this->arguments['users']['options']) > 10) |
||
| 211 | { |
||
| 212 | $this->arguments['users']['multiple'] = 10; |
||
| 213 | } |
||
| 214 | else if (count($this->arguments['users']['options']) > 0) |
||
| 215 | { |
||
| 216 | $this->arguments['users']['multiple'] = true; |
||
| 217 | } |
||
| 218 | |||
| 219 | return parent::get_user_interface(); |
||
| 220 | } |
||
| 315 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths