@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * Construtor |
141 | 141 | * |
142 | 142 | * @param array |
143 | - * @param bool|int|string $_adminConnection create admin connection if true or account_id or imap username |
|
143 | + * @param boolean|string $_adminConnection create admin connection if true or account_id or imap username |
|
144 | 144 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
145 | 145 | * @return void |
146 | 146 | */ |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * Returns an array containing the names of the selected mailboxes |
565 | 565 | * |
566 | 566 | * @param string $reference base mailbox to start the search (default is current mailbox) |
567 | - * @param string $restriction_search false or 0 means return all mailboxes |
|
567 | + * @param integer $restriction_search false or 0 means return all mailboxes |
|
568 | 568 | * true or 1 return only the mailbox that contains that exact name |
569 | 569 | * 2 return all mailboxes in that hierarchy level |
570 | 570 | * @param string $returnAttributes true means return an assoc array containing mailbox names and mailbox attributes |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * Returns an array containing the names of the subscribed selected mailboxes |
649 | 649 | * |
650 | 650 | * @param string $reference base mailbox to start the search |
651 | - * @param string $restriction_search false or 0 means return all mailboxes |
|
651 | + * @param integer $restriction_search false or 0 means return all mailboxes |
|
652 | 652 | * true or 1 return only the mailbox that contains that exact name |
653 | 653 | * 2 return all mailboxes in that hierarchy level |
654 | 654 | * @param string $returnAttributes true means return an assoc array containing mailbox names and mailbox attributes |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * Returns an array containing the names of the selected unsubscribed mailboxes |
717 | 717 | * |
718 | 718 | * @param string $reference base mailbox to start the search |
719 | - * @param string $restriction_search false or 0 means return all mailboxes |
|
719 | + * @param integer $restriction_search false or 0 means return all mailboxes |
|
720 | 720 | * true or 1 return only the mailbox that contains that exact name |
721 | 721 | * 2 return all mailboxes in that hierarchy level |
722 | 722 | * |
@@ -894,6 +894,7 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @var array $_nameSpace |
896 | 896 | * @var string $_folderName |
897 | + * @param string $_folderName |
|
897 | 898 | * @return string the prefix (may be an empty string) |
898 | 899 | */ |
899 | 900 | static function getFolderPrefixFromNamespace($_nameSpace, $_folderName) |
@@ -912,7 +913,7 @@ discard block |
||
912 | 913 | * @param string $_mailbox |
913 | 914 | * @param string $delimiter |
914 | 915 | * @param string $prefix |
915 | - * @param string $reclevel = 0, counter to keep track of the current recursionlevel |
|
916 | + * @param integer $reclevel = 0, counter to keep track of the current recursionlevel |
|
916 | 917 | * @return array of mailboxes |
917 | 918 | */ |
918 | 919 | function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
@@ -1344,7 +1345,7 @@ discard block |
||
1344 | 1345 | /** |
1345 | 1346 | * Get vacation message for given user |
1346 | 1347 | * |
1347 | - * @param int|string $_euser nummeric account_id or imap username |
|
1348 | + * @param string|null $_euser nummeric account_id or imap username |
|
1348 | 1349 | * @param string $_scriptName =null |
1349 | 1350 | * @throws Exception on connection error or authentication failure |
1350 | 1351 | * @return array |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | $mailbox = ''; |
581 | 581 | if ( is_int( $restriction_search ) ){ |
582 | 582 | switch ( $restriction_search ) { |
583 | - case 0: |
|
584 | - $searchstring = $reference."*"; |
|
585 | - break; |
|
586 | - case 1: |
|
587 | - $mailbox = $searchstring = $reference; |
|
588 | - //$reference = '%'; |
|
589 | - break; |
|
590 | - case 2: |
|
591 | - $searchstring = $reference."%"; |
|
592 | - break; |
|
583 | + case 0: |
|
584 | + $searchstring = $reference."*"; |
|
585 | + break; |
|
586 | + case 1: |
|
587 | + $mailbox = $searchstring = $reference; |
|
588 | + //$reference = '%'; |
|
589 | + break; |
|
590 | + case 2: |
|
591 | + $searchstring = $reference."%"; |
|
592 | + break; |
|
593 | 593 | } |
594 | 594 | }else{ |
595 | 595 | if ( is_string( $restriction_search ) ){ |
@@ -664,16 +664,16 @@ discard block |
||
664 | 664 | $mailbox = ''; |
665 | 665 | if ( is_int( $restriction_search ) ){ |
666 | 666 | switch ( $restriction_search ) { |
667 | - case 0: |
|
668 | - $searchstring = $reference."*"; |
|
669 | - break; |
|
670 | - case 1: |
|
671 | - $mailbox = $searchstring = $reference; |
|
672 | - //$reference = '%'; |
|
673 | - break; |
|
674 | - case 2: |
|
675 | - $searchstring = $reference."%"; |
|
676 | - break; |
|
667 | + case 0: |
|
668 | + $searchstring = $reference."*"; |
|
669 | + break; |
|
670 | + case 1: |
|
671 | + $mailbox = $searchstring = $reference; |
|
672 | + //$reference = '%'; |
|
673 | + break; |
|
674 | + case 2: |
|
675 | + $searchstring = $reference."%"; |
|
676 | + break; |
|
677 | 677 | } |
678 | 678 | }else{ |
679 | 679 | if ( is_string( $restriction_search ) ){ |
@@ -730,16 +730,16 @@ discard block |
||
730 | 730 | |
731 | 731 | if ( is_int( $restriction_search ) ){ |
732 | 732 | switch ( $restriction_search ) { |
733 | - case 0: |
|
734 | - $mailbox = $reference."*"; |
|
735 | - break; |
|
736 | - case 1: |
|
737 | - $mailbox = $reference; |
|
738 | - $reference = '%'; |
|
739 | - break; |
|
740 | - case 2: |
|
741 | - $mailbox = "%"; |
|
742 | - break; |
|
733 | + case 0: |
|
734 | + $mailbox = $reference."*"; |
|
735 | + break; |
|
736 | + case 1: |
|
737 | + $mailbox = $reference; |
|
738 | + $reference = '%'; |
|
739 | + break; |
|
740 | + case 2: |
|
741 | + $mailbox = "%"; |
|
742 | + break; |
|
743 | 743 | } |
744 | 744 | }else{ |
745 | 745 | if ( is_string( $restriction_search ) ){ |
@@ -156,7 +156,10 @@ discard block |
||
156 | 156 | $this->loginType = $this->params['acc_imap_logintype']; |
157 | 157 | $this->domainName = $this->params['acc_domain']; |
158 | 158 | |
159 | - if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); |
|
159 | + if (is_null($_timeout)) |
|
160 | + { |
|
161 | + $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); |
|
162 | + } |
|
160 | 163 | |
161 | 164 | // Horde use locale for translation of error messages |
162 | 165 | // need to set LC_CTYPE for charachter classification (eg. Umlauts) |
@@ -169,7 +172,10 @@ discard block |
||
169 | 172 | { |
170 | 173 | $username = $this->getMailBoxUserName($username); |
171 | 174 | } |
172 | - if ($_adminConnection) $this->adminConnection($username); |
|
175 | + if ($_adminConnection) |
|
176 | + { |
|
177 | + $this->adminConnection($username); |
|
178 | + } |
|
173 | 179 | $parent_params = array( |
174 | 180 | 'username' => $this->params[$_adminConnection ? 'acc_imap_admin_username' : 'acc_imap_username'], |
175 | 181 | 'password' => $this->params[$_adminConnection ? 'acc_imap_admin_password' : 'acc_imap_password'], |
@@ -343,7 +349,11 @@ discard block |
||
343 | 349 | static function getTimeOut($_use='IMAP') |
344 | 350 | { |
345 | 351 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
346 | - if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value |
|
352 | + if (empty($timeout) || !($timeout > 0)) |
|
353 | + { |
|
354 | + $timeout = $_use == 'SIEVE' ? 10 : 20; |
|
355 | + } |
|
356 | + // this is the default value |
|
347 | 357 | return $timeout; |
348 | 358 | } |
349 | 359 | |
@@ -406,7 +416,8 @@ discard block |
||
406 | 416 | */ |
407 | 417 | function encodeFolderName($_folderName) |
408 | 418 | { |
409 | - if($this->mbAvailable) { |
|
419 | + if($this->mbAvailable) |
|
420 | + { |
|
410 | 421 | return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset()); |
411 | 422 | } |
412 | 423 | |
@@ -424,14 +435,21 @@ discard block |
||
424 | 435 | function getMailbox($mailbox) |
425 | 436 | { |
426 | 437 | $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL); |
427 | - if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
438 | + if (empty($mailboxes)) |
|
439 | + { |
|
440 | + $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
441 | + } |
|
428 | 442 | //error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes)); |
429 | 443 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
430 | 444 | //_debug_array($mboxes->count()); |
431 | 445 | foreach ($mboxes->getIterator() as $k =>$box) |
432 | 446 | { |
433 | 447 | //error_log(__METHOD__.__LINE__.'->'.$k); |
434 | - if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k))); |
|
448 | + if ($k!='user' && $k != '' && $k==$mailbox) |
|
449 | + { |
|
450 | + return $box['mailbox']; |
|
451 | + } |
|
452 | + //_debug_array(array($k => $client->status($k))); |
|
435 | 453 | } |
436 | 454 | return ($this->mailboxExist($mailbox)?$mailbox:false); |
437 | 455 | } |
@@ -500,8 +518,14 @@ discard block |
||
500 | 518 | //throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage()); |
501 | 519 | unset($e); |
502 | 520 | } |
503 | - if (!empty($mailbox)) return $mailbox['mailbox']; |
|
504 | - if (empty($mailbox) && $this->mailboxExist('INBOX')) return 'INBOX'; |
|
521 | + if (!empty($mailbox)) |
|
522 | + { |
|
523 | + return $mailbox['mailbox']; |
|
524 | + } |
|
525 | + if (empty($mailbox) && $this->mailboxExist('INBOX')) |
|
526 | + { |
|
527 | + return 'INBOX'; |
|
528 | + } |
|
505 | 529 | return null; |
506 | 530 | } |
507 | 531 | |
@@ -571,7 +595,10 @@ discard block |
||
571 | 595 | )); |
572 | 596 | |
573 | 597 | $flags = Horde_Imap_Client::STATUS_ALL; |
574 | - if ($ignoreStatusCache) $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH; |
|
598 | + if ($ignoreStatusCache) |
|
599 | + { |
|
600 | + $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH; |
|
601 | + } |
|
575 | 602 | |
576 | 603 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
577 | 604 | //error_log(__METHOD__.__LINE__.array2string($mboxes->count())); |
@@ -614,12 +641,15 @@ discard block |
||
614 | 641 | */ |
615 | 642 | function getMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
616 | 643 | { |
617 | - if ( is_bool($restriction_search) ){ |
|
644 | + if ( is_bool($restriction_search) ) |
|
645 | + { |
|
618 | 646 | $restriction_search = (int) $restriction_search; |
619 | 647 | } |
620 | 648 | $mailbox = ''; |
621 | - if ( is_int( $restriction_search ) ){ |
|
622 | - switch ( $restriction_search ) { |
|
649 | + if ( is_int( $restriction_search ) ) |
|
650 | + { |
|
651 | + switch ( $restriction_search ) |
|
652 | + { |
|
623 | 653 | case 0: |
624 | 654 | $searchstring = $reference."*"; |
625 | 655 | break; |
@@ -631,8 +661,11 @@ discard block |
||
631 | 661 | $searchstring = $reference."%"; |
632 | 662 | break; |
633 | 663 | } |
634 | - }else{ |
|
635 | - if ( is_string( $restriction_search ) ){ |
|
664 | + } |
|
665 | + else |
|
666 | + { |
|
667 | + if ( is_string( $restriction_search ) ) |
|
668 | + { |
|
636 | 669 | $mailbox = $searchstring = $restriction_search; |
637 | 670 | } |
638 | 671 | } |
@@ -698,12 +731,15 @@ discard block |
||
698 | 731 | */ |
699 | 732 | function listSubscribedMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
700 | 733 | { |
701 | - if ( is_bool($restriction_search) ){ |
|
734 | + if ( is_bool($restriction_search) ) |
|
735 | + { |
|
702 | 736 | $restriction_search = (int) $restriction_search; |
703 | 737 | } |
704 | 738 | $mailbox = ''; |
705 | - if ( is_int( $restriction_search ) ){ |
|
706 | - switch ( $restriction_search ) { |
|
739 | + if ( is_int( $restriction_search ) ) |
|
740 | + { |
|
741 | + switch ( $restriction_search ) |
|
742 | + { |
|
707 | 743 | case 0: |
708 | 744 | $searchstring = $reference."*"; |
709 | 745 | break; |
@@ -715,8 +751,11 @@ discard block |
||
715 | 751 | $searchstring = $reference."%"; |
716 | 752 | break; |
717 | 753 | } |
718 | - }else{ |
|
719 | - if ( is_string( $restriction_search ) ){ |
|
754 | + } |
|
755 | + else |
|
756 | + { |
|
757 | + if ( is_string( $restriction_search ) ) |
|
758 | + { |
|
720 | 759 | $mailbox = $searchstring = $restriction_search; |
721 | 760 | } |
722 | 761 | } |
@@ -764,12 +803,15 @@ discard block |
||
764 | 803 | */ |
765 | 804 | function listUnSubscribedMailboxes($reference = '' , $restriction_search = 0) |
766 | 805 | { |
767 | - if ( is_bool($restriction_search) ){ |
|
806 | + if ( is_bool($restriction_search) ) |
|
807 | + { |
|
768 | 808 | $restriction_search = (int) $restriction_search; |
769 | 809 | } |
770 | 810 | |
771 | - if ( is_int( $restriction_search ) ){ |
|
772 | - switch ( $restriction_search ) { |
|
811 | + if ( is_int( $restriction_search ) ) |
|
812 | + { |
|
813 | + switch ( $restriction_search ) |
|
814 | + { |
|
773 | 815 | case 0: |
774 | 816 | $mailbox = $reference."*"; |
775 | 817 | break; |
@@ -781,8 +823,11 @@ discard block |
||
781 | 823 | $mailbox = "%"; |
782 | 824 | break; |
783 | 825 | } |
784 | - }else{ |
|
785 | - if ( is_string( $restriction_search ) ){ |
|
826 | + } |
|
827 | + else |
|
828 | + { |
|
829 | + if ( is_string( $restriction_search ) ) |
|
830 | + { |
|
786 | 831 | $mailbox = $restriction_search; |
787 | 832 | } |
788 | 833 | } |
@@ -801,7 +846,10 @@ discard block |
||
801 | 846 | foreach ($unsubscribed as $box) |
802 | 847 | { |
803 | 848 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8)); |
804 | - if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8; |
|
849 | + if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') |
|
850 | + { |
|
851 | + $ret[]=$box['mailbox']->utf8; |
|
852 | + } |
|
805 | 853 | } |
806 | 854 | return $ret; |
807 | 855 | } |
@@ -815,10 +863,16 @@ discard block |
||
815 | 863 | */ |
816 | 864 | function examineMailbox($mailbox, $flags=null) |
817 | 865 | { |
818 | - if ($mailbox=='') return false; |
|
866 | + if ($mailbox=='') |
|
867 | + { |
|
868 | + return false; |
|
869 | + } |
|
819 | 870 | $mailboxes = $this->listMailboxes($mailbox); |
820 | 871 | |
821 | - if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS; |
|
872 | + if (is_null($flags)) |
|
873 | + { |
|
874 | + $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS; |
|
875 | + } |
|
822 | 876 | |
823 | 877 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
824 | 878 | //_debug_array($mboxes->count()); |
@@ -900,7 +954,10 @@ discard block |
||
900 | 954 | } |
901 | 955 | catch (\Exception $e) |
902 | 956 | { |
903 | - if ($this->debug) error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage()); |
|
957 | + if ($this->debug) |
|
958 | + { |
|
959 | + error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage()); |
|
960 | + } |
|
904 | 961 | return false; |
905 | 962 | } |
906 | 963 | if (!is_array($cap)) |
@@ -940,7 +997,10 @@ discard block |
||
940 | 997 | { |
941 | 998 | foreach($_nameSpace as &$singleNameSpace) |
942 | 999 | { |
943 | - if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
1000 | + if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) |
|
1001 | + { |
|
1002 | + return $singleNameSpace['prefix']; |
|
1003 | + } |
|
944 | 1004 | } |
945 | 1005 | return ""; |
946 | 1006 | } |
@@ -957,7 +1017,8 @@ discard block |
||
957 | 1017 | */ |
958 | 1018 | function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
959 | 1019 | { |
960 | - if ($reclevel > 25) { |
|
1020 | + if ($reclevel > 25) |
|
1021 | + { |
|
961 | 1022 | error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
962 | 1023 | return array(); |
963 | 1024 | } |
@@ -973,7 +1034,8 @@ discard block |
||
973 | 1034 | { |
974 | 1035 | $buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
975 | 1036 | $allMailboxes = array(); |
976 | - foreach ($buff as $mbxname) { |
|
1037 | + foreach ($buff as $mbxname) |
|
1038 | + { |
|
977 | 1039 | $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
978 | 1040 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
979 | 1041 | if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
@@ -981,7 +1043,10 @@ discard block |
||
981 | 1043 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
982 | 1044 | } |
983 | 1045 | } |
984 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
1046 | + if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
1047 | + { |
|
1048 | + $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
1049 | + } |
|
985 | 1050 | return $allMailboxes; |
986 | 1051 | } |
987 | 1052 | else |
@@ -1003,9 +1068,16 @@ discard block |
||
1003 | 1068 | static $nameSpace=null; |
1004 | 1069 | $foldersNameSpace = array(); |
1005 | 1070 | $delimiter = $this->getDelimiter(); |
1006 | - if (empty($delimiter)) $delimiter='/'; |
|
1007 | - if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray(); |
|
1008 | - if (is_array($nameSpace)) { |
|
1071 | + if (empty($delimiter)) |
|
1072 | + { |
|
1073 | + $delimiter='/'; |
|
1074 | + } |
|
1075 | + if (is_null($nameSpace)) |
|
1076 | + { |
|
1077 | + $nameSpace = $this->getNameSpaceArray(); |
|
1078 | + } |
|
1079 | + if (is_array($nameSpace)) |
|
1080 | + { |
|
1009 | 1081 | foreach($nameSpace as $type => $singleNameSpaceArray) |
1010 | 1082 | { |
1011 | 1083 | foreach ($singleNameSpaceArray as $singleNameSpace) |
@@ -1022,7 +1094,9 @@ discard block |
||
1022 | 1094 | $_foldersNameSpace['prefix_present'] = 'forced'; |
1023 | 1095 | // uw-imap server with mailbox prefix or dovecot maybe |
1024 | 1096 | $_foldersNameSpace['prefix'] = 'mail'; |
1025 | - } else { |
|
1097 | + } |
|
1098 | + else |
|
1099 | + { |
|
1026 | 1100 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
1027 | 1101 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
1028 | 1102 | } |
@@ -1062,7 +1136,10 @@ discard block |
||
1062 | 1136 | $namespaces = $this->getNamespaces(); |
1063 | 1137 | foreach ($namespaces as $nsp) |
1064 | 1138 | { |
1065 | - if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter']; |
|
1139 | + if ($nsp['type']==$type && $nsp['delimiter']) |
|
1140 | + { |
|
1141 | + return $nsp['delimiter']; |
|
1142 | + } |
|
1066 | 1143 | } |
1067 | 1144 | return "/"; |
1068 | 1145 | } |
@@ -1158,12 +1235,14 @@ discard block |
||
1158 | 1235 | { |
1159 | 1236 | $nameSpaces = $this->getNameSpaceArray(); |
1160 | 1237 | |
1161 | - if(!isset($nameSpaces['others'])) { |
|
1238 | + if(!isset($nameSpaces['others'])) |
|
1239 | + { |
|
1162 | 1240 | return false; |
1163 | 1241 | } |
1164 | 1242 | |
1165 | 1243 | $username = $this->getMailBoxUserName($_username); |
1166 | - if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') { |
|
1244 | + if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') |
|
1245 | + { |
|
1167 | 1246 | $username .= '@'. $this->domainName; |
1168 | 1247 | } |
1169 | 1248 | |
@@ -1315,7 +1394,10 @@ discard block |
||
1315 | 1394 | */ |
1316 | 1395 | public function __call($name,array $params=null) |
1317 | 1396 | { |
1318 | - if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params)); |
|
1397 | + if ($this->debug) |
|
1398 | + { |
|
1399 | + error_log(__METHOD__.'->'.$name.' with params:'.array2string($params)); |
|
1400 | + } |
|
1319 | 1401 | switch($name) |
1320 | 1402 | { |
1321 | 1403 | case 'installScript': |
@@ -1350,7 +1432,10 @@ discard block |
||
1350 | 1432 | */ |
1351 | 1433 | public function setVacationUser($_euser, array $_vacation, $_scriptName=null) |
1352 | 1434 | { |
1353 | - if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation)); |
|
1435 | + if ($this->debug) |
|
1436 | + { |
|
1437 | + error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation)); |
|
1438 | + } |
|
1354 | 1439 | |
1355 | 1440 | if (is_numeric($_euser)) |
1356 | 1441 | { |
@@ -1378,7 +1463,10 @@ discard block |
||
1378 | 1463 | */ |
1379 | 1464 | public function getVacationUser($_euser, $_scriptName=null) |
1380 | 1465 | { |
1381 | - if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser)); |
|
1466 | + if ($this->debug) |
|
1467 | + { |
|
1468 | + error_log(__METHOD__.' User:'.array2string($_euser)); |
|
1469 | + } |
|
1382 | 1470 | |
1383 | 1471 | if (is_numeric($_euser)) |
1384 | 1472 | { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | static public $default_params = array( |
67 | 67 | //'debug' => '/tmp/imap.log', // uncomment to log communitcation with IMAP server |
68 | 68 | //'debug_literal' => true, // uncomment to log mail contents returned by IMAP server |
69 | - 'cache' => true, // default caching via Cache / Api\Cache |
|
69 | + 'cache' => true, // default caching via Cache / Api\Cache |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - function __construct(array $params, $_adminConnection=false, $_timeout=null) |
|
147 | + function __construct(array $params, $_adminConnection = false, $_timeout = null) |
|
148 | 148 | { |
149 | 149 | if (function_exists('mb_convert_encoding')) |
150 | 150 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->loginType = $this->params['acc_imap_logintype']; |
157 | 157 | $this->domainName = $this->params['acc_domain']; |
158 | 158 | |
159 | - if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); |
|
159 | + if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout'] ? $this->params['acc_imap_timeout'] : self::getTimeOut(); |
|
160 | 160 | |
161 | 161 | // Horde use locale for translation of error messages |
162 | 162 | // need to set LC_CTYPE for charachter classification (eg. Umlauts) |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | 'port' => $this->params['acc_imap_port'], |
178 | 178 | 'secure' => Account::ssl2secure($this->params['acc_imap_ssl']), |
179 | 179 | 'timeout' => $_timeout, |
180 | - )+self::$default_params; |
|
180 | + ) + self::$default_params; |
|
181 | 181 | |
182 | 182 | if ($parent_params['cache'] === true) |
183 | 183 | { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | // as we have no way to tell this apart we ignore BINARY this affects |
202 | 202 | // Horde_Imap_Client_Fetch_Query::bodyPart for its fetch parameter decode=true is ignored |
203 | 203 | // (other functionality depending on BINARY is, of cause, affected too) |
204 | - $parent_params['capability_ignore']= array_merge((array)$parent_params['capability_ignore'],array('BINARY')); |
|
204 | + $parent_params['capability_ignore'] = array_merge((array)$parent_params['capability_ignore'], array('BINARY')); |
|
205 | 205 | break; |
206 | 206 | } |
207 | 207 | parent::__construct($parent_params); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @param string $_username =true create an admin connection for given user or $this->acc_imap_username |
216 | 216 | */ |
217 | - function adminConnection($_username=true) |
|
217 | + function adminConnection($_username = true) |
|
218 | 218 | { |
219 | 219 | if ($this->isAdminConnection !== $_username) |
220 | 220 | { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $_username =null create an admin connection for given user or $this->acc_imap_username |
232 | 232 | * @throws Horde_IMAP_Client_Exception |
233 | 233 | */ |
234 | - public function checkAdminConnection($_username=true) |
|
234 | + public function checkAdminConnection($_username = true) |
|
235 | 235 | { |
236 | 236 | if ($this->acc_imap_administration) |
237 | 237 | { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function __get($name) |
250 | 250 | { |
251 | - switch($name) |
|
251 | + switch ($name) |
|
252 | 252 | { |
253 | 253 | case 'acc_imap_administration': |
254 | 254 | return !empty($this->params['acc_imap_admin_username']); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | { |
267 | 267 | return $this->$name; |
268 | 268 | } |
269 | - if (array_key_exists($name,$this->params)) |
|
269 | + if (array_key_exists($name, $this->params)) |
|
270 | 270 | { |
271 | 271 | return $this->params[$name]; |
272 | 272 | } |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | * @deprecated allready called by constructor automatic, parameters must be passed to constructor! |
288 | 288 | * @throws Api\Exception\WrongParameter |
289 | 289 | */ |
290 | - function openConnection($_adminConnection=false, $_timeout=null) |
|
290 | + function openConnection($_adminConnection = false, $_timeout = null) |
|
291 | 291 | { |
292 | - unset($_timeout); // not used |
|
292 | + unset($_timeout); // not used |
|
293 | 293 | if ($_adminConnection !== $this->params['adminConnection']) |
294 | 294 | { |
295 | 295 | throw new Api\Exception\WrongParameter('need to set parameters on calling Account->imapServer()!'); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string _use decide if the use is for IMAP or SIEVE, by now only the default differs |
303 | 303 | * @return int - timeout (either set or default 20/10) |
304 | 304 | */ |
305 | - static function getTimeOut($_use='IMAP') |
|
305 | + static function getTimeOut($_use = 'IMAP') |
|
306 | 306 | { |
307 | 307 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
308 | 308 | if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | function addAccount($_hookValues) |
329 | 329 | { |
330 | - unset($_hookValues); // not used |
|
330 | + unset($_hookValues); // not used |
|
331 | 331 | return true; |
332 | 332 | } |
333 | 333 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | function updateAccount($_hookValues) |
341 | 341 | { |
342 | - unset($_hookValues); // not used |
|
342 | + unset($_hookValues); // not used |
|
343 | 343 | return true; |
344 | 344 | } |
345 | 345 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function deleteAccount($_hookValues) |
353 | 353 | { |
354 | - unset($_hookValues); // not used |
|
354 | + unset($_hookValues); // not used |
|
355 | 355 | return true; |
356 | 356 | } |
357 | 357 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | function encodeFolderName($_folderName) |
370 | 370 | { |
371 | - if($this->mbAvailable) { |
|
371 | + if ($this->mbAvailable) { |
|
372 | 372 | return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset()); |
373 | 373 | } |
374 | 374 | |
@@ -385,17 +385,17 @@ discard block |
||
385 | 385 | */ |
386 | 386 | function getMailbox($mailbox) |
387 | 387 | { |
388 | - $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL); |
|
389 | - if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
388 | + $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL); |
|
389 | + if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
390 | 390 | //error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes)); |
391 | 391 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
392 | 392 | //_debug_array($mboxes->count()); |
393 | 393 | foreach ($mboxes->getIterator() as $k =>$box) |
394 | 394 | { |
395 | 395 | //error_log(__METHOD__.__LINE__.'->'.$k); |
396 | - if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k))); |
|
396 | + if ($k != 'user' && $k != '' && $k == $mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k))); |
|
397 | 397 | } |
398 | - return ($this->mailboxExist($mailbox)?$mailbox:false); |
|
398 | + return ($this->mailboxExist($mailbox) ? $mailbox : false); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -411,23 +411,23 @@ discard block |
||
411 | 411 | //error_log(__METHOD__.__LINE__.':'.$mailbox); |
412 | 412 | $currentMailbox = $this->currentMailbox(); |
413 | 413 | } |
414 | - catch(\Exception $e) |
|
414 | + catch (\Exception $e) |
|
415 | 415 | { |
416 | 416 | //error_log(__METHOD__.__LINE__.' failed detecting currentMailbox:'.$currentMailbox.':'.$e->getMessage()); |
417 | - $currentMailbox=null; |
|
417 | + $currentMailbox = null; |
|
418 | 418 | unset($e); |
419 | 419 | } |
420 | 420 | try |
421 | 421 | { |
422 | 422 | //error_log(__METHOD__.__LINE__.':'.$mailbox); |
423 | 423 | $this->openMailbox($mailbox); |
424 | - $returnvalue=true; |
|
424 | + $returnvalue = true; |
|
425 | 425 | } |
426 | - catch(\Exception $e) |
|
426 | + catch (\Exception $e) |
|
427 | 427 | { |
428 | 428 | //error_log(__METHOD__.__LINE__.' failed opening:'.$mailbox.':'.$e->getMessage().' Called by:'.function_backtrace()); |
429 | 429 | unset($e); |
430 | - $returnvalue=false; |
|
430 | + $returnvalue = false; |
|
431 | 431 | } |
432 | 432 | if (!empty($currentMailbox) && $currentMailbox['mailbox'] != $mailbox) |
433 | 433 | { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | //error_log(__METHOD__.__LINE__.':'.$currentMailbox .'<->'.$mailbox); |
437 | 437 | $this->openMailbox($currentMailbox['mailbox']); |
438 | 438 | } |
439 | - catch(\Exception $e) |
|
439 | + catch (\Exception $e) |
|
440 | 440 | { |
441 | 441 | //error_log(__METHOD__.__LINE__.' failed reopening:'.$currentMailbox.':'.$e->getMessage()); |
442 | 442 | unset($e); |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | { |
457 | 457 | $mailbox = $this->currentMailbox(); |
458 | 458 | } |
459 | - catch(\Exception $e) |
|
459 | + catch (\Exception $e) |
|
460 | 460 | { |
461 | 461 | error_log(__METHOD__.' ('.__LINE__.') failed fetching currentMailbox:'.$e->getMessage()); |
462 | 462 | //throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage()); |
@@ -474,16 +474,16 @@ discard block |
||
474 | 474 | */ |
475 | 475 | function getSpecialUseFolders() |
476 | 476 | { |
477 | - $mailboxes = $this->getMailboxes('',0,true); |
|
477 | + $mailboxes = $this->getMailboxes('', 0, true); |
|
478 | 478 | $suF = array(); |
479 | 479 | foreach ($mailboxes as $box) |
480 | 480 | { |
481 | - if ($box['MAILBOX']!='user' && $box['MAILBOX'] != '') |
|
481 | + if ($box['MAILBOX'] != 'user' && $box['MAILBOX'] != '') |
|
482 | 482 | { |
483 | 483 | //error_log(__METHOD__.__LINE__.$k.'->'.array2string($box)); |
484 | - if (isset($box['ATTRIBUTES'])&&!empty($box['ATTRIBUTES'])&& |
|
485 | - stripos(strtolower(array2string($box['ATTRIBUTES'])),'\noselect')=== false&& |
|
486 | - stripos(strtolower(array2string($box['ATTRIBUTES'])),'\nonexistent')=== false) |
|
484 | + if (isset($box['ATTRIBUTES']) && !empty($box['ATTRIBUTES']) && |
|
485 | + stripos(strtolower(array2string($box['ATTRIBUTES'])), '\noselect') === false && |
|
486 | + stripos(strtolower(array2string($box['ATTRIBUTES'])), '\nonexistent') === false) |
|
487 | 487 | { |
488 | 488 | $suF[$box['MAILBOX']] = $box; |
489 | 489 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $status = $this->status($mailbox); |
506 | 506 | foreach ($status as $key => $v) |
507 | 507 | { |
508 | - $_status[strtoupper($key)]=$v; |
|
508 | + $_status[strtoupper($key)] = $v; |
|
509 | 509 | } |
510 | 510 | return $_status; |
511 | 511 | } |
@@ -523,9 +523,9 @@ discard block |
||
523 | 523 | * @param ignoreStatusCache bool ignore the cache used for counters |
524 | 524 | * @return array with counters |
525 | 525 | */ |
526 | - function getStatus($mailbox, $ignoreStatusCache=false) |
|
526 | + function getStatus($mailbox, $ignoreStatusCache = false) |
|
527 | 527 | { |
528 | - $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL,array( |
|
528 | + $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL, array( |
|
529 | 529 | 'attributes'=>true, |
530 | 530 | 'children'=>true, //child info |
531 | 531 | 'delimiter'=>true, |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | //error_log(__METHOD__.__LINE__.array2string($mboxes->count())); |
540 | 540 | foreach ($mboxes->getIterator() as $k =>$box) |
541 | 541 | { |
542 | - if ($k!='user' && $k != '' && $k==$mailbox) |
|
542 | + if ($k != 'user' && $k != '' && $k == $mailbox) |
|
543 | 543 | { |
544 | - if (stripos(array2string($box['attributes']),'\noselect')=== false) |
|
544 | + if (stripos(array2string($box['attributes']), '\noselect') === false) |
|
545 | 545 | { |
546 | 546 | $status = $this->status($k, $flags); |
547 | 547 | foreach ($status as $key => $v) |
548 | 548 | { |
549 | - $_status[strtoupper($key)]=$v; |
|
549 | + $_status[strtoupper($key)] = $v; |
|
550 | 550 | } |
551 | - $_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')); |
|
551 | + $_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')); |
|
552 | 552 | $_status['ATTRIBUTES'] = $box['attributes']; |
553 | 553 | //error_log(__METHOD__.__LINE__.$k.'->'.array2string($_status)); |
554 | 554 | return $_status; |
@@ -574,14 +574,14 @@ discard block |
||
574 | 574 | * |
575 | 575 | * @return mixed array of mailboxes |
576 | 576 | */ |
577 | - function getMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
|
577 | + function getMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false) |
|
578 | 578 | { |
579 | - if ( is_bool($restriction_search) ){ |
|
580 | - $restriction_search = (int) $restriction_search; |
|
579 | + if (is_bool($restriction_search)) { |
|
580 | + $restriction_search = (int)$restriction_search; |
|
581 | 581 | } |
582 | 582 | $mailbox = ''; |
583 | - if ( is_int( $restriction_search ) ){ |
|
584 | - switch ( $restriction_search ) { |
|
583 | + if (is_int($restriction_search)) { |
|
584 | + switch ($restriction_search) { |
|
585 | 585 | case 0: |
586 | 586 | $searchstring = $reference."*"; |
587 | 587 | break; |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | $searchstring = $reference."%"; |
594 | 594 | break; |
595 | 595 | } |
596 | - }else{ |
|
597 | - if ( is_string( $restriction_search ) ){ |
|
596 | + } else { |
|
597 | + if (is_string($restriction_search)) { |
|
598 | 598 | $mailbox = $searchstring = $restriction_search; |
599 | 599 | } |
600 | 600 | } |
@@ -607,35 +607,35 @@ discard block |
||
607 | 607 | 'special_use'=>true, |
608 | 608 | 'sort'=>true, |
609 | 609 | ); |
610 | - if ($returnAttributes==false) |
|
610 | + if ($returnAttributes == false) |
|
611 | 611 | { |
612 | 612 | unset($options['attributes']); |
613 | 613 | unset($options['children']); |
614 | 614 | unset($options['special_use']); |
615 | 615 | } |
616 | - $mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_ALL, $options); |
|
616 | + $mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_ALL, $options); |
|
617 | 617 | //$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
618 | 618 | //_debug_array($mboxes->count()); |
619 | 619 | foreach ((array)$mailboxes as $k =>$box) |
620 | 620 | { |
621 | 621 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box)); |
622 | - $ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true); |
|
622 | + $ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true); |
|
623 | 623 | } |
624 | 624 | // for unknown reasons on ALL, UNSUBSCRIBED are not returned |
625 | 625 | //always fetch unsubscribed, think about only fetching it when $options['attributes'] is set |
626 | 626 | //but then allMailboxes are not all, .... |
627 | 627 | //if (!empty($mailbox) && !isset($ret[$mailbox])) |
628 | 628 | { |
629 | - $unsub_mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
629 | + $unsub_mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
630 | 630 | //$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
631 | 631 | //_debug_array($mboxes->count()); |
632 | 632 | //error_log(__METHOD__.__LINE__.' '.$mailbox.':'.count((array)$mailboxes).'->'.function_backtrace()); |
633 | 633 | foreach ((array)$unsub_mailboxes as $k =>$box) |
634 | 634 | { |
635 | 635 | //error_log(__METHOD__.__LINE__.' Box:'.$k.' already In?'.array_key_exists($k,$boxexists).'->'.array2string($box)); |
636 | - if(!array_key_exists($k,$ret)) |
|
636 | + if (!array_key_exists($k, $ret)) |
|
637 | 637 | { |
638 | - $ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>false); |
|
638 | + $ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>false); |
|
639 | 639 | } |
640 | 640 | else |
641 | 641 | { |
@@ -658,14 +658,14 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @return mixed array of mailboxes |
660 | 660 | */ |
661 | - function listSubscribedMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
|
661 | + function listSubscribedMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false) |
|
662 | 662 | { |
663 | - if ( is_bool($restriction_search) ){ |
|
664 | - $restriction_search = (int) $restriction_search; |
|
663 | + if (is_bool($restriction_search)) { |
|
664 | + $restriction_search = (int)$restriction_search; |
|
665 | 665 | } |
666 | 666 | $mailbox = ''; |
667 | - if ( is_int( $restriction_search ) ){ |
|
668 | - switch ( $restriction_search ) { |
|
667 | + if (is_int($restriction_search)) { |
|
668 | + switch ($restriction_search) { |
|
669 | 669 | case 0: |
670 | 670 | $searchstring = $reference."*"; |
671 | 671 | break; |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | $searchstring = $reference."%"; |
678 | 678 | break; |
679 | 679 | } |
680 | - }else{ |
|
681 | - if ( is_string( $restriction_search ) ){ |
|
680 | + } else { |
|
681 | + if (is_string($restriction_search)) { |
|
682 | 682 | $mailbox = $searchstring = $restriction_search; |
683 | 683 | } |
684 | 684 | } |
@@ -690,25 +690,25 @@ discard block |
||
690 | 690 | 'special_use'=>true, |
691 | 691 | 'sort'=>true, |
692 | 692 | ); |
693 | - if ($returnAttributes==false) |
|
693 | + if ($returnAttributes == false) |
|
694 | 694 | { |
695 | 695 | unset($options['attributes']); |
696 | 696 | unset($options['children']); |
697 | 697 | unset($options['special_use']); |
698 | 698 | } |
699 | - $mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
699 | + $mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
700 | 700 | //$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
701 | 701 | //_debug_array($mboxes->count()); |
702 | 702 | foreach ((array)$mailboxes as $k =>$box) |
703 | 703 | { |
704 | 704 | //error_log(__METHOD__.__LINE__.' Searched for:'.$mailbox.' got Box:'.$k.'->'.array2string($box).function_backtrace()); |
705 | - if ($returnAttributes==false) |
|
705 | + if ($returnAttributes == false) |
|
706 | 706 | { |
707 | - $ret[]=$k; |
|
707 | + $ret[] = $k; |
|
708 | 708 | } |
709 | 709 | else |
710 | 710 | { |
711 | - $ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true); |
|
711 | + $ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | return $ret; |
@@ -724,14 +724,14 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @return mixed array of mailboxes |
726 | 726 | */ |
727 | - function listUnSubscribedMailboxes($reference = '' , $restriction_search = 0) |
|
727 | + function listUnSubscribedMailboxes($reference = '', $restriction_search = 0) |
|
728 | 728 | { |
729 | - if ( is_bool($restriction_search) ){ |
|
730 | - $restriction_search = (int) $restriction_search; |
|
729 | + if (is_bool($restriction_search)) { |
|
730 | + $restriction_search = (int)$restriction_search; |
|
731 | 731 | } |
732 | 732 | |
733 | - if ( is_int( $restriction_search ) ){ |
|
734 | - switch ( $restriction_search ) { |
|
733 | + if (is_int($restriction_search)) { |
|
734 | + switch ($restriction_search) { |
|
735 | 735 | case 0: |
736 | 736 | $mailbox = $reference."*"; |
737 | 737 | break; |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | $mailbox = "%"; |
744 | 744 | break; |
745 | 745 | } |
746 | - }else{ |
|
747 | - if ( is_string( $restriction_search ) ){ |
|
746 | + } else { |
|
747 | + if (is_string($restriction_search)) { |
|
748 | 748 | $mailbox = $restriction_search; |
749 | 749 | } |
750 | 750 | } |
@@ -753,17 +753,17 @@ discard block |
||
753 | 753 | 'sort'=>true, |
754 | 754 | //'flat'=>true, |
755 | 755 | ); |
756 | - $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
756 | + $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
757 | 757 | foreach ($mailboxes as $box) |
758 | 758 | { |
759 | 759 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8)); |
760 | - $sret[]=$box['mailbox']->utf8; |
|
760 | + $sret[] = $box['mailbox']->utf8; |
|
761 | 761 | } |
762 | - $unsubscribed = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
762 | + $unsubscribed = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
763 | 763 | foreach ($unsubscribed as $box) |
764 | 764 | { |
765 | 765 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8)); |
766 | - if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8; |
|
766 | + if (!in_array($box['mailbox']->utf8, $sret) && $box['mailbox']->utf8 != 'INBOX') $ret[] = $box['mailbox']->utf8; |
|
767 | 767 | } |
768 | 768 | return $ret; |
769 | 769 | } |
@@ -775,12 +775,12 @@ discard block |
||
775 | 775 | * @param int $flags =null default Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS |
776 | 776 | * @return array of counters for mailbox |
777 | 777 | */ |
778 | - function examineMailbox($mailbox, $flags=null) |
|
778 | + function examineMailbox($mailbox, $flags = null) |
|
779 | 779 | { |
780 | - if ($mailbox=='') return false; |
|
780 | + if ($mailbox == '') return false; |
|
781 | 781 | $mailboxes = $this->listMailboxes($mailbox); |
782 | 782 | |
783 | - if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS; |
|
783 | + if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL|Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS; |
|
784 | 784 | |
785 | 785 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
786 | 786 | //_debug_array($mboxes->count()); |
@@ -788,18 +788,18 @@ discard block |
||
788 | 788 | { |
789 | 789 | //error_log(__METHOD__.__LINE__.array2string($box)); |
790 | 790 | unset($box); |
791 | - if ($k!='user' && $k != '' && $k==$mailbox) |
|
791 | + if ($k != 'user' && $k != '' && $k == $mailbox) |
|
792 | 792 | { |
793 | 793 | $status = $this->status($k, $flags); |
794 | 794 | //error_log(__METHOD__.__LINE__.array2string($status)); |
795 | 795 | foreach ($status as $key => $v) |
796 | 796 | { |
797 | - $_status[strtoupper($key)]=$v; |
|
797 | + $_status[strtoupper($key)] = $v; |
|
798 | 798 | } |
799 | - if ($flags & (Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS)) |
|
799 | + if ($flags&(Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS)) |
|
800 | 800 | { |
801 | 801 | self::$supports_keywords[$this->ImapServerId] = stripos(implode('', $status['flags']), '$label') !== false || |
802 | - in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords |
|
802 | + in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords |
|
803 | 803 | } |
804 | 804 | return $_status; |
805 | 805 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | */ |
839 | 839 | function hasCapability($capability) |
840 | 840 | { |
841 | - if ($capability=='SUPPORTS_KEYWORDS') |
|
841 | + if ($capability == 'SUPPORTS_KEYWORDS') |
|
842 | 842 | { |
843 | 843 | // if pseudo-flag is not set, call examineMailbox now to set it (no STATUS_ALL = counters necessary) |
844 | 844 | if (!isset(self::$supports_keywords[$this->ImapServerId])) |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | catch (\Exception $e) |
851 | 851 | { |
852 | 852 | error_log(__METHOD__.__LINE__.' (examineServer for detection) '.$capability.'->'.array2string(self::$supports_keywords).' failed '.function_backtrace()); |
853 | - self::$supports_keywords[$this->ImapServerId]=false; |
|
853 | + self::$supports_keywords[$this->ImapServerId] = false; |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | //error_log(__METHOD__.__LINE__.' '.$capability.'->'.array2string(self::$supports_keywords).' '.function_backtrace()); |
@@ -900,9 +900,9 @@ discard block |
||
900 | 900 | */ |
901 | 901 | static function getFolderPrefixFromNamespace($_nameSpace, $_folderName) |
902 | 902 | { |
903 | - foreach($_nameSpace as &$singleNameSpace) |
|
903 | + foreach ($_nameSpace as &$singleNameSpace) |
|
904 | 904 | { |
905 | - if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
905 | + if (substr($_folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
906 | 906 | } |
907 | 907 | return ""; |
908 | 908 | } |
@@ -917,33 +917,33 @@ discard block |
||
917 | 917 | * @param string $reclevel = 0, counter to keep track of the current recursionlevel |
918 | 918 | * @return array of mailboxes |
919 | 919 | */ |
920 | - function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
|
920 | + function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0) |
|
921 | 921 | { |
922 | 922 | if ($reclevel > 25) { |
923 | - error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
923 | + error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
924 | 924 | return array(); |
925 | 925 | } |
926 | 926 | $reclevel++; |
927 | 927 | // clean up double delimiters |
928 | - $mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox); |
|
928 | + $mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox); |
|
929 | 929 | //get that mailbox in question |
930 | - $mbx = $this->getMailboxes($mailbox,1,true); |
|
930 | + $mbx = $this->getMailboxes($mailbox, 1, true); |
|
931 | 931 | $mbxkeys = array_keys($mbx); |
932 | 932 | |
933 | 933 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
934 | - if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
934 | + if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
935 | 935 | { |
936 | - $buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
|
936 | + $buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false); |
|
937 | 937 | $allMailboxes = array(); |
938 | 938 | foreach ($buff as $mbxname) { |
939 | - $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
|
939 | + $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']); |
|
940 | 940 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
941 | - if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
941 | + if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
942 | 942 | { |
943 | 943 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
944 | 944 | } |
945 | 945 | } |
946 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
946 | + if (!(in_array('\NoSelect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
947 | 947 | return $allMailboxes; |
948 | 948 | } |
949 | 949 | else |
@@ -962,24 +962,24 @@ discard block |
||
962 | 962 | */ |
963 | 963 | function getNameSpace() |
964 | 964 | { |
965 | - static $nameSpace=null; |
|
965 | + static $nameSpace = null; |
|
966 | 966 | $foldersNameSpace = array(); |
967 | 967 | $delimiter = $this->getDelimiter(); |
968 | - if (empty($delimiter)) $delimiter='/'; |
|
968 | + if (empty($delimiter)) $delimiter = '/'; |
|
969 | 969 | if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray(); |
970 | 970 | if (is_array($nameSpace)) { |
971 | - foreach($nameSpace as $type => $singleNameSpaceArray) |
|
971 | + foreach ($nameSpace as $type => $singleNameSpaceArray) |
|
972 | 972 | { |
973 | 973 | foreach ($singleNameSpaceArray as $singleNameSpace) |
974 | 974 | { |
975 | 975 | $_foldersNameSpace = array(); |
976 | - if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) |
|
976 | + if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX'))) |
|
977 | 977 | { |
978 | 978 | $_foldersNameSpace['prefix_present'] = 'forced'; |
979 | 979 | // uw-imap server with mailbox prefix or dovecot maybe |
980 | - $_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:'')); |
|
980 | + $_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : '')); |
|
981 | 981 | } |
982 | - elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
982 | + elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
983 | 983 | { |
984 | 984 | $_foldersNameSpace['prefix_present'] = 'forced'; |
985 | 985 | // uw-imap server with mailbox prefix or dovecot maybe |
@@ -988,9 +988,9 @@ discard block |
||
988 | 988 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
989 | 989 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
990 | 990 | } |
991 | - $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter); |
|
991 | + $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter); |
|
992 | 992 | $_foldersNameSpace['type'] = $type; |
993 | - $foldersNameSpace[] =$_foldersNameSpace; |
|
993 | + $foldersNameSpace[] = $_foldersNameSpace; |
|
994 | 994 | } |
995 | 995 | } |
996 | 996 | } |
@@ -1002,29 +1002,29 @@ discard block |
||
1002 | 1002 | * @param mixed _type (1=personal, 2=user/other, 3=shared) |
1003 | 1003 | * @return string the delimimiter |
1004 | 1004 | */ |
1005 | - function getDelimiter($_type=1) |
|
1005 | + function getDelimiter($_type = 1) |
|
1006 | 1006 | { |
1007 | 1007 | switch ($_type) |
1008 | 1008 | { |
1009 | 1009 | case 'user': |
1010 | 1010 | case 'other': |
1011 | 1011 | case 2: |
1012 | - $type=2; |
|
1012 | + $type = 2; |
|
1013 | 1013 | break; |
1014 | 1014 | case 'shared': |
1015 | 1015 | case '': |
1016 | 1016 | case 3: |
1017 | - $type=3; |
|
1017 | + $type = 3; |
|
1018 | 1018 | break; |
1019 | 1019 | case 'personal': |
1020 | 1020 | case 1: |
1021 | 1021 | default: |
1022 | - $type=1; |
|
1022 | + $type = 1; |
|
1023 | 1023 | } |
1024 | 1024 | $namespaces = $this->getNamespaces(); |
1025 | 1025 | foreach ($namespaces as $nsp) |
1026 | 1026 | { |
1027 | - if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter']; |
|
1027 | + if ($nsp['type'] == $type && $nsp['delimiter']) return $nsp['delimiter']; |
|
1028 | 1028 | } |
1029 | 1029 | return "/"; |
1030 | 1030 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | { |
1053 | 1053 | if (is_numeric($_username)) |
1054 | 1054 | { |
1055 | - $_username = $GLOBALS['egw']->accounts->id2name($accountID=$_username); |
|
1055 | + $_username = $GLOBALS['egw']->accounts->id2name($accountID = $_username); |
|
1056 | 1056 | } |
1057 | 1057 | else |
1058 | 1058 | { |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | switch ($this->loginType) |
1062 | 1062 | { |
1063 | 1063 | case 'email': |
1064 | - $_username = $GLOBALS['egw']->accounts->id2name($accountID,'account_email'); |
|
1064 | + $_username = $GLOBALS['egw']->accounts->id2name($accountID, 'account_email'); |
|
1065 | 1065 | break; |
1066 | 1066 | |
1067 | 1067 | case 'vmailmgr': |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | if (empty($this->loginType)) |
1077 | 1077 | { |
1078 | 1078 | // try to figure out by params['acc_imap_username'] |
1079 | - list($lusername,$domain) = explode('@',$this->params['acc_imap_username'],2); |
|
1080 | - if (strpos($_username,'@')===false && !empty($domain) && !empty($lusername)) |
|
1079 | + list($lusername, $domain) = explode('@', $this->params['acc_imap_username'], 2); |
|
1080 | + if (strpos($_username, '@') === false && !empty($domain) && !empty($lusername)) |
|
1081 | 1081 | { |
1082 | 1082 | $_username = $_username.'@'.$domain; |
1083 | 1083 | } |
@@ -1116,20 +1116,20 @@ discard block |
||
1116 | 1116 | * @param string $_folderName='' |
1117 | 1117 | * @return string utf-7 encoded (done in getMailboxName) |
1118 | 1118 | */ |
1119 | - function getUserMailboxString($_username, $_folderName='') |
|
1119 | + function getUserMailboxString($_username, $_folderName = '') |
|
1120 | 1120 | { |
1121 | 1121 | $nameSpaces = $this->getNameSpaceArray(); |
1122 | 1122 | |
1123 | - if(!isset($nameSpaces['others'])) { |
|
1123 | + if (!isset($nameSpaces['others'])) { |
|
1124 | 1124 | return false; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | $username = $this->getMailBoxUserName($_username); |
1128 | - if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') { |
|
1129 | - $username .= '@'. $this->domainName; |
|
1128 | + if ($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') { |
|
1129 | + $username .= '@'.$this->domainName; |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | - $mailboxString = $nameSpaces['others'][0]['name'] . $username . (!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter']?$nameSpaces['others'][0]['delimiter']:'/') . $_folderName : ''); |
|
1132 | + $mailboxString = $nameSpaces['others'][0]['name'].$username.(!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter'] ? $nameSpaces['others'][0]['delimiter'] : '/').$_folderName : ''); |
|
1133 | 1133 | |
1134 | 1134 | return $mailboxString; |
1135 | 1135 | } |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ); |
1149 | 1149 | //error_log(__METHOD__.__LINE__.array2string($types)); |
1150 | 1150 | $result = array(); |
1151 | - foreach($this->getNamespaces() as $data) |
|
1151 | + foreach ($this->getNamespaces() as $data) |
|
1152 | 1152 | { |
1153 | 1153 | //error_log(__METHOD__.__LINE__.array2string($data)); |
1154 | 1154 | if (isset($types[$data['type']])) |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | 'name' => $data['name'], |
1159 | 1159 | 'prefix' => $data['name'], |
1160 | 1160 | 'prefix_present' => !empty($data['name']), |
1161 | - 'delimiter' => ($data['delimiter']?$data['delimiter']:'/'), |
|
1161 | + 'delimiter' => ($data['delimiter'] ? $data['delimiter'] : '/'), |
|
1162 | 1162 | ); |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | { |
1180 | 1180 | if ($qInfo['storage']) |
1181 | 1181 | { |
1182 | - return array('USED'=>$qInfo['storage']['usage'],'QMAX'=>$qInfo['storage']['limit']); |
|
1182 | + return array('USED'=>$qInfo['storage']['usage'], 'QMAX'=>$qInfo['storage']['limit']); |
|
1183 | 1183 | } |
1184 | 1184 | } |
1185 | 1185 | return false; |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | * @param string $_what - what to retrieve either limit/QMAX, usage/USED or ALL is supported |
1194 | 1194 | * @return int|array|boolean the quota for specified user (by what) or array with values for "limit" and "usage", or false |
1195 | 1195 | */ |
1196 | - function getQuotaByUser($_username, $_what='QMAX') |
|
1196 | + function getQuotaByUser($_username, $_what = 'QMAX') |
|
1197 | 1197 | { |
1198 | 1198 | $mailboxName = $this->getUserMailboxString($_username); |
1199 | 1199 | $storageQuota = $this->getQuotaRoot($mailboxName); |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | if (is_array($storageQuota) && isset($storageQuota[$mailboxName]) && is_array($storageQuota[$mailboxName]) && |
1203 | 1203 | isset($storageQuota[$mailboxName]['storage']) && is_array($storageQuota[$mailboxName]['storage'])) |
1204 | 1204 | { |
1205 | - switch($_what) |
|
1205 | + switch ($_what) |
|
1206 | 1206 | { |
1207 | 1207 | case 'QMAX': |
1208 | 1208 | $_what = 'limit'; |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | */ |
1229 | 1229 | function getUserData($_username) |
1230 | 1230 | { |
1231 | - unset($_username); // not used |
|
1231 | + unset($_username); // not used |
|
1232 | 1232 | return array(); |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | */ |
1242 | 1242 | function setUserData($_username, $_quota) |
1243 | 1243 | { |
1244 | - unset($_username, $_quota); // not used |
|
1244 | + unset($_username, $_quota); // not used |
|
1245 | 1245 | return true; |
1246 | 1246 | } |
1247 | 1247 | |
@@ -1275,10 +1275,10 @@ discard block |
||
1275 | 1275 | * @param array $params |
1276 | 1276 | * @throws Api\Exception\WrongParameter |
1277 | 1277 | */ |
1278 | - public function __call($name,array $params=null) |
|
1278 | + public function __call($name, array $params = null) |
|
1279 | 1279 | { |
1280 | 1280 | if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params)); |
1281 | - switch($name) |
|
1281 | + switch ($name) |
|
1282 | 1282 | { |
1283 | 1283 | case 'installScript': |
1284 | 1284 | case 'getScript': |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | if (is_null($this->sieve)) |
1294 | 1294 | { |
1295 | 1295 | $this->sieve = new Sieve($this); |
1296 | - $this->error =& $this->sieve->error; |
|
1296 | + $this->error = & $this->sieve->error; |
|
1297 | 1297 | } |
1298 | - $ret = call_user_func_array(array($this->sieve,$name),$params); |
|
1298 | + $ret = call_user_func_array(array($this->sieve, $name), $params); |
|
1299 | 1299 | //error_log(__CLASS__.'->'.$name.'('.array2string($params).') returns '.array2string($ret)); |
1300 | 1300 | return $ret; |
1301 | 1301 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | * @param string $_scriptName =null |
1311 | 1311 | * @return boolean |
1312 | 1312 | */ |
1313 | - public function setVacationUser($_euser, array $_vacation, $_scriptName=null) |
|
1313 | + public function setVacationUser($_euser, array $_vacation, $_scriptName = null) |
|
1314 | 1314 | { |
1315 | 1315 | if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation)); |
1316 | 1316 | |
@@ -1322,8 +1322,8 @@ discard block |
||
1322 | 1322 | { |
1323 | 1323 | $this->adminConnection($_euser); |
1324 | 1324 | $this->sieve = new Sieve($this, $_euser, $_scriptName); |
1325 | - $this->scriptName =& $this->sieve->scriptName; |
|
1326 | - $this->error =& $this->sieve->error; |
|
1325 | + $this->scriptName = & $this->sieve->scriptName; |
|
1326 | + $this->error = & $this->sieve->error; |
|
1327 | 1327 | } |
1328 | 1328 | $ret = $this->setVacation($_vacation, $_scriptName); |
1329 | 1329 | |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | * @throws Exception on connection error or authentication failure |
1339 | 1339 | * @return array |
1340 | 1340 | */ |
1341 | - public function getVacationUser($_euser, $_scriptName=null) |
|
1341 | + public function getVacationUser($_euser, $_scriptName = null) |
|
1342 | 1342 | { |
1343 | 1343 | if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser)); |
1344 | 1344 | |
@@ -1350,8 +1350,8 @@ discard block |
||
1350 | 1350 | { |
1351 | 1351 | $this->adminConnection($_euser); |
1352 | 1352 | $this->sieve = new Sieve($this, $_euser, $_scriptName); |
1353 | - $this->error =& $this->sieve->error; |
|
1354 | - $this->scriptName =& $this->sieve->scriptName; |
|
1353 | + $this->error = & $this->sieve->error; |
|
1354 | + $this->scriptName = & $this->sieve->scriptName; |
|
1355 | 1355 | } |
1356 | 1356 | return $this->sieve->getVacation(); |
1357 | 1357 | } |
@@ -1371,7 +1371,7 @@ discard block |
||
1371 | 1371 | */ |
1372 | 1372 | public static function init_static() |
1373 | 1373 | { |
1374 | - self::$supports_keywords =& Api\Cache::getSession (__CLASS__, 'supports_keywords'); |
|
1374 | + self::$supports_keywords = & Api\Cache::getSession(__CLASS__, 'supports_keywords'); |
|
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | Imap::init_static(); |
@@ -121,6 +121,7 @@ |
||
121 | 121 | * @param bool $_adminConnection create admin connection if true |
122 | 122 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
123 | 123 | * @throws Exception on error |
124 | + * @return void |
|
124 | 125 | */ |
125 | 126 | function openConnection($_adminConnection=false, $_timeout=null); |
126 | 127 |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | namespace EGroupware\Api\Mail\Imap; |
15 | 15 | |
16 | 16 | define('IMAP_NAMESPACE_PERSONAL', 'personal'); |
17 | -define('IMAP_NAMESPACE_OTHERS' , 'others'); |
|
18 | -define('IMAP_NAMESPACE_SHARED' , 'shared'); |
|
19 | -define('IMAP_NAMESPACE_ALL' , 'all'); |
|
17 | +define('IMAP_NAMESPACE_OTHERS', 'others'); |
|
18 | +define('IMAP_NAMESPACE_SHARED', 'shared'); |
|
19 | +define('IMAP_NAMESPACE_ALL', 'all'); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * This class holds all information about the imap connection. |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string $_folderName='' |
88 | 88 | * @return string utf-7 encoded (done in getMailboxName) |
89 | 89 | */ |
90 | - function getUserMailboxString($_username, $_folderName=''); |
|
90 | + function getUserMailboxString($_username, $_folderName = ''); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * get list of namespaces |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $_what - what to retrieve either QMAX, USED or ALL is supported |
104 | 104 | * @return mixed the quota for specified user (by what) or array with all available Quota Information, or false |
105 | 105 | */ |
106 | - function getQuotaByUser($_username, $_what='QMAX'); |
|
106 | + function getQuotaByUser($_username, $_what = 'QMAX'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * returns information about a user |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
123 | 123 | * @throws Exception on error |
124 | 124 | */ |
125 | - function openConnection($_adminConnection=false, $_timeout=null); |
|
125 | + function openConnection($_adminConnection = false, $_timeout = null); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * set userdata |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param string $_scriptName =null |
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | - public function setVacationUser($_euser, array $_vacation, $_scriptName=null); |
|
152 | + public function setVacationUser($_euser, array $_vacation, $_scriptName = null); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Get vacation message for given user |
@@ -159,5 +159,5 @@ discard block |
||
159 | 159 | * @throws Exception on connection error or authentication failure |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - public function getVacationUser($_euser, $_scriptName=null); |
|
162 | + public function getVacationUser($_euser, $_scriptName = null); |
|
163 | 163 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Constructor |
84 | 84 | * |
85 | - * @param array|Imap $params =array() |
|
85 | + * @param Imap $params =array() |
|
86 | 86 | */ |
87 | 87 | function __construct($params=array()) |
88 | 88 | { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param array $_emailNotification |
167 | 167 | * @param string $_scriptName |
168 | - * @return Script |
|
168 | + * @return boolean |
|
169 | 169 | */ |
170 | 170 | function setEmailNotification(array $_emailNotification, $_scriptName=null) |
171 | 171 | { |
@@ -37,28 +37,28 @@ discard block |
||
37 | 37 | var $icServer; |
38 | 38 | |
39 | 39 | /** |
40 | - * @var string name of active script queried from Sieve server |
|
41 | - */ |
|
40 | + * @var string name of active script queried from Sieve server |
|
41 | + */ |
|
42 | 42 | var $scriptName; |
43 | 43 | |
44 | 44 | /** |
45 | - * @var $rules containing the rules |
|
46 | - */ |
|
45 | + * @var $rules containing the rules |
|
46 | + */ |
|
47 | 47 | var $rules; |
48 | 48 | |
49 | 49 | /** |
50 | - * @var $vacation containing the vacation |
|
51 | - */ |
|
50 | + * @var $vacation containing the vacation |
|
51 | + */ |
|
52 | 52 | var $vacation; |
53 | 53 | |
54 | 54 | /** |
55 | - * @var $emailNotification containing the emailNotification |
|
56 | - */ |
|
55 | + * @var $emailNotification containing the emailNotification |
|
56 | + */ |
|
57 | 57 | var $emailNotification; |
58 | 58 | |
59 | 59 | /** |
60 | - * @var object $error the last PEAR error object |
|
61 | - */ |
|
60 | + * @var object $error the last PEAR error object |
|
61 | + */ |
|
62 | 62 | var $error; |
63 | 63 | |
64 | 64 | /** |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | function setEmailNotification(array $_emailNotification, $_scriptName=null) |
171 | 171 | { |
172 | 172 | if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) { |
173 | - $_emailNotification['status'] = 'off'; |
|
174 | - $_emailNotification['externalEmail'] = ''; |
|
175 | - } |
|
173 | + $_emailNotification['status'] = 'off'; |
|
174 | + $_emailNotification['externalEmail'] = ''; |
|
175 | + } |
|
176 | 176 | |
177 | - $script = $this->retrieveRules($_scriptName); |
|
177 | + $script = $this->retrieveRules($_scriptName); |
|
178 | 178 | $script->emailNotification = $_emailNotification; |
179 | 179 | $ret = $script->updateScript($this); |
180 | 180 | $this->error = $script->errstr; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param array|Imap $params =array() |
86 | 86 | */ |
87 | - function __construct($params=array()) |
|
87 | + function __construct($params = array()) |
|
88 | 88 | { |
89 | 89 | if (is_a($params, __NAMESPACE__.'\\Imap')) |
90 | 90 | { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | parent::__construct($params); |
101 | 101 | |
102 | - $this->displayCharset = Translation::charset(); |
|
102 | + $this->displayCharset = Translation::charset(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | function getRules() |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param string $_scriptName |
131 | 131 | * @param boolean $utf7imap_fileinto =false true: encode foldernames with utf7imap, default utf8 |
132 | 132 | */ |
133 | - function setRules(array $_rules, $_scriptName=null, $utf7imap_fileinto=false) |
|
133 | + function setRules(array $_rules, $_scriptName = null, $utf7imap_fileinto = false) |
|
134 | 134 | { |
135 | 135 | $script = $this->retrieveRules($_scriptName); |
136 | 136 | $script->debug = $this->debug; |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | * @param array $_vacation |
147 | 147 | * @param string $_scriptName |
148 | 148 | */ |
149 | - function setVacation(array $_vacation, $_scriptName=null) |
|
149 | + function setVacation(array $_vacation, $_scriptName = null) |
|
150 | 150 | { |
151 | 151 | if ($this->debug) |
152 | 152 | { |
153 | - error_log(__METHOD__ . "($_scriptName," . print_r($_vacation, true) . ')'); |
|
153 | + error_log(__METHOD__."($_scriptName,".print_r($_vacation, true).')'); |
|
154 | 154 | } |
155 | 155 | $script = $this->retrieveRules($_scriptName); |
156 | 156 | $script->debug = $this->debug; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * @param string $_scriptName |
168 | 168 | * @return Script |
169 | 169 | */ |
170 | - function setEmailNotification(array $_emailNotification, $_scriptName=null) |
|
170 | + function setEmailNotification(array $_emailNotification, $_scriptName = null) |
|
171 | 171 | { |
172 | - if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) { |
|
172 | + if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/", $_emailNotification['externalEmail'])) { |
|
173 | 173 | $_emailNotification['status'] = 'off'; |
174 | 174 | $_emailNotification['externalEmail'] = ''; |
175 | 175 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param string $_scriptName |
188 | 188 | * @return Script |
189 | 189 | */ |
190 | - function retrieveRules($_scriptName=null) |
|
190 | + function retrieveRules($_scriptName = null) |
|
191 | 191 | { |
192 | 192 | if (!$_scriptName) |
193 | 193 | { |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | try { |
198 | 198 | $this->scriptName = $this->getActive(); |
199 | 199 | } |
200 | - catch(Exception $e) { |
|
201 | - unset($e); // ignore NOTEXISTS exception |
|
200 | + catch (Exception $e) { |
|
201 | + unset($e); // ignore NOTEXISTS exception |
|
202 | 202 | } |
203 | 203 | if (empty($this->scriptName)) |
204 | 204 | { |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | $script->retrieveRules($this); |
214 | 214 | } |
215 | 215 | catch (\Exception $e) { |
216 | - unset($e); // ignore not found script exception |
|
216 | + unset($e); // ignore not found script exception |
|
217 | 217 | } |
218 | - $this->rules =& $script->rules; |
|
219 | - $this->vacation =& $script->vacation; |
|
220 | - $this->emailNotification =& $script->emailNotification; // Added email notifications |
|
218 | + $this->rules = & $script->rules; |
|
219 | + $this->vacation = & $script->vacation; |
|
220 | + $this->emailNotification = & $script->emailNotification; // Added email notifications |
|
221 | 221 | |
222 | 222 | return $script; |
223 | 223 | } |
@@ -104,21 +104,30 @@ discard block |
||
104 | 104 | |
105 | 105 | function getRules() |
106 | 106 | { |
107 | - if (!isset($this->rules)) $this->retrieveRules(); |
|
107 | + if (!isset($this->rules)) |
|
108 | + { |
|
109 | + $this->retrieveRules(); |
|
110 | + } |
|
108 | 111 | |
109 | 112 | return $this->rules; |
110 | 113 | } |
111 | 114 | |
112 | 115 | function getVacation() |
113 | 116 | { |
114 | - if (!isset($this->rules)) $this->retrieveRules(); |
|
117 | + if (!isset($this->rules)) |
|
118 | + { |
|
119 | + $this->retrieveRules(); |
|
120 | + } |
|
115 | 121 | |
116 | 122 | return $this->vacation; |
117 | 123 | } |
118 | 124 | |
119 | 125 | function getEmailNotification() |
120 | 126 | { |
121 | - if (!isset($this->rules)) $this->retrieveRules(); |
|
127 | + if (!isset($this->rules)) |
|
128 | + { |
|
129 | + $this->retrieveRules(); |
|
130 | + } |
|
122 | 131 | |
123 | 132 | return $this->emailNotification; |
124 | 133 | } |
@@ -169,7 +178,8 @@ discard block |
||
169 | 178 | */ |
170 | 179 | function setEmailNotification(array $_emailNotification, $_scriptName=null) |
171 | 180 | { |
172 | - if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) { |
|
181 | + if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) |
|
182 | + { |
|
173 | 183 | $_emailNotification['status'] = 'off'; |
174 | 184 | $_emailNotification['externalEmail'] = ''; |
175 | 185 | } |
@@ -156,7 +156,7 @@ |
||
156 | 156 | /** |
157 | 157 | * Get the data of a given user |
158 | 158 | * |
159 | - * @param int|string $user numerical account-id, account-name or email address |
|
159 | + * @param integer $user numerical account-id, account-name or email address |
|
160 | 160 | * @param boolean $match_uid_at_domain =true true: uid@domain matches, false only an email or alias address matches |
161 | 161 | * @return array with values for keys 'mailLocalAddress', 'mailAlternateAddress' (array), 'mailForwardingAddress' (array), |
162 | 162 | * 'accountStatus' ("active"), 'quotaLimit' and 'deliveryMode' ("forwardOnly") |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param string $defaultDomain =null |
81 | 81 | */ |
82 | - function __construct($defaultDomain=null) |
|
82 | + function __construct($defaultDomain = null) |
|
83 | 83 | { |
84 | 84 | $this->defaultDomain = $defaultDomain ? $defaultDomain : $GLOBALS['egw_info']['server']['mail_suffix']; |
85 | 85 | |
@@ -104,12 +104,10 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function addAccount($_hookValues) |
106 | 106 | { |
107 | - $mailLocalAddress = $_hookValues['account_email'] ? $_hookValues['account_email'] : |
|
108 | - Api\Accounts::email($_hookValues['account_firstname'], |
|
109 | - $_hookValues['account_lastname'],$_hookValues['account_lid'],$this->defaultDomain); |
|
107 | + $mailLocalAddress = $_hookValues['account_email'] ? $_hookValues['account_email'] : Api\Accounts::email($_hookValues['account_firstname'], |
|
108 | + $_hookValues['account_lastname'], $_hookValues['account_lid'], $this->defaultDomain); |
|
110 | 109 | |
111 | - $account_id = !empty($_hookValues['account_id']) ? $_hookValues['account_id'] : |
|
112 | - $this->accounts->name2id($_hookValues['account_lid'], 'account_lid', 'u'); |
|
110 | + $account_id = !empty($_hookValues['account_id']) ? $_hookValues['account_id'] : $this->accounts->name2id($_hookValues['account_lid'], 'account_lid', 'u'); |
|
113 | 111 | |
114 | 112 | if ($this->accounts->exists($account_id) != 1) |
115 | 113 | { |
@@ -126,7 +124,7 @@ discard block |
||
126 | 124 | */ |
127 | 125 | function deleteAccount($_hookValues) |
128 | 126 | { |
129 | - unset($_hookValues); // not used, but required by function signature |
|
127 | + unset($_hookValues); // not used, but required by function signature |
|
130 | 128 | |
131 | 129 | return true; |
132 | 130 | } |
@@ -139,12 +137,12 @@ discard block |
||
139 | 137 | */ |
140 | 138 | function getAccountEmailAddress($_accountName) |
141 | 139 | { |
142 | - $emailAddresses = array(); |
|
140 | + $emailAddresses = array(); |
|
143 | 141 | |
144 | 142 | if (($account_id = $this->accounts->name2id($_accountName, 'account_lid', 'u'))) |
145 | 143 | { |
146 | - $realName = trim($GLOBALS['egw_info']['user']['account_firstname'] . (!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '') . $GLOBALS['egw_info']['user']['account_lastname']); |
|
147 | - $emailAddresses[] = array ( |
|
144 | + $realName = trim($GLOBALS['egw_info']['user']['account_firstname'].(!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '').$GLOBALS['egw_info']['user']['account_lastname']); |
|
145 | + $emailAddresses[] = array( |
|
148 | 146 | 'name' => $realName, |
149 | 147 | 'address' => $this->accounts->id2name($account_id, 'account_email'), |
150 | 148 | 'type' => 'default', |
@@ -161,9 +159,9 @@ discard block |
||
161 | 159 | * @return array with values for keys 'mailLocalAddress', 'mailAlternateAddress' (array), 'mailForwardingAddress' (array), |
162 | 160 | * 'accountStatus' ("active"), 'quotaLimit' and 'deliveryMode' ("forwardOnly") |
163 | 161 | */ |
164 | - function getUserData($user, $match_uid_at_domain=false) |
|
162 | + function getUserData($user, $match_uid_at_domain = false) |
|
165 | 163 | { |
166 | - unset($user, $match_uid_at_domain); // not used, but required by function signature |
|
164 | + unset($user, $match_uid_at_domain); // not used, but required by function signature |
|
167 | 165 | |
168 | 166 | $userData = array(); |
169 | 167 | |
@@ -201,9 +199,9 @@ discard block |
||
201 | 199 | * @return boolean true on success, false on error writing to ldap |
202 | 200 | */ |
203 | 201 | function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode, |
204 | - $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false, $_setMailbox=null) |
|
202 | + $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only = false, $_setMailbox = null) |
|
205 | 203 | { |
206 | - unset($_uidnumber, $_mailAlternateAddress, $_mailForwardingAddress, // not used, but require by function signature |
|
204 | + unset($_uidnumber, $_mailAlternateAddress, $_mailForwardingAddress, // not used, but require by function signature |
|
207 | 205 | $_deliveryMode, $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only, $_setMailbox); |
208 | 206 | |
209 | 207 | return true; |
@@ -217,7 +215,7 @@ discard block |
||
217 | 215 | */ |
218 | 216 | function updateAccount($_hookValues) |
219 | 217 | { |
220 | - unset($_hookValues); // not used, but required by function signature |
|
218 | + unset($_hookValues); // not used, but required by function signature |
|
221 | 219 | |
222 | 220 | return true; |
223 | 221 | } |
@@ -233,15 +231,15 @@ discard block |
||
233 | 231 | * default use $this->loginType |
234 | 232 | * @return string |
235 | 233 | */ |
236 | - /*static*/ public function mailbox_addr($account,$domain=null,$mail_login_type=null) |
|
234 | + /*static*/ public function mailbox_addr($account, $domain = null, $mail_login_type = null) |
|
237 | 235 | { |
238 | 236 | if (is_null($domain)) $domain = $this->defaultDomain; |
239 | 237 | if (is_null($mail_login_type)) $mail_login_type = $this->loginType; |
240 | 238 | |
241 | - switch($mail_login_type) |
|
239 | + switch ($mail_login_type) |
|
242 | 240 | { |
243 | 241 | case 'email': |
244 | - $mbox = is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account,'account_email'); |
|
242 | + $mbox = is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account, 'account_email'); |
|
245 | 243 | break; |
246 | 244 | |
247 | 245 | case 'uidNumber': |
@@ -235,8 +235,14 @@ discard block |
||
235 | 235 | */ |
236 | 236 | /*static*/ public function mailbox_addr($account,$domain=null,$mail_login_type=null) |
237 | 237 | { |
238 | - if (is_null($domain)) $domain = $this->defaultDomain; |
|
239 | - if (is_null($mail_login_type)) $mail_login_type = $this->loginType; |
|
238 | + if (is_null($domain)) |
|
239 | + { |
|
240 | + $domain = $this->defaultDomain; |
|
241 | + } |
|
242 | + if (is_null($mail_login_type)) |
|
243 | + { |
|
244 | + $mail_login_type = $this->loginType; |
|
245 | + } |
|
240 | 246 | |
241 | 247 | switch($mail_login_type) |
242 | 248 | { |
@@ -245,7 +251,10 @@ discard block |
||
245 | 251 | break; |
246 | 252 | |
247 | 253 | case 'uidNumber': |
248 | - if (is_array($account)) $account = $account['account_id']; |
|
254 | + if (is_array($account)) |
|
255 | + { |
|
256 | + $account = $account['account_id']; |
|
257 | + } |
|
249 | 258 | $mbox = 'u'.$account.'@'.$domain; |
250 | 259 | break; |
251 | 260 |
@@ -628,7 +628,7 @@ |
||
628 | 628 | * @param int $_accountID |
629 | 629 | * @param string $_forwardingAddress |
630 | 630 | * @param string $_keepLocalCopy 'yes' |
631 | - * @return boolean true on success, false on error writing to ldap |
|
631 | + * @return boolean|null true on success, false on error writing to ldap |
|
632 | 632 | */ |
633 | 633 | function saveSMTPForwarding($_accountID, $_forwardingAddress, $_keepLocalCopy) |
634 | 634 | { |
@@ -303,7 +303,10 @@ discard block |
||
303 | 303 | { |
304 | 304 | foreach($allValues[0][static::MAIL_ATTR] as $key => $value) |
305 | 305 | { |
306 | - if ($key === 'count') continue; |
|
306 | + if ($key === 'count') |
|
307 | + { |
|
308 | + continue; |
|
309 | + } |
|
307 | 310 | |
308 | 311 | $emailAddresses[] = array ( |
309 | 312 | 'name' => $realName, |
@@ -324,7 +327,10 @@ discard block |
||
324 | 327 | } |
325 | 328 | } |
326 | 329 | } |
327 | - if ($this->debug) error_log(__METHOD__."('$_accountName') returning ".array2string($emailAddresses)); |
|
330 | + if ($this->debug) |
|
331 | + { |
|
332 | + error_log(__METHOD__."('$_accountName') returning ".array2string($emailAddresses)); |
|
333 | + } |
|
328 | 334 | |
329 | 335 | return $emailAddresses; |
330 | 336 | } |
@@ -357,7 +363,10 @@ discard block |
||
357 | 363 | } |
358 | 364 | elseif (strpos($user, '@') === false) |
359 | 365 | { |
360 | - if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
|
366 | + if (is_numeric($user)) |
|
367 | + { |
|
368 | + $user = $GLOBALS['egw']->accounts->id2name($user); |
|
369 | + } |
|
361 | 370 | $filter = '(&'.static::USER_FILTER.'('.static::USER_ATTR.'='.Api\Ldap::quote($user).'))'; |
362 | 371 | } |
363 | 372 | else // email address --> build filter by attributes defined in config |
@@ -374,7 +383,10 @@ discard block |
||
374 | 383 | else |
375 | 384 | { |
376 | 385 | $to_or = array('('.static::MAIL_ATTR.'='.Api\Ldap::quote($user).')'); |
377 | - if ($match_uid_at_domain) $to_or[] = '('.static::USER_ATTR.'='.Api\Ldap::quote($namepart).')'; |
|
386 | + if ($match_uid_at_domain) |
|
387 | + { |
|
388 | + $to_or[] = '('.static::USER_ATTR.'='.Api\Ldap::quote($namepart).')'; |
|
389 | + } |
|
378 | 390 | if (static::ALIAS_ATTR) |
379 | 391 | { |
380 | 392 | $to_or[] = '('.static::ALIAS_ATTR.'='.static::ALIAS_PREFIX.Api\Ldap::quote($user).')'; |
@@ -399,11 +411,17 @@ discard block |
||
399 | 411 | if ($sri) |
400 | 412 | { |
401 | 413 | $allValues = ldap_get_entries($ldap, $sri); |
402 | - if ($this->debug) error_log(__METHOD__."('$user') --> ldap_search(, '$this->search_base', '$filter') --> ldap_get_entries=".array2string($allValues[0])); |
|
414 | + if ($this->debug) |
|
415 | + { |
|
416 | + error_log(__METHOD__."('$user') --> ldap_search(, '$this->search_base', '$filter') --> ldap_get_entries=".array2string($allValues[0])); |
|
417 | + } |
|
403 | 418 | |
404 | 419 | foreach($allValues as $key => $values) |
405 | 420 | { |
406 | - if ($key === 'count') continue; |
|
421 | + if ($key === 'count') |
|
422 | + { |
|
423 | + continue; |
|
424 | + } |
|
407 | 425 | |
408 | 426 | // groups are always active (if they have an email) and allways forwardOnly |
409 | 427 | if (in_array(static::GROUP_SCHEMA, $values['objectclass'])) |
@@ -445,11 +463,14 @@ discard block |
||
445 | 463 | } |
446 | 464 | } |
447 | 465 | } |
448 | - elseif (static::FORWARD_ONLY) // check caseinsensitiv for existence of that value |
|
466 | + elseif (static::FORWARD_ONLY) |
|
467 | + { |
|
468 | + // check caseinsensitiv for existence of that value |
|
449 | 469 | { |
450 | 470 | $deliveryMode = self::getAttributePrefix($values[static::FORWARD_ONLY_ATTR], static::FORWARD_ONLY) ? |
451 | 471 | Mail\Smtp::FORWARD_ONLY : ''; |
452 | 472 | } |
473 | + } |
|
453 | 474 | else // check for existence of any value |
454 | 475 | { |
455 | 476 | $deliveryMode = $values[static::FORWARD_ONLY_ATTR]['count'] > 0 ? |
@@ -482,7 +503,10 @@ discard block |
||
482 | 503 | } |
483 | 504 | |
484 | 505 | // regular user-data can only be from users, NOT groups |
485 | - if (in_array(static::GROUP_SCHEMA, $values['objectclass'])) continue; |
|
506 | + if (in_array(static::GROUP_SCHEMA, $values['objectclass'])) |
|
507 | + { |
|
508 | + continue; |
|
509 | + } |
|
486 | 510 | |
487 | 511 | $userData['mailLocalAddress'] = $values[static::MAIL_ATTR][0]; |
488 | 512 | $userData['accountStatus'] = $accountStatus; |
@@ -507,7 +531,10 @@ discard block |
||
507 | 531 | $userData['mailForwardingAddress'] = self::getAttributePrefix($values[static::FORWARD_ATTR], static::FORWARD_PREFIX); |
508 | 532 | } |
509 | 533 | |
510 | - if (static::MAILBOX_ATTR) $userData['mailMessageStore'] = $values[static::MAILBOX_ATTR][0]; |
|
534 | + if (static::MAILBOX_ATTR) |
|
535 | + { |
|
536 | + $userData['mailMessageStore'] = $values[static::MAILBOX_ATTR][0]; |
|
537 | + } |
|
511 | 538 | |
512 | 539 | $userData['deliveryMode'] = $deliveryMode; |
513 | 540 | |
@@ -526,7 +553,10 @@ discard block |
||
526 | 553 | } |
527 | 554 | } |
528 | 555 | } |
529 | - if ($this->debug) error_log(__METHOD__."('$user') returning ".array2string($userData)); |
|
556 | + if ($this->debug) |
|
557 | + { |
|
558 | + error_log(__METHOD__."('$user') returning ".array2string($userData)); |
|
559 | + } |
|
530 | 560 | |
531 | 561 | return $userData; |
532 | 562 | } |
@@ -649,7 +679,10 @@ discard block |
||
649 | 679 | |
650 | 680 | $this->addAccountExtra(array('location' => 'setUserData'), $allValues[0], $newData); |
651 | 681 | |
652 | - if ($this->debug) error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'$accountDN',".array2string($newData).')'); |
|
682 | + if ($this->debug) |
|
683 | + { |
|
684 | + error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'$accountDN',".array2string($newData).')'); |
|
685 | + } |
|
653 | 686 | |
654 | 687 | if (!($ret = @ldap_mod_replace($ldap, $accountDN, $newData)) && static::CHECK_FORWARD_ATTR) |
655 | 688 | { |
@@ -749,7 +782,10 @@ discard block |
||
749 | 782 | // merge in again all new set forwards incl. opt. prefix |
750 | 783 | self::setAttributePrefix($newData[static::FORWARD_ATTR], $forwards, static::FORWARD_PREFIX); |
751 | 784 | } |
752 | - if ($this->debug) error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'{$allValues[0]['dn']}',".array2string($newData).')'); |
|
785 | + if ($this->debug) |
|
786 | + { |
|
787 | + error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'{$allValues[0]['dn']}',".array2string($newData).')'); |
|
788 | + } |
|
753 | 789 | |
754 | 790 | return ldap_modify ($ds, $allValues[0]['dn'], $newData); |
755 | 791 | } |
@@ -795,7 +831,11 @@ discard block |
||
795 | 831 | $mailboxes = array(); |
796 | 832 | foreach($entries as $entry) |
797 | 833 | { |
798 | - if ($entry[static::USER_ATTR][0] == 'anonymous') continue; // anonymous is never a mail-user! |
|
834 | + if ($entry[static::USER_ATTR][0] == 'anonymous') |
|
835 | + { |
|
836 | + continue; |
|
837 | + } |
|
838 | + // anonymous is never a mail-user! |
|
799 | 839 | list($mailbox) = explode('@', $entry[static::MAILBOX_ATTR ? static::MAILBOX_ATTR : static::MAIL_ATTR][0]); |
800 | 840 | $mailboxes[$entry[static::USER_ATTR][0]] = $mailbox; |
801 | 841 | } |
@@ -812,8 +852,14 @@ discard block |
||
812 | 852 | protected static function setAttributePrefix(&$attribute, $values, $prefix='') |
813 | 853 | { |
814 | 854 | //$attribute_in = $attribute; |
815 | - if (empty($attribute)) $attribute = array(); |
|
816 | - if (!is_array($attribute)) $attribute = (array)$attribute; |
|
855 | + if (empty($attribute)) |
|
856 | + { |
|
857 | + $attribute = array(); |
|
858 | + } |
|
859 | + if (!is_array($attribute)) |
|
860 | + { |
|
861 | + $attribute = (array)$attribute; |
|
862 | + } |
|
817 | 863 | |
818 | 864 | foreach((array)$values as $value) |
819 | 865 | { |
@@ -843,12 +889,18 @@ discard block |
||
843 | 889 | { |
844 | 890 | if (!$prefix || stripos($value, $prefix) === 0) |
845 | 891 | { |
846 | - if ($remove) unset($attribute[$key]); |
|
892 | + if ($remove) |
|
893 | + { |
|
894 | + unset($attribute[$key]); |
|
895 | + } |
|
847 | 896 | $values[] = substr($value, strlen($prefix)); |
848 | 897 | } |
849 | 898 | } |
850 | 899 | // reindex $attribute, if neccessary |
851 | - if ($values && $attribute) $attribute = array_values($attribute); |
|
900 | + if ($values && $attribute) |
|
901 | + { |
|
902 | + $attribute = array_values($attribute); |
|
903 | + } |
|
852 | 904 | } |
853 | 905 | //error_log(__METHOD__."(".array2string($attribute_in).", '$prefix', $remove) attribute=".array2string($attribute).' returning '.array2string($values)); |
854 | 906 | return $values; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param string $defaultDomain =null |
166 | 166 | */ |
167 | - function __construct($defaultDomain=null) |
|
167 | + function __construct($defaultDomain = null) |
|
168 | 168 | { |
169 | 169 | parent::__construct($defaultDomain); |
170 | 170 | |
@@ -212,9 +212,8 @@ discard block |
||
212 | 212 | */ |
213 | 213 | function addAccount($_hookValues) |
214 | 214 | { |
215 | - $mailLocalAddress = $_hookValues['account_email'] ? $_hookValues['account_email'] : |
|
216 | - Api\Accounts::email($_hookValues['account_firstname'], |
|
217 | - $_hookValues['account_lastname'],$_hookValues['account_lid'],$this->defaultDomain); |
|
215 | + $mailLocalAddress = $_hookValues['account_email'] ? $_hookValues['account_email'] : Api\Accounts::email($_hookValues['account_firstname'], |
|
216 | + $_hookValues['account_lastname'], $_hookValues['account_lid'], $this->defaultDomain); |
|
218 | 217 | |
219 | 218 | $ds = $this->getLdapConnection(); |
220 | 219 | |
@@ -226,13 +225,13 @@ discard block |
||
226 | 225 | } |
227 | 226 | $allValues = ldap_get_entries($ds, $sri); |
228 | 227 | $accountDN = $allValues[0]['dn']; |
229 | - $objectClasses = $allValues[0]['objectclass']; |
|
228 | + $objectClasses = $allValues[0]['objectclass']; |
|
230 | 229 | unset($objectClasses['count']); |
231 | 230 | |
232 | 231 | // add our mail schema, if not already set |
233 | - if(!in_array(static::SCHEMA,$objectClasses) && !in_array(strtolower(static::SCHEMA),$objectClasses)) |
|
232 | + if (!in_array(static::SCHEMA, $objectClasses) && !in_array(strtolower(static::SCHEMA), $objectClasses)) |
|
234 | 233 | { |
235 | - $objectClasses[] = static::SCHEMA; |
|
234 | + $objectClasses[] = static::SCHEMA; |
|
236 | 235 | } |
237 | 236 | // the new code for postfix+cyrus+ldap |
238 | 237 | $newData = array( |
@@ -263,7 +262,7 @@ discard block |
||
263 | 262 | { |
264 | 263 | error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'$accountDN',". |
265 | 264 | array2string($newData).') returning '.array2string($ret). |
266 | - (!$ret?' ('.ldap_error($ds).')':'')); |
|
265 | + (!$ret ? ' ('.ldap_error($ds).')' : '')); |
|
267 | 266 | } |
268 | 267 | return $ret; |
269 | 268 | } |
@@ -277,7 +276,7 @@ discard block |
||
277 | 276 | */ |
278 | 277 | function addAccountExtra(array $_hookValues, array $allValues, array &$newData) |
279 | 278 | { |
280 | - unset($_hookValues, $allValues, $newData); // not used, but required by function signature |
|
279 | + unset($_hookValues, $allValues, $newData); // not used, but required by function signature |
|
281 | 280 | } |
282 | 281 | |
283 | 282 | /** |
@@ -288,24 +287,24 @@ discard block |
||
288 | 287 | */ |
289 | 288 | function getAccountEmailAddress($_accountName) |
290 | 289 | { |
291 | - $emailAddresses = array(); |
|
290 | + $emailAddresses = array(); |
|
292 | 291 | $ds = $this->getLdapConnection(); |
293 | 292 | $filter = '(&'.static::USER_FILTER.'('.static::USER_ATTR.'='.Api\Ldap::quote($_accountName).'))'; |
294 | - $attributes = array('dn', static::MAIL_ATTR, static::ALIAS_ATTR); |
|
293 | + $attributes = array('dn', static::MAIL_ATTR, static::ALIAS_ATTR); |
|
295 | 294 | $sri = @ldap_search($ds, $this->search_base, $filter, $attributes); |
296 | 295 | |
297 | 296 | if ($sri) |
298 | 297 | { |
299 | - $realName = trim($GLOBALS['egw_info']['user']['account_firstname'] . (!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '') . $GLOBALS['egw_info']['user']['account_lastname']); |
|
298 | + $realName = trim($GLOBALS['egw_info']['user']['account_firstname'].(!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '').$GLOBALS['egw_info']['user']['account_lastname']); |
|
300 | 299 | $allValues = ldap_get_entries($ds, $sri); |
301 | 300 | |
302 | - if(isset($allValues[0][static::MAIL_ATTR])) |
|
301 | + if (isset($allValues[0][static::MAIL_ATTR])) |
|
303 | 302 | { |
304 | - foreach($allValues[0][static::MAIL_ATTR] as $key => $value) |
|
303 | + foreach ($allValues[0][static::MAIL_ATTR] as $key => $value) |
|
305 | 304 | { |
306 | 305 | if ($key === 'count') continue; |
307 | 306 | |
308 | - $emailAddresses[] = array ( |
|
307 | + $emailAddresses[] = array( |
|
309 | 308 | 'name' => $realName, |
310 | 309 | 'address' => $value, |
311 | 310 | 'type' => !$key ? 'default' : 'alternate', |
@@ -314,7 +313,7 @@ discard block |
||
314 | 313 | } |
315 | 314 | if (static::ALIAS_ATTR && isset($allValues[0][static::ALIAS_ATTR])) |
316 | 315 | { |
317 | - foreach(self::getAttributePrefix($allValues[0][static::ALIAS_ATTR], static::ALIAS_PREFIX) as $value) |
|
316 | + foreach (self::getAttributePrefix($allValues[0][static::ALIAS_ATTR], static::ALIAS_PREFIX) as $value) |
|
318 | 317 | { |
319 | 318 | $emailAddresses[] = array( |
320 | 319 | 'name' => $realName, |
@@ -341,7 +340,7 @@ discard block |
||
341 | 340 | * @return array with values for keys 'mailLocalAddress', 'mailAlternateAddress' (array), 'mailForwardingAddress' (array), |
342 | 341 | * 'accountStatus' ("active"), 'quotaLimit' and 'deliveryMode' ("forwardOnly") |
343 | 342 | */ |
344 | - function getUserData($user, $match_uid_at_domain=false) |
|
343 | + function getUserData($user, $match_uid_at_domain = false) |
|
345 | 344 | { |
346 | 345 | $userData = array( |
347 | 346 | 'mailbox' => array(), |
@@ -401,7 +400,7 @@ discard block |
||
401 | 400 | $allValues = ldap_get_entries($ldap, $sri); |
402 | 401 | if ($this->debug) error_log(__METHOD__."('$user') --> ldap_search(, '$this->search_base', '$filter') --> ldap_get_entries=".array2string($allValues[0])); |
403 | 402 | |
404 | - foreach($allValues as $key => $values) |
|
403 | + foreach ($allValues as $key => $values) |
|
405 | 404 | { |
406 | 405 | if ($key === 'count') continue; |
407 | 406 | |
@@ -504,16 +503,16 @@ discard block |
||
504 | 503 | // remember if server returned forward-attribute |
505 | 504 | $this->forward_attr_returned = isset($values[static::FORWARD_ATTR]); |
506 | 505 | |
507 | - $userData['mailForwardingAddress'] = self::getAttributePrefix($values[static::FORWARD_ATTR], static::FORWARD_PREFIX); |
|
506 | + $userData['mailForwardingAddress'] = self::getAttributePrefix($values[static::FORWARD_ATTR], static::FORWARD_PREFIX); |
|
508 | 507 | } |
509 | 508 | |
510 | - if (static::MAILBOX_ATTR) $userData['mailMessageStore'] = $values[static::MAILBOX_ATTR][0]; |
|
509 | + if (static::MAILBOX_ATTR) $userData['mailMessageStore'] = $values[static::MAILBOX_ATTR][0]; |
|
511 | 510 | |
512 | 511 | $userData['deliveryMode'] = $deliveryMode; |
513 | 512 | |
514 | 513 | // eg. suse stores all email addresses as aliases |
515 | 514 | if (static::REQUIRE_MAIL_AS_ALIAS && |
516 | - ($k = array_search($userData['mailLocalAddress'],$userData['mailAlternateAddress'])) !== false) |
|
515 | + ($k = array_search($userData['mailLocalAddress'], $userData['mailAlternateAddress'])) !== false) |
|
517 | 516 | { |
518 | 517 | unset($userData['mailAlternateAddress'][$k]); |
519 | 518 | $userData['mailAlternateAddress'] = array_values($userData['mailAlternateAddress']); |
@@ -547,9 +546,9 @@ discard block |
||
547 | 546 | * @return boolean true on success, false on error writing to ldap |
548 | 547 | */ |
549 | 548 | function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode, |
550 | - $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false, $_setMailbox=null) |
|
549 | + $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only = false, $_setMailbox = null) |
|
551 | 550 | { |
552 | - unset($_forwarding_only); // not used |
|
551 | + unset($_forwarding_only); // not used |
|
553 | 552 | |
554 | 553 | if (static::USERID_ATTR) |
555 | 554 | { |
@@ -569,15 +568,15 @@ discard block |
||
569 | 568 | $allValues = ldap_get_entries($ldap, $sri); |
570 | 569 | |
571 | 570 | $accountDN = $allValues[0]['dn']; |
572 | - $uid = $allValues[0][static::USER_ATTR][0]; |
|
573 | - $objectClasses = $allValues[0]['objectclass']; |
|
571 | + $uid = $allValues[0][static::USER_ATTR][0]; |
|
572 | + $objectClasses = $allValues[0]['objectclass']; |
|
574 | 573 | |
575 | 574 | unset($objectClasses['count']); |
576 | 575 | |
577 | - if(!in_array(static::SCHEMA,$objectClasses) && !in_array(strtolower(static::SCHEMA),$objectClasses)) |
|
576 | + if (!in_array(static::SCHEMA, $objectClasses) && !in_array(strtolower(static::SCHEMA), $objectClasses)) |
|
578 | 577 | { |
579 | - $objectClasses[] = static::SCHEMA; |
|
580 | - $newData['objectclass'] = $objectClasses; |
|
578 | + $objectClasses[] = static::SCHEMA; |
|
579 | + $newData['objectclass'] = $objectClasses; |
|
581 | 580 | } |
582 | 581 | |
583 | 582 | sort($_mailAlternateAddress); |
@@ -590,7 +589,7 @@ discard block |
||
590 | 589 | self::setAttributePrefix($newData[static::ALIAS_ATTR], $_mailAlternateAddress, static::ALIAS_PREFIX); |
591 | 590 | |
592 | 591 | // all email must be stored as alias for suse |
593 | - if (static::REQUIRE_MAIL_AS_ALIAS && !in_array($_mailLocalAddress,(array)$_mailAlternateAddress)) |
|
592 | + if (static::REQUIRE_MAIL_AS_ALIAS && !in_array($_mailLocalAddress, (array)$_mailAlternateAddress)) |
|
594 | 593 | { |
595 | 594 | self::setAttributePrefix($newData[static::ALIAS_ATTR], $_mailLocalAddress, static::ALIAS_PREFIX); |
596 | 595 | } |
@@ -628,12 +627,12 @@ discard block |
||
628 | 627 | if (static::QUOTA_ATTR) |
629 | 628 | { |
630 | 629 | self::setAttributePrefix($newData[static::QUOTA_ATTR], |
631 | - (int)$_quota > 0 ? (int)$_quota*static::QUOTA_FACTOR : array(), static::QUOTA_PREFIX); |
|
630 | + (int)$_quota > 0 ? (int)$_quota * static::QUOTA_FACTOR : array(), static::QUOTA_PREFIX); |
|
632 | 631 | } |
633 | 632 | // does schema support enabling/disabling mail via attribute |
634 | 633 | if (static::MAIL_ENABLE_ATTR) |
635 | 634 | { |
636 | - $newData[static::MAIL_ENABLE_ATTR] = $_accountStatus ? |
|
635 | + $newData[static::MAIL_ENABLE_ATTR] = $_accountStatus ? |
|
637 | 636 | (static::MAIL_ENABLED == self::MAIL_ENABLED_USE_MAIL ? $_mailLocalAddress : static::MAIL_ENABLED) : array(); |
638 | 637 | } |
639 | 638 | // if we have no mail-enabled attribute, but require primary mail in aliases-attr |
@@ -681,7 +680,7 @@ discard block |
||
681 | 680 | $uid = $GLOBALS['egw']->accounts->id2name($_accountID); |
682 | 681 | $filter = '(&'.static::USER_FILTER.'('.static::USER_ATTR.'='.Api\Ldap::quote($uid).'))'; |
683 | 682 | } |
684 | - $attributes = array('dn', static::MAIL_ATTR, static::FORWARD_ATTR, 'objectclass'); |
|
683 | + $attributes = array('dn', static::MAIL_ATTR, static::FORWARD_ATTR, 'objectclass'); |
|
685 | 684 | if (static::FORWARD_ONLY_ATTR) |
686 | 685 | { |
687 | 686 | $attributes[] = static::FORWARD_ONLY_ATTR; |
@@ -692,12 +691,12 @@ discard block |
||
692 | 691 | { |
693 | 692 | $newData = array(); |
694 | 693 | $allValues = ldap_get_entries($ds, $sri); |
695 | - $objectClasses = $allValues[0]['objectclass']; |
|
696 | - $newData['objectclass'] = $allValues[0]['objectclass']; |
|
694 | + $objectClasses = $allValues[0]['objectclass']; |
|
695 | + $newData['objectclass'] = $allValues[0]['objectclass']; |
|
697 | 696 | |
698 | 697 | unset($newData['objectclass']['count']); |
699 | 698 | |
700 | - if(!in_array(static::SCHEMA,$objectClasses)) |
|
699 | + if (!in_array(static::SCHEMA, $objectClasses)) |
|
701 | 700 | { |
702 | 701 | $newData['objectclass'][] = static::SCHEMA; |
703 | 702 | } |
@@ -707,9 +706,9 @@ discard block |
||
707 | 706 | $newData[static::FORWARD_ATTR] = $allValues[0][static::FORWARD_ATTR]; |
708 | 707 | $forwards = self::getAttributePrefix($newData[static::FORWARD_ATTR], static::FORWARD_PREFIX); |
709 | 708 | |
710 | - if(!empty($_forwardingAddress)) |
|
709 | + if (!empty($_forwardingAddress)) |
|
711 | 710 | { |
712 | - if($forwards) |
|
711 | + if ($forwards) |
|
713 | 712 | { |
714 | 713 | if (!is_array($_forwardingAddress)) |
715 | 714 | { |
@@ -752,7 +751,7 @@ discard block |
||
752 | 751 | } |
753 | 752 | if ($this->debug) error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'{$allValues[0]['dn']}',".array2string($newData).')'); |
754 | 753 | |
755 | - return ldap_modify ($ds, $allValues[0]['dn'], $newData); |
|
754 | + return ldap_modify($ds, $allValues[0]['dn'], $newData); |
|
756 | 755 | } |
757 | 756 | } |
758 | 757 | |
@@ -794,9 +793,9 @@ discard block |
||
794 | 793 | unset($entries['count']); |
795 | 794 | |
796 | 795 | $mailboxes = array(); |
797 | - foreach($entries as $entry) |
|
796 | + foreach ($entries as $entry) |
|
798 | 797 | { |
799 | - if ($entry[static::USER_ATTR][0] == 'anonymous') continue; // anonymous is never a mail-user! |
|
798 | + if ($entry[static::USER_ATTR][0] == 'anonymous') continue; // anonymous is never a mail-user! |
|
800 | 799 | list($mailbox) = explode('@', $entry[static::MAILBOX_ATTR ? static::MAILBOX_ATTR : static::MAIL_ATTR][0]); |
801 | 800 | $mailboxes[$entry[static::USER_ATTR][0]] = $mailbox; |
802 | 801 | } |
@@ -810,13 +809,13 @@ discard block |
||
810 | 809 | * @param string|array $values value(s) to set |
811 | 810 | * @param string $prefix ='' prefix to use or '' |
812 | 811 | */ |
813 | - protected static function setAttributePrefix(&$attribute, $values, $prefix='') |
|
812 | + protected static function setAttributePrefix(&$attribute, $values, $prefix = '') |
|
814 | 813 | { |
815 | 814 | //$attribute_in = $attribute; |
816 | 815 | if (empty($attribute)) $attribute = array(); |
817 | 816 | if (!is_array($attribute)) $attribute = (array)$attribute; |
818 | 817 | |
819 | - foreach((array)$values as $value) |
|
818 | + foreach ((array)$values as $value) |
|
820 | 819 | { |
821 | 820 | $attribute[] = $prefix.$value; |
822 | 821 | } |
@@ -831,7 +830,7 @@ discard block |
||
831 | 830 | * @param boolean $remove =true remove returned values from $attribute |
832 | 831 | * @return array with values (prefix removed) or array() if nothing found |
833 | 832 | */ |
834 | - protected static function getAttributePrefix(&$attribute, $prefix='', $remove=true) |
|
833 | + protected static function getAttributePrefix(&$attribute, $prefix = '', $remove = true) |
|
835 | 834 | { |
836 | 835 | //$attribute_in = $attribute; |
837 | 836 | $values = array(); |
@@ -840,7 +839,7 @@ discard block |
||
840 | 839 | { |
841 | 840 | unset($attribute['count']); |
842 | 841 | |
843 | - foreach($attribute as $key => $value) |
|
842 | + foreach ($attribute as $key => $value) |
|
844 | 843 | { |
845 | 844 | if (!$prefix || stripos($value, $prefix) === 0) |
846 | 845 | { |
@@ -311,6 +311,7 @@ discard block |
||
311 | 311 | * Encrypt the variables in the session |
312 | 312 | * |
313 | 313 | * Is called by self::__destruct(). |
314 | + * @param string $kp3 |
|
314 | 315 | */ |
315 | 316 | static function encrypt($kp3) |
316 | 317 | { |
@@ -439,7 +440,7 @@ discard block |
||
439 | 440 | * @param boolean $no_session =false dont create a real session, eg. for GroupDAV clients using only basic auth, no cookie support |
440 | 441 | * @param boolean $auth_check =true if false, the user is loged in without checking his password (eg. for single sign on), default = true |
441 | 442 | * @param boolean $fail_on_forced_password_change =false true: do NOT create session, if password change requested |
442 | - * @return string|boolean session id or false if session was not created, $this->(cd_)reason contains cause |
|
443 | + * @return false|string session id or false if session was not created, $this->(cd_)reason contains cause |
|
443 | 444 | */ |
444 | 445 | function create($login,$passwd = '',$passwd_type = '',$no_session=false,$auth_check=true,$fail_on_forced_password_change=false) |
445 | 446 | { |
@@ -1021,7 +1022,7 @@ discard block |
||
1021 | 1022 | /** |
1022 | 1023 | * Terminate a session |
1023 | 1024 | * |
1024 | - * @param int|string $sessionid nummeric or php session id of session to be terminated |
|
1025 | + * @param string $sessionid nummeric or php session id of session to be terminated |
|
1025 | 1026 | * @param string $kp3 |
1026 | 1027 | * @return boolean true on success, false on error |
1027 | 1028 | */ |
@@ -80,60 +80,60 @@ discard block |
||
80 | 80 | const MCRYPT_MODE = MCRYPT_MODE_ECB; |
81 | 81 | |
82 | 82 | /** |
83 | - * current user login (account_lid@domain) |
|
84 | - * |
|
85 | - * @var string |
|
86 | - */ |
|
83 | + * current user login (account_lid@domain) |
|
84 | + * |
|
85 | + * @var string |
|
86 | + */ |
|
87 | 87 | var $login; |
88 | 88 | |
89 | 89 | /** |
90 | - * current user password |
|
91 | - * |
|
92 | - * @var string |
|
93 | - */ |
|
90 | + * current user password |
|
91 | + * |
|
92 | + * @var string |
|
93 | + */ |
|
94 | 94 | var $passwd; |
95 | 95 | |
96 | 96 | /** |
97 | - * current user db/ldap account id |
|
98 | - * |
|
99 | - * @var int |
|
100 | - */ |
|
97 | + * current user db/ldap account id |
|
98 | + * |
|
99 | + * @var int |
|
100 | + */ |
|
101 | 101 | var $account_id; |
102 | 102 | |
103 | 103 | /** |
104 | - * current user account login id (without the eGW-domain/-instance part |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
104 | + * current user account login id (without the eGW-domain/-instance part |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | 108 | var $account_lid; |
109 | 109 | |
110 | 110 | /** |
111 | - * domain for current user |
|
112 | - * |
|
113 | - * @var string |
|
114 | - */ |
|
111 | + * domain for current user |
|
112 | + * |
|
113 | + * @var string |
|
114 | + */ |
|
115 | 115 | var $account_domain; |
116 | 116 | |
117 | 117 | /** |
118 | - * type flag, A - anonymous session, N - None, normal session |
|
119 | - * |
|
120 | - * @var string |
|
121 | - */ |
|
118 | + * type flag, A - anonymous session, N - None, normal session |
|
119 | + * |
|
120 | + * @var string |
|
121 | + */ |
|
122 | 122 | var $session_flags; |
123 | 123 | |
124 | 124 | /** |
125 | - * current user session id |
|
126 | - * |
|
127 | - * @var string |
|
128 | - */ |
|
125 | + * current user session id |
|
126 | + * |
|
127 | + * @var string |
|
128 | + */ |
|
129 | 129 | var $sessionid; |
130 | 130 | |
131 | 131 | /** |
132 | - * an other session specific id (md5 from a random string), |
|
133 | - * used together with the sessionid for xmlrpc basic auth and the encryption of session-data (if that's enabled) |
|
134 | - * |
|
135 | - * @var string |
|
136 | - */ |
|
132 | + * an other session specific id (md5 from a random string), |
|
133 | + * used together with the sessionid for xmlrpc basic auth and the encryption of session-data (if that's enabled) |
|
134 | + * |
|
135 | + * @var string |
|
136 | + */ |
|
137 | 137 | var $kp3; |
138 | 138 | |
139 | 139 | /** |
@@ -144,17 +144,17 @@ discard block |
||
144 | 144 | var $sessionid_access_log; |
145 | 145 | |
146 | 146 | /** |
147 | - * name of XML-RPC/SOAP method called |
|
148 | - * |
|
149 | - * @var string |
|
150 | - */ |
|
147 | + * name of XML-RPC/SOAP method called |
|
148 | + * |
|
149 | + * @var string |
|
150 | + */ |
|
151 | 151 | var $xmlrpc_method_called; |
152 | 152 | |
153 | 153 | /** |
154 | - * Array with the name of the system domains |
|
155 | - * |
|
156 | - * @var array |
|
157 | - */ |
|
154 | + * Array with the name of the system domains |
|
155 | + * |
|
156 | + * @var array |
|
157 | + */ |
|
158 | 158 | private $egw_domains; |
159 | 159 | |
160 | 160 | /** |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | |
249 | 249 | // set session_timeout from global php.ini and default to 14400=4h, if not set |
250 | 250 | if (!($GLOBALS['egw_info']['server']['sessions_timeout'] = ini_get('session.gc_maxlifetime'))) |
251 | - { |
|
252 | - ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); |
|
253 | - } |
|
251 | + { |
|
252 | + ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); |
|
253 | + } |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | const ACCESS_LOG_TABLE = 'egw_access_log'; |
662 | 662 | |
663 | 663 | /** |
664 | - * Write or update (for logout) the access_log |
|
665 | - * |
|
666 | - * @param string|int $sessionid nummeric or PHP session id or 0 for unsuccessful logins |
|
667 | - * @param string $login ='' account_lid (evtl. with domain) or '' for setting the logout-time |
|
668 | - * @param string $user_ip ='' ip to log |
|
669 | - * @param int $account_id =0 numerical account_id |
|
670 | - * @return int $sessionid primary key of egw_access_log for login, null otherwise |
|
671 | - */ |
|
664 | + * Write or update (for logout) the access_log |
|
665 | + * |
|
666 | + * @param string|int $sessionid nummeric or PHP session id or 0 for unsuccessful logins |
|
667 | + * @param string $login ='' account_lid (evtl. with domain) or '' for setting the logout-time |
|
668 | + * @param string $user_ip ='' ip to log |
|
669 | + * @param int $account_id =0 numerical account_id |
|
670 | + * @return int $sessionid primary key of egw_access_log for login, null otherwise |
|
671 | + */ |
|
672 | 672 | private function log_access($sessionid,$login='',$user_ip='',$account_id=0) |
673 | 673 | { |
674 | 674 | $now = time(); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | |
717 | 717 | /** |
718 | 718 | * Protect against brute force attacks, block login if too many unsuccessful login attmepts |
719 | - * |
|
719 | + * |
|
720 | 720 | * @param string $login account_lid (evtl. with domain) |
721 | 721 | * @param string $ip ip of the user |
722 | 722 | * @returns bool login blocked? |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | // set session_timeout from global php.ini and default to 14400=4h, if not set |
257 | 257 | if (!($GLOBALS['egw_info']['server']['sessions_timeout'] = ini_get('session.gc_maxlifetime'))) |
258 | - { |
|
258 | + { |
|
259 | 259 | ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); |
260 | 260 | } |
261 | 261 | } |
@@ -292,7 +292,10 @@ discard block |
||
292 | 292 | */ |
293 | 293 | function commit_session() |
294 | 294 | { |
295 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() sessionid=$this->sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]).' '.function_backtrace()); |
|
295 | + if (self::ERROR_LOG_DEBUG) |
|
296 | + { |
|
297 | + error_log(__METHOD__."() sessionid=$this->sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]).' '.function_backtrace()); |
|
298 | + } |
|
296 | 299 | self::encrypt($this->kp3); |
297 | 300 | |
298 | 301 | session_write_close(); |
@@ -354,7 +357,10 @@ discard block |
||
354 | 357 | */ |
355 | 358 | static function log_session_usage(&$arr,$label,$recursion=true,$limit=1000) |
356 | 359 | { |
357 | - if (!is_array($arr)) return; |
|
360 | + if (!is_array($arr)) |
|
361 | + { |
|
362 | + return; |
|
363 | + } |
|
358 | 364 | |
359 | 365 | $sizes = array(); |
360 | 366 | foreach($arr as $key => &$data) |
@@ -369,7 +375,10 @@ discard block |
||
369 | 375 | if ($diff > $limit) |
370 | 376 | { |
371 | 377 | error_log("strlen({$label}[$key])=".Vfs::hsize($size).", diff=".Vfs::hsize($diff)); |
372 | - if ($recursion) self::log_session_usage($arr[$key],$label.'['.$key.']',$recursion,$limit); |
|
378 | + if ($recursion) |
|
379 | + { |
|
380 | + self::log_session_usage($arr[$key],$label.'['.$key.']',$recursion,$limit); |
|
381 | + } |
|
373 | 382 | } |
374 | 383 | } |
375 | 384 | } |
@@ -467,7 +476,10 @@ discard block |
||
467 | 476 | $this->passwd = $passwd; |
468 | 477 | $this->passwd_type = $passwd_type; |
469 | 478 | } |
470 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) starting ..."); |
|
479 | + if (self::ERROR_LOG_DEBUG) |
|
480 | + { |
|
481 | + error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) starting ..."); |
|
482 | + } |
|
471 | 483 | |
472 | 484 | self::split_login_domain($login,$this->account_lid,$this->account_domain); |
473 | 485 | // add domain to the login, if not already there |
@@ -511,7 +523,10 @@ discard block |
||
511 | 523 | { |
512 | 524 | $this->log_access($this->reason,$login,$user_ip,0); // log unsuccessfull login |
513 | 525 | } |
514 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
|
526 | + if (self::ERROR_LOG_DEBUG) |
|
527 | + { |
|
528 | + error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
|
529 | + } |
|
515 | 530 | return false; |
516 | 531 | } |
517 | 532 | if ($fail_on_forced_password_change && Auth::check_password_change($this->reason) === false) |
@@ -561,7 +576,10 @@ discard block |
||
561 | 576 | $this->reason = 'account is expired'; |
562 | 577 | $this->cd_reason = self::CD_ACCOUNT_EXPIRED; |
563 | 578 | |
564 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
|
579 | + if (self::ERROR_LOG_DEBUG) |
|
580 | + { |
|
581 | + error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
|
582 | + } |
|
565 | 583 | return false; |
566 | 584 | } |
567 | 585 | |
@@ -585,25 +603,34 @@ discard block |
||
585 | 603 | 'passwd' => $this->passwd, |
586 | 604 | 'account_domain' => $this->account_domain, |
587 | 605 | 'user_ip' => $user_ip, |
588 | - ),'',true))) // true = run hooks from all apps, not just the ones the current user has perms to run |
|
606 | + ),'',true))) |
|
607 | + { |
|
608 | + // true = run hooks from all apps, not just the ones the current user has perms to run |
|
589 | 609 | { |
590 | 610 | foreach($hook_result as $reason) |
591 | 611 | { |
592 | 612 | if ($reason) // called hook requests to deny the session |
593 | 613 | { |
594 | 614 | $this->reason = $this->cd_reason = $reason; |
615 | + } |
|
595 | 616 | $this->log_access($this->reason,$login,$user_ip,0); // log unsuccessfull login |
596 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
|
617 | + if (self::ERROR_LOG_DEBUG) |
|
618 | + { |
|
619 | + error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
|
620 | + } |
|
597 | 621 | return false; |
598 | 622 | } |
599 | 623 | } |
600 | 624 | } |
601 | 625 | $GLOBALS['egw']->db->transaction_begin(); |
602 | 626 | $this->register_session($this->login,$user_ip,$now,$this->session_flags); |
603 | - if ($this->session_flags != 'A') // dont log anonymous sessions |
|
627 | + if ($this->session_flags != 'A') |
|
628 | + { |
|
629 | + // dont log anonymous sessions |
|
604 | 630 | { |
605 | 631 | $this->sessionid_access_log = $this->log_access($this->sessionid,$login,$user_ip,$this->account_id); |
606 | 632 | } |
633 | + } |
|
607 | 634 | Cache::setSession('phpgwapi', 'account_previous_login', $GLOBALS['egw']->auth->previous_login); |
608 | 635 | $GLOBALS['egw']->accounts->update_lastlogin($this->account_id,$user_ip); |
609 | 636 | $GLOBALS['egw']->db->transaction_commit(); |
@@ -619,7 +646,10 @@ discard block |
||
619 | 646 | self::egw_setcookie('last_loginid', $this->account_lid ,$now+1209600); /* For 2 weeks */ |
620 | 647 | self::egw_setcookie('last_domain',$this->account_domain,$now+1209600); |
621 | 648 | } |
622 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid"); |
|
649 | + if (self::ERROR_LOG_DEBUG) |
|
650 | + { |
|
651 | + error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid"); |
|
652 | + } |
|
623 | 653 | |
624 | 654 | return $this->sessionid; |
625 | 655 | } |
@@ -773,10 +803,13 @@ discard block |
||
773 | 803 | //error_log(__METHOD__."('$login', '$ip') false_ip=$false_ip, false_id=$false_id --> blocked=".array2string($blocked)); |
774 | 804 | |
775 | 805 | if ($blocked && $GLOBALS['egw_info']['server']['admin_mails'] && |
776 | - $GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time()-5*60) // max. one mail every 5mins |
|
806 | + $GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time()-5*60) |
|
807 | + { |
|
808 | + // max. one mail every 5mins |
|
777 | 809 | { |
778 | 810 | try { |
779 | 811 | $mailer = new Mailer(); |
812 | + } |
|
780 | 813 | // notify admin(s) via email |
781 | 814 | $mailer->setFrom('eGroupWare@'.$GLOBALS['egw_info']['server']['mail_suffix']); |
782 | 815 | $mailer->addHeader('Subject', lang("eGroupWare: login blocked for user '%1', IP %2",$login,$ip)); |
@@ -854,7 +887,10 @@ discard block |
||
854 | 887 | { |
855 | 888 | $sessionid = false; |
856 | 889 | } |
857 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true)); |
|
890 | + if (self::ERROR_LOG_DEBUG) |
|
891 | + { |
|
892 | + error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true)); |
|
893 | + } |
|
858 | 894 | return $sessionid; |
859 | 895 | } |
860 | 896 | |
@@ -884,7 +920,10 @@ discard block |
||
884 | 920 | */ |
885 | 921 | function verify($sessionid=null,$kp3=null) |
886 | 922 | { |
887 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace()); |
|
923 | + if (self::ERROR_LOG_DEBUG) |
|
924 | + { |
|
925 | + error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace()); |
|
926 | + } |
|
888 | 927 | |
889 | 928 | $fill_egw_info_and_repositories = !$GLOBALS['egw_info']['flags']['restored_from_session']; |
890 | 929 | |
@@ -900,7 +939,10 @@ discard block |
||
900 | 939 | |
901 | 940 | if (!$this->sessionid) |
902 | 941 | { |
903 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') get_sessionid()='".self::get_sessionid()."' No session ID"); |
|
942 | + if (self::ERROR_LOG_DEBUG) |
|
943 | + { |
|
944 | + error_log(__METHOD__."('$sessionid') get_sessionid()='".self::get_sessionid()."' No session ID"); |
|
945 | + } |
|
904 | 946 | return false; |
905 | 947 | } |
906 | 948 | |
@@ -912,14 +954,20 @@ discard block |
||
912 | 954 | // check if we have a eGroupware session --> return false if not (but dont destroy it!) |
913 | 955 | if (is_null($_SESSION) || !isset($_SESSION[self::EGW_SESSION_VAR])) |
914 | 956 | { |
915 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session does NOT exist!"); |
|
957 | + if (self::ERROR_LOG_DEBUG) |
|
958 | + { |
|
959 | + error_log(__METHOD__."('$sessionid') session does NOT exist!"); |
|
960 | + } |
|
916 | 961 | return false; |
917 | 962 | } |
918 | 963 | $session =& $_SESSION[self::EGW_SESSION_VAR]; |
919 | 964 | |
920 | 965 | if ($session['session_dla'] <= time() - $GLOBALS['egw_info']['server']['sessions_timeout']) |
921 | 966 | { |
922 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session timed out!"); |
|
967 | + if (self::ERROR_LOG_DEBUG) |
|
968 | + { |
|
969 | + error_log(__METHOD__."('$sessionid') session timed out!"); |
|
970 | + } |
|
923 | 971 | $this->destroy($sessionid,$kp3); |
924 | 972 | return false; |
925 | 973 | } |
@@ -947,7 +995,10 @@ discard block |
||
947 | 995 | $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid,'account_lid','u'); |
948 | 996 | if (!$this->account_id) |
949 | 997 | { |
950 | - if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) !accounts::name2id('$this->account_lid')"); |
|
998 | + if (self::ERROR_LOG_DEBUG) |
|
999 | + { |
|
1000 | + error_log("*** Session::verify($sessionid) !accounts::name2id('$this->account_lid')"); |
|
1001 | + } |
|
951 | 1002 | return false; |
952 | 1003 | } |
953 | 1004 | |
@@ -965,7 +1016,10 @@ discard block |
||
965 | 1016 | |
966 | 1017 | if ($GLOBALS['egw']->accounts->is_expired($GLOBALS['egw_info']['user'])) |
967 | 1018 | { |
968 | - if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) accounts is expired"); |
|
1019 | + if (self::ERROR_LOG_DEBUG) |
|
1020 | + { |
|
1021 | + error_log("*** Session::verify($sessionid) accounts is expired"); |
|
1022 | + } |
|
969 | 1023 | return false; |
970 | 1024 | } |
971 | 1025 | $this->passwd = base64_decode(Cache::getSession('phpgwapi', 'password')); |
@@ -976,7 +1030,10 @@ discard block |
||
976 | 1030 | } |
977 | 1031 | if ($this->account_domain != $GLOBALS['egw_info']['user']['domain']) |
978 | 1032 | { |
979 | - if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) wrong domain"); |
|
1033 | + if (self::ERROR_LOG_DEBUG) |
|
1034 | + { |
|
1035 | + error_log("*** Session::verify($sessionid) wrong domain"); |
|
1036 | + } |
|
980 | 1037 | return false; |
981 | 1038 | } |
982 | 1039 | |
@@ -985,7 +1042,10 @@ discard block |
||
985 | 1042 | if (strtoupper(substr(PHP_OS,0,3)) != 'WIN' && (!$GLOBALS['egw_info']['user']['session_ip'] || |
986 | 1043 | $GLOBALS['egw_info']['user']['session_ip'] != $this->getuser_ip())) |
987 | 1044 | { |
988 | - if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) wrong IP"); |
|
1045 | + if (self::ERROR_LOG_DEBUG) |
|
1046 | + { |
|
1047 | + error_log("*** Session::verify($sessionid) wrong IP"); |
|
1048 | + } |
|
989 | 1049 | return false; |
990 | 1050 | } |
991 | 1051 | } |
@@ -998,7 +1058,10 @@ discard block |
||
998 | 1058 | } |
999 | 1059 | if (!$this->account_lid) |
1000 | 1060 | { |
1001 | - if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) !account_lid"); |
|
1061 | + if (self::ERROR_LOG_DEBUG) |
|
1062 | + { |
|
1063 | + error_log("*** Session::verify($sessionid) !account_lid"); |
|
1064 | + } |
|
1002 | 1065 | return false; |
1003 | 1066 | } |
1004 | 1067 | |
@@ -1017,13 +1080,19 @@ discard block |
||
1017 | 1080 | $_REQUEST[self::EGW_SESSION_NAME] === $this->sessionid && |
1018 | 1081 | (!isset($_COOKIE[self::EGW_SESSION_NAME]) || $_COOKIE[self::EGW_SESSION_NAME] !== $_REQUEST[self::EGW_SESSION_NAME])) |
1019 | 1082 | { |
1020 | - if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now"); |
|
1083 | + if (self::ERROR_LOG_DEBUG) |
|
1084 | + { |
|
1085 | + error_log("--> Session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now"); |
|
1086 | + } |
|
1021 | 1087 | self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid); |
1022 | 1088 | self::egw_setcookie('kp3',$this->kp3); |
1023 | 1089 | self::egw_setcookie('domain',$this->account_domain); |
1024 | 1090 | } |
1025 | 1091 | |
1026 | - if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS"); |
|
1092 | + if (self::ERROR_LOG_DEBUG) |
|
1093 | + { |
|
1094 | + error_log("--> Session::verify($sessionid) SUCCESS"); |
|
1095 | + } |
|
1027 | 1096 | |
1028 | 1097 | return true; |
1029 | 1098 | } |
@@ -1043,14 +1112,20 @@ discard block |
||
1043 | 1112 | } |
1044 | 1113 | $this->log_access($sessionid); // log logout-time |
1045 | 1114 | |
1046 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($sessionid,$kp3)"); |
|
1115 | + if (self::ERROR_LOG_DEBUG) |
|
1116 | + { |
|
1117 | + error_log(__METHOD__."($sessionid,$kp3)"); |
|
1118 | + } |
|
1047 | 1119 | |
1048 | - if (is_numeric($sessionid)) // do we have a access-log-id --> get PHP session id |
|
1120 | + if (is_numeric($sessionid)) |
|
1121 | + { |
|
1122 | + // do we have a access-log-id --> get PHP session id |
|
1049 | 1123 | { |
1050 | 1124 | $sessionid = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE,'session_php',array( |
1051 | 1125 | 'sessionid' => $sessionid, |
1052 | 1126 | ),__LINE__,__FILE__)->fetchColumn(); |
1053 | 1127 | } |
1128 | + } |
|
1054 | 1129 | |
1055 | 1130 | Hooks::process(array( |
1056 | 1131 | 'location' => 'session_destroyed', |
@@ -1060,7 +1135,10 @@ discard block |
||
1060 | 1135 | // Only do the following, if where working with the current user |
1061 | 1136 | if (!$GLOBALS['egw_info']['user']['sessionid'] || $sessionid == $GLOBALS['egw_info']['user']['sessionid']) |
1062 | 1137 | { |
1063 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__." ********* about to call session_destroy!"); |
|
1138 | + if (self::ERROR_LOG_DEBUG) |
|
1139 | + { |
|
1140 | + error_log(__METHOD__." ********* about to call session_destroy!"); |
|
1141 | + } |
|
1064 | 1142 | session_unset(); |
1065 | 1143 | @session_destroy(); |
1066 | 1144 | // we need to (re-)load the eGW session-handler, as session_destroy unloads custom session-handlers |
@@ -1155,7 +1233,10 @@ discard block |
||
1155 | 1233 | } |
1156 | 1234 | else |
1157 | 1235 | { |
1158 | - if ($othervars) $extravars .= ($extravars?'&':'').$othervars; |
|
1236 | + if ($othervars) |
|
1237 | + { |
|
1238 | + $extravars .= ($extravars?'&':'').$othervars; |
|
1239 | + } |
|
1159 | 1240 | } |
1160 | 1241 | |
1161 | 1242 | // parse extravars string into the vars array |
@@ -1164,7 +1245,11 @@ discard block |
||
1164 | 1245 | foreach(explode('&',$extravars) as $expr) |
1165 | 1246 | { |
1166 | 1247 | list($var,$val) = explode('=', $expr,2); |
1167 | - if (strpos($val,'%26') != false) $val = str_replace('%26','&',$val); // make sure to not double encode & |
|
1248 | + if (strpos($val,'%26') != false) |
|
1249 | + { |
|
1250 | + $val = str_replace('%26','&',$val); |
|
1251 | + } |
|
1252 | + // make sure to not double encode & |
|
1168 | 1253 | if (substr($var,-2) == '[]') |
1169 | 1254 | { |
1170 | 1255 | $vars[substr($var,0,-2)][] = $val; |
@@ -1245,14 +1330,22 @@ discard block |
||
1245 | 1330 | { |
1246 | 1331 | self::set_cookiedomain(); |
1247 | 1332 | } |
1248 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($cookiename,$cookievalue,$cookietime,$cookiepath,".self::$cookie_domain.")"); |
|
1333 | + if (self::ERROR_LOG_DEBUG) |
|
1334 | + { |
|
1335 | + error_log(__METHOD__."($cookiename,$cookievalue,$cookietime,$cookiepath,".self::$cookie_domain.")"); |
|
1336 | + } |
|
1249 | 1337 | |
1250 | 1338 | // if we are installed in iOS as web-app, we must not set a cookietime==0 (session-cookie), |
1251 | 1339 | // as every change between apps will cause the cookie to get lost |
1252 | 1340 | static $is_iOS = null; |
1253 | - if (!$cookietime && !isset($is_iOS)) $is_iOS = (bool)preg_match('/^(iPhone|iPad|iPod)/i', Header\UserAgent::mobile()); |
|
1341 | + if (!$cookietime && !isset($is_iOS)) |
|
1342 | + { |
|
1343 | + $is_iOS = (bool)preg_match('/^(iPhone|iPad|iPod)/i', Header\UserAgent::mobile()); |
|
1344 | + } |
|
1254 | 1345 | |
1255 | - if(!headers_sent()) // gives only a warning, but can not send the cookie anyway |
|
1346 | + if(!headers_sent()) |
|
1347 | + { |
|
1348 | + // gives only a warning, but can not send the cookie anyway |
|
1256 | 1349 | { |
1257 | 1350 | setcookie($cookiename, $cookievalue, |
1258 | 1351 | !$cookietime && $is_iOS ? time()+self::IOS_SESSION_COOKIE_LIFETIME : $cookietime, |
@@ -1260,6 +1353,7 @@ discard block |
||
1260 | 1353 | // if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true) |
1261 | 1354 | empty($GLOBALS['egw_info']['server']['insecure_cookies']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off', true); |
1262 | 1355 | } |
1356 | + } |
|
1263 | 1357 | } |
1264 | 1358 | |
1265 | 1359 | /** |
@@ -1311,15 +1405,25 @@ discard block |
||
1311 | 1405 | */ |
1312 | 1406 | public static function search_instance($login,$domain_requested,&$default_domain,$server_names,array $domains=null) |
1313 | 1407 | { |
1314 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$login','$domain_requested',".array2string($default_domain).".".array2string($server_names).".".array2string($domains).")"); |
|
1408 | + if (self::ERROR_LOG_DEBUG) |
|
1409 | + { |
|
1410 | + error_log(__METHOD__."('$login','$domain_requested',".array2string($default_domain).".".array2string($server_names).".".array2string($domains).")"); |
|
1411 | + } |
|
1315 | 1412 | |
1316 | - if (is_null($domains)) $domains = $GLOBALS['egw_domain']; |
|
1413 | + if (is_null($domains)) |
|
1414 | + { |
|
1415 | + $domains = $GLOBALS['egw_domain']; |
|
1416 | + } |
|
1317 | 1417 | |
1318 | - if (!isset($default_domain) || !isset($domains[$default_domain])) // allow to overwrite the default domain |
|
1418 | + if (!isset($default_domain) || !isset($domains[$default_domain])) |
|
1419 | + { |
|
1420 | + // allow to overwrite the default domain |
|
1319 | 1421 | { |
1320 | 1422 | foreach((array)$server_names as $server_name) |
1321 | 1423 | { |
1322 | - list($server_name) = explode(':', $server_name); // remove port from HTTP_HOST |
|
1424 | + list($server_name) = explode(':', $server_name); |
|
1425 | + } |
|
1426 | + // remove port from HTTP_HOST |
|
1323 | 1427 | if(isset($domains[$server_name])) |
1324 | 1428 | { |
1325 | 1429 | $default_domain = $server_name; |
@@ -1344,11 +1448,14 @@ discard block |
||
1344 | 1448 | } |
1345 | 1449 | } |
1346 | 1450 | } |
1347 | - if (isset($login)) // on login |
|
1451 | + if (isset($login)) |
|
1452 | + { |
|
1453 | + // on login |
|
1348 | 1454 | { |
1349 | 1455 | if (strpos($login,'@') === false || count($domains) == 1) |
1350 | 1456 | { |
1351 | 1457 | $login .= '@' . (isset($_POST['logindomain']) ? $_POST['logindomain'] : $default_domain); |
1458 | + } |
|
1352 | 1459 | } |
1353 | 1460 | $parts = explode('@',$login); |
1354 | 1461 | $domain = array_pop($parts); |
@@ -1362,7 +1469,10 @@ discard block |
||
1362 | 1469 | { |
1363 | 1470 | $domain = $default_domain; |
1364 | 1471 | } |
1365 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() default_domain=".array2string($default_domain).', login='.array2string($login)." returning ".array2string($domain)); |
|
1472 | + if (self::ERROR_LOG_DEBUG) |
|
1473 | + { |
|
1474 | + error_log(__METHOD__."() default_domain=".array2string($default_domain).', login='.array2string($login)." returning ".array2string($domain)); |
|
1475 | + } |
|
1366 | 1476 | |
1367 | 1477 | return $domain; |
1368 | 1478 | } |
@@ -1401,7 +1511,10 @@ discard block |
||
1401 | 1511 | $action = $_SERVER['PHP_SELF']; |
1402 | 1512 | // remove EGroupware path, if not installed in webroot |
1403 | 1513 | $egw_path = $GLOBALS['egw_info']['server']['webserver_url']; |
1404 | - if ($egw_path[0] != '/') $egw_path = parse_url($egw_path,PHP_URL_PATH); |
|
1514 | + if ($egw_path[0] != '/') |
|
1515 | + { |
|
1516 | + $egw_path = parse_url($egw_path,PHP_URL_PATH); |
|
1517 | + } |
|
1405 | 1518 | if ($action == '/Microsoft-Server-ActiveSync') |
1406 | 1519 | { |
1407 | 1520 | $action .= '?Cmd='.$_GET['Cmd'].'&DeviceId='.$_GET['DeviceId']; |
@@ -1427,7 +1540,10 @@ discard block |
||
1427 | 1540 | |
1428 | 1541 | $_SESSION[self::EGW_SESSION_VAR]['session_dla'] = time(); |
1429 | 1542 | $_SESSION[self::EGW_SESSION_VAR]['session_action'] = $this->action; |
1430 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__.'() _SESSION['.self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR])); |
|
1543 | + if (self::ERROR_LOG_DEBUG) |
|
1544 | + { |
|
1545 | + error_log(__METHOD__.'() _SESSION['.self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR])); |
|
1546 | + } |
|
1431 | 1547 | |
1432 | 1548 | return $this->action; |
1433 | 1549 | } |
@@ -1561,10 +1677,16 @@ discard block |
||
1561 | 1677 | self::cache_control(); |
1562 | 1678 | $ok = session_start(); |
1563 | 1679 | self::decrypt(); |
1564 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() sessionid=$sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR])); |
|
1680 | + if (self::ERROR_LOG_DEBUG) |
|
1681 | + { |
|
1682 | + error_log(__METHOD__."() sessionid=$sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR])); |
|
1683 | + } |
|
1565 | 1684 | return $ok; |
1566 | 1685 | } |
1567 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() no active session!"); |
|
1686 | + if (self::ERROR_LOG_DEBUG) |
|
1687 | + { |
|
1688 | + error_log(__METHOD__."() no active session!"); |
|
1689 | + } |
|
1568 | 1690 | |
1569 | 1691 | return false; |
1570 | 1692 | } |
@@ -1622,9 +1744,12 @@ discard block |
||
1622 | 1744 | error_log(__METHOD__."($expire) called, but header already sent in $file: $line"); |
1623 | 1745 | return; |
1624 | 1746 | } |
1625 | - if($expire === true) // same behavior as session_cache_limiter('private_no_expire') |
|
1747 | + if($expire === true) |
|
1748 | + { |
|
1749 | + // same behavior as session_cache_limiter('private_no_expire') |
|
1626 | 1750 | { |
1627 | 1751 | header('Cache-Control: private, max-age='.(60*session_cache_expire())); |
1752 | + } |
|
1628 | 1753 | header_remove('Expires'); |
1629 | 1754 | } |
1630 | 1755 | elseif ($private) |
@@ -1638,10 +1763,13 @@ discard block |
||
1638 | 1763 | header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expire) . ' GMT'); |
1639 | 1764 | } |
1640 | 1765 | // remove Pragma header, might be set by old header |
1641 | - if (function_exists('header_remove')) // PHP 5.3+ |
|
1766 | + if (function_exists('header_remove')) |
|
1767 | + { |
|
1768 | + // PHP 5.3+ |
|
1642 | 1769 | { |
1643 | 1770 | header_remove('Pragma'); |
1644 | 1771 | } |
1772 | + } |
|
1645 | 1773 | else |
1646 | 1774 | { |
1647 | 1775 | header('Pragma:'); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | const CD_BAD_LOGIN_OR_PASSWORD = 5; |
174 | 174 | const CD_FORCE_PASSWORD_CHANGE = 97; |
175 | 175 | const CD_ACCOUNT_EXPIRED = 98; |
176 | - const CD_BLOCKED = 99; // to many failed attempts to loing |
|
176 | + const CD_BLOCKED = 99; // to many failed attempts to loing |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Verbose reason why session creation failed |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param array $domain_names =null domain-names used in this install |
196 | 196 | */ |
197 | - function __construct(array $domain_names=null) |
|
197 | + function __construct(array $domain_names = null) |
|
198 | 198 | { |
199 | 199 | $this->required_files = $_SESSION[self::EGW_REQUIRED_FILES]; |
200 | 200 | |
@@ -210,27 +210,27 @@ discard block |
||
210 | 210 | $save_rep = false; |
211 | 211 | if (!isset($GLOBALS['egw_info']['server']['max_access_log_age'])) |
212 | 212 | { |
213 | - $GLOBALS['egw_info']['server']['max_access_log_age'] = 90; // default 90 days |
|
213 | + $GLOBALS['egw_info']['server']['max_access_log_age'] = 90; // default 90 days |
|
214 | 214 | $save_rep = true; |
215 | 215 | } |
216 | 216 | if (!isset($GLOBALS['egw_info']['server']['block_time'])) |
217 | 217 | { |
218 | - $GLOBALS['egw_info']['server']['block_time'] = 1; // default 1min, its enough to slow down brute force attacks |
|
218 | + $GLOBALS['egw_info']['server']['block_time'] = 1; // default 1min, its enough to slow down brute force attacks |
|
219 | 219 | $save_rep = true; |
220 | 220 | } |
221 | 221 | if (!isset($GLOBALS['egw_info']['server']['num_unsuccessful_id'])) |
222 | 222 | { |
223 | - $GLOBALS['egw_info']['server']['num_unsuccessful_id'] = 3; // default 3 trys per id |
|
223 | + $GLOBALS['egw_info']['server']['num_unsuccessful_id'] = 3; // default 3 trys per id |
|
224 | 224 | $save_rep = true; |
225 | 225 | } |
226 | 226 | if (!isset($GLOBALS['egw_info']['server']['num_unsuccessful_ip'])) |
227 | 227 | { |
228 | - $GLOBALS['egw_info']['server']['num_unsuccessful_ip'] = $GLOBALS['egw_info']['server']['num_unsuccessful_id'] * 5; // default is 5 times as high as the id default; since accessing via proxy is quite common |
|
228 | + $GLOBALS['egw_info']['server']['num_unsuccessful_ip'] = $GLOBALS['egw_info']['server']['num_unsuccessful_id'] * 5; // default is 5 times as high as the id default; since accessing via proxy is quite common |
|
229 | 229 | $save_rep = true; |
230 | 230 | } |
231 | 231 | if (!isset($GLOBALS['egw_info']['server']['install_id'])) |
232 | 232 | { |
233 | - $GLOBALS['egw_info']['server']['install_id'] = md5(Auth::randomstring(15)); |
|
233 | + $GLOBALS['egw_info']['server']['install_id'] = md5(Auth::randomstring(15)); |
|
234 | 234 | } |
235 | 235 | if (!isset($GLOBALS['egw_info']['server']['max_history'])) |
236 | 236 | { |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | { |
243 | 243 | $config = new Config('phpgwapi'); |
244 | 244 | $config->read_repository(); |
245 | - $config->value('max_access_log_age',$GLOBALS['egw_info']['server']['max_access_log_age']); |
|
246 | - $config->value('block_time',$GLOBALS['egw_info']['server']['block_time']); |
|
247 | - $config->value('num_unsuccessful_id',$GLOBALS['egw_info']['server']['num_unsuccessful_id']); |
|
248 | - $config->value('num_unsuccessful_ip',$GLOBALS['egw_info']['server']['num_unsuccessful_ip']); |
|
249 | - $config->value('install_id',$GLOBALS['egw_info']['server']['install_id']); |
|
250 | - $config->value('max_history',$GLOBALS['egw_info']['server']['max_history']); |
|
245 | + $config->value('max_access_log_age', $GLOBALS['egw_info']['server']['max_access_log_age']); |
|
246 | + $config->value('block_time', $GLOBALS['egw_info']['server']['block_time']); |
|
247 | + $config->value('num_unsuccessful_id', $GLOBALS['egw_info']['server']['num_unsuccessful_id']); |
|
248 | + $config->value('num_unsuccessful_ip', $GLOBALS['egw_info']['server']['num_unsuccessful_ip']); |
|
249 | + $config->value('install_id', $GLOBALS['egw_info']['server']['install_id']); |
|
250 | + $config->value('max_history', $GLOBALS['egw_info']['server']['max_history']); |
|
251 | 251 | $config->save_repository(); |
252 | 252 | } |
253 | 253 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | // set session_timeout from global php.ini and default to 14400=4h, if not set |
257 | 257 | if (!($GLOBALS['egw_info']['server']['sessions_timeout'] = ini_get('session.gc_maxlifetime'))) |
258 | 258 | { |
259 | - ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); |
|
259 | + ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout'] = 14400); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
@@ -329,15 +329,15 @@ discard block |
||
329 | 329 | |
330 | 330 | if (!isset($_SESSION[self::EGW_SESSION_ENCRYPTED]) && self::init_crypt($kp3)) |
331 | 331 | { |
332 | - foreach(self::$egw_session_vars as $name) |
|
332 | + foreach (self::$egw_session_vars as $name) |
|
333 | 333 | { |
334 | 334 | if (isset($_SESSION[$name])) |
335 | 335 | { |
336 | - $_SESSION[$name] = mcrypt_generic(self::$mcrypt,serialize($_SESSION[$name])); |
|
336 | + $_SESSION[$name] = mcrypt_generic(self::$mcrypt, serialize($_SESSION[$name])); |
|
337 | 337 | //error_log(__METHOD__."() 'encrypting' session var: $name, len=".strlen($_SESSION[$name])); |
338 | 338 | } |
339 | 339 | } |
340 | - $_SESSION[self::EGW_SESSION_ENCRYPTED] = true; // flag session as encrypted |
|
340 | + $_SESSION[self::EGW_SESSION_ENCRYPTED] = true; // flag session as encrypted |
|
341 | 341 | |
342 | 342 | mcrypt_generic_deinit(self::$mcrypt); |
343 | 343 | self::$mcrypt = null; |
@@ -352,24 +352,24 @@ discard block |
||
352 | 352 | * @param boolean $recursion =true if true call itself for every item > $limit |
353 | 353 | * @param int $limit =1000 log only differences > $limit |
354 | 354 | */ |
355 | - static function log_session_usage(&$arr,$label,$recursion=true,$limit=1000) |
|
355 | + static function log_session_usage(&$arr, $label, $recursion = true, $limit = 1000) |
|
356 | 356 | { |
357 | 357 | if (!is_array($arr)) return; |
358 | 358 | |
359 | 359 | $sizes = array(); |
360 | - foreach($arr as $key => &$data) |
|
360 | + foreach ($arr as $key => &$data) |
|
361 | 361 | { |
362 | 362 | $sizes[$key] = strlen(serialize($data)); |
363 | 363 | } |
364 | - arsort($sizes,SORT_NUMERIC); |
|
365 | - foreach($sizes as $key => $size) |
|
364 | + arsort($sizes, SORT_NUMERIC); |
|
365 | + foreach ($sizes as $key => $size) |
|
366 | 366 | { |
367 | 367 | $diff = $size - (int)$_SESSION[$label.'-sizes'][$key]; |
368 | 368 | $_SESSION[$label.'-sizes'][$key] = $size; |
369 | 369 | if ($diff > $limit) |
370 | 370 | { |
371 | 371 | error_log("strlen({$label}[$key])=".Vfs::hsize($size).", diff=".Vfs::hsize($diff)); |
372 | - if ($recursion) self::log_session_usage($arr[$key],$label.'['.$key.']',$recursion,$limit); |
|
372 | + if ($recursion) self::log_session_usage($arr[$key], $label.'['.$key.']', $recursion, $limit); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
@@ -384,15 +384,15 @@ discard block |
||
384 | 384 | { |
385 | 385 | if ($_SESSION[self::EGW_SESSION_ENCRYPTED] && self::init_crypt(self::get_request('kp3'))) |
386 | 386 | { |
387 | - foreach(self::$egw_session_vars as $name) |
|
387 | + foreach (self::$egw_session_vars as $name) |
|
388 | 388 | { |
389 | 389 | if (isset($_SESSION[$name])) |
390 | 390 | { |
391 | - $_SESSION[$name] = unserialize(trim(mdecrypt_generic(self::$mcrypt,$_SESSION[$name]))); |
|
391 | + $_SESSION[$name] = unserialize(trim(mdecrypt_generic(self::$mcrypt, $_SESSION[$name]))); |
|
392 | 392 | //error_log(__METHOD__."() 'decrypting' session var $name: gettype($name) = ".gettype($_SESSION[$name])); |
393 | 393 | } |
394 | 394 | } |
395 | - unset($_SESSION[self::EGW_SESSION_ENCRYPTED]); // delete encryption flag |
|
395 | + unset($_SESSION[self::EGW_SESSION_ENCRYPTED]); // delete encryption flag |
|
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | * @param string $mode =self::MCRYPT_MODE |
406 | 406 | * @return boolean true if encryption is used, false otherwise |
407 | 407 | */ |
408 | - static private function init_crypt($kp3,$algo=self::MCRYPT_ALGO,$mode=self::MCRYPT_MODE) |
|
408 | + static private function init_crypt($kp3, $algo = self::MCRYPT_ALGO, $mode = self::MCRYPT_MODE) |
|
409 | 409 | { |
410 | - if(!$GLOBALS['egw_info']['server']['mcrypt_enabled']) |
|
410 | + if (!$GLOBALS['egw_info']['server']['mcrypt_enabled']) |
|
411 | 411 | { |
412 | - return false; // session encryption is switched off |
|
412 | + return false; // session encryption is switched off |
|
413 | 413 | } |
414 | 414 | if ($GLOBALS['egw_info']['currentapp'] == 'syncml' || !$kp3) |
415 | 415 | { |
416 | - $kp3 = 'staticsyncmlkp3'; // syncml has no kp3! |
|
416 | + $kp3 = 'staticsyncmlkp3'; // syncml has no kp3! |
|
417 | 417 | } |
418 | 418 | if (is_null(self::$mcrypt)) |
419 | 419 | { |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | } |
430 | 430 | $iv_size = mcrypt_enc_get_iv_size(self::$mcrypt); |
431 | 431 | $iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ? |
432 | - mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size); |
|
432 | + mcrypt_create_iv($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'], 0, $iv_size); |
|
433 | 433 | |
434 | - if (mcrypt_generic_init(self::$mcrypt,$kp3, $iv) < 0) |
|
434 | + if (mcrypt_generic_init(self::$mcrypt, $kp3, $iv) < 0) |
|
435 | 435 | { |
436 | 436 | error_log(__METHOD__."() could not initialise mcrypt, sessions get NOT encrypted!"); |
437 | 437 | return self::$mcrypt = false; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @param boolean $fail_on_forced_password_change =false true: do NOT create session, if password change requested |
452 | 452 | * @return string|boolean session id or false if session was not created, $this->(cd_)reason contains cause |
453 | 453 | */ |
454 | - function create($login,$passwd = '',$passwd_type = '',$no_session=false,$auth_check=true,$fail_on_forced_password_change=false) |
|
454 | + function create($login, $passwd = '', $passwd_type = '', $no_session = false, $auth_check = true, $fail_on_forced_password_change = false) |
|
455 | 455 | { |
456 | 456 | try { |
457 | 457 | if (is_array($login)) |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | } |
470 | 470 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) starting ..."); |
471 | 471 | |
472 | - self::split_login_domain($login,$this->account_lid,$this->account_domain); |
|
472 | + self::split_login_domain($login, $this->account_lid, $this->account_domain); |
|
473 | 473 | // add domain to the login, if not already there |
474 | - if (substr($this->login,-strlen($this->account_domain)-1) != '@'.$this->account_domain) |
|
474 | + if (substr($this->login, -strlen($this->account_domain) - 1) != '@'.$this->account_domain) |
|
475 | 475 | { |
476 | 476 | $this->login .= '@'.$this->account_domain; |
477 | 477 | } |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | { |
489 | 489 | $this->account_domain = $GLOBALS['egw_info']['user']['domain']; |
490 | 490 | } |
491 | - elseif($this->account_domain != $GLOBALS['egw_info']['user']['domain']) |
|
491 | + elseif ($this->account_domain != $GLOBALS['egw_info']['user']['domain']) |
|
492 | 492 | { |
493 | 493 | throw new Exception("Wrong domain! '$this->account_domain' != '{$GLOBALS['egw_info']['user']['domain']}'"); |
494 | 494 | } |
@@ -496,9 +496,9 @@ discard block |
||
496 | 496 | |
497 | 497 | $user_ip = self::getuser_ip(); |
498 | 498 | |
499 | - $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid,'account_lid','u'); |
|
499 | + $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid, 'account_lid', 'u'); |
|
500 | 500 | |
501 | - if (($blocked = $this->login_blocked($login,$user_ip)) || // too many unsuccessful attempts |
|
501 | + if (($blocked = $this->login_blocked($login, $user_ip)) || // too many unsuccessful attempts |
|
502 | 502 | $GLOBALS['egw_info']['server']['global_denied_users'][$this->account_lid] || |
503 | 503 | $auth_check && !$GLOBALS['egw']->auth->authenticate($this->account_lid, $this->passwd, $this->passwd_type) || |
504 | 504 | $this->account_id && $GLOBALS['egw']->accounts->get_type($this->account_id) == 'g') |
@@ -507,9 +507,9 @@ discard block |
||
507 | 507 | $this->cd_reason = $blocked ? self::CD_BLOCKED : self::CD_BAD_LOGIN_OR_PASSWORD; |
508 | 508 | |
509 | 509 | // we dont log anon users as it would block the website |
510 | - if (!$GLOBALS['egw']->acl->get_specific_rights_for_account($this->account_id,'anonymous','phpgwapi')) |
|
510 | + if (!$GLOBALS['egw']->acl->get_specific_rights_for_account($this->account_id, 'anonymous', 'phpgwapi')) |
|
511 | 511 | { |
512 | - $this->log_access($this->reason,$login,$user_ip,0); // log unsuccessfull login |
|
512 | + $this->log_access($this->reason, $login, $user_ip, 0); // log unsuccessfull login |
|
513 | 513 | } |
514 | 514 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
515 | 515 | return false; |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | if ($this->account_lid != ($lid = $GLOBALS['egw']->accounts->id2name($this->account_id))) |
532 | 532 | { |
533 | 533 | $this->account_lid = $lid; |
534 | - $this->login = $lid.substr($this->login,strlen($lid)); |
|
534 | + $this->login = $lid.substr($this->login, strlen($lid)); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | $GLOBALS['egw_info']['user']['account_id'] = $this->account_id; |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | } |
554 | 554 | $this->sessionid = session_id(); |
555 | 555 | } |
556 | - $this->kp3 = Auth::randomstring(24); |
|
556 | + $this->kp3 = Auth::randomstring(24); |
|
557 | 557 | |
558 | 558 | $GLOBALS['egw_info']['user'] = $this->read_repositories(); |
559 | 559 | if ($GLOBALS['egw']->accounts->is_expired($GLOBALS['egw_info']['user'])) |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | Cache::setSession('phpgwapi', 'password', base64_encode($this->passwd)); |
569 | 569 | |
570 | - if ($GLOBALS['egw']->acl->check('anonymous',1,'phpgwapi')) |
|
570 | + if ($GLOBALS['egw']->acl->check('anonymous', 1, 'phpgwapi')) |
|
571 | 571 | { |
572 | 572 | $this->session_flags = 'A'; |
573 | 573 | } |
@@ -585,46 +585,46 @@ discard block |
||
585 | 585 | 'passwd' => $this->passwd, |
586 | 586 | 'account_domain' => $this->account_domain, |
587 | 587 | 'user_ip' => $user_ip, |
588 | - ),'',true))) // true = run hooks from all apps, not just the ones the current user has perms to run |
|
588 | + ), '', true))) // true = run hooks from all apps, not just the ones the current user has perms to run |
|
589 | 589 | { |
590 | - foreach($hook_result as $reason) |
|
590 | + foreach ($hook_result as $reason) |
|
591 | 591 | { |
592 | 592 | if ($reason) // called hook requests to deny the session |
593 | 593 | { |
594 | 594 | $this->reason = $this->cd_reason = $reason; |
595 | - $this->log_access($this->reason,$login,$user_ip,0); // log unsuccessfull login |
|
595 | + $this->log_access($this->reason, $login, $user_ip, 0); // log unsuccessfull login |
|
596 | 596 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)"); |
597 | 597 | return false; |
598 | 598 | } |
599 | 599 | } |
600 | 600 | } |
601 | 601 | $GLOBALS['egw']->db->transaction_begin(); |
602 | - $this->register_session($this->login,$user_ip,$now,$this->session_flags); |
|
602 | + $this->register_session($this->login, $user_ip, $now, $this->session_flags); |
|
603 | 603 | if ($this->session_flags != 'A') // dont log anonymous sessions |
604 | 604 | { |
605 | - $this->sessionid_access_log = $this->log_access($this->sessionid,$login,$user_ip,$this->account_id); |
|
605 | + $this->sessionid_access_log = $this->log_access($this->sessionid, $login, $user_ip, $this->account_id); |
|
606 | 606 | } |
607 | 607 | Cache::setSession('phpgwapi', 'account_previous_login', $GLOBALS['egw']->auth->previous_login); |
608 | - $GLOBALS['egw']->accounts->update_lastlogin($this->account_id,$user_ip); |
|
608 | + $GLOBALS['egw']->accounts->update_lastlogin($this->account_id, $user_ip); |
|
609 | 609 | $GLOBALS['egw']->db->transaction_commit(); |
610 | 610 | |
611 | 611 | if ($GLOBALS['egw_info']['server']['usecookies'] && !$no_session) |
612 | 612 | { |
613 | - self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid); |
|
614 | - self::egw_setcookie('kp3',$this->kp3); |
|
615 | - self::egw_setcookie('domain',$this->account_domain); |
|
613 | + self::egw_setcookie(self::EGW_SESSION_NAME, $this->sessionid); |
|
614 | + self::egw_setcookie('kp3', $this->kp3); |
|
615 | + self::egw_setcookie('domain', $this->account_domain); |
|
616 | 616 | } |
617 | 617 | if ($GLOBALS['egw_info']['server']['usecookies'] && !$no_session || isset($_COOKIE['last_loginid'])) |
618 | 618 | { |
619 | - self::egw_setcookie('last_loginid', $this->account_lid ,$now+1209600); /* For 2 weeks */ |
|
620 | - self::egw_setcookie('last_domain',$this->account_domain,$now+1209600); |
|
619 | + self::egw_setcookie('last_loginid', $this->account_lid, $now + 1209600); /* For 2 weeks */ |
|
620 | + self::egw_setcookie('last_domain', $this->account_domain, $now + 1209600); |
|
621 | 621 | } |
622 | 622 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid"); |
623 | 623 | |
624 | 624 | return $this->sessionid; |
625 | 625 | } |
626 | 626 | // catch all exceptions, as their (allways logged) trace (eg. on a database error) would contain the user password |
627 | - catch(Exception $e) { |
|
627 | + catch (Exception $e) { |
|
628 | 628 | $this->reason = $this->cd_reason = $e->getMessage(); |
629 | 629 | error_log(__METHOD__."('$login', ".array2string(str_repeat('*', strlen($passwd))). |
630 | 630 | ", '$passwd_type', no_session=".array2string($no_session). |
@@ -643,13 +643,12 @@ discard block |
||
643 | 643 | * @param int $now |
644 | 644 | * @param string $session_flags |
645 | 645 | */ |
646 | - private function register_session($login,$user_ip,$now,$session_flags) |
|
646 | + private function register_session($login, $user_ip, $now, $session_flags) |
|
647 | 647 | { |
648 | 648 | // restore session vars set before session was started |
649 | 649 | if (is_array($this->required_files)) |
650 | 650 | { |
651 | - $_SESSION[self::EGW_REQUIRED_FILES] = !is_array($_SESSION[self::EGW_REQUIRED_FILES]) ? $this->required_files : |
|
652 | - array_unique(array_merge($_SESSION[self::EGW_REQUIRED_FILES],$this->required_files)); |
|
651 | + $_SESSION[self::EGW_REQUIRED_FILES] = !is_array($_SESSION[self::EGW_REQUIRED_FILES]) ? $this->required_files : array_unique(array_merge($_SESSION[self::EGW_REQUIRED_FILES], $this->required_files)); |
|
653 | 652 | unset($this->required_files); |
654 | 653 | } |
655 | 654 | $_SESSION[self::EGW_SESSION_VAR] = array( |
@@ -679,13 +678,13 @@ discard block |
||
679 | 678 | * @param int $account_id =0 numerical account_id |
680 | 679 | * @return int $sessionid primary key of egw_access_log for login, null otherwise |
681 | 680 | */ |
682 | - private function log_access($sessionid,$login='',$user_ip='',$account_id=0) |
|
681 | + private function log_access($sessionid, $login = '', $user_ip = '', $account_id = 0) |
|
683 | 682 | { |
684 | 683 | $now = time(); |
685 | 684 | |
686 | 685 | if ($login) |
687 | 686 | { |
688 | - $GLOBALS['egw']->db->insert(self::ACCESS_LOG_TABLE,array( |
|
687 | + $GLOBALS['egw']->db->insert(self::ACCESS_LOG_TABLE, array( |
|
689 | 688 | 'session_php' => $sessionid, |
690 | 689 | 'loginid' => $login, |
691 | 690 | 'ip' => $user_ip, |
@@ -693,10 +692,10 @@ discard block |
||
693 | 692 | 'account_id'=> $account_id, |
694 | 693 | 'user_agent'=> $_SERVER['HTTP_USER_AGENT'], |
695 | 694 | 'session_dla' => $now, |
696 | - 'session_action' => $this->update_dla(false), // dont update egw_access_log |
|
697 | - ),false,__LINE__,__FILE__); |
|
695 | + 'session_action' => $this->update_dla(false), // dont update egw_access_log |
|
696 | + ), false, __LINE__, __FILE__); |
|
698 | 697 | |
699 | - $ret = $GLOBALS['egw']->db->get_last_insert_id(self::ACCESS_LOG_TABLE,'sessionid'); |
|
698 | + $ret = $GLOBALS['egw']->db->get_last_insert_id(self::ACCESS_LOG_TABLE, 'sessionid'); |
|
700 | 699 | } |
701 | 700 | else |
702 | 701 | { |
@@ -704,20 +703,20 @@ discard block |
||
704 | 703 | { |
705 | 704 | $sessionid = $this->sessionid_access_log; |
706 | 705 | } |
707 | - $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE,array( |
|
706 | + $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE, array( |
|
708 | 707 | 'lo' => $now |
709 | - ),is_numeric($sessionid) ? array( |
|
708 | + ), is_numeric($sessionid) ? array( |
|
710 | 709 | 'sessionid' => $sessionid, |
711 | 710 | ) : array( |
712 | 711 | 'session_php' => $sessionid, |
713 | - ),__LINE__,__FILE__); |
|
712 | + ), __LINE__, __FILE__); |
|
714 | 713 | |
715 | 714 | // run maintenance only on logout, to not delay login |
716 | 715 | if ($GLOBALS['egw_info']['server']['max_access_log_age']) |
717 | 716 | { |
718 | 717 | $max_age = $now - $GLOBALS['egw_info']['server']['max_access_log_age'] * 24 * 60 * 60; |
719 | 718 | |
720 | - $GLOBALS['egw']->db->delete(self::ACCESS_LOG_TABLE,"li < $max_age",__LINE__,__FILE__); |
|
719 | + $GLOBALS['egw']->db->delete(self::ACCESS_LOG_TABLE, "li < $max_age", __LINE__, __FILE__); |
|
721 | 720 | } |
722 | 721 | } |
723 | 722 | //error_log(__METHOD__."('$sessionid', '$login', '$user_ip', $account_id) returning ".array2string($ret)); |
@@ -731,12 +730,12 @@ discard block |
||
731 | 730 | * @param string $ip ip of the user |
732 | 731 | * @returns bool login blocked? |
733 | 732 | */ |
734 | - private function login_blocked($login,$ip) |
|
733 | + private function login_blocked($login, $ip) |
|
735 | 734 | { |
736 | 735 | $block_time = time() - $GLOBALS['egw_info']['server']['block_time'] * 60; |
737 | 736 | |
738 | 737 | $false_id = $false_ip = 0; |
739 | - foreach($GLOBALS['egw']->db->union(array( |
|
738 | + foreach ($GLOBALS['egw']->db->union(array( |
|
740 | 739 | array( |
741 | 740 | 'table' => self::ACCESS_LOG_TABLE, |
742 | 741 | 'cols' => "'false_ip' AS name,COUNT(*) AS num", |
@@ -773,28 +772,28 @@ discard block |
||
773 | 772 | //error_log(__METHOD__."('$login', '$ip') false_ip=$false_ip, false_id=$false_id --> blocked=".array2string($blocked)); |
774 | 773 | |
775 | 774 | if ($blocked && $GLOBALS['egw_info']['server']['admin_mails'] && |
776 | - $GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time()-5*60) // max. one mail every 5mins |
|
775 | + $GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time() - 5 * 60) // max. one mail every 5mins |
|
777 | 776 | { |
778 | 777 | try { |
779 | 778 | $mailer = new Mailer(); |
780 | 779 | // notify admin(s) via email |
781 | 780 | $mailer->setFrom('eGroupWare@'.$GLOBALS['egw_info']['server']['mail_suffix']); |
782 | - $mailer->addHeader('Subject', lang("eGroupWare: login blocked for user '%1', IP %2",$login,$ip)); |
|
783 | - $mailer->setBody(lang("Too many unsucessful attempts to login: %1 for the user '%2', %3 for the IP %4",$false_id,$login,$false_ip,$ip)); |
|
784 | - foreach(preg_split('/,\s*/',$GLOBALS['egw_info']['server']['admin_mails']) as $mail) |
|
781 | + $mailer->addHeader('Subject', lang("eGroupWare: login blocked for user '%1', IP %2", $login, $ip)); |
|
782 | + $mailer->setBody(lang("Too many unsucessful attempts to login: %1 for the user '%2', %3 for the IP %4", $false_id, $login, $false_ip, $ip)); |
|
783 | + foreach (preg_split('/,\s*/', $GLOBALS['egw_info']['server']['admin_mails']) as $mail) |
|
785 | 784 | { |
786 | 785 | $mailer->addAddress($mail); |
787 | 786 | } |
788 | 787 | $mailer->send(); |
789 | 788 | } |
790 | - catch(Exception $e) { |
|
789 | + catch (Exception $e) { |
|
791 | 790 | // ignore exception, but log it, to block the account and give a correct error-message to user |
792 | 791 | error_log(__METHOD__."('$login', '$ip') ".$e->getMessage()); |
793 | 792 | } |
794 | 793 | // save time of mail, to not send to many mails |
795 | 794 | $config = new Config('phpgwapi'); |
796 | 795 | $config->read_repository(); |
797 | - $config->value('login_blocked_mail_time',time()); |
|
796 | + $config->value('login_blocked_mail_time', time()); |
|
798 | 797 | $config->save_repository(); |
799 | 798 | } |
800 | 799 | return $blocked; |
@@ -815,7 +814,7 @@ discard block |
||
815 | 814 | * @param boolean $only_basic_auth =false return only a basic auth pseudo sessionid, default no |
816 | 815 | * @return string |
817 | 816 | */ |
818 | - static function get_sessionid($only_basic_auth=false) |
|
817 | + static function get_sessionid($only_basic_auth = false) |
|
819 | 818 | { |
820 | 819 | // for WebDAV and GroupDAV we use a pseudo sessionid created from md5(user:passwd) |
821 | 820 | // --> allows this stateless protocolls which use basic auth to use sessions! |
@@ -842,11 +841,11 @@ discard block |
||
842 | 841 | EGW_SERVER_ROOT.':'.self::getuser_ip().':'.filemtime(EGW_SERVER_ROOT.'/api/setup/setup.inc.php'). |
843 | 842 | ':'.$_SERVER['HTTP_USER_AGENT']); |
844 | 843 | } |
845 | - elseif(!$only_basic_auth && isset($_REQUEST[self::EGW_SESSION_NAME])) |
|
844 | + elseif (!$only_basic_auth && isset($_REQUEST[self::EGW_SESSION_NAME])) |
|
846 | 845 | { |
847 | 846 | $sessionid = $_REQUEST[self::EGW_SESSION_NAME]; |
848 | 847 | } |
849 | - elseif(!$only_basic_auth && isset($_COOKIE[self::EGW_SESSION_NAME])) |
|
848 | + elseif (!$only_basic_auth && isset($_COOKIE[self::EGW_SESSION_NAME])) |
|
850 | 849 | { |
851 | 850 | $sessionid = $_COOKIE[self::EGW_SESSION_NAME]; |
852 | 851 | } |
@@ -854,7 +853,7 @@ discard block |
||
854 | 853 | { |
855 | 854 | $sessionid = false; |
856 | 855 | } |
857 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true)); |
|
856 | + if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid, true)); |
|
858 | 857 | return $sessionid; |
859 | 858 | } |
860 | 859 | |
@@ -870,9 +869,7 @@ discard block |
||
870 | 869 | */ |
871 | 870 | static function get_request($name) |
872 | 871 | { |
873 | - return isset($_REQUEST[$name]) ? $_REQUEST[$name] : |
|
874 | - (isset($_COOKIE[$name]) ? $_COOKIE[$name] : |
|
875 | - (isset($_COOKIE[$name=ucfirst($name)]) ? $_COOKIE[$name] : null)); |
|
872 | + return isset($_REQUEST[$name]) ? $_REQUEST[$name] : (isset($_COOKIE[$name]) ? $_COOKIE[$name] : (isset($_COOKIE[$name = ucfirst($name)]) ? $_COOKIE[$name] : null)); |
|
876 | 873 | } |
877 | 874 | |
878 | 875 | /** |
@@ -882,13 +879,13 @@ discard block |
||
882 | 879 | * @param string $kp3 ?? to be verified |
883 | 880 | * @return bool is the session valid? |
884 | 881 | */ |
885 | - function verify($sessionid=null,$kp3=null) |
|
882 | + function verify($sessionid = null, $kp3 = null) |
|
886 | 883 | { |
887 | 884 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace()); |
888 | 885 | |
889 | 886 | $fill_egw_info_and_repositories = !$GLOBALS['egw_info']['flags']['restored_from_session']; |
890 | 887 | |
891 | - if(!$sessionid) |
|
888 | + if (!$sessionid) |
|
892 | 889 | { |
893 | 890 | $sessionid = self::get_sessionid(); |
894 | 891 | $kp3 = self::get_request('kp3'); |
@@ -915,23 +912,23 @@ discard block |
||
915 | 912 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session does NOT exist!"); |
916 | 913 | return false; |
917 | 914 | } |
918 | - $session =& $_SESSION[self::EGW_SESSION_VAR]; |
|
915 | + $session = & $_SESSION[self::EGW_SESSION_VAR]; |
|
919 | 916 | |
920 | 917 | if ($session['session_dla'] <= time() - $GLOBALS['egw_info']['server']['sessions_timeout']) |
921 | 918 | { |
922 | 919 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session timed out!"); |
923 | - $this->destroy($sessionid,$kp3); |
|
920 | + $this->destroy($sessionid, $kp3); |
|
924 | 921 | return false; |
925 | 922 | } |
926 | 923 | |
927 | 924 | $this->session_flags = $session['session_flags']; |
928 | 925 | |
929 | - $this->split_login_domain($session['session_lid'],$this->account_lid,$this->account_domain); |
|
926 | + $this->split_login_domain($session['session_lid'], $this->account_lid, $this->account_domain); |
|
930 | 927 | |
931 | 928 | // This is to ensure that we authenticate to the correct domain (might not be default) |
932 | - if($GLOBALS['egw_info']['user']['domain'] && $this->account_domain != $GLOBALS['egw_info']['user']['domain']) |
|
929 | + if ($GLOBALS['egw_info']['user']['domain'] && $this->account_domain != $GLOBALS['egw_info']['user']['domain']) |
|
933 | 930 | { |
934 | - return false; // session not verified, domain changed |
|
931 | + return false; // session not verified, domain changed |
|
935 | 932 | } |
936 | 933 | $GLOBALS['egw_info']['user']['kp3'] = $this->kp3; |
937 | 934 | |
@@ -944,7 +941,7 @@ discard block |
||
944 | 941 | { |
945 | 942 | $this->update_notification_heartbeat(); |
946 | 943 | } |
947 | - $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid,'account_lid','u'); |
|
944 | + $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid, 'account_lid', 'u'); |
|
948 | 945 | if (!$this->account_id) |
949 | 946 | { |
950 | 947 | if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) !accounts::name2id('$this->account_lid')"); |
@@ -982,7 +979,7 @@ discard block |
||
982 | 979 | |
983 | 980 | if ($GLOBALS['egw_info']['server']['sessions_checkip']) |
984 | 981 | { |
985 | - if (strtoupper(substr(PHP_OS,0,3)) != 'WIN' && (!$GLOBALS['egw_info']['user']['session_ip'] || |
|
982 | + if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' && (!$GLOBALS['egw_info']['user']['session_ip'] || |
|
986 | 983 | $GLOBALS['egw_info']['user']['session_ip'] != $this->getuser_ip())) |
987 | 984 | { |
988 | 985 | if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) wrong IP"); |
@@ -1005,9 +1002,9 @@ discard block |
||
1005 | 1002 | // query accesslog-id, if not set in session (session is made persistent after login!) |
1006 | 1003 | if (!$this->sessionid_access_log && $this->session_flags != 'A') |
1007 | 1004 | { |
1008 | - $this->sessionid_access_log = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE,'sessionid',array( |
|
1005 | + $this->sessionid_access_log = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, 'sessionid', array( |
|
1009 | 1006 | 'session_php' => $this->sessionid, |
1010 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
1007 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
1011 | 1008 | //error_log(__METHOD__."() sessionid=$this->sessionid --> sessionid_access_log=$this->sessionid_access_log"); |
1012 | 1009 | } |
1013 | 1010 | |
@@ -1018,9 +1015,9 @@ discard block |
||
1018 | 1015 | (!isset($_COOKIE[self::EGW_SESSION_NAME]) || $_COOKIE[self::EGW_SESSION_NAME] !== $_REQUEST[self::EGW_SESSION_NAME])) |
1019 | 1016 | { |
1020 | 1017 | if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now"); |
1021 | - self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid); |
|
1022 | - self::egw_setcookie('kp3',$this->kp3); |
|
1023 | - self::egw_setcookie('domain',$this->account_domain); |
|
1018 | + self::egw_setcookie(self::EGW_SESSION_NAME, $this->sessionid); |
|
1019 | + self::egw_setcookie('kp3', $this->kp3); |
|
1020 | + self::egw_setcookie('domain', $this->account_domain); |
|
1024 | 1021 | } |
1025 | 1022 | |
1026 | 1023 | if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS"); |
@@ -1035,27 +1032,27 @@ discard block |
||
1035 | 1032 | * @param string $kp3 |
1036 | 1033 | * @return boolean true on success, false on error |
1037 | 1034 | */ |
1038 | - function destroy($sessionid, $kp3='') |
|
1035 | + function destroy($sessionid, $kp3 = '') |
|
1039 | 1036 | { |
1040 | 1037 | if (!$sessionid && $kp3) |
1041 | 1038 | { |
1042 | 1039 | return false; |
1043 | 1040 | } |
1044 | - $this->log_access($sessionid); // log logout-time |
|
1041 | + $this->log_access($sessionid); // log logout-time |
|
1045 | 1042 | |
1046 | 1043 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($sessionid,$kp3)"); |
1047 | 1044 | |
1048 | 1045 | if (is_numeric($sessionid)) // do we have a access-log-id --> get PHP session id |
1049 | 1046 | { |
1050 | - $sessionid = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE,'session_php',array( |
|
1047 | + $sessionid = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, 'session_php', array( |
|
1051 | 1048 | 'sessionid' => $sessionid, |
1052 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
1049 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
1053 | 1050 | } |
1054 | 1051 | |
1055 | 1052 | Hooks::process(array( |
1056 | 1053 | 'location' => 'session_destroyed', |
1057 | 1054 | 'sessionid' => $sessionid, |
1058 | - ),'',true); // true = run hooks from all apps, not just the ones the current user has perms to run |
|
1055 | + ), '', true); // true = run hooks from all apps, not just the ones the current user has perms to run |
|
1059 | 1056 | |
1060 | 1057 | // Only do the following, if where working with the current user |
1061 | 1058 | if (!$GLOBALS['egw_info']['user']['sessionid'] || $sessionid == $GLOBALS['egw_info']['user']['sessionid']) |
@@ -1076,7 +1073,7 @@ discard block |
||
1076 | 1073 | } |
1077 | 1074 | else |
1078 | 1075 | { |
1079 | - $this->commit_session(); // close our own session |
|
1076 | + $this->commit_session(); // close our own session |
|
1080 | 1077 | |
1081 | 1078 | session_id($sessionid); |
1082 | 1079 | if (session_start()) |
@@ -1116,25 +1113,25 @@ discard block |
||
1116 | 1113 | // as $webserver_url may be part of $url (as /egw is part of phpgwapi/js/egw_instant_load.html) |
1117 | 1114 | if (($url[0] != '/' || $webserver_url != '/') && (!$webserver_url || strpos($url, $webserver_url.'/') === false)) |
1118 | 1115 | { |
1119 | - if($url[0] != '/' && substr($webserver_url,-1) != '/') |
|
1116 | + if ($url[0] != '/' && substr($webserver_url, -1) != '/') |
|
1120 | 1117 | { |
1121 | - $url = $webserver_url .'/'. $url; |
|
1118 | + $url = $webserver_url.'/'.$url; |
|
1122 | 1119 | } |
1123 | 1120 | else |
1124 | 1121 | { |
1125 | - $url = $webserver_url . $url; |
|
1122 | + $url = $webserver_url.$url; |
|
1126 | 1123 | } |
1127 | 1124 | } |
1128 | 1125 | |
1129 | - if(isset($GLOBALS['egw_info']['server']['enforce_ssl']) && $GLOBALS['egw_info']['server']['enforce_ssl']) |
|
1126 | + if (isset($GLOBALS['egw_info']['server']['enforce_ssl']) && $GLOBALS['egw_info']['server']['enforce_ssl']) |
|
1130 | 1127 | { |
1131 | - if(substr($url ,0,4) != 'http') |
|
1128 | + if (substr($url, 0, 4) != 'http') |
|
1132 | 1129 | { |
1133 | 1130 | $url = 'https://'.$_SERVER['HTTP_HOST'].$url; |
1134 | 1131 | } |
1135 | 1132 | else |
1136 | 1133 | { |
1137 | - $url = str_replace ( 'http:', 'https:', $url); |
|
1134 | + $url = str_replace('http:', 'https:', $url); |
|
1138 | 1135 | } |
1139 | 1136 | } |
1140 | 1137 | $vars = array(); |
@@ -1147,7 +1144,7 @@ discard block |
||
1147 | 1144 | } |
1148 | 1145 | |
1149 | 1146 | // check if the url already contains a query and ensure that vars is an array and all strings are in extravars |
1150 | - list($ret_url,$othervars) = explode('?', $url, 2); |
|
1147 | + list($ret_url, $othervars) = explode('?', $url, 2); |
|
1151 | 1148 | if ($extravars && is_array($extravars)) |
1152 | 1149 | { |
1153 | 1150 | $vars += $extravars; |
@@ -1155,19 +1152,19 @@ discard block |
||
1155 | 1152 | } |
1156 | 1153 | else |
1157 | 1154 | { |
1158 | - if ($othervars) $extravars .= ($extravars?'&':'').$othervars; |
|
1155 | + if ($othervars) $extravars .= ($extravars ? '&' : '').$othervars; |
|
1159 | 1156 | } |
1160 | 1157 | |
1161 | 1158 | // parse extravars string into the vars array |
1162 | 1159 | if ($extravars) |
1163 | 1160 | { |
1164 | - foreach(explode('&',$extravars) as $expr) |
|
1161 | + foreach (explode('&', $extravars) as $expr) |
|
1165 | 1162 | { |
1166 | - list($var,$val) = explode('=', $expr,2); |
|
1167 | - if (strpos($val,'%26') != false) $val = str_replace('%26','&',$val); // make sure to not double encode & |
|
1168 | - if (substr($var,-2) == '[]') |
|
1163 | + list($var, $val) = explode('=', $expr, 2); |
|
1164 | + if (strpos($val, '%26') != false) $val = str_replace('%26', '&', $val); // make sure to not double encode & |
|
1165 | + if (substr($var, -2) == '[]') |
|
1169 | 1166 | { |
1170 | - $vars[substr($var,0,-2)][] = $val; |
|
1167 | + $vars[substr($var, 0, -2)][] = $val; |
|
1171 | 1168 | } |
1172 | 1169 | else |
1173 | 1170 | { |
@@ -1180,11 +1177,11 @@ discard block |
||
1180 | 1177 | if (count($vars)) |
1181 | 1178 | { |
1182 | 1179 | $query = array(); |
1183 | - foreach($vars as $key => $value) |
|
1180 | + foreach ($vars as $key => $value) |
|
1184 | 1181 | { |
1185 | 1182 | if (is_array($value)) |
1186 | 1183 | { |
1187 | - foreach($value as $val) |
|
1184 | + foreach ($value as $val) |
|
1188 | 1185 | { |
1189 | 1186 | $query[] = $key.'[]='.urlencode($val); |
1190 | 1187 | } |
@@ -1194,7 +1191,7 @@ discard block |
||
1194 | 1191 | $query[] = $key.'='.urlencode($value); |
1195 | 1192 | } |
1196 | 1193 | } |
1197 | - $ret_url .= '?' . implode('&',$query); |
|
1194 | + $ret_url .= '?'.implode('&', $query); |
|
1198 | 1195 | } |
1199 | 1196 | return $ret_url; |
1200 | 1197 | } |
@@ -1239,7 +1236,7 @@ discard block |
||
1239 | 1236 | * @param int $cookietime =0 when cookie should expire, 0 for session only (optional) |
1240 | 1237 | * @param string $cookiepath =null optional path (eg. '/') if the eGW install-dir should not be used |
1241 | 1238 | */ |
1242 | - public static function egw_setcookie($cookiename,$cookievalue='',$cookietime=0,$cookiepath=null) |
|
1239 | + public static function egw_setcookie($cookiename, $cookievalue = '', $cookietime = 0, $cookiepath = null) |
|
1243 | 1240 | { |
1244 | 1241 | if (empty(self::$cookie_domain) || empty(self::$cookie_path)) |
1245 | 1242 | { |
@@ -1252,11 +1249,11 @@ discard block |
||
1252 | 1249 | static $is_iOS = null; |
1253 | 1250 | if (!$cookietime && !isset($is_iOS)) $is_iOS = (bool)preg_match('/^(iPhone|iPad|iPod)/i', Header\UserAgent::mobile()); |
1254 | 1251 | |
1255 | - if(!headers_sent()) // gives only a warning, but can not send the cookie anyway |
|
1252 | + if (!headers_sent()) // gives only a warning, but can not send the cookie anyway |
|
1256 | 1253 | { |
1257 | 1254 | setcookie($cookiename, $cookievalue, |
1258 | - !$cookietime && $is_iOS ? time()+self::IOS_SESSION_COOKIE_LIFETIME : $cookietime, |
|
1259 | - is_null($cookiepath) ? self::$cookie_path : $cookiepath,self::$cookie_domain, |
|
1255 | + !$cookietime && $is_iOS ? time() + self::IOS_SESSION_COOKIE_LIFETIME : $cookietime, |
|
1256 | + is_null($cookiepath) ? self::$cookie_path : $cookiepath, self::$cookie_domain, |
|
1260 | 1257 | // if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true) |
1261 | 1258 | empty($GLOBALS['egw_info']['server']['insecure_cookies']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off', true); |
1262 | 1259 | } |
@@ -1275,21 +1272,21 @@ discard block |
||
1275 | 1272 | else |
1276 | 1273 | { |
1277 | 1274 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
1278 | - self::$cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
1275 | + self::$cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
1279 | 1276 | } |
1280 | 1277 | // remove port from HTTP_HOST |
1281 | 1278 | $arr = null; |
1282 | - if (preg_match("/^(.*):(.*)$/",self::$cookie_domain,$arr)) |
|
1279 | + if (preg_match("/^(.*):(.*)$/", self::$cookie_domain, $arr)) |
|
1283 | 1280 | { |
1284 | 1281 | self::$cookie_domain = $arr[1]; |
1285 | 1282 | } |
1286 | - if (count(explode('.',self::$cookie_domain)) <= 1) |
|
1283 | + if (count(explode('.', self::$cookie_domain)) <= 1) |
|
1287 | 1284 | { |
1288 | 1285 | // setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in |
1289 | 1286 | self::$cookie_domain = ''; |
1290 | 1287 | } |
1291 | 1288 | if (!$GLOBALS['egw_info']['server']['cookiepath'] || |
1292 | - !(self::$cookie_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH))) |
|
1289 | + !(self::$cookie_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH))) |
|
1293 | 1290 | { |
1294 | 1291 | self::$cookie_path = '/'; |
1295 | 1292 | } |
@@ -1309,7 +1306,7 @@ discard block |
||
1309 | 1306 | * @param array $domains =null defaults to $GLOBALS['egw_domain'] from the header |
1310 | 1307 | * @return string $GLOBALS['egw_info']['user']['domain'] set with the domain/instance to use |
1311 | 1308 | */ |
1312 | - public static function search_instance($login,$domain_requested,&$default_domain,$server_names,array $domains=null) |
|
1309 | + public static function search_instance($login, $domain_requested, &$default_domain, $server_names, array $domains = null) |
|
1313 | 1310 | { |
1314 | 1311 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$login','$domain_requested',".array2string($default_domain).".".array2string($server_names).".".array2string($domains).")"); |
1315 | 1312 | |
@@ -1317,10 +1314,10 @@ discard block |
||
1317 | 1314 | |
1318 | 1315 | if (!isset($default_domain) || !isset($domains[$default_domain])) // allow to overwrite the default domain |
1319 | 1316 | { |
1320 | - foreach((array)$server_names as $server_name) |
|
1317 | + foreach ((array)$server_names as $server_name) |
|
1321 | 1318 | { |
1322 | - list($server_name) = explode(':', $server_name); // remove port from HTTP_HOST |
|
1323 | - if(isset($domains[$server_name])) |
|
1319 | + list($server_name) = explode(':', $server_name); // remove port from HTTP_HOST |
|
1320 | + if (isset($domains[$server_name])) |
|
1324 | 1321 | { |
1325 | 1322 | $default_domain = $server_name; |
1326 | 1323 | break; |
@@ -1330,7 +1327,7 @@ discard block |
||
1330 | 1327 | $parts = explode('.', $server_name); |
1331 | 1328 | array_shift($parts); |
1332 | 1329 | $domain_part = implode('.', $parts); |
1333 | - if(isset($domains[$domain_part])) |
|
1330 | + if (isset($domains[$domain_part])) |
|
1334 | 1331 | { |
1335 | 1332 | $default_domain = $domain_part; |
1336 | 1333 | break; |
@@ -1346,11 +1343,11 @@ discard block |
||
1346 | 1343 | } |
1347 | 1344 | if (isset($login)) // on login |
1348 | 1345 | { |
1349 | - if (strpos($login,'@') === false || count($domains) == 1) |
|
1346 | + if (strpos($login, '@') === false || count($domains) == 1) |
|
1350 | 1347 | { |
1351 | - $login .= '@' . (isset($_POST['logindomain']) ? $_POST['logindomain'] : $default_domain); |
|
1348 | + $login .= '@'.(isset($_POST['logindomain']) ? $_POST['logindomain'] : $default_domain); |
|
1352 | 1349 | } |
1353 | - $parts = explode('@',$login); |
|
1350 | + $parts = explode('@', $login); |
|
1354 | 1351 | $domain = array_pop($parts); |
1355 | 1352 | $GLOBALS['login'] = $login; |
1356 | 1353 | } |
@@ -1383,7 +1380,7 @@ discard block |
||
1383 | 1380 | * @param boolean $update_access_log =false false: dont update egw_access_log table, but set $this->action |
1384 | 1381 | * @return string action as written to egw_access_log.session_action |
1385 | 1382 | */ |
1386 | - private function update_dla($update_access_log=false) |
|
1383 | + private function update_dla($update_access_log = false) |
|
1387 | 1384 | { |
1388 | 1385 | // This way XML-RPC users aren't always listed as xmlrpc.php |
1389 | 1386 | if (!$update_access_log) |
@@ -1401,14 +1398,14 @@ discard block |
||
1401 | 1398 | $action = $_SERVER['PHP_SELF']; |
1402 | 1399 | // remove EGroupware path, if not installed in webroot |
1403 | 1400 | $egw_path = $GLOBALS['egw_info']['server']['webserver_url']; |
1404 | - if ($egw_path[0] != '/') $egw_path = parse_url($egw_path,PHP_URL_PATH); |
|
1401 | + if ($egw_path[0] != '/') $egw_path = parse_url($egw_path, PHP_URL_PATH); |
|
1405 | 1402 | if ($action == '/Microsoft-Server-ActiveSync') |
1406 | 1403 | { |
1407 | 1404 | $action .= '?Cmd='.$_GET['Cmd'].'&DeviceId='.$_GET['DeviceId']; |
1408 | 1405 | } |
1409 | 1406 | elseif ($egw_path) |
1410 | 1407 | { |
1411 | - list(,$action) = explode($egw_path,$action,2); |
|
1408 | + list(,$action) = explode($egw_path, $action, 2); |
|
1412 | 1409 | } |
1413 | 1410 | } |
1414 | 1411 | $this->set_action($action); |
@@ -1416,14 +1413,14 @@ discard block |
||
1416 | 1413 | // update dla in access-log table, if we have an access-log row (non-anonymous session) |
1417 | 1414 | if ($this->sessionid_access_log && $update_access_log && is_object($GLOBALS['egw']->db)) |
1418 | 1415 | { |
1419 | - $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE,array( |
|
1416 | + $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE, array( |
|
1420 | 1417 | 'session_dla' => time(), |
1421 | 1418 | 'session_action' => $this->action, |
1422 | 1419 | ) + ($this->action === '/logout.php' ? array() : array( |
1423 | - 'lo' => null, // just in case it was (automatic) timed out before |
|
1424 | - )),array( |
|
1420 | + 'lo' => null, // just in case it was (automatic) timed out before |
|
1421 | + )), array( |
|
1425 | 1422 | 'sessionid' => $this->sessionid_access_log, |
1426 | - ),__LINE__,__FILE__); |
|
1423 | + ), __LINE__, __FILE__); |
|
1427 | 1424 | } |
1428 | 1425 | |
1429 | 1426 | $_SESSION[self::EGW_SESSION_VAR]['session_dla'] = time(); |
@@ -1441,12 +1438,12 @@ discard block |
||
1441 | 1438 | // update dla in access-log table, if we have an access-log row (non-anonymous session) |
1442 | 1439 | if ($this->sessionid_access_log) |
1443 | 1440 | { |
1444 | - $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE,array( |
|
1441 | + $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE, array( |
|
1445 | 1442 | 'notification_heartbeat' => time(), |
1446 | - ),array( |
|
1443 | + ), array( |
|
1447 | 1444 | 'sessionid' => $this->sessionid_access_log, |
1448 | 1445 | 'lo IS NULL', |
1449 | - ),__LINE__,__FILE__); |
|
1446 | + ), __LINE__, __FILE__); |
|
1450 | 1447 | } |
1451 | 1448 | } |
1452 | 1449 | |
@@ -1467,7 +1464,7 @@ discard block |
||
1467 | 1464 | { |
1468 | 1465 | // authentication happens in login.php, which does NOT yet create egw-object in session |
1469 | 1466 | // --> need to store homedirectory in session |
1470 | - if(isset($GLOBALS['auto_create_acct']['homedirectory'])) |
|
1467 | + if (isset($GLOBALS['auto_create_acct']['homedirectory'])) |
|
1471 | 1468 | { |
1472 | 1469 | Cache::setSession(__CLASS__, 'homedirectory', |
1473 | 1470 | $user['homedirectory'] = $GLOBALS['auto_create_acct']['homedirectory']); |
@@ -1480,7 +1477,7 @@ discard block |
||
1480 | 1477 | $user['preferences'] = $GLOBALS['egw']->preferences->read_repository(); |
1481 | 1478 | if (is_object($GLOBALS['egw']->datetime)) |
1482 | 1479 | { |
1483 | - $GLOBALS['egw']->datetime->__construct(); // to set tz_offset from the now read prefs |
|
1480 | + $GLOBALS['egw']->datetime->__construct(); // to set tz_offset from the now read prefs |
|
1484 | 1481 | } |
1485 | 1482 | $user['apps'] = $GLOBALS['egw']->applications->read_repository(); |
1486 | 1483 | $user['domain'] = $this->account_domain; |
@@ -1503,9 +1500,9 @@ discard block |
||
1503 | 1500 | * @param string &$account_lid returned account_lid (ie. user) |
1504 | 1501 | * @param string &$domain returned domain (ie. domain) |
1505 | 1502 | */ |
1506 | - private function split_login_domain($login,&$account_lid,&$domain) |
|
1503 | + private function split_login_domain($login, &$account_lid, &$domain) |
|
1507 | 1504 | { |
1508 | - $parts = explode('@',$login); |
|
1505 | + $parts = explode('@', $login); |
|
1509 | 1506 | |
1510 | 1507 | //conference - for strings like [email protected]@default , |
1511 | 1508 | //allows that user have a login that is his e-mail. (viniciuscb) |
@@ -1513,11 +1510,11 @@ discard block |
||
1513 | 1510 | { |
1514 | 1511 | $probable_domain = array_pop($parts); |
1515 | 1512 | //Last part of login string, when separated by @, is a domain name |
1516 | - if (in_array($probable_domain,$this->egw_domains)) |
|
1513 | + if (in_array($probable_domain, $this->egw_domains)) |
|
1517 | 1514 | { |
1518 | 1515 | $got_login = true; |
1519 | 1516 | $domain = $probable_domain; |
1520 | - $account_lid = implode('@',$parts); |
|
1517 | + $account_lid = implode('@', $parts); |
|
1521 | 1518 | } |
1522 | 1519 | } |
1523 | 1520 | |
@@ -1540,9 +1537,9 @@ discard block |
||
1540 | 1537 | * @param boolean $allow_password_md5 =false can password alread be an md5 hash |
1541 | 1538 | * @return string |
1542 | 1539 | */ |
1543 | - static function user_pw_hash($user,$password,$allow_password_md5=false) |
|
1540 | + static function user_pw_hash($user, $password, $allow_password_md5 = false) |
|
1544 | 1541 | { |
1545 | - $password_md5 = $allow_password_md5 && preg_match('/^[a-f0-9]{32}$/',$password) ? $password : md5($password); |
|
1542 | + $password_md5 = $allow_password_md5 && preg_match('/^[a-f0-9]{32}$/', $password) ? $password : md5($password); |
|
1546 | 1543 | |
1547 | 1544 | $hash = sha1(strtolower($user).$password_md5); |
1548 | 1545 | |
@@ -1554,7 +1551,7 @@ discard block |
||
1554 | 1551 | */ |
1555 | 1552 | public static function init_handler() |
1556 | 1553 | { |
1557 | - ini_set('session.use_cookies',0); // disable the automatic use of cookies, as it uses the path / by default |
|
1554 | + ini_set('session.use_cookies', 0); // disable the automatic use of cookies, as it uses the path / by default |
|
1558 | 1555 | session_name(self::EGW_SESSION_NAME); |
1559 | 1556 | if (($sessionid = self::get_sessionid())) |
1560 | 1557 | { |
@@ -1581,7 +1578,7 @@ discard block |
||
1581 | 1578 | * @param int $expire =null expiration time in seconds, default $GLOBALS['egw_info']['flags']['nocachecontrol'] or php.ini session.cache_expire |
1582 | 1579 | * @param int $private =null allows to set private caching with given expiration time, by setting it to true |
1583 | 1580 | */ |
1584 | - public static function cache_control($expire=null, $private=null) |
|
1581 | + public static function cache_control($expire = null, $private = null) |
|
1585 | 1582 | { |
1586 | 1583 | if (is_null($expire) && isset($GLOBALS['egw_info']['flags']['nocachecontrol']) && is_int($GLOBALS['egw_info']['flags']['nocachecontrol'])) |
1587 | 1584 | { |
@@ -1591,7 +1588,7 @@ discard block |
||
1591 | 1588 | if (!isset($_SESSION)) |
1592 | 1589 | { |
1593 | 1590 | // controling caching and expires header |
1594 | - if(!isset($expire) && (!isset($GLOBALS['egw_info']['flags']['nocachecontrol']) || |
|
1591 | + if (!isset($expire) && (!isset($GLOBALS['egw_info']['flags']['nocachecontrol']) || |
|
1595 | 1592 | !$GLOBALS['egw_info']['flags']['nocachecontrol'])) |
1596 | 1593 | { |
1597 | 1594 | session_cache_limiter('nocache'); |
@@ -1601,7 +1598,7 @@ discard block |
||
1601 | 1598 | // allow public caching: proxys, cdns, ... |
1602 | 1599 | if (isset($expire)) |
1603 | 1600 | { |
1604 | - session_cache_expire((int)ceil($expire/60)); // in minutes |
|
1601 | + session_cache_expire((int)ceil($expire / 60)); // in minutes |
|
1605 | 1602 | } |
1606 | 1603 | session_cache_limiter($private ? 'private' : 'public'); |
1607 | 1604 | } |
@@ -1614,8 +1611,8 @@ discard block |
||
1614 | 1611 | // session already started |
1615 | 1612 | if (isset($_SESSION)) |
1616 | 1613 | { |
1617 | - if ($expire && (session_cache_limiter() !== ($expire===true?'private_no_expire':'public') || |
|
1618 | - is_int($expire) && $expire/60 !== session_cache_expire())) |
|
1614 | + if ($expire && (session_cache_limiter() !== ($expire === true ? 'private_no_expire' : 'public') || |
|
1615 | + is_int($expire) && $expire / 60 !== session_cache_expire())) |
|
1619 | 1616 | { |
1620 | 1617 | $file = $line = null; |
1621 | 1618 | if (headers_sent($file, $line)) |
@@ -1623,20 +1620,20 @@ discard block |
||
1623 | 1620 | error_log(__METHOD__."($expire) called, but header already sent in $file: $line"); |
1624 | 1621 | return; |
1625 | 1622 | } |
1626 | - if($expire === true) // same behavior as session_cache_limiter('private_no_expire') |
|
1623 | + if ($expire === true) // same behavior as session_cache_limiter('private_no_expire') |
|
1627 | 1624 | { |
1628 | - header('Cache-Control: private, max-age='.(60*session_cache_expire())); |
|
1625 | + header('Cache-Control: private, max-age='.(60 * session_cache_expire())); |
|
1629 | 1626 | header_remove('Expires'); |
1630 | 1627 | } |
1631 | 1628 | elseif ($private) |
1632 | 1629 | { |
1633 | 1630 | header('Cache-Control: private, max-age='.$expire); |
1634 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expire) . ' GMT'); |
|
1631 | + header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expire).' GMT'); |
|
1635 | 1632 | } |
1636 | 1633 | else |
1637 | 1634 | { |
1638 | 1635 | header('Cache-Control: public, max-age='.$expire); |
1639 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expire) . ' GMT'); |
|
1636 | + header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expire).' GMT'); |
|
1640 | 1637 | } |
1641 | 1638 | // remove Pragma header, might be set by old header |
1642 | 1639 | if (function_exists('header_remove')) // PHP 5.3+ |
@@ -1661,10 +1658,10 @@ discard block |
||
1661 | 1658 | * @param array $filter =array() extra filter for sessions |
1662 | 1659 | * @return array with sessions (values for keys as in $sort) |
1663 | 1660 | */ |
1664 | - public static function session_list($start,$sort='DESC',$order='session_dla',$all_no_sort=False,array $filter=array()) |
|
1661 | + public static function session_list($start, $sort = 'DESC', $order = 'session_dla', $all_no_sort = False, array $filter = array()) |
|
1665 | 1662 | { |
1666 | 1663 | $sessions = array(); |
1667 | - if (!preg_match('/^[a-z0-9_ ,]+$/i',$order_by=$order.' '.$sort) || $order_by == ' ') |
|
1664 | + if (!preg_match('/^[a-z0-9_ ,]+$/i', $order_by = $order.' '.$sort) || $order_by == ' ') |
|
1668 | 1665 | { |
1669 | 1666 | $order_by = 'session_dla DESC'; |
1670 | 1667 | } |
@@ -1672,7 +1669,7 @@ discard block |
||
1672 | 1669 | $filter[] = 'account_id>0'; |
1673 | 1670 | $filter[] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); |
1674 | 1671 | $filter[] = '(notification_heartbeat IS NULL OR notification_heartbeat > '.self::heartbeat_limit().')'; |
1675 | - foreach($GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, '*', $filter, __LINE__, __FILE__, |
|
1672 | + foreach ($GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, '*', $filter, __LINE__, __FILE__, |
|
1676 | 1673 | $all_no_sort ? false : $start, 'ORDER BY '.$order_by) as $row) |
1677 | 1674 | { |
1678 | 1675 | $sessions[$row['sessionid']] = $row; |
@@ -1686,7 +1683,7 @@ discard block |
||
1686 | 1683 | * @param array $filter =array() extra filter for sessions |
1687 | 1684 | * @return int number of active sessions |
1688 | 1685 | */ |
1689 | - public static function session_count(array $filter=array()) |
|
1686 | + public static function session_count(array $filter = array()) |
|
1690 | 1687 | { |
1691 | 1688 | $filter['lo'] = null; |
1692 | 1689 | $filter[] = 'account_id>0'; |
@@ -1702,16 +1699,16 @@ discard block |
||
1702 | 1699 | */ |
1703 | 1700 | public static function heartbeat_limit() |
1704 | 1701 | { |
1705 | - static $limit=null; |
|
1702 | + static $limit = null; |
|
1706 | 1703 | |
1707 | 1704 | if (is_null($limit)) |
1708 | 1705 | { |
1709 | 1706 | $config = Config::read('notifications'); |
1710 | - if (!($popup_poll_interval = $config['popup_poll_interval'])) |
|
1707 | + if (!($popup_poll_interval = $config['popup_poll_interval'])) |
|
1711 | 1708 | { |
1712 | 1709 | $popup_poll_interval = 60; |
1713 | 1710 | } |
1714 | - $limit = (int)(time() - $popup_poll_interval-10); // 10s grace periode |
|
1711 | + $limit = (int)(time() - $popup_poll_interval - 10); // 10s grace periode |
|
1715 | 1712 | } |
1716 | 1713 | return $limit; |
1717 | 1714 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
367 | 367 | * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
368 | 368 | * @param boolean $need_full_no_count =false If true an unlimited query is run to determine the total number of rows, default false |
369 | - * @param mixed $only_keys =false, see search |
|
369 | + * @param boolean $only_keys =false, see search |
|
370 | 370 | * @param string|array $extra_cols =array() |
371 | 371 | * @return int total number of rows |
372 | 372 | */ |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * Check if cf is stored as 1:N relation in DB and array in memory |
735 | 735 | * |
736 | 736 | * @param string $name |
737 | - * @return string |
|
737 | + * @return boolean |
|
738 | 738 | */ |
739 | 739 | function is_multiple($name) |
740 | 740 | { |
@@ -210,12 +210,12 @@ |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | - * saves custom field data |
|
214 | - * |
|
215 | - * @param array $data data to save (cf's have to be prefixed with self::CF_PREFIX = #) |
|
216 | - * @param array $extra_cols =array() extra-data to be saved |
|
217 | - * @return bool false on success, errornumber on failure |
|
218 | - */ |
|
213 | + * saves custom field data |
|
214 | + * |
|
215 | + * @param array $data data to save (cf's have to be prefixed with self::CF_PREFIX = #) |
|
216 | + * @param array $extra_cols =array() extra-data to be saved |
|
217 | + * @return bool false on success, errornumber on failure |
|
218 | + */ |
|
219 | 219 | function save_customfields($data, array $extra_cols=array()) |
220 | 220 | { |
221 | 221 | $id = isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]]; |
@@ -118,41 +118,41 @@ discard block |
||
118 | 118 | * @param boolean $allow_multiple_values =false should we allow AND store multiple values (1:N relations) |
119 | 119 | * @param string $timestamp_type =null default null=leave them as is, 'ts'|'integer' use integer unix timestamps, 'object' use DateTime objects |
120 | 120 | */ |
121 | - function __construct($app,$table,$extra_table,$column_prefix='', |
|
122 | - $extra_key='_name',$extra_value='_value',$extra_id='_id', |
|
123 | - Db $db=null,$no_clone=true,$allow_multiple_values=false,$timestamp_type=null) |
|
121 | + function __construct($app, $table, $extra_table, $column_prefix = '', |
|
122 | + $extra_key = '_name', $extra_value = '_value', $extra_id = '_id', |
|
123 | + Db $db = null, $no_clone = true, $allow_multiple_values = false, $timestamp_type = null) |
|
124 | 124 | { |
125 | 125 | // calling the Storage\Base constructor |
126 | - parent::__construct($app,$table,$db,$column_prefix,$no_clone,$timestamp_type); |
|
126 | + parent::__construct($app, $table, $db, $column_prefix, $no_clone, $timestamp_type); |
|
127 | 127 | |
128 | 128 | $this->allow_multiple_values = $allow_multiple_values; |
129 | 129 | $this->extra_table = $extra_table; |
130 | - if (!$this->extra_id) $this->extra_id = $this->autoinc_id; // default to auto id of regular table |
|
130 | + if (!$this->extra_id) $this->extra_id = $this->autoinc_id; // default to auto id of regular table |
|
131 | 131 | |
132 | 132 | // if names from columns of extra table are only postfixes (starting with _), prepend column prefix |
133 | - if (!($prefix=$column_prefix)) |
|
133 | + if (!($prefix = $column_prefix)) |
|
134 | 134 | { |
135 | - list($prefix) = explode('_',$this->autoinc_id); |
|
135 | + list($prefix) = explode('_', $this->autoinc_id); |
|
136 | 136 | } |
137 | - elseif(substr($prefix,-1) == '_') |
|
137 | + elseif (substr($prefix, -1) == '_') |
|
138 | 138 | { |
139 | - $prefix = substr($prefix,0,-1); // remove trailing underscore from column prefix parameter |
|
139 | + $prefix = substr($prefix, 0, -1); // remove trailing underscore from column prefix parameter |
|
140 | 140 | } |
141 | - foreach(array( |
|
141 | + foreach (array( |
|
142 | 142 | 'extra_id' => $extra_id, |
143 | 143 | 'extra_key' => $extra_key, |
144 | 144 | 'extra_value' => $extra_value |
145 | 145 | ) as $col => $val) |
146 | 146 | { |
147 | 147 | $this->$col = $col_name = $val; |
148 | - if ($col_name[0] == '_') $this->$col = $prefix . $val; |
|
148 | + if ($col_name[0] == '_') $this->$col = $prefix.$val; |
|
149 | 149 | } |
150 | 150 | // some sanity checks, maybe they should be active only for development |
151 | - if (!($extra_defs = $this->db->get_table_definitions($app,$extra_table))) |
|
151 | + if (!($extra_defs = $this->db->get_table_definitions($app, $extra_table))) |
|
152 | 152 | { |
153 | 153 | throw new Exception\WrongParameter("extra table $extra_table is NOT defined!"); |
154 | 154 | } |
155 | - foreach(array('extra_id','extra_key','extra_value') as $col) |
|
155 | + foreach (array('extra_id', 'extra_key', 'extra_value') as $col) |
|
156 | 156 | { |
157 | 157 | if (!$this->$col || !isset($extra_defs['fd'][$this->$col])) |
158 | 158 | { |
@@ -177,23 +177,23 @@ discard block |
||
177 | 177 | * @param array $field_names =null custom fields to read, default all |
178 | 178 | * @return array id => $this->cf_field(name) => value |
179 | 179 | */ |
180 | - function read_customfields($ids,$field_names=null) |
|
180 | + function read_customfields($ids, $field_names = null) |
|
181 | 181 | { |
182 | 182 | if (is_null($field_names)) $field_names = array_keys($this->customfields); |
183 | 183 | |
184 | - foreach((array)$ids as $key => $id) |
|
184 | + foreach ((array)$ids as $key => $id) |
|
185 | 185 | { |
186 | 186 | if (!(int)$id && is_array($ids)) unset($ids[$key]); |
187 | 187 | } |
188 | - if (!$ids || !$field_names) return array(); // nothing to do |
|
188 | + if (!$ids || !$field_names) return array(); // nothing to do |
|
189 | 189 | |
190 | 190 | $entries = array(); |
191 | - foreach($this->db->select($this->extra_table,'*',array( |
|
191 | + foreach ($this->db->select($this->extra_table, '*', array( |
|
192 | 192 | $this->extra_id => $ids, |
193 | 193 | $this->extra_key => $field_names, |
194 | - ),__LINE__,__FILE__,false,'',$this->app) as $row) |
|
194 | + ), __LINE__, __FILE__, false, '', $this->app) as $row) |
|
195 | 195 | { |
196 | - $entry =& $entries[$row[$this->extra_id]]; |
|
196 | + $entry = & $entries[$row[$this->extra_id]]; |
|
197 | 197 | if (!is_array($entry)) $entry = array(); |
198 | 198 | $field = $this->get_cf_field($row[$this->extra_key]); |
199 | 199 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param array $extra_cols =array() extra-data to be saved |
217 | 217 | * @return bool false on success, errornumber on failure |
218 | 218 | */ |
219 | - function save_customfields($data, array $extra_cols=array()) |
|
219 | + function save_customfields($data, array $extra_cols = array()) |
|
220 | 220 | { |
221 | 221 | $id = isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]]; |
222 | 222 | |
@@ -233,22 +233,21 @@ discard block |
||
233 | 233 | $is_multiple = $this->is_multiple($name); |
234 | 234 | |
235 | 235 | // we explicitly need to delete fields, if value is empty or field allows multiple values or we have no unique index |
236 | - if(empty($data[$field]) || $is_multiple || !$this->extra_has_unique_index) |
|
236 | + if (empty($data[$field]) || $is_multiple || !$this->extra_has_unique_index) |
|
237 | 237 | { |
238 | - $this->db->delete($this->extra_table,$where,__LINE__,__FILE__,$this->app); |
|
239 | - if (empty($data[$field])) continue; // nothing else to do for empty values |
|
238 | + $this->db->delete($this->extra_table, $where, __LINE__, __FILE__, $this->app); |
|
239 | + if (empty($data[$field])) continue; // nothing else to do for empty values |
|
240 | 240 | } |
241 | - foreach($is_multiple && !is_array($data[$field]) ? explode(',',$data[$field]) : |
|
242 | - // regular custom fields (!$is_multiple) eg. addressbook store multiple values comma-separated |
|
241 | + foreach ($is_multiple && !is_array($data[$field]) ? explode(',', $data[$field]) : // regular custom fields (!$is_multiple) eg. addressbook store multiple values comma-separated |
|
243 | 242 | (array)(!$is_multiple && is_array($data[$field]) ? implode(',', $data[$field]) : $data[$field]) as $value) |
244 | 243 | { |
245 | - if (!$this->db->insert($this->extra_table,array($this->extra_value => $value)+$extra_cols,$where,__LINE__,__FILE__,$this->app)) |
|
244 | + if (!$this->db->insert($this->extra_table, array($this->extra_value => $value) + $extra_cols, $where, __LINE__, __FILE__, $this->app)) |
|
246 | 245 | { |
247 | 246 | return $this->db->Errno; |
248 | 247 | } |
249 | 248 | } |
250 | 249 | } |
251 | - return false; // no error |
|
250 | + return false; // no error |
|
252 | 251 | } |
253 | 252 | |
254 | 253 | /** |
@@ -264,7 +263,7 @@ discard block |
||
264 | 263 | |
265 | 264 | if ($this->customfields) |
266 | 265 | { |
267 | - foreach(array_keys($this->customfields) as $name) |
|
266 | + foreach (array_keys($this->customfields) as $name) |
|
268 | 267 | { |
269 | 268 | if (isset($new[$field = $this->get_cf_field($name)])) |
270 | 269 | { |
@@ -284,16 +283,16 @@ discard block |
||
284 | 283 | * @param string $join sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
285 | 284 | * @return array|boolean data if row could be retrived else False |
286 | 285 | */ |
287 | - function read($keys,$extra_cols='',$join='') |
|
286 | + function read($keys, $extra_cols = '', $join = '') |
|
288 | 287 | { |
289 | - if (!parent::read($keys,$extra_cols,$join)) |
|
288 | + if (!parent::read($keys, $extra_cols, $join)) |
|
290 | 289 | { |
291 | 290 | return false; |
292 | 291 | } |
293 | 292 | if (($id = (int)$this->data[$this->db_key_cols[$this->autoinc_id]]) && $this->customfields && |
294 | 293 | ($cfs = $this->read_customfields($id))) |
295 | 294 | { |
296 | - $this->data = array_merge($this->data,$cfs[$id]); |
|
295 | + $this->data = array_merge($this->data, $cfs[$id]); |
|
297 | 296 | } |
298 | 297 | return $this->data; |
299 | 298 | } |
@@ -307,14 +306,14 @@ discard block |
||
307 | 306 | * @param string|array $extra_where =null extra where clause, eg. to check an etag, returns true if no affected rows! |
308 | 307 | * @return int|boolean 0 on success, or errno != 0 on error, or true if $extra_where is given and no rows affected |
309 | 308 | */ |
310 | - function save($keys=null,$extra_where=null) |
|
309 | + function save($keys = null, $extra_where = null) |
|
311 | 310 | { |
312 | 311 | if (is_array($keys) && count($keys) && !isset($keys[0])) // allow to use an etag, eg array('etag=etag+1') |
313 | 312 | { |
314 | 313 | $this->data_merge($keys); |
315 | 314 | $keys = null; |
316 | 315 | } |
317 | - $ret = parent::save($keys,$extra_where); |
|
316 | + $ret = parent::save($keys, $extra_where); |
|
318 | 317 | |
319 | 318 | if ($ret == 0 && $this->customfields) |
320 | 319 | { |
@@ -332,26 +331,26 @@ discard block |
||
332 | 331 | * @param boolean $only_return_ids =false return $ids of delete call to db object, but not run it (can be used by extending classes!) |
333 | 332 | * @return int|array affected rows, should be 1 if ok, 0 if an error or array with id's if $only_return_ids |
334 | 333 | */ |
335 | - function delete($keys=null,$only_return_ids=false) |
|
334 | + function delete($keys = null, $only_return_ids = false) |
|
336 | 335 | { |
337 | 336 | if ($this->customfields || $only_return_ids) |
338 | 337 | { |
339 | - $query = parent::delete($keys,true); |
|
338 | + $query = parent::delete($keys, true); |
|
340 | 339 | // check if query contains more then the id's |
341 | 340 | if (!isset($query[$this->autoinc_id]) || count($query) != 1) |
342 | 341 | { |
343 | - foreach($this->db->select($this->table_name,$this->autoinc_id,$query,__LINE__,__FILE__,false,'',$this->app) as $row) |
|
342 | + foreach ($this->db->select($this->table_name, $this->autoinc_id, $query, __LINE__, __FILE__, false, '', $this->app) as $row) |
|
344 | 343 | { |
345 | 344 | $ids[] = $row[$this->autoinc_id]; |
346 | 345 | } |
347 | - if (!$ids) return 0; // no rows affected |
|
346 | + if (!$ids) return 0; // no rows affected |
|
348 | 347 | } |
349 | 348 | else |
350 | 349 | { |
351 | 350 | $ids = (array)$query[$this->autoinc_id]; |
352 | 351 | } |
353 | 352 | if ($only_return_ids) return $ids; |
354 | - $this->db->delete($this->extra_table,array($this->extra_id => $ids),__LINE__,__FILE__); |
|
353 | + $this->db->delete($this->extra_table, array($this->extra_id => $ids), __LINE__, __FILE__); |
|
355 | 354 | } |
356 | 355 | return parent::delete($keys); |
357 | 356 | } |
@@ -374,32 +373,32 @@ discard block |
||
374 | 373 | * @param string|array $extra_cols =array() |
375 | 374 | * @return int total number of rows |
376 | 375 | */ |
377 | - function get_rows($query,&$rows,&$readonlys,$join='',$need_full_no_count=false,$only_keys=false,$extra_cols=array()) |
|
376 | + function get_rows($query, &$rows, &$readonlys, $join = '', $need_full_no_count = false, $only_keys = false, $extra_cols = array()) |
|
378 | 377 | { |
379 | - parent::get_rows($query,$rows,$readonlys,$join,$need_full_no_count,$only_keys,$extra_cols); |
|
378 | + parent::get_rows($query, $rows, $readonlys, $join, $need_full_no_count, $only_keys, $extra_cols); |
|
380 | 379 | |
381 | - $selectcols = $query['selectcols'] ? explode(',',$query['selectcols']) : array(); |
|
380 | + $selectcols = $query['selectcols'] ? explode(',', $query['selectcols']) : array(); |
|
382 | 381 | |
383 | - if ($rows && $this->customfields && (!$selectcols || in_array('customfields',$selectcols))) |
|
382 | + if ($rows && $this->customfields && (!$selectcols || in_array('customfields', $selectcols))) |
|
384 | 383 | { |
385 | 384 | $id2keys = array(); |
386 | - foreach($rows as $key => $row) |
|
385 | + foreach ($rows as $key => $row) |
|
387 | 386 | { |
388 | 387 | $id2keys[$row[$this->db_key_cols[$this->autoinc_id]]] = $key; |
389 | 388 | } |
390 | 389 | // check if only certain cf's to show |
391 | 390 | if (!in_array('customfields', $selectcols)) |
392 | 391 | { |
393 | - foreach($selectcols as $col) |
|
392 | + foreach ($selectcols as $col) |
|
394 | 393 | { |
395 | 394 | if ($this->is_cf($col)) $fields[] = $this->get_cf_name($col); |
396 | 395 | } |
397 | 396 | } |
398 | - if (($cfs = $this->read_customfields(array_keys($id2keys),$fields))) |
|
397 | + if (($cfs = $this->read_customfields(array_keys($id2keys), $fields))) |
|
399 | 398 | { |
400 | - foreach($cfs as $id => $data) |
|
399 | + foreach ($cfs as $id => $data) |
|
401 | 400 | { |
402 | - $rows[$id2keys[$id]] = array_merge($rows[$id2keys[$id]],$data); |
|
401 | + $rows[$id2keys[$id]] = array_merge($rows[$id2keys[$id]], $data); |
|
403 | 402 | } |
404 | 403 | } |
405 | 404 | } |
@@ -426,12 +425,12 @@ discard block |
||
426 | 425 | * @param boolean $need_full_no_count =false If true an unlimited query is run to determine the total number of rows, default false |
427 | 426 | * @return array|NULL array of matching rows (the row is an array of the cols) or NULL |
428 | 427 | */ |
429 | - 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) |
|
428 | + 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) |
|
430 | 429 | { |
431 | 430 | //error_log(__METHOD__.'('.array2string(array_combine(array_slice(array('criteria','only_keys','order_by','extra_cols','wildcard','empty','op','start','filter','join','need_full_no_count'), 0, count(func_get_args())), func_get_args())).')'); |
432 | 431 | if (!$this->customfields) |
433 | 432 | { |
434 | - return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count); |
|
433 | + return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count); |
|
435 | 434 | } |
436 | 435 | if ($only_keys === false) |
437 | 436 | { |
@@ -440,7 +439,7 @@ discard block |
||
440 | 439 | // if string given as criteria --> search in all (or $this->columns_to_search) columns including custom fields |
441 | 440 | if ($criteria && is_string($criteria)) |
442 | 441 | { |
443 | - $criteria = $this->search2criteria($criteria,$wildcard,$op); |
|
442 | + $criteria = $this->search2criteria($criteria, $wildcard, $op); |
|
444 | 443 | } |
445 | 444 | if ($criteria && is_array($criteria)) |
446 | 445 | { |
@@ -449,10 +448,10 @@ discard block |
||
449 | 448 | { |
450 | 449 | if (($negate = $criteria[$this->extra_value][0] === '!')) |
451 | 450 | { |
452 | - $criteria[$this->extra_value] = substr($criteria[$this->extra_value],1); |
|
451 | + $criteria[$this->extra_value] = substr($criteria[$this->extra_value], 1); |
|
453 | 452 | } |
454 | - $criteria[] = $this->extra_table.'.'.$this->extra_value . ' ' .($negate ? 'NOT ' : ''). |
|
455 | - $this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE]. ' ' . |
|
453 | + $criteria[] = $this->extra_table.'.'.$this->extra_value.' '.($negate ? 'NOT ' : ''). |
|
454 | + $this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '. |
|
456 | 455 | $this->db->quote($wildcard.$criteria[$this->extra_value].$wildcard); |
457 | 456 | unset($criteria[$this->extra_value]); |
458 | 457 | } |
@@ -461,14 +460,14 @@ discard block |
||
461 | 460 | { |
462 | 461 | if ($criteria[$this->autoinc_id]) |
463 | 462 | { |
464 | - $criteria[] = $this->db->expression($this->table_name,$this->table_name.'.', |
|
463 | + $criteria[] = $this->db->expression($this->table_name, $this->table_name.'.', |
|
465 | 464 | array($this->autoinc_id => $criteria[$this->autoinc_id])); |
466 | 465 | } |
467 | 466 | unset($criteria[$this->autoinc_id]); |
468 | 467 | } |
469 | 468 | // replace ambiguous column with (an exact match of) table_name.column |
470 | 469 | $extra_join_added = $join && strpos($join, $this->extra_join) !== false; |
471 | - foreach($criteria as $name => $val) |
|
470 | + foreach ($criteria as $name => $val) |
|
472 | 471 | { |
473 | 472 | // only add extra_join, if we really need it |
474 | 473 | if (!$extra_join_added && ( |
@@ -480,9 +479,9 @@ discard block |
||
480 | 479 | $extra_join_added = true; |
481 | 480 | } |
482 | 481 | $extra_columns = $this->db->get_table_definitions($this->app, $this->extra_table); |
483 | - if(is_string($name) && $extra_columns['fd'][array_search($name, $this->db_cols)]) |
|
482 | + if (is_string($name) && $extra_columns['fd'][array_search($name, $this->db_cols)]) |
|
484 | 483 | { |
485 | - $criteria[] = $this->db->expression($this->table_name,$this->table_name.'.',array( |
|
484 | + $criteria[] = $this->db->expression($this->table_name, $this->table_name.'.', array( |
|
486 | 485 | array_search($name, $this->db_cols) => $val, |
487 | 486 | )); |
488 | 487 | unset($criteria[$name]); |
@@ -494,12 +493,12 @@ discard block |
||
494 | 493 | $name = substr($name, 1); |
495 | 494 | if (($negate = $criteria[$name][0] === '!')) |
496 | 495 | { |
497 | - $val = substr($val,1); |
|
496 | + $val = substr($val, 1); |
|
498 | 497 | } |
499 | - $cfcriteria[] = '(' . $this->extra_table.'.'.$this->extra_value . ' ' .($negate ? 'NOT ' : ''). |
|
500 | - $this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE]. ' ' . |
|
501 | - $this->db->quote($wildcard.$val.$wildcard) . ' AND ' . |
|
502 | - $this->extra_table.'.'.$this->extra_key . ' = ' . $this->db->quote($name) . |
|
498 | + $cfcriteria[] = '('.$this->extra_table.'.'.$this->extra_value.' '.($negate ? 'NOT ' : ''). |
|
499 | + $this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '. |
|
500 | + $this->db->quote($wildcard.$val.$wildcard).' AND '. |
|
501 | + $this->extra_table.'.'.$this->extra_key.' = '.$this->db->quote($name). |
|
503 | 502 | ')'; |
504 | 503 | unset($criteria[self::CF_PREFIX.$name]); |
505 | 504 | } |
@@ -511,38 +510,38 @@ discard block |
||
511 | 510 | } |
512 | 511 | } |
513 | 512 | } |
514 | - if ($cfcriteria && $op =='OR') $criteria[] = implode(' OR ',$cfcriteria); |
|
513 | + if ($cfcriteria && $op == 'OR') $criteria[] = implode(' OR ', $cfcriteria); |
|
515 | 514 | } |
516 | - if($only_keys === true) |
|
515 | + if ($only_keys === true) |
|
517 | 516 | { |
518 | 517 | // Expand to keys here, so table_name can be prepended below |
519 | 518 | $only_keys = array_values($this->db_key_cols); |
520 | 519 | } |
521 | 520 | // replace ambiguous column with (an exact match of) table_name.column |
522 | - if(is_array($only_keys)) |
|
521 | + if (is_array($only_keys)) |
|
523 | 522 | { |
524 | - foreach($only_keys as $key => &$col) |
|
523 | + foreach ($only_keys as $key => &$col) |
|
525 | 524 | { |
526 | - if(is_numeric($key) && in_array($col, $this->db_cols, true)) |
|
525 | + if (is_numeric($key) && in_array($col, $this->db_cols, true)) |
|
527 | 526 | { |
528 | - $col = $this->table_name .'.'.array_search($col, $this->db_cols).' AS '.$col; |
|
527 | + $col = $this->table_name.'.'.array_search($col, $this->db_cols).' AS '.$col; |
|
529 | 528 | } |
530 | 529 | } |
531 | 530 | } |
532 | 531 | // check if we order by a custom field --> join cf table for given cf and order by it's value |
533 | - if (strpos($order_by,self::CF_PREFIX) !== false) |
|
532 | + if (strpos($order_by, self::CF_PREFIX) !== false) |
|
534 | 533 | { |
535 | 534 | // fields to order by, as cutomfields may have names with spaces, we examine each order by criteria |
536 | - $fields2order = explode(',',$order_by); |
|
537 | - foreach($fields2order as $v) |
|
535 | + $fields2order = explode(',', $order_by); |
|
536 | + foreach ($fields2order as $v) |
|
538 | 537 | { |
539 | - if (strpos($v,self::CF_PREFIX) !== false) |
|
538 | + if (strpos($v, self::CF_PREFIX) !== false) |
|
540 | 539 | { |
541 | 540 | // we found a customfield, so we split that part by space char in order to get Sorting Direction and Fieldname |
542 | - $buff = explode(' ',trim($v)); |
|
541 | + $buff = explode(' ', trim($v)); |
|
543 | 542 | $orderDir = array_pop($buff); |
544 | - $key = substr(trim(implode(' ',$buff)), 1); |
|
545 | - switch($this->customfields[$key]['type']) |
|
543 | + $key = substr(trim(implode(' ', $buff)), 1); |
|
544 | + switch ($this->customfields[$key]['type']) |
|
546 | 545 | { |
547 | 546 | case 'int': |
548 | 547 | $order_by = str_replace($v, 'extra_order.'.$this->extra_value.' IS NULL,'. |
@@ -575,26 +574,26 @@ discard block |
||
575 | 574 | { |
576 | 575 | $_cfnames = array_keys($this->customfields); |
577 | 576 | $extra_filter = null; |
578 | - foreach($filter as $name => $val) |
|
577 | + foreach ($filter as $name => $val) |
|
579 | 578 | { |
580 | 579 | // replace ambiguous auto-id with (an exact match of) table_name.autoid |
581 | 580 | if (is_string($name) && $name == $this->autoinc_id) |
582 | 581 | { |
583 | 582 | if ((int)$filter[$this->autoinc_id]) |
584 | 583 | { |
585 | - $filter[] = $this->db->expression($this->table_name,$this->table_name.'.',array( |
|
584 | + $filter[] = $this->db->expression($this->table_name, $this->table_name.'.', array( |
|
586 | 585 | $this->autoinc_id => $filter[$this->autoinc_id], |
587 | 586 | )); |
588 | 587 | } |
589 | 588 | unset($filter[$this->autoinc_id]); |
590 | 589 | } |
591 | 590 | // replace ambiguous column with (an exact match of) table_name.column |
592 | - elseif (is_string($name) && $val!=null && in_array($name, $this->db_cols)) |
|
591 | + elseif (is_string($name) && $val != null && in_array($name, $this->db_cols)) |
|
593 | 592 | { |
594 | 593 | $extra_columns = $this->db->get_table_definitions($this->app, $this->extra_table); |
595 | 594 | if ($extra_columns['fd'][array_search($name, $this->db_cols)]) |
596 | 595 | { |
597 | - $filter[] = $this->db->expression($this->table_name,$this->table_name.'.',array( |
|
596 | + $filter[] = $this->db->expression($this->table_name, $this->table_name.'.', array( |
|
598 | 597 | array_search($name, $this->db_cols) => $val, |
599 | 598 | )); |
600 | 599 | unset($filter[$name]); |
@@ -606,61 +605,61 @@ discard block |
||
606 | 605 | { |
607 | 606 | if ($val[0] === '!') // negative filter |
608 | 607 | { |
609 | - $sql_filter = 'extra_filter.'.$this->extra_value.'!='.$this->db->quote(substr($val,1)); |
|
608 | + $sql_filter = 'extra_filter.'.$this->extra_value.'!='.$this->db->quote(substr($val, 1)); |
|
610 | 609 | } |
611 | 610 | else // using Db::expression to allow to use array() with possible values or NULL |
612 | 611 | { |
613 | - if($this->customfields[$this->get_cf_name($name)]['type'] == 'select' && |
|
612 | + if ($this->customfields[$this->get_cf_name($name)]['type'] == 'select' && |
|
614 | 613 | $this->customfields[$this->get_cf_name($name)]['rows'] > 1) |
615 | 614 | { |
616 | 615 | // Multi-select - any entry with the filter value selected matches |
617 | - $sql_filter = str_replace($this->extra_value,'extra_filter.'. |
|
618 | - $this->extra_value,$this->db->expression($this->extra_table,array( |
|
619 | - $this->db->concat("','",$this->extra_value,"','").' '.$this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$val.',%') |
|
616 | + $sql_filter = str_replace($this->extra_value, 'extra_filter.'. |
|
617 | + $this->extra_value, $this->db->expression($this->extra_table, array( |
|
618 | + $this->db->concat("','", $this->extra_value, "','").' '.$this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$val.',%') |
|
620 | 619 | )) |
621 | 620 | ); |
622 | 621 | } |
623 | 622 | elseif ($this->customfields[$this->get_cf_name($name)]['type'] == 'text') |
624 | 623 | { |
625 | - $sql_filter = str_replace($this->extra_value,'extra_filter.'.$this->extra_value, |
|
626 | - $this->db->expression($this->extra_table,array( |
|
624 | + $sql_filter = str_replace($this->extra_value, 'extra_filter.'.$this->extra_value, |
|
625 | + $this->db->expression($this->extra_table, array( |
|
627 | 626 | $this->extra_value.' '.$this->db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote($wildcard.$val.$wildcard) |
628 | 627 | )) |
629 | 628 | ); |
630 | 629 | } |
631 | 630 | else |
632 | 631 | { |
633 | - $sql_filter = str_replace($this->extra_value,'extra_filter.'. |
|
634 | - $this->extra_value,$this->db->expression($this->extra_table,array($this->extra_value => $val))); |
|
632 | + $sql_filter = str_replace($this->extra_value, 'extra_filter.'. |
|
633 | + $this->extra_value, $this->db->expression($this->extra_table, array($this->extra_value => $val))); |
|
635 | 634 | } |
636 | 635 | } |
637 | 636 | // need to use a LEFT JOIN for negative search or to allow NULL values |
638 | - $need_left_join = $val[0] === '!' || strpos($sql_filter,'IS NULL') !== false ? ' LEFT ' : ''; |
|
639 | - $join .= str_replace('extra_filter','extra_filter'.$extra_filter,$need_left_join.$this->extra_join_filter. |
|
637 | + $need_left_join = $val[0] === '!' || strpos($sql_filter, 'IS NULL') !== false ? ' LEFT ' : ''; |
|
638 | + $join .= str_replace('extra_filter', 'extra_filter'.$extra_filter, $need_left_join.$this->extra_join_filter. |
|
640 | 639 | ' AND extra_filter.'.$this->extra_key.'='.$this->db->quote($this->get_cf_name($name)). |
641 | 640 | ' AND '.$sql_filter); |
642 | 641 | ++$extra_filter; |
643 | 642 | } |
644 | 643 | unset($filter[$name]); |
645 | 644 | } |
646 | - elseif(is_int($name) && $this->is_cf($val)) // lettersearch: #cfname LIKE 's%' |
|
645 | + elseif (is_int($name) && $this->is_cf($val)) // lettersearch: #cfname LIKE 's%' |
|
647 | 646 | { |
648 | - $_cf = explode(' ',$val); |
|
649 | - foreach($_cf as $cf_np) |
|
647 | + $_cf = explode(' ', $val); |
|
648 | + foreach ($_cf as $cf_np) |
|
650 | 649 | { |
651 | 650 | // building cf_name by glueing parts together (, in case someone used whitespace in their custom field names) |
652 | - $tcf_name = ($tcf_name?$tcf_name.' ':'').$cf_np; |
|
651 | + $tcf_name = ($tcf_name ? $tcf_name.' ' : '').$cf_np; |
|
653 | 652 | // reacts on the first one found that matches an existing customfield, should be better then the old behavior of |
654 | 653 | // simply splitting by " " and using the first part |
655 | - if ($this->is_cf($tcf_name) && ($cfn = $this->get_cf_name($tcf_name)) && array_search($cfn,(array)$_cfnames,true)!==false ) |
|
654 | + if ($this->is_cf($tcf_name) && ($cfn = $this->get_cf_name($tcf_name)) && array_search($cfn, (array)$_cfnames, true) !== false) |
|
656 | 655 | { |
657 | 656 | $cf = $tcf_name; |
658 | 657 | break; |
659 | 658 | } |
660 | 659 | } |
661 | - $join .= str_replace('extra_filter','extra_filter'.$extra_filter,$this->extra_join_filter. |
|
660 | + $join .= str_replace('extra_filter', 'extra_filter'.$extra_filter, $this->extra_join_filter. |
|
662 | 661 | ' AND extra_filter.'.$this->extra_key.'='.$this->db->quote($this->get_cf_name($cf)). |
663 | - ' AND '.str_replace($cf,'extra_filter.'.$this->extra_value,$val)); |
|
662 | + ' AND '.str_replace($cf, 'extra_filter.'.$this->extra_value, $val)); |
|
664 | 663 | ++$extra_filter; |
665 | 664 | unset($filter[$name]); |
666 | 665 | } |
@@ -672,15 +671,14 @@ discard block |
||
672 | 671 | if (is_array($only_keys)) |
673 | 672 | { |
674 | 673 | $only_keys = array_values($only_keys); |
675 | - $only_keys[0] = 'DISTINCT '.($only_keys[0] != $this->autoinc_id ? $only_keys[0] : |
|
676 | - $this->table_name.'.'.$this->autoinc_id.' AS '.$this->autoinc_id); |
|
674 | + $only_keys[0] = 'DISTINCT '.($only_keys[0] != $this->autoinc_id ? $only_keys[0] : $this->table_name.'.'.$this->autoinc_id.' AS '.$this->autoinc_id); |
|
677 | 675 | } |
678 | 676 | else |
679 | 677 | { |
680 | 678 | $only_keys = 'DISTINCT '.$only_keys; |
681 | 679 | } |
682 | 680 | } |
683 | - return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count); |
|
681 | + return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count); |
|
684 | 682 | } |
685 | 683 | |
686 | 684 | /** |
@@ -720,7 +718,7 @@ discard block |
||
720 | 718 | */ |
721 | 719 | function get_cf_name($field) |
722 | 720 | { |
723 | - return substr($field,1); |
|
721 | + return substr($field, 1); |
|
724 | 722 | } |
725 | 723 | |
726 | 724 | /** |
@@ -742,7 +740,7 @@ discard block |
||
742 | 740 | */ |
743 | 741 | function is_multiple($name) |
744 | 742 | { |
745 | - return $this->allow_multiple_values && in_array($this->customfields[$name]['type'],array('select','select-account')) && |
|
743 | + return $this->allow_multiple_values && in_array($this->customfields[$name]['type'], array('select', 'select-account')) && |
|
746 | 744 | $this->customfields[$name]['rows'] > 1; |
747 | 745 | } |
748 | 746 | } |
@@ -127,7 +127,11 @@ discard block |
||
127 | 127 | |
128 | 128 | $this->allow_multiple_values = $allow_multiple_values; |
129 | 129 | $this->extra_table = $extra_table; |
130 | - if (!$this->extra_id) $this->extra_id = $this->autoinc_id; // default to auto id of regular table |
|
130 | + if (!$this->extra_id) |
|
131 | + { |
|
132 | + $this->extra_id = $this->autoinc_id; |
|
133 | + } |
|
134 | + // default to auto id of regular table |
|
131 | 135 | |
132 | 136 | // if names from columns of extra table are only postfixes (starting with _), prepend column prefix |
133 | 137 | if (!($prefix=$column_prefix)) |
@@ -145,7 +149,10 @@ discard block |
||
145 | 149 | ) as $col => $val) |
146 | 150 | { |
147 | 151 | $this->$col = $col_name = $val; |
148 | - if ($col_name[0] == '_') $this->$col = $prefix . $val; |
|
152 | + if ($col_name[0] == '_') |
|
153 | + { |
|
154 | + $this->$col = $prefix . $val; |
|
155 | + } |
|
149 | 156 | } |
150 | 157 | // some sanity checks, maybe they should be active only for development |
151 | 158 | if (!($extra_defs = $this->db->get_table_definitions($app,$extra_table))) |
@@ -179,13 +186,23 @@ discard block |
||
179 | 186 | */ |
180 | 187 | function read_customfields($ids,$field_names=null) |
181 | 188 | { |
182 | - if (is_null($field_names)) $field_names = array_keys($this->customfields); |
|
189 | + if (is_null($field_names)) |
|
190 | + { |
|
191 | + $field_names = array_keys($this->customfields); |
|
192 | + } |
|
183 | 193 | |
184 | 194 | foreach((array)$ids as $key => $id) |
185 | 195 | { |
186 | - if (!(int)$id && is_array($ids)) unset($ids[$key]); |
|
196 | + if (!(int)$id && is_array($ids)) |
|
197 | + { |
|
198 | + unset($ids[$key]); |
|
199 | + } |
|
187 | 200 | } |
188 | - if (!$ids || !$field_names) return array(); // nothing to do |
|
201 | + if (!$ids || !$field_names) |
|
202 | + { |
|
203 | + return array(); |
|
204 | + } |
|
205 | + // nothing to do |
|
189 | 206 | |
190 | 207 | $entries = array(); |
191 | 208 | foreach($this->db->select($this->extra_table,'*',array( |
@@ -194,7 +211,10 @@ discard block |
||
194 | 211 | ),__LINE__,__FILE__,false,'',$this->app) as $row) |
195 | 212 | { |
196 | 213 | $entry =& $entries[$row[$this->extra_id]]; |
197 | - if (!is_array($entry)) $entry = array(); |
|
214 | + if (!is_array($entry)) |
|
215 | + { |
|
216 | + $entry = array(); |
|
217 | + } |
|
198 | 218 | $field = $this->get_cf_field($row[$this->extra_key]); |
199 | 219 | |
200 | 220 | if ($this->allow_multiple_values && $this->is_multiple($row[$this->extra_key])) |
@@ -224,7 +244,10 @@ discard block |
||
224 | 244 | |
225 | 245 | foreach (array_keys((array)$this->customfields) as $name) |
226 | 246 | { |
227 | - if (!isset($data[$field = $this->get_cf_field($name)])) continue; |
|
247 | + if (!isset($data[$field = $this->get_cf_field($name)])) |
|
248 | + { |
|
249 | + continue; |
|
250 | + } |
|
228 | 251 | |
229 | 252 | $where = array( |
230 | 253 | $this->extra_id => isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]], |
@@ -236,7 +259,11 @@ discard block |
||
236 | 259 | if(empty($data[$field]) || $is_multiple || !$this->extra_has_unique_index) |
237 | 260 | { |
238 | 261 | $this->db->delete($this->extra_table,$where,__LINE__,__FILE__,$this->app); |
239 | - if (empty($data[$field])) continue; // nothing else to do for empty values |
|
262 | + if (empty($data[$field])) |
|
263 | + { |
|
264 | + continue; |
|
265 | + } |
|
266 | + // nothing else to do for empty values |
|
240 | 267 | } |
241 | 268 | foreach($is_multiple && !is_array($data[$field]) ? explode(',',$data[$field]) : |
242 | 269 | // regular custom fields (!$is_multiple) eg. addressbook store multiple values comma-separated |
@@ -309,9 +336,12 @@ discard block |
||
309 | 336 | */ |
310 | 337 | function save($keys=null,$extra_where=null) |
311 | 338 | { |
312 | - if (is_array($keys) && count($keys) && !isset($keys[0])) // allow to use an etag, eg array('etag=etag+1') |
|
339 | + if (is_array($keys) && count($keys) && !isset($keys[0])) |
|
340 | + { |
|
341 | + // allow to use an etag, eg array('etag=etag+1') |
|
313 | 342 | { |
314 | 343 | $this->data_merge($keys); |
344 | + } |
|
315 | 345 | $keys = null; |
316 | 346 | } |
317 | 347 | $ret = parent::save($keys,$extra_where); |
@@ -344,13 +374,20 @@ discard block |
||
344 | 374 | { |
345 | 375 | $ids[] = $row[$this->autoinc_id]; |
346 | 376 | } |
347 | - if (!$ids) return 0; // no rows affected |
|
377 | + if (!$ids) |
|
378 | + { |
|
379 | + return 0; |
|
380 | + } |
|
381 | + // no rows affected |
|
348 | 382 | } |
349 | 383 | else |
350 | 384 | { |
351 | 385 | $ids = (array)$query[$this->autoinc_id]; |
352 | 386 | } |
353 | - if ($only_return_ids) return $ids; |
|
387 | + if ($only_return_ids) |
|
388 | + { |
|
389 | + return $ids; |
|
390 | + } |
|
354 | 391 | $this->db->delete($this->extra_table,array($this->extra_id => $ids),__LINE__,__FILE__); |
355 | 392 | } |
356 | 393 | return parent::delete($keys); |
@@ -392,7 +429,10 @@ discard block |
||
392 | 429 | { |
393 | 430 | foreach($selectcols as $col) |
394 | 431 | { |
395 | - if ($this->is_cf($col)) $fields[] = $this->get_cf_name($col); |
|
432 | + if ($this->is_cf($col)) |
|
433 | + { |
|
434 | + $fields[] = $this->get_cf_name($col); |
|
435 | + } |
|
396 | 436 | } |
397 | 437 | } |
398 | 438 | if (($cfs = $this->read_customfields(array_keys($id2keys),$fields))) |
@@ -511,7 +551,10 @@ discard block |
||
511 | 551 | } |
512 | 552 | } |
513 | 553 | } |
514 | - if ($cfcriteria && $op =='OR') $criteria[] = implode(' OR ',$cfcriteria); |
|
554 | + if ($cfcriteria && $op =='OR') |
|
555 | + { |
|
556 | + $criteria[] = implode(' OR ',$cfcriteria); |
|
557 | + } |
|
515 | 558 | } |
516 | 559 | if($only_keys === true) |
517 | 560 | { |
@@ -602,11 +645,14 @@ discard block |
||
602 | 645 | } |
603 | 646 | elseif (is_string($name) && $this->is_cf($name)) |
604 | 647 | { |
605 | - if (!empty($val)) // empty -> dont filter |
|
648 | + if (!empty($val)) |
|
649 | + { |
|
650 | + // empty -> dont filter |
|
606 | 651 | { |
607 | 652 | if ($val[0] === '!') // negative filter |
608 | 653 | { |
609 | 654 | $sql_filter = 'extra_filter.'.$this->extra_value.'!='.$this->db->quote(substr($val,1)); |
655 | + } |
|
610 | 656 | } |
611 | 657 | else // using Db::expression to allow to use array() with possible values or NULL |
612 | 658 | { |
@@ -643,9 +689,12 @@ discard block |
||
643 | 689 | } |
644 | 690 | unset($filter[$name]); |
645 | 691 | } |
646 | - elseif(is_int($name) && $this->is_cf($val)) // lettersearch: #cfname LIKE 's%' |
|
692 | + elseif(is_int($name) && $this->is_cf($val)) |
|
693 | + { |
|
694 | + // lettersearch: #cfname LIKE 's%' |
|
647 | 695 | { |
648 | 696 | $_cf = explode(' ',$val); |
697 | + } |
|
649 | 698 | foreach($_cf as $cf_np) |
650 | 699 | { |
651 | 700 | // building cf_name by glueing parts together (, in case someone used whitespace in their custom field names) |
@@ -112,6 +112,8 @@ |
||
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Static function to add a history record |
115 | + * @param string $field_code |
|
116 | + * @param string $new_value |
|
115 | 117 | */ |
116 | 118 | public static function static_add($appname, $id, $user, $field_code, $new_value, $old_value = '') |
117 | 119 | { |
@@ -142,7 +142,10 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function search($filter,$order='history_id',$sort='DESC',$limit=null) |
144 | 144 | { |
145 | - if (!is_array($filter)) $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array(); |
|
145 | + if (!is_array($filter)) |
|
146 | + { |
|
147 | + $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array(); |
|
148 | + } |
|
146 | 149 | |
147 | 150 | if (!$order || !preg_match('/^[a-z0-9_]+$/i',$order) || !preg_match('/^(asc|desc)?$/i',$sort)) |
148 | 151 | { |
@@ -160,10 +163,16 @@ discard block |
||
160 | 163 | unset($filter[$col]); |
161 | 164 | } |
162 | 165 | } |
163 | - if (!isset($filter['history_appname'])) $filter['history_appname'] = $this->appname; |
|
166 | + if (!isset($filter['history_appname'])) |
|
167 | + { |
|
168 | + $filter['history_appname'] = $this->appname; |
|
169 | + } |
|
164 | 170 | |
165 | 171 | // do not try to read all history entries of an app |
166 | - if (!$filter['history_record_id']) return array(); |
|
172 | + if (!$filter['history_record_id']) |
|
173 | + { |
|
174 | + return array(); |
|
175 | + } |
|
167 | 176 | |
168 | 177 | $rows = array(); |
169 | 178 | foreach($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__, |
@@ -188,8 +197,10 @@ discard block |
||
188 | 197 | $rows = array(); |
189 | 198 | $filter['history_appname'] = $query['appname']; |
190 | 199 | $filter['history_record_id'] = $query['record_id']; |
191 | - if(is_array($query['colfilter'])) { |
|
192 | - foreach($query['colfilter'] as $column => $value) { |
|
200 | + if(is_array($query['colfilter'])) |
|
201 | + { |
|
202 | + foreach($query['colfilter'] as $column => $value) |
|
203 | + { |
|
193 | 204 | $filter[$column] = $value; |
194 | 205 | } |
195 | 206 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param string $appname app name this instance operates on |
52 | 52 | * @return historylog |
53 | 53 | */ |
54 | - function __construct($appname='',$user=null) |
|
54 | + function __construct($appname = '', $user = null) |
|
55 | 55 | { |
56 | 56 | $this->appname = $appname ? $appname : $GLOBALS['egw_info']['flags']['currentapp']; |
57 | 57 | $this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id']; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $where['history_record_id'] = $record_id; |
82 | 82 | } |
83 | - $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
83 | + $this->db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
84 | 84 | |
85 | 85 | return $this->db->affected_rows(); |
86 | 86 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param string $new_value new value |
94 | 94 | * @param string $old_value old value |
95 | 95 | */ |
96 | - function add($status,$record_id,$new_value,$old_value) |
|
96 | + function add($status, $record_id, $new_value, $old_value) |
|
97 | 97 | { |
98 | 98 | if ($new_value != $old_value) |
99 | 99 | { |
100 | - $this->db->insert(self::TABLE,array( |
|
100 | + $this->db->insert(self::TABLE, array( |
|
101 | 101 | 'history_record_id' => $record_id, |
102 | 102 | 'history_appname' => $this->appname, |
103 | 103 | 'history_owner' => $this->user, |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'history_old_value' => $old_value, |
107 | 107 | 'history_timestamp' => time(), |
108 | 108 | 'sessionid' => $GLOBALS['egw']->session->sessionid_access_log, |
109 | - ),false,__LINE__,__FILE__); |
|
109 | + ), false, __LINE__, __FILE__); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | if ($new_value != $old_value) |
119 | 119 | { |
120 | - $GLOBALS['egw']->db->insert(self::TABLE,array( |
|
120 | + $GLOBALS['egw']->db->insert(self::TABLE, array( |
|
121 | 121 | 'history_record_id' => $id, |
122 | 122 | 'history_appname' => $appname, |
123 | 123 | 'history_owner' => (int)$user, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | 'history_old_value' => $old_value, |
127 | 127 | 'history_timestamp' => time(), |
128 | 128 | 'sessionid' => $GLOBALS['egw']->session->sessionid_access_log, |
129 | - ),false,__LINE__,__FILE__); |
|
129 | + ), false, __LINE__, __FILE__); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | * @return array of arrays with keys id, record_id, appname, owner (account_id), status, new_value, old_value, |
141 | 141 | * timestamp (Y-m-d H:i:s in servertime), user_ts (timestamp in user-time) |
142 | 142 | */ |
143 | - function search($filter,$order='history_id',$sort='DESC',$limit=null) |
|
143 | + function search($filter, $order = 'history_id', $sort = 'DESC', $limit = null) |
|
144 | 144 | { |
145 | 145 | if (!is_array($filter)) $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array(); |
146 | 146 | |
147 | - if (!$order || !preg_match('/^[a-z0-9_]+$/i',$order) || !preg_match('/^(asc|desc)?$/i',$sort)) |
|
147 | + if (!$order || !preg_match('/^[a-z0-9_]+$/i', $order) || !preg_match('/^(asc|desc)?$/i', $sort)) |
|
148 | 148 | { |
149 | 149 | $orderby = 'ORDER BY history_id DESC'; |
150 | 150 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | $orderby = "ORDER BY $order $sort"; |
154 | 154 | } |
155 | - foreach($filter as $col => $value) |
|
155 | + foreach ($filter as $col => $value) |
|
156 | 156 | { |
157 | - if (!is_numeric($col) && substr($col,0,8) != 'history_') |
|
157 | + if (!is_numeric($col) && substr($col, 0, 8) != 'history_') |
|
158 | 158 | { |
159 | 159 | $filter['history_'.$col] = $value; |
160 | 160 | unset($filter[$col]); |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | if (!$filter['history_record_id']) return array(); |
167 | 167 | |
168 | 168 | $rows = array(); |
169 | - foreach($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__, |
|
169 | + foreach ($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__, |
|
170 | 170 | isset($limit) ? 0 : false, $orderby, 'phpgwapi', $limit) as $row) |
171 | 171 | { |
172 | 172 | $row['user_ts'] = $this->db->from_timestamp($row['history_timestamp']) + 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']; |
173 | - $rows[] = Api\Db::strip_array_keys($row,'history_'); |
|
173 | + $rows[] = Api\Db::strip_array_keys($row, 'history_'); |
|
174 | 174 | } |
175 | 175 | return $rows; |
176 | 176 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | $rows = array(); |
189 | 189 | $filter['history_appname'] = $query['appname']; |
190 | 190 | $filter['history_record_id'] = $query['record_id']; |
191 | - if(is_array($query['colfilter'])) { |
|
192 | - foreach($query['colfilter'] as $column => $value) { |
|
191 | + if (is_array($query['colfilter'])) { |
|
192 | + foreach ($query['colfilter'] as $column => $value) { |
|
193 | 193 | $filter[$column] = $value; |
194 | 194 | } |
195 | 195 | } |
@@ -199,20 +199,20 @@ discard block |
||
199 | 199 | } |
200 | 200 | else |
201 | 201 | { |
202 | - $total = $GLOBALS['egw']->db->select(self::TABLE,'COUNT(*)',$filter,__LINE__,__FILE__,false,'','phpgwapi',0)->fetchColumn(); |
|
202 | + $total = $GLOBALS['egw']->db->select(self::TABLE, 'COUNT(*)', $filter, __LINE__, __FILE__, false, '', 'phpgwapi', 0)->fetchColumn(); |
|
203 | 203 | } |
204 | 204 | // filter out private (or no longer defined) custom fields |
205 | 205 | if ($filter['history_appname']) |
206 | 206 | { |
207 | 207 | $to_or[] = "history_status NOT LIKE '#%'"; |
208 | 208 | // explicitly allow "##" used to store iCal/vCard X-attributes |
209 | - if (in_array($filter['history_appname'], array('calendar','infolog','addressbook'))) |
|
209 | + if (in_array($filter['history_appname'], array('calendar', 'infolog', 'addressbook'))) |
|
210 | 210 | { |
211 | 211 | $to_or[] = "history_status LIKE '##%'"; |
212 | 212 | } |
213 | 213 | if (($cfs = Customfields::get($filter['history_appname']))) |
214 | 214 | { |
215 | - $to_or[] = 'history_status IN ('.implode(',', array_map(function($str) |
|
215 | + $to_or[] = 'history_status IN ('.implode(',', array_map(function($str) |
|
216 | 216 | { |
217 | 217 | return $GLOBALS['egw']->db->quote('#'.$str); |
218 | 218 | }, array_keys($cfs))).')'; |
@@ -221,26 +221,26 @@ discard block |
||
221 | 221 | } |
222 | 222 | $_query = array(array( |
223 | 223 | 'table' => self::TABLE, |
224 | - 'cols' => array('history_id', 'history_record_id','history_appname','history_owner','history_status','history_new_value', 'history_timestamp','history_old_value'), |
|
224 | + 'cols' => array('history_id', 'history_record_id', 'history_appname', 'history_owner', 'history_status', 'history_new_value', 'history_timestamp', 'history_old_value'), |
|
225 | 225 | 'where' => $filter, |
226 | 226 | )); |
227 | 227 | |
228 | 228 | // Add in files, if possible |
229 | - if($GLOBALS['egw_info']['user']['apps']['filemanager'] && |
|
229 | + if ($GLOBALS['egw_info']['user']['apps']['filemanager'] && |
|
230 | 230 | ($sqlfs_sw = new Api\Vfs\Sqlfs\StreamWrapper()) && |
231 | - ($file = $sqlfs_sw->url_stat("/apps/{$query['appname']}/{$query['record_id']}",STREAM_URL_STAT_LINK))) |
|
231 | + ($file = $sqlfs_sw->url_stat("/apps/{$query['appname']}/{$query['record_id']}", STREAM_URL_STAT_LINK))) |
|
232 | 232 | { |
233 | 233 | $_query[] = array( |
234 | 234 | 'table' => Api\Vfs\Sqlfs\StreamWrapper::TABLE, |
235 | - 'cols' =>array('fs_id', 'fs_dir', "'filemanager'",'COALESCE(fs_modifier,fs_creator)',"'~file~'",'fs_name','fs_modified', 'fs_mime'), |
|
235 | + 'cols' =>array('fs_id', 'fs_dir', "'filemanager'", 'COALESCE(fs_modifier,fs_creator)', "'~file~'", 'fs_name', 'fs_modified', 'fs_mime'), |
|
236 | 236 | 'where' => array('fs_dir' => $file['ino']) |
237 | 237 | ); |
238 | 238 | } |
239 | 239 | $new_file_id = array(); |
240 | - foreach($GLOBALS['egw']->db->union( |
|
240 | + foreach ($GLOBALS['egw']->db->union( |
|
241 | 241 | $_query, |
242 | 242 | __LINE__, __FILE__, |
243 | - ' ORDER BY ' . ($query['order'] ? $query['order'] : 'history_timestamp') . ' ' . ($query['sort'] ? $query['sort'] : 'DESC'), |
|
243 | + ' ORDER BY '.($query['order'] ? $query['order'] : 'history_timestamp').' '.($query['sort'] ? $query['sort'] : 'DESC'), |
|
244 | 244 | $query['start'], |
245 | 245 | $query['num_rows'] |
246 | 246 | ) as $row) |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | $row['user_ts'] = $GLOBALS['egw']->db->from_timestamp($row['history_timestamp']) + 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']; |
249 | 249 | |
250 | 250 | // Explode multi-part values |
251 | - foreach(array('history_new_value','history_old_value') as $field) |
|
251 | + foreach (array('history_new_value', 'history_old_value') as $field) |
|
252 | 252 | { |
253 | - if(strpos($row[$field],Tracking::ONE2N_SEPERATOR) !== false) |
|
253 | + if (strpos($row[$field], Tracking::ONE2N_SEPERATOR) !== false) |
|
254 | 254 | { |
255 | - $row[$field] = explode(Tracking::ONE2N_SEPERATOR,$row[$field]); |
|
255 | + $row[$field] = explode(Tracking::ONE2N_SEPERATOR, $row[$field]); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | // Get information needed for proper display |
259 | - if($row['history_appname'] == 'filemanager') |
|
259 | + if ($row['history_appname'] == 'filemanager') |
|
260 | 260 | { |
261 | 261 | $new_version = $new_file_id[$row['history_new_value']]; |
262 | 262 | $new_file_id[$row['history_new_value']] = count($rows); |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | 'mime' => $row['history_old_value'] |
273 | 273 | ); |
274 | 274 | $row['history_old_value'] = ''; |
275 | - if($new_version !== null) |
|
275 | + if ($new_version !== null) |
|
276 | 276 | { |
277 | 277 | $rows[$new_version]['old_value'] = $row['history_new_value']; |
278 | 278 | } |
279 | 279 | } |
280 | - $rows[] = Api\Db::strip_array_keys($row,'history_'); |
|
280 | + $rows[] = Api\Db::strip_array_keys($row, 'history_'); |
|
281 | 281 | } |
282 | 282 | if ($mysql_calc_rows) |
283 | 283 | { |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * @param array $data current entry |
529 | 529 | * @param array $old = null old/last state of the entry or null for a new entry |
530 | 530 | * @param boolean $deleted = null can be set to true to let the tracking know the item got deleted or undelted |
531 | - * @param array $email_notified=null if present will return the emails notified, if given emails in that list will not be notified |
|
531 | + * @param array $email_notified if present will return the emails notified, if given emails in that list will not be notified |
|
532 | 532 | * @return boolean true on success, false on error (error messages are in $this->errors) |
533 | 533 | */ |
534 | 534 | public function do_notifications($data,$old,$deleted=null,&$email_notified=null) |
@@ -824,7 +824,6 @@ discard block |
||
824 | 824 | * The default implementation prefers depending on the prefer_user_as_sender class-var the user over |
825 | 825 | * what is returned by get_config('sender'). |
826 | 826 | * |
827 | - * @param int $user account_lid of user |
|
828 | 827 | * @param array $data |
829 | 828 | * @param array $old |
830 | 829 | * @param bool $prefer_id returns the userid rather than email |
@@ -239,7 +239,10 @@ discard block |
||
239 | 239 | $header_done = false; |
240 | 240 | foreach($cfs as $name => $field) |
241 | 241 | { |
242 | - if (in_array($field['type'], Customfields::$non_printable_fields)) continue; |
|
242 | + if (in_array($field['type'], Customfields::$non_printable_fields)) |
|
243 | + { |
|
244 | + continue; |
|
245 | + } |
|
243 | 246 | |
244 | 247 | if (!$header_done) |
245 | 248 | { |
@@ -337,8 +340,14 @@ discard block |
||
337 | 340 | { |
338 | 341 | //error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (new):'.array2string($data[$name])); |
339 | 342 | //error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (old):'.array2string($old[$name])); |
340 | - if (is_array($data[$name]) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id']; |
|
341 | - if (is_array($old[$name]) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id']; |
|
343 | + if (is_array($data[$name]) && array_key_exists('id',$data[$name])) |
|
344 | + { |
|
345 | + $data[$name] = $data[$name]['id']; |
|
346 | + } |
|
347 | + if (is_array($old[$name]) && array_key_exists('id',$old[$name])) |
|
348 | + { |
|
349 | + $old[$name] = $old[$name]['id']; |
|
350 | + } |
|
342 | 351 | //error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (new):'.array2string($data[$name])); |
343 | 352 | //error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (old):'.array2string($old[$name])); |
344 | 353 | } |
@@ -352,11 +361,18 @@ discard block |
||
352 | 361 | if (!($app = $this->cf_link_fields[$name])) |
353 | 362 | { |
354 | 363 | list($app,$id) = explode(':',$id); |
355 | - if (!$id) continue; // can be eg. 'addressbook:', if no contact selected |
|
364 | + if (!$id) |
|
365 | + { |
|
366 | + continue; |
|
367 | + } |
|
368 | + // can be eg. 'addressbook:', if no contact selected |
|
356 | 369 | } |
357 | 370 | $source_id = $data[$this->id_field]; |
358 | 371 | //error_log(__METHOD__.__LINE__.array2string($source_id)); |
359 | - if ($source_id) Api\Link::link($this->app,$source_id,$app,$id); |
|
372 | + if ($source_id) |
|
373 | + { |
|
374 | + Api\Link::link($this->app,$source_id,$app,$id); |
|
375 | + } |
|
360 | 376 | //error_log(__METHOD__.__LINE__."Api\Link::link('$this->app',".array2string($source_id).",'$app',$id);"); |
361 | 377 | //echo "<p>Api\Link::link('$this->app',{$data[$this->id_field]},'$app',$id);</p>\n"; |
362 | 378 | } |
@@ -364,14 +380,24 @@ discard block |
||
364 | 380 | // unlink removed application entries |
365 | 381 | foreach(array_diff($old_ids,$current_ids) as $name => $id) |
366 | 382 | { |
367 | - if (!isset($data[$name])) continue; // ignore not set link cf's, eg. from sync clients |
|
383 | + if (!isset($data[$name])) |
|
384 | + { |
|
385 | + continue; |
|
386 | + } |
|
387 | + // ignore not set link cf's, eg. from sync clients |
|
368 | 388 | if (!($app = $this->cf_link_fields[$name])) |
369 | 389 | { |
370 | 390 | list($app,$id) = explode(':',$id); |
371 | - if (!$id) continue; |
|
391 | + if (!$id) |
|
392 | + { |
|
393 | + continue; |
|
394 | + } |
|
372 | 395 | } |
373 | 396 | $source_id = $data[$this->id_field]; |
374 | - if ($source_id) Api\Link::unlink(null,$this->app,$source_id,0,$app,$id); |
|
397 | + if ($source_id) |
|
398 | + { |
|
399 | + Api\Link::unlink(null,$this->app,$source_id,0,$app,$id); |
|
400 | + } |
|
375 | 401 | //echo "<p>Api\Link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);</p>\n"; |
376 | 402 | } |
377 | 403 | } |
@@ -396,7 +422,10 @@ discard block |
||
396 | 422 | $changed_fields = self::changed_fields($data,$old); |
397 | 423 | //error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields)); |
398 | 424 | } |
399 | - if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action'])) return 0; |
|
425 | + if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action'])) |
|
426 | + { |
|
427 | + return 0; |
|
428 | + } |
|
400 | 429 | |
401 | 430 | if (!is_object($this->historylog) || $this->historylog->user != $this->user) |
402 | 431 | { |
@@ -412,10 +441,13 @@ discard block |
||
412 | 441 | { |
413 | 442 | $status = isset($this->field2history[$name]) ? $this->field2history[$name] : $name; |
414 | 443 | //error_log(__METHOD__.__LINE__." Name $name,".' Status:'.array2string($status)); |
415 | - if (is_array($status)) // 1:N relation --> remove common rows |
|
444 | + if (is_array($status)) |
|
445 | + { |
|
446 | + // 1:N relation --> remove common rows |
|
416 | 447 | { |
417 | 448 | //error_log(__METHOD__.__LINE__.' is Array'); |
418 | 449 | self::compact_1_N_relation($data[$name],$status); |
450 | + } |
|
419 | 451 | self::compact_1_N_relation($old[$name],$status); |
420 | 452 | $added = array_values(array_diff($data[$name],$old[$name])); |
421 | 453 | $removed = array_values(array_diff($old[$name],$data[$name])); |
@@ -449,17 +481,31 @@ discard block |
||
449 | 481 | */ |
450 | 482 | public function changed_fields(array $data,array $old=null) |
451 | 483 | { |
452 | - if (is_null($old)) return array_keys($data); |
|
484 | + if (is_null($old)) |
|
485 | + { |
|
486 | + return array_keys($data); |
|
487 | + } |
|
453 | 488 | $changed_fields = array(); |
454 | 489 | foreach($this->field2history as $name => $status) |
455 | 490 | { |
456 | - if (!$old[$name] && !$data[$name]) continue; // treat all sorts of empty equally |
|
491 | + if (!$old[$name] && !$data[$name]) |
|
492 | + { |
|
493 | + continue; |
|
494 | + } |
|
495 | + // treat all sorts of empty equally |
|
457 | 496 | |
458 | - if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed |
|
497 | + if ($name[0] == '#' && !isset($data[$name])) |
|
498 | + { |
|
499 | + continue; |
|
500 | + } |
|
501 | + // no set customfields are not stored, therefore not changed |
|
459 | 502 | |
460 | - if (is_array($status)) // 1:N relation |
|
503 | + if (is_array($status)) |
|
504 | + { |
|
505 | + // 1:N relation |
|
461 | 506 | { |
462 | 507 | self::compact_1_N_relation($data[$name],$status); |
508 | + } |
|
463 | 509 | self::compact_1_N_relation($old[$name],$status); |
464 | 510 | } |
465 | 511 | if ($old[$name] != $data[$name]) |
@@ -467,13 +513,22 @@ discard block |
||
467 | 513 | // normalize arrays, we do NOT care for the order of multiselections |
468 | 514 | if (is_array($data[$name]) || is_array($old[$name])) |
469 | 515 | { |
470 | - if (!is_array($data[$name])) $data[$name] = explode(',',$data[$name]); |
|
471 | - if (!is_array($old[$name])) $old[$name] = explode(',',$old[$name]); |
|
516 | + if (!is_array($data[$name])) |
|
517 | + { |
|
518 | + $data[$name] = explode(',',$data[$name]); |
|
519 | + } |
|
520 | + if (!is_array($old[$name])) |
|
521 | + { |
|
522 | + $old[$name] = explode(',',$old[$name]); |
|
523 | + } |
|
472 | 524 | if (count($data[$name]) == count($old[$name])) |
473 | 525 | { |
474 | 526 | sort($data[$name]); |
475 | 527 | sort($old[$name]); |
476 | - if ($data[$name] == $old[$name]) continue; |
|
528 | + if ($data[$name] == $old[$name]) |
|
529 | + { |
|
530 | + continue; |
|
531 | + } |
|
477 | 532 | } |
478 | 533 | } |
479 | 534 | elseif (str_replace("\r", '', $old[$name]) == str_replace("\r", '', $data[$name])) |
@@ -534,13 +589,19 @@ discard block |
||
534 | 589 | public function do_notifications($data,$old,$deleted=null,&$email_notified=null) |
535 | 590 | { |
536 | 591 | $this->errors = $email_sent = array(); |
537 | - if (!empty($email_notified) && is_array($email_notified)) $email_sent = $email_notified; |
|
592 | + if (!empty($email_notified) && is_array($email_notified)) |
|
593 | + { |
|
594 | + $email_sent = $email_notified; |
|
595 | + } |
|
538 | 596 | |
539 | - if (!$this->notify_current_user && $this->user) // do we have a current user and should we notify the current user about his own changes |
|
597 | + if (!$this->notify_current_user && $this->user) |
|
598 | + { |
|
599 | + // do we have a current user and should we notify the current user about his own changes |
|
540 | 600 | { |
541 | 601 | //error_log("do_notificaton() adding user=$this->user to email_sent, to not notify him"); |
542 | 602 | $email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user,'account_email'); |
543 | 603 | } |
604 | + } |
|
544 | 605 | $skip_notify = $this->get_config('skip_notify',$data,$old); |
545 | 606 | if($skip_notify && is_array($skip_notify)) |
546 | 607 | { |
@@ -579,11 +640,14 @@ discard block |
||
579 | 640 | //error_log(__METHOD__."() data[$this->assigned_field]=".print_r($data[$this->assigned_field],true).", old[$this->assigned_field]=".print_r($old[$this->assigned_field],true)); |
580 | 641 | $old_assignees = array(); |
581 | 642 | $assignees = $assigned ? $assigned : array(); |
582 | - if ($data[$this->assigned_field]) // current assignments |
|
643 | + if ($data[$this->assigned_field]) |
|
644 | + { |
|
645 | + // current assignments |
|
583 | 646 | { |
584 | 647 | $assignees = is_array($data[$this->assigned_field]) ? |
585 | 648 | $data[$this->assigned_field] : explode(',',$data[$this->assigned_field]); |
586 | 649 | } |
650 | + } |
|
587 | 651 | if ($old && $old[$this->assigned_field]) |
588 | 652 | { |
589 | 653 | $old_assignees = is_array($old[$this->assigned_field]) ? |
@@ -592,7 +656,10 @@ discard block |
||
592 | 656 | foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee) |
593 | 657 | { |
594 | 658 | //error_log(__METHOD__."() assignee=$assignee, type=".$GLOBALS['egw']->accounts->get_type($assignee).", email=".$GLOBALS['egw']->accounts->id2name($assignee,'account_email')); |
595 | - if (!$assignee) continue; |
|
659 | + if (!$assignee) |
|
660 | + { |
|
661 | + continue; |
|
662 | + } |
|
596 | 663 | |
597 | 664 | // item assignee is a user |
598 | 665 | if ($GLOBALS['egw']->accounts->get_type($assignee) == 'u') |
@@ -600,10 +667,13 @@ discard block |
||
600 | 667 | if (($email = $GLOBALS['egw']->accounts->id2name($assignee,'account_email')) && !in_array($email, $email_sent)) |
601 | 668 | { |
602 | 669 | if ($this->send_notification($data,$old,$email,$assignee,'notify_assigned', |
603 | - in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted)) // assignment changed |
|
670 | + in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted)) |
|
671 | + { |
|
672 | + // assignment changed |
|
604 | 673 | { |
605 | 674 | $email_sent[] = $email; |
606 | 675 | } |
676 | + } |
|
607 | 677 | } |
608 | 678 | } |
609 | 679 | else // item assignee is a group |
@@ -613,10 +683,13 @@ discard block |
||
613 | 683 | if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && !in_array($email, $email_sent)) |
614 | 684 | { |
615 | 685 | if ($this->send_notification($data,$old,$email,$u,'notify_assigned', |
616 | - in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted)) // assignment changed |
|
686 | + in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted)) |
|
687 | + { |
|
688 | + // assignment changed |
|
617 | 689 | { |
618 | 690 | $email_sent[] = $email; |
619 | 691 | } |
692 | + } |
|
620 | 693 | } |
621 | 694 | } |
622 | 695 | } |
@@ -679,25 +752,38 @@ discard block |
||
679 | 752 | public function send_notification($data,$old,$email,$user_or_lang,$check=null,$assignment_changed=true,$deleted=null) |
680 | 753 | { |
681 | 754 | //error_log(__METHOD__."(,,'$email',$user_or_lang,$check,$assignment_changed,$deleted)"); |
682 | - if (!$email) return false; |
|
755 | + if (!$email) |
|
756 | + { |
|
757 | + return false; |
|
758 | + } |
|
683 | 759 | |
684 | 760 | $save_user = $GLOBALS['egw_info']['user']; |
685 | 761 | $do_notify = true; |
686 | 762 | |
687 | - if (is_numeric($user_or_lang)) // user --> read everything from his prefs |
|
763 | + if (is_numeric($user_or_lang)) |
|
764 | + { |
|
765 | + // user --> read everything from his prefs |
|
688 | 766 | { |
689 | 767 | $GLOBALS['egw_info']['user']['account_id'] = $user_or_lang; |
768 | + } |
|
690 | 769 | $GLOBALS['egw']->preferences->__construct($user_or_lang); |
691 | 770 | $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs! |
692 | 771 | |
693 | - if ($check && $this->check2pref) $check = $this->check2pref[$check]; |
|
772 | + if ($check && $this->check2pref) |
|
773 | + { |
|
774 | + $check = $this->check2pref[$check]; |
|
775 | + } |
|
694 | 776 | |
695 | 777 | if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] || // no notification requested |
696 | 778 | // only notification about changed assignment requested |
697 | 779 | $check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed || |
698 | - $this->user == $user_or_lang && !$this->notify_current_user) // no popup for own actions |
|
780 | + $this->user == $user_or_lang && !$this->notify_current_user) |
|
699 | 781 | { |
700 | - $do_notify = false; // no notification requested / necessary |
|
782 | + // no popup for own actions |
|
783 | + { |
|
784 | + $do_notify = false; |
|
785 | + } |
|
786 | + // no notification requested / necessary |
|
701 | 787 | } |
702 | 788 | } |
703 | 789 | else |
@@ -706,10 +792,13 @@ discard block |
||
706 | 792 | $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->default_prefs(); |
707 | 793 | $GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $user_or_lang; |
708 | 794 | } |
709 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != Api\Translation::$userlang) // load the right language if needed |
|
795 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != Api\Translation::$userlang) |
|
796 | + { |
|
797 | + // load the right language if needed |
|
710 | 798 | { |
711 | 799 | Api\Translation::init(); |
712 | 800 | } |
801 | + } |
|
713 | 802 | |
714 | 803 | $receiver = is_numeric($user_or_lang) ? $user_or_lang : $email; |
715 | 804 | |
@@ -813,7 +902,10 @@ discard block |
||
813 | 902 | $do_time = ($timestamp->format('Hi') != '0000'); |
814 | 903 | } |
815 | 904 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
816 | - if ($do_time) $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] != 12 ? 'H:i' : 'h:i a'); |
|
905 | + if ($do_time) |
|
906 | + { |
|
907 | + $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] != 12 ? 'H:i' : 'h:i a'); |
|
908 | + } |
|
817 | 909 | |
818 | 910 | return $timestamp->format($format); |
819 | 911 | } |
@@ -843,9 +935,12 @@ discard block |
||
843 | 935 | { |
844 | 936 | $name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname'); |
845 | 937 | |
846 | - if($prefer_id) { |
|
938 | + if($prefer_id) |
|
939 | + { |
|
847 | 940 | $sender = $this->user; |
848 | - } else { |
|
941 | + } |
|
942 | + else |
|
943 | + { |
|
849 | 944 | $sender = $name ? $name.' <'.$email.'>' : $email; |
850 | 945 | } |
851 | 946 | } |
@@ -947,7 +1042,10 @@ discard block |
||
947 | 1042 | // remove the session-id in the notification mail! |
948 | 1043 | $link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link); |
949 | 1044 | |
950 | - if ($popup) $link .= '&nopopup=1'; |
|
1045 | + if ($popup) |
|
1046 | + { |
|
1047 | + $link .= '&nopopup=1'; |
|
1048 | + } |
|
951 | 1049 | } |
952 | 1050 | //error_log(__METHOD__."(..., $allow_popup, $receiver) returning ".array2string($allow_popup ? array($link,$popup) : $link)); |
953 | 1051 | return $allow_popup ? array($link,$popup) : $link; |
@@ -1022,7 +1120,11 @@ discard block |
||
1022 | 1120 | // if both values are '', 0 or null, we count them as equal too |
1023 | 1121 | $modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]); |
1024 | 1122 | //if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified); |
1025 | - if (empty($detail['value']) && !$modified) continue; // skip unchanged, empty values |
|
1123 | + if (empty($detail['value']) && !$modified) |
|
1124 | + { |
|
1125 | + continue; |
|
1126 | + } |
|
1127 | + // skip unchanged, empty values |
|
1026 | 1128 | |
1027 | 1129 | $body .= $this->format_line($html_email,$detail['type'],$modified, |
1028 | 1130 | $detail['label'] ? $detail['label'] : '', $detail['value']); |
@@ -1056,7 +1158,11 @@ discard block |
||
1056 | 1158 | |
1057 | 1159 | if ($html_mail) |
1058 | 1160 | { |
1059 | - if (!$this->html_content_allow) $line = Api\Html::htmlspecialchars($line); // XSS |
|
1161 | + if (!$this->html_content_allow) |
|
1162 | + { |
|
1163 | + $line = Api\Html::htmlspecialchars($line); |
|
1164 | + } |
|
1165 | + // XSS |
|
1060 | 1166 | |
1061 | 1167 | $color = $modified ? 'red' : false; |
1062 | 1168 | $size = '110%'; |
@@ -1095,15 +1201,24 @@ discard block |
||
1095 | 1201 | } |
1096 | 1202 | else // text-mail |
1097 | 1203 | { |
1098 | - if ($type == 'reply') $content = str_repeat('-',64)."\n"; |
|
1204 | + if ($type == 'reply') |
|
1205 | + { |
|
1206 | + $content = str_repeat('-',64)."\n"; |
|
1207 | + } |
|
1099 | 1208 | |
1100 | - if ($modified) $content .= '> '; |
|
1209 | + if ($modified) |
|
1210 | + { |
|
1211 | + $content .= '> '; |
|
1212 | + } |
|
1101 | 1213 | } |
1102 | 1214 | $content .= $line; |
1103 | 1215 | |
1104 | 1216 | if ($html_mail) |
1105 | 1217 | { |
1106 | - if ($line && $data) $content .= '</td><td style="'.$style.'">'; |
|
1218 | + if ($line && $data) |
|
1219 | + { |
|
1220 | + $content .= '</td><td style="'.$style.'">'; |
|
1221 | + } |
|
1107 | 1222 | if ($type == 'link') |
1108 | 1223 | { |
1109 | 1224 | // the link is often too long for html boxes chunk-split allows to break lines if needed |
@@ -1122,7 +1237,10 @@ discard block |
||
1122 | 1237 | { |
1123 | 1238 | $content .= ($content&&$data?': ':'').$data; |
1124 | 1239 | } |
1125 | - if ($html_mail) $content .= '</td></tr>'; |
|
1240 | + if ($html_mail) |
|
1241 | + { |
|
1242 | + $content .= '</td></tr>'; |
|
1243 | + } |
|
1126 | 1244 | |
1127 | 1245 | $content .= "\n"; |
1128 | 1246 |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | { |
195 | 195 | if ($cf_app) |
196 | 196 | { |
197 | - $linkable_cf_types = array('link-entry')+array_keys(Api\Link::app_list()); |
|
198 | - foreach(Customfields::get($cf_app, true) as $cf_name => $cf_data) |
|
197 | + $linkable_cf_types = array('link-entry') + array_keys(Api\Link::app_list()); |
|
198 | + foreach (Customfields::get($cf_app, true) as $cf_name => $cf_data) |
|
199 | 199 | { |
200 | 200 | $this->field2history['#'.$cf_name] = '#'.$cf_name; |
201 | 201 | |
202 | - if (in_array($cf_data['type'],$linkable_cf_types)) |
|
202 | + if (in_array($cf_data['type'], $linkable_cf_types)) |
|
203 | 203 | { |
204 | 204 | $this->cf_link_fields['#'.$cf_name] = $cf_data['type'] == 'link-entry' ? '' : $cf_data['type']; |
205 | 205 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @param int|string $receiver nummeric account_id or email address |
217 | 217 | * @return array of details as array with values for keys 'label','value','type' |
218 | 218 | */ |
219 | - function get_details($data,$receiver=null) |
|
219 | + function get_details($data, $receiver = null) |
|
220 | 220 | { |
221 | - unset($data, $receiver); // not uses as just a stub |
|
221 | + unset($data, $receiver); // not uses as just a stub |
|
222 | 222 | |
223 | 223 | return array(); |
224 | 224 | } |
@@ -230,14 +230,14 @@ discard block |
||
230 | 230 | * @param string $only_type2 = null if given only return fields of type2 == $only_type2 |
231 | 231 | * @return array of details as array with values for keys 'label','value','type' |
232 | 232 | */ |
233 | - function get_customfields($data, $only_type2=null) |
|
233 | + function get_customfields($data, $only_type2 = null) |
|
234 | 234 | { |
235 | 235 | $details = array(); |
236 | 236 | |
237 | - if (($cfs = Customfields::get($this->app, $all_private_too=false, $only_type2))) |
|
237 | + if (($cfs = Customfields::get($this->app, $all_private_too = false, $only_type2))) |
|
238 | 238 | { |
239 | 239 | $header_done = false; |
240 | - foreach($cfs as $name => $field) |
|
240 | + foreach ($cfs as $name => $field) |
|
241 | 241 | { |
242 | 242 | if (in_array($field['type'], Customfields::$non_printable_fields)) continue; |
243 | 243 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | * @param array $old = null old/last state of the entry or null for a new entry |
279 | 279 | * @return mixed |
280 | 280 | */ |
281 | - protected function get_config($name,$data,$old=null) |
|
281 | + protected function get_config($name, $data, $old = null) |
|
282 | 282 | { |
283 | - unset($name, $data, $old); // not used as just a stub |
|
283 | + unset($name, $data, $old); // not used as just a stub |
|
284 | 284 | |
285 | 285 | return null; |
286 | 286 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param boolean $skip_notification = false do NOT send any notification |
297 | 297 | * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null) |
298 | 298 | */ |
299 | - public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false) |
|
299 | + public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false) |
|
300 | 300 | { |
301 | 301 | $this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id']; |
302 | 302 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | if ($old && $this->field2history) |
306 | 306 | { |
307 | 307 | //error_log(__METHOD__.__LINE__.' Changedfields:'.print_r($changed_fields,true)); |
308 | - $changes = $this->save_history($data,$old,$deleted,$changed_fields); |
|
308 | + $changes = $this->save_history($data, $old, $deleted, $changed_fields); |
|
309 | 309 | //error_log(__METHOD__.__LINE__.' Changedfields:'.print_r($changed_fields,true)); |
310 | 310 | //error_log(__METHOD__.__LINE__.' Changes:'.print_r($changes,true)); |
311 | 311 | } |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | //error_log(__METHOD__.__LINE__.' LinkFields:'.array2string($this->cf_link_fields)); |
314 | 314 | if ($changes && $this->cf_link_fields) |
315 | 315 | { |
316 | - $this->update_links($data,(array)$old); |
|
316 | + $this->update_links($data, (array)$old); |
|
317 | 317 | } |
318 | 318 | // do not run do_notifications if we have no changes |
319 | - if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted)) |
|
319 | + if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted)) |
|
320 | 320 | { |
321 | 321 | $changes = false; |
322 | 322 | } |
@@ -333,45 +333,45 @@ discard block |
||
333 | 333 | { |
334 | 334 | //error_log(__METHOD__.__LINE__.array2string($data).function_backtrace()); |
335 | 335 | //error_log(__METHOD__.__LINE__.array2string($this->cf_link_fields)); |
336 | - foreach(array_keys((array)$this->cf_link_fields) as $name) |
|
336 | + foreach (array_keys((array)$this->cf_link_fields) as $name) |
|
337 | 337 | { |
338 | 338 | //error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (new):'.array2string($data[$name])); |
339 | 339 | //error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (old):'.array2string($old[$name])); |
340 | - if (is_array($data[$name]) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id']; |
|
341 | - if (is_array($old[$name]) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id']; |
|
340 | + if (is_array($data[$name]) && array_key_exists('id', $data[$name])) $data[$name] = $data[$name]['id']; |
|
341 | + if (is_array($old[$name]) && array_key_exists('id', $old[$name])) $old[$name] = $old[$name]['id']; |
|
342 | 342 | //error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (new):'.array2string($data[$name])); |
343 | 343 | //error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (old):'.array2string($old[$name])); |
344 | 344 | } |
345 | - $current_ids = array_unique(array_diff(array_intersect_key($data,$this->cf_link_fields),array('',0,NULL))); |
|
346 | - $old_ids = $old ? array_unique(array_diff(array_intersect_key($old,$this->cf_link_fields),array('',0,NULL))) : array(); |
|
345 | + $current_ids = array_unique(array_diff(array_intersect_key($data, $this->cf_link_fields), array('', 0, NULL))); |
|
346 | + $old_ids = $old ? array_unique(array_diff(array_intersect_key($old, $this->cf_link_fields), array('', 0, NULL))) : array(); |
|
347 | 347 | //error_log(__METHOD__.__LINE__.array2string($current_ids)); |
348 | 348 | //error_log(__METHOD__.__LINE__.array2string($old_ids)); |
349 | 349 | // create links for added application entry |
350 | - foreach(array_diff($current_ids,$old_ids) as $name => $id) |
|
350 | + foreach (array_diff($current_ids, $old_ids) as $name => $id) |
|
351 | 351 | { |
352 | 352 | if (!($app = $this->cf_link_fields[$name])) |
353 | 353 | { |
354 | - list($app,$id) = explode(':',$id); |
|
355 | - if (!$id) continue; // can be eg. 'addressbook:', if no contact selected |
|
354 | + list($app, $id) = explode(':', $id); |
|
355 | + if (!$id) continue; // can be eg. 'addressbook:', if no contact selected |
|
356 | 356 | } |
357 | 357 | $source_id = $data[$this->id_field]; |
358 | 358 | //error_log(__METHOD__.__LINE__.array2string($source_id)); |
359 | - if ($source_id) Api\Link::link($this->app,$source_id,$app,$id); |
|
359 | + if ($source_id) Api\Link::link($this->app, $source_id, $app, $id); |
|
360 | 360 | //error_log(__METHOD__.__LINE__."Api\Link::link('$this->app',".array2string($source_id).",'$app',$id);"); |
361 | 361 | //echo "<p>Api\Link::link('$this->app',{$data[$this->id_field]},'$app',$id);</p>\n"; |
362 | 362 | } |
363 | 363 | |
364 | 364 | // unlink removed application entries |
365 | - foreach(array_diff($old_ids,$current_ids) as $name => $id) |
|
365 | + foreach (array_diff($old_ids, $current_ids) as $name => $id) |
|
366 | 366 | { |
367 | - if (!isset($data[$name])) continue; // ignore not set link cf's, eg. from sync clients |
|
367 | + if (!isset($data[$name])) continue; // ignore not set link cf's, eg. from sync clients |
|
368 | 368 | if (!($app = $this->cf_link_fields[$name])) |
369 | 369 | { |
370 | - list($app,$id) = explode(':',$id); |
|
370 | + list($app, $id) = explode(':', $id); |
|
371 | 371 | if (!$id) continue; |
372 | 372 | } |
373 | 373 | $source_id = $data[$this->id_field]; |
374 | - if ($source_id) Api\Link::unlink(null,$this->app,$source_id,0,$app,$id); |
|
374 | + if ($source_id) Api\Link::unlink(null, $this->app, $source_id, 0, $app, $id); |
|
375 | 375 | //echo "<p>Api\Link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);</p>\n"; |
376 | 376 | } |
377 | 377 | } |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | * @param array $changed_fields = null changed fields from ealier call to $this->changed_fields($data,$old), to not compute it again |
387 | 387 | * @return int number of log-entries made |
388 | 388 | */ |
389 | - protected function save_history(array $data,array $old=null,$deleted=null,array $changed_fields=null) |
|
389 | + protected function save_history(array $data, array $old = null, $deleted = null, array $changed_fields = null) |
|
390 | 390 | { |
391 | - unset($deleted); // not used, but required by function signature |
|
391 | + unset($deleted); // not used, but required by function signature |
|
392 | 392 | |
393 | 393 | //error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields)); |
394 | 394 | if (is_null($changed_fields)) |
395 | 395 | { |
396 | - $changed_fields = self::changed_fields($data,$old); |
|
396 | + $changed_fields = self::changed_fields($data, $old); |
|
397 | 397 | //error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields)); |
398 | 398 | } |
399 | 399 | if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action'])) return 0; |
@@ -408,30 +408,30 @@ discard block |
||
408 | 408 | $this->historylog->add('user_agent_action', $data[$this->id_field], |
409 | 409 | $_SERVER['HTTP_USER_AGENT'], $_SESSION[Api\Session::EGW_SESSION_VAR]['session_action']); |
410 | 410 | } |
411 | - foreach($changed_fields as $name) |
|
411 | + foreach ($changed_fields as $name) |
|
412 | 412 | { |
413 | 413 | $status = isset($this->field2history[$name]) ? $this->field2history[$name] : $name; |
414 | 414 | //error_log(__METHOD__.__LINE__." Name $name,".' Status:'.array2string($status)); |
415 | 415 | if (is_array($status)) // 1:N relation --> remove common rows |
416 | 416 | { |
417 | 417 | //error_log(__METHOD__.__LINE__.' is Array'); |
418 | - self::compact_1_N_relation($data[$name],$status); |
|
419 | - self::compact_1_N_relation($old[$name],$status); |
|
420 | - $added = array_values(array_diff($data[$name],$old[$name])); |
|
421 | - $removed = array_values(array_diff($old[$name],$data[$name])); |
|
422 | - $n = max(array(count($added),count($removed))); |
|
423 | - for($i = 0; $i < $n; ++$i) |
|
418 | + self::compact_1_N_relation($data[$name], $status); |
|
419 | + self::compact_1_N_relation($old[$name], $status); |
|
420 | + $added = array_values(array_diff($data[$name], $old[$name])); |
|
421 | + $removed = array_values(array_diff($old[$name], $data[$name])); |
|
422 | + $n = max(array(count($added), count($removed))); |
|
423 | + for ($i = 0; $i < $n; ++$i) |
|
424 | 424 | { |
425 | 425 | //error_log(__METHOD__."() $i: historylog->add('$name',data['$this->id_field']={$data[$this->id_field]},".array2string($added[$i]).','.array2string($removed[$i])); |
426 | - $this->historylog->add($name,$data[$this->id_field],$added[$i],$removed[$i]); |
|
426 | + $this->historylog->add($name, $data[$this->id_field], $added[$i], $removed[$i]); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | else |
430 | 430 | { |
431 | 431 | //error_log(__METHOD__.__LINE__.' IDField:'.array2string($this->id_field).' ->'.$data[$this->id_field].' New:'.$data[$name].' Old:'.$old[$name]); |
432 | - $this->historylog->add($status,$data[$this->id_field], |
|
433 | - is_array($data[$name]) ? implode(',',$data[$name]) : $data[$name], |
|
434 | - is_array($old[$name]) ? implode(',',$old[$name]) : $old[$name]); |
|
432 | + $this->historylog->add($status, $data[$this->id_field], |
|
433 | + is_array($data[$name]) ? implode(',', $data[$name]) : $data[$name], |
|
434 | + is_array($old[$name]) ? implode(',', $old[$name]) : $old[$name]); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | //error_log(__METHOD__.__LINE__.' return:'.count($changed_fields)); |
@@ -447,28 +447,28 @@ discard block |
||
447 | 447 | * @param array $old = null |
448 | 448 | * @return array of keys with different values in $data and $old |
449 | 449 | */ |
450 | - public function changed_fields(array $data,array $old=null) |
|
450 | + public function changed_fields(array $data, array $old = null) |
|
451 | 451 | { |
452 | 452 | if (is_null($old)) return array_keys($data); |
453 | 453 | $changed_fields = array(); |
454 | - foreach($this->field2history as $name => $status) |
|
454 | + foreach ($this->field2history as $name => $status) |
|
455 | 455 | { |
456 | - if (!$old[$name] && !$data[$name]) continue; // treat all sorts of empty equally |
|
456 | + if (!$old[$name] && !$data[$name]) continue; // treat all sorts of empty equally |
|
457 | 457 | |
458 | - if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed |
|
458 | + if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed |
|
459 | 459 | |
460 | 460 | if (is_array($status)) // 1:N relation |
461 | 461 | { |
462 | - self::compact_1_N_relation($data[$name],$status); |
|
463 | - self::compact_1_N_relation($old[$name],$status); |
|
462 | + self::compact_1_N_relation($data[$name], $status); |
|
463 | + self::compact_1_N_relation($old[$name], $status); |
|
464 | 464 | } |
465 | 465 | if ($old[$name] != $data[$name]) |
466 | 466 | { |
467 | 467 | // normalize arrays, we do NOT care for the order of multiselections |
468 | 468 | if (is_array($data[$name]) || is_array($old[$name])) |
469 | 469 | { |
470 | - if (!is_array($data[$name])) $data[$name] = explode(',',$data[$name]); |
|
471 | - if (!is_array($old[$name])) $old[$name] = explode(',',$old[$name]); |
|
470 | + if (!is_array($data[$name])) $data[$name] = explode(',', $data[$name]); |
|
471 | + if (!is_array($old[$name])) $old[$name] = explode(',', $old[$name]); |
|
472 | 472 | if (count($data[$name]) == count($old[$name])) |
473 | 473 | { |
474 | 474 | sort($data[$name]); |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | } |
479 | 479 | elseif (str_replace("\r", '', $old[$name]) == str_replace("\r", '', $data[$name])) |
480 | 480 | { |
481 | - continue; // change only in CR (eg. different OS) --> ignore |
|
481 | + continue; // change only in CR (eg. different OS) --> ignore |
|
482 | 482 | } |
483 | 483 | $changed_fields[] = $name; |
484 | 484 | //echo "<p>$name: ".array2string($data[$name]).' != '.array2string($old[$name])."</p>\n"; |
485 | 485 | } |
486 | 486 | } |
487 | - foreach($data as $name => $value) |
|
487 | + foreach ($data as $name => $value) |
|
488 | 488 | { |
489 | 489 | if ($name[0] == '#' && $name[1] == '#' && $value !== $old[$name]) |
490 | 490 | { |
@@ -501,18 +501,18 @@ discard block |
||
501 | 501 | * @param array &$rows rows of the 1:N relation |
502 | 502 | * @param array $cols field names as values |
503 | 503 | */ |
504 | - private static function compact_1_N_relation(&$rows,array $cols) |
|
504 | + private static function compact_1_N_relation(&$rows, array $cols) |
|
505 | 505 | { |
506 | 506 | if (is_array($rows)) |
507 | 507 | { |
508 | - foreach($rows as &$row) |
|
508 | + foreach ($rows as &$row) |
|
509 | 509 | { |
510 | 510 | $values = array(); |
511 | - foreach($cols as $col) |
|
511 | + foreach ($cols as $col) |
|
512 | 512 | { |
513 | 513 | $values[] = $row[$col]; |
514 | 514 | } |
515 | - $row = implode(self::ONE2N_SEPERATOR,$values); |
|
515 | + $row = implode(self::ONE2N_SEPERATOR, $values); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | else |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @param array $email_notified=null if present will return the emails notified, if given emails in that list will not be notified |
532 | 532 | * @return boolean true on success, false on error (error messages are in $this->errors) |
533 | 533 | */ |
534 | - public function do_notifications($data,$old,$deleted=null,&$email_notified=null) |
|
534 | + public function do_notifications($data, $old, $deleted = null, &$email_notified = null) |
|
535 | 535 | { |
536 | 536 | $this->errors = $email_sent = array(); |
537 | 537 | if (!empty($email_notified) && is_array($email_notified)) $email_sent = $email_notified; |
@@ -539,19 +539,19 @@ discard block |
||
539 | 539 | if (!$this->notify_current_user && $this->user) // do we have a current user and should we notify the current user about his own changes |
540 | 540 | { |
541 | 541 | //error_log("do_notificaton() adding user=$this->user to email_sent, to not notify him"); |
542 | - $email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user,'account_email'); |
|
542 | + $email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user, 'account_email'); |
|
543 | 543 | } |
544 | - $skip_notify = $this->get_config('skip_notify',$data,$old); |
|
545 | - if($skip_notify && is_array($skip_notify)) |
|
544 | + $skip_notify = $this->get_config('skip_notify', $data, $old); |
|
545 | + if ($skip_notify && is_array($skip_notify)) |
|
546 | 546 | { |
547 | 547 | $email_sent = array_merge($email_sent, $skip_notify); |
548 | 548 | } |
549 | 549 | |
550 | 550 | // entry creator |
551 | - if ($this->creator_field && ($email = $GLOBALS['egw']->accounts->id2name($data[$this->creator_field],'account_email')) && |
|
551 | + if ($this->creator_field && ($email = $GLOBALS['egw']->accounts->id2name($data[$this->creator_field], 'account_email')) && |
|
552 | 552 | !in_array($email, $email_sent)) |
553 | 553 | { |
554 | - if ($this->send_notification($data,$old,$email,$data[$this->creator_field],'notify_creator')) |
|
554 | + if ($this->send_notification($data, $old, $email, $data[$this->creator_field], 'notify_creator')) |
|
555 | 555 | { |
556 | 556 | $email_sent[] = $email; |
557 | 557 | } |
@@ -560,12 +560,12 @@ discard block |
||
560 | 560 | // members of group when entry owned by group |
561 | 561 | if ($this->creator_field && $GLOBALS['egw']->accounts->get_type($data[$this->creator_field]) == 'g') |
562 | 562 | { |
563 | - foreach($GLOBALS['egw']->accounts->members($data[$this->creator_field],true) as $u) |
|
563 | + foreach ($GLOBALS['egw']->accounts->members($data[$this->creator_field], true) as $u) |
|
564 | 564 | { |
565 | - if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && |
|
565 | + if (($email = $GLOBALS['egw']->accounts->id2name($u, 'account_email')) && |
|
566 | 566 | !in_array($email, $email_sent)) |
567 | 567 | { |
568 | - if ($this->send_notification($data,$old,$email,$u,'notify_owner_group_member')) |
|
568 | + if ($this->send_notification($data, $old, $email, $u, 'notify_owner_group_member')) |
|
569 | 569 | { |
570 | 570 | $email_sent[] = $email; |
571 | 571 | } |
@@ -582,14 +582,14 @@ discard block |
||
582 | 582 | if ($data[$this->assigned_field]) // current assignments |
583 | 583 | { |
584 | 584 | $assignees = is_array($data[$this->assigned_field]) ? |
585 | - $data[$this->assigned_field] : explode(',',$data[$this->assigned_field]); |
|
585 | + $data[$this->assigned_field] : explode(',', $data[$this->assigned_field]); |
|
586 | 586 | } |
587 | 587 | if ($old && $old[$this->assigned_field]) |
588 | 588 | { |
589 | 589 | $old_assignees = is_array($old[$this->assigned_field]) ? |
590 | - $old[$this->assigned_field] : explode(',',$old[$this->assigned_field]); |
|
590 | + $old[$this->assigned_field] : explode(',', $old[$this->assigned_field]); |
|
591 | 591 | } |
592 | - foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee) |
|
592 | + foreach (array_unique(array_merge($assignees, $old_assignees)) as $assignee) |
|
593 | 593 | { |
594 | 594 | //error_log(__METHOD__."() assignee=$assignee, type=".$GLOBALS['egw']->accounts->get_type($assignee).", email=".$GLOBALS['egw']->accounts->id2name($assignee,'account_email')); |
595 | 595 | if (!$assignee) continue; |
@@ -597,10 +597,10 @@ discard block |
||
597 | 597 | // item assignee is a user |
598 | 598 | if ($GLOBALS['egw']->accounts->get_type($assignee) == 'u') |
599 | 599 | { |
600 | - if (($email = $GLOBALS['egw']->accounts->id2name($assignee,'account_email')) && !in_array($email, $email_sent)) |
|
600 | + if (($email = $GLOBALS['egw']->accounts->id2name($assignee, 'account_email')) && !in_array($email, $email_sent)) |
|
601 | 601 | { |
602 | - if ($this->send_notification($data,$old,$email,$assignee,'notify_assigned', |
|
603 | - in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted)) // assignment changed |
|
602 | + if ($this->send_notification($data, $old, $email, $assignee, 'notify_assigned', |
|
603 | + in_array($assignee, $assignees) !== in_array($assignee, $old_assignees) || $deleted)) // assignment changed |
|
604 | 604 | { |
605 | 605 | $email_sent[] = $email; |
606 | 606 | } |
@@ -608,12 +608,12 @@ discard block |
||
608 | 608 | } |
609 | 609 | else // item assignee is a group |
610 | 610 | { |
611 | - foreach($GLOBALS['egw']->accounts->members($assignee,true) as $u) |
|
611 | + foreach ($GLOBALS['egw']->accounts->members($assignee, true) as $u) |
|
612 | 612 | { |
613 | - if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && !in_array($email, $email_sent)) |
|
613 | + if (($email = $GLOBALS['egw']->accounts->id2name($u, 'account_email')) && !in_array($email, $email_sent)) |
|
614 | 614 | { |
615 | - if ($this->send_notification($data,$old,$email,$u,'notify_assigned', |
|
616 | - in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted)) // assignment changed |
|
615 | + if ($this->send_notification($data, $old, $email, $u, 'notify_assigned', |
|
616 | + in_array($u, $assignees) !== in_array($u, $old_assignees) || $deleted)) // assignment changed |
|
617 | 617 | { |
618 | 618 | $email_sent[] = $email; |
619 | 619 | } |
@@ -624,14 +624,14 @@ discard block |
||
624 | 624 | } |
625 | 625 | |
626 | 626 | // notification copies |
627 | - if (($copies = $this->get_config('copy',$data,$old))) |
|
627 | + if (($copies = $this->get_config('copy', $data, $old))) |
|
628 | 628 | { |
629 | - $lang = $this->get_config('lang',$data,$old); |
|
630 | - foreach($copies as $email) |
|
629 | + $lang = $this->get_config('lang', $data, $old); |
|
630 | + foreach ($copies as $email) |
|
631 | 631 | { |
632 | - if (strchr($email,'@') !== false && !in_array($email, $email_sent)) |
|
632 | + if (strchr($email, '@') !== false && !in_array($email, $email_sent)) |
|
633 | 633 | { |
634 | - if ($this->send_notification($data,$old,$email,$lang,'notify_copy')) |
|
634 | + if ($this->send_notification($data, $old, $email, $lang, 'notify_copy')) |
|
635 | 635 | { |
636 | 636 | $email_sent[] = $email; |
637 | 637 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | * @param boolean $deleted = null can be set to true to let the tracking know the item got deleted or undelted |
677 | 677 | * @return boolean true on success or false if notification not requested or error (error-message is in $this->errors) |
678 | 678 | */ |
679 | - public function send_notification($data,$old,$email,$user_or_lang,$check=null,$assignment_changed=true,$deleted=null) |
|
679 | + public function send_notification($data, $old, $email, $user_or_lang, $check = null, $assignment_changed = true, $deleted = null) |
|
680 | 680 | { |
681 | 681 | //error_log(__METHOD__."(,,'$email',$user_or_lang,$check,$assignment_changed,$deleted)"); |
682 | 682 | if (!$email) return false; |
@@ -688,16 +688,16 @@ discard block |
||
688 | 688 | { |
689 | 689 | $GLOBALS['egw_info']['user']['account_id'] = $user_or_lang; |
690 | 690 | $GLOBALS['egw']->preferences->__construct($user_or_lang); |
691 | - $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs! |
|
691 | + $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs! |
|
692 | 692 | |
693 | 693 | if ($check && $this->check2pref) $check = $this->check2pref[$check]; |
694 | 694 | |
695 | - if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] || // no notification requested |
|
695 | + if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] || // no notification requested |
|
696 | 696 | // only notification about changed assignment requested |
697 | 697 | $check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed || |
698 | 698 | $this->user == $user_or_lang && !$this->notify_current_user) // no popup for own actions |
699 | 699 | { |
700 | - $do_notify = false; // no notification requested / necessary |
|
700 | + $do_notify = false; // no notification requested / necessary |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | else |
@@ -720,33 +720,33 @@ discard block |
||
720 | 720 | |
721 | 721 | // Cache message body to not have to re-generate it every time |
722 | 722 | $lang = Api\Translation::$userlang; |
723 | - $date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . |
|
723 | + $date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']. |
|
724 | 724 | $GLOBALS['egw_info']['user']['preferences']['common']['timeformat']; |
725 | 725 | |
726 | 726 | // Cache text body |
727 | - $body_cache =& $this->body_cache[$data[$this->id_field]][$lang][$date_format]; |
|
728 | - if(empty($data[$this->id_field]) || !isset($body_cache['text'])) |
|
727 | + $body_cache = & $this->body_cache[$data[$this->id_field]][$lang][$date_format]; |
|
728 | + if (empty($data[$this->id_field]) || !isset($body_cache['text'])) |
|
729 | 729 | { |
730 | - $body_cache['text'] = $this->get_body(false,$data,$old,false,$receiver); |
|
730 | + $body_cache['text'] = $this->get_body(false, $data, $old, false, $receiver); |
|
731 | 731 | } |
732 | 732 | // Cache HTML body |
733 | - if(empty($data[$this->id_field]) || !isset($body_cache['html'])) |
|
733 | + if (empty($data[$this->id_field]) || !isset($body_cache['html'])) |
|
734 | 734 | { |
735 | - $body_cache['html'] = $this->get_body(true,$data,$old,false,$receiver); |
|
735 | + $body_cache['html'] = $this->get_body(true, $data, $old, false, $receiver); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | // get rest of notification message |
739 | - $sender = $this->get_sender($data,$old,true,$receiver); |
|
740 | - $subject = $this->get_subject($data,$old,$deleted,$receiver); |
|
741 | - $link = $this->get_notification_link($data,$old,$receiver); |
|
742 | - $attachments = $this->get_attachments($data,$old,$receiver); |
|
739 | + $sender = $this->get_sender($data, $old, true, $receiver); |
|
740 | + $subject = $this->get_subject($data, $old, $deleted, $receiver); |
|
741 | + $link = $this->get_notification_link($data, $old, $receiver); |
|
742 | + $attachments = $this->get_attachments($data, $old, $receiver); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | // restore user enviroment BEFORE calling notification class or returning |
746 | 746 | $GLOBALS['egw_info']['user'] = $save_user; |
747 | 747 | // need to call preferences constructor and read_repository, to set user timezone again |
748 | 748 | $GLOBALS['egw']->preferences->__construct($GLOBALS['egw_info']['user']['account_id']); |
749 | - $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs! |
|
749 | + $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs! |
|
750 | 750 | |
751 | 751 | // Re-load date/time preferences |
752 | 752 | Api\DateTime::init(); |
@@ -804,11 +804,11 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @return string |
806 | 806 | */ |
807 | - public function datetime($timestamp,$do_time=true) |
|
807 | + public function datetime($timestamp, $do_time = true) |
|
808 | 808 | { |
809 | - if (!is_a($timestamp,'DateTime')) |
|
809 | + if (!is_a($timestamp, 'DateTime')) |
|
810 | 810 | { |
811 | - $timestamp = new Api\DateTime($timestamp,Api\DateTime::$server_timezone); |
|
811 | + $timestamp = new Api\DateTime($timestamp, Api\DateTime::$server_timezone); |
|
812 | 812 | } |
813 | 813 | $timestamp->setTimezone(Api\DateTime::$user_timezone); |
814 | 814 | if (is_null($do_time)) |
@@ -834,25 +834,25 @@ discard block |
||
834 | 834 | * @param int|string $receiver nummeric account_id or email address |
835 | 835 | * @return string or userid |
836 | 836 | */ |
837 | - protected function get_sender($data,$old,$prefer_id=false,$receiver=null) |
|
837 | + protected function get_sender($data, $old, $prefer_id = false, $receiver = null) |
|
838 | 838 | { |
839 | - unset($receiver); // not used, but required by function signature |
|
839 | + unset($receiver); // not used, but required by function signature |
|
840 | 840 | |
841 | - $sender = $this->get_config('sender',$data,$old); |
|
841 | + $sender = $this->get_config('sender', $data, $old); |
|
842 | 842 | //echo "<p>".__METHOD__."() get_config('sender',...)='".htmlspecialchars($sender)."'</p>\n"; |
843 | 843 | |
844 | 844 | if (($this->prefer_user_as_sender || !$sender) && $this->user && |
845 | - ($email = $GLOBALS['egw']->accounts->id2name($this->user,'account_email'))) |
|
845 | + ($email = $GLOBALS['egw']->accounts->id2name($this->user, 'account_email'))) |
|
846 | 846 | { |
847 | - $name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname'); |
|
847 | + $name = $GLOBALS['egw']->accounts->id2name($this->user, 'account_fullname'); |
|
848 | 848 | |
849 | - if($prefer_id) { |
|
849 | + if ($prefer_id) { |
|
850 | 850 | $sender = $this->user; |
851 | 851 | } else { |
852 | 852 | $sender = $name ? $name.' <'.$email.'>' : $email; |
853 | 853 | } |
854 | 854 | } |
855 | - elseif(!$sender) |
|
855 | + elseif (!$sender) |
|
856 | 856 | { |
857 | 857 | $sender = 'EGroupware '.lang($this->app).' <noreply@'.$GLOBALS['egw_info']['server']['mail_suffix'].'>'; |
858 | 858 | } |
@@ -867,11 +867,11 @@ discard block |
||
867 | 867 | * @param array $old |
868 | 868 | * @return string |
869 | 869 | */ |
870 | - protected function get_title($data,$old) |
|
870 | + protected function get_title($data, $old) |
|
871 | 871 | { |
872 | - unset($old); // not used, but required by function signature |
|
872 | + unset($old); // not used, but required by function signature |
|
873 | 873 | |
874 | - return Api\Link::title($this->app,$data[$this->id_field]); |
|
874 | + return Api\Link::title($this->app, $data[$this->id_field]); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | /** |
@@ -885,11 +885,11 @@ discard block |
||
885 | 885 | * @param int|string $receiver nummeric account_id or email address |
886 | 886 | * @return string |
887 | 887 | */ |
888 | - protected function get_subject($data,$old,$deleted=null,$receiver=null) |
|
888 | + protected function get_subject($data, $old, $deleted = null, $receiver = null) |
|
889 | 889 | { |
890 | - unset($old, $deleted, $receiver); // not used, but required by function signature |
|
890 | + unset($old, $deleted, $receiver); // not used, but required by function signature |
|
891 | 891 | |
892 | - return Api\Link::title($this->app,$data[$this->id_field]); |
|
892 | + return Api\Link::title($this->app, $data[$this->id_field]); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
@@ -902,9 +902,9 @@ discard block |
||
902 | 902 | * @param int|string $receiver nummeric account_id or email address |
903 | 903 | * @return string |
904 | 904 | */ |
905 | - protected function get_message($data,$old,$receiver=null) |
|
905 | + protected function get_message($data, $old, $receiver = null) |
|
906 | 906 | { |
907 | - unset($data, $old, $receiver); // not used, but required by function signature |
|
907 | + unset($data, $old, $receiver); // not used, but required by function signature |
|
908 | 908 | |
909 | 909 | return ''; |
910 | 910 | } |
@@ -920,24 +920,24 @@ discard block |
||
920 | 920 | * @param int|string $receiver nummeric account_id or email address |
921 | 921 | * @return string|array string with link (!$allow_popup) or array(link,popup-size), popup size is something like '640x480' |
922 | 922 | */ |
923 | - protected function get_link($data,$old,$allow_popup=false,$receiver=null) |
|
923 | + protected function get_link($data, $old, $allow_popup = false, $receiver = null) |
|
924 | 924 | { |
925 | - unset($receiver); // not used, but required by function signature |
|
925 | + unset($receiver); // not used, but required by function signature |
|
926 | 926 | |
927 | - if (($link = $this->get_config('link',$data,$old))) |
|
927 | + if (($link = $this->get_config('link', $data, $old))) |
|
928 | 928 | { |
929 | - if (!$this->get_config('link_no_id', $data) && strpos($link,$this->id_field.'=') === false && isset($data[$this->id_field])) |
|
929 | + if (!$this->get_config('link_no_id', $data) && strpos($link, $this->id_field.'=') === false && isset($data[$this->id_field])) |
|
930 | 930 | { |
931 | - $link .= strpos($link,'?') === false ? '?' : '&'; |
|
931 | + $link .= strpos($link, '?') === false ? '?' : '&'; |
|
932 | 932 | $link .= $this->id_field.'='.$data[$this->id_field]; |
933 | 933 | } |
934 | 934 | } |
935 | 935 | else |
936 | 936 | { |
937 | - if (($view = Api\Link::view($this->app,$data[$this->id_field]))) |
|
937 | + if (($view = Api\Link::view($this->app, $data[$this->id_field]))) |
|
938 | 938 | { |
939 | - $link = $GLOBALS['egw']->link('/index.php',$view); |
|
940 | - $popup = Api\Link::is_popup($this->app,'view'); |
|
939 | + $link = $GLOBALS['egw']->link('/index.php', $view); |
|
940 | + $popup = Api\Link::is_popup($this->app, 'view'); |
|
941 | 941 | } |
942 | 942 | } |
943 | 943 | if ($link[0] == '/') |
@@ -948,12 +948,12 @@ discard block |
||
948 | 948 | if (!$allow_popup) |
949 | 949 | { |
950 | 950 | // remove the session-id in the notification mail! |
951 | - $link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link); |
|
951 | + $link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', $link); |
|
952 | 952 | |
953 | 953 | if ($popup) $link .= '&nopopup=1'; |
954 | 954 | } |
955 | 955 | //error_log(__METHOD__."(..., $allow_popup, $receiver) returning ".array2string($allow_popup ? array($link,$popup) : $link)); |
956 | - return $allow_popup ? array($link,$popup) : $link; |
|
956 | + return $allow_popup ? array($link, $popup) : $link; |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | * @param int|string $receiver nummeric account_id or email address |
965 | 965 | * @return array with link |
966 | 966 | */ |
967 | - protected function get_notification_link($data,$old,$receiver=null) |
|
967 | + protected function get_notification_link($data, $old, $receiver = null) |
|
968 | 968 | { |
969 | - unset($receiver); // not used, but required by function signature |
|
969 | + unset($receiver); // not used, but required by function signature |
|
970 | 970 | |
971 | - if (($view = Api\Link::view($this->app,$data[$this->id_field]))) |
|
971 | + if (($view = Api\Link::view($this->app, $data[$this->id_field]))) |
|
972 | 972 | { |
973 | 973 | return array( |
974 | - 'text' => $this->get_title($data,$old), |
|
974 | + 'text' => $this->get_title($data, $old), |
|
975 | 975 | 'app' => $this->app, |
976 | 976 | 'id' => $data[$this->id_field], |
977 | 977 | 'view' => $view, |
978 | - 'popup' => Api\Link::is_popup($this->app,'view'), |
|
978 | + 'popup' => Api\Link::is_popup($this->app, 'view'), |
|
979 | 979 | ); |
980 | 980 | } |
981 | 981 | return false; |
@@ -991,15 +991,15 @@ discard block |
||
991 | 991 | * @param int|string $receiver nummeric account_id or email address |
992 | 992 | * @return string |
993 | 993 | */ |
994 | - public function get_body($html_email,$data,$old,$integrate_link = true,$receiver=null) |
|
994 | + public function get_body($html_email, $data, $old, $integrate_link = true, $receiver = null) |
|
995 | 995 | { |
996 | 996 | $body = ''; |
997 | - if($this->get_config(self::CUSTOM_NOTIFICATION, $data, $old)) |
|
997 | + if ($this->get_config(self::CUSTOM_NOTIFICATION, $data, $old)) |
|
998 | 998 | { |
999 | - $body = $this->get_custom_message($data,$old); |
|
1000 | - if(($sig = $this->get_signature($data,$old,$receiver))) |
|
999 | + $body = $this->get_custom_message($data, $old); |
|
1000 | + if (($sig = $this->get_signature($data, $old, $receiver))) |
|
1001 | 1001 | { |
1002 | - $body .= ($html_email ? '<br />':'') . "\n$sig"; |
|
1002 | + $body .= ($html_email ? '<br />' : '')."\n$sig"; |
|
1003 | 1003 | } |
1004 | 1004 | return $body; |
1005 | 1005 | } |
@@ -1008,35 +1008,35 @@ discard block |
||
1008 | 1008 | $body = '<table cellspacing="2" cellpadding="0" border="0" width="100%">'."\n"; |
1009 | 1009 | } |
1010 | 1010 | // new or modified message |
1011 | - if (($message = $this->get_message($data,$old,$receiver))) |
|
1011 | + if (($message = $this->get_message($data, $old, $receiver))) |
|
1012 | 1012 | { |
1013 | 1013 | foreach ((array)$message as $_message) |
1014 | 1014 | { |
1015 | - $body .= $this->format_line($html_email,'message',false,($_message=='---'?($html_email?'<hr/>':$_message):$_message)); |
|
1015 | + $body .= $this->format_line($html_email, 'message', false, ($_message == '---' ? ($html_email ? '<hr/>' : $_message) : $_message)); |
|
1016 | 1016 | } |
1017 | 1017 | } |
1018 | - if ($integrate_link && ($link = $this->get_link($data,$old,false,$receiver))) |
|
1018 | + if ($integrate_link && ($link = $this->get_link($data, $old, false, $receiver))) |
|
1019 | 1019 | { |
1020 | - $body .= $this->format_line($html_email,'link',false,$integrate_link === true ? lang('You can respond by visiting:') : $integrate_link,$link); |
|
1020 | + $body .= $this->format_line($html_email, 'link', false, $integrate_link === true ? lang('You can respond by visiting:') : $integrate_link, $link); |
|
1021 | 1021 | } |
1022 | - foreach($this->get_details($data,$receiver) as $name => $detail) |
|
1022 | + foreach ($this->get_details($data, $receiver) as $name => $detail) |
|
1023 | 1023 | { |
1024 | 1024 | // if there's no old entry, the entry is not modified by definition |
1025 | 1025 | // if both values are '', 0 or null, we count them as equal too |
1026 | 1026 | $modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]); |
1027 | 1027 | //if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified); |
1028 | - if (empty($detail['value']) && !$modified) continue; // skip unchanged, empty values |
|
1028 | + if (empty($detail['value']) && !$modified) continue; // skip unchanged, empty values |
|
1029 | 1029 | |
1030 | - $body .= $this->format_line($html_email,$detail['type'],$modified, |
|
1030 | + $body .= $this->format_line($html_email, $detail['type'], $modified, |
|
1031 | 1031 | $detail['label'] ? $detail['label'] : '', $detail['value']); |
1032 | 1032 | } |
1033 | 1033 | if ($html_email) |
1034 | 1034 | { |
1035 | 1035 | $body .= "</table>\n"; |
1036 | 1036 | } |
1037 | - if(($sig = $this->get_signature($data,$old,$receiver))) |
|
1037 | + if (($sig = $this->get_signature($data, $old, $receiver))) |
|
1038 | 1038 | { |
1039 | - $body .= ($html_email ? '<br />':'') . "\n$sig"; |
|
1039 | + $body .= ($html_email ? '<br />' : '')."\n$sig"; |
|
1040 | 1040 | } |
1041 | 1041 | return $body; |
1042 | 1042 | } |
@@ -1052,20 +1052,20 @@ discard block |
||
1052 | 1052 | * @param string $data = null data or null to display just $line over 2 columns |
1053 | 1053 | * @return string |
1054 | 1054 | */ |
1055 | - protected function format_line($html_mail,$type,$modified,$line,$data=null) |
|
1055 | + protected function format_line($html_mail, $type, $modified, $line, $data = null) |
|
1056 | 1056 | { |
1057 | 1057 | //error_log(__METHOD__.'('.array2string($html_mail).",'$type',".array2string($modified).",'$line',".array2string($data).')'); |
1058 | 1058 | $content = ''; |
1059 | 1059 | |
1060 | 1060 | if ($html_mail) |
1061 | 1061 | { |
1062 | - if (!$this->html_content_allow) $line = Api\Html::htmlspecialchars($line); // XSS |
|
1062 | + if (!$this->html_content_allow) $line = Api\Html::htmlspecialchars($line); // XSS |
|
1063 | 1063 | |
1064 | 1064 | $color = $modified ? 'red' : false; |
1065 | 1065 | $size = '110%'; |
1066 | 1066 | $bold = false; |
1067 | 1067 | $background = '#FFFFF1'; |
1068 | - switch($type) |
|
1068 | + switch ($type) |
|
1069 | 1069 | { |
1070 | 1070 | case 'message': |
1071 | 1071 | $background = '#D3DCE3;'; |
@@ -1083,7 +1083,7 @@ discard block |
||
1083 | 1083 | if (strpos($data, '<br') === false) |
1084 | 1084 | { |
1085 | 1085 | $data = nl2br($this->html_content_allow ? $data : Api\Html::htmlspecialchars($data)); |
1086 | - $this->html_content_allow = true; // to NOT do htmlspecialchars again |
|
1086 | + $this->html_content_allow = true; // to NOT do htmlspecialchars again |
|
1087 | 1087 | } |
1088 | 1088 | break; |
1089 | 1089 | case 'reply': |
@@ -1092,13 +1092,13 @@ discard block |
||
1092 | 1092 | default: |
1093 | 1093 | $size = false; |
1094 | 1094 | } |
1095 | - $style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color?'color:'.$color:''); |
|
1095 | + $style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color ? 'color:'.$color : ''); |
|
1096 | 1096 | |
1097 | - $content = '<tr style="background-color: '.$background.';"><td style="'.$style.($line && $data?'" width="20%':'" colspan="2').'">'; |
|
1097 | + $content = '<tr style="background-color: '.$background.';"><td style="'.$style.($line && $data ? '" width="20%' : '" colspan="2').'">'; |
|
1098 | 1098 | } |
1099 | 1099 | else // text-mail |
1100 | 1100 | { |
1101 | - if ($type == 'reply') $content = str_repeat('-',64)."\n"; |
|
1101 | + if ($type == 'reply') $content = str_repeat('-', 64)."\n"; |
|
1102 | 1102 | |
1103 | 1103 | if ($modified) $content .= '> '; |
1104 | 1104 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | if ($type == 'link') |
1111 | 1111 | { |
1112 | 1112 | // the link is often too long for html boxes chunk-split allows to break lines if needed |
1113 | - $content .= Api\Html::a_href(chunk_split(rawurldecode($data),40,'​'),$data,'','target="_blank"'); |
|
1113 | + $content .= Api\Html::a_href(chunk_split(rawurldecode($data), 40, '​'), $data, '', 'target="_blank"'); |
|
1114 | 1114 | } |
1115 | 1115 | elseif ($this->html_content_allow) |
1116 | 1116 | { |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | } |
1124 | 1124 | else |
1125 | 1125 | { |
1126 | - $content .= ($content&&$data?': ':'').$data; |
|
1126 | + $content .= ($content && $data ? ': ' : '').$data; |
|
1127 | 1127 | } |
1128 | 1128 | if ($html_mail) $content .= '</td></tr>'; |
1129 | 1129 | |
@@ -1140,9 +1140,9 @@ discard block |
||
1140 | 1140 | * @param int|string $receiver nummeric account_id or email address |
1141 | 1141 | * @return array or array with values for either 'string' or 'path' and optionally (mime-)'type', 'filename' and 'encoding' |
1142 | 1142 | */ |
1143 | - protected function get_attachments($data,$old,$receiver=null) |
|
1143 | + protected function get_attachments($data, $old, $receiver = null) |
|
1144 | 1144 | { |
1145 | - unset($data, $old, $receiver); // not used, but required by function signature |
|
1145 | + unset($data, $old, $receiver); // not used, but required by function signature |
|
1146 | 1146 | |
1147 | 1147 | return array(); |
1148 | 1148 | } |
@@ -1155,20 +1155,20 @@ discard block |
||
1155 | 1155 | */ |
1156 | 1156 | protected function get_signature($data, $old, $receiver) |
1157 | 1157 | { |
1158 | - unset($old, $receiver); // not used, but required by function signature |
|
1158 | + unset($old, $receiver); // not used, but required by function signature |
|
1159 | 1159 | |
1160 | 1160 | $config = Api\Config::read('notifications'); |
1161 | - if(!isset($data[$this->id_field])) |
|
1161 | + if (!isset($data[$this->id_field])) |
|
1162 | 1162 | { |
1163 | - error_log($this->app . ' did not properly implement bo_tracking->id_field. Merge skipped.'); |
|
1163 | + error_log($this->app.' did not properly implement bo_tracking->id_field. Merge skipped.'); |
|
1164 | 1164 | } |
1165 | - elseif(class_exists($this->app. '_merge')) |
|
1165 | + elseif (class_exists($this->app.'_merge')) |
|
1166 | 1166 | { |
1167 | 1167 | $merge_class = $this->app.'_merge'; |
1168 | 1168 | $merge = new $merge_class(); |
1169 | 1169 | $error = null; |
1170 | 1170 | $sig = $merge->merge_string($config['signature'], array($data[$this->id_field]), $error, 'text/html'); |
1171 | - if($error) |
|
1171 | + if ($error) |
|
1172 | 1172 | { |
1173 | 1173 | error_log($error); |
1174 | 1174 | return $config['signature']; |
@@ -1185,27 +1185,27 @@ discard block |
||
1185 | 1185 | protected function get_custom_message($data, $old, $merge_class = null) |
1186 | 1186 | { |
1187 | 1187 | $message = $this->get_config(self::CUSTOM_NOTIFICATION, $data, $old); |
1188 | - if(!$message) |
|
1188 | + if (!$message) |
|
1189 | 1189 | { |
1190 | 1190 | return ''; |
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | // Automatically set merge class from naming conventions |
1194 | - if($merge_class == null) |
|
1194 | + if ($merge_class == null) |
|
1195 | 1195 | { |
1196 | 1196 | $merge_class = $this->app.'_merge'; |
1197 | 1197 | } |
1198 | - if(!isset($data[$this->id_field])) |
|
1198 | + if (!isset($data[$this->id_field])) |
|
1199 | 1199 | { |
1200 | - error_log($this->app . ' did not properly implement bo_tracking->id_field. Merge skipped.'); |
|
1200 | + error_log($this->app.' did not properly implement bo_tracking->id_field. Merge skipped.'); |
|
1201 | 1201 | return $message; |
1202 | 1202 | } |
1203 | - elseif(class_exists($merge_class)) |
|
1203 | + elseif (class_exists($merge_class)) |
|
1204 | 1204 | { |
1205 | 1205 | $merge = new $merge_class(); |
1206 | 1206 | $error = null; |
1207 | 1207 | $merged_message = $merge->merge_string($message, array($data[$this->id_field]), $error, 'text/html'); |
1208 | - if($error) |
|
1208 | + if ($error) |
|
1209 | 1209 | { |
1210 | 1210 | error_log($error); |
1211 | 1211 | return $message; |