@@ -108,7 +108,7 @@ |
||
108 | 108 | |
109 | 109 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile()) |
110 | 110 | { |
111 | - $file = Array( |
|
111 | + $file = array( |
|
112 | 112 | 'Site configuration' => Egw::link('/index.php',array( |
113 | 113 | 'menuaction' => 'infolog.infolog_ui.admin' )), |
114 | 114 | 'Global Categories' => Egw::link('/index.php',array( |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | static function not_enum_group_acls($location) |
25 | 25 | { |
26 | - unset($location); // not used, but part of hook signature |
|
26 | + unset($location); // not used, but part of hook signature |
|
27 | 27 | $config = config::read('infolog'); |
28 | 28 | |
29 | 29 | return $config['group_owners']; |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | */ |
38 | 38 | static function search_link($location) |
39 | 39 | { |
40 | - unset($location); // not used, but part of hook signature |
|
40 | + unset($location); // not used, but part of hook signature |
|
41 | 41 | // register our not_enum_group_acls hook, if not already registered |
42 | 42 | // can be removed after next infolog version update after 1.6 |
43 | 43 | if ($GLOBALS['egw']->hooks->single('not_enum_group_acls', 'infolog') === false) |
44 | 44 | { |
45 | 45 | $setup_info = array(); |
46 | 46 | include(EGW_INCLUDE_ROOT.'/infolog/setup/setup.inc.php'); |
47 | - $GLOBALS['egw']->hooks->register_hooks('infolog',$setup_info['infolog']['hooks']); |
|
47 | + $GLOBALS['egw']->hooks->register_hooks('infolog', $setup_info['infolog']['hooks']); |
|
48 | 48 | unset($setup_info); |
49 | 49 | } |
50 | 50 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'add_id' => 'action_id', |
70 | 70 | 'add_popup' => '750x550', |
71 | 71 | 'file_access'=> 'infolog.infolog_bo.file_access', |
72 | - 'file_access_user' => true, // file_access supports 4th parameter $user |
|
72 | + 'file_access_user' => true, // file_access supports 4th parameter $user |
|
73 | 73 | 'edit' => array( |
74 | 74 | 'menuaction' => 'infolog.infolog_ui.edit', |
75 | 75 | ), |
@@ -96,38 +96,38 @@ discard block |
||
96 | 96 | display_sidebox($appname, lang('Favorites'), egw_framework::favorite_list($appname)); |
97 | 97 | |
98 | 98 | $file = array( |
99 | - 'infolog list' => egw::link('/index.php',array( |
|
99 | + 'infolog list' => egw::link('/index.php', array( |
|
100 | 100 | 'menuaction' => 'infolog.infolog_ui.index', |
101 | 101 | 'ajax' => 'true')), |
102 | 102 | array( |
103 | - 'text' => lang('Add %1',lang(egw_link::get_registry($appname, 'entry'))), |
|
103 | + 'text' => lang('Add %1', lang(egw_link::get_registry($appname, 'entry'))), |
|
104 | 104 | 'no_lang' => true, |
105 | 105 | 'link' => "javascript:app.infolog.add_link_sidemenu();" |
106 | 106 | ), |
107 | - 'Placeholders' => egw::link('/index.php','menuaction=infolog.infolog_merge.show_replacements') |
|
107 | + 'Placeholders' => egw::link('/index.php', 'menuaction=infolog.infolog_merge.show_replacements') |
|
108 | 108 | ); |
109 | - display_sidebox($appname,$GLOBALS['egw_info']['apps']['infolog']['title'].' '.lang('Menu'),$file); |
|
109 | + display_sidebox($appname, $GLOBALS['egw_info']['apps']['infolog']['title'].' '.lang('Menu'), $file); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
113 | 113 | { |
114 | 114 | $file = Array( |
115 | - 'Site configuration' => egw::link('/index.php',array( |
|
115 | + 'Site configuration' => egw::link('/index.php', array( |
|
116 | 116 | 'menuaction' => 'infolog.infolog_ui.admin' )), |
117 | - 'Global Categories' => egw::link('/index.php',array( |
|
117 | + 'Global Categories' => egw::link('/index.php', array( |
|
118 | 118 | 'menuaction' => 'admin.admin_categories.index', |
119 | 119 | 'appname' => $appname, |
120 | 120 | 'global_cats'=> True)), |
121 | - 'Custom fields, typ and status' => egw::link('/index.php',array( |
|
121 | + 'Custom fields, typ and status' => egw::link('/index.php', array( |
|
122 | 122 | 'menuaction' => 'infolog.infolog_customfields.index')), |
123 | 123 | ); |
124 | 124 | if ($location == 'admin') |
125 | 125 | { |
126 | - display_section($appname,$file); |
|
126 | + display_section($appname, $file); |
|
127 | 127 | } |
128 | 128 | else |
129 | 129 | { |
130 | - display_sidebox($appname,lang('Admin'),$file); |
|
130 | + display_sidebox($appname, lang('Admin'), $file); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | static function settings() |
141 | 141 | { |
142 | 142 | /* Setup some values to fill the array of this app's settings below */ |
143 | - $info = new infolog_bo(); // need some labels from |
|
143 | + $info = new infolog_bo(); // need some labels from |
|
144 | 144 | $filters = $show_home = array(); |
145 | 145 | $show_home[] = lang("DON'T show InfoLog"); |
146 | 146 | $filters['none'] = $info->filters['']; |
147 | - foreach($info->filters as $key => $label) |
|
147 | + foreach ($info->filters as $key => $label) |
|
148 | 148 | { |
149 | 149 | $show_home[$key] = $filters[$key] = lang($label); |
150 | 150 | } |
151 | 151 | |
152 | 152 | // migrage old filter-pref 1,2 to the filter one 'own-open-today' |
153 | - if (isset($GLOBALS['type']) && in_array($GLOBALS['egw']->preferences->{$GLOBALS['type']}['homeShowEvents'],array('1','2'))) |
|
153 | + if (isset($GLOBALS['type']) && in_array($GLOBALS['egw']->preferences->{$GLOBALS['type']}['homeShowEvents'], array('1', '2'))) |
|
154 | 154 | { |
155 | - $GLOBALS['egw']->preferences->add('infolog','homeShowEvents','own-open-today',$GLOBALS['type']); |
|
155 | + $GLOBALS['egw']->preferences->add('infolog', 'homeShowEvents', 'own-open-today', $GLOBALS['type']); |
|
156 | 156 | $GLOBALS['egw']->preferences->save_repository(); |
157 | 157 | } |
158 | 158 | $show_links = array( |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'help' => 'Should the Infolog list show a unique numerical Id, which can be used eg. as ticket Id.', |
230 | 230 | 'xmlrpc' => True, |
231 | 231 | 'admin' => False, |
232 | - 'default'=> '1', // Yes |
|
232 | + 'default'=> '1', // Yes |
|
233 | 233 | ), |
234 | 234 | 'listNoSubs' => array( |
235 | 235 | 'type' => 'select', |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | 'help' => 'Should InfoLog show Subtasks, -calls or -notes in the normal view or not. You can always view the Subs via there parent.', |
244 | 244 | 'xmlrpc' => True, |
245 | 245 | 'admin' => False, |
246 | - 'default'=> '0', // Allways show them |
|
246 | + 'default'=> '0', // Allways show them |
|
247 | 247 | ), |
248 | 248 | 'show_links' => array( |
249 | 249 | 'type' => 'select', |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | 'help' => 'Should the Infolog list show the percent done only for status ongoing or two separate icons.', |
264 | 264 | 'xmlrpc' => True, |
265 | 265 | 'admin' => False, |
266 | - 'default'=> 1, // Yes |
|
266 | + 'default'=> 1, // Yes |
|
267 | 267 | ), |
268 | 268 | 'limit_des_lines' => array( |
269 | 269 | 'type' => 'input', |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | 'help' => 'Do you want a notification, if items you created get updated?', |
293 | 293 | 'xmlrpc' => True, |
294 | 294 | 'admin' => False, |
295 | - 'default'=> '1', // Yes |
|
295 | + 'default'=> '1', // Yes |
|
296 | 296 | ); |
297 | 297 | $settings['notify_assigned'] = array( |
298 | 298 | 'type' => 'select', |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | ), |
307 | 307 | 'xmlrpc' => True, |
308 | 308 | 'admin' => False, |
309 | - 'default'=> '1', // Yes |
|
309 | + 'default'=> '1', // Yes |
|
310 | 310 | ); |
311 | 311 | |
312 | 312 | // to add options for more then 3 days back or in advance, you need to update soinfolog::users_with_open_entries()! |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | '-1d' => lang('one day after'), |
316 | 316 | '0d' => lang('same day'), |
317 | 317 | '1d' => lang('one day in advance'), |
318 | - '2d' => lang('%1 days in advance',2), |
|
319 | - '3d' => lang('%1 days in advance',3), |
|
318 | + '2d' => lang('%1 days in advance', 2), |
|
319 | + '3d' => lang('%1 days in advance', 3), |
|
320 | 320 | ); |
321 | 321 | $settings['notify_due_delegated'] = array( |
322 | 322 | 'type' => 'select', |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | 'values' => $options, |
327 | 327 | 'xmlrpc' => True, |
328 | 328 | 'admin' => False, |
329 | - 'default'=> '0', // No |
|
329 | + 'default'=> '0', // No |
|
330 | 330 | ); |
331 | 331 | $settings['notify_due_responsible'] = array( |
332 | 332 | 'type' => 'select', |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | 'values' => $options, |
337 | 337 | 'xmlrpc' => True, |
338 | 338 | 'admin' => False, |
339 | - 'default'=> '0d', // Same day |
|
339 | + 'default'=> '0d', // Same day |
|
340 | 340 | ); |
341 | 341 | $settings['notify_start_delegated'] = array( |
342 | 342 | 'type' => 'select', |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | 'values' => $options, |
347 | 347 | 'xmlrpc' => True, |
348 | 348 | 'admin' => False, |
349 | - 'default'=> '0', // No |
|
349 | + 'default'=> '0', // No |
|
350 | 350 | ); |
351 | 351 | $settings['notify_start_responsible'] = array( |
352 | 352 | 'type' => 'select', |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | 'values' => $options, |
357 | 357 | 'xmlrpc' => True, |
358 | 358 | 'admin' => False, |
359 | - 'default'=> '0d', // Same day |
|
359 | + 'default'=> '0d', // Same day |
|
360 | 360 | ); |
361 | 361 | |
362 | 362 | // receive notification for items owned by groups you are part of |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | 'help' => 'Do you want a notification if items owned by groups you are part of get updated ?', |
368 | 368 | 'xmlrpc' => True, |
369 | 369 | 'admin' => False, |
370 | - 'default'=> '0', // No |
|
370 | + 'default'=> '0', // No |
|
371 | 371 | ); |
372 | 372 | |
373 | 373 | $settings[] = array( |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | 'size' => 60, |
387 | 387 | 'label' => 'Default document to insert entries', |
388 | 388 | 'name' => 'default_document', |
389 | - '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('infolog')).' '. |
|
390 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','info_subject').' '. |
|
389 | + '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('infolog')).' '. |
|
390 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'info_subject').' '. |
|
391 | 391 | lang('The following document-types are supported:').'*.rtf, *.txt', |
392 | 392 | 'run_lang' => false, |
393 | 393 | 'xmlrpc' => True, |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | 'size' => 60, |
399 | 399 | 'label' => 'Directory with documents to insert entries', |
400 | 400 | 'name' => 'document_dir', |
401 | - '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('infolog')).' '. |
|
402 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','info_subject').' '. |
|
401 | + '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('infolog')).' '. |
|
402 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'info_subject').' '. |
|
403 | 403 | lang('The following document-types are supported:').'*.rtf, *.txt', |
404 | 404 | 'run_lang' => false, |
405 | 405 | 'xmlrpc' => True, |
@@ -488,12 +488,12 @@ discard block |
||
488 | 488 | */ |
489 | 489 | private static function all_cats() |
490 | 490 | { |
491 | - $categories = new categories('','infolog'); |
|
491 | + $categories = new categories('', 'infolog'); |
|
492 | 492 | $accountId = $GLOBALS['egw_info']['user']['account_id']; |
493 | 493 | |
494 | - foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat) |
|
494 | + foreach ((array)$categories->return_sorted_array(0, False, '', '', '', true) as $cat) |
|
495 | 495 | { |
496 | - $s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']); |
|
496 | + $s = str_repeat(' ', $cat['level']).stripslashes($cat['name']); |
|
497 | 497 | |
498 | 498 | if ($cat['app_name'] == 'phpgw' || $cat['owner'] == '-1') |
499 | 499 | { |
@@ -501,13 +501,13 @@ discard block |
||
501 | 501 | } |
502 | 502 | elseif ($cat['owner'] != $accountId) |
503 | 503 | { |
504 | - $s .= '<' . $GLOBALS['egw']->accounts->id2name($cat['owner'], 'account_fullname') . '>'; |
|
504 | + $s .= '<'.$GLOBALS['egw']->accounts->id2name($cat['owner'], 'account_fullname').'>'; |
|
505 | 505 | } |
506 | 506 | elseif ($cat['access'] == 'private') |
507 | 507 | { |
508 | 508 | $s .= ' ♥'; |
509 | 509 | } |
510 | - $sel_options[$cat['id']] = $s; // 0.9.14 only |
|
510 | + $sel_options[$cat['id']] = $s; // 0.9.14 only |
|
511 | 511 | } |
512 | 512 | return $sel_options; |
513 | 513 | } |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | |
529 | 529 | if (!$async->read('infolog-async-notification')) |
530 | 530 | { |
531 | - $async->set_timer(array('hour' => 2),'infolog-async-notification','infolog.infolog_bo.async_notification',null); |
|
531 | + $async->set_timer(array('hour' => 2), 'infolog-async-notification', 'infolog.infolog_bo.async_notification', null); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public static function acl_rights($params) |
543 | 543 | { |
544 | - unset($params); // not used, but default function signature for hooks |
|
544 | + unset($params); // not used, but default function signature for hooks |
|
545 | 545 | return array( |
546 | 546 | acl::READ => 'read', |
547 | 547 | acl::ADD => 'add', |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | */ |
560 | 560 | public static function categories($location) |
561 | 561 | { |
562 | - unset($location); // not used, but part of hook signature |
|
562 | + unset($location); // not used, but part of hook signature |
|
563 | 563 | return true; |
564 | 564 | } |
565 | 565 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | public static function mail_import($args) |
572 | 572 | { |
573 | - return array ( |
|
573 | + return array( |
|
574 | 574 | 'menuaction' => 'infolog.infolog_ui.mail_import', |
575 | 575 | 'popup' => egw_link::get_registry('infolog', 'edit_popup') |
576 | 576 | ); |
@@ -464,7 +464,7 @@ |
||
464 | 464 | { |
465 | 465 | unset($args); // unused, but required by function signature |
466 | 466 | $appname = 'preferences'; |
467 | - $file = Array( |
|
467 | + $file = array( |
|
468 | 468 | 'Site configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'), |
469 | 469 | ); |
470 | 470 | display_section($appname, $file); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ); |
79 | 79 | |
80 | 80 | $account_display = array( |
81 | - 'firstname' => lang('Firstname'). ' '.lang('Lastname'), |
|
81 | + 'firstname' => lang('Firstname').' '.lang('Lastname'), |
|
82 | 82 | 'lastname' => lang('Lastname').', '.lang('Firstname'), |
83 | 83 | 'username' => lang('username'), |
84 | 84 | 'firstall' => lang('Firstname').' '.lang('Lastname').' ['.lang('username').']', |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $lang = setup::get_lang(); |
93 | 93 | if (empty($lang)) $lang = 'en'; |
94 | - list(,$country) = explode('-',$lang); |
|
94 | + list(,$country) = explode('-', $lang); |
|
95 | 95 | if (empty($country)) $country = $lang; |
96 | 96 | } |
97 | 97 | // check for old rte_font_size pref including px and split it in size and unit |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | substr($GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'], -2) == 'px') |
100 | 100 | { |
101 | 101 | $prefs = $GLOBALS['egw']->preferences; |
102 | - foreach(array('user','default','forced') as $type) |
|
102 | + foreach (array('user', 'default', 'forced') as $type) |
|
103 | 103 | { |
104 | 104 | if (substr($prefs->{$type}['common']['rte_font_size'], -2) == 'px') |
105 | 105 | { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | 'size' => 3, |
127 | 127 | 'xmlrpc' => True, |
128 | 128 | 'admin' => False, |
129 | - 'forced' => 20, // hidden as not used in eTemplate2 |
|
129 | + 'forced' => 20, // hidden as not used in eTemplate2 |
|
130 | 130 | ), |
131 | 131 | 'template_set' => array( |
132 | 132 | 'type' => 'select', |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'type' => 'select', |
153 | 153 | 'label' => 'Audio effect', |
154 | 154 | 'name' => 'audio_effect', |
155 | - 'values' => array('0'=>lang('Disable'),'1'=>lang('Enable')), |
|
155 | + 'values' => array('0'=>lang('Disable'), '1'=>lang('Enable')), |
|
156 | 156 | 'help' => 'Audio effect enables|disables sound effects used in the theme', |
157 | 157 | 'xmlrpc' => True, |
158 | 158 | 'admin' => False, |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | 'type' => 'multiselect', |
274 | 274 | 'label' => 'Permanent time zone selection', |
275 | 275 | 'name' => 'tz_selection', |
276 | - 'values' => $tzs ? call_user_func_array('array_merge',$tzs) : null, // only flat arrays supported |
|
276 | + 'values' => $tzs ? call_user_func_array('array_merge', $tzs) : null, // only flat arrays supported |
|
277 | 277 | 'help' => 'Please select timezones, you want to be able to quickly switch between. Switch is NOT shown, if less then two are selected.', |
278 | 278 | 'xmlrpc' => True, |
279 | 279 | 'admin' => False, |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | 'type' => 'select', |
405 | 405 | 'label' => 'Features of the editor', |
406 | 406 | 'name' => 'rte_features', |
407 | - 'values' => array('simple'=>'simple','extended'=>'regular','advanced'=>'everything'), |
|
407 | + 'values' => array('simple'=>'simple', 'extended'=>'regular', 'advanced'=>'everything'), |
|
408 | 408 | 'help' => 'How many toolbar buttons are available', |
409 | 409 | 'admin' => false, |
410 | 410 | 'default'=> 'extended' |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | { |
426 | 426 | $account_id = (int)$data['account_id']; |
427 | 427 | |
428 | - if($account_id > 0) // user |
|
428 | + if ($account_id > 0) // user |
|
429 | 429 | { |
430 | 430 | $GLOBALS['egw']->preferences->delete_user($account_id); |
431 | 431 | } |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | */ |
458 | 458 | static function admin($args) |
459 | 459 | { |
460 | - unset($args); // unused, but required by function signature |
|
460 | + unset($args); // unused, but required by function signature |
|
461 | 461 | $appname = 'preferences'; |
462 | 462 | $file = Array( |
463 | - 'Site configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname), |
|
463 | + 'Site configuration' => egw::link('/index.php', 'menuaction=admin.uiconfig.index&appname='.$appname), |
|
464 | 464 | ); |
465 | 465 | display_section($appname, $file); |
466 | 466 | } |
@@ -87,12 +87,21 @@ discard block |
||
87 | 87 | 'all' => '['.lang('username').'] '.lang('Lastname').','.lang('Firstname'), |
88 | 88 | ); |
89 | 89 | |
90 | - if ($hook_data['setup']) // called via setup |
|
90 | + if ($hook_data['setup']) |
|
91 | + { |
|
92 | + // called via setup |
|
91 | 93 | { |
92 | 94 | $lang = setup::get_lang(); |
93 | - if (empty($lang)) $lang = 'en'; |
|
95 | + } |
|
96 | + if (empty($lang)) |
|
97 | + { |
|
98 | + $lang = 'en'; |
|
99 | + } |
|
94 | 100 | list(,$country) = explode('-',$lang); |
95 | - if (empty($country)) $country = $lang; |
|
101 | + if (empty($country)) |
|
102 | + { |
|
103 | + $country = $lang; |
|
104 | + } |
|
96 | 105 | } |
97 | 106 | // check for old rte_font_size pref including px and split it in size and unit |
98 | 107 | if (!isset($GLOBALS['egw_setup']) && |
@@ -411,7 +420,10 @@ discard block |
||
411 | 420 | ), |
412 | 421 | ); |
413 | 422 | // disable thumbnails, if no size configured by admin |
414 | - if (!$GLOBALS['egw_info']['server']['link_list_thumbnail']) unset($settings['link_list_thumbnail']); |
|
423 | + if (!$GLOBALS['egw_info']['server']['link_list_thumbnail']) |
|
424 | + { |
|
425 | + unset($settings['link_list_thumbnail']); |
|
426 | + } |
|
415 | 427 | |
416 | 428 | return $settings; |
417 | 429 | } |
@@ -425,14 +437,20 @@ discard block |
||
425 | 437 | { |
426 | 438 | $account_id = (int)$data['account_id']; |
427 | 439 | |
428 | - if($account_id > 0) // user |
|
440 | + if($account_id > 0) |
|
441 | + { |
|
442 | + // user |
|
429 | 443 | { |
430 | 444 | $GLOBALS['egw']->preferences->delete_user($account_id); |
431 | 445 | } |
432 | - elseif ($account_id < 0) // group |
|
446 | + } |
|
447 | + elseif ($account_id < 0) |
|
448 | + { |
|
449 | + // group |
|
433 | 450 | { |
434 | 451 | $GLOBALS['egw']->preferences->delete_group($account_id); |
435 | 452 | } |
453 | + } |
|
436 | 454 | } |
437 | 455 | |
438 | 456 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * Context for this portlet |
36 | 36 | */ |
37 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
37 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
38 | 38 | { |
39 | 39 | if (false) parent::__construct(); |
40 | 40 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @see http://openweathermap.org/api |
131 | 131 | * @param array $query |
132 | 132 | */ |
133 | - public function get_weather(Array $query, $api_url = '') |
|
133 | + public function get_weather(array $query, $api_url = '') |
|
134 | 134 | { |
135 | 135 | static $debug = false; |
136 | 136 | if(!$api_url) |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function __construct(Array &$context = array(), &$need_reload = false) |
35 | 35 | { |
36 | 36 | // City not set for new widgets created via context menu |
37 | - if(!$context['city'] || $context['height'] < 2) |
|
37 | + if (!$context['city'] || $context['height'] < 2) |
|
38 | 38 | { |
39 | 39 | // Set initial size to 3x2, default is too small |
40 | 40 | $context['width'] = 3; |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | $this->context = $context; |
47 | 47 | } |
48 | 48 | |
49 | - public function exec($id = null, etemplate_new &$etemplate = null) |
|
49 | + public function exec($id = null, etemplate_new&$etemplate = null) |
|
50 | 50 | { |
51 | 51 | // Allow to submit directly back here |
52 | - if(is_array($id) && $id['id']) |
|
52 | + if (is_array($id) && $id['id']) |
|
53 | 53 | { |
54 | 54 | $id = $id['id']; |
55 | 55 | } |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | 'cnt' => 10 |
66 | 66 | ); |
67 | 67 | |
68 | - if($this->context['city']) |
|
68 | + if ($this->context['city']) |
|
69 | 69 | { |
70 | 70 | $content += $this->get_weather($request); |
71 | 71 | } |
72 | 72 | |
73 | 73 | // Adjust data to match portlet size |
74 | - if($this->context['height'] <= 2 && $this->context['width'] <= 3) |
|
74 | + if ($this->context['height'] <= 2 && $this->context['width'] <= 3) |
|
75 | 75 | { |
76 | 76 | // Too small for the other days |
77 | 77 | unset($content['list']); |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | unset($content['current']); |
83 | 83 | } |
84 | 84 | // Even too small for current high/low |
85 | - if($this->context['width'] < 3) |
|
85 | + if ($this->context['width'] < 3) |
|
86 | 86 | { |
87 | 87 | $content['current']['no_current_temp'] = true; |
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | // Direct to full forecast page |
92 | - $content['attribution'] ='http://openweathermap.org/city/'.$content['city_id']; |
|
92 | + $content['attribution'] = 'http://openweathermap.org/city/'.$content['city_id']; |
|
93 | 93 | |
94 | - $etemplate->exec('home.home_weather_portlet.exec',$content,array(),array('__ALL__'=>true),array('id' =>$id)); |
|
94 | + $etemplate->exec('home.home_weather_portlet.exec', $content, array(), array('__ALL__'=>true), array('id' =>$id)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,28 +103,28 @@ discard block |
||
103 | 103 | public function get_weather(Array $query, $api_url = '') |
104 | 104 | { |
105 | 105 | static $debug = true; |
106 | - if(!$api_url) |
|
106 | + if (!$api_url) |
|
107 | 107 | { |
108 | - $api_url = self::API_URL . '/weather?'; |
|
108 | + $api_url = self::API_URL.'/weather?'; |
|
109 | 109 | } |
110 | - if(self::API_KEY) |
|
110 | + if (self::API_KEY) |
|
111 | 111 | { |
112 | 112 | $query['APPID'] = self::API_KEY; |
113 | 113 | } |
114 | 114 | $data = egw_cache::getTree('home', json_encode($query), function($query) use(&$clear_cache) { |
115 | 115 | $debug = true; |
116 | - if($debug) error_log('Fetching fresh data from ' . static::API_URL); |
|
116 | + if ($debug) error_log('Fetching fresh data from '.static::API_URL); |
|
117 | 117 | |
118 | - $url = static::API_URL.'forecast/daily?'. http_build_query($query); |
|
118 | + $url = static::API_URL.'forecast/daily?'.http_build_query($query); |
|
119 | 119 | $forecast = file_get_contents($url); |
120 | - if($debug) error_log(__METHOD__ . ' forecast: ' . $weather); |
|
121 | - if($forecast === FALSE) |
|
120 | + if ($debug) error_log(__METHOD__.' forecast: '.$weather); |
|
121 | + if ($forecast === FALSE) |
|
122 | 122 | |
123 | - $url = static::API_URL.'weather?'. http_build_query($query); |
|
123 | + $url = static::API_URL.'weather?'.http_build_query($query); |
|
124 | 124 | $current = file_get_contents($url) || array(); |
125 | - if($debug) error_log(__METHOD__ . ' current: ' . $current); |
|
125 | + if ($debug) error_log(__METHOD__.' current: '.$current); |
|
126 | 126 | |
127 | - return array_merge(array('current' => json_decode($current,true)), json_decode($forecast,true)); |
|
127 | + return array_merge(array('current' => json_decode($current, true)), json_decode($forecast, true)); |
|
128 | 128 | }, array($query), self::CACHE_TIME); |
129 | 129 | |
130 | 130 | // Some sample data, if you need to test |
@@ -132,22 +132,22 @@ discard block |
||
132 | 132 | //$weather = '{"coord":{"lon":-114.05,"lat":53.23},"sys":{"message":0.3098,"country":"Canada","sunrise":1420559329,"sunset":1420587344},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"base":"cmc stations","main":{"temp":-21.414,"temp_min":-21.414,"temp_max":-21.414,"pressure":947.79,"sea_level":1050.73,"grnd_level":947.79,"humidity":69},"wind":{"speed":3,"deg":273.5},"clouds":{"all":32},"dt":1420502430,"id":0,"name":"Thorsby","cod":200}'; |
133 | 133 | //$weather = '{"cod":"200","message":0.1743,"city":{"id":"5978233","name":"Thorsby","coord":{"lon":-114.051,"lat":53.2285},"country":"Canada","population":0},"cnt":6,"list":[{"dt":1420743600,"temp":{"day":-17.49,"min":-27.86,"max":-16.38,"night":-27.86,"eve":-19.91,"morn":-16.77},"pressure":966.21,"humidity":66,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":6.91,"deg":312,"clouds":0,"snow":0.02},{"dt":1420830000,"temp":{"day":-24.86,"min":-29.71,"max":-17.98,"night":-18.31,"eve":-18.32,"morn":-29.51},"pressure":948.46,"humidity":54,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"speed":3.21,"deg":166,"clouds":20},{"dt":1420916400,"temp":{"day":-18.51,"min":-25.57,"max":-17.86,"night":-23.83,"eve":-23.91,"morn":-19.28},"pressure":947.22,"humidity":74,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"speed":1.97,"deg":314,"clouds":48},{"dt":1421002800,"temp":{"day":-26.69,"min":-29.86,"max":-20.19,"night":-21.82,"eve":-24.66,"morn":-28.85},"pressure":951.93,"humidity":22,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"02d"}],"speed":1.36,"deg":196,"clouds":8},{"dt":1421089200,"temp":{"day":0.9,"min":-8.24,"max":0.9,"night":-4.99,"eve":-0.21,"morn":-8.24},"pressure":929.31,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":6.01,"deg":302,"clouds":5,"snow":0},{"dt":1421175600,"temp":{"day":-1.53,"min":-6.7,"max":2.23,"night":-3.65,"eve":2.23,"morn":-6.7},"pressure":934.51,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.9,"deg":201,"clouds":78}]}'; |
134 | 134 | |
135 | - if($debug) |
|
135 | + if ($debug) |
|
136 | 136 | { |
137 | - error_log(__METHOD__ .' weather info:'); |
|
138 | - foreach($data as $key => $val) |
|
137 | + error_log(__METHOD__.' weather info:'); |
|
138 | + foreach ($data as $key => $val) |
|
139 | 139 | { |
140 | - error_log($key . ': ' .array2string($data[$key])); |
|
140 | + error_log($key.': '.array2string($data[$key])); |
|
141 | 141 | } |
142 | 142 | } |
143 | - if(is_string($data['message'])) |
|
143 | + if (is_string($data['message'])) |
|
144 | 144 | { |
145 | 145 | $desc = $this->get_description(); |
146 | - egw_framework::message($desc['displayName'] . ': ' . $desc['title'] . "\n".$data['message'], 'warning'); |
|
146 | + egw_framework::message($desc['displayName'].': '.$desc['title']."\n".$data['message'], 'warning'); |
|
147 | 147 | return array(); |
148 | 148 | } |
149 | 149 | |
150 | - if(array_key_exists('city', $data)) |
|
150 | + if (array_key_exists('city', $data)) |
|
151 | 151 | { |
152 | 152 | $data['city_id'] = $data['city']['id']; |
153 | 153 | } |
@@ -155,23 +155,23 @@ discard block |
||
155 | 155 | { |
156 | 156 | $data['city_id'] = $data['id']; |
157 | 157 | } |
158 | - if($data['list']) |
|
158 | + if ($data['list']) |
|
159 | 159 | { |
160 | - $massage =& $data['list']; |
|
160 | + $massage = & $data['list']; |
|
161 | 161 | |
162 | - for($i = 0; $i < min(count($massage), $this->context['width']); $i++) |
|
162 | + for ($i = 0; $i < min(count($massage), $this->context['width']); $i++) |
|
163 | 163 | { |
164 | - $forecast =& $massage[$i]; |
|
165 | - $forecast['day'] = egw_time::to($forecast['dt'],'l'); |
|
164 | + $forecast = & $massage[$i]; |
|
165 | + $forecast['day'] = egw_time::to($forecast['dt'], 'l'); |
|
166 | 166 | self::format_forecast($forecast); |
167 | 167 | } |
168 | 168 | // Chop data to fit into portlet |
169 | - for($i; $i < count($massage); $i++) |
|
169 | + for ($i; $i < count($massage); $i++) |
|
170 | 170 | { |
171 | 171 | unset($massage[$i]); |
172 | 172 | } |
173 | 173 | } |
174 | - if($data['current']) |
|
174 | + if ($data['current']) |
|
175 | 175 | { |
176 | 176 | // Current weather |
177 | 177 | $data['current']['temp'] = $data['current']['main']; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | if ($data['list']) |
183 | 183 | { |
184 | - $data['current']['temp'] = array_merge($data['current']['temp'],$data['list'][0]['temp']); |
|
184 | + $data['current']['temp'] = array_merge($data['current']['temp'], $data['list'][0]['temp']); |
|
185 | 185 | } |
186 | 186 | return $data; |
187 | 187 | } |
@@ -191,22 +191,22 @@ discard block |
||
191 | 191 | */ |
192 | 192 | protected static function format_forecast(&$data) |
193 | 193 | { |
194 | - $weather =& $data['weather'] ? $data['weather'] : $data; |
|
195 | - $temp =& $data['temp'] ? $data['temp'] : $data; |
|
194 | + $weather = & $data['weather'] ? $data['weather'] : $data; |
|
195 | + $temp = & $data['temp'] ? $data['temp'] : $data; |
|
196 | 196 | |
197 | 197 | // Full URL for icon |
198 | - if(is_array($weather)) |
|
198 | + if (is_array($weather)) |
|
199 | 199 | { |
200 | - foreach($weather as &$w) |
|
200 | + foreach ($weather as &$w) |
|
201 | 201 | { |
202 | - $w['icon'] = static::ICON_URL . $w['icon'].'.png'; |
|
202 | + $w['icon'] = static::ICON_URL.$w['icon'].'.png'; |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Round |
207 | - foreach(array('temp','temp_min','temp_max','min','max') as $temp_name) |
|
207 | + foreach (array('temp', 'temp_min', 'temp_max', 'min', 'max') as $temp_name) |
|
208 | 208 | { |
209 | - if(array_key_exists($temp_name, $temp)) |
|
209 | + if (array_key_exists($temp_name, $temp)) |
|
210 | 210 | { |
211 | 211 | $temp[$temp_name] = ''.round($temp[$temp_name]); |
212 | 212 | } |
@@ -111,18 +111,30 @@ |
||
111 | 111 | { |
112 | 112 | $query['APPID'] = self::API_KEY; |
113 | 113 | } |
114 | - $data = egw_cache::getTree('home', json_encode($query), function($query) use(&$clear_cache) { |
|
114 | + $data = egw_cache::getTree('home', json_encode($query), function($query) use(&$clear_cache) |
|
115 | + { |
|
115 | 116 | $debug = true; |
116 | - if($debug) error_log('Fetching fresh data from ' . static::API_URL); |
|
117 | + if($debug) |
|
118 | + { |
|
119 | + error_log('Fetching fresh data from ' . static::API_URL); |
|
120 | + } |
|
117 | 121 | |
118 | 122 | $url = static::API_URL.'forecast/daily?'. http_build_query($query); |
119 | 123 | $forecast = file_get_contents($url); |
120 | - if($debug) error_log(__METHOD__ . ' forecast: ' . $weather); |
|
124 | + if($debug) |
|
125 | + { |
|
126 | + error_log(__METHOD__ . ' forecast: ' . $weather); |
|
127 | + } |
|
121 | 128 | if($forecast === FALSE) |
122 | - |
|
129 | + { |
|
130 | + |
|
123 | 131 | $url = static::API_URL.'weather?'. http_build_query($query); |
132 | + } |
|
124 | 133 | $current = file_get_contents($url) || array(); |
125 | - if($debug) error_log(__METHOD__ . ' current: ' . $current); |
|
134 | + if($debug) |
|
135 | + { |
|
136 | + error_log(__METHOD__ . ' current: ' . $current); |
|
137 | + } |
|
126 | 138 | |
127 | 139 | return array_merge(array('current' => json_decode($current,true)), json_decode($forecast,true)); |
128 | 140 | }, array($query), self::CACHE_TIME); |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * |
115 | 115 | * Takes addessbook-abs and addressbook-all-in-one preference into account. |
116 | 116 | * |
117 | - * @param int $account=null account_id of addressbook or null to get array of all addressbooks |
|
118 | - * @param boolean $return_all_in_one=true if false and all-in-one pref is set, return all selected abs |
|
117 | + * @param int $account account_id of addressbook or null to get array of all addressbooks |
|
118 | + * @param boolean $return_all_in_one if false and all-in-one pref is set, return all selected abs |
|
119 | 119 | * if true only the all-in-one ab is returned (with id of personal ab) |
120 | - * @param booelan $ab_prefix=false prefix personal, private and accounts addressbook with lang('Addressbook').' ' |
|
120 | + * @param booelan $ab_prefix prefix personal, private and accounts addressbook with lang('Addressbook').' ' |
|
121 | 121 | * @return string|array addressbook name of array with int account_id => label pairs |
122 | 122 | */ |
123 | 123 | private function get_addressbooks($account=null,$return_all_in_one=true, $ab_prefix=false) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @todo if AB supports an extra private addressbook and AS prefs want an all-in-one AB, the private AB is always included, even if not selected in the prefs |
272 | 272 | * @param string $id folder id |
273 | - * @param int $cutoffdate=null |
|
273 | + * @param int $cutoffdate |
|
274 | 274 | * @return array |
275 | 275 | */ |
276 | 276 | function GetMessageList($id, $cutoffdate=NULL) |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param string $id |
320 | 320 | * @param int $truncsize |
321 | 321 | * @param int $bodypreference |
322 | - * @param bool $mimesupport |
|
322 | + * @param integer $mimesupport |
|
323 | 323 | * @return $messageobject|boolean false on error |
324 | 324 | */ |
325 | 325 | public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param string $id folder id |
273 | 273 | * @param int $cutoffdate=null |
274 | 274 | * @return array |
275 | - */ |
|
275 | + */ |
|
276 | 276 | function GetMessageList($id, $cutoffdate=NULL) |
277 | 277 | { |
278 | 278 | if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
369 | 369 | if (!empty($contact[$attr])) |
370 | 370 | { |
371 | - $tz = date_default_timezone_get(); |
|
372 | - date_default_timezone_set('UTC'); |
|
373 | - $message->birthday = strtotime($contact[$attr]); |
|
374 | - date_default_timezone_set($tz); |
|
371 | + $tz = date_default_timezone_get(); |
|
372 | + date_default_timezone_set('UTC'); |
|
373 | + $message->birthday = strtotime($contact[$attr]); |
|
374 | + date_default_timezone_set($tz); |
|
375 | 375 | } |
376 | 376 | break; |
377 | 377 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * |
684 | 684 | * |
685 | 685 | * @DESC The $flags parameter must contains the poommailflag Object |
686 | - */ |
|
686 | + */ |
|
687 | 687 | function ChangeMessageFlag($folderid, $id, $flags) |
688 | 688 | { |
689 | 689 | return false; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'homestreet' => 'adr_two_street', |
69 | 69 | 'homefaxnumber' => 'tel_fax_home', |
70 | 70 | 'homephonenumber' => 'tel_home', |
71 | - 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
71 | + 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
72 | 72 | 'lastname' => 'n_family', |
73 | 73 | 'middlename' => 'n_middle', |
74 | 74 | 'mobilephonenumber' => 'tel_cell', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param booelan $ab_prefix=false prefix personal, private and accounts addressbook with lang('Addressbook').' ' |
121 | 121 | * @return string|array addressbook name of array with int account_id => label pairs |
122 | 122 | */ |
123 | - private function get_addressbooks($account=null,$return_all_in_one=true, $ab_prefix=false) |
|
123 | + private function get_addressbooks($account = null, $return_all_in_one = true, $ab_prefix = false) |
|
124 | 124 | { |
125 | 125 | static $abs; |
126 | 126 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | } |
135 | 135 | else |
136 | 136 | { |
137 | - translation::add_app('addressbook'); // we need the addressbook translations |
|
137 | + translation::add_app('addressbook'); // we need the addressbook translations |
|
138 | 138 | |
139 | 139 | if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
140 | 140 | |
141 | 141 | // error_log(print_r($this->addressbook->get_addressbooks(EGW_ACL_READ),true)); |
142 | 142 | $pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
143 | - $pref_abs = (string)$pref_abs !== '' ? explode(',',$pref_abs) : array(); |
|
143 | + $pref_abs = (string)$pref_abs !== '' ? explode(',', $pref_abs) : array(); |
|
144 | 144 | |
145 | 145 | foreach ($this->addressbook->get_addressbooks() as $account_id => $label) |
146 | 146 | { |
@@ -148,18 +148,17 @@ discard block |
||
148 | 148 | { |
149 | 149 | $account_id = self::PRIVATE_AB; |
150 | 150 | } |
151 | - if ($account_id && in_array($account_id,$pref_abs) || in_array('A',$pref_abs) || |
|
152 | - $account_id == 0 && in_array('U',$pref_abs) || |
|
153 | - $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
154 | - $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$pref_abs)) |
|
151 | + if ($account_id && in_array($account_id, $pref_abs) || in_array('A', $pref_abs) || |
|
152 | + $account_id == 0 && in_array('U', $pref_abs) || |
|
153 | + $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
154 | + $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $pref_abs)) |
|
155 | 155 | { |
156 | 156 | $abs[$account_id] = $label; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | - $ret = is_null($account) ? $abs : |
|
162 | - ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
161 | + $ret = is_null($account) ? $abs : ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
163 | 162 | lang('Addressbook').' ' : '').$abs[$account]; |
164 | 163 | //error_log(__METHOD__."($account, $return_all_in_one, $ab_prefix) returning ".array2string($ret)); |
165 | 164 | return $ret; |
@@ -177,7 +176,7 @@ discard block |
||
177 | 176 | foreach ($this->get_addressbooks() as $account => $label) |
178 | 177 | { |
179 | 178 | $folderlist[] = array( |
180 | - 'id' => $this->backend->createID('addressbook',$account), |
|
179 | + 'id' => $this->backend->createID('addressbook', $account), |
|
181 | 180 | 'mod' => $label, |
182 | 181 | 'parent'=> '0', |
183 | 182 | ); |
@@ -273,18 +272,18 @@ discard block |
||
273 | 272 | * @param int $cutoffdate=null |
274 | 273 | * @return array |
275 | 274 | */ |
276 | - function GetMessageList($id, $cutoffdate=NULL) |
|
275 | + function GetMessageList($id, $cutoffdate = NULL) |
|
277 | 276 | { |
278 | 277 | if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
279 | 278 | |
280 | - $this->backend->splitID($id,$type,$user); |
|
279 | + $this->backend->splitID($id, $type, $user); |
|
281 | 280 | $filter = array('owner' => $user); |
282 | 281 | |
283 | 282 | // handle all-in-one addressbook |
284 | 283 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
285 | 284 | $user == $GLOBALS['egw_info']['user']['account_id']) |
286 | 285 | { |
287 | - $filter['owner'] = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
286 | + $filter['owner'] = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
288 | 287 | // translate AS private AB ID to EGroupware one |
289 | 288 | if (($key == array_search(self::PRIVATE_AB, $filter['owner'])) !== false) |
290 | 289 | { |
@@ -300,10 +299,10 @@ discard block |
||
300 | 299 | } |
301 | 300 | |
302 | 301 | $messagelist = array(); |
303 | - if (($contacts =& $this->addressbook->search($criteria,'contact_id,contact_etag',$order_by='',$extra_cols='',$wildcard='', |
|
304 | - $empty=false,$op='AND',$start=false,$filter))) |
|
302 | + if (($contacts = & $this->addressbook->search($criteria, 'contact_id,contact_etag', $order_by = '', $extra_cols = '', $wildcard = '', |
|
303 | + $empty = false, $op = 'AND', $start = false, $filter))) |
|
305 | 304 | { |
306 | - foreach($contacts as $contact) |
|
305 | + foreach ($contacts as $contact) |
|
307 | 306 | { |
308 | 307 | $messagelist[] = $this->StatMessage($id, $contact); |
309 | 308 | } |
@@ -322,11 +321,11 @@ discard block |
||
322 | 321 | * @param bool $mimesupport |
323 | 322 | * @return $messageobject|boolean false on error |
324 | 323 | */ |
325 | - public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
324 | + public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
326 | 325 | { |
327 | 326 | if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
328 | 327 | |
329 | - debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
|
328 | + debugLog(__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
|
330 | 329 | $this->backend->splitID($folderid, $type, $account); |
331 | 330 | if ($type != 'addressbook' || !($contact = $this->addressbook->read($id))) |
332 | 331 | { |
@@ -335,9 +334,9 @@ discard block |
||
335 | 334 | } |
336 | 335 | $emailname = isset($contact['n_given']) ? $contact['n_given'].' ' : ''; |
337 | 336 | $emailname .= isset($contact['n_middle']) ? $contact['n_middle'].' ' : ''; |
338 | - $emailname .= isset($contact['n_family']) ? $contact['n_family']: ''; |
|
337 | + $emailname .= isset($contact['n_family']) ? $contact['n_family'] : ''; |
|
339 | 338 | $message = new SyncContact(); |
340 | - foreach(self::$mapping as $key => $attr) |
|
339 | + foreach (self::$mapping as $key => $attr) |
|
341 | 340 | { |
342 | 341 | switch ($attr) |
343 | 342 | { |
@@ -350,11 +349,11 @@ discard block |
||
350 | 349 | } |
351 | 350 | else |
352 | 351 | { |
353 | - if (strlen ($contact[$attr]) > 0) |
|
352 | + if (strlen($contact[$attr]) > 0) |
|
354 | 353 | { |
355 | 354 | debugLog("airsyncbasebody!"); |
356 | 355 | $message->airsyncbasebody = new SyncAirSyncBaseBody(); |
357 | - $message->airsyncbasenativebodytype=1; |
|
356 | + $message->airsyncbasenativebodytype = 1; |
|
358 | 357 | $this->backend->note2messagenote($contact[$attr], $bodypreference, $message->airsyncbasebody); |
359 | 358 | } |
360 | 359 | } |
@@ -377,14 +376,14 @@ discard block |
||
377 | 376 | |
378 | 377 | case 'cat_id': |
379 | 378 | $message->$key = array(); |
380 | - foreach($contact[$attr] ? explode(',',$contact[$attr]) : array() as $cat_id) |
|
379 | + foreach ($contact[$attr] ? explode(',', $contact[$attr]) : array() as $cat_id) |
|
381 | 380 | { |
382 | 381 | $message->categories[] = categories::id2name($cat_id); |
383 | 382 | } |
384 | 383 | // for all addressbooks in one, add addressbook name itself as category |
385 | 384 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
386 | 385 | { |
387 | - $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true); |
|
386 | + $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true); |
|
388 | 387 | } |
389 | 388 | break; |
390 | 389 | case 'email': |
@@ -403,7 +402,7 @@ discard block |
||
403 | 402 | case 'n_fileas': |
404 | 403 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']) |
405 | 404 | { |
406 | - $message->$key = $this->addressbook->fileas($contact,$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
405 | + $message->$key = $this->addressbook->fileas($contact, $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
407 | 406 | break; |
408 | 407 | } |
409 | 408 | // fall through |
@@ -518,10 +517,10 @@ discard block |
||
518 | 517 | if ($account == 0) // as a precausion, we currently do NOT allow to change accounts |
519 | 518 | { |
520 | 519 | debugLog(__METHOD__." Changing of accounts denied!"); |
521 | - return false; //no changing of accounts |
|
520 | + return false; //no changing of accounts |
|
522 | 521 | } |
523 | 522 | $contact = array(); |
524 | - if (empty($id) && ($this->addressbook->grants[$account] & EGW_ACL_EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(EGW_ACL_EDIT, $contact)) |
|
523 | + if (empty($id) && ($this->addressbook->grants[$account]&EGW_ACL_EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(EGW_ACL_EDIT, $contact)) |
|
525 | 524 | { |
526 | 525 | // remove all fields supported by AS, leaving all unsupported fields unchanged |
527 | 526 | $contact = array_diff_key($contact, array_flip(self::$mapping)); |
@@ -534,7 +533,7 @@ discard block |
||
534 | 533 | break; |
535 | 534 | |
536 | 535 | case 'bday': // zpush uses timestamp in servertime |
537 | - $contact[$attr] = $message->$key ? date('Y-m-d',$message->$key) : null; |
|
536 | + $contact[$attr] = $message->$key ? date('Y-m-d', $message->$key) : null; |
|
538 | 537 | break; |
539 | 538 | |
540 | 539 | case 'jpegphoto': |
@@ -544,20 +543,20 @@ discard block |
||
544 | 543 | case 'cat_id': |
545 | 544 | // for existing entries in all-in-one addressbook, remove addressbook name as category |
546 | 545 | if ($contact && $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
547 | - ($k=array_search($this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true),$message->$key))) |
|
546 | + ($k = array_search($this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true), $message->$key))) |
|
548 | 547 | { |
549 | 548 | unset($message->categories[$k]); |
550 | 549 | } |
551 | 550 | if (is_array($message->$key)) |
552 | 551 | { |
553 | - $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id),'strlen')); |
|
552 | + $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id), 'strlen')); |
|
554 | 553 | } |
555 | 554 | break; |
556 | 555 | case 'email': |
557 | 556 | case 'email_home': |
558 | - if (function_exists ('imap_rfc822_parse_adrlist')) |
|
557 | + if (function_exists('imap_rfc822_parse_adrlist')) |
|
559 | 558 | { |
560 | - $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key,"")); |
|
559 | + $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key, "")); |
|
561 | 560 | if (!empty($email_array->mailbox) && $email_array->mailbox != 'INVALID_ADDRESS' && !empty($email_array->host)) |
562 | 561 | { |
563 | 562 | $contact[$attr] = $email_array->mailbox.'@'.$email_array->host; |
@@ -569,7 +568,7 @@ discard block |
||
569 | 568 | } |
570 | 569 | else |
571 | 570 | { |
572 | - debugLog(__METHOD__. " Warning : php-imap not available"); |
|
571 | + debugLog(__METHOD__." Warning : php-imap not available"); |
|
573 | 572 | $contact[$attr] = $message->$key; |
574 | 573 | } |
575 | 574 | break; |
@@ -596,9 +595,9 @@ discard block |
||
596 | 595 | $contact['private'] = (int)$is_private; |
597 | 596 | } |
598 | 597 | // if default addressbook for new contacts is NOT synced --> use personal addressbook |
599 | - elseif($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
598 | + elseif ($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
600 | 599 | !in_array($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'], |
601 | - array_keys($this->get_addressbooks(null,false)))) |
|
600 | + array_keys($this->get_addressbooks(null, false)))) |
|
602 | 601 | { |
603 | 602 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
604 | 603 | } |
@@ -710,18 +709,18 @@ discard block |
||
710 | 709 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
711 | 710 | $owner == $GLOBALS['egw_info']['user']['account_id']) |
712 | 711 | { |
713 | - if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'],'A') !== false) |
|
712 | + if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'], 'A') !== false) |
|
714 | 713 | { |
715 | - $owner = null; // all AB's |
|
714 | + $owner = null; // all AB's |
|
716 | 715 | } |
717 | 716 | else |
718 | 717 | { |
719 | - $owner = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
718 | + $owner = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
720 | 719 | // translate AS private AB ID to current user |
721 | 720 | if (($key == array_search(self::PRIVATE_AB, $owner)) !== false) |
722 | 721 | { |
723 | 722 | unset($owner[$key]); |
724 | - if (!in_array($GLOBALS['egw_info']['user']['account_id'],$owner)) |
|
723 | + if (!in_array($GLOBALS['egw_info']['user']['account_id'], $owner)) |
|
725 | 724 | { |
726 | 725 | $owner[] = $GLOBALS['egw_info']['user']['account_id']; |
727 | 726 | } |
@@ -734,7 +733,7 @@ discard block |
||
734 | 733 | } |
735 | 734 | $ctag = $this->addressbook->get_ctag($owner); |
736 | 735 | |
737 | - $changes = array(); // no change |
|
736 | + $changes = array(); // no change |
|
738 | 737 | $syncstate_was = $syncstate; |
739 | 738 | |
740 | 739 | if ($ctag !== $syncstate) |
@@ -762,20 +761,20 @@ discard block |
||
762 | 761 | $range = false; |
763 | 762 | if (isset($searchquery['range']) && preg_match('/^\d+-\d+$/', $searchquery['range'])) |
764 | 763 | { |
765 | - list($start,$end) = explode('-', $searchquery['range']); |
|
766 | - $range = array($start, $end-$start+1); // array(start, num_entries) |
|
764 | + list($start, $end) = explode('-', $searchquery['range']); |
|
765 | + $range = array($start, $end - $start + 1); // array(start, num_entries) |
|
767 | 766 | } |
768 | 767 | //error_log(__METHOD__.'('.array2string($searchquery).') range='.array2string($range)); |
769 | 768 | |
770 | 769 | $items = array(); |
771 | - if (($contacts =& $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range))) |
|
770 | + if (($contacts = & $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range))) |
|
772 | 771 | { |
773 | - foreach($contacts as $contact) |
|
772 | + foreach ($contacts as $contact) |
|
774 | 773 | { |
775 | 774 | $item['username'] = $contact['n_family']; |
776 | 775 | $item['fullname'] = $contact['n_fn']; |
777 | 776 | if (!trim($item['fullname'])) $item['fullname'] = $item['username']; |
778 | - $item['emailaddress'] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
|
777 | + $item['emailaddress'] = $contact['email'] ? $contact['email'] : (string)$contact['email_private']; |
|
779 | 778 | $item['nameid'] = $searchquery; |
780 | 779 | $item['phone'] = (string)$contact['tel_work']; |
781 | 780 | $item['homephone'] = (string)$contact['tel_home']; |
@@ -810,14 +809,14 @@ discard block |
||
810 | 809 | $addressbooks = $addressbook_bo->get_addressbooks(EGW_ACL_READ, null, $user); |
811 | 810 | if ($user > 0) |
812 | 811 | { |
813 | - unset($addressbooks[$user]); // personal addressbook is allways synced |
|
812 | + unset($addressbooks[$user]); // personal addressbook is allways synced |
|
814 | 813 | if (isset($addressbooks[$user.'p'])) |
815 | 814 | { |
816 | 815 | $addressbooks[self::PRIVATE_AB] = lang('Private'); |
817 | 816 | } |
818 | 817 | } |
819 | - unset($addressbooks[$user.'p']);// private addressbook uses ID self::PRIVATE_AB |
|
820 | - $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute'))+$addressbook_bo->fileas_options(); |
|
818 | + unset($addressbooks[$user.'p']); // private addressbook uses ID self::PRIVATE_AB |
|
819 | + $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute')) + $addressbook_bo->fileas_options(); |
|
821 | 820 | } |
822 | 821 | $addressbooks += array( |
823 | 822 | 'G' => lang('Primary Group'), |
@@ -136,7 +136,10 @@ discard block |
||
136 | 136 | { |
137 | 137 | translation::add_app('addressbook'); // we need the addressbook translations |
138 | 138 | |
139 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
139 | + if (!isset($this->addressbook)) |
|
140 | + { |
|
141 | + $this->addressbook = new addressbook_bo(); |
|
142 | + } |
|
140 | 143 | |
141 | 144 | // error_log(print_r($this->addressbook->get_addressbooks(EGW_ACL_READ),true)); |
142 | 145 | $pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
@@ -275,7 +278,10 @@ discard block |
||
275 | 278 | */ |
276 | 279 | function GetMessageList($id, $cutoffdate=NULL) |
277 | 280 | { |
278 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
281 | + if (!isset($this->addressbook)) |
|
282 | + { |
|
283 | + $this->addressbook = new addressbook_bo(); |
|
284 | + } |
|
279 | 285 | |
280 | 286 | $this->backend->splitID($id,$type,$user); |
281 | 287 | $filter = array('owner' => $user); |
@@ -324,7 +330,10 @@ discard block |
||
324 | 330 | */ |
325 | 331 | public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
326 | 332 | { |
327 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
333 | + if (!isset($this->addressbook)) |
|
334 | + { |
|
335 | + $this->addressbook = new addressbook_bo(); |
|
336 | + } |
|
328 | 337 | |
329 | 338 | debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
330 | 339 | $this->backend->splitID($folderid, $type, $account); |
@@ -362,7 +371,10 @@ discard block |
||
362 | 371 | break; |
363 | 372 | |
364 | 373 | case 'jpegphoto': |
365 | - if (!empty($contact[$attr])) $message->$key = base64_encode($contact[$attr]); |
|
374 | + if (!empty($contact[$attr])) |
|
375 | + { |
|
376 | + $message->$key = base64_encode($contact[$attr]); |
|
377 | + } |
|
366 | 378 | break; |
367 | 379 | |
368 | 380 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
@@ -408,7 +420,10 @@ discard block |
||
408 | 420 | } |
409 | 421 | // fall through |
410 | 422 | default: |
411 | - if (!empty($contact[$attr])) $message->$key = $contact[$attr]; |
|
423 | + if (!empty($contact[$attr])) |
|
424 | + { |
|
425 | + $message->$key = $contact[$attr]; |
|
426 | + } |
|
412 | 427 | } |
413 | 428 | } |
414 | 429 | //error_log(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message)); |
@@ -429,9 +444,15 @@ discard block |
||
429 | 444 | */ |
430 | 445 | public function StatMessage($folderid, $contact) |
431 | 446 | { |
432 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
447 | + if (!isset($this->addressbook)) |
|
448 | + { |
|
449 | + $this->addressbook = new addressbook_bo(); |
|
450 | + } |
|
433 | 451 | |
434 | - if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
|
452 | + if (!is_array($contact)) |
|
453 | + { |
|
454 | + $contact = $this->addressbook->read($contact); |
|
455 | + } |
|
435 | 456 | |
436 | 457 | if (!$contact) |
437 | 458 | { |
@@ -499,7 +520,10 @@ discard block |
||
499 | 520 | */ |
500 | 521 | public function ChangeMessage($folderid, $id, $message) |
501 | 522 | { |
502 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
523 | + if (!isset($this->addressbook)) |
|
524 | + { |
|
525 | + $this->addressbook = new addressbook_bo(); |
|
526 | + } |
|
503 | 527 | |
504 | 528 | $this->backend->splitID($folderid, $type, $account); |
505 | 529 | $is_private = false; |
@@ -510,14 +534,20 @@ discard block |
||
510 | 534 | |
511 | 535 | } |
512 | 536 | // error_log(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid); |
513 | - if ($type != 'addressbook') // || !($contact = $this->addressbook->read($id))) |
|
537 | + if ($type != 'addressbook') |
|
538 | + { |
|
539 | + // || !($contact = $this->addressbook->read($id))) |
|
514 | 540 | { |
515 | 541 | debugLog(__METHOD__." Folder wrong or contact not existing"); |
542 | + } |
|
516 | 543 | return false; |
517 | 544 | } |
518 | - if ($account == 0) // as a precausion, we currently do NOT allow to change accounts |
|
545 | + if ($account == 0) |
|
546 | + { |
|
547 | + // as a precausion, we currently do NOT allow to change accounts |
|
519 | 548 | { |
520 | 549 | debugLog(__METHOD__." Changing of accounts denied!"); |
550 | + } |
|
521 | 551 | return false; //no changing of accounts |
522 | 552 | } |
523 | 553 | $contact = array(); |
@@ -580,7 +610,10 @@ discard block |
||
580 | 610 | } |
581 | 611 | break; |
582 | 612 | case 'title': // as ol jobtitle mapping changed in egw from role to title, do NOT overwrite title with value of role |
583 | - if ($id && $message->$key == $contact['role']) break; |
|
613 | + if ($id && $message->$key == $contact['role']) |
|
614 | + { |
|
615 | + break; |
|
616 | + } |
|
584 | 617 | // fall throught |
585 | 618 | default: |
586 | 619 | $contact[$attr] = $message->$key; |
@@ -589,7 +622,10 @@ discard block |
||
589 | 622 | } |
590 | 623 | // for all-in-one addressbook, account is meaningless and wrong! |
591 | 624 | // addressbook_bo::save() keeps the owner or sets an appropriate one if none given |
592 | - if (!isset($contact['private'])) $contact['private'] = (int)$is_private; |
|
625 | + if (!isset($contact['private'])) |
|
626 | + { |
|
627 | + $contact['private'] = (int)$is_private; |
|
628 | + } |
|
593 | 629 | if (!$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
594 | 630 | { |
595 | 631 | $contact['owner'] = $account; |
@@ -602,7 +638,10 @@ discard block |
||
602 | 638 | { |
603 | 639 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
604 | 640 | } |
605 | - if (!empty($id)) $contact['id'] = $id; |
|
641 | + if (!empty($id)) |
|
642 | + { |
|
643 | + $contact['id'] = $id; |
|
644 | + } |
|
606 | 645 | $this->addressbook->fixup_contact($contact); |
607 | 646 | $newid = $this->addressbook->save($contact); |
608 | 647 | //error_log(__METHOD__."($folderid,$id) contact=".array2string($contact)." returning ".array2string($newid)); |
@@ -654,7 +693,10 @@ discard block |
||
654 | 693 | */ |
655 | 694 | public function DeleteMessage($folderid, $id) |
656 | 695 | { |
657 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
696 | + if (!isset($this->addressbook)) |
|
697 | + { |
|
698 | + $this->addressbook = new addressbook_bo(); |
|
699 | + } |
|
658 | 700 | |
659 | 701 | $ret = $this->addressbook->delete($id); |
660 | 702 | debugLog(__METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -702,9 +744,15 @@ discard block |
||
702 | 744 | { |
703 | 745 | $this->backend->splitID($folderid, $type, $owner); |
704 | 746 | |
705 | - if ($type != 'addressbook') return false; |
|
747 | + if ($type != 'addressbook') |
|
748 | + { |
|
749 | + return false; |
|
750 | + } |
|
706 | 751 | |
707 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
752 | + if (!isset($this->addressbook)) |
|
753 | + { |
|
754 | + $this->addressbook = new addressbook_bo(); |
|
755 | + } |
|
708 | 756 | |
709 | 757 | // handle all-in-one addressbook |
710 | 758 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
@@ -755,7 +803,10 @@ discard block |
||
755 | 803 | */ |
756 | 804 | function getSearchResultsGAL($searchquery) |
757 | 805 | { |
758 | - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); |
|
806 | + if (!isset($this->addressbook)) |
|
807 | + { |
|
808 | + $this->addressbook = new addressbook_bo(); |
|
809 | + } |
|
759 | 810 | //error_log(__METHOD__.'('.array2string($searchquery).')'); |
760 | 811 | |
761 | 812 | // only return items in given range, eg. "0-50" |
@@ -774,7 +825,10 @@ discard block |
||
774 | 825 | { |
775 | 826 | $item['username'] = $contact['n_family']; |
776 | 827 | $item['fullname'] = $contact['n_fn']; |
777 | - if (!trim($item['fullname'])) $item['fullname'] = $item['username']; |
|
828 | + if (!trim($item['fullname'])) |
|
829 | + { |
|
830 | + $item['fullname'] = $item['username']; |
|
831 | + } |
|
778 | 832 | $item['emailaddress'] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
779 | 833 | $item['nameid'] = $searchquery; |
780 | 834 | $item['phone'] = (string)$contact['tel_work']; |
@@ -785,7 +839,10 @@ discard block |
||
785 | 839 | $item['title'] = $contact['title']; |
786 | 840 | |
787 | 841 | //do not return users without email |
788 | - if (!trim($item['emailaddress'])) continue; |
|
842 | + if (!trim($item['emailaddress'])) |
|
843 | + { |
|
844 | + continue; |
|
845 | + } |
|
789 | 846 | |
790 | 847 | $items[] = $item; |
791 | 848 | } |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * constructor of the class |
76 | 76 | * |
77 | - * @param array $ldap_config=null default use from $GLOBALS['egw_info']['server'] |
|
78 | - * @param resource $ds=null ldap connection to use |
|
77 | + * @param array $ldap_config default use from $GLOBALS['egw_info']['server'] |
|
79 | 78 | */ |
80 | 79 | function __construct(array $ldap_config=null, $ds=null) |
81 | 80 | { |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | /** |
131 | 130 | * connect to LDAP server |
132 | 131 | * |
133 | - * @param boolean $admin=false true (re-)connect with admin not user credentials, eg. to modify accounts |
|
134 | 132 | */ |
135 | 133 | function connect($admin=false) |
136 | 134 | { |
@@ -204,7 +202,6 @@ discard block |
||
204 | 202 | /** |
205 | 203 | * Remove attributes we are not allowed to update |
206 | 204 | * |
207 | - * @param array $attributes |
|
208 | 205 | */ |
209 | 206 | function sanitize_update(array &$ldapContact) |
210 | 207 | { |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * while it uses select-account for owner in historylog (containing all users). |
34 | 34 | * |
35 | 35 | * @param string $cname |
36 | - */ |
|
36 | + */ |
|
37 | 37 | public function beforeSendToClient($cname) |
38 | 38 | { |
39 | 39 | $form_name = self::form_name($cname, $this->id); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | * minimum: $this->columns_to_search = array('n_family','n_given','org_name','email'); |
31 | 31 | */ |
32 | 32 | var $search_attributes = array( |
33 | - 'n_family','n_middle','n_given','org_name','org_unit', |
|
34 | - 'adr_one_location','note','email','samaccountname', |
|
33 | + 'n_family', 'n_middle', 'n_given', 'org_name', 'org_unit', |
|
34 | + 'adr_one_location', 'note', 'email', 'samaccountname', |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @var string |
47 | 47 | */ |
48 | - var $dn_attribute='cn'; |
|
48 | + var $dn_attribute = 'cn'; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Do NOT attempt to change DN (dn-attribute can NOT be part of schemas used in addressbook!) |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @param array $ldap_config=null default use from $GLOBALS['egw_info']['server'] |
78 | 78 | * @param resource $ds=null ldap connection to use |
79 | 79 | */ |
80 | - function __construct(array $ldap_config=null, $ds=null) |
|
80 | + function __construct(array $ldap_config = null, $ds = null) |
|
81 | 81 | { |
82 | - $this->accountName = $GLOBALS['egw_info']['user']['account_lid']; |
|
82 | + $this->accountName = $GLOBALS['egw_info']['user']['account_lid']; |
|
83 | 83 | |
84 | 84 | if ($ldap_config) |
85 | 85 | { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | else |
89 | 89 | { |
90 | - $this->ldap_config =& $GLOBALS['egw_info']['server']; |
|
90 | + $this->ldap_config = & $GLOBALS['egw_info']['server']; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $this->accounts_ads = $GLOBALS['egw']->accounts->backend; |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | 'account_id' => 'objectsid', |
113 | 113 | 'id' => 'objectguid', |
114 | 114 | 'uid' => 'objectguid', |
115 | - 'n_fn' => 'displayname', // leave CN used in DN untouched |
|
116 | - 'accountexpires', 'useraccountcontrol', // needed to exclude deactivated or expired accounts |
|
115 | + 'n_fn' => 'displayname', // leave CN used in DN untouched |
|
116 | + 'accountexpires', 'useraccountcontrol', // needed to exclude deactivated or expired accounts |
|
117 | 117 | )); |
118 | 118 | unset($this->schema2egw['user']['n_fileas']); |
119 | 119 | unset($this->schema2egw['inetorgperson']); |
120 | 120 | |
121 | - foreach($this->schema2egw as $schema => $attributes) |
|
121 | + foreach ($this->schema2egw as $schema => $attributes) |
|
122 | 122 | { |
123 | - $this->all_attributes = array_merge($this->all_attributes,array_values($attributes)); |
|
123 | + $this->all_attributes = array_merge($this->all_attributes, array_values($attributes)); |
|
124 | 124 | } |
125 | 125 | $this->all_attributes = array_values(array_unique($this->all_attributes)); |
126 | 126 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param boolean $admin=false true (re-)connect with admin not user credentials, eg. to modify accounts |
134 | 134 | */ |
135 | - function connect($admin=false) |
|
135 | + function connect($admin = false) |
|
136 | 136 | { |
137 | 137 | $this->ds = $this->accounts_ads->ldap_connection(); |
138 | 138 | } |
@@ -165,15 +165,14 @@ discard block |
||
165 | 165 | function read($contact_id) |
166 | 166 | { |
167 | 167 | if (is_array($contact_id) && isset($contact_id['account_id']) || |
168 | - !is_array($contact_id) && substr($contact_id,0,8) == 'account:') |
|
168 | + !is_array($contact_id) && substr($contact_id, 0, 8) == 'account:') |
|
169 | 169 | { |
170 | - $account_id = (int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id,8)); |
|
170 | + $account_id = (int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id, 8)); |
|
171 | 171 | $contact_id = $GLOBALS['egw']->accounts->id2name($account_id, 'person_id'); |
172 | 172 | } |
173 | - $contact_id = !is_array($contact_id) ? $contact_id : |
|
174 | - (isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid']); |
|
173 | + $contact_id = !is_array($contact_id) ? $contact_id : (isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid']); |
|
175 | 174 | |
176 | - $rows = $this->_searchLDAP($this->allContactsDN, $filter=$this->id_filter($contact_id), $this->all_attributes, ADDRESSBOOK_ALL); |
|
175 | + $rows = $this->_searchLDAP($this->allContactsDN, $filter = $this->id_filter($contact_id), $this->all_attributes, ADDRESSBOOK_ALL); |
|
177 | 176 | //error_log(__METHOD__."('$contact_id') _searchLDAP($this->allContactsDN, '$filter',...)=".array2string($rows)); |
178 | 177 | return $rows ? $rows[0] : false; |
179 | 178 | } |
@@ -193,10 +193,16 @@ |
||
193 | 193 | $contact['id'] = $contact['uid'] = $this->accounts_ads->objectguid2str($data['objectguid']); |
194 | 194 | |
195 | 195 | // ignore system accounts |
196 | - if ($contact['account_id'] < accounts_ads::MIN_ACCOUNT_ID) return false; |
|
196 | + if ($contact['account_id'] < accounts_ads::MIN_ACCOUNT_ID) |
|
197 | + { |
|
198 | + return false; |
|
199 | + } |
|
197 | 200 | |
198 | 201 | // ignore deactivated or expired accounts |
199 | - if (!$this->accounts_ads->user_active($data)) return false; |
|
202 | + if (!$this->accounts_ads->user_active($data)) |
|
203 | + { |
|
204 | + return false; |
|
205 | + } |
|
200 | 206 | |
201 | 207 | $this->_inetorgperson2egw($contact, $data, 'displayname'); |
202 | 208 | } |
@@ -158,8 +158,6 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * Constructor |
160 | 160 | * |
161 | - * @param string $contact_app='addressbook' used for acl->get_grants() |
|
162 | - * @param egw_db $db=null |
|
163 | 161 | */ |
164 | 162 | function __construct($contact_app='addressbook',egw_db $db=null) |
165 | 163 | { |
@@ -329,10 +327,8 @@ discard block |
||
329 | 327 | /** |
330 | 328 | * Get the availible addressbooks of the user |
331 | 329 | * |
332 | - * @param int $required=EGW_ACL_READ required rights on the addressbook or multiple rights or'ed together, |
|
333 | - * to return only addressbooks fullfilling all the given rights |
|
334 | 330 | * @param string $extra_label first label if given (already translated) |
335 | - * @param int $user=null account_id or null for current user |
|
331 | + * @param integer $required |
|
336 | 332 | * @return array with owner => label pairs |
337 | 333 | */ |
338 | 334 | function get_addressbooks($required=EGW_ACL_READ,$extra_label=null,$user=null) |
@@ -402,8 +398,6 @@ discard block |
||
402 | 398 | * calculate the file_as string from the contact and the file_as type |
403 | 399 | * |
404 | 400 | * @param array $contact |
405 | - * @param string $type=null file_as type, default null to read it from the contact, unknown/not set type default to the first one |
|
406 | - * @param boolean $update=false If true, reads the old record for any not set fields |
|
407 | 401 | * @return string |
408 | 402 | */ |
409 | 403 | function fileas($contact,$type=null, $isUpdate=false) |
@@ -459,7 +453,6 @@ discard block |
||
459 | 453 | * determine the file_as type from the file_as string and the contact |
460 | 454 | * |
461 | 455 | * @param array $contact |
462 | - * @param string $type=null file_as type, default null to read it from the contact, unknown/not set type default to the first one |
|
463 | 456 | * @return string |
464 | 457 | */ |
465 | 458 | function fileas_type($contact,$file_as=null) |
@@ -482,7 +475,6 @@ discard block |
||
482 | 475 | /** |
483 | 476 | * get selectbox options for the customfields |
484 | 477 | * |
485 | - * @param array $field=null |
|
486 | 478 | * @return array with options: |
487 | 479 | */ |
488 | 480 | public static function cf_options() |
@@ -498,7 +490,7 @@ discard block |
||
498 | 490 | /** |
499 | 491 | * get selectbox options for the fileas types with translated labels, or real content |
500 | 492 | * |
501 | - * @param array $contact=null real content to use, default none |
|
493 | + * @param array $contact real content to use, default none |
|
502 | 494 | * @return array with options: fileas type => label pairs |
503 | 495 | */ |
504 | 496 | function fileas_options($contact=null) |
@@ -532,7 +524,6 @@ discard block |
||
532 | 524 | * If $all all fileas fields will be set, if !$all only empty ones |
533 | 525 | * |
534 | 526 | * @param string $fileas_type '' or type of $this->fileas_types |
535 | - * @param int $all=false update all contacts or only ones with empty values |
|
536 | 527 | * @param int &$errors=null on return number of errors |
537 | 528 | * @return int|boolean number of contacts updated, false for wrong fileas type |
538 | 529 | */ |
@@ -596,7 +587,7 @@ discard block |
||
596 | 587 | * remove unneeded carriage returns or set empty fields to NULL |
597 | 588 | * |
598 | 589 | * @param int &$errors=null on return number of errors |
599 | - * @return int|boolean number of contacts updated |
|
590 | + * @return integer number of contacts updated |
|
600 | 591 | */ |
601 | 592 | function set_all_cleanup(&$errors=null,$ignore_acl=false) |
602 | 593 | { |
@@ -744,9 +735,7 @@ discard block |
||
744 | 735 | /** |
745 | 736 | * src for photo: returns array with linkparams if jpeg exists or the $default image-name if not |
746 | 737 | * @param int $id contact_id |
747 | - * @param boolean $jpeg=false jpeg exists or not |
|
748 | 738 | * @param string $default='' image-name to use if !$jpeg, eg. 'template' |
749 | - * @param string $etag=null etag to set in url to allow caching with Expires header |
|
750 | 739 | * @return string/array |
751 | 740 | */ |
752 | 741 | function photo_src($id,$jpeg,$default='',$etag=null) |
@@ -788,8 +777,8 @@ discard block |
||
788 | 777 | * deletes contact in db |
789 | 778 | * |
790 | 779 | * @param mixed &$contact contact array with key id or (array of) id(s) |
791 | - * @param boolean $deny_account_delete=true if true never allow to delete accounts |
|
792 | - * @param int $check_etag=null |
|
780 | + * @param boolean $deny_account_delete if true never allow to delete accounts |
|
781 | + * @param int $check_etag |
|
793 | 782 | * @return boolean|int true on success or false on failiure, 0 if etag does not match |
794 | 783 | */ |
795 | 784 | function delete($contact,$deny_account_delete=true,$check_etag=null) |
@@ -847,7 +836,7 @@ discard block |
||
847 | 836 | * saves contact to db |
848 | 837 | * |
849 | 838 | * @param array &$contact contact array from etemplate::exec |
850 | - * @param boolean $ignore_acl=false should the acl be checked or not |
|
839 | + * @param boolean $ignore_acl should the acl be checked or not |
|
851 | 840 | * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
852 | 841 | */ |
853 | 842 | function save(&$contact,$ignore_acl=false) |
@@ -1028,7 +1017,7 @@ discard block |
||
1028 | 1017 | * Resizes photo to 60*80 pixel and returns it |
1029 | 1018 | * |
1030 | 1019 | * @param string|FILE $photo string with image or open filedescribtor |
1031 | - * @param int $dst_w=240 max width to resize to |
|
1020 | + * @param int $dst_w max width to resize to |
|
1032 | 1021 | * @return string with resized jpeg photo, null on error |
1033 | 1022 | */ |
1034 | 1023 | public static function resize_photo($photo,$dst_w=240) |
@@ -1121,9 +1110,8 @@ discard block |
||
1121 | 1110 | * |
1122 | 1111 | * @param int $needed necessary ACL right: EGW_ACL_{READ|EDIT|DELETE} |
1123 | 1112 | * @param mixed $contact contact as array or the contact-id |
1124 | - * @param boolean $deny_account_delete=false if true never allow to delete accounts |
|
1125 | - * @param int $user=null for which user to check, default current user |
|
1126 | - * @return boolean true permission granted, false for permission denied, null for contact does not exist |
|
1113 | + * @param boolean $deny_account_delete if true never allow to delete accounts |
|
1114 | + * @return null|boolean true permission granted, false for permission denied, null for contact does not exist |
|
1127 | 1115 | */ |
1128 | 1116 | function check_perms($needed,$contact,$deny_account_delete=false,$user=null) |
1129 | 1117 | { |
@@ -1177,9 +1165,8 @@ discard block |
||
1177 | 1165 | * |
1178 | 1166 | * @param int|array $id id of entry or entry array |
1179 | 1167 | * @param int $check EGW_ACL_READ for read and EGW_ACL_EDIT for write or delete access |
1180 | - * @param string $rel_path=null currently not used in InfoLog |
|
1181 | - * @param int $user=null for which user to check, default current user |
|
1182 | - * @return boolean true if access is granted or false otherwise |
|
1168 | + * @param string $rel_path currently not used in InfoLog |
|
1169 | + * @return null|boolean true if access is granted or false otherwise |
|
1183 | 1170 | */ |
1184 | 1171 | function file_access($id,$check,$rel_path=null,$user=null) |
1185 | 1172 | { |
@@ -1333,7 +1320,7 @@ discard block |
||
1333 | 1320 | * |
1334 | 1321 | * @param array $from original/old version of the contact |
1335 | 1322 | * @param array $to changed/new version of the contact |
1336 | - * @param boolean $onld_org_fields=true check and return only org_fields, default true |
|
1323 | + * @param boolean $only_org_fields check and return only org_fields, default true |
|
1337 | 1324 | * @return array with field-name => value from $from |
1338 | 1325 | */ |
1339 | 1326 | function changed_fields($from,$to,$only_org_fields=true) |
@@ -1368,7 +1355,7 @@ discard block |
||
1368 | 1355 | * @param string $org_name |
1369 | 1356 | * @param array $from original/old version of the contact |
1370 | 1357 | * @param array $to changed/new version of the contact |
1371 | - * @param array $members=null org-members to change, default null --> function queries them itself |
|
1358 | + * @param array $members org-members to change, default null --> function queries them itself |
|
1372 | 1359 | * @return array/boolean (changed-members,changed-fields,failed-members) or false if no org_fields changed or no (other) members matching that fields |
1373 | 1360 | */ |
1374 | 1361 | function change_org($org_name,$from,$to,$members=null) |
@@ -1599,7 +1586,7 @@ discard block |
||
1599 | 1586 | * Read the next and last event of given contacts |
1600 | 1587 | * |
1601 | 1588 | * @param array $ids contact_id's |
1602 | - * @param boolean $extra_title=true if true, use a short date only title and put the full title as extra_title (tooltip) |
|
1589 | + * @param boolean $extra_title if true, use a short date only title and put the full title as extra_title (tooltip) |
|
1603 | 1590 | * @return array |
1604 | 1591 | */ |
1605 | 1592 | function read_calendar($ids,$extra_title=true) |
@@ -1867,7 +1854,6 @@ discard block |
||
1867 | 1854 | * |
1868 | 1855 | * @param int $list |
1869 | 1856 | * @param int $required |
1870 | - * @param int $owner=null |
|
1871 | 1857 | * @return boolean |
1872 | 1858 | */ |
1873 | 1859 | function check_list($list,$required,$owner=null) |
@@ -1885,7 +1871,6 @@ discard block |
||
1885 | 1871 | * |
1886 | 1872 | * @param string|array $keys list-name or array with column-name => value pairs to specify the list |
1887 | 1873 | * @param int $owner user- or group-id |
1888 | - * @param array $contacts=array() contacts to add (only for not yet existing lists!) |
|
1889 | 1874 | * @param array &$data=array() values for keys 'list_uid', 'list_carddav_name', 'list_name' |
1890 | 1875 | * @return int|boolean integer list_id or false on error |
1891 | 1876 | */ |
@@ -1909,7 +1894,7 @@ discard block |
||
1909 | 1894 | * |
1910 | 1895 | * @param int|array $contact contact_id(s) |
1911 | 1896 | * @param int $list list-id |
1912 | - * @param array $existing=null array of existing contact-id(s) of list, to not reread it, eg. array() |
|
1897 | + * @param array $existing array of existing contact-id(s) of list, to not reread it, eg. array() |
|
1913 | 1898 | * @return false on error |
1914 | 1899 | */ |
1915 | 1900 | function add2list($contact,$list,array $existing=null) |
@@ -2051,7 +2036,7 @@ discard block |
||
2051 | 2036 | * currently used for vcard import |
2052 | 2037 | * |
2053 | 2038 | * @param array $catname_list names of the categories which should be found or added |
2054 | - * @param int $contact_id=null match against existing contact and expand the returned category ids |
|
2039 | + * @param int $contact_id match against existing contact and expand the returned category ids |
|
2055 | 2040 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
2056 | 2041 | * @return array category ids (found, added and preserved categories) |
2057 | 2042 | */ |
@@ -2151,7 +2136,6 @@ discard block |
||
2151 | 2136 | * Try to find a matching db entry |
2152 | 2137 | * |
2153 | 2138 | * @param array $contact the contact data we try to find |
2154 | - * @param boolean $relax=false if asked to relax, we only match against some key fields |
|
2155 | 2139 | * @return array od matching contact_ids |
2156 | 2140 | */ |
2157 | 2141 | function find_contact($contact, $relax=false) |
@@ -2386,7 +2370,6 @@ discard block |
||
2386 | 2370 | * We have to include deleted entries, as otherwise the ctag will not change if an entry gets deleted! |
2387 | 2371 | * (Only works if tracking of deleted entries / history is switched on!) |
2388 | 2372 | * |
2389 | - * @param int|array $owner=null 0=accounts, null=all addressbooks or integer account_id of user or group |
|
2390 | 2373 | * @return string |
2391 | 2374 | */ |
2392 | 2375 | public function get_ctag($owner=null) |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | var $categories; |
141 | 141 | |
142 | 142 | /** |
143 | - * Tracking changes |
|
144 | - * |
|
145 | - * @var addressbook_tracking |
|
146 | - */ |
|
143 | + * Tracking changes |
|
144 | + * |
|
145 | + * @var addressbook_tracking |
|
146 | + */ |
|
147 | 147 | protected $tracking; |
148 | 148 | |
149 | 149 | /** |
150 | - * Keep deleted addresses, or really delete them |
|
151 | - * Set in Admin -> Addressbook -> Site Configuration |
|
152 | - * ''=really delete, 'history'=keep, only admins delete, 'userpurge'=keep, users delete |
|
153 | - * |
|
154 | - * @var string |
|
155 | - */ |
|
150 | + * Keep deleted addresses, or really delete them |
|
151 | + * Set in Admin -> Addressbook -> Site Configuration |
|
152 | + * ''=really delete, 'history'=keep, only admins delete, 'userpurge'=keep, users delete |
|
153 | + * |
|
154 | + * @var string |
|
155 | + */ |
|
156 | 156 | protected $delete_history = ''; |
157 | 157 | |
158 | 158 | /** |
@@ -785,13 +785,13 @@ discard block |
||
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
788 | - * deletes contact in db |
|
789 | - * |
|
790 | - * @param mixed &$contact contact array with key id or (array of) id(s) |
|
791 | - * @param boolean $deny_account_delete=true if true never allow to delete accounts |
|
792 | - * @param int $check_etag=null |
|
793 | - * @return boolean|int true on success or false on failiure, 0 if etag does not match |
|
794 | - */ |
|
788 | + * deletes contact in db |
|
789 | + * |
|
790 | + * @param mixed &$contact contact array with key id or (array of) id(s) |
|
791 | + * @param boolean $deny_account_delete=true if true never allow to delete accounts |
|
792 | + * @param int $check_etag=null |
|
793 | + * @return boolean|int true on success or false on failiure, 0 if etag does not match |
|
794 | + */ |
|
795 | 795 | function delete($contact,$deny_account_delete=true,$check_etag=null) |
796 | 796 | { |
797 | 797 | if (is_array($contact) && isset($contact['id'])) |
@@ -844,12 +844,12 @@ discard block |
||
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
847 | - * saves contact to db |
|
848 | - * |
|
849 | - * @param array &$contact contact array from etemplate::exec |
|
850 | - * @param boolean $ignore_acl=false should the acl be checked or not |
|
851 | - * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
|
852 | - */ |
|
847 | + * saves contact to db |
|
848 | + * |
|
849 | + * @param array &$contact contact array from etemplate::exec |
|
850 | + * @param boolean $ignore_acl=false should the acl be checked or not |
|
851 | + * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
|
852 | + */ |
|
853 | 853 | function save(&$contact,$ignore_acl=false) |
854 | 854 | { |
855 | 855 | // remember if we add or update a entry |
@@ -1070,12 +1070,12 @@ discard block |
||
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
1073 | - * reads contacts matched by key and puts all cols in the data array |
|
1074 | - * |
|
1075 | - * @param int|string $contact_id |
|
1076 | - * @param boolean $ignore_acl =false true: no acl check |
|
1077 | - * @return array|boolean array with contact data, null if not found or false on no view perms |
|
1078 | - */ |
|
1073 | + * reads contacts matched by key and puts all cols in the data array |
|
1074 | + * |
|
1075 | + * @param int|string $contact_id |
|
1076 | + * @param boolean $ignore_acl =false true: no acl check |
|
1077 | + * @return array|boolean array with contact data, null if not found or false on no view perms |
|
1078 | + */ |
|
1079 | 1079 | function read($contact_id, $ignore_acl=false) |
1080 | 1080 | { |
1081 | 1081 | // get so_sql_cf to read private customfields too, if we ignore acl |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var array $timestamps timestamps |
28 | 28 | */ |
29 | - var $timestamps = array('modified','created'); |
|
29 | + var $timestamps = array('modified', 'created'); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @var array $fileas_types |
@@ -161,28 +161,28 @@ discard block |
||
161 | 161 | * @param string $contact_app='addressbook' used for acl->get_grants() |
162 | 162 | * @param egw_db $db=null |
163 | 163 | */ |
164 | - function __construct($contact_app='addressbook',egw_db $db=null) |
|
164 | + function __construct($contact_app = 'addressbook', egw_db $db = null) |
|
165 | 165 | { |
166 | - parent::__construct($contact_app,$db); |
|
166 | + parent::__construct($contact_app, $db); |
|
167 | 167 | if ($this->log) |
168 | 168 | { |
169 | 169 | $this->logfile = $GLOBALS['egw_info']['server']['temp_dir'].'/log-addressbook_bo'; |
170 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($contact_app)\n", 3 ,$this->logfile); |
|
170 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($contact_app)\n", 3, $this->logfile); |
|
171 | 171 | } |
172 | 172 | |
173 | - $this->now_su = egw_time::to('now','ts'); |
|
173 | + $this->now_su = egw_time::to('now', 'ts'); |
|
174 | 174 | |
175 | - $this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
175 | + $this->prefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
176 | 176 | // get the default addressbook from the users prefs |
177 | 177 | $this->default_addressbook = $GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ? |
178 | 178 | (int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] : $this->user; |
179 | - $this->default_private = substr($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'],-1) == 'p'; |
|
179 | + $this->default_private = substr($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'], -1) == 'p'; |
|
180 | 180 | if ($this->default_addressbook > 0 && $this->default_addressbook != $this->user && |
181 | 181 | ($this->default_private || |
182 | 182 | $this->default_addressbook == (int)$GLOBALS['egw']->preferences->forced['addressbook']['add_default'] || |
183 | 183 | $this->default_addressbook == (int)$GLOBALS['egw']->preferences->default['addressbook']['add_default'])) |
184 | 184 | { |
185 | - $this->default_addressbook = $this->user; // admin set a default or forced pref for personal addressbook |
|
185 | + $this->default_addressbook = $this->user; // admin set a default or forced pref for personal addressbook |
|
186 | 186 | } |
187 | 187 | $this->private_addressbook = self::private_addressbook($this->contact_repository == 'sql', $this->prefs); |
188 | 188 | |
@@ -287,27 +287,27 @@ discard block |
||
287 | 287 | $this->own_account_acl = $GLOBALS['egw_info']['server']['own_account_acl']; |
288 | 288 | if (!is_array($this->own_account_acl)) $this->own_account_acl = unserialize($this->own_account_acl); |
289 | 289 | // we have only one acl (n_fn) for the whole name, as not all backends store every part in an own field |
290 | - if ($this->own_account_acl && in_array('n_fn',$this->own_account_acl)) |
|
290 | + if ($this->own_account_acl && in_array('n_fn', $this->own_account_acl)) |
|
291 | 291 | { |
292 | - $this->own_account_acl = array_merge($this->own_account_acl,array('n_prefix','n_given','n_middle','n_family','n_suffix')); |
|
292 | + $this->own_account_acl = array_merge($this->own_account_acl, array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix')); |
|
293 | 293 | } |
294 | 294 | if ($GLOBALS['egw_info']['server']['org_fileds_to_update']) |
295 | 295 | { |
296 | - $this->org_fields = $GLOBALS['egw_info']['server']['org_fileds_to_update']; |
|
296 | + $this->org_fields = $GLOBALS['egw_info']['server']['org_fileds_to_update']; |
|
297 | 297 | if (!is_array($this->org_fields)) $this->org_fields = unserialize($this->org_fields); |
298 | 298 | |
299 | 299 | // Set country code if country name is selected |
300 | - $supported_fields = $this->get_fields('supported',null,0); |
|
301 | - if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$this->org_fields)) |
|
300 | + $supported_fields = $this->get_fields('supported', null, 0); |
|
301 | + if (in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname', $this->org_fields)) |
|
302 | 302 | { |
303 | 303 | $this->org_fields[] = 'adr_one_countrycode'; |
304 | 304 | } |
305 | - if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$this->org_fields)) |
|
305 | + if (in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname', $this->org_fields)) |
|
306 | 306 | { |
307 | 307 | $this->org_fields[] = 'adr_two_countrycode'; |
308 | 308 | } |
309 | 309 | } |
310 | - $this->categories = new categories($this->user,'addressbook'); |
|
310 | + $this->categories = new categories($this->user, 'addressbook'); |
|
311 | 311 | |
312 | 312 | $this->delete_history = $GLOBALS['egw_info']['server']['history']; |
313 | 313 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param array $prefs addressbook preferences |
322 | 322 | * @return boolean |
323 | 323 | */ |
324 | - public static function private_addressbook($contact_repository, array $prefs=null) |
|
324 | + public static function private_addressbook($contact_repository, array $prefs = null) |
|
325 | 325 | { |
326 | 326 | return $contact_repository == 'sql' && $prefs['private_addressbook']; |
327 | 327 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * @param int $user=null account_id or null for current user |
336 | 336 | * @return array with owner => label pairs |
337 | 337 | */ |
338 | - function get_addressbooks($required=EGW_ACL_READ,$extra_label=null,$user=null) |
|
338 | + function get_addressbooks($required = EGW_ACL_READ, $extra_label = null, $user = null) |
|
339 | 339 | { |
340 | 340 | //echo "uicontacts::get_addressbooks($required,$include_all) grants="; _debug_array($this->grants); |
341 | 341 | |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | if ($extra_label) $addressbooks[''] = $extra_label; |
357 | 357 | $addressbooks[$user] = lang('Personal'); |
358 | 358 | // add all group addressbooks the user has the necessary rights too |
359 | - foreach($grants as $uid => $rights) |
|
359 | + foreach ($grants as $uid => $rights) |
|
360 | 360 | { |
361 | - if (($rights & $required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'g') |
|
361 | + if (($rights&$required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'g') |
|
362 | 362 | { |
363 | - $to_sort[$uid] = lang('Group %1',$GLOBALS['egw']->accounts->id2name($uid)); |
|
363 | + $to_sort[$uid] = lang('Group %1', $GLOBALS['egw']->accounts->id2name($uid)); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | if ($to_sort) |
@@ -368,19 +368,19 @@ discard block |
||
368 | 368 | asort($to_sort); |
369 | 369 | $addressbooks += $to_sort; |
370 | 370 | } |
371 | - if ($required != EGW_ACL_ADD && // do NOT allow to set accounts as default addressbook (AB can add accounts) |
|
371 | + if ($required != EGW_ACL_ADD && // do NOT allow to set accounts as default addressbook (AB can add accounts) |
|
372 | 372 | !$preferences['addressbook']['hide_accounts'] && ( |
373 | - ($grants[0] & $required) == $required || |
|
373 | + ($grants[0]&$required) == $required || |
|
374 | 374 | $preferences['common']['account_selection'] == 'groupmembers' && |
375 | - $this->account_repository != 'ldap' && ($required & EGW_ACL_READ))) |
|
375 | + $this->account_repository != 'ldap' && ($required&EGW_ACL_READ))) |
|
376 | 376 | { |
377 | 377 | $addressbooks[0] = lang('Accounts'); |
378 | 378 | } |
379 | 379 | // add all other user addressbooks the user has the necessary rights too |
380 | 380 | $to_sort = array(); |
381 | - foreach($grants as $uid => $rights) |
|
381 | + foreach ($grants as $uid => $rights) |
|
382 | 382 | { |
383 | - if ($uid != $user && ($rights & $required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'u') |
|
383 | + if ($uid != $user && ($rights&$required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'u') |
|
384 | 384 | { |
385 | 385 | $to_sort[$uid] = common::grab_owner_name($uid); |
386 | 386 | } |
@@ -406,22 +406,22 @@ discard block |
||
406 | 406 | * @param boolean $update=false If true, reads the old record for any not set fields |
407 | 407 | * @return string |
408 | 408 | */ |
409 | - function fileas($contact,$type=null, $isUpdate=false) |
|
409 | + function fileas($contact, $type = null, $isUpdate = false) |
|
410 | 410 | { |
411 | 411 | if (is_null($type)) $type = $contact['fileas_type']; |
412 | 412 | if (!$type) $type = $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; |
413 | 413 | |
414 | - if (strpos($type,'n_fn') !== false) $contact['n_fn'] = $this->fullname($contact); |
|
414 | + if (strpos($type, 'n_fn') !== false) $contact['n_fn'] = $this->fullname($contact); |
|
415 | 415 | |
416 | - if($isUpdate) |
|
416 | + if ($isUpdate) |
|
417 | 417 | { |
418 | - $fileas_fields = array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name','org_unit','adr_one_locality','bday'); |
|
418 | + $fileas_fields = array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix', 'n_fn', 'org_name', 'org_unit', 'adr_one_locality', 'bday'); |
|
419 | 419 | $old = null; |
420 | - foreach($fileas_fields as $field) |
|
420 | + foreach ($fileas_fields as $field) |
|
421 | 421 | { |
422 | - if(!isset($contact[$field])) |
|
422 | + if (!isset($contact[$field])) |
|
423 | 423 | { |
424 | - if(is_null($old)) $old = $this->read($contact['id']); |
|
424 | + if (is_null($old)) $old = $this->read($contact['id']); |
|
425 | 425 | $contact[$field] = $old[$field]; |
426 | 426 | } |
427 | 427 | } |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | // removing empty delimiters, caused by empty contact fields |
432 | - $fileas = str_replace(array(', , : ',', : ',': , ',', , ',': : ',' ()'), |
|
433 | - array(': ',': ',': ',', ',': ',''), |
|
432 | + $fileas = str_replace(array(', , : ', ', : ', ': , ', ', , ', ': : ', ' ()'), |
|
433 | + array(': ', ': ', ': ', ', ', ': ', ''), |
|
434 | 434 | strtr($type, array( |
435 | 435 | 'n_prefix' => $contact['n_prefix'], |
436 | 436 | 'n_given' => $contact['n_given'], |
@@ -444,13 +444,13 @@ discard block |
||
444 | 444 | 'bday' => (int)$contact['bday'] ? egw_time::to($contact['bday'], true) : $contact['bday'], |
445 | 445 | ))); |
446 | 446 | |
447 | - while ($fileas[0] == ':' || $fileas[0] == ',') |
|
447 | + while ($fileas[0] == ':' || $fileas[0] == ',') |
|
448 | 448 | { |
449 | - $fileas = substr($fileas,2); |
|
449 | + $fileas = substr($fileas, 2); |
|
450 | 450 | } |
451 | - while (substr($fileas,-2) == ': ' || substr($fileas,-2) == ', ') |
|
451 | + while (substr($fileas, -2) == ': ' || substr($fileas, -2) == ', ') |
|
452 | 452 | { |
453 | - $fileas = substr($fileas,0,-2); |
|
453 | + $fileas = substr($fileas, 0, -2); |
|
454 | 454 | } |
455 | 455 | return $fileas; |
456 | 456 | } |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | * @param string $type=null file_as type, default null to read it from the contact, unknown/not set type default to the first one |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - function fileas_type($contact,$file_as=null) |
|
465 | + function fileas_type($contact, $file_as = null) |
|
466 | 466 | { |
467 | 467 | if (is_null($file_as)) $file_as = $contact['n_fileas']; |
468 | 468 | |
469 | 469 | if ($file_as) |
470 | 470 | { |
471 | - foreach($this->fileas_types as $type) |
|
471 | + foreach ($this->fileas_types as $type) |
|
472 | 472 | { |
473 | - if ($this->fileas($contact,$type) == $file_as) |
|
473 | + if ($this->fileas($contact, $type) == $file_as) |
|
474 | 474 | { |
475 | 475 | return $type; |
476 | 476 | } |
@@ -487,10 +487,10 @@ discard block |
||
487 | 487 | */ |
488 | 488 | public static function cf_options() |
489 | 489 | { |
490 | - $cf_fields = config::get_customfields('addressbook',TRUE); |
|
491 | - foreach ($cf_fields as $key => $value ) |
|
490 | + $cf_fields = config::get_customfields('addressbook', TRUE); |
|
491 | + foreach ($cf_fields as $key => $value) |
|
492 | 492 | { |
493 | - $options[$key]= $value['label']; |
|
493 | + $options[$key] = $value['label']; |
|
494 | 494 | } |
495 | 495 | return $options; |
496 | 496 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param array $contact=null real content to use, default none |
502 | 502 | * @return array with options: fileas type => label pairs |
503 | 503 | */ |
504 | - function fileas_options($contact=null) |
|
504 | + function fileas_options($contact = null) |
|
505 | 505 | { |
506 | 506 | $labels = array( |
507 | 507 | 'n_prefix' => lang('prefix'), |
@@ -515,13 +515,13 @@ discard block |
||
515 | 515 | 'adr_one_locality' => lang('city'), |
516 | 516 | 'bday' => lang('Birthday'), |
517 | 517 | ); |
518 | - foreach($labels as $name => $label) |
|
518 | + foreach ($labels as $name => $label) |
|
519 | 519 | { |
520 | 520 | if ($contact[$name]) $labels[$name] = $contact[$name]; |
521 | 521 | } |
522 | - foreach($this->fileas_types as $fileas_type) |
|
522 | + foreach ($this->fileas_types as $fileas_type) |
|
523 | 523 | { |
524 | - $options[$fileas_type] = $this->fileas($labels,$fileas_type); |
|
524 | + $options[$fileas_type] = $this->fileas($labels, $fileas_type); |
|
525 | 525 | } |
526 | 526 | return $options; |
527 | 527 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @param int &$errors=null on return number of errors |
537 | 537 | * @return int|boolean number of contacts updated, false for wrong fileas type |
538 | 538 | */ |
539 | - function set_all_fileas($fileas_type,$all=false,&$errors=null,$ignore_acl=false) |
|
539 | + function set_all_fileas($fileas_type, $all = false, &$errors = null, $ignore_acl = false) |
|
540 | 540 | { |
541 | 541 | if ($fileas_type != '' && !in_array($fileas_type, $this->fileas_types)) |
542 | 542 | { |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | } |
545 | 545 | if ($ignore_acl) |
546 | 546 | { |
547 | - unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
547 | + unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
548 | 548 | } |
549 | 549 | // to be able to work on huge contact repositories we read the contacts in chunks of 100 |
550 | - for($n = $updated = $errors = 0; ($contacts = parent::search($all ? array() : array( |
|
550 | + for ($n = $updated = $errors = 0; ($contacts = parent::search($all ? array() : array( |
|
551 | 551 | 'n_fileas IS NULL', |
552 | 552 | "n_fileas=''", |
553 | 553 | 'n_fn IS NULL', |
554 | 554 | "n_fn=''", |
555 | - ),false,'','','',false,'OR',array($n*100,100))); ++$n) |
|
555 | + ), false, '', '', '', false, 'OR', array($n * 100, 100))); ++$n) |
|
556 | 556 | { |
557 | - foreach($contacts as $contact) |
|
557 | + foreach ($contacts as $contact) |
|
558 | 558 | { |
559 | 559 | $old_fn = $contact['n_fn']; |
560 | 560 | $old_fileas = $contact['n_fileas']; |
@@ -562,20 +562,20 @@ discard block |
||
562 | 562 | // only update fileas if type is given AND (all should be updated or n_fileas is empty) |
563 | 563 | if ($fileas_type && ($all || empty($contact['n_fileas']))) |
564 | 564 | { |
565 | - $contact['n_fileas'] = $this->fileas($contact,$fileas_type); |
|
565 | + $contact['n_fileas'] = $this->fileas($contact, $fileas_type); |
|
566 | 566 | } |
567 | 567 | if ($old_fileas != $contact['n_fileas'] || $old_fn != $contact['n_fn']) |
568 | 568 | { |
569 | 569 | //echo "<p>('$old_fileas' != '{$contact['n_fileas']}' || '$old_fn' != '{$contact['n_fn']}')=".array2string($old_fileas != $contact['n_fileas'] || $old_fn != $contact['n_fn'])."</p>\n"; |
570 | 570 | // only specify/write updated fields plus "keys" |
571 | - $contact = array_intersect_key($contact,array( |
|
571 | + $contact = array_intersect_key($contact, array( |
|
572 | 572 | 'id' => true, |
573 | 573 | 'owner' => true, |
574 | 574 | 'private' => true, |
575 | 575 | 'account_id' => true, |
576 | 576 | 'uid' => true, |
577 | - )+($old_fileas != $contact['n_fileas'] ? array('n_fileas' => true) : array())+($old_fn != $contact['n_fn'] ? array('n_fn' => true) : array())); |
|
578 | - if ($this->save($contact,$ignore_acl)) |
|
577 | + ) + ($old_fileas != $contact['n_fileas'] ? array('n_fileas' => true) : array()) + ($old_fn != $contact['n_fn'] ? array('n_fn' => true) : array())); |
|
578 | + if ($this->save($contact, $ignore_acl)) |
|
579 | 579 | { |
580 | 580 | $updated++; |
581 | 581 | } |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | * @param int &$errors=null on return number of errors |
599 | 599 | * @return int|boolean number of contacts updated |
600 | 600 | */ |
601 | - function set_all_cleanup(&$errors=null,$ignore_acl=false) |
|
601 | + function set_all_cleanup(&$errors = null, $ignore_acl = false) |
|
602 | 602 | { |
603 | 603 | if ($ignore_acl) |
604 | 604 | { |
605 | - unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
605 | + unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | // fields that must not be touched |
@@ -624,14 +624,14 @@ discard block |
||
624 | 624 | ); |
625 | 625 | |
626 | 626 | // to be able to work on huge contact repositories we read the contacts in chunks of 100 |
627 | - for($n = $updated = $errors = 0; ($contacts = parent::search(array(),false,'','','',false,'OR',array($n*100,100))); ++$n) |
|
627 | + for ($n = $updated = $errors = 0; ($contacts = parent::search(array(), false, '', '', '', false, 'OR', array($n * 100, 100))); ++$n) |
|
628 | 628 | { |
629 | - foreach($contacts as $contact) |
|
629 | + foreach ($contacts as $contact) |
|
630 | 630 | { |
631 | 631 | $fields_to_update = array(); |
632 | - foreach($contact as $field_name => $field_value) |
|
632 | + foreach ($contact as $field_name => $field_value) |
|
633 | 633 | { |
634 | - if($fields_exclude[$field_name] === true) continue; // dont touch specified field |
|
634 | + if ($fields_exclude[$field_name] === true) continue; // dont touch specified field |
|
635 | 635 | |
636 | 636 | if (is_string($field_value) && $field_name != 'pubkey' && $field_name != 'jpegphoto') |
637 | 637 | { |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | $fields_to_update[$field_name] = $field_value = trim($field_value); |
642 | 642 | } |
643 | 643 | // check if field contains a carriage return - exclude notes |
644 | - if ($field_name != 'note' && strpos($field_value,"\x0D\x0A") !== false) |
|
644 | + if ($field_name != 'note' && strpos($field_value, "\x0D\x0A") !== false) |
|
645 | 645 | { |
646 | - $fields_to_update[$field_name] = $field_value = str_replace("\x0D\x0A"," ",$field_value);; |
|
646 | + $fields_to_update[$field_name] = $field_value = str_replace("\x0D\x0A", " ", $field_value); ; |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | // check if a field contains an empty string |
@@ -653,13 +653,13 @@ discard block |
||
653 | 653 | } |
654 | 654 | // check for valid birthday date |
655 | 655 | if ($field_name == 'bday' && $field_value != null && |
656 | - !preg_match('/^(18|19|20|21|22)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/',$field_value)) |
|
656 | + !preg_match('/^(18|19|20|21|22)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/', $field_value)) |
|
657 | 657 | { |
658 | 658 | $fields_to_update[$field_name] = $field_value = null; |
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
662 | - if(count($fields_to_update) > 0) |
|
662 | + if (count($fields_to_update) > 0) |
|
663 | 663 | { |
664 | 664 | $contact_to_save = array( |
665 | 665 | 'id' => $contact['id'], |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | 'account_id' => $contact['account_id'], |
669 | 669 | 'uid' => $contact['uid']) + $fields_to_update; |
670 | 670 | |
671 | - if ($this->save($contact_to_save,$ignore_acl)) |
|
671 | + if ($this->save($contact_to_save, $ignore_acl)) |
|
672 | 672 | { |
673 | 673 | $updated++; |
674 | 674 | } |
@@ -693,14 +693,14 @@ discard block |
||
693 | 693 | if (empty($contact['n_family']) && empty($contact['n_given'])) { |
694 | 694 | $cpart = array('org_name'); |
695 | 695 | } else { |
696 | - $cpart = array('n_prefix','n_given','n_middle','n_family','n_suffix'); |
|
696 | + $cpart = array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix'); |
|
697 | 697 | } |
698 | 698 | $parts = array(); |
699 | - foreach($cpart as $n) |
|
699 | + foreach ($cpart as $n) |
|
700 | 700 | { |
701 | 701 | if ($contact[$n]) $parts[] = $contact[$n]; |
702 | 702 | } |
703 | - return implode(' ',$parts); |
|
703 | + return implode(' ', $parts); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @return array updated data |
716 | 716 | */ |
717 | - function db2data($data, $date_format='ts') |
|
717 | + function db2data($data, $date_format = 'ts') |
|
718 | 718 | { |
719 | 719 | static $fb_url = false; |
720 | 720 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | $data[$name] = egw_time::server2user($data[$name], $date_format); |
727 | 727 | } |
728 | 728 | } |
729 | - $data['photo'] = $this->photo_src($data['id'],$data['jpegphoto'],'',$data['etag']); |
|
729 | + $data['photo'] = $this->photo_src($data['id'], $data['jpegphoto'], '', $data['etag']); |
|
730 | 730 | |
731 | 731 | // set freebusy_uri for accounts |
732 | 732 | if (!$data['freebusy_uri'] && !$data['owner'] && $data['account_id'] && !is_object($GLOBALS['egw_setup'])) |
@@ -749,13 +749,13 @@ discard block |
||
749 | 749 | * @param string $etag=null etag to set in url to allow caching with Expires header |
750 | 750 | * @return string/array |
751 | 751 | */ |
752 | - function photo_src($id,$jpeg,$default='',$etag=null) |
|
752 | + function photo_src($id, $jpeg, $default = '', $etag = null) |
|
753 | 753 | { |
754 | 754 | //error_log(__METHOD__."($id, ..., etag=$etag) ". function_backtrace()); |
755 | 755 | return $jpeg ? array( |
756 | 756 | 'menuaction' => 'addressbook.addressbook_ui.photo', |
757 | 757 | 'contact_id' => $id, |
758 | - )+(isset($etag) ? array( |
|
758 | + ) + (isset($etag) ? array( |
|
759 | 759 | 'etag' => $etag, |
760 | 760 | ) : array()) : $default; |
761 | 761 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @return array upated data |
773 | 773 | */ |
774 | - function data2db($data, $date_format='ts') |
|
774 | + function data2db($data, $date_format = 'ts') |
|
775 | 775 | { |
776 | 776 | // convert timestamps from user-time to server-time in the db |
777 | 777 | foreach ($this->timestamps as $name) |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | * @param int $check_etag=null |
793 | 793 | * @return boolean|int true on success or false on failiure, 0 if etag does not match |
794 | 794 | */ |
795 | - function delete($contact,$deny_account_delete=true,$check_etag=null) |
|
795 | + function delete($contact, $deny_account_delete = true, $check_etag = null) |
|
796 | 796 | { |
797 | 797 | if (is_array($contact) && isset($contact['id'])) |
798 | 798 | { |
@@ -802,12 +802,12 @@ discard block |
||
802 | 802 | { |
803 | 803 | $contact = array($contact); |
804 | 804 | } |
805 | - foreach($contact as $c) |
|
805 | + foreach ($contact as $c) |
|
806 | 806 | { |
807 | 807 | $id = is_array($c) ? $c['id'] : $c; |
808 | 808 | |
809 | 809 | $ok = false; |
810 | - if ($this->check_perms(EGW_ACL_DELETE,$c,$deny_account_delete)) |
|
810 | + if ($this->check_perms(EGW_ACL_DELETE, $c, $deny_account_delete)) |
|
811 | 811 | { |
812 | 812 | if (!($old = $this->read($id))) return false; |
813 | 813 | // check if we only mark contacts as deleted, or really delete them |
@@ -818,12 +818,12 @@ discard block |
||
818 | 818 | $delete = $old; |
819 | 819 | $delete['tid'] = addressbook_so::DELETED_TYPE; |
820 | 820 | if ($check_etag) $delete['etag'] = $check_etag; |
821 | - if (($ok = $this->save($delete))) $ok = true; // we have to return true or false |
|
822 | - egw_link::unlink(0,'addressbook',$id,'','','',true); |
|
821 | + if (($ok = $this->save($delete))) $ok = true; // we have to return true or false |
|
822 | + egw_link::unlink(0, 'addressbook', $id, '', '', '', true); |
|
823 | 823 | } |
824 | - elseif (($ok = parent::delete($id,$check_etag))) |
|
824 | + elseif (($ok = parent::delete($id, $check_etag))) |
|
825 | 825 | { |
826 | - egw_link::unlink(0,'addressbook',$id); |
|
826 | + egw_link::unlink(0, 'addressbook', $id); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | // Don't notify of final purge |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | * @param boolean $ignore_acl=false should the acl be checked or not |
851 | 851 | * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
852 | 852 | */ |
853 | - function save(&$contact,$ignore_acl=false) |
|
853 | + function save(&$contact, $ignore_acl = false) |
|
854 | 854 | { |
855 | 855 | // remember if we add or update a entry |
856 | 856 | if (($isUpdate = $contact['id'])) |
@@ -859,11 +859,11 @@ discard block |
||
859 | 859 | { |
860 | 860 | if (($old = $this->read($contact['id']))) // --> try reading the old entry and set it from there |
861 | 861 | { |
862 | - if(!isset($contact['owner'])) |
|
862 | + if (!isset($contact['owner'])) |
|
863 | 863 | { |
864 | 864 | $contact['owner'] = $old['owner']; |
865 | 865 | } |
866 | - if(!isset($contact['private'])) |
|
866 | + if (!isset($contact['private'])) |
|
867 | 867 | { |
868 | 868 | $contact['private'] = $old['private']; |
869 | 869 | } |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | { |
896 | 896 | $contact['private'] = 0; |
897 | 897 | } |
898 | - if(!$ignore_acl && !$this->check_perms($isUpdate ? EGW_ACL_EDIT : EGW_ACL_ADD,$contact)) |
|
898 | + if (!$ignore_acl && !$this->check_perms($isUpdate ? EGW_ACL_EDIT : EGW_ACL_ADD, $contact)) |
|
899 | 899 | { |
900 | 900 | $this->error = 'access denied'; |
901 | 901 | return false; |
@@ -908,15 +908,15 @@ discard block |
||
908 | 908 | // convert categories |
909 | 909 | if (is_array($contact['cat_id'])) |
910 | 910 | { |
911 | - $contact['cat_id'] = implode(',',$contact['cat_id']); |
|
911 | + $contact['cat_id'] = implode(',', $contact['cat_id']); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | // Update country codes |
915 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
916 | - if($contact[$c_prefix.'countryname'] && !$contact[$c_prefix.'countrycode'] && |
|
915 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) { |
|
916 | + if ($contact[$c_prefix.'countryname'] && !$contact[$c_prefix.'countrycode'] && |
|
917 | 917 | $code = $GLOBALS['egw']->country->country_code($contact[$c_prefix.'countryname'])) |
918 | 918 | { |
919 | - if(strlen($code) == 2) |
|
919 | + if (strlen($code) == 2) |
|
920 | 920 | { |
921 | 921 | $contact[$c_prefix.'countrycode'] = $code; |
922 | 922 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | $contact[$c_prefix.'countrycode'] = null; |
926 | 926 | } |
927 | 927 | } |
928 | - if($contact[$c_prefix.'countrycode'] != null) |
|
928 | + if ($contact[$c_prefix.'countrycode'] != null) |
|
929 | 929 | { |
930 | 930 | $contact[$c_prefix.'countryname'] = null; |
931 | 931 | } |
@@ -950,9 +950,9 @@ discard block |
||
950 | 950 | // (non-admin) user editing his own account, make sure he does not change fields he is not allowed to (eg. via SyncML or xmlrpc) |
951 | 951 | if (!$ignore_acl && !$contact['owner'] && !($this->is_admin($contact) || $this->allow_account_edit())) |
952 | 952 | { |
953 | - foreach($contact as $field => $value) |
|
953 | + foreach ($contact as $field => $value) |
|
954 | 954 | { |
955 | - if (!in_array($field,$this->own_account_acl) && !in_array($field,array('id','owner','account_id','modified','modifier'))) |
|
955 | + if (!in_array($field, $this->own_account_acl) && !in_array($field, array('id', 'owner', 'account_id', 'modified', 'modifier'))) |
|
956 | 956 | { |
957 | 957 | // user is not allowed to change that |
958 | 958 | if ($old) |
@@ -973,17 +973,17 @@ discard block |
||
973 | 973 | { |
974 | 974 | if (isset($to_write['owner']) && !empty($to_write['owner'])) |
975 | 975 | { |
976 | - error_log(__METHOD__.__LINE__." Trying to change account to owner:". $to_write['owner'].' Account affected:'.array2string($old).' Data send:'.array2string($to_write)); |
|
976 | + error_log(__METHOD__.__LINE__." Trying to change account to owner:".$to_write['owner'].' Account affected:'.array2string($old).' Data send:'.array2string($to_write)); |
|
977 | 977 | unset($to_write['owner']); |
978 | 978 | } |
979 | 979 | } |
980 | 980 | // we dont update the content-history, if we run inside setup (admin-account-creation) |
981 | - if(!($this->error = parent::save($to_write)) && is_object($GLOBALS['egw']->contenthistory)) |
|
981 | + if (!($this->error = parent::save($to_write)) && is_object($GLOBALS['egw']->contenthistory)) |
|
982 | 982 | { |
983 | 983 | $contact['id'] = $to_write['id']; |
984 | 984 | $contact['uid'] = $to_write['uid']; |
985 | 985 | $contact['etag'] = $to_write['etag']; |
986 | - $GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $contact['id'],$isUpdate ? 'modify' : 'add', time()); |
|
986 | + $GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $contact['id'], $isUpdate ? 'modify' : 'add', time()); |
|
987 | 987 | |
988 | 988 | // if contact is an account and account-relevant data got updated, handle it like account got updated |
989 | 989 | if ($contact['account_id'] && $isUpdate && |
@@ -993,27 +993,27 @@ discard block |
||
993 | 993 | $GLOBALS['egw']->accounts->cache_invalidate($contact['account_id']); |
994 | 994 | // call edit-accout hook, to let other apps know about changed account (names or email) |
995 | 995 | $GLOBALS['hook_values'] = $GLOBALS['egw']->accounts->read($contact['account_id']); |
996 | - $GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array( |
|
996 | + $GLOBALS['egw']->hooks->process($GLOBALS['hook_values'] + array( |
|
997 | 997 | 'location' => 'editaccount', |
998 | - ),False,True); // called for every app now, not only enabled ones) |
|
998 | + ), False, True); // called for every app now, not only enabled ones) |
|
999 | 999 | } |
1000 | 1000 | // notify interested apps about changes in the account-contact data |
1001 | 1001 | if (!$to_write['owner'] && $to_write['account_id'] && $isUpdate) |
1002 | 1002 | { |
1003 | 1003 | $to_write['location'] = 'editaccountcontact'; |
1004 | - $GLOBALS['egw']->hooks->process($to_write,False,True); // called for every app now, not only enabled ones)); |
|
1004 | + $GLOBALS['egw']->hooks->process($to_write, False, True); // called for every app now, not only enabled ones)); |
|
1005 | 1005 | } |
1006 | 1006 | // Notify linked apps about changes in the contact data |
1007 | - egw_link::notify_update('addressbook', $contact['id'], $contact); |
|
1007 | + egw_link::notify_update('addressbook', $contact['id'], $contact); |
|
1008 | 1008 | |
1009 | 1009 | // Check for restore of deleted contact, restore held links |
1010 | - if($old && $old['tid'] == addressbook_so::DELETED_TYPE && $contact['tid'] != addressbook_so::DELETED_TYPE) |
|
1010 | + if ($old && $old['tid'] == addressbook_so::DELETED_TYPE && $contact['tid'] != addressbook_so::DELETED_TYPE) |
|
1011 | 1011 | { |
1012 | 1012 | egw_link::restore('addressbook', $contact['id']); |
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | // Record change history for sql - doesn't work for LDAP accounts |
1016 | - if(!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') |
|
1016 | + if (!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') |
|
1017 | 1017 | { |
1018 | 1018 | $deleted = ($old['tid'] == addressbook_so::DELETED_TYPE || $contact['tid'] == addressbook_so::DELETED_TYPE); |
1019 | 1019 | if (!isset($this->tracking)) $this->tracking = new addressbook_tracking($this); |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | * @param int $dst_w=240 max width to resize to |
1032 | 1032 | * @return string with resized jpeg photo, null on error |
1033 | 1033 | */ |
1034 | - public static function resize_photo($photo,$dst_w=240) |
|
1034 | + public static function resize_photo($photo, $dst_w = 240) |
|
1035 | 1035 | { |
1036 | 1036 | if (is_resource($photo)) |
1037 | 1037 | { |
@@ -1047,15 +1047,15 @@ discard block |
||
1047 | 1047 | //error_log(__METHOD__."() got image $src_w * $src_h, is_jpeg=".array2string(substr($photo,0,2) === "\377\330")); |
1048 | 1048 | |
1049 | 1049 | // if $photo is to width or not a jpeg image --> resize it |
1050 | - if ($src_w > $dst_w || cut_bytes($photo,0,2) !== "\377\330") |
|
1050 | + if ($src_w > $dst_w || cut_bytes($photo, 0, 2) !== "\377\330") |
|
1051 | 1051 | { |
1052 | 1052 | //error_log(__METHOD__."(,dst_w=$dst_w) src_w=$src_w, cut_bytes(photo,0,2)=".array2string(cut_bytes($photo,0,2)).' --> resizing'); |
1053 | 1053 | // scale the image to a width of 60 and a height according to the proportion of the source image |
1054 | - $resized = imagecreatetruecolor($dst_w,$dst_h = round($src_h * $dst_w / $src_w)); |
|
1055 | - imagecopyresized($resized,$image,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h); |
|
1054 | + $resized = imagecreatetruecolor($dst_w, $dst_h = round($src_h * $dst_w / $src_w)); |
|
1055 | + imagecopyresized($resized, $image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h); |
|
1056 | 1056 | |
1057 | 1057 | ob_start(); |
1058 | - imagejpeg($resized,null,90); |
|
1058 | + imagejpeg($resized, null, 90); |
|
1059 | 1059 | $photo = ob_get_contents(); |
1060 | 1060 | ob_end_clean(); |
1061 | 1061 | |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | * @param boolean $ignore_acl =false true: no acl check |
1077 | 1077 | * @return array|boolean array with contact data, null if not found or false on no view perms |
1078 | 1078 | */ |
1079 | - function read($contact_id, $ignore_acl=false) |
|
1079 | + function read($contact_id, $ignore_acl = false) |
|
1080 | 1080 | { |
1081 | 1081 | // get so_sql_cf to read private customfields too, if we ignore acl |
1082 | 1082 | if ($ignore_acl && is_a($this->somain, 'addressbook_sql')) |
@@ -1086,11 +1086,11 @@ discard block |
||
1086 | 1086 | } |
1087 | 1087 | if (!($data = parent::read($contact_id))) |
1088 | 1088 | { |
1089 | - $data = null; // not found |
|
1089 | + $data = null; // not found |
|
1090 | 1090 | } |
1091 | - elseif (!$ignore_acl && !$this->check_perms(EGW_ACL_READ,$data)) |
|
1091 | + elseif (!$ignore_acl && !$this->check_perms(EGW_ACL_READ, $data)) |
|
1092 | 1092 | { |
1093 | - $data = false; // no view perms |
|
1093 | + $data = false; // no view perms |
|
1094 | 1094 | } |
1095 | 1095 | else |
1096 | 1096 | { |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | $data['fileas_type'] = $this->fileas_type($data); |
1099 | 1099 | |
1100 | 1100 | // Update country name from code |
1101 | - if($data['adr_one_countrycode'] != null) { |
|
1101 | + if ($data['adr_one_countrycode'] != null) { |
|
1102 | 1102 | $data['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_one_countrycode'], true); |
1103 | 1103 | } |
1104 | - if($data['adr_two_countrycode'] != null) { |
|
1104 | + if ($data['adr_two_countrycode'] != null) { |
|
1105 | 1105 | $data['adr_two_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_two_countrycode'], true); |
1106 | 1106 | } |
1107 | 1107 | } |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | * @param int $user=null for which user to check, default current user |
1126 | 1126 | * @return boolean true permission granted, false for permission denied, null for contact does not exist |
1127 | 1127 | */ |
1128 | - function check_perms($needed,$contact,$deny_account_delete=false,$user=null) |
|
1128 | + function check_perms($needed, $contact, $deny_account_delete = false, $user = null) |
|
1129 | 1129 | { |
1130 | 1130 | if (!$user) $user = $this->user; |
1131 | 1131 | if ($user == $this->user) |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | else |
1137 | 1137 | { |
1138 | 1138 | $grants = $this->get_grants($user); |
1139 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
1139 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | if ((!is_array($contact) || !isset($contact['owner'])) && |
@@ -1161,12 +1161,12 @@ discard block |
||
1161 | 1161 | $GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'groupmembers' && |
1162 | 1162 | !isset($GLOBALS['egw_info']['user']['apps']['admin'])) |
1163 | 1163 | { |
1164 | - $access = !!array_intersect($memberships,$GLOBALS['egw']->accounts->memberships($contact['account_id'],true)); |
|
1164 | + $access = !!array_intersect($memberships, $GLOBALS['egw']->accounts->memberships($contact['account_id'], true)); |
|
1165 | 1165 | } |
1166 | 1166 | else |
1167 | 1167 | { |
1168 | - $access = ($grants[$owner] & $needed) && |
|
1169 | - (!$contact['private'] || ($grants[$owner] & EGW_ACL_PRIVATE) || in_array($owner,$memberships)); |
|
1168 | + $access = ($grants[$owner]&$needed) && |
|
1169 | + (!$contact['private'] || ($grants[$owner]&EGW_ACL_PRIVATE) || in_array($owner, $memberships)); |
|
1170 | 1170 | } |
1171 | 1171 | //error_log(__METHOD__."($needed,$contact[id],$deny_account_delete,$user) returning ".array2string($access)); |
1172 | 1172 | return $access; |
@@ -1181,9 +1181,9 @@ discard block |
||
1181 | 1181 | * @param int $user=null for which user to check, default current user |
1182 | 1182 | * @return boolean true if access is granted or false otherwise |
1183 | 1183 | */ |
1184 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
1184 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
1185 | 1185 | { |
1186 | - return $this->check_perms($check,$id,false,$user); |
|
1186 | + return $this->check_perms($check, $id, false, $user); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | /** |
@@ -1195,18 +1195,18 @@ discard block |
||
1195 | 1195 | function read_org($org_id) |
1196 | 1196 | { |
1197 | 1197 | if (!$org_id) return false; |
1198 | - if (strpos($org_id,'*AND*')!== false) $org_id = str_replace('*AND*','&',$org_id); |
|
1198 | + if (strpos($org_id, '*AND*') !== false) $org_id = str_replace('*AND*', '&', $org_id); |
|
1199 | 1199 | $org = array(); |
1200 | - foreach(explode('|||',$org_id) as $part) |
|
1200 | + foreach (explode('|||', $org_id) as $part) |
|
1201 | 1201 | { |
1202 | - list($name,$value) = explode(':',$part,2); |
|
1202 | + list($name, $value) = explode(':', $part, 2); |
|
1203 | 1203 | $org[$name] = $value; |
1204 | 1204 | } |
1205 | - $csvs = array('cat_id'); // fields with comma-separated-values |
|
1205 | + $csvs = array('cat_id'); // fields with comma-separated-values |
|
1206 | 1206 | |
1207 | 1207 | // split regular fields and custom fields |
1208 | 1208 | $custom_fields = $regular_fields = array(); |
1209 | - foreach($this->org_fields as $name) |
|
1209 | + foreach ($this->org_fields as $name) |
|
1210 | 1210 | { |
1211 | 1211 | if ($name[0] != '#') |
1212 | 1212 | { |
@@ -1214,9 +1214,9 @@ discard block |
||
1214 | 1214 | } |
1215 | 1215 | else |
1216 | 1216 | { |
1217 | - $custom_fields[] = $name = substr($name,1); |
|
1217 | + $custom_fields[] = $name = substr($name, 1); |
|
1218 | 1218 | $regular_fields['id'] = 'id'; |
1219 | - if (substr($this->customfields[$name]['type'],0,6)=='select' && $this->customfields[$name]['rows'] || // multiselection |
|
1219 | + if (substr($this->customfields[$name]['type'], 0, 6) == 'select' && $this->customfields[$name]['rows'] || // multiselection |
|
1220 | 1220 | $this->customfields[$name]['type'] == 'radio') |
1221 | 1221 | { |
1222 | 1222 | $csvs[] = '#'.$name; |
@@ -1224,24 +1224,24 @@ discard block |
||
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | // read the regular fields |
1227 | - $contacts = parent::search('',$regular_fields,'','','',false,'AND',false,$org); |
|
1227 | + $contacts = parent::search('', $regular_fields, '', '', '', false, 'AND', false, $org); |
|
1228 | 1228 | if (!$contacts) return false; |
1229 | 1229 | |
1230 | 1230 | // if we have custom fields, read and merge them in |
1231 | 1231 | if ($custom_fields) |
1232 | 1232 | { |
1233 | - foreach($contacts as $contact) |
|
1233 | + foreach ($contacts as $contact) |
|
1234 | 1234 | { |
1235 | 1235 | $ids[] = $contact['id']; |
1236 | 1236 | } |
1237 | - if (($cfs = $this->read_customfields($ids,$custom_fields))) |
|
1237 | + if (($cfs = $this->read_customfields($ids, $custom_fields))) |
|
1238 | 1238 | { |
1239 | 1239 | foreach ($contacts as &$contact) |
1240 | 1240 | { |
1241 | 1241 | $id = $contact['id']; |
1242 | 1242 | if (isset($cfs[$id])) |
1243 | 1243 | { |
1244 | - foreach($cfs[$id] as $name => $value) |
|
1244 | + foreach ($cfs[$id] as $name => $value) |
|
1245 | 1245 | { |
1246 | 1246 | $contact['#'.$name] = $value; |
1247 | 1247 | } |
@@ -1253,34 +1253,34 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | // create a statistic about the commonness of each fields values |
1255 | 1255 | $fields = array(); |
1256 | - foreach($contacts as $contact) |
|
1256 | + foreach ($contacts as $contact) |
|
1257 | 1257 | { |
1258 | - foreach($contact as $name => $value) |
|
1258 | + foreach ($contact as $name => $value) |
|
1259 | 1259 | { |
1260 | - if (!in_array($name,$csvs)) |
|
1260 | + if (!in_array($name, $csvs)) |
|
1261 | 1261 | { |
1262 | 1262 | $fields[$name][$value]++; |
1263 | 1263 | } |
1264 | 1264 | else |
1265 | 1265 | { |
1266 | 1266 | // for comma separated fields, we have to use each single value |
1267 | - foreach(explode(',',$value) as $val) |
|
1267 | + foreach (explode(',', $value) as $val) |
|
1268 | 1268 | { |
1269 | 1269 | $fields[$name][$val]++; |
1270 | 1270 | } |
1271 | 1271 | } |
1272 | 1272 | } |
1273 | 1273 | } |
1274 | - foreach($fields as $name => $values) |
|
1274 | + foreach ($fields as $name => $values) |
|
1275 | 1275 | { |
1276 | - if (!in_array($name,$this->org_fields)) continue; |
|
1276 | + if (!in_array($name, $this->org_fields)) continue; |
|
1277 | 1277 | |
1278 | - arsort($values,SORT_NUMERIC); |
|
1279 | - list($value,$num) = each($values); |
|
1278 | + arsort($values, SORT_NUMERIC); |
|
1279 | + list($value, $num) = each($values); |
|
1280 | 1280 | //echo "<p>$name: '$value' $num/".count($contacts)."=".($num / (double) count($contacts))." >= $this->org_common_factor = ".($num / (double) count($contacts) >= $this->org_common_factor ? 'true' : 'false')."</p>\n"; |
1281 | - if ($value && $num / (double) count($contacts) >= $this->org_common_factor) |
|
1281 | + if ($value && $num / (double)count($contacts) >= $this->org_common_factor) |
|
1282 | 1282 | { |
1283 | - if (!in_array($name,$csvs)) |
|
1283 | + if (!in_array($name, $csvs)) |
|
1284 | 1284 | { |
1285 | 1285 | $org[$name] = $value; |
1286 | 1286 | } |
@@ -1289,12 +1289,12 @@ discard block |
||
1289 | 1289 | $org[$name] = array(); |
1290 | 1290 | foreach ($values as $value => $num) |
1291 | 1291 | { |
1292 | - if ($value && $num / (double) count($contacts) >= $this->org_common_factor) |
|
1292 | + if ($value && $num / (double)count($contacts) >= $this->org_common_factor) |
|
1293 | 1293 | { |
1294 | 1294 | $org[$name][] = $value; |
1295 | 1295 | } |
1296 | 1296 | } |
1297 | - $org[$name] = implode(',',$org[$name]); |
|
1297 | + $org[$name] = implode(',', $org[$name]); |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | } |
@@ -1308,10 +1308,10 @@ discard block |
||
1308 | 1308 | * @param array $fields field-name => value pairs |
1309 | 1309 | * @return array with contacts |
1310 | 1310 | */ |
1311 | - function org_similar($org_name,$fields) |
|
1311 | + function org_similar($org_name, $fields) |
|
1312 | 1312 | { |
1313 | 1313 | $criteria = array(); |
1314 | - foreach($this->org_fields as $name) |
|
1314 | + foreach ($this->org_fields as $name) |
|
1315 | 1315 | { |
1316 | 1316 | if (isset($fields[$name])) |
1317 | 1317 | { |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | } |
1326 | 1326 | } |
1327 | 1327 | } |
1328 | - return parent::search($criteria,false,'n_family,n_given','','',false,'OR',false,array('org_name'=>$org_name)); |
|
1328 | + return parent::search($criteria, false, 'n_family,n_given', '', '', false, 'OR', false, array('org_name'=>$org_name)); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | /** |
@@ -1336,10 +1336,10 @@ discard block |
||
1336 | 1336 | * @param boolean $onld_org_fields=true check and return only org_fields, default true |
1337 | 1337 | * @return array with field-name => value from $from |
1338 | 1338 | */ |
1339 | - function changed_fields($from,$to,$only_org_fields=true) |
|
1339 | + function changed_fields($from, $to, $only_org_fields = true) |
|
1340 | 1340 | { |
1341 | 1341 | // we only care about countryname, if contrycode is empty |
1342 | - foreach(array( |
|
1342 | + foreach (array( |
|
1343 | 1343 | 'adr_one_countryname' => 'adr_one_countrycode', |
1344 | 1344 | 'adr_two_countryname' => 'adr_one_countrycode', |
1345 | 1345 | ) as $name => $code) |
@@ -1348,13 +1348,13 @@ discard block |
||
1348 | 1348 | if (!empty($to[$code])) $to[$name] = ''; |
1349 | 1349 | } |
1350 | 1350 | $changed = array(); |
1351 | - foreach($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) |
|
1351 | + foreach ($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) |
|
1352 | 1352 | { |
1353 | - if (in_array($name,array('modified','modifier'))) // never count these |
|
1353 | + if (in_array($name, array('modified', 'modifier'))) // never count these |
|
1354 | 1354 | { |
1355 | 1355 | continue; |
1356 | 1356 | } |
1357 | - if ((string) $from[$name] != (string) $to[$name]) |
|
1357 | + if ((string)$from[$name] != (string)$to[$name]) |
|
1358 | 1358 | { |
1359 | 1359 | $changed[$name] = $from[$name]; |
1360 | 1360 | } |
@@ -1371,35 +1371,35 @@ discard block |
||
1371 | 1371 | * @param array $members=null org-members to change, default null --> function queries them itself |
1372 | 1372 | * @return array/boolean (changed-members,changed-fields,failed-members) or false if no org_fields changed or no (other) members matching that fields |
1373 | 1373 | */ |
1374 | - function change_org($org_name,$from,$to,$members=null) |
|
1374 | + function change_org($org_name, $from, $to, $members = null) |
|
1375 | 1375 | { |
1376 | - if (!($changed = $this->changed_fields($from,$to,true))) return false; |
|
1376 | + if (!($changed = $this->changed_fields($from, $to, true))) return false; |
|
1377 | 1377 | |
1378 | 1378 | if (is_null($members) || !is_array($members)) |
1379 | 1379 | { |
1380 | - $members = $this->org_similar($org_name,$changed); |
|
1380 | + $members = $this->org_similar($org_name, $changed); |
|
1381 | 1381 | } |
1382 | 1382 | if (!$members) return false; |
1383 | 1383 | |
1384 | 1384 | $ids = array(); |
1385 | - foreach($members as $member) |
|
1385 | + foreach ($members as $member) |
|
1386 | 1386 | { |
1387 | 1387 | $ids[] = $member['id']; |
1388 | 1388 | } |
1389 | 1389 | $customfields = $this->read_customfields($ids); |
1390 | 1390 | |
1391 | 1391 | $changed_members = $changed_fields = $failed_members = 0; |
1392 | - foreach($members as $member) |
|
1392 | + foreach ($members as $member) |
|
1393 | 1393 | { |
1394 | 1394 | if (isset($customfields[$member['id']])) |
1395 | 1395 | { |
1396 | - foreach($this->customfields as $name => $data) |
|
1396 | + foreach ($this->customfields as $name => $data) |
|
1397 | 1397 | { |
1398 | 1398 | $member['#'.$name] = $customfields[$member['id']][$name]; |
1399 | 1399 | } |
1400 | 1400 | } |
1401 | 1401 | $fields = 0; |
1402 | - foreach($changed as $name => $value) |
|
1402 | + foreach ($changed as $name => $value) |
|
1403 | 1403 | { |
1404 | 1404 | if ((string)$value == (string)$member[$name]) |
1405 | 1405 | { |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | } |
1411 | 1411 | if ($fields) |
1412 | 1412 | { |
1413 | - if (!$this->check_perms(EGW_ACL_EDIT,$member) || !$this->save($member)) |
|
1413 | + if (!$this->check_perms(EGW_ACL_EDIT, $member) || !$this->save($member)) |
|
1414 | 1414 | { |
1415 | 1415 | ++$failed_members; |
1416 | 1416 | } |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | } |
1422 | 1422 | } |
1423 | 1423 | } |
1424 | - return array($changed_members,$changed_fields,$failed_members); |
|
1424 | + return array($changed_members, $changed_fields, $failed_members); |
|
1425 | 1425 | } |
1426 | 1426 | |
1427 | 1427 | /** |
@@ -1448,12 +1448,12 @@ discard block |
||
1448 | 1448 | if ($contact['n_fileas']) return $contact['n_fileas']; |
1449 | 1449 | $type = null; |
1450 | 1450 | } |
1451 | - $title = $this->fileas($contact,$type); |
|
1451 | + $title = $this->fileas($contact, $type); |
|
1452 | 1452 | if ($this->prefs['link_title_cf'] && $contact['#'.$this->prefs['link_title_cf']]) |
1453 | 1453 | { |
1454 | - $title .= ' ' . $contact['#'.$this->prefs['link_title_cf']]; |
|
1454 | + $title .= ' '.$contact['#'.$this->prefs['link_title_cf']]; |
|
1455 | 1455 | } |
1456 | - return $title ; |
|
1456 | + return $title; |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | /** |
@@ -1467,21 +1467,21 @@ discard block |
||
1467 | 1467 | function link_titles(array $ids) |
1468 | 1468 | { |
1469 | 1469 | $titles = array(); |
1470 | - if (($contacts =& $this->search(array('contact_id' => $ids),false))) |
|
1470 | + if (($contacts = & $this->search(array('contact_id' => $ids), false))) |
|
1471 | 1471 | { |
1472 | 1472 | $ids = array(); |
1473 | - foreach($contacts as $contact) |
|
1473 | + foreach ($contacts as $contact) |
|
1474 | 1474 | { |
1475 | 1475 | $ids[] = $contact['id']; |
1476 | 1476 | } |
1477 | 1477 | $cfs = $this->read_customfields($ids); |
1478 | - foreach($contacts as $contact) |
|
1478 | + foreach ($contacts as $contact) |
|
1479 | 1479 | { |
1480 | - $titles[$contact['id']] = $this->link_title($contact+(array)$cfs[$contact['id']]); |
|
1480 | + $titles[$contact['id']] = $this->link_title($contact + (array)$cfs[$contact['id']]); |
|
1481 | 1481 | } |
1482 | 1482 | } |
1483 | 1483 | // we assume all not returned contacts are not readable for the user (as we report all deleted contacts to egw_link) |
1484 | - foreach($ids as $id) |
|
1484 | + foreach ($ids as $id) |
|
1485 | 1485 | { |
1486 | 1486 | if (!isset($titles[$id])) |
1487 | 1487 | { |
@@ -1508,23 +1508,23 @@ discard block |
||
1508 | 1508 | { |
1509 | 1509 | $criteria = is_array($pattern) ? $pattern['search'] : $pattern; |
1510 | 1510 | } |
1511 | - if($options['start'] || $options['num_rows']) |
|
1511 | + if ($options['start'] || $options['num_rows']) |
|
1512 | 1512 | { |
1513 | 1513 | $limit = array($options['start'], $options['num_rows']); |
1514 | 1514 | } |
1515 | 1515 | $filter = (array)$options['filter']; |
1516 | 1516 | if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; |
1517 | - if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) |
|
1517 | + if (($contacts = & parent::search($criteria, false, 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', $limit, $filter))) |
|
1518 | 1518 | { |
1519 | 1519 | $ids = array(); |
1520 | - foreach($contacts as $contact) |
|
1520 | + foreach ($contacts as $contact) |
|
1521 | 1521 | { |
1522 | 1522 | $ids[] = $contact['id']; |
1523 | 1523 | } |
1524 | 1524 | $cfs = $this->read_customfields($ids); |
1525 | - foreach($contacts as $contact) |
|
1525 | + foreach ($contacts as $contact) |
|
1526 | 1526 | { |
1527 | - $result[$contact['id']] = $this->link_title($contact+(array)$cfs[$contact['id']]); |
|
1527 | + $result[$contact['id']] = $this->link_title($contact + (array)$cfs[$contact['id']]); |
|
1528 | 1528 | // make sure to return a correctly quoted rfc822 address, if requested |
1529 | 1529 | if ($options['type'] === 'email') |
1530 | 1530 | { |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | // let link query know, to append email to list |
1566 | 1566 | $options['type'] = 'email'; |
1567 | 1567 | |
1568 | - return $this->link_query($pattern,$options); |
|
1568 | + return $this->link_query($pattern, $options); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | /** |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | if (!$ids) return null; |
1580 | 1580 | |
1581 | 1581 | $data = array(); |
1582 | - foreach(!is_array($ids) ? array($ids) : $ids as $id) |
|
1582 | + foreach (!is_array($ids) ? array($ids) : $ids as $id) |
|
1583 | 1583 | { |
1584 | 1584 | if (!($contact = $this->read($id))) continue; |
1585 | 1585 | |
@@ -1602,12 +1602,12 @@ discard block |
||
1602 | 1602 | * @param boolean $extra_title=true if true, use a short date only title and put the full title as extra_title (tooltip) |
1603 | 1603 | * @return array |
1604 | 1604 | */ |
1605 | - function read_calendar($ids,$extra_title=true) |
|
1605 | + function read_calendar($ids, $extra_title = true) |
|
1606 | 1606 | { |
1607 | 1607 | if (!$GLOBALS['egw_info']['user']['apps']['calendar']) return array(); |
1608 | 1608 | |
1609 | 1609 | $uids = array(); |
1610 | - foreach($ids as $id) |
|
1610 | + foreach ($ids as $id) |
|
1611 | 1611 | { |
1612 | 1612 | if (is_numeric($id)) $uids[] = 'c'.$id; |
1613 | 1613 | } |
@@ -1622,15 +1622,15 @@ discard block |
||
1622 | 1622 | |
1623 | 1623 | //_debug_array($events); |
1624 | 1624 | $calendars = array(); |
1625 | - foreach($events as $event) |
|
1625 | + foreach ($events as $event) |
|
1626 | 1626 | { |
1627 | - foreach($event['participants'] as $uid => $status) |
|
1627 | + foreach ($event['participants'] as $uid => $status) |
|
1628 | 1628 | { |
1629 | 1629 | if ($uid[0] != 'c' || ($status == 'R' && !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])) |
1630 | 1630 | { |
1631 | 1631 | continue; |
1632 | 1632 | } |
1633 | - $id = (int)substr($uid,1); |
|
1633 | + $id = (int)substr($uid, 1); |
|
1634 | 1634 | |
1635 | 1635 | if ($event['start'] < $this->now_su) // past event --> check for last event |
1636 | 1636 | { |
@@ -1642,13 +1642,13 @@ discard block |
||
1642 | 1642 | 'app' => 'calendar', |
1643 | 1643 | 'title' => $bocal->link_title($event), |
1644 | 1644 | 'extra_args' => array( |
1645 | - 'date' => date('Ymd',$event['start']), |
|
1645 | + 'date' => date('Ymd', $event['start']), |
|
1646 | 1646 | ), |
1647 | 1647 | ); |
1648 | 1648 | if ($extra_title) |
1649 | 1649 | { |
1650 | 1650 | $link['extra_title'] = $link['title']; |
1651 | - $link['title'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],$event['start']); |
|
1651 | + $link['title'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $event['start']); |
|
1652 | 1652 | } |
1653 | 1653 | $calendars[$id]['last_link'] = $link; |
1654 | 1654 | } |
@@ -1663,13 +1663,13 @@ discard block |
||
1663 | 1663 | 'app' => 'calendar', |
1664 | 1664 | 'title' => $bocal->link_title($event), |
1665 | 1665 | 'extra_args' => array( |
1666 | - 'date' => date('Ymd',$event['start']), |
|
1666 | + 'date' => date('Ymd', $event['start']), |
|
1667 | 1667 | ), |
1668 | 1668 | ); |
1669 | 1669 | if ($extra_title) |
1670 | 1670 | { |
1671 | 1671 | $link['extra_title'] = $link['title']; |
1672 | - $link['title'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],$event['start']); |
|
1672 | + $link['title'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $event['start']); |
|
1673 | 1673 | } |
1674 | 1674 | $calendars[$id]['next_link'] = $link; |
1675 | 1675 | } |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | { |
1699 | 1699 | // get all cats if you want to drop sub cats |
1700 | 1700 | $drop_subs = ($data['drop_subs'] && !$data['modify_subs']); |
1701 | - if($drop_subs) |
|
1701 | + if ($drop_subs) |
|
1702 | 1702 | { |
1703 | 1703 | $cats = new categories('', 'addressbook'); |
1704 | 1704 | $cat_ids = $cats->return_all_children($data['cat_id']); |
@@ -1709,14 +1709,14 @@ discard block |
||
1709 | 1709 | } |
1710 | 1710 | |
1711 | 1711 | // Get addresses that use the category |
1712 | - @set_time_limit( 0 ); |
|
1713 | - foreach($cat_ids as $cat_id) |
|
1712 | + @set_time_limit(0); |
|
1713 | + foreach ($cat_ids as $cat_id) |
|
1714 | 1714 | { |
1715 | 1715 | if (($ids = $this->search(array('cat_id' => $cat_id), false))) |
1716 | 1716 | { |
1717 | - foreach($ids as &$info) |
|
1717 | + foreach ($ids as &$info) |
|
1718 | 1718 | { |
1719 | - $info['cat_id'] = implode(',',array_diff(explode(',',$info['cat_id']), $cat_ids)); |
|
1719 | + $info['cat_id'] = implode(',', array_diff(explode(',', $info['cat_id']), $cat_ids)); |
|
1720 | 1720 | $this->save($info); |
1721 | 1721 | } |
1722 | 1722 | } |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | { |
1736 | 1736 | // just force a new registration of the addressbook hooks |
1737 | 1737 | include(EGW_INCLUDE_ROOT.'/addressbook/setup/setup.inc.php'); |
1738 | - $GLOBALS['egw']->hooks->register_hooks('addressbook',$setup_info['addressbook']['hooks']); |
|
1738 | + $GLOBALS['egw']->hooks->register_hooks('addressbook', $setup_info['addressbook']['hooks']); |
|
1739 | 1739 | } |
1740 | 1740 | |
1741 | 1741 | /** |
@@ -1753,14 +1753,14 @@ discard block |
||
1753 | 1753 | $account = null; |
1754 | 1754 | $custom_fields = config::get_customfields('addressbook', true); |
1755 | 1755 | $custom_field_list = $this->read_customfields($ids); |
1756 | - foreach(parent::search(array('id'=>$ids),false) as $contact) // $this->search calls the extended search from ui! |
|
1756 | + foreach (parent::search(array('id'=>$ids), false) as $contact) // $this->search calls the extended search from ui! |
|
1757 | 1757 | { |
1758 | 1758 | if ($contact['account_id']) |
1759 | 1759 | { |
1760 | 1760 | if (!is_null($account)) |
1761 | 1761 | { |
1762 | 1762 | echo $this->error = 'Can not merge more then one account!'; |
1763 | - return false; // we dont deal with two accounts! |
|
1763 | + return false; // we dont deal with two accounts! |
|
1764 | 1764 | } |
1765 | 1765 | $account = $contact; |
1766 | 1766 | continue; |
@@ -1768,7 +1768,7 @@ discard block |
||
1768 | 1768 | // Add in custom fields |
1769 | 1769 | if (is_array($custom_field_list[$contact['id']])) $contact = array_merge($contact, $custom_field_list[$contact['id']]); |
1770 | 1770 | |
1771 | - $pos = array_search($contact['id'],$ids); |
|
1771 | + $pos = array_search($contact['id'], $ids); |
|
1772 | 1772 | $contacts[$pos] = $contact; |
1773 | 1773 | } |
1774 | 1774 | if (!is_null($account)) // we found an account, so we merge the contacts into it |
@@ -1781,38 +1781,38 @@ discard block |
||
1781 | 1781 | $target = $contacts[0]; |
1782 | 1782 | unset($contacts[0]); |
1783 | 1783 | } |
1784 | - if (!$this->check_perms(EGW_ACL_EDIT,$target)) |
|
1784 | + if (!$this->check_perms(EGW_ACL_EDIT, $target)) |
|
1785 | 1785 | { |
1786 | 1786 | echo $this->error = 'No edit permission for the target contact!'; |
1787 | 1787 | return 0; |
1788 | 1788 | } |
1789 | - foreach($contacts as $contact) |
|
1789 | + foreach ($contacts as $contact) |
|
1790 | 1790 | { |
1791 | - foreach($contact as $name => $value) |
|
1791 | + foreach ($contact as $name => $value) |
|
1792 | 1792 | { |
1793 | 1793 | if (!$value) continue; |
1794 | 1794 | |
1795 | - switch($name) |
|
1795 | + switch ($name) |
|
1796 | 1796 | { |
1797 | 1797 | case 'id': |
1798 | 1798 | case 'tid': |
1799 | 1799 | case 'owner': |
1800 | 1800 | case 'private': |
1801 | 1801 | case 'etag'; |
1802 | - break; // ignored |
|
1802 | + break; // ignored |
|
1803 | 1803 | |
1804 | 1804 | case 'cat_id': // cats are all merged together |
1805 | - if (!is_array($target['cat_id'])) $target['cat_id'] = $target['cat_id'] ? explode(',',$target['cat_id']) : array(); |
|
1806 | - $target['cat_id'] = array_unique(array_merge($target['cat_id'],is_array($value)?$value:explode(',',$value))); |
|
1805 | + if (!is_array($target['cat_id'])) $target['cat_id'] = $target['cat_id'] ? explode(',', $target['cat_id']) : array(); |
|
1806 | + $target['cat_id'] = array_unique(array_merge($target['cat_id'], is_array($value) ? $value : explode(',', $value))); |
|
1807 | 1807 | break; |
1808 | 1808 | |
1809 | 1809 | default: |
1810 | 1810 | // Multi-select custom fields can also be merged |
1811 | - if($name[0] == '#') { |
|
1811 | + if ($name[0] == '#') { |
|
1812 | 1812 | $c_name = substr($name, 1); |
1813 | - if($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) { |
|
1814 | - if (!is_array($target[$name])) $target[$name] = $target[$name] ? explode(',',$target[$name]) : array(); |
|
1815 | - $target[$name] = implode(',',array_unique(array_merge($target[$name],is_array($value)?$value:explode(',',$value)))); |
|
1813 | + if ($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) { |
|
1814 | + if (!is_array($target[$name])) $target[$name] = $target[$name] ? explode(',', $target[$name]) : array(); |
|
1815 | + $target[$name] = implode(',', array_unique(array_merge($target[$name], is_array($value) ? $value : explode(',', $value)))); |
|
1816 | 1816 | } |
1817 | 1817 | } |
1818 | 1818 | if (!$target[$name]) $target[$name] = $value; |
@@ -1823,29 +1823,29 @@ discard block |
||
1823 | 1823 | if (!$this->save($target)) return 0; |
1824 | 1824 | |
1825 | 1825 | $success = 1; |
1826 | - foreach($contacts as $contact) |
|
1826 | + foreach ($contacts as $contact) |
|
1827 | 1827 | { |
1828 | - if (!$this->check_perms(EGW_ACL_DELETE,$contact)) |
|
1828 | + if (!$this->check_perms(EGW_ACL_DELETE, $contact)) |
|
1829 | 1829 | { |
1830 | 1830 | continue; |
1831 | 1831 | } |
1832 | - foreach(egw_link::get_links('addressbook',$contact['id']) as $data) |
|
1832 | + foreach (egw_link::get_links('addressbook', $contact['id']) as $data) |
|
1833 | 1833 | { |
1834 | 1834 | //_debug_array(array('function'=>__METHOD__,'line'=>__LINE__,'app'=>'addressbook','id'=>$contact['id'],'data:'=>$data,'target'=>$target['id'])); |
1835 | 1835 | // info_from and info_link_id (main link) |
1836 | - $newlinkID = egw_link::link('addressbook',$target['id'],$data['app'],$data['id'],$data['remark'],$target['owner']); |
|
1836 | + $newlinkID = egw_link::link('addressbook', $target['id'], $data['app'], $data['id'], $data['remark'], $target['owner']); |
|
1837 | 1837 | //_debug_array(array('newLinkID'=>$newlinkID)); |
1838 | 1838 | if ($newlinkID) |
1839 | 1839 | { |
1840 | 1840 | // update egw_infolog set info_link_id=$newlinkID where info_id=$data['id'] and info_link_id=$data['link_id'] |
1841 | - if ($data['app']=='infolog') |
|
1841 | + if ($data['app'] == 'infolog') |
|
1842 | 1842 | { |
1843 | - $this->db->update('egw_infolog',array( |
|
1843 | + $this->db->update('egw_infolog', array( |
|
1844 | 1844 | 'info_link_id' => $newlinkID |
1845 | - ),array( |
|
1845 | + ), array( |
|
1846 | 1846 | 'info_id' => $data['id'], |
1847 | 1847 | 'info_link_id' => $data['link_id'] |
1848 | - ),__LINE__,__FILE__,'infolog'); |
|
1848 | + ), __LINE__, __FILE__, 'infolog'); |
|
1849 | 1849 | } |
1850 | 1850 | unset($newlinkID); |
1851 | 1851 | } |
@@ -1870,14 +1870,14 @@ discard block |
||
1870 | 1870 | * @param int $owner=null |
1871 | 1871 | * @return boolean |
1872 | 1872 | */ |
1873 | - function check_list($list,$required,$owner=null) |
|
1873 | + function check_list($list, $required, $owner = null) |
|
1874 | 1874 | { |
1875 | 1875 | if ($list && ($list_data = $this->read_list($list))) |
1876 | 1876 | { |
1877 | 1877 | $owner = $list_data['list_owner']; |
1878 | 1878 | } |
1879 | 1879 | //error_log(__METHOD__."($list, $required, $owner) grants[$owner]=".$this->grants[$owner]." returning ".array2string(!!($this->grants[$owner] & $required))); |
1880 | - return !!($this->grants[$owner] & $required); |
|
1880 | + return !!($this->grants[$owner]&$required); |
|
1881 | 1881 | } |
1882 | 1882 | |
1883 | 1883 | /** |
@@ -1889,16 +1889,16 @@ discard block |
||
1889 | 1889 | * @param array &$data=array() values for keys 'list_uid', 'list_carddav_name', 'list_name' |
1890 | 1890 | * @return int|boolean integer list_id or false on error |
1891 | 1891 | */ |
1892 | - function add_list($keys,$owner,$contacts=array(),array &$data=array()) |
|
1892 | + function add_list($keys, $owner, $contacts = array(), array &$data = array()) |
|
1893 | 1893 | { |
1894 | - if (!$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) return false; |
|
1894 | + if (!$this->check_list(null, EGW_ACL_ADD|EGW_ACL_EDIT, $owner)) return false; |
|
1895 | 1895 | |
1896 | 1896 | try { |
1897 | - $ret = parent::add_list($keys,$owner,$contacts,$data); |
|
1897 | + $ret = parent::add_list($keys, $owner, $contacts, $data); |
|
1898 | 1898 | if ($ret) unset(self::$list_cache[$ret]); |
1899 | 1899 | } |
1900 | 1900 | // catch sql error, as creating same name&owner list gives a sql error doublicate key |
1901 | - catch(egw_exception_db_invalid_sql $e) { |
|
1901 | + catch (egw_exception_db_invalid_sql $e) { |
|
1902 | 1902 | return false; |
1903 | 1903 | } |
1904 | 1904 | return $ret; |
@@ -1912,13 +1912,13 @@ discard block |
||
1912 | 1912 | * @param array $existing=null array of existing contact-id(s) of list, to not reread it, eg. array() |
1913 | 1913 | * @return false on error |
1914 | 1914 | */ |
1915 | - function add2list($contact,$list,array $existing=null) |
|
1915 | + function add2list($contact, $list, array $existing = null) |
|
1916 | 1916 | { |
1917 | - if (!$this->check_list($list,EGW_ACL_EDIT)) return false; |
|
1917 | + if (!$this->check_list($list, EGW_ACL_EDIT)) return false; |
|
1918 | 1918 | |
1919 | 1919 | unset(self::$list_cache[$list]); |
1920 | 1920 | |
1921 | - return parent::add2list($contact,$list,$existing); |
|
1921 | + return parent::add2list($contact, $list, $existing); |
|
1922 | 1922 | } |
1923 | 1923 | |
1924 | 1924 | /** |
@@ -1928,9 +1928,9 @@ discard block |
||
1928 | 1928 | * @param int $list list-id |
1929 | 1929 | * @return false on error |
1930 | 1930 | */ |
1931 | - function remove_from_list($contact,$list=null) |
|
1931 | + function remove_from_list($contact, $list = null) |
|
1932 | 1932 | { |
1933 | - if ($list && !$this->check_list($list,EGW_ACL_EDIT)) return false; |
|
1933 | + if ($list && !$this->check_list($list, EGW_ACL_EDIT)) return false; |
|
1934 | 1934 | |
1935 | 1935 | if ($list) |
1936 | 1936 | { |
@@ -1941,7 +1941,7 @@ discard block |
||
1941 | 1941 | self::$list_cache = array(); |
1942 | 1942 | } |
1943 | 1943 | |
1944 | - return parent::remove_from_list($contact,$list); |
|
1944 | + return parent::remove_from_list($contact, $list); |
|
1945 | 1945 | } |
1946 | 1946 | |
1947 | 1947 | /** |
@@ -1952,9 +1952,9 @@ discard block |
||
1952 | 1952 | */ |
1953 | 1953 | function delete_list($list) |
1954 | 1954 | { |
1955 | - if (!$this->check_list($list,EGW_ACL_DELETE)) return false; |
|
1955 | + if (!$this->check_list($list, EGW_ACL_DELETE)) return false; |
|
1956 | 1956 | |
1957 | - foreach((array)$list as $l) |
|
1957 | + foreach ((array)$list as $l) |
|
1958 | 1958 | { |
1959 | 1959 | unset(self::$list_cache[$l]); |
1960 | 1960 | } |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | { |
1991 | 1991 | $code = $GLOBALS['egw']->country->country_code($country); |
1992 | 1992 | |
1993 | - switch($code) |
|
1993 | + switch ($code) |
|
1994 | 1994 | { |
1995 | 1995 | case 'AU': |
1996 | 1996 | case 'CA': |
@@ -2055,12 +2055,12 @@ discard block |
||
2055 | 2055 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
2056 | 2056 | * @return array category ids (found, added and preserved categories) |
2057 | 2057 | */ |
2058 | - function find_or_add_categories($catname_list, $contact_id=null) |
|
2058 | + function find_or_add_categories($catname_list, $contact_id = null) |
|
2059 | 2059 | { |
2060 | 2060 | if ($contact_id && $contact_id > 0 && ($old_contact = $this->read($contact_id))) |
2061 | 2061 | { |
2062 | 2062 | // preserve categories without users read access |
2063 | - $old_categories = explode(',',$old_contact['cat_id']); |
|
2063 | + $old_categories = explode(',', $old_contact['cat_id']); |
|
2064 | 2064 | $old_cats_preserve = array(); |
2065 | 2065 | if (is_array($old_categories) && count($old_categories) > 0) |
2066 | 2066 | { |
@@ -2114,15 +2114,15 @@ discard block |
||
2114 | 2114 | { |
2115 | 2115 | if (!is_object($this->categories)) |
2116 | 2116 | { |
2117 | - $this->categories = new categories($this->user,'addressbook'); |
|
2117 | + $this->categories = new categories($this->user, 'addressbook'); |
|
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | if (!is_array($cat_id_list)) |
2121 | 2121 | { |
2122 | - $cat_id_list = explode(',',$cat_id_list); |
|
2122 | + $cat_id_list = explode(',', $cat_id_list); |
|
2123 | 2123 | } |
2124 | 2124 | $cat_list = array(); |
2125 | - foreach($cat_id_list as $cat_id) |
|
2125 | + foreach ($cat_id_list as $cat_id) |
|
2126 | 2126 | { |
2127 | 2127 | if ($cat_id && $this->categories->check_perms(EGW_ACL_READ, $cat_id) && |
2128 | 2128 | ($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--') |
@@ -2154,14 +2154,14 @@ discard block |
||
2154 | 2154 | * @param boolean $relax=false if asked to relax, we only match against some key fields |
2155 | 2155 | * @return array od matching contact_ids |
2156 | 2156 | */ |
2157 | - function find_contact($contact, $relax=false) |
|
2157 | + function find_contact($contact, $relax = false) |
|
2158 | 2158 | { |
2159 | 2159 | $empty_addr_one = $empty_addr_two = true; |
2160 | 2160 | |
2161 | 2161 | if ($this->log) |
2162 | 2162 | { |
2163 | 2163 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2164 | - . '('. ($relax ? 'RELAX': 'EXACT') . ')[ContactData]:' |
|
2164 | + . '('.($relax ? 'RELAX' : 'EXACT').')[ContactData]:' |
|
2165 | 2165 | . array2string($contact) |
2166 | 2166 | . "\n", 3, $this->logfile); |
2167 | 2167 | } |
@@ -2172,7 +2172,7 @@ discard block |
||
2172 | 2172 | if ($this->log) |
2173 | 2173 | { |
2174 | 2174 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2175 | - . '()[ContactID]: ' . $contact['id'] |
|
2175 | + . '()[ContactID]: '.$contact['id'] |
|
2176 | 2176 | . "\n", 3, $this->logfile); |
2177 | 2177 | } |
2178 | 2178 | // We only do a simple consistency check |
@@ -2190,11 +2190,11 @@ discard block |
||
2190 | 2190 | if ($this->log) |
2191 | 2191 | { |
2192 | 2192 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2193 | - . '()[ContactUID]: ' . $contact['uid'] |
|
2193 | + . '()[ContactUID]: '.$contact['uid'] |
|
2194 | 2194 | . "\n", 3, $this->logfile); |
2195 | 2195 | } |
2196 | 2196 | // Try the given UID first |
2197 | - $criteria = array ('contact_uid' => $contact['uid']); |
|
2197 | + $criteria = array('contact_uid' => $contact['uid']); |
|
2198 | 2198 | if (($foundContacts = parent::search($criteria))) |
2199 | 2199 | { |
2200 | 2200 | foreach ($foundContacts as $egwContact) |
@@ -2279,7 +2279,7 @@ discard block |
||
2279 | 2279 | { |
2280 | 2280 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2281 | 2281 | . '()[Addressbook FIND Step 1]: ' |
2282 | - . 'CRITERIA = ' . array2string($criteria) |
|
2282 | + . 'CRITERIA = '.array2string($criteria) |
|
2283 | 2283 | . "\n", 3, $this->logfile); |
2284 | 2284 | } |
2285 | 2285 | |
@@ -2308,7 +2308,7 @@ discard block |
||
2308 | 2308 | { |
2309 | 2309 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2310 | 2310 | . '()[Addressbook FIND Step 2]: ' |
2311 | - . 'CRITERIA = ' . array2string($criteria) |
|
2311 | + . 'CRITERIA = '.array2string($criteria) |
|
2312 | 2312 | . "\n", 3, $this->logfile); |
2313 | 2313 | } |
2314 | 2314 | |
@@ -2332,7 +2332,7 @@ discard block |
||
2332 | 2332 | { |
2333 | 2333 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2334 | 2334 | . '()[Addressbook FIND Step 3]: ' |
2335 | - . 'CRITERIA = ' . array2string($criteria) |
|
2335 | + . 'CRITERIA = '.array2string($criteria) |
|
2336 | 2336 | . "\n", 3, $this->logfile); |
2337 | 2337 | } |
2338 | 2338 | |
@@ -2358,7 +2358,7 @@ discard block |
||
2358 | 2358 | { |
2359 | 2359 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2360 | 2360 | . '()[Addressbook FIND Step 4]: ' |
2361 | - . 'CRITERIA = ' . array2string($criteria) |
|
2361 | + . 'CRITERIA = '.array2string($criteria) |
|
2362 | 2362 | . "\n", 3, $this->logfile); |
2363 | 2363 | } |
2364 | 2364 | if (($foundContacts = parent::search($criteria, true, '', '', '', true))) |
@@ -2372,7 +2372,7 @@ discard block |
||
2372 | 2372 | if ($this->log) |
2373 | 2373 | { |
2374 | 2374 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2375 | - . '()[FOUND]: ' . array2string($matchingContacts) |
|
2375 | + . '()[FOUND]: '.array2string($matchingContacts) |
|
2376 | 2376 | . "\n", 3, $this->logfile); |
2377 | 2377 | } |
2378 | 2378 | return $matchingContacts; |
@@ -2389,9 +2389,9 @@ discard block |
||
2389 | 2389 | * @param int|array $owner=null 0=accounts, null=all addressbooks or integer account_id of user or group |
2390 | 2390 | * @return string |
2391 | 2391 | */ |
2392 | - public function get_ctag($owner=null) |
|
2392 | + public function get_ctag($owner = null) |
|
2393 | 2393 | { |
2394 | - $filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D') |
|
2394 | + $filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D') |
|
2395 | 2395 | // show addressbook of a single user? |
2396 | 2396 | if (!is_null($owner)) $filter['owner'] = $owner; |
2397 | 2397 | |
@@ -2400,11 +2400,11 @@ discard block |
||
2400 | 2400 | { |
2401 | 2401 | $filter['account_id'] = null; |
2402 | 2402 | } |
2403 | - $result = $this->search(array(),'contact_modified','contact_modified DESC','','',false,'AND',array(0,1),$filter); |
|
2403 | + $result = $this->search(array(), 'contact_modified', 'contact_modified DESC', '', '', false, 'AND', array(0, 1), $filter); |
|
2404 | 2404 | |
2405 | 2405 | if (!$result || !isset($result[0]['modified'])) |
2406 | 2406 | { |
2407 | - $ctag = 'empty'; // ctag for empty addressbook |
|
2407 | + $ctag = 'empty'; // ctag for empty addressbook |
|
2408 | 2408 | } |
2409 | 2409 | else |
2410 | 2410 | { |
@@ -285,7 +285,10 @@ discard block |
||
285 | 285 | ); |
286 | 286 | //_debug_array($this->contact_fields); |
287 | 287 | $this->own_account_acl = $GLOBALS['egw_info']['server']['own_account_acl']; |
288 | - if (!is_array($this->own_account_acl)) $this->own_account_acl = unserialize($this->own_account_acl); |
|
288 | + if (!is_array($this->own_account_acl)) |
|
289 | + { |
|
290 | + $this->own_account_acl = unserialize($this->own_account_acl); |
|
291 | + } |
|
289 | 292 | // we have only one acl (n_fn) for the whole name, as not all backends store every part in an own field |
290 | 293 | if ($this->own_account_acl && in_array('n_fn',$this->own_account_acl)) |
291 | 294 | { |
@@ -294,7 +297,10 @@ discard block |
||
294 | 297 | if ($GLOBALS['egw_info']['server']['org_fileds_to_update']) |
295 | 298 | { |
296 | 299 | $this->org_fields = $GLOBALS['egw_info']['server']['org_fileds_to_update']; |
297 | - if (!is_array($this->org_fields)) $this->org_fields = unserialize($this->org_fields); |
|
300 | + if (!is_array($this->org_fields)) |
|
301 | + { |
|
302 | + $this->org_fields = unserialize($this->org_fields); |
|
303 | + } |
|
298 | 304 | |
299 | 305 | // Set country code if country name is selected |
300 | 306 | $supported_fields = $this->get_fields('supported',null,0); |
@@ -353,7 +359,10 @@ discard block |
||
353 | 359 | } |
354 | 360 | |
355 | 361 | $addressbooks = $to_sort = array(); |
356 | - if ($extra_label) $addressbooks[''] = $extra_label; |
|
362 | + if ($extra_label) |
|
363 | + { |
|
364 | + $addressbooks[''] = $extra_label; |
|
365 | + } |
|
357 | 366 | $addressbooks[$user] = lang('Personal'); |
358 | 367 | // add all group addressbooks the user has the necessary rights too |
359 | 368 | foreach($grants as $uid => $rights) |
@@ -408,10 +417,19 @@ discard block |
||
408 | 417 | */ |
409 | 418 | function fileas($contact,$type=null, $isUpdate=false) |
410 | 419 | { |
411 | - if (is_null($type)) $type = $contact['fileas_type']; |
|
412 | - if (!$type) $type = $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; |
|
420 | + if (is_null($type)) |
|
421 | + { |
|
422 | + $type = $contact['fileas_type']; |
|
423 | + } |
|
424 | + if (!$type) |
|
425 | + { |
|
426 | + $type = $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; |
|
427 | + } |
|
413 | 428 | |
414 | - if (strpos($type,'n_fn') !== false) $contact['n_fn'] = $this->fullname($contact); |
|
429 | + if (strpos($type,'n_fn') !== false) |
|
430 | + { |
|
431 | + $contact['n_fn'] = $this->fullname($contact); |
|
432 | + } |
|
415 | 433 | |
416 | 434 | if($isUpdate) |
417 | 435 | { |
@@ -421,7 +439,10 @@ discard block |
||
421 | 439 | { |
422 | 440 | if(!isset($contact[$field])) |
423 | 441 | { |
424 | - if(is_null($old)) $old = $this->read($contact['id']); |
|
442 | + if(is_null($old)) |
|
443 | + { |
|
444 | + $old = $this->read($contact['id']); |
|
445 | + } |
|
425 | 446 | $contact[$field] = $old[$field]; |
426 | 447 | } |
427 | 448 | } |
@@ -464,7 +485,10 @@ discard block |
||
464 | 485 | */ |
465 | 486 | function fileas_type($contact,$file_as=null) |
466 | 487 | { |
467 | - if (is_null($file_as)) $file_as = $contact['n_fileas']; |
|
488 | + if (is_null($file_as)) |
|
489 | + { |
|
490 | + $file_as = $contact['n_fileas']; |
|
491 | + } |
|
468 | 492 | |
469 | 493 | if ($file_as) |
470 | 494 | { |
@@ -517,7 +541,10 @@ discard block |
||
517 | 541 | ); |
518 | 542 | foreach($labels as $name => $label) |
519 | 543 | { |
520 | - if ($contact[$name]) $labels[$name] = $contact[$name]; |
|
544 | + if ($contact[$name]) |
|
545 | + { |
|
546 | + $labels[$name] = $contact[$name]; |
|
547 | + } |
|
521 | 548 | } |
522 | 549 | foreach($this->fileas_types as $fileas_type) |
523 | 550 | { |
@@ -631,7 +658,11 @@ discard block |
||
631 | 658 | $fields_to_update = array(); |
632 | 659 | foreach($contact as $field_name => $field_value) |
633 | 660 | { |
634 | - if($fields_exclude[$field_name] === true) continue; // dont touch specified field |
|
661 | + if($fields_exclude[$field_name] === true) |
|
662 | + { |
|
663 | + continue; |
|
664 | + } |
|
665 | + // dont touch specified field |
|
635 | 666 | |
636 | 667 | if (is_string($field_value) && $field_name != 'pubkey' && $field_name != 'jpegphoto') |
637 | 668 | { |
@@ -690,15 +721,21 @@ discard block |
||
690 | 721 | */ |
691 | 722 | function fullname($contact) |
692 | 723 | { |
693 | - if (empty($contact['n_family']) && empty($contact['n_given'])) { |
|
724 | + if (empty($contact['n_family']) && empty($contact['n_given'])) |
|
725 | + { |
|
694 | 726 | $cpart = array('org_name'); |
695 | - } else { |
|
727 | + } |
|
728 | + else |
|
729 | + { |
|
696 | 730 | $cpart = array('n_prefix','n_given','n_middle','n_family','n_suffix'); |
697 | 731 | } |
698 | 732 | $parts = array(); |
699 | 733 | foreach($cpart as $n) |
700 | 734 | { |
701 | - if ($contact[$n]) $parts[] = $contact[$n]; |
|
735 | + if ($contact[$n]) |
|
736 | + { |
|
737 | + $parts[] = $contact[$n]; |
|
738 | + } |
|
702 | 739 | } |
703 | 740 | return implode(' ',$parts); |
704 | 741 | } |
@@ -809,7 +846,10 @@ discard block |
||
809 | 846 | $ok = false; |
810 | 847 | if ($this->check_perms(EGW_ACL_DELETE,$c,$deny_account_delete)) |
811 | 848 | { |
812 | - if (!($old = $this->read($id))) return false; |
|
849 | + if (!($old = $this->read($id))) |
|
850 | + { |
|
851 | + return false; |
|
852 | + } |
|
813 | 853 | // check if we only mark contacts as deleted, or really delete them |
814 | 854 | // already marked as deleted item and accounts are always really deleted |
815 | 855 | // we cant mark accounts as deleted, as no such thing exists for accounts! |
@@ -817,8 +857,15 @@ discard block |
||
817 | 857 | { |
818 | 858 | $delete = $old; |
819 | 859 | $delete['tid'] = addressbook_so::DELETED_TYPE; |
820 | - if ($check_etag) $delete['etag'] = $check_etag; |
|
821 | - if (($ok = $this->save($delete))) $ok = true; // we have to return true or false |
|
860 | + if ($check_etag) |
|
861 | + { |
|
862 | + $delete['etag'] = $check_etag; |
|
863 | + } |
|
864 | + if (($ok = $this->save($delete))) |
|
865 | + { |
|
866 | + $ok = true; |
|
867 | + } |
|
868 | + // we have to return true or false |
|
822 | 869 | egw_link::unlink(0,'addressbook',$id,'','','',true); |
823 | 870 | } |
824 | 871 | elseif (($ok = parent::delete($id,$check_etag))) |
@@ -830,7 +877,10 @@ discard block |
||
830 | 877 | if ($ok && $old['tid'] != addressbook_so::DELETED_TYPE) |
831 | 878 | { |
832 | 879 | $GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time()); |
833 | - if (!isset($this->tracking)) $this->tracking = new addressbook_tracking($this); |
|
880 | + if (!isset($this->tracking)) |
|
881 | + { |
|
882 | + $this->tracking = new addressbook_tracking($this); |
|
883 | + } |
|
834 | 884 | $this->tracking->track(array('id' => $id), array('id' => $id), null, true); |
835 | 885 | } |
836 | 886 | } |
@@ -855,13 +905,16 @@ discard block |
||
855 | 905 | // remember if we add or update a entry |
856 | 906 | if (($isUpdate = $contact['id'])) |
857 | 907 | { |
858 | - if (!isset($contact['owner']) || !isset($contact['private'])) // owner/private not set on update, eg. SyncML |
|
908 | + if (!isset($contact['owner']) || !isset($contact['private'])) |
|
909 | + { |
|
910 | + // owner/private not set on update, eg. SyncML |
|
859 | 911 | { |
860 | 912 | if (($old = $this->read($contact['id']))) // --> try reading the old entry and set it from there |
861 | 913 | { |
862 | 914 | if(!isset($contact['owner'])) |
863 | 915 | { |
864 | 916 | $contact['owner'] = $old['owner']; |
917 | + } |
|
865 | 918 | } |
866 | 919 | if(!isset($contact['private'])) |
867 | 920 | { |
@@ -877,18 +930,33 @@ discard block |
||
877 | 930 | else |
878 | 931 | { |
879 | 932 | // if no owner/addressbook set use the setting of the add_default prefs (if set, otherwise the users personal addressbook) |
880 | - if (!isset($contact['owner'])) $contact['owner'] = $this->default_addressbook; |
|
881 | - if (!isset($contact['private'])) $contact['private'] = (int)$this->default_private; |
|
933 | + if (!isset($contact['owner'])) |
|
934 | + { |
|
935 | + $contact['owner'] = $this->default_addressbook; |
|
936 | + } |
|
937 | + if (!isset($contact['private'])) |
|
938 | + { |
|
939 | + $contact['private'] = (int)$this->default_private; |
|
940 | + } |
|
882 | 941 | // do NOT allow to create new accounts via addressbook, they are broken without an account_id |
883 | 942 | if (!$contact['owner'] && empty($contact['account_id'])) |
884 | 943 | { |
885 | 944 | $contact['owner'] = $this->default_addressbook ? $this->default_addressbook : $this->user; |
886 | 945 | } |
887 | 946 | // allow admins to import contacts with creator / created date set |
888 | - if (!$contact['creator'] || !$this->is_admin($contact)) $contact['creator'] = $this->user; |
|
889 | - if (!$contact['created'] || !$this->is_admin($contact)) $contact['created'] = $this->now_su; |
|
947 | + if (!$contact['creator'] || !$this->is_admin($contact)) |
|
948 | + { |
|
949 | + $contact['creator'] = $this->user; |
|
950 | + } |
|
951 | + if (!$contact['created'] || !$this->is_admin($contact)) |
|
952 | + { |
|
953 | + $contact['created'] = $this->now_su; |
|
954 | + } |
|
890 | 955 | |
891 | - if (!$contact['tid']) $contact['tid'] = 'n'; |
|
956 | + if (!$contact['tid']) |
|
957 | + { |
|
958 | + $contact['tid'] = 'n'; |
|
959 | + } |
|
892 | 960 | } |
893 | 961 | // ensure accounts and group addressbooks are never private! |
894 | 962 | if ($contact['owner'] <= 0) |
@@ -912,7 +980,8 @@ discard block |
||
912 | 980 | } |
913 | 981 | |
914 | 982 | // Update country codes |
915 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
983 | + foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
984 | + { |
|
916 | 985 | if($contact[$c_prefix.'countryname'] && !$contact[$c_prefix.'countrycode'] && |
917 | 986 | $code = $GLOBALS['egw']->country->country_code($contact[$c_prefix.'countryname'])) |
918 | 987 | { |
@@ -939,7 +1008,10 @@ discard block |
||
939 | 1008 | { |
940 | 1009 | $contact['n_fn'] = $this->fullname($contact); |
941 | 1010 | } |
942 | - if (isset($contact['org_name'])) $contact['n_fileas'] = $this->fileas($contact, null, false); |
|
1011 | + if (isset($contact['org_name'])) |
|
1012 | + { |
|
1013 | + $contact['n_fileas'] = $this->fileas($contact, null, false); |
|
1014 | + } |
|
943 | 1015 | |
944 | 1016 | // Get old record for tracking changes |
945 | 1017 | if (!isset($old) && $isUpdate) |
@@ -1016,7 +1088,10 @@ discard block |
||
1016 | 1088 | if(!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') |
1017 | 1089 | { |
1018 | 1090 | $deleted = ($old['tid'] == addressbook_so::DELETED_TYPE || $contact['tid'] == addressbook_so::DELETED_TYPE); |
1019 | - if (!isset($this->tracking)) $this->tracking = new addressbook_tracking($this); |
|
1091 | + if (!isset($this->tracking)) |
|
1092 | + { |
|
1093 | + $this->tracking = new addressbook_tracking($this); |
|
1094 | + } |
|
1020 | 1095 | $this->tracking->track($to_write, $old ? $old : null, null, $deleted); |
1021 | 1096 | } |
1022 | 1097 | } |
@@ -1098,10 +1173,12 @@ discard block |
||
1098 | 1173 | $data['fileas_type'] = $this->fileas_type($data); |
1099 | 1174 | |
1100 | 1175 | // Update country name from code |
1101 | - if($data['adr_one_countrycode'] != null) { |
|
1176 | + if($data['adr_one_countrycode'] != null) |
|
1177 | + { |
|
1102 | 1178 | $data['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_one_countrycode'], true); |
1103 | 1179 | } |
1104 | - if($data['adr_two_countrycode'] != null) { |
|
1180 | + if($data['adr_two_countrycode'] != null) |
|
1181 | + { |
|
1105 | 1182 | $data['adr_two_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_two_countrycode'], true); |
1106 | 1183 | } |
1107 | 1184 | } |
@@ -1127,7 +1204,10 @@ discard block |
||
1127 | 1204 | */ |
1128 | 1205 | function check_perms($needed,$contact,$deny_account_delete=false,$user=null) |
1129 | 1206 | { |
1130 | - if (!$user) $user = $this->user; |
|
1207 | + if (!$user) |
|
1208 | + { |
|
1209 | + $user = $this->user; |
|
1210 | + } |
|
1131 | 1211 | if ($user == $this->user) |
1132 | 1212 | { |
1133 | 1213 | $grants = $this->grants; |
@@ -1194,8 +1274,14 @@ discard block |
||
1194 | 1274 | */ |
1195 | 1275 | function read_org($org_id) |
1196 | 1276 | { |
1197 | - if (!$org_id) return false; |
|
1198 | - if (strpos($org_id,'*AND*')!== false) $org_id = str_replace('*AND*','&',$org_id); |
|
1277 | + if (!$org_id) |
|
1278 | + { |
|
1279 | + return false; |
|
1280 | + } |
|
1281 | + if (strpos($org_id,'*AND*')!== false) |
|
1282 | + { |
|
1283 | + $org_id = str_replace('*AND*','&',$org_id); |
|
1284 | + } |
|
1199 | 1285 | $org = array(); |
1200 | 1286 | foreach(explode('|||',$org_id) as $part) |
1201 | 1287 | { |
@@ -1225,7 +1311,10 @@ discard block |
||
1225 | 1311 | } |
1226 | 1312 | // read the regular fields |
1227 | 1313 | $contacts = parent::search('',$regular_fields,'','','',false,'AND',false,$org); |
1228 | - if (!$contacts) return false; |
|
1314 | + if (!$contacts) |
|
1315 | + { |
|
1316 | + return false; |
|
1317 | + } |
|
1229 | 1318 | |
1230 | 1319 | // if we have custom fields, read and merge them in |
1231 | 1320 | if ($custom_fields) |
@@ -1273,7 +1362,10 @@ discard block |
||
1273 | 1362 | } |
1274 | 1363 | foreach($fields as $name => $values) |
1275 | 1364 | { |
1276 | - if (!in_array($name,$this->org_fields)) continue; |
|
1365 | + if (!in_array($name,$this->org_fields)) |
|
1366 | + { |
|
1367 | + continue; |
|
1368 | + } |
|
1277 | 1369 | |
1278 | 1370 | arsort($values,SORT_NUMERIC); |
1279 | 1371 | list($value,$num) = each($values); |
@@ -1344,16 +1436,25 @@ discard block |
||
1344 | 1436 | 'adr_two_countryname' => 'adr_one_countrycode', |
1345 | 1437 | ) as $name => $code) |
1346 | 1438 | { |
1347 | - if (!empty($from[$code])) $from[$name] = ''; |
|
1348 | - if (!empty($to[$code])) $to[$name] = ''; |
|
1439 | + if (!empty($from[$code])) |
|
1440 | + { |
|
1441 | + $from[$name] = ''; |
|
1442 | + } |
|
1443 | + if (!empty($to[$code])) |
|
1444 | + { |
|
1445 | + $to[$name] = ''; |
|
1446 | + } |
|
1349 | 1447 | } |
1350 | 1448 | $changed = array(); |
1351 | 1449 | foreach($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) |
1352 | 1450 | { |
1353 | - if (in_array($name,array('modified','modifier'))) // never count these |
|
1451 | + if (in_array($name,array('modified','modifier'))) |
|
1452 | + { |
|
1453 | + // never count these |
|
1354 | 1454 | { |
1355 | 1455 | continue; |
1356 | 1456 | } |
1457 | + } |
|
1357 | 1458 | if ((string) $from[$name] != (string) $to[$name]) |
1358 | 1459 | { |
1359 | 1460 | $changed[$name] = $from[$name]; |
@@ -1373,13 +1474,19 @@ discard block |
||
1373 | 1474 | */ |
1374 | 1475 | function change_org($org_name,$from,$to,$members=null) |
1375 | 1476 | { |
1376 | - if (!($changed = $this->changed_fields($from,$to,true))) return false; |
|
1477 | + if (!($changed = $this->changed_fields($from,$to,true))) |
|
1478 | + { |
|
1479 | + return false; |
|
1480 | + } |
|
1377 | 1481 | |
1378 | 1482 | if (is_null($members) || !is_array($members)) |
1379 | 1483 | { |
1380 | 1484 | $members = $this->org_similar($org_name,$changed); |
1381 | 1485 | } |
1382 | - if (!$members) return false; |
|
1486 | + if (!$members) |
|
1487 | + { |
|
1488 | + return false; |
|
1489 | + } |
|
1383 | 1490 | |
1384 | 1491 | $ids = array(); |
1385 | 1492 | foreach($members as $member) |
@@ -1445,7 +1552,10 @@ discard block |
||
1445 | 1552 | $type = $this->prefs['link_title']; |
1446 | 1553 | if (!$type || $type === 'n_fileas') |
1447 | 1554 | { |
1448 | - if ($contact['n_fileas']) return $contact['n_fileas']; |
|
1555 | + if ($contact['n_fileas']) |
|
1556 | + { |
|
1557 | + return $contact['n_fileas']; |
|
1558 | + } |
|
1449 | 1559 | $type = null; |
1450 | 1560 | } |
1451 | 1561 | $title = $this->fileas($contact,$type); |
@@ -1513,7 +1623,10 @@ discard block |
||
1513 | 1623 | $limit = array($options['start'], $options['num_rows']); |
1514 | 1624 | } |
1515 | 1625 | $filter = (array)$options['filter']; |
1516 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; |
|
1626 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
1627 | + { |
|
1628 | + $filter['account_id'] = null; |
|
1629 | + } |
|
1517 | 1630 | if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) |
1518 | 1631 | { |
1519 | 1632 | $ids = array(); |
@@ -1576,12 +1689,18 @@ discard block |
||
1576 | 1689 | */ |
1577 | 1690 | function calendar_info($ids) |
1578 | 1691 | { |
1579 | - if (!$ids) return null; |
|
1692 | + if (!$ids) |
|
1693 | + { |
|
1694 | + return null; |
|
1695 | + } |
|
1580 | 1696 | |
1581 | 1697 | $data = array(); |
1582 | 1698 | foreach(!is_array($ids) ? array($ids) : $ids as $id) |
1583 | 1699 | { |
1584 | - if (!($contact = $this->read($id))) continue; |
|
1700 | + if (!($contact = $this->read($id))) |
|
1701 | + { |
|
1702 | + continue; |
|
1703 | + } |
|
1585 | 1704 | |
1586 | 1705 | $data[] = array( |
1587 | 1706 | 'res_id' => $id, |
@@ -1604,21 +1723,33 @@ discard block |
||
1604 | 1723 | */ |
1605 | 1724 | function read_calendar($ids,$extra_title=true) |
1606 | 1725 | { |
1607 | - if (!$GLOBALS['egw_info']['user']['apps']['calendar']) return array(); |
|
1726 | + if (!$GLOBALS['egw_info']['user']['apps']['calendar']) |
|
1727 | + { |
|
1728 | + return array(); |
|
1729 | + } |
|
1608 | 1730 | |
1609 | 1731 | $uids = array(); |
1610 | 1732 | foreach($ids as $id) |
1611 | 1733 | { |
1612 | - if (is_numeric($id)) $uids[] = 'c'.$id; |
|
1734 | + if (is_numeric($id)) |
|
1735 | + { |
|
1736 | + $uids[] = 'c'.$id; |
|
1737 | + } |
|
1738 | + } |
|
1739 | + if (!$uids) |
|
1740 | + { |
|
1741 | + return array(); |
|
1613 | 1742 | } |
1614 | - if (!$uids) return array(); |
|
1615 | 1743 | |
1616 | 1744 | $bocal = new calendar_bo(); |
1617 | 1745 | $events = $bocal->search(array( |
1618 | 1746 | 'users' => $uids, |
1619 | 1747 | 'enum_recuring' => true, |
1620 | 1748 | )); |
1621 | - if (!$events) return array(); |
|
1749 | + if (!$events) |
|
1750 | + { |
|
1751 | + return array(); |
|
1752 | + } |
|
1622 | 1753 | |
1623 | 1754 | //_debug_array($events); |
1624 | 1755 | $calendars = array(); |
@@ -1632,11 +1763,14 @@ discard block |
||
1632 | 1763 | } |
1633 | 1764 | $id = (int)substr($uid,1); |
1634 | 1765 | |
1635 | - if ($event['start'] < $this->now_su) // past event --> check for last event |
|
1766 | + if ($event['start'] < $this->now_su) |
|
1767 | + { |
|
1768 | + // past event --> check for last event |
|
1636 | 1769 | { |
1637 | 1770 | if (!isset($calendars[$id]['last_event']) || $event['start'] > $calendars[$id]['last_event']) |
1638 | 1771 | { |
1639 | 1772 | $calendars[$id]['last_event'] = $event['start']; |
1773 | + } |
|
1640 | 1774 | $link = array( |
1641 | 1775 | 'id' => $event['id'], |
1642 | 1776 | 'app' => 'calendar', |
@@ -1753,27 +1887,36 @@ discard block |
||
1753 | 1887 | $account = null; |
1754 | 1888 | $custom_fields = config::get_customfields('addressbook', true); |
1755 | 1889 | $custom_field_list = $this->read_customfields($ids); |
1756 | - foreach(parent::search(array('id'=>$ids),false) as $contact) // $this->search calls the extended search from ui! |
|
1890 | + foreach(parent::search(array('id'=>$ids),false) as $contact) |
|
1891 | + { |
|
1892 | + // $this->search calls the extended search from ui! |
|
1757 | 1893 | { |
1758 | 1894 | if ($contact['account_id']) |
1759 | 1895 | { |
1760 | 1896 | if (!is_null($account)) |
1761 | 1897 | { |
1762 | 1898 | echo $this->error = 'Can not merge more then one account!'; |
1899 | + } |
|
1763 | 1900 | return false; // we dont deal with two accounts! |
1764 | 1901 | } |
1765 | 1902 | $account = $contact; |
1766 | 1903 | continue; |
1767 | 1904 | } |
1768 | 1905 | // Add in custom fields |
1769 | - if (is_array($custom_field_list[$contact['id']])) $contact = array_merge($contact, $custom_field_list[$contact['id']]); |
|
1906 | + if (is_array($custom_field_list[$contact['id']])) |
|
1907 | + { |
|
1908 | + $contact = array_merge($contact, $custom_field_list[$contact['id']]); |
|
1909 | + } |
|
1770 | 1910 | |
1771 | 1911 | $pos = array_search($contact['id'],$ids); |
1772 | 1912 | $contacts[$pos] = $contact; |
1773 | 1913 | } |
1774 | - if (!is_null($account)) // we found an account, so we merge the contacts into it |
|
1914 | + if (!is_null($account)) |
|
1915 | + { |
|
1916 | + // we found an account, so we merge the contacts into it |
|
1775 | 1917 | { |
1776 | 1918 | $target = $account; |
1919 | + } |
|
1777 | 1920 | unset($account); |
1778 | 1921 | } |
1779 | 1922 | else // we found no account, so we merge all but the first into the first |
@@ -1790,7 +1933,10 @@ discard block |
||
1790 | 1933 | { |
1791 | 1934 | foreach($contact as $name => $value) |
1792 | 1935 | { |
1793 | - if (!$value) continue; |
|
1936 | + if (!$value) |
|
1937 | + { |
|
1938 | + continue; |
|
1939 | + } |
|
1794 | 1940 | |
1795 | 1941 | switch($name) |
1796 | 1942 | { |
@@ -1802,25 +1948,39 @@ discard block |
||
1802 | 1948 | break; // ignored |
1803 | 1949 | |
1804 | 1950 | case 'cat_id': // cats are all merged together |
1805 | - if (!is_array($target['cat_id'])) $target['cat_id'] = $target['cat_id'] ? explode(',',$target['cat_id']) : array(); |
|
1951 | + if (!is_array($target['cat_id'])) |
|
1952 | + { |
|
1953 | + $target['cat_id'] = $target['cat_id'] ? explode(',',$target['cat_id']) : array(); |
|
1954 | + } |
|
1806 | 1955 | $target['cat_id'] = array_unique(array_merge($target['cat_id'],is_array($value)?$value:explode(',',$value))); |
1807 | 1956 | break; |
1808 | 1957 | |
1809 | 1958 | default: |
1810 | 1959 | // Multi-select custom fields can also be merged |
1811 | - if($name[0] == '#') { |
|
1960 | + if($name[0] == '#') |
|
1961 | + { |
|
1812 | 1962 | $c_name = substr($name, 1); |
1813 | - if($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) { |
|
1814 | - if (!is_array($target[$name])) $target[$name] = $target[$name] ? explode(',',$target[$name]) : array(); |
|
1963 | + if($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) |
|
1964 | + { |
|
1965 | + if (!is_array($target[$name])) |
|
1966 | + { |
|
1967 | + $target[$name] = $target[$name] ? explode(',',$target[$name]) : array(); |
|
1968 | + } |
|
1815 | 1969 | $target[$name] = implode(',',array_unique(array_merge($target[$name],is_array($value)?$value:explode(',',$value)))); |
1816 | 1970 | } |
1817 | 1971 | } |
1818 | - if (!$target[$name]) $target[$name] = $value; |
|
1972 | + if (!$target[$name]) |
|
1973 | + { |
|
1974 | + $target[$name] = $value; |
|
1975 | + } |
|
1819 | 1976 | break; |
1820 | 1977 | } |
1821 | 1978 | } |
1822 | 1979 | } |
1823 | - if (!$this->save($target)) return 0; |
|
1980 | + if (!$this->save($target)) |
|
1981 | + { |
|
1982 | + return 0; |
|
1983 | + } |
|
1824 | 1984 | |
1825 | 1985 | $success = 1; |
1826 | 1986 | foreach($contacts as $contact) |
@@ -1850,7 +2010,10 @@ discard block |
||
1850 | 2010 | unset($newlinkID); |
1851 | 2011 | } |
1852 | 2012 | } |
1853 | - if ($this->delete($contact['id'])) $success++; |
|
2013 | + if ($this->delete($contact['id'])) |
|
2014 | + { |
|
2015 | + $success++; |
|
2016 | + } |
|
1854 | 2017 | } |
1855 | 2018 | return $success; |
1856 | 2019 | } |
@@ -1891,11 +2054,17 @@ discard block |
||
1891 | 2054 | */ |
1892 | 2055 | function add_list($keys,$owner,$contacts=array(),array &$data=array()) |
1893 | 2056 | { |
1894 | - if (!$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) return false; |
|
2057 | + if (!$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) |
|
2058 | + { |
|
2059 | + return false; |
|
2060 | + } |
|
1895 | 2061 | |
1896 | 2062 | try { |
1897 | 2063 | $ret = parent::add_list($keys,$owner,$contacts,$data); |
1898 | - if ($ret) unset(self::$list_cache[$ret]); |
|
2064 | + if ($ret) |
|
2065 | + { |
|
2066 | + unset(self::$list_cache[$ret]); |
|
2067 | + } |
|
1899 | 2068 | } |
1900 | 2069 | // catch sql error, as creating same name&owner list gives a sql error doublicate key |
1901 | 2070 | catch(egw_exception_db_invalid_sql $e) { |
@@ -1914,7 +2083,10 @@ discard block |
||
1914 | 2083 | */ |
1915 | 2084 | function add2list($contact,$list,array $existing=null) |
1916 | 2085 | { |
1917 | - if (!$this->check_list($list,EGW_ACL_EDIT)) return false; |
|
2086 | + if (!$this->check_list($list,EGW_ACL_EDIT)) |
|
2087 | + { |
|
2088 | + return false; |
|
2089 | + } |
|
1918 | 2090 | |
1919 | 2091 | unset(self::$list_cache[$list]); |
1920 | 2092 | |
@@ -1930,7 +2102,10 @@ discard block |
||
1930 | 2102 | */ |
1931 | 2103 | function remove_from_list($contact,$list=null) |
1932 | 2104 | { |
1933 | - if ($list && !$this->check_list($list,EGW_ACL_EDIT)) return false; |
|
2105 | + if ($list && !$this->check_list($list,EGW_ACL_EDIT)) |
|
2106 | + { |
|
2107 | + return false; |
|
2108 | + } |
|
1934 | 2109 | |
1935 | 2110 | if ($list) |
1936 | 2111 | { |
@@ -1952,7 +2127,10 @@ discard block |
||
1952 | 2127 | */ |
1953 | 2128 | function delete_list($list) |
1954 | 2129 | { |
1955 | - if (!$this->check_list($list,EGW_ACL_DELETE)) return false; |
|
2130 | + if (!$this->check_list($list,EGW_ACL_DELETE)) |
|
2131 | + { |
|
2132 | + return false; |
|
2133 | + } |
|
1956 | 2134 | |
1957 | 2135 | foreach((array)$list as $l) |
1958 | 2136 | { |
@@ -1970,7 +2148,10 @@ discard block |
||
1970 | 2148 | */ |
1971 | 2149 | function read_list($list) |
1972 | 2150 | { |
1973 | - if (isset(self::$list_cache[$list])) return self::$list_cache[$list]; |
|
2151 | + if (isset(self::$list_cache[$list])) |
|
2152 | + { |
|
2153 | + return self::$list_cache[$list]; |
|
2154 | + } |
|
1974 | 2155 | |
1975 | 2156 | return self::$list_cache[$list] = parent::read_list($list); |
1976 | 2157 | } |
@@ -2228,7 +2409,10 @@ discard block |
||
2228 | 2409 | |
2229 | 2410 | foreach ($columns_to_search as $field) |
2230 | 2411 | { |
2231 | - if ($relax && in_array($field, $tolerance_fields)) continue; |
|
2412 | + if ($relax && in_array($field, $tolerance_fields)) |
|
2413 | + { |
|
2414 | + continue; |
|
2415 | + } |
|
2232 | 2416 | |
2233 | 2417 | if (empty($contact[$field])) |
2234 | 2418 | { |
@@ -2293,7 +2477,10 @@ discard block |
||
2293 | 2477 | } |
2294 | 2478 | |
2295 | 2479 | // No need for more searches for relaxed matching |
2296 | - if ($relax || count($matchingContacts)) return $matchingContacts; |
|
2480 | + if ($relax || count($matchingContacts)) |
|
2481 | + { |
|
2482 | + return $matchingContacts; |
|
2483 | + } |
|
2297 | 2484 | |
2298 | 2485 | |
2299 | 2486 | if (!$empty_addr_one && $empty_addr_two) |
@@ -2346,7 +2533,8 @@ discard block |
||
2346 | 2533 | } |
2347 | 2534 | } |
2348 | 2535 | elseif (!$empty_addr_one && !$empty_addr_two) |
2349 | - { // try again after address swap |
|
2536 | + { |
|
2537 | +// try again after address swap |
|
2350 | 2538 | |
2351 | 2539 | foreach ($addr_one_fields as $key => $field) |
2352 | 2540 | { |
@@ -2393,7 +2581,10 @@ discard block |
||
2393 | 2581 | { |
2394 | 2582 | $filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D') |
2395 | 2583 | // show addressbook of a single user? |
2396 | - if (!is_null($owner)) $filter['owner'] = $owner; |
|
2584 | + if (!is_null($owner)) |
|
2585 | + { |
|
2586 | + $filter['owner'] = $owner; |
|
2587 | + } |
|
2397 | 2588 | |
2398 | 2589 | // should we hide the accounts addressbook |
2399 | 2590 | if (!$owner && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
@@ -1500,7 +1500,7 @@ discard block |
||
1500 | 1500 | * @param array $options Array of options for the search |
1501 | 1501 | * @return array with id - title pairs of the matching entries |
1502 | 1502 | */ |
1503 | - function link_query($pattern, Array &$options = array()) |
|
1503 | + function link_query($pattern, array &$options = array()) |
|
1504 | 1504 | { |
1505 | 1505 | $result = $criteria = array(); |
1506 | 1506 | $limit = false; |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | * @param array $options |
1554 | 1554 | * @return Ambigous <multitype:, string, multitype:Ambigous <multitype:, string> string > |
1555 | 1555 | */ |
1556 | - function link_query_email($pattern, Array &$options = array()) |
|
1556 | + function link_query_email($pattern, array &$options = array()) |
|
1557 | 1557 | { |
1558 | 1558 | if (isset($options['filter']) && !is_array($options['filter'])) |
1559 | 1559 | { |
@@ -104,8 +104,7 @@ discard block |
||
104 | 104 | * @param array &$options |
105 | 105 | * @param array &$files |
106 | 106 | * @param int $user account_id |
107 | - * @param string $id='' |
|
108 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
107 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
109 | 108 | */ |
110 | 109 | function propfind($path,&$options,&$files,$user,$id='') |
111 | 110 | { |
@@ -186,7 +185,6 @@ discard block |
||
186 | 185 | * |
187 | 186 | * @param string $path |
188 | 187 | * @param array& $filter |
189 | - * @param array|boolean $start=false false=return all or array(start,num) |
|
190 | 188 | * @return array with "files" array with values for keys path and props |
191 | 189 | */ |
192 | 190 | function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) |
@@ -535,8 +533,7 @@ discard block |
||
535 | 533 | * |
536 | 534 | * @param array &$options |
537 | 535 | * @param int $id |
538 | - * @param int $user=null account_id |
|
539 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
536 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
540 | 537 | */ |
541 | 538 | function get(&$options,$id,$user=null) |
542 | 539 | { |
@@ -559,9 +556,8 @@ discard block |
||
559 | 556 | * |
560 | 557 | * @param array &$options |
561 | 558 | * @param int $id |
562 | - * @param int $user=null account_id of owner, default null |
|
563 | - * @param string $prefix=null user prefix from path (eg. /ralf from /ralf/addressbook) |
|
564 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
559 | + * @param string $prefix user prefix from path (eg. /ralf from /ralf/addressbook) |
|
560 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
565 | 561 | */ |
566 | 562 | function put(&$options,$id,$user=null,$prefix=null) |
567 | 563 | { |
@@ -828,10 +824,8 @@ discard block |
||
828 | 824 | * </D:supported-report-set> |
829 | 825 | * @link http://www.mail-archive.com/[email protected]/msg01156.html |
830 | 826 | * |
831 | - * @param array $props=array() regular props by the groupdav handler |
|
832 | 827 | * @param string $displayname |
833 | - * @param string $base_uri=null base url of handler |
|
834 | - * @param int $user=null account_id of owner of collection |
|
828 | + * @param string $base_uri base url of handler |
|
835 | 829 | * @return array |
836 | 830 | */ |
837 | 831 | public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null) |
@@ -944,7 +938,6 @@ discard block |
||
944 | 938 | * the same UID and/or carddav_name as not deleted contacts and would block access to valid entries |
945 | 939 | * |
946 | 940 | * @param string|int $id |
947 | - * @param string $path=null |
|
948 | 941 | * @return array|boolean array with entry, false if no read rights, null if $id does not exist |
949 | 942 | */ |
950 | 943 | function read($id, $path=null) |
@@ -1013,7 +1006,7 @@ discard block |
||
1013 | 1006 | * |
1014 | 1007 | * @param int $acl EGW_ACL_READ, EGW_ACL_EDIT or EGW_ACL_DELETE |
1015 | 1008 | * @param array|int $contact contact-array or id |
1016 | - * @return boolean null if entry does not exist, false if no access, true if access permitted |
|
1009 | + * @return null|boolean null if entry does not exist, false if no access, true if access permitted |
|
1017 | 1010 | */ |
1018 | 1011 | function check_access($acl,$contact) |
1019 | 1012 | { |
@@ -1042,7 +1035,7 @@ discard block |
||
1042 | 1035 | /** |
1043 | 1036 | * Return calendars/addressbooks shared from other users with the current one |
1044 | 1037 | * |
1045 | - * @param boolean $ignore_all_in_one=false if true, return selected addressbooks and not array() for all-in-one |
|
1038 | + * @param boolean $ignore_all_in_one if true, return selected addressbooks and not array() for all-in-one |
|
1046 | 1039 | * @return array account_id => account_lid pairs |
1047 | 1040 | */ |
1048 | 1041 | function get_shared($ignore_all_in_one=false) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | // LDAP does NOT have a carddav_name attribute --> stick with id mapped to LDAP attribute uid |
76 | 76 | if (version_compare($GLOBALS['egw_info']['apps']['phpgwapi']['version'], '1.9.007', '<') || |
77 | 77 | $this->bo->contact_repository != 'sql' || |
78 | - $this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/','/addressbook-accounts/') !== false) |
|
78 | + $this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/', '/addressbook-accounts/') !== false) |
|
79 | 79 | { |
80 | 80 | groupdav_handler::$path_extension = '.vcf'; |
81 | 81 | } |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
88 | 88 | |
89 | 89 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
90 | - $this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); |
|
90 | + $this->home_set_pref = $this->home_set_pref ? explode(',', $this->home_set_pref) : array(); |
|
91 | 91 | |
92 | 92 | // silently switch "Sync all into one" preference on for OS X addressbook, as it only supports one AB |
93 | 93 | // this restores behavior before Lion (10.7), where AB synced all ABs contained in addressbook-home-set |
94 | - if (substr(self::get_agent(),0,9) == 'cfnetwork' && !in_array('O',$this->home_set_pref)) |
|
94 | + if (substr(self::get_agent(), 0, 9) == 'cfnetwork' && !in_array('O', $this->home_set_pref)) |
|
95 | 95 | { |
96 | 96 | $this->home_set_pref[] = 'O'; |
97 | 97 | } |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @param string $id='' |
108 | 108 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
109 | 109 | */ |
110 | - function propfind($path,&$options,&$files,$user,$id='') |
|
110 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
111 | 111 | { |
112 | 112 | $filter = array(); |
113 | 113 | // If "Sync selected addressbooks into one" is set |
114 | - if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
|
114 | + if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref)) |
|
115 | 115 | { |
116 | - $filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref |
|
116 | + $filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref |
|
117 | 117 | $filter['owner'][] = $user; |
118 | 118 | } |
119 | 119 | // show addressbook of a single user? |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; |
126 | 126 | |
127 | 127 | // process REPORT filters or multiget href's |
128 | - if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options,$filter,$id, $nresults)) |
|
128 | + if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options, $filter, $id, $nresults)) |
|
129 | 129 | { |
130 | 130 | return false; |
131 | 131 | } |
132 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
132 | + if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
133 | 133 | |
134 | 134 | if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if (!($filter['address_data'] = $options['props'] == 'all' && |
138 | 138 | $options['root']['ns'] == groupdav::CARDDAV) && is_array($options['props'])) |
139 | 139 | { |
140 | - foreach($options['props'] as $prop) |
|
140 | + foreach ($options['props'] as $prop) |
|
141 | 141 | { |
142 | 142 | if ($prop['name'] == 'address-data') |
143 | 143 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $this->sync_collection_token = null; |
158 | 158 | |
159 | - $filter['order'] = 'contact_modified ASC'; // return oldest modifications first |
|
159 | + $filter['order'] = 'contact_modified ASC'; // return oldest modifications first |
|
160 | 160 | $filter['sync-collection'] = true; |
161 | 161 | } |
162 | 162 | |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
171 | 171 | { |
172 | 172 | --$this->sync_collection_token; |
173 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
173 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | else |
177 | 177 | { |
178 | 178 | // return iterator, calling ourself to return result in chunks |
179 | - $files['files'] = new groupdav_propfind_iterator($this,$path,$filter,$files['files']); |
|
179 | + $files['files'] = new groupdav_propfind_iterator($this, $path, $filter, $files['files']); |
|
180 | 180 | } |
181 | 181 | return true; |
182 | 182 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param array|boolean $start=false false=return all or array(start,num) |
190 | 190 | * @return array with "files" array with values for keys path and props |
191 | 191 | */ |
192 | - function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) |
|
192 | + function &propfind_callback($path, array &$filter, $start = false, $report_not_found_multiget_ids = true) |
|
193 | 193 | { |
194 | 194 | //error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start).", $report_not_found_multiget_ids)"); |
195 | 195 | $starttime = microtime(true); |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | if (isset($filter[self::$path_attr])) |
218 | 218 | { |
219 | 219 | if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
220 | - $requested_multiget_ids =& $filter[self::$path_attr]; |
|
220 | + $requested_multiget_ids = & $filter[self::$path_attr]; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $files = array(); |
224 | 224 | // we query etag and modified, as LDAP does not have the strong sql etag |
225 | - $cols = array('id','uid','etag','modified','n_fn'); |
|
226 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; |
|
225 | + $cols = array('id', 'uid', 'etag', 'modified', 'n_fn'); |
|
226 | + if (!in_array(self::$path_attr, $cols)) $cols[] = self::$path_attr; |
|
227 | 227 | // we need tid for sync-collection report |
228 | 228 | if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; |
229 | - if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) |
|
229 | + if (($contacts = & $this->bo->search(array(), $cols, $order, '', '', False, 'AND', $start, $filter))) |
|
230 | 230 | { |
231 | - foreach($contacts as &$contact) |
|
231 | + foreach ($contacts as &$contact) |
|
232 | 232 | { |
233 | 233 | // remove contact from requested multiget ids, to be able to report not found urls |
234 | 234 | if ($requested_multiget_ids && ($k = array_search($contact[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | ); |
249 | 249 | if ($address_data) |
250 | 250 | { |
251 | - $content = $handler->getVCard($contact['id'],$this->charset,false); |
|
251 | + $content = $handler->getVCard($contact['id'], $this->charset, false); |
|
252 | 252 | $props['getcontentlength'] = bytes($content); |
253 | - $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'address-data',$content,true); |
|
253 | + $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'address-data', $content, true); |
|
254 | 254 | } |
255 | 255 | $files[] = $this->add_resource($path, $contact, $props); |
256 | 256 | } |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | } |
282 | 282 | } |
283 | 283 | // add groups after contacts, but only if enabled and NOT for '/addressbook/' (!isset($filter['owner']) |
284 | - if (in_array('D',$this->home_set_pref) && (string)$filter['owner'] !== '0') |
|
284 | + if (in_array('D', $this->home_set_pref) && (string)$filter['owner'] !== '0') |
|
285 | 285 | { |
286 | 286 | $where = array( |
287 | - 'list_owner' => isset($filter['owner'])?$filter['owner']:array_keys($this->bo->grants) |
|
287 | + 'list_owner' => isset($filter['owner']) ? $filter['owner'] : array_keys($this->bo->grants) |
|
288 | 288 | ); |
289 | 289 | // add sync-token to support sync-collection report |
290 | 290 | if ($sync_collection_report) |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; |
298 | 298 | } |
299 | 299 | //error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); |
300 | - if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
300 | + if (($lists = $this->bo->read_lists($where, 'contact_uid', $where['list_owner']))) // limit to contacts in same AB! |
|
301 | 301 | { |
302 | - foreach($lists as $list) |
|
302 | + foreach ($lists as $list) |
|
303 | 303 | { |
304 | 304 | $list[self::$path_attr] = $list['list_carddav_name']; |
305 | 305 | $etag = $list['list_id'].':'.$list['list_etag']; |
306 | 306 | // for all-in-one addressbook, add selected ABs to etag |
307 | 307 | if (isset($filter['owner']) && is_array($filter['owner'])) |
308 | 308 | { |
309 | - $etag .= ':'.implode('-',$filter['owner']); |
|
309 | + $etag .= ':'.implode('-', $filter['owner']); |
|
310 | 310 | } |
311 | 311 | $props = array( |
312 | 312 | 'getcontenttype' => HTTP_WebDAV_Server::mkprop('getcontenttype', 'text/vcard'), |
313 | - 'getlastmodified' => egw_time::to($list['list_modified'],'ts'), |
|
313 | + 'getlastmodified' => egw_time::to($list['list_modified'], 'ts'), |
|
314 | 314 | 'displayname' => $list['list_name'], |
315 | 315 | 'getetag' => '"'.$etag.'"', |
316 | 316 | ); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | { |
319 | 319 | $content = $handler->getGroupVCard($list); |
320 | 320 | $props['getcontentlength'] = bytes($content); |
321 | - $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'address-data',$content,true); |
|
321 | + $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'address-data', $content, true); |
|
322 | 322 | } |
323 | 323 | $files[] = $this->add_resource($path, $list, $props); |
324 | 324 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | unset($requested_multiget_ids[$k]); |
329 | 329 | } |
330 | 330 | |
331 | - if ($sync_collection_report && $this->sync_collection_token < ($ts=$GLOBALS['egw']->db->from_timestamp($list['list_modified']))) |
|
331 | + if ($sync_collection_report && $this->sync_collection_token < ($ts = $GLOBALS['egw']->db->from_timestamp($list['list_modified']))) |
|
332 | 332 | { |
333 | 333 | $this->sync_collection_token = $ts; |
334 | 334 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | // report not found multiget urls |
339 | 339 | if ($report_not_found_multiget_ids && $requested_multiget_ids) |
340 | 340 | { |
341 | - foreach($requested_multiget_ids as $id) |
|
341 | + foreach ($requested_multiget_ids as $id) |
|
342 | 342 | { |
343 | 343 | $files[] = array('path' => $path.$id.self::$path_extension); |
344 | 344 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param int &$nresult on return limit for number or results or unchanged/null |
359 | 359 | * @return boolean true if filter could be processed |
360 | 360 | */ |
361 | - function _report_filters($options,&$filters,$id, &$nresults) |
|
361 | + function _report_filters($options, &$filters, $id, &$nresults) |
|
362 | 362 | { |
363 | 363 | if ($options['filters']) |
364 | 364 | { |
@@ -382,17 +382,17 @@ discard block |
||
382 | 382 | $options['filters']['attrs']['test'] : 'anyof'; |
383 | 383 | $prop_filters = array(); |
384 | 384 | |
385 | - foreach($options['filters'] as $n => $filter) |
|
385 | + foreach ($options['filters'] as $n => $filter) |
|
386 | 386 | { |
387 | - if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
387 | + if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
388 | 388 | |
389 | - switch((string)$filter['name']) |
|
389 | + switch ((string)$filter['name']) |
|
390 | 390 | { |
391 | 391 | case 'param-filter': |
392 | 392 | $this->groupdav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
393 | 393 | break; |
394 | 394 | case 'prop-filter': // can be multiple prop-filter, see example |
395 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
395 | + if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches); |
|
396 | 396 | $matches = array(); |
397 | 397 | $prop_filter = strtoupper($filter['attrs']['name']); |
398 | 398 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware |
406 | 406 | { |
407 | 407 | if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); |
408 | - $column = false; // to ignore following data too |
|
408 | + $column = false; // to ignore following data too |
|
409 | 409 | } |
410 | 410 | else |
411 | 411 | { |
412 | - switch($filter['attrs']['collation']) // todo: which other collations allowed, we are allways unicode |
|
412 | + switch ($filter['attrs']['collation']) // todo: which other collations allowed, we are allways unicode |
|
413 | 413 | { |
414 | 414 | case 'i;unicode-casemap': |
415 | 415 | default: |
@@ -429,20 +429,20 @@ discard block |
||
429 | 429 | if ($column) // false for properties not known to EGroupware |
430 | 430 | { |
431 | 431 | $value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); |
432 | - switch($match_type) |
|
432 | + switch ($match_type) |
|
433 | 433 | { |
434 | 434 | case 'equals': |
435 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value); |
|
435 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value); |
|
436 | 436 | break; |
437 | 437 | default: |
438 | 438 | case 'contains': |
439 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value.'%'); |
|
439 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value.'%'); |
|
440 | 440 | break; |
441 | 441 | case 'starts-with': |
442 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value.'%'); |
|
442 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value.'%'); |
|
443 | 443 | break; |
444 | 444 | case 'ends-with': |
445 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value); |
|
445 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value); |
|
446 | 446 | break; |
447 | 447 | } |
448 | 448 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | break; |
459 | 459 | } |
460 | 460 | } |
461 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
461 | + if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches); |
|
462 | 462 | if ($prop_filters) |
463 | 463 | { |
464 | - $filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; |
|
464 | + $filters[] = $filter = '(('.implode($filter_test == 'allof' ? ') AND (' : ') OR (', $prop_filters).'))'; |
|
465 | 465 | if ($this->debug) error_log(__METHOD__."($path,...) sql-filter: $filter"); |
466 | 466 | } |
467 | 467 | } |
@@ -471,9 +471,9 @@ discard block |
||
471 | 471 | <B:nresults>10</B:nresults> |
472 | 472 | </B:limit> |
473 | 473 | */ |
474 | - foreach((array)$options['other'] as $option) |
|
474 | + foreach ((array)$options['other'] as $option) |
|
475 | 475 | { |
476 | - switch($option['name']) |
|
476 | + switch ($option['name']) |
|
477 | 477 | { |
478 | 478 | case 'nresults': |
479 | 479 | $nresults = (int)$option['data']; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | case 'limit': |
483 | 483 | break; |
484 | 484 | case 'href': |
485 | - break; // from addressbook-multiget, handled below |
|
485 | + break; // from addressbook-multiget, handled below |
|
486 | 486 | // rfc 6578 sync-report |
487 | 487 | case 'sync-token': |
488 | 488 | if (!empty($option['data'])) |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | $parts = explode('/', $option['data']); |
491 | 491 | $sync_token = array_pop($parts); |
492 | 492 | $filters[] = 'contact_modified>'.(int)$sync_token; |
493 | - $filters['tid'] = null; // to return deleted entries too |
|
493 | + $filters['tid'] = null; // to return deleted entries too |
|
494 | 494 | } |
495 | 495 | break; |
496 | 496 | case 'sync-level': |
@@ -508,23 +508,23 @@ discard block |
||
508 | 508 | if ($options['root']['name'] == 'addressbook-multiget') |
509 | 509 | { |
510 | 510 | $ids = array(); |
511 | - foreach($options['other'] as $option) |
|
511 | + foreach ($options['other'] as $option) |
|
512 | 512 | { |
513 | 513 | if ($option['name'] == 'href') |
514 | 514 | { |
515 | - $parts = explode('/',$option['data']); |
|
515 | + $parts = explode('/', $option['data']); |
|
516 | 516 | if (($id = urldecode(array_pop($parts)))) |
517 | 517 | { |
518 | - $ids[] = groupdav_handler::$path_extension ? basename($id,groupdav_handler::$path_extension) : $id; |
|
518 | + $ids[] = groupdav_handler::$path_extension ? basename($id, groupdav_handler::$path_extension) : $id; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
522 | 522 | if ($ids) $filters[self::$path_attr] = $ids; |
523 | - if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
523 | + if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',', $ids)); |
|
524 | 524 | } |
525 | 525 | elseif ($id) |
526 | 526 | { |
527 | - $filters[self::$path_attr] = groupdav_handler::$path_extension ? basename($id,groupdav_handler::$path_extension) : $id; |
|
527 | + $filters[self::$path_attr] = groupdav_handler::$path_extension ? basename($id, groupdav_handler::$path_extension) : $id; |
|
528 | 528 | } |
529 | 529 | //error_log(__METHOD__."() options[other]=".array2string($options['other'])." --> filters=".array2string($filters)); |
530 | 530 | return true; |
@@ -538,15 +538,14 @@ discard block |
||
538 | 538 | * @param int $user=null account_id |
539 | 539 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
540 | 540 | */ |
541 | - function get(&$options,$id,$user=null) |
|
541 | + function get(&$options, $id, $user = null) |
|
542 | 542 | { |
543 | - if (!is_array($contact = $this->_common_get_put_delete('GET',$options,$id))) |
|
543 | + if (!is_array($contact = $this->_common_get_put_delete('GET', $options, $id))) |
|
544 | 544 | { |
545 | 545 | return $contact; |
546 | 546 | } |
547 | 547 | $handler = self::_get_handler(); |
548 | - $options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : |
|
549 | - $handler->getVCard($contact['id'],$this->charset,false); |
|
548 | + $options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : $handler->getVCard($contact['id'], $this->charset, false); |
|
550 | 549 | // e.g. Evolution does not understand 'text/vcard' |
551 | 550 | $options['mimetype'] = 'text/x-vcard; charset='.$this->charset; |
552 | 551 | header('Content-Encoding: identity'); |
@@ -563,11 +562,11 @@ discard block |
||
563 | 562 | * @param string $prefix=null user prefix from path (eg. /ralf from /ralf/addressbook) |
564 | 563 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
565 | 564 | */ |
566 | - function put(&$options,$id,$user=null,$prefix=null) |
|
565 | + function put(&$options, $id, $user = null, $prefix = null) |
|
567 | 566 | { |
568 | 567 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
569 | 568 | |
570 | - $oldContact = $this->_common_get_put_delete('PUT',$options,$id); |
|
569 | + $oldContact = $this->_common_get_put_delete('PUT', $options, $id); |
|
571 | 570 | if (!is_null($oldContact) && !is_array($oldContact)) |
572 | 571 | { |
573 | 572 | if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
@@ -592,7 +591,7 @@ discard block |
||
592 | 591 | switch (strtolower($key)) |
593 | 592 | { |
594 | 593 | case 'charset': |
595 | - $charset = strtoupper(substr($value,1,-1)); |
|
594 | + $charset = strtoupper(substr($value, 1, -1)); |
|
596 | 595 | } |
597 | 596 | } |
598 | 597 | } |
@@ -619,7 +618,7 @@ discard block |
||
619 | 618 | |
620 | 619 | if (!$is_group && is_array($contact['cat_id'])) |
621 | 620 | { |
622 | - $contact['cat_id'] = implode(',',$this->bo->find_or_add_categories($contact['cat_id'], $contactId)); |
|
621 | + $contact['cat_id'] = implode(',', $this->bo->find_or_add_categories($contact['cat_id'], $contactId)); |
|
623 | 622 | } |
624 | 623 | elseif ($contactId > 0) |
625 | 624 | { |
@@ -643,12 +642,12 @@ discard block |
||
643 | 642 | $contact['carddav_name'] = $id; |
644 | 643 | |
645 | 644 | // only set owner, if user is explicitly specified in URL (check via prefix, NOT for /addressbook/) or sync-all-in-one!) |
646 | - if ($prefix && !in_array('O',$this->home_set_pref) && $user) |
|
645 | + if ($prefix && !in_array('O', $this->home_set_pref) && $user) |
|
647 | 646 | { |
648 | 647 | $contact['owner'] = $user; |
649 | 648 | } |
650 | 649 | // check if default addressbook is synced and not accounts, if not use (always synced) personal addressbook |
651 | - elseif(!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook,$this->home_set_pref)) |
|
650 | + elseif (!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook, $this->home_set_pref)) |
|
652 | 651 | { |
653 | 652 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
654 | 653 | } |
@@ -659,7 +658,7 @@ discard block |
||
659 | 658 | } |
660 | 659 | // check if user has add rights for addressbook |
661 | 660 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... |
662 | - if (!($this->bo->grants[$contact['owner']] & EGW_ACL_ADD)) |
|
661 | + if (!($this->bo->grants[$contact['owner']]&EGW_ACL_ADD)) |
|
663 | 662 | { |
664 | 663 | if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
665 | 664 | return '403 Forbidden'; |
@@ -676,7 +675,7 @@ discard block |
||
676 | 675 | $this->check_return_representation($options, $id, $user); |
677 | 676 | return '412 Precondition Failed'; |
678 | 677 | } |
679 | - return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights |
|
678 | + return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights |
|
680 | 679 | } |
681 | 680 | |
682 | 681 | if (empty($contact['etag']) || empty($contact['cardav_name'])) |
@@ -709,16 +708,16 @@ discard block |
||
709 | 708 | * @param array|false $oldContact |
710 | 709 | * @return int|boolean $list_id or false on error |
711 | 710 | */ |
712 | - function save_group(array &$contact, $oldContact=null) |
|
711 | + function save_group(array &$contact, $oldContact = null) |
|
713 | 712 | { |
714 | 713 | $data = array('list_name' => $contact['n_fn']); |
715 | 714 | if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
716 | - foreach(array('id','carddav_name','uid','owner') as $name) |
|
715 | + foreach (array('id', 'carddav_name', 'uid', 'owner') as $name) |
|
717 | 716 | { |
718 | 717 | $data['list_'.$name] = $contact[$name]; |
719 | 718 | } |
720 | 719 | //error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') data='.array2string($data)); |
721 | - if (($list_id=$this->bo->add_list(array('list_'.self::$path_attr => $contact[self::$path_attr]), |
|
720 | + if (($list_id = $this->bo->add_list(array('list_'.self::$path_attr => $contact[self::$path_attr]), |
|
722 | 721 | $contact['owner'], null, $data))) |
723 | 722 | { |
724 | 723 | // update members given in $contact['##X-ADDRESSBOOKSERVER-MEMBER'] |
@@ -731,12 +730,12 @@ discard block |
||
731 | 730 | { |
732 | 731 | $new_members = array($new_members); |
733 | 732 | } |
734 | - foreach($new_members as &$uid) $uid = substr($uid,9); // cut off "urn:uuid:" prefix |
|
733 | + foreach ($new_members as &$uid) $uid = substr($uid, 9); // cut off "urn:uuid:" prefix |
|
735 | 734 | |
736 | 735 | if ($oldContact) |
737 | 736 | { |
738 | - $to_add = array_diff($new_members,$oldContact['members']); |
|
739 | - $to_delete = array_diff($oldContact['members'],$new_members); |
|
737 | + $to_add = array_diff($new_members, $oldContact['members']); |
|
738 | + $to_delete = array_diff($oldContact['members'], $new_members); |
|
740 | 739 | } |
741 | 740 | else |
742 | 741 | { |
@@ -747,9 +746,9 @@ discard block |
||
747 | 746 | { |
748 | 747 | $to_add_ids = $to_delete_ids = array(); |
749 | 748 | $filter = array('uid' => $to_delete ? array_merge($to_add, $to_delete) : $to_add); |
750 | - if (($contacts =& $this->bo->search(array(), array('id', 'uid'),'','','',False,'AND',false,$filter))) |
|
749 | + if (($contacts = & $this->bo->search(array(), array('id', 'uid'), '', '', '', False, 'AND', false, $filter))) |
|
751 | 750 | { |
752 | - foreach($contacts as $c) |
|
751 | + foreach ($contacts as $c) |
|
753 | 752 | { |
754 | 753 | if ($to_delete && in_array($c['uid'], $to_delete)) |
755 | 754 | { |
@@ -779,9 +778,9 @@ discard block |
||
779 | 778 | * @param int $user |
780 | 779 | * @return string |
781 | 780 | */ |
782 | - public function getctag($path,$user) |
|
781 | + public function getctag($path, $user) |
|
783 | 782 | { |
784 | - static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
|
783 | + static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
|
785 | 784 | if (isset($ctags[$path])) return $ctags[$path]; |
786 | 785 | |
787 | 786 | $user_in = $user; |
@@ -789,9 +788,9 @@ discard block |
||
789 | 788 | if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
790 | 789 | |
791 | 790 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
792 | - if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
|
791 | + if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref)) |
|
793 | 792 | { |
794 | - $user = array_merge((array)$user,array_keys($this->get_shared(true))); // true: ignore all-in-one pref |
|
793 | + $user = array_merge((array)$user, array_keys($this->get_shared(true))); // true: ignore all-in-one pref |
|
795 | 794 | |
796 | 795 | // include accounts ctag, if accounts stored different from contacts (eg.in LDAP or ADS) |
797 | 796 | if ($this->bo->so_accounts && in_array('0', $user)) |
@@ -802,7 +801,7 @@ discard block |
||
802 | 801 | $ctag = $this->bo->get_ctag($user); |
803 | 802 | |
804 | 803 | // include lists-ctag, if enabled |
805 | - if (in_array('D',$this->home_set_pref)) |
|
804 | + if (in_array('D', $this->home_set_pref)) |
|
806 | 805 | { |
807 | 806 | $lists_ctag = $this->bo->lists_ctag($user); |
808 | 807 | } |
@@ -834,32 +833,32 @@ discard block |
||
834 | 833 | * @param int $user=null account_id of owner of collection |
835 | 834 | * @return array |
836 | 835 | */ |
837 | - public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null) |
|
836 | + public function extra_properties(array $props = array(), $displayname, $base_uri = null, $user = null) |
|
838 | 837 | { |
839 | 838 | if (!isset($props['addressbook-description'])) |
840 | 839 | { |
841 | 840 | // default addressbook description: can be overwritten via PROPPATCH, in which case it's already set |
842 | - $props['addressbook-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-description',$props['displayname']); |
|
841 | + $props['addressbook-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'addressbook-description', $props['displayname']); |
|
843 | 842 | } |
844 | 843 | // setting an max image size, so iOS scales the images before transmitting them |
845 | 844 | // we currently scale down to width of 240px, which tests shown to be ~20k |
846 | - $props['max-image-size'] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'max-image-size',24*1024); |
|
845 | + $props['max-image-size'] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'max-image-size', 24 * 1024); |
|
847 | 846 | |
848 | 847 | // supported reports (required property for CardDAV) |
849 | 848 | $props['supported-report-set'] = array( |
850 | - 'addressbook-query' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
851 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
852 | - HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-query',''))))), |
|
853 | - 'addressbook-multiget' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
854 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
855 | - HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-multiget',''))))), |
|
849 | + 'addressbook-query' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
850 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
851 | + HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'addressbook-query', ''))))), |
|
852 | + 'addressbook-multiget' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
853 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
854 | + HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'addressbook-multiget', ''))))), |
|
856 | 855 | ); |
857 | 856 | // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
858 | 857 | if ($GLOBALS['egw_info']['server']['history']) |
859 | 858 | { |
860 | - $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
861 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
862 | - HTTP_WebDAV_Server::mkprop('sync-collection',''))))); |
|
859 | + $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
860 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
861 | + HTTP_WebDAV_Server::mkprop('sync-collection', ''))))); |
|
863 | 862 | } |
864 | 863 | return $props; |
865 | 864 | } |
@@ -871,7 +870,7 @@ discard block |
||
871 | 870 | */ |
872 | 871 | private function _get_handler() |
873 | 872 | { |
874 | - $handler = new addressbook_vcal('addressbook','text/vcard'); |
|
873 | + $handler = new addressbook_vcal('addressbook', 'text/vcard'); |
|
875 | 874 | $supportedFields = $handler->supportedFields; |
876 | 875 | // Apple iOS or OS X addressbook |
877 | 876 | if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess') |
@@ -884,10 +883,10 @@ discard block |
||
884 | 883 | unset($supportedFields['TEL;CELL;WORK']); |
885 | 884 | $supportedFields['TEL;IPHONE'] = array('tel_cell_private'); |
886 | 885 | unset($supportedFields['TEL;CELL;HOME']); |
887 | - $databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names! |
|
886 | + $databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names! |
|
888 | 887 | |
889 | 888 | // Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone) |
890 | - if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520 || |
|
889 | + if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520 || |
|
891 | 890 | // iOS 5.1.1 does not display CLASS or CATEGORY, but wrongly escapes multiple, comma-separated categories |
892 | 891 | // and appends CLASS: PUBLIC to an empty NOTE: field --> leaving them out for iOS |
893 | 892 | $this->agent == 'dataaccess') |
@@ -897,7 +896,7 @@ discard block |
||
897 | 896 | unset($supportedFields['CATEGORIES']); |
898 | 897 | unset($databaseFields['CATEGORIES']); |
899 | 898 | } |
900 | - if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520) |
|
899 | + if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520) |
|
901 | 900 | { |
902 | 901 | // gd cant parse or resize images stored from snow leopard addressbook: gd-jpeg: |
903 | 902 | // - JPEG library reports unrecoverable error |
@@ -909,7 +908,7 @@ discard block |
||
909 | 908 | } |
910 | 909 | $handler->setDatabaseFields($databaseFields); |
911 | 910 | } |
912 | - $handler->setSupportedFields('GroupDAV',$this->agent,$supportedFields); |
|
911 | + $handler->setSupportedFields('GroupDAV', $this->agent, $supportedFields); |
|
913 | 912 | return $handler; |
914 | 913 | } |
915 | 914 | |
@@ -920,9 +919,9 @@ discard block |
||
920 | 919 | * @param int $id |
921 | 920 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
922 | 921 | */ |
923 | - function delete(&$options,$id) |
|
922 | + function delete(&$options, $id) |
|
924 | 923 | { |
925 | - if (!is_array($contact = $this->_common_get_put_delete('DELETE',$options,$id))) |
|
924 | + if (!is_array($contact = $this->_common_get_put_delete('DELETE', $options, $id))) |
|
926 | 925 | { |
927 | 926 | return $contact; |
928 | 927 | } |
@@ -930,7 +929,7 @@ discard block |
||
930 | 929 | { |
931 | 930 | $ok = $this->bo->delete_list($contact['list_id']) !== false; |
932 | 931 | } |
933 | - elseif (($ok = $this->bo->delete($contact['id'],self::etag2value($this->http_if_match))) === 0) |
|
932 | + elseif (($ok = $this->bo->delete($contact['id'], self::etag2value($this->http_if_match))) === 0) |
|
934 | 933 | { |
935 | 934 | return '412 Precondition Failed'; |
936 | 935 | } |
@@ -947,7 +946,7 @@ discard block |
||
947 | 946 | * @param string $path=null |
948 | 947 | * @return array|boolean array with entry, false if no read rights, null if $id does not exist |
949 | 948 | */ |
950 | - function read($id, $path=null) |
|
949 | + function read($id, $path = null) |
|
951 | 950 | { |
952 | 951 | static $non_deleted_tids; |
953 | 952 | if (is_null($non_deleted_tids)) |
@@ -959,7 +958,7 @@ discard block |
||
959 | 958 | $contact = $this->bo->read(array(self::$path_attr => $id, 'tid' => $non_deleted_tids)); |
960 | 959 | |
961 | 960 | // if contact not found and accounts stored NOT like contacts, try reading it without path-extension as id |
962 | - if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test=basename($id, '.vcf')))) |
|
961 | + if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test = basename($id, '.vcf')))) |
|
963 | 962 | { |
964 | 963 | $contact = $c; |
965 | 964 | } |
@@ -968,9 +967,9 @@ discard block |
||
968 | 967 | // bo->read_list(..., true) limits returned uid to same owner's addressbook, as iOS and OS X addressbooks |
969 | 968 | // only understands/shows that and if return more, save_lists would delete the others ones on update! |
970 | 969 | $limit_in_ab = true; |
971 | - list(,$account_lid,$app) = explode('/',$path); // eg. /<username>/addressbook/<id> |
|
970 | + list(,$account_lid, $app) = explode('/', $path); // eg. /<username>/addressbook/<id> |
|
972 | 971 | // /<username>/addressbook/ with home_set_prefs containing 'O'=all-in-one contains selected ab's |
973 | - if($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O',$this->home_set_pref)) |
|
972 | + if ($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O', $this->home_set_pref)) |
|
974 | 973 | { |
975 | 974 | $limit_in_ab = array_keys($this->get_shared(true)); |
976 | 975 | $limit_in_ab[] = $GLOBALS['egw_info']['user']['account_id']; |
@@ -981,28 +980,28 @@ discard block |
||
981 | 980 | { |
982 | 981 | $limit_in_ab = array_keys($this->bo->grants); |
983 | 982 | }*/ |
984 | - if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id),'contact_uid',$limit_in_ab))) |
|
983 | + if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id), 'contact_uid', $limit_in_ab))) |
|
985 | 984 | { |
986 | 985 | $contact = array_shift($contact); |
987 | 986 | $contact['n_fn'] = $contact['n_family'] = $contact['list_name']; |
988 | - foreach(array('owner','id','carddav_name','modified','modifier','created','creator','etag','uid') as $name) |
|
987 | + foreach (array('owner', 'id', 'carddav_name', 'modified', 'modifier', 'created', 'creator', 'etag', 'uid') as $name) |
|
989 | 988 | { |
990 | 989 | $contact[$name] = $contact['list_'.$name]; |
991 | 990 | } |
992 | 991 | // if NOT limited to containing AB ($limit_in_ab === true), add that limit to etag |
993 | 992 | if ($limit_in_ab !== true) |
994 | 993 | { |
995 | - $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
|
994 | + $contact['etag'] .= ':'.implode('-', $limit_in_ab); |
|
996 | 995 | } |
997 | 996 | } |
998 | - elseif($contact === array()) // not found from read_lists() |
|
997 | + elseif ($contact === array()) // not found from read_lists() |
|
999 | 998 | { |
1000 | 999 | $contact = null; |
1001 | 1000 | } |
1002 | 1001 | |
1003 | 1002 | if ($contact && $contact['tid'] == addressbook_so::DELETED_TYPE) |
1004 | 1003 | { |
1005 | - $contact = null; // handle deleted events, as not existing (404 Not Found) |
|
1004 | + $contact = null; // handle deleted events, as not existing (404 Not Found) |
|
1006 | 1005 | } |
1007 | 1006 | if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
1008 | 1007 | return $contact; |
@@ -1015,9 +1014,9 @@ discard block |
||
1015 | 1014 | * @param array|int $contact contact-array or id |
1016 | 1015 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
1017 | 1016 | */ |
1018 | - function check_access($acl,$contact) |
|
1017 | + function check_access($acl, $contact) |
|
1019 | 1018 | { |
1020 | - return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts |
|
1019 | + return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts |
|
1021 | 1020 | } |
1022 | 1021 | |
1023 | 1022 | /** |
@@ -1045,15 +1044,15 @@ discard block |
||
1045 | 1044 | * @param boolean $ignore_all_in_one=false if true, return selected addressbooks and not array() for all-in-one |
1046 | 1045 | * @return array account_id => account_lid pairs |
1047 | 1046 | */ |
1048 | - function get_shared($ignore_all_in_one=false) |
|
1047 | + function get_shared($ignore_all_in_one = false) |
|
1049 | 1048 | { |
1050 | 1049 | $shared = array(); |
1051 | 1050 | |
1052 | 1051 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
1053 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
1052 | + if (!$ignore_all_in_one && in_array('O', $this->home_set_pref)) return array(); |
|
1054 | 1053 | |
1055 | 1054 | // replace symbolic id's with real nummeric id's |
1056 | - foreach(array( |
|
1055 | + foreach (array( |
|
1057 | 1056 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
1058 | 1057 | 'U' => '0', |
1059 | 1058 | ) as $sym => $id) |
@@ -1063,11 +1062,11 @@ discard block |
||
1063 | 1062 | $this->home_set_pref[$key] = $id; |
1064 | 1063 | } |
1065 | 1064 | } |
1066 | - foreach($this->bo->get_addressbooks(EGW_ACL_READ) as $id => $label) |
|
1065 | + foreach ($this->bo->get_addressbooks(EGW_ACL_READ) as $id => $label) |
|
1067 | 1066 | { |
1068 | 1067 | if (($id || !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) && |
1069 | - $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs |
|
1070 | - (in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) && |
|
1068 | + $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs |
|
1069 | + (in_array('A', $this->home_set_pref) || in_array((string)$id, $this->home_set_pref)) && |
|
1071 | 1070 | is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts')) |
1072 | 1071 | { |
1073 | 1072 | $shared[$id] = 'addressbook-'.$owner; |
@@ -1087,14 +1086,14 @@ discard block |
||
1087 | 1086 | public static function groupdav_root_props(array $data) |
1088 | 1087 | { |
1089 | 1088 | $data['props']['addressbook-home-set'] = groupdav::mkprop(groupdav::CARDDAV, 'addressbook-home-set', array( |
1090 | - groupdav::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); |
|
1089 | + groupdav::mkprop('href', $data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); |
|
1091 | 1090 | |
1092 | 1091 | $data['props']['principal-address'] = groupdav::mkprop(groupdav::CARDDAV, 'principal-address', |
1093 | 1092 | $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array( |
1094 | - groupdav::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); |
|
1093 | + groupdav::mkprop('href', $data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); |
|
1095 | 1094 | |
1096 | 1095 | $data['props']['directory-gateway'] = groupdav::mkprop(groupdav::CARDDAV, 'directory-gateway', array( |
1097 | - groupdav::mkprop('href',$data['caldav']->base_uri.'/addressbook/'))); |
|
1096 | + groupdav::mkprop('href', $data['caldav']->base_uri.'/addressbook/'))); |
|
1098 | 1097 | } |
1099 | 1098 | |
1100 | 1099 | /** |
@@ -1117,8 +1116,8 @@ discard block |
||
1117 | 1116 | $user = $hook_data['account_id']; |
1118 | 1117 | $addressbook_bo = new addressbook_bo(); |
1119 | 1118 | $addressbooks += $addressbook_bo->get_addressbooks(EGW_ACL_READ, null, $user); |
1120 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
1121 | - unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
|
1119 | + if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
1120 | + unset($addressbooks[$user.'p']); // ignore (optional) private addressbook for now |
|
1122 | 1121 | } |
1123 | 1122 | |
1124 | 1123 | // allow to force no other addressbooks |
@@ -1145,9 +1144,9 @@ discard block |
||
1145 | 1144 | 'label' => 'Addressbooks to sync in addition to personal addressbook', |
1146 | 1145 | 'name' => 'addressbook-home-set', |
1147 | 1146 | 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likely not be supported!'). |
1148 | - '<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"'). |
|
1149 | - '<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.',lang('Sync all selected into one')). |
|
1150 | - '<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.',lang('Distribution lists as groups')), |
|
1147 | + '<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CardDAV "addressbook-home-set"'). |
|
1148 | + '<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.', lang('Sync all selected into one')). |
|
1149 | + '<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.', lang('Distribution lists as groups')), |
|
1151 | 1150 | 'values' => $addressbooks, |
1152 | 1151 | 'xmlrpc' => True, |
1153 | 1152 | 'admin' => False, |
@@ -84,7 +84,10 @@ discard block |
||
84 | 84 | groupdav_handler::$path_attr = 'carddav_name'; |
85 | 85 | groupdav_handler::$path_extension = ''; |
86 | 86 | } |
87 | - if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
|
87 | + if ($this->debug) |
|
88 | + { |
|
89 | + error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
|
90 | + } |
|
88 | 91 | |
89 | 92 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
90 | 93 | $this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); |
@@ -122,16 +125,26 @@ discard block |
||
122 | 125 | $filter['owner'] = $user; |
123 | 126 | } |
124 | 127 | // should we hide the accounts addressbook |
125 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; |
|
128 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
129 | + { |
|
130 | + $filter['account_id'] = null; |
|
131 | + } |
|
126 | 132 | |
127 | 133 | // process REPORT filters or multiget href's |
128 | 134 | if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options,$filter,$id, $nresults)) |
129 | 135 | { |
130 | 136 | return false; |
131 | 137 | } |
132 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
138 | + if ($id) |
|
139 | + { |
|
140 | + $path = dirname($path).'/'; |
|
141 | + } |
|
142 | + // carddav_name get's added anyway in the callback |
|
133 | 143 | |
134 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
|
144 | + if ($this->debug) |
|
145 | + { |
|
146 | + error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
|
147 | + } |
|
135 | 148 | |
136 | 149 | // check if we have to return the full contact data or just the etag's |
137 | 150 | if (!($filter['address_data'] = $options['props'] == 'all' && |
@@ -216,16 +229,25 @@ discard block |
||
216 | 229 | |
217 | 230 | if (isset($filter[self::$path_attr])) |
218 | 231 | { |
219 | - if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
|
232 | + if (!is_array($filter[self::$path_attr])) |
|
233 | + { |
|
234 | + $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
|
235 | + } |
|
220 | 236 | $requested_multiget_ids =& $filter[self::$path_attr]; |
221 | 237 | } |
222 | 238 | |
223 | 239 | $files = array(); |
224 | 240 | // we query etag and modified, as LDAP does not have the strong sql etag |
225 | 241 | $cols = array('id','uid','etag','modified','n_fn'); |
226 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; |
|
242 | + if (!in_array(self::$path_attr,$cols)) |
|
243 | + { |
|
244 | + $cols[] = self::$path_attr; |
|
245 | + } |
|
227 | 246 | // we need tid for sync-collection report |
228 | - if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; |
|
247 | + if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) |
|
248 | + { |
|
249 | + $cols[] = 'tid'; |
|
250 | + } |
|
229 | 251 | if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) |
230 | 252 | { |
231 | 253 | foreach($contacts as &$contact) |
@@ -269,7 +291,10 @@ discard block |
||
269 | 291 | { |
270 | 292 | $accounts_filter = $filter_in; |
271 | 293 | $accounts_filter['owner'] = '0'; |
272 | - if ($sync_collection_report) $token_was = $this->sync_collection_token; |
|
294 | + if ($sync_collection_report) |
|
295 | + { |
|
296 | + $token_was = $this->sync_collection_token; |
|
297 | + } |
|
273 | 298 | groupdav_handler::$path_attr = 'id'; |
274 | 299 | groupdav_handler::$path_extension = '.vcf'; |
275 | 300 | $files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false)); |
@@ -292,16 +317,22 @@ discard block |
||
292 | 317 | list(,$sync_token) = explode('>', $filter[0]); |
293 | 318 | $where[] = 'list_modified>FROM_UNIXTIME('.(int)$sync_token.')'; |
294 | 319 | } |
295 | - if (isset($filter[self::$path_attr])) // multiget report? |
|
320 | + if (isset($filter[self::$path_attr])) |
|
321 | + { |
|
322 | + // multiget report? |
|
296 | 323 | { |
297 | 324 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; |
298 | 325 | } |
326 | + } |
|
299 | 327 | //error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); |
300 | - if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
328 | + if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) |
|
329 | + { |
|
330 | + // limit to contacts in same AB! |
|
301 | 331 | { |
302 | 332 | foreach($lists as $list) |
303 | 333 | { |
304 | 334 | $list[self::$path_attr] = $list['list_carddav_name']; |
335 | + } |
|
305 | 336 | $etag = $list['list_id'].':'.$list['list_etag']; |
306 | 337 | // for all-in-one addressbook, add selected ABs to etag |
307 | 338 | if (isset($filter['owner']) && is_array($filter['owner'])) |
@@ -345,7 +376,10 @@ discard block |
||
345 | 376 | } |
346 | 377 | } |
347 | 378 | |
348 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
379 | + if ($this->debug) |
|
380 | + { |
|
381 | + error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
382 | + } |
|
349 | 383 | return $files; |
350 | 384 | } |
351 | 385 | |
@@ -384,7 +418,11 @@ discard block |
||
384 | 418 | |
385 | 419 | foreach($options['filters'] as $n => $filter) |
386 | 420 | { |
387 | - if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
421 | + if (!is_int($n)) |
|
422 | + { |
|
423 | + continue; |
|
424 | + } |
|
425 | + // eg. attributes of filter xml element |
|
388 | 426 | |
389 | 427 | switch((string)$filter['name']) |
390 | 428 | { |
@@ -392,19 +430,28 @@ discard block |
||
392 | 430 | $this->groupdav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
393 | 431 | break; |
394 | 432 | case 'prop-filter': // can be multiple prop-filter, see example |
395 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
433 | + if ($matches) |
|
434 | + { |
|
435 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
436 | + } |
|
396 | 437 | $matches = array(); |
397 | 438 | $prop_filter = strtoupper($filter['attrs']['name']); |
398 | 439 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; |
399 | - if ($this->debug > 1) error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); |
|
440 | + if ($this->debug > 1) |
|
441 | + { |
|
442 | + error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); |
|
443 | + } |
|
400 | 444 | break; |
401 | 445 | case 'is-not-defined': |
402 | 446 | $matches[] = '('.$column."='' OR ".$column.' IS NULL)'; |
403 | 447 | break; |
404 | 448 | case 'text-match': // prop-filter can have multiple text-match, see example |
405 | - if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware |
|
449 | + if (!isset($this->filter_prop2cal[$prop_filter])) |
|
450 | + { |
|
451 | + // eg. not existing NICKNAME in EGroupware |
|
406 | 452 | { |
407 | 453 | if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); |
454 | + } |
|
408 | 455 | $column = false; // to ignore following data too |
409 | 456 | } |
410 | 457 | else |
@@ -417,8 +464,14 @@ discard block |
||
417 | 464 | break; |
418 | 465 | } |
419 | 466 | $column = $this->filter_prop2cal[strtoupper($prop_filter)]; |
420 | - if (strpos($column, '_') === false) $column = 'contact_'.$column; |
|
421 | - if (!isset($filters['order'])) $filters['order'] = $column; |
|
467 | + if (strpos($column, '_') === false) |
|
468 | + { |
|
469 | + $column = 'contact_'.$column; |
|
470 | + } |
|
471 | + if (!isset($filters['order'])) |
|
472 | + { |
|
473 | + $filters['order'] = $column; |
|
474 | + } |
|
422 | 475 | $match_type = $filter['attrs']['match-type']; |
423 | 476 | $negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes'; |
424 | 477 | } |
@@ -426,9 +479,12 @@ discard block |
||
426 | 479 | case '': // data of text-match element |
427 | 480 | if (isset($filter['data']) && isset($column)) |
428 | 481 | { |
429 | - if ($column) // false for properties not known to EGroupware |
|
482 | + if ($column) |
|
483 | + { |
|
484 | + // false for properties not known to EGroupware |
|
430 | 485 | { |
431 | 486 | $value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); |
487 | + } |
|
432 | 488 | switch($match_type) |
433 | 489 | { |
434 | 490 | case 'equals': |
@@ -447,7 +503,10 @@ discard block |
||
447 | 503 | } |
448 | 504 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; |
449 | 505 | |
450 | - if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); |
|
506 | + if ($this->debug > 1) |
|
507 | + { |
|
508 | + error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); |
|
509 | + } |
|
451 | 510 | } |
452 | 511 | unset($column); |
453 | 512 | break; |
@@ -458,11 +517,17 @@ discard block |
||
458 | 517 | break; |
459 | 518 | } |
460 | 519 | } |
461 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
520 | + if ($matches) |
|
521 | + { |
|
522 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
523 | + } |
|
462 | 524 | if ($prop_filters) |
463 | 525 | { |
464 | 526 | $filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; |
465 | - if ($this->debug) error_log(__METHOD__."($path,...) sql-filter: $filter"); |
|
527 | + if ($this->debug) |
|
528 | + { |
|
529 | + error_log(__METHOD__."($path,...) sql-filter: $filter"); |
|
530 | + } |
|
466 | 531 | } |
467 | 532 | } |
468 | 533 | // parse limit from $options['other'] |
@@ -519,8 +584,14 @@ discard block |
||
519 | 584 | } |
520 | 585 | } |
521 | 586 | } |
522 | - if ($ids) $filters[self::$path_attr] = $ids; |
|
523 | - if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
587 | + if ($ids) |
|
588 | + { |
|
589 | + $filters[self::$path_attr] = $ids; |
|
590 | + } |
|
591 | + if ($this->debug) |
|
592 | + { |
|
593 | + error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
594 | + } |
|
524 | 595 | } |
525 | 596 | elseif ($id) |
526 | 597 | { |
@@ -565,12 +636,18 @@ discard block |
||
565 | 636 | */ |
566 | 637 | function put(&$options,$id,$user=null,$prefix=null) |
567 | 638 | { |
568 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
|
639 | + if ($this->debug) |
|
640 | + { |
|
641 | + error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
|
642 | + } |
|
569 | 643 | |
570 | 644 | $oldContact = $this->_common_get_put_delete('PUT',$options,$id); |
571 | 645 | if (!is_null($oldContact) && !is_array($oldContact)) |
572 | 646 | { |
573 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
|
647 | + if ($this->debug) |
|
648 | + { |
|
649 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
|
650 | + } |
|
574 | 651 | return $oldContact; |
575 | 652 | } |
576 | 653 | |
@@ -661,15 +738,24 @@ discard block |
||
661 | 738 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... |
662 | 739 | if (!($this->bo->grants[$contact['owner']] & EGW_ACL_ADD)) |
663 | 740 | { |
664 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
|
741 | + if ($this->debug) |
|
742 | + { |
|
743 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
|
744 | + } |
|
665 | 745 | return '403 Forbidden'; |
666 | 746 | } |
667 | 747 | } |
668 | - if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match); |
|
748 | + if ($this->http_if_match) |
|
749 | + { |
|
750 | + $contact['etag'] = self::etag2value($this->http_if_match); |
|
751 | + } |
|
669 | 752 | |
670 | 753 | if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact))) |
671 | 754 | { |
672 | - if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
755 | + if ($this->debug) |
|
756 | + { |
|
757 | + error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
758 | + } |
|
673 | 759 | if ($save_ok === 0) |
674 | 760 | { |
675 | 761 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
@@ -698,7 +784,10 @@ discard block |
||
698 | 784 | // send evtl. necessary respose headers: Location, etag, ... |
699 | 785 | $this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id'); |
700 | 786 | |
701 | - if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
787 | + if ($this->debug > 1) |
|
788 | + { |
|
789 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
790 | + } |
|
702 | 791 | return $retval; |
703 | 792 | } |
704 | 793 | |
@@ -712,7 +801,10 @@ discard block |
||
712 | 801 | function save_group(array &$contact, $oldContact=null) |
713 | 802 | { |
714 | 803 | $data = array('list_name' => $contact['n_fn']); |
715 | - if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
804 | + if (!isset($contact['owner'])) |
|
805 | + { |
|
806 | + $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
807 | + } |
|
716 | 808 | foreach(array('id','carddav_name','uid','owner') as $name) |
717 | 809 | { |
718 | 810 | $data['list_'.$name] = $contact[$name]; |
@@ -731,7 +823,11 @@ discard block |
||
731 | 823 | { |
732 | 824 | $new_members = array($new_members); |
733 | 825 | } |
734 | - foreach($new_members as &$uid) $uid = substr($uid,9); // cut off "urn:uuid:" prefix |
|
826 | + foreach($new_members as &$uid) |
|
827 | + { |
|
828 | + $uid = substr($uid,9); |
|
829 | + } |
|
830 | + // cut off "urn:uuid:" prefix |
|
735 | 831 | |
736 | 832 | if ($oldContact) |
737 | 833 | { |
@@ -762,13 +858,22 @@ discard block |
||
762 | 858 | } |
763 | 859 | } |
764 | 860 | //error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids)); |
765 | - if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array()); |
|
766 | - if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
861 | + if ($to_add_ids) |
|
862 | + { |
|
863 | + $this->bo->add2list($to_add_ids, $list_id, array()); |
|
864 | + } |
|
865 | + if ($to_delete_ids) |
|
866 | + { |
|
867 | + $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
868 | + } |
|
767 | 869 | } |
768 | 870 | // reread as update of list-members updates etag and modified |
769 | 871 | $contact = $this->bo->read_list($list_id); |
770 | 872 | } |
771 | - if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
873 | + if ($this->debug > 1) |
|
874 | + { |
|
875 | + error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
876 | + } |
|
772 | 877 | return $list_id; |
773 | 878 | } |
774 | 879 | |
@@ -782,11 +887,17 @@ discard block |
||
782 | 887 | public function getctag($path,$user) |
783 | 888 | { |
784 | 889 | static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
785 | - if (isset($ctags[$path])) return $ctags[$path]; |
|
890 | + if (isset($ctags[$path])) |
|
891 | + { |
|
892 | + return $ctags[$path]; |
|
893 | + } |
|
786 | 894 | |
787 | 895 | $user_in = $user; |
788 | 896 | // not showing addressbook of a single user? |
789 | - if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
|
897 | + if (is_null($user) || $user === '' || $path == '/addressbook/') |
|
898 | + { |
|
899 | + $user = null; |
|
900 | + } |
|
790 | 901 | |
791 | 902 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
792 | 903 | if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
@@ -995,16 +1106,22 @@ discard block |
||
995 | 1106 | $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
996 | 1107 | } |
997 | 1108 | } |
998 | - elseif($contact === array()) // not found from read_lists() |
|
1109 | + elseif($contact === array()) |
|
1110 | + { |
|
1111 | + // not found from read_lists() |
|
999 | 1112 | { |
1000 | 1113 | $contact = null; |
1001 | 1114 | } |
1115 | + } |
|
1002 | 1116 | |
1003 | 1117 | if ($contact && $contact['tid'] == addressbook_so::DELETED_TYPE) |
1004 | 1118 | { |
1005 | 1119 | $contact = null; // handle deleted events, as not existing (404 Not Found) |
1006 | 1120 | } |
1007 | - if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
1121 | + if ($this->debug > 1) |
|
1122 | + { |
|
1123 | + error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
1124 | + } |
|
1008 | 1125 | return $contact; |
1009 | 1126 | } |
1010 | 1127 | |
@@ -1034,7 +1151,10 @@ discard block |
||
1034 | 1151 | // remove add and delete grants for accounts (for admins too) |
1035 | 1152 | // as accounts can not be created as contacts, they eg. need further data |
1036 | 1153 | // and admins might not recognice they delete an account incl. its data |
1037 | - if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
1154 | + if (isset($grants[0])) |
|
1155 | + { |
|
1156 | + $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
1157 | + } |
|
1038 | 1158 | |
1039 | 1159 | return $grants; |
1040 | 1160 | } |
@@ -1050,7 +1170,10 @@ discard block |
||
1050 | 1170 | $shared = array(); |
1051 | 1171 | |
1052 | 1172 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
1053 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
1173 | + if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) |
|
1174 | + { |
|
1175 | + return array(); |
|
1176 | + } |
|
1054 | 1177 | |
1055 | 1178 | // replace symbolic id's with real nummeric id's |
1056 | 1179 | foreach(array( |
@@ -1117,7 +1240,11 @@ discard block |
||
1117 | 1240 | $user = $hook_data['account_id']; |
1118 | 1241 | $addressbook_bo = new addressbook_bo(); |
1119 | 1242 | $addressbooks += $addressbook_bo->get_addressbooks(EGW_ACL_READ, null, $user); |
1120 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
1243 | + if ($user > 0) |
|
1244 | + { |
|
1245 | + unset($addressbooks[$user]); |
|
1246 | + } |
|
1247 | + // allways synced |
|
1121 | 1248 | unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
1122 | 1249 | } |
1123 | 1250 |
@@ -425,7 +425,6 @@ discard block |
||
425 | 425 | /** |
426 | 426 | * Remove attributes we are not allowed to update |
427 | 427 | * |
428 | - * @param array $attributes |
|
429 | 428 | */ |
430 | 429 | function sanitize_update(array &$ldapContact) |
431 | 430 | { |
@@ -703,14 +702,14 @@ discard block |
||
703 | 702 | * |
704 | 703 | * '*' and '?' are replaced with sql-wildcards '%' and '_' |
705 | 704 | * |
706 | - * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
|
705 | + * @param boolean $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
|
707 | 706 | * @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return |
708 | 707 | * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
709 | - * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
708 | + * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
710 | 709 | * @param string $wildcard ='' appended befor and after each criteria |
711 | 710 | * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row |
712 | 711 | * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
713 | - * @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num) |
|
712 | + * @param boolean $start =false if != false, return only maxmatch rows begining with start, or array($start,$num) |
|
714 | 713 | * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
715 | 714 | * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
716 | 715 | * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
@@ -41,33 +41,33 @@ discard block |
||
41 | 41 | var $contacts_id='id'; |
42 | 42 | |
43 | 43 | /** |
44 | - * @var string $accountName holds the accountname of the current user |
|
45 | - */ |
|
44 | + * @var string $accountName holds the accountname of the current user |
|
45 | + */ |
|
46 | 46 | var $accountName; |
47 | 47 | |
48 | 48 | /** |
49 | - * @var object $ldapServerInfo holds the information about the current used ldap server |
|
50 | - */ |
|
49 | + * @var object $ldapServerInfo holds the information about the current used ldap server |
|
50 | + */ |
|
51 | 51 | var $ldapServerInfo; |
52 | 52 | |
53 | 53 | /** |
54 | - * @var int $ldapLimit how many rows to fetch from ldap server |
|
55 | - */ |
|
54 | + * @var int $ldapLimit how many rows to fetch from ldap server |
|
55 | + */ |
|
56 | 56 | var $ldapLimit = 2000; |
57 | 57 | |
58 | 58 | /** |
59 | - * @var string $personalContactsDN holds the base DN for the personal addressbooks |
|
60 | - */ |
|
59 | + * @var string $personalContactsDN holds the base DN for the personal addressbooks |
|
60 | + */ |
|
61 | 61 | var $personalContactsDN; |
62 | 62 | |
63 | 63 | /** |
64 | - * @var string $sharedContactsDN holds the base DN for the shared addressbooks |
|
65 | - */ |
|
64 | + * @var string $sharedContactsDN holds the base DN for the shared addressbooks |
|
65 | + */ |
|
66 | 66 | var $sharedContactsDN; |
67 | 67 | |
68 | 68 | /** |
69 | - * @var string $accountContactsDN holds the base DN for accounts addressbook |
|
70 | - */ |
|
69 | + * @var string $accountContactsDN holds the base DN for accounts addressbook |
|
70 | + */ |
|
71 | 71 | var $accountContactsDN; |
72 | 72 | |
73 | 73 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | var $accountsFilter = '(objectclass=posixaccount)'; |
78 | 78 | |
79 | 79 | /** |
80 | - * @var string $allContactsDN holds the base DN of all addressbook |
|
81 | - */ |
|
80 | + * @var string $allContactsDN holds the base DN of all addressbook |
|
81 | + */ |
|
82 | 82 | var $allContactsDN; |
83 | 83 | |
84 | 84 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | var $never_change_dn = false; |
97 | 97 | |
98 | 98 | /** |
99 | - * @var int $total holds the total count of found rows |
|
100 | - */ |
|
99 | + * @var int $total holds the total count of found rows |
|
100 | + */ |
|
101 | 101 | var $total; |
102 | 102 | |
103 | 103 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @param string|array $contact_id contact_id or array with values for id or account_id |
405 | 405 | * @return array/boolean data if row could be retrived else False |
406 | - */ |
|
406 | + */ |
|
407 | 407 | function read($contact_id) |
408 | 408 | { |
409 | 409 | if (is_array($contact_id) && isset($contact_id['account_id']) || |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | * @version $Id$ |
12 | 12 | */ |
13 | 13 | |
14 | -define('ADDRESSBOOK_ALL',0); |
|
15 | -define('ADDRESSBOOK_ACCOUNTS',1); |
|
16 | -define('ADDRESSBOOK_PERSONAL',2); |
|
17 | -define('ADDRESSBOOK_GROUP',3); |
|
14 | +define('ADDRESSBOOK_ALL', 0); |
|
15 | +define('ADDRESSBOOK_ACCOUNTS', 1); |
|
16 | +define('ADDRESSBOOK_PERSONAL', 2); |
|
17 | +define('ADDRESSBOOK_GROUP', 3); |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * LDAP Backend for contacts, compatible with vars and parameters of eTemplate's so_sql. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @var string |
34 | 34 | */ |
35 | - var $contacts_id='id'; |
|
35 | + var $contacts_id = 'id'; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var string $accountName holds the accountname of the current user |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @var string |
82 | 82 | */ |
83 | - var $dn_attribute='uid'; |
|
83 | + var $dn_attribute = 'uid'; |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Do NOT attempt to change DN (dn-attribute can NOT be part of schemas used in addressbook!) |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | * minimum: $this->columns_to_search = array('n_family','n_given','org_name','email'); |
108 | 108 | */ |
109 | 109 | var $search_attributes = array( |
110 | - 'n_family','n_middle','n_given','org_name','org_unit', |
|
111 | - 'adr_one_location','adr_two_location','note', |
|
112 | - 'email','mozillasecondemail','uidnumber', |
|
110 | + 'n_family', 'n_middle', 'n_given', 'org_name', 'org_unit', |
|
111 | + 'adr_one_location', 'adr_two_location', 'note', |
|
112 | + 'email', 'mozillasecondemail', 'uidnumber', |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | /** |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | #postOfficeBox |
166 | 166 | 'mozillaabpersonalpha' => array( |
167 | 167 | 'adr_one_street2' => 'mozillaworkstreet2', |
168 | - 'adr_one_countryname' => 'c', // 2 letter country code |
|
169 | - 'adr_one_countrycode' => 'c', // 2 letter country code |
|
168 | + 'adr_one_countryname' => 'c', // 2 letter country code |
|
169 | + 'adr_one_countrycode' => 'c', // 2 letter country code |
|
170 | 170 | 'adr_two_street' => 'mozillahomestreet', |
171 | 171 | 'adr_two_street2' => 'mozillahomestreet2', |
172 | 172 | 'adr_two_locality' => 'mozillahomelocalityname', |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | // similar to the newer mozillaAbPerson, but uses mozillaPostalAddress2 instead of mozillaStreet2 |
181 | 181 | 'mozillaorgperson' => array( |
182 | 182 | 'adr_one_street2' => 'mozillapostaladdress2', |
183 | - 'adr_one_countrycode' => 'c', // 2 letter country code |
|
184 | - 'adr_one_countryname' => 'co', // human readable country name, must be after 'c' to take precedence on read! |
|
183 | + 'adr_one_countrycode' => 'c', // 2 letter country code |
|
184 | + 'adr_one_countryname' => 'co', // human readable country name, must be after 'c' to take precedence on read! |
|
185 | 185 | 'adr_two_street' => 'mozillahomestreet', |
186 | 186 | 'adr_two_street2' => 'mozillahomepostaladdress2', |
187 | 187 | 'adr_two_locality' => 'mozillahomelocalityname', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'note' => 'note', |
208 | 208 | 'tel_car' => 'carphone', |
209 | 209 | 'tel_prefer' => 'primaryphone', |
210 | - 'cat_id' => 'category', // special handling in _egw2evolutionperson method |
|
210 | + 'cat_id' => 'category', // special handling in _egw2evolutionperson method |
|
211 | 211 | 'role' => 'businessrole', |
212 | 212 | 'tel_assistent' => 'assistantphone', |
213 | 213 | 'assistent' => 'assistantname', |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | 'freebusy_uri' => 'freeBusyuri', |
217 | 217 | 'calendar_uri' => 'calendaruri', |
218 | 218 | 'tel_other' => 'otherphone', |
219 | - 'tel_cell_private' => 'callbackphone', // not the best choice, but better then nothing |
|
219 | + 'tel_cell_private' => 'callbackphone', // not the best choice, but better then nothing |
|
220 | 220 | ), |
221 | 221 | // additional schema can be added here, including special functions |
222 | 222 | |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * @param array $ldap_config =null default use from $GLOBALS['egw_info']['server'] |
265 | 265 | * @param resource $ds =null ldap connection to use |
266 | 266 | */ |
267 | - function __construct(array $ldap_config=null, $ds=null) |
|
267 | + function __construct(array $ldap_config = null, $ds = null) |
|
268 | 268 | { |
269 | 269 | //$this->db_data_cols = $this->stock_contact_fields + $this->non_contact_fields; |
270 | - $this->accountName = $GLOBALS['egw_info']['user']['account_lid']; |
|
270 | + $this->accountName = $GLOBALS['egw_info']['user']['account_lid']; |
|
271 | 271 | |
272 | 272 | if ($ldap_config) |
273 | 273 | { |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | } |
276 | 276 | else |
277 | 277 | { |
278 | - $this->ldap_config =& $GLOBALS['egw_info']['server']; |
|
278 | + $this->ldap_config = & $GLOBALS['egw_info']['server']; |
|
279 | 279 | } |
280 | 280 | $this->accountContactsDN = $this->ldap_config['ldap_context']; |
281 | - $this->allContactsDN = $this->ldap_config['ldap_contact_context']; |
|
282 | - $this->personalContactsDN = 'ou=personal,ou=contacts,'. $this->allContactsDN; |
|
283 | - $this->sharedContactsDN = 'ou=shared,ou=contacts,'. $this->allContactsDN; |
|
281 | + $this->allContactsDN = $this->ldap_config['ldap_contact_context']; |
|
282 | + $this->personalContactsDN = 'ou=personal,ou=contacts,'.$this->allContactsDN; |
|
283 | + $this->sharedContactsDN = 'ou=shared,ou=contacts,'.$this->allContactsDN; |
|
284 | 284 | |
285 | 285 | if ($ds) |
286 | 286 | { |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | } |
293 | 293 | $this->ldapServerInfo = $GLOBALS['egw']->ldap->getLDAPServerInfo($this->ldap_config['ldap_contact_host']); |
294 | 294 | |
295 | - foreach($this->schema2egw as $attributes) |
|
295 | + foreach ($this->schema2egw as $attributes) |
|
296 | 296 | { |
297 | - $this->all_attributes = array_merge($this->all_attributes,array_values($attributes)); |
|
297 | + $this->all_attributes = array_merge($this->all_attributes, array_values($attributes)); |
|
298 | 298 | } |
299 | 299 | $this->all_attributes = array_values(array_unique($this->all_attributes)); |
300 | 300 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $this->ds = $ldap->ldapConnect(); |
325 | 325 | } |
326 | 326 | // if ldap is NOT the contact repository, we only do accounts and need to use the account-data |
327 | - elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap') // not (ldap or sql-ldap) |
|
327 | + elseif (substr($GLOBALS['egw_info']['server']['contact_repository'], -4) != 'ldap') // not (ldap or sql-ldap) |
|
328 | 328 | { |
329 | 329 | $this->ldap_config['ldap_contact_host'] = $this->ldap_config['ldap_host']; |
330 | 330 | $this->allContactsDN = $this->ldap_config['ldap_context']; |
@@ -348,17 +348,17 @@ discard block |
||
348 | 348 | function supported_fields() |
349 | 349 | { |
350 | 350 | $fields = array( |
351 | - 'id','tid','owner', |
|
352 | - 'n_middle','n_prefix','n_suffix', // stored in the cn |
|
353 | - 'created','modified', // automatic timestamps |
|
354 | - 'creator','modifier', // automatic for non accounts |
|
355 | - 'private', // true for personal addressbooks, false otherwise |
|
351 | + 'id', 'tid', 'owner', |
|
352 | + 'n_middle', 'n_prefix', 'n_suffix', // stored in the cn |
|
353 | + 'created', 'modified', // automatic timestamps |
|
354 | + 'creator', 'modifier', // automatic for non accounts |
|
355 | + 'private', // true for personal addressbooks, false otherwise |
|
356 | 356 | ); |
357 | - foreach($this->schema2egw as $objectclass => $mapping) |
|
357 | + foreach ($this->schema2egw as $objectclass => $mapping) |
|
358 | 358 | { |
359 | - if($this->ldapServerInfo->supportsObjectClass($objectclass)) |
|
359 | + if ($this->ldapServerInfo->supportsObjectClass($objectclass)) |
|
360 | 360 | { |
361 | - $fields = array_merge($fields,array_keys($mapping)); |
|
361 | + $fields = array_merge($fields, array_keys($mapping)); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | return array_values(array_unique($fields)); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | return $this->id_filter(is_array($ids) ? array_shift($ids) : $ids); |
389 | 389 | } |
390 | 390 | $filter = array(); |
391 | - foreach($ids as $id) |
|
391 | + foreach ($ids as $id) |
|
392 | 392 | { |
393 | 393 | $filter[] = $this->id_filter($id); |
394 | 394 | } |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | function read($contact_id) |
405 | 405 | { |
406 | 406 | if (is_array($contact_id) && isset($contact_id['account_id']) || |
407 | - !is_array($contact_id) && substr($contact_id,0,8) == 'account:') |
|
407 | + !is_array($contact_id) && substr($contact_id, 0, 8) == 'account:') |
|
408 | 408 | { |
409 | - $filter = 'uidNumber='.(int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id,8)); |
|
409 | + $filter = 'uidNumber='.(int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id, 8)); |
|
410 | 410 | } |
411 | 411 | else |
412 | 412 | { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | // never allow to change the uidNumber (account_id) on update, as it could be misused by eg. xmlrpc or syncml |
430 | 430 | unset($ldapContact['uidnumber']); |
431 | 431 | |
432 | - unset($ldapContact['entryuuid']); // not allowed to modify that, no need either |
|
432 | + unset($ldapContact['entryuuid']); // not allowed to modify that, no need either |
|
433 | 433 | |
434 | 434 | unset($ldapContact['objectClass']); |
435 | 435 | } |
@@ -440,28 +440,28 @@ discard block |
||
440 | 440 | * @param array $keys if given $keys are copied to data before saveing => allows a save as |
441 | 441 | * @return int 0 on success and errno != 0 else |
442 | 442 | */ |
443 | - function save($keys=null) |
|
443 | + function save($keys = null) |
|
444 | 444 | { |
445 | 445 | //error_log(__METHOD__."(".array2string($keys).") this->data=".array2string($this->data)); |
446 | - if(is_array($keys)) |
|
446 | + if (is_array($keys)) |
|
447 | 447 | { |
448 | - $this->data = is_array($this->data) ? array_merge($this->data,$keys) : $keys; |
|
448 | + $this->data = is_array($this->data) ? array_merge($this->data, $keys) : $keys; |
|
449 | 449 | } |
450 | 450 | |
451 | - $data =& $this->data; |
|
451 | + $data = & $this->data; |
|
452 | 452 | $isUpdate = false; |
453 | 453 | $ldapContact = array(); |
454 | 454 | |
455 | 455 | // generate addressbook dn |
456 | - if((int)$data['owner']) |
|
456 | + if ((int)$data['owner']) |
|
457 | 457 | { |
458 | 458 | // group address book |
459 | - if(!($cn = strtolower($GLOBALS['egw']->accounts->id2name((int)$data['owner'])))) |
|
459 | + if (!($cn = strtolower($GLOBALS['egw']->accounts->id2name((int)$data['owner'])))) |
|
460 | 460 | { |
461 | 461 | error_log('Unknown owner'); |
462 | 462 | return true; |
463 | 463 | } |
464 | - $baseDN = 'cn='. $cn .','.($data['owner'] < 0 ? $this->sharedContactsDN : $this->personalContactsDN); |
|
464 | + $baseDN = 'cn='.$cn.','.($data['owner'] < 0 ? $this->sharedContactsDN : $this->personalContactsDN); |
|
465 | 465 | } |
466 | 466 | // only an admin or the user itself is allowed to change the data of an account |
467 | 467 | elseif ($data['account_id'] && ($GLOBALS['egw_info']['user']['apps']['admin'] || |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | { |
470 | 470 | // account |
471 | 471 | $baseDN = $this->accountContactsDN; |
472 | - $cn = false; |
|
472 | + $cn = false; |
|
473 | 473 | // we need an admin connection |
474 | 474 | $this->connect(true); |
475 | 475 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | else |
483 | 483 | { |
484 | 484 | error_log("Permission denied, to write: data[owner]=$data[owner], data[account_id]=$data[account_id], account_id=".$GLOBALS['egw_info']['user']['account_id']); |
485 | - return lang('Permission denied !!!'); // only admin or the user itself is allowd to write accounts! |
|
485 | + return lang('Permission denied !!!'); // only admin or the user itself is allowd to write accounts! |
|
486 | 486 | } |
487 | 487 | // check if $baseDN exists. If not create it |
488 | 488 | if (($err = $this->_check_create_dn($baseDN))) |
@@ -491,55 +491,54 @@ discard block |
||
491 | 491 | } |
492 | 492 | // check the existing objectclasses of an entry, none = array() for new ones |
493 | 493 | $oldObjectclasses = array(); |
494 | - $attributes = array('dn','cn','objectClass',$this->dn_attribute,'mail'); |
|
494 | + $attributes = array('dn', 'cn', 'objectClass', $this->dn_attribute, 'mail'); |
|
495 | 495 | |
496 | 496 | $contactUID = $this->data[$this->contacts_id]; |
497 | 497 | if (!empty($contactUID) && |
498 | - ($result = ldap_search($this->ds, $base=$this->allContactsDN, $this->id_filter($contactUID), $attributes)) && |
|
498 | + ($result = ldap_search($this->ds, $base = $this->allContactsDN, $this->id_filter($contactUID), $attributes)) && |
|
499 | 499 | ($oldContactInfo = ldap_get_entries($this->ds, $result)) && $oldContactInfo['count']) |
500 | 500 | { |
501 | 501 | unset($oldContactInfo[0]['objectclass']['count']); |
502 | - foreach($oldContactInfo[0]['objectclass'] as $objectclass) |
|
502 | + foreach ($oldContactInfo[0]['objectclass'] as $objectclass) |
|
503 | 503 | { |
504 | - $oldObjectclasses[] = strtolower($objectclass); |
|
504 | + $oldObjectclasses[] = strtolower($objectclass); |
|
505 | 505 | } |
506 | 506 | $isUpdate = true; |
507 | 507 | } |
508 | 508 | |
509 | - if(empty($contactUID)) |
|
509 | + if (empty($contactUID)) |
|
510 | 510 | { |
511 | 511 | $ldapContact[$this->dn_attribute] = $this->data[$this->contacts_id] = $contactUID = md5($GLOBALS['egw']->common->randomstring(15)); |
512 | 512 | } |
513 | 513 | //error_log(__METHOD__."() contactUID='$contactUID', isUpdate=".array2string($isUpdate).", oldContactInfo=".array2string($oldContactInfo)); |
514 | 514 | // add for all supported objectclasses the objectclass and it's attributes |
515 | - foreach($this->schema2egw as $objectclass => $mapping) |
|
515 | + foreach ($this->schema2egw as $objectclass => $mapping) |
|
516 | 516 | { |
517 | - if(!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue; |
|
517 | + if (!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue; |
|
518 | 518 | |
519 | - if($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses)) |
|
519 | + if ($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses)) |
|
520 | 520 | { |
521 | 521 | $ldapContact['objectClass'][] = $objectclass; |
522 | 522 | } |
523 | 523 | if (isset($this->required_subs[$objectclass])) |
524 | 524 | { |
525 | - foreach($this->required_subs[$objectclass] as $sub) |
|
525 | + foreach ($this->required_subs[$objectclass] as $sub) |
|
526 | 526 | { |
527 | - if(!in_array($sub, $oldObjectclasses)) |
|
527 | + if (!in_array($sub, $oldObjectclasses)) |
|
528 | 528 | { |
529 | 529 | $ldapContact['objectClass'][] = $sub; |
530 | 530 | } |
531 | 531 | } |
532 | 532 | } |
533 | - foreach($mapping as $egwFieldName => $ldapFieldName) |
|
533 | + foreach ($mapping as $egwFieldName => $ldapFieldName) |
|
534 | 534 | { |
535 | 535 | if (is_int($egwFieldName)) continue; |
536 | - if(!empty($data[$egwFieldName])) |
|
536 | + if (!empty($data[$egwFieldName])) |
|
537 | 537 | { |
538 | 538 | // dont convert the (binary) jpegPhoto! |
539 | - $ldapContact[$ldapFieldName] = $ldapFieldName == 'jpegphoto' ? $data[$egwFieldName] : |
|
540 | - translation::convert(trim($data[$egwFieldName]),$this->charset,'utf-8'); |
|
539 | + $ldapContact[$ldapFieldName] = $ldapFieldName == 'jpegphoto' ? $data[$egwFieldName] : translation::convert(trim($data[$egwFieldName]), $this->charset, 'utf-8'); |
|
541 | 540 | } |
542 | - elseif($isUpdate && isset($data[$egwFieldName])) |
|
541 | + elseif ($isUpdate && isset($data[$egwFieldName])) |
|
543 | 542 | { |
544 | 543 | $ldapContact[$ldapFieldName] = array(); |
545 | 544 | } |
@@ -547,9 +546,9 @@ discard block |
||
547 | 546 | } |
548 | 547 | // handling of special attributes, like cat_id in evolutionPerson |
549 | 548 | $egw2objectclass = '_egw2'.$objectclass; |
550 | - if (method_exists($this,$egw2objectclass)) |
|
549 | + if (method_exists($this, $egw2objectclass)) |
|
551 | 550 | { |
552 | - $this->$egw2objectclass($ldapContact,$data,$isUpdate); |
|
551 | + $this->$egw2objectclass($ldapContact, $data, $isUpdate); |
|
553 | 552 | } |
554 | 553 | } |
555 | 554 | if ($isUpdate) |
@@ -567,11 +566,11 @@ discard block |
||
567 | 566 | $needRecreation = false; |
568 | 567 | |
569 | 568 | // add missing objectclasses |
570 | - if($ldapContact['objectClass'] && ($missing=array_diff($ldapContact['objectClass'],$oldObjectclasses))) |
|
569 | + if ($ldapContact['objectClass'] && ($missing = array_diff($ldapContact['objectClass'], $oldObjectclasses))) |
|
571 | 570 | { |
572 | 571 | if (!@ldap_mod_add($this->ds, $dn, array('objectClass' => $ldapContact['objectClass']))) |
573 | 572 | { |
574 | - if(in_array(ldap_errno($this->ds),array(69,20))) |
|
573 | + if (in_array(ldap_errno($this->ds), array(69, 20))) |
|
575 | 574 | { |
576 | 575 | // need to modify structural objectclass |
577 | 576 | $needRecreation = true; |
@@ -580,15 +579,15 @@ discard block |
||
580 | 579 | else |
581 | 580 | { |
582 | 581 | //echo "<p>ldap_mod_add($this->ds,'$dn',array(objectClass =>".print_r($ldapContact['objectClass'],true)."))</p>\n"; |
583 | - error_log(__METHOD__.'() '.__LINE__.' update of '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .')'); |
|
582 | + error_log(__METHOD__.'() '.__LINE__.' update of '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).')'); |
|
584 | 583 | return $this->_error(__LINE__); |
585 | 584 | } |
586 | 585 | } |
587 | 586 | } |
588 | 587 | |
589 | 588 | // check if we need to rename the DN or need to recreate the contact |
590 | - $newRDN = $this->dn_attribute.'='. $ldapContact[$this->dn_attribute]; |
|
591 | - $newDN = $newRDN .','. $baseDN; |
|
589 | + $newRDN = $this->dn_attribute.'='.$ldapContact[$this->dn_attribute]; |
|
590 | + $newDN = $newRDN.','.$baseDN; |
|
592 | 591 | if ($needRecreation) |
593 | 592 | { |
594 | 593 | $result = ldap_read($this->ds, $dn, 'objectclass=*'); |
@@ -599,20 +598,20 @@ discard block |
||
599 | 598 | $newContact = $oldContact; |
600 | 599 | $newContact[$this->dn_attribute] = $ldapContact[$this->dn_attribute]; |
601 | 600 | |
602 | - if(is_array($ldapContact['objectClass']) && count($ldapContact['objectClass']) > 0) |
|
601 | + if (is_array($ldapContact['objectClass']) && count($ldapContact['objectClass']) > 0) |
|
603 | 602 | { |
604 | - $newContact['objectclass'] = array_unique(array_map('strtolower', // objectclasses my have different case |
|
603 | + $newContact['objectclass'] = array_unique(array_map('strtolower', // objectclasses my have different case |
|
605 | 604 | array_merge($newContact['objectclass'], $ldapContact['objectClass']))); |
606 | 605 | } |
607 | 606 | |
608 | - if(!ldap_delete($this->ds, $dn)) |
|
607 | + if (!ldap_delete($this->ds, $dn)) |
|
609 | 608 | { |
610 | - error_log(__METHOD__.'() '.__LINE__.' delete of old '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .')'); |
|
609 | + error_log(__METHOD__.'() '.__LINE__.' delete of old '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).')'); |
|
611 | 610 | return $this->_error(__LINE__); |
612 | 611 | } |
613 | - if(!@ldap_add($this->ds, $newDN, $newContact)) |
|
612 | + if (!@ldap_add($this->ds, $newDN, $newContact)) |
|
614 | 613 | { |
615 | - error_log(__METHOD__.'() '.__LINE__.' re-create contact as '. $newDN .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .') newContact='.array2string($newContact)); |
|
614 | + error_log(__METHOD__.'() '.__LINE__.' re-create contact as '.$newDN.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).') newContact='.array2string($newContact)); |
|
616 | 615 | // if adding with new objectclass or dn fails, re-add deleted contact |
617 | 616 | @ldap_add($this->ds, $dn, $oldContact); |
618 | 617 | return $this->_error(__LINE__); |
@@ -641,22 +640,22 @@ discard block |
||
641 | 640 | |
642 | 641 | if (!@ldap_modify($this->ds, $dn, $ldapContact)) |
643 | 642 | { |
644 | - error_log(__METHOD__.'() '.__LINE__.' update of '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .') ldapContact='.array2string($ldapContact)); |
|
643 | + error_log(__METHOD__.'() '.__LINE__.' update of '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).') ldapContact='.array2string($ldapContact)); |
|
645 | 644 | return $this->_error(__LINE__); |
646 | 645 | } |
647 | 646 | } |
648 | 647 | else |
649 | 648 | { |
650 | - $dn = $this->dn_attribute.'='. $ldapContact[$this->dn_attribute] .','. $baseDN; |
|
651 | - unset($ldapContact['entryuuid']); // trying to write it, gives an error |
|
649 | + $dn = $this->dn_attribute.'='.$ldapContact[$this->dn_attribute].','.$baseDN; |
|
650 | + unset($ldapContact['entryuuid']); // trying to write it, gives an error |
|
652 | 651 | |
653 | 652 | if (!@ldap_add($this->ds, $dn, $ldapContact)) |
654 | 653 | { |
655 | - error_log(__METHOD__.'() '.__LINE__.' add of '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .') ldapContact='.array2string($ldapContact)); |
|
654 | + error_log(__METHOD__.'() '.__LINE__.' add of '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).') ldapContact='.array2string($ldapContact)); |
|
656 | 655 | return $this->_error(__LINE__); |
657 | 656 | } |
658 | 657 | } |
659 | - return 0; // Ok, no error |
|
658 | + return 0; // Ok, no error |
|
660 | 659 | } |
661 | 660 | |
662 | 661 | /** |
@@ -665,28 +664,28 @@ discard block |
||
665 | 664 | * @param array $keys if given array with col => value pairs to characterise the rows to delete |
666 | 665 | * @return int affected rows, should be 1 if ok, 0 if an error |
667 | 666 | */ |
668 | - function delete($keys=null) |
|
667 | + function delete($keys = null) |
|
669 | 668 | { |
670 | 669 | // single entry |
671 | - if($keys[$this->contacts_id]) $keys = array( 0 => $keys); |
|
670 | + if ($keys[$this->contacts_id]) $keys = array(0 => $keys); |
|
672 | 671 | |
673 | - if(!is_array($keys)) |
|
672 | + if (!is_array($keys)) |
|
674 | 673 | { |
675 | - $keys = array( $keys); |
|
674 | + $keys = array($keys); |
|
676 | 675 | } |
677 | 676 | |
678 | 677 | $ret = 0; |
679 | 678 | |
680 | 679 | $attributes = array('dn'); |
681 | 680 | |
682 | - foreach($keys as $entry) |
|
681 | + foreach ($keys as $entry) |
|
683 | 682 | { |
684 | 683 | $entry = ldap::quote(is_array($entry) ? $entry['id'] : $entry); |
685 | - if(($result = ldap_search($this->ds, $this->allContactsDN, |
|
684 | + if (($result = ldap_search($this->ds, $this->allContactsDN, |
|
686 | 685 | "(|(entryUUID=$entry)(uid=$entry))", $attributes))) |
687 | 686 | { |
688 | 687 | $contactInfo = ldap_get_entries($this->ds, $result); |
689 | - if(@ldap_delete($this->ds, $contactInfo[0]['dn'])) |
|
688 | + if (@ldap_delete($this->ds, $contactInfo[0]['dn'])) |
|
690 | 689 | { |
691 | 690 | $ret++; |
692 | 691 | } |
@@ -714,10 +713,10 @@ discard block |
||
714 | 713 | * @param boolean $need_full_no_count =false If true an unlimited query is run to determine the total number of rows, default false |
715 | 714 | * @return array of matching rows (the row is an array of the cols) or False |
716 | 715 | */ |
717 | - function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false) |
|
716 | + function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false) |
|
718 | 717 | { |
719 | 718 | //error_log(__METHOD__."(".array2string($criteria).", ".array2string($only_keys).", '$order_by', ".array2string($extra_cols).", '$wildcard', '$empty', '$op', ".array2string($start).", ".array2string($filter).")"); |
720 | - unset($only_keys, $extra_cols, $empty, $join, $need_full_no_count); // not used, but required by function signature |
|
719 | + unset($only_keys, $extra_cols, $empty, $join, $need_full_no_count); // not used, but required by function signature |
|
721 | 720 | |
722 | 721 | if (is_array($filter['owner'])) |
723 | 722 | { |
@@ -739,7 +738,7 @@ discard block |
||
739 | 738 | 'created' => 'createtimestamp', |
740 | 739 | 'modified' => 'modifytimestamp', |
741 | 740 | ); |
742 | - foreach($filter as $key => $value) |
|
741 | + foreach ($filter as $key => $value) |
|
743 | 742 | { |
744 | 743 | $matches = null; |
745 | 744 | if (is_int($key) && preg_match('/^(contact_)?(modified|created)([<=>]+)([0-9]+)$/', $value, $matches)) |
@@ -755,11 +754,11 @@ discard block |
||
755 | 754 | } |
756 | 755 | } |
757 | 756 | |
758 | - if((int)$filter['owner']) |
|
757 | + if ((int)$filter['owner']) |
|
759 | 758 | { |
760 | 759 | if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false; |
761 | 760 | |
762 | - $searchDN = 'cn='. ldap::quote(strtolower($accountName)) .','; |
|
761 | + $searchDN = 'cn='.ldap::quote(strtolower($accountName)).','; |
|
763 | 762 | |
764 | 763 | if ($filter['owner'] < 0) |
765 | 764 | { |
@@ -783,7 +782,7 @@ discard block |
||
783 | 782 | $addressbookType = ADDRESSBOOK_ACCOUNTS; |
784 | 783 | } |
785 | 784 | // create the search filter |
786 | - switch($addressbookType) |
|
785 | + switch ($addressbookType) |
|
787 | 786 | { |
788 | 787 | case ADDRESSBOOK_ACCOUNTS: |
789 | 788 | $objectFilter = $this->accountsFilter; |
@@ -798,28 +797,28 @@ discard block |
||
798 | 797 | // shadowExpire>= does NOT work, as shadow schema only specifies integerMatch and not integerOrderingMatch :-( |
799 | 798 | |
800 | 799 | $searchFilter = ''; |
801 | - if(is_array($criteria) && count($criteria) > 0) |
|
800 | + if (is_array($criteria) && count($criteria) > 0) |
|
802 | 801 | { |
803 | 802 | $wildcard = $wildcard === '%' ? '*' : ''; |
804 | 803 | $searchFilter = ''; |
805 | - foreach($criteria as $egwSearchKey => $searchValue) |
|
804 | + foreach ($criteria as $egwSearchKey => $searchValue) |
|
806 | 805 | { |
807 | - if (in_array($egwSearchKey, array('id','contact_id'))) |
|
806 | + if (in_array($egwSearchKey, array('id', 'contact_id'))) |
|
808 | 807 | { |
809 | 808 | $searchFilter .= $this->ids_filter($searchValue); |
810 | 809 | continue; |
811 | 810 | } |
812 | - foreach($this->schema2egw as $mapping) |
|
811 | + foreach ($this->schema2egw as $mapping) |
|
813 | 812 | { |
814 | - if(($ldapSearchKey = $mapping[$egwSearchKey])) |
|
813 | + if (($ldapSearchKey = $mapping[$egwSearchKey])) |
|
815 | 814 | { |
816 | - $searchString = translation::convert($searchValue,$this->charset,'utf-8'); |
|
815 | + $searchString = translation::convert($searchValue, $this->charset, 'utf-8'); |
|
817 | 816 | $searchFilter .= '('.$ldapSearchKey.'='.$wildcard.ldap::quote($searchString).$wildcard.')'; |
818 | 817 | break; |
819 | 818 | } |
820 | 819 | } |
821 | 820 | } |
822 | - if($op == 'AND') |
|
821 | + if ($op == 'AND') |
|
823 | 822 | { |
824 | 823 | $searchFilter = "(&$searchFilter)"; |
825 | 824 | } |
@@ -838,9 +837,9 @@ discard block |
||
838 | 837 | // only return certain owners --> unset not matching ones |
839 | 838 | if ($owner_filter) |
840 | 839 | { |
841 | - foreach($rows as $k => $row) |
|
840 | + foreach ($rows as $k => $row) |
|
842 | 841 | { |
843 | - if (!in_array($row['owner'],$owner_filter)) |
|
842 | + if (!in_array($row['owner'], $owner_filter)) |
|
844 | 843 | { |
845 | 844 | unset($rows[$k]); |
846 | 845 | --$this->total; |
@@ -851,36 +850,36 @@ discard block |
||
851 | 850 | { |
852 | 851 | $order = array(); |
853 | 852 | $sort = 'ASC'; |
854 | - foreach(explode(',',$order_by) as $o) |
|
853 | + foreach (explode(',', $order_by) as $o) |
|
855 | 854 | { |
856 | - if (substr($o,0,8) == 'contact_') $o = substr($o,8); |
|
857 | - if (substr($o,-4) == ' ASC') |
|
855 | + if (substr($o, 0, 8) == 'contact_') $o = substr($o, 8); |
|
856 | + if (substr($o, -4) == ' ASC') |
|
858 | 857 | { |
859 | 858 | $sort = 'ASC'; |
860 | - $order[] = substr($o,0,-4); |
|
859 | + $order[] = substr($o, 0, -4); |
|
861 | 860 | } |
862 | - elseif (substr($o,-5) == ' DESC') |
|
861 | + elseif (substr($o, -5) == ' DESC') |
|
863 | 862 | { |
864 | 863 | $sort = 'DESC'; |
865 | - $order[] = substr($o,0,-5); |
|
864 | + $order[] = substr($o, 0, -5); |
|
866 | 865 | } |
867 | 866 | elseif ($o) |
868 | 867 | { |
869 | 868 | $order[] = $o; |
870 | 869 | } |
871 | 870 | } |
872 | - $rows = ExecMethod2('phpgwapi.arrayfunctions.arfsort',$rows,$order,$sort); |
|
871 | + $rows = ExecMethod2('phpgwapi.arrayfunctions.arfsort', $rows, $order, $sort); |
|
873 | 872 | } |
874 | 873 | // if requested ($start !== false) return only limited resultset |
875 | 874 | if (is_array($start)) |
876 | 875 | { |
877 | - list($start,$offset) = $start; |
|
876 | + list($start, $offset) = $start; |
|
878 | 877 | } |
879 | - if(is_numeric($start) && is_numeric($offset) && $offset >= 0) |
|
878 | + if (is_numeric($start) && is_numeric($offset) && $offset >= 0) |
|
880 | 879 | { |
881 | 880 | return array_slice($rows, $start, $offset); |
882 | 881 | } |
883 | - elseif(is_numeric($start)) |
|
882 | + elseif (is_numeric($start)) |
|
884 | 883 | { |
885 | 884 | return array_slice($rows, $start, $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']); |
886 | 885 | } |
@@ -898,11 +897,11 @@ discard block |
||
898 | 897 | if (!is_array($filter)) return ''; |
899 | 898 | |
900 | 899 | $filters = ''; |
901 | - foreach($filter as $key => $value) |
|
900 | + foreach ($filter as $key => $value) |
|
902 | 901 | { |
903 | 902 | if ($key != 'cat_id' && $key != 'account_id' && !$value) continue; |
904 | 903 | |
905 | - switch((string) $key) |
|
904 | + switch ((string)$key) |
|
906 | 905 | { |
907 | 906 | case 'owner': // already handled |
908 | 907 | case 'tid': // ignored |
@@ -925,7 +924,7 @@ discard block |
||
925 | 924 | { |
926 | 925 | $filters .= '(!(category=*))'; |
927 | 926 | } |
928 | - elseif((int)$value) |
|
927 | + elseif ((int)$value) |
|
929 | 928 | { |
930 | 929 | if (!is_object($GLOBALS['egw']->categories)) |
931 | 930 | { |
@@ -933,10 +932,10 @@ discard block |
||
933 | 932 | } |
934 | 933 | $cats = $GLOBALS['egw']->categories->return_all_children((int)$value); |
935 | 934 | if (count($cats) > 1) $filters .= '(|'; |
936 | - foreach($cats as $cat) |
|
935 | + foreach ($cats as $cat) |
|
937 | 936 | { |
938 | 937 | $catName = translation::convert( |
939 | - $GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8'); |
|
938 | + $GLOBALS['egw']->categories->id2name($cat), $this->charset, 'utf-8'); |
|
940 | 939 | $filters .= '(category='.ldap::quote($catName).')'; |
941 | 940 | } |
942 | 941 | if (count($cats) > 1) $filters .= ')'; |
@@ -945,7 +944,7 @@ discard block |
||
945 | 944 | |
946 | 945 | case 'carddav_name': |
947 | 946 | if (!is_array($value)) $value = array($value); |
948 | - foreach($value as &$v) |
|
947 | + foreach ($value as &$v) |
|
949 | 948 | { |
950 | 949 | $v = basename($v, '.vcf'); |
951 | 950 | } |
@@ -959,28 +958,27 @@ discard block |
||
959 | 958 | $matches = null; |
960 | 959 | if (!is_int($key)) |
961 | 960 | { |
962 | - foreach($this->schema2egw as $mapping) |
|
961 | + foreach ($this->schema2egw as $mapping) |
|
963 | 962 | { |
964 | 963 | if (isset($mapping[$key])) |
965 | 964 | { |
966 | 965 | // todo: value = "!''" |
967 | - $filters .= '('.$mapping[$key].'='.($value === "!''" ? '*' : |
|
968 | - ldap::quote(translation::convert($value,$this->charset,'utf-8'))).')'; |
|
966 | + $filters .= '('.$mapping[$key].'='.($value === "!''" ? '*' : ldap::quote(translation::convert($value, $this->charset, 'utf-8'))).')'; |
|
969 | 967 | break; |
970 | 968 | } |
971 | 969 | } |
972 | 970 | } |
973 | 971 | // filter for letter-search |
974 | - elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/",$value,$matches)) |
|
972 | + elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/", $value, $matches)) |
|
975 | 973 | { |
976 | - list(,$name,$value) = $matches; |
|
977 | - if (strpos($name,'.') !== false) list(,$name) = explode('.',$name); |
|
978 | - foreach($this->schema2egw as $mapping) |
|
974 | + list(,$name, $value) = $matches; |
|
975 | + if (strpos($name, '.') !== false) list(,$name) = explode('.', $name); |
|
976 | + foreach ($this->schema2egw as $mapping) |
|
979 | 977 | { |
980 | 978 | if (isset($mapping[$name])) |
981 | 979 | { |
982 | 980 | $filters .= '('.$mapping[$name].'='.ldap::quote( |
983 | - translation::convert($value,$this->charset,'utf-8')).'*)'; |
|
981 | + translation::convert($value, $this->charset, 'utf-8')).'*)'; |
|
984 | 982 | break; |
985 | 983 | } |
986 | 984 | } |
@@ -1004,7 +1002,7 @@ discard block |
||
1004 | 1002 | * @param array $_skipPlugins =null schema-plugins to skip |
1005 | 1003 | * @return array/boolean with eGW contacts or false on error |
1006 | 1004 | */ |
1007 | - function _searchLDAP($_ldapContext, $_filter, $_attributes, $_addressbooktype, array $_skipPlugins=null) |
|
1005 | + function _searchLDAP($_ldapContext, $_filter, $_attributes, $_addressbooktype, array $_skipPlugins = null) |
|
1008 | 1006 | { |
1009 | 1007 | $this->total = 0; |
1010 | 1008 | |
@@ -1017,7 +1015,7 @@ discard block |
||
1017 | 1015 | |
1018 | 1016 | //error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype)"); |
1019 | 1017 | |
1020 | - if($_addressbooktype == ADDRESSBOOK_ALL || $_ldapContext == $this->allContactsDN) |
|
1018 | + if ($_addressbooktype == ADDRESSBOOK_ALL || $_ldapContext == $this->allContactsDN) |
|
1021 | 1019 | { |
1022 | 1020 | $result = ldap_search($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit); |
1023 | 1021 | } |
@@ -1025,36 +1023,36 @@ discard block |
||
1025 | 1023 | { |
1026 | 1024 | $result = @ldap_list($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit); |
1027 | 1025 | } |
1028 | - if(!$result || !$entries = ldap_get_entries($this->ds, $result)) return array(); |
|
1026 | + if (!$result || !$entries = ldap_get_entries($this->ds, $result)) return array(); |
|
1029 | 1027 | //error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype) result of $entries[count]"); |
1030 | 1028 | |
1031 | 1029 | $this->total = $entries['count']; |
1032 | - foreach($entries as $i => $entry) |
|
1030 | + foreach ($entries as $i => $entry) |
|
1033 | 1031 | { |
1034 | - if (!is_int($i)) continue; // eg. count |
|
1032 | + if (!is_int($i)) continue; // eg. count |
|
1035 | 1033 | |
1036 | 1034 | $contact = array( |
1037 | 1035 | 'id' => $entry['uid'][0] ? $entry['uid'][0] : $entry['entryuuid'][0], |
1038 | - 'tid' => 'n', // the type id for the addressbook |
|
1036 | + 'tid' => 'n', // the type id for the addressbook |
|
1039 | 1037 | ); |
1040 | - foreach($entry['objectclass'] as $ii => $objectclass) |
|
1038 | + foreach ($entry['objectclass'] as $ii => $objectclass) |
|
1041 | 1039 | { |
1042 | 1040 | $objectclass = strtolower($objectclass); |
1043 | 1041 | if (!is_int($ii) || !isset($this->schema2egw[$objectclass])) |
1044 | 1042 | { |
1045 | - continue; // eg. count or unsupported objectclass |
|
1043 | + continue; // eg. count or unsupported objectclass |
|
1046 | 1044 | } |
1047 | - foreach($this->schema2egw[$objectclass] as $egwFieldName => $ldapFieldName) |
|
1045 | + foreach ($this->schema2egw[$objectclass] as $egwFieldName => $ldapFieldName) |
|
1048 | 1046 | { |
1049 | - if(!empty($entry[$ldapFieldName][0]) && !is_int($egwFieldName) && !isset($contact[$egwFieldName])) |
|
1047 | + if (!empty($entry[$ldapFieldName][0]) && !is_int($egwFieldName) && !isset($contact[$egwFieldName])) |
|
1050 | 1048 | { |
1051 | - $contact[$egwFieldName] = translation::convert($entry[$ldapFieldName][0],'utf-8'); |
|
1049 | + $contact[$egwFieldName] = translation::convert($entry[$ldapFieldName][0], 'utf-8'); |
|
1052 | 1050 | } |
1053 | 1051 | } |
1054 | 1052 | $objectclass2egw = '_'.$objectclass.'2egw'; |
1055 | - if (!in_array($objectclass2egw, (array)$_skipPlugins) &&method_exists($this,$objectclass2egw)) |
|
1053 | + if (!in_array($objectclass2egw, (array)$_skipPlugins) && method_exists($this, $objectclass2egw)) |
|
1056 | 1054 | { |
1057 | - if (($ret=$this->$objectclass2egw($contact,$entry)) === false) |
|
1055 | + if (($ret = $this->$objectclass2egw($contact, $entry)) === false) |
|
1058 | 1056 | { |
1059 | 1057 | --$this->total; |
1060 | 1058 | continue 2; |
@@ -1064,20 +1062,20 @@ discard block |
||
1064 | 1062 | // read binary jpegphoto only for one result == call by read |
1065 | 1063 | if ($this->total == 1 && isset($entry['jpegphoto'][0])) |
1066 | 1064 | { |
1067 | - $bin = ldap_get_values_len($this->ds,ldap_first_entry($this->ds,$result),'jpegphoto'); |
|
1065 | + $bin = ldap_get_values_len($this->ds, ldap_first_entry($this->ds, $result), 'jpegphoto'); |
|
1068 | 1066 | $contact['jpegphoto'] = $bin[0]; |
1069 | 1067 | } |
1070 | 1068 | $matches = null; |
1071 | - if(preg_match('/cn=([^,]+),'.preg_quote($this->personalContactsDN,'/').'$/i',$entry['dn'],$matches)) |
|
1069 | + if (preg_match('/cn=([^,]+),'.preg_quote($this->personalContactsDN, '/').'$/i', $entry['dn'], $matches)) |
|
1072 | 1070 | { |
1073 | 1071 | // personal addressbook |
1074 | - $contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1],'account_lid','u'); |
|
1072 | + $contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'u'); |
|
1075 | 1073 | $contact['private'] = 0; |
1076 | 1074 | } |
1077 | - elseif(preg_match('/cn=([^,]+),'.preg_quote($this->sharedContactsDN,'/').'$/i',$entry['dn'],$matches)) |
|
1075 | + elseif (preg_match('/cn=([^,]+),'.preg_quote($this->sharedContactsDN, '/').'$/i', $entry['dn'], $matches)) |
|
1078 | 1076 | { |
1079 | 1077 | // group addressbook |
1080 | - $contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1],'account_lid','g'); |
|
1078 | + $contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g'); |
|
1081 | 1079 | $contact['private'] = 0; |
1082 | 1080 | } |
1083 | 1081 | else |
@@ -1086,12 +1084,12 @@ discard block |
||
1086 | 1084 | $contact['owner'] = 0; |
1087 | 1085 | $contact['private'] = 0; |
1088 | 1086 | } |
1089 | - foreach(array( |
|
1087 | + foreach (array( |
|
1090 | 1088 | 'createtimestamp' => 'created', |
1091 | 1089 | 'modifytimestamp' => 'modified', |
1092 | 1090 | ) as $ldapFieldName => $egwFieldName) |
1093 | 1091 | { |
1094 | - if(!empty($entry[$ldapFieldName][0])) |
|
1092 | + if (!empty($entry[$ldapFieldName][0])) |
|
1095 | 1093 | { |
1096 | 1094 | $contact[$egwFieldName] = $this->_ldap2ts($entry[$ldapFieldName][0]); |
1097 | 1095 | } |
@@ -1110,8 +1108,8 @@ discard block |
||
1110 | 1108 | */ |
1111 | 1109 | static function _ldap2ts($date) |
1112 | 1110 | { |
1113 | - return gmmktime(substr($date,8,2),substr($date,10,2),substr($date,12,2), |
|
1114 | - substr($date,4,2),substr($date,6,2),substr($date,0,4)); |
|
1111 | + return gmmktime(substr($date, 8, 2), substr($date, 10, 2), substr($date, 12, 2), |
|
1112 | + substr($date, 4, 2), substr($date, 6, 2), substr($date, 0, 4)); |
|
1115 | 1113 | } |
1116 | 1114 | |
1117 | 1115 | /** |
@@ -1134,22 +1132,22 @@ discard block |
||
1134 | 1132 | function _check_create_dn($baseDN) |
1135 | 1133 | { |
1136 | 1134 | // check if $baseDN exists. If not create new one |
1137 | - if(@ldap_read($this->ds, $baseDN, 'objectclass=*')) |
|
1135 | + if (@ldap_read($this->ds, $baseDN, 'objectclass=*')) |
|
1138 | 1136 | { |
1139 | 1137 | return false; |
1140 | 1138 | } |
1141 | 1139 | //error_log(__METHOD__."('$baseDN') !ldap_read({$this->ds}, '$baseDN', 'objectclass=*') ldap_errno()=".ldap_errno($this->ds).', ldap_error()='.ldap_error($this->ds).get_class($this)); |
1142 | - if(ldap_errno($this->ds) != 32 || substr($baseDN,0,3) != 'cn=') |
|
1140 | + if (ldap_errno($this->ds) != 32 || substr($baseDN, 0, 3) != 'cn=') |
|
1143 | 1141 | { |
1144 | 1142 | error_log(__METHOD__."('$baseDN') baseDN does NOT exist and we cant/wont create it! ldap_errno()=".ldap_errno($this->ds).', ldap_error()='.ldap_error($this->ds)); |
1145 | - return $this->_error(__LINE__); // baseDN does NOT exist and we cant/wont create it |
|
1143 | + return $this->_error(__LINE__); // baseDN does NOT exist and we cant/wont create it |
|
1146 | 1144 | } |
1147 | 1145 | // create a admin connection to add the needed DN |
1148 | 1146 | $adminLDAP = new ldap; |
1149 | 1147 | $adminDS = $adminLDAP->ldapConnect(); |
1150 | 1148 | |
1151 | - list(,$ou) = explode(',',$baseDN); |
|
1152 | - foreach(array( |
|
1149 | + list(,$ou) = explode(',', $baseDN); |
|
1150 | + foreach (array( |
|
1153 | 1151 | 'ou=contacts,'.$this->allContactsDN, |
1154 | 1152 | $ou.',ou=contacts,'.$this->allContactsDN, |
1155 | 1153 | $baseDN, |
@@ -1158,16 +1156,16 @@ discard block |
||
1158 | 1156 | if (!@ldap_read($this->ds, $dn, 'objectclass=*') && ldap_errno($this->ds) == 32) |
1159 | 1157 | { |
1160 | 1158 | // entry does not exist, lets try to create it |
1161 | - list($top) = explode(',',$dn); |
|
1162 | - list($var,$val) = explode('=',$top); |
|
1159 | + list($top) = explode(',', $dn); |
|
1160 | + list($var, $val) = explode('=', $top); |
|
1163 | 1161 | $data = array( |
1164 | 1162 | 'objectClass' => $var == 'cn' ? 'organizationalRole' : 'organizationalUnit', |
1165 | 1163 | $var => $val, |
1166 | 1164 | ); |
1167 | - if(!@ldap_add($adminDS, $dn, $data)) |
|
1165 | + if (!@ldap_add($adminDS, $dn, $data)) |
|
1168 | 1166 | { |
1169 | 1167 | //echo "<p>ldap_add($adminDS,'$dn',".print_r($data,true).")</p>\n"; |
1170 | - $err = lang("Can't create dn %1",$dn).': '.$this->_error(__LINE__,$adminDS); |
|
1168 | + $err = lang("Can't create dn %1", $dn).': '.$this->_error(__LINE__, $adminDS); |
|
1171 | 1169 | $adminLDAP->ldapDisconnect(); |
1172 | 1170 | return $err; |
1173 | 1171 | } |
@@ -1184,7 +1182,7 @@ discard block |
||
1184 | 1182 | * @param int $line |
1185 | 1183 | * @return string |
1186 | 1184 | */ |
1187 | - function _error($line,$ds=null) |
|
1185 | + function _error($line, $ds = null) |
|
1188 | 1186 | { |
1189 | 1187 | return ldap_error($ds ? $ds : $this->ds).': '.__CLASS__.': '.$line; |
1190 | 1188 | } |
@@ -1199,27 +1197,27 @@ discard block |
||
1199 | 1197 | * @param array $data eGW contact data |
1200 | 1198 | * @param boolean $isUpdate |
1201 | 1199 | */ |
1202 | - function _egw2evolutionperson(&$ldapContact,$data,$isUpdate) |
|
1200 | + function _egw2evolutionperson(&$ldapContact, $data, $isUpdate) |
|
1203 | 1201 | { |
1204 | - if(!empty($data['cat_id'])) |
|
1202 | + if (!empty($data['cat_id'])) |
|
1205 | 1203 | { |
1206 | 1204 | $ldapContact['category'] = array(); |
1207 | - foreach(is_array($data['cat_id']) ? $data['cat_id'] : explode(',',$data['cat_id']) as $cat) |
|
1205 | + foreach (is_array($data['cat_id']) ? $data['cat_id'] : explode(',', $data['cat_id']) as $cat) |
|
1208 | 1206 | { |
1209 | 1207 | $ldapContact['category'][] = translation::convert( |
1210 | - ExecMethod('phpgwapi.categories.id2name',$cat),$this->charset,'utf-8'); |
|
1208 | + ExecMethod('phpgwapi.categories.id2name', $cat), $this->charset, 'utf-8'); |
|
1211 | 1209 | } |
1212 | 1210 | } |
1213 | - foreach(array( |
|
1214 | - 'postaladdress' => $data['adr_one_street'] .'$'. $data['adr_one_locality'] .', '. $data['adr_one_region'] .'$'. $data['adr_one_postalcode'] .'$$'. $data['adr_one_countryname'], |
|
1215 | - 'homepostaladdress' => $data['adr_two_street'] .'$'. $data['adr_two_locality'] .', '. $data['adr_two_region'] .'$'. $data['adr_two_postalcode'] .'$$'. $data['adr_two_countryname'], |
|
1211 | + foreach (array( |
|
1212 | + 'postaladdress' => $data['adr_one_street'].'$'.$data['adr_one_locality'].', '.$data['adr_one_region'].'$'.$data['adr_one_postalcode'].'$$'.$data['adr_one_countryname'], |
|
1213 | + 'homepostaladdress' => $data['adr_two_street'].'$'.$data['adr_two_locality'].', '.$data['adr_two_region'].'$'.$data['adr_two_postalcode'].'$$'.$data['adr_two_countryname'], |
|
1216 | 1214 | ) as $attr => $value) |
1217 | 1215 | { |
1218 | - if($value != '$, $$$') |
|
1216 | + if ($value != '$, $$$') |
|
1219 | 1217 | { |
1220 | - $ldapContact[$attr] = translation::convert($value,$this->charset,'utf-8'); |
|
1218 | + $ldapContact[$attr] = translation::convert($value, $this->charset, 'utf-8'); |
|
1221 | 1219 | } |
1222 | - elseif($isUpdate) |
|
1220 | + elseif ($isUpdate) |
|
1223 | 1221 | { |
1224 | 1222 | $ldapContact[$attr] = array(); |
1225 | 1223 | } |
@@ -1229,7 +1227,7 @@ discard block |
||
1229 | 1227 | { |
1230 | 1228 | $ldapContact['primaryphone'] = $data[$data['tel_prefer']]; |
1231 | 1229 | } |
1232 | - elseif($isUpdate) |
|
1230 | + elseif ($isUpdate) |
|
1233 | 1231 | { |
1234 | 1232 | $ldapContact['primaryphone'] = array(); |
1235 | 1233 | } |
@@ -1244,23 +1242,23 @@ discard block |
||
1244 | 1242 | * @param array &$contact already copied fields according to the mapping |
1245 | 1243 | * @param array $data eGW contact data |
1246 | 1244 | */ |
1247 | - function _evolutionperson2egw(&$contact,$data) |
|
1245 | + function _evolutionperson2egw(&$contact, $data) |
|
1248 | 1246 | { |
1249 | 1247 | if ($data['category'] && is_array($data['category'])) |
1250 | 1248 | { |
1251 | 1249 | $contact['cat_id'] = array(); |
1252 | - foreach($data['category'] as $iii => $cat) |
|
1250 | + foreach ($data['category'] as $iii => $cat) |
|
1253 | 1251 | { |
1254 | 1252 | if (!is_int($iii)) continue; |
1255 | 1253 | |
1256 | - $contact['cat_id'][] = ExecMethod('phpgwapi.categories.name2id',$cat); |
|
1254 | + $contact['cat_id'][] = ExecMethod('phpgwapi.categories.name2id', $cat); |
|
1257 | 1255 | } |
1258 | - if ($contact['cat_id']) $contact['cat_id'] = implode(',',$contact['cat_id']); |
|
1256 | + if ($contact['cat_id']) $contact['cat_id'] = implode(',', $contact['cat_id']); |
|
1259 | 1257 | } |
1260 | 1258 | if ($data['primaryphone']) |
1261 | 1259 | { |
1262 | - unset($contact['tel_prefer']); // to not find itself |
|
1263 | - $contact['tel_prefer'] = array_search($data['primaryphone'][0],$contact); |
|
1260 | + unset($contact['tel_prefer']); // to not find itself |
|
1261 | + $contact['tel_prefer'] = array_search($data['primaryphone'][0], $contact); |
|
1264 | 1262 | } |
1265 | 1263 | } |
1266 | 1264 | |
@@ -1273,10 +1271,10 @@ discard block |
||
1273 | 1271 | * @param array &$contact already copied fields according to the mapping |
1274 | 1272 | * @param array $data eGW contact data |
1275 | 1273 | */ |
1276 | - function _inetorgperson2egw(&$contact, $data, $cn='cn') |
|
1274 | + function _inetorgperson2egw(&$contact, $data, $cn = 'cn') |
|
1277 | 1275 | { |
1278 | 1276 | $matches = null; |
1279 | - if(empty($data['givenname'][0])) |
|
1277 | + if (empty($data['givenname'][0])) |
|
1280 | 1278 | { |
1281 | 1279 | $parts = explode($data['sn'][0], $data[$cn][0]); |
1282 | 1280 | $contact['n_prefix'] = trim($parts[0]); |
@@ -1284,8 +1282,8 @@ discard block |
||
1284 | 1282 | } |
1285 | 1283 | // iOS addressbook either use "givenname surname" or "surname givenname" depending on contact preference display-order |
1286 | 1284 | // in full name, so we need to check for both when trying to parse prefix, middle name and suffix form full name |
1287 | - elseif (preg_match($preg='/^(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*) *'.preg_quote($data['sn'][0], '/').' *(.*)$/', $data[$cn][0], $matches) || |
|
1288 | - preg_match($preg='/^(.*) *'.preg_quote($data['sn'][0], '/').'[, ]*(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*)$/', $data[$cn][0], $matches)) |
|
1285 | + elseif (preg_match($preg = '/^(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*) *'.preg_quote($data['sn'][0], '/').' *(.*)$/', $data[$cn][0], $matches) || |
|
1286 | + preg_match($preg = '/^(.*) *'.preg_quote($data['sn'][0], '/').'[, ]*(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*)$/', $data[$cn][0], $matches)) |
|
1289 | 1287 | { |
1290 | 1288 | list(,$contact['n_prefix'], $contact['n_middle'], $contact['n_suffix']) = $matches; |
1291 | 1289 | //error_log(__METHOD__."() preg_match('$preg', '{$data[$cn][0]}') = ".array2string($matches)); |
@@ -1306,11 +1304,11 @@ discard block |
||
1306 | 1304 | * @param array &$contact already copied fields according to the mapping |
1307 | 1305 | * @param array $data eGW contact data |
1308 | 1306 | */ |
1309 | - function _posixaccount2egw(&$contact,$data) |
|
1307 | + function _posixaccount2egw(&$contact, $data) |
|
1310 | 1308 | { |
1311 | - unset($contact); // not used, but required by function signature |
|
1312 | - static $shadowExpireNow=null; |
|
1313 | - if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time()-date('Z'))/86400); |
|
1309 | + unset($contact); // not used, but required by function signature |
|
1310 | + static $shadowExpireNow = null; |
|
1311 | + if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time() - date('Z')) / 86400); |
|
1314 | 1312 | |
1315 | 1313 | // exclude expired or deactivated accounts |
1316 | 1314 | if (isset($data['shadowexpire']) && $data['shadowexpire'][0] <= $shadowExpireNow) |
@@ -1328,11 +1326,11 @@ discard block |
||
1328 | 1326 | * @param array &$contact already copied fields according to the mapping |
1329 | 1327 | * @param array $data eGW contact data |
1330 | 1328 | */ |
1331 | - function _mozillaabpersonalpha2egw(&$contact,$data) |
|
1329 | + function _mozillaabpersonalpha2egw(&$contact, $data) |
|
1332 | 1330 | { |
1333 | 1331 | if ($data['c']) |
1334 | 1332 | { |
1335 | - $contact['adr_one_countryname'] = ExecMethod('phpgwapi.country.get_full_name',$data['c'][0]); |
|
1333 | + $contact['adr_one_countryname'] = ExecMethod('phpgwapi.country.get_full_name', $data['c'][0]); |
|
1336 | 1334 | } |
1337 | 1335 | } |
1338 | 1336 | |
@@ -1346,7 +1344,7 @@ discard block |
||
1346 | 1344 | * @param array $data eGW contact data |
1347 | 1345 | * @param boolean $isUpdate |
1348 | 1346 | */ |
1349 | - function _egw2mozillaabpersonalpha(&$ldapContact,$data,$isUpdate) |
|
1347 | + function _egw2mozillaabpersonalpha(&$ldapContact, $data, $isUpdate) |
|
1350 | 1348 | { |
1351 | 1349 | if ($data['adr_one_countrycode']) |
1352 | 1350 | { |
@@ -1354,7 +1352,7 @@ discard block |
||
1354 | 1352 | } |
1355 | 1353 | elseif ($data['adr_one_countryname']) |
1356 | 1354 | { |
1357 | - $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code',$data['adr_one_countryname']); |
|
1355 | + $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code', $data['adr_one_countryname']); |
|
1358 | 1356 | if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) // Bad countryname when "custom" selected! |
1359 | 1357 | { |
1360 | 1358 | $ldapContact['c'] = array(); // should return error... |
@@ -1375,9 +1373,9 @@ discard block |
||
1375 | 1373 | * @param array &$contact already copied fields according to the mapping |
1376 | 1374 | * @param array $data eGW contact data |
1377 | 1375 | */ |
1378 | - function _mozillaorgperson2egw(&$contact,$data) |
|
1376 | + function _mozillaorgperson2egw(&$contact, $data) |
|
1379 | 1377 | { |
1380 | - unset($contact, $data); // not used, but required by function signature |
|
1378 | + unset($contact, $data); // not used, but required by function signature |
|
1381 | 1379 | // no special handling necessary, as it supports two distinct attributes: c, cn |
1382 | 1380 | } |
1383 | 1381 | |
@@ -1391,7 +1389,7 @@ discard block |
||
1391 | 1389 | * @param array $data eGW contact data |
1392 | 1390 | * @param boolean $isUpdate |
1393 | 1391 | */ |
1394 | - function _egw2mozillaorgperson(&$ldapContact,$data,$isUpdate) |
|
1392 | + function _egw2mozillaorgperson(&$ldapContact, $data, $isUpdate) |
|
1395 | 1393 | { |
1396 | 1394 | if ($data['adr_one_countrycode']) |
1397 | 1395 | { |
@@ -1400,7 +1398,7 @@ discard block |
||
1400 | 1398 | } |
1401 | 1399 | elseif ($data['adr_one_countryname']) |
1402 | 1400 | { |
1403 | - $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code',$data['adr_one_countryname']); |
|
1401 | + $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code', $data['adr_one_countryname']); |
|
1404 | 1402 | if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) // Bad countryname when "custom" selected! |
1405 | 1403 | { |
1406 | 1404 | $ldapContact['c'] = array(); // should return error... |
@@ -1419,7 +1417,7 @@ discard block |
||
1419 | 1417 | * @param int $account_id account-id of the old owner |
1420 | 1418 | * @param int $new_owner account-id of the new owner |
1421 | 1419 | */ |
1422 | - function change_owner($account_id,$new_owner) |
|
1420 | + function change_owner($account_id, $new_owner) |
|
1423 | 1421 | { |
1424 | 1422 | error_log("so_ldap::change_owner($account_id,$new_owner) not yet implemented"); |
1425 | 1423 | } |
@@ -327,9 +327,12 @@ discard block |
||
327 | 327 | $this->ds = Api\Ldap::factory(); |
328 | 328 | } |
329 | 329 | // if ldap is NOT the contact repository, we only do accounts and need to use the account-data |
330 | - elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap') // not (ldap or sql-ldap) |
|
330 | + elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap') |
|
331 | + { |
|
332 | + // not (ldap or sql-ldap) |
|
331 | 333 | { |
332 | 334 | $this->ldap_config['ldap_contact_host'] = $this->ldap_config['ldap_host']; |
335 | + } |
|
333 | 336 | $this->allContactsDN = $this->ldap_config['ldap_context']; |
334 | 337 | $this->ds = Api\Ldap::factory(); |
335 | 338 | } |
@@ -413,7 +416,10 @@ discard block |
||
413 | 416 | } |
414 | 417 | else |
415 | 418 | { |
416 | - if (is_array($contact_id)) $contact_id = isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid']; |
|
419 | + if (is_array($contact_id)) |
|
420 | + { |
|
421 | + $contact_id = isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid']; |
|
422 | + } |
|
417 | 423 | $filter = $this->id_filter($contact_id); |
418 | 424 | } |
419 | 425 | $rows = $this->_searchLDAP($this->allContactsDN, |
@@ -517,7 +523,10 @@ discard block |
||
517 | 523 | // add for all supported objectclasses the objectclass and it's attributes |
518 | 524 | foreach($this->schema2egw as $objectclass => $mapping) |
519 | 525 | { |
520 | - if(!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue; |
|
526 | + if(!$this->ldapServerInfo->supportsObjectClass($objectclass)) |
|
527 | + { |
|
528 | + continue; |
|
529 | + } |
|
521 | 530 | |
522 | 531 | if($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses)) |
523 | 532 | { |
@@ -535,7 +544,10 @@ discard block |
||
535 | 544 | } |
536 | 545 | foreach($mapping as $egwFieldName => $ldapFieldName) |
537 | 546 | { |
538 | - if (is_int($egwFieldName)) continue; |
|
547 | + if (is_int($egwFieldName)) |
|
548 | + { |
|
549 | + continue; |
|
550 | + } |
|
539 | 551 | if(!empty($data[$egwFieldName])) |
540 | 552 | { |
541 | 553 | // dont convert the (binary) jpegPhoto! |
@@ -671,7 +683,10 @@ discard block |
||
671 | 683 | function delete($keys=null) |
672 | 684 | { |
673 | 685 | // single entry |
674 | - if($keys[$this->contacts_id]) $keys = array( 0 => $keys); |
|
686 | + if($keys[$this->contacts_id]) |
|
687 | + { |
|
688 | + $keys = array( 0 => $keys); |
|
689 | + } |
|
675 | 690 | |
676 | 691 | if(!is_array($keys)) |
677 | 692 | { |
@@ -760,7 +775,10 @@ discard block |
||
760 | 775 | |
761 | 776 | if((int)$filter['owner']) |
762 | 777 | { |
763 | - if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false; |
|
778 | + if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) |
|
779 | + { |
|
780 | + return false; |
|
781 | + } |
|
764 | 782 | |
765 | 783 | $searchDN = 'cn='. Api\Ldap::quote(strtolower($accountName)) .','; |
766 | 784 | |
@@ -856,7 +874,10 @@ discard block |
||
856 | 874 | $sort = 'ASC'; |
857 | 875 | foreach(explode(',',$order_by) as $o) |
858 | 876 | { |
859 | - if (substr($o,0,8) == 'contact_') $o = substr($o,8); |
|
877 | + if (substr($o,0,8) == 'contact_') |
|
878 | + { |
|
879 | + $o = substr($o,8); |
|
880 | + } |
|
860 | 881 | if (substr($o,-4) == ' ASC') |
861 | 882 | { |
862 | 883 | $sort = 'ASC'; |
@@ -898,12 +919,18 @@ discard block |
||
898 | 919 | */ |
899 | 920 | function _colFilter($filter) |
900 | 921 | { |
901 | - if (!is_array($filter)) return ''; |
|
922 | + if (!is_array($filter)) |
|
923 | + { |
|
924 | + return ''; |
|
925 | + } |
|
902 | 926 | |
903 | 927 | $filters = ''; |
904 | 928 | foreach($filter as $key => $value) |
905 | 929 | { |
906 | - if ($key != 'cat_id' && $key != 'account_id' && !$value) continue; |
|
930 | + if ($key != 'cat_id' && $key != 'account_id' && !$value) |
|
931 | + { |
|
932 | + continue; |
|
933 | + } |
|
907 | 934 | |
908 | 935 | switch((string) $key) |
909 | 936 | { |
@@ -935,19 +962,28 @@ discard block |
||
935 | 962 | $GLOBALS['egw']->categories = new Api\Categories(); |
936 | 963 | } |
937 | 964 | $cats = $GLOBALS['egw']->categories->return_all_children((int)$value); |
938 | - if (count($cats) > 1) $filters .= '(|'; |
|
965 | + if (count($cats) > 1) |
|
966 | + { |
|
967 | + $filters .= '(|'; |
|
968 | + } |
|
939 | 969 | foreach($cats as $cat) |
940 | 970 | { |
941 | 971 | $catName = Api\Translation::convert( |
942 | 972 | $GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8'); |
943 | 973 | $filters .= '(category='.Api\Ldap::quote($catName).')'; |
944 | 974 | } |
945 | - if (count($cats) > 1) $filters .= ')'; |
|
975 | + if (count($cats) > 1) |
|
976 | + { |
|
977 | + $filters .= ')'; |
|
978 | + } |
|
946 | 979 | } |
947 | 980 | break; |
948 | 981 | |
949 | 982 | case 'carddav_name': |
950 | - if (!is_array($value)) $value = array($value); |
|
983 | + if (!is_array($value)) |
|
984 | + { |
|
985 | + $value = array($value); |
|
986 | + } |
|
951 | 987 | foreach($value as &$v) |
952 | 988 | { |
953 | 989 | $v = basename($v, '.vcf'); |
@@ -977,7 +1013,10 @@ discard block |
||
977 | 1013 | elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/",$value,$matches)) |
978 | 1014 | { |
979 | 1015 | list(,$name,$value) = $matches; |
980 | - if (strpos($name,'.') !== false) list(,$name) = explode('.',$name); |
|
1016 | + if (strpos($name,'.') !== false) |
|
1017 | + { |
|
1018 | + list(,$name) = explode('.',$name); |
|
1019 | + } |
|
981 | 1020 | foreach($this->schema2egw as $mapping) |
982 | 1021 | { |
983 | 1022 | if (isset($mapping[$name])) |
@@ -1028,13 +1067,20 @@ discard block |
||
1028 | 1067 | { |
1029 | 1068 | $result = @ldap_list($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit); |
1030 | 1069 | } |
1031 | - if(!$result || !$entries = ldap_get_entries($this->ds, $result)) return array(); |
|
1070 | + if(!$result || !$entries = ldap_get_entries($this->ds, $result)) |
|
1071 | + { |
|
1072 | + return array(); |
|
1073 | + } |
|
1032 | 1074 | //error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype) result of $entries[count]"); |
1033 | 1075 | |
1034 | 1076 | $this->total = $entries['count']; |
1035 | 1077 | foreach($entries as $i => $entry) |
1036 | 1078 | { |
1037 | - if (!is_int($i)) continue; // eg. count |
|
1079 | + if (!is_int($i)) |
|
1080 | + { |
|
1081 | + continue; |
|
1082 | + } |
|
1083 | + // eg. count |
|
1038 | 1084 | |
1039 | 1085 | $contact = array( |
1040 | 1086 | 'id' => $entry['uid'][0] ? $entry['uid'][0] : $entry['entryuuid'][0], |
@@ -1254,11 +1300,17 @@ discard block |
||
1254 | 1300 | $contact['cat_id'] = array(); |
1255 | 1301 | foreach($data['category'] as $iii => $cat) |
1256 | 1302 | { |
1257 | - if (!is_int($iii)) continue; |
|
1303 | + if (!is_int($iii)) |
|
1304 | + { |
|
1305 | + continue; |
|
1306 | + } |
|
1258 | 1307 | |
1259 | 1308 | $contact['cat_id'][] = $GLOBALS['egw']->categories->name2id($cat); |
1260 | 1309 | } |
1261 | - if ($contact['cat_id']) $contact['cat_id'] = implode(',',$contact['cat_id']); |
|
1310 | + if ($contact['cat_id']) |
|
1311 | + { |
|
1312 | + $contact['cat_id'] = implode(',',$contact['cat_id']); |
|
1313 | + } |
|
1262 | 1314 | } |
1263 | 1315 | if ($data['primaryphone']) |
1264 | 1316 | { |
@@ -1313,7 +1365,10 @@ discard block |
||
1313 | 1365 | { |
1314 | 1366 | unset($contact); // not used, but required by function signature |
1315 | 1367 | static $shadowExpireNow=null; |
1316 | - if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time()-date('Z'))/86400); |
|
1368 | + if (!isset($shadowExpireNow)) |
|
1369 | + { |
|
1370 | + $shadowExpireNow = floor((time()-date('Z'))/86400); |
|
1371 | + } |
|
1317 | 1372 | |
1318 | 1373 | // exclude expired or deactivated accounts |
1319 | 1374 | if (isset($data['shadowexpire']) && $data['shadowexpire'][0] <= $shadowExpireNow) |
@@ -1358,9 +1413,13 @@ discard block |
||
1358 | 1413 | elseif ($data['adr_one_countryname']) |
1359 | 1414 | { |
1360 | 1415 | $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code',$data['adr_one_countryname']); |
1361 | - if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) // Bad countryname when "custom" selected! |
|
1416 | + if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) |
|
1417 | + { |
|
1418 | + // Bad countryname when "custom" selected! |
|
1362 | 1419 | { |
1363 | - $ldapContact['c'] = array(); // should return error... |
|
1420 | + $ldapContact['c'] = array(); |
|
1421 | + } |
|
1422 | + // should return error... |
|
1364 | 1423 | } |
1365 | 1424 | } |
1366 | 1425 | elseif ($isUpdate) |
@@ -1399,14 +1458,21 @@ discard block |
||
1399 | 1458 | if ($data['adr_one_countrycode']) |
1400 | 1459 | { |
1401 | 1460 | $ldapContact['c'] = $data['adr_one_countrycode']; |
1402 | - if ($isUpdate) $ldapContact['co'] = array(); |
|
1461 | + if ($isUpdate) |
|
1462 | + { |
|
1463 | + $ldapContact['co'] = array(); |
|
1464 | + } |
|
1403 | 1465 | } |
1404 | 1466 | elseif ($data['adr_one_countryname']) |
1405 | 1467 | { |
1406 | 1468 | $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code',$data['adr_one_countryname']); |
1407 | - if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) // Bad countryname when "custom" selected! |
|
1469 | + if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) |
|
1408 | 1470 | { |
1409 | - $ldapContact['c'] = array(); // should return error... |
|
1471 | + // Bad countryname when "custom" selected! |
|
1472 | + { |
|
1473 | + $ldapContact['c'] = array(); |
|
1474 | + } |
|
1475 | + // should return error... |
|
1410 | 1476 | } |
1411 | 1477 | } |
1412 | 1478 | elseif ($isUpdate) |
@@ -196,9 +196,6 @@ |
||
196 | 196 | * import a vard into addressbook |
197 | 197 | * |
198 | 198 | * @return int contact id |
199 | - * @param string $_vcard the vcard |
|
200 | - * @param int/string $_abID=null the internal addressbook id or !$_abID for a new enty |
|
201 | - * @param boolean $merge=false merge data with existing entry |
|
202 | 199 | */ |
203 | 200 | function addSIF($_sifdata, $_abID=null, $merge=false) |
204 | 201 | { |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * import a vard into addressbook |
|
197 | - * |
|
198 | - * @return int contact id |
|
199 | - * @param string $_vcard the vcard |
|
200 | - * @param int/string $_abID=null the internal addressbook id or !$_abID for a new enty |
|
201 | - * @param boolean $merge=false merge data with existing entry |
|
202 | - */ |
|
196 | + * import a vard into addressbook |
|
197 | + * |
|
198 | + * @return int contact id |
|
199 | + * @param string $_vcard the vcard |
|
200 | + * @param int/string $_abID=null the internal addressbook id or !$_abID for a new enty |
|
201 | + * @param boolean $merge=false merge data with existing entry |
|
202 | + */ |
|
203 | 203 | function addSIF($_sifdata, $_abID=null, $merge=false) |
204 | 204 | { |
205 | 205 | if (!$contact = $this->siftoegw($_sifdata)) |
@@ -242,21 +242,21 @@ discard block |
||
242 | 242 | $contact['id'] = $_abID; |
243 | 243 | } |
244 | 244 | else |
245 | - { |
|
246 | - if (is_array($contact['cat_id'])) |
|
245 | + { |
|
246 | + if (is_array($contact['cat_id'])) |
|
247 | 247 | { |
248 | 248 | $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); |
249 | 249 | } |
250 | - } |
|
250 | + } |
|
251 | 251 | return $this->save($contact); |
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * return a sifc |
|
256 | - * |
|
257 | - * @param int $_id the id of the contact |
|
258 | - * @return string containing the vcard |
|
259 | - */ |
|
255 | + * return a sifc |
|
256 | + * |
|
257 | + * @param int $_id the id of the contact |
|
258 | + * @return string containing the vcard |
|
259 | + */ |
|
260 | 260 | function getSIF($_id) |
261 | 261 | { |
262 | 262 | $sysCharSet = $GLOBALS['egw']->translation->charset(); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | break; |
158 | 158 | |
159 | 159 | case 'private': |
160 | - $finalContact[$key] = (int) ($value > 0); // eGW private is 0 (public) or 1 (private), SIF seems to use 0 and 2 |
|
160 | + $finalContact[$key] = (int)($value > 0); // eGW private is 0 (public) or 1 (private), SIF seems to use 0 and 2 |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | default: |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string $_sifdata |
178 | 178 | * @return array of matching contact-ids |
179 | 179 | */ |
180 | - function search($_sifdata, $contentID=null, $relax=false) |
|
180 | + function search($_sifdata, $contentID = null, $relax = false) |
|
181 | 181 | { |
182 | 182 | $result = array(); |
183 | 183 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param int/string $_abID=null the internal addressbook id or !$_abID for a new enty |
201 | 201 | * @param boolean $merge=false merge data with existing entry |
202 | 202 | */ |
203 | - function addSIF($_sifdata, $_abID=null, $merge=false) |
|
203 | + function addSIF($_sifdata, $_abID = null, $merge = false) |
|
204 | 204 | { |
205 | 205 | if (!$contact = $this->siftoegw($_sifdata)) |
206 | 206 | { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | if (is_array($contact['cat_id'])) |
231 | 231 | { |
232 | - $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID)); |
|
232 | + $contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], $_abID)); |
|
233 | 233 | } |
234 | 234 | else |
235 | 235 | { |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | if (is_array($contact['cat_id'])) |
247 | 247 | { |
248 | - $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); |
|
248 | + $contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], -1)); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | return $this->save($contact); |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | */ |
260 | 260 | function getSIF($_id) |
261 | 261 | { |
262 | - $sysCharSet = $GLOBALS['egw']->translation->charset(); |
|
262 | + $sysCharSet = $GLOBALS['egw']->translation->charset(); |
|
263 | 263 | |
264 | 264 | $fields = array_unique(array_values($this->sifMapping)); |
265 | 265 | sort($fields); |
266 | 266 | |
267 | 267 | if (!($entry = $this->read($_id))) return false; |
268 | 268 | |
269 | - $sifContact = self::xml_decl . "\n<contact>" . self::SIF_decl; |
|
269 | + $sifContact = self::xml_decl."\n<contact>".self::SIF_decl; |
|
270 | 270 | |
271 | 271 | #error_log(print_r($entry,true)); |
272 | 272 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | switch ($sifField) |
286 | 286 | { |
287 | 287 | case 'Sensitivity': |
288 | - $value = 2 * $value; // eGW private is 0 (public) or 1 (private) |
|
288 | + $value = 2 * $value; // eGW private is 0 (public) or 1 (private) |
|
289 | 289 | $sifContact .= "<$sifField>$value</$sifField>"; |
290 | 290 | break; |
291 | 291 |
@@ -146,7 +146,8 @@ discard block |
||
146 | 146 | { |
147 | 147 | $value = preg_replace('/<\!\[CDATA\[(.+)\]\]>/Usim', '$1', $value); |
148 | 148 | $value = $GLOBALS['egw']->translation->convert($value, 'utf-8'); |
149 | - switch ($key) { |
|
149 | + switch ($key) |
|
150 | + { |
|
150 | 151 | case 'cat_id': |
151 | 152 | if (!empty($value)) |
152 | 153 | { |
@@ -242,9 +243,9 @@ discard block |
||
242 | 243 | $contact['id'] = $_abID; |
243 | 244 | } |
244 | 245 | else |
245 | - { |
|
246 | + { |
|
246 | 247 | if (is_array($contact['cat_id'])) |
247 | - { |
|
248 | + { |
|
248 | 249 | $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); |
249 | 250 | } |
250 | 251 | } |
@@ -264,7 +265,10 @@ discard block |
||
264 | 265 | $fields = array_unique(array_values($this->sifMapping)); |
265 | 266 | sort($fields); |
266 | 267 | |
267 | - if (!($entry = $this->read($_id))) return false; |
|
268 | + if (!($entry = $this->read($_id))) |
|
269 | + { |
|
270 | + return false; |
|
271 | + } |
|
268 | 272 | |
269 | 273 | $sifContact = self::xml_decl . "\n<contact>" . self::SIF_decl; |
270 | 274 | |
@@ -275,7 +279,10 @@ discard block |
||
275 | 279 | |
276 | 280 | foreach ($this->sifMapping as $sifField => $egwField) |
277 | 281 | { |
278 | - if (empty($egwField)) continue; |
|
282 | + if (empty($egwField)) |
|
283 | + { |
|
284 | + continue; |
|
285 | + } |
|
279 | 286 | |
280 | 287 | #error_log("$sifField => $egwField"); |
281 | 288 | #error_log('VALUE1: '.$entry[0][$egwField]); |
@@ -295,10 +302,13 @@ discard block |
||
295 | 302 | break; |
296 | 303 | |
297 | 304 | case 'Categories': |
298 | - if (!empty($value)) { |
|
305 | + if (!empty($value)) |
|
306 | + { |
|
299 | 307 | $value = implode(", ", $this->get_categories($value)); |
300 | 308 | $value = $GLOBALS['egw']->translation->convert($value, $sysCharSet, 'utf-8'); |
301 | - } else { |
|
309 | + } |
|
310 | + else |
|
311 | + { |
|
302 | 312 | break; |
303 | 313 | } |
304 | 314 |