@@ -82,7 +82,10 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $this->mailPreferences['message_forwarding'] = 'asmail'; |
| 84 | 84 | } |
| 85 | - if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail'); |
|
| 85 | + if (is_null(Mail::$mailConfig)) |
|
| 86 | + { |
|
| 87 | + Mail::$mailConfig = Api\Config::read('mail'); |
|
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
| 88 | 91 | } |
@@ -96,11 +99,21 @@ discard block |
||
| 96 | 99 | { |
| 97 | 100 | if ($this->mail_bo->profileID!=$_icServerID) |
| 98 | 101 | { |
| 99 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
| 102 | + if (Mail::$debug) |
|
| 103 | + { |
|
| 104 | + error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
| 105 | + } |
|
| 100 | 106 | $this->mail_bo = Mail::getInstance(false,$_icServerID); |
| 101 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 107 | + if (Mail::$debug) |
|
| 108 | + { |
|
| 109 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 110 | + } |
|
| 102 | 111 | // no icServer Object: something failed big time |
| 103 | - if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
|
| 112 | + if (!isset($this->mail_bo->icServer)) |
|
| 113 | + { |
|
| 114 | + exit; |
|
| 115 | + } |
|
| 116 | + // ToDo: Exception or the dialog for setting up a server config |
|
| 104 | 117 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
| 105 | 118 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
| 106 | 119 | } |
@@ -242,7 +255,8 @@ discard block |
||
| 242 | 255 | { |
| 243 | 256 | foreach (array_keys($actions) as $key) |
| 244 | 257 | { |
| 245 | - if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) { |
|
| 258 | + if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) |
|
| 259 | + { |
|
| 246 | 260 | $actions[$key]['toolbarDefault'] = false; |
| 247 | 261 | } |
| 248 | 262 | } |
@@ -268,7 +282,10 @@ discard block |
||
| 268 | 282 | */ |
| 269 | 283 | function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
| 270 | 284 | { |
| 271 | - if ($msg) Framework::message($msg); |
|
| 285 | + if ($msg) |
|
| 286 | + { |
|
| 287 | + Framework::message($msg); |
|
| 288 | + } |
|
| 272 | 289 | |
| 273 | 290 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
| 274 | 291 | { |
@@ -289,8 +306,14 @@ discard block |
||
| 289 | 306 | //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); |
| 290 | 307 | $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; |
| 291 | 308 | $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; |
| 292 | - if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; |
|
| 293 | - if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; |
|
| 309 | + if (isset($_GET['reply_id'])) |
|
| 310 | + { |
|
| 311 | + $replyID = $_GET['reply_id']; |
|
| 312 | + } |
|
| 313 | + if (!$replyID && isset($_GET['id'])) |
|
| 314 | + { |
|
| 315 | + $replyID = $_GET['id']; |
|
| 316 | + } |
|
| 294 | 317 | |
| 295 | 318 | // Process different places we can use as a start for composing an email |
| 296 | 319 | $actionToProcess = 'compose'; |
@@ -357,7 +380,10 @@ discard block |
||
| 357 | 380 | $suppressSigOnTop = true; |
| 358 | 381 | foreach ($_content['uploadForCompose'] as $i => &$upload) |
| 359 | 382 | { |
| 360 | - if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
|
| 383 | + if (!isset($upload['file'])) |
|
| 384 | + { |
|
| 385 | + $upload['file'] = $upload['tmp_name']; |
|
| 386 | + } |
|
| 361 | 387 | try |
| 362 | 388 | { |
| 363 | 389 | $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false); |
@@ -391,9 +417,15 @@ discard block |
||
| 391 | 417 | $remove=false; |
| 392 | 418 | foreach(array_keys($toDelete) as $k) |
| 393 | 419 | { |
| 394 | - if ($att['tmp_name']==$k) $remove=true; |
|
| 420 | + if ($att['tmp_name']==$k) |
|
| 421 | + { |
|
| 422 | + $remove=true; |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + if (!$remove) |
|
| 426 | + { |
|
| 427 | + $_content['attachments'][] = $att; |
|
| 395 | 428 | } |
| 396 | - if (!$remove) $_content['attachments'][] = $att; |
|
| 397 | 429 | } |
| 398 | 430 | } |
| 399 | 431 | // someone clicked something like send, or saveAsDraft |
@@ -408,8 +440,7 @@ discard block |
||
| 408 | 440 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
| 409 | 441 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
| 410 | 442 | ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
| 411 | - ) |
|
| 412 | - { |
|
| 443 | + ) { |
|
| 413 | 444 | $this->changeProfile($_content['serverID']); |
| 414 | 445 | $composeProfile = $this->mail_bo->profileID; |
| 415 | 446 | } |
@@ -489,7 +520,10 @@ discard block |
||
| 489 | 520 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
| 490 | 521 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
| 491 | 522 | $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
| 492 | - if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
|
| 523 | + if (!empty($fhA['folder'])) |
|
| 524 | + { |
|
| 525 | + $workingFolder = $fhA['folder']; |
|
| 526 | + } |
|
| 493 | 527 | } |
| 494 | 528 | } |
| 495 | 529 | if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
@@ -540,7 +574,10 @@ discard block |
||
| 540 | 574 | } |
| 541 | 575 | } |
| 542 | 576 | |
| 543 | - if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
|
| 577 | + if ($activeProfile != $composeProfile) |
|
| 578 | + { |
|
| 579 | + $this->changeProfile($activeProfile); |
|
| 580 | + } |
|
| 544 | 581 | $insertSigOnTop = false; |
| 545 | 582 | $content = (is_array($_content)?$_content:array()); |
| 546 | 583 | if ($_contentHasMimeType) |
@@ -569,7 +606,10 @@ discard block |
||
| 569 | 606 | { |
| 570 | 607 | foreach ($contentArr as $k =>&$elem) |
| 571 | 608 | { |
| 572 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
| 609 | + if (stripos($elem,'<pre>')!==false) |
|
| 610 | + { |
|
| 611 | + $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
| 612 | + } |
|
| 573 | 613 | } |
| 574 | 614 | $content['mail_htmltext'] = implode('',$contentArr); |
| 575 | 615 | } |
@@ -611,8 +651,7 @@ discard block |
||
| 611 | 651 | if ( !empty($content['body']) && |
| 612 | 652 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
| 613 | 653 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
| 614 | - ) |
|
| 615 | - { |
|
| 654 | + ) { |
|
| 616 | 655 | $buttonClicked = true; |
| 617 | 656 | $suppressSigOnTop = true; |
| 618 | 657 | if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) |
@@ -628,7 +667,10 @@ discard block |
||
| 628 | 667 | else |
| 629 | 668 | { |
| 630 | 669 | $newSig = $this->mail_bo->getDefaultIdentity(); |
| 631 | - if ($newSig === false) $newSig = -2; |
|
| 670 | + if ($newSig === false) |
|
| 671 | + { |
|
| 672 | + $newSig = -2; |
|
| 673 | + } |
|
| 632 | 674 | } |
| 633 | 675 | } |
| 634 | 676 | $_oldSig = $composeCache['mailidentity']; |
@@ -636,7 +678,10 @@ discard block |
||
| 636 | 678 | |
| 637 | 679 | if ($_oldSig != $_signatureid) |
| 638 | 680 | { |
| 639 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
| 681 | + if($this->_debug) |
|
| 682 | + { |
|
| 683 | + error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
| 684 | + } |
|
| 640 | 685 | // prepare signatures, the selected sig may be used on top of the body |
| 641 | 686 | try |
| 642 | 687 | { |
@@ -666,7 +711,10 @@ discard block |
||
| 666 | 711 | { |
| 667 | 712 | $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
| 668 | 713 | $sigText = $this->convertHTMLToText($sigText,true,true); |
| 669 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
| 714 | + if($this->_debug) |
|
| 715 | + { |
|
| 716 | + error_log(__METHOD__." Old signature:".$oldSigText); |
|
| 717 | + } |
|
| 670 | 718 | } |
| 671 | 719 | |
| 672 | 720 | //$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -682,7 +730,11 @@ discard block |
||
| 682 | 730 | { |
| 683 | 731 | $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
| 684 | 732 | $styles = Mail::getStyles(array(array('body'=>$content['body']))); |
| 685 | - if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags |
|
| 733 | + if (stripos($content['body'],'style')!==false) |
|
| 734 | + { |
|
| 735 | + Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); |
|
| 736 | + } |
|
| 737 | + // clean out empty or pagewide style definitions / left over tags |
|
| 686 | 738 | } |
| 687 | 739 | $content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), |
| 688 | 740 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
@@ -727,8 +779,14 @@ discard block |
||
| 727 | 779 | |
| 728 | 780 | if ($found === false) |
| 729 | 781 | { |
| 730 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
| 731 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
| 782 | + if($this->_debug) |
|
| 783 | + { |
|
| 784 | + error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
| 785 | + } |
|
| 786 | + if($this->_debug) |
|
| 787 | + { |
|
| 788 | + error_log(__METHOD__." Compare content:".$content['body']); |
|
| 789 | + } |
|
| 732 | 790 | } |
| 733 | 791 | else |
| 734 | 792 | { |
@@ -746,7 +804,10 @@ discard block |
||
| 746 | 804 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
| 747 | 805 | |
| 748 | 806 | // do not double insert a signature on a server roundtrip |
| 749 | - if ($buttonClicked) $suppressSigOnTop = true; |
|
| 807 | + if ($buttonClicked) |
|
| 808 | + { |
|
| 809 | + $suppressSigOnTop = true; |
|
| 810 | + } |
|
| 750 | 811 | if ($isFirstLoad) |
| 751 | 812 | { |
| 752 | 813 | $alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached |
@@ -785,7 +846,8 @@ discard block |
||
| 785 | 846 | } |
| 786 | 847 | } |
| 787 | 848 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
| 788 | - foreach(array('subject','body','mimetype') as $name) { |
|
| 849 | + foreach(array('subject','body','mimetype') as $name) |
|
| 850 | + { |
|
| 789 | 851 | $sName = $name; |
| 790 | 852 | if ($name=='mimetype'&&$res[$name]) |
| 791 | 853 | { |
@@ -794,7 +856,10 @@ discard block |
||
| 794 | 856 | } |
| 795 | 857 | else |
| 796 | 858 | { |
| 797 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
| 859 | + if ($res[$name]) |
|
| 860 | + { |
|
| 861 | + $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
| 862 | + } |
|
| 798 | 863 | } |
| 799 | 864 | } |
| 800 | 865 | } |
@@ -805,7 +870,8 @@ discard block |
||
| 805 | 870 | { |
| 806 | 871 | $alreadyProcessed=array(); |
| 807 | 872 | //_debug_array($_REQUEST); |
| 808 | - if ($_REQUEST['preset']['mailto']) { |
|
| 873 | + if ($_REQUEST['preset']['mailto']) |
|
| 874 | + { |
|
| 809 | 875 | // handle mailto strings such as |
| 810 | 876 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
| 811 | 877 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
@@ -813,10 +879,12 @@ discard block |
||
| 813 | 879 | $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
| 814 | 880 | // check if there is more than the to address |
| 815 | 881 | $mailtoArray = explode('?',$tmp_send_to,2); |
| 816 | - if ($mailtoArray[1]) { |
|
| 882 | + if ($mailtoArray[1]) |
|
| 883 | + { |
|
| 817 | 884 | // check if there are more than one requests |
| 818 | 885 | $addRequests = explode('&',$mailtoArray[1]); |
| 819 | - foreach ($addRequests as $key => $reqval) { |
|
| 886 | + foreach ($addRequests as $key => $reqval) |
|
| 887 | + { |
|
| 820 | 888 | // the additional requests should have a =, to separate key from value. |
| 821 | 889 | $keyValuePair = explode('=',$reqval,2); |
| 822 | 890 | $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1]; |
@@ -825,17 +893,24 @@ discard block |
||
| 825 | 893 | $content['to']=$mailtoArray[0]; |
| 826 | 894 | $alreadyProcessed['to']='to'; |
| 827 | 895 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
| 828 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
| 896 | + foreach(array('cc','bcc','subject','body') as $name) |
|
| 897 | + { |
|
| 829 | 898 | $alreadyProcessed[$name]=$name; |
| 830 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
| 899 | + if ($_REQUEST[$name]) |
|
| 900 | + { |
|
| 901 | + $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
| 902 | + } |
|
| 831 | 903 | } |
| 832 | 904 | } |
| 833 | 905 | |
| 834 | - if ($_REQUEST['preset']['mailtocontactbyid']) { |
|
| 835 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
|
| 906 | + if ($_REQUEST['preset']['mailtocontactbyid']) |
|
| 907 | + { |
|
| 908 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook']) |
|
| 909 | + { |
|
| 836 | 910 | $contacts_obj = new Api\Contacts(); |
| 837 | 911 | $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
| 838 | - if (method_exists($contacts_obj,'search')) { |
|
| 912 | + if (method_exists($contacts_obj,'search')) |
|
| 913 | + { |
|
| 839 | 914 | |
| 840 | 915 | $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
| 841 | 916 | foreach ((array)$addressArray as $id => $addressID) |
@@ -850,7 +925,10 @@ discard block |
||
| 850 | 925 | { |
| 851 | 926 | $_searchCond = array('contact_id'=>$addressArray); |
| 852 | 927 | //error_log(__METHOD__.__LINE__.$_searchString); |
| 853 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false; |
|
| 928 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
| 929 | + { |
|
| 930 | + $showAccounts=false; |
|
| 931 | + } |
|
| 854 | 932 | $filter = ($showAccounts?array():array('account_id' => null)); |
| 855 | 933 | $filter['cols_to_search']=array('n_fn','email','email_home'); |
| 856 | 934 | $contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); |
@@ -873,21 +951,28 @@ discard block |
||
| 873 | 951 | unset($accounts); |
| 874 | 952 | } |
| 875 | 953 | } |
| 876 | - if(is_array($contacts)) { |
|
| 954 | + if(is_array($contacts)) |
|
| 955 | + { |
|
| 877 | 956 | $mailtoArray = array(); |
| 878 | 957 | $primary = $addressbookprefs['distributionListPreferredMail']; |
| 879 | - if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
|
| 958 | + if ($primary != 'email' && $primary != 'email_home') |
|
| 959 | + { |
|
| 960 | + $primary = 'email'; |
|
| 961 | + } |
|
| 880 | 962 | $secondary = ($primary == 'email'?'email_home':'email'); |
| 881 | 963 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
| 882 | - foreach($contacts as $contact) { |
|
| 964 | + foreach($contacts as $contact) |
|
| 965 | + { |
|
| 883 | 966 | $innerCounter=0; |
| 884 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
| 967 | + foreach(array($contact[$primary],$contact[$secondary]) as $email) |
|
| 968 | + { |
|
| 885 | 969 | // use pref distributionListPreferredMail for the primary address |
| 886 | 970 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 887 | 971 | $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
| 888 | 972 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
| 889 | 973 | $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
| 890 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
| 974 | + if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) |
|
| 975 | + { |
|
| 891 | 976 | $i++; |
| 892 | 977 | $innerCounter++; |
| 893 | 978 | $mailtoArray[$i] = $completeMailString; |
@@ -979,7 +1064,10 @@ discard block |
||
| 979 | 1064 | } |
| 980 | 1065 | } |
| 981 | 1066 | } |
| 982 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
| 1067 | + if(!empty($remember)) |
|
| 1068 | + { |
|
| 1069 | + $content = array_merge($content,$remember); |
|
| 1070 | + } |
|
| 983 | 1071 | } |
| 984 | 1072 | foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
| 985 | 1073 | { |
@@ -989,9 +1077,15 @@ discard block |
||
| 989 | 1077 | $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
| 990 | 1078 | } |
| 991 | 1079 | //skip if already processed by "preset Routines" |
| 992 | - if ($alreadyProcessed[$name]) continue; |
|
| 1080 | + if ($alreadyProcessed[$name]) |
|
| 1081 | + { |
|
| 1082 | + continue; |
|
| 1083 | + } |
|
| 993 | 1084 | //error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]); |
| 994 | - if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name]; |
|
| 1085 | + if ($_REQUEST['preset'][$name]) |
|
| 1086 | + { |
|
| 1087 | + $content[$name] = $_REQUEST['preset'][$name]; |
|
| 1088 | + } |
|
| 995 | 1089 | } |
| 996 | 1090 | } |
| 997 | 1091 | // is the to address set already? |
@@ -999,7 +1093,10 @@ discard block |
||
| 999 | 1093 | { |
| 1000 | 1094 | $content['to'] = base64_decode($_REQUEST['send_to']); |
| 1001 | 1095 | // first check if there is a questionmark or ampersand |
| 1002 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
| 1096 | + if (strpos($content['to'],'?')!== false) |
|
| 1097 | + { |
|
| 1098 | + list($content['to'],$rest) = explode('?',$content['to'],2); |
|
| 1099 | + } |
|
| 1003 | 1100 | $content['to'] = html_entity_decode($content['to']); |
| 1004 | 1101 | if (($at_pos = strpos($content['to'],'@')) !== false) |
| 1005 | 1102 | { |
@@ -1012,9 +1109,15 @@ discard block |
||
| 1012 | 1109 | $content['to'] = $email; |
| 1013 | 1110 | } |
| 1014 | 1111 | } |
| 1015 | - if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
| 1112 | + if (strpos($content['to'],'%40')!== false) |
|
| 1113 | + { |
|
| 1114 | + $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
| 1115 | + } |
|
| 1016 | 1116 | $rarr = array(Api\Html::purify($rest)); |
| 1017 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
| 1117 | + if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) |
|
| 1118 | + { |
|
| 1119 | + $rarr = explode('&',$rest); |
|
| 1120 | + } |
|
| 1018 | 1121 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
| 1019 | 1122 | $karr = array(); |
| 1020 | 1123 | foreach ($rarr as &$rval) |
@@ -1030,9 +1133,15 @@ discard block |
||
| 1030 | 1133 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
| 1031 | 1134 | foreach(array('cc','bcc','subject','body') as $name) |
| 1032 | 1135 | { |
| 1033 | - if ($karr[$name]) $content[$name] = $karr[$name]; |
|
| 1136 | + if ($karr[$name]) |
|
| 1137 | + { |
|
| 1138 | + $content[$name] = $karr[$name]; |
|
| 1139 | + } |
|
| 1140 | + } |
|
| 1141 | + if (!empty($_REQUEST['subject'])) |
|
| 1142 | + { |
|
| 1143 | + $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
| 1034 | 1144 | } |
| 1035 | - if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
| 1036 | 1145 | } |
| 1037 | 1146 | } |
| 1038 | 1147 | //error_log(__METHOD__.__LINE__.array2string($content)); |
@@ -1050,7 +1159,10 @@ discard block |
||
| 1050 | 1159 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
| 1051 | 1160 | $content['body'] = "<pre>".$content['body']."</pre>"; |
| 1052 | 1161 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
| 1053 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1162 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
| 1163 | + { |
|
| 1164 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1165 | + } |
|
| 1054 | 1166 | } |
| 1055 | 1167 | } |
| 1056 | 1168 | else |
@@ -1070,7 +1182,10 @@ discard block |
||
| 1070 | 1182 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
| 1071 | 1183 | $content['body'] = "<pre>".$content['body']."</pre>"; |
| 1072 | 1184 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
| 1073 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1185 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
| 1186 | + { |
|
| 1187 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1188 | + } |
|
| 1074 | 1189 | } |
| 1075 | 1190 | } |
| 1076 | 1191 | } |
@@ -1110,24 +1225,33 @@ discard block |
||
| 1110 | 1225 | $disableRuler = true; |
| 1111 | 1226 | } |
| 1112 | 1227 | $font_span = $font_part = ''; |
| 1113 | - if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
| 1228 | + if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) |
|
| 1229 | + { |
|
| 1114 | 1230 | // User preferences for style |
| 1115 | 1231 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
| 1116 | 1232 | $font_size = Api\Html\CkEditorConfig::font_size_from_prefs(); |
| 1117 | 1233 | $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
| 1118 | 1234 | $font_span = $font_part.'​</span>'; |
| 1119 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
| 1235 | + if (empty($font) && empty($font_size)) |
|
| 1236 | + { |
|
| 1237 | + $font_span = ''; |
|
| 1238 | + } |
|
| 1120 | 1239 | } |
| 1121 | 1240 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
| 1122 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
| 1241 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) |
|
| 1242 | + { |
|
| 1243 | + $font_span = ''; |
|
| 1244 | + } |
|
| 1123 | 1245 | //remove possible html header stuff |
| 1124 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1246 | + if (stripos($content['body'],'<html><head></head><body>')!==false) |
|
| 1247 | + { |
|
| 1248 | + $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1249 | + } |
|
| 1125 | 1250 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
| 1126 | 1251 | $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
| 1127 | 1252 | if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
| 1128 | 1253 | !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
| 1129 | - ) |
|
| 1130 | - { |
|
| 1254 | + ) { |
|
| 1131 | 1255 | // ON tOP OR BELOW? pREF CAN TELL |
| 1132 | 1256 | /* |
| 1133 | 1257 | Signature behavior preference changed. New default, if not set -> 0 |
@@ -1142,14 +1266,23 @@ discard block |
||
| 1142 | 1266 | $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
| 1143 | 1267 | foreach($blockElements as $e) |
| 1144 | 1268 | { |
| 1145 | - if ($sigTextStartsWithBlockElement) break; |
|
| 1146 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
| 1269 | + if ($sigTextStartsWithBlockElement) |
|
| 1270 | + { |
|
| 1271 | + break; |
|
| 1272 | + } |
|
| 1273 | + if (stripos(trim($sigText),'<'.$e)===0) |
|
| 1274 | + { |
|
| 1275 | + $sigTextStartsWithBlockElement = true; |
|
| 1276 | + } |
|
| 1147 | 1277 | } |
| 1148 | 1278 | } |
| 1149 | - if($content['mimeType'] == 'html') { |
|
| 1279 | + if($content['mimeType'] == 'html') |
|
| 1280 | + { |
|
| 1150 | 1281 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
| 1151 | 1282 | $inbetween = ''; |
| 1152 | - } else { |
|
| 1283 | + } |
|
| 1284 | + else |
|
| 1285 | + { |
|
| 1153 | 1286 | $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 1154 | 1287 | $inbetween = "\r\n"; |
| 1155 | 1288 | } |
@@ -1183,7 +1316,10 @@ discard block |
||
| 1183 | 1316 | foreach(Mail\Account::search(true,false) as $acc_id => $account) |
| 1184 | 1317 | { |
| 1185 | 1318 | // do NOT add SMTP only accounts as identities |
| 1186 | - if (!$account->is_imap(false)) continue; |
|
| 1319 | + if (!$account->is_imap(false)) |
|
| 1320 | + { |
|
| 1321 | + continue; |
|
| 1322 | + } |
|
| 1187 | 1323 | |
| 1188 | 1324 | foreach($account->identities($acc_id) as $ident_id => $identity) |
| 1189 | 1325 | { |
@@ -1196,16 +1332,24 @@ discard block |
||
| 1196 | 1332 | //$content['bcc'] = array('[email protected]','[email protected]'); |
| 1197 | 1333 | // address stuff like from, to, cc, replyto |
| 1198 | 1334 | $destinationRows = 0; |
| 1199 | - foreach(self::$destinations as $destination) { |
|
| 1335 | + foreach(self::$destinations as $destination) |
|
| 1336 | + { |
|
| 1200 | 1337 | if (!is_array($content[$destination])) |
| 1201 | 1338 | { |
| 1202 | - if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
|
| 1339 | + if (!empty($content[$destination])) |
|
| 1340 | + { |
|
| 1341 | + $content[$destination] = (array)$content[$destination]; |
|
| 1342 | + } |
|
| 1203 | 1343 | } |
| 1204 | 1344 | $addr_content = $content[strtolower($destination)]; |
| 1205 | 1345 | // we clear the given address array and rebuild it |
| 1206 | 1346 | unset($content[strtolower($destination)]); |
| 1207 | - foreach((array)$addr_content as $key => $value) { |
|
| 1208 | - if ($value=="NIL@NIL") continue; |
|
| 1347 | + foreach((array)$addr_content as $key => $value) |
|
| 1348 | + { |
|
| 1349 | + if ($value=="NIL@NIL") |
|
| 1350 | + { |
|
| 1351 | + continue; |
|
| 1352 | + } |
|
| 1209 | 1353 | if ($destination=='replyto' && str_replace('"','',$value) == |
| 1210 | 1354 | str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()])) |
| 1211 | 1355 | { |
@@ -1215,8 +1359,12 @@ discard block |
||
| 1215 | 1359 | } |
| 1216 | 1360 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
| 1217 | 1361 | $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
| 1218 | - foreach(Mail::parseAddressList($value) as $addressObject) { |
|
| 1219 | - if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
|
| 1362 | + foreach(Mail::parseAddressList($value) as $addressObject) |
|
| 1363 | + { |
|
| 1364 | + if ($addressObject->host == '.SYNTAX-ERROR.') |
|
| 1365 | + { |
|
| 1366 | + continue; |
|
| 1367 | + } |
|
| 1220 | 1368 | $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
| 1221 | 1369 | //$address = Mail::htmlentities($address, $this->displayCharset); |
| 1222 | 1370 | $content[strtolower($destination)][]=$address; |
@@ -1227,11 +1375,20 @@ discard block |
||
| 1227 | 1375 | if ($_content) |
| 1228 | 1376 | { |
| 1229 | 1377 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
| 1230 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
| 1378 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) |
|
| 1379 | + { |
|
| 1380 | + unset($_content['mailidentity']); |
|
| 1381 | + } |
|
| 1231 | 1382 | $content = array_merge($content,$_content); |
| 1232 | 1383 | |
| 1233 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1234 | - if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
|
| 1384 | + if (!empty($content['folder'])) |
|
| 1385 | + { |
|
| 1386 | + $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1387 | + } |
|
| 1388 | + if (empty($content['mailaccount'])) |
|
| 1389 | + { |
|
| 1390 | + $content['mailaccount'] = $this->mail_bo->profileID; |
|
| 1391 | + } |
|
| 1235 | 1392 | } |
| 1236 | 1393 | else |
| 1237 | 1394 | { |
@@ -1274,11 +1431,17 @@ discard block |
||
| 1274 | 1431 | //error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']); |
| 1275 | 1432 | $preserv['is_html'] = $content['is_html']; |
| 1276 | 1433 | $preserv['is_plain'] = $content['is_plain']; |
| 1277 | - if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType']; |
|
| 1434 | + if (isset($content['mimeType'])) |
|
| 1435 | + { |
|
| 1436 | + $preserv['mimeType'] = $content['mimeType']; |
|
| 1437 | + } |
|
| 1278 | 1438 | $sel_options['mimeType'] = self::$mimeTypes; |
| 1279 | 1439 | $sel_options['priority'] = self::$priorities; |
| 1280 | 1440 | $sel_options['filemode'] = Vfs\Sharing::$modes; |
| 1281 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
| 1441 | + if (!isset($content['priority']) || empty($content['priority'])) |
|
| 1442 | + { |
|
| 1443 | + $content['priority']=3; |
|
| 1444 | + } |
|
| 1282 | 1445 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 1283 | 1446 | $etpl = new Etemplate('mail.compose'); |
| 1284 | 1447 | |
@@ -1325,9 +1488,12 @@ discard block |
||
| 1325 | 1488 | $preserv['list-id'] = $content['list-id']; |
| 1326 | 1489 | $preserv['mode'] = $content['mode']; |
| 1327 | 1490 | // convert it back to checkbox expectations |
| 1328 | - if($content['mimeType'] == 'html') { |
|
| 1491 | + if($content['mimeType'] == 'html') |
|
| 1492 | + { |
|
| 1329 | 1493 | $content['mimeType']=1; |
| 1330 | - } else { |
|
| 1494 | + } |
|
| 1495 | + else |
|
| 1496 | + { |
|
| 1331 | 1497 | $content['mimeType']=0; |
| 1332 | 1498 | } |
| 1333 | 1499 | // set the current selected mailaccount as param for folderselection |
@@ -1352,7 +1518,10 @@ discard block |
||
| 1352 | 1518 | // Resolve distribution list before send content to client |
| 1353 | 1519 | foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
| 1354 | 1520 | { |
| 1355 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1521 | + if (is_array($content[$f])) |
|
| 1522 | + { |
|
| 1523 | + $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1524 | + } |
|
| 1356 | 1525 | } |
| 1357 | 1526 | |
| 1358 | 1527 | $content['to'] = self::resolveEmailAddressList($content['to']); |
@@ -1400,7 +1569,10 @@ discard block |
||
| 1400 | 1569 | case 'composefromdraft': |
| 1401 | 1570 | case 'composeasnew': |
| 1402 | 1571 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
| 1403 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
| 1572 | + if ($from =='composefromdraft') |
|
| 1573 | + { |
|
| 1574 | + $content['mode'] = 'composefromdraft'; |
|
| 1575 | + } |
|
| 1404 | 1576 | $content['processedmail_id'] = $mail_id; |
| 1405 | 1577 | |
| 1406 | 1578 | $_focusElement = 'body'; |
@@ -1448,7 +1620,10 @@ discard block |
||
| 1448 | 1620 | $document_merge = new $merge_class(); |
| 1449 | 1621 | $this->mail_bo->openConnection(); |
| 1450 | 1622 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
| 1451 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
| 1623 | + if (!is_array($merge_ids)) |
|
| 1624 | + { |
|
| 1625 | + $merge_ids = explode(',',$merge_ids); |
|
| 1626 | + } |
|
| 1452 | 1627 | try |
| 1453 | 1628 | { |
| 1454 | 1629 | $merged_mail_id = ''; |
@@ -1479,7 +1654,10 @@ discard block |
||
| 1479 | 1654 | { |
| 1480 | 1655 | $success = implode(', ',$results['success']); |
| 1481 | 1656 | $fail = implode(', ', $results['failed']); |
| 1482 | - if($success) Framework::message($success, 'success'); |
|
| 1657 | + if($success) |
|
| 1658 | + { |
|
| 1659 | + Framework::message($success, 'success'); |
|
| 1660 | + } |
|
| 1483 | 1661 | Framework::window_close($fail); |
| 1484 | 1662 | } |
| 1485 | 1663 | } |
@@ -1511,17 +1689,25 @@ discard block |
||
| 1511 | 1689 | { |
| 1512 | 1690 | $stripalltags = true; |
| 1513 | 1691 | // third param is stripalltags, we may not need that, if the source is already in ascii |
| 1514 | - if (!$sourceishtml) $stripalltags=false; |
|
| 1692 | + if (!$sourceishtml) |
|
| 1693 | + { |
|
| 1694 | + $stripalltags=false; |
|
| 1695 | + } |
|
| 1515 | 1696 | return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags); |
| 1516 | 1697 | } |
| 1517 | 1698 | |
| 1518 | 1699 | function generateRFC822Address($_addressObject) |
| 1519 | 1700 | { |
| 1520 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
| 1701 | + if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) |
|
| 1702 | + { |
|
| 1521 | 1703 | return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
| 1522 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
| 1704 | + } |
|
| 1705 | + elseif($_addressObject->mailbox && $_addressObject->host) |
|
| 1706 | + { |
|
| 1523 | 1707 | return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
| 1524 | - } else { |
|
| 1708 | + } |
|
| 1709 | + else |
|
| 1710 | + { |
|
| 1525 | 1711 | return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
| 1526 | 1712 | } |
| 1527 | 1713 | } |
@@ -1555,16 +1741,28 @@ discard block |
||
| 1555 | 1741 | //if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC']; |
| 1556 | 1742 | |
| 1557 | 1743 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
| 1558 | - if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
|
| 1559 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
| 1744 | + if (!empty($addHeadInfo['X-MAILFOLDER'])) |
|
| 1745 | + { |
|
| 1746 | + foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) |
|
| 1747 | + { |
|
| 1560 | 1748 | $fval=$val; |
| 1561 | 1749 | $icServerID = $mail_bo->icServer->ImapServerId; |
| 1562 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
| 1563 | - if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
|
| 1564 | - if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
|
| 1750 | + if (stripos($val,'::')!==false) |
|
| 1751 | + { |
|
| 1752 | + list($icServerID,$fval) = explode('::',$val,2); |
|
| 1753 | + } |
|
| 1754 | + if ($icServerID != $mail_bo->icServer->ImapServerId) |
|
| 1755 | + { |
|
| 1756 | + continue; |
|
| 1757 | + } |
|
| 1758 | + if ($mail_bo->folderExists($fval)) |
|
| 1759 | + { |
|
| 1760 | + $this->sessionData['folder'][] = $val; |
|
| 1761 | + } |
|
| 1565 | 1762 | } |
| 1566 | 1763 | } |
| 1567 | - if (!empty($addHeadInfo['X-MAILIDENTITY'])) { |
|
| 1764 | + if (!empty($addHeadInfo['X-MAILIDENTITY'])) |
|
| 1765 | + { |
|
| 1568 | 1766 | // with the new system it would be the identity |
| 1569 | 1767 | try |
| 1570 | 1768 | { |
@@ -1580,7 +1778,8 @@ discard block |
||
| 1580 | 1778 | $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; |
| 1581 | 1779 | } |
| 1582 | 1780 | */ |
| 1583 | - if (!empty($addHeadInfo['X-MAILACCOUNT'])) { |
|
| 1781 | + if (!empty($addHeadInfo['X-MAILACCOUNT'])) |
|
| 1782 | + { |
|
| 1584 | 1783 | // with the new system it would the identity is the account id |
| 1585 | 1784 | try |
| 1586 | 1785 | { |
@@ -1595,27 +1794,38 @@ discard block |
||
| 1595 | 1794 | } |
| 1596 | 1795 | } |
| 1597 | 1796 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
| 1598 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1797 | + if ($mail_bo->isDraftFolder($_folder)) |
|
| 1798 | + { |
|
| 1799 | + $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); |
|
| 1800 | + } |
|
| 1801 | + //array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1599 | 1802 | $this->sessionData['uid'] = $_uid; |
| 1600 | 1803 | $this->sessionData['messageFolder'] = $_folder; |
| 1601 | 1804 | $this->sessionData['isDraft'] = true; |
| 1602 | 1805 | $foundAddresses = array(); |
| 1603 | - foreach((array)$headers['CC'] as $val) { |
|
| 1806 | + foreach((array)$headers['CC'] as $val) |
|
| 1807 | + { |
|
| 1604 | 1808 | $rfcAddr=Mail::parseAddressList($val); |
| 1605 | 1809 | $_rfcAddr = $rfcAddr[0]; |
| 1606 | - if (!$_rfcAddr->valid) continue; |
|
| 1607 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1810 | + if (!$_rfcAddr->valid) |
|
| 1811 | + { |
|
| 1812 | + continue; |
|
| 1813 | + } |
|
| 1814 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
| 1815 | + { |
|
| 1608 | 1816 | continue; |
| 1609 | 1817 | } |
| 1610 | 1818 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1611 | - if(!$foundAddresses[$keyemail]) { |
|
| 1819 | + if(!$foundAddresses[$keyemail]) |
|
| 1820 | + { |
|
| 1612 | 1821 | $address = $this->mail_bo->decode_header($val,true); |
| 1613 | 1822 | $this->sessionData['cc'][] = $val; |
| 1614 | 1823 | $foundAddresses[$keyemail] = true; |
| 1615 | 1824 | } |
| 1616 | 1825 | } |
| 1617 | 1826 | |
| 1618 | - foreach((array)$headers['TO'] as $val) { |
|
| 1827 | + foreach((array)$headers['TO'] as $val) |
|
| 1828 | + { |
|
| 1619 | 1829 | if(!is_array($val)) |
| 1620 | 1830 | { |
| 1621 | 1831 | $this->sessionData['to'][] = $val; |
@@ -1623,42 +1833,59 @@ discard block |
||
| 1623 | 1833 | } |
| 1624 | 1834 | $rfcAddr=Mail::parseAddressList($val); |
| 1625 | 1835 | $_rfcAddr = $rfcAddr[0]; |
| 1626 | - if (!$_rfcAddr->valid) continue; |
|
| 1627 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1836 | + if (!$_rfcAddr->valid) |
|
| 1837 | + { |
|
| 1838 | + continue; |
|
| 1839 | + } |
|
| 1840 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
| 1841 | + { |
|
| 1628 | 1842 | continue; |
| 1629 | 1843 | } |
| 1630 | 1844 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1631 | - if(!$foundAddresses[$keyemail]) { |
|
| 1845 | + if(!$foundAddresses[$keyemail]) |
|
| 1846 | + { |
|
| 1632 | 1847 | $address = $this->mail_bo->decode_header($val,true); |
| 1633 | 1848 | $this->sessionData['to'][] = $val; |
| 1634 | 1849 | $foundAddresses[$keyemail] = true; |
| 1635 | 1850 | } |
| 1636 | 1851 | } |
| 1637 | 1852 | |
| 1638 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
| 1853 | + foreach((array)$headers['REPLY-TO'] as $val) |
|
| 1854 | + { |
|
| 1639 | 1855 | $rfcAddr=Mail::parseAddressList($val); |
| 1640 | 1856 | $_rfcAddr = $rfcAddr[0]; |
| 1641 | - if (!$_rfcAddr->valid) continue; |
|
| 1642 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1857 | + if (!$_rfcAddr->valid) |
|
| 1858 | + { |
|
| 1859 | + continue; |
|
| 1860 | + } |
|
| 1861 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
| 1862 | + { |
|
| 1643 | 1863 | continue; |
| 1644 | 1864 | } |
| 1645 | 1865 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1646 | - if(!$foundAddresses[$keyemail]) { |
|
| 1866 | + if(!$foundAddresses[$keyemail]) |
|
| 1867 | + { |
|
| 1647 | 1868 | $address = $this->mail_bo->decode_header($val,true); |
| 1648 | 1869 | $this->sessionData['replyto'][] = $val; |
| 1649 | 1870 | $foundAddresses[$keyemail] = true; |
| 1650 | 1871 | } |
| 1651 | 1872 | } |
| 1652 | 1873 | |
| 1653 | - foreach((array)$headers['BCC'] as $val) { |
|
| 1874 | + foreach((array)$headers['BCC'] as $val) |
|
| 1875 | + { |
|
| 1654 | 1876 | $rfcAddr=Mail::parseAddressList($val); |
| 1655 | 1877 | $_rfcAddr = $rfcAddr[0]; |
| 1656 | - if (!$_rfcAddr->valid) continue; |
|
| 1657 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1878 | + if (!$_rfcAddr->valid) |
|
| 1879 | + { |
|
| 1880 | + continue; |
|
| 1881 | + } |
|
| 1882 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
| 1883 | + { |
|
| 1658 | 1884 | continue; |
| 1659 | 1885 | } |
| 1660 | 1886 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1661 | - if(!$foundAddresses[$keyemail]) { |
|
| 1887 | + if(!$foundAddresses[$keyemail]) |
|
| 1888 | + { |
|
| 1662 | 1889 | $address = $this->mail_bo->decode_header($val,true); |
| 1663 | 1890 | $this->sessionData['bcc'][] = $val; |
| 1664 | 1891 | $foundAddresses[$keyemail] = true; |
@@ -1672,32 +1899,46 @@ discard block |
||
| 1672 | 1899 | $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
| 1673 | 1900 | //_debug_array($bodyParts); |
| 1674 | 1901 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
| 1675 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 1902 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
| 1903 | + { |
|
| 1676 | 1904 | $this->sessionData['mimeType'] = 'html'; |
| 1677 | 1905 | |
| 1678 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1679 | - if($i>0) { |
|
| 1906 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 1907 | + { |
|
| 1908 | + if($i>0) |
|
| 1909 | + { |
|
| 1680 | 1910 | $this->sessionData['body'] .= '<hr>'; |
| 1681 | 1911 | } |
| 1682 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 1912 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
| 1913 | + { |
|
| 1683 | 1914 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
| 1684 | 1915 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 1685 | 1916 | } |
| 1686 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1917 | + if ($bodyParts[$i]['charSet']===false) |
|
| 1918 | + { |
|
| 1919 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1920 | + } |
|
| 1687 | 1921 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1688 | 1922 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1689 | 1923 | $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
| 1690 | 1924 | } |
| 1691 | 1925 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
| 1692 | 1926 | |
| 1693 | - } else { |
|
| 1927 | + } |
|
| 1928 | + else |
|
| 1929 | + { |
|
| 1694 | 1930 | $this->sessionData['mimeType'] = 'plain'; |
| 1695 | 1931 | |
| 1696 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1697 | - if($i>0) { |
|
| 1932 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 1933 | + { |
|
| 1934 | + if($i>0) |
|
| 1935 | + { |
|
| 1698 | 1936 | $this->sessionData['body'] .= "<hr>"; |
| 1699 | 1937 | } |
| 1700 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1938 | + if ($bodyParts[$i]['charSet']===false) |
|
| 1939 | + { |
|
| 1940 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1941 | + } |
|
| 1701 | 1942 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1702 | 1943 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1703 | 1944 | $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
@@ -1705,8 +1946,10 @@ discard block |
||
| 1705 | 1946 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
| 1706 | 1947 | } |
| 1707 | 1948 | |
| 1708 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
| 1709 | - foreach($attachments as $attachment) { |
|
| 1949 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) |
|
| 1950 | + { |
|
| 1951 | + foreach($attachments as $attachment) |
|
| 1952 | + { |
|
| 1710 | 1953 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 1711 | 1954 | $cid = $attachment['cid']; |
| 1712 | 1955 | $match=null; |
@@ -1729,7 +1972,8 @@ discard block |
||
| 1729 | 1972 | |
| 1730 | 1973 | function getErrorInfo() |
| 1731 | 1974 | { |
| 1732 | - if(isset($this->errorInfo)) { |
|
| 1975 | + if(isset($this->errorInfo)) |
|
| 1976 | + { |
|
| 1733 | 1977 | $errorInfo = $this->errorInfo; |
| 1734 | 1978 | unset($this->errorInfo); |
| 1735 | 1979 | return $errorInfo; |
@@ -1744,7 +1988,8 @@ discard block |
||
| 1744 | 1988 | $modebuff = $this->mailPreferences['message_forwarding']; |
| 1745 | 1989 | $this->mailPreferences['message_forwarding'] = $_mode; |
| 1746 | 1990 | } |
| 1747 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
| 1991 | + if ($this->mailPreferences['message_forwarding'] == 'inline') |
|
| 1992 | + { |
|
| 1748 | 1993 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
| 1749 | 1994 | } |
| 1750 | 1995 | $mail_bo = $this->mail_bo; |
@@ -1761,12 +2006,16 @@ discard block |
||
| 1761 | 2006 | //$this->sessionData['sourceFolder']=$_folder; |
| 1762 | 2007 | //$this->sessionData['forwardFlag']='forwarded'; |
| 1763 | 2008 | //$this->sessionData['forwardedUID']=$_uid; |
| 1764 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
| 2009 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') |
|
| 2010 | + { |
|
| 1765 | 2011 | $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
| 1766 | 2012 | if($headers['SIZE']) |
| 1767 | - $size = $headers['SIZE']; |
|
| 1768 | - else |
|
| 1769 | - $size = lang('unknown'); |
|
| 2013 | + { |
|
| 2014 | + $size = $headers['SIZE']; |
|
| 2015 | + } |
|
| 2016 | + else { |
|
| 2017 | + $size = lang('unknown'); |
|
| 2018 | + } |
|
| 1770 | 2019 | |
| 1771 | 2020 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
| 1772 | 2021 | $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
@@ -1777,9 +2026,11 @@ discard block |
||
| 1777 | 2026 | unset($this->sessionData['in-reply-to']); |
| 1778 | 2027 | unset($this->sessionData['to']); |
| 1779 | 2028 | unset($this->sessionData['cc']); |
| 1780 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) { |
|
| 2029 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) |
|
| 2030 | + { |
|
| 1781 | 2031 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
| 1782 | - foreach($attachments as $attachment) { |
|
| 2032 | + foreach($attachments as $attachment) |
|
| 2033 | + { |
|
| 1783 | 2034 | if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
| 1784 | 2035 | { |
| 1785 | 2036 | $this->addMessageAttachment($_uid, $attachment['partID'], |
@@ -1835,7 +2086,10 @@ discard block |
||
| 1835 | 2086 | { |
| 1836 | 2087 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
| 1837 | 2088 | strtolower($_formData['type'])== strtolower($attach['type']) && |
| 1838 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
| 2089 | + stripos($_formData['file'],'vfs://') !== false) |
|
| 2090 | + { |
|
| 2091 | + return; |
|
| 2092 | + } |
|
| 1839 | 2093 | } |
| 1840 | 2094 | } |
| 1841 | 2095 | if ($attachfailed === false) |
@@ -1847,7 +2101,10 @@ discard block |
||
| 1847 | 2101 | 'tmp_name' => $tmpFileName, |
| 1848 | 2102 | 'size' => $_formData['size'] |
| 1849 | 2103 | ); |
| 1850 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
| 2104 | + if (!is_array($_content['attachments'])) |
|
| 2105 | + { |
|
| 2106 | + $_content['attachments']=array(); |
|
| 2107 | + } |
|
| 1851 | 2108 | $_content['attachments'][] = $buffer; |
| 1852 | 2109 | unset($buffer); |
| 1853 | 2110 | } |
@@ -1878,7 +2135,10 @@ discard block |
||
| 1878 | 2135 | { |
| 1879 | 2136 | foreach($request->preserv['attachments'] as $attachment) |
| 1880 | 2137 | { |
| 1881 | - if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
|
| 2138 | + if ($_GET['tmpname'] === $attachment['tmp_name']) |
|
| 2139 | + { |
|
| 2140 | + break; |
|
| 2141 | + } |
|
| 1882 | 2142 | } |
| 1883 | 2143 | } |
| 1884 | 2144 | if (!$request || $_GET['tmpname'] !== $attachment['tmp_name']) |
@@ -1912,10 +2172,20 @@ discard block |
||
| 1912 | 2172 | $sfxMimeType = $attachment['type']; |
| 1913 | 2173 | $buff = explode('.',$attachment['tmp_name']); |
| 1914 | 2174 | $suffix = ''; |
| 1915 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 1916 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2175 | + if (is_array($buff)) |
|
| 2176 | + { |
|
| 2177 | + $suffix = array_pop($buff); |
|
| 2178 | + } |
|
| 2179 | + // take the last extension to check with ext2mime |
|
| 2180 | + if (!empty($suffix)) |
|
| 2181 | + { |
|
| 2182 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2183 | + } |
|
| 1917 | 2184 | $attachment['type'] = $sfxMimeType; |
| 1918 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2185 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
| 2186 | + { |
|
| 2187 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2188 | + } |
|
| 1919 | 2189 | } |
| 1920 | 2190 | //error_log(__METHOD__.print_r($attachment,true)); |
| 1921 | 2191 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -1924,7 +2194,10 @@ discard block |
||
| 1924 | 2194 | $calendar_ical = new calendar_ical(); |
| 1925 | 2195 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
| 1926 | 2196 | //error_log(__METHOD__.array2string($eventid)); |
| 1927 | - if (!$eventid) $eventid = -1; |
|
| 2197 | + if (!$eventid) |
|
| 2198 | + { |
|
| 2199 | + $eventid = -1; |
|
| 2200 | + } |
|
| 1928 | 2201 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
| 1929 | 2202 | //error_log(__METHOD__.$event); |
| 1930 | 2203 | if ((int)$event > 0) |
@@ -1950,7 +2223,10 @@ discard block |
||
| 1950 | 2223 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 1951 | 2224 | $contact = $addressbook_vcal->find_contact($vcard,false); |
| 1952 | 2225 | } |
| 1953 | - if (!$contact) $contact = null; |
|
| 2226 | + if (!$contact) |
|
| 2227 | + { |
|
| 2228 | + $contact = null; |
|
| 2229 | + } |
|
| 1954 | 2230 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
| 1955 | 2231 | if ($contact || count($vcard)>2) |
| 1956 | 2232 | { |
@@ -1981,7 +2257,8 @@ discard block |
||
| 1981 | 2257 | * @param string haystack |
| 1982 | 2258 | * @return boolean |
| 1983 | 2259 | */ |
| 1984 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
| 2260 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) |
|
| 2261 | + { |
|
| 1985 | 2262 | foreach (array_keys($arrayToTestAgainst) as $k) |
| 1986 | 2263 | { |
| 1987 | 2264 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
@@ -2038,21 +2315,34 @@ discard block |
||
| 2038 | 2315 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
| 2039 | 2316 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
| 2040 | 2317 | //if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC']; |
| 2041 | - if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
| 2042 | - if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
| 2318 | + if ($headers['THREAD-INDEX']) |
|
| 2319 | + { |
|
| 2320 | + $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
| 2321 | + } |
|
| 2322 | + if ($headers['LIST-ID']) |
|
| 2323 | + { |
|
| 2324 | + $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
| 2325 | + } |
|
| 2043 | 2326 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
| 2044 | 2327 | // check for Reply-To: header and use if available |
| 2045 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
| 2046 | - foreach($headers['REPLY-TO'] as $val) { |
|
| 2047 | - if(!$foundAddresses[$val]) { |
|
| 2328 | + if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) |
|
| 2329 | + { |
|
| 2330 | + foreach($headers['REPLY-TO'] as $val) |
|
| 2331 | + { |
|
| 2332 | + if(!$foundAddresses[$val]) |
|
| 2333 | + { |
|
| 2048 | 2334 | $oldTo[] = $val; |
| 2049 | 2335 | $foundAddresses[$val] = true; |
| 2050 | 2336 | } |
| 2051 | 2337 | } |
| 2052 | 2338 | $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
| 2053 | - } else { |
|
| 2054 | - foreach($headers['FROM'] as $val) { |
|
| 2055 | - if(!$foundAddresses[$val]) { |
|
| 2339 | + } |
|
| 2340 | + else |
|
| 2341 | + { |
|
| 2342 | + foreach($headers['FROM'] as $val) |
|
| 2343 | + { |
|
| 2344 | + if(!$foundAddresses[$val]) |
|
| 2345 | + { |
|
| 2056 | 2346 | $oldTo[] = $val; |
| 2057 | 2347 | $foundAddresses[$val] = true; |
| 2058 | 2348 | } |
@@ -2060,18 +2350,23 @@ discard block |
||
| 2060 | 2350 | $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
| 2061 | 2351 | } |
| 2062 | 2352 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
| 2063 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
| 2353 | + if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) |
|
| 2354 | + { |
|
| 2064 | 2355 | $this->sessionData['to'] = $oldTo; |
| 2065 | 2356 | } |
| 2066 | 2357 | |
| 2067 | - if($_mode == 'all') { |
|
| 2358 | + if($_mode == 'all') |
|
| 2359 | + { |
|
| 2068 | 2360 | // reply to any address which is cc, but not to my self |
| 2069 | 2361 | #if($headers->cc) { |
| 2070 | - foreach($headers['CC'] as $val) { |
|
| 2071 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2362 | + foreach($headers['CC'] as $val) |
|
| 2363 | + { |
|
| 2364 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2365 | + { |
|
| 2072 | 2366 | continue; |
| 2073 | 2367 | } |
| 2074 | - if(!$foundAddresses[$val]) { |
|
| 2368 | + if(!$foundAddresses[$val]) |
|
| 2369 | + { |
|
| 2075 | 2370 | $this->sessionData['cc'][] = $val; |
| 2076 | 2371 | $foundAddresses[$val] = true; |
| 2077 | 2372 | } |
@@ -2080,11 +2375,14 @@ discard block |
||
| 2080 | 2375 | |
| 2081 | 2376 | // reply to any address which is to, but not to my self |
| 2082 | 2377 | #if($headers->to) { |
| 2083 | - foreach($headers['TO'] as $val) { |
|
| 2084 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2378 | + foreach($headers['TO'] as $val) |
|
| 2379 | + { |
|
| 2380 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2381 | + { |
|
| 2085 | 2382 | continue; |
| 2086 | 2383 | } |
| 2087 | - if(!$foundAddresses[$val]) { |
|
| 2384 | + if(!$foundAddresses[$val]) |
|
| 2385 | + { |
|
| 2088 | 2386 | $this->sessionData['to'][] = $val; |
| 2089 | 2387 | $foundAddresses[$val] = true; |
| 2090 | 2388 | } |
@@ -2092,12 +2390,15 @@ discard block |
||
| 2092 | 2390 | #} |
| 2093 | 2391 | |
| 2094 | 2392 | #if($headers->from) { |
| 2095 | - foreach($headers['FROM'] as $val) { |
|
| 2096 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2393 | + foreach($headers['FROM'] as $val) |
|
| 2394 | + { |
|
| 2395 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2396 | + { |
|
| 2097 | 2397 | continue; |
| 2098 | 2398 | } |
| 2099 | 2399 | //error_log(__METHOD__.__LINE__.' '.$val); |
| 2100 | - if(!$foundAddresses[$val]) { |
|
| 2400 | + if(!$foundAddresses[$val]) |
|
| 2401 | + { |
|
| 2101 | 2402 | $this->sessionData['to'][] = $val; |
| 2102 | 2403 | $foundAddresses[$val] = true; |
| 2103 | 2404 | } |
@@ -2106,9 +2407,12 @@ discard block |
||
| 2106 | 2407 | } |
| 2107 | 2408 | |
| 2108 | 2409 | // check for Re: in subject header |
| 2109 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
| 2410 | + if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") |
|
| 2411 | + { |
|
| 2110 | 2412 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
| 2111 | - } else { |
|
| 2413 | + } |
|
| 2414 | + else |
|
| 2415 | + { |
|
| 2112 | 2416 | $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
| 2113 | 2417 | } |
| 2114 | 2418 | |
@@ -2122,7 +2426,8 @@ discard block |
||
| 2122 | 2426 | |
| 2123 | 2427 | $toAddressA = array(); |
| 2124 | 2428 | $toAddress = ''; |
| 2125 | - foreach ($headers['TO'] as $mailheader) { |
|
| 2429 | + foreach ($headers['TO'] as $mailheader) |
|
| 2430 | + { |
|
| 2126 | 2431 | $toAddressA[] = $mailheader; |
| 2127 | 2432 | } |
| 2128 | 2433 | if (count($toAddressA)>0) |
@@ -2132,7 +2437,8 @@ discard block |
||
| 2132 | 2437 | } |
| 2133 | 2438 | $ccAddressA = array(); |
| 2134 | 2439 | $ccAddress = ''; |
| 2135 | - foreach ($headers['CC'] as $mailheader) { |
|
| 2440 | + foreach ($headers['CC'] as $mailheader) |
|
| 2441 | + { |
|
| 2136 | 2442 | $ccAddressA[] = $mailheader; |
| 2137 | 2443 | } |
| 2138 | 2444 | if (count($ccAddressA)>0) |
@@ -2140,25 +2446,35 @@ discard block |
||
| 2140 | 2446 | $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
| 2141 | 2447 | $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
| 2142 | 2448 | } |
| 2143 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 2449 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
| 2450 | + { |
|
| 2144 | 2451 | $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
| 2145 | 2452 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
| 2146 | 2453 | $toAddress.$ccAddress. |
| 2147 | 2454 | @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>". |
| 2148 | 2455 | '----------------------------------------------------------'."</div>"; |
| 2149 | 2456 | $this->sessionData['mimeType'] = 'html'; |
| 2150 | - if (!empty($styles)) $this->sessionData['body'] .= $styles; |
|
| 2457 | + if (!empty($styles)) |
|
| 2458 | + { |
|
| 2459 | + $this->sessionData['body'] .= $styles; |
|
| 2460 | + } |
|
| 2151 | 2461 | $this->sessionData['body'] .= '<blockquote type="cite">'; |
| 2152 | 2462 | |
| 2153 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2154 | - if($i>0) { |
|
| 2463 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 2464 | + { |
|
| 2465 | + if($i>0) |
|
| 2466 | + { |
|
| 2155 | 2467 | $this->sessionData['body'] .= '<hr>'; |
| 2156 | 2468 | } |
| 2157 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 2469 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
| 2470 | + { |
|
| 2158 | 2471 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
| 2159 | 2472 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 2160 | 2473 | } |
| 2161 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2474 | + if ($bodyParts[$i]['charSet']===false) |
|
| 2475 | + { |
|
| 2476 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2477 | + } |
|
| 2162 | 2478 | |
| 2163 | 2479 | $_htmlConfig = Mail::$htmLawed_config; |
| 2164 | 2480 | Mail::$htmLawed_config['comment'] = 2; |
@@ -2170,7 +2486,9 @@ discard block |
||
| 2170 | 2486 | |
| 2171 | 2487 | $this->sessionData['body'] .= '</blockquote><br>'; |
| 2172 | 2488 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
| 2173 | - } else { |
|
| 2489 | + } |
|
| 2490 | + else |
|
| 2491 | + { |
|
| 2174 | 2492 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
| 2175 | 2493 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
| 2176 | 2494 | $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
@@ -2180,8 +2498,10 @@ discard block |
||
| 2180 | 2498 | '-------------------------------------------------'."\r\n \r\n "; |
| 2181 | 2499 | $this->sessionData['mimeType'] = 'plain'; |
| 2182 | 2500 | |
| 2183 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2184 | - if($i>0) { |
|
| 2501 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 2502 | + { |
|
| 2503 | + if($i>0) |
|
| 2504 | + { |
|
| 2185 | 2505 | $this->sessionData['body'] .= "<hr>"; |
| 2186 | 2506 | } |
| 2187 | 2507 | |
@@ -2192,7 +2512,8 @@ discard block |
||
| 2192 | 2512 | $this->sessionData['body'] .= "\r\n"; |
| 2193 | 2513 | $hasSignature = false; |
| 2194 | 2514 | // create body new, with good line breaks and indention |
| 2195 | - foreach(explode("\n",$newBody) as $value) { |
|
| 2515 | + foreach(explode("\n",$newBody) as $value) |
|
| 2516 | + { |
|
| 2196 | 2517 | // the explode is removing the character |
| 2197 | 2518 | //$value .= 'ee'; |
| 2198 | 2519 | |
@@ -2208,9 +2529,12 @@ discard block |
||
| 2208 | 2529 | |
| 2209 | 2530 | $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
| 2210 | 2531 | |
| 2211 | - if($bodyAppend[0] == '>') { |
|
| 2532 | + if($bodyAppend[0] == '>') |
|
| 2533 | + { |
|
| 2212 | 2534 | $bodyAppend = '>'. $bodyAppend; |
| 2213 | - } else { |
|
| 2535 | + } |
|
| 2536 | + else |
|
| 2537 | + { |
|
| 2214 | 2538 | $bodyAppend = '> '. $bodyAppend; |
| 2215 | 2539 | } |
| 2216 | 2540 | |
@@ -2259,9 +2583,12 @@ discard block |
||
| 2259 | 2583 | |
| 2260 | 2584 | static function _getHostName() |
| 2261 | 2585 | { |
| 2262 | - if (isset($_SERVER['SERVER_NAME'])) { |
|
| 2586 | + if (isset($_SERVER['SERVER_NAME'])) |
|
| 2587 | + { |
|
| 2263 | 2588 | $result = $_SERVER['SERVER_NAME']; |
| 2264 | - } else { |
|
| 2589 | + } |
|
| 2590 | + else |
|
| 2591 | + { |
|
| 2265 | 2592 | $result = 'localhost.localdomain'; |
| 2266 | 2593 | } |
| 2267 | 2594 | return $result; |
@@ -2299,11 +2626,16 @@ discard block |
||
| 2299 | 2626 | |
| 2300 | 2627 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
| 2301 | 2628 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
| 2302 | - if(!empty($_formData['in-reply-to'])) { |
|
| 2303 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2629 | + if(!empty($_formData['in-reply-to'])) |
|
| 2630 | + { |
|
| 2631 | + if (stripos($_formData['in-reply-to'],'<')===false) |
|
| 2632 | + { |
|
| 2633 | + $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2634 | + } |
|
| 2304 | 2635 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
| 2305 | 2636 | } |
| 2306 | - if(!empty($_formData['references'])) { |
|
| 2637 | + if(!empty($_formData['references'])) |
|
| 2638 | + { |
|
| 2307 | 2639 | if (stripos($_formData['references'],'<')===false) |
| 2308 | 2640 | { |
| 2309 | 2641 | $_formData['references']='<'.trim($_formData['references']).'>'; |
@@ -2311,28 +2643,38 @@ discard block |
||
| 2311 | 2643 | $_mailObject->addHeader('References', $_formData['references']); |
| 2312 | 2644 | } |
| 2313 | 2645 | |
| 2314 | - if(!empty($_formData['thread-index'])) { |
|
| 2646 | + if(!empty($_formData['thread-index'])) |
|
| 2647 | + { |
|
| 2315 | 2648 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
| 2316 | 2649 | } |
| 2317 | - if(!empty($_formData['list-id'])) { |
|
| 2650 | + if(!empty($_formData['list-id'])) |
|
| 2651 | + { |
|
| 2318 | 2652 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
| 2319 | 2653 | } |
| 2320 | - if($_formData['disposition']=='on') { |
|
| 2654 | + if($_formData['disposition']=='on') |
|
| 2655 | + { |
|
| 2321 | 2656 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
| 2322 | 2657 | } |
| 2323 | 2658 | |
| 2324 | 2659 | // Expand any mailing lists |
| 2325 | 2660 | foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
| 2326 | 2661 | { |
| 2327 | - if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
| 2662 | + if ($field != 'replyto') |
|
| 2663 | + { |
|
| 2664 | + $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
| 2665 | + } |
|
| 2328 | 2666 | |
| 2329 | - if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field); |
|
| 2667 | + if ($_formData[$field]) |
|
| 2668 | + { |
|
| 2669 | + $_mailObject->addAddress($_formData[$field], '', $field); |
|
| 2670 | + } |
|
| 2330 | 2671 | } |
| 2331 | 2672 | |
| 2332 | 2673 | $_mailObject->addHeader('Subject', $_formData['subject']); |
| 2333 | 2674 | |
| 2334 | 2675 | // this should never happen since we come from the edit dialog |
| 2335 | - if (Mail::detect_qp($_formData['body'])) { |
|
| 2676 | + if (Mail::detect_qp($_formData['body'])) |
|
| 2677 | + { |
|
| 2336 | 2678 | $_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']); |
| 2337 | 2679 | $_formData['body'] = quoted_printable_decode($_formData['body']); |
| 2338 | 2680 | } |
@@ -2385,7 +2727,10 @@ discard block |
||
| 2385 | 2727 | $_mailObject->setBody($this->convertHTMLToText($body, true, true)); |
| 2386 | 2728 | } |
| 2387 | 2729 | // convert URL Images to inline images - if possible |
| 2388 | - if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
| 2730 | + if (!$_autosaving) |
|
| 2731 | + { |
|
| 2732 | + $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
| 2733 | + } |
|
| 2389 | 2734 | if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
| 2390 | 2735 | { |
| 2391 | 2736 | $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
@@ -2400,10 +2745,14 @@ discard block |
||
| 2400 | 2745 | { |
| 2401 | 2746 | $body = $this->convertHTMLToText($_formData['body'],false); |
| 2402 | 2747 | |
| 2403 | - if ($attachment_links) $body .= $attachment_links; |
|
| 2748 | + if ($attachment_links) |
|
| 2749 | + { |
|
| 2750 | + $body .= $attachment_links; |
|
| 2751 | + } |
|
| 2404 | 2752 | |
| 2405 | 2753 | #$_mailObject->Body = $_formData['body']; |
| 2406 | - if(!empty($signature)) { |
|
| 2754 | + if(!empty($signature)) |
|
| 2755 | + { |
|
| 2407 | 2756 | $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
| 2408 | 2757 | $this->convertHTMLToText($signature,true,true); |
| 2409 | 2758 | } |
@@ -2414,10 +2763,12 @@ discard block |
||
| 2414 | 2763 | { |
| 2415 | 2764 | $connection_opened = false; |
| 2416 | 2765 | $tnfattachments = null; |
| 2417 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
| 2766 | + foreach((array)$_formData['attachments'] as $attachment) |
|
| 2767 | + { |
|
| 2418 | 2768 | if(is_array($attachment)) |
| 2419 | 2769 | { |
| 2420 | - if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
|
| 2770 | + if (!empty($attachment['uid']) && !empty($attachment['folder'])) |
|
| 2771 | + { |
|
| 2421 | 2772 | /* Example: |
| 2422 | 2773 | Array([0] => Array( |
| 2423 | 2774 | [uid] => 21178 |
@@ -2433,14 +2784,18 @@ discard block |
||
| 2433 | 2784 | $connection_opened = true; |
| 2434 | 2785 | } |
| 2435 | 2786 | $mail_bo->reopen($attachment['folder']); |
| 2436 | - switch(strtoupper($attachment['type'])) { |
|
| 2787 | + switch(strtoupper($attachment['type'])) |
|
| 2788 | + { |
|
| 2437 | 2789 | case 'MESSAGE/RFC': |
| 2438 | 2790 | case 'MESSAGE/RFC822': |
| 2439 | 2791 | $rawBody=''; |
| 2440 | - if (isset($attachment['partID'])) { |
|
| 2792 | + if (isset($attachment['partID'])) |
|
| 2793 | + { |
|
| 2441 | 2794 | $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
| 2442 | 2795 | $rawBody=$eml['attachment']; |
| 2443 | - } else { |
|
| 2796 | + } |
|
| 2797 | + else |
|
| 2798 | + { |
|
| 2444 | 2799 | $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
| 2445 | 2800 | } |
| 2446 | 2801 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
@@ -2449,7 +2804,10 @@ discard block |
||
| 2449 | 2804 | $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
| 2450 | 2805 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
| 2451 | 2806 | { |
| 2452 | - if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
| 2807 | + if (!is_array($tnfattachments)) |
|
| 2808 | + { |
|
| 2809 | + $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
| 2810 | + } |
|
| 2453 | 2811 | foreach ($tnfattachments as $k) |
| 2454 | 2812 | { |
| 2455 | 2813 | if ($k['name'] == $attachment['name']) |
@@ -2484,7 +2842,10 @@ discard block |
||
| 2484 | 2842 | } |
| 2485 | 2843 | } |
| 2486 | 2844 | } |
| 2487 | - if ($connection_opened) $mail_bo->closeConnection(); |
|
| 2845 | + if ($connection_opened) |
|
| 2846 | + { |
|
| 2847 | + $mail_bo->closeConnection(); |
|
| 2848 | + } |
|
| 2488 | 2849 | } |
| 2489 | 2850 | return is_array($inline_images)?$inline_images:array(); |
| 2490 | 2851 | } |
@@ -2504,13 +2865,20 @@ discard block |
||
| 2504 | 2865 | */ |
| 2505 | 2866 | protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
| 2506 | 2867 | { |
| 2507 | - if ($filemode == Vfs\Sharing::ATTACH) return ''; |
|
| 2868 | + if ($filemode == Vfs\Sharing::ATTACH) |
|
| 2869 | + { |
|
| 2870 | + return ''; |
|
| 2871 | + } |
|
| 2508 | 2872 | |
| 2509 | 2873 | $links = array(); |
| 2510 | 2874 | foreach($attachments as $attachment) |
| 2511 | 2875 | { |
| 2512 | 2876 | $path = $attachment['file']; |
| 2513 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
| 2877 | + if (empty($path)) |
|
| 2878 | + { |
|
| 2879 | + continue; |
|
| 2880 | + } |
|
| 2881 | + // we only care about file attachments, not forwarded messages or parts |
|
| 2514 | 2882 | if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
| 2515 | 2883 | { |
| 2516 | 2884 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path); |
@@ -2613,13 +2981,19 @@ discard block |
||
| 2613 | 2981 | $success = false; |
| 2614 | 2982 | error_log(__METHOD__.__LINE__.$msg); |
| 2615 | 2983 | } |
| 2616 | - } else { |
|
| 2984 | + } |
|
| 2985 | + else |
|
| 2986 | + { |
|
| 2617 | 2987 | error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former'); |
| 2618 | 2988 | } |
| 2619 | - } else { |
|
| 2989 | + } |
|
| 2990 | + else |
|
| 2991 | + { |
|
| 2620 | 2992 | error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)"); |
| 2621 | 2993 | } |
| 2622 | - } else { |
|
| 2994 | + } |
|
| 2995 | + else |
|
| 2996 | + { |
|
| 2623 | 2997 | error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)"); |
| 2624 | 2998 | } |
| 2625 | 2999 | } |
@@ -2635,7 +3009,10 @@ discard block |
||
| 2635 | 3009 | $success = false; |
| 2636 | 3010 | } |
| 2637 | 3011 | |
| 2638 | - if ($success) $msg = lang('Message saved successfully.'); |
|
| 3012 | + if ($success) |
|
| 3013 | + { |
|
| 3014 | + $msg = lang('Message saved successfully.'); |
|
| 3015 | + } |
|
| 2639 | 3016 | |
| 2640 | 3017 | // Include new information to json respose, because we need them in client-side callback |
| 2641 | 3018 | $response->data(array( |
@@ -2659,7 +3036,10 @@ discard block |
||
| 2659 | 3036 | { |
| 2660 | 3037 | if(is_int($address)) |
| 2661 | 3038 | { |
| 2662 | - if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts(); |
|
| 3039 | + if (!isset($contacts_obs)) |
|
| 3040 | + { |
|
| 3041 | + $contacts_obj = new Api\Contacts(); |
|
| 3042 | + } |
|
| 2663 | 3043 | // List was selected, expand to addresses |
| 2664 | 3044 | unset($_emailAddressList[$ak]); |
| 2665 | 3045 | $list = $contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address)); |
@@ -2674,7 +3054,10 @@ discard block |
||
| 2674 | 3054 | { |
| 2675 | 3055 | foreach ($addrFromList as $addr) |
| 2676 | 3056 | { |
| 2677 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
| 3057 | + if (!empty($addr)) |
|
| 3058 | + { |
|
| 3059 | + $_emailAddressList[]=$addr; |
|
| 3060 | + } |
|
| 2678 | 3061 | } |
| 2679 | 3062 | } |
| 2680 | 3063 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2728,7 +3111,10 @@ discard block |
||
| 2728 | 3111 | // decide where to save the message (default to draft folder, if we find nothing else) |
| 2729 | 3112 | // if the current folder is in draft or template folder save it there |
| 2730 | 3113 | // if it is called from printview then save it with the draft folder |
| 2731 | - if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3114 | + if (empty($savingDestination)) |
|
| 3115 | + { |
|
| 3116 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3117 | + } |
|
| 2732 | 3118 | if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) |
| 2733 | 3119 | { |
| 2734 | 3120 | $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; |
@@ -2739,13 +3125,17 @@ discard block |
||
| 2739 | 3125 | $savingDestination = $this->sessionData['messageFolder']; |
| 2740 | 3126 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
| 2741 | 3127 | } |
| 2742 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3128 | + if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) |
|
| 3129 | + { |
|
| 3130 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3131 | + } |
|
| 2743 | 3132 | |
| 2744 | 3133 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
| 2745 | 3134 | $mail->forceBccHeader(); |
| 2746 | 3135 | |
| 2747 | 3136 | $mail_bo->openConnection(); |
| 2748 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
| 3137 | + if ($mail_bo->folderExists($savingDestination,true)) |
|
| 3138 | + { |
|
| 2749 | 3139 | try |
| 2750 | 3140 | { |
| 2751 | 3141 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
@@ -2756,7 +3146,9 @@ discard block |
||
| 2756 | 3146 | return false; |
| 2757 | 3147 | } |
| 2758 | 3148 | |
| 2759 | - } else { |
|
| 3149 | + } |
|
| 3150 | + else |
|
| 3151 | + { |
|
| 2760 | 3152 | error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
| 2761 | 3153 | return false; |
| 2762 | 3154 | } |
@@ -2804,7 +3196,10 @@ discard block |
||
| 2804 | 3196 | $fhA = mail_ui::splitRowID($rowid); |
| 2805 | 3197 | $this->sessionData['uid'][] = $fhA['msgUID']; |
| 2806 | 3198 | $this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
| 2807 | - if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
| 3199 | + if (!empty($fhA['folder'])) |
|
| 3200 | + { |
|
| 3201 | + $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
| 3202 | + } |
|
| 2808 | 3203 | } |
| 2809 | 3204 | } |
| 2810 | 3205 | if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
@@ -2836,7 +3231,8 @@ discard block |
||
| 2836 | 3231 | #error_log($this->sessionData['body']); |
| 2837 | 3232 | } |
| 2838 | 3233 | if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
| 2839 | - empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
|
| 3234 | + empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) |
|
| 3235 | + { |
|
| 2840 | 3236 | $messageIsDraft = true; |
| 2841 | 3237 | } |
| 2842 | 3238 | try |
@@ -2852,7 +3248,11 @@ discard block |
||
| 2852 | 3248 | // create the messages and store inline images |
| 2853 | 3249 | $inline_images = $this->createMessage($mail, $_formData, $identity); |
| 2854 | 3250 | // remember the identity |
| 2855 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 3251 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
| 3252 | + { |
|
| 3253 | + $fromAddress = $mail->From; |
|
| 3254 | + } |
|
| 3255 | + //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 2856 | 3256 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
| 2857 | 3257 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
| 2858 | 3258 | #exit; |
@@ -2865,7 +3265,10 @@ discard block |
||
| 2865 | 3265 | { |
| 2866 | 3266 | $fval=$f; |
| 2867 | 3267 | $icServerID = $_formData['serverID'];//folders always assumed with serverID |
| 2868 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
| 3268 | + if (stripos($f,'::')!==false) |
|
| 3269 | + { |
|
| 3270 | + list($icServerID,$fval) = explode('::',$f,2); |
|
| 3271 | + } |
|
| 2869 | 3272 | if ($_formData['serverID']!=$_formData['mailaccount']) |
| 2870 | 3273 | { |
| 2871 | 3274 | if ($icServerID == $_formData['serverID'] ) |
@@ -2906,13 +3309,19 @@ discard block |
||
| 2906 | 3309 | // sentFolder is account specific |
| 2907 | 3310 | $sentFolder = $this->mail_bo->getSentFolder(); |
| 2908 | 3311 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2909 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 3312 | + if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) |
|
| 3313 | + { |
|
| 3314 | + $sentFolder=false; |
|
| 3315 | + } |
|
| 2910 | 3316 | } |
| 2911 | 3317 | else |
| 2912 | 3318 | { |
| 2913 | 3319 | $sentFolder = $mail_bo->getSentFolder(); |
| 2914 | 3320 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2915 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 3321 | + if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) |
|
| 3322 | + { |
|
| 3323 | + $sentFolder=false; |
|
| 3324 | + } |
|
| 2916 | 3325 | } |
| 2917 | 3326 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2918 | 3327 | |
@@ -2948,19 +3357,30 @@ discard block |
||
| 2948 | 3357 | { |
| 2949 | 3358 | if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
| 2950 | 3359 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
| 2951 | - $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
|
| 3360 | + $sentFolder != 'none')) |
|
| 3361 | + { |
|
| 3362 | + $this->errorInfo = lang("No Send Folder set in preferences"); |
|
| 3363 | + } |
|
| 2952 | 3364 | } |
| 2953 | 3365 | // draftFolder is on Server we start from |
| 2954 | - if($messageIsDraft == true) { |
|
| 3366 | + if($messageIsDraft == true) |
|
| 3367 | + { |
|
| 2955 | 3368 | $draftFolder = $mail_bo->getDraftFolder(); |
| 2956 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
| 3369 | + if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) |
|
| 3370 | + { |
|
| 2957 | 3371 | $this->sessionData['folder'] = array($draftFolder); |
| 2958 | 3372 | $folderOnServerID[] = $draftFolder; |
| 2959 | 3373 | $folder[$draftFolder] = $draftFolder; |
| 2960 | 3374 | } |
| 2961 | 3375 | } |
| 2962 | - if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
|
| 2963 | - if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
| 3376 | + if ($folderOnServerID) |
|
| 3377 | + { |
|
| 3378 | + $folderOnServerID = array_unique($folderOnServerID); |
|
| 3379 | + } |
|
| 3380 | + if ($folderOnMailAccount) |
|
| 3381 | + { |
|
| 3382 | + $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
| 3383 | + } |
|
| 2964 | 3384 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
| 2965 | 3385 | !( count($folder) > 0) && |
| 2966 | 3386 | !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
@@ -2974,7 +3394,8 @@ discard block |
||
| 2974 | 3394 | @set_time_limit(120); |
| 2975 | 3395 | //$mail->SMTPDebug = 10; |
| 2976 | 3396 | //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); |
| 2977 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
| 3397 | + if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) |
|
| 3398 | + { |
|
| 2978 | 3399 | try { |
| 2979 | 3400 | $mail->send(); |
| 2980 | 3401 | } |
@@ -2984,10 +3405,15 @@ discard block |
||
| 2984 | 3405 | $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
| 2985 | 3406 | return false; |
| 2986 | 3407 | } |
| 2987 | - } else { |
|
| 2988 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
| 3408 | + } |
|
| 3409 | + else |
|
| 3410 | + { |
|
| 3411 | + if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) |
|
| 3412 | + { |
|
| 2989 | 3413 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
| 2990 | - } else { |
|
| 3414 | + } |
|
| 3415 | + else |
|
| 3416 | + { |
|
| 2991 | 3417 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
| 2992 | 3418 | //error_log(__METHOD__.__LINE__.$this->errorInfo); |
| 2993 | 3419 | return false; |
@@ -2997,14 +3423,16 @@ discard block |
||
| 2997 | 3423 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
| 2998 | 3424 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
| 2999 | 3425 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
| 3000 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
| 3426 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
| 3427 | + { |
|
| 3001 | 3428 | $mail_bo = $this->mail_bo; |
| 3002 | 3429 | $mail_bo->openConnection(); |
| 3003 | 3430 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
| 3004 | 3431 | #error_log("(re)opened Connection"); |
| 3005 | 3432 | } |
| 3006 | 3433 | // if copying mail to folder, or saving mail to infolog, we need to gather the needed information |
| 3007 | - if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') { |
|
| 3434 | + if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
| 3435 | + { |
|
| 3008 | 3436 | //error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc'])); |
| 3009 | 3437 | |
| 3010 | 3438 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
@@ -3013,17 +3441,28 @@ discard block |
||
| 3013 | 3441 | // copying mail to folder |
| 3014 | 3442 | if (count($folder) > 0) |
| 3015 | 3443 | { |
| 3016 | - foreach($folderOnServerID as $folderName) { |
|
| 3017 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
| 3444 | + foreach($folderOnServerID as $folderName) |
|
| 3445 | + { |
|
| 3446 | + if (is_array($folderName)) |
|
| 3447 | + { |
|
| 3448 | + $folderName = array_shift($folderName); |
|
| 3449 | + } |
|
| 3450 | + // should not happen at all |
|
| 3018 | 3451 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3019 | 3452 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3020 | 3453 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3021 | - if ($mail_bo->folderExists($folderName,true)) { |
|
| 3022 | - if($mail_bo->isSentFolder($folderName)) { |
|
| 3454 | + if ($mail_bo->folderExists($folderName,true)) |
|
| 3455 | + { |
|
| 3456 | + if($mail_bo->isSentFolder($folderName)) |
|
| 3457 | + { |
|
| 3023 | 3458 | $flags = '\\Seen'; |
| 3024 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
| 3459 | + } |
|
| 3460 | + elseif($mail_bo->isDraftFolder($folderName)) |
|
| 3461 | + { |
|
| 3025 | 3462 | $flags = '\\Draft'; |
| 3026 | - } else { |
|
| 3463 | + } |
|
| 3464 | + else |
|
| 3465 | + { |
|
| 3027 | 3466 | $flags = '\\Seen'; |
| 3028 | 3467 | } |
| 3029 | 3468 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3046,18 +3485,32 @@ discard block |
||
| 3046 | 3485 | } |
| 3047 | 3486 | } |
| 3048 | 3487 | // if we choose to send from a differing profile |
| 3049 | - if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
|
| 3050 | - foreach($folderOnMailAccount as $folderName) { |
|
| 3051 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
| 3488 | + if ($folderOnMailAccount) |
|
| 3489 | + { |
|
| 3490 | + $this->changeProfile($_formData['mailaccount']); |
|
| 3491 | + } |
|
| 3492 | + foreach($folderOnMailAccount as $folderName) |
|
| 3493 | + { |
|
| 3494 | + if (is_array($folderName)) |
|
| 3495 | + { |
|
| 3496 | + $folderName = array_shift($folderName); |
|
| 3497 | + } |
|
| 3498 | + // should not happen at all |
|
| 3052 | 3499 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3053 | 3500 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3054 | 3501 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3055 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
| 3056 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
| 3502 | + if ($this->mail_bo->folderExists($folderName,true)) |
|
| 3503 | + { |
|
| 3504 | + if($this->mail_bo->isSentFolder($folderName)) |
|
| 3505 | + { |
|
| 3057 | 3506 | $flags = '\\Seen'; |
| 3058 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
| 3507 | + } |
|
| 3508 | + elseif($this->mail_bo->isDraftFolder($folderName)) |
|
| 3509 | + { |
|
| 3059 | 3510 | $flags = '\\Draft'; |
| 3060 | - } else { |
|
| 3511 | + } |
|
| 3512 | + else |
|
| 3513 | + { |
|
| 3061 | 3514 | $flags = '\\Seen'; |
| 3062 | 3515 | } |
| 3063 | 3516 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3079,7 +3532,10 @@ discard block |
||
| 3079 | 3532 | error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
| 3080 | 3533 | } |
| 3081 | 3534 | } |
| 3082 | - if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
|
| 3535 | + if ($folderOnMailAccount) |
|
| 3536 | + { |
|
| 3537 | + $this->changeProfile($_formData['serverID']); |
|
| 3538 | + } |
|
| 3083 | 3539 | |
| 3084 | 3540 | //$mail_bo->closeConnection(); |
| 3085 | 3541 | } |
@@ -3091,10 +3547,16 @@ discard block |
||
| 3091 | 3547 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
| 3092 | 3548 | $lastDrafted['uid'] = $dhA['msgUID']; |
| 3093 | 3549 | $lastDrafted['folder'] = $dhA['folder']; |
| 3094 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3550 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) |
|
| 3551 | + { |
|
| 3552 | + $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3553 | + } |
|
| 3095 | 3554 | // manually drafted, do not delete |
| 3096 | 3555 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
| 3097 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
| 3556 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) |
|
| 3557 | + { |
|
| 3558 | + $lastDrafted=false; |
|
| 3559 | + } |
|
| 3098 | 3560 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
| 3099 | 3561 | } |
| 3100 | 3562 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
@@ -3120,7 +3582,8 @@ discard block |
||
| 3120 | 3582 | |
| 3121 | 3583 | //error_log("handling draft messages, flagging and such"); |
| 3122 | 3584 | if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
| 3123 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
| 3585 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
| 3586 | + { |
|
| 3124 | 3587 | // mark message as answered |
| 3125 | 3588 | $mail_bo->openConnection(); |
| 3126 | 3589 | $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
@@ -3142,7 +3605,9 @@ discard block |
||
| 3142 | 3605 | //error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage())); |
| 3143 | 3606 | unset($e); |
| 3144 | 3607 | } |
| 3145 | - } else { |
|
| 3608 | + } |
|
| 3609 | + else |
|
| 3610 | + { |
|
| 3146 | 3611 | $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
| 3147 | 3612 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
| 3148 | 3613 | if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
@@ -3161,7 +3626,10 @@ discard block |
||
| 3161 | 3626 | } |
| 3162 | 3627 | //$mail_bo->closeConnection(); |
| 3163 | 3628 | } |
| 3164 | - if ($mail_bo) $mail_bo->closeConnection(); |
|
| 3629 | + if ($mail_bo) |
|
| 3630 | + { |
|
| 3631 | + $mail_bo->closeConnection(); |
|
| 3632 | + } |
|
| 3165 | 3633 | //error_log("performing Infolog Stuff"); |
| 3166 | 3634 | //error_log(print_r($this->sessionData['to'],true)); |
| 3167 | 3635 | //error_log(print_r($this->sessionData['cc'],true)); |
@@ -3174,9 +3642,18 @@ discard block |
||
| 3174 | 3642 | { |
| 3175 | 3643 | $mailaddresses = array(); |
| 3176 | 3644 | } |
| 3177 | - if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc']; |
|
| 3178 | - if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
| 3179 | - if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
| 3645 | + if (is_array($this->sessionData['cc'])) |
|
| 3646 | + { |
|
| 3647 | + $mailaddresses['cc'] = $this->sessionData['cc']; |
|
| 3648 | + } |
|
| 3649 | + if (is_array($this->sessionData['bcc'])) |
|
| 3650 | + { |
|
| 3651 | + $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
| 3652 | + } |
|
| 3653 | + if (!empty($mailaddresses)) |
|
| 3654 | + { |
|
| 3655 | + $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
| 3656 | + } |
|
| 3180 | 3657 | |
| 3181 | 3658 | if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
| 3182 | 3659 | { |
@@ -3208,7 +3685,10 @@ discard block |
||
| 3208 | 3685 | $_formData['serverID']),true), |
| 3209 | 3686 | 'app' => $app_name |
| 3210 | 3687 | ); |
| 3211 | - if ($entryid) $target['entry_id'] = $entryid; |
|
| 3688 | + if ($entryid) |
|
| 3689 | + { |
|
| 3690 | + $target['entry_id'] = $entryid; |
|
| 3691 | + } |
|
| 3212 | 3692 | // Open the app called for integration in a popup |
| 3213 | 3693 | // and store the mail raw data as egw_data, in order to |
| 3214 | 3694 | // be stored from registered app method later |
@@ -3219,8 +3699,11 @@ discard block |
||
| 3219 | 3699 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
| 3220 | 3700 | elseif(is_array($this->sessionData['attachments'])) |
| 3221 | 3701 | { |
| 3222 | - foreach($this->sessionData['attachments'] as $value) { |
|
| 3223 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
| 3702 | + foreach($this->sessionData['attachments'] as $value) |
|
| 3703 | + { |
|
| 3704 | + if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') |
|
| 3705 | + { |
|
| 3706 | +// happens when forwarding mails |
|
| 3224 | 3707 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
| 3225 | 3708 | } |
| 3226 | 3709 | } |
@@ -3257,7 +3740,10 @@ discard block |
||
| 3257 | 3740 | $default_identity = null; |
| 3258 | 3741 | foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
| 3259 | 3742 | { |
| 3260 | - if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
|
| 3743 | + if (!isset($default_identity)) |
|
| 3744 | + { |
|
| 3745 | + $default_identity = $identity['ident_id']; |
|
| 3746 | + } |
|
| 3261 | 3747 | if (!empty($identity['ident_signature'])) |
| 3262 | 3748 | { |
| 3263 | 3749 | $content['mailidentity'] = $identity['ident_id']; |
@@ -3265,12 +3751,18 @@ discard block |
||
| 3265 | 3751 | } |
| 3266 | 3752 | } |
| 3267 | 3753 | } |
| 3268 | - if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity; |
|
| 3754 | + if (empty($content['mailidentity'])) |
|
| 3755 | + { |
|
| 3756 | + $content['mailidentity'] = $default_identity; |
|
| 3757 | + } |
|
| 3269 | 3758 | } |
| 3270 | 3759 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
| 3271 | 3760 | { |
| 3272 | 3761 | $content['mimeType'] = 'html'; |
| 3273 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
| 3762 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") |
|
| 3763 | + { |
|
| 3764 | + $content['mimeType'] = 'plain'; |
|
| 3765 | + } |
|
| 3274 | 3766 | } |
| 3275 | 3767 | return $content; |
| 3276 | 3768 | |
@@ -3278,9 +3770,12 @@ discard block |
||
| 3278 | 3770 | |
| 3279 | 3771 | function stripSlashes($_string) |
| 3280 | 3772 | { |
| 3281 | - if (get_magic_quotes_gpc()) { |
|
| 3773 | + if (get_magic_quotes_gpc()) |
|
| 3774 | + { |
|
| 3282 | 3775 | return stripslashes($_string); |
| 3283 | - } else { |
|
| 3776 | + } |
|
| 3777 | + else |
|
| 3778 | + { |
|
| 3284 | 3779 | return $_string; |
| 3285 | 3780 | } |
| 3286 | 3781 | } |
@@ -3293,15 +3788,25 @@ discard block |
||
| 3293 | 3788 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
| 3294 | 3789 | * @return type |
| 3295 | 3790 | */ |
| 3296 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
| 3791 | + function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
|
| 3792 | + { |
|
| 3297 | 3793 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
| 3298 | 3794 | static $useCacheIfPossible = null; |
| 3299 | - if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
|
| 3795 | + if (is_null($useCacheIfPossible)) |
|
| 3796 | + { |
|
| 3797 | + $useCacheIfPossible = true; |
|
| 3798 | + } |
|
| 3300 | 3799 | $_searchString = trim($_REQUEST['query']); |
| 3301 | 3800 | $results = array(); |
| 3302 | 3801 | $rememberServerID = $this->mail_bo->icServer->ImapServerId; |
| 3303 | - if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
| 3304 | - if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
| 3802 | + if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) |
|
| 3803 | + { |
|
| 3804 | + $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
| 3805 | + } |
|
| 3806 | + if (empty($_mailaccountToSearch)) |
|
| 3807 | + { |
|
| 3808 | + $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
| 3809 | + } |
|
| 3305 | 3810 | if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch) |
| 3306 | 3811 | { |
| 3307 | 3812 | $this->changeProfile($_mailaccountToSearch); |
@@ -3312,7 +3817,8 @@ discard block |
||
| 3312 | 3817 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
| 3313 | 3818 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
| 3314 | 3819 | $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
| 3315 | - if (count($folderObjects)<=1) { |
|
| 3820 | + if (count($folderObjects)<=1) |
|
| 3821 | + { |
|
| 3316 | 3822 | $useCacheIfPossible = false; |
| 3317 | 3823 | } |
| 3318 | 3824 | else |
@@ -3363,7 +3869,8 @@ discard block |
||
| 3363 | 3869 | exit(); |
| 3364 | 3870 | } |
| 3365 | 3871 | |
| 3366 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
| 3872 | + public static function ajax_searchAddress($_searchStringLength=2) |
|
| 3873 | + { |
|
| 3367 | 3874 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
| 3368 | 3875 | $_searchString = trim($_REQUEST['query']); |
| 3369 | 3876 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3376,7 +3883,8 @@ discard block |
||
| 3376 | 3883 | { |
| 3377 | 3884 | $lists = array_filter( |
| 3378 | 3885 | $contacts_obj->get_lists(Acl::READ), |
| 3379 | - function($element) use($_searchString) { |
|
| 3886 | + function($element) use($_searchString) |
|
| 3887 | + { |
|
| 3380 | 3888 | return (stripos($element, $_searchString) !== false); |
| 3381 | 3889 | } |
| 3382 | 3890 | ); |
@@ -3391,7 +3899,10 @@ discard block |
||
| 3391 | 3899 | 'title' => lang('Mailinglist'), |
| 3392 | 3900 | 'data' => $key |
| 3393 | 3901 | ); |
| 3394 | - if($list_count++ > 5) break; |
|
| 3902 | + if($list_count++ > 5) |
|
| 3903 | + { |
|
| 3904 | + break; |
|
| 3905 | + } |
|
| 3395 | 3906 | } |
| 3396 | 3907 | } |
| 3397 | 3908 | |
@@ -3402,7 +3913,10 @@ discard block |
||
| 3402 | 3913 | $search = explode(' ', $_searchString); |
| 3403 | 3914 | foreach ($search as $k => $v) |
| 3404 | 3915 | { |
| 3405 | - if (mb_strlen($v) < 3) unset($search[$k]); |
|
| 3916 | + if (mb_strlen($v) < 3) |
|
| 3917 | + { |
|
| 3918 | + unset($search[$k]); |
|
| 3919 | + } |
|
| 3406 | 3920 | } |
| 3407 | 3921 | $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
| 3408 | 3922 | //error_log(__METHOD__.__LINE__.$_searchString); |
@@ -3432,9 +3946,12 @@ discard block |
||
| 3432 | 3946 | } |
| 3433 | 3947 | } |
| 3434 | 3948 | |
| 3435 | - if(is_array($contacts)) { |
|
| 3436 | - foreach($contacts as $contact) { |
|
| 3437 | - foreach(array($contact['email'],$contact['email_home']) as $email) { |
|
| 3949 | + if(is_array($contacts)) |
|
| 3950 | + { |
|
| 3951 | + foreach($contacts as $contact) |
|
| 3952 | + { |
|
| 3953 | + foreach(array($contact['email'],$contact['email_home']) as $email) |
|
| 3954 | + { |
|
| 3438 | 3955 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 3439 | 3956 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
| 3440 | 3957 | $rfcAddr = Mail::parseAddressList($email); |
@@ -3448,10 +3965,22 @@ discard block |
||
| 3448 | 3965 | if (method_exists($contacts_obj,'search')) |
| 3449 | 3966 | { |
| 3450 | 3967 | $contact['n_fn']=''; |
| 3451 | - if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
|
| 3452 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3453 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3454 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3968 | + if (!empty($contact['n_prefix'])) |
|
| 3969 | + { |
|
| 3970 | + $contact['n_fn'] = $contact['n_prefix']; |
|
| 3971 | + } |
|
| 3972 | + if (!empty($contact['n_given'])) |
|
| 3973 | + { |
|
| 3974 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3975 | + } |
|
| 3976 | + if (!empty($contact['n_family'])) |
|
| 3977 | + { |
|
| 3978 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3979 | + } |
|
| 3980 | + if (!empty($contact['org_name'])) |
|
| 3981 | + { |
|
| 3982 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3983 | + } |
|
| 3455 | 3984 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
| 3456 | 3985 | } |
| 3457 | 3986 | else |
@@ -3461,7 +3990,8 @@ discard block |
||
| 3461 | 3990 | $args = explode('@', trim($email)); |
| 3462 | 3991 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
| 3463 | 3992 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
| 3464 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
| 3993 | + if(!empty($email) && in_array($completeMailString ,$results) === false) |
|
| 3994 | + { |
|
| 3465 | 3995 | $results[] = array( |
| 3466 | 3996 | 'id'=>$completeMailString, |
| 3467 | 3997 | 'label' => $completeMailString, |
@@ -3480,7 +4010,10 @@ discard block |
||
| 3480 | 4010 | foreach($groups as $g_id => $name) |
| 3481 | 4011 | { |
| 3482 | 4012 | $group = $GLOBALS['egw']->accounts->read($g_id); |
| 3483 | - if(!$group['account_email']) continue; |
|
| 4013 | + if(!$group['account_email']) |
|
| 4014 | + { |
|
| 4015 | + continue; |
|
| 4016 | + } |
|
| 3484 | 4017 | $args = explode('@', trim($group['account_email'])); |
| 3485 | 4018 | $args[] = $name; |
| 3486 | 4019 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |