@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'homestreet' => 'adr_two_street', |
72 | 72 | 'homefaxnumber' => 'tel_fax_home', |
73 | 73 | 'homephonenumber' => 'tel_home', |
74 | - 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
74 | + 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
75 | 75 | 'lastname' => 'n_family', |
76 | 76 | 'middlename' => 'n_middle', |
77 | 77 | 'mobilephonenumber' => 'tel_cell', |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param booelan $ab_prefix =false prefix personal, private and accounts addressbook with lang('Addressbook').' ' |
124 | 124 | * @return string|array addressbook name of array with int account_id => label pairs |
125 | 125 | */ |
126 | - private function get_addressbooks($account=null,$return_all_in_one=true, $ab_prefix=false) |
|
126 | + private function get_addressbooks($account = null, $return_all_in_one = true, $ab_prefix = false) |
|
127 | 127 | { |
128 | - static $abs=null; |
|
128 | + static $abs = null; |
|
129 | 129 | |
130 | 130 | if (!isset($abs) || !$return_all_in_one) |
131 | 131 | { |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - Api\Translation::add_app('addressbook'); // we need the addressbook translations |
|
140 | + Api\Translation::add_app('addressbook'); // we need the addressbook translations |
|
141 | 141 | |
142 | 142 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
143 | 143 | |
144 | 144 | $pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
145 | 145 | if (!is_array($pref_abs)) |
146 | 146 | { |
147 | - $pref_abs = $pref_abs ? explode(',',$pref_abs) : []; |
|
147 | + $pref_abs = $pref_abs ? explode(',', $pref_abs) : []; |
|
148 | 148 | } |
149 | 149 | foreach ($this->addressbook->get_addressbooks() as $account_id => $label) |
150 | 150 | { |
@@ -152,18 +152,17 @@ discard block |
||
152 | 152 | { |
153 | 153 | $account_id = self::PRIVATE_AB; |
154 | 154 | } |
155 | - if ($account_id && in_array($account_id,$pref_abs) || in_array('A',$pref_abs) || |
|
156 | - $account_id == 0 && in_array('U',$pref_abs) || |
|
157 | - $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
158 | - $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$pref_abs)) |
|
155 | + if ($account_id && in_array($account_id, $pref_abs) || in_array('A', $pref_abs) || |
|
156 | + $account_id == 0 && in_array('U', $pref_abs) || |
|
157 | + $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
158 | + $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $pref_abs)) |
|
159 | 159 | { |
160 | 160 | $abs[$account_id] = $label; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
165 | - $ret = is_null($account) ? $abs : |
|
166 | - ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
165 | + $ret = is_null($account) ? $abs : ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
167 | 166 | lang('Addressbook').' ' : '').$abs[$account]; |
168 | 167 | //error_log(__METHOD__."($account, $return_all_in_one, $ab_prefix) returning ".array2string($ret)); |
169 | 168 | return $ret; |
@@ -181,7 +180,7 @@ discard block |
||
181 | 180 | foreach ($this->get_addressbooks() as $account => $label) |
182 | 181 | { |
183 | 182 | $folderlist[] = array( |
184 | - 'id' => $this->backend->createID('addressbook',$account), |
|
183 | + 'id' => $this->backend->createID('addressbook', $account), |
|
185 | 184 | 'mod' => $label, |
186 | 185 | 'parent'=> '0', |
187 | 186 | ); |
@@ -279,20 +278,20 @@ discard block |
||
279 | 278 | * @param int $cutoffdate =null |
280 | 279 | * @return array |
281 | 280 | */ |
282 | - function GetMessageList($id, $cutoffdate=NULL) |
|
281 | + function GetMessageList($id, $cutoffdate = NULL) |
|
283 | 282 | { |
284 | - unset($cutoffdate); // not used, but required by function signature |
|
283 | + unset($cutoffdate); // not used, but required by function signature |
|
285 | 284 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
286 | 285 | |
287 | 286 | $type = $user = null; |
288 | - $this->backend->splitID($id,$type,$user); |
|
287 | + $this->backend->splitID($id, $type, $user); |
|
289 | 288 | $filter = array('owner' => $user); |
290 | 289 | |
291 | 290 | // handle all-in-one addressbook |
292 | 291 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
293 | 292 | $user == $GLOBALS['egw_info']['user']['account_id']) |
294 | 293 | { |
295 | - $filter['owner'] = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
294 | + $filter['owner'] = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
296 | 295 | // translate AS private AB ID to EGroupware one |
297 | 296 | if (($key = array_search(self::PRIVATE_AB, $filter['owner'])) !== false) |
298 | 297 | { |
@@ -309,10 +308,10 @@ discard block |
||
309 | 308 | |
310 | 309 | $messagelist = array(); |
311 | 310 | $criteria = null; |
312 | - if (($contacts =& $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '', |
|
313 | - false, 'AND', false,$filter))) |
|
311 | + if (($contacts = & $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '', |
|
312 | + false, 'AND', false, $filter))) |
|
314 | 313 | { |
315 | - foreach($contacts as $contact) |
|
314 | + foreach ($contacts as $contact) |
|
316 | 315 | { |
317 | 316 | $messagelist[] = $this->StatMessage($id, $contact); |
318 | 317 | } |
@@ -349,9 +348,9 @@ discard block |
||
349 | 348 | } |
350 | 349 | $emailname = isset($contact['n_given']) ? $contact['n_given'].' ' : ''; |
351 | 350 | $emailname .= isset($contact['n_middle']) ? $contact['n_middle'].' ' : ''; |
352 | - $emailname .= isset($contact['n_family']) ? $contact['n_family']: ''; |
|
351 | + $emailname .= isset($contact['n_family']) ? $contact['n_family'] : ''; |
|
353 | 352 | $message = new SyncContact(); |
354 | - foreach(self::$mapping as $key => $attr) |
|
353 | + foreach (self::$mapping as $key => $attr) |
|
355 | 354 | { |
356 | 355 | switch ($attr) |
357 | 356 | { |
@@ -364,7 +363,7 @@ discard block |
||
364 | 363 | } |
365 | 364 | else |
366 | 365 | { |
367 | - if (strlen ($contact[$attr]) > 0) |
|
366 | + if (strlen($contact[$attr]) > 0) |
|
368 | 367 | { |
369 | 368 | $message->asbody = new SyncBaseBody(); |
370 | 369 | $this->backend->note2messagenote($contact[$attr], $bodypreference, $message->asbody); |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | break; |
374 | 373 | |
375 | 374 | case 'jpegphoto': |
376 | - if (empty($contact[$attr]) && ($contact['files'] & Api\Contacts::FILES_BIT_PHOTO)) |
|
375 | + if (empty($contact[$attr]) && ($contact['files']&Api\Contacts::FILES_BIT_PHOTO)) |
|
377 | 376 | { |
378 | 377 | $contact[$attr] = file_get_contents(Api\Link::vfs_path('addressbook', $contact['id'], Api\Contacts::FILES_PHOTO)); |
379 | 378 | } |
@@ -392,14 +391,14 @@ discard block |
||
392 | 391 | |
393 | 392 | case 'cat_id': |
394 | 393 | $message->$key = array(); |
395 | - foreach($contact[$attr] ? explode(',',$contact[$attr]) : array() as $cat_id) |
|
394 | + foreach ($contact[$attr] ? explode(',', $contact[$attr]) : array() as $cat_id) |
|
396 | 395 | { |
397 | 396 | $message->categories[] = Api\Categories::id2name($cat_id); |
398 | 397 | } |
399 | 398 | // for all addressbooks in one, add addressbook name itself as category |
400 | 399 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
401 | 400 | { |
402 | - $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true); |
|
401 | + $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true); |
|
403 | 402 | } |
404 | 403 | break; |
405 | 404 | // HTC Desire needs at least one telefon number, otherwise sync of contact fails without error, |
@@ -411,7 +410,7 @@ discard block |
||
411 | 410 | case 'n_fileas': |
412 | 411 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']) |
413 | 412 | { |
414 | - $message->$key = $this->addressbook->fileas($contact,$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
413 | + $message->$key = $this->addressbook->fileas($contact, $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
415 | 414 | break; |
416 | 415 | } |
417 | 416 | // fall through |
@@ -437,7 +436,7 @@ discard block |
||
437 | 436 | */ |
438 | 437 | public function StatMessage($folderid, $contact) |
439 | 438 | { |
440 | - unset($folderid); // not used (contact_id is global), but required by function signaure |
|
439 | + unset($folderid); // not used (contact_id is global), but required by function signaure |
|
441 | 440 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
442 | 441 | |
443 | 442 | if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
@@ -472,7 +471,7 @@ discard block |
||
472 | 471 | */ |
473 | 472 | public function ChangeFolder($id, $oldid, $displayname, $type) |
474 | 473 | { |
475 | - unset($id, $oldid, $displayname, $type); // not used, but required by function signature |
|
474 | + unset($id, $oldid, $displayname, $type); // not used, but required by function signature |
|
476 | 475 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." not implemented"); |
477 | 476 | } |
478 | 477 | |
@@ -511,7 +510,7 @@ discard block |
||
511 | 510 | */ |
512 | 511 | public function ChangeMessage($folderid, $id, $message, $contentParameters) |
513 | 512 | { |
514 | - unset($contentParameters); // not used, but required by function signature |
|
513 | + unset($contentParameters); // not used, but required by function signature |
|
515 | 514 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
516 | 515 | |
517 | 516 | $type = $account = null; |
@@ -532,10 +531,10 @@ discard block |
||
532 | 531 | if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts |
533 | 532 | { |
534 | 533 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Changing of Api\Accounts denied!"); |
535 | - return false; //no changing of Api\Accounts |
|
534 | + return false; //no changing of Api\Accounts |
|
536 | 535 | } |
537 | 536 | $contact = array(); |
538 | - if (empty($id) && ($this->addressbook->grants[$account] & Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) |
|
537 | + if (empty($id) && ($this->addressbook->grants[$account]&Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) |
|
539 | 538 | { |
540 | 539 | // remove all fields supported by AS, leaving all unsupported fields unchanged |
541 | 540 | $contact = array_diff_key($contact, array_flip(self::$mapping)); |
@@ -548,7 +547,7 @@ discard block |
||
548 | 547 | break; |
549 | 548 | |
550 | 549 | case 'bday': // zpush uses timestamp in servertime |
551 | - $contact[$attr] = $message->$key ? date('Y-m-d',$message->$key) : null; |
|
550 | + $contact[$attr] = $message->$key ? date('Y-m-d', $message->$key) : null; |
|
552 | 551 | break; |
553 | 552 | |
554 | 553 | case 'jpegphoto': |
@@ -558,20 +557,20 @@ discard block |
||
558 | 557 | case 'cat_id': |
559 | 558 | // for existing entries in all-in-one addressbook, remove addressbook name as category |
560 | 559 | if ($contact && $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
561 | - ($k=array_search($this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true),$message->$key))) |
|
560 | + ($k = array_search($this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true), $message->$key))) |
|
562 | 561 | { |
563 | 562 | unset($message->categories[$k]); |
564 | 563 | } |
565 | 564 | if (is_array($message->$key)) |
566 | 565 | { |
567 | - $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id),'strlen')); |
|
566 | + $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id), 'strlen')); |
|
568 | 567 | } |
569 | 568 | break; |
570 | 569 | case 'email': |
571 | 570 | case 'email_home': |
572 | - if (function_exists ('imap_rfc822_parse_adrlist')) |
|
571 | + if (function_exists('imap_rfc822_parse_adrlist')) |
|
573 | 572 | { |
574 | - $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key,"")); |
|
573 | + $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key, "")); |
|
575 | 574 | if (!empty($email_array->mailbox) && $email_array->mailbox != 'INVALID_ADDRESS' && !empty($email_array->host)) |
576 | 575 | { |
577 | 576 | $contact[$attr] = $email_array->mailbox.'@'.$email_array->host; |
@@ -583,7 +582,7 @@ discard block |
||
583 | 582 | } |
584 | 583 | else |
585 | 584 | { |
586 | - ZLog::Write(LOGLEVEL_DEBUG, __METHOD__. " Warning : php-imap not available"); |
|
585 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Warning : php-imap not available"); |
|
587 | 586 | $contact[$attr] = $message->$key; |
588 | 587 | } |
589 | 588 | break; |
@@ -610,9 +609,9 @@ discard block |
||
610 | 609 | $contact['private'] = (int)$is_private; |
611 | 610 | } |
612 | 611 | // if default addressbook for new contacts is NOT synced --> use personal addressbook |
613 | - elseif($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
612 | + elseif ($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
614 | 613 | !in_array($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'], |
615 | - array_keys($this->get_addressbooks(null,false)))) |
|
614 | + array_keys($this->get_addressbooks(null, false)))) |
|
616 | 615 | { |
617 | 616 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
618 | 617 | } |
@@ -644,7 +643,7 @@ discard block |
||
644 | 643 | */ |
645 | 644 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
646 | 645 | { |
647 | - unset($contentParameters); // not used, but required by function signature |
|
646 | + unset($contentParameters); // not used, but required by function signature |
|
648 | 647 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
649 | 648 | { |
650 | 649 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, $newfolderid) NOT allowed for an all-in-one addressbook --> returning false"); |
@@ -671,7 +670,7 @@ discard block |
||
671 | 670 | */ |
672 | 671 | public function DeleteMessage($folderid, $id, $contentParameters) |
673 | 672 | { |
674 | - unset($contentParameters); // not used, but required by function signature |
|
673 | + unset($contentParameters); // not used, but required by function signature |
|
675 | 674 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
676 | 675 | |
677 | 676 | $ret = $this->addressbook->delete($id); |
@@ -747,16 +746,16 @@ discard block |
||
747 | 746 | } |
748 | 747 | if (in_array('A', $prefs_abs)) |
749 | 748 | { |
750 | - $owner = null; // all AB's |
|
749 | + $owner = null; // all AB's |
|
751 | 750 | } |
752 | 751 | else |
753 | 752 | { |
754 | - $owner = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
753 | + $owner = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
755 | 754 | // translate AS private AB ID to current user |
756 | 755 | if (($key = array_search(self::PRIVATE_AB, $owner)) !== false) |
757 | 756 | { |
758 | 757 | unset($owner[$key]); |
759 | - if (!in_array($GLOBALS['egw_info']['user']['account_id'],$owner)) |
|
758 | + if (!in_array($GLOBALS['egw_info']['user']['account_id'], $owner)) |
|
760 | 759 | { |
761 | 760 | $owner[] = $GLOBALS['egw_info']['user']['account_id']; |
762 | 761 | } |
@@ -769,7 +768,7 @@ discard block |
||
769 | 768 | } |
770 | 769 | $ctag = $this->addressbook->get_ctag($owner); |
771 | 770 | |
772 | - $changes = array(); // no change |
|
771 | + $changes = array(); // no change |
|
773 | 772 | //$syncstate_was = $syncstate; |
774 | 773 | |
775 | 774 | if ($ctag !== $syncstate) |
@@ -797,32 +796,32 @@ discard block |
||
797 | 796 | $range = false; |
798 | 797 | if (isset($searchquery['range']) && preg_match('/^\d+-\d+$/', $searchquery['range'])) |
799 | 798 | { |
800 | - list($start,$end) = explode('-', $searchquery['range']); |
|
801 | - $range = array($start, $end-$start+1); // array(start, num_entries) |
|
799 | + list($start, $end) = explode('-', $searchquery['range']); |
|
800 | + $range = array($start, $end - $start + 1); // array(start, num_entries) |
|
802 | 801 | } |
803 | 802 | //error_log(__METHOD__.'('.array2string($searchquery).') range='.array2string($range)); |
804 | 803 | |
805 | 804 | $items = $filter = array(); |
806 | 805 | $filter['cols_to_search'] = array('n_fn', 'n_family', 'n_given', |
807 | - 'room','org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell', |
|
806 | + 'room', 'org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell', |
|
808 | 807 | 'email', 'email_home'); |
809 | - if (($contacts =& $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter))) |
|
808 | + if (($contacts = & $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter))) |
|
810 | 809 | { |
811 | - foreach($contacts as $contact) |
|
810 | + foreach ($contacts as $contact) |
|
812 | 811 | { |
813 | 812 | //$item[SYNC_GAL_ALIAS] = $contact['contact_id']; |
814 | - $item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
813 | + $item[SYNC_GAL_LASTNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name']; |
|
815 | 814 | $item[SYNC_GAL_FIRSTNAME] = $contact['n_given']; |
816 | 815 | $item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn']; |
817 | - if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
818 | - $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
|
816 | + if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name']; |
|
817 | + $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private']; |
|
819 | 818 | //$item['nameid'] = $searchquery; |
820 | 819 | $item[SYNC_GAL_PHONE] = (string)$contact['tel_work']; |
821 | 820 | $item[SYNC_GAL_HOMEPHONE] = (string)$contact['tel_home']; |
822 | 821 | $item[SYNC_GAL_MOBILEPHONE] = (string)$contact['tel_cell']; |
823 | 822 | $item[SYNC_GAL_COMPANY] = (string)$contact['org_name']; |
824 | 823 | $item[SYNC_GAL_OFFICE] = $contact['room']; |
825 | - $item[SYNC_GAL_TITLE ] = $contact['title']; |
|
824 | + $item[SYNC_GAL_TITLE] = $contact['title']; |
|
826 | 825 | |
827 | 826 | //do not return users without email |
828 | 827 | if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue; |
@@ -830,8 +829,8 @@ discard block |
||
830 | 829 | $items[] = $item; |
831 | 830 | } |
832 | 831 | } |
833 | - $items['searchtotal']=count($items); |
|
834 | - $items['range']=$searchquery['range']; |
|
832 | + $items['searchtotal'] = count($items); |
|
833 | + $items['range'] = $searchquery['range']; |
|
835 | 834 | return $items; |
836 | 835 | } |
837 | 836 | |
@@ -853,14 +852,14 @@ discard block |
||
853 | 852 | $addressbooks = $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
854 | 853 | if ($user > 0) |
855 | 854 | { |
856 | - unset($addressbooks[$user]); // personal addressbook is allways synced |
|
855 | + unset($addressbooks[$user]); // personal addressbook is allways synced |
|
857 | 856 | if (isset($addressbooks[$user.'p'])) |
858 | 857 | { |
859 | 858 | $addressbooks[self::PRIVATE_AB] = lang('Private'); |
860 | 859 | } |
861 | 860 | } |
862 | - unset($addressbooks[$user.'p']);// private addressbook uses ID self::PRIVATE_AB |
|
863 | - $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute'))+$addressbook_bo->fileas_options(); |
|
861 | + unset($addressbooks[$user.'p']); // private addressbook uses ID self::PRIVATE_AB |
|
862 | + $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute')) + $addressbook_bo->fileas_options(); |
|
864 | 863 | } |
865 | 864 | $addressbooks += array( |
866 | 865 | 'G' => lang('Primary Group'), |
@@ -139,7 +139,10 @@ discard block |
||
139 | 139 | { |
140 | 140 | Api\Translation::add_app('addressbook'); // we need the addressbook translations |
141 | 141 | |
142 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
142 | + if (!isset($this->addressbook)) |
|
143 | + { |
|
144 | + $this->addressbook = new Api\Contacts(); |
|
145 | + } |
|
143 | 146 | |
144 | 147 | $pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
145 | 148 | if (!is_array($pref_abs)) |
@@ -282,7 +285,10 @@ discard block |
||
282 | 285 | function GetMessageList($id, $cutoffdate=NULL) |
283 | 286 | { |
284 | 287 | unset($cutoffdate); // not used, but required by function signature |
285 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
288 | + if (!isset($this->addressbook)) |
|
289 | + { |
|
290 | + $this->addressbook = new Api\Contacts(); |
|
291 | + } |
|
286 | 292 | |
287 | 293 | $type = $user = null; |
288 | 294 | $this->backend->splitID($id,$type,$user); |
@@ -333,7 +339,10 @@ discard block |
||
333 | 339 | */ |
334 | 340 | public function GetMessage($folderid, $id, $contentparameters) |
335 | 341 | { |
336 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
342 | + if (!isset($this->addressbook)) |
|
343 | + { |
|
344 | + $this->addressbook = new Api\Contacts(); |
|
345 | + } |
|
337 | 346 | |
338 | 347 | //$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
339 | 348 | //$mimesupport = $contentparameters->GetMimeSupport(); |
@@ -377,7 +386,10 @@ discard block |
||
377 | 386 | { |
378 | 387 | $contact[$attr] = file_get_contents(Api\Link::vfs_path('addressbook', $contact['id'], Api\Contacts::FILES_PHOTO)); |
379 | 388 | } |
380 | - if (!empty($contact[$attr])) $message->$key = base64_encode($contact[$attr]); |
|
389 | + if (!empty($contact[$attr])) |
|
390 | + { |
|
391 | + $message->$key = base64_encode($contact[$attr]); |
|
392 | + } |
|
381 | 393 | break; |
382 | 394 | |
383 | 395 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
@@ -416,7 +428,10 @@ discard block |
||
416 | 428 | } |
417 | 429 | // fall through |
418 | 430 | default: |
419 | - if (!empty($contact[$attr])) $message->$key = $contact[$attr]; |
|
431 | + if (!empty($contact[$attr])) |
|
432 | + { |
|
433 | + $message->$key = $contact[$attr]; |
|
434 | + } |
|
420 | 435 | } |
421 | 436 | } |
422 | 437 | //error_log(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message)); |
@@ -438,9 +453,15 @@ discard block |
||
438 | 453 | public function StatMessage($folderid, $contact) |
439 | 454 | { |
440 | 455 | unset($folderid); // not used (contact_id is global), but required by function signaure |
441 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
456 | + if (!isset($this->addressbook)) |
|
457 | + { |
|
458 | + $this->addressbook = new Api\Contacts(); |
|
459 | + } |
|
442 | 460 | |
443 | - if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
|
461 | + if (!is_array($contact)) |
|
462 | + { |
|
463 | + $contact = $this->addressbook->read($contact); |
|
464 | + } |
|
444 | 465 | |
445 | 466 | if (!$contact) |
446 | 467 | { |
@@ -512,7 +533,10 @@ discard block |
||
512 | 533 | public function ChangeMessage($folderid, $id, $message, $contentParameters) |
513 | 534 | { |
514 | 535 | unset($contentParameters); // not used, but required by function signature |
515 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
536 | + if (!isset($this->addressbook)) |
|
537 | + { |
|
538 | + $this->addressbook = new Api\Contacts(); |
|
539 | + } |
|
516 | 540 | |
517 | 541 | $type = $account = null; |
518 | 542 | $this->backend->splitID($folderid, $type, $account); |
@@ -524,14 +548,20 @@ discard block |
||
524 | 548 | |
525 | 549 | } |
526 | 550 | // error_log(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid); |
527 | - if ($type != 'addressbook') // || !($contact = $this->addressbook->read($id))) |
|
551 | + if ($type != 'addressbook') |
|
552 | + { |
|
553 | + // || !($contact = $this->addressbook->read($id))) |
|
528 | 554 | { |
529 | 555 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Folder wrong or contact not existing"); |
556 | + } |
|
530 | 557 | return false; |
531 | 558 | } |
532 | - if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts |
|
559 | + if ($account == 0) |
|
560 | + { |
|
561 | + // as a precausion, we currently do NOT allow to change Api\Accounts |
|
533 | 562 | { |
534 | 563 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Changing of Api\Accounts denied!"); |
564 | + } |
|
535 | 565 | return false; //no changing of Api\Accounts |
536 | 566 | } |
537 | 567 | $contact = array(); |
@@ -594,7 +624,10 @@ discard block |
||
594 | 624 | } |
595 | 625 | break; |
596 | 626 | case 'title': // as ol jobtitle mapping changed in egw from role to title, do NOT overwrite title with value of role |
597 | - if ($id && $message->$key == $contact['role']) break; |
|
627 | + if ($id && $message->$key == $contact['role']) |
|
628 | + { |
|
629 | + break; |
|
630 | + } |
|
598 | 631 | // fall throught |
599 | 632 | default: |
600 | 633 | $contact[$attr] = $message->$key; |
@@ -603,7 +636,10 @@ discard block |
||
603 | 636 | } |
604 | 637 | // for all-in-one addressbook, account is meaningless and wrong! |
605 | 638 | // Api\Contacts::save() keeps the owner or sets an appropriate one if none given |
606 | - if (!isset($contact['private'])) $contact['private'] = (int)$is_private; |
|
639 | + if (!isset($contact['private'])) |
|
640 | + { |
|
641 | + $contact['private'] = (int)$is_private; |
|
642 | + } |
|
607 | 643 | if (!$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
608 | 644 | { |
609 | 645 | $contact['owner'] = $account; |
@@ -616,7 +652,10 @@ discard block |
||
616 | 652 | { |
617 | 653 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
618 | 654 | } |
619 | - if (!empty($id)) $contact['id'] = $id; |
|
655 | + if (!empty($id)) |
|
656 | + { |
|
657 | + $contact['id'] = $id; |
|
658 | + } |
|
620 | 659 | $this->addressbook->fixup_contact($contact); |
621 | 660 | $newid = $this->addressbook->save($contact); |
622 | 661 | //error_log(__METHOD__."($folderid,$id) contact=".array2string($contact)." returning ".array2string($newid)); |
@@ -672,7 +711,10 @@ discard block |
||
672 | 711 | public function DeleteMessage($folderid, $id, $contentParameters) |
673 | 712 | { |
674 | 713 | unset($contentParameters); // not used, but required by function signature |
675 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
714 | + if (!isset($this->addressbook)) |
|
715 | + { |
|
716 | + $this->addressbook = new Api\Contacts(); |
|
717 | + } |
|
676 | 718 | |
677 | 719 | $ret = $this->addressbook->delete($id); |
678 | 720 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -732,9 +774,15 @@ discard block |
||
732 | 774 | $type = $owner = null; |
733 | 775 | $this->backend->splitID($folderid, $type, $owner); |
734 | 776 | |
735 | - if ($type != 'addressbook') return false; |
|
777 | + if ($type != 'addressbook') |
|
778 | + { |
|
779 | + return false; |
|
780 | + } |
|
736 | 781 | |
737 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
782 | + if (!isset($this->addressbook)) |
|
783 | + { |
|
784 | + $this->addressbook = new Api\Contacts(); |
|
785 | + } |
|
738 | 786 | |
739 | 787 | // handle all-in-one addressbook |
740 | 788 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
@@ -790,7 +838,10 @@ discard block |
||
790 | 838 | */ |
791 | 839 | function getSearchResultsGAL($searchquery) |
792 | 840 | { |
793 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
841 | + if (!isset($this->addressbook)) |
|
842 | + { |
|
843 | + $this->addressbook = new Api\Contacts(); |
|
844 | + } |
|
794 | 845 | //error_log(__METHOD__.'('.array2string($searchquery).')'); |
795 | 846 | |
796 | 847 | // only return items in given range, eg. "0-50" |
@@ -814,7 +865,10 @@ discard block |
||
814 | 865 | $item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
815 | 866 | $item[SYNC_GAL_FIRSTNAME] = $contact['n_given']; |
816 | 867 | $item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn']; |
817 | - if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
868 | + if (!trim($item[SYNC_GAL_DISPLAYNAME])) |
|
869 | + { |
|
870 | + $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
871 | + } |
|
818 | 872 | $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
819 | 873 | //$item['nameid'] = $searchquery; |
820 | 874 | $item[SYNC_GAL_PHONE] = (string)$contact['tel_work']; |
@@ -825,7 +879,10 @@ discard block |
||
825 | 879 | $item[SYNC_GAL_TITLE ] = $contact['title']; |
826 | 880 | |
827 | 881 | //do not return users without email |
828 | - if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue; |
|
882 | + if (!trim($item[SYNC_GAL_EMAILADDRESS])) |
|
883 | + { |
|
884 | + continue; |
|
885 | + } |
|
829 | 886 | |
830 | 887 | $items[] = $item; |
831 | 888 | } |