@@ -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 | } |
@@ -1108,24 +1223,33 @@ discard block |
||
| 1108 | 1223 | $disableRuler = true; |
| 1109 | 1224 | } |
| 1110 | 1225 | $font_span = $font_part = ''; |
| 1111 | - if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
| 1226 | + if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) |
|
| 1227 | + { |
|
| 1112 | 1228 | // User preferences for style |
| 1113 | 1229 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
| 1114 | 1230 | $font_size = Api\Html\CkEditorConfig::font_size_from_prefs(); |
| 1115 | 1231 | $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
| 1116 | 1232 | $font_span = $font_part.'​</span>'; |
| 1117 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
| 1233 | + if (empty($font) && empty($font_size)) |
|
| 1234 | + { |
|
| 1235 | + $font_span = ''; |
|
| 1236 | + } |
|
| 1118 | 1237 | } |
| 1119 | 1238 | // 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 |
| 1120 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
| 1239 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) |
|
| 1240 | + { |
|
| 1241 | + $font_span = ''; |
|
| 1242 | + } |
|
| 1121 | 1243 | //remove possible html header stuff |
| 1122 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1244 | + if (stripos($content['body'],'<html><head></head><body>')!==false) |
|
| 1245 | + { |
|
| 1246 | + $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1247 | + } |
|
| 1123 | 1248 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
| 1124 | 1249 | $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'); |
| 1125 | 1250 | if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
| 1126 | 1251 | !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
| 1127 | - ) |
|
| 1128 | - { |
|
| 1252 | + ) { |
|
| 1129 | 1253 | // ON tOP OR BELOW? pREF CAN TELL |
| 1130 | 1254 | /* |
| 1131 | 1255 | Signature behavior preference changed. New default, if not set -> 0 |
@@ -1140,14 +1264,23 @@ discard block |
||
| 1140 | 1264 | $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
| 1141 | 1265 | foreach($blockElements as $e) |
| 1142 | 1266 | { |
| 1143 | - if ($sigTextStartsWithBlockElement) break; |
|
| 1144 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
| 1267 | + if ($sigTextStartsWithBlockElement) |
|
| 1268 | + { |
|
| 1269 | + break; |
|
| 1270 | + } |
|
| 1271 | + if (stripos(trim($sigText),'<'.$e)===0) |
|
| 1272 | + { |
|
| 1273 | + $sigTextStartsWithBlockElement = true; |
|
| 1274 | + } |
|
| 1145 | 1275 | } |
| 1146 | 1276 | } |
| 1147 | - if($content['mimeType'] == 'html') { |
|
| 1277 | + if($content['mimeType'] == 'html') |
|
| 1278 | + { |
|
| 1148 | 1279 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
| 1149 | 1280 | $inbetween = ''; |
| 1150 | - } else { |
|
| 1281 | + } |
|
| 1282 | + else |
|
| 1283 | + { |
|
| 1151 | 1284 | $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 1152 | 1285 | $inbetween = "\r\n"; |
| 1153 | 1286 | } |
@@ -1181,7 +1314,10 @@ discard block |
||
| 1181 | 1314 | foreach(Mail\Account::search(true,false) as $acc_id => $account) |
| 1182 | 1315 | { |
| 1183 | 1316 | // do NOT add SMTP only accounts as identities |
| 1184 | - if (!$account->is_imap(false)) continue; |
|
| 1317 | + if (!$account->is_imap(false)) |
|
| 1318 | + { |
|
| 1319 | + continue; |
|
| 1320 | + } |
|
| 1185 | 1321 | |
| 1186 | 1322 | foreach($account->identities($acc_id) as $ident_id => $identity) |
| 1187 | 1323 | { |
@@ -1194,16 +1330,24 @@ discard block |
||
| 1194 | 1330 | //$content['bcc'] = array('[email protected]','[email protected]'); |
| 1195 | 1331 | // address stuff like from, to, cc, replyto |
| 1196 | 1332 | $destinationRows = 0; |
| 1197 | - foreach(self::$destinations as $destination) { |
|
| 1333 | + foreach(self::$destinations as $destination) |
|
| 1334 | + { |
|
| 1198 | 1335 | if (!is_array($content[$destination])) |
| 1199 | 1336 | { |
| 1200 | - if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
|
| 1337 | + if (!empty($content[$destination])) |
|
| 1338 | + { |
|
| 1339 | + $content[$destination] = (array)$content[$destination]; |
|
| 1340 | + } |
|
| 1201 | 1341 | } |
| 1202 | 1342 | $addr_content = $content[strtolower($destination)]; |
| 1203 | 1343 | // we clear the given address array and rebuild it |
| 1204 | 1344 | unset($content[strtolower($destination)]); |
| 1205 | - foreach((array)$addr_content as $key => $value) { |
|
| 1206 | - if ($value=="NIL@NIL") continue; |
|
| 1345 | + foreach((array)$addr_content as $key => $value) |
|
| 1346 | + { |
|
| 1347 | + if ($value=="NIL@NIL") |
|
| 1348 | + { |
|
| 1349 | + continue; |
|
| 1350 | + } |
|
| 1207 | 1351 | if ($destination=='replyto' && str_replace('"','',$value) == |
| 1208 | 1352 | str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()])) |
| 1209 | 1353 | { |
@@ -1213,8 +1357,12 @@ discard block |
||
| 1213 | 1357 | } |
| 1214 | 1358 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
| 1215 | 1359 | $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
| 1216 | - foreach(Mail::parseAddressList($value) as $addressObject) { |
|
| 1217 | - if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
|
| 1360 | + foreach(Mail::parseAddressList($value) as $addressObject) |
|
| 1361 | + { |
|
| 1362 | + if ($addressObject->host == '.SYNTAX-ERROR.') |
|
| 1363 | + { |
|
| 1364 | + continue; |
|
| 1365 | + } |
|
| 1218 | 1366 | $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
| 1219 | 1367 | //$address = Mail::htmlentities($address, $this->displayCharset); |
| 1220 | 1368 | $content[strtolower($destination)][]=$address; |
@@ -1225,11 +1373,20 @@ discard block |
||
| 1225 | 1373 | if ($_content) |
| 1226 | 1374 | { |
| 1227 | 1375 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
| 1228 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
| 1376 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) |
|
| 1377 | + { |
|
| 1378 | + unset($_content['mailidentity']); |
|
| 1379 | + } |
|
| 1229 | 1380 | $content = array_merge($content,$_content); |
| 1230 | 1381 | |
| 1231 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1232 | - if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
|
| 1382 | + if (!empty($content['folder'])) |
|
| 1383 | + { |
|
| 1384 | + $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1385 | + } |
|
| 1386 | + if (empty($content['mailaccount'])) |
|
| 1387 | + { |
|
| 1388 | + $content['mailaccount'] = $this->mail_bo->profileID; |
|
| 1389 | + } |
|
| 1233 | 1390 | } |
| 1234 | 1391 | else |
| 1235 | 1392 | { |
@@ -1272,11 +1429,17 @@ discard block |
||
| 1272 | 1429 | //error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']); |
| 1273 | 1430 | $preserv['is_html'] = $content['is_html']; |
| 1274 | 1431 | $preserv['is_plain'] = $content['is_plain']; |
| 1275 | - if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType']; |
|
| 1432 | + if (isset($content['mimeType'])) |
|
| 1433 | + { |
|
| 1434 | + $preserv['mimeType'] = $content['mimeType']; |
|
| 1435 | + } |
|
| 1276 | 1436 | $sel_options['mimeType'] = self::$mimeTypes; |
| 1277 | 1437 | $sel_options['priority'] = self::$priorities; |
| 1278 | 1438 | $sel_options['filemode'] = Vfs\Sharing::$modes; |
| 1279 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
| 1439 | + if (!isset($content['priority']) || empty($content['priority'])) |
|
| 1440 | + { |
|
| 1441 | + $content['priority']=3; |
|
| 1442 | + } |
|
| 1280 | 1443 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 1281 | 1444 | $etpl = new Etemplate('mail.compose'); |
| 1282 | 1445 | |
@@ -1323,9 +1486,12 @@ discard block |
||
| 1323 | 1486 | $preserv['list-id'] = $content['list-id']; |
| 1324 | 1487 | $preserv['mode'] = $content['mode']; |
| 1325 | 1488 | // convert it back to checkbox expectations |
| 1326 | - if($content['mimeType'] == 'html') { |
|
| 1489 | + if($content['mimeType'] == 'html') |
|
| 1490 | + { |
|
| 1327 | 1491 | $content['mimeType']=1; |
| 1328 | - } else { |
|
| 1492 | + } |
|
| 1493 | + else |
|
| 1494 | + { |
|
| 1329 | 1495 | $content['mimeType']=0; |
| 1330 | 1496 | } |
| 1331 | 1497 | // set the current selected mailaccount as param for folderselection |
@@ -1336,7 +1502,10 @@ discard block |
||
| 1336 | 1502 | // Resolve distribution list before send content to client |
| 1337 | 1503 | foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
| 1338 | 1504 | { |
| 1339 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1505 | + if (is_array($content[$f])) |
|
| 1506 | + { |
|
| 1507 | + $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1508 | + } |
|
| 1340 | 1509 | } |
| 1341 | 1510 | |
| 1342 | 1511 | $content['to'] = self::resolveEmailAddressList($content['to']); |
@@ -1384,7 +1553,10 @@ discard block |
||
| 1384 | 1553 | case 'composefromdraft': |
| 1385 | 1554 | case 'composeasnew': |
| 1386 | 1555 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
| 1387 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
| 1556 | + if ($from =='composefromdraft') |
|
| 1557 | + { |
|
| 1558 | + $content['mode'] = 'composefromdraft'; |
|
| 1559 | + } |
|
| 1388 | 1560 | $content['processedmail_id'] = $mail_id; |
| 1389 | 1561 | |
| 1390 | 1562 | $_focusElement = 'body'; |
@@ -1432,7 +1604,10 @@ discard block |
||
| 1432 | 1604 | $document_merge = new $merge_class(); |
| 1433 | 1605 | $this->mail_bo->openConnection(); |
| 1434 | 1606 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
| 1435 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
| 1607 | + if (!is_array($merge_ids)) |
|
| 1608 | + { |
|
| 1609 | + $merge_ids = explode(',',$merge_ids); |
|
| 1610 | + } |
|
| 1436 | 1611 | try |
| 1437 | 1612 | { |
| 1438 | 1613 | $merged_mail_id = ''; |
@@ -1463,7 +1638,10 @@ discard block |
||
| 1463 | 1638 | { |
| 1464 | 1639 | $success = implode(', ',$results['success']); |
| 1465 | 1640 | $fail = implode(', ', $results['failed']); |
| 1466 | - if($success) Framework::message($success, 'success'); |
|
| 1641 | + if($success) |
|
| 1642 | + { |
|
| 1643 | + Framework::message($success, 'success'); |
|
| 1644 | + } |
|
| 1467 | 1645 | Framework::window_close($fail); |
| 1468 | 1646 | } |
| 1469 | 1647 | } |
@@ -1495,17 +1673,25 @@ discard block |
||
| 1495 | 1673 | { |
| 1496 | 1674 | $stripalltags = true; |
| 1497 | 1675 | // third param is stripalltags, we may not need that, if the source is already in ascii |
| 1498 | - if (!$sourceishtml) $stripalltags=false; |
|
| 1676 | + if (!$sourceishtml) |
|
| 1677 | + { |
|
| 1678 | + $stripalltags=false; |
|
| 1679 | + } |
|
| 1499 | 1680 | return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags); |
| 1500 | 1681 | } |
| 1501 | 1682 | |
| 1502 | 1683 | function generateRFC822Address($_addressObject) |
| 1503 | 1684 | { |
| 1504 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
| 1685 | + if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) |
|
| 1686 | + { |
|
| 1505 | 1687 | return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
| 1506 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
| 1688 | + } |
|
| 1689 | + elseif($_addressObject->mailbox && $_addressObject->host) |
|
| 1690 | + { |
|
| 1507 | 1691 | return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
| 1508 | - } else { |
|
| 1692 | + } |
|
| 1693 | + else |
|
| 1694 | + { |
|
| 1509 | 1695 | return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
| 1510 | 1696 | } |
| 1511 | 1697 | } |
@@ -1539,16 +1725,28 @@ discard block |
||
| 1539 | 1725 | //if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC']; |
| 1540 | 1726 | |
| 1541 | 1727 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
| 1542 | - if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
|
| 1543 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
| 1728 | + if (!empty($addHeadInfo['X-MAILFOLDER'])) |
|
| 1729 | + { |
|
| 1730 | + foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) |
|
| 1731 | + { |
|
| 1544 | 1732 | $fval=$val; |
| 1545 | 1733 | $icServerID = $mail_bo->icServer->ImapServerId; |
| 1546 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
| 1547 | - if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
|
| 1548 | - if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
|
| 1734 | + if (stripos($val,'::')!==false) |
|
| 1735 | + { |
|
| 1736 | + list($icServerID,$fval) = explode('::',$val,2); |
|
| 1737 | + } |
|
| 1738 | + if ($icServerID != $mail_bo->icServer->ImapServerId) |
|
| 1739 | + { |
|
| 1740 | + continue; |
|
| 1741 | + } |
|
| 1742 | + if ($mail_bo->folderExists($fval)) |
|
| 1743 | + { |
|
| 1744 | + $this->sessionData['folder'][] = $val; |
|
| 1745 | + } |
|
| 1549 | 1746 | } |
| 1550 | 1747 | } |
| 1551 | - if (!empty($addHeadInfo['X-MAILIDENTITY'])) { |
|
| 1748 | + if (!empty($addHeadInfo['X-MAILIDENTITY'])) |
|
| 1749 | + { |
|
| 1552 | 1750 | // with the new system it would be the identity |
| 1553 | 1751 | try |
| 1554 | 1752 | { |
@@ -1564,7 +1762,8 @@ discard block |
||
| 1564 | 1762 | $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; |
| 1565 | 1763 | } |
| 1566 | 1764 | */ |
| 1567 | - if (!empty($addHeadInfo['X-MAILACCOUNT'])) { |
|
| 1765 | + if (!empty($addHeadInfo['X-MAILACCOUNT'])) |
|
| 1766 | + { |
|
| 1568 | 1767 | // with the new system it would the identity is the account id |
| 1569 | 1768 | try |
| 1570 | 1769 | { |
@@ -1579,27 +1778,38 @@ discard block |
||
| 1579 | 1778 | } |
| 1580 | 1779 | } |
| 1581 | 1780 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
| 1582 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1781 | + if ($mail_bo->isDraftFolder($_folder)) |
|
| 1782 | + { |
|
| 1783 | + $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); |
|
| 1784 | + } |
|
| 1785 | + //array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1583 | 1786 | $this->sessionData['uid'] = $_uid; |
| 1584 | 1787 | $this->sessionData['messageFolder'] = $_folder; |
| 1585 | 1788 | $this->sessionData['isDraft'] = true; |
| 1586 | 1789 | $foundAddresses = array(); |
| 1587 | - foreach((array)$headers['CC'] as $val) { |
|
| 1790 | + foreach((array)$headers['CC'] as $val) |
|
| 1791 | + { |
|
| 1588 | 1792 | $rfcAddr=Mail::parseAddressList($val); |
| 1589 | 1793 | $_rfcAddr = $rfcAddr[0]; |
| 1590 | - if (!$_rfcAddr->valid) continue; |
|
| 1591 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1794 | + if (!$_rfcAddr->valid) |
|
| 1795 | + { |
|
| 1796 | + continue; |
|
| 1797 | + } |
|
| 1798 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
| 1799 | + { |
|
| 1592 | 1800 | continue; |
| 1593 | 1801 | } |
| 1594 | 1802 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1595 | - if(!$foundAddresses[$keyemail]) { |
|
| 1803 | + if(!$foundAddresses[$keyemail]) |
|
| 1804 | + { |
|
| 1596 | 1805 | $address = $this->mail_bo->decode_header($val,true); |
| 1597 | 1806 | $this->sessionData['cc'][] = $val; |
| 1598 | 1807 | $foundAddresses[$keyemail] = true; |
| 1599 | 1808 | } |
| 1600 | 1809 | } |
| 1601 | 1810 | |
| 1602 | - foreach((array)$headers['TO'] as $val) { |
|
| 1811 | + foreach((array)$headers['TO'] as $val) |
|
| 1812 | + { |
|
| 1603 | 1813 | if(!is_array($val)) |
| 1604 | 1814 | { |
| 1605 | 1815 | $this->sessionData['to'][] = $val; |
@@ -1607,42 +1817,59 @@ discard block |
||
| 1607 | 1817 | } |
| 1608 | 1818 | $rfcAddr=Mail::parseAddressList($val); |
| 1609 | 1819 | $_rfcAddr = $rfcAddr[0]; |
| 1610 | - if (!$_rfcAddr->valid) continue; |
|
| 1611 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1820 | + if (!$_rfcAddr->valid) |
|
| 1821 | + { |
|
| 1822 | + continue; |
|
| 1823 | + } |
|
| 1824 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
| 1825 | + { |
|
| 1612 | 1826 | continue; |
| 1613 | 1827 | } |
| 1614 | 1828 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1615 | - if(!$foundAddresses[$keyemail]) { |
|
| 1829 | + if(!$foundAddresses[$keyemail]) |
|
| 1830 | + { |
|
| 1616 | 1831 | $address = $this->mail_bo->decode_header($val,true); |
| 1617 | 1832 | $this->sessionData['to'][] = $val; |
| 1618 | 1833 | $foundAddresses[$keyemail] = true; |
| 1619 | 1834 | } |
| 1620 | 1835 | } |
| 1621 | 1836 | |
| 1622 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
| 1837 | + foreach((array)$headers['REPLY-TO'] as $val) |
|
| 1838 | + { |
|
| 1623 | 1839 | $rfcAddr=Mail::parseAddressList($val); |
| 1624 | 1840 | $_rfcAddr = $rfcAddr[0]; |
| 1625 | - if (!$_rfcAddr->valid) continue; |
|
| 1626 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1841 | + if (!$_rfcAddr->valid) |
|
| 1842 | + { |
|
| 1843 | + continue; |
|
| 1844 | + } |
|
| 1845 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
| 1846 | + { |
|
| 1627 | 1847 | continue; |
| 1628 | 1848 | } |
| 1629 | 1849 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1630 | - if(!$foundAddresses[$keyemail]) { |
|
| 1850 | + if(!$foundAddresses[$keyemail]) |
|
| 1851 | + { |
|
| 1631 | 1852 | $address = $this->mail_bo->decode_header($val,true); |
| 1632 | 1853 | $this->sessionData['replyto'][] = $val; |
| 1633 | 1854 | $foundAddresses[$keyemail] = true; |
| 1634 | 1855 | } |
| 1635 | 1856 | } |
| 1636 | 1857 | |
| 1637 | - foreach((array)$headers['BCC'] as $val) { |
|
| 1858 | + foreach((array)$headers['BCC'] as $val) |
|
| 1859 | + { |
|
| 1638 | 1860 | $rfcAddr=Mail::parseAddressList($val); |
| 1639 | 1861 | $_rfcAddr = $rfcAddr[0]; |
| 1640 | - if (!$_rfcAddr->valid) continue; |
|
| 1641 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1862 | + if (!$_rfcAddr->valid) |
|
| 1863 | + { |
|
| 1864 | + continue; |
|
| 1865 | + } |
|
| 1866 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
| 1867 | + { |
|
| 1642 | 1868 | continue; |
| 1643 | 1869 | } |
| 1644 | 1870 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1645 | - if(!$foundAddresses[$keyemail]) { |
|
| 1871 | + if(!$foundAddresses[$keyemail]) |
|
| 1872 | + { |
|
| 1646 | 1873 | $address = $this->mail_bo->decode_header($val,true); |
| 1647 | 1874 | $this->sessionData['bcc'][] = $val; |
| 1648 | 1875 | $foundAddresses[$keyemail] = true; |
@@ -1656,32 +1883,46 @@ discard block |
||
| 1656 | 1883 | $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
| 1657 | 1884 | //_debug_array($bodyParts); |
| 1658 | 1885 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
| 1659 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 1886 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
| 1887 | + { |
|
| 1660 | 1888 | $this->sessionData['mimeType'] = 'html'; |
| 1661 | 1889 | |
| 1662 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1663 | - if($i>0) { |
|
| 1890 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 1891 | + { |
|
| 1892 | + if($i>0) |
|
| 1893 | + { |
|
| 1664 | 1894 | $this->sessionData['body'] .= '<hr>'; |
| 1665 | 1895 | } |
| 1666 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 1896 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
| 1897 | + { |
|
| 1667 | 1898 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
| 1668 | 1899 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 1669 | 1900 | } |
| 1670 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1901 | + if ($bodyParts[$i]['charSet']===false) |
|
| 1902 | + { |
|
| 1903 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1904 | + } |
|
| 1671 | 1905 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1672 | 1906 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1673 | 1907 | $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
| 1674 | 1908 | } |
| 1675 | 1909 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
| 1676 | 1910 | |
| 1677 | - } else { |
|
| 1911 | + } |
|
| 1912 | + else |
|
| 1913 | + { |
|
| 1678 | 1914 | $this->sessionData['mimeType'] = 'plain'; |
| 1679 | 1915 | |
| 1680 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1681 | - if($i>0) { |
|
| 1916 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 1917 | + { |
|
| 1918 | + if($i>0) |
|
| 1919 | + { |
|
| 1682 | 1920 | $this->sessionData['body'] .= "<hr>"; |
| 1683 | 1921 | } |
| 1684 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1922 | + if ($bodyParts[$i]['charSet']===false) |
|
| 1923 | + { |
|
| 1924 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1925 | + } |
|
| 1685 | 1926 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1686 | 1927 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1687 | 1928 | $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
@@ -1689,8 +1930,10 @@ discard block |
||
| 1689 | 1930 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
| 1690 | 1931 | } |
| 1691 | 1932 | |
| 1692 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
| 1693 | - foreach($attachments as $attachment) { |
|
| 1933 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) |
|
| 1934 | + { |
|
| 1935 | + foreach($attachments as $attachment) |
|
| 1936 | + { |
|
| 1694 | 1937 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 1695 | 1938 | $cid = $attachment['cid']; |
| 1696 | 1939 | $match=null; |
@@ -1713,7 +1956,8 @@ discard block |
||
| 1713 | 1956 | |
| 1714 | 1957 | function getErrorInfo() |
| 1715 | 1958 | { |
| 1716 | - if(isset($this->errorInfo)) { |
|
| 1959 | + if(isset($this->errorInfo)) |
|
| 1960 | + { |
|
| 1717 | 1961 | $errorInfo = $this->errorInfo; |
| 1718 | 1962 | unset($this->errorInfo); |
| 1719 | 1963 | return $errorInfo; |
@@ -1728,7 +1972,8 @@ discard block |
||
| 1728 | 1972 | $modebuff = $this->mailPreferences['message_forwarding']; |
| 1729 | 1973 | $this->mailPreferences['message_forwarding'] = $_mode; |
| 1730 | 1974 | } |
| 1731 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
| 1975 | + if ($this->mailPreferences['message_forwarding'] == 'inline') |
|
| 1976 | + { |
|
| 1732 | 1977 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
| 1733 | 1978 | } |
| 1734 | 1979 | $mail_bo = $this->mail_bo; |
@@ -1745,12 +1990,16 @@ discard block |
||
| 1745 | 1990 | //$this->sessionData['sourceFolder']=$_folder; |
| 1746 | 1991 | //$this->sessionData['forwardFlag']='forwarded'; |
| 1747 | 1992 | //$this->sessionData['forwardedUID']=$_uid; |
| 1748 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
| 1993 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') |
|
| 1994 | + { |
|
| 1749 | 1995 | $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
| 1750 | 1996 | if($headers['SIZE']) |
| 1751 | - $size = $headers['SIZE']; |
|
| 1752 | - else |
|
| 1753 | - $size = lang('unknown'); |
|
| 1997 | + { |
|
| 1998 | + $size = $headers['SIZE']; |
|
| 1999 | + } |
|
| 2000 | + else { |
|
| 2001 | + $size = lang('unknown'); |
|
| 2002 | + } |
|
| 1754 | 2003 | |
| 1755 | 2004 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
| 1756 | 2005 | $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
@@ -1761,9 +2010,11 @@ discard block |
||
| 1761 | 2010 | unset($this->sessionData['in-reply-to']); |
| 1762 | 2011 | unset($this->sessionData['to']); |
| 1763 | 2012 | unset($this->sessionData['cc']); |
| 1764 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) { |
|
| 2013 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) |
|
| 2014 | + { |
|
| 1765 | 2015 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
| 1766 | - foreach($attachments as $attachment) { |
|
| 2016 | + foreach($attachments as $attachment) |
|
| 2017 | + { |
|
| 1767 | 2018 | if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
| 1768 | 2019 | { |
| 1769 | 2020 | $this->addMessageAttachment($_uid, $attachment['partID'], |
@@ -1819,7 +2070,10 @@ discard block |
||
| 1819 | 2070 | { |
| 1820 | 2071 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
| 1821 | 2072 | strtolower($_formData['type'])== strtolower($attach['type']) && |
| 1822 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
| 2073 | + stripos($_formData['file'],'vfs://') !== false) |
|
| 2074 | + { |
|
| 2075 | + return; |
|
| 2076 | + } |
|
| 1823 | 2077 | } |
| 1824 | 2078 | } |
| 1825 | 2079 | if ($attachfailed === false) |
@@ -1831,7 +2085,10 @@ discard block |
||
| 1831 | 2085 | 'tmp_name' => $tmpFileName, |
| 1832 | 2086 | 'size' => $_formData['size'] |
| 1833 | 2087 | ); |
| 1834 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
| 2088 | + if (!is_array($_content['attachments'])) |
|
| 2089 | + { |
|
| 2090 | + $_content['attachments']=array(); |
|
| 2091 | + } |
|
| 1835 | 2092 | $_content['attachments'][] = $buffer; |
| 1836 | 2093 | unset($buffer); |
| 1837 | 2094 | } |
@@ -1862,7 +2119,10 @@ discard block |
||
| 1862 | 2119 | { |
| 1863 | 2120 | foreach($request->preserv['attachments'] as $attachment) |
| 1864 | 2121 | { |
| 1865 | - if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
|
| 2122 | + if ($_GET['tmpname'] === $attachment['tmp_name']) |
|
| 2123 | + { |
|
| 2124 | + break; |
|
| 2125 | + } |
|
| 1866 | 2126 | } |
| 1867 | 2127 | } |
| 1868 | 2128 | if (!$request || $_GET['tmpname'] !== $attachment['tmp_name']) |
@@ -1896,10 +2156,20 @@ discard block |
||
| 1896 | 2156 | $sfxMimeType = $attachment['type']; |
| 1897 | 2157 | $buff = explode('.',$attachment['tmp_name']); |
| 1898 | 2158 | $suffix = ''; |
| 1899 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 1900 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2159 | + if (is_array($buff)) |
|
| 2160 | + { |
|
| 2161 | + $suffix = array_pop($buff); |
|
| 2162 | + } |
|
| 2163 | + // take the last extension to check with ext2mime |
|
| 2164 | + if (!empty($suffix)) |
|
| 2165 | + { |
|
| 2166 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2167 | + } |
|
| 1901 | 2168 | $attachment['type'] = $sfxMimeType; |
| 1902 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2169 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
| 2170 | + { |
|
| 2171 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2172 | + } |
|
| 1903 | 2173 | } |
| 1904 | 2174 | //error_log(__METHOD__.print_r($attachment,true)); |
| 1905 | 2175 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -1908,7 +2178,10 @@ discard block |
||
| 1908 | 2178 | $calendar_ical = new calendar_ical(); |
| 1909 | 2179 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
| 1910 | 2180 | //error_log(__METHOD__.array2string($eventid)); |
| 1911 | - if (!$eventid) $eventid = -1; |
|
| 2181 | + if (!$eventid) |
|
| 2182 | + { |
|
| 2183 | + $eventid = -1; |
|
| 2184 | + } |
|
| 1912 | 2185 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
| 1913 | 2186 | //error_log(__METHOD__.$event); |
| 1914 | 2187 | if ((int)$event > 0) |
@@ -1934,7 +2207,10 @@ discard block |
||
| 1934 | 2207 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 1935 | 2208 | $contact = $addressbook_vcal->find_contact($vcard,false); |
| 1936 | 2209 | } |
| 1937 | - if (!$contact) $contact = null; |
|
| 2210 | + if (!$contact) |
|
| 2211 | + { |
|
| 2212 | + $contact = null; |
|
| 2213 | + } |
|
| 1938 | 2214 | // 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)) |
| 1939 | 2215 | if ($contact || count($vcard)>2) |
| 1940 | 2216 | { |
@@ -1965,7 +2241,8 @@ discard block |
||
| 1965 | 2241 | * @param string haystack |
| 1966 | 2242 | * @return boolean |
| 1967 | 2243 | */ |
| 1968 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
| 2244 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) |
|
| 2245 | + { |
|
| 1969 | 2246 | foreach (array_keys($arrayToTestAgainst) as $k) |
| 1970 | 2247 | { |
| 1971 | 2248 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
@@ -2022,21 +2299,34 @@ discard block |
||
| 2022 | 2299 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
| 2023 | 2300 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
| 2024 | 2301 | //if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC']; |
| 2025 | - if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
| 2026 | - if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
| 2302 | + if ($headers['THREAD-INDEX']) |
|
| 2303 | + { |
|
| 2304 | + $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
| 2305 | + } |
|
| 2306 | + if ($headers['LIST-ID']) |
|
| 2307 | + { |
|
| 2308 | + $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
| 2309 | + } |
|
| 2027 | 2310 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
| 2028 | 2311 | // check for Reply-To: header and use if available |
| 2029 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
| 2030 | - foreach($headers['REPLY-TO'] as $val) { |
|
| 2031 | - if(!$foundAddresses[$val]) { |
|
| 2312 | + if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) |
|
| 2313 | + { |
|
| 2314 | + foreach($headers['REPLY-TO'] as $val) |
|
| 2315 | + { |
|
| 2316 | + if(!$foundAddresses[$val]) |
|
| 2317 | + { |
|
| 2032 | 2318 | $oldTo[] = $val; |
| 2033 | 2319 | $foundAddresses[$val] = true; |
| 2034 | 2320 | } |
| 2035 | 2321 | } |
| 2036 | 2322 | $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
| 2037 | - } else { |
|
| 2038 | - foreach($headers['FROM'] as $val) { |
|
| 2039 | - if(!$foundAddresses[$val]) { |
|
| 2323 | + } |
|
| 2324 | + else |
|
| 2325 | + { |
|
| 2326 | + foreach($headers['FROM'] as $val) |
|
| 2327 | + { |
|
| 2328 | + if(!$foundAddresses[$val]) |
|
| 2329 | + { |
|
| 2040 | 2330 | $oldTo[] = $val; |
| 2041 | 2331 | $foundAddresses[$val] = true; |
| 2042 | 2332 | } |
@@ -2044,18 +2334,23 @@ discard block |
||
| 2044 | 2334 | $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
| 2045 | 2335 | } |
| 2046 | 2336 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
| 2047 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
| 2337 | + if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) |
|
| 2338 | + { |
|
| 2048 | 2339 | $this->sessionData['to'] = $oldTo; |
| 2049 | 2340 | } |
| 2050 | 2341 | |
| 2051 | - if($_mode == 'all') { |
|
| 2342 | + if($_mode == 'all') |
|
| 2343 | + { |
|
| 2052 | 2344 | // reply to any address which is cc, but not to my self |
| 2053 | 2345 | #if($headers->cc) { |
| 2054 | - foreach($headers['CC'] as $val) { |
|
| 2055 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2346 | + foreach($headers['CC'] as $val) |
|
| 2347 | + { |
|
| 2348 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2349 | + { |
|
| 2056 | 2350 | continue; |
| 2057 | 2351 | } |
| 2058 | - if(!$foundAddresses[$val]) { |
|
| 2352 | + if(!$foundAddresses[$val]) |
|
| 2353 | + { |
|
| 2059 | 2354 | $this->sessionData['cc'][] = $val; |
| 2060 | 2355 | $foundAddresses[$val] = true; |
| 2061 | 2356 | } |
@@ -2064,11 +2359,14 @@ discard block |
||
| 2064 | 2359 | |
| 2065 | 2360 | // reply to any address which is to, but not to my self |
| 2066 | 2361 | #if($headers->to) { |
| 2067 | - foreach($headers['TO'] as $val) { |
|
| 2068 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2362 | + foreach($headers['TO'] as $val) |
|
| 2363 | + { |
|
| 2364 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2365 | + { |
|
| 2069 | 2366 | continue; |
| 2070 | 2367 | } |
| 2071 | - if(!$foundAddresses[$val]) { |
|
| 2368 | + if(!$foundAddresses[$val]) |
|
| 2369 | + { |
|
| 2072 | 2370 | $this->sessionData['to'][] = $val; |
| 2073 | 2371 | $foundAddresses[$val] = true; |
| 2074 | 2372 | } |
@@ -2076,12 +2374,15 @@ discard block |
||
| 2076 | 2374 | #} |
| 2077 | 2375 | |
| 2078 | 2376 | #if($headers->from) { |
| 2079 | - foreach($headers['FROM'] as $val) { |
|
| 2080 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2377 | + foreach($headers['FROM'] as $val) |
|
| 2378 | + { |
|
| 2379 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2380 | + { |
|
| 2081 | 2381 | continue; |
| 2082 | 2382 | } |
| 2083 | 2383 | //error_log(__METHOD__.__LINE__.' '.$val); |
| 2084 | - if(!$foundAddresses[$val]) { |
|
| 2384 | + if(!$foundAddresses[$val]) |
|
| 2385 | + { |
|
| 2085 | 2386 | $this->sessionData['to'][] = $val; |
| 2086 | 2387 | $foundAddresses[$val] = true; |
| 2087 | 2388 | } |
@@ -2090,9 +2391,12 @@ discard block |
||
| 2090 | 2391 | } |
| 2091 | 2392 | |
| 2092 | 2393 | // check for Re: in subject header |
| 2093 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
| 2394 | + if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") |
|
| 2395 | + { |
|
| 2094 | 2396 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
| 2095 | - } else { |
|
| 2397 | + } |
|
| 2398 | + else |
|
| 2399 | + { |
|
| 2096 | 2400 | $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
| 2097 | 2401 | } |
| 2098 | 2402 | |
@@ -2106,7 +2410,8 @@ discard block |
||
| 2106 | 2410 | |
| 2107 | 2411 | $toAddressA = array(); |
| 2108 | 2412 | $toAddress = ''; |
| 2109 | - foreach ($headers['TO'] as $mailheader) { |
|
| 2413 | + foreach ($headers['TO'] as $mailheader) |
|
| 2414 | + { |
|
| 2110 | 2415 | $toAddressA[] = $mailheader; |
| 2111 | 2416 | } |
| 2112 | 2417 | if (count($toAddressA)>0) |
@@ -2116,7 +2421,8 @@ discard block |
||
| 2116 | 2421 | } |
| 2117 | 2422 | $ccAddressA = array(); |
| 2118 | 2423 | $ccAddress = ''; |
| 2119 | - foreach ($headers['CC'] as $mailheader) { |
|
| 2424 | + foreach ($headers['CC'] as $mailheader) |
|
| 2425 | + { |
|
| 2120 | 2426 | $ccAddressA[] = $mailheader; |
| 2121 | 2427 | } |
| 2122 | 2428 | if (count($ccAddressA)>0) |
@@ -2124,25 +2430,35 @@ discard block |
||
| 2124 | 2430 | $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
| 2125 | 2431 | $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
| 2126 | 2432 | } |
| 2127 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 2433 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
| 2434 | + { |
|
| 2128 | 2435 | $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
| 2129 | 2436 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
| 2130 | 2437 | $toAddress.$ccAddress. |
| 2131 | 2438 | @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>". |
| 2132 | 2439 | '----------------------------------------------------------'."</div>"; |
| 2133 | 2440 | $this->sessionData['mimeType'] = 'html'; |
| 2134 | - if (!empty($styles)) $this->sessionData['body'] .= $styles; |
|
| 2441 | + if (!empty($styles)) |
|
| 2442 | + { |
|
| 2443 | + $this->sessionData['body'] .= $styles; |
|
| 2444 | + } |
|
| 2135 | 2445 | $this->sessionData['body'] .= '<blockquote type="cite">'; |
| 2136 | 2446 | |
| 2137 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2138 | - if($i>0) { |
|
| 2447 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 2448 | + { |
|
| 2449 | + if($i>0) |
|
| 2450 | + { |
|
| 2139 | 2451 | $this->sessionData['body'] .= '<hr>'; |
| 2140 | 2452 | } |
| 2141 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 2453 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
| 2454 | + { |
|
| 2142 | 2455 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
| 2143 | 2456 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 2144 | 2457 | } |
| 2145 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2458 | + if ($bodyParts[$i]['charSet']===false) |
|
| 2459 | + { |
|
| 2460 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2461 | + } |
|
| 2146 | 2462 | |
| 2147 | 2463 | $_htmlConfig = Mail::$htmLawed_config; |
| 2148 | 2464 | Mail::$htmLawed_config['comment'] = 2; |
@@ -2154,7 +2470,9 @@ discard block |
||
| 2154 | 2470 | |
| 2155 | 2471 | $this->sessionData['body'] .= '</blockquote><br>'; |
| 2156 | 2472 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
| 2157 | - } else { |
|
| 2473 | + } |
|
| 2474 | + else |
|
| 2475 | + { |
|
| 2158 | 2476 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
| 2159 | 2477 | // 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) |
| 2160 | 2478 | $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
@@ -2164,8 +2482,10 @@ discard block |
||
| 2164 | 2482 | '-------------------------------------------------'."\r\n \r\n "; |
| 2165 | 2483 | $this->sessionData['mimeType'] = 'plain'; |
| 2166 | 2484 | |
| 2167 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2168 | - if($i>0) { |
|
| 2485 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 2486 | + { |
|
| 2487 | + if($i>0) |
|
| 2488 | + { |
|
| 2169 | 2489 | $this->sessionData['body'] .= "<hr>"; |
| 2170 | 2490 | } |
| 2171 | 2491 | |
@@ -2175,9 +2495,11 @@ discard block |
||
| 2175 | 2495 | $newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain'); |
| 2176 | 2496 | $this->sessionData['body'] .= "\r\n"; |
| 2177 | 2497 | // create body new, with good line breaks and indention |
| 2178 | - foreach(explode("\n",$newBody) as $value) { |
|
| 2498 | + foreach(explode("\n",$newBody) as $value) |
|
| 2499 | + { |
|
| 2179 | 2500 | // the explode is removing the character |
| 2180 | - if (trim($value) != '') { |
|
| 2501 | + if (trim($value) != '') |
|
| 2502 | + { |
|
| 2181 | 2503 | #if ($value != "\r") $value .= "\n"; |
| 2182 | 2504 | } |
| 2183 | 2505 | $numberOfChars = strspn(trim($value), ">"); |
@@ -2185,9 +2507,12 @@ discard block |
||
| 2185 | 2507 | |
| 2186 | 2508 | $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
| 2187 | 2509 | |
| 2188 | - if($bodyAppend[0] == '>') { |
|
| 2510 | + if($bodyAppend[0] == '>') |
|
| 2511 | + { |
|
| 2189 | 2512 | $bodyAppend = '>'. $bodyAppend; |
| 2190 | - } else { |
|
| 2513 | + } |
|
| 2514 | + else |
|
| 2515 | + { |
|
| 2191 | 2516 | $bodyAppend = '> '. $bodyAppend; |
| 2192 | 2517 | } |
| 2193 | 2518 | |
@@ -2236,9 +2561,12 @@ discard block |
||
| 2236 | 2561 | |
| 2237 | 2562 | static function _getHostName() |
| 2238 | 2563 | { |
| 2239 | - if (isset($_SERVER['SERVER_NAME'])) { |
|
| 2564 | + if (isset($_SERVER['SERVER_NAME'])) |
|
| 2565 | + { |
|
| 2240 | 2566 | $result = $_SERVER['SERVER_NAME']; |
| 2241 | - } else { |
|
| 2567 | + } |
|
| 2568 | + else |
|
| 2569 | + { |
|
| 2242 | 2570 | $result = 'localhost.localdomain'; |
| 2243 | 2571 | } |
| 2244 | 2572 | return $result; |
@@ -2276,11 +2604,16 @@ discard block |
||
| 2276 | 2604 | |
| 2277 | 2605 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
| 2278 | 2606 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
| 2279 | - if(!empty($_formData['in-reply-to'])) { |
|
| 2280 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2607 | + if(!empty($_formData['in-reply-to'])) |
|
| 2608 | + { |
|
| 2609 | + if (stripos($_formData['in-reply-to'],'<')===false) |
|
| 2610 | + { |
|
| 2611 | + $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2612 | + } |
|
| 2281 | 2613 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
| 2282 | 2614 | } |
| 2283 | - if(!empty($_formData['references'])) { |
|
| 2615 | + if(!empty($_formData['references'])) |
|
| 2616 | + { |
|
| 2284 | 2617 | if (stripos($_formData['references'],'<')===false) |
| 2285 | 2618 | { |
| 2286 | 2619 | $_formData['references']='<'.trim($_formData['references']).'>'; |
@@ -2288,28 +2621,38 @@ discard block |
||
| 2288 | 2621 | $_mailObject->addHeader('References', $_formData['references']); |
| 2289 | 2622 | } |
| 2290 | 2623 | |
| 2291 | - if(!empty($_formData['thread-index'])) { |
|
| 2624 | + if(!empty($_formData['thread-index'])) |
|
| 2625 | + { |
|
| 2292 | 2626 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
| 2293 | 2627 | } |
| 2294 | - if(!empty($_formData['list-id'])) { |
|
| 2628 | + if(!empty($_formData['list-id'])) |
|
| 2629 | + { |
|
| 2295 | 2630 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
| 2296 | 2631 | } |
| 2297 | - if($_formData['disposition']=='on') { |
|
| 2632 | + if($_formData['disposition']=='on') |
|
| 2633 | + { |
|
| 2298 | 2634 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
| 2299 | 2635 | } |
| 2300 | 2636 | |
| 2301 | 2637 | // Expand any mailing lists |
| 2302 | 2638 | foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
| 2303 | 2639 | { |
| 2304 | - if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
| 2640 | + if ($field != 'replyto') |
|
| 2641 | + { |
|
| 2642 | + $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
| 2643 | + } |
|
| 2305 | 2644 | |
| 2306 | - if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field); |
|
| 2645 | + if ($_formData[$field]) |
|
| 2646 | + { |
|
| 2647 | + $_mailObject->addAddress($_formData[$field], '', $field); |
|
| 2648 | + } |
|
| 2307 | 2649 | } |
| 2308 | 2650 | |
| 2309 | 2651 | $_mailObject->addHeader('Subject', $_formData['subject']); |
| 2310 | 2652 | |
| 2311 | 2653 | // this should never happen since we come from the edit dialog |
| 2312 | - if (Mail::detect_qp($_formData['body'])) { |
|
| 2654 | + if (Mail::detect_qp($_formData['body'])) |
|
| 2655 | + { |
|
| 2313 | 2656 | $_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']); |
| 2314 | 2657 | $_formData['body'] = quoted_printable_decode($_formData['body']); |
| 2315 | 2658 | } |
@@ -2362,7 +2705,10 @@ discard block |
||
| 2362 | 2705 | $_mailObject->setBody($this->convertHTMLToText($body, true, true)); |
| 2363 | 2706 | } |
| 2364 | 2707 | // convert URL Images to inline images - if possible |
| 2365 | - if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
| 2708 | + if (!$_autosaving) |
|
| 2709 | + { |
|
| 2710 | + $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
| 2711 | + } |
|
| 2366 | 2712 | if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
| 2367 | 2713 | { |
| 2368 | 2714 | $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
@@ -2377,10 +2723,14 @@ discard block |
||
| 2377 | 2723 | { |
| 2378 | 2724 | $body = $this->convertHTMLToText($_formData['body'],false); |
| 2379 | 2725 | |
| 2380 | - if ($attachment_links) $body .= $attachment_links; |
|
| 2726 | + if ($attachment_links) |
|
| 2727 | + { |
|
| 2728 | + $body .= $attachment_links; |
|
| 2729 | + } |
|
| 2381 | 2730 | |
| 2382 | 2731 | #$_mailObject->Body = $_formData['body']; |
| 2383 | - if(!empty($signature)) { |
|
| 2732 | + if(!empty($signature)) |
|
| 2733 | + { |
|
| 2384 | 2734 | $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
| 2385 | 2735 | $this->convertHTMLToText($signature,true,true); |
| 2386 | 2736 | } |
@@ -2391,10 +2741,12 @@ discard block |
||
| 2391 | 2741 | { |
| 2392 | 2742 | $connection_opened = false; |
| 2393 | 2743 | $tnfattachments = null; |
| 2394 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
| 2744 | + foreach((array)$_formData['attachments'] as $attachment) |
|
| 2745 | + { |
|
| 2395 | 2746 | if(is_array($attachment)) |
| 2396 | 2747 | { |
| 2397 | - if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
|
| 2748 | + if (!empty($attachment['uid']) && !empty($attachment['folder'])) |
|
| 2749 | + { |
|
| 2398 | 2750 | /* Example: |
| 2399 | 2751 | Array([0] => Array( |
| 2400 | 2752 | [uid] => 21178 |
@@ -2410,14 +2762,18 @@ discard block |
||
| 2410 | 2762 | $connection_opened = true; |
| 2411 | 2763 | } |
| 2412 | 2764 | $mail_bo->reopen($attachment['folder']); |
| 2413 | - switch(strtoupper($attachment['type'])) { |
|
| 2765 | + switch(strtoupper($attachment['type'])) |
|
| 2766 | + { |
|
| 2414 | 2767 | case 'MESSAGE/RFC': |
| 2415 | 2768 | case 'MESSAGE/RFC822': |
| 2416 | 2769 | $rawBody=''; |
| 2417 | - if (isset($attachment['partID'])) { |
|
| 2770 | + if (isset($attachment['partID'])) |
|
| 2771 | + { |
|
| 2418 | 2772 | $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
| 2419 | 2773 | $rawBody=$eml['attachment']; |
| 2420 | - } else { |
|
| 2774 | + } |
|
| 2775 | + else |
|
| 2776 | + { |
|
| 2421 | 2777 | $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
| 2422 | 2778 | } |
| 2423 | 2779 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
@@ -2426,7 +2782,10 @@ discard block |
||
| 2426 | 2782 | $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
| 2427 | 2783 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
| 2428 | 2784 | { |
| 2429 | - if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
| 2785 | + if (!is_array($tnfattachments)) |
|
| 2786 | + { |
|
| 2787 | + $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
| 2788 | + } |
|
| 2430 | 2789 | foreach ($tnfattachments as $k) |
| 2431 | 2790 | { |
| 2432 | 2791 | if ($k['name'] == $attachment['name']) |
@@ -2461,7 +2820,10 @@ discard block |
||
| 2461 | 2820 | } |
| 2462 | 2821 | } |
| 2463 | 2822 | } |
| 2464 | - if ($connection_opened) $mail_bo->closeConnection(); |
|
| 2823 | + if ($connection_opened) |
|
| 2824 | + { |
|
| 2825 | + $mail_bo->closeConnection(); |
|
| 2826 | + } |
|
| 2465 | 2827 | } |
| 2466 | 2828 | return is_array($inline_images)?$inline_images:array(); |
| 2467 | 2829 | } |
@@ -2481,13 +2843,20 @@ discard block |
||
| 2481 | 2843 | */ |
| 2482 | 2844 | protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
| 2483 | 2845 | { |
| 2484 | - if ($filemode == Vfs\Sharing::ATTACH) return ''; |
|
| 2846 | + if ($filemode == Vfs\Sharing::ATTACH) |
|
| 2847 | + { |
|
| 2848 | + return ''; |
|
| 2849 | + } |
|
| 2485 | 2850 | |
| 2486 | 2851 | $links = array(); |
| 2487 | 2852 | foreach($attachments as $attachment) |
| 2488 | 2853 | { |
| 2489 | 2854 | $path = $attachment['file']; |
| 2490 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
| 2855 | + if (empty($path)) |
|
| 2856 | + { |
|
| 2857 | + continue; |
|
| 2858 | + } |
|
| 2859 | + // we only care about file attachments, not forwarded messages or parts |
|
| 2491 | 2860 | if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
| 2492 | 2861 | { |
| 2493 | 2862 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path); |
@@ -2590,13 +2959,19 @@ discard block |
||
| 2590 | 2959 | $success = false; |
| 2591 | 2960 | error_log(__METHOD__.__LINE__.$msg); |
| 2592 | 2961 | } |
| 2593 | - } else { |
|
| 2962 | + } |
|
| 2963 | + else |
|
| 2964 | + { |
|
| 2594 | 2965 | error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former'); |
| 2595 | 2966 | } |
| 2596 | - } else { |
|
| 2967 | + } |
|
| 2968 | + else |
|
| 2969 | + { |
|
| 2597 | 2970 | error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)"); |
| 2598 | 2971 | } |
| 2599 | - } else { |
|
| 2972 | + } |
|
| 2973 | + else |
|
| 2974 | + { |
|
| 2600 | 2975 | error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)"); |
| 2601 | 2976 | } |
| 2602 | 2977 | } |
@@ -2612,7 +2987,10 @@ discard block |
||
| 2612 | 2987 | $success = false; |
| 2613 | 2988 | } |
| 2614 | 2989 | |
| 2615 | - if ($success) $msg = lang('Message saved successfully.'); |
|
| 2990 | + if ($success) |
|
| 2991 | + { |
|
| 2992 | + $msg = lang('Message saved successfully.'); |
|
| 2993 | + } |
|
| 2616 | 2994 | |
| 2617 | 2995 | // Include new information to json respose, because we need them in client-side callback |
| 2618 | 2996 | $response->data(array( |
@@ -2636,7 +3014,10 @@ discard block |
||
| 2636 | 3014 | { |
| 2637 | 3015 | if(is_int($address)) |
| 2638 | 3016 | { |
| 2639 | - if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts(); |
|
| 3017 | + if (!isset($contacts_obs)) |
|
| 3018 | + { |
|
| 3019 | + $contacts_obj = new Api\Contacts(); |
|
| 3020 | + } |
|
| 2640 | 3021 | // List was selected, expand to addresses |
| 2641 | 3022 | unset($_emailAddressList[$ak]); |
| 2642 | 3023 | $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)); |
@@ -2651,7 +3032,10 @@ discard block |
||
| 2651 | 3032 | { |
| 2652 | 3033 | foreach ($addrFromList as $addr) |
| 2653 | 3034 | { |
| 2654 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
| 3035 | + if (!empty($addr)) |
|
| 3036 | + { |
|
| 3037 | + $_emailAddressList[]=$addr; |
|
| 3038 | + } |
|
| 2655 | 3039 | } |
| 2656 | 3040 | } |
| 2657 | 3041 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2705,7 +3089,10 @@ discard block |
||
| 2705 | 3089 | // decide where to save the message (default to draft folder, if we find nothing else) |
| 2706 | 3090 | // if the current folder is in draft or template folder save it there |
| 2707 | 3091 | // if it is called from printview then save it with the draft folder |
| 2708 | - if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3092 | + if (empty($savingDestination)) |
|
| 3093 | + { |
|
| 3094 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3095 | + } |
|
| 2709 | 3096 | if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) |
| 2710 | 3097 | { |
| 2711 | 3098 | $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; |
@@ -2716,13 +3103,17 @@ discard block |
||
| 2716 | 3103 | $savingDestination = $this->sessionData['messageFolder']; |
| 2717 | 3104 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
| 2718 | 3105 | } |
| 2719 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3106 | + if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) |
|
| 3107 | + { |
|
| 3108 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3109 | + } |
|
| 2720 | 3110 | |
| 2721 | 3111 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
| 2722 | 3112 | $mail->forceBccHeader(); |
| 2723 | 3113 | |
| 2724 | 3114 | $mail_bo->openConnection(); |
| 2725 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
| 3115 | + if ($mail_bo->folderExists($savingDestination,true)) |
|
| 3116 | + { |
|
| 2726 | 3117 | try |
| 2727 | 3118 | { |
| 2728 | 3119 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
@@ -2733,7 +3124,9 @@ discard block |
||
| 2733 | 3124 | return false; |
| 2734 | 3125 | } |
| 2735 | 3126 | |
| 2736 | - } else { |
|
| 3127 | + } |
|
| 3128 | + else |
|
| 3129 | + { |
|
| 2737 | 3130 | error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
| 2738 | 3131 | return false; |
| 2739 | 3132 | } |
@@ -2781,7 +3174,10 @@ discard block |
||
| 2781 | 3174 | $fhA = mail_ui::splitRowID($rowid); |
| 2782 | 3175 | $this->sessionData['uid'][] = $fhA['msgUID']; |
| 2783 | 3176 | $this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
| 2784 | - if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
| 3177 | + if (!empty($fhA['folder'])) |
|
| 3178 | + { |
|
| 3179 | + $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
| 3180 | + } |
|
| 2785 | 3181 | } |
| 2786 | 3182 | } |
| 2787 | 3183 | if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
@@ -2813,7 +3209,8 @@ discard block |
||
| 2813 | 3209 | #error_log($this->sessionData['body']); |
| 2814 | 3210 | } |
| 2815 | 3211 | if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
| 2816 | - empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
|
| 3212 | + empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) |
|
| 3213 | + { |
|
| 2817 | 3214 | $messageIsDraft = true; |
| 2818 | 3215 | } |
| 2819 | 3216 | try |
@@ -2829,7 +3226,11 @@ discard block |
||
| 2829 | 3226 | // create the messages and store inline images |
| 2830 | 3227 | $inline_images = $this->createMessage($mail, $_formData, $identity); |
| 2831 | 3228 | // remember the identity |
| 2832 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 3229 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
| 3230 | + { |
|
| 3231 | + $fromAddress = $mail->From; |
|
| 3232 | + } |
|
| 3233 | + //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 2833 | 3234 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
| 2834 | 3235 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
| 2835 | 3236 | #exit; |
@@ -2842,7 +3243,10 @@ discard block |
||
| 2842 | 3243 | { |
| 2843 | 3244 | $fval=$f; |
| 2844 | 3245 | $icServerID = $_formData['serverID'];//folders always assumed with serverID |
| 2845 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
| 3246 | + if (stripos($f,'::')!==false) |
|
| 3247 | + { |
|
| 3248 | + list($icServerID,$fval) = explode('::',$f,2); |
|
| 3249 | + } |
|
| 2846 | 3250 | if ($_formData['serverID']!=$_formData['mailaccount']) |
| 2847 | 3251 | { |
| 2848 | 3252 | if ($icServerID == $_formData['serverID'] ) |
@@ -2883,13 +3287,19 @@ discard block |
||
| 2883 | 3287 | // sentFolder is account specific |
| 2884 | 3288 | $sentFolder = $this->mail_bo->getSentFolder(); |
| 2885 | 3289 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2886 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 3290 | + if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) |
|
| 3291 | + { |
|
| 3292 | + $sentFolder=false; |
|
| 3293 | + } |
|
| 2887 | 3294 | } |
| 2888 | 3295 | else |
| 2889 | 3296 | { |
| 2890 | 3297 | $sentFolder = $mail_bo->getSentFolder(); |
| 2891 | 3298 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2892 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 3299 | + if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) |
|
| 3300 | + { |
|
| 3301 | + $sentFolder=false; |
|
| 3302 | + } |
|
| 2893 | 3303 | } |
| 2894 | 3304 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2895 | 3305 | |
@@ -2925,19 +3335,30 @@ discard block |
||
| 2925 | 3335 | { |
| 2926 | 3336 | if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
| 2927 | 3337 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
| 2928 | - $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
|
| 3338 | + $sentFolder != 'none')) |
|
| 3339 | + { |
|
| 3340 | + $this->errorInfo = lang("No Send Folder set in preferences"); |
|
| 3341 | + } |
|
| 2929 | 3342 | } |
| 2930 | 3343 | // draftFolder is on Server we start from |
| 2931 | - if($messageIsDraft == true) { |
|
| 3344 | + if($messageIsDraft == true) |
|
| 3345 | + { |
|
| 2932 | 3346 | $draftFolder = $mail_bo->getDraftFolder(); |
| 2933 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
| 3347 | + if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) |
|
| 3348 | + { |
|
| 2934 | 3349 | $this->sessionData['folder'] = array($draftFolder); |
| 2935 | 3350 | $folderOnServerID[] = $draftFolder; |
| 2936 | 3351 | $folder[$draftFolder] = $draftFolder; |
| 2937 | 3352 | } |
| 2938 | 3353 | } |
| 2939 | - if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
|
| 2940 | - if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
| 3354 | + if ($folderOnServerID) |
|
| 3355 | + { |
|
| 3356 | + $folderOnServerID = array_unique($folderOnServerID); |
|
| 3357 | + } |
|
| 3358 | + if ($folderOnMailAccount) |
|
| 3359 | + { |
|
| 3360 | + $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
| 3361 | + } |
|
| 2941 | 3362 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
| 2942 | 3363 | !( count($folder) > 0) && |
| 2943 | 3364 | !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
@@ -2951,7 +3372,8 @@ discard block |
||
| 2951 | 3372 | @set_time_limit(120); |
| 2952 | 3373 | //$mail->SMTPDebug = 10; |
| 2953 | 3374 | //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'])); |
| 2954 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
| 3375 | + if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) |
|
| 3376 | + { |
|
| 2955 | 3377 | try { |
| 2956 | 3378 | $mail->send(); |
| 2957 | 3379 | } |
@@ -2961,10 +3383,15 @@ discard block |
||
| 2961 | 3383 | $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
| 2962 | 3384 | return false; |
| 2963 | 3385 | } |
| 2964 | - } else { |
|
| 2965 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
| 3386 | + } |
|
| 3387 | + else |
|
| 3388 | + { |
|
| 3389 | + if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) |
|
| 3390 | + { |
|
| 2966 | 3391 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
| 2967 | - } else { |
|
| 3392 | + } |
|
| 3393 | + else |
|
| 3394 | + { |
|
| 2968 | 3395 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
| 2969 | 3396 | //error_log(__METHOD__.__LINE__.$this->errorInfo); |
| 2970 | 3397 | return false; |
@@ -2974,14 +3401,16 @@ discard block |
||
| 2974 | 3401 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
| 2975 | 3402 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
| 2976 | 3403 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
| 2977 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
| 3404 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
| 3405 | + { |
|
| 2978 | 3406 | $mail_bo = $this->mail_bo; |
| 2979 | 3407 | $mail_bo->openConnection(); |
| 2980 | 3408 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
| 2981 | 3409 | #error_log("(re)opened Connection"); |
| 2982 | 3410 | } |
| 2983 | 3411 | // if copying mail to folder, or saving mail to infolog, we need to gather the needed information |
| 2984 | - if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') { |
|
| 3412 | + if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
| 3413 | + { |
|
| 2985 | 3414 | //error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc'])); |
| 2986 | 3415 | |
| 2987 | 3416 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
@@ -2990,17 +3419,28 @@ discard block |
||
| 2990 | 3419 | // copying mail to folder |
| 2991 | 3420 | if (count($folder) > 0) |
| 2992 | 3421 | { |
| 2993 | - foreach($folderOnServerID as $folderName) { |
|
| 2994 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
| 3422 | + foreach($folderOnServerID as $folderName) |
|
| 3423 | + { |
|
| 3424 | + if (is_array($folderName)) |
|
| 3425 | + { |
|
| 3426 | + $folderName = array_shift($folderName); |
|
| 3427 | + } |
|
| 3428 | + // should not happen at all |
|
| 2995 | 3429 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 2996 | 3430 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 2997 | 3431 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 2998 | - if ($mail_bo->folderExists($folderName,true)) { |
|
| 2999 | - if($mail_bo->isSentFolder($folderName)) { |
|
| 3432 | + if ($mail_bo->folderExists($folderName,true)) |
|
| 3433 | + { |
|
| 3434 | + if($mail_bo->isSentFolder($folderName)) |
|
| 3435 | + { |
|
| 3000 | 3436 | $flags = '\\Seen'; |
| 3001 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
| 3437 | + } |
|
| 3438 | + elseif($mail_bo->isDraftFolder($folderName)) |
|
| 3439 | + { |
|
| 3002 | 3440 | $flags = '\\Draft'; |
| 3003 | - } else { |
|
| 3441 | + } |
|
| 3442 | + else |
|
| 3443 | + { |
|
| 3004 | 3444 | $flags = '\\Seen'; |
| 3005 | 3445 | } |
| 3006 | 3446 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3023,18 +3463,32 @@ discard block |
||
| 3023 | 3463 | } |
| 3024 | 3464 | } |
| 3025 | 3465 | // if we choose to send from a differing profile |
| 3026 | - if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
|
| 3027 | - foreach($folderOnMailAccount as $folderName) { |
|
| 3028 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
| 3466 | + if ($folderOnMailAccount) |
|
| 3467 | + { |
|
| 3468 | + $this->changeProfile($_formData['mailaccount']); |
|
| 3469 | + } |
|
| 3470 | + foreach($folderOnMailAccount as $folderName) |
|
| 3471 | + { |
|
| 3472 | + if (is_array($folderName)) |
|
| 3473 | + { |
|
| 3474 | + $folderName = array_shift($folderName); |
|
| 3475 | + } |
|
| 3476 | + // should not happen at all |
|
| 3029 | 3477 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3030 | 3478 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3031 | 3479 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3032 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
| 3033 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
| 3480 | + if ($this->mail_bo->folderExists($folderName,true)) |
|
| 3481 | + { |
|
| 3482 | + if($this->mail_bo->isSentFolder($folderName)) |
|
| 3483 | + { |
|
| 3034 | 3484 | $flags = '\\Seen'; |
| 3035 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
| 3485 | + } |
|
| 3486 | + elseif($this->mail_bo->isDraftFolder($folderName)) |
|
| 3487 | + { |
|
| 3036 | 3488 | $flags = '\\Draft'; |
| 3037 | - } else { |
|
| 3489 | + } |
|
| 3490 | + else |
|
| 3491 | + { |
|
| 3038 | 3492 | $flags = '\\Seen'; |
| 3039 | 3493 | } |
| 3040 | 3494 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3056,7 +3510,10 @@ discard block |
||
| 3056 | 3510 | error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
| 3057 | 3511 | } |
| 3058 | 3512 | } |
| 3059 | - if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
|
| 3513 | + if ($folderOnMailAccount) |
|
| 3514 | + { |
|
| 3515 | + $this->changeProfile($_formData['serverID']); |
|
| 3516 | + } |
|
| 3060 | 3517 | |
| 3061 | 3518 | //$mail_bo->closeConnection(); |
| 3062 | 3519 | } |
@@ -3068,10 +3525,16 @@ discard block |
||
| 3068 | 3525 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
| 3069 | 3526 | $lastDrafted['uid'] = $dhA['msgUID']; |
| 3070 | 3527 | $lastDrafted['folder'] = $dhA['folder']; |
| 3071 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3528 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) |
|
| 3529 | + { |
|
| 3530 | + $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3531 | + } |
|
| 3072 | 3532 | // manually drafted, do not delete |
| 3073 | 3533 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
| 3074 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
| 3534 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) |
|
| 3535 | + { |
|
| 3536 | + $lastDrafted=false; |
|
| 3537 | + } |
|
| 3075 | 3538 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
| 3076 | 3539 | } |
| 3077 | 3540 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
@@ -3097,7 +3560,8 @@ discard block |
||
| 3097 | 3560 | |
| 3098 | 3561 | //error_log("handling draft messages, flagging and such"); |
| 3099 | 3562 | if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
| 3100 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
| 3563 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
| 3564 | + { |
|
| 3101 | 3565 | // mark message as answered |
| 3102 | 3566 | $mail_bo->openConnection(); |
| 3103 | 3567 | $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
@@ -3119,7 +3583,9 @@ discard block |
||
| 3119 | 3583 | //error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage())); |
| 3120 | 3584 | unset($e); |
| 3121 | 3585 | } |
| 3122 | - } else { |
|
| 3586 | + } |
|
| 3587 | + else |
|
| 3588 | + { |
|
| 3123 | 3589 | $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
| 3124 | 3590 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
| 3125 | 3591 | if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
@@ -3138,7 +3604,10 @@ discard block |
||
| 3138 | 3604 | } |
| 3139 | 3605 | //$mail_bo->closeConnection(); |
| 3140 | 3606 | } |
| 3141 | - if ($mail_bo) $mail_bo->closeConnection(); |
|
| 3607 | + if ($mail_bo) |
|
| 3608 | + { |
|
| 3609 | + $mail_bo->closeConnection(); |
|
| 3610 | + } |
|
| 3142 | 3611 | //error_log("performing Infolog Stuff"); |
| 3143 | 3612 | //error_log(print_r($this->sessionData['to'],true)); |
| 3144 | 3613 | //error_log(print_r($this->sessionData['cc'],true)); |
@@ -3151,9 +3620,18 @@ discard block |
||
| 3151 | 3620 | { |
| 3152 | 3621 | $mailaddresses = array(); |
| 3153 | 3622 | } |
| 3154 | - if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc']; |
|
| 3155 | - if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
| 3156 | - if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
| 3623 | + if (is_array($this->sessionData['cc'])) |
|
| 3624 | + { |
|
| 3625 | + $mailaddresses['cc'] = $this->sessionData['cc']; |
|
| 3626 | + } |
|
| 3627 | + if (is_array($this->sessionData['bcc'])) |
|
| 3628 | + { |
|
| 3629 | + $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
| 3630 | + } |
|
| 3631 | + if (!empty($mailaddresses)) |
|
| 3632 | + { |
|
| 3633 | + $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
| 3634 | + } |
|
| 3157 | 3635 | |
| 3158 | 3636 | if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
| 3159 | 3637 | { |
@@ -3185,7 +3663,10 @@ discard block |
||
| 3185 | 3663 | $_formData['serverID']),true), |
| 3186 | 3664 | 'app' => $app_name |
| 3187 | 3665 | ); |
| 3188 | - if ($entryid) $target['entry_id'] = $entryid; |
|
| 3666 | + if ($entryid) |
|
| 3667 | + { |
|
| 3668 | + $target['entry_id'] = $entryid; |
|
| 3669 | + } |
|
| 3189 | 3670 | // Open the app called for integration in a popup |
| 3190 | 3671 | // and store the mail raw data as egw_data, in order to |
| 3191 | 3672 | // be stored from registered app method later |
@@ -3196,8 +3677,11 @@ discard block |
||
| 3196 | 3677 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
| 3197 | 3678 | elseif(is_array($this->sessionData['attachments'])) |
| 3198 | 3679 | { |
| 3199 | - foreach($this->sessionData['attachments'] as $value) { |
|
| 3200 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
| 3680 | + foreach($this->sessionData['attachments'] as $value) |
|
| 3681 | + { |
|
| 3682 | + if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') |
|
| 3683 | + { |
|
| 3684 | +// happens when forwarding mails |
|
| 3201 | 3685 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
| 3202 | 3686 | } |
| 3203 | 3687 | } |
@@ -3234,7 +3718,10 @@ discard block |
||
| 3234 | 3718 | $default_identity = null; |
| 3235 | 3719 | foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
| 3236 | 3720 | { |
| 3237 | - if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
|
| 3721 | + if (!isset($default_identity)) |
|
| 3722 | + { |
|
| 3723 | + $default_identity = $identity['ident_id']; |
|
| 3724 | + } |
|
| 3238 | 3725 | if (!empty($identity['ident_signature'])) |
| 3239 | 3726 | { |
| 3240 | 3727 | $content['mailidentity'] = $identity['ident_id']; |
@@ -3242,12 +3729,18 @@ discard block |
||
| 3242 | 3729 | } |
| 3243 | 3730 | } |
| 3244 | 3731 | } |
| 3245 | - if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity; |
|
| 3732 | + if (empty($content['mailidentity'])) |
|
| 3733 | + { |
|
| 3734 | + $content['mailidentity'] = $default_identity; |
|
| 3735 | + } |
|
| 3246 | 3736 | } |
| 3247 | 3737 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
| 3248 | 3738 | { |
| 3249 | 3739 | $content['mimeType'] = 'html'; |
| 3250 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
| 3740 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") |
|
| 3741 | + { |
|
| 3742 | + $content['mimeType'] = 'plain'; |
|
| 3743 | + } |
|
| 3251 | 3744 | } |
| 3252 | 3745 | return $content; |
| 3253 | 3746 | |
@@ -3255,9 +3748,12 @@ discard block |
||
| 3255 | 3748 | |
| 3256 | 3749 | function stripSlashes($_string) |
| 3257 | 3750 | { |
| 3258 | - if (get_magic_quotes_gpc()) { |
|
| 3751 | + if (get_magic_quotes_gpc()) |
|
| 3752 | + { |
|
| 3259 | 3753 | return stripslashes($_string); |
| 3260 | - } else { |
|
| 3754 | + } |
|
| 3755 | + else |
|
| 3756 | + { |
|
| 3261 | 3757 | return $_string; |
| 3262 | 3758 | } |
| 3263 | 3759 | } |
@@ -3270,15 +3766,25 @@ discard block |
||
| 3270 | 3766 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
| 3271 | 3767 | * @return type |
| 3272 | 3768 | */ |
| 3273 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
| 3769 | + function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
|
| 3770 | + { |
|
| 3274 | 3771 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
| 3275 | 3772 | static $useCacheIfPossible = null; |
| 3276 | - if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
|
| 3773 | + if (is_null($useCacheIfPossible)) |
|
| 3774 | + { |
|
| 3775 | + $useCacheIfPossible = true; |
|
| 3776 | + } |
|
| 3277 | 3777 | $_searchString = trim($_REQUEST['query']); |
| 3278 | 3778 | $results = array(); |
| 3279 | 3779 | $rememberServerID = $this->mail_bo->icServer->ImapServerId; |
| 3280 | - if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
| 3281 | - if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
| 3780 | + if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) |
|
| 3781 | + { |
|
| 3782 | + $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
| 3783 | + } |
|
| 3784 | + if (empty($_mailaccountToSearch)) |
|
| 3785 | + { |
|
| 3786 | + $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
| 3787 | + } |
|
| 3282 | 3788 | if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch) |
| 3283 | 3789 | { |
| 3284 | 3790 | $this->changeProfile($_mailaccountToSearch); |
@@ -3289,7 +3795,8 @@ discard block |
||
| 3289 | 3795 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
| 3290 | 3796 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
| 3291 | 3797 | $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
| 3292 | - if (count($folderObjects)<=1) { |
|
| 3798 | + if (count($folderObjects)<=1) |
|
| 3799 | + { |
|
| 3293 | 3800 | $useCacheIfPossible = false; |
| 3294 | 3801 | } |
| 3295 | 3802 | else |
@@ -3340,7 +3847,8 @@ discard block |
||
| 3340 | 3847 | exit(); |
| 3341 | 3848 | } |
| 3342 | 3849 | |
| 3343 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
| 3850 | + public static function ajax_searchAddress($_searchStringLength=2) |
|
| 3851 | + { |
|
| 3344 | 3852 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
| 3345 | 3853 | $_searchString = trim($_REQUEST['query']); |
| 3346 | 3854 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3353,7 +3861,8 @@ discard block |
||
| 3353 | 3861 | { |
| 3354 | 3862 | $lists = array_filter( |
| 3355 | 3863 | $contacts_obj->get_lists(Acl::READ), |
| 3356 | - function($element) use($_searchString) { |
|
| 3864 | + function($element) use($_searchString) |
|
| 3865 | + { |
|
| 3357 | 3866 | return (stripos($element, $_searchString) !== false); |
| 3358 | 3867 | } |
| 3359 | 3868 | ); |
@@ -3368,7 +3877,10 @@ discard block |
||
| 3368 | 3877 | 'title' => lang('Mailinglist'), |
| 3369 | 3878 | 'data' => $key |
| 3370 | 3879 | ); |
| 3371 | - if($list_count++ > 5) break; |
|
| 3880 | + if($list_count++ > 5) |
|
| 3881 | + { |
|
| 3882 | + break; |
|
| 3883 | + } |
|
| 3372 | 3884 | } |
| 3373 | 3885 | } |
| 3374 | 3886 | |
@@ -3379,7 +3891,10 @@ discard block |
||
| 3379 | 3891 | $search = explode(' ', $_searchString); |
| 3380 | 3892 | foreach ($search as $k => $v) |
| 3381 | 3893 | { |
| 3382 | - if (mb_strlen($v) < 3) unset($search[$k]); |
|
| 3894 | + if (mb_strlen($v) < 3) |
|
| 3895 | + { |
|
| 3896 | + unset($search[$k]); |
|
| 3897 | + } |
|
| 3383 | 3898 | } |
| 3384 | 3899 | $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
| 3385 | 3900 | //error_log(__METHOD__.__LINE__.$_searchString); |
@@ -3409,9 +3924,12 @@ discard block |
||
| 3409 | 3924 | } |
| 3410 | 3925 | } |
| 3411 | 3926 | |
| 3412 | - if(is_array($contacts)) { |
|
| 3413 | - foreach($contacts as $contact) { |
|
| 3414 | - foreach(array($contact['email'],$contact['email_home']) as $email) { |
|
| 3927 | + if(is_array($contacts)) |
|
| 3928 | + { |
|
| 3929 | + foreach($contacts as $contact) |
|
| 3930 | + { |
|
| 3931 | + foreach(array($contact['email'],$contact['email_home']) as $email) |
|
| 3932 | + { |
|
| 3415 | 3933 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 3416 | 3934 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
| 3417 | 3935 | $rfcAddr = Mail::parseAddressList($email); |
@@ -3425,10 +3943,22 @@ discard block |
||
| 3425 | 3943 | if (method_exists($contacts_obj,'search')) |
| 3426 | 3944 | { |
| 3427 | 3945 | $contact['n_fn']=''; |
| 3428 | - if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
|
| 3429 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3430 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3431 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3946 | + if (!empty($contact['n_prefix'])) |
|
| 3947 | + { |
|
| 3948 | + $contact['n_fn'] = $contact['n_prefix']; |
|
| 3949 | + } |
|
| 3950 | + if (!empty($contact['n_given'])) |
|
| 3951 | + { |
|
| 3952 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3953 | + } |
|
| 3954 | + if (!empty($contact['n_family'])) |
|
| 3955 | + { |
|
| 3956 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3957 | + } |
|
| 3958 | + if (!empty($contact['org_name'])) |
|
| 3959 | + { |
|
| 3960 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3961 | + } |
|
| 3432 | 3962 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
| 3433 | 3963 | } |
| 3434 | 3964 | else |
@@ -3438,7 +3968,8 @@ discard block |
||
| 3438 | 3968 | $args = explode('@', trim($email)); |
| 3439 | 3969 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
| 3440 | 3970 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
| 3441 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
| 3971 | + if(!empty($email) && in_array($completeMailString ,$results) === false) |
|
| 3972 | + { |
|
| 3442 | 3973 | $results[] = array( |
| 3443 | 3974 | 'id'=>$completeMailString, |
| 3444 | 3975 | 'label' => $completeMailString, |
@@ -3457,7 +3988,10 @@ discard block |
||
| 3457 | 3988 | foreach($groups as $g_id => $name) |
| 3458 | 3989 | { |
| 3459 | 3990 | $group = $GLOBALS['egw']->accounts->read($g_id); |
| 3460 | - if(!$group['account_email']) continue; |
|
| 3991 | + if(!$group['account_email']) |
|
| 3992 | + { |
|
| 3993 | + continue; |
|
| 3994 | + } |
|
| 3461 | 3995 | $args = explode('@', trim($group['account_email'])); |
| 3462 | 3996 | $args[] = $name; |
| 3463 | 3997 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |