@@ -84,29 +84,47 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function __construct(activesync_backend $backend) |
| 86 | 86 | { |
| 87 | - if ($GLOBALS['egw_setup']) return; |
|
| 87 | + if ($GLOBALS['egw_setup']) |
|
| 88 | + { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | //$this->debugLevel=2; |
| 90 | 93 | $this->backend = $backend; |
| 91 | 94 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 92 | 95 | { |
| 93 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 96 | + if ($this->debugLevel>1) |
|
| 97 | + { |
|
| 98 | + error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 99 | + } |
|
| 94 | 100 | // globals preferences add appname varname value |
| 95 | 101 | $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
| 96 | 102 | // save prefs |
| 97 | 103 | $GLOBALS['egw']->preferences->save_repository(true); |
| 98 | 104 | } |
| 99 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 105 | + if ($this->debugLevel>1) |
|
| 106 | + { |
|
| 107 | + error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 108 | + } |
|
| 100 | 109 | |
| 101 | 110 | if (is_null(self::$profileID)) |
| 102 | 111 | { |
| 103 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 112 | + if ($this->debugLevel>1) |
|
| 113 | + { |
|
| 114 | + error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 115 | + } |
|
| 104 | 116 | self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
| 105 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 117 | + if ($this->debugLevel>1) |
|
| 118 | + { |
|
| 119 | + error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 120 | + } |
|
| 106 | 121 | } |
| 107 | 122 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 108 | 123 | { |
| 109 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 124 | + if ($this->debugLevel>1) |
|
| 125 | + { |
|
| 126 | + error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 127 | + } |
|
| 110 | 128 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
| 111 | 129 | { |
| 112 | 130 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -116,7 +134,10 @@ discard block |
||
| 116 | 134 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
| 117 | 135 | } |
| 118 | 136 | } |
| 119 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 137 | + if ($this->debugLevel>1) |
|
| 138 | + { |
|
| 139 | + error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 140 | + } |
|
| 120 | 141 | |
| 121 | 142 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
| 122 | 143 | if (!isset($GLOBALS['egw_setup'])) |
@@ -129,7 +150,10 @@ discard block |
||
| 129 | 150 | self::$profileID = Mail\Account::get_default_acc_id(); |
| 130 | 151 | } |
| 131 | 152 | } |
| 132 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 153 | + if ($this->debugLevel>0) |
|
| 154 | + { |
|
| 155 | + error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 156 | + } |
|
| 133 | 157 | //$this->debugLevel=0; |
| 134 | 158 | } |
| 135 | 159 | |
@@ -245,8 +269,14 @@ discard block |
||
| 245 | 269 | $this->_connect(0,true); |
| 246 | 270 | $this->_disconnect(); |
| 247 | 271 | |
| 248 | - if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 249 | - if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 272 | + if (!$this->_wasteID) |
|
| 273 | + { |
|
| 274 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 275 | + } |
|
| 276 | + if (!$this->_sentID) |
|
| 277 | + { |
|
| 278 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 279 | + } |
|
| 250 | 280 | } |
| 251 | 281 | catch(Exception $e) { |
| 252 | 282 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
@@ -268,8 +298,14 @@ discard block |
||
| 268 | 298 | */ |
| 269 | 299 | private function _connect($account=0) |
| 270 | 300 | { |
| 271 | - if (!$account) $account = self::$profileID ? self::$profileID : 0; |
|
| 272 | - if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
| 301 | + if (!$account) |
|
| 302 | + { |
|
| 303 | + $account = self::$profileID ? self::$profileID : 0; |
|
| 304 | + } |
|
| 305 | + if ($this->mail && $this->account != $account) |
|
| 306 | + { |
|
| 307 | + $this->_disconnect(); |
|
| 308 | + } |
|
| 273 | 309 | |
| 274 | 310 | $this->_wasteID = false; |
| 275 | 311 | $this->_sentID = false; |
@@ -280,12 +316,18 @@ discard block |
||
| 280 | 316 | // todo: tell mail which account to use |
| 281 | 317 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 282 | 318 | $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
| 283 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 319 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 320 | + { |
|
| 321 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 322 | + } |
|
| 284 | 323 | } |
| 285 | 324 | else |
| 286 | 325 | { |
| 287 | 326 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 288 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 327 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 328 | + { |
|
| 329 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 330 | + } |
|
| 289 | 331 | } |
| 290 | 332 | $this->mail->openConnection(self::$profileID,false); |
| 291 | 333 | |
@@ -302,8 +344,14 @@ discard block |
||
| 302 | 344 | */ |
| 303 | 345 | private function _disconnect() |
| 304 | 346 | { |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 306 | - if ($this->mail) $this->mail->closeConnection(); |
|
| 347 | + if ($this->debugLevel>0) |
|
| 348 | + { |
|
| 349 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 350 | + } |
|
| 351 | + if ($this->mail) |
|
| 352 | + { |
|
| 353 | + $this->mail->closeConnection(); |
|
| 354 | + } |
|
| 307 | 355 | |
| 308 | 356 | unset($this->mail); |
| 309 | 357 | unset($this->account); |
@@ -318,24 +366,43 @@ discard block |
||
| 318 | 366 | public function GetFolderList() |
| 319 | 367 | { |
| 320 | 368 | $folderlist = array(); |
| 321 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 369 | + if ($this->debugLevel>0) |
|
| 370 | + { |
|
| 371 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 372 | + } |
|
| 322 | 373 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 323 | 374 | { |
| 324 | 375 | $this->_connect($account); |
| 325 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 326 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 376 | + if (!isset($this->folders)) |
|
| 377 | + { |
|
| 378 | + $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 379 | + } |
|
| 380 | + if ($this->debugLevel>1) |
|
| 381 | + { |
|
| 382 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 383 | + } |
|
| 327 | 384 | |
| 328 | - foreach ($this->folders as $folder => $folderObj) { |
|
| 329 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 385 | + foreach ($this->folders as $folder => $folderObj) |
|
| 386 | + { |
|
| 387 | + if ($this->debugLevel>1) |
|
| 388 | + { |
|
| 389 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 390 | + } |
|
| 330 | 391 | $folderlist[] = $f = array( |
| 331 | 392 | 'id' => $this->createID($account,$folder), |
| 332 | 393 | 'mod' => $folderObj->shortDisplayName, |
| 333 | 394 | 'parent' => $this->getParentID($account,$folder), |
| 334 | 395 | ); |
| 335 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 396 | + if ($this->debugLevel>1) |
|
| 397 | + { |
|
| 398 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 399 | + } |
|
| 336 | 400 | } |
| 337 | 401 | } |
| 338 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 402 | + if ($this->debugLevel>0) |
|
| 403 | + { |
|
| 404 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 405 | + } |
|
| 339 | 406 | |
| 340 | 407 | return $folderlist; |
| 341 | 408 | } |
@@ -396,11 +463,17 @@ discard block |
||
| 396 | 463 | $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
| 397 | 464 | |
| 398 | 465 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
| 399 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 466 | + if ($this->debugLevel>0) |
|
| 467 | + { |
|
| 468 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 469 | + } |
|
| 400 | 470 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 401 | 471 | |
| 402 | 472 | // initialize our Mail |
| 403 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 473 | + if (!isset($this->mail)) |
|
| 474 | + { |
|
| 475 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 476 | + } |
|
| 404 | 477 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 405 | 478 | // use the standardIdentity |
| 406 | 479 | $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
@@ -428,12 +501,18 @@ discard block |
||
| 428 | 501 | $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
| 429 | 502 | $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 430 | 503 | $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
| 431 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 504 | + if ($this->debugLevel>0) |
|
| 505 | + { |
|
| 506 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 507 | + } |
|
| 432 | 508 | $sigTextHtml = $beforeHtml.$sigText; |
| 433 | 509 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 434 | 510 | |
| 435 | 511 | $force8bit=false; |
| 436 | - if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
| 512 | + if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') |
|
| 513 | + { |
|
| 514 | + $force8bit=true; |
|
| 515 | + } |
|
| 437 | 516 | // initialize the new Api\Mailer object for sending |
| 438 | 517 | $mailObject = new Api\Mailer(self::$profileID); |
| 439 | 518 | $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); |
@@ -444,22 +523,34 @@ discard block |
||
| 444 | 523 | |
| 445 | 524 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 446 | 525 | // to |
| 447 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 448 | - if (!$addressObject->valid) continue; |
|
| 526 | + foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) |
|
| 527 | + { |
|
| 528 | + if (!$addressObject->valid) |
|
| 529 | + { |
|
| 530 | + continue; |
|
| 531 | + } |
|
| 449 | 532 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
| 450 | 533 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 451 | 534 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 452 | 535 | } |
| 453 | 536 | // CC |
| 454 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 455 | - if (!$addressObject->valid) continue; |
|
| 537 | + foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) |
|
| 538 | + { |
|
| 539 | + if (!$addressObject->valid) |
|
| 540 | + { |
|
| 541 | + continue; |
|
| 542 | + } |
|
| 456 | 543 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
| 457 | 544 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 458 | 545 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 459 | 546 | } |
| 460 | 547 | // BCC |
| 461 | - foreach($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 462 | - if (!$addressObject->valid) continue; |
|
| 548 | + foreach($mailObject->getAddresses('bcc') as $addressObject) |
|
| 549 | + { |
|
| 550 | + if (!$addressObject->valid) |
|
| 551 | + { |
|
| 552 | + continue; |
|
| 553 | + } |
|
| 463 | 554 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
| 464 | 555 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 465 | 556 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
@@ -472,12 +563,14 @@ discard block |
||
| 472 | 563 | $ContentType =$mailObject->getHeader('Content-Type'); |
| 473 | 564 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 474 | 565 | // if the message is a multipart message, then we should use the sent body |
| 475 | - if (preg_match("/multipart/i", $ContentType)) { |
|
| 566 | + if (preg_match("/multipart/i", $ContentType)) |
|
| 567 | + { |
|
| 476 | 568 | $use_orgbody = true; |
| 477 | 569 | } |
| 478 | 570 | |
| 479 | 571 | // save the original content-type header for the body part when forwarding |
| 480 | - if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) { |
|
| 572 | + if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) |
|
| 573 | + { |
|
| 481 | 574 | //continue; // ignore |
| 482 | 575 | } |
| 483 | 576 | // horde/egw_ mailer does everything as utf-8, the following should not be needed |
@@ -486,7 +579,8 @@ discard block |
||
| 486 | 579 | // if the message is a multipart message, then we should use the sent body |
| 487 | 580 | if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') && |
| 488 | 581 | ((isset($smartdata->replacemime) && $smartdata->replacemime == true) || |
| 489 | - $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
| 582 | + $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) |
|
| 583 | + { |
|
| 490 | 584 | $use_orgbody = true; |
| 491 | 585 | } |
| 492 | 586 | $Body = $AltBody = ""; |
@@ -519,12 +613,19 @@ discard block |
||
| 519 | 613 | $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
| 520 | 614 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 521 | 615 | } |
| 522 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 523 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 616 | + if ($this->debugLevel>1 && $Body) |
|
| 617 | + { |
|
| 618 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 619 | + } |
|
| 620 | + if ($this->debugLevel>1 && $AltBody) |
|
| 621 | + { |
|
| 622 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 623 | + } |
|
| 524 | 624 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 525 | 625 | // if this is a multipart message with a boundary, we must use the original body |
| 526 | 626 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 527 | - if ($use_orgbody) { |
|
| 627 | + if ($use_orgbody) |
|
| 628 | + { |
|
| 528 | 629 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
| 529 | 630 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 530 | 631 | if (($cal_body = $mailObject->findBody('calendar')) && |
@@ -534,15 +635,20 @@ discard block |
||
| 534 | 635 | { |
| 535 | 636 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 536 | 637 | } |
| 537 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 638 | + if ($this->debugLevel) |
|
| 639 | + { |
|
| 640 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 641 | + } |
|
| 538 | 642 | $ClientSideMeetingRequest = true; |
| 539 | 643 | } |
| 540 | 644 | } |
| 541 | 645 | // now handle the addressee list |
| 542 | 646 | $toCount = 0; |
| 543 | 647 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 544 | - foreach((array)$toMailAddr as $address) { |
|
| 545 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 648 | + foreach((array)$toMailAddr as $address) |
|
| 649 | + { |
|
| 650 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 651 | + { |
|
| 546 | 652 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 547 | 653 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 548 | 654 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
@@ -556,19 +662,29 @@ discard block |
||
| 556 | 662 | } |
| 557 | 663 | } |
| 558 | 664 | $ccCount = 0; |
| 559 | - foreach((array)$ccMailAddr as $address) { |
|
| 560 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 665 | + foreach((array)$ccMailAddr as $address) |
|
| 666 | + { |
|
| 667 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 668 | + { |
|
| 561 | 669 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 562 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 670 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 671 | + { |
|
| 672 | + continue; |
|
| 673 | + } |
|
| 563 | 674 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 564 | 675 | $ccCount++; |
| 565 | 676 | } |
| 566 | 677 | } |
| 567 | 678 | $bccCount = 0; |
| 568 | - foreach((array)$bccMailAddr as $address) { |
|
| 569 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 679 | + foreach((array)$bccMailAddr as $address) |
|
| 680 | + { |
|
| 681 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 682 | + { |
|
| 570 | 683 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 571 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 684 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 685 | + { |
|
| 686 | + continue; |
|
| 687 | + } |
|
| 572 | 688 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 573 | 689 | $bccCount++; |
| 574 | 690 | } |
@@ -578,7 +694,10 @@ discard block |
||
| 578 | 694 | { |
| 579 | 695 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 580 | 696 | } |
| 581 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 697 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) |
|
| 698 | + { |
|
| 699 | + return true; |
|
| 700 | + } |
|
| 582 | 701 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 583 | 702 | /* |
| 584 | 703 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -601,10 +720,17 @@ discard block |
||
| 601 | 720 | $this->mail->reopen($folder); |
| 602 | 721 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 603 | 722 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 604 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 605 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 723 | + if ($this->debugLevel>3) |
|
| 724 | + { |
|
| 725 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 726 | + } |
|
| 727 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 728 | + { |
|
| 606 | 729 | // may be html |
| 607 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 730 | + if ($this->debugLevel>0) |
|
| 731 | + { |
|
| 732 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 733 | + } |
|
| 608 | 734 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 609 | 735 | $isreply = true; |
| 610 | 736 | } |
@@ -613,8 +739,12 @@ discard block |
||
| 613 | 739 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 614 | 740 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 615 | 741 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 616 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 617 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 742 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 743 | + { |
|
| 744 | + if ($this->debugLevel>0) |
|
| 745 | + { |
|
| 746 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 747 | + } |
|
| 618 | 748 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 619 | 749 | $isreply = true; |
| 620 | 750 | } |
@@ -622,7 +752,10 @@ discard block |
||
| 622 | 752 | { |
| 623 | 753 | $isreply = true; |
| 624 | 754 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 625 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 755 | + if ($this->debugLevel>0) |
|
| 756 | + { |
|
| 757 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 758 | + } |
|
| 626 | 759 | } |
| 627 | 760 | } |
| 628 | 761 | |
@@ -636,11 +769,17 @@ discard block |
||
| 636 | 769 | (isset($smartdata->replacemime) && $smartdata->replacemime == false))) |
| 637 | 770 | { |
| 638 | 771 | //force the default for the forwarding -> asmail |
| 639 | - if (is_array($preferencesArray)) { |
|
| 772 | + if (is_array($preferencesArray)) |
|
| 773 | + { |
|
| 640 | 774 | if (!array_key_exists('message_forwarding',$preferencesArray) |
| 641 | 775 | || !isset($preferencesArray['message_forwarding']) |
| 642 | - || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 643 | - } else { |
|
| 776 | + || empty($preferencesArray['message_forwarding'])) |
|
| 777 | + { |
|
| 778 | + $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | + else |
|
| 782 | + { |
|
| 644 | 783 | $preferencesArray['message_forwarding'] = 'asmail'; |
| 645 | 784 | } |
| 646 | 785 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
@@ -672,27 +811,44 @@ discard block |
||
| 672 | 811 | $this->mail->reopen($folder); |
| 673 | 812 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 674 | 813 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 675 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 676 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 814 | + if ($this->debugLevel>0) |
|
| 815 | + { |
|
| 816 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 817 | + } |
|
| 818 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 819 | + { |
|
| 677 | 820 | // may be html |
| 678 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 821 | + if ($this->debugLevel>0) |
|
| 822 | + { |
|
| 823 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 824 | + } |
|
| 679 | 825 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 680 | 826 | $isforward = true; |
| 681 | 827 | } |
| 682 | 828 | // plain text Message part |
| 683 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 829 | + if ($this->debugLevel>0) |
|
| 830 | + { |
|
| 831 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 832 | + } |
|
| 684 | 833 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 685 | 834 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 686 | 835 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 687 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 688 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 836 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 837 | + { |
|
| 838 | + if ($this->debugLevel>0) |
|
| 839 | + { |
|
| 840 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 841 | + } |
|
| 689 | 842 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 690 | 843 | $isforward = true; |
| 691 | 844 | } |
| 692 | 845 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 693 | 846 | { |
| 694 | 847 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 695 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 848 | + if ($this->debugLevel>0) |
|
| 849 | + { |
|
| 850 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 851 | + } |
|
| 696 | 852 | $isforward = true; |
| 697 | 853 | } |
| 698 | 854 | // get all the attachments and add them too. |
@@ -705,7 +861,10 @@ discard block |
||
| 705 | 861 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
| 706 | 862 | foreach((array)$attachments as $key => $attachment) |
| 707 | 863 | { |
| 708 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 864 | + if ($this->debugLevel>0) |
|
| 865 | + { |
|
| 866 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 867 | + } |
|
| 709 | 868 | $attachmentNames .= $attachment['name']."\n"; |
| 710 | 869 | $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
| 711 | 870 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
@@ -724,20 +883,29 @@ discard block |
||
| 724 | 883 | // now set the body |
| 725 | 884 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 726 | 885 | { |
| 727 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 886 | + if ($this->debugLevel>1) |
|
| 887 | + { |
|
| 888 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 889 | + } |
|
| 728 | 890 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 729 | 891 | $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 730 | 892 | } |
| 731 | 893 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 732 | 894 | { |
| 733 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 895 | + if ($this->debugLevel>1) |
|
| 896 | + { |
|
| 897 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 898 | + } |
|
| 734 | 899 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 735 | 900 | $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 736 | 901 | } |
| 737 | 902 | //advanced debugging |
| 738 | 903 | // Horde SMTP Class uses utf-8 by default. |
| 739 | 904 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 740 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 905 | + if ($this->debugLevel>2) |
|
| 906 | + { |
|
| 907 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 908 | + } |
|
| 741 | 909 | |
| 742 | 910 | // set a higher timeout for big messages |
| 743 | 911 | @set_time_limit(120); |
@@ -764,7 +932,9 @@ discard block |
||
| 764 | 932 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 765 | 933 | { |
| 766 | 934 | $this->mail->deleteMessages(array($uid),$folder); |
| 767 | - } else { |
|
| 935 | + } |
|
| 936 | + else |
|
| 937 | + { |
|
| 768 | 938 | $this->mail->flagMessages("answered", array($uid),$folder); |
| 769 | 939 | if ($smartdata_task== "forward") |
| 770 | 940 | { |
@@ -778,7 +948,8 @@ discard block |
||
| 778 | 948 | { |
| 779 | 949 | $asf = false; |
| 780 | 950 | $sentFolder = $this->mail->getSentFolder(); |
| 781 | - if ($this->_sentID) { |
|
| 951 | + if ($this->_sentID) |
|
| 952 | + { |
|
| 782 | 953 | $folderArray[] = $this->_sentID; |
| 783 | 954 | } |
| 784 | 955 | else if(isset($sentFolder) && $sentFolder != 'none') |
@@ -792,28 +963,41 @@ discard block |
||
| 792 | 963 | // we dont try guessing |
| 793 | 964 | $asf = true; |
| 794 | 965 | } |
| 795 | - if (count($folderArray) > 0) { |
|
| 796 | - foreach((array)$bccMailAddr as $address) { |
|
| 797 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 966 | + if (count($folderArray) > 0) |
|
| 967 | + { |
|
| 968 | + foreach((array)$bccMailAddr as $address) |
|
| 969 | + { |
|
| 970 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 971 | + { |
|
| 798 | 972 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 799 | 973 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 800 | 974 | } |
| 801 | 975 | } |
| 802 | 976 | //$BCCmail=''; |
| 803 | - if (count($mailAddr)>0) $mailObject->forceBccHeader(); |
|
| 977 | + if (count($mailAddr)>0) |
|
| 978 | + { |
|
| 979 | + $mailObject->forceBccHeader(); |
|
| 980 | + } |
|
| 804 | 981 | //$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
| 805 | - foreach($folderArray as $folderName) { |
|
| 806 | - if($this->mail->isSentFolder($folderName)) { |
|
| 982 | + foreach($folderArray as $folderName) |
|
| 983 | + { |
|
| 984 | + if($this->mail->isSentFolder($folderName)) |
|
| 985 | + { |
|
| 807 | 986 | $flags = '\\Seen'; |
| 808 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 987 | + } |
|
| 988 | + elseif($this->mail->isDraftFolder($folderName)) |
|
| 989 | + { |
|
| 809 | 990 | $flags = '\\Draft'; |
| 810 | - } else { |
|
| 991 | + } |
|
| 992 | + else |
|
| 993 | + { |
|
| 811 | 994 | $flags = ''; |
| 812 | 995 | } |
| 813 | 996 | $asf = true; |
| 814 | 997 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 815 | 998 | $this->mail->openConnection(self::$profileID,false); |
| 816 | - if ($this->mail->folderExists($folderName)) { |
|
| 999 | + if ($this->mail->folderExists($folderName)) |
|
| 1000 | + { |
|
| 817 | 1001 | try |
| 818 | 1002 | { |
| 819 | 1003 | $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
@@ -871,17 +1055,26 @@ discard block |
||
| 871 | 1055 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 872 | 1056 | |
| 873 | 1057 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 874 | - if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
|
| 1058 | + if (!$mimesupport && ($key = array_search('4', $bodypreference))) |
|
| 1059 | + { |
|
| 1060 | + unset($bodypreference[$key]); |
|
| 1061 | + } |
|
| 875 | 1062 | |
| 876 | 1063 | //$this->debugLevel=4; |
| 877 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1064 | + if (!isset($this->mail)) |
|
| 1065 | + { |
|
| 1066 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1067 | + } |
|
| 878 | 1068 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
| 879 | 1069 | $account = $_folderName = $xid = null; |
| 880 | 1070 | $this->splitID($folderid,$account,$_folderName,$xid); |
| 881 | 1071 | $this->mail->reopen($_folderName); |
| 882 | 1072 | $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
| 883 | 1073 | $headers = $messages[$id]; |
| 884 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1074 | + if ($this->debugLevel>3) |
|
| 1075 | + { |
|
| 1076 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1077 | + } |
|
| 885 | 1078 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 886 | 1079 | if ($headers) |
| 887 | 1080 | { |
@@ -891,16 +1084,25 @@ discard block |
||
| 891 | 1084 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 892 | 1085 | // simple style |
| 893 | 1086 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 894 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1087 | + if ($this->debugLevel>0) |
|
| 1088 | + { |
|
| 1089 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1090 | + } |
|
| 895 | 1091 | |
| 896 | - if ($bodypreference === false) { |
|
| 1092 | + if ($bodypreference === false) |
|
| 1093 | + { |
|
| 897 | 1094 | $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
| 898 | 1095 | $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 899 | 1096 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 900 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 1097 | + if (stripos($raw_body,'<style')!==false) |
|
| 1098 | + { |
|
| 1099 | + $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); |
|
| 1100 | + } |
|
| 1101 | + // in case there is only a html part |
|
| 901 | 1102 | // remove all other html |
| 902 | 1103 | $body = strip_tags($raw_body); |
| 903 | - if(strlen($body) > $truncsize) { |
|
| 1104 | + if(strlen($body) > $truncsize) |
|
| 1105 | + { |
|
| 904 | 1106 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 905 | 1107 | $output->bodytruncated = 1; |
| 906 | 1108 | } |
@@ -915,7 +1117,8 @@ discard block |
||
| 915 | 1117 | { |
| 916 | 1118 | //Select body type preference |
| 917 | 1119 | $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
| 918 | - if ($bodypreference !== false) { |
|
| 1120 | + if ($bodypreference !== false) |
|
| 1121 | + { |
|
| 919 | 1122 | // bodypreference can occur multiple times |
| 920 | 1123 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
| 921 | 1124 | $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -949,25 +1152,49 @@ discard block |
||
| 949 | 1152 | // fetch the body (try to gather data only once) |
| 950 | 1153 | $css =''; |
| 951 | 1154 | $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
| 952 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1155 | + if ($this->debugLevel>2) |
|
| 1156 | + { |
|
| 1157 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1158 | + } |
|
| 953 | 1159 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 954 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 955 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 1160 | + if ($this->debugLevel>3) |
|
| 1161 | + { |
|
| 1162 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 1163 | + } |
|
| 1164 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 1165 | + { |
|
| 956 | 1166 | // may be html |
| 957 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1167 | + if ($this->debugLevel>0) |
|
| 1168 | + { |
|
| 1169 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1170 | + } |
|
| 958 | 1171 | $css = $this->mail->getStyles($bodyStruct); |
| 959 | 1172 | $output->nativebodytype=2; |
| 960 | - } else { |
|
| 1173 | + } |
|
| 1174 | + else |
|
| 1175 | + { |
|
| 961 | 1176 | // plain text Message |
| 962 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1177 | + if ($this->debugLevel>0) |
|
| 1178 | + { |
|
| 1179 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1180 | + } |
|
| 963 | 1181 | $output->nativebodytype=1; |
| 964 | 1182 | $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
| 965 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1183 | + if ($this->debugLevel>3) |
|
| 1184 | + { |
|
| 1185 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1186 | + } |
|
| 966 | 1187 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 967 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1188 | + if ($this->debugLevel>3) |
|
| 1189 | + { |
|
| 1190 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1191 | + } |
|
| 968 | 1192 | } |
| 969 | 1193 | // whatever format decode (using the correct encoding) |
| 970 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1194 | + if ($this->debugLevel>3) |
|
| 1195 | + { |
|
| 1196 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1197 | + } |
|
| 971 | 1198 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 972 | 1199 | // prepare plaintextbody |
| 973 | 1200 | $plainBody=''; |
@@ -988,12 +1215,18 @@ discard block |
||
| 988 | 1215 | // remove all other html |
| 989 | 1216 | $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
| 990 | 1217 | $plainBody = strip_tags($plainBody); |
| 991 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1218 | + if ($this->debugLevel>3 && $output->nativebodytype==1) |
|
| 1219 | + { |
|
| 1220 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1221 | + } |
|
| 992 | 1222 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 993 | 1223 | |
| 994 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 1224 | + if ($bpReturnType==2) |
|
| 1225 | + { |
|
| 1226 | + //SYNC_BODYPREFERENCE_HTML |
|
| 995 | 1227 | { |
| 996 | 1228 | if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
| 1229 | + } |
|
| 997 | 1230 | // Send HTML if requested and native type was html |
| 998 | 1231 | $output->asbody->type = 2; |
| 999 | 1232 | $htmlbody = '<html>'. |
@@ -1005,7 +1238,10 @@ discard block |
||
| 1005 | 1238 | '<body>'; |
| 1006 | 1239 | if ($output->nativebodytype==2) |
| 1007 | 1240 | { |
| 1008 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1241 | + if ($css) |
|
| 1242 | + { |
|
| 1243 | + Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1244 | + } |
|
| 1009 | 1245 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1010 | 1246 | $htmlbody .= $body; |
| 1011 | 1247 | } |
@@ -1030,7 +1266,10 @@ discard block |
||
| 1030 | 1266 | else |
| 1031 | 1267 | { |
| 1032 | 1268 | // Send Plaintext as Fallback or if original body is plainttext |
| 1033 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1269 | + if ($this->debugLevel>0) |
|
| 1270 | + { |
|
| 1271 | + ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1272 | + } |
|
| 1034 | 1273 | /* we use plainBody (set above) instead |
| 1035 | 1274 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1036 | 1275 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1067,7 +1306,9 @@ discard block |
||
| 1067 | 1306 | { |
| 1068 | 1307 | $output->flag->flagstatus = 2; |
| 1069 | 1308 | //$output->flag->flagtype = "Flag for Follow up"; |
| 1070 | - } else { |
|
| 1309 | + } |
|
| 1310 | + else |
|
| 1311 | + { |
|
| 1071 | 1312 | $output->flag->flagstatus = 0; |
| 1072 | 1313 | } |
| 1073 | 1314 | if ($headers['answered']) |
@@ -1083,10 +1324,20 @@ discard block |
||
| 1083 | 1324 | ($headers['priority'] < 3 ? 2 : 1) ; |
| 1084 | 1325 | $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
| 1085 | 1326 | $output->to = $headers['to_address']; |
| 1086 | - if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
|
| 1327 | + if ($headers['to']) |
|
| 1328 | + { |
|
| 1329 | + $output->displayto = $headers['to_address']; |
|
| 1330 | + } |
|
| 1331 | + //$headers['FETCHED_HEADER']['to_name'] |
|
| 1087 | 1332 | $output->from = $headers['sender_address']; |
| 1088 | - if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses']; |
|
| 1089 | - if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
|
| 1333 | + if (isset($headers['cc_addresses']) && $headers['cc_addresses']) |
|
| 1334 | + { |
|
| 1335 | + $output->cc = $headers['cc_addresses']; |
|
| 1336 | + } |
|
| 1337 | + if (isset($headers['reply_to_address']) && $headers['reply_to_address']) |
|
| 1338 | + { |
|
| 1339 | + $output->reply_to = $headers['reply_to_address']; |
|
| 1340 | + } |
|
| 1090 | 1341 | |
| 1091 | 1342 | $output->messageclass = "IPM.Note"; |
| 1092 | 1343 | if (stripos($headers['mimetype'],'multipart')!== false && |
@@ -1094,7 +1345,8 @@ discard block |
||
| 1094 | 1345 | { |
| 1095 | 1346 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1096 | 1347 | } |
| 1097 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1348 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1349 | + { |
|
| 1098 | 1350 | $output->contentclass = "urn:content-classes:message"; |
| 1099 | 1351 | } |
| 1100 | 1352 | |
@@ -1107,7 +1359,10 @@ discard block |
||
| 1107 | 1359 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1108 | 1360 | foreach ($attachments as $key => $attach) |
| 1109 | 1361 | { |
| 1110 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1362 | + if ($this->debugLevel>0) |
|
| 1363 | + { |
|
| 1364 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1365 | + } |
|
| 1111 | 1366 | |
| 1112 | 1367 | // pass meeting requests to calendar plugin |
| 1113 | 1368 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1124,17 +1379,24 @@ discard block |
||
| 1124 | 1379 | unset($attachment); |
| 1125 | 1380 | continue; // do NOT add attachment as attachment |
| 1126 | 1381 | } |
| 1127 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1382 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1383 | + { |
|
| 1128 | 1384 | $attachment = new SyncBaseAttachment(); |
| 1129 | 1385 | if (!isset($output->asattachments) || !is_array($output->asattachments)) |
| 1130 | - $output->asattachments = array(); |
|
| 1386 | + { |
|
| 1387 | + $output->asattachments = array(); |
|
| 1388 | + } |
|
| 1131 | 1389 | $attachment->estimatedDataSize = $attach['size']; |
| 1132 | 1390 | $attachment->method = 1; |
| 1133 | 1391 | $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
| 1134 | - } else { |
|
| 1392 | + } |
|
| 1393 | + else |
|
| 1394 | + { |
|
| 1135 | 1395 | $attachment = new SyncAttachment(); |
| 1136 | 1396 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1137 | - $output->attachments = array(); |
|
| 1397 | + { |
|
| 1398 | + $output->attachments = array(); |
|
| 1399 | + } |
|
| 1138 | 1400 | $attachment->attsize = $attach['size']; |
| 1139 | 1401 | $attachment->attmethod = 1; |
| 1140 | 1402 | $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
@@ -1151,10 +1413,13 @@ discard block |
||
| 1151 | 1413 | { |
| 1152 | 1414 | $attachment->isinline = true; |
| 1153 | 1415 | } |
| 1154 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1416 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1417 | + { |
|
| 1155 | 1418 | $attachment->method=1; |
| 1156 | 1419 | $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
| 1157 | - } else { |
|
| 1420 | + } |
|
| 1421 | + else |
|
| 1422 | + { |
|
| 1158 | 1423 | $attachment->attmethod=6; |
| 1159 | 1424 | $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
| 1160 | 1425 | } |
@@ -1162,9 +1427,12 @@ discard block |
||
| 1162 | 1427 | $attachment->contenttype = trim($attach['mimeType']); |
| 1163 | 1428 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-type']."' ".$attachment->contentid); |
| 1164 | 1429 | } |
| 1165 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1430 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1431 | + { |
|
| 1166 | 1432 | array_push($output->asattachments, $attachment); |
| 1167 | - } else { |
|
| 1433 | + } |
|
| 1434 | + else |
|
| 1435 | + { |
|
| 1168 | 1436 | array_push($output->attachments, $attachment); |
| 1169 | 1437 | } |
| 1170 | 1438 | unset($attachment); |
@@ -1177,8 +1445,11 @@ discard block |
||
| 1177 | 1445 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1178 | 1446 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1179 | 1447 | |
| 1180 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1181 | -//$this->debugLevel=0; |
|
| 1448 | + if ($this->debugLevel>3) |
|
| 1449 | + { |
|
| 1450 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1451 | + } |
|
| 1452 | + //$this->debugLevel=0; |
|
| 1182 | 1453 | return $output; |
| 1183 | 1454 | } |
| 1184 | 1455 | //$this->debugLevel=0; |
@@ -1237,7 +1508,8 @@ discard block |
||
| 1237 | 1508 | * @param string $attname - should contain (folder)id |
| 1238 | 1509 | * @return SyncItemOperationsAttachment-object |
| 1239 | 1510 | */ |
| 1240 | - function GetAttachmentData($fid,$attname) { |
|
| 1511 | + function GetAttachmentData($fid,$attname) |
|
| 1512 | + { |
|
| 1241 | 1513 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1242 | 1514 | return $this->_GetAttachmentData($fid,$attname); |
| 1243 | 1515 | } |
@@ -1252,7 +1524,8 @@ discard block |
||
| 1252 | 1524 | * @param string $attname - should contain (folder)id |
| 1253 | 1525 | * @return SyncItemOperationsAttachment-object |
| 1254 | 1526 | */ |
| 1255 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1527 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
| 1528 | + { |
|
| 1256 | 1529 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1257 | 1530 | return $this->_GetAttachmentData($fid,$attname); |
| 1258 | 1531 | } |
@@ -1274,7 +1547,10 @@ discard block |
||
| 1274 | 1547 | |
| 1275 | 1548 | $this->splitID($folderid, $account, $folder); |
| 1276 | 1549 | |
| 1277 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1550 | + if (!isset($this->mail)) |
|
| 1551 | + { |
|
| 1552 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1553 | + } |
|
| 1278 | 1554 | |
| 1279 | 1555 | $this->mail->reopen($folder); |
| 1280 | 1556 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
@@ -1283,7 +1559,9 @@ discard block |
||
| 1283 | 1559 | $SIOattachment->data = $attachment['attachment']; |
| 1284 | 1560 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1285 | 1561 | if (isset($attachment['type']) ) |
| 1286 | - $SIOattachment->contenttype = $attachment['type']; |
|
| 1562 | + { |
|
| 1563 | + $SIOattachment->contenttype = $attachment['type']; |
|
| 1564 | + } |
|
| 1287 | 1565 | |
| 1288 | 1566 | unset($attachment); |
| 1289 | 1567 | |
@@ -1329,11 +1607,15 @@ discard block |
||
| 1329 | 1607 | //unset($folderid, $id, $message, $contentParameters); |
| 1330 | 1608 | $account = $folder = null; |
| 1331 | 1609 | $this->splitID($folderid, $account, $folder); |
| 1332 | - if (isset($message->flag)) { |
|
| 1333 | - if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
|
| 1610 | + if (isset($message->flag)) |
|
| 1611 | + { |
|
| 1612 | + if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) |
|
| 1613 | + { |
|
| 1334 | 1614 | $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
| 1335 | 1615 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
| 1336 | - } else { |
|
| 1616 | + } |
|
| 1617 | + else |
|
| 1618 | + { |
|
| 1337 | 1619 | $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
| 1338 | 1620 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
| 1339 | 1621 | } |
@@ -1363,7 +1645,10 @@ discard block |
||
| 1363 | 1645 | $this->splitID($folderid, $account, $srcFolder); |
| 1364 | 1646 | $this->splitID($newfolderid, $account, $destFolder); |
| 1365 | 1647 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1366 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1648 | + if (!isset($this->mail)) |
|
| 1649 | + { |
|
| 1650 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1651 | + } |
|
| 1367 | 1652 | $this->mail->reopen($destFolder); |
| 1368 | 1653 | $status = $this->mail->getFolderStatus($destFolder); |
| 1369 | 1654 | $uidNext = $status['uidnext']; |
@@ -1395,11 +1680,15 @@ discard block |
||
| 1395 | 1680 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1396 | 1681 | } |
| 1397 | 1682 | $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
| 1398 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1683 | + if (is_numeric($maximumSyncRangeInDays)) |
|
| 1684 | + { |
|
| 1685 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1686 | + } |
|
| 1399 | 1687 | } |
| 1400 | 1688 | try { |
| 1401 | 1689 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1402 | - } catch (Exception $e) |
|
| 1690 | + } |
|
| 1691 | + catch (Exception $e) |
|
| 1403 | 1692 | { |
| 1404 | 1693 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details?$e->details:'')); |
| 1405 | 1694 | return array(); |
@@ -1423,7 +1712,10 @@ discard block |
||
| 1423 | 1712 | { |
| 1424 | 1713 | static $headers = array(); |
| 1425 | 1714 | |
| 1426 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1715 | + if ($this->debugLevel>1) |
|
| 1716 | + { |
|
| 1717 | + $gstarttime = microtime (true); |
|
| 1718 | + } |
|
| 1427 | 1719 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1428 | 1720 | $rv_messages = array(); |
| 1429 | 1721 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1436,7 +1728,10 @@ discard block |
||
| 1436 | 1728 | { |
| 1437 | 1729 | $headers = array(); // clear cache to not use too much memory |
| 1438 | 1730 | |
| 1439 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1731 | + if ($this->debugLevel>1) |
|
| 1732 | + { |
|
| 1733 | + $starttime = microtime (true); |
|
| 1734 | + } |
|
| 1440 | 1735 | $this->_connect($this->account); |
| 1441 | 1736 | if ($this->debugLevel>1) |
| 1442 | 1737 | { |
@@ -1445,8 +1740,14 @@ discard block |
||
| 1445 | 1740 | } |
| 1446 | 1741 | $messagelist = $_filter = array(); |
| 1447 | 1742 | // if not connected, any further action must fail |
| 1448 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1449 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1743 | + if (!empty($cutoffdate)) |
|
| 1744 | + { |
|
| 1745 | + $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1746 | + } |
|
| 1747 | + if ($this->debugLevel>1) |
|
| 1748 | + { |
|
| 1749 | + $starttime = microtime (true); |
|
| 1750 | + } |
|
| 1450 | 1751 | $account = $_folderName = $id = null; |
| 1451 | 1752 | $this->splitID($folderid,$account,$_folderName,$id); |
| 1452 | 1753 | if ($this->debugLevel>1) |
@@ -1454,8 +1755,14 @@ discard block |
||
| 1454 | 1755 | $endtime = microtime(true) - $starttime; |
| 1455 | 1756 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
| 1456 | 1757 | } |
| 1457 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1458 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1758 | + if ($this->debugLevel>1) |
|
| 1759 | + { |
|
| 1760 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1761 | + } |
|
| 1762 | + if ($this->debugLevel>1) |
|
| 1763 | + { |
|
| 1764 | + $starttime = microtime (true); |
|
| 1765 | + } |
|
| 1459 | 1766 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
| 1460 | 1767 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
| 1461 | 1768 | if ($this->debugLevel>1) |
@@ -1464,27 +1771,56 @@ discard block |
||
| 1464 | 1771 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
| 1465 | 1772 | } |
| 1466 | 1773 | } |
| 1467 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1774 | + if ($_id == NULL && $this->debugLevel>1) |
|
| 1775 | + { |
|
| 1776 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1777 | + } |
|
| 1468 | 1778 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1469 | 1779 | $messagelist = array(); |
| 1470 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1780 | + if (!isset($rv_messages['header'])||empty($rv_messages['header'])) |
|
| 1781 | + { |
|
| 1782 | + return $messagelist; |
|
| 1783 | + } |
|
| 1471 | 1784 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1472 | 1785 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1473 | 1786 | { |
| 1474 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1787 | + if ($this->debugLevel>3) |
|
| 1788 | + { |
|
| 1789 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1790 | + } |
|
| 1475 | 1791 | $headers[$vars['uid']] = $vars; |
| 1476 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1477 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
| 1478 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
| 1479 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1792 | + if ($this->debugLevel>3) |
|
| 1793 | + { |
|
| 1794 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1795 | + } |
|
| 1796 | + if (!empty($vars['deleted'])) |
|
| 1797 | + { |
|
| 1798 | + continue; |
|
| 1799 | + } |
|
| 1800 | + // cut of deleted messages |
|
| 1801 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
| 1802 | + { |
|
| 1803 | + continue; |
|
| 1804 | + } |
|
| 1805 | + // message is out of range for cutoffdate, ignore it |
|
| 1806 | + if ($this->debugLevel>0) |
|
| 1807 | + { |
|
| 1808 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1809 | + } |
|
| 1480 | 1810 | $mess = $return_all_headers ? $vars : array(); |
| 1481 | 1811 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1482 | 1812 | $mess["id"] = $vars['uid']; |
| 1483 | 1813 | // 'seen' aka 'read' is the only flag we want to know about |
| 1484 | 1814 | $mess["flags"] = 0; |
| 1485 | 1815 | // outlook supports additional flags, set them to 0 |
| 1486 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1487 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1816 | + if($vars["seen"]) |
|
| 1817 | + { |
|
| 1818 | + $mess["flags"] = 1; |
|
| 1819 | + } |
|
| 1820 | + if ($this->debugLevel>3) |
|
| 1821 | + { |
|
| 1822 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1823 | + } |
|
| 1488 | 1824 | $messagelist[$vars['uid']] = $mess; |
| 1489 | 1825 | unset($mess); |
| 1490 | 1826 | } |
@@ -1509,9 +1845,18 @@ discard block |
||
| 1509 | 1845 | static function doFlagsMod($headerFlags) |
| 1510 | 1846 | { |
| 1511 | 1847 | $flags = 'nnn'; |
| 1512 | - if ($headerFlags['flagged']) $flags[0] = 'f'; |
|
| 1513 | - if ($headerFlags['answered']) $flags[1] = 'a'; |
|
| 1514 | - if ($headerFlags['forwarded']) $flags[2] = 'f'; |
|
| 1848 | + if ($headerFlags['flagged']) |
|
| 1849 | + { |
|
| 1850 | + $flags[0] = 'f'; |
|
| 1851 | + } |
|
| 1852 | + if ($headerFlags['answered']) |
|
| 1853 | + { |
|
| 1854 | + $flags[1] = 'a'; |
|
| 1855 | + } |
|
| 1856 | + if ($headerFlags['forwarded']) |
|
| 1857 | + { |
|
| 1858 | + $flags[2] = 'f'; |
|
| 1859 | + } |
|
| 1515 | 1860 | //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags)); |
| 1516 | 1861 | return $flags; |
| 1517 | 1862 | } |
@@ -1543,31 +1888,55 @@ discard block |
||
| 1543 | 1888 | { |
| 1544 | 1889 | //$this->debugLevel=1; |
| 1545 | 1890 | $searchquery=$_searchquery->GetDataArray(); |
| 1546 | - if (!is_array($searchquery)) return array(); |
|
| 1547 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1891 | + if (!is_array($searchquery)) |
|
| 1892 | + { |
|
| 1893 | + return array(); |
|
| 1894 | + } |
|
| 1895 | + if ($this->debugLevel>0) |
|
| 1896 | + { |
|
| 1897 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1898 | + } |
|
| 1548 | 1899 | |
| 1549 | - if (isset($searchquery['searchrebuildresults'])) { |
|
| 1900 | + if (isset($searchquery['searchrebuildresults'])) |
|
| 1901 | + { |
|
| 1550 | 1902 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1551 | - } else { |
|
| 1903 | + } |
|
| 1904 | + else |
|
| 1905 | + { |
|
| 1552 | 1906 | $rebuildresults = false; |
| 1553 | 1907 | } |
| 1554 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1908 | + if ($this->debugLevel>0) |
|
| 1909 | + { |
|
| 1910 | + ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1911 | + } |
|
| 1555 | 1912 | |
| 1556 | - if (isset($searchquery['deeptraversal'])) { |
|
| 1913 | + if (isset($searchquery['deeptraversal'])) |
|
| 1914 | + { |
|
| 1557 | 1915 | $deeptraversal = $searchquery['deeptraversal']; |
| 1558 | - } else { |
|
| 1916 | + } |
|
| 1917 | + else |
|
| 1918 | + { |
|
| 1559 | 1919 | $deeptraversal = false; |
| 1560 | 1920 | } |
| 1561 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1921 | + if ($this->debugLevel>0) |
|
| 1922 | + { |
|
| 1923 | + ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1924 | + } |
|
| 1562 | 1925 | |
| 1563 | - if (isset($searchquery['searchrange'])) { |
|
| 1926 | + if (isset($searchquery['searchrange'])) |
|
| 1927 | + { |
|
| 1564 | 1928 | $range = explode("-",$_searchquery->GetSearchRange()); |
| 1565 | 1929 | $start =$range[0] + 1; |
| 1566 | 1930 | $limit = $range[1] - $range[0] + 1; |
| 1567 | - } else { |
|
| 1931 | + } |
|
| 1932 | + else |
|
| 1933 | + { |
|
| 1568 | 1934 | $range = false; |
| 1569 | 1935 | } |
| 1570 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1936 | + if ($this->debugLevel>0) |
|
| 1937 | + { |
|
| 1938 | + ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1939 | + } |
|
| 1571 | 1940 | |
| 1572 | 1941 | //foreach($searchquery['query'] as $k => $value) { |
| 1573 | 1942 | // $query = $value; |
@@ -1619,7 +1988,10 @@ discard block |
||
| 1619 | 1988 | $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
| 1620 | 1989 | } |
| 1621 | 1990 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1622 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1991 | + if ($this->debugLevel>1) |
|
| 1992 | + { |
|
| 1993 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1994 | + } |
|
| 1623 | 1995 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
| 1624 | 1996 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1625 | 1997 | $list=array(); |
@@ -1651,17 +2023,26 @@ discard block |
||
| 1651 | 2023 | private function getParentID($account,$folder) |
| 1652 | 2024 | { |
| 1653 | 2025 | $this->_connect($account); |
| 1654 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2026 | + if (!isset($this->folders)) |
|
| 2027 | + { |
|
| 2028 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2029 | + } |
|
| 1655 | 2030 | |
| 1656 | 2031 | $mailFolder = $this->folders[$folder]; |
| 1657 | - if (!isset($mailFolder)) return false; |
|
| 2032 | + if (!isset($mailFolder)) |
|
| 2033 | + { |
|
| 2034 | + return false; |
|
| 2035 | + } |
|
| 1658 | 2036 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
| 1659 | 2037 | $parent = explode($delimiter,$folder); |
| 1660 | 2038 | array_pop($parent); |
| 1661 | 2039 | $parent = implode($delimiter,$parent); |
| 1662 | 2040 | |
| 1663 | 2041 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1664 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2042 | + if ($this->debugLevel>1) |
|
| 2043 | + { |
|
| 2044 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2045 | + } |
|
| 1665 | 2046 | return $id; |
| 1666 | 2047 | } |
| 1667 | 2048 | |
@@ -1675,7 +2056,10 @@ discard block |
||
| 1675 | 2056 | { |
| 1676 | 2057 | static $last_id = null; |
| 1677 | 2058 | static $folderObj = null; |
| 1678 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
| 2059 | + if (isset($last_id) && $last_id === $id) |
|
| 2060 | + { |
|
| 2061 | + return $folderObj; |
|
| 2062 | + } |
|
| 1679 | 2063 | |
| 1680 | 2064 | try { |
| 1681 | 2065 | $account = $folder = null; |
@@ -1686,18 +2070,30 @@ discard block |
||
| 1686 | 2070 | return $folderObj=false; |
| 1687 | 2071 | } |
| 1688 | 2072 | $this->_connect($account); |
| 1689 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2073 | + if (!isset($this->folders)) |
|
| 2074 | + { |
|
| 2075 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2076 | + } |
|
| 1690 | 2077 | |
| 1691 | 2078 | $mailFolder = $this->folders[$folder]; |
| 1692 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 2079 | + if (!isset($mailFolder)) |
|
| 2080 | + { |
|
| 2081 | + return $folderObj=false; |
|
| 2082 | + } |
|
| 1693 | 2083 | |
| 1694 | 2084 | $folderObj = new SyncFolder(); |
| 1695 | 2085 | $folderObj->serverid = $id; |
| 1696 | 2086 | $folderObj->parentid = $this->getParentID($account,$folder); |
| 1697 | 2087 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1698 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2088 | + if ($this->debugLevel>1) |
|
| 2089 | + { |
|
| 2090 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2091 | + } |
|
| 1699 | 2092 | // get folder-type |
| 1700 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 2093 | + foreach($this->folders as $inbox => $mailFolder) |
|
| 2094 | + { |
|
| 2095 | + break; |
|
| 2096 | + } |
|
| 1701 | 2097 | if ($folder == $inbox) |
| 1702 | 2098 | { |
| 1703 | 2099 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1734,7 +2130,10 @@ discard block |
||
| 1734 | 2130 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1735 | 2131 | } |
| 1736 | 2132 | |
| 1737 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2133 | + if ($this->debugLevel>1) |
|
| 2134 | + { |
|
| 2135 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2136 | + } |
|
| 1738 | 2137 | return $folderObj; |
| 1739 | 2138 | } |
| 1740 | 2139 | |
@@ -1778,11 +2177,20 @@ discard block |
||
| 1778 | 2177 | { |
| 1779 | 2178 | $account = $folder = null; |
| 1780 | 2179 | $this->splitID($folderid, $account, $folder); |
| 1781 | - if (is_numeric($account)) $type = 'mail'; |
|
| 2180 | + if (is_numeric($account)) |
|
| 2181 | + { |
|
| 2182 | + $type = 'mail'; |
|
| 2183 | + } |
|
| 1782 | 2184 | |
| 1783 | - if ($type != 'mail') return false; |
|
| 2185 | + if ($type != 'mail') |
|
| 2186 | + { |
|
| 2187 | + return false; |
|
| 2188 | + } |
|
| 1784 | 2189 | |
| 1785 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2190 | + if (!isset($this->mail)) |
|
| 2191 | + { |
|
| 2192 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2193 | + } |
|
| 1786 | 2194 | |
| 1787 | 2195 | $this->mail->reopen($folder); |
| 1788 | 2196 | |
@@ -1827,7 +2235,7 @@ discard block |
||
| 1827 | 2235 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1828 | 2236 | */ |
| 1829 | 2237 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1830 | - { |
|
| 2238 | + { |
|
| 1831 | 2239 | unset($contentParameters); // not used, but required by function signature |
| 1832 | 2240 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1833 | 2241 | /* |
@@ -1853,7 +2261,10 @@ discard block |
||
| 1853 | 2261 | $error = $e->getMessage(); |
| 1854 | 2262 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
| 1855 | 2263 | // if the server thinks the message does not exist report deletion as success |
| 1856 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 2264 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
| 2265 | + { |
|
| 2266 | + return true; |
|
| 2267 | + } |
|
| 1857 | 2268 | return false; |
| 1858 | 2269 | } |
| 1859 | 2270 | |
@@ -1886,7 +2297,7 @@ discard block |
||
| 1886 | 2297 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1887 | 2298 | */ |
| 1888 | 2299 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1889 | - { |
|
| 2300 | + { |
|
| 1890 | 2301 | unset($contentParameters); // not used, but required by function signature |
| 1891 | 2302 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1892 | 2303 | $account = $folder = null; |
@@ -1970,10 +2381,16 @@ discard block |
||
| 1970 | 2381 | $account = $parent_id = $app = null; |
| 1971 | 2382 | $this->splitID($id, $account, $folder, $app); |
| 1972 | 2383 | $old_hash = $this->folder2hash($account, $folder); |
| 1973 | - if ($parentid) $this->splitID($parentid, $account, $parentfolder, $app); |
|
| 2384 | + if ($parentid) |
|
| 2385 | + { |
|
| 2386 | + $this->splitID($parentid, $account, $parentfolder, $app); |
|
| 2387 | + } |
|
| 1974 | 2388 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."( '$id (-> $folder)','$parentid ".($parentid?'(->'.$parentfolder.')':'')."') called!"); |
| 1975 | 2389 | $ret = $this->mail->deleteFolder($folder); |
| 1976 | - if ($ret) $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
|
| 2390 | + if ($ret) |
|
| 2391 | + { |
|
| 2392 | + $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
|
| 2393 | + } |
|
| 1977 | 2394 | return $ret; |
| 1978 | 2395 | } |
| 1979 | 2396 | |
@@ -2018,7 +2435,10 @@ discard block |
||
| 2018 | 2435 | |
| 2019 | 2436 | $str = $this->backend->createID($account, $folder, $id); |
| 2020 | 2437 | |
| 2021 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2438 | + if ($this->debugLevel>1) |
|
| 2439 | + { |
|
| 2440 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2441 | + } |
|
| 2022 | 2442 | |
| 2023 | 2443 | return $str; |
| 2024 | 2444 | } |
@@ -2039,7 +2459,10 @@ discard block |
||
| 2039 | 2459 | // convert numeric folder-id back to folder name |
| 2040 | 2460 | $folder = $this->hash2folder($account,$f=$folder); |
| 2041 | 2461 | |
| 2042 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2462 | + if ($this->debugLevel>1) |
|
| 2463 | + { |
|
| 2464 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2465 | + } |
|
| 2043 | 2466 | } |
| 2044 | 2467 | |
| 2045 | 2468 | /** |
@@ -2058,7 +2481,10 @@ discard block |
||
| 2058 | 2481 | */ |
| 2059 | 2482 | private function folder2hash($account,$folder) |
| 2060 | 2483 | { |
| 2061 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2484 | + if(!isset($this->folderHashes)) |
|
| 2485 | + { |
|
| 2486 | + $this->readFolderHashes(); |
|
| 2487 | + } |
|
| 2062 | 2488 | |
| 2063 | 2489 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2064 | 2490 | { |
@@ -2081,7 +2507,10 @@ discard block |
||
| 2081 | 2507 | */ |
| 2082 | 2508 | private function hash2folder($account,$index) |
| 2083 | 2509 | { |
| 2084 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2510 | + if(!isset($this->folderHashes)) |
|
| 2511 | + { |
|
| 2512 | + $this->readFolderHashes(); |
|
| 2513 | + } |
|
| 2085 | 2514 | |
| 2086 | 2515 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2087 | 2516 | } |