@@ -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 | |
@@ -226,13 +226,13 @@ discard block |
||
| 226 | 226 | $this->__construct($this->backend); |
| 227 | 227 | |
| 228 | 228 | try { |
| 229 | - $this->_connect(0,true); |
|
| 229 | + $this->_connect(0, true); |
|
| 230 | 230 | $this->_disconnect(); |
| 231 | 231 | |
| 232 | 232 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
| 233 | 233 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
| 234 | 234 | } |
| 235 | - catch(Exception $e) { |
|
| 235 | + catch (Exception $e) { |
|
| 236 | 236 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
| 237 | 237 | } |
| 238 | 238 | if ($errors) |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @param int $account integer id of account to use |
| 251 | 251 | * @todo support different accounts |
| 252 | 252 | */ |
| 253 | - private function _connect($account=0) |
|
| 253 | + private function _connect($account = 0) |
|
| 254 | 254 | { |
| 255 | 255 | if (!$account) $account = self::$profileID ? self::$profileID : 0; |
| 256 | 256 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $this->account = $account; |
| 264 | 264 | // todo: tell mail which account to use |
| 265 | 265 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 266 | - $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 266 | + $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 267 | 267 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 268 | 268 | } |
| 269 | 269 | else |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 272 | 272 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 273 | 273 | } |
| 274 | - $this->mail->openConnection(self::$profileID,false); |
|
| 274 | + $this->mail->openConnection(self::$profileID, false); |
|
| 275 | 275 | |
| 276 | 276 | $this->_wasteID = $this->mail->getTrashFolder(false); |
| 277 | 277 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | private function _disconnect() |
| 288 | 288 | { |
| 289 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 289 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__); |
|
| 290 | 290 | if ($this->mail) $this->mail->closeConnection(); |
| 291 | 291 | |
| 292 | 292 | unset($this->mail); |
@@ -302,24 +302,24 @@ discard block |
||
| 302 | 302 | public function GetFolderList() |
| 303 | 303 | { |
| 304 | 304 | $folderlist = array(); |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 305 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__); |
|
| 306 | 306 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 307 | 307 | { |
| 308 | 308 | $this->_connect($account); |
| 309 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 310 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 309 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
| 310 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders)); |
|
| 311 | 311 | |
| 312 | 312 | foreach ($this->folders as $folder => $folderObj) { |
| 313 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 313 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder); |
|
| 314 | 314 | $folderlist[] = $f = array( |
| 315 | - 'id' => $this->createID($account,$folder), |
|
| 315 | + 'id' => $this->createID($account, $folder), |
|
| 316 | 316 | 'mod' => $folderObj->shortDisplayName, |
| 317 | - 'parent' => $this->getParentID($account,$folder), |
|
| 317 | + 'parent' => $this->getParentID($account, $folder), |
|
| 318 | 318 | ); |
| 319 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 319 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f)); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 322 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist)); |
|
| 323 | 323 | |
| 324 | 324 | return $folderlist; |
| 325 | 325 | } |
@@ -368,58 +368,58 @@ discard block |
||
| 368 | 368 | $ClientSideMeetingRequest = false; |
| 369 | 369 | $allowSendingInvitations = 'sendifnocalnotif'; |
| 370 | 370 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 371 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
| 371 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
| 372 | 372 | { |
| 373 | 373 | $allowSendingInvitations = false; |
| 374 | 374 | } |
| 375 | 375 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 376 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
| 376 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
| 377 | 377 | { |
| 378 | 378 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
| 379 | 379 | } |
| 380 | - $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
|
| 380 | + $smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new')); |
|
| 381 | 381 | |
| 382 | - 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 : "")); |
|
| 383 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 382 | + 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 : "")); |
|
| 383 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 384 | 384 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 385 | 385 | |
| 386 | 386 | // initialize our Mail |
| 387 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 387 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 388 | 388 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 389 | 389 | // use the standardIdentity |
| 390 | - $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
| 390 | + $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
| 391 | 391 | |
| 392 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 392 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 393 | 393 | |
| 394 | 394 | // initialize the new Api\Mailer object for sending |
| 395 | 395 | $mailObject = new Api\Mailer(self::$profileID); |
| 396 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime); |
|
| 396 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime); |
|
| 397 | 397 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
| 398 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 399 | - $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); |
|
| 398 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 399 | + $mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false)); |
|
| 400 | 400 | $mailObject->addHeader('X-Mailer', 'mail-Activesync'); |
| 401 | 401 | |
| 402 | 402 | |
| 403 | 403 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 404 | 404 | // to |
| 405 | 405 | |
| 406 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 406 | + foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 407 | 407 | if (!$addressObject->valid) continue; |
| 408 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
| 408 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
| 409 | 409 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 410 | 410 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 411 | 411 | } |
| 412 | 412 | // CC |
| 413 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 413 | + foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 414 | 414 | if (!$addressObject->valid) continue; |
| 415 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
| 415 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
| 416 | 416 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 417 | 417 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 418 | 418 | } |
| 419 | 419 | // BCC |
| 420 | - foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 420 | + foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 421 | 421 | if (!$addressObject->valid) continue; |
| 422 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
| 422 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
| 423 | 423 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 424 | 424 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 425 | 425 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | $use_orgbody = false; |
| 429 | 429 | |
| 430 | 430 | $k = 'Content-Type'; |
| 431 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
| 431 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
| 432 | 432 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 433 | 433 | // if the message is a multipart message, then we should use the sent body |
| 434 | 434 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -448,43 +448,43 @@ discard block |
||
| 448 | 448 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
| 449 | 449 | $use_orgbody = true; |
| 450 | 450 | } |
| 451 | - $Body = $AltBody = ""; |
|
| 451 | + $Body = $AltBody = ""; |
|
| 452 | 452 | // get body of the transmitted message |
| 453 | 453 | // if this is a simple message, no structure at all |
| 454 | 454 | if (preg_match("/text/i", $ContentType)) |
| 455 | 455 | { |
| 456 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
| 456 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
| 457 | 457 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
| 458 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
| 459 | - if ($simpleBodyType == "text/plain") |
|
| 458 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
| 459 | + if ($simpleBodyType == "text/plain") |
|
| 460 | 460 | { |
| 461 | 461 | $Body = $body; |
| 462 | 462 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 463 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
| 463 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
| 464 | 464 | } |
| 465 | 465 | else |
| 466 | 466 | { |
| 467 | 467 | $AltBody = $body; |
| 468 | - $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 469 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
| 468 | + $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 469 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | else |
| 473 | 473 | { |
| 474 | 474 | // if this is a structured message |
| 475 | 475 | // prefer plain over html |
| 476 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 476 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 477 | 477 | ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
| 478 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 478 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 479 | 479 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 480 | 480 | } |
| 481 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 482 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 481 | + if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
| 482 | + if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
| 483 | 483 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 484 | 484 | // if this is a multipart message with a boundary, we must use the original body |
| 485 | 485 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 486 | 486 | if ($use_orgbody) { |
| 487 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 487 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 488 | 488 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 489 | 489 | if (($cal_body = $mailObject->findBody('calendar')) && |
| 490 | 490 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -493,21 +493,21 @@ discard block |
||
| 493 | 493 | { |
| 494 | 494 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 495 | 495 | } |
| 496 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 496 | + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 497 | 497 | $ClientSideMeetingRequest = true; |
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | // now handle the addressee list |
| 501 | 501 | $toCount = 0; |
| 502 | 502 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 503 | - foreach((array)$toMailAddr as $address) { |
|
| 504 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 505 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 503 | + foreach ((array)$toMailAddr as $address) { |
|
| 504 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 505 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 506 | 506 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 507 | 507 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
| 508 | 508 | $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
| 509 | 509 | { |
| 510 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 510 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 511 | 511 | continue; |
| 512 | 512 | } |
| 513 | 513 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
@@ -515,29 +515,29 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | $ccCount = 0; |
| 518 | - foreach((array)$ccMailAddr as $address) { |
|
| 519 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 520 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 518 | + foreach ((array)$ccMailAddr as $address) { |
|
| 519 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 520 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 521 | 521 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 522 | 522 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 523 | 523 | $ccCount++; |
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | $bccCount = 0; |
| 527 | - foreach((array)$bccMailAddr as $address) { |
|
| 528 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 529 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 527 | + foreach ((array)$bccMailAddr as $address) { |
|
| 528 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 529 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 530 | 530 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 531 | 531 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 532 | 532 | $bccCount++; |
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
| 536 | - if ($toCount+$ccCount+$bccCount == 0) |
|
| 536 | + if ($toCount + $ccCount + $bccCount == 0) |
|
| 537 | 537 | { |
| 538 | 538 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 539 | 539 | } |
| 540 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 540 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
| 541 | 541 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 542 | 542 | /* |
| 543 | 543 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -545,29 +545,29 @@ discard block |
||
| 545 | 545 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body (modified):'.$body); |
| 546 | 546 | */ |
| 547 | 547 | // add signature!! ----------------------------------------------------------------- |
| 548 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 548 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 549 | 549 | try |
| 550 | 550 | { |
| 551 | 551 | $acc = Mail\Account::read($this->mail->icServer->ImapServerId); |
| 552 | 552 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 553 | - $_signature = Mail\Account::read_identity($acc['ident_id'],true); |
|
| 553 | + $_signature = Mail\Account::read_identity($acc['ident_id'], true); |
|
| 554 | 554 | } |
| 555 | 555 | catch (Exception $e) |
| 556 | 556 | { |
| 557 | - $_signature=array(); |
|
| 557 | + $_signature = array(); |
|
| 558 | 558 | } |
| 559 | 559 | $signature = $_signature['ident_signature']; |
| 560 | 560 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
| 561 | 561 | $preferencesArray['disableRulerForSignatureSeparation']) || |
| 562 | - empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='') |
|
| 562 | + empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '') |
|
| 563 | 563 | { |
| 564 | 564 | $disableRuler = true; |
| 565 | 565 | } |
| 566 | 566 | $beforePlain = $beforeHtml = ""; |
| 567 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 568 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
| 569 | - $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
| 570 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 567 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 568 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
| 569 | + $sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
| 570 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 571 | 571 | $sigTextHtml = $beforeHtml.$sigText; |
| 572 | 572 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 573 | 573 | $isreply = $isforward = false; |
@@ -579,26 +579,26 @@ discard block |
||
| 579 | 579 | { |
| 580 | 580 | // now get on, and fetch the original mail |
| 581 | 581 | $uid = $smartdata->source->itemid; |
| 582 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 582 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 583 | 583 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 584 | 584 | |
| 585 | 585 | $this->mail->reopen($folder); |
| 586 | 586 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 587 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 588 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 589 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 587 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 588 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 589 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 590 | 590 | // may be html |
| 591 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 591 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 592 | 592 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 593 | 593 | $isreply = true; |
| 594 | 594 | } |
| 595 | 595 | // plain text Message part |
| 596 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 596 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 597 | 597 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 598 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 599 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 600 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 601 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 598 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 599 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 600 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 601 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 602 | 602 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 603 | 603 | $isreply = true; |
| 604 | 604 | } |
@@ -606,12 +606,12 @@ discard block |
||
| 606 | 606 | { |
| 607 | 607 | $isreply = true; |
| 608 | 608 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 609 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 609 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // how to forward and other prefs |
| 614 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 614 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 615 | 615 | |
| 616 | 616 | // forward ------------------------------------------------------------------------- |
| 617 | 617 | if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | { |
| 622 | 622 | //force the default for the forwarding -> asmail |
| 623 | 623 | if (is_array($preferencesArray)) { |
| 624 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
| 624 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
| 625 | 625 | || !isset($preferencesArray['message_forwarding']) |
| 626 | 626 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
| 627 | 627 | } else { |
@@ -629,18 +629,18 @@ discard block |
||
| 629 | 629 | } |
| 630 | 630 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
| 631 | 631 | $uid = $smartdata->source->itemid; |
| 632 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 632 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 633 | 633 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 634 | 634 | |
| 635 | 635 | $this->mail->reopen($folder); |
| 636 | 636 | // receive entire mail (header + body) |
| 637 | 637 | // get message headers for specified message |
| 638 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 638 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 639 | 639 | // build a new mime message, forward entire old mail as file |
| 640 | 640 | if ($preferencesArray['message_forwarding'] == 'asmail') |
| 641 | 641 | { |
| 642 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
| 643 | - $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
| 642 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
| 643 | + $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
| 644 | 644 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
| 645 | 645 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
| 646 | 646 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -650,50 +650,50 @@ discard block |
||
| 650 | 650 | { |
| 651 | 651 | // now get on, and fetch the original mail |
| 652 | 652 | $uid = $smartdata->source->itemid; |
| 653 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 653 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 654 | 654 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 655 | 655 | |
| 656 | 656 | $this->mail->reopen($folder); |
| 657 | 657 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 658 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 659 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 660 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 658 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 659 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 660 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 661 | 661 | // may be html |
| 662 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 662 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 663 | 663 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 664 | 664 | $isforward = true; |
| 665 | 665 | } |
| 666 | 666 | // plain text Message part |
| 667 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 667 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 668 | 668 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 669 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 670 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 671 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 672 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 669 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 670 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 671 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 672 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 673 | 673 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 674 | 674 | $isforward = true; |
| 675 | 675 | } |
| 676 | 676 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 677 | 677 | { |
| 678 | 678 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 679 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 679 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 680 | 680 | $isforward = true; |
| 681 | 681 | } |
| 682 | 682 | // get all the attachments and add them too. |
| 683 | 683 | // start handle Attachments |
| 684 | 684 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
| 685 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
| 685 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
| 686 | 686 | $attachmentNames = false; |
| 687 | - if (is_array($attachments) && count($attachments)>0) |
|
| 687 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 688 | 688 | { |
| 689 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 690 | - foreach((array)$attachments as $key => $attachment) |
|
| 689 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 690 | + foreach ((array)$attachments as $key => $attachment) |
|
| 691 | 691 | { |
| 692 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 692 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 693 | 693 | $attachmentNames .= $attachment['name']."\n"; |
| 694 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
| 694 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
| 695 | 695 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
| 696 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
| 696 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | } |
@@ -707,36 +707,36 @@ discard block |
||
| 707 | 707 | // now set the body |
| 708 | 708 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 709 | 709 | { |
| 710 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 711 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 710 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
| 711 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 712 | 712 | } |
| 713 | 713 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 714 | 714 | { |
| 715 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 716 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 715 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
| 716 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 717 | 717 | } |
| 718 | 718 | //advanced debugging |
| 719 | 719 | // Horde SMTP Class uses utf-8 by default. |
| 720 | 720 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 721 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 721 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 722 | 722 | |
| 723 | 723 | // set a higher timeout for big messages |
| 724 | 724 | @set_time_limit(120); |
| 725 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 725 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 726 | 726 | // send |
| 727 | 727 | $send = true; |
| 728 | 728 | try { |
| 729 | 729 | $mailObject->Send(); |
| 730 | 730 | } |
| 731 | - catch(Exception $e) { |
|
| 732 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
| 731 | + catch (Exception $e) { |
|
| 732 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
| 733 | 733 | $send = false; |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | - if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 736 | + if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 737 | 737 | { |
| 738 | 738 | $uid = $smartdata->source->itemid; |
| 739 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 739 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 740 | 740 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 741 | 741 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
| 742 | 742 | $this->mail->reopen($folder); |
@@ -744,89 +744,89 @@ discard block |
||
| 744 | 744 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 745 | 745 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 746 | 746 | { |
| 747 | - $this->mail->deleteMessages(array($uid),$folder); |
|
| 747 | + $this->mail->deleteMessages(array($uid), $folder); |
|
| 748 | 748 | } else { |
| 749 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
| 750 | - if ($smartdata_task== "forward") |
|
| 749 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
| 750 | + if ($smartdata_task == "forward") |
|
| 751 | 751 | { |
| 752 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
| 752 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
| 753 | 753 | } |
| 754 | 754 | } |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - $asf = ($send ? true:false); // initalize accordingly |
|
| 758 | - if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 757 | + $asf = ($send ? true : false); // initalize accordingly |
|
| 758 | + if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 759 | 759 | { |
| 760 | 760 | $asf = false; |
| 761 | 761 | $sentFolder = $this->mail->getSentFolder(); |
| 762 | 762 | if ($this->_sentID) { |
| 763 | 763 | $folderArray[] = $this->_sentID; |
| 764 | 764 | } |
| 765 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
| 765 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
| 766 | 766 | { |
| 767 | 767 | $folderArray[] = $sentFolder; |
| 768 | 768 | } |
| 769 | 769 | // No Sent folder set, try defaults |
| 770 | 770 | else |
| 771 | 771 | { |
| 772 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 772 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 773 | 773 | // we dont try guessing |
| 774 | 774 | $asf = true; |
| 775 | 775 | } |
| 776 | 776 | if (count($folderArray) > 0) { |
| 777 | - foreach((array)$bccMailAddr as $address) { |
|
| 778 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 779 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 777 | + foreach ((array)$bccMailAddr as $address) { |
|
| 778 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 779 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 780 | 780 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | - $BCCmail=''; |
|
| 784 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 785 | - foreach($folderArray as $folderName) { |
|
| 786 | - if($this->mail->isSentFolder($folderName)) { |
|
| 783 | + $BCCmail = ''; |
|
| 784 | + if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
| 785 | + foreach ($folderArray as $folderName) { |
|
| 786 | + if ($this->mail->isSentFolder($folderName)) { |
|
| 787 | 787 | $flags = '\\Seen'; |
| 788 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 788 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
| 789 | 789 | $flags = '\\Draft'; |
| 790 | 790 | } else { |
| 791 | 791 | $flags = ''; |
| 792 | 792 | } |
| 793 | 793 | $asf = true; |
| 794 | 794 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 795 | - $this->mail->openConnection(self::$profileID,false); |
|
| 795 | + $this->mail->openConnection(self::$profileID, false); |
|
| 796 | 796 | if ($this->mail->folderExists($folderName)) { |
| 797 | 797 | try |
| 798 | 798 | { |
| 799 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
| 799 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
| 800 | 800 | $flags); |
| 801 | 801 | } |
| 802 | 802 | catch (Api\Exception\WrongUserinput $e) |
| 803 | 803 | { |
| 804 | 804 | //$asf = false; |
| 805 | - 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())); |
|
| 805 | + 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())); |
|
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | else |
| 809 | 809 | { |
| 810 | 810 | //$asf = false; |
| 811 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
| 811 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
| 812 | 812 | } |
| 813 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 813 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
| 814 | 814 | } |
| 815 | 815 | //$this->mail->closeConnection(); |
| 816 | 816 | } |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - $this->debugLevel=0; |
|
| 819 | + $this->debugLevel = 0; |
|
| 820 | 820 | |
| 821 | 821 | if ($send && $asf) |
| 822 | 822 | { |
| 823 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
| 823 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
| 824 | 824 | return true; |
| 825 | 825 | } |
| 826 | 826 | else |
| 827 | 827 | { |
| 828 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
| 829 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 828 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
| 829 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | |
@@ -844,43 +844,43 @@ discard block |
||
| 844 | 844 | public function GetMessage($folderid, $id, $contentparameters) |
| 845 | 845 | { |
| 846 | 846 | //$this->debugLevel=4; |
| 847 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 847 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 848 | 848 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 849 | 849 | $mimesupport = $contentparameters->GetMimeSupport(); |
| 850 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 850 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 851 | 851 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 852 | 852 | |
| 853 | 853 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 854 | 854 | if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
| 855 | 855 | |
| 856 | 856 | //$this->debugLevel=4; |
| 857 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 858 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 857 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 858 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 859 | 859 | $account = $_folderName = $xid = null; |
| 860 | - $this->splitID($folderid,$account,$_folderName,$xid); |
|
| 860 | + $this->splitID($folderid, $account, $_folderName, $xid); |
|
| 861 | 861 | $this->mail->reopen($_folderName); |
| 862 | - $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 862 | + $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 863 | 863 | $headers = $messages[$id]; |
| 864 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 864 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers)); |
|
| 865 | 865 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 866 | 866 | if ($headers) |
| 867 | 867 | { |
| 868 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 868 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 869 | 869 | // initialize the object |
| 870 | 870 | $output = new SyncMail(); |
| 871 | 871 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 872 | 872 | // simple style |
| 873 | 873 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 874 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 874 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 875 | 875 | |
| 876 | 876 | if ($bodypreference === false) { |
| 877 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
| 878 | - $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 877 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
| 878 | + $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 879 | 879 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 880 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 880 | + if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 881 | 881 | // remove all other html |
| 882 | 882 | $body = strip_tags($raw_body); |
| 883 | - if(strlen($body) > $truncsize) { |
|
| 883 | + if (strlen($body) > $truncsize) { |
|
| 884 | 884 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 885 | 885 | $output->bodytruncated = 1; |
| 886 | 886 | } |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | else // style with bodypreferences |
| 895 | 895 | { |
| 896 | 896 | //Select body type preference |
| 897 | - $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
| 897 | + $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
| 898 | 898 | if ($bodypreference !== false) { |
| 899 | 899 | // bodypreference can occur multiple times |
| 900 | 900 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -908,12 +908,12 @@ discard block |
||
| 908 | 908 | } |
| 909 | 909 | */ |
| 910 | 910 | } |
| 911 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 911 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 912 | 912 | // set the protocoll class |
| 913 | 913 | $output->asbody = new SyncBaseBody(); |
| 914 | 914 | |
| 915 | 915 | // return full mime-message without any (charset) conversation directly as stream |
| 916 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
| 916 | + if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) |
|
| 917 | 917 | { |
| 918 | 918 | //SYNC_BODYPREFERENCE_MIME |
| 919 | 919 | $output->asbody->type = SYNC_BODYPREFERENCE_MIME; |
@@ -922,58 +922,58 @@ discard block |
||
| 922 | 922 | fseek($stream, 0, SEEK_SET); |
| 923 | 923 | $output->asbody->data = $stream; |
| 924 | 924 | $output->asbody->estimatedDataSize = $fstat['size']; |
| 925 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 925 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 926 | 926 | } |
| 927 | 927 | else |
| 928 | 928 | { |
| 929 | 929 | // fetch the body (try to gather data only once) |
| 930 | - $css =''; |
|
| 931 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
| 932 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 933 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 934 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 935 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 930 | + $css = ''; |
|
| 931 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
| 932 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 933 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 934 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
| 935 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 936 | 936 | // may be html |
| 937 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 937 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 938 | 938 | $css = $this->mail->getStyles($bodyStruct); |
| 939 | - $output->nativebodytype=2; |
|
| 939 | + $output->nativebodytype = 2; |
|
| 940 | 940 | } else { |
| 941 | 941 | // plain text Message |
| 942 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 943 | - $output->nativebodytype=1; |
|
| 944 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 945 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 946 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 947 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 942 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 943 | + $output->nativebodytype = 1; |
|
| 944 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 945 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 946 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 947 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 948 | 948 | } |
| 949 | 949 | // whatever format decode (using the correct encoding) |
| 950 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 950 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
| 951 | 951 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 952 | 952 | // prepare plaintextbody |
| 953 | - $plainBody=''; |
|
| 953 | + $plainBody = ''; |
|
| 954 | 954 | if ($output->nativebodytype == 2) |
| 955 | 955 | { |
| 956 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 957 | - if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
| 956 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 957 | + if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
| 958 | 958 | { |
| 959 | 959 | $plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
| 960 | 960 | } |
| 961 | 961 | else |
| 962 | 962 | { |
| 963 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
| 963 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
| 964 | 964 | } |
| 965 | 965 | } |
| 966 | 966 | //if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body); |
| 967 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
| 967 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
| 968 | 968 | // remove all other html |
| 969 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
| 969 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
| 970 | 970 | $plainBody = strip_tags($plainBody); |
| 971 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 971 | + if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 972 | 972 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 973 | 973 | |
| 974 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 974 | + if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
| 975 | 975 | { |
| 976 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 976 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 977 | 977 | // Send HTML if requested and native type was html |
| 978 | 978 | $output->asbody->type = 2; |
| 979 | 979 | $htmlbody = '<html>'. |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | $css. |
| 984 | 984 | '</head>'. |
| 985 | 985 | '<body>'; |
| 986 | - if ($output->nativebodytype==2) |
|
| 986 | + if ($output->nativebodytype == 2) |
|
| 987 | 987 | { |
| 988 | 988 | // as we fetch html, and body is HTML, we may not need to handle this |
| 989 | 989 | $htmlbody .= $body; |
@@ -991,14 +991,14 @@ discard block |
||
| 991 | 991 | else |
| 992 | 992 | { |
| 993 | 993 | // html requested but got only plaintext, so fake html |
| 994 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
| 994 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
| 995 | 995 | } |
| 996 | 996 | $htmlbody .= '</body>'. |
| 997 | 997 | '</html>'; |
| 998 | 998 | |
| 999 | - if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 999 | + if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1000 | 1000 | { |
| 1001 | - $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
| 1001 | + $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
| 1002 | 1002 | $output->asbody->truncated = 1; |
| 1003 | 1003 | } |
| 1004 | 1004 | // output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | else |
| 1010 | 1010 | { |
| 1011 | 1011 | // Send Plaintext as Fallback or if original body is plainttext |
| 1012 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1012 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1013 | 1013 | /* we use plainBody (set above) instead |
| 1014 | 1014 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1015 | 1015 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | */ |
| 1020 | 1020 | $output->asbody->type = 1; |
| 1021 | 1021 | $output->nativebodytype = 1; |
| 1022 | - if(isset($truncsize) && |
|
| 1022 | + if (isset($truncsize) && |
|
| 1023 | 1023 | strlen($plainBody) > $truncsize) |
| 1024 | 1024 | { |
| 1025 | 1025 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | } |
| 1039 | 1039 | } |
| 1040 | 1040 | // end AS12 Stuff |
| 1041 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1041 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1042 | 1042 | $output->read = $headers["flags"]; |
| 1043 | 1043 | |
| 1044 | 1044 | $output->flag = new SyncMailFlags(); |
@@ -1058,9 +1058,8 @@ discard block |
||
| 1058 | 1058 | $output->lastverexecuted = AS_FORWARD; |
| 1059 | 1059 | } |
| 1060 | 1060 | $output->subject = $headers['subject']; |
| 1061 | - $output->importance = $headers['priority'] > 3 ? 0 : |
|
| 1062 | - ($headers['priority'] < 3 ? 2 : 1) ; |
|
| 1063 | - $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
|
| 1061 | + $output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1); |
|
| 1062 | + $output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true); |
|
| 1064 | 1063 | $output->to = $headers['to_address']; |
| 1065 | 1064 | if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
| 1066 | 1065 | $output->from = $headers['sender_address']; |
@@ -1068,8 +1067,8 @@ discard block |
||
| 1068 | 1067 | if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
| 1069 | 1068 | |
| 1070 | 1069 | $output->messageclass = "IPM.Note"; |
| 1071 | - if (stripos($headers['mimetype'],'multipart')!== false && |
|
| 1072 | - stripos($headers['mimetype'],'signed')!== false) |
|
| 1070 | + if (stripos($headers['mimetype'], 'multipart') !== false && |
|
| 1071 | + stripos($headers['mimetype'], 'signed') !== false) |
|
| 1073 | 1072 | { |
| 1074 | 1073 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1075 | 1074 | } |
@@ -1078,20 +1077,20 @@ discard block |
||
| 1078 | 1077 | } |
| 1079 | 1078 | |
| 1080 | 1079 | // start handle Attachments (include text/calendar multipart alternative) |
| 1081 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
| 1080 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
| 1082 | 1081 | // Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
| 1083 | - if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
| 1082 | + if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
| 1084 | 1083 | { |
| 1085 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1084 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1086 | 1085 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1087 | 1086 | foreach ($attachments as $key => $attach) |
| 1088 | 1087 | { |
| 1089 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1088 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1090 | 1089 | |
| 1091 | 1090 | // pass meeting requests to calendar plugin |
| 1092 | 1091 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1093 | 1092 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 1094 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
| 1093 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
| 1095 | 1094 | ($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
| 1096 | 1095 | { |
| 1097 | 1096 | //overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
@@ -1101,7 +1100,7 @@ discard block |
||
| 1101 | 1100 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1102 | 1101 | //$output->messageclass = "IPM.Schedule.Meeting"; |
| 1103 | 1102 | unset($attachment); |
| 1104 | - continue; // do NOT add attachment as attachment |
|
| 1103 | + continue; // do NOT add attachment as attachment |
|
| 1105 | 1104 | } |
| 1106 | 1105 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1107 | 1106 | $attachment = new SyncBaseAttachment(); |
@@ -1109,33 +1108,33 @@ discard block |
||
| 1109 | 1108 | $output->asattachments = array(); |
| 1110 | 1109 | $attachment->estimatedDataSize = $attach['size']; |
| 1111 | 1110 | $attachment->method = 1; |
| 1112 | - $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
| 1111 | + $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
| 1113 | 1112 | } else { |
| 1114 | 1113 | $attachment = new SyncAttachment(); |
| 1115 | 1114 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1116 | 1115 | $output->attachments = array(); |
| 1117 | 1116 | $attachment->attsize = $attach['size']; |
| 1118 | 1117 | $attachment->attmethod = 1; |
| 1119 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
| 1118 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
| 1120 | 1119 | } |
| 1121 | 1120 | |
| 1122 | 1121 | $attachment->displayname = $attach['name']; |
| 1123 | 1122 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
| 1124 | 1123 | |
| 1125 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1124 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1126 | 1125 | //$attachment->isinline=0; // if not inline, do not use isinline |
| 1127 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
| 1126 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
| 1128 | 1127 | { |
| 1129 | 1128 | if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
| 1130 | 1129 | { |
| 1131 | 1130 | $attachment->isinline = true; |
| 1132 | 1131 | } |
| 1133 | 1132 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1134 | - $attachment->method=1; |
|
| 1135 | - $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
| 1133 | + $attachment->method = 1; |
|
| 1134 | + $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1136 | 1135 | } else { |
| 1137 | - $attachment->attmethod=6; |
|
| 1138 | - $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
| 1136 | + $attachment->attmethod = 6; |
|
| 1137 | + $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1139 | 1138 | } |
| 1140 | 1139 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1141 | 1140 | $attachment->contenttype = trim($attach['mimeType']); |
@@ -1156,7 +1155,7 @@ discard block |
||
| 1156 | 1155 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1157 | 1156 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1158 | 1157 | |
| 1159 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1158 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
| 1160 | 1159 | //$this->debugLevel=0; |
| 1161 | 1160 | return $output; |
| 1162 | 1161 | } |
@@ -1179,30 +1178,30 @@ discard block |
||
| 1179 | 1178 | { |
| 1180 | 1179 | if (!class_exists('calendar_zpush')) |
| 1181 | 1180 | { |
| 1182 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1181 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1183 | 1182 | return null; |
| 1184 | 1183 | } |
| 1185 | 1184 | if (!($stat = $this->StatMessage($folderid, $requestid))) |
| 1186 | 1185 | { |
| 1187 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1186 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1188 | 1187 | return false; |
| 1189 | 1188 | } |
| 1190 | 1189 | $ret = false; |
| 1191 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
| 1190 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
| 1192 | 1191 | { |
| 1193 | 1192 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1194 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
| 1193 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
| 1195 | 1194 | { |
| 1196 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1195 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1197 | 1196 | |
| 1198 | 1197 | // calling backend again with iCal attachment, to let calendar add the event |
| 1199 | 1198 | $ret = $this->backend->MeetingResponse($attachment['attachment'], |
| 1200 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
| 1199 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
| 1201 | 1200 | $response); |
| 1202 | 1201 | break; |
| 1203 | 1202 | } |
| 1204 | 1203 | } |
| 1205 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1204 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1206 | 1205 | return $ret; |
| 1207 | 1206 | } |
| 1208 | 1207 | |
@@ -1216,9 +1215,9 @@ discard block |
||
| 1216 | 1215 | * @param string $attname - should contain (folder)id |
| 1217 | 1216 | * @return SyncItemOperationsAttachment-object |
| 1218 | 1217 | */ |
| 1219 | - function GetAttachmentData($fid,$attname) { |
|
| 1220 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1221 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1218 | + function GetAttachmentData($fid, $attname) { |
|
| 1219 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1220 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1222 | 1221 | } |
| 1223 | 1222 | |
| 1224 | 1223 | /** |
@@ -1231,9 +1230,9 @@ discard block |
||
| 1231 | 1230 | * @param string $attname - should contain (folder)id |
| 1232 | 1231 | * @return SyncItemOperationsAttachment-object |
| 1233 | 1232 | */ |
| 1234 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1235 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1236 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1233 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
| 1234 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1235 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1237 | 1236 | } |
| 1238 | 1237 | |
| 1239 | 1238 | /** |
@@ -1245,23 +1244,23 @@ discard block |
||
| 1245 | 1244 | * @param string $attname - should contain (folder)id |
| 1246 | 1245 | * @return SyncItemOperationsAttachment-object |
| 1247 | 1246 | */ |
| 1248 | - private function _GetAttachmentData($fid,$attname) |
|
| 1247 | + private function _GetAttachmentData($fid, $attname) |
|
| 1249 | 1248 | { |
| 1250 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1249 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1251 | 1250 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1252 | 1251 | list($folderid, $id, $part) = explode(":", $attname); |
| 1253 | 1252 | |
| 1254 | 1253 | $this->splitID($folderid, $account, $folder); |
| 1255 | 1254 | |
| 1256 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1255 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1257 | 1256 | |
| 1258 | 1257 | $this->mail->reopen($folder); |
| 1259 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
| 1258 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
| 1260 | 1259 | $SIOattachment = new SyncItemOperationsAttachment(); |
| 1261 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1260 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1262 | 1261 | $SIOattachment->data = $attachment['attachment']; |
| 1263 | 1262 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1264 | - if (isset($attachment['type']) ) |
|
| 1263 | + if (isset($attachment['type'])) |
|
| 1265 | 1264 | $SIOattachment->contenttype = $attachment['type']; |
| 1266 | 1265 | |
| 1267 | 1266 | unset($attachment); |
@@ -1304,17 +1303,17 @@ discard block |
||
| 1304 | 1303 | */ |
| 1305 | 1304 | function ChangeMessage($folderid, $id, $message, $contentParameters) |
| 1306 | 1305 | { |
| 1307 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1306 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1308 | 1307 | //unset($folderid, $id, $message, $contentParameters); |
| 1309 | 1308 | $account = $folder = null; |
| 1310 | 1309 | $this->splitID($folderid, $account, $folder); |
| 1311 | 1310 | if (isset($message->flag)) { |
| 1312 | 1311 | if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
| 1313 | - $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
| 1314 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1312 | + $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
| 1313 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1315 | 1314 | } else { |
| 1316 | - $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
| 1317 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
| 1315 | + $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
| 1316 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
| 1318 | 1317 | } |
| 1319 | 1318 | } |
| 1320 | 1319 | return $this->StatMessage($folderid, $id); |
@@ -1336,23 +1335,23 @@ discard block |
||
| 1336 | 1335 | */ |
| 1337 | 1336 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
| 1338 | 1337 | { |
| 1339 | - unset($contentParameters); // not used, but required by function signature |
|
| 1338 | + unset($contentParameters); // not used, but required by function signature |
|
| 1340 | 1339 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
| 1341 | 1340 | $account = $srcFolder = $destFolder = null; |
| 1342 | 1341 | $this->splitID($folderid, $account, $srcFolder); |
| 1343 | 1342 | $this->splitID($newfolderid, $account, $destFolder); |
| 1344 | 1343 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1345 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1344 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1346 | 1345 | $this->mail->reopen($destFolder); |
| 1347 | 1346 | $status = $this->mail->getFolderStatus($destFolder); |
| 1348 | 1347 | $uidNext = $status['uidnext']; |
| 1349 | 1348 | $this->mail->reopen($srcFolder); |
| 1350 | 1349 | |
| 1351 | 1350 | // move message |
| 1352 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
| 1353 | - 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 |
|
| 1351 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
| 1352 | + 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 |
|
| 1354 | 1353 | // return the new id "as string" |
| 1355 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
| 1354 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
| 1356 | 1355 | } |
| 1357 | 1356 | |
| 1358 | 1357 | /** |
@@ -1360,7 +1359,7 @@ discard block |
||
| 1360 | 1359 | * |
| 1361 | 1360 | * @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks |
| 1362 | 1361 | */ |
| 1363 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
| 1362 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
| 1364 | 1363 | { |
| 1365 | 1364 | if ($cutoffdate > 0) |
| 1366 | 1365 | { |
@@ -1373,8 +1372,8 @@ discard block |
||
| 1373 | 1372 | { |
| 1374 | 1373 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1375 | 1374 | } |
| 1376 | - $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
|
| 1377 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1375 | + $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null); |
|
| 1376 | + if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1378 | 1377 | } |
| 1379 | 1378 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1380 | 1379 | } |
@@ -1392,11 +1391,11 @@ discard block |
||
| 1392 | 1391 | * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject" |
| 1393 | 1392 | * @return array uid => array StatMessage($folderid, $_id) |
| 1394 | 1393 | */ |
| 1395 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false) |
|
| 1394 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false) |
|
| 1396 | 1395 | { |
| 1397 | 1396 | static $headers = array(); |
| 1398 | 1397 | |
| 1399 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1398 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
| 1400 | 1399 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1401 | 1400 | $rv_messages = array(); |
| 1402 | 1401 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1407,64 +1406,64 @@ discard block |
||
| 1407 | 1406 | } |
| 1408 | 1407 | else |
| 1409 | 1408 | { |
| 1410 | - $headers = array(); // clear cache to not use too much memory |
|
| 1409 | + $headers = array(); // clear cache to not use too much memory |
|
| 1411 | 1410 | |
| 1412 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1411 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1413 | 1412 | $this->_connect($this->account); |
| 1414 | - if ($this->debugLevel>1) |
|
| 1413 | + if ($this->debugLevel > 1) |
|
| 1415 | 1414 | { |
| 1416 | 1415 | $endtime = microtime(true) - $starttime; |
| 1417 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
| 1416 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
| 1418 | 1417 | } |
| 1419 | 1418 | $messagelist = $_filter = array(); |
| 1420 | 1419 | // if not connected, any further action must fail |
| 1421 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1422 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1420 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1421 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1423 | 1422 | $account = $_folderName = $id = null; |
| 1424 | - $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1425 | - if ($this->debugLevel>1) |
|
| 1423 | + $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1424 | + if ($this->debugLevel > 1) |
|
| 1426 | 1425 | { |
| 1427 | 1426 | $endtime = microtime(true) - $starttime; |
| 1428 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1427 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1429 | 1428 | } |
| 1430 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1431 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1432 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
| 1433 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
| 1434 | - if ($this->debugLevel>1) |
|
| 1429 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1430 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1431 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
| 1432 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
| 1433 | + if ($this->debugLevel > 1) |
|
| 1435 | 1434 | { |
| 1436 | 1435 | $endtime = microtime(true) - $starttime; |
| 1437 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1436 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1438 | 1437 | } |
| 1439 | 1438 | } |
| 1440 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1439 | + if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
| 1441 | 1440 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1442 | 1441 | $messagelist = array(); |
| 1443 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1442 | + if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
| 1444 | 1443 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1445 | 1444 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1446 | 1445 | { |
| 1447 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1446 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1448 | 1447 | $headers[$vars['uid']] = $vars; |
| 1449 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1448 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1450 | 1449 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
| 1451 | 1450 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
| 1452 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1451 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1453 | 1452 | $mess = $return_all_headers ? $vars : array(); |
| 1454 | 1453 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1455 | 1454 | $mess["id"] = $vars['uid']; |
| 1456 | 1455 | // 'seen' aka 'read' is the only flag we want to know about |
| 1457 | 1456 | $mess["flags"] = 0; |
| 1458 | 1457 | // outlook supports additional flags, set them to 0 |
| 1459 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1460 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1458 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
| 1459 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
| 1461 | 1460 | $messagelist[$vars['uid']] = $mess; |
| 1462 | 1461 | unset($mess); |
| 1463 | 1462 | } |
| 1464 | - if ($this->debugLevel>1) |
|
| 1463 | + if ($this->debugLevel > 1) |
|
| 1465 | 1464 | { |
| 1466 | 1465 | $endtime = microtime(true) - $gstarttime; |
| 1467 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1466 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1468 | 1467 | } |
| 1469 | 1468 | return $messagelist; |
| 1470 | 1469 | } |
@@ -1515,32 +1514,32 @@ discard block |
||
| 1515 | 1514 | public function getSearchResultsMailbox($_searchquery) |
| 1516 | 1515 | { |
| 1517 | 1516 | //$this->debugLevel=1; |
| 1518 | - $searchquery=$_searchquery->GetDataArray(); |
|
| 1517 | + $searchquery = $_searchquery->GetDataArray(); |
|
| 1519 | 1518 | if (!is_array($searchquery)) return array(); |
| 1520 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1519 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
| 1521 | 1520 | |
| 1522 | 1521 | if (isset($searchquery['searchrebuildresults'])) { |
| 1523 | 1522 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1524 | 1523 | } else { |
| 1525 | 1524 | $rebuildresults = false; |
| 1526 | 1525 | } |
| 1527 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1526 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']'); |
|
| 1528 | 1527 | |
| 1529 | 1528 | if (isset($searchquery['deeptraversal'])) { |
| 1530 | 1529 | $deeptraversal = $searchquery['deeptraversal']; |
| 1531 | 1530 | } else { |
| 1532 | 1531 | $deeptraversal = false; |
| 1533 | 1532 | } |
| 1534 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1533 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']'); |
|
| 1535 | 1534 | |
| 1536 | 1535 | if (isset($searchquery['searchrange'])) { |
| 1537 | - $range = explode("-",$_searchquery->GetSearchRange()); |
|
| 1538 | - $start =$range[0] + 1; |
|
| 1536 | + $range = explode("-", $_searchquery->GetSearchRange()); |
|
| 1537 | + $start = $range[0] + 1; |
|
| 1539 | 1538 | $limit = $range[1] - $range[0] + 1; |
| 1540 | 1539 | } else { |
| 1541 | 1540 | $range = false; |
| 1542 | 1541 | } |
| 1543 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1542 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']'); |
|
| 1544 | 1543 | |
| 1545 | 1544 | //foreach($searchquery['query'] as $k => $value) { |
| 1546 | 1545 | // $query = $value; |
@@ -1563,15 +1562,15 @@ discard block |
||
| 1563 | 1562 | } |
| 1564 | 1563 | if (!$folderid) |
| 1565 | 1564 | { |
| 1566 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
| 1567 | - $folderid = $this->createID($account=0,$_folderName); |
|
| 1565 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
| 1566 | + $folderid = $this->createID($account = 0, $_folderName); |
|
| 1568 | 1567 | } |
| 1569 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1570 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1568 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1569 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1571 | 1570 | $this->_connect($account); |
| 1572 | 1571 | // this should not be needed ??? |
| 1573 | - Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
| 1574 | - $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
| 1572 | + Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
| 1573 | + $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
| 1575 | 1574 | 'string'=> $searchText, |
| 1576 | 1575 | 'status'=>'any' |
| 1577 | 1576 | ); |
@@ -1586,22 +1585,22 @@ discard block |
||
| 1586 | 1585 | * [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
| 1587 | 1586 | */ |
| 1588 | 1587 | $_filter['range'] = "BETWEEN"; |
| 1589 | - list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
| 1590 | - list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
| 1591 | - $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
| 1592 | - $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
| 1588 | + list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
| 1589 | + list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
| 1590 | + $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
| 1591 | + $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
| 1593 | 1592 | } |
| 1594 | 1593 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1595 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1596 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
| 1594 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1595 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
| 1597 | 1596 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1598 | - $list=array(); |
|
| 1597 | + $list = array(); |
|
| 1599 | 1598 | |
| 1600 | 1599 | $cnt = count($rv_messages['header']); |
| 1601 | 1600 | //$list['status'] = 1; |
| 1602 | 1601 | $list['searchtotal'] = $cnt; |
| 1603 | 1602 | $list["range"] = $_searchquery->GetSearchRange(); |
| 1604 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
| 1603 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
| 1605 | 1604 | { |
| 1606 | 1605 | $list[] = array( |
| 1607 | 1606 | "class" => "Email", |
@@ -1621,20 +1620,20 @@ discard block |
||
| 1621 | 1620 | * @param string $folder |
| 1622 | 1621 | * @return string |
| 1623 | 1622 | */ |
| 1624 | - private function getParentID($account,$folder) |
|
| 1623 | + private function getParentID($account, $folder) |
|
| 1625 | 1624 | { |
| 1626 | 1625 | $this->_connect($account); |
| 1627 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1626 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1628 | 1627 | |
| 1629 | 1628 | $mailFolder = $this->folders[$folder]; |
| 1630 | 1629 | if (!isset($mailFolder)) return false; |
| 1631 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
| 1632 | - $parent = explode($delimiter,$folder); |
|
| 1630 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
| 1631 | + $parent = explode($delimiter, $folder); |
|
| 1633 | 1632 | array_pop($parent); |
| 1634 | - $parent = implode($delimiter,$parent); |
|
| 1633 | + $parent = implode($delimiter, $parent); |
|
| 1635 | 1634 | |
| 1636 | 1635 | $id = $parent ? $this->createID($account, $parent) : '0'; |
| 1637 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1636 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1638 | 1637 | return $id; |
| 1639 | 1638 | } |
| 1640 | 1639 | |
@@ -1654,48 +1653,48 @@ discard block |
||
| 1654 | 1653 | $account = $folder = null; |
| 1655 | 1654 | $this->splitID($id, $account, $folder); |
| 1656 | 1655 | } |
| 1657 | - catch(Exception $e) { |
|
| 1658 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1659 | - return $folderObj=false; |
|
| 1656 | + catch (Exception $e) { |
|
| 1657 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1658 | + return $folderObj = false; |
|
| 1660 | 1659 | } |
| 1661 | 1660 | $this->_connect($account); |
| 1662 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1661 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1663 | 1662 | |
| 1664 | 1663 | $mailFolder = $this->folders[$folder]; |
| 1665 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 1664 | + if (!isset($mailFolder)) return $folderObj = false; |
|
| 1666 | 1665 | |
| 1667 | 1666 | $folderObj = new SyncFolder(); |
| 1668 | 1667 | $folderObj->serverid = $id; |
| 1669 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
| 1668 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
| 1670 | 1669 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1671 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1670 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1672 | 1671 | // get folder-type |
| 1673 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 1672 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
| 1674 | 1673 | if ($folder == $inbox) |
| 1675 | 1674 | { |
| 1676 | 1675 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
| 1677 | 1676 | } |
| 1678 | - elseif($this->mail->isDraftFolder($folder, false, true)) |
|
| 1677 | + elseif ($this->mail->isDraftFolder($folder, false, true)) |
|
| 1679 | 1678 | { |
| 1680 | 1679 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
| 1681 | 1680 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
| 1682 | 1681 | $folderObj->parentid = 0; // required by devices |
| 1683 | 1682 | } |
| 1684 | - elseif($this->mail->isTrashFolder($folder, false, true)) |
|
| 1683 | + elseif ($this->mail->isTrashFolder($folder, false, true)) |
|
| 1685 | 1684 | { |
| 1686 | 1685 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
| 1687 | 1686 | $this->_wasteID = $folder; |
| 1688 | 1687 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
| 1689 | 1688 | $folderObj->parentid = 0; // required by devices |
| 1690 | 1689 | } |
| 1691 | - elseif($this->mail->isSentFolder($folder, false, true)) |
|
| 1690 | + elseif ($this->mail->isSentFolder($folder, false, true)) |
|
| 1692 | 1691 | { |
| 1693 | 1692 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
| 1694 | 1693 | $folderObj->parentid = 0; // required by devices |
| 1695 | 1694 | $this->_sentID = $folder; |
| 1696 | 1695 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
| 1697 | 1696 | } |
| 1698 | - elseif($this->mail->isOutbox($folder, false, true)) |
|
| 1697 | + elseif ($this->mail->isOutbox($folder, false, true)) |
|
| 1699 | 1698 | { |
| 1700 | 1699 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
| 1701 | 1700 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1707,7 +1706,7 @@ discard block |
||
| 1707 | 1706 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1708 | 1707 | } |
| 1709 | 1708 | |
| 1710 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1709 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1711 | 1710 | return $folderObj; |
| 1712 | 1711 | } |
| 1713 | 1712 | |
@@ -1755,18 +1754,18 @@ discard block |
||
| 1755 | 1754 | |
| 1756 | 1755 | if ($type != 'mail') return false; |
| 1757 | 1756 | |
| 1758 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1757 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1759 | 1758 | |
| 1760 | 1759 | $this->mail->reopen($folder); |
| 1761 | 1760 | |
| 1762 | - if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true))) |
|
| 1761 | + if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true))) |
|
| 1763 | 1762 | { |
| 1764 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
| 1763 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
| 1765 | 1764 | return false; |
| 1766 | 1765 | } |
| 1767 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1766 | + $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1768 | 1767 | |
| 1769 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1768 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1770 | 1769 | return array(); |
| 1771 | 1770 | } |
| 1772 | 1771 | |
@@ -1779,8 +1778,8 @@ discard block |
||
| 1779 | 1778 | function GetWasteBasket() |
| 1780 | 1779 | { |
| 1781 | 1780 | $this->_connect($this->account); |
| 1782 | - $id = $this->createID($account=0, $this->_wasteID); |
|
| 1783 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1781 | + $id = $this->createID($account = 0, $this->_wasteID); |
|
| 1782 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1784 | 1783 | return $id; |
| 1785 | 1784 | } |
| 1786 | 1785 | |
@@ -1801,7 +1800,7 @@ discard block |
||
| 1801 | 1800 | */ |
| 1802 | 1801 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1803 | 1802 | { |
| 1804 | - unset($contentParameters); // not used, but required by function signature |
|
| 1803 | + unset($contentParameters); // not used, but required by function signature |
|
| 1805 | 1804 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1806 | 1805 | /* |
| 1807 | 1806 | $this->imap_reopenFolder($folderid); |
@@ -1812,7 +1811,7 @@ discard block |
||
| 1812 | 1811 | // we may have to split folderid |
| 1813 | 1812 | $account = $folder = null; |
| 1814 | 1813 | $this->splitID($folderid, $account, $folder); |
| 1815 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1814 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1816 | 1815 | $_messageUID = (array)$id; |
| 1817 | 1816 | |
| 1818 | 1817 | $this->_connect($this->account); |
@@ -1824,9 +1823,9 @@ discard block |
||
| 1824 | 1823 | catch (Api\Exception $e) |
| 1825 | 1824 | { |
| 1826 | 1825 | $error = $e->getMessage(); |
| 1827 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1826 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1828 | 1827 | // if the server thinks the message does not exist report deletion as success |
| 1829 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 1828 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
| 1830 | 1829 | return false; |
| 1831 | 1830 | } |
| 1832 | 1831 | |
@@ -1860,15 +1859,15 @@ discard block |
||
| 1860 | 1859 | */ |
| 1861 | 1860 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1862 | 1861 | { |
| 1863 | - unset($contentParameters); // not used, but required by function signature |
|
| 1862 | + unset($contentParameters); // not used, but required by function signature |
|
| 1864 | 1863 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1865 | 1864 | $account = $folder = null; |
| 1866 | 1865 | $this->splitID($folderid, $account, $folder); |
| 1867 | 1866 | |
| 1868 | 1867 | $_messageUID = (array)$id; |
| 1869 | 1868 | $this->_connect($this->account); |
| 1870 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
| 1871 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
| 1869 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
| 1870 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
| 1872 | 1871 | |
| 1873 | 1872 | return $rv; |
| 1874 | 1873 | } |
@@ -1885,7 +1884,7 @@ discard block |
||
| 1885 | 1884 | */ |
| 1886 | 1885 | public function ChangeFolder($id, $oldid, $displayname, $type) |
| 1887 | 1886 | { |
| 1888 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!"); |
|
| 1887 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!"); |
|
| 1889 | 1888 | return false; |
| 1890 | 1889 | } |
| 1891 | 1890 | |
@@ -1900,7 +1899,7 @@ discard block |
||
| 1900 | 1899 | */ |
| 1901 | 1900 | public function DeleteFolder($parentid, $id) |
| 1902 | 1901 | { |
| 1903 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$parentid', '$id') NOT supported!"); |
|
| 1902 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$parentid', '$id') NOT supported!"); |
|
| 1904 | 1903 | return false; |
| 1905 | 1904 | } |
| 1906 | 1905 | |
@@ -1920,8 +1919,8 @@ discard block |
||
| 1920 | 1919 | $this->_connect($this->account); |
| 1921 | 1920 | $account = $folder = null; |
| 1922 | 1921 | $this->splitID($folderid, $account, $folder); |
| 1923 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
| 1924 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1922 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
| 1923 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1925 | 1924 | |
| 1926 | 1925 | return $rv; |
| 1927 | 1926 | } |
@@ -1935,17 +1934,17 @@ discard block |
||
| 1935 | 1934 | * @return string |
| 1936 | 1935 | * @throws Api\Exception\WrongParameter |
| 1937 | 1936 | */ |
| 1938 | - private function createID($account,$folder,$id=0) |
|
| 1937 | + private function createID($account, $folder, $id = 0) |
|
| 1939 | 1938 | { |
| 1940 | 1939 | if (!is_numeric($folder)) |
| 1941 | 1940 | { |
| 1942 | 1941 | // convert string $folder in numeric id |
| 1943 | - $folder = $this->folder2hash($account,$f=$folder); |
|
| 1942 | + $folder = $this->folder2hash($account, $f = $folder); |
|
| 1944 | 1943 | } |
| 1945 | 1944 | |
| 1946 | 1945 | $str = $this->backend->createID($account, $folder, $id); |
| 1947 | 1946 | |
| 1948 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 1947 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 1949 | 1948 | |
| 1950 | 1949 | return $str; |
| 1951 | 1950 | } |
@@ -1959,14 +1958,14 @@ discard block |
||
| 1959 | 1958 | * @param int &$id=null |
| 1960 | 1959 | * @throws Api\Exception\WrongParameter |
| 1961 | 1960 | */ |
| 1962 | - private function splitID($str,&$account,&$folder,&$id=null) |
|
| 1961 | + private function splitID($str, &$account, &$folder, &$id = null) |
|
| 1963 | 1962 | { |
| 1964 | 1963 | $this->backend->splitID($str, $account, $folder, $id); |
| 1965 | 1964 | |
| 1966 | 1965 | // convert numeric folder-id back to folder name |
| 1967 | - $folder = $this->hash2folder($account,$f=$folder); |
|
| 1966 | + $folder = $this->hash2folder($account, $f = $folder); |
|
| 1968 | 1967 | |
| 1969 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
| 1968 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$id)"); |
|
| 1970 | 1969 | } |
| 1971 | 1970 | |
| 1972 | 1971 | /** |
@@ -1983,9 +1982,9 @@ discard block |
||
| 1983 | 1982 | * @param string $folder |
| 1984 | 1983 | * @return int |
| 1985 | 1984 | */ |
| 1986 | - private function folder2hash($account,$folder) |
|
| 1985 | + private function folder2hash($account, $folder) |
|
| 1987 | 1986 | { |
| 1988 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 1987 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 1989 | 1988 | |
| 1990 | 1989 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 1991 | 1990 | { |
@@ -2006,9 +2005,9 @@ discard block |
||
| 2006 | 2005 | * @param int $index |
| 2007 | 2006 | * @return string NULL if not used so far |
| 2008 | 2007 | */ |
| 2009 | - private function hash2folder($account,$index) |
|
| 2008 | + private function hash2folder($account, $index) |
|
| 2010 | 2009 | { |
| 2011 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2010 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2012 | 2011 | |
| 2013 | 2012 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2014 | 2013 | } |
@@ -2045,9 +2044,9 @@ discard block |
||
| 2045 | 2044 | if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
| 2046 | 2045 | ($hashes = file_get_contents($file))) |
| 2047 | 2046 | { |
| 2048 | - $this->folderHashes = json_decode($hashes,true); |
|
| 2047 | + $this->folderHashes = json_decode($hashes, true); |
|
| 2049 | 2048 | // fallback in case hashes have been serialized instead of being json-encoded |
| 2050 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
| 2049 | + if (json_last_error() != JSON_ERROR_NONE) |
|
| 2051 | 2050 | { |
| 2052 | 2051 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
| 2053 | 2052 | $this->folderHashes = unserialize($hashes); |
@@ -2093,9 +2092,9 @@ discard block |
||
| 2093 | 2092 | * @param boolean $old =false true: return old / pre-15 hash-file |
| 2094 | 2093 | * @throws Api\Exception\AssertionFailed |
| 2095 | 2094 | */ |
| 2096 | - private function hashFile($old=false) |
|
| 2095 | + private function hashFile($old = false) |
|
| 2097 | 2096 | { |
| 2098 | - if (!($dev_id=Request::GetDeviceID())) |
|
| 2097 | + if (!($dev_id = Request::GetDeviceID())) |
|
| 2099 | 2098 | { |
| 2100 | 2099 | throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
| 2101 | 2100 | } |
@@ -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 | |
@@ -229,8 +253,14 @@ discard block |
||
| 229 | 253 | $this->_connect(0,true); |
| 230 | 254 | $this->_disconnect(); |
| 231 | 255 | |
| 232 | - if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 233 | - if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 256 | + if (!$this->_wasteID) |
|
| 257 | + { |
|
| 258 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 259 | + } |
|
| 260 | + if (!$this->_sentID) |
|
| 261 | + { |
|
| 262 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 263 | + } |
|
| 234 | 264 | } |
| 235 | 265 | catch(Exception $e) { |
| 236 | 266 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
@@ -252,8 +282,14 @@ discard block |
||
| 252 | 282 | */ |
| 253 | 283 | private function _connect($account=0) |
| 254 | 284 | { |
| 255 | - if (!$account) $account = self::$profileID ? self::$profileID : 0; |
|
| 256 | - if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
| 285 | + if (!$account) |
|
| 286 | + { |
|
| 287 | + $account = self::$profileID ? self::$profileID : 0; |
|
| 288 | + } |
|
| 289 | + if ($this->mail && $this->account != $account) |
|
| 290 | + { |
|
| 291 | + $this->_disconnect(); |
|
| 292 | + } |
|
| 257 | 293 | |
| 258 | 294 | $this->_wasteID = false; |
| 259 | 295 | $this->_sentID = false; |
@@ -264,12 +300,18 @@ discard block |
||
| 264 | 300 | // todo: tell mail which account to use |
| 265 | 301 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 266 | 302 | $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
| 267 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 303 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 304 | + { |
|
| 305 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 306 | + } |
|
| 268 | 307 | } |
| 269 | 308 | else |
| 270 | 309 | { |
| 271 | 310 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 272 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 311 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 312 | + { |
|
| 313 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 314 | + } |
|
| 273 | 315 | } |
| 274 | 316 | $this->mail->openConnection(self::$profileID,false); |
| 275 | 317 | |
@@ -286,8 +328,14 @@ discard block |
||
| 286 | 328 | */ |
| 287 | 329 | private function _disconnect() |
| 288 | 330 | { |
| 289 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 290 | - if ($this->mail) $this->mail->closeConnection(); |
|
| 331 | + if ($this->debugLevel>0) |
|
| 332 | + { |
|
| 333 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 334 | + } |
|
| 335 | + if ($this->mail) |
|
| 336 | + { |
|
| 337 | + $this->mail->closeConnection(); |
|
| 338 | + } |
|
| 291 | 339 | |
| 292 | 340 | unset($this->mail); |
| 293 | 341 | unset($this->account); |
@@ -302,24 +350,43 @@ discard block |
||
| 302 | 350 | public function GetFolderList() |
| 303 | 351 | { |
| 304 | 352 | $folderlist = array(); |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 353 | + if ($this->debugLevel>0) |
|
| 354 | + { |
|
| 355 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 356 | + } |
|
| 306 | 357 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 307 | 358 | { |
| 308 | 359 | $this->_connect($account); |
| 309 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 310 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 360 | + if (!isset($this->folders)) |
|
| 361 | + { |
|
| 362 | + $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 363 | + } |
|
| 364 | + if ($this->debugLevel>1) |
|
| 365 | + { |
|
| 366 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 367 | + } |
|
| 311 | 368 | |
| 312 | - foreach ($this->folders as $folder => $folderObj) { |
|
| 313 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 369 | + foreach ($this->folders as $folder => $folderObj) |
|
| 370 | + { |
|
| 371 | + if ($this->debugLevel>1) |
|
| 372 | + { |
|
| 373 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 374 | + } |
|
| 314 | 375 | $folderlist[] = $f = array( |
| 315 | 376 | 'id' => $this->createID($account,$folder), |
| 316 | 377 | 'mod' => $folderObj->shortDisplayName, |
| 317 | 378 | 'parent' => $this->getParentID($account,$folder), |
| 318 | 379 | ); |
| 319 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 380 | + if ($this->debugLevel>1) |
|
| 381 | + { |
|
| 382 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 383 | + } |
|
| 320 | 384 | } |
| 321 | 385 | } |
| 322 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 386 | + if ($this->debugLevel>0) |
|
| 387 | + { |
|
| 388 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 389 | + } |
|
| 323 | 390 | |
| 324 | 391 | return $folderlist; |
| 325 | 392 | } |
@@ -380,11 +447,17 @@ discard block |
||
| 380 | 447 | $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
| 381 | 448 | |
| 382 | 449 | 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 : "")); |
| 383 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 450 | + if ($this->debugLevel>0) |
|
| 451 | + { |
|
| 452 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 453 | + } |
|
| 384 | 454 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 385 | 455 | |
| 386 | 456 | // initialize our Mail |
| 387 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 457 | + if (!isset($this->mail)) |
|
| 458 | + { |
|
| 459 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 460 | + } |
|
| 388 | 461 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 389 | 462 | // use the standardIdentity |
| 390 | 463 | $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
@@ -403,22 +476,34 @@ discard block |
||
| 403 | 476 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 404 | 477 | // to |
| 405 | 478 | |
| 406 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 407 | - if (!$addressObject->valid) continue; |
|
| 479 | + foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) |
|
| 480 | + { |
|
| 481 | + if (!$addressObject->valid) |
|
| 482 | + { |
|
| 483 | + continue; |
|
| 484 | + } |
|
| 408 | 485 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
| 409 | 486 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 410 | 487 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 411 | 488 | } |
| 412 | 489 | // CC |
| 413 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 414 | - if (!$addressObject->valid) continue; |
|
| 490 | + foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) |
|
| 491 | + { |
|
| 492 | + if (!$addressObject->valid) |
|
| 493 | + { |
|
| 494 | + continue; |
|
| 495 | + } |
|
| 415 | 496 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
| 416 | 497 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 417 | 498 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 418 | 499 | } |
| 419 | 500 | // BCC |
| 420 | - foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 421 | - if (!$addressObject->valid) continue; |
|
| 501 | + foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) |
|
| 502 | + { |
|
| 503 | + if (!$addressObject->valid) |
|
| 504 | + { |
|
| 505 | + continue; |
|
| 506 | + } |
|
| 422 | 507 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
| 423 | 508 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 424 | 509 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
@@ -431,12 +516,14 @@ discard block |
||
| 431 | 516 | $ContentType =$mailObject->getHeader('Content-Type'); |
| 432 | 517 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 433 | 518 | // if the message is a multipart message, then we should use the sent body |
| 434 | - if (preg_match("/multipart/i", $ContentType)) { |
|
| 519 | + if (preg_match("/multipart/i", $ContentType)) |
|
| 520 | + { |
|
| 435 | 521 | $use_orgbody = true; |
| 436 | 522 | } |
| 437 | 523 | |
| 438 | 524 | // save the original content-type header for the body part when forwarding |
| 439 | - if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) { |
|
| 525 | + if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) |
|
| 526 | + { |
|
| 440 | 527 | //continue; // ignore |
| 441 | 528 | } |
| 442 | 529 | // horde/egw_ mailer does everything as utf-8, the following should not be needed |
@@ -445,7 +532,8 @@ discard block |
||
| 445 | 532 | // if the message is a multipart message, then we should use the sent body |
| 446 | 533 | if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') && |
| 447 | 534 | ((isset($smartdata->replacemime) && $smartdata->replacemime == true) || |
| 448 | - $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
| 535 | + $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) |
|
| 536 | + { |
|
| 449 | 537 | $use_orgbody = true; |
| 450 | 538 | } |
| 451 | 539 | $Body = $AltBody = ""; |
@@ -478,12 +566,19 @@ discard block |
||
| 478 | 566 | $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
| 479 | 567 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 480 | 568 | } |
| 481 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 482 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 569 | + if ($this->debugLevel>1 && $Body) |
|
| 570 | + { |
|
| 571 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 572 | + } |
|
| 573 | + if ($this->debugLevel>1 && $AltBody) |
|
| 574 | + { |
|
| 575 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 576 | + } |
|
| 483 | 577 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 484 | 578 | // if this is a multipart message with a boundary, we must use the original body |
| 485 | 579 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 486 | - if ($use_orgbody) { |
|
| 580 | + if ($use_orgbody) |
|
| 581 | + { |
|
| 487 | 582 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
| 488 | 583 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 489 | 584 | if (($cal_body = $mailObject->findBody('calendar')) && |
@@ -493,15 +588,20 @@ discard block |
||
| 493 | 588 | { |
| 494 | 589 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 495 | 590 | } |
| 496 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 591 | + if ($this->debugLevel) |
|
| 592 | + { |
|
| 593 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 594 | + } |
|
| 497 | 595 | $ClientSideMeetingRequest = true; |
| 498 | 596 | } |
| 499 | 597 | } |
| 500 | 598 | // now handle the addressee list |
| 501 | 599 | $toCount = 0; |
| 502 | 600 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 503 | - foreach((array)$toMailAddr as $address) { |
|
| 504 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 601 | + foreach((array)$toMailAddr as $address) |
|
| 602 | + { |
|
| 603 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 604 | + { |
|
| 505 | 605 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 506 | 606 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 507 | 607 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
@@ -515,19 +615,29 @@ discard block |
||
| 515 | 615 | } |
| 516 | 616 | } |
| 517 | 617 | $ccCount = 0; |
| 518 | - foreach((array)$ccMailAddr as $address) { |
|
| 519 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 618 | + foreach((array)$ccMailAddr as $address) |
|
| 619 | + { |
|
| 620 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 621 | + { |
|
| 520 | 622 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 521 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 623 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 624 | + { |
|
| 625 | + continue; |
|
| 626 | + } |
|
| 522 | 627 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 523 | 628 | $ccCount++; |
| 524 | 629 | } |
| 525 | 630 | } |
| 526 | 631 | $bccCount = 0; |
| 527 | - foreach((array)$bccMailAddr as $address) { |
|
| 528 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 632 | + foreach((array)$bccMailAddr as $address) |
|
| 633 | + { |
|
| 634 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 635 | + { |
|
| 529 | 636 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 530 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 637 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 638 | + { |
|
| 639 | + continue; |
|
| 640 | + } |
|
| 531 | 641 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 532 | 642 | $bccCount++; |
| 533 | 643 | } |
@@ -537,7 +647,10 @@ discard block |
||
| 537 | 647 | { |
| 538 | 648 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 539 | 649 | } |
| 540 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 650 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) |
|
| 651 | + { |
|
| 652 | + return true; |
|
| 653 | + } |
|
| 541 | 654 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 542 | 655 | /* |
| 543 | 656 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -567,7 +680,10 @@ discard block |
||
| 567 | 680 | $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
| 568 | 681 | $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 569 | 682 | $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
| 570 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 683 | + if ($this->debugLevel>0) |
|
| 684 | + { |
|
| 685 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 686 | + } |
|
| 571 | 687 | $sigTextHtml = $beforeHtml.$sigText; |
| 572 | 688 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 573 | 689 | $isreply = $isforward = false; |
@@ -585,10 +701,17 @@ discard block |
||
| 585 | 701 | $this->mail->reopen($folder); |
| 586 | 702 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 587 | 703 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 588 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 589 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 704 | + if ($this->debugLevel>3) |
|
| 705 | + { |
|
| 706 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 707 | + } |
|
| 708 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 709 | + { |
|
| 590 | 710 | // may be html |
| 591 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 711 | + if ($this->debugLevel>0) |
|
| 712 | + { |
|
| 713 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 714 | + } |
|
| 592 | 715 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 593 | 716 | $isreply = true; |
| 594 | 717 | } |
@@ -597,8 +720,12 @@ discard block |
||
| 597 | 720 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 598 | 721 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 599 | 722 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 600 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 601 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 723 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 724 | + { |
|
| 725 | + if ($this->debugLevel>0) |
|
| 726 | + { |
|
| 727 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 728 | + } |
|
| 602 | 729 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 603 | 730 | $isreply = true; |
| 604 | 731 | } |
@@ -606,7 +733,10 @@ discard block |
||
| 606 | 733 | { |
| 607 | 734 | $isreply = true; |
| 608 | 735 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 609 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 736 | + if ($this->debugLevel>0) |
|
| 737 | + { |
|
| 738 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 739 | + } |
|
| 610 | 740 | } |
| 611 | 741 | } |
| 612 | 742 | |
@@ -620,11 +750,17 @@ discard block |
||
| 620 | 750 | (isset($smartdata->replacemime) && $smartdata->replacemime == false))) |
| 621 | 751 | { |
| 622 | 752 | //force the default for the forwarding -> asmail |
| 623 | - if (is_array($preferencesArray)) { |
|
| 753 | + if (is_array($preferencesArray)) |
|
| 754 | + { |
|
| 624 | 755 | if (!array_key_exists('message_forwarding',$preferencesArray) |
| 625 | 756 | || !isset($preferencesArray['message_forwarding']) |
| 626 | - || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 627 | - } else { |
|
| 757 | + || empty($preferencesArray['message_forwarding'])) |
|
| 758 | + { |
|
| 759 | + $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + else |
|
| 763 | + { |
|
| 628 | 764 | $preferencesArray['message_forwarding'] = 'asmail'; |
| 629 | 765 | } |
| 630 | 766 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
@@ -656,27 +792,44 @@ discard block |
||
| 656 | 792 | $this->mail->reopen($folder); |
| 657 | 793 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 658 | 794 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 659 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 660 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 795 | + if ($this->debugLevel>0) |
|
| 796 | + { |
|
| 797 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 798 | + } |
|
| 799 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 800 | + { |
|
| 661 | 801 | // may be html |
| 662 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 802 | + if ($this->debugLevel>0) |
|
| 803 | + { |
|
| 804 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 805 | + } |
|
| 663 | 806 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 664 | 807 | $isforward = true; |
| 665 | 808 | } |
| 666 | 809 | // plain text Message part |
| 667 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 810 | + if ($this->debugLevel>0) |
|
| 811 | + { |
|
| 812 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 813 | + } |
|
| 668 | 814 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 669 | 815 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 670 | 816 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 671 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 672 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 817 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 818 | + { |
|
| 819 | + if ($this->debugLevel>0) |
|
| 820 | + { |
|
| 821 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 822 | + } |
|
| 673 | 823 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 674 | 824 | $isforward = true; |
| 675 | 825 | } |
| 676 | 826 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 677 | 827 | { |
| 678 | 828 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 679 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 829 | + if ($this->debugLevel>0) |
|
| 830 | + { |
|
| 831 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 832 | + } |
|
| 680 | 833 | $isforward = true; |
| 681 | 834 | } |
| 682 | 835 | // get all the attachments and add them too. |
@@ -689,7 +842,10 @@ discard block |
||
| 689 | 842 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
| 690 | 843 | foreach((array)$attachments as $key => $attachment) |
| 691 | 844 | { |
| 692 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 845 | + if ($this->debugLevel>0) |
|
| 846 | + { |
|
| 847 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 848 | + } |
|
| 693 | 849 | $attachmentNames .= $attachment['name']."\n"; |
| 694 | 850 | $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
| 695 | 851 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
@@ -707,18 +863,27 @@ discard block |
||
| 707 | 863 | // now set the body |
| 708 | 864 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 709 | 865 | { |
| 710 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 866 | + if ($this->debugLevel>1) |
|
| 867 | + { |
|
| 868 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 869 | + } |
|
| 711 | 870 | $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 712 | 871 | } |
| 713 | 872 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 714 | 873 | { |
| 715 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 874 | + if ($this->debugLevel>1) |
|
| 875 | + { |
|
| 876 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 877 | + } |
|
| 716 | 878 | $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 717 | 879 | } |
| 718 | 880 | //advanced debugging |
| 719 | 881 | // Horde SMTP Class uses utf-8 by default. |
| 720 | 882 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 721 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 883 | + if ($this->debugLevel>2) |
|
| 884 | + { |
|
| 885 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 886 | + } |
|
| 722 | 887 | |
| 723 | 888 | // set a higher timeout for big messages |
| 724 | 889 | @set_time_limit(120); |
@@ -745,7 +910,9 @@ discard block |
||
| 745 | 910 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 746 | 911 | { |
| 747 | 912 | $this->mail->deleteMessages(array($uid),$folder); |
| 748 | - } else { |
|
| 913 | + } |
|
| 914 | + else |
|
| 915 | + { |
|
| 749 | 916 | $this->mail->flagMessages("answered", array($uid),$folder); |
| 750 | 917 | if ($smartdata_task== "forward") |
| 751 | 918 | { |
@@ -759,7 +926,8 @@ discard block |
||
| 759 | 926 | { |
| 760 | 927 | $asf = false; |
| 761 | 928 | $sentFolder = $this->mail->getSentFolder(); |
| 762 | - if ($this->_sentID) { |
|
| 929 | + if ($this->_sentID) |
|
| 930 | + { |
|
| 763 | 931 | $folderArray[] = $this->_sentID; |
| 764 | 932 | } |
| 765 | 933 | else if(isset($sentFolder) && $sentFolder != 'none') |
@@ -773,27 +941,40 @@ discard block |
||
| 773 | 941 | // we dont try guessing |
| 774 | 942 | $asf = true; |
| 775 | 943 | } |
| 776 | - if (count($folderArray) > 0) { |
|
| 777 | - foreach((array)$bccMailAddr as $address) { |
|
| 778 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 944 | + if (count($folderArray) > 0) |
|
| 945 | + { |
|
| 946 | + foreach((array)$bccMailAddr as $address) |
|
| 947 | + { |
|
| 948 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 949 | + { |
|
| 779 | 950 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 780 | 951 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 781 | 952 | } |
| 782 | 953 | } |
| 783 | 954 | $BCCmail=''; |
| 784 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 785 | - foreach($folderArray as $folderName) { |
|
| 786 | - if($this->mail->isSentFolder($folderName)) { |
|
| 955 | + if (count($mailAddr)>0) |
|
| 956 | + { |
|
| 957 | + $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 958 | + } |
|
| 959 | + foreach($folderArray as $folderName) |
|
| 960 | + { |
|
| 961 | + if($this->mail->isSentFolder($folderName)) |
|
| 962 | + { |
|
| 787 | 963 | $flags = '\\Seen'; |
| 788 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 964 | + } |
|
| 965 | + elseif($this->mail->isDraftFolder($folderName)) |
|
| 966 | + { |
|
| 789 | 967 | $flags = '\\Draft'; |
| 790 | - } else { |
|
| 968 | + } |
|
| 969 | + else |
|
| 970 | + { |
|
| 791 | 971 | $flags = ''; |
| 792 | 972 | } |
| 793 | 973 | $asf = true; |
| 794 | 974 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 795 | 975 | $this->mail->openConnection(self::$profileID,false); |
| 796 | - if ($this->mail->folderExists($folderName)) { |
|
| 976 | + if ($this->mail->folderExists($folderName)) |
|
| 977 | + { |
|
| 797 | 978 | try |
| 798 | 979 | { |
| 799 | 980 | $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
@@ -851,17 +1032,26 @@ discard block |
||
| 851 | 1032 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 852 | 1033 | |
| 853 | 1034 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 854 | - if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
|
| 1035 | + if (!$mimesupport && ($key = array_search('4', $bodypreference))) |
|
| 1036 | + { |
|
| 1037 | + unset($bodypreference[$key]); |
|
| 1038 | + } |
|
| 855 | 1039 | |
| 856 | 1040 | //$this->debugLevel=4; |
| 857 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1041 | + if (!isset($this->mail)) |
|
| 1042 | + { |
|
| 1043 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1044 | + } |
|
| 858 | 1045 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
| 859 | 1046 | $account = $_folderName = $xid = null; |
| 860 | 1047 | $this->splitID($folderid,$account,$_folderName,$xid); |
| 861 | 1048 | $this->mail->reopen($_folderName); |
| 862 | 1049 | $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
| 863 | 1050 | $headers = $messages[$id]; |
| 864 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1051 | + if ($this->debugLevel>3) |
|
| 1052 | + { |
|
| 1053 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1054 | + } |
|
| 865 | 1055 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 866 | 1056 | if ($headers) |
| 867 | 1057 | { |
@@ -871,16 +1061,25 @@ discard block |
||
| 871 | 1061 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 872 | 1062 | // simple style |
| 873 | 1063 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 874 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1064 | + if ($this->debugLevel>0) |
|
| 1065 | + { |
|
| 1066 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1067 | + } |
|
| 875 | 1068 | |
| 876 | - if ($bodypreference === false) { |
|
| 1069 | + if ($bodypreference === false) |
|
| 1070 | + { |
|
| 877 | 1071 | $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
| 878 | 1072 | $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 879 | 1073 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 880 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 1074 | + if (stripos($raw_body,'<style')!==false) |
|
| 1075 | + { |
|
| 1076 | + $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); |
|
| 1077 | + } |
|
| 1078 | + // in case there is only a html part |
|
| 881 | 1079 | // remove all other html |
| 882 | 1080 | $body = strip_tags($raw_body); |
| 883 | - if(strlen($body) > $truncsize) { |
|
| 1081 | + if(strlen($body) > $truncsize) |
|
| 1082 | + { |
|
| 884 | 1083 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 885 | 1084 | $output->bodytruncated = 1; |
| 886 | 1085 | } |
@@ -895,7 +1094,8 @@ discard block |
||
| 895 | 1094 | { |
| 896 | 1095 | //Select body type preference |
| 897 | 1096 | $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
| 898 | - if ($bodypreference !== false) { |
|
| 1097 | + if ($bodypreference !== false) |
|
| 1098 | + { |
|
| 899 | 1099 | // bodypreference can occur multiple times |
| 900 | 1100 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
| 901 | 1101 | $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -929,25 +1129,49 @@ discard block |
||
| 929 | 1129 | // fetch the body (try to gather data only once) |
| 930 | 1130 | $css =''; |
| 931 | 1131 | $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
| 932 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1132 | + if ($this->debugLevel>2) |
|
| 1133 | + { |
|
| 1134 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1135 | + } |
|
| 933 | 1136 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 934 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 935 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 1137 | + if ($this->debugLevel>3) |
|
| 1138 | + { |
|
| 1139 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 1140 | + } |
|
| 1141 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 1142 | + { |
|
| 936 | 1143 | // may be html |
| 937 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1144 | + if ($this->debugLevel>0) |
|
| 1145 | + { |
|
| 1146 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1147 | + } |
|
| 938 | 1148 | $css = $this->mail->getStyles($bodyStruct); |
| 939 | 1149 | $output->nativebodytype=2; |
| 940 | - } else { |
|
| 1150 | + } |
|
| 1151 | + else |
|
| 1152 | + { |
|
| 941 | 1153 | // plain text Message |
| 942 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1154 | + if ($this->debugLevel>0) |
|
| 1155 | + { |
|
| 1156 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1157 | + } |
|
| 943 | 1158 | $output->nativebodytype=1; |
| 944 | 1159 | $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
| 945 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1160 | + if ($this->debugLevel>3) |
|
| 1161 | + { |
|
| 1162 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1163 | + } |
|
| 946 | 1164 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 947 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1165 | + if ($this->debugLevel>3) |
|
| 1166 | + { |
|
| 1167 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1168 | + } |
|
| 948 | 1169 | } |
| 949 | 1170 | // whatever format decode (using the correct encoding) |
| 950 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1171 | + if ($this->debugLevel>3) |
|
| 1172 | + { |
|
| 1173 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1174 | + } |
|
| 951 | 1175 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 952 | 1176 | // prepare plaintextbody |
| 953 | 1177 | $plainBody=''; |
@@ -968,12 +1192,18 @@ discard block |
||
| 968 | 1192 | // remove all other html |
| 969 | 1193 | $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
| 970 | 1194 | $plainBody = strip_tags($plainBody); |
| 971 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1195 | + if ($this->debugLevel>3 && $output->nativebodytype==1) |
|
| 1196 | + { |
|
| 1197 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1198 | + } |
|
| 972 | 1199 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 973 | 1200 | |
| 974 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 1201 | + if ($bpReturnType==2) |
|
| 1202 | + { |
|
| 1203 | + //SYNC_BODYPREFERENCE_HTML |
|
| 975 | 1204 | { |
| 976 | 1205 | if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
| 1206 | + } |
|
| 977 | 1207 | // Send HTML if requested and native type was html |
| 978 | 1208 | $output->asbody->type = 2; |
| 979 | 1209 | $htmlbody = '<html>'. |
@@ -1009,7 +1239,10 @@ discard block |
||
| 1009 | 1239 | else |
| 1010 | 1240 | { |
| 1011 | 1241 | // Send Plaintext as Fallback or if original body is plainttext |
| 1012 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1242 | + if ($this->debugLevel>0) |
|
| 1243 | + { |
|
| 1244 | + ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1245 | + } |
|
| 1013 | 1246 | /* we use plainBody (set above) instead |
| 1014 | 1247 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1015 | 1248 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1046,7 +1279,9 @@ discard block |
||
| 1046 | 1279 | { |
| 1047 | 1280 | $output->flag->flagstatus = 2; |
| 1048 | 1281 | //$output->flag->flagtype = "Flag for Follow up"; |
| 1049 | - } else { |
|
| 1282 | + } |
|
| 1283 | + else |
|
| 1284 | + { |
|
| 1050 | 1285 | $output->flag->flagstatus = 0; |
| 1051 | 1286 | } |
| 1052 | 1287 | if ($headers['answered']) |
@@ -1062,10 +1297,20 @@ discard block |
||
| 1062 | 1297 | ($headers['priority'] < 3 ? 2 : 1) ; |
| 1063 | 1298 | $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
| 1064 | 1299 | $output->to = $headers['to_address']; |
| 1065 | - if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
|
| 1300 | + if ($headers['to']) |
|
| 1301 | + { |
|
| 1302 | + $output->displayto = $headers['to_address']; |
|
| 1303 | + } |
|
| 1304 | + //$headers['FETCHED_HEADER']['to_name'] |
|
| 1066 | 1305 | $output->from = $headers['sender_address']; |
| 1067 | - if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses']; |
|
| 1068 | - if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
|
| 1306 | + if (isset($headers['cc_addresses']) && $headers['cc_addresses']) |
|
| 1307 | + { |
|
| 1308 | + $output->cc = $headers['cc_addresses']; |
|
| 1309 | + } |
|
| 1310 | + if (isset($headers['reply_to_address']) && $headers['reply_to_address']) |
|
| 1311 | + { |
|
| 1312 | + $output->reply_to = $headers['reply_to_address']; |
|
| 1313 | + } |
|
| 1069 | 1314 | |
| 1070 | 1315 | $output->messageclass = "IPM.Note"; |
| 1071 | 1316 | if (stripos($headers['mimetype'],'multipart')!== false && |
@@ -1073,7 +1318,8 @@ discard block |
||
| 1073 | 1318 | { |
| 1074 | 1319 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1075 | 1320 | } |
| 1076 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1321 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1322 | + { |
|
| 1077 | 1323 | $output->contentclass = "urn:content-classes:message"; |
| 1078 | 1324 | } |
| 1079 | 1325 | |
@@ -1086,7 +1332,10 @@ discard block |
||
| 1086 | 1332 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1087 | 1333 | foreach ($attachments as $key => $attach) |
| 1088 | 1334 | { |
| 1089 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1335 | + if ($this->debugLevel>0) |
|
| 1336 | + { |
|
| 1337 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1338 | + } |
|
| 1090 | 1339 | |
| 1091 | 1340 | // pass meeting requests to calendar plugin |
| 1092 | 1341 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1103,17 +1352,24 @@ discard block |
||
| 1103 | 1352 | unset($attachment); |
| 1104 | 1353 | continue; // do NOT add attachment as attachment |
| 1105 | 1354 | } |
| 1106 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1355 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1356 | + { |
|
| 1107 | 1357 | $attachment = new SyncBaseAttachment(); |
| 1108 | 1358 | if (!isset($output->asattachments) || !is_array($output->asattachments)) |
| 1109 | - $output->asattachments = array(); |
|
| 1359 | + { |
|
| 1360 | + $output->asattachments = array(); |
|
| 1361 | + } |
|
| 1110 | 1362 | $attachment->estimatedDataSize = $attach['size']; |
| 1111 | 1363 | $attachment->method = 1; |
| 1112 | 1364 | $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
| 1113 | - } else { |
|
| 1365 | + } |
|
| 1366 | + else |
|
| 1367 | + { |
|
| 1114 | 1368 | $attachment = new SyncAttachment(); |
| 1115 | 1369 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1116 | - $output->attachments = array(); |
|
| 1370 | + { |
|
| 1371 | + $output->attachments = array(); |
|
| 1372 | + } |
|
| 1117 | 1373 | $attachment->attsize = $attach['size']; |
| 1118 | 1374 | $attachment->attmethod = 1; |
| 1119 | 1375 | $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
@@ -1130,10 +1386,13 @@ discard block |
||
| 1130 | 1386 | { |
| 1131 | 1387 | $attachment->isinline = true; |
| 1132 | 1388 | } |
| 1133 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1389 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1390 | + { |
|
| 1134 | 1391 | $attachment->method=1; |
| 1135 | 1392 | $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
| 1136 | - } else { |
|
| 1393 | + } |
|
| 1394 | + else |
|
| 1395 | + { |
|
| 1137 | 1396 | $attachment->attmethod=6; |
| 1138 | 1397 | $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
| 1139 | 1398 | } |
@@ -1141,9 +1400,12 @@ discard block |
||
| 1141 | 1400 | $attachment->contenttype = trim($attach['mimeType']); |
| 1142 | 1401 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-type']."' ".$attachment->contentid); |
| 1143 | 1402 | } |
| 1144 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1403 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1404 | + { |
|
| 1145 | 1405 | array_push($output->asattachments, $attachment); |
| 1146 | - } else { |
|
| 1406 | + } |
|
| 1407 | + else |
|
| 1408 | + { |
|
| 1147 | 1409 | array_push($output->attachments, $attachment); |
| 1148 | 1410 | } |
| 1149 | 1411 | unset($attachment); |
@@ -1156,8 +1418,11 @@ discard block |
||
| 1156 | 1418 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1157 | 1419 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1158 | 1420 | |
| 1159 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1160 | -//$this->debugLevel=0; |
|
| 1421 | + if ($this->debugLevel>3) |
|
| 1422 | + { |
|
| 1423 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1424 | + } |
|
| 1425 | + //$this->debugLevel=0; |
|
| 1161 | 1426 | return $output; |
| 1162 | 1427 | } |
| 1163 | 1428 | //$this->debugLevel=0; |
@@ -1216,7 +1481,8 @@ discard block |
||
| 1216 | 1481 | * @param string $attname - should contain (folder)id |
| 1217 | 1482 | * @return SyncItemOperationsAttachment-object |
| 1218 | 1483 | */ |
| 1219 | - function GetAttachmentData($fid,$attname) { |
|
| 1484 | + function GetAttachmentData($fid,$attname) |
|
| 1485 | + { |
|
| 1220 | 1486 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1221 | 1487 | return $this->_GetAttachmentData($fid,$attname); |
| 1222 | 1488 | } |
@@ -1231,7 +1497,8 @@ discard block |
||
| 1231 | 1497 | * @param string $attname - should contain (folder)id |
| 1232 | 1498 | * @return SyncItemOperationsAttachment-object |
| 1233 | 1499 | */ |
| 1234 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1500 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
| 1501 | + { |
|
| 1235 | 1502 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1236 | 1503 | return $this->_GetAttachmentData($fid,$attname); |
| 1237 | 1504 | } |
@@ -1253,7 +1520,10 @@ discard block |
||
| 1253 | 1520 | |
| 1254 | 1521 | $this->splitID($folderid, $account, $folder); |
| 1255 | 1522 | |
| 1256 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1523 | + if (!isset($this->mail)) |
|
| 1524 | + { |
|
| 1525 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1526 | + } |
|
| 1257 | 1527 | |
| 1258 | 1528 | $this->mail->reopen($folder); |
| 1259 | 1529 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
@@ -1262,7 +1532,9 @@ discard block |
||
| 1262 | 1532 | $SIOattachment->data = $attachment['attachment']; |
| 1263 | 1533 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1264 | 1534 | if (isset($attachment['type']) ) |
| 1265 | - $SIOattachment->contenttype = $attachment['type']; |
|
| 1535 | + { |
|
| 1536 | + $SIOattachment->contenttype = $attachment['type']; |
|
| 1537 | + } |
|
| 1266 | 1538 | |
| 1267 | 1539 | unset($attachment); |
| 1268 | 1540 | |
@@ -1308,11 +1580,15 @@ discard block |
||
| 1308 | 1580 | //unset($folderid, $id, $message, $contentParameters); |
| 1309 | 1581 | $account = $folder = null; |
| 1310 | 1582 | $this->splitID($folderid, $account, $folder); |
| 1311 | - if (isset($message->flag)) { |
|
| 1312 | - if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
|
| 1583 | + if (isset($message->flag)) |
|
| 1584 | + { |
|
| 1585 | + if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) |
|
| 1586 | + { |
|
| 1313 | 1587 | $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
| 1314 | 1588 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
| 1315 | - } else { |
|
| 1589 | + } |
|
| 1590 | + else |
|
| 1591 | + { |
|
| 1316 | 1592 | $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
| 1317 | 1593 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
| 1318 | 1594 | } |
@@ -1342,7 +1618,10 @@ discard block |
||
| 1342 | 1618 | $this->splitID($folderid, $account, $srcFolder); |
| 1343 | 1619 | $this->splitID($newfolderid, $account, $destFolder); |
| 1344 | 1620 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1345 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1621 | + if (!isset($this->mail)) |
|
| 1622 | + { |
|
| 1623 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1624 | + } |
|
| 1346 | 1625 | $this->mail->reopen($destFolder); |
| 1347 | 1626 | $status = $this->mail->getFolderStatus($destFolder); |
| 1348 | 1627 | $uidNext = $status['uidnext']; |
@@ -1374,7 +1653,10 @@ discard block |
||
| 1374 | 1653 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1375 | 1654 | } |
| 1376 | 1655 | $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
| 1377 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1656 | + if (is_numeric($maximumSyncRangeInDays)) |
|
| 1657 | + { |
|
| 1658 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1659 | + } |
|
| 1378 | 1660 | } |
| 1379 | 1661 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1380 | 1662 | } |
@@ -1396,7 +1678,10 @@ discard block |
||
| 1396 | 1678 | { |
| 1397 | 1679 | static $headers = array(); |
| 1398 | 1680 | |
| 1399 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1681 | + if ($this->debugLevel>1) |
|
| 1682 | + { |
|
| 1683 | + $gstarttime = microtime (true); |
|
| 1684 | + } |
|
| 1400 | 1685 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1401 | 1686 | $rv_messages = array(); |
| 1402 | 1687 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1409,7 +1694,10 @@ discard block |
||
| 1409 | 1694 | { |
| 1410 | 1695 | $headers = array(); // clear cache to not use too much memory |
| 1411 | 1696 | |
| 1412 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1697 | + if ($this->debugLevel>1) |
|
| 1698 | + { |
|
| 1699 | + $starttime = microtime (true); |
|
| 1700 | + } |
|
| 1413 | 1701 | $this->_connect($this->account); |
| 1414 | 1702 | if ($this->debugLevel>1) |
| 1415 | 1703 | { |
@@ -1418,8 +1706,14 @@ discard block |
||
| 1418 | 1706 | } |
| 1419 | 1707 | $messagelist = $_filter = array(); |
| 1420 | 1708 | // if not connected, any further action must fail |
| 1421 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1422 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1709 | + if (!empty($cutoffdate)) |
|
| 1710 | + { |
|
| 1711 | + $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1712 | + } |
|
| 1713 | + if ($this->debugLevel>1) |
|
| 1714 | + { |
|
| 1715 | + $starttime = microtime (true); |
|
| 1716 | + } |
|
| 1423 | 1717 | $account = $_folderName = $id = null; |
| 1424 | 1718 | $this->splitID($folderid,$account,$_folderName,$id); |
| 1425 | 1719 | if ($this->debugLevel>1) |
@@ -1427,8 +1721,14 @@ discard block |
||
| 1427 | 1721 | $endtime = microtime(true) - $starttime; |
| 1428 | 1722 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
| 1429 | 1723 | } |
| 1430 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1431 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1724 | + if ($this->debugLevel>1) |
|
| 1725 | + { |
|
| 1726 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1727 | + } |
|
| 1728 | + if ($this->debugLevel>1) |
|
| 1729 | + { |
|
| 1730 | + $starttime = microtime (true); |
|
| 1731 | + } |
|
| 1432 | 1732 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
| 1433 | 1733 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
| 1434 | 1734 | if ($this->debugLevel>1) |
@@ -1437,27 +1737,56 @@ discard block |
||
| 1437 | 1737 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
| 1438 | 1738 | } |
| 1439 | 1739 | } |
| 1440 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1740 | + if ($_id == NULL && $this->debugLevel>1) |
|
| 1741 | + { |
|
| 1742 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1743 | + } |
|
| 1441 | 1744 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1442 | 1745 | $messagelist = array(); |
| 1443 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1746 | + if (!isset($rv_messages['header'])||empty($rv_messages['header'])) |
|
| 1747 | + { |
|
| 1748 | + return $messagelist; |
|
| 1749 | + } |
|
| 1444 | 1750 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1445 | 1751 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1446 | 1752 | { |
| 1447 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1753 | + if ($this->debugLevel>3) |
|
| 1754 | + { |
|
| 1755 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1756 | + } |
|
| 1448 | 1757 | $headers[$vars['uid']] = $vars; |
| 1449 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1450 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
| 1451 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
| 1452 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1758 | + if ($this->debugLevel>3) |
|
| 1759 | + { |
|
| 1760 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1761 | + } |
|
| 1762 | + if (!empty($vars['deleted'])) |
|
| 1763 | + { |
|
| 1764 | + continue; |
|
| 1765 | + } |
|
| 1766 | + // cut of deleted messages |
|
| 1767 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
| 1768 | + { |
|
| 1769 | + continue; |
|
| 1770 | + } |
|
| 1771 | + // message is out of range for cutoffdate, ignore it |
|
| 1772 | + if ($this->debugLevel>0) |
|
| 1773 | + { |
|
| 1774 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1775 | + } |
|
| 1453 | 1776 | $mess = $return_all_headers ? $vars : array(); |
| 1454 | 1777 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1455 | 1778 | $mess["id"] = $vars['uid']; |
| 1456 | 1779 | // 'seen' aka 'read' is the only flag we want to know about |
| 1457 | 1780 | $mess["flags"] = 0; |
| 1458 | 1781 | // outlook supports additional flags, set them to 0 |
| 1459 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1460 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1782 | + if($vars["seen"]) |
|
| 1783 | + { |
|
| 1784 | + $mess["flags"] = 1; |
|
| 1785 | + } |
|
| 1786 | + if ($this->debugLevel>3) |
|
| 1787 | + { |
|
| 1788 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1789 | + } |
|
| 1461 | 1790 | $messagelist[$vars['uid']] = $mess; |
| 1462 | 1791 | unset($mess); |
| 1463 | 1792 | } |
@@ -1482,9 +1811,18 @@ discard block |
||
| 1482 | 1811 | static function doFlagsMod($headerFlags) |
| 1483 | 1812 | { |
| 1484 | 1813 | $flags = 'nnn'; |
| 1485 | - if ($headerFlags['flagged']) $flags[0] = 'f'; |
|
| 1486 | - if ($headerFlags['answered']) $flags[1] = 'a'; |
|
| 1487 | - if ($headerFlags['forwarded']) $flags[2] = 'f'; |
|
| 1814 | + if ($headerFlags['flagged']) |
|
| 1815 | + { |
|
| 1816 | + $flags[0] = 'f'; |
|
| 1817 | + } |
|
| 1818 | + if ($headerFlags['answered']) |
|
| 1819 | + { |
|
| 1820 | + $flags[1] = 'a'; |
|
| 1821 | + } |
|
| 1822 | + if ($headerFlags['forwarded']) |
|
| 1823 | + { |
|
| 1824 | + $flags[2] = 'f'; |
|
| 1825 | + } |
|
| 1488 | 1826 | //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags)); |
| 1489 | 1827 | return $flags; |
| 1490 | 1828 | } |
@@ -1516,31 +1854,55 @@ discard block |
||
| 1516 | 1854 | { |
| 1517 | 1855 | //$this->debugLevel=1; |
| 1518 | 1856 | $searchquery=$_searchquery->GetDataArray(); |
| 1519 | - if (!is_array($searchquery)) return array(); |
|
| 1520 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1857 | + if (!is_array($searchquery)) |
|
| 1858 | + { |
|
| 1859 | + return array(); |
|
| 1860 | + } |
|
| 1861 | + if ($this->debugLevel>0) |
|
| 1862 | + { |
|
| 1863 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1864 | + } |
|
| 1521 | 1865 | |
| 1522 | - if (isset($searchquery['searchrebuildresults'])) { |
|
| 1866 | + if (isset($searchquery['searchrebuildresults'])) |
|
| 1867 | + { |
|
| 1523 | 1868 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1524 | - } else { |
|
| 1869 | + } |
|
| 1870 | + else |
|
| 1871 | + { |
|
| 1525 | 1872 | $rebuildresults = false; |
| 1526 | 1873 | } |
| 1527 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1874 | + if ($this->debugLevel>0) |
|
| 1875 | + { |
|
| 1876 | + ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1877 | + } |
|
| 1528 | 1878 | |
| 1529 | - if (isset($searchquery['deeptraversal'])) { |
|
| 1879 | + if (isset($searchquery['deeptraversal'])) |
|
| 1880 | + { |
|
| 1530 | 1881 | $deeptraversal = $searchquery['deeptraversal']; |
| 1531 | - } else { |
|
| 1882 | + } |
|
| 1883 | + else |
|
| 1884 | + { |
|
| 1532 | 1885 | $deeptraversal = false; |
| 1533 | 1886 | } |
| 1534 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1887 | + if ($this->debugLevel>0) |
|
| 1888 | + { |
|
| 1889 | + ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1890 | + } |
|
| 1535 | 1891 | |
| 1536 | - if (isset($searchquery['searchrange'])) { |
|
| 1892 | + if (isset($searchquery['searchrange'])) |
|
| 1893 | + { |
|
| 1537 | 1894 | $range = explode("-",$_searchquery->GetSearchRange()); |
| 1538 | 1895 | $start =$range[0] + 1; |
| 1539 | 1896 | $limit = $range[1] - $range[0] + 1; |
| 1540 | - } else { |
|
| 1897 | + } |
|
| 1898 | + else |
|
| 1899 | + { |
|
| 1541 | 1900 | $range = false; |
| 1542 | 1901 | } |
| 1543 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1902 | + if ($this->debugLevel>0) |
|
| 1903 | + { |
|
| 1904 | + ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1905 | + } |
|
| 1544 | 1906 | |
| 1545 | 1907 | //foreach($searchquery['query'] as $k => $value) { |
| 1546 | 1908 | // $query = $value; |
@@ -1592,7 +1954,10 @@ discard block |
||
| 1592 | 1954 | $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
| 1593 | 1955 | } |
| 1594 | 1956 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1595 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1957 | + if ($this->debugLevel>1) |
|
| 1958 | + { |
|
| 1959 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1960 | + } |
|
| 1596 | 1961 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
| 1597 | 1962 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1598 | 1963 | $list=array(); |
@@ -1624,17 +1989,26 @@ discard block |
||
| 1624 | 1989 | private function getParentID($account,$folder) |
| 1625 | 1990 | { |
| 1626 | 1991 | $this->_connect($account); |
| 1627 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1992 | + if (!isset($this->folders)) |
|
| 1993 | + { |
|
| 1994 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1995 | + } |
|
| 1628 | 1996 | |
| 1629 | 1997 | $mailFolder = $this->folders[$folder]; |
| 1630 | - if (!isset($mailFolder)) return false; |
|
| 1998 | + if (!isset($mailFolder)) |
|
| 1999 | + { |
|
| 2000 | + return false; |
|
| 2001 | + } |
|
| 1631 | 2002 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
| 1632 | 2003 | $parent = explode($delimiter,$folder); |
| 1633 | 2004 | array_pop($parent); |
| 1634 | 2005 | $parent = implode($delimiter,$parent); |
| 1635 | 2006 | |
| 1636 | 2007 | $id = $parent ? $this->createID($account, $parent) : '0'; |
| 1637 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2008 | + if ($this->debugLevel>1) |
|
| 2009 | + { |
|
| 2010 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2011 | + } |
|
| 1638 | 2012 | return $id; |
| 1639 | 2013 | } |
| 1640 | 2014 | |
@@ -1648,7 +2022,10 @@ discard block |
||
| 1648 | 2022 | { |
| 1649 | 2023 | static $last_id = null; |
| 1650 | 2024 | static $folderObj = null; |
| 1651 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
| 2025 | + if (isset($last_id) && $last_id === $id) |
|
| 2026 | + { |
|
| 2027 | + return $folderObj; |
|
| 2028 | + } |
|
| 1652 | 2029 | |
| 1653 | 2030 | try { |
| 1654 | 2031 | $account = $folder = null; |
@@ -1659,18 +2036,30 @@ discard block |
||
| 1659 | 2036 | return $folderObj=false; |
| 1660 | 2037 | } |
| 1661 | 2038 | $this->_connect($account); |
| 1662 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2039 | + if (!isset($this->folders)) |
|
| 2040 | + { |
|
| 2041 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2042 | + } |
|
| 1663 | 2043 | |
| 1664 | 2044 | $mailFolder = $this->folders[$folder]; |
| 1665 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 2045 | + if (!isset($mailFolder)) |
|
| 2046 | + { |
|
| 2047 | + return $folderObj=false; |
|
| 2048 | + } |
|
| 1666 | 2049 | |
| 1667 | 2050 | $folderObj = new SyncFolder(); |
| 1668 | 2051 | $folderObj->serverid = $id; |
| 1669 | 2052 | $folderObj->parentid = $this->getParentID($account,$folder); |
| 1670 | 2053 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1671 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2054 | + if ($this->debugLevel>1) |
|
| 2055 | + { |
|
| 2056 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2057 | + } |
|
| 1672 | 2058 | // get folder-type |
| 1673 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 2059 | + foreach($this->folders as $inbox => $mailFolder) |
|
| 2060 | + { |
|
| 2061 | + break; |
|
| 2062 | + } |
|
| 1674 | 2063 | if ($folder == $inbox) |
| 1675 | 2064 | { |
| 1676 | 2065 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1707,7 +2096,10 @@ discard block |
||
| 1707 | 2096 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1708 | 2097 | } |
| 1709 | 2098 | |
| 1710 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2099 | + if ($this->debugLevel>1) |
|
| 2100 | + { |
|
| 2101 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2102 | + } |
|
| 1711 | 2103 | return $folderObj; |
| 1712 | 2104 | } |
| 1713 | 2105 | |
@@ -1751,11 +2143,20 @@ discard block |
||
| 1751 | 2143 | { |
| 1752 | 2144 | $account = $folder = null; |
| 1753 | 2145 | $this->splitID($folderid, $account, $folder); |
| 1754 | - if (is_numeric($account)) $type = 'mail'; |
|
| 2146 | + if (is_numeric($account)) |
|
| 2147 | + { |
|
| 2148 | + $type = 'mail'; |
|
| 2149 | + } |
|
| 1755 | 2150 | |
| 1756 | - if ($type != 'mail') return false; |
|
| 2151 | + if ($type != 'mail') |
|
| 2152 | + { |
|
| 2153 | + return false; |
|
| 2154 | + } |
|
| 1757 | 2155 | |
| 1758 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2156 | + if (!isset($this->mail)) |
|
| 2157 | + { |
|
| 2158 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2159 | + } |
|
| 1759 | 2160 | |
| 1760 | 2161 | $this->mail->reopen($folder); |
| 1761 | 2162 | |
@@ -1800,7 +2201,7 @@ discard block |
||
| 1800 | 2201 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1801 | 2202 | */ |
| 1802 | 2203 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1803 | - { |
|
| 2204 | + { |
|
| 1804 | 2205 | unset($contentParameters); // not used, but required by function signature |
| 1805 | 2206 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1806 | 2207 | /* |
@@ -1826,7 +2227,10 @@ discard block |
||
| 1826 | 2227 | $error = $e->getMessage(); |
| 1827 | 2228 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
| 1828 | 2229 | // if the server thinks the message does not exist report deletion as success |
| 1829 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 2230 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
| 2231 | + { |
|
| 2232 | + return true; |
|
| 2233 | + } |
|
| 1830 | 2234 | return false; |
| 1831 | 2235 | } |
| 1832 | 2236 | |
@@ -1859,7 +2263,7 @@ discard block |
||
| 1859 | 2263 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1860 | 2264 | */ |
| 1861 | 2265 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1862 | - { |
|
| 2266 | + { |
|
| 1863 | 2267 | unset($contentParameters); // not used, but required by function signature |
| 1864 | 2268 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1865 | 2269 | $account = $folder = null; |
@@ -1945,7 +2349,10 @@ discard block |
||
| 1945 | 2349 | |
| 1946 | 2350 | $str = $this->backend->createID($account, $folder, $id); |
| 1947 | 2351 | |
| 1948 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2352 | + if ($this->debugLevel>1) |
|
| 2353 | + { |
|
| 2354 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2355 | + } |
|
| 1949 | 2356 | |
| 1950 | 2357 | return $str; |
| 1951 | 2358 | } |
@@ -1966,7 +2373,10 @@ discard block |
||
| 1966 | 2373 | // convert numeric folder-id back to folder name |
| 1967 | 2374 | $folder = $this->hash2folder($account,$f=$folder); |
| 1968 | 2375 | |
| 1969 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
| 2376 | + if ($this->debugLevel>1) |
|
| 2377 | + { |
|
| 2378 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
| 2379 | + } |
|
| 1970 | 2380 | } |
| 1971 | 2381 | |
| 1972 | 2382 | /** |
@@ -1985,7 +2395,10 @@ discard block |
||
| 1985 | 2395 | */ |
| 1986 | 2396 | private function folder2hash($account,$folder) |
| 1987 | 2397 | { |
| 1988 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2398 | + if(!isset($this->folderHashes)) |
|
| 2399 | + { |
|
| 2400 | + $this->readFolderHashes(); |
|
| 2401 | + } |
|
| 1989 | 2402 | |
| 1990 | 2403 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 1991 | 2404 | { |
@@ -2008,7 +2421,10 @@ discard block |
||
| 2008 | 2421 | */ |
| 2009 | 2422 | private function hash2folder($account,$index) |
| 2010 | 2423 | { |
| 2011 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2424 | + if(!isset($this->folderHashes)) |
|
| 2425 | + { |
|
| 2426 | + $this->readFolderHashes(); |
|
| 2427 | + } |
|
| 2012 | 2428 | |
| 2013 | 2429 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2014 | 2430 | } |