| Conditions | 10 |
| Paths | 256 |
| Total Lines | 226 |
| Code Lines | 179 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 111 | static function settings($hook_data) |
||
| 112 | { |
||
| 113 | $settings = array( |
||
| 114 | array( |
||
| 115 | 'type' => 'section', |
||
| 116 | 'title' => lang('General settings'), |
||
| 117 | 'no_lang'=> true, |
||
| 118 | 'xmlrpc' => False, |
||
| 119 | 'admin' => False |
||
| 120 | ), |
||
| 121 | ); |
||
| 122 | $settings['add_default'] = array( |
||
| 123 | 'type' => 'select', |
||
| 124 | 'label' => 'Default addressbook for adding contacts', |
||
| 125 | 'name' => 'add_default', |
||
| 126 | 'help' => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.', |
||
| 127 | 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks',Acl::ADD) : array(), |
||
| 128 | 'xmlrpc' => True, |
||
| 129 | 'admin' => False, |
||
| 130 | ); |
||
| 131 | if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
||
| 132 | { |
||
| 133 | $settings['private_addressbook'] = array( |
||
| 134 | 'type' => 'check', |
||
| 135 | 'label' => 'Enable an extra private addressbook', |
||
| 136 | 'name' => 'private_addressbook', |
||
| 137 | 'help' => 'Do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook?', |
||
| 138 | 'xmlrpc' => True, |
||
| 139 | 'admin' => False, |
||
| 140 | 'forced' => false, |
||
| 141 | ); |
||
| 142 | } |
||
| 143 | $settings['hide_accounts'] = array( |
||
| 144 | 'type' => 'select', |
||
| 145 | 'values' => array('1' => lang('Hide all accounts'), '0' => lang('Show active accounts'), 'none' => lang('Show all accounts')), |
||
| 146 | 'label' => 'Hide accounts from addressbook', |
||
| 147 | 'name' => 'hide_accounts', |
||
| 148 | 'help' => 'Hides accounts completly from the adressbook.', |
||
| 149 | 'xmlrpc' => True, |
||
| 150 | 'admin' => false, |
||
| 151 | 'default'=> '0' |
||
| 152 | ); |
||
| 153 | $settings['hide_groups_as_lists'] = array( |
||
| 154 | 'type' => 'check', |
||
| 155 | 'label' => 'Hide user groups as distribution lists', |
||
| 156 | 'name' => 'hide_groups_as_lists', |
||
| 157 | 'help' => 'User groups are automatically shown as distribution lists.', |
||
| 158 | 'xmlrpc' => False, |
||
| 159 | 'admin' => false, |
||
| 160 | 'default'=> '0' |
||
| 161 | ); |
||
| 162 | $contacts = new Api\Contacts(); |
||
| 163 | $fileas_options = $contacts->fileas_options(); |
||
| 164 | foreach(Api\Contacts\Storage::$duplicate_fields as $key => $label) |
||
| 165 | { |
||
| 166 | $duplicate_options[$key] = lang($label); |
||
| 167 | } |
||
| 168 | |||
| 169 | $settings['link_title'] = array( |
||
| 170 | 'type' => 'select', |
||
| 171 | 'label' => 'Link title for contacts show', |
||
| 172 | 'name' => 'link_title', |
||
| 173 | 'values' => array( |
||
| 174 | 'n_fileas' => lang('own sorting').' ('.lang('default').': '.lang('Company').': '.lang('lastname').', '.lang('firstname').')', |
||
| 175 | )+$fileas_options, // plus all fileas types |
||
| 176 | 'help' => 'What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!', |
||
| 177 | 'xmlrpc' => True, |
||
| 178 | 'admin' => false, |
||
| 179 | 'default'=> 'org_name: n_family, n_given', |
||
| 180 | ); |
||
| 181 | if (($cf_opts = Api\Contacts::cf_options())) |
||
| 182 | { |
||
| 183 | $settings['link_title_cf'] = array( |
||
| 184 | 'type' => 'multiselect', |
||
| 185 | 'label' => 'Add a customfield to link title', |
||
| 186 | 'name' => 'link_title_cf', |
||
| 187 | 'values' => $cf_opts, |
||
| 188 | 'help' => 'Add customfield to links of addressbook, which displays in other applications. The default value is none customfield.', |
||
| 189 | 'xmlrpc' => True, |
||
| 190 | 'admin' => false, |
||
| 191 | ); |
||
| 192 | } |
||
| 193 | $settings['addr_format'] = array( |
||
| 194 | 'type' => 'select', |
||
| 195 | 'label' => 'Default address format', |
||
| 196 | 'name' => 'addr_format', |
||
| 197 | 'values' => array( |
||
| 198 | 'postcode_city' => lang('zip code').' '.lang('City'), |
||
| 199 | 'city_state_postcode' => lang('City').' '.lang('State').' '.lang('zip code'), |
||
| 200 | ), |
||
| 201 | 'help' => 'Which address format should the addressbook use for countries it does not know the address format. If the address format of a country is known, it uses it independent of this setting.', |
||
| 202 | 'xmlrpc' => True, |
||
| 203 | 'admin' => false, |
||
| 204 | 'default'=> 'postcode_city', |
||
| 205 | ); |
||
| 206 | $settings['fileas_default'] = array( |
||
| 207 | 'type' => 'select', |
||
| 208 | 'label' => 'Default file as format', |
||
| 209 | 'name' => 'fileas_default', |
||
| 210 | 'values' => $fileas_options, |
||
| 211 | 'help' => 'Default format for fileas, eg. for new entries.', |
||
| 212 | 'xmlrpc' => True, |
||
| 213 | 'admin' => false, |
||
| 214 | 'default'=> 'org_name: n_family, n_given', |
||
| 215 | ); |
||
| 216 | $settings['duplicate_fields'] = array( |
||
| 217 | 'type' => 'multiselect', |
||
| 218 | 'label' => 'Fields to check for duplicates', |
||
| 219 | 'name' => 'duplicate_fields', |
||
| 220 | 'values' => $duplicate_options, |
||
| 221 | 'help' => 'Fields to consider when looking for duplicate contacts.', |
||
| 222 | 'admin' => false, |
||
| 223 | 'default' => 'n_family,org_name,contact_email' |
||
| 224 | ); |
||
| 225 | $settings['duplicate_threshold'] = array( |
||
| 226 | 'type' => 'input', |
||
| 227 | 'size' => 5, |
||
| 228 | 'label' => 'Duplicate threshold', |
||
| 229 | 'name' => 'duplicate_threshold', |
||
| 230 | 'help' => 'How many fields must match for the record to be considered a duplicate.', |
||
| 231 | 'xmlrpc' => True, |
||
| 232 | 'default'=> 3, |
||
| 233 | 'admin' => False |
||
| 234 | ); |
||
| 235 | |||
| 236 | $crm_list_options = array( |
||
| 237 | '~edit~' => lang('Edit contact'), |
||
| 238 | 'infolog' => lang('Open %1 CRM view', lang('infolog')), |
||
| 239 | 'infolog-organisation' => lang('infolog-organisation'), |
||
| 240 | ); |
||
| 241 | if($GLOBALS['egw_info']['user']['apps']['tracker']) |
||
| 242 | { |
||
| 243 | $crm_list_options['tracker'] = lang('Open %1 CRM view', lang('tracker')); |
||
| 244 | } |
||
| 245 | $settings['crm_list'] = array( |
||
| 246 | 'type' => 'select', |
||
| 247 | 'label' => 'Default action on double-click', |
||
| 248 | 'name' => 'crm_list', |
||
| 249 | 'values' => $crm_list_options, |
||
| 250 | 'help' => 'When viewing a contact, show linked entries from the selected application', |
||
| 251 | 'xmlrpc' => True, |
||
| 252 | 'admin' => false, |
||
| 253 | 'default'=> 'infolog', |
||
| 254 | ); |
||
| 255 | |||
| 256 | $settings['geolocation_src'] = array( |
||
| 257 | 'type' => 'select', |
||
| 258 | 'label' => 'Default GeoLocation source address', |
||
| 259 | 'name' => 'geolocation_src', |
||
| 260 | 'values' => array( |
||
| 261 | 'browser' => lang('Browser location'), |
||
| 262 | 'one' => lang('Business address'), |
||
| 263 | 'two' => lang('Private address') |
||
| 264 | ), |
||
| 265 | 'help' => 'Select a source address to be used in GeoLocation routing system', |
||
| 266 | 'xmlrpc' => True, |
||
| 267 | 'admin' => false, |
||
| 268 | 'default'=> 'browser', |
||
| 269 | ); |
||
| 270 | |||
| 271 | $settings[] = array( |
||
| 272 | 'type' => 'section', |
||
| 273 | 'title' => lang('Data exchange settings'), |
||
| 274 | 'no_lang'=> true, |
||
| 275 | 'xmlrpc' => False, |
||
| 276 | 'admin' => False |
||
| 277 | ); |
||
| 278 | // CSV Export |
||
| 279 | |||
| 280 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
||
| 281 | { |
||
| 282 | $settings['default_document'] = array( |
||
| 283 | 'type' => 'vfs_file', |
||
| 284 | 'size' => 60, |
||
| 285 | 'label' => 'Default document to insert contacts', |
||
| 286 | 'name' => 'default_document', |
||
| 287 | 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('addressbook')).' '. |
||
| 288 | lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. |
||
| 289 | lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
||
| 290 | 'run_lang' => false, |
||
| 291 | 'xmlrpc' => True, |
||
| 292 | 'admin' => False, |
||
| 293 | ); |
||
| 294 | $settings['document_dir'] = array( |
||
| 295 | 'type' => 'vfs_dirs', |
||
| 296 | 'size' => 60, |
||
| 297 | 'label' => 'Directory with documents to insert contacts', |
||
| 298 | 'name' => 'document_dir', |
||
| 299 | 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.',lang('addressbook')).' '. |
||
| 300 | lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. |
||
| 301 | lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
||
| 302 | 'run_lang' => false, |
||
| 303 | 'xmlrpc' => True, |
||
| 304 | 'admin' => False, |
||
| 305 | 'default' => '/templates/addressbook', |
||
| 306 | ); |
||
| 307 | } |
||
| 308 | |||
| 309 | if ($GLOBALS['egw_info']['user']['apps']['felamimail'] || $GLOBALS['egw_info']['user']['apps']['mail']) |
||
| 310 | { |
||
| 311 | $settings['force_mailto'] = array( |
||
| 312 | 'type' => 'check', |
||
| 313 | 'label' => 'Open EMail addresses in external mail program', |
||
| 314 | 'name' => 'force_mailto', |
||
| 315 | 'help' => 'Default is to open EMail addresses in EGroupware EMail application, if user has access to it.', |
||
| 316 | 'xmlrpc' => True, |
||
| 317 | 'admin' => False, |
||
| 318 | 'default'=> false, |
||
| 319 | ); |
||
| 320 | } |
||
| 321 | |||
| 322 | // Import / Export for nextmatch |
||
| 323 | if ($GLOBALS['egw_info']['user']['apps']['importexport']) |
||
| 324 | { |
||
| 325 | $settings['vcard_charset'] = array( |
||
| 326 | 'type' => 'select', |
||
| 327 | 'label' => 'Charset for the vCard import and export', |
||
| 328 | 'name' => 'vcard_charset', |
||
| 329 | 'values' => Api\Translation::get_installed_charsets(), |
||
| 330 | 'help' => 'Which charset should be used for the vCard import and export.', |
||
| 331 | 'xmlrpc' => True, |
||
| 332 | 'admin' => false, |
||
| 333 | 'default'=> 'utf-8', |
||
| 334 | ); |
||
| 335 | } |
||
| 336 | return $settings; |
||
| 337 | } |
||
| 580 |