@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class mail_compose |
| 26 | 26 | { |
| 27 | - var $public_functions = array |
|
| 28 | - ( |
|
| 27 | + var $public_functions = array( |
|
| 29 | 28 | 'compose' => True, |
| 30 | 29 | 'getAttachment' => True, |
| 31 | 30 | ); |
@@ -34,8 +33,8 @@ discard block |
||
| 34 | 33 | * class vars for destination, priorities, mimeTypes |
| 35 | 34 | */ |
| 36 | 35 | static $destinations = array( |
| 37 | - 'to' => 'to', // lang('to') |
|
| 38 | - 'cc' => 'cc', // lang('cc') |
|
| 36 | + 'to' => 'to', // lang('to') |
|
| 37 | + 'cc' => 'cc', // lang('cc') |
|
| 39 | 38 | 'bcc' => 'bcc', // lang('bcc') |
| 40 | 39 | 'replyto' => 'replyto', // lang('replyto') |
| 41 | 40 | 'folder' => 'folder' // lang('folder') |
@@ -63,20 +62,20 @@ discard block |
||
| 63 | 62 | * @var array |
| 64 | 63 | */ |
| 65 | 64 | var $mailPreferences; |
| 66 | - var $attachments; // Array of attachments |
|
| 65 | + var $attachments; // Array of attachments |
|
| 67 | 66 | var $displayCharset; |
| 68 | 67 | var $composeID; |
| 69 | 68 | var $sessionData; |
| 70 | 69 | |
| 71 | 70 | function __construct() |
| 72 | 71 | { |
| 73 | - $this->displayCharset = Api\Translation::charset(); |
|
| 72 | + $this->displayCharset = Api\Translation::charset(); |
|
| 74 | 73 | |
| 75 | 74 | $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
| 76 | - $this->mail_bo = Mail::getInstance(true,$profileID); |
|
| 75 | + $this->mail_bo = Mail::getInstance(true, $profileID); |
|
| 77 | 76 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->mail_bo->profileID; |
| 78 | 77 | |
| 79 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
| 78 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
| 80 | 79 | //force the default for the forwarding -> asmail |
| 81 | 80 | if (!is_array($this->mailPreferences) || empty($this->mailPreferences['message_forwarding'])) |
| 82 | 81 | { |
@@ -84,7 +83,7 @@ discard block |
||
| 84 | 83 | } |
| 85 | 84 | if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail'); |
| 86 | 85 | |
| 87 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
| 86 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
| 88 | 87 | } |
| 89 | 88 | |
| 90 | 89 | /** |
@@ -94,15 +93,15 @@ discard block |
||
| 94 | 93 | */ |
| 95 | 94 | function changeProfile($_icServerID) |
| 96 | 95 | { |
| 97 | - if ($this->mail_bo->profileID!=$_icServerID) |
|
| 96 | + if ($this->mail_bo->profileID != $_icServerID) |
|
| 98 | 97 | { |
| 99 | 98 | if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
| 100 | - $this->mail_bo = Mail::getInstance(false,$_icServerID); |
|
| 99 | + $this->mail_bo = Mail::getInstance(false, $_icServerID); |
|
| 101 | 100 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 102 | 101 | // no icServer Object: something failed big time |
| 103 | 102 | if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
| 104 | 103 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
| 105 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
| 104 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
| 106 | 105 | } |
| 107 | 106 | } |
| 108 | 107 | |
@@ -180,7 +179,7 @@ discard block |
||
| 180 | 179 | 'checkbox' => true, |
| 181 | 180 | 'hint' => 'check to save as trackerentry on send', |
| 182 | 181 | 'onExecute' => 'javaScript:app.mail.compose_setToggle', |
| 183 | - 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'), |
|
| 182 | + 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'), |
|
| 184 | 183 | ), |
| 185 | 184 | 'to_calendar' => array( |
| 186 | 185 | 'caption' => 'Calendar', |
@@ -205,7 +204,7 @@ discard block |
||
| 205 | 204 | 'children' => array(), |
| 206 | 205 | 'hint' => 'Select the message priority tag', |
| 207 | 206 | ), |
| 208 | - 'save2vfs' => array ( |
|
| 207 | + 'save2vfs' => array( |
|
| 209 | 208 | 'caption' => 'Save to filemanager', |
| 210 | 209 | 'icon' => 'filesave', |
| 211 | 210 | 'group' => ++$group, |
@@ -242,7 +241,7 @@ discard block |
||
| 242 | 241 | { |
| 243 | 242 | foreach (array_keys($actions) as $key) |
| 244 | 243 | { |
| 245 | - if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) { |
|
| 244 | + if (!in_array($key, array('send', 'button[saveAsDraft]', 'uploadForCompose'))) { |
|
| 246 | 245 | $actions[$key]['toolbarDefault'] = false; |
| 247 | 246 | } |
| 248 | 247 | } |
@@ -266,7 +265,7 @@ discard block |
||
| 266 | 265 | * @var boolean $suppressSigOnTop =false |
| 267 | 266 | * @var boolean $isReply =false |
| 268 | 267 | */ |
| 269 | - function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
|
| 268 | + function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false) |
|
| 270 | 269 | { |
| 271 | 270 | if ($msg) Framework::message($msg); |
| 272 | 271 | |
@@ -287,14 +286,14 @@ discard block |
||
| 287 | 286 | //lang('compose'),lang('from') // needed to be found by translationtools |
| 288 | 287 | //error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace()); |
| 289 | 288 | //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); |
| 290 | - $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; |
|
| 291 | - $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; |
|
| 289 | + $_contentHasSigID = $_content ?array_key_exists('mailidentity', (array)$_content) : false; |
|
| 290 | + $_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false; |
|
| 292 | 291 | if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; |
| 293 | 292 | if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; |
| 294 | 293 | |
| 295 | 294 | // Process different places we can use as a start for composing an email |
| 296 | 295 | $actionToProcess = 'compose'; |
| 297 | - if($_GET['from'] && $replyID) |
|
| 296 | + if ($_GET['from'] && $replyID) |
|
| 298 | 297 | { |
| 299 | 298 | $_content = array_merge((array)$_content, $this->getComposeFrom( |
| 300 | 299 | // Parameters needed for fetching appropriate data |
@@ -312,10 +311,10 @@ discard block |
||
| 312 | 311 | } |
| 313 | 312 | |
| 314 | 313 | $composeCache = array(); |
| 315 | - if (isset($_content['composeID'])&&!empty($_content['composeID'])) |
|
| 314 | + if (isset($_content['composeID']) && !empty($_content['composeID'])) |
|
| 316 | 315 | { |
| 317 | 316 | $isFirstLoad = false; |
| 318 | - $composeCache = Api\Cache::getCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2); |
|
| 317 | + $composeCache = Api\Cache::getCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'], $callback = null, $callback_params = array(), $expiration = 60 * 60 * 2); |
|
| 319 | 318 | $this->composeID = $_content['composeID']; |
| 320 | 319 | //error_log(__METHOD__.__LINE__.array2string($composeCache)); |
| 321 | 320 | } |
@@ -325,7 +324,7 @@ discard block |
||
| 325 | 324 | // respect that composeasnew may not want that, as we assume there |
| 326 | 325 | // is some style already set and our initalStyle always adds a span with |
| 327 | 326 | // and we want to avoid that |
| 328 | - $isFirstLoad = !($actionToProcess=='composeasnew');//true; |
|
| 327 | + $isFirstLoad = !($actionToProcess == 'composeasnew'); //true; |
|
| 329 | 328 | $this->composeID = $_content['composeID'] = $this->generateComposeID(); |
| 330 | 329 | if (!is_array($_content)) |
| 331 | 330 | { |
@@ -360,7 +359,7 @@ discard block |
||
| 360 | 359 | if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
| 361 | 360 | try |
| 362 | 361 | { |
| 363 | - $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false); |
|
| 362 | + $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload, $this->composeID, false); |
|
| 364 | 363 | } |
| 365 | 364 | catch (Api\Exception\WrongUserinput $e) |
| 366 | 365 | { |
@@ -386,12 +385,12 @@ discard block |
||
| 386 | 385 | unset($_content['attachments']['delete']); |
| 387 | 386 | $attachments = $_content['attachments']; |
| 388 | 387 | unset($_content['attachments']); |
| 389 | - foreach($attachments as $i => $att) |
|
| 388 | + foreach ($attachments as $i => $att) |
|
| 390 | 389 | { |
| 391 | - $remove=false; |
|
| 392 | - foreach(array_keys($toDelete) as $k) |
|
| 390 | + $remove = false; |
|
| 391 | + foreach (array_keys($toDelete) as $k) |
|
| 393 | 392 | { |
| 394 | - if ($att['tmp_name']==$k) $remove=true; |
|
| 393 | + if ($att['tmp_name'] == $k) $remove = true; |
|
| 395 | 394 | } |
| 396 | 395 | if (!$remove) $_content['attachments'][] = $att; |
| 397 | 396 | } |
@@ -399,7 +398,7 @@ discard block |
||
| 399 | 398 | // someone clicked something like send, or saveAsDraft |
| 400 | 399 | // make sure, we are connected to the correct server for sending and storing the send message |
| 401 | 400 | $activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose |
| 402 | - $activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10); |
|
| 401 | + $activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10); |
|
| 403 | 402 | if (!empty($activeFolderCache[$this->mail_bo->profileID])) |
| 404 | 403 | { |
| 405 | 404 | //error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]); |
@@ -407,7 +406,7 @@ discard block |
||
| 407 | 406 | } |
| 408 | 407 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
| 409 | 408 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
| 410 | - ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
|
| 409 | + ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint']) |
|
| 411 | 410 | ) |
| 412 | 411 | { |
| 413 | 412 | $this->changeProfile($_content['serverID']); |
@@ -421,19 +420,19 @@ discard block |
||
| 421 | 420 | { |
| 422 | 421 | $buttonClicked = $suppressSigOnTop = true; |
| 423 | 422 | $sendOK = true; |
| 424 | - $_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']); |
|
| 423 | + $_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']); |
|
| 425 | 424 | /* |
| 426 | 425 | perform some simple checks, before trying to send on: |
| 427 | 426 | $_content['to'];$_content['cc'];$_content['bcc']; |
| 428 | 427 | trim($_content['subject']); |
| 429 | 428 | trim(strip_tags(str_replace(' ','',$_content['body']))); |
| 430 | 429 | */ |
| 431 | - if (strlen(trim(strip_tags(str_replace(' ','',$_content['body']))))==0 && count($_content['attachments'])==0) |
|
| 430 | + if (strlen(trim(strip_tags(str_replace(' ', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0) |
|
| 432 | 431 | { |
| 433 | 432 | $sendOK = false; |
| 434 | 433 | $_content['msg'] = $message = lang("no message body supplied"); |
| 435 | 434 | } |
| 436 | - if ($sendOK && strlen(trim($_content['subject']))==0) |
|
| 435 | + if ($sendOK && strlen(trim($_content['subject'])) == 0) |
|
| 437 | 436 | { |
| 438 | 437 | $sendOK = false; |
| 439 | 438 | $_content['msg'] = $message = lang("no subject supplied"); |
@@ -448,15 +447,15 @@ discard block |
||
| 448 | 447 | try |
| 449 | 448 | { |
| 450 | 449 | $success = $this->send($_content); |
| 451 | - if ($success==false) |
|
| 450 | + if ($success == false) |
|
| 452 | 451 | { |
| 453 | - $sendOK=false; |
|
| 452 | + $sendOK = false; |
|
| 454 | 453 | $message = $this->errorInfo; |
| 455 | 454 | } |
| 456 | 455 | if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID]) |
| 457 | 456 | { |
| 458 | - $sigPref[$this->mail_bo->profileID]=$_content['mailidentity']; |
|
| 459 | - $GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user'); |
|
| 457 | + $sigPref[$this->mail_bo->profileID] = $_content['mailidentity']; |
|
| 458 | + $GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user'); |
|
| 460 | 459 | // save prefs |
| 461 | 460 | $GLOBALS['egw']->preferences->save_repository(true); |
| 462 | 461 | } |
@@ -480,23 +479,23 @@ discard block |
||
| 480 | 479 | if (isset($_content['mode']) && !empty($_content['mode'])) |
| 481 | 480 | { |
| 482 | 481 | $mode = $_content['mode']; |
| 483 | - if ($_content['mode']=='forward' && !empty($_content['processedmail_id'])) |
|
| 482 | + if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id'])) |
|
| 484 | 483 | { |
| 485 | - $_content['processedmail_id'] = explode(',',$_content['processedmail_id']); |
|
| 484 | + $_content['processedmail_id'] = explode(',', $_content['processedmail_id']); |
|
| 486 | 485 | foreach ($_content['processedmail_id'] as $k =>$rowid) |
| 487 | 486 | { |
| 488 | 487 | $fhA = mail_ui::splitRowID($rowid); |
| 489 | 488 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
| 490 | 489 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
| 491 | - $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
|
| 490 | + $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false); |
|
| 492 | 491 | if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
| 493 | 492 | } |
| 494 | 493 | } |
| 495 | - if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
|
| 494 | + if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id'])) |
|
| 496 | 495 | { |
| 497 | 496 | $rhA = mail_ui::splitRowID($_content['processedmail_id']); |
| 498 | 497 | //$this->sessionData['uid'] = $rhA['msgUID']; |
| 499 | - $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false); |
|
| 498 | + $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false); |
|
| 500 | 499 | $workingFolder = $rhA['folder']; |
| 501 | 500 | } |
| 502 | 501 | } |
@@ -504,30 +503,30 @@ discard block |
||
| 504 | 503 | if (empty($idsForRefresh) && !empty($_content['processedmail_id'])) |
| 505 | 504 | { |
| 506 | 505 | $rhA = mail_ui::splitRowID($_content['processedmail_id']); |
| 507 | - $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false); |
|
| 506 | + $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false); |
|
| 508 | 507 | } |
| 509 | 508 | $response = Api\Json\Response::get(); |
| 510 | 509 | if ($activeProfile != $composeProfile) |
| 511 | 510 | { |
| 512 | 511 | // we need a message only, when account ids (composeProfile vs. activeProfile) differ |
| 513 | - $response->call('opener.egw_message',lang('Message send successfully.')); |
|
| 512 | + $response->call('opener.egw_message', lang('Message send successfully.')); |
|
| 514 | 513 | } |
| 515 | - elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))) |
|
| 514 | + elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))) |
|
| 516 | 515 | { |
| 517 | - if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)) |
|
| 516 | + if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)) |
|
| 518 | 517 | { |
| 519 | 518 | // we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action |
| 520 | - $response->call('opener.egw_refresh',lang('Message send successfully.'),'mail'); |
|
| 519 | + $response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail'); |
|
| 521 | 520 | } |
| 522 | 521 | else |
| 523 | 522 | { |
| 524 | 523 | //error_log(__METHOD__.__LINE__.array2string($idsForRefresh)); |
| 525 | - $response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update'); |
|
| 524 | + $response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update'); |
|
| 526 | 525 | } |
| 527 | 526 | } |
| 528 | 527 | else |
| 529 | 528 | { |
| 530 | - $response->call('opener.egw_message',lang('Message send successfully.')); |
|
| 529 | + $response->call('opener.egw_message', lang('Message send successfully.')); |
|
| 531 | 530 | } |
| 532 | 531 | //egw_framework::refresh_opener(lang('Message send successfully.'),'mail'); |
| 533 | 532 | Framework::window_close(); |
@@ -535,60 +534,60 @@ discard block |
||
| 535 | 534 | if ($sendOK == false) |
| 536 | 535 | { |
| 537 | 536 | $response = Api\Json\Response::get(); |
| 538 | - Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate |
|
| 537 | + Framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate |
|
| 539 | 538 | $response->call('app.mail.clearIntevals'); |
| 540 | 539 | } |
| 541 | 540 | } |
| 542 | 541 | |
| 543 | 542 | if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
| 544 | 543 | $insertSigOnTop = false; |
| 545 | - $content = (is_array($_content)?$_content:array()); |
|
| 544 | + $content = (is_array($_content) ? $_content : array()); |
|
| 546 | 545 | if ($_contentHasMimeType) |
| 547 | 546 | { |
| 548 | 547 | // mimeType is now a checkbox; convert it here to match expectations |
| 549 | 548 | // ToDo: match Code to meet checkbox value |
| 550 | - if ($content['mimeType']==1) |
|
| 549 | + if ($content['mimeType'] == 1) |
|
| 551 | 550 | { |
| 552 | - $_content['mimeType'] = $content['mimeType']='html'; |
|
| 551 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
| 553 | 552 | } |
| 554 | 553 | else |
| 555 | 554 | { |
| 556 | - $_content['mimeType'] = $content['mimeType']='plain'; |
|
| 555 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
| 557 | 556 | } |
| 558 | 557 | |
| 559 | 558 | } |
| 560 | 559 | // user might have switched desired mimetype, so we should convert |
| 561 | - if ($content['is_html'] && $content['mimeType']=='plain') |
|
| 560 | + if ($content['is_html'] && $content['mimeType'] == 'plain') |
|
| 562 | 561 | { |
| 563 | 562 | //error_log(__METHOD__.__LINE__.$content['mail_htmltext']); |
| 564 | 563 | $suppressSigOnTop = true; |
| 565 | - if (stripos($content['mail_htmltext'],'<pre>')!==false) |
|
| 564 | + if (stripos($content['mail_htmltext'], '<pre>') !== false) |
|
| 566 | 565 | { |
| 567 | 566 | $contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']); |
| 568 | 567 | if (is_array($contentArr)) |
| 569 | 568 | { |
| 570 | 569 | foreach ($contentArr as $k =>&$elem) |
| 571 | 570 | { |
| 572 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
| 571 | + if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem); |
|
| 573 | 572 | } |
| 574 | - $content['mail_htmltext'] = implode('',$contentArr); |
|
| 573 | + $content['mail_htmltext'] = implode('', $contentArr); |
|
| 575 | 574 | } |
| 576 | 575 | } |
| 577 | 576 | $content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']); |
| 578 | - $content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true); |
|
| 577 | + $content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true); |
|
| 579 | 578 | |
| 580 | 579 | $content['body'] = $content['mail_htmltext']; |
| 581 | 580 | unset($content['mail_htmltext']); |
| 582 | 581 | $content['is_html'] = false; |
| 583 | 582 | $content['is_plain'] = true; |
| 584 | 583 | } |
| 585 | - if ($content['is_plain'] && $content['mimeType']=='html') |
|
| 584 | + if ($content['is_plain'] && $content['mimeType'] == 'html') |
|
| 586 | 585 | { |
| 587 | 586 | // the possible font span should only be applied on first load or on switch plain->html |
| 588 | 587 | $isFirstLoad = "switchedplaintohtml"; |
| 589 | 588 | //error_log(__METHOD__.__LINE__.$content['mail_plaintext']); |
| 590 | 589 | $suppressSigOnTop = true; |
| 591 | - $content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']); |
|
| 590 | + $content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']); |
|
| 592 | 591 | //$this->replaceEmailAdresses($content['mail_plaintext']); |
| 593 | 592 | $content['body'] = $content['mail_plaintext']; |
| 594 | 593 | unset($content['mail_plaintext']); |
@@ -596,7 +595,7 @@ discard block |
||
| 596 | 595 | $content['is_plain'] = false; |
| 597 | 596 | } |
| 598 | 597 | |
| 599 | - $content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']); |
|
| 598 | + $content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']); |
|
| 600 | 599 | unset($_content['body']); |
| 601 | 600 | unset($_content['mail_htmltext']); |
| 602 | 601 | unset($_content['mail_plaintext']); |
@@ -608,7 +607,7 @@ discard block |
||
| 608 | 607 | |
| 609 | 608 | // form was submitted either by clicking a button or by changing one of the triggering selectboxes |
| 610 | 609 | // identity and signatureid; this might trigger that the signature in mail body may have to be altered |
| 611 | - if ( !empty($content['body']) && |
|
| 610 | + if (!empty($content['body']) && |
|
| 612 | 611 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
| 613 | 612 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
| 614 | 613 | ) |
@@ -619,7 +618,7 @@ discard block |
||
| 619 | 618 | { |
| 620 | 619 | $acc = Mail\Account::read($_content['mailaccount']); |
| 621 | 620 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 622 | - $Identities = Mail\Account::read_identity($acc['ident_id'],true); |
|
| 621 | + $Identities = Mail\Account::read_identity($acc['ident_id'], true); |
|
| 623 | 622 | //error_log(__METHOD__.__LINE__.array2string($Identities)); |
| 624 | 623 | if ($Identities['ident_id']) |
| 625 | 624 | { |
@@ -632,41 +631,41 @@ discard block |
||
| 632 | 631 | } |
| 633 | 632 | } |
| 634 | 633 | $_oldSig = $composeCache['mailidentity']; |
| 635 | - $_signatureid = ($newSig?$newSig:$_content['mailidentity']); |
|
| 634 | + $_signatureid = ($newSig ? $newSig : $_content['mailidentity']); |
|
| 636 | 635 | |
| 637 | 636 | if ($_oldSig != $_signatureid) |
| 638 | 637 | { |
| 639 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
| 638 | + if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
| 640 | 639 | // prepare signatures, the selected sig may be used on top of the body |
| 641 | 640 | try |
| 642 | 641 | { |
| 643 | - $oldSignature = Mail\Account::read_identity($_oldSig,true); |
|
| 642 | + $oldSignature = Mail\Account::read_identity($_oldSig, true); |
|
| 644 | 643 | //error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#'); |
| 645 | 644 | $oldSigText = $oldSignature['ident_signature']; |
| 646 | 645 | } |
| 647 | 646 | catch (Exception $e) |
| 648 | 647 | { |
| 649 | - $oldSignature=array(); |
|
| 648 | + $oldSignature = array(); |
|
| 650 | 649 | $oldSigText = null; |
| 651 | 650 | } |
| 652 | 651 | try |
| 653 | 652 | { |
| 654 | - $signature = Mail\Account::read_identity($_signatureid,true); |
|
| 653 | + $signature = Mail\Account::read_identity($_signatureid, true); |
|
| 655 | 654 | //error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#'); |
| 656 | 655 | $sigText = $signature['ident_signature']; |
| 657 | 656 | } |
| 658 | 657 | catch (Exception $e) |
| 659 | 658 | { |
| 660 | - $signature=array(); |
|
| 659 | + $signature = array(); |
|
| 661 | 660 | $sigText = null; |
| 662 | 661 | } |
| 663 | 662 | //error_log(__METHOD__.'Old:'.$oldSigText.'#'); |
| 664 | 663 | //error_log(__METHOD__.'New:'.$sigText.'#'); |
| 665 | 664 | if ($_currentMode == 'plain') |
| 666 | 665 | { |
| 667 | - $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
|
| 668 | - $sigText = $this->convertHTMLToText($sigText,true,true); |
|
| 669 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
| 666 | + $oldSigText = $this->convertHTMLToText($oldSigText, true, true); |
|
| 667 | + $sigText = $this->convertHTMLToText($sigText, true, true); |
|
| 668 | + if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
| 670 | 669 | } |
| 671 | 670 | |
| 672 | 671 | //$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -680,9 +679,9 @@ discard block |
||
| 680 | 679 | //error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#'); |
| 681 | 680 | if ($_currentMode == 'html') |
| 682 | 681 | { |
| 683 | - $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
|
| 682 | + $content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace |
|
| 684 | 683 | $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 |
|
| 684 | + 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 |
|
| 686 | 685 | } |
| 687 | 686 | $content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), |
| 688 | 687 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
@@ -690,9 +689,9 @@ discard block |
||
| 690 | 689 | if ($_currentMode == 'html') |
| 691 | 690 | { |
| 692 | 691 | $replaced = null; |
| 693 | - $content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u', |
|
| 694 | - $rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced); |
|
| 695 | - $content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'–','—','€'),$content['body']); |
|
| 692 | + $content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u', |
|
| 693 | + $rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced); |
|
| 694 | + $content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '–', '—', '€'), $content['body']); |
|
| 696 | 695 | //error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced"); |
| 697 | 696 | unset($rep, $in); |
| 698 | 697 | if ($replaced) |
@@ -703,32 +702,32 @@ discard block |
||
| 703 | 702 | else |
| 704 | 703 | { |
| 705 | 704 | // try the old way |
| 706 | - $found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false); |
|
| 705 | + $found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false); |
|
| 707 | 706 | } |
| 708 | 707 | } |
| 709 | 708 | else |
| 710 | 709 | { |
| 711 | - $found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false); |
|
| 710 | + $found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false); |
|
| 712 | 711 | } |
| 713 | 712 | |
| 714 | - if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) =='')) |
|
| 713 | + if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == '')) |
|
| 715 | 714 | { |
| 716 | 715 | //error_log(__METHOD__.'Old Content:'.$content['body'].'#'); |
| 717 | - $_oldSigText = preg_quote($oldSigTextCleaned,'~'); |
|
| 716 | + $_oldSigText = preg_quote($oldSigTextCleaned, '~'); |
|
| 718 | 717 | //error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#'); |
| 719 | - $content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1); |
|
| 718 | + $content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1); |
|
| 720 | 719 | //error_log(__METHOD__.'new Content:'.$content['body'].'#'); |
| 721 | 720 | } |
| 722 | 721 | |
| 723 | - if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) =='')) |
|
| 722 | + if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == '')) |
|
| 724 | 723 | { |
| 725 | 724 | // if there is no sig selected, there is no way to replace a signature |
| 726 | 725 | } |
| 727 | 726 | |
| 728 | 727 | if ($found === false) |
| 729 | 728 | { |
| 730 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
| 731 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
| 729 | + if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
| 730 | + if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
| 732 | 731 | } |
| 733 | 732 | else |
| 734 | 733 | { |
@@ -750,7 +749,7 @@ discard block |
||
| 750 | 749 | if ($isFirstLoad) |
| 751 | 750 | { |
| 752 | 751 | $alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached |
| 753 | - if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) && |
|
| 752 | + if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) && |
|
| 754 | 753 | $this->mailPreferences['attachVCardAtCompose'])) |
| 755 | 754 | { |
| 756 | 755 | $alwaysAttachVCardAtCompose = true; |
@@ -759,7 +758,7 @@ discard block |
||
| 759 | 758 | $f = $_REQUEST['preset']['file']; |
| 760 | 759 | $_REQUEST['preset']['file'] = array($f); |
| 761 | 760 | } |
| 762 | - $_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry"; |
|
| 761 | + $_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry"; |
|
| 763 | 762 | } |
| 764 | 763 | // an app passed the request for fetching and mailing an entry |
| 765 | 764 | if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])) |
@@ -768,33 +767,33 @@ discard block |
||
| 768 | 767 | $mt = $_REQUEST['method']; |
| 769 | 768 | $id = $_REQUEST['id']; |
| 770 | 769 | // passed method MUST be registered |
| 771 | - $method = Link::get_registry($app,$mt); |
|
| 770 | + $method = Link::get_registry($app, $mt); |
|
| 772 | 771 | //error_log(__METHOD__.__LINE__.array2string($method)); |
| 773 | 772 | if ($method) |
| 774 | 773 | { |
| 775 | - $res = ExecMethod($method,array($id,'html')); |
|
| 774 | + $res = ExecMethod($method, array($id, 'html')); |
|
| 776 | 775 | //error_log(__METHOD__.__LINE__.array2string($res)); |
| 777 | 776 | if (!empty($res)) |
| 778 | 777 | { |
| 779 | 778 | $insertSigOnTop = 'below'; |
| 780 | 779 | if (isset($res['attachments']) && is_array($res['attachments'])) |
| 781 | 780 | { |
| 782 | - foreach($res['attachments'] as $f) |
|
| 781 | + foreach ($res['attachments'] as $f) |
|
| 783 | 782 | { |
| 784 | 783 | $_REQUEST['preset']['file'][] = $f; |
| 785 | 784 | } |
| 786 | 785 | } |
| 787 | 786 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
| 788 | - foreach(array('subject','body','mimetype') as $name) { |
|
| 787 | + foreach (array('subject', 'body', 'mimetype') as $name) { |
|
| 789 | 788 | $sName = $name; |
| 790 | - if ($name=='mimetype'&&$res[$name]) |
|
| 789 | + if ($name == 'mimetype' && $res[$name]) |
|
| 791 | 790 | { |
| 792 | 791 | $sName = 'mimeType'; |
| 793 | 792 | $content[$sName] = $res[$name]; |
| 794 | 793 | } |
| 795 | 794 | else |
| 796 | 795 | { |
| 797 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
| 796 | + if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name]; |
|
| 798 | 797 | } |
| 799 | 798 | } |
| 800 | 799 | } |
@@ -803,45 +802,45 @@ discard block |
||
| 803 | 802 | // handle preset info/values |
| 804 | 803 | if (is_array($_REQUEST['preset'])) |
| 805 | 804 | { |
| 806 | - $alreadyProcessed=array(); |
|
| 805 | + $alreadyProcessed = array(); |
|
| 807 | 806 | //_debug_array($_REQUEST); |
| 808 | 807 | if ($_REQUEST['preset']['mailto']) { |
| 809 | 808 | // handle mailto strings such as |
| 810 | 809 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
| 811 | 810 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
| 812 | 811 | // first, strip the mailto: string out of the mailto URL |
| 813 | - $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
|
| 812 | + $tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7))); |
|
| 814 | 813 | // check if there is more than the to address |
| 815 | - $mailtoArray = explode('?',$tmp_send_to,2); |
|
| 814 | + $mailtoArray = explode('?', $tmp_send_to, 2); |
|
| 816 | 815 | if ($mailtoArray[1]) { |
| 817 | 816 | // check if there are more than one requests |
| 818 | - $addRequests = explode('&',$mailtoArray[1]); |
|
| 817 | + $addRequests = explode('&', $mailtoArray[1]); |
|
| 819 | 818 | foreach ($addRequests as $key => $reqval) { |
| 820 | 819 | // the additional requests should have a =, to separate key from value. |
| 821 | - $keyValuePair = explode('=',$reqval,2); |
|
| 822 | - $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1]; |
|
| 820 | + $keyValuePair = explode('=', $reqval, 2); |
|
| 821 | + $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1]; |
|
| 823 | 822 | } |
| 824 | 823 | } |
| 825 | - $content['to']=$mailtoArray[0]; |
|
| 826 | - $alreadyProcessed['to']='to'; |
|
| 824 | + $content['to'] = $mailtoArray[0]; |
|
| 825 | + $alreadyProcessed['to'] = 'to'; |
|
| 827 | 826 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
| 828 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
| 829 | - $alreadyProcessed[$name]=$name; |
|
| 830 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
| 827 | + foreach (array('cc', 'bcc', 'subject', 'body') as $name) { |
|
| 828 | + $alreadyProcessed[$name] = $name; |
|
| 829 | + if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name]; |
|
| 831 | 830 | } |
| 832 | 831 | } |
| 833 | 832 | |
| 834 | 833 | if ($_REQUEST['preset']['mailtocontactbyid']) { |
| 835 | 834 | if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
| 836 | 835 | $contacts_obj = new Api\Contacts(); |
| 837 | - $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
| 838 | - if (method_exists($contacts_obj,'search')) { |
|
| 836 | + $addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
| 837 | + if (method_exists($contacts_obj, 'search')) { |
|
| 839 | 838 | |
| 840 | - $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
|
| 839 | + $addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']); |
|
| 841 | 840 | foreach ((array)$addressArray as $id => $addressID) |
| 842 | 841 | { |
| 843 | - $addressID = (int) $addressID; |
|
| 844 | - if (!($addressID>0)) |
|
| 842 | + $addressID = (int)$addressID; |
|
| 843 | + if (!($addressID > 0)) |
|
| 845 | 844 | { |
| 846 | 845 | unset($addressArray[$id]); |
| 847 | 846 | } |
@@ -850,44 +849,44 @@ discard block |
||
| 850 | 849 | { |
| 851 | 850 | $_searchCond = array('contact_id'=>$addressArray); |
| 852 | 851 | //error_log(__METHOD__.__LINE__.$_searchString); |
| 853 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false; |
|
| 854 | - $filter = ($showAccounts?array():array('account_id' => null)); |
|
| 855 | - $filter['cols_to_search']=array('n_fn','email','email_home'); |
|
| 856 | - $contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); |
|
| 852 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts = false; |
|
| 853 | + $filter = ($showAccounts ? array() : array('account_id' => null)); |
|
| 854 | + $filter['cols_to_search'] = array('n_fn', 'email', 'email_home'); |
|
| 855 | + $contacts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
| 857 | 856 | // additionally search the accounts, if the contact storage is not the account storage |
| 858 | 857 | if ($showAccounts && |
| 859 | 858 | $GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && |
| 860 | 859 | $GLOBALS['egw_info']['server']['contact_repository'] == 'sql') |
| 861 | 860 | { |
| 862 | - $accounts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0)); |
|
| 861 | + $accounts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0)); |
|
| 863 | 862 | |
| 864 | 863 | if ($contacts && $accounts) |
| 865 | 864 | { |
| 866 | - $contacts = array_merge($contacts,$accounts); |
|
| 867 | - usort($contacts,create_function('$a,$b','return strcasecmp($a["n_fn"],$b["n_fn"]);')); |
|
| 865 | + $contacts = array_merge($contacts, $accounts); |
|
| 866 | + usort($contacts, create_function('$a,$b', 'return strcasecmp($a["n_fn"],$b["n_fn"]);')); |
|
| 868 | 867 | } |
| 869 | - elseif($accounts) |
|
| 868 | + elseif ($accounts) |
|
| 870 | 869 | { |
| 871 | - $contacts =& $accounts; |
|
| 870 | + $contacts = & $accounts; |
|
| 872 | 871 | } |
| 873 | 872 | unset($accounts); |
| 874 | 873 | } |
| 875 | 874 | } |
| 876 | - if(is_array($contacts)) { |
|
| 875 | + if (is_array($contacts)) { |
|
| 877 | 876 | $mailtoArray = array(); |
| 878 | 877 | $primary = $addressbookprefs['distributionListPreferredMail']; |
| 879 | 878 | if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
| 880 | - $secondary = ($primary == 'email'?'email_home':'email'); |
|
| 879 | + $secondary = ($primary == 'email' ? 'email_home' : 'email'); |
|
| 881 | 880 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
| 882 | - foreach($contacts as $contact) { |
|
| 883 | - $innerCounter=0; |
|
| 884 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
| 881 | + foreach ($contacts as $contact) { |
|
| 882 | + $innerCounter = 0; |
|
| 883 | + foreach (array($contact[$primary], $contact[$secondary]) as $email) { |
|
| 885 | 884 | // use pref distributionListPreferredMail for the primary address |
| 886 | 885 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 887 | - $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
|
| 888 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
| 889 | - $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
|
| 890 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
| 886 | + $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email); |
|
| 887 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
| 888 | + $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>'); |
|
| 889 | + if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) { |
|
| 891 | 890 | $i++; |
| 892 | 891 | $innerCounter++; |
| 893 | 892 | $mailtoArray[$i] = $completeMailString; |
@@ -896,8 +895,8 @@ discard block |
||
| 896 | 895 | } |
| 897 | 896 | } |
| 898 | 897 | //error_log(__METHOD__.__LINE__.array2string($mailtoArray)); |
| 899 | - $alreadyProcessed['to']='to'; |
|
| 900 | - $content['to']=$mailtoArray; |
|
| 898 | + $alreadyProcessed['to'] = 'to'; |
|
| 899 | + $content['to'] = $mailtoArray; |
|
| 901 | 900 | } |
| 902 | 901 | } |
| 903 | 902 | } |
@@ -912,20 +911,20 @@ discard block |
||
| 912 | 911 | $types = (array)$_REQUEST['preset']['type']; |
| 913 | 912 | //if (!empty($types) && in_array('text/calendar; method=request',$types)) |
| 914 | 913 | $files = (array)$_REQUEST['preset']['file']; |
| 915 | - foreach($files as $k => $path) |
|
| 914 | + foreach ($files as $k => $path) |
|
| 916 | 915 | { |
| 917 | - if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false) |
|
| 916 | + if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false) |
|
| 918 | 917 | { |
| 919 | 918 | $insertSigOnTop = 'below'; |
| 920 | 919 | } |
| 921 | 920 | //error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs'))); |
| 922 | - if (parse_url($path,PHP_URL_SCHEME == 'vfs')) |
|
| 921 | + if (parse_url($path, PHP_URL_SCHEME == 'vfs')) |
|
| 923 | 922 | { |
| 924 | 923 | //Vfs::load_wrapper('vfs'); |
| 925 | 924 | $type = Vfs::mime_content_type($path); |
| 926 | 925 | // special handling for attaching vCard of iCal --> use their link-title as name |
| 927 | - if (substr($path,-7) != '/.entry' || |
|
| 928 | - !(list($app,$id) = array_slice(explode('/',$path),-3)) || |
|
| 926 | + if (substr($path, -7) != '/.entry' || |
|
| 927 | + !(list($app, $id) = array_slice(explode('/', $path), -3)) || |
|
| 929 | 928 | !($name = Link::title($app, $id))) |
| 930 | 929 | { |
| 931 | 930 | $name = Vfs::decodePath(Vfs::basename($path)); |
@@ -939,7 +938,7 @@ discard block |
||
| 939 | 938 | { |
| 940 | 939 | $type = $types[$k]; |
| 941 | 940 | } |
| 942 | - $path = str_replace('+','%2B',$path); |
|
| 941 | + $path = str_replace('+', '%2B', $path); |
|
| 943 | 942 | $formData = array( |
| 944 | 943 | 'name' => $name, |
| 945 | 944 | 'type' => $type, |
@@ -952,7 +951,7 @@ discard block |
||
| 952 | 951 | Framework::message(lang('Directories have to be shared.'), 'info'); |
| 953 | 952 | } |
| 954 | 953 | } |
| 955 | - elseif(is_readable($path)) |
|
| 954 | + elseif (is_readable($path)) |
|
| 956 | 955 | { |
| 957 | 956 | $formData = array( |
| 958 | 957 | 'name' => isset($names[$k]) ? $names[$k] : basename($path), |
@@ -965,28 +964,28 @@ discard block |
||
| 965 | 964 | { |
| 966 | 965 | continue; |
| 967 | 966 | } |
| 968 | - $this->addAttachment($formData,$content,($alwaysAttachVCardAtCompose?true:false)); |
|
| 967 | + $this->addAttachment($formData, $content, ($alwaysAttachVCardAtCompose ?true:false)); |
|
| 969 | 968 | } |
| 970 | 969 | $remember = array(); |
| 971 | 970 | if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))) |
| 972 | 971 | { |
| 973 | - foreach(array_keys($content) as $k) |
|
| 972 | + foreach (array_keys($content) as $k) |
|
| 974 | 973 | { |
| 975 | - if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k])) |
|
| 974 | + if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k])) |
|
| 976 | 975 | { |
| 977 | - $alreadyProcessed[$k]=$k; |
|
| 976 | + $alreadyProcessed[$k] = $k; |
|
| 978 | 977 | $remember[$k] = $this->sessionData[$k]; |
| 979 | 978 | } |
| 980 | 979 | } |
| 981 | 980 | } |
| 982 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
| 981 | + if (!empty($remember)) $content = array_merge($content, $remember); |
|
| 983 | 982 | } |
| 984 | - foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
|
| 983 | + foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name) |
|
| 985 | 984 | { |
| 986 | 985 | //always handle mimeType |
| 987 | - if ($name=='mimeType' && $_REQUEST['preset'][$name]) |
|
| 986 | + if ($name == 'mimeType' && $_REQUEST['preset'][$name]) |
|
| 988 | 987 | { |
| 989 | - $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
|
| 988 | + $_content[$name] = $content[$name] = $_REQUEST['preset'][$name]; |
|
| 990 | 989 | } |
| 991 | 990 | //skip if already processed by "preset Routines" |
| 992 | 991 | if ($alreadyProcessed[$name]) continue; |
@@ -999,36 +998,36 @@ discard block |
||
| 999 | 998 | { |
| 1000 | 999 | $content['to'] = base64_decode($_REQUEST['send_to']); |
| 1001 | 1000 | // first check if there is a questionmark or ampersand |
| 1002 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
| 1001 | + if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2); |
|
| 1003 | 1002 | $content['to'] = html_entity_decode($content['to']); |
| 1004 | - if (($at_pos = strpos($content['to'],'@')) !== false) |
|
| 1003 | + if (($at_pos = strpos($content['to'], '@')) !== false) |
|
| 1005 | 1004 | { |
| 1006 | - if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false) |
|
| 1005 | + if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false) |
|
| 1007 | 1006 | { |
| 1008 | 1007 | //list($email,$addoptions) = explode('&',$value,2); |
| 1009 | - $email = substr($content['to'],0,$amp_pos+$at_pos); |
|
| 1010 | - $rest = substr($content['to'], $amp_pos+$at_pos+1); |
|
| 1008 | + $email = substr($content['to'], 0, $amp_pos + $at_pos); |
|
| 1009 | + $rest = substr($content['to'], $amp_pos + $at_pos + 1); |
|
| 1011 | 1010 | //error_log(__METHOD__.__LINE__.$email.' '.$rest); |
| 1012 | 1011 | $content['to'] = $email; |
| 1013 | 1012 | } |
| 1014 | 1013 | } |
| 1015 | - if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
| 1014 | + if (strpos($content['to'], '%40') !== false) $content['to'] = Api\Html::purify(str_replace('%40', '@', $content['to'])); |
|
| 1016 | 1015 | $rarr = array(Api\Html::purify($rest)); |
| 1017 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
| 1016 | + if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest); |
|
| 1018 | 1017 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
| 1019 | 1018 | $karr = array(); |
| 1020 | 1019 | foreach ($rarr as &$rval) |
| 1021 | 1020 | { |
| 1022 | 1021 | //must contain = |
| 1023 | - if (strpos($rval,'=')!== false) |
|
| 1022 | + if (strpos($rval, '=') !== false) |
|
| 1024 | 1023 | { |
| 1025 | - list($k,$v) = explode('=',$rval,2); |
|
| 1024 | + list($k, $v) = explode('=', $rval, 2); |
|
| 1026 | 1025 | $karr[$k] = (string)$v; |
| 1027 | - unset($k,$v); |
|
| 1026 | + unset($k, $v); |
|
| 1028 | 1027 | } |
| 1029 | 1028 | } |
| 1030 | 1029 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
| 1031 | - foreach(array('cc','bcc','subject','body') as $name) |
|
| 1030 | + foreach (array('cc', 'bcc', 'subject', 'body') as $name) |
|
| 1032 | 1031 | { |
| 1033 | 1032 | if ($karr[$name]) $content[$name] = $karr[$name]; |
| 1034 | 1033 | } |
@@ -1040,17 +1039,17 @@ discard block |
||
| 1040 | 1039 | if ($isFirstLoad && !empty($_REQUEST['mimeType'])) |
| 1041 | 1040 | { |
| 1042 | 1041 | $_content['mimeType'] = $content['mimeType']; |
| 1043 | - if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html') |
|
| 1042 | + if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html') |
|
| 1044 | 1043 | { |
| 1045 | - $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
| 1046 | - $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body'])); |
|
| 1044 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
| 1045 | + $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body'])); |
|
| 1047 | 1046 | } |
| 1048 | - if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html') |
|
| 1047 | + if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html') |
|
| 1049 | 1048 | { |
| 1050 | - $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
| 1049 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
| 1051 | 1050 | $content['body'] = "<pre>".$content['body']."</pre>"; |
| 1052 | 1051 | // 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); |
|
| 1052 | + 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); |
|
| 1054 | 1053 | } |
| 1055 | 1054 | } |
| 1056 | 1055 | else |
@@ -1058,24 +1057,24 @@ discard block |
||
| 1058 | 1057 | // try to enforce a mimeType on reply ( if type is not of the wanted type ) |
| 1059 | 1058 | if ($isReply) |
| 1060 | 1059 | { |
| 1061 | - if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" && |
|
| 1060 | + if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" && |
|
| 1062 | 1061 | $content['mimeType'] == 'html') |
| 1063 | 1062 | { |
| 1064 | - $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
| 1065 | - $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body'])); |
|
| 1063 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
| 1064 | + $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body'])); |
|
| 1066 | 1065 | } |
| 1067 | - if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" && |
|
| 1066 | + if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" && |
|
| 1068 | 1067 | $content['mimeType'] != 'html') |
| 1069 | 1068 | { |
| 1070 | - $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
| 1069 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
| 1071 | 1070 | $content['body'] = "<pre>".$content['body']."</pre>"; |
| 1072 | 1071 | // 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); |
|
| 1072 | + 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); |
|
| 1074 | 1073 | } |
| 1075 | 1074 | } |
| 1076 | 1075 | } |
| 1077 | 1076 | |
| 1078 | - if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false) |
|
| 1077 | + if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible() === false) |
|
| 1079 | 1078 | { |
| 1080 | 1079 | $_content['mimeType'] = $content['mimeType'] = 'plain'; |
| 1081 | 1080 | $content['body'] = $this->convertHTMLToText($content['body']); |
@@ -1094,38 +1093,38 @@ discard block |
||
| 1094 | 1093 | //_debug_array(($presetSig ? $presetSig : $content['mailidentity'])); |
| 1095 | 1094 | try |
| 1096 | 1095 | { |
| 1097 | - $signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true); |
|
| 1096 | + $signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true); |
|
| 1098 | 1097 | } |
| 1099 | 1098 | catch (Exception $e) |
| 1100 | 1099 | { |
| 1101 | 1100 | //PROBABLY NOT FOUND |
| 1102 | - $signature=array(); |
|
| 1101 | + $signature = array(); |
|
| 1103 | 1102 | } |
| 1104 | 1103 | if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) && |
| 1105 | 1104 | $this->mailPreferences['disableRulerForSignatureSeparation']) || |
| 1106 | 1105 | empty($signature['ident_signature']) || |
| 1107 | - trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='' || |
|
| 1106 | + trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '' || |
|
| 1108 | 1107 | $this->mailPreferences['insertSignatureAtTopOfMessage'] == '1') |
| 1109 | 1108 | { |
| 1110 | 1109 | $disableRuler = true; |
| 1111 | 1110 | } |
| 1112 | 1111 | $font_span = $font_part = ''; |
| 1113 | - if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
| 1112 | + if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
| 1114 | 1113 | // User preferences for style |
| 1115 | 1114 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
| 1116 | 1115 | $font_size = Api\Html\CkEditorConfig::font_size_from_prefs(); |
| 1117 | - $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
|
| 1116 | + $font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">'; |
|
| 1118 | 1117 | $font_span = $font_part.'​</span>'; |
| 1119 | 1118 | if (empty($font) && empty($font_size)) $font_span = ''; |
| 1120 | 1119 | } |
| 1121 | 1120 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
| 1122 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
| 1121 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = ''; |
|
| 1123 | 1122 | //remove possible html header stuff |
| 1124 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1123 | + if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']); |
|
| 1125 | 1124 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
| 1126 | - $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
|
| 1127 | - if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
|
| 1128 | - !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
|
| 1125 | + $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'); |
|
| 1126 | + if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' && |
|
| 1127 | + !(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop |
|
| 1129 | 1128 | ) |
| 1130 | 1129 | { |
| 1131 | 1130 | // ON tOP OR BELOW? pREF CAN TELL |
@@ -1135,57 +1134,57 @@ discard block |
||
| 1135 | 1134 | '1' => 'before reply, visible during compose', |
| 1136 | 1135 | 'no_belowaftersend' => 'appended after reply before sending', |
| 1137 | 1136 | */ |
| 1138 | - $insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below')); |
|
| 1139 | - $sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
| 1137 | + $insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below')); |
|
| 1138 | + $sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
| 1140 | 1139 | if ($content['mimeType'] == 'html') |
| 1141 | 1140 | { |
| 1142 | - $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
|
| 1143 | - foreach($blockElements as $e) |
|
| 1141 | + $sigTextStartsWithBlockElement = ($disableRuler ?false:true); |
|
| 1142 | + foreach ($blockElements as $e) |
|
| 1144 | 1143 | { |
| 1145 | 1144 | if ($sigTextStartsWithBlockElement) break; |
| 1146 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
| 1145 | + if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true; |
|
| 1147 | 1146 | } |
| 1148 | 1147 | } |
| 1149 | - if($content['mimeType'] == 'html') { |
|
| 1148 | + if ($content['mimeType'] == 'html') { |
|
| 1150 | 1149 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
| 1151 | 1150 | $inbetween = ''; |
| 1152 | 1151 | } else { |
| 1153 | - $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
| 1152 | + $before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
| 1154 | 1153 | $inbetween = "\r\n"; |
| 1155 | 1154 | } |
| 1156 | 1155 | if ($content['mimeType'] == 'html') |
| 1157 | 1156 | { |
| 1158 | - $sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>"); |
|
| 1157 | + $sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>"); |
|
| 1159 | 1158 | } |
| 1160 | 1159 | |
| 1161 | 1160 | if ($insertSigOnTop === 'below') |
| 1162 | 1161 | { |
| 1163 | - $content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)); |
|
| 1162 | + $content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)); |
|
| 1164 | 1163 | } |
| 1165 | 1164 | else |
| 1166 | 1165 | { |
| 1167 | - $content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body']; |
|
| 1166 | + $content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body']; |
|
| 1168 | 1167 | } |
| 1169 | 1168 | } |
| 1170 | 1169 | else |
| 1171 | 1170 | { |
| 1172 | - $content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?' ':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":""); |
|
| 1171 | + $content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?' ':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : ""); |
|
| 1173 | 1172 | } |
| 1174 | 1173 | //error_log(__METHOD__.__LINE__.$content['body']); |
| 1175 | 1174 | |
| 1176 | 1175 | // prepare body |
| 1177 | 1176 | // in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct |
| 1178 | - $content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8'); |
|
| 1177 | + $content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8'); |
|
| 1179 | 1178 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 1180 | 1179 | |
| 1181 | 1180 | // get identities of all accounts as "$acc_id:$ident_id" => $identity |
| 1182 | 1181 | $sel_options['mailaccount'] = $identities = array(); |
| 1183 | - foreach(Mail\Account::search(true,false) as $acc_id => $account) |
|
| 1182 | + foreach (Mail\Account::search(true, false) as $acc_id => $account) |
|
| 1184 | 1183 | { |
| 1185 | 1184 | // do NOT add SMTP only accounts as identities |
| 1186 | 1185 | if (!$account->is_imap(false)) continue; |
| 1187 | 1186 | |
| 1188 | - foreach($account->identities($acc_id) as $ident_id => $identity) |
|
| 1187 | + foreach ($account->identities($acc_id) as $ident_id => $identity) |
|
| 1189 | 1188 | { |
| 1190 | 1189 | $sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity; |
| 1191 | 1190 | $identities[$ident_id] = $identity; |
@@ -1196,7 +1195,7 @@ discard block |
||
| 1196 | 1195 | //$content['bcc'] = array('[email protected]','[email protected]'); |
| 1197 | 1196 | // address stuff like from, to, cc, replyto |
| 1198 | 1197 | $destinationRows = 0; |
| 1199 | - foreach(self::$destinations as $destination) { |
|
| 1198 | + foreach (self::$destinations as $destination) { |
|
| 1200 | 1199 | if (!is_array($content[$destination])) |
| 1201 | 1200 | { |
| 1202 | 1201 | if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
@@ -1204,22 +1203,22 @@ discard block |
||
| 1204 | 1203 | $addr_content = $content[strtolower($destination)]; |
| 1205 | 1204 | // we clear the given address array and rebuild it |
| 1206 | 1205 | unset($content[strtolower($destination)]); |
| 1207 | - foreach((array)$addr_content as $key => $value) { |
|
| 1208 | - if ($value=="NIL@NIL") continue; |
|
| 1209 | - if ($destination=='replyto' && str_replace('"','',$value) == |
|
| 1210 | - str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()])) |
|
| 1206 | + foreach ((array)$addr_content as $key => $value) { |
|
| 1207 | + if ($value == "NIL@NIL") continue; |
|
| 1208 | + if ($destination == 'replyto' && str_replace('"', '', $value) == |
|
| 1209 | + str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()])) |
|
| 1211 | 1210 | { |
| 1212 | 1211 | // preserve/restore the value to content. |
| 1213 | - $content[strtolower($destination)][]=$value; |
|
| 1212 | + $content[strtolower($destination)][] = $value; |
|
| 1214 | 1213 | continue; |
| 1215 | 1214 | } |
| 1216 | 1215 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
| 1217 | - $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
|
| 1218 | - foreach(Mail::parseAddressList($value) as $addressObject) { |
|
| 1216 | + $value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT)); |
|
| 1217 | + foreach (Mail::parseAddressList($value) as $addressObject) { |
|
| 1219 | 1218 | if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
| 1220 | - $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
|
| 1219 | + $address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
|
| 1221 | 1220 | //$address = Mail::htmlentities($address, $this->displayCharset); |
| 1222 | - $content[strtolower($destination)][]=$address; |
|
| 1221 | + $content[strtolower($destination)][] = $address; |
|
| 1223 | 1222 | $destinationRows++; |
| 1224 | 1223 | } |
| 1225 | 1224 | } |
@@ -1227,10 +1226,10 @@ discard block |
||
| 1227 | 1226 | if ($_content) |
| 1228 | 1227 | { |
| 1229 | 1228 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
| 1230 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
| 1231 | - $content = array_merge($content,$_content); |
|
| 1229 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']); |
|
| 1230 | + $content = array_merge($content, $_content); |
|
| 1232 | 1231 | |
| 1233 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1232 | + if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true); |
|
| 1234 | 1233 | if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
| 1235 | 1234 | } |
| 1236 | 1235 | else |
@@ -1239,12 +1238,12 @@ discard block |
||
| 1239 | 1238 | $content['mailaccount'] = $this->mail_bo->profileID; |
| 1240 | 1239 | //error_log(__METHOD__.__LINE__.$content['body']); |
| 1241 | 1240 | } |
| 1242 | - $content['is_html'] = ($content['mimeType'] == 'html'?true:''); |
|
| 1243 | - $content['is_plain'] = ($content['mimeType'] == 'html'?'':true); |
|
| 1244 | - $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body']; |
|
| 1245 | - $content['showtempname']=0; |
|
| 1241 | + $content['is_html'] = ($content['mimeType'] == 'html' ?true:''); |
|
| 1242 | + $content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true); |
|
| 1243 | + $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body']; |
|
| 1244 | + $content['showtempname'] = 0; |
|
| 1246 | 1245 | //if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments'])); |
| 1247 | - $content['attachments']=(is_array($content['attachments'])&&is_array($content['uploadForCompose'])?array_merge($content['attachments'],(!empty($content['uploadForCompose'])?$content['uploadForCompose']:array())):(is_array($content['uploadForCompose'])?$content['uploadForCompose']:(is_array($content['attachments'])?$content['attachments']:null))); |
|
| 1246 | + $content['attachments'] = (is_array($content['attachments']) && is_array($content['uploadForCompose']) ?array_merge($content['attachments'], (!empty($content['uploadForCompose']) ? $content['uploadForCompose'] : array())) : (is_array($content['uploadForCompose']) ? $content['uploadForCompose'] : (is_array($content['attachments']) ? $content['attachments'] : null))); |
|
| 1248 | 1247 | //if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0; |
| 1249 | 1248 | $content['no_griddata'] = empty($content['attachments']); |
| 1250 | 1249 | $preserv['attachments'] = $content['attachments']; |
@@ -1278,12 +1277,12 @@ discard block |
||
| 1278 | 1277 | $sel_options['mimeType'] = self::$mimeTypes; |
| 1279 | 1278 | $sel_options['priority'] = self::$priorities; |
| 1280 | 1279 | $sel_options['filemode'] = Vfs\Sharing::$modes; |
| 1281 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
| 1280 | + if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3; |
|
| 1282 | 1281 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 1283 | 1282 | $etpl = new Etemplate('mail.compose'); |
| 1284 | 1283 | |
| 1285 | 1284 | $etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content)); |
| 1286 | - if ($content['mimeType']=='html') |
|
| 1285 | + if ($content['mimeType'] == 'html') |
|
| 1287 | 1286 | { |
| 1288 | 1287 | //mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]" |
| 1289 | 1288 | $_htmlConfig = Mail::$htmLawed_config; |
@@ -1293,23 +1292,23 @@ discard block |
||
| 1293 | 1292 | // and not the eGroupware wide pref to prevent users from trying things that will potentially not work |
| 1294 | 1293 | // or not work as expected, as a full featured editor that may be wanted in other apps |
| 1295 | 1294 | // is way overloading the "normal" needs for composing mails |
| 1296 | - $content['rtfEditorFeatures']='simple-withimage';//Api\Html\CkEditorConfig::get_ckeditor_config(); |
|
| 1295 | + $content['rtfEditorFeatures'] = 'simple-withimage'; //Api\Html\CkEditorConfig::get_ckeditor_config(); |
|
| 1297 | 1296 | //$content['rtfEditorFeatures']='advanced';//Api\Html\CkEditorConfig::get_ckeditor_config(); |
| 1298 | - $content['validation_rules']= json_encode(Mail::$htmLawed_config); |
|
| 1299 | - $etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']); |
|
| 1300 | - $etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']); |
|
| 1297 | + $content['validation_rules'] = json_encode(Mail::$htmLawed_config); |
|
| 1298 | + $etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']); |
|
| 1299 | + $etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']); |
|
| 1301 | 1300 | Mail::$htmLawed_config = $_htmlConfig; |
| 1302 | 1301 | } |
| 1303 | 1302 | |
| 1304 | - if (isset($content['composeID'])&&!empty($content['composeID'])) |
|
| 1303 | + if (isset($content['composeID']) && !empty($content['composeID'])) |
|
| 1305 | 1304 | { |
| 1306 | 1305 | $composeCache = $content; |
| 1307 | 1306 | unset($composeCache['body']); |
| 1308 | 1307 | unset($composeCache['mail_htmltext']); |
| 1309 | 1308 | unset($composeCache['mail_plaintext']); |
| 1310 | - Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2); |
|
| 1309 | + Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2); |
|
| 1311 | 1310 | } |
| 1312 | - if (!isset($_content['serverID'])||empty($_content['serverID'])) |
|
| 1311 | + if (!isset($_content['serverID']) || empty($_content['serverID'])) |
|
| 1313 | 1312 | { |
| 1314 | 1313 | $content['serverID'] = $this->mail_bo->profileID; |
| 1315 | 1314 | } |
@@ -1325,13 +1324,13 @@ discard block |
||
| 1325 | 1324 | $preserv['list-id'] = $content['list-id']; |
| 1326 | 1325 | $preserv['mode'] = $content['mode']; |
| 1327 | 1326 | // convert it back to checkbox expectations |
| 1328 | - if($content['mimeType'] == 'html') { |
|
| 1329 | - $content['mimeType']=1; |
|
| 1327 | + if ($content['mimeType'] == 'html') { |
|
| 1328 | + $content['mimeType'] = 1; |
|
| 1330 | 1329 | } else { |
| 1331 | - $content['mimeType']=0; |
|
| 1330 | + $content['mimeType'] = 0; |
|
| 1332 | 1331 | } |
| 1333 | 1332 | // set the current selected mailaccount as param for folderselection |
| 1334 | - $etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount'])); |
|
| 1333 | + $etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount'])); |
|
| 1335 | 1334 | // join again mailaccount and identity |
| 1336 | 1335 | $content['mailaccount'] .= ':'.$content['mailidentity']; |
| 1337 | 1336 | //Try to set the initial selected account to the first identity match found |
@@ -1350,14 +1349,14 @@ discard block |
||
| 1350 | 1349 | } |
| 1351 | 1350 | } |
| 1352 | 1351 | // Resolve distribution list before send content to client |
| 1353 | - foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
|
| 1352 | + foreach (array('to', 'cc', 'bcc', 'replyto') as $f) |
|
| 1354 | 1353 | { |
| 1355 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1354 | + if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]); |
|
| 1356 | 1355 | } |
| 1357 | 1356 | |
| 1358 | 1357 | $content['to'] = self::resolveEmailAddressList($content['to']); |
| 1359 | 1358 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 1360 | - $etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2); |
|
| 1359 | + $etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2); |
|
| 1361 | 1360 | } |
| 1362 | 1361 | |
| 1363 | 1362 | /** |
@@ -1378,9 +1377,9 @@ discard block |
||
| 1378 | 1377 | $content = array(); |
| 1379 | 1378 | //error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply"); |
| 1380 | 1379 | // on forward we may have to support multiple ids |
| 1381 | - if ($from=='forward') |
|
| 1380 | + if ($from == 'forward') |
|
| 1382 | 1381 | { |
| 1383 | - $replyIds = explode(',',$mail_id); |
|
| 1382 | + $replyIds = explode(',', $mail_id); |
|
| 1384 | 1383 | $mail_id = $replyIds[0]; |
| 1385 | 1384 | } |
| 1386 | 1385 | $hA = mail_ui::splitRowID($mail_id); |
@@ -1392,15 +1391,15 @@ discard block |
||
| 1392 | 1391 | $this->changeProfile($icServerID); |
| 1393 | 1392 | } |
| 1394 | 1393 | $icServer = $this->mail_bo->icServer; |
| 1395 | - if (!empty($folder) && !empty($msgUID) ) |
|
| 1394 | + if (!empty($folder) && !empty($msgUID)) |
|
| 1396 | 1395 | { |
| 1397 | 1396 | // this fill the session data with the values from the original email |
| 1398 | - switch($from) |
|
| 1397 | + switch ($from) |
|
| 1399 | 1398 | { |
| 1400 | 1399 | case 'composefromdraft': |
| 1401 | 1400 | case 'composeasnew': |
| 1402 | 1401 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
| 1403 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
| 1402 | + if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft'; |
|
| 1404 | 1403 | $content['processedmail_id'] = $mail_id; |
| 1405 | 1404 | |
| 1406 | 1405 | $_focusElement = 'body'; |
@@ -1416,7 +1415,7 @@ discard block |
||
| 1416 | 1415 | $isReply = true; |
| 1417 | 1416 | break; |
| 1418 | 1417 | case 'forward': |
| 1419 | - $mode = ($_GET['mode']=='forwardinline'?'inline':'asmail'); |
|
| 1418 | + $mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail'); |
|
| 1420 | 1419 | // this fill the session data with the values from the original email |
| 1421 | 1420 | foreach ($replyIds as &$mail_id) |
| 1422 | 1421 | { |
@@ -1426,14 +1425,14 @@ discard block |
||
| 1426 | 1425 | $folder = $hA['folder']; |
| 1427 | 1426 | $content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode); |
| 1428 | 1427 | } |
| 1429 | - $content['processedmail_id'] = implode(',',$replyIds); |
|
| 1428 | + $content['processedmail_id'] = implode(',', $replyIds); |
|
| 1430 | 1429 | $content['mode'] = 'forward'; |
| 1431 | - $isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline'); |
|
| 1432 | - $suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution |
|
| 1430 | + $isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline'); |
|
| 1431 | + $suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution |
|
| 1433 | 1432 | $_focusElement = 'to'; |
| 1434 | 1433 | break; |
| 1435 | 1434 | default: |
| 1436 | - error_log('Unhandled compose source: ' . $from); |
|
| 1435 | + error_log('Unhandled compose source: '.$from); |
|
| 1437 | 1436 | } |
| 1438 | 1437 | } |
| 1439 | 1438 | else if ($from == 'merge' && $_REQUEST['document']) |
@@ -1448,12 +1447,12 @@ discard block |
||
| 1448 | 1447 | $document_merge = new $merge_class(); |
| 1449 | 1448 | $this->mail_bo->openConnection(); |
| 1450 | 1449 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
| 1451 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
| 1450 | + if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids); |
|
| 1452 | 1451 | try |
| 1453 | 1452 | { |
| 1454 | 1453 | $merged_mail_id = ''; |
| 1455 | 1454 | $folder = ''; |
| 1456 | - if(($error = $document_merge->check_document($_REQUEST['document'],''))) |
|
| 1455 | + if (($error = $document_merge->check_document($_REQUEST['document'], ''))) |
|
| 1457 | 1456 | { |
| 1458 | 1457 | $content['msg'] = $error; |
| 1459 | 1458 | return $content; |
@@ -1463,10 +1462,10 @@ discard block |
||
| 1463 | 1462 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; |
| 1464 | 1463 | |
| 1465 | 1464 | // Actually do the merge |
| 1466 | - if(count($merge_ids) <= 1) |
|
| 1465 | + if (count($merge_ids) <= 1) |
|
| 1467 | 1466 | { |
| 1468 | 1467 | $results = $this->mail_bo->importMessageToMergeAndSend( |
| 1469 | - $document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id |
|
| 1468 | + $document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id |
|
| 1470 | 1469 | ); |
| 1471 | 1470 | |
| 1472 | 1471 | // Open compose |
@@ -1477,9 +1476,9 @@ discard block |
||
| 1477 | 1476 | } |
| 1478 | 1477 | else |
| 1479 | 1478 | { |
| 1480 | - $success = implode(', ',$results['success']); |
|
| 1479 | + $success = implode(', ', $results['success']); |
|
| 1481 | 1480 | $fail = implode(', ', $results['failed']); |
| 1482 | - if($success) Framework::message($success, 'success'); |
|
| 1481 | + if ($success) Framework::message($success, 'success'); |
|
| 1483 | 1482 | Framework::window_close($fail); |
| 1484 | 1483 | } |
| 1485 | 1484 | } |
@@ -1507,22 +1506,22 @@ discard block |
||
| 1507 | 1506 | return 1; |
| 1508 | 1507 | } |
| 1509 | 1508 | |
| 1510 | - function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false) |
|
| 1509 | + function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false) |
|
| 1511 | 1510 | { |
| 1512 | 1511 | $stripalltags = true; |
| 1513 | 1512 | // third param is stripalltags, we may not need that, if the source is already in ascii |
| 1514 | - if (!$sourceishtml) $stripalltags=false; |
|
| 1515 | - return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags); |
|
| 1513 | + if (!$sourceishtml) $stripalltags = false; |
|
| 1514 | + return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags); |
|
| 1516 | 1515 | } |
| 1517 | 1516 | |
| 1518 | 1517 | function generateRFC822Address($_addressObject) |
| 1519 | 1518 | { |
| 1520 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
| 1521 | - return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
|
| 1522 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
| 1523 | - return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
|
| 1519 | + if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
| 1520 | + return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE')); |
|
| 1521 | + } elseif ($_addressObject->mailbox && $_addressObject->host) { |
|
| 1522 | + return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE')); |
|
| 1524 | 1523 | } else { |
| 1525 | - return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
|
| 1524 | + return $this->mail_bo->decode_header($_addressObject->mailbox, true); |
|
| 1526 | 1525 | } |
| 1527 | 1526 | } |
| 1528 | 1527 | |
@@ -1537,9 +1536,9 @@ discard block |
||
| 1537 | 1536 | // $_mode can be: |
| 1538 | 1537 | // single: for a reply to one address |
| 1539 | 1538 | // all: for a reply to all |
| 1540 | - function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL) |
|
| 1539 | + function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL) |
|
| 1541 | 1540 | { |
| 1542 | - unset($_icServer); // not used |
|
| 1541 | + unset($_icServer); // not used |
|
| 1543 | 1542 | $this->sessionData['to'] = array(); |
| 1544 | 1543 | |
| 1545 | 1544 | $mail_bo = $this->mail_bo; |
@@ -1548,7 +1547,7 @@ discard block |
||
| 1548 | 1547 | |
| 1549 | 1548 | // get message headers for specified message |
| 1550 | 1549 | #$headers = $mail_bo->getMessageHeader($_folder, $_uid); |
| 1551 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
| 1550 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
| 1552 | 1551 | $addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID); |
| 1553 | 1552 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
| 1554 | 1553 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
@@ -1556,10 +1555,10 @@ discard block |
||
| 1556 | 1555 | |
| 1557 | 1556 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
| 1558 | 1557 | if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
| 1559 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
| 1560 | - $fval=$val; |
|
| 1558 | + foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) { |
|
| 1559 | + $fval = $val; |
|
| 1561 | 1560 | $icServerID = $mail_bo->icServer->ImapServerId; |
| 1562 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
| 1561 | + if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2); |
|
| 1563 | 1562 | if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
| 1564 | 1563 | if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
| 1565 | 1564 | } |
@@ -1595,71 +1594,71 @@ discard block |
||
| 1595 | 1594 | } |
| 1596 | 1595 | } |
| 1597 | 1596 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
| 1598 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1597 | + if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1599 | 1598 | $this->sessionData['uid'] = $_uid; |
| 1600 | 1599 | $this->sessionData['messageFolder'] = $_folder; |
| 1601 | 1600 | $this->sessionData['isDraft'] = true; |
| 1602 | 1601 | $foundAddresses = array(); |
| 1603 | - foreach((array)$headers['CC'] as $val) { |
|
| 1604 | - $rfcAddr=Mail::parseAddressList($val); |
|
| 1602 | + foreach ((array)$headers['CC'] as $val) { |
|
| 1603 | + $rfcAddr = Mail::parseAddressList($val); |
|
| 1605 | 1604 | $_rfcAddr = $rfcAddr[0]; |
| 1606 | 1605 | if (!$_rfcAddr->valid) continue; |
| 1607 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1606 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) { |
|
| 1608 | 1607 | continue; |
| 1609 | 1608 | } |
| 1610 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1611 | - if(!$foundAddresses[$keyemail]) { |
|
| 1612 | - $address = $this->mail_bo->decode_header($val,true); |
|
| 1609 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1610 | + if (!$foundAddresses[$keyemail]) { |
|
| 1611 | + $address = $this->mail_bo->decode_header($val, true); |
|
| 1613 | 1612 | $this->sessionData['cc'][] = $val; |
| 1614 | 1613 | $foundAddresses[$keyemail] = true; |
| 1615 | 1614 | } |
| 1616 | 1615 | } |
| 1617 | 1616 | |
| 1618 | - foreach((array)$headers['TO'] as $val) { |
|
| 1619 | - if(!is_array($val)) |
|
| 1617 | + foreach ((array)$headers['TO'] as $val) { |
|
| 1618 | + if (!is_array($val)) |
|
| 1620 | 1619 | { |
| 1621 | 1620 | $this->sessionData['to'][] = $val; |
| 1622 | 1621 | continue; |
| 1623 | 1622 | } |
| 1624 | - $rfcAddr=Mail::parseAddressList($val); |
|
| 1623 | + $rfcAddr = Mail::parseAddressList($val); |
|
| 1625 | 1624 | $_rfcAddr = $rfcAddr[0]; |
| 1626 | 1625 | if (!$_rfcAddr->valid) continue; |
| 1627 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1626 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) { |
|
| 1628 | 1627 | continue; |
| 1629 | 1628 | } |
| 1630 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1631 | - if(!$foundAddresses[$keyemail]) { |
|
| 1632 | - $address = $this->mail_bo->decode_header($val,true); |
|
| 1629 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1630 | + if (!$foundAddresses[$keyemail]) { |
|
| 1631 | + $address = $this->mail_bo->decode_header($val, true); |
|
| 1633 | 1632 | $this->sessionData['to'][] = $val; |
| 1634 | 1633 | $foundAddresses[$keyemail] = true; |
| 1635 | 1634 | } |
| 1636 | 1635 | } |
| 1637 | 1636 | |
| 1638 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
| 1639 | - $rfcAddr=Mail::parseAddressList($val); |
|
| 1637 | + foreach ((array)$headers['REPLY-TO'] as $val) { |
|
| 1638 | + $rfcAddr = Mail::parseAddressList($val); |
|
| 1640 | 1639 | $_rfcAddr = $rfcAddr[0]; |
| 1641 | 1640 | if (!$_rfcAddr->valid) continue; |
| 1642 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1641 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) { |
|
| 1643 | 1642 | continue; |
| 1644 | 1643 | } |
| 1645 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1646 | - if(!$foundAddresses[$keyemail]) { |
|
| 1647 | - $address = $this->mail_bo->decode_header($val,true); |
|
| 1644 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1645 | + if (!$foundAddresses[$keyemail]) { |
|
| 1646 | + $address = $this->mail_bo->decode_header($val, true); |
|
| 1648 | 1647 | $this->sessionData['replyto'][] = $val; |
| 1649 | 1648 | $foundAddresses[$keyemail] = true; |
| 1650 | 1649 | } |
| 1651 | 1650 | } |
| 1652 | 1651 | |
| 1653 | - foreach((array)$headers['BCC'] as $val) { |
|
| 1654 | - $rfcAddr=Mail::parseAddressList($val); |
|
| 1652 | + foreach ((array)$headers['BCC'] as $val) { |
|
| 1653 | + $rfcAddr = Mail::parseAddressList($val); |
|
| 1655 | 1654 | $_rfcAddr = $rfcAddr[0]; |
| 1656 | 1655 | if (!$_rfcAddr->valid) continue; |
| 1657 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1656 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) { |
|
| 1658 | 1657 | continue; |
| 1659 | 1658 | } |
| 1660 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1661 | - if(!$foundAddresses[$keyemail]) { |
|
| 1662 | - $address = $this->mail_bo->decode_header($val,true); |
|
| 1659 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
| 1660 | + if (!$foundAddresses[$keyemail]) { |
|
| 1661 | + $address = $this->mail_bo->decode_header($val, true); |
|
| 1663 | 1662 | $this->sessionData['bcc'][] = $val; |
| 1664 | 1663 | $foundAddresses[$keyemail] = true; |
| 1665 | 1664 | } |
@@ -1668,48 +1667,48 @@ discard block |
||
| 1668 | 1667 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
| 1669 | 1668 | // remove a printview tag if composing |
| 1670 | 1669 | $searchfor = '/^\['.lang('printview').':\]/'; |
| 1671 | - $this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']); |
|
| 1672 | - $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
|
| 1670 | + $this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']); |
|
| 1671 | + $bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID); |
|
| 1673 | 1672 | //_debug_array($bodyParts); |
| 1674 | 1673 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
| 1675 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 1676 | - $this->sessionData['mimeType'] = 'html'; |
|
| 1674 | + if ($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 1675 | + $this->sessionData['mimeType'] = 'html'; |
|
| 1677 | 1676 | |
| 1678 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1679 | - if($i>0) { |
|
| 1677 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
| 1678 | + if ($i > 0) { |
|
| 1680 | 1679 | $this->sessionData['body'] .= '<hr>'; |
| 1681 | 1680 | } |
| 1682 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 1681 | + if ($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 1683 | 1682 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
| 1684 | 1683 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 1685 | 1684 | } |
| 1686 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1685 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1687 | 1686 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1688 | 1687 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1689 | - $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
|
| 1688 | + $this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body']; |
|
| 1690 | 1689 | } |
| 1691 | 1690 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
| 1692 | 1691 | |
| 1693 | 1692 | } else { |
| 1694 | - $this->sessionData['mimeType'] = 'plain'; |
|
| 1693 | + $this->sessionData['mimeType'] = 'plain'; |
|
| 1695 | 1694 | |
| 1696 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1697 | - if($i>0) { |
|
| 1695 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
| 1696 | + if ($i > 0) { |
|
| 1698 | 1697 | $this->sessionData['body'] .= "<hr>"; |
| 1699 | 1698 | } |
| 1700 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1699 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1701 | 1700 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1702 | 1701 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1703 | - $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
|
| 1702 | + $this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body']; |
|
| 1704 | 1703 | } |
| 1705 | - $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
|
| 1704 | + $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain'); |
|
| 1706 | 1705 | } |
| 1707 | 1706 | |
| 1708 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
| 1709 | - foreach($attachments as $attachment) { |
|
| 1707 | + if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) { |
|
| 1708 | + foreach ($attachments as $attachment) { |
|
| 1710 | 1709 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 1711 | 1710 | $cid = $attachment['cid']; |
| 1712 | - $match=null; |
|
| 1711 | + $match = null; |
|
| 1713 | 1712 | preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match); |
| 1714 | 1713 | //error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match)); |
| 1715 | 1714 | if (!$match || !$attachment['cid']) |
@@ -1729,7 +1728,7 @@ discard block |
||
| 1729 | 1728 | |
| 1730 | 1729 | function getErrorInfo() |
| 1731 | 1730 | { |
| 1732 | - if(isset($this->errorInfo)) { |
|
| 1731 | + if (isset($this->errorInfo)) { |
|
| 1733 | 1732 | $errorInfo = $this->errorInfo; |
| 1734 | 1733 | unset($this->errorInfo); |
| 1735 | 1734 | return $errorInfo; |
@@ -1737,39 +1736,39 @@ discard block |
||
| 1737 | 1736 | return false; |
| 1738 | 1737 | } |
| 1739 | 1738 | |
| 1740 | - function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false) |
|
| 1739 | + function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false) |
|
| 1741 | 1740 | { |
| 1742 | 1741 | if ($_mode) |
| 1743 | 1742 | { |
| 1744 | 1743 | $modebuff = $this->mailPreferences['message_forwarding']; |
| 1745 | 1744 | $this->mailPreferences['message_forwarding'] = $_mode; |
| 1746 | 1745 | } |
| 1747 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
| 1746 | + if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
| 1748 | 1747 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
| 1749 | 1748 | } |
| 1750 | - $mail_bo = $this->mail_bo; |
|
| 1749 | + $mail_bo = $this->mail_bo; |
|
| 1751 | 1750 | $mail_bo->openConnection(); |
| 1752 | 1751 | $mail_bo->reopen($_folder); |
| 1753 | 1752 | |
| 1754 | 1753 | // get message headers for specified message |
| 1755 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder); |
|
| 1754 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder); |
|
| 1756 | 1755 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
| 1757 | 1756 | //_debug_array($headers); exit; |
| 1758 | 1757 | // check for Re: in subject header |
| 1759 | - $this->sessionData['subject'] = "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']); |
|
| 1758 | + $this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']); |
|
| 1760 | 1759 | // the three attributes below are substituted by processedmail_id and mode |
| 1761 | 1760 | //$this->sessionData['sourceFolder']=$_folder; |
| 1762 | 1761 | //$this->sessionData['forwardFlag']='forwarded'; |
| 1763 | 1762 | //$this->sessionData['forwardedUID']=$_uid; |
| 1764 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
| 1765 | - $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
|
| 1766 | - if($headers['SIZE']) |
|
| 1763 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
| 1764 | + $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
|
| 1765 | + if ($headers['SIZE']) |
|
| 1767 | 1766 | $size = $headers['SIZE']; |
| 1768 | 1767 | else |
| 1769 | 1768 | $size = lang('unknown'); |
| 1770 | 1769 | |
| 1771 | 1770 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
| 1772 | - $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
|
| 1771 | + $mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml', |
|
| 1773 | 1772 | 'MESSAGE/RFC822', $size); |
| 1774 | 1773 | } |
| 1775 | 1774 | else |
@@ -1777,10 +1776,10 @@ discard block |
||
| 1777 | 1776 | unset($this->sessionData['in-reply-to']); |
| 1778 | 1777 | unset($this->sessionData['to']); |
| 1779 | 1778 | unset($this->sessionData['cc']); |
| 1780 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) { |
|
| 1779 | + if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID, null, true, false, false))) { |
|
| 1781 | 1780 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
| 1782 | - foreach($attachments as $attachment) { |
|
| 1783 | - if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
|
| 1781 | + foreach ($attachments as $attachment) { |
|
| 1782 | + if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
|
| 1784 | 1783 | { |
| 1785 | 1784 | $this->addMessageAttachment($_uid, $attachment['partID'], |
| 1786 | 1785 | $_folder, |
@@ -1809,7 +1808,7 @@ discard block |
||
| 1809 | 1808 | * @param array $_content the content passed to the function and to be modified |
| 1810 | 1809 | * @return void |
| 1811 | 1810 | */ |
| 1812 | - function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false) |
|
| 1811 | + function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false) |
|
| 1813 | 1812 | { |
| 1814 | 1813 | //error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content)); |
| 1815 | 1814 | |
@@ -1818,7 +1817,7 @@ discard block |
||
| 1818 | 1817 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 1819 | 1818 | try |
| 1820 | 1819 | { |
| 1821 | - $tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false); |
|
| 1820 | + $tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false); |
|
| 1822 | 1821 | } |
| 1823 | 1822 | catch (Api\Exception\WrongUserinput $e) |
| 1824 | 1823 | { |
@@ -1834,8 +1833,8 @@ discard block |
||
| 1834 | 1833 | foreach ((array)$_content['attachments'] as $attach) |
| 1835 | 1834 | { |
| 1836 | 1835 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
| 1837 | - strtolower($_formData['type'])== strtolower($attach['type']) && |
|
| 1838 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
| 1836 | + strtolower($_formData['type']) == strtolower($attach['type']) && |
|
| 1837 | + stripos($_formData['file'], 'vfs://') !== false) return; |
|
| 1839 | 1838 | } |
| 1840 | 1839 | } |
| 1841 | 1840 | if ($attachfailed === false) |
@@ -1847,7 +1846,7 @@ discard block |
||
| 1847 | 1846 | 'tmp_name' => $tmpFileName, |
| 1848 | 1847 | 'size' => $_formData['size'] |
| 1849 | 1848 | ); |
| 1850 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
| 1849 | + if (!is_array($_content['attachments'])) $_content['attachments'] = array(); |
|
| 1851 | 1850 | $_content['attachments'][] = $buffer; |
| 1852 | 1851 | unset($buffer); |
| 1853 | 1852 | } |
@@ -1857,9 +1856,9 @@ discard block |
||
| 1857 | 1856 | } |
| 1858 | 1857 | } |
| 1859 | 1858 | |
| 1860 | - function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail= null) |
|
| 1859 | + function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail = null) |
|
| 1861 | 1860 | { |
| 1862 | - $this->sessionData['attachments'][]=array ( |
|
| 1861 | + $this->sessionData['attachments'][] = array( |
|
| 1863 | 1862 | 'uid' => $_uid, |
| 1864 | 1863 | 'partID' => $_partID, |
| 1865 | 1864 | 'name' => $_name, |
@@ -1867,7 +1866,7 @@ discard block |
||
| 1867 | 1866 | 'size' => $_size, |
| 1868 | 1867 | 'folder' => $_folder, |
| 1869 | 1868 | 'winmailFlag' => $_is_winmail, |
| 1870 | - 'tmp_name' => mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1), |
|
| 1869 | + 'tmp_name' => mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1), |
|
| 1871 | 1870 | ); |
| 1872 | 1871 | } |
| 1873 | 1872 | |
@@ -1876,7 +1875,7 @@ discard block |
||
| 1876 | 1875 | // read attachment data from etemplate request, use tmpname only to identify it |
| 1877 | 1876 | if (($request = Etemplate\Request::read($_GET['etemplate_exec_id']))) |
| 1878 | 1877 | { |
| 1879 | - foreach($request->preserv['attachments'] as $attachment) |
|
| 1878 | + foreach ($request->preserv['attachments'] as $attachment) |
|
| 1880 | 1879 | { |
| 1881 | 1880 | if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
| 1882 | 1881 | } |
@@ -1888,7 +1887,7 @@ discard block |
||
| 1888 | 1887 | } |
| 1889 | 1888 | |
| 1890 | 1889 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 1891 | - if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs') |
|
| 1890 | + if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs') |
|
| 1892 | 1891 | { |
| 1893 | 1892 | Vfs::load_wrapper('vfs'); |
| 1894 | 1893 | } |
@@ -1897,7 +1896,7 @@ discard block |
||
| 1897 | 1896 | { |
| 1898 | 1897 | $attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['tmp_name']); |
| 1899 | 1898 | } |
| 1900 | - if(!file_exists($attachment['tmp_name'])) |
|
| 1899 | + if (!file_exists($attachment['tmp_name'])) |
|
| 1901 | 1900 | { |
| 1902 | 1901 | header('HTTP/1.1 404 Not found'); |
| 1903 | 1902 | die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!'); |
@@ -1910,7 +1909,7 @@ discard block |
||
| 1910 | 1909 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY') |
| 1911 | 1910 | { |
| 1912 | 1911 | $sfxMimeType = $attachment['type']; |
| 1913 | - $buff = explode('.',$attachment['tmp_name']); |
|
| 1912 | + $buff = explode('.', $attachment['tmp_name']); |
|
| 1914 | 1913 | $suffix = ''; |
| 1915 | 1914 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 1916 | 1915 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -1922,10 +1921,10 @@ discard block |
||
| 1922 | 1921 | { |
| 1923 | 1922 | //error_log(__METHOD__."about to call calendar_ical"); |
| 1924 | 1923 | $calendar_ical = new calendar_ical(); |
| 1925 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
| 1924 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
| 1926 | 1925 | //error_log(__METHOD__.array2string($eventid)); |
| 1927 | 1926 | if (!$eventid) $eventid = -1; |
| 1928 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
|
| 1927 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true); |
|
| 1929 | 1928 | //error_log(__METHOD__.$event); |
| 1930 | 1929 | if ((int)$event > 0) |
| 1931 | 1930 | { |
@@ -1933,7 +1932,7 @@ discard block |
||
| 1933 | 1932 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 1934 | 1933 | 'cal_id' => $event, |
| 1935 | 1934 | ); |
| 1936 | - $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
| 1935 | + $GLOBALS['egw']->redirect_link('../index.php', $vars); |
|
| 1937 | 1936 | } |
| 1938 | 1937 | //Import failed, download content anyway |
| 1939 | 1938 | } |
@@ -1948,13 +1947,13 @@ discard block |
||
| 1948 | 1947 | { |
| 1949 | 1948 | $vcard['uid'] = trim($vcard['uid']); |
| 1950 | 1949 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 1951 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 1950 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
| 1952 | 1951 | } |
| 1953 | 1952 | if (!$contact) $contact = null; |
| 1954 | 1953 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
| 1955 | - if ($contact || count($vcard)>2) |
|
| 1954 | + if ($contact || count($vcard) > 2) |
|
| 1956 | 1955 | { |
| 1957 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true); |
|
| 1956 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ?array_shift($contact) : $contact), true); |
|
| 1958 | 1957 | } |
| 1959 | 1958 | if ((int)$contact > 0) |
| 1960 | 1959 | { |
@@ -1962,13 +1961,13 @@ discard block |
||
| 1962 | 1961 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
| 1963 | 1962 | 'contact_id' => $contact, |
| 1964 | 1963 | ); |
| 1965 | - $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
| 1964 | + $GLOBALS['egw']->redirect_link('../index.php', $vars); |
|
| 1966 | 1965 | } |
| 1967 | 1966 | //Import failed, download content anyway |
| 1968 | 1967 | } |
| 1969 | 1968 | } |
| 1970 | 1969 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
| 1971 | - Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save"); |
|
| 1970 | + Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save"); |
|
| 1972 | 1971 | echo $attachment['attachment']; |
| 1973 | 1972 | |
| 1974 | 1973 | exit(); |
@@ -1981,11 +1980,11 @@ discard block |
||
| 1981 | 1980 | * @param string haystack |
| 1982 | 1981 | * @return boolean |
| 1983 | 1982 | */ |
| 1984 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
| 1983 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) { |
|
| 1985 | 1984 | foreach (array_keys($arrayToTestAgainst) as $k) |
| 1986 | 1985 | { |
| 1987 | 1986 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
| 1988 | - if (stripos($haystack,$k)!==false) |
|
| 1987 | + if (stripos($haystack, $k) !== false) |
|
| 1989 | 1988 | { |
| 1990 | 1989 | //error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace()); |
| 1991 | 1990 | return true; |
@@ -2008,10 +2007,10 @@ discard block |
||
| 2008 | 2007 | */ |
| 2009 | 2008 | function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID) |
| 2010 | 2009 | { |
| 2011 | - unset($_icServer); // not used |
|
| 2010 | + unset($_icServer); // not used |
|
| 2012 | 2011 | $foundAddresses = array(); |
| 2013 | 2012 | |
| 2014 | - $mail_bo = $this->mail_bo; |
|
| 2013 | + $mail_bo = $this->mail_bo; |
|
| 2015 | 2014 | $mail_bo->openConnection(); |
| 2016 | 2015 | $mail_bo->reopen($_folder); |
| 2017 | 2016 | |
@@ -2019,20 +2018,20 @@ discard block |
||
| 2019 | 2018 | |
| 2020 | 2019 | // get message headers for specified message |
| 2021 | 2020 | //print "AAAA: $_folder, $_uid, $_partID<br>"; |
| 2022 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true); |
|
| 2021 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true); |
|
| 2023 | 2022 | //$headers = $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder); |
| 2024 | 2023 | $this->sessionData['uid'] = $_uid; |
| 2025 | 2024 | $this->sessionData['messageFolder'] = $_folder; |
| 2026 | - $this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']); |
|
| 2027 | - $this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']); |
|
| 2025 | + $this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']); |
|
| 2026 | + $this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']); |
|
| 2028 | 2027 | |
| 2029 | 2028 | // break reference into multiple lines if they're greater than 998 chars |
| 2030 | 2029 | // and remove comma seperation. Fix error serer does not support binary |
| 2031 | 2030 | // data due to long references. |
| 2032 | - if (strlen($this->sessionData['references'])> 998) |
|
| 2031 | + if (strlen($this->sessionData['references']) > 998) |
|
| 2033 | 2032 | { |
| 2034 | - $temp_refs = explode(',',$this->sessionData['references']); |
|
| 2035 | - $this->sessionData['references'] = implode(" ",$temp_refs); |
|
| 2033 | + $temp_refs = explode(',', $this->sessionData['references']); |
|
| 2034 | + $this->sessionData['references'] = implode(" ", $temp_refs); |
|
| 2036 | 2035 | } |
| 2037 | 2036 | |
| 2038 | 2037 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
@@ -2042,36 +2041,36 @@ discard block |
||
| 2042 | 2041 | if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
| 2043 | 2042 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
| 2044 | 2043 | // check for Reply-To: header and use if available |
| 2045 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
| 2046 | - foreach($headers['REPLY-TO'] as $val) { |
|
| 2047 | - if(!$foundAddresses[$val]) { |
|
| 2044 | + if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
| 2045 | + foreach ($headers['REPLY-TO'] as $val) { |
|
| 2046 | + if (!$foundAddresses[$val]) { |
|
| 2048 | 2047 | $oldTo[] = $val; |
| 2049 | 2048 | $foundAddresses[$val] = true; |
| 2050 | 2049 | } |
| 2051 | 2050 | } |
| 2052 | - $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
|
| 2051 | + $oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']); |
|
| 2053 | 2052 | } else { |
| 2054 | - foreach($headers['FROM'] as $val) { |
|
| 2055 | - if(!$foundAddresses[$val]) { |
|
| 2053 | + foreach ($headers['FROM'] as $val) { |
|
| 2054 | + if (!$foundAddresses[$val]) { |
|
| 2056 | 2055 | $oldTo[] = $val; |
| 2057 | 2056 | $foundAddresses[$val] = true; |
| 2058 | 2057 | } |
| 2059 | 2058 | } |
| 2060 | - $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
|
| 2059 | + $oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']); |
|
| 2061 | 2060 | } |
| 2062 | 2061 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
| 2063 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
| 2062 | + if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) { |
|
| 2064 | 2063 | $this->sessionData['to'] = $oldTo; |
| 2065 | 2064 | } |
| 2066 | 2065 | |
| 2067 | - if($_mode == 'all') { |
|
| 2066 | + if ($_mode == 'all') { |
|
| 2068 | 2067 | // reply to any address which is cc, but not to my self |
| 2069 | 2068 | #if($headers->cc) { |
| 2070 | - foreach($headers['CC'] as $val) { |
|
| 2071 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2069 | + foreach ($headers['CC'] as $val) { |
|
| 2070 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
| 2072 | 2071 | continue; |
| 2073 | 2072 | } |
| 2074 | - if(!$foundAddresses[$val]) { |
|
| 2073 | + if (!$foundAddresses[$val]) { |
|
| 2075 | 2074 | $this->sessionData['cc'][] = $val; |
| 2076 | 2075 | $foundAddresses[$val] = true; |
| 2077 | 2076 | } |
@@ -2080,11 +2079,11 @@ discard block |
||
| 2080 | 2079 | |
| 2081 | 2080 | // reply to any address which is to, but not to my self |
| 2082 | 2081 | #if($headers->to) { |
| 2083 | - foreach($headers['TO'] as $val) { |
|
| 2084 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2082 | + foreach ($headers['TO'] as $val) { |
|
| 2083 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
| 2085 | 2084 | continue; |
| 2086 | 2085 | } |
| 2087 | - if(!$foundAddresses[$val]) { |
|
| 2086 | + if (!$foundAddresses[$val]) { |
|
| 2088 | 2087 | $this->sessionData['to'][] = $val; |
| 2089 | 2088 | $foundAddresses[$val] = true; |
| 2090 | 2089 | } |
@@ -2092,12 +2091,12 @@ discard block |
||
| 2092 | 2091 | #} |
| 2093 | 2092 | |
| 2094 | 2093 | #if($headers->from) { |
| 2095 | - foreach($headers['FROM'] as $val) { |
|
| 2096 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2094 | + foreach ($headers['FROM'] as $val) { |
|
| 2095 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
| 2097 | 2096 | continue; |
| 2098 | 2097 | } |
| 2099 | 2098 | //error_log(__METHOD__.__LINE__.' '.$val); |
| 2100 | - if(!$foundAddresses[$val]) { |
|
| 2099 | + if (!$foundAddresses[$val]) { |
|
| 2101 | 2100 | $this->sessionData['to'][] = $val; |
| 2102 | 2101 | $foundAddresses[$val] = true; |
| 2103 | 2102 | } |
@@ -2106,59 +2105,59 @@ discard block |
||
| 2106 | 2105 | } |
| 2107 | 2106 | |
| 2108 | 2107 | // check for Re: in subject header |
| 2109 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
| 2108 | + if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
| 2110 | 2109 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
| 2111 | 2110 | } else { |
| 2112 | - $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
|
| 2111 | + $this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']); |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | //_debug_array($headers); |
| 2116 | 2115 | //error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions'])); |
| 2117 | - $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID); |
|
| 2116 | + $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID); |
|
| 2118 | 2117 | //_debug_array($bodyParts); |
| 2119 | 2118 | $styles = Mail::getStyles($bodyParts); |
| 2120 | 2119 | |
| 2121 | - $fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM'])); |
|
| 2120 | + $fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM'])); |
|
| 2122 | 2121 | |
| 2123 | 2122 | $toAddressA = array(); |
| 2124 | 2123 | $toAddress = ''; |
| 2125 | 2124 | foreach ($headers['TO'] as $mailheader) { |
| 2126 | - $toAddressA[] = $mailheader; |
|
| 2125 | + $toAddressA[] = $mailheader; |
|
| 2127 | 2126 | } |
| 2128 | - if (count($toAddressA)>0) |
|
| 2127 | + if (count($toAddressA) > 0) |
|
| 2129 | 2128 | { |
| 2130 | - $toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA)); |
|
| 2131 | - $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
|
| 2129 | + $toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA)); |
|
| 2130 | + $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n"); |
|
| 2132 | 2131 | } |
| 2133 | 2132 | $ccAddressA = array(); |
| 2134 | 2133 | $ccAddress = ''; |
| 2135 | 2134 | foreach ($headers['CC'] as $mailheader) { |
| 2136 | - $ccAddressA[] = $mailheader; |
|
| 2135 | + $ccAddressA[] = $mailheader; |
|
| 2137 | 2136 | } |
| 2138 | - if (count($ccAddressA)>0) |
|
| 2137 | + if (count($ccAddressA) > 0) |
|
| 2139 | 2138 | { |
| 2140 | - $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
|
| 2141 | - $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
|
| 2139 | + $ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA)); |
|
| 2140 | + $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n"); |
|
| 2142 | 2141 | } |
| 2143 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 2144 | - $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
|
| 2142 | + if ($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 2143 | + $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
|
| 2145 | 2144 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
| 2146 | 2145 | $toAddress.$ccAddress. |
| 2147 | - @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>". |
|
| 2146 | + @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>". |
|
| 2148 | 2147 | '----------------------------------------------------------'."</div>"; |
| 2149 | - $this->sessionData['mimeType'] = 'html'; |
|
| 2148 | + $this->sessionData['mimeType'] = 'html'; |
|
| 2150 | 2149 | if (!empty($styles)) $this->sessionData['body'] .= $styles; |
| 2151 | - $this->sessionData['body'] .= '<blockquote type="cite">'; |
|
| 2150 | + $this->sessionData['body'] .= '<blockquote type="cite">'; |
|
| 2152 | 2151 | |
| 2153 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2154 | - if($i>0) { |
|
| 2152 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
| 2153 | + if ($i > 0) { |
|
| 2155 | 2154 | $this->sessionData['body'] .= '<hr>'; |
| 2156 | 2155 | } |
| 2157 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 2156 | + if ($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 2158 | 2157 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
| 2159 | 2158 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 2160 | 2159 | } |
| 2161 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2160 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2162 | 2161 | |
| 2163 | 2162 | $_htmlConfig = Mail::$htmLawed_config; |
| 2164 | 2163 | Mail::$htmLawed_config['comment'] = 2; |
@@ -2168,37 +2167,37 @@ discard block |
||
| 2168 | 2167 | #error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 2169 | 2168 | } |
| 2170 | 2169 | |
| 2171 | - $this->sessionData['body'] .= '</blockquote><br>'; |
|
| 2172 | - $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
|
| 2170 | + $this->sessionData['body'] .= '</blockquote><br>'; |
|
| 2171 | + $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
|
| 2173 | 2172 | } else { |
| 2174 | 2173 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
| 2175 | 2174 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
| 2176 | - $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
| 2175 | + $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
| 2177 | 2176 | @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
| 2178 | 2177 | $toAddress.$ccAddress. |
| 2179 | - @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n". |
|
| 2178 | + @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n". |
|
| 2180 | 2179 | '-------------------------------------------------'."\r\n \r\n "; |
| 2181 | - $this->sessionData['mimeType'] = 'plain'; |
|
| 2180 | + $this->sessionData['mimeType'] = 'plain'; |
|
| 2182 | 2181 | |
| 2183 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2184 | - if($i>0) { |
|
| 2182 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
| 2183 | + if ($i > 0) { |
|
| 2185 | 2184 | $this->sessionData['body'] .= "<hr>"; |
| 2186 | 2185 | } |
| 2187 | 2186 | |
| 2188 | 2187 | // add line breaks to $bodyParts |
| 2189 | - $newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']); |
|
| 2188 | + $newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 2190 | 2189 | #error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 2191 | 2190 | $newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain'); |
| 2192 | 2191 | $this->sessionData['body'] .= "\r\n"; |
| 2193 | 2192 | $hasSignature = false; |
| 2194 | 2193 | // create body new, with good line breaks and indention |
| 2195 | - foreach(explode("\n",$newBody) as $value) { |
|
| 2194 | + foreach (explode("\n", $newBody) as $value) { |
|
| 2196 | 2195 | // the explode is removing the character |
| 2197 | 2196 | //$value .= 'ee'; |
| 2198 | 2197 | |
| 2199 | 2198 | // Try to remove signatures from qouted parts to avoid multiple |
| 2200 | 2199 | // signatures problem in reply (rfc3676#section-4.3). |
| 2201 | - if ($hasSignature || ($hasSignature = preg_match("/\G--(\s|\s[\r\n])$/",$value))) |
|
| 2200 | + if ($hasSignature || ($hasSignature = preg_match("/\G--(\s|\s[\r\n])$/", $value))) |
|
| 2202 | 2201 | { |
| 2203 | 2202 | continue; |
| 2204 | 2203 | } |
@@ -2210,12 +2209,12 @@ discard block |
||
| 2210 | 2209 | $numberOfChars = strspn(trim($value), ">"); |
| 2211 | 2210 | $appendString = str_repeat('>', $numberOfChars + 1); |
| 2212 | 2211 | |
| 2213 | - $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
|
| 2212 | + $bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>'); |
|
| 2214 | 2213 | |
| 2215 | - if($bodyAppend[0] == '>') { |
|
| 2216 | - $bodyAppend = '>'. $bodyAppend; |
|
| 2214 | + if ($bodyAppend[0] == '>') { |
|
| 2215 | + $bodyAppend = '>'.$bodyAppend; |
|
| 2217 | 2216 | } else { |
| 2218 | - $bodyAppend = '> '. $bodyAppend; |
|
| 2217 | + $bodyAppend = '> '.$bodyAppend; |
|
| 2219 | 2218 | } |
| 2220 | 2219 | |
| 2221 | 2220 | $this->sessionData['body'] .= $bodyAppend; |
@@ -2238,16 +2237,16 @@ discard block |
||
| 2238 | 2237 | */ |
| 2239 | 2238 | static function _getCleanHTML($_body, $_useTidy = false) |
| 2240 | 2239 | { |
| 2241 | - static $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 2242 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 2243 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 2240 | + static $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 2241 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 2242 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 2244 | 2243 | |
| 2245 | - if ($_useTidy && extension_loaded('tidy') ) |
|
| 2244 | + if ($_useTidy && extension_loaded('tidy')) |
|
| 2246 | 2245 | { |
| 2247 | 2246 | $tidy = new tidy(); |
| 2248 | - $cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8'); |
|
| 2247 | + $cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8'); |
|
| 2249 | 2248 | // Found errors. Strip it all so there's some output |
| 2250 | - if($tidy->getStatus() == 2) |
|
| 2249 | + if ($tidy->getStatus() == 2) |
|
| 2251 | 2250 | { |
| 2252 | 2251 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 2253 | 2252 | } |
@@ -2281,13 +2280,13 @@ discard block |
||
| 2281 | 2280 | * |
| 2282 | 2281 | * @return array returns found inline images as attachment structure |
| 2283 | 2282 | */ |
| 2284 | - function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false) |
|
| 2283 | + function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false) |
|
| 2285 | 2284 | { |
| 2286 | 2285 | if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----') |
| 2287 | 2286 | { |
| 2288 | 2287 | $_formData['mimeType'] = 'openpgp'; |
| 2289 | 2288 | } |
| 2290 | - $mail_bo = $this->mail_bo; |
|
| 2289 | + $mail_bo = $this->mail_bo; |
|
| 2291 | 2290 | $activeMailProfile = Mail\Account::read($this->mail_bo->profileID); |
| 2292 | 2291 | |
| 2293 | 2292 | // you need to set the sender, if you work with different identities, since most smtp servers, dont allow |
@@ -2296,37 +2295,37 @@ discard block |
||
| 2296 | 2295 | { |
| 2297 | 2296 | error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity)); |
| 2298 | 2297 | } |
| 2299 | - $email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email']; |
|
| 2298 | + $email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email']; |
|
| 2300 | 2299 | // Try to fix identity email with no domain part set |
| 2301 | 2300 | $_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From), |
| 2302 | - Mail::generateIdentityString($_identity,false)); |
|
| 2301 | + Mail::generateIdentityString($_identity, false)); |
|
| 2303 | 2302 | |
| 2304 | 2303 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
| 2305 | 2304 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
| 2306 | - if(!empty($_formData['in-reply-to'])) { |
|
| 2307 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2305 | + if (!empty($_formData['in-reply-to'])) { |
|
| 2306 | + if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>'; |
|
| 2308 | 2307 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
| 2309 | 2308 | } |
| 2310 | - if(!empty($_formData['references'])) { |
|
| 2311 | - if (stripos($_formData['references'],'<')===false) |
|
| 2309 | + if (!empty($_formData['references'])) { |
|
| 2310 | + if (stripos($_formData['references'], '<') === false) |
|
| 2312 | 2311 | { |
| 2313 | - $_formData['references']='<'.trim($_formData['references']).'>'; |
|
| 2312 | + $_formData['references'] = '<'.trim($_formData['references']).'>'; |
|
| 2314 | 2313 | } |
| 2315 | 2314 | $_mailObject->addHeader('References', $_formData['references']); |
| 2316 | 2315 | } |
| 2317 | 2316 | |
| 2318 | - if(!empty($_formData['thread-index'])) { |
|
| 2317 | + if (!empty($_formData['thread-index'])) { |
|
| 2319 | 2318 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
| 2320 | 2319 | } |
| 2321 | - if(!empty($_formData['list-id'])) { |
|
| 2320 | + if (!empty($_formData['list-id'])) { |
|
| 2322 | 2321 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
| 2323 | 2322 | } |
| 2324 | - if($_formData['disposition']=='on') { |
|
| 2323 | + if ($_formData['disposition'] == 'on') { |
|
| 2325 | 2324 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
| 2326 | 2325 | } |
| 2327 | 2326 | |
| 2328 | 2327 | // Expand any mailing lists |
| 2329 | - foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
|
| 2328 | + foreach (array('to', 'cc', 'bcc', 'replyto') as $field) |
|
| 2330 | 2329 | { |
| 2331 | 2330 | if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
| 2332 | 2331 | |
@@ -2342,7 +2341,7 @@ discard block |
||
| 2342 | 2341 | } |
| 2343 | 2342 | $disableRuler = false; |
| 2344 | 2343 | $signature = $_identity['ident_signature']; |
| 2345 | - $sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0; |
|
| 2344 | + $sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0; |
|
| 2346 | 2345 | if ($sigAlreadyThere) |
| 2347 | 2346 | { |
| 2348 | 2347 | // note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature |
@@ -2351,7 +2350,7 @@ discard block |
||
| 2351 | 2350 | } |
| 2352 | 2351 | if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) && |
| 2353 | 2352 | $this->mailPreferences['disableRulerForSignatureSeparation']) || |
| 2354 | - empty($signature) || trim($this->convertHTMLToText($signature)) =='') |
|
| 2353 | + empty($signature) || trim($this->convertHTMLToText($signature)) == '') |
|
| 2355 | 2354 | { |
| 2356 | 2355 | $disableRuler = true; |
| 2357 | 2356 | } |
@@ -2362,7 +2361,7 @@ discard block |
||
| 2362 | 2361 | array_unique(array_merge((array)$_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc'])), |
| 2363 | 2362 | $_formData['expiration'], $_formData['password']); |
| 2364 | 2363 | } |
| 2365 | - if($_formData['mimeType'] == 'html') |
|
| 2364 | + if ($_formData['mimeType'] == 'html') |
|
| 2366 | 2365 | { |
| 2367 | 2366 | $body = $_formData['body']; |
| 2368 | 2367 | if ($attachment_links) |
@@ -2376,13 +2375,13 @@ discard block |
||
| 2376 | 2375 | $body .= $attachment_links; |
| 2377 | 2376 | } |
| 2378 | 2377 | } |
| 2379 | - if(!empty($signature)) |
|
| 2378 | + if (!empty($signature)) |
|
| 2380 | 2379 | { |
| 2381 | 2380 | $_mailObject->setBody($this->convertHTMLToText($body, true, true). |
| 2382 | 2381 | ($disableRuler ? "\r\n" : "\r\n-- \r\n"). |
| 2383 | 2382 | $this->convertHTMLToText($signature, true, true)); |
| 2384 | 2383 | |
| 2385 | - $body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature; |
|
| 2384 | + $body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature; |
|
| 2386 | 2385 | } |
| 2387 | 2386 | else |
| 2388 | 2387 | { |
@@ -2390,11 +2389,11 @@ discard block |
||
| 2390 | 2389 | } |
| 2391 | 2390 | // convert URL Images to inline images - if possible |
| 2392 | 2391 | if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
| 2393 | - if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
|
| 2392 | + if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false) |
|
| 2394 | 2393 | { |
| 2395 | - $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
|
| 2394 | + $body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body); |
|
| 2396 | 2395 | } |
| 2397 | - $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() |
|
| 2396 | + $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() |
|
| 2398 | 2397 | } |
| 2399 | 2398 | elseif ($_formData['mimeType'] == 'openpgp') |
| 2400 | 2399 | { |
@@ -2402,14 +2401,14 @@ discard block |
||
| 2402 | 2401 | } |
| 2403 | 2402 | else |
| 2404 | 2403 | { |
| 2405 | - $body = $this->convertHTMLToText($_formData['body'],false); |
|
| 2404 | + $body = $this->convertHTMLToText($_formData['body'], false); |
|
| 2406 | 2405 | |
| 2407 | 2406 | if ($attachment_links) $body .= $attachment_links; |
| 2408 | 2407 | |
| 2409 | 2408 | #$_mailObject->Body = $_formData['body']; |
| 2410 | - if(!empty($signature)) { |
|
| 2411 | - $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
|
| 2412 | - $this->convertHTMLToText($signature,true,true); |
|
| 2409 | + if (!empty($signature)) { |
|
| 2410 | + $body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n"). |
|
| 2411 | + $this->convertHTMLToText($signature, true, true); |
|
| 2413 | 2412 | } |
| 2414 | 2413 | $_mailObject->setBody($body); |
| 2415 | 2414 | } |
@@ -2418,8 +2417,8 @@ discard block |
||
| 2418 | 2417 | { |
| 2419 | 2418 | $connection_opened = false; |
| 2420 | 2419 | $tnfattachments = null; |
| 2421 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
| 2422 | - if(is_array($attachment)) |
|
| 2420 | + foreach ((array)$_formData['attachments'] as $attachment) { |
|
| 2421 | + if (is_array($attachment)) |
|
| 2423 | 2422 | { |
| 2424 | 2423 | if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
| 2425 | 2424 | /* Example: |
@@ -2437,20 +2436,20 @@ discard block |
||
| 2437 | 2436 | $connection_opened = true; |
| 2438 | 2437 | } |
| 2439 | 2438 | $mail_bo->reopen($attachment['folder']); |
| 2440 | - switch(strtoupper($attachment['type'])) { |
|
| 2439 | + switch (strtoupper($attachment['type'])) { |
|
| 2441 | 2440 | case 'MESSAGE/RFC': |
| 2442 | 2441 | case 'MESSAGE/RFC822': |
| 2443 | - $rawBody=''; |
|
| 2442 | + $rawBody = ''; |
|
| 2444 | 2443 | if (isset($attachment['partID'])) { |
| 2445 | - $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
|
| 2446 | - $rawBody=$eml['attachment']; |
|
| 2444 | + $eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']); |
|
| 2445 | + $rawBody = $eml['attachment']; |
|
| 2447 | 2446 | } else { |
| 2448 | - $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
|
| 2447 | + $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']); |
|
| 2449 | 2448 | } |
| 2450 | 2449 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
| 2451 | 2450 | break; |
| 2452 | 2451 | default: |
| 2453 | - $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
|
| 2452 | + $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false); |
|
| 2454 | 2453 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
| 2455 | 2454 | { |
| 2456 | 2455 | if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
@@ -2458,7 +2457,7 @@ discard block |
||
| 2458 | 2457 | { |
| 2459 | 2458 | if ($k['name'] == $attachment['name']) |
| 2460 | 2459 | { |
| 2461 | - $tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']); |
|
| 2460 | + $tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']); |
|
| 2462 | 2461 | $attachmentData['attachment'] = $tnfpart['attachment']; |
| 2463 | 2462 | break; |
| 2464 | 2463 | } |
@@ -2471,7 +2470,7 @@ discard block |
||
| 2471 | 2470 | // attach files not for autosaving |
| 2472 | 2471 | elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving) |
| 2473 | 2472 | { |
| 2474 | - if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs') |
|
| 2473 | + if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs') |
|
| 2475 | 2474 | { |
| 2476 | 2475 | Vfs::load_wrapper('vfs'); |
| 2477 | 2476 | $tmp_path = $attachment['file']; |
@@ -2480,7 +2479,7 @@ discard block |
||
| 2480 | 2479 | { |
| 2481 | 2480 | $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['file']); |
| 2482 | 2481 | } |
| 2483 | - $_mailObject->addAttachment ( |
|
| 2482 | + $_mailObject->addAttachment( |
|
| 2484 | 2483 | $tmp_path, |
| 2485 | 2484 | $attachment['name'], |
| 2486 | 2485 | $attachment['type'] |
@@ -2490,7 +2489,7 @@ discard block |
||
| 2490 | 2489 | } |
| 2491 | 2490 | if ($connection_opened) $mail_bo->closeConnection(); |
| 2492 | 2491 | } |
| 2493 | - return is_array($inline_images)?$inline_images:array(); |
|
| 2492 | + return is_array($inline_images) ? $inline_images : array(); |
|
| 2494 | 2493 | } |
| 2495 | 2494 | |
| 2496 | 2495 | /** |
@@ -2506,16 +2505,16 @@ discard block |
||
| 2506 | 2505 | * @param string $password =null |
| 2507 | 2506 | * @return string might be empty if no file attachments found |
| 2508 | 2507 | */ |
| 2509 | - protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
|
| 2508 | + protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null) |
|
| 2510 | 2509 | { |
| 2511 | 2510 | if ($filemode == Vfs\Sharing::ATTACH) return ''; |
| 2512 | 2511 | |
| 2513 | 2512 | $links = array(); |
| 2514 | - foreach($attachments as $attachment) |
|
| 2513 | + foreach ($attachments as $attachment) |
|
| 2515 | 2514 | { |
| 2516 | 2515 | $path = $attachment['file']; |
| 2517 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
| 2518 | - if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
|
| 2516 | + if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
| 2517 | + if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs') |
|
| 2519 | 2518 | { |
| 2520 | 2519 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path); |
| 2521 | 2520 | } |
@@ -2545,7 +2544,7 @@ discard block |
||
| 2545 | 2544 | } |
| 2546 | 2545 | if (!$links) |
| 2547 | 2546 | { |
| 2548 | - return null; // no file attachments found |
|
| 2547 | + return null; // no file attachments found |
|
| 2549 | 2548 | } |
| 2550 | 2549 | elseif ($html) |
| 2551 | 2550 | { |
@@ -2560,7 +2559,7 @@ discard block |
||
| 2560 | 2559 | * @param array $content content sent from client-side |
| 2561 | 2560 | * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]' |
| 2562 | 2561 | */ |
| 2563 | - public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]') |
|
| 2562 | + public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]') |
|
| 2564 | 2563 | { |
| 2565 | 2564 | //error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)"); |
| 2566 | 2565 | $response = Api\Json\Response::get(); |
@@ -2574,8 +2573,8 @@ discard block |
||
| 2574 | 2573 | |
| 2575 | 2574 | $formData = array_merge($content, array( |
| 2576 | 2575 | 'isDrafted' => 1, |
| 2577 | - 'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')], |
|
| 2578 | - 'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value |
|
| 2576 | + 'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')], |
|
| 2577 | + 'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value |
|
| 2579 | 2578 | )); |
| 2580 | 2579 | |
| 2581 | 2580 | //Saving draft procedure |
@@ -2587,8 +2586,8 @@ discard block |
||
| 2587 | 2586 | if (($messageUid = $this->saveAsDraft($formData, $folder, $action))) |
| 2588 | 2587 | { |
| 2589 | 2588 | // saving as draft, does not mean closing the message |
| 2590 | - $messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid); |
|
| 2591 | - if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder))) |
|
| 2589 | + $messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid); |
|
| 2590 | + if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder))) |
|
| 2592 | 2591 | { |
| 2593 | 2592 | $draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid); |
| 2594 | 2593 | if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted'])) |
@@ -2597,7 +2596,7 @@ discard block |
||
| 2597 | 2596 | $duid = $dhA['msgUID']; |
| 2598 | 2597 | $dmailbox = $dhA['folder']; |
| 2599 | 2598 | // beware: do not delete the original mail as found in processedmail_id |
| 2600 | - $pMuid=''; |
|
| 2599 | + $pMuid = ''; |
|
| 2601 | 2600 | if ($content['processedmail_id']) |
| 2602 | 2601 | { |
| 2603 | 2602 | $pMhA = mail_ui::splitRowID($content['processedmail_id']); |
@@ -2605,15 +2604,15 @@ discard block |
||
| 2605 | 2604 | } |
| 2606 | 2605 | //error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments'])); |
| 2607 | 2606 | // do not delete the original message if attachments are present |
| 2608 | - if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments'])) |
|
| 2607 | + if (empty($pMuid) || $pMuid != $duid || empty($content['attachments'])) |
|
| 2609 | 2608 | { |
| 2610 | 2609 | try |
| 2611 | 2610 | { |
| 2612 | - $this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately'); |
|
| 2611 | + $this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately'); |
|
| 2613 | 2612 | } |
| 2614 | 2613 | catch (Api\Exception $e) |
| 2615 | 2614 | { |
| 2616 | - $msg = str_replace('"',"'",$e->getMessage()); |
|
| 2615 | + $msg = str_replace('"', "'", $e->getMessage()); |
|
| 2617 | 2616 | $success = false; |
| 2618 | 2617 | error_log(__METHOD__.__LINE__.$msg); |
| 2619 | 2618 | } |
@@ -2634,7 +2633,7 @@ discard block |
||
| 2634 | 2633 | } |
| 2635 | 2634 | catch (Api\Exception\WrongUserinput $e) |
| 2636 | 2635 | { |
| 2637 | - $msg = str_replace('"',"'",$e->getMessage()); |
|
| 2636 | + $msg = str_replace('"', "'", $e->getMessage()); |
|
| 2638 | 2637 | error_log(__METHOD__.__LINE__.$msg); |
| 2639 | 2638 | $success = false; |
| 2640 | 2639 | } |
@@ -2658,17 +2657,17 @@ discard block |
||
| 2658 | 2657 | static function resolveEmailAddressList($_emailAddressList) |
| 2659 | 2658 | { |
| 2660 | 2659 | $contacts_obs = null; |
| 2661 | - $addrFromList=array(); |
|
| 2662 | - foreach((array)$_emailAddressList as $ak => $address) |
|
| 2660 | + $addrFromList = array(); |
|
| 2661 | + foreach ((array)$_emailAddressList as $ak => $address) |
|
| 2663 | 2662 | { |
| 2664 | - if(is_int($address)) |
|
| 2663 | + if (is_int($address)) |
|
| 2665 | 2664 | { |
| 2666 | 2665 | if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts(); |
| 2667 | 2666 | // List was selected, expand to addresses |
| 2668 | 2667 | unset($_emailAddressList[$ak]); |
| 2669 | - $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)); |
|
| 2668 | + $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)); |
|
| 2670 | 2669 | // Just add email addresses, they'll be checked below |
| 2671 | - foreach($list as $email) |
|
| 2670 | + foreach ($list as $email) |
|
| 2672 | 2671 | { |
| 2673 | 2672 | $addrFromList[] = $email['email'] ? $email['email'] : $email['email_home']; |
| 2674 | 2673 | } |
@@ -2678,7 +2677,7 @@ discard block |
||
| 2678 | 2677 | { |
| 2679 | 2678 | foreach ($addrFromList as $addr) |
| 2680 | 2679 | { |
| 2681 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
| 2680 | + if (!empty($addr)) $_emailAddressList[] = $addr; |
|
| 2682 | 2681 | } |
| 2683 | 2682 | } |
| 2684 | 2683 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2692,15 +2691,15 @@ discard block |
||
| 2692 | 2691 | * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]' |
| 2693 | 2692 | * @return boolean return messageUID| false due to an error |
| 2694 | 2693 | */ |
| 2695 | - function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]') |
|
| 2694 | + function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]') |
|
| 2696 | 2695 | { |
| 2697 | 2696 | //error_log(__METHOD__."(..., $savingDestination, action=$action)"); |
| 2698 | - $mail_bo = $this->mail_bo; |
|
| 2699 | - $mail = new Api\Mailer($this->mail_bo->profileID); |
|
| 2697 | + $mail_bo = $this->mail_bo; |
|
| 2698 | + $mail = new Api\Mailer($this->mail_bo->profileID); |
|
| 2700 | 2699 | |
| 2701 | 2700 | // preserve the bcc and if possible the save to folder information |
| 2702 | - $this->sessionData['folder'] = $_formData['folder']; |
|
| 2703 | - $this->sessionData['bcc'] = $_formData['bcc']; |
|
| 2701 | + $this->sessionData['folder'] = $_formData['folder']; |
|
| 2702 | + $this->sessionData['bcc'] = $_formData['bcc']; |
|
| 2704 | 2703 | $this->sessionData['mailidentity'] = $_formData['mailidentity']; |
| 2705 | 2704 | //$this->sessionData['stationeryID'] = $_formData['stationeryID']; |
| 2706 | 2705 | $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
@@ -2709,11 +2708,11 @@ discard block |
||
| 2709 | 2708 | { |
| 2710 | 2709 | $acc = Mail\Account::read($this->sessionData['mailaccount']); |
| 2711 | 2710 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 2712 | - $identity = Mail\Account::read_identity($acc['ident_id'],true); |
|
| 2711 | + $identity = Mail\Account::read_identity($acc['ident_id'], true); |
|
| 2713 | 2712 | } |
| 2714 | 2713 | catch (Exception $e) |
| 2715 | 2714 | { |
| 2716 | - $identity=array(); |
|
| 2715 | + $identity = array(); |
|
| 2717 | 2716 | } |
| 2718 | 2717 | |
| 2719 | 2718 | $flags = '\\Seen \\Draft'; |
@@ -2723,7 +2722,7 @@ discard block |
||
| 2723 | 2722 | // folder list as Customheader |
| 2724 | 2723 | if (!empty($this->sessionData['folder'])) |
| 2725 | 2724 | { |
| 2726 | - $folders = implode('|',array_unique($this->sessionData['folder'])); |
|
| 2725 | + $folders = implode('|', array_unique($this->sessionData['folder'])); |
|
| 2727 | 2726 | $mail->addHeader('X-Mailfolder', $folders); |
| 2728 | 2727 | } |
| 2729 | 2728 | $mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']); |
@@ -2743,25 +2742,25 @@ discard block |
||
| 2743 | 2742 | $savingDestination = $this->sessionData['messageFolder']; |
| 2744 | 2743 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
| 2745 | 2744 | } |
| 2746 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 2745 | + if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 2747 | 2746 | |
| 2748 | 2747 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
| 2749 | 2748 | $mail->forceBccHeader(); |
| 2750 | 2749 | |
| 2751 | 2750 | $mail_bo->openConnection(); |
| 2752 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
| 2751 | + if ($mail_bo->folderExists($savingDestination, true)) { |
|
| 2753 | 2752 | try |
| 2754 | 2753 | { |
| 2755 | 2754 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
| 2756 | 2755 | } |
| 2757 | 2756 | catch (Api\Exception\WrongUserinput $e) |
| 2758 | 2757 | { |
| 2759 | - error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage())); |
|
| 2758 | + error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage())); |
|
| 2760 | 2759 | return false; |
| 2761 | 2760 | } |
| 2762 | 2761 | |
| 2763 | 2762 | } else { |
| 2764 | - error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
|
| 2763 | + error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server.")); |
|
| 2765 | 2764 | return false; |
| 2766 | 2765 | } |
| 2767 | 2766 | $mail_bo->closeConnection(); |
@@ -2770,26 +2769,26 @@ discard block |
||
| 2770 | 2769 | |
| 2771 | 2770 | function send($_formData) |
| 2772 | 2771 | { |
| 2773 | - $mail_bo = $this->mail_bo; |
|
| 2774 | - $mail = new Api\Mailer($mail_bo->profileID); |
|
| 2775 | - $messageIsDraft = false; |
|
| 2772 | + $mail_bo = $this->mail_bo; |
|
| 2773 | + $mail = new Api\Mailer($mail_bo->profileID); |
|
| 2774 | + $messageIsDraft = false; |
|
| 2776 | 2775 | |
| 2777 | - $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
|
| 2776 | + $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
|
| 2778 | 2777 | $this->sessionData['to'] = self::resolveEmailAddressList($_formData['to']); |
| 2779 | 2778 | $this->sessionData['cc'] = self::resolveEmailAddressList($_formData['cc']); |
| 2780 | - $this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']); |
|
| 2781 | - $this->sessionData['folder'] = $_formData['folder']; |
|
| 2779 | + $this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']); |
|
| 2780 | + $this->sessionData['folder'] = $_formData['folder']; |
|
| 2782 | 2781 | $this->sessionData['replyto'] = $_formData['replyto']; |
| 2783 | 2782 | $this->sessionData['subject'] = trim($_formData['subject']); |
| 2784 | - $this->sessionData['body'] = $_formData['body']; |
|
| 2785 | - $this->sessionData['priority'] = $_formData['priority']; |
|
| 2783 | + $this->sessionData['body'] = $_formData['body']; |
|
| 2784 | + $this->sessionData['priority'] = $_formData['priority']; |
|
| 2786 | 2785 | $this->sessionData['mailidentity'] = $_formData['mailidentity']; |
| 2787 | 2786 | //$this->sessionData['stationeryID'] = $_formData['stationeryID']; |
| 2788 | 2787 | $this->sessionData['disposition'] = $_formData['disposition']; |
| 2789 | - $this->sessionData['mimeType'] = $_formData['mimeType']; |
|
| 2788 | + $this->sessionData['mimeType'] = $_formData['mimeType']; |
|
| 2790 | 2789 | $this->sessionData['to_infolog'] = $_formData['to_infolog']; |
| 2791 | 2790 | $this->sessionData['to_tracker'] = $_formData['to_tracker']; |
| 2792 | - $this->sessionData['attachments'] = $_formData['attachments']; |
|
| 2791 | + $this->sessionData['attachments'] = $_formData['attachments']; |
|
| 2793 | 2792 | |
| 2794 | 2793 | if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted'])) |
| 2795 | 2794 | { |
@@ -2798,11 +2797,11 @@ discard block |
||
| 2798 | 2797 | //error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']); |
| 2799 | 2798 | if (isset($_formData['mode']) && !empty($_formData['mode'])) |
| 2800 | 2799 | { |
| 2801 | - if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id'])) |
|
| 2800 | + if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id'])) |
|
| 2802 | 2801 | { |
| 2803 | - $this->sessionData['forwardFlag']='forwarded'; |
|
| 2804 | - $_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']); |
|
| 2805 | - $this->sessionData['uid']=array(); |
|
| 2802 | + $this->sessionData['forwardFlag'] = 'forwarded'; |
|
| 2803 | + $_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']); |
|
| 2804 | + $this->sessionData['uid'] = array(); |
|
| 2806 | 2805 | foreach ($_formData['processedmail_id'] as $k =>$rowid) |
| 2807 | 2806 | { |
| 2808 | 2807 | $fhA = mail_ui::splitRowID($rowid); |
@@ -2811,13 +2810,13 @@ discard block |
||
| 2811 | 2810 | if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
| 2812 | 2811 | } |
| 2813 | 2812 | } |
| 2814 | - if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
|
| 2813 | + if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id'])) |
|
| 2815 | 2814 | { |
| 2816 | 2815 | $rhA = mail_ui::splitRowID($_formData['processedmail_id']); |
| 2817 | 2816 | $this->sessionData['uid'] = $rhA['msgUID']; |
| 2818 | 2817 | $this->sessionData['messageFolder'] = $rhA['folder']; |
| 2819 | 2818 | } |
| 2820 | - if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id'])) |
|
| 2819 | + if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id'])) |
|
| 2821 | 2820 | { |
| 2822 | 2821 | $dhA = mail_ui::splitRowID($_formData['processedmail_id']); |
| 2823 | 2822 | $this->sessionData['uid'] = $dhA['msgUID']; |
@@ -2826,26 +2825,26 @@ discard block |
||
| 2826 | 2825 | } |
| 2827 | 2826 | // if the body is empty, maybe someone pasted something with scripts, into the message body |
| 2828 | 2827 | // this should not happen anymore, unless you call send directly, since the check was introduced with the action command |
| 2829 | - if(empty($this->sessionData['body'])) |
|
| 2828 | + if (empty($this->sessionData['body'])) |
|
| 2830 | 2829 | { |
| 2831 | 2830 | // this is to be found with the egw_unset_vars array for the _POST['body'] array |
| 2832 | - $name='_POST'; |
|
| 2833 | - $key='body'; |
|
| 2831 | + $name = '_POST'; |
|
| 2832 | + $key = 'body'; |
|
| 2834 | 2833 | #error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
| 2835 | 2834 | if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']'])) |
| 2836 | 2835 | { |
| 2837 | - $this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
|
| 2838 | - $_formData['body']=$this->sessionData['body']; |
|
| 2836 | + $this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
|
| 2837 | + $_formData['body'] = $this->sessionData['body']; |
|
| 2839 | 2838 | } |
| 2840 | 2839 | #error_log($this->sessionData['body']); |
| 2841 | 2840 | } |
| 2842 | - if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
|
| 2841 | + if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
|
| 2843 | 2842 | empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
| 2844 | 2843 | $messageIsDraft = true; |
| 2845 | 2844 | } |
| 2846 | 2845 | try |
| 2847 | 2846 | { |
| 2848 | - $identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true); |
|
| 2847 | + $identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true); |
|
| 2849 | 2848 | } |
| 2850 | 2849 | catch (Exception $e) |
| 2851 | 2850 | { |
@@ -2856,7 +2855,7 @@ discard block |
||
| 2856 | 2855 | // create the messages and store inline images |
| 2857 | 2856 | $inline_images = $this->createMessage($mail, $_formData, $identity); |
| 2858 | 2857 | // remember the identity |
| 2859 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 2858 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 2860 | 2859 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
| 2861 | 2860 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
| 2862 | 2861 | #exit; |
@@ -2867,12 +2866,12 @@ discard block |
||
| 2867 | 2866 | $folderOnMailAccount = array(); |
| 2868 | 2867 | foreach ($folderToCheck as $k => $f) |
| 2869 | 2868 | { |
| 2870 | - $fval=$f; |
|
| 2871 | - $icServerID = $_formData['serverID'];//folders always assumed with serverID |
|
| 2872 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
| 2873 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
| 2869 | + $fval = $f; |
|
| 2870 | + $icServerID = $_formData['serverID']; //folders always assumed with serverID |
|
| 2871 | + if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2); |
|
| 2872 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
| 2874 | 2873 | { |
| 2875 | - if ($icServerID == $_formData['serverID'] ) |
|
| 2874 | + if ($icServerID == $_formData['serverID']) |
|
| 2876 | 2875 | { |
| 2877 | 2876 | $folder[$fval] = $fval; |
| 2878 | 2877 | $folderOnServerID[] = $fval; |
@@ -2885,7 +2884,7 @@ discard block |
||
| 2885 | 2884 | } |
| 2886 | 2885 | else |
| 2887 | 2886 | { |
| 2888 | - if ($icServerID == $_formData['serverID'] ) |
|
| 2887 | + if ($icServerID == $_formData['serverID']) |
|
| 2889 | 2888 | { |
| 2890 | 2889 | $folder[$fval] = $fval; |
| 2891 | 2890 | $folderOnServerID[] = $fval; |
@@ -2902,7 +2901,7 @@ discard block |
||
| 2902 | 2901 | // we use the sentFolder settings of the choosen mailaccount |
| 2903 | 2902 | // sentFolder is account specific |
| 2904 | 2903 | $changeProfileOnSentFolderNeeded = false; |
| 2905 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
| 2904 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
| 2906 | 2905 | { |
| 2907 | 2906 | $this->changeProfile($_formData['mailaccount']); |
| 2908 | 2907 | //error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#'); |
@@ -2910,30 +2909,30 @@ discard block |
||
| 2910 | 2909 | // sentFolder is account specific |
| 2911 | 2910 | $sentFolder = $this->mail_bo->getSentFolder(); |
| 2912 | 2911 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2913 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 2912 | + if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false; |
|
| 2914 | 2913 | } |
| 2915 | 2914 | else |
| 2916 | 2915 | { |
| 2917 | 2916 | $sentFolder = $mail_bo->getSentFolder(); |
| 2918 | 2917 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2919 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 2918 | + if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false; |
|
| 2920 | 2919 | } |
| 2921 | 2920 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2922 | 2921 | |
| 2923 | 2922 | // we switch $this->mail_bo back to the account we used to work on |
| 2924 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
| 2923 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
| 2925 | 2924 | { |
| 2926 | 2925 | $this->changeProfile($_formData['serverID']); |
| 2927 | 2926 | } |
| 2928 | 2927 | |
| 2929 | 2928 | |
| 2930 | - if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' && |
|
| 2929 | + if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' && |
|
| 2931 | 2930 | $this->mailPreferences['sendOptions'] != 'send_only' && |
| 2932 | 2931 | $messageIsDraft == false) |
| 2933 | 2932 | { |
| 2934 | 2933 | if ($sentFolder) |
| 2935 | 2934 | { |
| 2936 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
| 2935 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
| 2937 | 2936 | { |
| 2938 | 2937 | $folderOnMailAccount[] = $sentFolder; |
| 2939 | 2938 | } |
@@ -2950,14 +2949,14 @@ discard block |
||
| 2950 | 2949 | } |
| 2951 | 2950 | else |
| 2952 | 2951 | { |
| 2953 | - if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
|
| 2952 | + if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
|
| 2954 | 2953 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
| 2955 | 2954 | $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
| 2956 | 2955 | } |
| 2957 | 2956 | // draftFolder is on Server we start from |
| 2958 | - if($messageIsDraft == true) { |
|
| 2957 | + if ($messageIsDraft == true) { |
|
| 2959 | 2958 | $draftFolder = $mail_bo->getDraftFolder(); |
| 2960 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
| 2959 | + if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) { |
|
| 2961 | 2960 | $this->sessionData['folder'] = array($draftFolder); |
| 2962 | 2961 | $folderOnServerID[] = $draftFolder; |
| 2963 | 2962 | $folder[$draftFolder] = $draftFolder; |
@@ -2966,10 +2965,10 @@ discard block |
||
| 2966 | 2965 | if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
| 2967 | 2966 | if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
| 2968 | 2967 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
| 2969 | - !( count($folder) > 0) && |
|
| 2970 | - !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
|
| 2968 | + !(count($folder) > 0) && |
|
| 2969 | + !($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')) |
|
| 2971 | 2970 | { |
| 2972 | - $this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo?' '.$this->errorInfo:''); |
|
| 2971 | + $this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo ? ' '.$this->errorInfo : ''); |
|
| 2973 | 2972 | #error_log($this->errorInfo); |
| 2974 | 2973 | return false; |
| 2975 | 2974 | } |
@@ -2978,18 +2977,18 @@ discard block |
||
| 2978 | 2977 | @set_time_limit(120); |
| 2979 | 2978 | //$mail->SMTPDebug = 10; |
| 2980 | 2979 | //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'])); |
| 2981 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
| 2980 | + if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
| 2982 | 2981 | try { |
| 2983 | 2982 | $mail->send(); |
| 2984 | 2983 | } |
| 2985 | - catch(Exception $e) { |
|
| 2984 | + catch (Exception $e) { |
|
| 2986 | 2985 | _egw_log_exception($e); |
| 2987 | 2986 | //if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details)); |
| 2988 | - $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
|
| 2987 | + $this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : ''); |
|
| 2989 | 2988 | return false; |
| 2990 | 2989 | } |
| 2991 | 2990 | } else { |
| 2992 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
| 2991 | + if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) { |
|
| 2993 | 2992 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
| 2994 | 2993 | } else { |
| 2995 | 2994 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
@@ -3017,15 +3016,15 @@ discard block |
||
| 3017 | 3016 | // copying mail to folder |
| 3018 | 3017 | if (count($folder) > 0) |
| 3019 | 3018 | { |
| 3020 | - foreach($folderOnServerID as $folderName) { |
|
| 3019 | + foreach ($folderOnServerID as $folderName) { |
|
| 3021 | 3020 | if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
| 3022 | 3021 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3023 | 3022 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3024 | 3023 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3025 | - if ($mail_bo->folderExists($folderName,true)) { |
|
| 3026 | - if($mail_bo->isSentFolder($folderName)) { |
|
| 3024 | + if ($mail_bo->folderExists($folderName, true)) { |
|
| 3025 | + if ($mail_bo->isSentFolder($folderName)) { |
|
| 3027 | 3026 | $flags = '\\Seen'; |
| 3028 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
| 3027 | + } elseif ($mail_bo->isDraftFolder($folderName)) { |
|
| 3029 | 3028 | $flags = '\\Draft'; |
| 3030 | 3029 | } else { |
| 3031 | 3030 | $flags = '\\Seen'; |
@@ -3041,25 +3040,25 @@ discard block |
||
| 3041 | 3040 | } |
| 3042 | 3041 | catch (Api\Exception\WrongUserinput $e) |
| 3043 | 3042 | { |
| 3044 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage())); |
|
| 3043 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage())); |
|
| 3045 | 3044 | } |
| 3046 | 3045 | } |
| 3047 | 3046 | else |
| 3048 | 3047 | { |
| 3049 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
|
| 3048 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName)); |
|
| 3050 | 3049 | } |
| 3051 | 3050 | } |
| 3052 | 3051 | // if we choose to send from a differing profile |
| 3053 | 3052 | if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
| 3054 | - foreach($folderOnMailAccount as $folderName) { |
|
| 3053 | + foreach ($folderOnMailAccount as $folderName) { |
|
| 3055 | 3054 | if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
| 3056 | 3055 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3057 | 3056 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3058 | 3057 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3059 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
| 3060 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
| 3058 | + if ($this->mail_bo->folderExists($folderName, true)) { |
|
| 3059 | + if ($this->mail_bo->isSentFolder($folderName)) { |
|
| 3061 | 3060 | $flags = '\\Seen'; |
| 3062 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
| 3061 | + } elseif ($this->mail_bo->isDraftFolder($folderName)) { |
|
| 3063 | 3062 | $flags = '\\Draft'; |
| 3064 | 3063 | } else { |
| 3065 | 3064 | $flags = '\\Seen'; |
@@ -3075,12 +3074,12 @@ discard block |
||
| 3075 | 3074 | } |
| 3076 | 3075 | catch (Api\Exception\WrongUserinput $e) |
| 3077 | 3076 | { |
| 3078 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage())); |
|
| 3077 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage())); |
|
| 3079 | 3078 | } |
| 3080 | 3079 | } |
| 3081 | 3080 | else |
| 3082 | 3081 | { |
| 3083 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
|
| 3082 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName)); |
|
| 3084 | 3083 | } |
| 3085 | 3084 | } |
| 3086 | 3085 | if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
@@ -3091,27 +3090,27 @@ discard block |
||
| 3091 | 3090 | $lastDrafted = false; |
| 3092 | 3091 | if (isset($this->sessionData['lastDrafted'])) |
| 3093 | 3092 | { |
| 3094 | - $lastDrafted=array(); |
|
| 3093 | + $lastDrafted = array(); |
|
| 3095 | 3094 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
| 3096 | 3095 | $lastDrafted['uid'] = $dhA['msgUID']; |
| 3097 | 3096 | $lastDrafted['folder'] = $dhA['folder']; |
| 3098 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3097 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']); |
|
| 3099 | 3098 | // manually drafted, do not delete |
| 3100 | 3099 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
| 3101 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
| 3100 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false; |
|
| 3102 | 3101 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
| 3103 | 3102 | } |
| 3104 | 3103 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
| 3105 | 3104 | { |
| 3106 | 3105 | try |
| 3107 | 3106 | { |
| 3108 | - if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' && |
|
| 3109 | - ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments'])) |
|
| 3107 | + if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' && |
|
| 3108 | + ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) |
|
| 3110 | 3109 | { |
| 3111 | 3110 | //error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData)); |
| 3112 | 3111 | //error_log(__METHOD__.__LINE__."#".array2string($_formData)); |
| 3113 | 3112 | //error_log(__METHOD__.__LINE__."#".array2string($this->sessionData)); |
| 3114 | - $mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately'); |
|
| 3113 | + $mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately'); |
|
| 3115 | 3114 | } |
| 3116 | 3115 | } |
| 3117 | 3116 | catch (Api\Exception $e) |
@@ -3123,22 +3122,22 @@ discard block |
||
| 3123 | 3122 | unset($this->sessionData['lastDrafted']); |
| 3124 | 3123 | |
| 3125 | 3124 | //error_log("handling draft messages, flagging and such"); |
| 3126 | - if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
|
| 3125 | + if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
|
| 3127 | 3126 | || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
| 3128 | 3127 | // mark message as answered |
| 3129 | 3128 | $mail_bo->openConnection(); |
| 3130 | - $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
|
| 3129 | + $mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder'])); |
|
| 3131 | 3130 | // if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send |
| 3132 | 3131 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 3133 | 3132 | if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder'])) |
| 3134 | 3133 | { |
| 3135 | 3134 | try // message may be deleted already, as it maybe done by autosave |
| 3136 | 3135 | { |
| 3137 | - if ($_formData['mode']=='composefromdraft' && |
|
| 3136 | + if ($_formData['mode'] == 'composefromdraft' && |
|
| 3138 | 3137 | !(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) |
| 3139 | 3138 | { |
| 3140 | 3139 | //error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']); |
| 3141 | - $mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']); |
|
| 3140 | + $mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder']); |
|
| 3142 | 3141 | } |
| 3143 | 3142 | } |
| 3144 | 3143 | catch (Api\Exception $e) |
@@ -3147,14 +3146,14 @@ discard block |
||
| 3147 | 3146 | unset($e); |
| 3148 | 3147 | } |
| 3149 | 3148 | } else { |
| 3150 | - $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
|
| 3149 | + $mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder'])); |
|
| 3151 | 3150 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
| 3152 | - if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
|
| 3151 | + if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded') |
|
| 3153 | 3152 | { |
| 3154 | 3153 | try |
| 3155 | 3154 | { |
| 3156 | 3155 | //error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
| 3157 | - $mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']); |
|
| 3156 | + $mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']); |
|
| 3158 | 3157 | } |
| 3159 | 3158 | catch (Api\Exception $e) |
| 3160 | 3159 | { |
@@ -3182,49 +3181,49 @@ discard block |
||
| 3182 | 3181 | if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
| 3183 | 3182 | if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
| 3184 | 3183 | |
| 3185 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
|
| 3184 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') |
|
| 3186 | 3185 | { |
| 3187 | 3186 | $this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images); |
| 3188 | 3187 | |
| 3189 | - foreach(array('to_infolog','to_tracker','to_calendar') as $app_key) |
|
| 3188 | + foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key) |
|
| 3190 | 3189 | { |
| 3191 | 3190 | $entryid = $_formData['to_integrate_ids'][0][$app_key]; |
| 3192 | 3191 | if ($_formData[$app_key] == 'on') |
| 3193 | 3192 | { |
| 3194 | - $app_name = substr($app_key,3); |
|
| 3193 | + $app_name = substr($app_key, 3); |
|
| 3195 | 3194 | // Get registered hook data of the app called for integration |
| 3196 | - $hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name); |
|
| 3195 | + $hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name); |
|
| 3197 | 3196 | |
| 3198 | 3197 | // store mail / eml in temp. file to not have to download it from mail-server again |
| 3199 | - $eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate'); |
|
| 3198 | + $eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate'); |
|
| 3200 | 3199 | $eml_fp = fopen($eml, 'w'); |
| 3201 | 3200 | stream_copy_to_stream($mail->getRaw(), $eml_fp); |
| 3202 | 3201 | fclose($eml_fp); |
| 3203 | 3202 | $target = array( |
| 3204 | 3203 | 'menuaction' => $hook['menuaction'], |
| 3205 | - 'egw_data' => Link::set_data(null,'mail_integration::integrate',array( |
|
| 3204 | + 'egw_data' => Link::set_data(null, 'mail_integration::integrate', array( |
|
| 3206 | 3205 | $mailaddresses, |
| 3207 | 3206 | $this->sessionData['subject'], |
| 3208 | 3207 | $this->convertHTMLToText($this->sessionData['body']), |
| 3209 | 3208 | $this->sessionData['attachments'], |
| 3210 | 3209 | false, // date |
| 3211 | 3210 | $eml, |
| 3212 | - $_formData['serverID']),true), |
|
| 3211 | + $_formData['serverID']), true), |
|
| 3213 | 3212 | 'app' => $app_name |
| 3214 | 3213 | ); |
| 3215 | 3214 | if ($entryid) $target['entry_id'] = $entryid; |
| 3216 | 3215 | // Open the app called for integration in a popup |
| 3217 | 3216 | // and store the mail raw data as egw_data, in order to |
| 3218 | 3217 | // be stored from registered app method later |
| 3219 | - Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']); |
|
| 3218 | + Framework::popup(Egw::link('/index.php', $target), '_blank', $hook['popup']); |
|
| 3220 | 3219 | } |
| 3221 | 3220 | } |
| 3222 | 3221 | } |
| 3223 | 3222 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
| 3224 | - elseif(is_array($this->sessionData['attachments'])) |
|
| 3223 | + elseif (is_array($this->sessionData['attachments'])) |
|
| 3225 | 3224 | { |
| 3226 | - foreach($this->sessionData['attachments'] as $value) { |
|
| 3227 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
| 3225 | + foreach ($this->sessionData['attachments'] as $value) { |
|
| 3226 | + if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
| 3228 | 3227 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
| 3229 | 3228 | } |
| 3230 | 3229 | } |
@@ -3241,7 +3240,7 @@ discard block |
||
| 3241 | 3240 | * @param array $content |
| 3242 | 3241 | * @return array - the input, enriched with some not set attributes |
| 3243 | 3242 | */ |
| 3244 | - function setDefaults($content=array()) |
|
| 3243 | + function setDefaults($content = array()) |
|
| 3245 | 3244 | { |
| 3246 | 3245 | // if there's not already an identity selected for current account |
| 3247 | 3246 | if (empty($content['mailidentity'])) |
@@ -3250,7 +3249,7 @@ discard block |
||
| 3250 | 3249 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
| 3251 | 3250 | { |
| 3252 | 3251 | $sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']; |
| 3253 | - if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0) |
|
| 3252 | + if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0) |
|
| 3254 | 3253 | { |
| 3255 | 3254 | $content['mailidentity'] = $sigPref[$this->mail_bo->profileID]; |
| 3256 | 3255 | } |
@@ -3259,7 +3258,7 @@ discard block |
||
| 3259 | 3258 | if (empty($content['mailidentity'])) |
| 3260 | 3259 | { |
| 3261 | 3260 | $default_identity = null; |
| 3262 | - foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
|
| 3261 | + foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
|
| 3263 | 3262 | { |
| 3264 | 3263 | if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
| 3265 | 3264 | if (!empty($identity['ident_signature'])) |
@@ -3274,7 +3273,7 @@ discard block |
||
| 3274 | 3273 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
| 3275 | 3274 | { |
| 3276 | 3275 | $content['mimeType'] = 'html'; |
| 3277 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
| 3276 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain'; |
|
| 3278 | 3277 | } |
| 3279 | 3278 | return $content; |
| 3280 | 3279 | |
@@ -3297,7 +3296,7 @@ discard block |
||
| 3297 | 3296 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
| 3298 | 3297 | * @return type |
| 3299 | 3298 | */ |
| 3300 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
| 3299 | + function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) { |
|
| 3301 | 3300 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
| 3302 | 3301 | static $useCacheIfPossible = null; |
| 3303 | 3302 | if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
@@ -3310,36 +3309,36 @@ discard block |
||
| 3310 | 3309 | { |
| 3311 | 3310 | $this->changeProfile($_mailaccountToSearch); |
| 3312 | 3311 | } |
| 3313 | - if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer)) |
|
| 3312 | + if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer)) |
|
| 3314 | 3313 | { |
| 3315 | 3314 | //error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId); |
| 3316 | 3315 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
| 3317 | 3316 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
| 3318 | - $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
|
| 3319 | - if (count($folderObjects)<=1) { |
|
| 3317 | + $folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible); |
|
| 3318 | + if (count($folderObjects) <= 1) { |
|
| 3320 | 3319 | $useCacheIfPossible = false; |
| 3321 | 3320 | } |
| 3322 | 3321 | else |
| 3323 | 3322 | { |
| 3324 | 3323 | $useCacheIfPossible = true; |
| 3325 | 3324 | } |
| 3326 | - $searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP'); |
|
| 3325 | + $searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP'); |
|
| 3327 | 3326 | foreach ($folderObjects as $k =>$fA) |
| 3328 | 3327 | { |
| 3329 | 3328 | //error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName); |
| 3330 | - $f=false; |
|
| 3331 | - $key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k; |
|
| 3332 | - if ($_searchStringLength<=0) |
|
| 3329 | + $f = false; |
|
| 3330 | + $key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k; |
|
| 3331 | + if ($_searchStringLength <= 0) |
|
| 3333 | 3332 | { |
| 3334 | - $f=true; |
|
| 3333 | + $f = true; |
|
| 3335 | 3334 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
| 3336 | 3335 | } |
| 3337 | - if ($f==false && stripos($fA->displayName,$_searchString)!==false) |
|
| 3336 | + if ($f == false && stripos($fA->displayName, $_searchString) !== false) |
|
| 3338 | 3337 | { |
| 3339 | - $f=true; |
|
| 3338 | + $f = true; |
|
| 3340 | 3339 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
| 3341 | 3340 | } |
| 3342 | - if ($f==false && stripos($k,$searchString)!==false) |
|
| 3341 | + if ($f == false && stripos($k, $searchString) !== false) |
|
| 3343 | 3342 | { |
| 3344 | 3343 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
| 3345 | 3344 | } |
@@ -3367,7 +3366,7 @@ discard block |
||
| 3367 | 3366 | exit(); |
| 3368 | 3367 | } |
| 3369 | 3368 | |
| 3370 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
| 3369 | + public static function ajax_searchAddress($_searchStringLength = 2) { |
|
| 3371 | 3370 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
| 3372 | 3371 | $_searchString = trim($_REQUEST['query']); |
| 3373 | 3372 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3376,7 +3375,7 @@ discard block |
||
| 3376 | 3375 | $results = array(); |
| 3377 | 3376 | |
| 3378 | 3377 | // Add up to 5 matching mailing lists |
| 3379 | - if($include_lists) |
|
| 3378 | + if ($include_lists) |
|
| 3380 | 3379 | { |
| 3381 | 3380 | $lists = array_filter( |
| 3382 | 3381 | $contacts_obj->get_lists(Acl::READ), |
@@ -3385,7 +3384,7 @@ discard block |
||
| 3385 | 3384 | } |
| 3386 | 3385 | ); |
| 3387 | 3386 | $list_count = 0; |
| 3388 | - foreach($lists as $key => $list_name) |
|
| 3387 | + foreach ($lists as $key => $list_name) |
|
| 3389 | 3388 | { |
| 3390 | 3389 | $results[] = array( |
| 3391 | 3390 | 'id' => $key, |
@@ -3395,11 +3394,11 @@ discard block |
||
| 3395 | 3394 | 'title' => lang('Mailinglist'), |
| 3396 | 3395 | 'data' => $key |
| 3397 | 3396 | ); |
| 3398 | - if($list_count++ > 5) break; |
|
| 3397 | + if ($list_count++ > 5) break; |
|
| 3399 | 3398 | } |
| 3400 | 3399 | } |
| 3401 | 3400 | |
| 3402 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) |
|
| 3401 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength) |
|
| 3403 | 3402 | { |
| 3404 | 3403 | //error_log(__METHOD__.__LINE__.array2string($_searchString)); |
| 3405 | 3404 | $showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']); |
@@ -3408,64 +3407,64 @@ discard block |
||
| 3408 | 3407 | { |
| 3409 | 3408 | if (mb_strlen($v) < 3) unset($search[$k]); |
| 3410 | 3409 | } |
| 3411 | - $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
|
| 3410 | + $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
|
| 3412 | 3411 | //error_log(__METHOD__.__LINE__.$_searchString); |
| 3413 | 3412 | $filter = $showAccounts ? array() : array('account_id' => null); |
| 3414 | - $filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home'); |
|
| 3415 | - $cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'); |
|
| 3416 | - $contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter); |
|
| 3413 | + $filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'); |
|
| 3414 | + $cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'); |
|
| 3415 | + $contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
| 3417 | 3416 | // additionally search the accounts, if the contact storage is not the account storage |
| 3418 | 3417 | if ($showAccounts && $contacts_obj->so_accounts) |
| 3419 | 3418 | { |
| 3420 | 3419 | $filter['owner'] = 0; |
| 3421 | - $accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter); |
|
| 3420 | + $accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
| 3422 | 3421 | |
| 3423 | 3422 | if ($contacts && $accounts) |
| 3424 | 3423 | { |
| 3425 | - $contacts = array_merge($contacts,$accounts); |
|
| 3426 | - usort($contacts,function($a, $b) |
|
| 3424 | + $contacts = array_merge($contacts, $accounts); |
|
| 3425 | + usort($contacts, function($a, $b) |
|
| 3427 | 3426 | { |
| 3428 | 3427 | return strcasecmp($a['n_fn'], $b['n_fn']); |
| 3429 | 3428 | }); |
| 3430 | 3429 | } |
| 3431 | - elseif($accounts) |
|
| 3430 | + elseif ($accounts) |
|
| 3432 | 3431 | { |
| 3433 | - $contacts =& $accounts; |
|
| 3432 | + $contacts = & $accounts; |
|
| 3434 | 3433 | } |
| 3435 | 3434 | unset($accounts); |
| 3436 | 3435 | } |
| 3437 | 3436 | } |
| 3438 | 3437 | |
| 3439 | - if(is_array($contacts)) { |
|
| 3440 | - foreach($contacts as $contact) { |
|
| 3441 | - foreach(array($contact['email'],$contact['email_home']) as $email) { |
|
| 3438 | + if (is_array($contacts)) { |
|
| 3439 | + foreach ($contacts as $contact) { |
|
| 3440 | + foreach (array($contact['email'], $contact['email_home']) as $email) { |
|
| 3442 | 3441 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 3443 | 3442 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
| 3444 | 3443 | $rfcAddr = Mail::parseAddressList($email); |
| 3445 | - $_rfcAddr=$rfcAddr->first(); |
|
| 3444 | + $_rfcAddr = $rfcAddr->first(); |
|
| 3446 | 3445 | if (!$_rfcAddr->valid) |
| 3447 | 3446 | { |
| 3448 | 3447 | continue; // skip address if we encounter an error here |
| 3449 | 3448 | } |
| 3450 | 3449 | $email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 3451 | 3450 | |
| 3452 | - if (method_exists($contacts_obj,'search')) |
|
| 3451 | + if (method_exists($contacts_obj, 'search')) |
|
| 3453 | 3452 | { |
| 3454 | - $contact['n_fn']=''; |
|
| 3453 | + $contact['n_fn'] = ''; |
|
| 3455 | 3454 | if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
| 3456 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3457 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3458 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3459 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
| 3455 | + if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given']; |
|
| 3456 | + if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family']; |
|
| 3457 | + if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')'; |
|
| 3458 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
| 3460 | 3459 | } |
| 3461 | 3460 | else |
| 3462 | 3461 | { |
| 3463 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
| 3462 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
| 3464 | 3463 | } |
| 3465 | 3464 | $args = explode('@', trim($email)); |
| 3466 | 3465 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
| 3467 | 3466 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
| 3468 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
| 3467 | + if (!empty($email) && in_array($completeMailString, $results) === false) { |
|
| 3469 | 3468 | $results[] = array( |
| 3470 | 3469 | 'id'=>$completeMailString, |
| 3471 | 3470 | 'label' => $completeMailString, |
@@ -3481,10 +3480,10 @@ discard block |
||
| 3481 | 3480 | // Add groups |
| 3482 | 3481 | $group_options = array('account_type' => 'groups'); |
| 3483 | 3482 | $groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options); |
| 3484 | - foreach($groups as $g_id => $name) |
|
| 3483 | + foreach ($groups as $g_id => $name) |
|
| 3485 | 3484 | { |
| 3486 | 3485 | $group = $GLOBALS['egw']->accounts->read($g_id); |
| 3487 | - if(!$group['account_email']) continue; |
|
| 3486 | + if (!$group['account_email']) continue; |
|
| 3488 | 3487 | $args = explode('@', trim($group['account_email'])); |
| 3489 | 3488 | $args[] = $name; |
| 3490 | 3489 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
@@ -3514,7 +3513,7 @@ discard block |
||
| 3514 | 3513 | public function ajax_merge($contact_id) |
| 3515 | 3514 | { |
| 3516 | 3515 | $response = Api\Json\Response::get(); |
| 3517 | - if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge')) |
|
| 3516 | + if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge')) |
|
| 3518 | 3517 | { |
| 3519 | 3518 | $document_merge = new $_REQUEST['merge'](); |
| 3520 | 3519 | } |
@@ -3524,7 +3523,7 @@ discard block |
||
| 3524 | 3523 | } |
| 3525 | 3524 | $this->mail_bo->openConnection(); |
| 3526 | 3525 | |
| 3527 | - if(($error = $document_merge->check_document($_REQUEST['document'],''))) |
|
| 3526 | + if (($error = $document_merge->check_document($_REQUEST['document'], ''))) |
|
| 3528 | 3527 | { |
| 3529 | 3528 | $response->error($error); |
| 3530 | 3529 | return; |
@@ -3535,11 +3534,11 @@ discard block |
||
| 3535 | 3534 | try |
| 3536 | 3535 | { |
| 3537 | 3536 | $results = $this->mail_bo->importMessageToMergeAndSend( |
| 3538 | - $document_merge, Vfs::PREFIX . $_REQUEST['document'], |
|
| 3537 | + $document_merge, Vfs::PREFIX.$_REQUEST['document'], |
|
| 3539 | 3538 | // Send an extra non-numeric ID to force actual send of document |
| 3540 | 3539 | // instead of save as draft |
| 3541 | 3540 | array((int)$contact_id, ''), |
| 3542 | - $folder,$merged_mail_id |
|
| 3541 | + $folder, $merged_mail_id |
|
| 3543 | 3542 | ); |
| 3544 | 3543 | } |
| 3545 | 3544 | catch (Exception $e) |
@@ -3553,13 +3552,13 @@ discard block |
||
| 3553 | 3552 | ); |
| 3554 | 3553 | } |
| 3555 | 3554 | |
| 3556 | - if($results['success']) |
|
| 3555 | + if ($results['success']) |
|
| 3557 | 3556 | { |
| 3558 | - $response->data(implode(',',$results['success'])); |
|
| 3557 | + $response->data(implode(',', $results['success'])); |
|
| 3559 | 3558 | } |
| 3560 | - if($results['failed']) |
|
| 3559 | + if ($results['failed']) |
|
| 3561 | 3560 | { |
| 3562 | - $response->error(implode(',',$results['failed'])); |
|
| 3561 | + $response->error(implode(',', $results['failed'])); |
|
| 3563 | 3562 | } |
| 3564 | 3563 | } |
| 3565 | 3564 | } |
@@ -82,7 +82,10 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $this->mailPreferences['message_forwarding'] = 'asmail'; |
| 84 | 84 | } |
| 85 | - if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail'); |
|
| 85 | + if (is_null(Mail::$mailConfig)) |
|
| 86 | + { |
|
| 87 | + Mail::$mailConfig = Api\Config::read('mail'); |
|
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
| 88 | 91 | } |
@@ -96,11 +99,21 @@ discard block |
||
| 96 | 99 | { |
| 97 | 100 | if ($this->mail_bo->profileID!=$_icServerID) |
| 98 | 101 | { |
| 99 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
| 102 | + if (Mail::$debug) |
|
| 103 | + { |
|
| 104 | + error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
| 105 | + } |
|
| 100 | 106 | $this->mail_bo = Mail::getInstance(false,$_icServerID); |
| 101 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 107 | + if (Mail::$debug) |
|
| 108 | + { |
|
| 109 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 110 | + } |
|
| 102 | 111 | // no icServer Object: something failed big time |
| 103 | - if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
|
| 112 | + if (!isset($this->mail_bo->icServer)) |
|
| 113 | + { |
|
| 114 | + exit; |
|
| 115 | + } |
|
| 116 | + // ToDo: Exception or the dialog for setting up a server config |
|
| 104 | 117 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
| 105 | 118 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
| 106 | 119 | } |
@@ -242,7 +255,8 @@ discard block |
||
| 242 | 255 | { |
| 243 | 256 | foreach (array_keys($actions) as $key) |
| 244 | 257 | { |
| 245 | - if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) { |
|
| 258 | + if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) |
|
| 259 | + { |
|
| 246 | 260 | $actions[$key]['toolbarDefault'] = false; |
| 247 | 261 | } |
| 248 | 262 | } |
@@ -268,7 +282,10 @@ discard block |
||
| 268 | 282 | */ |
| 269 | 283 | function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
| 270 | 284 | { |
| 271 | - if ($msg) Framework::message($msg); |
|
| 285 | + if ($msg) |
|
| 286 | + { |
|
| 287 | + Framework::message($msg); |
|
| 288 | + } |
|
| 272 | 289 | |
| 273 | 290 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
| 274 | 291 | { |
@@ -289,8 +306,14 @@ discard block |
||
| 289 | 306 | //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); |
| 290 | 307 | $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; |
| 291 | 308 | $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; |
| 292 | - if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; |
|
| 293 | - if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; |
|
| 309 | + if (isset($_GET['reply_id'])) |
|
| 310 | + { |
|
| 311 | + $replyID = $_GET['reply_id']; |
|
| 312 | + } |
|
| 313 | + if (!$replyID && isset($_GET['id'])) |
|
| 314 | + { |
|
| 315 | + $replyID = $_GET['id']; |
|
| 316 | + } |
|
| 294 | 317 | |
| 295 | 318 | // Process different places we can use as a start for composing an email |
| 296 | 319 | $actionToProcess = 'compose'; |
@@ -357,7 +380,10 @@ discard block |
||
| 357 | 380 | $suppressSigOnTop = true; |
| 358 | 381 | foreach ($_content['uploadForCompose'] as $i => &$upload) |
| 359 | 382 | { |
| 360 | - if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
|
| 383 | + if (!isset($upload['file'])) |
|
| 384 | + { |
|
| 385 | + $upload['file'] = $upload['tmp_name']; |
|
| 386 | + } |
|
| 361 | 387 | try |
| 362 | 388 | { |
| 363 | 389 | $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false); |
@@ -391,9 +417,15 @@ discard block |
||
| 391 | 417 | $remove=false; |
| 392 | 418 | foreach(array_keys($toDelete) as $k) |
| 393 | 419 | { |
| 394 | - if ($att['tmp_name']==$k) $remove=true; |
|
| 420 | + if ($att['tmp_name']==$k) |
|
| 421 | + { |
|
| 422 | + $remove=true; |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + if (!$remove) |
|
| 426 | + { |
|
| 427 | + $_content['attachments'][] = $att; |
|
| 395 | 428 | } |
| 396 | - if (!$remove) $_content['attachments'][] = $att; |
|
| 397 | 429 | } |
| 398 | 430 | } |
| 399 | 431 | // someone clicked something like send, or saveAsDraft |
@@ -408,8 +440,7 @@ discard block |
||
| 408 | 440 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
| 409 | 441 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
| 410 | 442 | ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
| 411 | - ) |
|
| 412 | - { |
|
| 443 | + ) { |
|
| 413 | 444 | $this->changeProfile($_content['serverID']); |
| 414 | 445 | $composeProfile = $this->mail_bo->profileID; |
| 415 | 446 | } |
@@ -489,7 +520,10 @@ discard block |
||
| 489 | 520 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
| 490 | 521 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
| 491 | 522 | $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
| 492 | - if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
|
| 523 | + if (!empty($fhA['folder'])) |
|
| 524 | + { |
|
| 525 | + $workingFolder = $fhA['folder']; |
|
| 526 | + } |
|
| 493 | 527 | } |
| 494 | 528 | } |
| 495 | 529 | if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
@@ -540,7 +574,10 @@ discard block |
||
| 540 | 574 | } |
| 541 | 575 | } |
| 542 | 576 | |
| 543 | - if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
|
| 577 | + if ($activeProfile != $composeProfile) |
|
| 578 | + { |
|
| 579 | + $this->changeProfile($activeProfile); |
|
| 580 | + } |
|
| 544 | 581 | $insertSigOnTop = false; |
| 545 | 582 | $content = (is_array($_content)?$_content:array()); |
| 546 | 583 | if ($_contentHasMimeType) |
@@ -569,7 +606,10 @@ discard block |
||
| 569 | 606 | { |
| 570 | 607 | foreach ($contentArr as $k =>&$elem) |
| 571 | 608 | { |
| 572 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
| 609 | + if (stripos($elem,'<pre>')!==false) |
|
| 610 | + { |
|
| 611 | + $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
| 612 | + } |
|
| 573 | 613 | } |
| 574 | 614 | $content['mail_htmltext'] = implode('',$contentArr); |
| 575 | 615 | } |
@@ -611,8 +651,7 @@ discard block |
||
| 611 | 651 | if ( !empty($content['body']) && |
| 612 | 652 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
| 613 | 653 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
| 614 | - ) |
|
| 615 | - { |
|
| 654 | + ) { |
|
| 616 | 655 | $buttonClicked = true; |
| 617 | 656 | $suppressSigOnTop = true; |
| 618 | 657 | if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) |
@@ -628,7 +667,10 @@ discard block |
||
| 628 | 667 | else |
| 629 | 668 | { |
| 630 | 669 | $newSig = $this->mail_bo->getDefaultIdentity(); |
| 631 | - if ($newSig === false) $newSig = -2; |
|
| 670 | + if ($newSig === false) |
|
| 671 | + { |
|
| 672 | + $newSig = -2; |
|
| 673 | + } |
|
| 632 | 674 | } |
| 633 | 675 | } |
| 634 | 676 | $_oldSig = $composeCache['mailidentity']; |
@@ -636,7 +678,10 @@ discard block |
||
| 636 | 678 | |
| 637 | 679 | if ($_oldSig != $_signatureid) |
| 638 | 680 | { |
| 639 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
| 681 | + if($this->_debug) |
|
| 682 | + { |
|
| 683 | + error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
| 684 | + } |
|
| 640 | 685 | // prepare signatures, the selected sig may be used on top of the body |
| 641 | 686 | try |
| 642 | 687 | { |
@@ -666,7 +711,10 @@ discard block |
||
| 666 | 711 | { |
| 667 | 712 | $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
| 668 | 713 | $sigText = $this->convertHTMLToText($sigText,true,true); |
| 669 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
| 714 | + if($this->_debug) |
|
| 715 | + { |
|
| 716 | + error_log(__METHOD__." Old signature:".$oldSigText); |
|
| 717 | + } |
|
| 670 | 718 | } |
| 671 | 719 | |
| 672 | 720 | //$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -682,7 +730,11 @@ discard block |
||
| 682 | 730 | { |
| 683 | 731 | $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
| 684 | 732 | $styles = Mail::getStyles(array(array('body'=>$content['body']))); |
| 685 | - if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags |
|
| 733 | + if (stripos($content['body'],'style')!==false) |
|
| 734 | + { |
|
| 735 | + Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); |
|
| 736 | + } |
|
| 737 | + // clean out empty or pagewide style definitions / left over tags |
|
| 686 | 738 | } |
| 687 | 739 | $content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), |
| 688 | 740 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
@@ -727,8 +779,14 @@ discard block |
||
| 727 | 779 | |
| 728 | 780 | if ($found === false) |
| 729 | 781 | { |
| 730 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
| 731 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
| 782 | + if($this->_debug) |
|
| 783 | + { |
|
| 784 | + error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
| 785 | + } |
|
| 786 | + if($this->_debug) |
|
| 787 | + { |
|
| 788 | + error_log(__METHOD__." Compare content:".$content['body']); |
|
| 789 | + } |
|
| 732 | 790 | } |
| 733 | 791 | else |
| 734 | 792 | { |
@@ -746,7 +804,10 @@ discard block |
||
| 746 | 804 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
| 747 | 805 | |
| 748 | 806 | // do not double insert a signature on a server roundtrip |
| 749 | - if ($buttonClicked) $suppressSigOnTop = true; |
|
| 807 | + if ($buttonClicked) |
|
| 808 | + { |
|
| 809 | + $suppressSigOnTop = true; |
|
| 810 | + } |
|
| 750 | 811 | if ($isFirstLoad) |
| 751 | 812 | { |
| 752 | 813 | $alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached |
@@ -785,7 +846,8 @@ discard block |
||
| 785 | 846 | } |
| 786 | 847 | } |
| 787 | 848 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
| 788 | - foreach(array('subject','body','mimetype') as $name) { |
|
| 849 | + foreach(array('subject','body','mimetype') as $name) |
|
| 850 | + { |
|
| 789 | 851 | $sName = $name; |
| 790 | 852 | if ($name=='mimetype'&&$res[$name]) |
| 791 | 853 | { |
@@ -794,7 +856,10 @@ discard block |
||
| 794 | 856 | } |
| 795 | 857 | else |
| 796 | 858 | { |
| 797 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
| 859 | + if ($res[$name]) |
|
| 860 | + { |
|
| 861 | + $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
| 862 | + } |
|
| 798 | 863 | } |
| 799 | 864 | } |
| 800 | 865 | } |
@@ -805,7 +870,8 @@ discard block |
||
| 805 | 870 | { |
| 806 | 871 | $alreadyProcessed=array(); |
| 807 | 872 | //_debug_array($_REQUEST); |
| 808 | - if ($_REQUEST['preset']['mailto']) { |
|
| 873 | + if ($_REQUEST['preset']['mailto']) |
|
| 874 | + { |
|
| 809 | 875 | // handle mailto strings such as |
| 810 | 876 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
| 811 | 877 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
@@ -813,10 +879,12 @@ discard block |
||
| 813 | 879 | $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
| 814 | 880 | // check if there is more than the to address |
| 815 | 881 | $mailtoArray = explode('?',$tmp_send_to,2); |
| 816 | - if ($mailtoArray[1]) { |
|
| 882 | + if ($mailtoArray[1]) |
|
| 883 | + { |
|
| 817 | 884 | // check if there are more than one requests |
| 818 | 885 | $addRequests = explode('&',$mailtoArray[1]); |
| 819 | - foreach ($addRequests as $key => $reqval) { |
|
| 886 | + foreach ($addRequests as $key => $reqval) |
|
| 887 | + { |
|
| 820 | 888 | // the additional requests should have a =, to separate key from value. |
| 821 | 889 | $keyValuePair = explode('=',$reqval,2); |
| 822 | 890 | $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1]; |
@@ -825,17 +893,24 @@ discard block |
||
| 825 | 893 | $content['to']=$mailtoArray[0]; |
| 826 | 894 | $alreadyProcessed['to']='to'; |
| 827 | 895 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
| 828 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
| 896 | + foreach(array('cc','bcc','subject','body') as $name) |
|
| 897 | + { |
|
| 829 | 898 | $alreadyProcessed[$name]=$name; |
| 830 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
| 899 | + if ($_REQUEST[$name]) |
|
| 900 | + { |
|
| 901 | + $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
| 902 | + } |
|
| 831 | 903 | } |
| 832 | 904 | } |
| 833 | 905 | |
| 834 | - if ($_REQUEST['preset']['mailtocontactbyid']) { |
|
| 835 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
|
| 906 | + if ($_REQUEST['preset']['mailtocontactbyid']) |
|
| 907 | + { |
|
| 908 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook']) |
|
| 909 | + { |
|
| 836 | 910 | $contacts_obj = new Api\Contacts(); |
| 837 | 911 | $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
| 838 | - if (method_exists($contacts_obj,'search')) { |
|
| 912 | + if (method_exists($contacts_obj,'search')) |
|
| 913 | + { |
|
| 839 | 914 | |
| 840 | 915 | $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
| 841 | 916 | foreach ((array)$addressArray as $id => $addressID) |
@@ -850,7 +925,10 @@ discard block |
||
| 850 | 925 | { |
| 851 | 926 | $_searchCond = array('contact_id'=>$addressArray); |
| 852 | 927 | //error_log(__METHOD__.__LINE__.$_searchString); |
| 853 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false; |
|
| 928 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
| 929 | + { |
|
| 930 | + $showAccounts=false; |
|
| 931 | + } |
|
| 854 | 932 | $filter = ($showAccounts?array():array('account_id' => null)); |
| 855 | 933 | $filter['cols_to_search']=array('n_fn','email','email_home'); |
| 856 | 934 | $contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); |
@@ -873,21 +951,28 @@ discard block |
||
| 873 | 951 | unset($accounts); |
| 874 | 952 | } |
| 875 | 953 | } |
| 876 | - if(is_array($contacts)) { |
|
| 954 | + if(is_array($contacts)) |
|
| 955 | + { |
|
| 877 | 956 | $mailtoArray = array(); |
| 878 | 957 | $primary = $addressbookprefs['distributionListPreferredMail']; |
| 879 | - if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
|
| 958 | + if ($primary != 'email' && $primary != 'email_home') |
|
| 959 | + { |
|
| 960 | + $primary = 'email'; |
|
| 961 | + } |
|
| 880 | 962 | $secondary = ($primary == 'email'?'email_home':'email'); |
| 881 | 963 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
| 882 | - foreach($contacts as $contact) { |
|
| 964 | + foreach($contacts as $contact) |
|
| 965 | + { |
|
| 883 | 966 | $innerCounter=0; |
| 884 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
| 967 | + foreach(array($contact[$primary],$contact[$secondary]) as $email) |
|
| 968 | + { |
|
| 885 | 969 | // use pref distributionListPreferredMail for the primary address |
| 886 | 970 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 887 | 971 | $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
| 888 | 972 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
| 889 | 973 | $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
| 890 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
| 974 | + if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) |
|
| 975 | + { |
|
| 891 | 976 | $i++; |
| 892 | 977 | $innerCounter++; |
| 893 | 978 | $mailtoArray[$i] = $completeMailString; |
@@ -979,7 +1064,10 @@ discard block |
||
| 979 | 1064 | } |
| 980 | 1065 | } |
| 981 | 1066 | } |
| 982 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
| 1067 | + if(!empty($remember)) |
|
| 1068 | + { |
|
| 1069 | + $content = array_merge($content,$remember); |
|
| 1070 | + } |
|
| 983 | 1071 | } |
| 984 | 1072 | foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
| 985 | 1073 | { |
@@ -989,9 +1077,15 @@ discard block |
||
| 989 | 1077 | $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
| 990 | 1078 | } |
| 991 | 1079 | //skip if already processed by "preset Routines" |
| 992 | - if ($alreadyProcessed[$name]) continue; |
|
| 1080 | + if ($alreadyProcessed[$name]) |
|
| 1081 | + { |
|
| 1082 | + continue; |
|
| 1083 | + } |
|
| 993 | 1084 | //error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]); |
| 994 | - if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name]; |
|
| 1085 | + if ($_REQUEST['preset'][$name]) |
|
| 1086 | + { |
|
| 1087 | + $content[$name] = $_REQUEST['preset'][$name]; |
|
| 1088 | + } |
|
| 995 | 1089 | } |
| 996 | 1090 | } |
| 997 | 1091 | // is the to address set already? |
@@ -999,7 +1093,10 @@ discard block |
||
| 999 | 1093 | { |
| 1000 | 1094 | $content['to'] = base64_decode($_REQUEST['send_to']); |
| 1001 | 1095 | // first check if there is a questionmark or ampersand |
| 1002 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
| 1096 | + if (strpos($content['to'],'?')!== false) |
|
| 1097 | + { |
|
| 1098 | + list($content['to'],$rest) = explode('?',$content['to'],2); |
|
| 1099 | + } |
|
| 1003 | 1100 | $content['to'] = html_entity_decode($content['to']); |
| 1004 | 1101 | if (($at_pos = strpos($content['to'],'@')) !== false) |
| 1005 | 1102 | { |
@@ -1012,9 +1109,15 @@ discard block |
||
| 1012 | 1109 | $content['to'] = $email; |
| 1013 | 1110 | } |
| 1014 | 1111 | } |
| 1015 | - if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
| 1112 | + if (strpos($content['to'],'%40')!== false) |
|
| 1113 | + { |
|
| 1114 | + $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
| 1115 | + } |
|
| 1016 | 1116 | $rarr = array(Api\Html::purify($rest)); |
| 1017 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
| 1117 | + if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) |
|
| 1118 | + { |
|
| 1119 | + $rarr = explode('&',$rest); |
|
| 1120 | + } |
|
| 1018 | 1121 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
| 1019 | 1122 | $karr = array(); |
| 1020 | 1123 | foreach ($rarr as &$rval) |
@@ -1030,9 +1133,15 @@ discard block |
||
| 1030 | 1133 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
| 1031 | 1134 | foreach(array('cc','bcc','subject','body') as $name) |
| 1032 | 1135 | { |
| 1033 | - if ($karr[$name]) $content[$name] = $karr[$name]; |
|
| 1136 | + if ($karr[$name]) |
|
| 1137 | + { |
|
| 1138 | + $content[$name] = $karr[$name]; |
|
| 1139 | + } |
|
| 1140 | + } |
|
| 1141 | + if (!empty($_REQUEST['subject'])) |
|
| 1142 | + { |
|
| 1143 | + $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
| 1034 | 1144 | } |
| 1035 | - if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
| 1036 | 1145 | } |
| 1037 | 1146 | } |
| 1038 | 1147 | //error_log(__METHOD__.__LINE__.array2string($content)); |
@@ -1050,7 +1159,10 @@ discard block |
||
| 1050 | 1159 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
| 1051 | 1160 | $content['body'] = "<pre>".$content['body']."</pre>"; |
| 1052 | 1161 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
| 1053 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1162 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
| 1163 | + { |
|
| 1164 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1165 | + } |
|
| 1054 | 1166 | } |
| 1055 | 1167 | } |
| 1056 | 1168 | else |
@@ -1070,7 +1182,10 @@ discard block |
||
| 1070 | 1182 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
| 1071 | 1183 | $content['body'] = "<pre>".$content['body']."</pre>"; |
| 1072 | 1184 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
| 1073 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1185 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
| 1186 | + { |
|
| 1187 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
| 1188 | + } |
|
| 1074 | 1189 | } |
| 1075 | 1190 | } |
| 1076 | 1191 | } |
@@ -1110,24 +1225,33 @@ discard block |
||
| 1110 | 1225 | $disableRuler = true; |
| 1111 | 1226 | } |
| 1112 | 1227 | $font_span = $font_part = ''; |
| 1113 | - if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
| 1228 | + if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) |
|
| 1229 | + { |
|
| 1114 | 1230 | // User preferences for style |
| 1115 | 1231 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
| 1116 | 1232 | $font_size = Api\Html\CkEditorConfig::font_size_from_prefs(); |
| 1117 | 1233 | $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
| 1118 | 1234 | $font_span = $font_part.'​</span>'; |
| 1119 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
| 1235 | + if (empty($font) && empty($font_size)) |
|
| 1236 | + { |
|
| 1237 | + $font_span = ''; |
|
| 1238 | + } |
|
| 1120 | 1239 | } |
| 1121 | 1240 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
| 1122 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
| 1241 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) |
|
| 1242 | + { |
|
| 1243 | + $font_span = ''; |
|
| 1244 | + } |
|
| 1123 | 1245 | //remove possible html header stuff |
| 1124 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1246 | + if (stripos($content['body'],'<html><head></head><body>')!==false) |
|
| 1247 | + { |
|
| 1248 | + $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
| 1249 | + } |
|
| 1125 | 1250 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
| 1126 | 1251 | $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
| 1127 | 1252 | if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
| 1128 | 1253 | !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
| 1129 | - ) |
|
| 1130 | - { |
|
| 1254 | + ) { |
|
| 1131 | 1255 | // ON tOP OR BELOW? pREF CAN TELL |
| 1132 | 1256 | /* |
| 1133 | 1257 | Signature behavior preference changed. New default, if not set -> 0 |
@@ -1142,14 +1266,23 @@ discard block |
||
| 1142 | 1266 | $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
| 1143 | 1267 | foreach($blockElements as $e) |
| 1144 | 1268 | { |
| 1145 | - if ($sigTextStartsWithBlockElement) break; |
|
| 1146 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
| 1269 | + if ($sigTextStartsWithBlockElement) |
|
| 1270 | + { |
|
| 1271 | + break; |
|
| 1272 | + } |
|
| 1273 | + if (stripos(trim($sigText),'<'.$e)===0) |
|
| 1274 | + { |
|
| 1275 | + $sigTextStartsWithBlockElement = true; |
|
| 1276 | + } |
|
| 1147 | 1277 | } |
| 1148 | 1278 | } |
| 1149 | - if($content['mimeType'] == 'html') { |
|
| 1279 | + if($content['mimeType'] == 'html') |
|
| 1280 | + { |
|
| 1150 | 1281 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
| 1151 | 1282 | $inbetween = ''; |
| 1152 | - } else { |
|
| 1283 | + } |
|
| 1284 | + else |
|
| 1285 | + { |
|
| 1153 | 1286 | $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 1154 | 1287 | $inbetween = "\r\n"; |
| 1155 | 1288 | } |
@@ -1183,7 +1316,10 @@ discard block |
||
| 1183 | 1316 | foreach(Mail\Account::search(true,false) as $acc_id => $account) |
| 1184 | 1317 | { |
| 1185 | 1318 | // do NOT add SMTP only accounts as identities |
| 1186 | - if (!$account->is_imap(false)) continue; |
|
| 1319 | + if (!$account->is_imap(false)) |
|
| 1320 | + { |
|
| 1321 | + continue; |
|
| 1322 | + } |
|
| 1187 | 1323 | |
| 1188 | 1324 | foreach($account->identities($acc_id) as $ident_id => $identity) |
| 1189 | 1325 | { |
@@ -1196,16 +1332,24 @@ discard block |
||
| 1196 | 1332 | //$content['bcc'] = array('[email protected]','[email protected]'); |
| 1197 | 1333 | // address stuff like from, to, cc, replyto |
| 1198 | 1334 | $destinationRows = 0; |
| 1199 | - foreach(self::$destinations as $destination) { |
|
| 1335 | + foreach(self::$destinations as $destination) |
|
| 1336 | + { |
|
| 1200 | 1337 | if (!is_array($content[$destination])) |
| 1201 | 1338 | { |
| 1202 | - if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
|
| 1339 | + if (!empty($content[$destination])) |
|
| 1340 | + { |
|
| 1341 | + $content[$destination] = (array)$content[$destination]; |
|
| 1342 | + } |
|
| 1203 | 1343 | } |
| 1204 | 1344 | $addr_content = $content[strtolower($destination)]; |
| 1205 | 1345 | // we clear the given address array and rebuild it |
| 1206 | 1346 | unset($content[strtolower($destination)]); |
| 1207 | - foreach((array)$addr_content as $key => $value) { |
|
| 1208 | - if ($value=="NIL@NIL") continue; |
|
| 1347 | + foreach((array)$addr_content as $key => $value) |
|
| 1348 | + { |
|
| 1349 | + if ($value=="NIL@NIL") |
|
| 1350 | + { |
|
| 1351 | + continue; |
|
| 1352 | + } |
|
| 1209 | 1353 | if ($destination=='replyto' && str_replace('"','',$value) == |
| 1210 | 1354 | str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()])) |
| 1211 | 1355 | { |
@@ -1215,8 +1359,12 @@ discard block |
||
| 1215 | 1359 | } |
| 1216 | 1360 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
| 1217 | 1361 | $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
| 1218 | - foreach(Mail::parseAddressList($value) as $addressObject) { |
|
| 1219 | - if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
|
| 1362 | + foreach(Mail::parseAddressList($value) as $addressObject) |
|
| 1363 | + { |
|
| 1364 | + if ($addressObject->host == '.SYNTAX-ERROR.') |
|
| 1365 | + { |
|
| 1366 | + continue; |
|
| 1367 | + } |
|
| 1220 | 1368 | $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
| 1221 | 1369 | //$address = Mail::htmlentities($address, $this->displayCharset); |
| 1222 | 1370 | $content[strtolower($destination)][]=$address; |
@@ -1227,11 +1375,20 @@ discard block |
||
| 1227 | 1375 | if ($_content) |
| 1228 | 1376 | { |
| 1229 | 1377 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
| 1230 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
| 1378 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) |
|
| 1379 | + { |
|
| 1380 | + unset($_content['mailidentity']); |
|
| 1381 | + } |
|
| 1231 | 1382 | $content = array_merge($content,$_content); |
| 1232 | 1383 | |
| 1233 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1234 | - if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
|
| 1384 | + if (!empty($content['folder'])) |
|
| 1385 | + { |
|
| 1386 | + $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
| 1387 | + } |
|
| 1388 | + if (empty($content['mailaccount'])) |
|
| 1389 | + { |
|
| 1390 | + $content['mailaccount'] = $this->mail_bo->profileID; |
|
| 1391 | + } |
|
| 1235 | 1392 | } |
| 1236 | 1393 | else |
| 1237 | 1394 | { |
@@ -1274,11 +1431,17 @@ discard block |
||
| 1274 | 1431 | //error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']); |
| 1275 | 1432 | $preserv['is_html'] = $content['is_html']; |
| 1276 | 1433 | $preserv['is_plain'] = $content['is_plain']; |
| 1277 | - if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType']; |
|
| 1434 | + if (isset($content['mimeType'])) |
|
| 1435 | + { |
|
| 1436 | + $preserv['mimeType'] = $content['mimeType']; |
|
| 1437 | + } |
|
| 1278 | 1438 | $sel_options['mimeType'] = self::$mimeTypes; |
| 1279 | 1439 | $sel_options['priority'] = self::$priorities; |
| 1280 | 1440 | $sel_options['filemode'] = Vfs\Sharing::$modes; |
| 1281 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
| 1441 | + if (!isset($content['priority']) || empty($content['priority'])) |
|
| 1442 | + { |
|
| 1443 | + $content['priority']=3; |
|
| 1444 | + } |
|
| 1282 | 1445 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 1283 | 1446 | $etpl = new Etemplate('mail.compose'); |
| 1284 | 1447 | |
@@ -1325,9 +1488,12 @@ discard block |
||
| 1325 | 1488 | $preserv['list-id'] = $content['list-id']; |
| 1326 | 1489 | $preserv['mode'] = $content['mode']; |
| 1327 | 1490 | // convert it back to checkbox expectations |
| 1328 | - if($content['mimeType'] == 'html') { |
|
| 1491 | + if($content['mimeType'] == 'html') |
|
| 1492 | + { |
|
| 1329 | 1493 | $content['mimeType']=1; |
| 1330 | - } else { |
|
| 1494 | + } |
|
| 1495 | + else |
|
| 1496 | + { |
|
| 1331 | 1497 | $content['mimeType']=0; |
| 1332 | 1498 | } |
| 1333 | 1499 | // set the current selected mailaccount as param for folderselection |
@@ -1352,7 +1518,10 @@ discard block |
||
| 1352 | 1518 | // Resolve distribution list before send content to client |
| 1353 | 1519 | foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
| 1354 | 1520 | { |
| 1355 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1521 | + if (is_array($content[$f])) |
|
| 1522 | + { |
|
| 1523 | + $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
| 1524 | + } |
|
| 1356 | 1525 | } |
| 1357 | 1526 | |
| 1358 | 1527 | $content['to'] = self::resolveEmailAddressList($content['to']); |
@@ -1400,7 +1569,10 @@ discard block |
||
| 1400 | 1569 | case 'composefromdraft': |
| 1401 | 1570 | case 'composeasnew': |
| 1402 | 1571 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
| 1403 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
| 1572 | + if ($from =='composefromdraft') |
|
| 1573 | + { |
|
| 1574 | + $content['mode'] = 'composefromdraft'; |
|
| 1575 | + } |
|
| 1404 | 1576 | $content['processedmail_id'] = $mail_id; |
| 1405 | 1577 | |
| 1406 | 1578 | $_focusElement = 'body'; |
@@ -1448,7 +1620,10 @@ discard block |
||
| 1448 | 1620 | $document_merge = new $merge_class(); |
| 1449 | 1621 | $this->mail_bo->openConnection(); |
| 1450 | 1622 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
| 1451 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
| 1623 | + if (!is_array($merge_ids)) |
|
| 1624 | + { |
|
| 1625 | + $merge_ids = explode(',',$merge_ids); |
|
| 1626 | + } |
|
| 1452 | 1627 | try |
| 1453 | 1628 | { |
| 1454 | 1629 | $merged_mail_id = ''; |
@@ -1479,7 +1654,10 @@ discard block |
||
| 1479 | 1654 | { |
| 1480 | 1655 | $success = implode(', ',$results['success']); |
| 1481 | 1656 | $fail = implode(', ', $results['failed']); |
| 1482 | - if($success) Framework::message($success, 'success'); |
|
| 1657 | + if($success) |
|
| 1658 | + { |
|
| 1659 | + Framework::message($success, 'success'); |
|
| 1660 | + } |
|
| 1483 | 1661 | Framework::window_close($fail); |
| 1484 | 1662 | } |
| 1485 | 1663 | } |
@@ -1511,17 +1689,25 @@ discard block |
||
| 1511 | 1689 | { |
| 1512 | 1690 | $stripalltags = true; |
| 1513 | 1691 | // third param is stripalltags, we may not need that, if the source is already in ascii |
| 1514 | - if (!$sourceishtml) $stripalltags=false; |
|
| 1692 | + if (!$sourceishtml) |
|
| 1693 | + { |
|
| 1694 | + $stripalltags=false; |
|
| 1695 | + } |
|
| 1515 | 1696 | return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags); |
| 1516 | 1697 | } |
| 1517 | 1698 | |
| 1518 | 1699 | function generateRFC822Address($_addressObject) |
| 1519 | 1700 | { |
| 1520 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
| 1701 | + if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) |
|
| 1702 | + { |
|
| 1521 | 1703 | return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
| 1522 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
| 1704 | + } |
|
| 1705 | + elseif($_addressObject->mailbox && $_addressObject->host) |
|
| 1706 | + { |
|
| 1523 | 1707 | return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
| 1524 | - } else { |
|
| 1708 | + } |
|
| 1709 | + else |
|
| 1710 | + { |
|
| 1525 | 1711 | return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
| 1526 | 1712 | } |
| 1527 | 1713 | } |
@@ -1555,16 +1741,28 @@ discard block |
||
| 1555 | 1741 | //if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC']; |
| 1556 | 1742 | |
| 1557 | 1743 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
| 1558 | - if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
|
| 1559 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
| 1744 | + if (!empty($addHeadInfo['X-MAILFOLDER'])) |
|
| 1745 | + { |
|
| 1746 | + foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) |
|
| 1747 | + { |
|
| 1560 | 1748 | $fval=$val; |
| 1561 | 1749 | $icServerID = $mail_bo->icServer->ImapServerId; |
| 1562 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
| 1563 | - if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
|
| 1564 | - if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
|
| 1750 | + if (stripos($val,'::')!==false) |
|
| 1751 | + { |
|
| 1752 | + list($icServerID,$fval) = explode('::',$val,2); |
|
| 1753 | + } |
|
| 1754 | + if ($icServerID != $mail_bo->icServer->ImapServerId) |
|
| 1755 | + { |
|
| 1756 | + continue; |
|
| 1757 | + } |
|
| 1758 | + if ($mail_bo->folderExists($fval)) |
|
| 1759 | + { |
|
| 1760 | + $this->sessionData['folder'][] = $val; |
|
| 1761 | + } |
|
| 1565 | 1762 | } |
| 1566 | 1763 | } |
| 1567 | - if (!empty($addHeadInfo['X-MAILIDENTITY'])) { |
|
| 1764 | + if (!empty($addHeadInfo['X-MAILIDENTITY'])) |
|
| 1765 | + { |
|
| 1568 | 1766 | // with the new system it would be the identity |
| 1569 | 1767 | try |
| 1570 | 1768 | { |
@@ -1580,7 +1778,8 @@ discard block |
||
| 1580 | 1778 | $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; |
| 1581 | 1779 | } |
| 1582 | 1780 | */ |
| 1583 | - if (!empty($addHeadInfo['X-MAILACCOUNT'])) { |
|
| 1781 | + if (!empty($addHeadInfo['X-MAILACCOUNT'])) |
|
| 1782 | + { |
|
| 1584 | 1783 | // with the new system it would the identity is the account id |
| 1585 | 1784 | try |
| 1586 | 1785 | { |
@@ -1595,27 +1794,38 @@ discard block |
||
| 1595 | 1794 | } |
| 1596 | 1795 | } |
| 1597 | 1796 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
| 1598 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1797 | + if ($mail_bo->isDraftFolder($_folder)) |
|
| 1798 | + { |
|
| 1799 | + $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); |
|
| 1800 | + } |
|
| 1801 | + //array('uid'=>$_uid,'folder'=>$_folder); |
|
| 1599 | 1802 | $this->sessionData['uid'] = $_uid; |
| 1600 | 1803 | $this->sessionData['messageFolder'] = $_folder; |
| 1601 | 1804 | $this->sessionData['isDraft'] = true; |
| 1602 | 1805 | $foundAddresses = array(); |
| 1603 | - foreach((array)$headers['CC'] as $val) { |
|
| 1806 | + foreach((array)$headers['CC'] as $val) |
|
| 1807 | + { |
|
| 1604 | 1808 | $rfcAddr=Mail::parseAddressList($val); |
| 1605 | 1809 | $_rfcAddr = $rfcAddr[0]; |
| 1606 | - if (!$_rfcAddr->valid) continue; |
|
| 1607 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1810 | + if (!$_rfcAddr->valid) |
|
| 1811 | + { |
|
| 1812 | + continue; |
|
| 1813 | + } |
|
| 1814 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
| 1815 | + { |
|
| 1608 | 1816 | continue; |
| 1609 | 1817 | } |
| 1610 | 1818 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1611 | - if(!$foundAddresses[$keyemail]) { |
|
| 1819 | + if(!$foundAddresses[$keyemail]) |
|
| 1820 | + { |
|
| 1612 | 1821 | $address = $this->mail_bo->decode_header($val,true); |
| 1613 | 1822 | $this->sessionData['cc'][] = $val; |
| 1614 | 1823 | $foundAddresses[$keyemail] = true; |
| 1615 | 1824 | } |
| 1616 | 1825 | } |
| 1617 | 1826 | |
| 1618 | - foreach((array)$headers['TO'] as $val) { |
|
| 1827 | + foreach((array)$headers['TO'] as $val) |
|
| 1828 | + { |
|
| 1619 | 1829 | if(!is_array($val)) |
| 1620 | 1830 | { |
| 1621 | 1831 | $this->sessionData['to'][] = $val; |
@@ -1623,42 +1833,59 @@ discard block |
||
| 1623 | 1833 | } |
| 1624 | 1834 | $rfcAddr=Mail::parseAddressList($val); |
| 1625 | 1835 | $_rfcAddr = $rfcAddr[0]; |
| 1626 | - if (!$_rfcAddr->valid) continue; |
|
| 1627 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
| 1836 | + if (!$_rfcAddr->valid) |
|
| 1837 | + { |
|
| 1838 | + continue; |
|
| 1839 | + } |
|
| 1840 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
| 1841 | + { |
|
| 1628 | 1842 | continue; |
| 1629 | 1843 | } |
| 1630 | 1844 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1631 | - if(!$foundAddresses[$keyemail]) { |
|
| 1845 | + if(!$foundAddresses[$keyemail]) |
|
| 1846 | + { |
|
| 1632 | 1847 | $address = $this->mail_bo->decode_header($val,true); |
| 1633 | 1848 | $this->sessionData['to'][] = $val; |
| 1634 | 1849 | $foundAddresses[$keyemail] = true; |
| 1635 | 1850 | } |
| 1636 | 1851 | } |
| 1637 | 1852 | |
| 1638 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
| 1853 | + foreach((array)$headers['REPLY-TO'] as $val) |
|
| 1854 | + { |
|
| 1639 | 1855 | $rfcAddr=Mail::parseAddressList($val); |
| 1640 | 1856 | $_rfcAddr = $rfcAddr[0]; |
| 1641 | - if (!$_rfcAddr->valid) continue; |
|
| 1642 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1857 | + if (!$_rfcAddr->valid) |
|
| 1858 | + { |
|
| 1859 | + continue; |
|
| 1860 | + } |
|
| 1861 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
| 1862 | + { |
|
| 1643 | 1863 | continue; |
| 1644 | 1864 | } |
| 1645 | 1865 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1646 | - if(!$foundAddresses[$keyemail]) { |
|
| 1866 | + if(!$foundAddresses[$keyemail]) |
|
| 1867 | + { |
|
| 1647 | 1868 | $address = $this->mail_bo->decode_header($val,true); |
| 1648 | 1869 | $this->sessionData['replyto'][] = $val; |
| 1649 | 1870 | $foundAddresses[$keyemail] = true; |
| 1650 | 1871 | } |
| 1651 | 1872 | } |
| 1652 | 1873 | |
| 1653 | - foreach((array)$headers['BCC'] as $val) { |
|
| 1874 | + foreach((array)$headers['BCC'] as $val) |
|
| 1875 | + { |
|
| 1654 | 1876 | $rfcAddr=Mail::parseAddressList($val); |
| 1655 | 1877 | $_rfcAddr = $rfcAddr[0]; |
| 1656 | - if (!$_rfcAddr->valid) continue; |
|
| 1657 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
| 1878 | + if (!$_rfcAddr->valid) |
|
| 1879 | + { |
|
| 1880 | + continue; |
|
| 1881 | + } |
|
| 1882 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
| 1883 | + { |
|
| 1658 | 1884 | continue; |
| 1659 | 1885 | } |
| 1660 | 1886 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
| 1661 | - if(!$foundAddresses[$keyemail]) { |
|
| 1887 | + if(!$foundAddresses[$keyemail]) |
|
| 1888 | + { |
|
| 1662 | 1889 | $address = $this->mail_bo->decode_header($val,true); |
| 1663 | 1890 | $this->sessionData['bcc'][] = $val; |
| 1664 | 1891 | $foundAddresses[$keyemail] = true; |
@@ -1672,32 +1899,46 @@ discard block |
||
| 1672 | 1899 | $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
| 1673 | 1900 | //_debug_array($bodyParts); |
| 1674 | 1901 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
| 1675 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 1902 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
| 1903 | + { |
|
| 1676 | 1904 | $this->sessionData['mimeType'] = 'html'; |
| 1677 | 1905 | |
| 1678 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1679 | - if($i>0) { |
|
| 1906 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 1907 | + { |
|
| 1908 | + if($i>0) |
|
| 1909 | + { |
|
| 1680 | 1910 | $this->sessionData['body'] .= '<hr>'; |
| 1681 | 1911 | } |
| 1682 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 1912 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
| 1913 | + { |
|
| 1683 | 1914 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
| 1684 | 1915 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 1685 | 1916 | } |
| 1686 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1917 | + if ($bodyParts[$i]['charSet']===false) |
|
| 1918 | + { |
|
| 1919 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1920 | + } |
|
| 1687 | 1921 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1688 | 1922 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1689 | 1923 | $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
| 1690 | 1924 | } |
| 1691 | 1925 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
| 1692 | 1926 | |
| 1693 | - } else { |
|
| 1927 | + } |
|
| 1928 | + else |
|
| 1929 | + { |
|
| 1694 | 1930 | $this->sessionData['mimeType'] = 'plain'; |
| 1695 | 1931 | |
| 1696 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 1697 | - if($i>0) { |
|
| 1932 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 1933 | + { |
|
| 1934 | + if($i>0) |
|
| 1935 | + { |
|
| 1698 | 1936 | $this->sessionData['body'] .= "<hr>"; |
| 1699 | 1937 | } |
| 1700 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1938 | + if ($bodyParts[$i]['charSet']===false) |
|
| 1939 | + { |
|
| 1940 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 1941 | + } |
|
| 1701 | 1942 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 1702 | 1943 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
| 1703 | 1944 | $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
@@ -1705,8 +1946,10 @@ discard block |
||
| 1705 | 1946 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
| 1706 | 1947 | } |
| 1707 | 1948 | |
| 1708 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
| 1709 | - foreach($attachments as $attachment) { |
|
| 1949 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) |
|
| 1950 | + { |
|
| 1951 | + foreach($attachments as $attachment) |
|
| 1952 | + { |
|
| 1710 | 1953 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 1711 | 1954 | $cid = $attachment['cid']; |
| 1712 | 1955 | $match=null; |
@@ -1729,7 +1972,8 @@ discard block |
||
| 1729 | 1972 | |
| 1730 | 1973 | function getErrorInfo() |
| 1731 | 1974 | { |
| 1732 | - if(isset($this->errorInfo)) { |
|
| 1975 | + if(isset($this->errorInfo)) |
|
| 1976 | + { |
|
| 1733 | 1977 | $errorInfo = $this->errorInfo; |
| 1734 | 1978 | unset($this->errorInfo); |
| 1735 | 1979 | return $errorInfo; |
@@ -1744,7 +1988,8 @@ discard block |
||
| 1744 | 1988 | $modebuff = $this->mailPreferences['message_forwarding']; |
| 1745 | 1989 | $this->mailPreferences['message_forwarding'] = $_mode; |
| 1746 | 1990 | } |
| 1747 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
| 1991 | + if ($this->mailPreferences['message_forwarding'] == 'inline') |
|
| 1992 | + { |
|
| 1748 | 1993 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
| 1749 | 1994 | } |
| 1750 | 1995 | $mail_bo = $this->mail_bo; |
@@ -1761,12 +2006,16 @@ discard block |
||
| 1761 | 2006 | //$this->sessionData['sourceFolder']=$_folder; |
| 1762 | 2007 | //$this->sessionData['forwardFlag']='forwarded'; |
| 1763 | 2008 | //$this->sessionData['forwardedUID']=$_uid; |
| 1764 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
| 2009 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') |
|
| 2010 | + { |
|
| 1765 | 2011 | $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
| 1766 | 2012 | if($headers['SIZE']) |
| 1767 | - $size = $headers['SIZE']; |
|
| 1768 | - else |
|
| 1769 | - $size = lang('unknown'); |
|
| 2013 | + { |
|
| 2014 | + $size = $headers['SIZE']; |
|
| 2015 | + } |
|
| 2016 | + else { |
|
| 2017 | + $size = lang('unknown'); |
|
| 2018 | + } |
|
| 1770 | 2019 | |
| 1771 | 2020 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
| 1772 | 2021 | $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
@@ -1777,9 +2026,11 @@ discard block |
||
| 1777 | 2026 | unset($this->sessionData['in-reply-to']); |
| 1778 | 2027 | unset($this->sessionData['to']); |
| 1779 | 2028 | unset($this->sessionData['cc']); |
| 1780 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) { |
|
| 2029 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) |
|
| 2030 | + { |
|
| 1781 | 2031 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
| 1782 | - foreach($attachments as $attachment) { |
|
| 2032 | + foreach($attachments as $attachment) |
|
| 2033 | + { |
|
| 1783 | 2034 | if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
| 1784 | 2035 | { |
| 1785 | 2036 | $this->addMessageAttachment($_uid, $attachment['partID'], |
@@ -1835,7 +2086,10 @@ discard block |
||
| 1835 | 2086 | { |
| 1836 | 2087 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
| 1837 | 2088 | strtolower($_formData['type'])== strtolower($attach['type']) && |
| 1838 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
| 2089 | + stripos($_formData['file'],'vfs://') !== false) |
|
| 2090 | + { |
|
| 2091 | + return; |
|
| 2092 | + } |
|
| 1839 | 2093 | } |
| 1840 | 2094 | } |
| 1841 | 2095 | if ($attachfailed === false) |
@@ -1847,7 +2101,10 @@ discard block |
||
| 1847 | 2101 | 'tmp_name' => $tmpFileName, |
| 1848 | 2102 | 'size' => $_formData['size'] |
| 1849 | 2103 | ); |
| 1850 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
| 2104 | + if (!is_array($_content['attachments'])) |
|
| 2105 | + { |
|
| 2106 | + $_content['attachments']=array(); |
|
| 2107 | + } |
|
| 1851 | 2108 | $_content['attachments'][] = $buffer; |
| 1852 | 2109 | unset($buffer); |
| 1853 | 2110 | } |
@@ -1878,7 +2135,10 @@ discard block |
||
| 1878 | 2135 | { |
| 1879 | 2136 | foreach($request->preserv['attachments'] as $attachment) |
| 1880 | 2137 | { |
| 1881 | - if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
|
| 2138 | + if ($_GET['tmpname'] === $attachment['tmp_name']) |
|
| 2139 | + { |
|
| 2140 | + break; |
|
| 2141 | + } |
|
| 1882 | 2142 | } |
| 1883 | 2143 | } |
| 1884 | 2144 | if (!$request || $_GET['tmpname'] !== $attachment['tmp_name']) |
@@ -1912,10 +2172,20 @@ discard block |
||
| 1912 | 2172 | $sfxMimeType = $attachment['type']; |
| 1913 | 2173 | $buff = explode('.',$attachment['tmp_name']); |
| 1914 | 2174 | $suffix = ''; |
| 1915 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 1916 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2175 | + if (is_array($buff)) |
|
| 2176 | + { |
|
| 2177 | + $suffix = array_pop($buff); |
|
| 2178 | + } |
|
| 2179 | + // take the last extension to check with ext2mime |
|
| 2180 | + if (!empty($suffix)) |
|
| 2181 | + { |
|
| 2182 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2183 | + } |
|
| 1917 | 2184 | $attachment['type'] = $sfxMimeType; |
| 1918 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2185 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
| 2186 | + { |
|
| 2187 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2188 | + } |
|
| 1919 | 2189 | } |
| 1920 | 2190 | //error_log(__METHOD__.print_r($attachment,true)); |
| 1921 | 2191 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -1924,7 +2194,10 @@ discard block |
||
| 1924 | 2194 | $calendar_ical = new calendar_ical(); |
| 1925 | 2195 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
| 1926 | 2196 | //error_log(__METHOD__.array2string($eventid)); |
| 1927 | - if (!$eventid) $eventid = -1; |
|
| 2197 | + if (!$eventid) |
|
| 2198 | + { |
|
| 2199 | + $eventid = -1; |
|
| 2200 | + } |
|
| 1928 | 2201 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
| 1929 | 2202 | //error_log(__METHOD__.$event); |
| 1930 | 2203 | if ((int)$event > 0) |
@@ -1950,7 +2223,10 @@ discard block |
||
| 1950 | 2223 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 1951 | 2224 | $contact = $addressbook_vcal->find_contact($vcard,false); |
| 1952 | 2225 | } |
| 1953 | - if (!$contact) $contact = null; |
|
| 2226 | + if (!$contact) |
|
| 2227 | + { |
|
| 2228 | + $contact = null; |
|
| 2229 | + } |
|
| 1954 | 2230 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
| 1955 | 2231 | if ($contact || count($vcard)>2) |
| 1956 | 2232 | { |
@@ -1981,7 +2257,8 @@ discard block |
||
| 1981 | 2257 | * @param string haystack |
| 1982 | 2258 | * @return boolean |
| 1983 | 2259 | */ |
| 1984 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
| 2260 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) |
|
| 2261 | + { |
|
| 1985 | 2262 | foreach (array_keys($arrayToTestAgainst) as $k) |
| 1986 | 2263 | { |
| 1987 | 2264 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
@@ -2038,21 +2315,34 @@ discard block |
||
| 2038 | 2315 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
| 2039 | 2316 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
| 2040 | 2317 | //if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC']; |
| 2041 | - if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
| 2042 | - if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
| 2318 | + if ($headers['THREAD-INDEX']) |
|
| 2319 | + { |
|
| 2320 | + $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
| 2321 | + } |
|
| 2322 | + if ($headers['LIST-ID']) |
|
| 2323 | + { |
|
| 2324 | + $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
| 2325 | + } |
|
| 2043 | 2326 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
| 2044 | 2327 | // check for Reply-To: header and use if available |
| 2045 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
| 2046 | - foreach($headers['REPLY-TO'] as $val) { |
|
| 2047 | - if(!$foundAddresses[$val]) { |
|
| 2328 | + if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) |
|
| 2329 | + { |
|
| 2330 | + foreach($headers['REPLY-TO'] as $val) |
|
| 2331 | + { |
|
| 2332 | + if(!$foundAddresses[$val]) |
|
| 2333 | + { |
|
| 2048 | 2334 | $oldTo[] = $val; |
| 2049 | 2335 | $foundAddresses[$val] = true; |
| 2050 | 2336 | } |
| 2051 | 2337 | } |
| 2052 | 2338 | $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
| 2053 | - } else { |
|
| 2054 | - foreach($headers['FROM'] as $val) { |
|
| 2055 | - if(!$foundAddresses[$val]) { |
|
| 2339 | + } |
|
| 2340 | + else |
|
| 2341 | + { |
|
| 2342 | + foreach($headers['FROM'] as $val) |
|
| 2343 | + { |
|
| 2344 | + if(!$foundAddresses[$val]) |
|
| 2345 | + { |
|
| 2056 | 2346 | $oldTo[] = $val; |
| 2057 | 2347 | $foundAddresses[$val] = true; |
| 2058 | 2348 | } |
@@ -2060,18 +2350,23 @@ discard block |
||
| 2060 | 2350 | $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
| 2061 | 2351 | } |
| 2062 | 2352 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
| 2063 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
| 2353 | + if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) |
|
| 2354 | + { |
|
| 2064 | 2355 | $this->sessionData['to'] = $oldTo; |
| 2065 | 2356 | } |
| 2066 | 2357 | |
| 2067 | - if($_mode == 'all') { |
|
| 2358 | + if($_mode == 'all') |
|
| 2359 | + { |
|
| 2068 | 2360 | // reply to any address which is cc, but not to my self |
| 2069 | 2361 | #if($headers->cc) { |
| 2070 | - foreach($headers['CC'] as $val) { |
|
| 2071 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2362 | + foreach($headers['CC'] as $val) |
|
| 2363 | + { |
|
| 2364 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2365 | + { |
|
| 2072 | 2366 | continue; |
| 2073 | 2367 | } |
| 2074 | - if(!$foundAddresses[$val]) { |
|
| 2368 | + if(!$foundAddresses[$val]) |
|
| 2369 | + { |
|
| 2075 | 2370 | $this->sessionData['cc'][] = $val; |
| 2076 | 2371 | $foundAddresses[$val] = true; |
| 2077 | 2372 | } |
@@ -2080,11 +2375,14 @@ discard block |
||
| 2080 | 2375 | |
| 2081 | 2376 | // reply to any address which is to, but not to my self |
| 2082 | 2377 | #if($headers->to) { |
| 2083 | - foreach($headers['TO'] as $val) { |
|
| 2084 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2378 | + foreach($headers['TO'] as $val) |
|
| 2379 | + { |
|
| 2380 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2381 | + { |
|
| 2085 | 2382 | continue; |
| 2086 | 2383 | } |
| 2087 | - if(!$foundAddresses[$val]) { |
|
| 2384 | + if(!$foundAddresses[$val]) |
|
| 2385 | + { |
|
| 2088 | 2386 | $this->sessionData['to'][] = $val; |
| 2089 | 2387 | $foundAddresses[$val] = true; |
| 2090 | 2388 | } |
@@ -2092,12 +2390,15 @@ discard block |
||
| 2092 | 2390 | #} |
| 2093 | 2391 | |
| 2094 | 2392 | #if($headers->from) { |
| 2095 | - foreach($headers['FROM'] as $val) { |
|
| 2096 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
| 2393 | + foreach($headers['FROM'] as $val) |
|
| 2394 | + { |
|
| 2395 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
| 2396 | + { |
|
| 2097 | 2397 | continue; |
| 2098 | 2398 | } |
| 2099 | 2399 | //error_log(__METHOD__.__LINE__.' '.$val); |
| 2100 | - if(!$foundAddresses[$val]) { |
|
| 2400 | + if(!$foundAddresses[$val]) |
|
| 2401 | + { |
|
| 2101 | 2402 | $this->sessionData['to'][] = $val; |
| 2102 | 2403 | $foundAddresses[$val] = true; |
| 2103 | 2404 | } |
@@ -2106,9 +2407,12 @@ discard block |
||
| 2106 | 2407 | } |
| 2107 | 2408 | |
| 2108 | 2409 | // check for Re: in subject header |
| 2109 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
| 2410 | + if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") |
|
| 2411 | + { |
|
| 2110 | 2412 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
| 2111 | - } else { |
|
| 2413 | + } |
|
| 2414 | + else |
|
| 2415 | + { |
|
| 2112 | 2416 | $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
| 2113 | 2417 | } |
| 2114 | 2418 | |
@@ -2122,7 +2426,8 @@ discard block |
||
| 2122 | 2426 | |
| 2123 | 2427 | $toAddressA = array(); |
| 2124 | 2428 | $toAddress = ''; |
| 2125 | - foreach ($headers['TO'] as $mailheader) { |
|
| 2429 | + foreach ($headers['TO'] as $mailheader) |
|
| 2430 | + { |
|
| 2126 | 2431 | $toAddressA[] = $mailheader; |
| 2127 | 2432 | } |
| 2128 | 2433 | if (count($toAddressA)>0) |
@@ -2132,7 +2437,8 @@ discard block |
||
| 2132 | 2437 | } |
| 2133 | 2438 | $ccAddressA = array(); |
| 2134 | 2439 | $ccAddress = ''; |
| 2135 | - foreach ($headers['CC'] as $mailheader) { |
|
| 2440 | + foreach ($headers['CC'] as $mailheader) |
|
| 2441 | + { |
|
| 2136 | 2442 | $ccAddressA[] = $mailheader; |
| 2137 | 2443 | } |
| 2138 | 2444 | if (count($ccAddressA)>0) |
@@ -2140,25 +2446,35 @@ discard block |
||
| 2140 | 2446 | $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
| 2141 | 2447 | $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
| 2142 | 2448 | } |
| 2143 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
| 2449 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
| 2450 | + { |
|
| 2144 | 2451 | $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
| 2145 | 2452 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
| 2146 | 2453 | $toAddress.$ccAddress. |
| 2147 | 2454 | @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>". |
| 2148 | 2455 | '----------------------------------------------------------'."</div>"; |
| 2149 | 2456 | $this->sessionData['mimeType'] = 'html'; |
| 2150 | - if (!empty($styles)) $this->sessionData['body'] .= $styles; |
|
| 2457 | + if (!empty($styles)) |
|
| 2458 | + { |
|
| 2459 | + $this->sessionData['body'] .= $styles; |
|
| 2460 | + } |
|
| 2151 | 2461 | $this->sessionData['body'] .= '<blockquote type="cite">'; |
| 2152 | 2462 | |
| 2153 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2154 | - if($i>0) { |
|
| 2463 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 2464 | + { |
|
| 2465 | + if($i>0) |
|
| 2466 | + { |
|
| 2155 | 2467 | $this->sessionData['body'] .= '<hr>'; |
| 2156 | 2468 | } |
| 2157 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
| 2469 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
| 2470 | + { |
|
| 2158 | 2471 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
| 2159 | 2472 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
| 2160 | 2473 | } |
| 2161 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2474 | + if ($bodyParts[$i]['charSet']===false) |
|
| 2475 | + { |
|
| 2476 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
| 2477 | + } |
|
| 2162 | 2478 | |
| 2163 | 2479 | $_htmlConfig = Mail::$htmLawed_config; |
| 2164 | 2480 | Mail::$htmLawed_config['comment'] = 2; |
@@ -2170,7 +2486,9 @@ discard block |
||
| 2170 | 2486 | |
| 2171 | 2487 | $this->sessionData['body'] .= '</blockquote><br>'; |
| 2172 | 2488 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
| 2173 | - } else { |
|
| 2489 | + } |
|
| 2490 | + else |
|
| 2491 | + { |
|
| 2174 | 2492 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
| 2175 | 2493 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
| 2176 | 2494 | $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
@@ -2180,8 +2498,10 @@ discard block |
||
| 2180 | 2498 | '-------------------------------------------------'."\r\n \r\n "; |
| 2181 | 2499 | $this->sessionData['mimeType'] = 'plain'; |
| 2182 | 2500 | |
| 2183 | - for($i=0; $i<count($bodyParts); $i++) { |
|
| 2184 | - if($i>0) { |
|
| 2501 | + for($i=0; $i<count($bodyParts); $i++) |
|
| 2502 | + { |
|
| 2503 | + if($i>0) |
|
| 2504 | + { |
|
| 2185 | 2505 | $this->sessionData['body'] .= "<hr>"; |
| 2186 | 2506 | } |
| 2187 | 2507 | |
@@ -2192,7 +2512,8 @@ discard block |
||
| 2192 | 2512 | $this->sessionData['body'] .= "\r\n"; |
| 2193 | 2513 | $hasSignature = false; |
| 2194 | 2514 | // create body new, with good line breaks and indention |
| 2195 | - foreach(explode("\n",$newBody) as $value) { |
|
| 2515 | + foreach(explode("\n",$newBody) as $value) |
|
| 2516 | + { |
|
| 2196 | 2517 | // the explode is removing the character |
| 2197 | 2518 | //$value .= 'ee'; |
| 2198 | 2519 | |
@@ -2203,8 +2524,12 @@ discard block |
||
| 2203 | 2524 | continue; |
| 2204 | 2525 | } |
| 2205 | 2526 | |
| 2206 | - if ($hasSignature) continue; |
|
| 2207 | - if (trim($value) != '') { |
|
| 2527 | + if ($hasSignature) |
|
| 2528 | + { |
|
| 2529 | + continue; |
|
| 2530 | + } |
|
| 2531 | + if (trim($value) != '') |
|
| 2532 | + { |
|
| 2208 | 2533 | #if ($value != "\r") $value .= "\n"; |
| 2209 | 2534 | } |
| 2210 | 2535 | $numberOfChars = strspn(trim($value), ">"); |
@@ -2212,9 +2537,12 @@ discard block |
||
| 2212 | 2537 | |
| 2213 | 2538 | $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
| 2214 | 2539 | |
| 2215 | - if($bodyAppend[0] == '>') { |
|
| 2540 | + if($bodyAppend[0] == '>') |
|
| 2541 | + { |
|
| 2216 | 2542 | $bodyAppend = '>'. $bodyAppend; |
| 2217 | - } else { |
|
| 2543 | + } |
|
| 2544 | + else |
|
| 2545 | + { |
|
| 2218 | 2546 | $bodyAppend = '> '. $bodyAppend; |
| 2219 | 2547 | } |
| 2220 | 2548 | |
@@ -2263,9 +2591,12 @@ discard block |
||
| 2263 | 2591 | |
| 2264 | 2592 | static function _getHostName() |
| 2265 | 2593 | { |
| 2266 | - if (isset($_SERVER['SERVER_NAME'])) { |
|
| 2594 | + if (isset($_SERVER['SERVER_NAME'])) |
|
| 2595 | + { |
|
| 2267 | 2596 | $result = $_SERVER['SERVER_NAME']; |
| 2268 | - } else { |
|
| 2597 | + } |
|
| 2598 | + else |
|
| 2599 | + { |
|
| 2269 | 2600 | $result = 'localhost.localdomain'; |
| 2270 | 2601 | } |
| 2271 | 2602 | return $result; |
@@ -2303,11 +2634,16 @@ discard block |
||
| 2303 | 2634 | |
| 2304 | 2635 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
| 2305 | 2636 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
| 2306 | - if(!empty($_formData['in-reply-to'])) { |
|
| 2307 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2637 | + if(!empty($_formData['in-reply-to'])) |
|
| 2638 | + { |
|
| 2639 | + if (stripos($_formData['in-reply-to'],'<')===false) |
|
| 2640 | + { |
|
| 2641 | + $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
| 2642 | + } |
|
| 2308 | 2643 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
| 2309 | 2644 | } |
| 2310 | - if(!empty($_formData['references'])) { |
|
| 2645 | + if(!empty($_formData['references'])) |
|
| 2646 | + { |
|
| 2311 | 2647 | if (stripos($_formData['references'],'<')===false) |
| 2312 | 2648 | { |
| 2313 | 2649 | $_formData['references']='<'.trim($_formData['references']).'>'; |
@@ -2315,28 +2651,38 @@ discard block |
||
| 2315 | 2651 | $_mailObject->addHeader('References', $_formData['references']); |
| 2316 | 2652 | } |
| 2317 | 2653 | |
| 2318 | - if(!empty($_formData['thread-index'])) { |
|
| 2654 | + if(!empty($_formData['thread-index'])) |
|
| 2655 | + { |
|
| 2319 | 2656 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
| 2320 | 2657 | } |
| 2321 | - if(!empty($_formData['list-id'])) { |
|
| 2658 | + if(!empty($_formData['list-id'])) |
|
| 2659 | + { |
|
| 2322 | 2660 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
| 2323 | 2661 | } |
| 2324 | - if($_formData['disposition']=='on') { |
|
| 2662 | + if($_formData['disposition']=='on') |
|
| 2663 | + { |
|
| 2325 | 2664 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
| 2326 | 2665 | } |
| 2327 | 2666 | |
| 2328 | 2667 | // Expand any mailing lists |
| 2329 | 2668 | foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
| 2330 | 2669 | { |
| 2331 | - if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
| 2670 | + if ($field != 'replyto') |
|
| 2671 | + { |
|
| 2672 | + $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
| 2673 | + } |
|
| 2332 | 2674 | |
| 2333 | - if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field); |
|
| 2675 | + if ($_formData[$field]) |
|
| 2676 | + { |
|
| 2677 | + $_mailObject->addAddress($_formData[$field], '', $field); |
|
| 2678 | + } |
|
| 2334 | 2679 | } |
| 2335 | 2680 | |
| 2336 | 2681 | $_mailObject->addHeader('Subject', $_formData['subject']); |
| 2337 | 2682 | |
| 2338 | 2683 | // this should never happen since we come from the edit dialog |
| 2339 | - if (Mail::detect_qp($_formData['body'])) { |
|
| 2684 | + if (Mail::detect_qp($_formData['body'])) |
|
| 2685 | + { |
|
| 2340 | 2686 | $_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']); |
| 2341 | 2687 | $_formData['body'] = quoted_printable_decode($_formData['body']); |
| 2342 | 2688 | } |
@@ -2389,7 +2735,10 @@ discard block |
||
| 2389 | 2735 | $_mailObject->setBody($this->convertHTMLToText($body, true, true)); |
| 2390 | 2736 | } |
| 2391 | 2737 | // convert URL Images to inline images - if possible |
| 2392 | - if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
| 2738 | + if (!$_autosaving) |
|
| 2739 | + { |
|
| 2740 | + $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
| 2741 | + } |
|
| 2393 | 2742 | if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
| 2394 | 2743 | { |
| 2395 | 2744 | $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
@@ -2404,10 +2753,14 @@ discard block |
||
| 2404 | 2753 | { |
| 2405 | 2754 | $body = $this->convertHTMLToText($_formData['body'],false); |
| 2406 | 2755 | |
| 2407 | - if ($attachment_links) $body .= $attachment_links; |
|
| 2756 | + if ($attachment_links) |
|
| 2757 | + { |
|
| 2758 | + $body .= $attachment_links; |
|
| 2759 | + } |
|
| 2408 | 2760 | |
| 2409 | 2761 | #$_mailObject->Body = $_formData['body']; |
| 2410 | - if(!empty($signature)) { |
|
| 2762 | + if(!empty($signature)) |
|
| 2763 | + { |
|
| 2411 | 2764 | $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
| 2412 | 2765 | $this->convertHTMLToText($signature,true,true); |
| 2413 | 2766 | } |
@@ -2418,10 +2771,12 @@ discard block |
||
| 2418 | 2771 | { |
| 2419 | 2772 | $connection_opened = false; |
| 2420 | 2773 | $tnfattachments = null; |
| 2421 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
| 2774 | + foreach((array)$_formData['attachments'] as $attachment) |
|
| 2775 | + { |
|
| 2422 | 2776 | if(is_array($attachment)) |
| 2423 | 2777 | { |
| 2424 | - if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
|
| 2778 | + if (!empty($attachment['uid']) && !empty($attachment['folder'])) |
|
| 2779 | + { |
|
| 2425 | 2780 | /* Example: |
| 2426 | 2781 | Array([0] => Array( |
| 2427 | 2782 | [uid] => 21178 |
@@ -2437,14 +2792,18 @@ discard block |
||
| 2437 | 2792 | $connection_opened = true; |
| 2438 | 2793 | } |
| 2439 | 2794 | $mail_bo->reopen($attachment['folder']); |
| 2440 | - switch(strtoupper($attachment['type'])) { |
|
| 2795 | + switch(strtoupper($attachment['type'])) |
|
| 2796 | + { |
|
| 2441 | 2797 | case 'MESSAGE/RFC': |
| 2442 | 2798 | case 'MESSAGE/RFC822': |
| 2443 | 2799 | $rawBody=''; |
| 2444 | - if (isset($attachment['partID'])) { |
|
| 2800 | + if (isset($attachment['partID'])) |
|
| 2801 | + { |
|
| 2445 | 2802 | $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
| 2446 | 2803 | $rawBody=$eml['attachment']; |
| 2447 | - } else { |
|
| 2804 | + } |
|
| 2805 | + else |
|
| 2806 | + { |
|
| 2448 | 2807 | $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
| 2449 | 2808 | } |
| 2450 | 2809 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
@@ -2453,7 +2812,10 @@ discard block |
||
| 2453 | 2812 | $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
| 2454 | 2813 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
| 2455 | 2814 | { |
| 2456 | - if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
| 2815 | + if (!is_array($tnfattachments)) |
|
| 2816 | + { |
|
| 2817 | + $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
| 2818 | + } |
|
| 2457 | 2819 | foreach ($tnfattachments as $k) |
| 2458 | 2820 | { |
| 2459 | 2821 | if ($k['name'] == $attachment['name']) |
@@ -2488,7 +2850,10 @@ discard block |
||
| 2488 | 2850 | } |
| 2489 | 2851 | } |
| 2490 | 2852 | } |
| 2491 | - if ($connection_opened) $mail_bo->closeConnection(); |
|
| 2853 | + if ($connection_opened) |
|
| 2854 | + { |
|
| 2855 | + $mail_bo->closeConnection(); |
|
| 2856 | + } |
|
| 2492 | 2857 | } |
| 2493 | 2858 | return is_array($inline_images)?$inline_images:array(); |
| 2494 | 2859 | } |
@@ -2508,13 +2873,20 @@ discard block |
||
| 2508 | 2873 | */ |
| 2509 | 2874 | protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
| 2510 | 2875 | { |
| 2511 | - if ($filemode == Vfs\Sharing::ATTACH) return ''; |
|
| 2876 | + if ($filemode == Vfs\Sharing::ATTACH) |
|
| 2877 | + { |
|
| 2878 | + return ''; |
|
| 2879 | + } |
|
| 2512 | 2880 | |
| 2513 | 2881 | $links = array(); |
| 2514 | 2882 | foreach($attachments as $attachment) |
| 2515 | 2883 | { |
| 2516 | 2884 | $path = $attachment['file']; |
| 2517 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
| 2885 | + if (empty($path)) |
|
| 2886 | + { |
|
| 2887 | + continue; |
|
| 2888 | + } |
|
| 2889 | + // we only care about file attachments, not forwarded messages or parts |
|
| 2518 | 2890 | if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
| 2519 | 2891 | { |
| 2520 | 2892 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path); |
@@ -2617,13 +2989,19 @@ discard block |
||
| 2617 | 2989 | $success = false; |
| 2618 | 2990 | error_log(__METHOD__.__LINE__.$msg); |
| 2619 | 2991 | } |
| 2620 | - } else { |
|
| 2992 | + } |
|
| 2993 | + else |
|
| 2994 | + { |
|
| 2621 | 2995 | error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former'); |
| 2622 | 2996 | } |
| 2623 | - } else { |
|
| 2997 | + } |
|
| 2998 | + else |
|
| 2999 | + { |
|
| 2624 | 3000 | error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)"); |
| 2625 | 3001 | } |
| 2626 | - } else { |
|
| 3002 | + } |
|
| 3003 | + else |
|
| 3004 | + { |
|
| 2627 | 3005 | error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)"); |
| 2628 | 3006 | } |
| 2629 | 3007 | } |
@@ -2639,7 +3017,10 @@ discard block |
||
| 2639 | 3017 | $success = false; |
| 2640 | 3018 | } |
| 2641 | 3019 | |
| 2642 | - if ($success) $msg = lang('Message saved successfully.'); |
|
| 3020 | + if ($success) |
|
| 3021 | + { |
|
| 3022 | + $msg = lang('Message saved successfully.'); |
|
| 3023 | + } |
|
| 2643 | 3024 | |
| 2644 | 3025 | // Include new information to json respose, because we need them in client-side callback |
| 2645 | 3026 | $response->data(array( |
@@ -2663,7 +3044,10 @@ discard block |
||
| 2663 | 3044 | { |
| 2664 | 3045 | if(is_int($address)) |
| 2665 | 3046 | { |
| 2666 | - if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts(); |
|
| 3047 | + if (!isset($contacts_obs)) |
|
| 3048 | + { |
|
| 3049 | + $contacts_obj = new Api\Contacts(); |
|
| 3050 | + } |
|
| 2667 | 3051 | // List was selected, expand to addresses |
| 2668 | 3052 | unset($_emailAddressList[$ak]); |
| 2669 | 3053 | $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)); |
@@ -2678,7 +3062,10 @@ discard block |
||
| 2678 | 3062 | { |
| 2679 | 3063 | foreach ($addrFromList as $addr) |
| 2680 | 3064 | { |
| 2681 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
| 3065 | + if (!empty($addr)) |
|
| 3066 | + { |
|
| 3067 | + $_emailAddressList[]=$addr; |
|
| 3068 | + } |
|
| 2682 | 3069 | } |
| 2683 | 3070 | } |
| 2684 | 3071 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2732,7 +3119,10 @@ discard block |
||
| 2732 | 3119 | // decide where to save the message (default to draft folder, if we find nothing else) |
| 2733 | 3120 | // if the current folder is in draft or template folder save it there |
| 2734 | 3121 | // if it is called from printview then save it with the draft folder |
| 2735 | - if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3122 | + if (empty($savingDestination)) |
|
| 3123 | + { |
|
| 3124 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3125 | + } |
|
| 2736 | 3126 | if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) |
| 2737 | 3127 | { |
| 2738 | 3128 | $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; |
@@ -2743,13 +3133,17 @@ discard block |
||
| 2743 | 3133 | $savingDestination = $this->sessionData['messageFolder']; |
| 2744 | 3134 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
| 2745 | 3135 | } |
| 2746 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3136 | + if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) |
|
| 3137 | + { |
|
| 3138 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
| 3139 | + } |
|
| 2747 | 3140 | |
| 2748 | 3141 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
| 2749 | 3142 | $mail->forceBccHeader(); |
| 2750 | 3143 | |
| 2751 | 3144 | $mail_bo->openConnection(); |
| 2752 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
| 3145 | + if ($mail_bo->folderExists($savingDestination,true)) |
|
| 3146 | + { |
|
| 2753 | 3147 | try |
| 2754 | 3148 | { |
| 2755 | 3149 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
@@ -2760,7 +3154,9 @@ discard block |
||
| 2760 | 3154 | return false; |
| 2761 | 3155 | } |
| 2762 | 3156 | |
| 2763 | - } else { |
|
| 3157 | + } |
|
| 3158 | + else |
|
| 3159 | + { |
|
| 2764 | 3160 | error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
| 2765 | 3161 | return false; |
| 2766 | 3162 | } |
@@ -2808,7 +3204,10 @@ discard block |
||
| 2808 | 3204 | $fhA = mail_ui::splitRowID($rowid); |
| 2809 | 3205 | $this->sessionData['uid'][] = $fhA['msgUID']; |
| 2810 | 3206 | $this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
| 2811 | - if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
| 3207 | + if (!empty($fhA['folder'])) |
|
| 3208 | + { |
|
| 3209 | + $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
| 3210 | + } |
|
| 2812 | 3211 | } |
| 2813 | 3212 | } |
| 2814 | 3213 | if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
@@ -2840,7 +3239,8 @@ discard block |
||
| 2840 | 3239 | #error_log($this->sessionData['body']); |
| 2841 | 3240 | } |
| 2842 | 3241 | if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
| 2843 | - empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
|
| 3242 | + empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) |
|
| 3243 | + { |
|
| 2844 | 3244 | $messageIsDraft = true; |
| 2845 | 3245 | } |
| 2846 | 3246 | try |
@@ -2856,7 +3256,11 @@ discard block |
||
| 2856 | 3256 | // create the messages and store inline images |
| 2857 | 3257 | $inline_images = $this->createMessage($mail, $_formData, $identity); |
| 2858 | 3258 | // remember the identity |
| 2859 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 3259 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
| 3260 | + { |
|
| 3261 | + $fromAddress = $mail->From; |
|
| 3262 | + } |
|
| 3263 | + //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
| 2860 | 3264 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
| 2861 | 3265 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
| 2862 | 3266 | #exit; |
@@ -2869,7 +3273,10 @@ discard block |
||
| 2869 | 3273 | { |
| 2870 | 3274 | $fval=$f; |
| 2871 | 3275 | $icServerID = $_formData['serverID'];//folders always assumed with serverID |
| 2872 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
| 3276 | + if (stripos($f,'::')!==false) |
|
| 3277 | + { |
|
| 3278 | + list($icServerID,$fval) = explode('::',$f,2); |
|
| 3279 | + } |
|
| 2873 | 3280 | if ($_formData['serverID']!=$_formData['mailaccount']) |
| 2874 | 3281 | { |
| 2875 | 3282 | if ($icServerID == $_formData['serverID'] ) |
@@ -2910,13 +3317,19 @@ discard block |
||
| 2910 | 3317 | // sentFolder is account specific |
| 2911 | 3318 | $sentFolder = $this->mail_bo->getSentFolder(); |
| 2912 | 3319 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2913 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 3320 | + if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) |
|
| 3321 | + { |
|
| 3322 | + $sentFolder=false; |
|
| 3323 | + } |
|
| 2914 | 3324 | } |
| 2915 | 3325 | else |
| 2916 | 3326 | { |
| 2917 | 3327 | $sentFolder = $mail_bo->getSentFolder(); |
| 2918 | 3328 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2919 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
| 3329 | + if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) |
|
| 3330 | + { |
|
| 3331 | + $sentFolder=false; |
|
| 3332 | + } |
|
| 2920 | 3333 | } |
| 2921 | 3334 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
| 2922 | 3335 | |
@@ -2952,19 +3365,30 @@ discard block |
||
| 2952 | 3365 | { |
| 2953 | 3366 | if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
| 2954 | 3367 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
| 2955 | - $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
|
| 3368 | + $sentFolder != 'none')) |
|
| 3369 | + { |
|
| 3370 | + $this->errorInfo = lang("No Send Folder set in preferences"); |
|
| 3371 | + } |
|
| 2956 | 3372 | } |
| 2957 | 3373 | // draftFolder is on Server we start from |
| 2958 | - if($messageIsDraft == true) { |
|
| 3374 | + if($messageIsDraft == true) |
|
| 3375 | + { |
|
| 2959 | 3376 | $draftFolder = $mail_bo->getDraftFolder(); |
| 2960 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
| 3377 | + if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) |
|
| 3378 | + { |
|
| 2961 | 3379 | $this->sessionData['folder'] = array($draftFolder); |
| 2962 | 3380 | $folderOnServerID[] = $draftFolder; |
| 2963 | 3381 | $folder[$draftFolder] = $draftFolder; |
| 2964 | 3382 | } |
| 2965 | 3383 | } |
| 2966 | - if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
|
| 2967 | - if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
| 3384 | + if ($folderOnServerID) |
|
| 3385 | + { |
|
| 3386 | + $folderOnServerID = array_unique($folderOnServerID); |
|
| 3387 | + } |
|
| 3388 | + if ($folderOnMailAccount) |
|
| 3389 | + { |
|
| 3390 | + $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
| 3391 | + } |
|
| 2968 | 3392 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
| 2969 | 3393 | !( count($folder) > 0) && |
| 2970 | 3394 | !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
@@ -2978,7 +3402,8 @@ discard block |
||
| 2978 | 3402 | @set_time_limit(120); |
| 2979 | 3403 | //$mail->SMTPDebug = 10; |
| 2980 | 3404 | //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'])); |
| 2981 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
| 3405 | + if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) |
|
| 3406 | + { |
|
| 2982 | 3407 | try { |
| 2983 | 3408 | $mail->send(); |
| 2984 | 3409 | } |
@@ -2988,10 +3413,15 @@ discard block |
||
| 2988 | 3413 | $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
| 2989 | 3414 | return false; |
| 2990 | 3415 | } |
| 2991 | - } else { |
|
| 2992 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
| 3416 | + } |
|
| 3417 | + else |
|
| 3418 | + { |
|
| 3419 | + if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) |
|
| 3420 | + { |
|
| 2993 | 3421 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
| 2994 | - } else { |
|
| 3422 | + } |
|
| 3423 | + else |
|
| 3424 | + { |
|
| 2995 | 3425 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
| 2996 | 3426 | //error_log(__METHOD__.__LINE__.$this->errorInfo); |
| 2997 | 3427 | return false; |
@@ -3001,14 +3431,16 @@ discard block |
||
| 3001 | 3431 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
| 3002 | 3432 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
| 3003 | 3433 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
| 3004 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
| 3434 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
| 3435 | + { |
|
| 3005 | 3436 | $mail_bo = $this->mail_bo; |
| 3006 | 3437 | $mail_bo->openConnection(); |
| 3007 | 3438 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
| 3008 | 3439 | #error_log("(re)opened Connection"); |
| 3009 | 3440 | } |
| 3010 | 3441 | // if copying mail to folder, or saving mail to infolog, we need to gather the needed information |
| 3011 | - if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') { |
|
| 3442 | + if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
| 3443 | + { |
|
| 3012 | 3444 | //error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc'])); |
| 3013 | 3445 | |
| 3014 | 3446 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
@@ -3017,17 +3449,28 @@ discard block |
||
| 3017 | 3449 | // copying mail to folder |
| 3018 | 3450 | if (count($folder) > 0) |
| 3019 | 3451 | { |
| 3020 | - foreach($folderOnServerID as $folderName) { |
|
| 3021 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
| 3452 | + foreach($folderOnServerID as $folderName) |
|
| 3453 | + { |
|
| 3454 | + if (is_array($folderName)) |
|
| 3455 | + { |
|
| 3456 | + $folderName = array_shift($folderName); |
|
| 3457 | + } |
|
| 3458 | + // should not happen at all |
|
| 3022 | 3459 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3023 | 3460 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3024 | 3461 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3025 | - if ($mail_bo->folderExists($folderName,true)) { |
|
| 3026 | - if($mail_bo->isSentFolder($folderName)) { |
|
| 3462 | + if ($mail_bo->folderExists($folderName,true)) |
|
| 3463 | + { |
|
| 3464 | + if($mail_bo->isSentFolder($folderName)) |
|
| 3465 | + { |
|
| 3027 | 3466 | $flags = '\\Seen'; |
| 3028 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
| 3467 | + } |
|
| 3468 | + elseif($mail_bo->isDraftFolder($folderName)) |
|
| 3469 | + { |
|
| 3029 | 3470 | $flags = '\\Draft'; |
| 3030 | - } else { |
|
| 3471 | + } |
|
| 3472 | + else |
|
| 3473 | + { |
|
| 3031 | 3474 | $flags = '\\Seen'; |
| 3032 | 3475 | } |
| 3033 | 3476 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3050,18 +3493,32 @@ discard block |
||
| 3050 | 3493 | } |
| 3051 | 3494 | } |
| 3052 | 3495 | // if we choose to send from a differing profile |
| 3053 | - if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
|
| 3054 | - foreach($folderOnMailAccount as $folderName) { |
|
| 3055 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
| 3496 | + if ($folderOnMailAccount) |
|
| 3497 | + { |
|
| 3498 | + $this->changeProfile($_formData['mailaccount']); |
|
| 3499 | + } |
|
| 3500 | + foreach($folderOnMailAccount as $folderName) |
|
| 3501 | + { |
|
| 3502 | + if (is_array($folderName)) |
|
| 3503 | + { |
|
| 3504 | + $folderName = array_shift($folderName); |
|
| 3505 | + } |
|
| 3506 | + // should not happen at all |
|
| 3056 | 3507 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
| 3057 | 3508 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
| 3058 | 3509 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
| 3059 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
| 3060 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
| 3510 | + if ($this->mail_bo->folderExists($folderName,true)) |
|
| 3511 | + { |
|
| 3512 | + if($this->mail_bo->isSentFolder($folderName)) |
|
| 3513 | + { |
|
| 3061 | 3514 | $flags = '\\Seen'; |
| 3062 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
| 3515 | + } |
|
| 3516 | + elseif($this->mail_bo->isDraftFolder($folderName)) |
|
| 3517 | + { |
|
| 3063 | 3518 | $flags = '\\Draft'; |
| 3064 | - } else { |
|
| 3519 | + } |
|
| 3520 | + else |
|
| 3521 | + { |
|
| 3065 | 3522 | $flags = '\\Seen'; |
| 3066 | 3523 | } |
| 3067 | 3524 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3083,7 +3540,10 @@ discard block |
||
| 3083 | 3540 | error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
| 3084 | 3541 | } |
| 3085 | 3542 | } |
| 3086 | - if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
|
| 3543 | + if ($folderOnMailAccount) |
|
| 3544 | + { |
|
| 3545 | + $this->changeProfile($_formData['serverID']); |
|
| 3546 | + } |
|
| 3087 | 3547 | |
| 3088 | 3548 | //$mail_bo->closeConnection(); |
| 3089 | 3549 | } |
@@ -3095,10 +3555,16 @@ discard block |
||
| 3095 | 3555 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
| 3096 | 3556 | $lastDrafted['uid'] = $dhA['msgUID']; |
| 3097 | 3557 | $lastDrafted['folder'] = $dhA['folder']; |
| 3098 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3558 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) |
|
| 3559 | + { |
|
| 3560 | + $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
| 3561 | + } |
|
| 3099 | 3562 | // manually drafted, do not delete |
| 3100 | 3563 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
| 3101 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
| 3564 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) |
|
| 3565 | + { |
|
| 3566 | + $lastDrafted=false; |
|
| 3567 | + } |
|
| 3102 | 3568 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
| 3103 | 3569 | } |
| 3104 | 3570 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
@@ -3124,7 +3590,8 @@ discard block |
||
| 3124 | 3590 | |
| 3125 | 3591 | //error_log("handling draft messages, flagging and such"); |
| 3126 | 3592 | if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
| 3127 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
| 3593 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
| 3594 | + { |
|
| 3128 | 3595 | // mark message as answered |
| 3129 | 3596 | $mail_bo->openConnection(); |
| 3130 | 3597 | $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
@@ -3146,7 +3613,9 @@ discard block |
||
| 3146 | 3613 | //error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage())); |
| 3147 | 3614 | unset($e); |
| 3148 | 3615 | } |
| 3149 | - } else { |
|
| 3616 | + } |
|
| 3617 | + else |
|
| 3618 | + { |
|
| 3150 | 3619 | $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
| 3151 | 3620 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
| 3152 | 3621 | if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
@@ -3165,7 +3634,10 @@ discard block |
||
| 3165 | 3634 | } |
| 3166 | 3635 | //$mail_bo->closeConnection(); |
| 3167 | 3636 | } |
| 3168 | - if ($mail_bo) $mail_bo->closeConnection(); |
|
| 3637 | + if ($mail_bo) |
|
| 3638 | + { |
|
| 3639 | + $mail_bo->closeConnection(); |
|
| 3640 | + } |
|
| 3169 | 3641 | //error_log("performing Infolog Stuff"); |
| 3170 | 3642 | //error_log(print_r($this->sessionData['to'],true)); |
| 3171 | 3643 | //error_log(print_r($this->sessionData['cc'],true)); |
@@ -3178,9 +3650,18 @@ discard block |
||
| 3178 | 3650 | { |
| 3179 | 3651 | $mailaddresses = array(); |
| 3180 | 3652 | } |
| 3181 | - if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc']; |
|
| 3182 | - if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
| 3183 | - if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
| 3653 | + if (is_array($this->sessionData['cc'])) |
|
| 3654 | + { |
|
| 3655 | + $mailaddresses['cc'] = $this->sessionData['cc']; |
|
| 3656 | + } |
|
| 3657 | + if (is_array($this->sessionData['bcc'])) |
|
| 3658 | + { |
|
| 3659 | + $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
| 3660 | + } |
|
| 3661 | + if (!empty($mailaddresses)) |
|
| 3662 | + { |
|
| 3663 | + $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
| 3664 | + } |
|
| 3184 | 3665 | |
| 3185 | 3666 | if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
| 3186 | 3667 | { |
@@ -3212,7 +3693,10 @@ discard block |
||
| 3212 | 3693 | $_formData['serverID']),true), |
| 3213 | 3694 | 'app' => $app_name |
| 3214 | 3695 | ); |
| 3215 | - if ($entryid) $target['entry_id'] = $entryid; |
|
| 3696 | + if ($entryid) |
|
| 3697 | + { |
|
| 3698 | + $target['entry_id'] = $entryid; |
|
| 3699 | + } |
|
| 3216 | 3700 | // Open the app called for integration in a popup |
| 3217 | 3701 | // and store the mail raw data as egw_data, in order to |
| 3218 | 3702 | // be stored from registered app method later |
@@ -3223,8 +3707,11 @@ discard block |
||
| 3223 | 3707 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
| 3224 | 3708 | elseif(is_array($this->sessionData['attachments'])) |
| 3225 | 3709 | { |
| 3226 | - foreach($this->sessionData['attachments'] as $value) { |
|
| 3227 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
| 3710 | + foreach($this->sessionData['attachments'] as $value) |
|
| 3711 | + { |
|
| 3712 | + if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') |
|
| 3713 | + { |
|
| 3714 | +// happens when forwarding mails |
|
| 3228 | 3715 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
| 3229 | 3716 | } |
| 3230 | 3717 | } |
@@ -3261,7 +3748,10 @@ discard block |
||
| 3261 | 3748 | $default_identity = null; |
| 3262 | 3749 | foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
| 3263 | 3750 | { |
| 3264 | - if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
|
| 3751 | + if (!isset($default_identity)) |
|
| 3752 | + { |
|
| 3753 | + $default_identity = $identity['ident_id']; |
|
| 3754 | + } |
|
| 3265 | 3755 | if (!empty($identity['ident_signature'])) |
| 3266 | 3756 | { |
| 3267 | 3757 | $content['mailidentity'] = $identity['ident_id']; |
@@ -3269,12 +3759,18 @@ discard block |
||
| 3269 | 3759 | } |
| 3270 | 3760 | } |
| 3271 | 3761 | } |
| 3272 | - if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity; |
|
| 3762 | + if (empty($content['mailidentity'])) |
|
| 3763 | + { |
|
| 3764 | + $content['mailidentity'] = $default_identity; |
|
| 3765 | + } |
|
| 3273 | 3766 | } |
| 3274 | 3767 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
| 3275 | 3768 | { |
| 3276 | 3769 | $content['mimeType'] = 'html'; |
| 3277 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
| 3770 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") |
|
| 3771 | + { |
|
| 3772 | + $content['mimeType'] = 'plain'; |
|
| 3773 | + } |
|
| 3278 | 3774 | } |
| 3279 | 3775 | return $content; |
| 3280 | 3776 | |
@@ -3282,9 +3778,12 @@ discard block |
||
| 3282 | 3778 | |
| 3283 | 3779 | function stripSlashes($_string) |
| 3284 | 3780 | { |
| 3285 | - if (get_magic_quotes_gpc()) { |
|
| 3781 | + if (get_magic_quotes_gpc()) |
|
| 3782 | + { |
|
| 3286 | 3783 | return stripslashes($_string); |
| 3287 | - } else { |
|
| 3784 | + } |
|
| 3785 | + else |
|
| 3786 | + { |
|
| 3288 | 3787 | return $_string; |
| 3289 | 3788 | } |
| 3290 | 3789 | } |
@@ -3297,15 +3796,25 @@ discard block |
||
| 3297 | 3796 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
| 3298 | 3797 | * @return type |
| 3299 | 3798 | */ |
| 3300 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
| 3799 | + function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
|
| 3800 | + { |
|
| 3301 | 3801 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
| 3302 | 3802 | static $useCacheIfPossible = null; |
| 3303 | - if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
|
| 3803 | + if (is_null($useCacheIfPossible)) |
|
| 3804 | + { |
|
| 3805 | + $useCacheIfPossible = true; |
|
| 3806 | + } |
|
| 3304 | 3807 | $_searchString = trim($_REQUEST['query']); |
| 3305 | 3808 | $results = array(); |
| 3306 | 3809 | $rememberServerID = $this->mail_bo->icServer->ImapServerId; |
| 3307 | - if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
| 3308 | - if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
| 3810 | + if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) |
|
| 3811 | + { |
|
| 3812 | + $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
| 3813 | + } |
|
| 3814 | + if (empty($_mailaccountToSearch)) |
|
| 3815 | + { |
|
| 3816 | + $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
| 3817 | + } |
|
| 3309 | 3818 | if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch) |
| 3310 | 3819 | { |
| 3311 | 3820 | $this->changeProfile($_mailaccountToSearch); |
@@ -3316,7 +3825,8 @@ discard block |
||
| 3316 | 3825 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
| 3317 | 3826 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
| 3318 | 3827 | $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
| 3319 | - if (count($folderObjects)<=1) { |
|
| 3828 | + if (count($folderObjects)<=1) |
|
| 3829 | + { |
|
| 3320 | 3830 | $useCacheIfPossible = false; |
| 3321 | 3831 | } |
| 3322 | 3832 | else |
@@ -3367,7 +3877,8 @@ discard block |
||
| 3367 | 3877 | exit(); |
| 3368 | 3878 | } |
| 3369 | 3879 | |
| 3370 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
| 3880 | + public static function ajax_searchAddress($_searchStringLength=2) |
|
| 3881 | + { |
|
| 3371 | 3882 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
| 3372 | 3883 | $_searchString = trim($_REQUEST['query']); |
| 3373 | 3884 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3380,7 +3891,8 @@ discard block |
||
| 3380 | 3891 | { |
| 3381 | 3892 | $lists = array_filter( |
| 3382 | 3893 | $contacts_obj->get_lists(Acl::READ), |
| 3383 | - function($element) use($_searchString) { |
|
| 3894 | + function($element) use($_searchString) |
|
| 3895 | + { |
|
| 3384 | 3896 | return (stripos($element, $_searchString) !== false); |
| 3385 | 3897 | } |
| 3386 | 3898 | ); |
@@ -3395,7 +3907,10 @@ discard block |
||
| 3395 | 3907 | 'title' => lang('Mailinglist'), |
| 3396 | 3908 | 'data' => $key |
| 3397 | 3909 | ); |
| 3398 | - if($list_count++ > 5) break; |
|
| 3910 | + if($list_count++ > 5) |
|
| 3911 | + { |
|
| 3912 | + break; |
|
| 3913 | + } |
|
| 3399 | 3914 | } |
| 3400 | 3915 | } |
| 3401 | 3916 | |
@@ -3406,7 +3921,10 @@ discard block |
||
| 3406 | 3921 | $search = explode(' ', $_searchString); |
| 3407 | 3922 | foreach ($search as $k => $v) |
| 3408 | 3923 | { |
| 3409 | - if (mb_strlen($v) < 3) unset($search[$k]); |
|
| 3924 | + if (mb_strlen($v) < 3) |
|
| 3925 | + { |
|
| 3926 | + unset($search[$k]); |
|
| 3927 | + } |
|
| 3410 | 3928 | } |
| 3411 | 3929 | $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
| 3412 | 3930 | //error_log(__METHOD__.__LINE__.$_searchString); |
@@ -3436,9 +3954,12 @@ discard block |
||
| 3436 | 3954 | } |
| 3437 | 3955 | } |
| 3438 | 3956 | |
| 3439 | - if(is_array($contacts)) { |
|
| 3440 | - foreach($contacts as $contact) { |
|
| 3441 | - foreach(array($contact['email'],$contact['email_home']) as $email) { |
|
| 3957 | + if(is_array($contacts)) |
|
| 3958 | + { |
|
| 3959 | + foreach($contacts as $contact) |
|
| 3960 | + { |
|
| 3961 | + foreach(array($contact['email'],$contact['email_home']) as $email) |
|
| 3962 | + { |
|
| 3442 | 3963 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
| 3443 | 3964 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
| 3444 | 3965 | $rfcAddr = Mail::parseAddressList($email); |
@@ -3452,10 +3973,22 @@ discard block |
||
| 3452 | 3973 | if (method_exists($contacts_obj,'search')) |
| 3453 | 3974 | { |
| 3454 | 3975 | $contact['n_fn']=''; |
| 3455 | - if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
|
| 3456 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3457 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3458 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3976 | + if (!empty($contact['n_prefix'])) |
|
| 3977 | + { |
|
| 3978 | + $contact['n_fn'] = $contact['n_prefix']; |
|
| 3979 | + } |
|
| 3980 | + if (!empty($contact['n_given'])) |
|
| 3981 | + { |
|
| 3982 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
| 3983 | + } |
|
| 3984 | + if (!empty($contact['n_family'])) |
|
| 3985 | + { |
|
| 3986 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
| 3987 | + } |
|
| 3988 | + if (!empty($contact['org_name'])) |
|
| 3989 | + { |
|
| 3990 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
| 3991 | + } |
|
| 3459 | 3992 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
| 3460 | 3993 | } |
| 3461 | 3994 | else |
@@ -3465,7 +3998,8 @@ discard block |
||
| 3465 | 3998 | $args = explode('@', trim($email)); |
| 3466 | 3999 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
| 3467 | 4000 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
| 3468 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
| 4001 | + if(!empty($email) && in_array($completeMailString ,$results) === false) |
|
| 4002 | + { |
|
| 3469 | 4003 | $results[] = array( |
| 3470 | 4004 | 'id'=>$completeMailString, |
| 3471 | 4005 | 'label' => $completeMailString, |
@@ -3484,7 +4018,10 @@ discard block |
||
| 3484 | 4018 | foreach($groups as $g_id => $name) |
| 3485 | 4019 | { |
| 3486 | 4020 | $group = $GLOBALS['egw']->accounts->read($g_id); |
| 3487 | - if(!$group['account_email']) continue; |
|
| 4021 | + if(!$group['account_email']) |
|
| 4022 | + { |
|
| 4023 | + continue; |
|
| 4024 | + } |
|
| 3488 | 4025 | $args = explode('@', trim($group['account_email'])); |
| 3489 | 4026 | $args[] = $name; |
| 3490 | 4027 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |