@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | * @param string $newfolderid id of the destination folder |
| 1355 | 1355 | * @param ContentParameters $contentParameters |
| 1356 | 1356 | * |
| 1357 | - * @return boolean status of the operation |
|
| 1357 | + * @return string status of the operation |
|
| 1358 | 1358 | * @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions |
| 1359 | 1359 | */ |
| 1360 | 1360 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
@@ -1745,6 +1745,7 @@ discard block |
||
| 1745 | 1745 | * the folder has not changed. In practice this means that 'mod' can be equal to the folder name |
| 1746 | 1746 | * as this is the only thing that ever changes in folders. (the type is normally constant) |
| 1747 | 1747 | * |
| 1748 | + * @param string $id |
|
| 1748 | 1749 | * @return array with values for keys 'id', 'mod' and 'parent' |
| 1749 | 1750 | */ |
| 1750 | 1751 | public function StatFolder($id) |
@@ -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 | } |
@@ -90,23 +90,23 @@ discard block |
||
| 90 | 90 | $this->backend = $backend; |
| 91 | 91 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 92 | 92 | { |
| 93 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 93 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 94 | 94 | // globals preferences add appname varname value |
| 95 | - $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
|
| 95 | + $GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user'); |
|
| 96 | 96 | // save prefs |
| 97 | 97 | $GLOBALS['egw']->preferences->save_repository(true); |
| 98 | 98 | } |
| 99 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 99 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 100 | 100 | |
| 101 | 101 | if (is_null(self::$profileID)) |
| 102 | 102 | { |
| 103 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 104 | - self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
|
| 105 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 103 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 104 | + self::$profileID = & Api\Cache::getSession('mail', 'activeSyncProfileID'); |
|
| 105 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 106 | 106 | } |
| 107 | 107 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 108 | 108 | { |
| 109 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 109 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 110 | 110 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
| 111 | 111 | { |
| 112 | 112 | 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 +116,7 @@ discard block |
||
| 116 | 116 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 119 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 120 | 120 | |
| 121 | 121 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
| 122 | 122 | if (!isset($GLOBALS['egw_setup'])) |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | try { |
| 125 | 125 | Mail\Account::read(self::$profileID); |
| 126 | 126 | } |
| 127 | - catch(Exception $e) { |
|
| 127 | + catch (Exception $e) { |
|
| 128 | 128 | unset($e); |
| 129 | 129 | self::$profileID = Mail\Account::get_default_acc_id(); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 132 | + if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 133 | 133 | //$this->debugLevel=0; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | $this->__construct($this->backend); |
| 243 | 243 | |
| 244 | 244 | try { |
| 245 | - $this->_connect(0,true); |
|
| 245 | + $this->_connect(0, true); |
|
| 246 | 246 | $this->_disconnect(); |
| 247 | 247 | |
| 248 | 248 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
| 249 | 249 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
| 250 | 250 | } |
| 251 | - catch(Exception $e) { |
|
| 251 | + catch (Exception $e) { |
|
| 252 | 252 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
| 253 | 253 | } |
| 254 | 254 | if ($errors) |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param int $account integer id of account to use |
| 267 | 267 | * @todo support different accounts |
| 268 | 268 | */ |
| 269 | - private function _connect($account=0) |
|
| 269 | + private function _connect($account = 0) |
|
| 270 | 270 | { |
| 271 | 271 | if (!$account) $account = self::$profileID ? self::$profileID : 0; |
| 272 | 272 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $this->account = $account; |
| 280 | 280 | // todo: tell mail which account to use |
| 281 | 281 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 282 | - $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 282 | + $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 283 | 283 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 284 | 284 | } |
| 285 | 285 | else |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 288 | 288 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 289 | 289 | } |
| 290 | - $this->mail->openConnection(self::$profileID,false); |
|
| 290 | + $this->mail->openConnection(self::$profileID, false); |
|
| 291 | 291 | |
| 292 | 292 | $this->_wasteID = $this->mail->getTrashFolder(false); |
| 293 | 293 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | private function _disconnect() |
| 304 | 304 | { |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 305 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__); |
|
| 306 | 306 | if ($this->mail) $this->mail->closeConnection(); |
| 307 | 307 | |
| 308 | 308 | unset($this->mail); |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | public function GetFolderList() |
| 319 | 319 | { |
| 320 | 320 | $folderlist = array(); |
| 321 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 321 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__); |
|
| 322 | 322 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 323 | 323 | { |
| 324 | 324 | $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)); |
|
| 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)); |
|
| 327 | 327 | |
| 328 | 328 | foreach ($this->folders as $folder => $folderObj) { |
| 329 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 329 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder); |
|
| 330 | 330 | $folderlist[] = $f = array( |
| 331 | - 'id' => $this->createID($account,$folder), |
|
| 331 | + 'id' => $this->createID($account, $folder), |
|
| 332 | 332 | 'mod' => $folderObj->shortDisplayName, |
| 333 | - 'parent' => $this->getParentID($account,$folder), |
|
| 333 | + 'parent' => $this->getParentID($account, $folder), |
|
| 334 | 334 | ); |
| 335 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 335 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f)); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 338 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist)); |
|
| 339 | 339 | |
| 340 | 340 | return $folderlist; |
| 341 | 341 | } |
@@ -384,90 +384,90 @@ discard block |
||
| 384 | 384 | $ClientSideMeetingRequest = false; |
| 385 | 385 | $allowSendingInvitations = 'sendifnocalnotif'; |
| 386 | 386 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 387 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
| 387 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
| 388 | 388 | { |
| 389 | 389 | $allowSendingInvitations = false; |
| 390 | 390 | } |
| 391 | 391 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 392 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
| 392 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
| 393 | 393 | { |
| 394 | 394 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
| 395 | 395 | } |
| 396 | - $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
|
| 396 | + $smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new')); |
|
| 397 | 397 | |
| 398 | - 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)); |
|
| 398 | + 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)); |
|
| 400 | 400 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 401 | 401 | |
| 402 | 402 | // initialize our Mail |
| 403 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 403 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 404 | 404 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 405 | 405 | // use the standardIdentity |
| 406 | - $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
| 406 | + $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
| 407 | 407 | |
| 408 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 408 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 409 | 409 | // collect identity / signature for later usage, and to determine if we may have to manipulate TransferEncoding and Charset |
| 410 | 410 | try |
| 411 | 411 | { |
| 412 | 412 | $acc = Mail\Account::read($this->mail->icServer->ImapServerId); |
| 413 | 413 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 414 | - $_signature = Mail\Account::read_identity($acc['ident_id'],true); |
|
| 414 | + $_signature = Mail\Account::read_identity($acc['ident_id'], true); |
|
| 415 | 415 | } |
| 416 | 416 | catch (Exception $e) |
| 417 | 417 | { |
| 418 | - $_signature=array(); |
|
| 418 | + $_signature = array(); |
|
| 419 | 419 | } |
| 420 | 420 | $signature = $_signature['ident_signature']; |
| 421 | 421 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
| 422 | 422 | $preferencesArray['disableRulerForSignatureSeparation']) || |
| 423 | - empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='') |
|
| 423 | + empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '') |
|
| 424 | 424 | { |
| 425 | 425 | $disableRuler = true; |
| 426 | 426 | } |
| 427 | 427 | $beforePlain = $beforeHtml = ""; |
| 428 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 429 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
| 430 | - $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); |
|
| 428 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 429 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
| 430 | + $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); |
|
| 432 | 432 | $sigTextHtml = $beforeHtml.$sigText; |
| 433 | 433 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 434 | 434 | |
| 435 | - $force8bit=false; |
|
| 436 | - if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
| 435 | + $force8bit = false; |
|
| 436 | + if (Api\Translation::detect_encoding($sigTextPlain) != 'ascii') $force8bit = true; |
|
| 437 | 437 | // beware. the section below might cause trouble regarding bcc and attachments, so maybe this is to be handeled differently |
| 438 | 438 | if ($force8bit) |
| 439 | 439 | { |
| 440 | - $converterObj = new Api\Mailer('initbasic'); |
|
| 441 | - $smartdata->mime = $converterObj->convertMessageTextParts($smartdata->mime,false,'utf-8'); |
|
| 440 | + $converterObj = new Api\Mailer('initbasic'); |
|
| 441 | + $smartdata->mime = $converterObj->convertMessageTextParts($smartdata->mime, false, 'utf-8'); |
|
| 442 | 442 | } |
| 443 | 443 | // initialize the new Api\Mailer object for sending |
| 444 | 444 | $mailObject = new Api\Mailer(self::$profileID); |
| 445 | 445 | |
| 446 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); |
|
| 446 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime, $force8bit); |
|
| 447 | 447 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
| 448 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 449 | - $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); |
|
| 448 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 449 | + $mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false)); |
|
| 450 | 450 | $mailObject->addHeader('X-Mailer', 'mail-Activesync'); |
| 451 | 451 | |
| 452 | 452 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 453 | 453 | // to |
| 454 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 454 | + foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 455 | 455 | if (!$addressObject->valid) continue; |
| 456 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
| 456 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
| 457 | 457 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 458 | 458 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 459 | 459 | } |
| 460 | 460 | // CC |
| 461 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 461 | + foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 462 | 462 | if (!$addressObject->valid) continue; |
| 463 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
| 463 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
| 464 | 464 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 465 | 465 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 466 | 466 | } |
| 467 | 467 | // BCC |
| 468 | - foreach($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 468 | + foreach ($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 469 | 469 | if (!$addressObject->valid) continue; |
| 470 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
| 470 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
| 471 | 471 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 472 | 472 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 473 | 473 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $use_orgbody = false; |
| 477 | 477 | |
| 478 | 478 | $k = 'Content-Type'; |
| 479 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
| 479 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
| 480 | 480 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 481 | 481 | // if the message is a multipart message, then we should use the sent body |
| 482 | 482 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -496,43 +496,43 @@ discard block |
||
| 496 | 496 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
| 497 | 497 | $use_orgbody = true; |
| 498 | 498 | } |
| 499 | - $Body = $AltBody = ""; |
|
| 499 | + $Body = $AltBody = ""; |
|
| 500 | 500 | // get body of the transmitted message |
| 501 | 501 | // if this is a simple message, no structure at all |
| 502 | 502 | if (preg_match("/text/i", $ContentType)) |
| 503 | 503 | { |
| 504 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
| 504 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
| 505 | 505 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
| 506 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
| 507 | - if ($simpleBodyType == "text/plain") |
|
| 506 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
| 507 | + if ($simpleBodyType == "text/plain") |
|
| 508 | 508 | { |
| 509 | 509 | $Body = $body; |
| 510 | 510 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 511 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
| 511 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
| 512 | 512 | } |
| 513 | 513 | else |
| 514 | 514 | { |
| 515 | 515 | $AltBody = $body; |
| 516 | - $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 517 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
| 516 | + $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 517 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | else |
| 521 | 521 | { |
| 522 | 522 | // if this is a structured message |
| 523 | 523 | // prefer plain over html |
| 524 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 524 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 525 | 525 | ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
| 526 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 526 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 527 | 527 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 528 | 528 | } |
| 529 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 530 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 529 | + if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
| 530 | + if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
| 531 | 531 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 532 | 532 | // if this is a multipart message with a boundary, we must use the original body |
| 533 | 533 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 534 | 534 | if ($use_orgbody) { |
| 535 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 535 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 536 | 536 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 537 | 537 | if (($cal_body = $mailObject->findBody('calendar')) && |
| 538 | 538 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -541,21 +541,21 @@ discard block |
||
| 541 | 541 | { |
| 542 | 542 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 543 | 543 | } |
| 544 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 544 | + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 545 | 545 | $ClientSideMeetingRequest = true; |
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | // now handle the addressee list |
| 549 | 549 | $toCount = 0; |
| 550 | 550 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 551 | - foreach((array)$toMailAddr as $address) { |
|
| 552 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 553 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 551 | + foreach ((array)$toMailAddr as $address) { |
|
| 552 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 553 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 554 | 554 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 555 | 555 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
| 556 | 556 | $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
| 557 | 557 | { |
| 558 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 558 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 559 | 559 | continue; |
| 560 | 560 | } |
| 561 | 561 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
@@ -563,29 +563,29 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | $ccCount = 0; |
| 566 | - foreach((array)$ccMailAddr as $address) { |
|
| 567 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 568 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 566 | + foreach ((array)$ccMailAddr as $address) { |
|
| 567 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 568 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 569 | 569 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 570 | 570 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 571 | 571 | $ccCount++; |
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | $bccCount = 0; |
| 575 | - foreach((array)$bccMailAddr as $address) { |
|
| 576 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 577 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 575 | + foreach ((array)$bccMailAddr as $address) { |
|
| 576 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 577 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 578 | 578 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 579 | 579 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 580 | 580 | $bccCount++; |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
| 584 | - if ($toCount+$ccCount+$bccCount == 0) |
|
| 584 | + if ($toCount + $ccCount + $bccCount == 0) |
|
| 585 | 585 | { |
| 586 | 586 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 587 | 587 | } |
| 588 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 588 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
| 589 | 589 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 590 | 590 | /* |
| 591 | 591 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -602,26 +602,26 @@ discard block |
||
| 602 | 602 | { |
| 603 | 603 | // now get on, and fetch the original mail |
| 604 | 604 | $uid = $smartdata->source->itemid; |
| 605 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 605 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 606 | 606 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 607 | 607 | |
| 608 | 608 | $this->mail->reopen($folder); |
| 609 | 609 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 610 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 611 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 612 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 610 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 611 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 612 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 613 | 613 | // may be html |
| 614 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 614 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 615 | 615 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 616 | 616 | $isreply = true; |
| 617 | 617 | } |
| 618 | 618 | // plain text Message part |
| 619 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 619 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 620 | 620 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 621 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 622 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 623 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 624 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 621 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 622 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 623 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 624 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 625 | 625 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 626 | 626 | $isreply = true; |
| 627 | 627 | } |
@@ -629,12 +629,12 @@ discard block |
||
| 629 | 629 | { |
| 630 | 630 | $isreply = true; |
| 631 | 631 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 632 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 632 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // how to forward and other prefs |
| 637 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 637 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 638 | 638 | |
| 639 | 639 | // forward ------------------------------------------------------------------------- |
| 640 | 640 | if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | { |
| 645 | 645 | //force the default for the forwarding -> asmail |
| 646 | 646 | if (is_array($preferencesArray)) { |
| 647 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
| 647 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
| 648 | 648 | || !isset($preferencesArray['message_forwarding']) |
| 649 | 649 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
| 650 | 650 | } else { |
@@ -652,18 +652,18 @@ discard block |
||
| 652 | 652 | } |
| 653 | 653 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
| 654 | 654 | $uid = $smartdata->source->itemid; |
| 655 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 655 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 656 | 656 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 657 | 657 | |
| 658 | 658 | $this->mail->reopen($folder); |
| 659 | 659 | // receive entire mail (header + body) |
| 660 | 660 | // get message headers for specified message |
| 661 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 661 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 662 | 662 | // build a new mime message, forward entire old mail as file |
| 663 | 663 | if ($preferencesArray['message_forwarding'] == 'asmail') |
| 664 | 664 | { |
| 665 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
| 666 | - $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
| 665 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
| 666 | + $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
| 667 | 667 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
| 668 | 668 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
| 669 | 669 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -673,50 +673,50 @@ discard block |
||
| 673 | 673 | { |
| 674 | 674 | // now get on, and fetch the original mail |
| 675 | 675 | $uid = $smartdata->source->itemid; |
| 676 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 676 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 677 | 677 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 678 | 678 | |
| 679 | 679 | $this->mail->reopen($folder); |
| 680 | 680 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 681 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 682 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 683 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 681 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 682 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 683 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 684 | 684 | // may be html |
| 685 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 685 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 686 | 686 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 687 | 687 | $isforward = true; |
| 688 | 688 | } |
| 689 | 689 | // plain text Message part |
| 690 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 690 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 691 | 691 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 692 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 693 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 694 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 695 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 692 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 693 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 694 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 695 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 696 | 696 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 697 | 697 | $isforward = true; |
| 698 | 698 | } |
| 699 | 699 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 700 | 700 | { |
| 701 | 701 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 702 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 702 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 703 | 703 | $isforward = true; |
| 704 | 704 | } |
| 705 | 705 | // get all the attachments and add them too. |
| 706 | 706 | // start handle Attachments |
| 707 | 707 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
| 708 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
| 708 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
| 709 | 709 | $attachmentNames = false; |
| 710 | - if (is_array($attachments) && count($attachments)>0) |
|
| 710 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 711 | 711 | { |
| 712 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 713 | - foreach((array)$attachments as $key => $attachment) |
|
| 712 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 713 | + foreach ((array)$attachments as $key => $attachment) |
|
| 714 | 714 | { |
| 715 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 715 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 716 | 716 | $attachmentNames .= $attachment['name']."\n"; |
| 717 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
| 717 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
| 718 | 718 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
| 719 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
| 719 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
| 720 | 720 | } |
| 721 | 721 | } |
| 722 | 722 | } |
@@ -731,38 +731,38 @@ discard block |
||
| 731 | 731 | // now set the body |
| 732 | 732 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 733 | 733 | { |
| 734 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 734 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
| 735 | 735 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 736 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 736 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 737 | 737 | } |
| 738 | 738 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 739 | 739 | { |
| 740 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 740 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
| 741 | 741 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 742 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 742 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 743 | 743 | } |
| 744 | 744 | //advanced debugging |
| 745 | 745 | // Horde SMTP Class uses utf-8 by default. |
| 746 | 746 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 747 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 747 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 748 | 748 | |
| 749 | 749 | // set a higher timeout for big messages |
| 750 | 750 | @set_time_limit(120); |
| 751 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 751 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 752 | 752 | // send |
| 753 | 753 | $send = true; |
| 754 | 754 | try { |
| 755 | 755 | $mailObject->Send(); |
| 756 | 756 | } |
| 757 | - catch(Exception $e) { |
|
| 758 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
| 757 | + catch (Exception $e) { |
|
| 758 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
| 759 | 759 | $send = false; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 762 | + if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 763 | 763 | { |
| 764 | 764 | $uid = $smartdata->source->itemid; |
| 765 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 765 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 766 | 766 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 767 | 767 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
| 768 | 768 | $this->mail->reopen($folder); |
@@ -770,90 +770,90 @@ discard block |
||
| 770 | 770 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 771 | 771 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 772 | 772 | { |
| 773 | - $this->mail->deleteMessages(array($uid),$folder); |
|
| 773 | + $this->mail->deleteMessages(array($uid), $folder); |
|
| 774 | 774 | } else { |
| 775 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
| 776 | - if ($smartdata_task== "forward") |
|
| 775 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
| 776 | + if ($smartdata_task == "forward") |
|
| 777 | 777 | { |
| 778 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
| 778 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - $asf = ($send ? true:false); // initalize accordingly |
|
| 784 | - if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 783 | + $asf = ($send ? true : false); // initalize accordingly |
|
| 784 | + if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 785 | 785 | { |
| 786 | 786 | $asf = false; |
| 787 | 787 | $sentFolder = $this->mail->getSentFolder(); |
| 788 | 788 | if ($this->_sentID) { |
| 789 | 789 | $folderArray[] = $this->_sentID; |
| 790 | 790 | } |
| 791 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
| 791 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
| 792 | 792 | { |
| 793 | 793 | $folderArray[] = $sentFolder; |
| 794 | 794 | } |
| 795 | 795 | // No Sent folder set, try defaults |
| 796 | 796 | else |
| 797 | 797 | { |
| 798 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 798 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 799 | 799 | // we dont try guessing |
| 800 | 800 | $asf = true; |
| 801 | 801 | } |
| 802 | 802 | if (count($folderArray) > 0) { |
| 803 | - foreach((array)$bccMailAddr as $address) { |
|
| 804 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 805 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 803 | + foreach ((array)$bccMailAddr as $address) { |
|
| 804 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 805 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 806 | 806 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | //$BCCmail=''; |
| 810 | - if (count($mailAddr)>0) $mailObject->forceBccHeader(); |
|
| 810 | + if (count($mailAddr) > 0) $mailObject->forceBccHeader(); |
|
| 811 | 811 | //$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
| 812 | - foreach($folderArray as $folderName) { |
|
| 813 | - if($this->mail->isSentFolder($folderName)) { |
|
| 812 | + foreach ($folderArray as $folderName) { |
|
| 813 | + if ($this->mail->isSentFolder($folderName)) { |
|
| 814 | 814 | $flags = '\\Seen'; |
| 815 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 815 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
| 816 | 816 | $flags = '\\Draft'; |
| 817 | 817 | } else { |
| 818 | 818 | $flags = ''; |
| 819 | 819 | } |
| 820 | 820 | $asf = true; |
| 821 | 821 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 822 | - $this->mail->openConnection(self::$profileID,false); |
|
| 822 | + $this->mail->openConnection(self::$profileID, false); |
|
| 823 | 823 | if ($this->mail->folderExists($folderName)) { |
| 824 | 824 | try |
| 825 | 825 | { |
| 826 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
| 826 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
| 827 | 827 | $flags); |
| 828 | 828 | } |
| 829 | 829 | catch (Api\Exception\WrongUserinput $e) |
| 830 | 830 | { |
| 831 | 831 | //$asf = false; |
| 832 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage())); |
|
| 832 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage())); |
|
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | else |
| 836 | 836 | { |
| 837 | 837 | //$asf = false; |
| 838 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
| 838 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
| 839 | 839 | } |
| 840 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 840 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
| 841 | 841 | } |
| 842 | 842 | //$this->mail->closeConnection(); |
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | - $this->debugLevel=0; |
|
| 846 | + $this->debugLevel = 0; |
|
| 847 | 847 | |
| 848 | 848 | if ($send && $asf) |
| 849 | 849 | { |
| 850 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
| 850 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
| 851 | 851 | return true; |
| 852 | 852 | } |
| 853 | 853 | else |
| 854 | 854 | { |
| 855 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
| 856 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 855 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
| 856 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | |
@@ -871,43 +871,43 @@ discard block |
||
| 871 | 871 | public function GetMessage($folderid, $id, $contentparameters) |
| 872 | 872 | { |
| 873 | 873 | //$this->debugLevel=4; |
| 874 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 874 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 875 | 875 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 876 | 876 | $mimesupport = $contentparameters->GetMimeSupport(); |
| 877 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 877 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 878 | 878 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 879 | 879 | |
| 880 | 880 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 881 | 881 | if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
| 882 | 882 | |
| 883 | 883 | //$this->debugLevel=4; |
| 884 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 885 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 884 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 885 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 886 | 886 | $account = $_folderName = $xid = null; |
| 887 | - $this->splitID($folderid,$account,$_folderName,$xid); |
|
| 887 | + $this->splitID($folderid, $account, $_folderName, $xid); |
|
| 888 | 888 | $this->mail->reopen($_folderName); |
| 889 | - $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 889 | + $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 890 | 890 | $headers = $messages[$id]; |
| 891 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 891 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers)); |
|
| 892 | 892 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 893 | 893 | if ($headers) |
| 894 | 894 | { |
| 895 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 895 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 896 | 896 | // initialize the object |
| 897 | 897 | $output = new SyncMail(); |
| 898 | 898 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 899 | 899 | // simple style |
| 900 | 900 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 901 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 901 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 902 | 902 | |
| 903 | 903 | if ($bodypreference === false) { |
| 904 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
| 905 | - $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 904 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
| 905 | + $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 906 | 906 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 907 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 907 | + if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 908 | 908 | // remove all other html |
| 909 | 909 | $body = strip_tags($raw_body); |
| 910 | - if(strlen($body) > $truncsize) { |
|
| 910 | + if (strlen($body) > $truncsize) { |
|
| 911 | 911 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 912 | 912 | $output->bodytruncated = 1; |
| 913 | 913 | } |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | else // style with bodypreferences |
| 922 | 922 | { |
| 923 | 923 | //Select body type preference |
| 924 | - $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
| 924 | + $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
| 925 | 925 | if ($bodypreference !== false) { |
| 926 | 926 | // bodypreference can occur multiple times |
| 927 | 927 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -935,12 +935,12 @@ discard block |
||
| 935 | 935 | } |
| 936 | 936 | */ |
| 937 | 937 | } |
| 938 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 938 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 939 | 939 | // set the protocoll class |
| 940 | 940 | $output->asbody = new SyncBaseBody(); |
| 941 | 941 | |
| 942 | 942 | // return full mime-message without any (charset) conversation directly as stream |
| 943 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
| 943 | + if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) |
|
| 944 | 944 | { |
| 945 | 945 | //SYNC_BODYPREFERENCE_MIME |
| 946 | 946 | $output->asbody->type = SYNC_BODYPREFERENCE_MIME; |
@@ -949,58 +949,58 @@ discard block |
||
| 949 | 949 | fseek($stream, 0, SEEK_SET); |
| 950 | 950 | $output->asbody->data = $stream; |
| 951 | 951 | $output->asbody->estimatedDataSize = $fstat['size']; |
| 952 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 952 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 953 | 953 | } |
| 954 | 954 | else |
| 955 | 955 | { |
| 956 | 956 | // fetch the body (try to gather data only once) |
| 957 | - $css =''; |
|
| 958 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
| 959 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 960 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 961 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 962 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 957 | + $css = ''; |
|
| 958 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
| 959 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 960 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 961 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
| 962 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 963 | 963 | // may be html |
| 964 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 964 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 965 | 965 | $css = $this->mail->getStyles($bodyStruct); |
| 966 | - $output->nativebodytype=2; |
|
| 966 | + $output->nativebodytype = 2; |
|
| 967 | 967 | } else { |
| 968 | 968 | // plain text Message |
| 969 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 970 | - $output->nativebodytype=1; |
|
| 971 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 972 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 973 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 974 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 969 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 970 | + $output->nativebodytype = 1; |
|
| 971 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 972 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 973 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 974 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 975 | 975 | } |
| 976 | 976 | // whatever format decode (using the correct encoding) |
| 977 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 977 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
| 978 | 978 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 979 | 979 | // prepare plaintextbody |
| 980 | - $plainBody=''; |
|
| 980 | + $plainBody = ''; |
|
| 981 | 981 | if ($output->nativebodytype == 2) |
| 982 | 982 | { |
| 983 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 984 | - if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
| 983 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 984 | + if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
| 985 | 985 | { |
| 986 | 986 | $plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
| 987 | 987 | } |
| 988 | 988 | else |
| 989 | 989 | { |
| 990 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
| 990 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | //if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body); |
| 994 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
| 994 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
| 995 | 995 | // remove all other html |
| 996 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
| 996 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
| 997 | 997 | $plainBody = strip_tags($plainBody); |
| 998 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 998 | + if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 999 | 999 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 1000 | 1000 | |
| 1001 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 1001 | + if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
| 1002 | 1002 | { |
| 1003 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 1003 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 1004 | 1004 | // Send HTML if requested and native type was html |
| 1005 | 1005 | $output->asbody->type = 2; |
| 1006 | 1006 | $htmlbody = '<html>'. |
@@ -1010,23 +1010,23 @@ discard block |
||
| 1010 | 1010 | $css. |
| 1011 | 1011 | '</head>'. |
| 1012 | 1012 | '<body>'; |
| 1013 | - if ($output->nativebodytype==2) |
|
| 1013 | + if ($output->nativebodytype == 2) |
|
| 1014 | 1014 | { |
| 1015 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1015 | + if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style'); |
|
| 1016 | 1016 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1017 | 1017 | $htmlbody .= $body; |
| 1018 | 1018 | } |
| 1019 | 1019 | else |
| 1020 | 1020 | { |
| 1021 | 1021 | // html requested but got only plaintext, so fake html |
| 1022 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
| 1022 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | $htmlbody .= '</body>'. |
| 1025 | 1025 | '</html>'; |
| 1026 | 1026 | |
| 1027 | - if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1027 | + if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1028 | 1028 | { |
| 1029 | - $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
| 1029 | + $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
| 1030 | 1030 | $output->asbody->truncated = 1; |
| 1031 | 1031 | } |
| 1032 | 1032 | // output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | else |
| 1038 | 1038 | { |
| 1039 | 1039 | // Send Plaintext as Fallback or if original body is plainttext |
| 1040 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1040 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1041 | 1041 | /* we use plainBody (set above) instead |
| 1042 | 1042 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1043 | 1043 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | */ |
| 1048 | 1048 | $output->asbody->type = 1; |
| 1049 | 1049 | $output->nativebodytype = 1; |
| 1050 | - if(isset($truncsize) && |
|
| 1050 | + if (isset($truncsize) && |
|
| 1051 | 1051 | strlen($plainBody) > $truncsize) |
| 1052 | 1052 | { |
| 1053 | 1053 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | } |
| 1067 | 1067 | } |
| 1068 | 1068 | // end AS12 Stuff |
| 1069 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1069 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1070 | 1070 | $output->read = $headers["flags"]; |
| 1071 | 1071 | |
| 1072 | 1072 | $output->flag = new SyncMailFlags(); |
@@ -1086,9 +1086,8 @@ discard block |
||
| 1086 | 1086 | $output->lastverexecuted = AS_FORWARD; |
| 1087 | 1087 | } |
| 1088 | 1088 | $output->subject = $headers['subject']; |
| 1089 | - $output->importance = $headers['priority'] > 3 ? 0 : |
|
| 1090 | - ($headers['priority'] < 3 ? 2 : 1) ; |
|
| 1091 | - $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
|
| 1089 | + $output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1); |
|
| 1090 | + $output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true); |
|
| 1092 | 1091 | $output->to = $headers['to_address']; |
| 1093 | 1092 | if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
| 1094 | 1093 | $output->from = $headers['sender_address']; |
@@ -1096,8 +1095,8 @@ discard block |
||
| 1096 | 1095 | if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
| 1097 | 1096 | |
| 1098 | 1097 | $output->messageclass = "IPM.Note"; |
| 1099 | - if (stripos($headers['mimetype'],'multipart')!== false && |
|
| 1100 | - stripos($headers['mimetype'],'signed')!== false) |
|
| 1098 | + if (stripos($headers['mimetype'], 'multipart') !== false && |
|
| 1099 | + stripos($headers['mimetype'], 'signed') !== false) |
|
| 1101 | 1100 | { |
| 1102 | 1101 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1103 | 1102 | } |
@@ -1106,20 +1105,20 @@ discard block |
||
| 1106 | 1105 | } |
| 1107 | 1106 | |
| 1108 | 1107 | // start handle Attachments (include text/calendar multipart alternative) |
| 1109 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
| 1108 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
| 1110 | 1109 | // Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
| 1111 | - if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
| 1110 | + if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
| 1112 | 1111 | { |
| 1113 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1112 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1114 | 1113 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1115 | 1114 | foreach ($attachments as $key => $attach) |
| 1116 | 1115 | { |
| 1117 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1116 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1118 | 1117 | |
| 1119 | 1118 | // pass meeting requests to calendar plugin |
| 1120 | 1119 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1121 | 1120 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 1122 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
| 1121 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
| 1123 | 1122 | ($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
| 1124 | 1123 | { |
| 1125 | 1124 | //overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
@@ -1129,7 +1128,7 @@ discard block |
||
| 1129 | 1128 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1130 | 1129 | //$output->messageclass = "IPM.Schedule.Meeting"; |
| 1131 | 1130 | unset($attachment); |
| 1132 | - continue; // do NOT add attachment as attachment |
|
| 1131 | + continue; // do NOT add attachment as attachment |
|
| 1133 | 1132 | } |
| 1134 | 1133 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1135 | 1134 | $attachment = new SyncBaseAttachment(); |
@@ -1137,33 +1136,33 @@ discard block |
||
| 1137 | 1136 | $output->asattachments = array(); |
| 1138 | 1137 | $attachment->estimatedDataSize = $attach['size']; |
| 1139 | 1138 | $attachment->method = 1; |
| 1140 | - $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
| 1139 | + $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
| 1141 | 1140 | } else { |
| 1142 | 1141 | $attachment = new SyncAttachment(); |
| 1143 | 1142 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1144 | 1143 | $output->attachments = array(); |
| 1145 | 1144 | $attachment->attsize = $attach['size']; |
| 1146 | 1145 | $attachment->attmethod = 1; |
| 1147 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
| 1146 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
| 1148 | 1147 | } |
| 1149 | 1148 | |
| 1150 | 1149 | $attachment->displayname = $attach['name']; |
| 1151 | 1150 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
| 1152 | 1151 | |
| 1153 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1152 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1154 | 1153 | //$attachment->isinline=0; // if not inline, do not use isinline |
| 1155 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
| 1154 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
| 1156 | 1155 | { |
| 1157 | 1156 | if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
| 1158 | 1157 | { |
| 1159 | 1158 | $attachment->isinline = true; |
| 1160 | 1159 | } |
| 1161 | 1160 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1162 | - $attachment->method=1; |
|
| 1163 | - $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
| 1161 | + $attachment->method = 1; |
|
| 1162 | + $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1164 | 1163 | } else { |
| 1165 | - $attachment->attmethod=6; |
|
| 1166 | - $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
| 1164 | + $attachment->attmethod = 6; |
|
| 1165 | + $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1167 | 1166 | } |
| 1168 | 1167 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1169 | 1168 | $attachment->contenttype = trim($attach['mimeType']); |
@@ -1184,7 +1183,7 @@ discard block |
||
| 1184 | 1183 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1185 | 1184 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1186 | 1185 | |
| 1187 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1186 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
| 1188 | 1187 | //$this->debugLevel=0; |
| 1189 | 1188 | return $output; |
| 1190 | 1189 | } |
@@ -1207,30 +1206,30 @@ discard block |
||
| 1207 | 1206 | { |
| 1208 | 1207 | if (!class_exists('calendar_zpush')) |
| 1209 | 1208 | { |
| 1210 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1209 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1211 | 1210 | return null; |
| 1212 | 1211 | } |
| 1213 | 1212 | if (!($stat = $this->StatMessage($folderid, $requestid))) |
| 1214 | 1213 | { |
| 1215 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1214 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1216 | 1215 | return false; |
| 1217 | 1216 | } |
| 1218 | 1217 | $ret = false; |
| 1219 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
| 1218 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
| 1220 | 1219 | { |
| 1221 | 1220 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1222 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
| 1221 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
| 1223 | 1222 | { |
| 1224 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1223 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1225 | 1224 | |
| 1226 | 1225 | // calling backend again with iCal attachment, to let calendar add the event |
| 1227 | 1226 | $ret = $this->backend->MeetingResponse($attachment['attachment'], |
| 1228 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
| 1227 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
| 1229 | 1228 | $response); |
| 1230 | 1229 | break; |
| 1231 | 1230 | } |
| 1232 | 1231 | } |
| 1233 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1232 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1234 | 1233 | return $ret; |
| 1235 | 1234 | } |
| 1236 | 1235 | |
@@ -1244,9 +1243,9 @@ discard block |
||
| 1244 | 1243 | * @param string $attname - should contain (folder)id |
| 1245 | 1244 | * @return SyncItemOperationsAttachment-object |
| 1246 | 1245 | */ |
| 1247 | - function GetAttachmentData($fid,$attname) { |
|
| 1248 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1249 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1246 | + function GetAttachmentData($fid, $attname) { |
|
| 1247 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1248 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1250 | 1249 | } |
| 1251 | 1250 | |
| 1252 | 1251 | /** |
@@ -1259,9 +1258,9 @@ discard block |
||
| 1259 | 1258 | * @param string $attname - should contain (folder)id |
| 1260 | 1259 | * @return SyncItemOperationsAttachment-object |
| 1261 | 1260 | */ |
| 1262 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1263 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1264 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1261 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
| 1262 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1263 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1265 | 1264 | } |
| 1266 | 1265 | |
| 1267 | 1266 | /** |
@@ -1273,23 +1272,23 @@ discard block |
||
| 1273 | 1272 | * @param string $attname - should contain (folder)id |
| 1274 | 1273 | * @return SyncItemOperationsAttachment-object |
| 1275 | 1274 | */ |
| 1276 | - private function _GetAttachmentData($fid,$attname) |
|
| 1275 | + private function _GetAttachmentData($fid, $attname) |
|
| 1277 | 1276 | { |
| 1278 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1277 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1279 | 1278 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1280 | 1279 | list($folderid, $id, $part) = explode(":", $attname); |
| 1281 | 1280 | |
| 1282 | 1281 | $this->splitID($folderid, $account, $folder); |
| 1283 | 1282 | |
| 1284 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1283 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1285 | 1284 | |
| 1286 | 1285 | $this->mail->reopen($folder); |
| 1287 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
| 1286 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
| 1288 | 1287 | $SIOattachment = new SyncItemOperationsAttachment(); |
| 1289 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1288 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1290 | 1289 | $SIOattachment->data = $attachment['attachment']; |
| 1291 | 1290 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1292 | - if (isset($attachment['type']) ) |
|
| 1291 | + if (isset($attachment['type'])) |
|
| 1293 | 1292 | $SIOattachment->contenttype = $attachment['type']; |
| 1294 | 1293 | |
| 1295 | 1294 | unset($attachment); |
@@ -1332,17 +1331,17 @@ discard block |
||
| 1332 | 1331 | */ |
| 1333 | 1332 | function ChangeMessage($folderid, $id, $message, $contentParameters) |
| 1334 | 1333 | { |
| 1335 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1334 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1336 | 1335 | //unset($folderid, $id, $message, $contentParameters); |
| 1337 | 1336 | $account = $folder = null; |
| 1338 | 1337 | $this->splitID($folderid, $account, $folder); |
| 1339 | 1338 | if (isset($message->flag)) { |
| 1340 | 1339 | if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
| 1341 | - $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
| 1342 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1340 | + $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
| 1341 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1343 | 1342 | } else { |
| 1344 | - $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
| 1345 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
| 1343 | + $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
| 1344 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
| 1346 | 1345 | } |
| 1347 | 1346 | } |
| 1348 | 1347 | return $this->StatMessage($folderid, $id); |
@@ -1364,23 +1363,23 @@ discard block |
||
| 1364 | 1363 | */ |
| 1365 | 1364 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
| 1366 | 1365 | { |
| 1367 | - unset($contentParameters); // not used, but required by function signature |
|
| 1366 | + unset($contentParameters); // not used, but required by function signature |
|
| 1368 | 1367 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
| 1369 | 1368 | $account = $srcFolder = $destFolder = null; |
| 1370 | 1369 | $this->splitID($folderid, $account, $srcFolder); |
| 1371 | 1370 | $this->splitID($newfolderid, $account, $destFolder); |
| 1372 | 1371 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1373 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1372 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1374 | 1373 | $this->mail->reopen($destFolder); |
| 1375 | 1374 | $status = $this->mail->getFolderStatus($destFolder); |
| 1376 | 1375 | $uidNext = $status['uidnext']; |
| 1377 | 1376 | $this->mail->reopen($srcFolder); |
| 1378 | 1377 | |
| 1379 | 1378 | // move message |
| 1380 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
| 1381 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine |
|
| 1379 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
| 1380 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine |
|
| 1382 | 1381 | // return the new id "as string" |
| 1383 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
| 1382 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
| 1384 | 1383 | } |
| 1385 | 1384 | |
| 1386 | 1385 | /** |
@@ -1388,7 +1387,7 @@ discard block |
||
| 1388 | 1387 | * |
| 1389 | 1388 | * @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks |
| 1390 | 1389 | */ |
| 1391 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
| 1390 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
| 1392 | 1391 | { |
| 1393 | 1392 | if ($cutoffdate > 0) |
| 1394 | 1393 | { |
@@ -1401,14 +1400,14 @@ discard block |
||
| 1401 | 1400 | { |
| 1402 | 1401 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1403 | 1402 | } |
| 1404 | - $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
|
| 1405 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1403 | + $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null); |
|
| 1404 | + if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1406 | 1405 | } |
| 1407 | 1406 | try { |
| 1408 | 1407 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1409 | 1408 | } catch (Exception $e) |
| 1410 | 1409 | { |
| 1411 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details?$e->details:'')); |
|
| 1410 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details ? $e->details : '')); |
|
| 1412 | 1411 | return array(); |
| 1413 | 1412 | } |
| 1414 | 1413 | } |
@@ -1426,11 +1425,11 @@ discard block |
||
| 1426 | 1425 | * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject" |
| 1427 | 1426 | * @return array uid => array StatMessage($folderid, $_id) |
| 1428 | 1427 | */ |
| 1429 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false) |
|
| 1428 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false) |
|
| 1430 | 1429 | { |
| 1431 | 1430 | static $headers = array(); |
| 1432 | 1431 | |
| 1433 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1432 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
| 1434 | 1433 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1435 | 1434 | $rv_messages = array(); |
| 1436 | 1435 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1441,64 +1440,64 @@ discard block |
||
| 1441 | 1440 | } |
| 1442 | 1441 | else |
| 1443 | 1442 | { |
| 1444 | - $headers = array(); // clear cache to not use too much memory |
|
| 1443 | + $headers = array(); // clear cache to not use too much memory |
|
| 1445 | 1444 | |
| 1446 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1445 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1447 | 1446 | $this->_connect($this->account); |
| 1448 | - if ($this->debugLevel>1) |
|
| 1447 | + if ($this->debugLevel > 1) |
|
| 1449 | 1448 | { |
| 1450 | 1449 | $endtime = microtime(true) - $starttime; |
| 1451 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
| 1450 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
| 1452 | 1451 | } |
| 1453 | 1452 | $messagelist = $_filter = array(); |
| 1454 | 1453 | // if not connected, any further action must fail |
| 1455 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1456 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1454 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1455 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1457 | 1456 | $account = $_folderName = $id = null; |
| 1458 | - $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1459 | - if ($this->debugLevel>1) |
|
| 1457 | + $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1458 | + if ($this->debugLevel > 1) |
|
| 1460 | 1459 | { |
| 1461 | 1460 | $endtime = microtime(true) - $starttime; |
| 1462 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1461 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1463 | 1462 | } |
| 1464 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1465 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1466 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
| 1467 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
| 1468 | - if ($this->debugLevel>1) |
|
| 1463 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1464 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1465 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
| 1466 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
| 1467 | + if ($this->debugLevel > 1) |
|
| 1469 | 1468 | { |
| 1470 | 1469 | $endtime = microtime(true) - $starttime; |
| 1471 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1470 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1472 | 1471 | } |
| 1473 | 1472 | } |
| 1474 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1473 | + if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
| 1475 | 1474 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1476 | 1475 | $messagelist = array(); |
| 1477 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1476 | + if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
| 1478 | 1477 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1479 | 1478 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1480 | 1479 | { |
| 1481 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1480 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1482 | 1481 | $headers[$vars['uid']] = $vars; |
| 1483 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1482 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1484 | 1483 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
| 1485 | 1484 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
| 1486 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1485 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1487 | 1486 | $mess = $return_all_headers ? $vars : array(); |
| 1488 | 1487 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1489 | 1488 | $mess["id"] = $vars['uid']; |
| 1490 | 1489 | // 'seen' aka 'read' is the only flag we want to know about |
| 1491 | 1490 | $mess["flags"] = 0; |
| 1492 | 1491 | // outlook supports additional flags, set them to 0 |
| 1493 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1494 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1492 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
| 1493 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
| 1495 | 1494 | $messagelist[$vars['uid']] = $mess; |
| 1496 | 1495 | unset($mess); |
| 1497 | 1496 | } |
| 1498 | - if ($this->debugLevel>1) |
|
| 1497 | + if ($this->debugLevel > 1) |
|
| 1499 | 1498 | { |
| 1500 | 1499 | $endtime = microtime(true) - $gstarttime; |
| 1501 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1500 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1502 | 1501 | } |
| 1503 | 1502 | return $messagelist; |
| 1504 | 1503 | } |
@@ -1549,32 +1548,32 @@ discard block |
||
| 1549 | 1548 | public function getSearchResultsMailbox($_searchquery) |
| 1550 | 1549 | { |
| 1551 | 1550 | //$this->debugLevel=1; |
| 1552 | - $searchquery=$_searchquery->GetDataArray(); |
|
| 1551 | + $searchquery = $_searchquery->GetDataArray(); |
|
| 1553 | 1552 | if (!is_array($searchquery)) return array(); |
| 1554 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1553 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
| 1555 | 1554 | |
| 1556 | 1555 | if (isset($searchquery['searchrebuildresults'])) { |
| 1557 | 1556 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1558 | 1557 | } else { |
| 1559 | 1558 | $rebuildresults = false; |
| 1560 | 1559 | } |
| 1561 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1560 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']'); |
|
| 1562 | 1561 | |
| 1563 | 1562 | if (isset($searchquery['deeptraversal'])) { |
| 1564 | 1563 | $deeptraversal = $searchquery['deeptraversal']; |
| 1565 | 1564 | } else { |
| 1566 | 1565 | $deeptraversal = false; |
| 1567 | 1566 | } |
| 1568 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1567 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']'); |
|
| 1569 | 1568 | |
| 1570 | 1569 | if (isset($searchquery['searchrange'])) { |
| 1571 | - $range = explode("-",$_searchquery->GetSearchRange()); |
|
| 1572 | - $start =$range[0] + 1; |
|
| 1570 | + $range = explode("-", $_searchquery->GetSearchRange()); |
|
| 1571 | + $start = $range[0] + 1; |
|
| 1573 | 1572 | $limit = $range[1] - $range[0] + 1; |
| 1574 | 1573 | } else { |
| 1575 | 1574 | $range = false; |
| 1576 | 1575 | } |
| 1577 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1576 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']'); |
|
| 1578 | 1577 | |
| 1579 | 1578 | //foreach($searchquery['query'] as $k => $value) { |
| 1580 | 1579 | // $query = $value; |
@@ -1597,15 +1596,15 @@ discard block |
||
| 1597 | 1596 | } |
| 1598 | 1597 | if (!$folderid) |
| 1599 | 1598 | { |
| 1600 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
| 1601 | - $folderid = $this->createID($account=0,$_folderName); |
|
| 1599 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
| 1600 | + $folderid = $this->createID($account = 0, $_folderName); |
|
| 1602 | 1601 | } |
| 1603 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1604 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1602 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1603 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1605 | 1604 | $this->_connect($account); |
| 1606 | 1605 | // this should not be needed ??? |
| 1607 | - Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
| 1608 | - $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
| 1606 | + Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
| 1607 | + $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
| 1609 | 1608 | 'string'=> $searchText, |
| 1610 | 1609 | 'status'=>'any' |
| 1611 | 1610 | ); |
@@ -1620,22 +1619,22 @@ discard block |
||
| 1620 | 1619 | * [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
| 1621 | 1620 | */ |
| 1622 | 1621 | $_filter['range'] = "BETWEEN"; |
| 1623 | - list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
| 1624 | - list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
| 1625 | - $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
| 1626 | - $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
| 1622 | + list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
| 1623 | + list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
| 1624 | + $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
| 1625 | + $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
| 1627 | 1626 | } |
| 1628 | 1627 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1629 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1630 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
| 1628 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1629 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
| 1631 | 1630 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1632 | - $list=array(); |
|
| 1631 | + $list = array(); |
|
| 1633 | 1632 | |
| 1634 | 1633 | $cnt = count($rv_messages['header']); |
| 1635 | 1634 | //$list['status'] = 1; |
| 1636 | 1635 | $list['searchtotal'] = $cnt; |
| 1637 | 1636 | $list["range"] = $_searchquery->GetSearchRange(); |
| 1638 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
| 1637 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
| 1639 | 1638 | { |
| 1640 | 1639 | $list[] = array( |
| 1641 | 1640 | "class" => "Email", |
@@ -1655,20 +1654,20 @@ discard block |
||
| 1655 | 1654 | * @param string $folder |
| 1656 | 1655 | * @return string |
| 1657 | 1656 | */ |
| 1658 | - private function getParentID($account,$folder) |
|
| 1657 | + private function getParentID($account, $folder) |
|
| 1659 | 1658 | { |
| 1660 | 1659 | $this->_connect($account); |
| 1661 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1660 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1662 | 1661 | |
| 1663 | 1662 | $mailFolder = $this->folders[$folder]; |
| 1664 | 1663 | if (!isset($mailFolder)) return false; |
| 1665 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
| 1666 | - $parent = explode($delimiter,$folder); |
|
| 1664 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
| 1665 | + $parent = explode($delimiter, $folder); |
|
| 1667 | 1666 | array_pop($parent); |
| 1668 | - $parent = implode($delimiter,$parent); |
|
| 1667 | + $parent = implode($delimiter, $parent); |
|
| 1669 | 1668 | |
| 1670 | 1669 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1671 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1670 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1672 | 1671 | return $id; |
| 1673 | 1672 | } |
| 1674 | 1673 | |
@@ -1688,48 +1687,48 @@ discard block |
||
| 1688 | 1687 | $account = $folder = null; |
| 1689 | 1688 | $this->splitID($id, $account, $folder); |
| 1690 | 1689 | } |
| 1691 | - catch(Exception $e) { |
|
| 1692 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1693 | - return $folderObj=false; |
|
| 1690 | + catch (Exception $e) { |
|
| 1691 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1692 | + return $folderObj = false; |
|
| 1694 | 1693 | } |
| 1695 | 1694 | $this->_connect($account); |
| 1696 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1695 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1697 | 1696 | |
| 1698 | 1697 | $mailFolder = $this->folders[$folder]; |
| 1699 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 1698 | + if (!isset($mailFolder)) return $folderObj = false; |
|
| 1700 | 1699 | |
| 1701 | 1700 | $folderObj = new SyncFolder(); |
| 1702 | 1701 | $folderObj->serverid = $id; |
| 1703 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
| 1702 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
| 1704 | 1703 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1705 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1704 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1706 | 1705 | // get folder-type |
| 1707 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 1706 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
| 1708 | 1707 | if ($folder == $inbox) |
| 1709 | 1708 | { |
| 1710 | 1709 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
| 1711 | 1710 | } |
| 1712 | - elseif($this->mail->isDraftFolder($folder, false, true)) |
|
| 1711 | + elseif ($this->mail->isDraftFolder($folder, false, true)) |
|
| 1713 | 1712 | { |
| 1714 | 1713 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
| 1715 | 1714 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
| 1716 | 1715 | $folderObj->parentid = 0; // required by devices |
| 1717 | 1716 | } |
| 1718 | - elseif($this->mail->isTrashFolder($folder, false, true)) |
|
| 1717 | + elseif ($this->mail->isTrashFolder($folder, false, true)) |
|
| 1719 | 1718 | { |
| 1720 | 1719 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
| 1721 | 1720 | $this->_wasteID = $folder; |
| 1722 | 1721 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
| 1723 | 1722 | $folderObj->parentid = 0; // required by devices |
| 1724 | 1723 | } |
| 1725 | - elseif($this->mail->isSentFolder($folder, false, true)) |
|
| 1724 | + elseif ($this->mail->isSentFolder($folder, false, true)) |
|
| 1726 | 1725 | { |
| 1727 | 1726 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
| 1728 | 1727 | $folderObj->parentid = 0; // required by devices |
| 1729 | 1728 | $this->_sentID = $folder; |
| 1730 | 1729 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
| 1731 | 1730 | } |
| 1732 | - elseif($this->mail->isOutbox($folder, false, true)) |
|
| 1731 | + elseif ($this->mail->isOutbox($folder, false, true)) |
|
| 1733 | 1732 | { |
| 1734 | 1733 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
| 1735 | 1734 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1741,7 +1740,7 @@ discard block |
||
| 1741 | 1740 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1742 | 1741 | } |
| 1743 | 1742 | |
| 1744 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1743 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1745 | 1744 | return $folderObj; |
| 1746 | 1745 | } |
| 1747 | 1746 | |
@@ -1789,24 +1788,24 @@ discard block |
||
| 1789 | 1788 | |
| 1790 | 1789 | if ($type != 'mail') return false; |
| 1791 | 1790 | |
| 1792 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1791 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1793 | 1792 | if (!$this->mail->folderIsSelectable($folder)) |
| 1794 | 1793 | { |
| 1795 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not select folder $folder returning fake state"); |
|
| 1794 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not select folder $folder returning fake state"); |
|
| 1796 | 1795 | $syncstate = "M:".'0'."-R:".'0'."-U:".'0'."-NUID:".'0'."-UIDV:".'0'; |
| 1797 | 1796 | return array(); |
| 1798 | 1797 | } |
| 1799 | 1798 | |
| 1800 | 1799 | $this->mail->reopen($folder); |
| 1801 | 1800 | |
| 1802 | - if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true))) |
|
| 1801 | + if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true))) |
|
| 1803 | 1802 | { |
| 1804 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
| 1803 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
| 1805 | 1804 | return false; |
| 1806 | 1805 | } |
| 1807 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1806 | + $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1808 | 1807 | |
| 1809 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1808 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1810 | 1809 | return array(); |
| 1811 | 1810 | } |
| 1812 | 1811 | |
@@ -1819,8 +1818,8 @@ discard block |
||
| 1819 | 1818 | function GetWasteBasket() |
| 1820 | 1819 | { |
| 1821 | 1820 | $this->_connect($this->account); |
| 1822 | - $id = $this->createID($account=0, $this->_wasteID); |
|
| 1823 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1821 | + $id = $this->createID($account = 0, $this->_wasteID); |
|
| 1822 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1824 | 1823 | return $id; |
| 1825 | 1824 | } |
| 1826 | 1825 | |
@@ -1841,7 +1840,7 @@ discard block |
||
| 1841 | 1840 | */ |
| 1842 | 1841 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1843 | 1842 | { |
| 1844 | - unset($contentParameters); // not used, but required by function signature |
|
| 1843 | + unset($contentParameters); // not used, but required by function signature |
|
| 1845 | 1844 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1846 | 1845 | /* |
| 1847 | 1846 | $this->imap_reopenFolder($folderid); |
@@ -1852,7 +1851,7 @@ discard block |
||
| 1852 | 1851 | // we may have to split folderid |
| 1853 | 1852 | $account = $folder = null; |
| 1854 | 1853 | $this->splitID($folderid, $account, $folder); |
| 1855 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1854 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1856 | 1855 | $_messageUID = (array)$id; |
| 1857 | 1856 | |
| 1858 | 1857 | $this->_connect($this->account); |
@@ -1864,9 +1863,9 @@ discard block |
||
| 1864 | 1863 | catch (Api\Exception $e) |
| 1865 | 1864 | { |
| 1866 | 1865 | $error = $e->getMessage(); |
| 1867 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1866 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1868 | 1867 | // if the server thinks the message does not exist report deletion as success |
| 1869 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 1868 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
| 1870 | 1869 | return false; |
| 1871 | 1870 | } |
| 1872 | 1871 | |
@@ -1900,15 +1899,15 @@ discard block |
||
| 1900 | 1899 | */ |
| 1901 | 1900 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1902 | 1901 | { |
| 1903 | - unset($contentParameters); // not used, but required by function signature |
|
| 1902 | + unset($contentParameters); // not used, but required by function signature |
|
| 1904 | 1903 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1905 | 1904 | $account = $folder = null; |
| 1906 | 1905 | $this->splitID($folderid, $account, $folder); |
| 1907 | 1906 | |
| 1908 | 1907 | $_messageUID = (array)$id; |
| 1909 | 1908 | $this->_connect($this->account); |
| 1910 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
| 1911 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
| 1909 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
| 1910 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
| 1912 | 1911 | |
| 1913 | 1912 | return $rv; |
| 1914 | 1913 | } |
@@ -1926,7 +1925,7 @@ discard block |
||
| 1926 | 1925 | */ |
| 1927 | 1926 | public function ChangeFolder($id, $oldid, $displayname, $type) |
| 1928 | 1927 | { |
| 1929 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
| 1928 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
| 1930 | 1929 | $account = $parent_id = null; |
| 1931 | 1930 | $this->splitID($id, $account, $parentFolder, $app); |
| 1932 | 1931 | |
@@ -1943,17 +1942,17 @@ discard block |
||
| 1943 | 1942 | $this->splitID($oldid, $account, $oldFolder, $app); |
| 1944 | 1943 | $old_hash = $this->folder2hash($account, $oldFolder); |
| 1945 | 1944 | } |
| 1946 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid?"=>($oldFolder ($old_hash))":'').", '$displayname', $type)"); |
|
| 1945 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid ? "=>($oldFolder ($old_hash))" : '').", '$displayname', $type)"); |
|
| 1947 | 1946 | $this->_connect($this->account); |
| 1948 | 1947 | try |
| 1949 | 1948 | { |
| 1950 | - if ($action=='rename') |
|
| 1949 | + if ($action == 'rename') |
|
| 1951 | 1950 | { |
| 1952 | 1951 | $newFolderName = $this->mail->renameFolder($oldFolder, $parentFolder, $displayname); |
| 1953 | 1952 | } |
| 1954 | - elseif ($action=='create') |
|
| 1953 | + elseif ($action == 'create') |
|
| 1955 | 1954 | { |
| 1956 | - $error=null; |
|
| 1955 | + $error = null; |
|
| 1957 | 1956 | $newFolderName = $this->mail->createFolder($parentFolder, $displayname, $error); |
| 1958 | 1957 | } |
| 1959 | 1958 | } |
@@ -1965,7 +1964,7 @@ discard block |
||
| 1965 | 1964 | $newHash = $this->rename_folder_hash($account, $old_hash, $newFolderName); |
| 1966 | 1965 | $newID = $this->createID($account, $newHash); |
| 1967 | 1966 | |
| 1968 | - ZLog::Write(LOGLEVEL_DEBUG,":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid?"=>($oldFolder)":'').", '$displayname' => $newFolderName (ID:$newID))"); |
|
| 1967 | + ZLog::Write(LOGLEVEL_DEBUG, ":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid ? "=>($oldFolder)" : '').", '$displayname' => $newFolderName (ID:$newID))"); |
|
| 1969 | 1968 | return $this->StatFolder($newID); |
| 1970 | 1969 | } |
| 1971 | 1970 | |
@@ -1978,13 +1977,13 @@ discard block |
||
| 1978 | 1977 | * @throws StatusException could throw specific SYNC_FSSTATUS_* exceptions |
| 1979 | 1978 | * @return boolean true or false on error |
| 1980 | 1979 | */ |
| 1981 | - public function DeleteFolder($id, $parentid=false) |
|
| 1980 | + public function DeleteFolder($id, $parentid = false) |
|
| 1982 | 1981 | { |
| 1983 | 1982 | $account = $parent_id = $app = null; |
| 1984 | 1983 | $this->splitID($id, $account, $folder, $app); |
| 1985 | 1984 | $old_hash = $this->folder2hash($account, $folder); |
| 1986 | 1985 | if ($parentid) $this->splitID($parentid, $account, $parentfolder, $app); |
| 1987 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."( '$id (-> $folder)','$parentid ".($parentid?'(->'.$parentfolder.')':'')."') called!"); |
|
| 1986 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."( '$id (-> $folder)','$parentid ".($parentid ? '(->'.$parentfolder.')' : '')."') called!"); |
|
| 1988 | 1987 | $ret = $this->mail->deleteFolder($folder); |
| 1989 | 1988 | if ($ret) $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
| 1990 | 1989 | return $ret; |
@@ -2006,8 +2005,8 @@ discard block |
||
| 2006 | 2005 | $this->_connect($this->account); |
| 2007 | 2006 | $account = $folder = null; |
| 2008 | 2007 | $this->splitID($folderid, $account, $folder); |
| 2009 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
| 2010 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 2008 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
| 2009 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 2011 | 2010 | |
| 2012 | 2011 | return $rv; |
| 2013 | 2012 | } |
@@ -2021,17 +2020,17 @@ discard block |
||
| 2021 | 2020 | * @return string |
| 2022 | 2021 | * @throws Api\Exception\WrongParameter |
| 2023 | 2022 | */ |
| 2024 | - private function createID($account,$folder,$id=0) |
|
| 2023 | + private function createID($account, $folder, $id = 0) |
|
| 2025 | 2024 | { |
| 2026 | 2025 | if (!is_numeric($folder)) |
| 2027 | 2026 | { |
| 2028 | 2027 | // convert string $folder in numeric id |
| 2029 | - $folder = $this->folder2hash($account,$f=$folder); |
|
| 2028 | + $folder = $this->folder2hash($account, $f = $folder); |
|
| 2030 | 2029 | } |
| 2031 | 2030 | |
| 2032 | 2031 | $str = $this->backend->createID($account, $folder, $id); |
| 2033 | 2032 | |
| 2034 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2033 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2035 | 2034 | |
| 2036 | 2035 | return $str; |
| 2037 | 2036 | } |
@@ -2045,14 +2044,14 @@ discard block |
||
| 2045 | 2044 | * @param int &$appid=null (for mail=mail is to be expected) |
| 2046 | 2045 | * @throws Api\Exception\WrongParameter |
| 2047 | 2046 | */ |
| 2048 | - private function splitID($str,&$account,&$folder,&$appid=null) |
|
| 2047 | + private function splitID($str, &$account, &$folder, &$appid = null) |
|
| 2049 | 2048 | { |
| 2050 | 2049 | $this->backend->splitID($str, $account, $folder, $appid); |
| 2051 | 2050 | |
| 2052 | 2051 | // convert numeric folder-id back to folder name |
| 2053 | - $folder = $this->hash2folder($account,$f=$folder); |
|
| 2052 | + $folder = $this->hash2folder($account, $f = $folder); |
|
| 2054 | 2053 | |
| 2055 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2054 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2056 | 2055 | } |
| 2057 | 2056 | |
| 2058 | 2057 | /** |
@@ -2069,9 +2068,9 @@ discard block |
||
| 2069 | 2068 | * @param string $folder |
| 2070 | 2069 | * @return int |
| 2071 | 2070 | */ |
| 2072 | - private function folder2hash($account,$folder) |
|
| 2071 | + private function folder2hash($account, $folder) |
|
| 2073 | 2072 | { |
| 2074 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2073 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2075 | 2074 | |
| 2076 | 2075 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2077 | 2076 | { |
@@ -2092,9 +2091,9 @@ discard block |
||
| 2092 | 2091 | * @param int $index |
| 2093 | 2092 | * @return string NULL if not used so far |
| 2094 | 2093 | */ |
| 2095 | - private function hash2folder($account,$index) |
|
| 2094 | + private function hash2folder($account, $index) |
|
| 2096 | 2095 | { |
| 2097 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2096 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2098 | 2097 | |
| 2099 | 2098 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2100 | 2099 | } |
@@ -2150,9 +2149,9 @@ discard block |
||
| 2150 | 2149 | if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
| 2151 | 2150 | ($hashes = file_get_contents($file))) |
| 2152 | 2151 | { |
| 2153 | - $this->folderHashes = json_decode($hashes,true); |
|
| 2152 | + $this->folderHashes = json_decode($hashes, true); |
|
| 2154 | 2153 | // fallback in case hashes have been serialized instead of being json-encoded |
| 2155 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
| 2154 | + if (json_last_error() != JSON_ERROR_NONE) |
|
| 2156 | 2155 | { |
| 2157 | 2156 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
| 2158 | 2157 | $this->folderHashes = unserialize($hashes); |
@@ -2198,9 +2197,9 @@ discard block |
||
| 2198 | 2197 | * @param boolean $old =false true: return old / pre-15 hash-file |
| 2199 | 2198 | * @throws Api\Exception\AssertionFailed |
| 2200 | 2199 | */ |
| 2201 | - private function hashFile($old=false) |
|
| 2200 | + private function hashFile($old = false) |
|
| 2202 | 2201 | { |
| 2203 | - if (!($dev_id=Request::GetDeviceID())) |
|
| 2202 | + if (!($dev_id = Request::GetDeviceID())) |
|
| 2204 | 2203 | { |
| 2205 | 2204 | throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
| 2206 | 2205 | } |