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