@@ -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 | } |