|
@@ -90,23 +90,23 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
124
|
124
|
try { |
|
125
|
125
|
Mail\Account::read(self::$profileID); |
|
126
|
126
|
} |
|
127
|
|
- catch(Exception $e) { |
|
|
127
|
+ catch (Exception $e) { |
|
128
|
128
|
unset($e); |
|
129
|
129
|
self::$profileID = Mail\Account::get_default_acc_id(); |
|
130
|
130
|
} |
|
131
|
131
|
} |
|
132
|
|
- if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
|
132
|
+ if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
133
|
133
|
//$this->debugLevel=0; |
|
134
|
134
|
} |
|
135
|
135
|
|
|
@@ -242,13 +242,13 @@ discard block |
|
|
block discarded – undo |
|
242
|
242
|
$this->__construct($this->backend); |
|
243
|
243
|
|
|
244
|
244
|
try { |
|
245
|
|
- $this->_connect(0,true); |
|
|
245
|
+ $this->_connect(0, true); |
|
246
|
246
|
$this->_disconnect(); |
|
247
|
247
|
|
|
248
|
248
|
if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
249
|
249
|
if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
250
|
250
|
} |
|
251
|
|
- catch(Exception $e) { |
|
|
251
|
+ catch (Exception $e) { |
|
252
|
252
|
$errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
|
253
|
253
|
} |
|
254
|
254
|
if ($errors) |
|
@@ -266,7 +266,7 @@ discard block |
|
|
block discarded – undo |
|
266
|
266
|
* @param int $account integer id of account to use |
|
267
|
267
|
* @todo support different accounts |
|
268
|
268
|
*/ |
|
269
|
|
- private function _connect($account=0) |
|
|
269
|
+ private function _connect($account = 0) |
|
270
|
270
|
{ |
|
271
|
271
|
if (!$account) $account = self::$profileID ? self::$profileID : 0; |
|
272
|
272
|
if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
@@ -279,7 +279,7 @@ discard block |
|
|
block discarded – undo |
|
279
|
279
|
$this->account = $account; |
|
280
|
280
|
// todo: tell mail which account to use |
|
281
|
281
|
//error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
|
282
|
|
- $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
|
282
|
+ $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
283
|
283
|
if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
284
|
284
|
} |
|
285
|
285
|
else |
|
@@ -287,7 +287,7 @@ discard block |
|
|
block discarded – undo |
|
287
|
287
|
//error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
|
288
|
288
|
if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
289
|
289
|
} |
|
290
|
|
- $this->mail->openConnection(self::$profileID,false); |
|
|
290
|
+ $this->mail->openConnection(self::$profileID, false); |
|
291
|
291
|
|
|
292
|
292
|
$this->_wasteID = $this->mail->getTrashFolder(false); |
|
293
|
293
|
//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
|
@@ -302,7 +302,7 @@ discard block |
|
|
block discarded – undo |
|
302
|
302
|
*/ |
|
303
|
303
|
private function _disconnect() |
|
304
|
304
|
{ |
|
305
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
|
305
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__); |
|
306
|
306
|
if ($this->mail) $this->mail->closeConnection(); |
|
307
|
307
|
|
|
308
|
308
|
unset($this->mail); |
|
@@ -318,24 +318,24 @@ discard block |
|
|
block discarded – undo |
|
318
|
318
|
public function GetFolderList() |
|
319
|
319
|
{ |
|
320
|
320
|
$folderlist = array(); |
|
321
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
|
321
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__); |
|
322
|
322
|
/*foreach($available_accounts as $account)*/ $account = 0; |
|
323
|
323
|
{ |
|
324
|
324
|
$this->_connect($account); |
|
325
|
|
- if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
326
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
|
325
|
+ if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
|
326
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders)); |
|
327
|
327
|
|
|
328
|
328
|
foreach ($this->folders as $folder => $folderObj) { |
|
329
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
|
329
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder); |
|
330
|
330
|
$folderlist[] = $f = array( |
|
331
|
|
- 'id' => $this->createID($account,$folder), |
|
|
331
|
+ 'id' => $this->createID($account, $folder), |
|
332
|
332
|
'mod' => $folderObj->shortDisplayName, |
|
333
|
|
- 'parent' => $this->getParentID($account,$folder), |
|
|
333
|
+ 'parent' => $this->getParentID($account, $folder), |
|
334
|
334
|
); |
|
335
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
|
335
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f)); |
|
336
|
336
|
} |
|
337
|
337
|
} |
|
338
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
|
338
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist)); |
|
339
|
339
|
|
|
340
|
340
|
return $folderlist; |
|
341
|
341
|
} |
|
@@ -384,86 +384,86 @@ discard block |
|
|
block discarded – undo |
|
384
|
384
|
$ClientSideMeetingRequest = false; |
|
385
|
385
|
$allowSendingInvitations = 'sendifnocalnotif'; |
|
386
|
386
|
if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
|
387
|
|
- $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
|
387
|
+ $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
388
|
388
|
{ |
|
389
|
389
|
$allowSendingInvitations = false; |
|
390
|
390
|
} |
|
391
|
391
|
elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
|
392
|
|
- $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
|
392
|
+ $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
393
|
393
|
{ |
|
394
|
394
|
$allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
|
395
|
395
|
} |
|
396
|
|
- $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
|
|
396
|
+ $smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new')); |
|
397
|
397
|
|
|
398
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
|
399
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
|
398
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.(isset($smartdata->mime) ? $smartdata->mime : "")."task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
|
|
399
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
400
|
400
|
//error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
401
|
401
|
|
|
402
|
402
|
// initialize our Mail |
|
403
|
|
- if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
|
403
|
+ if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
404
|
404
|
$activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
|
405
|
405
|
// use the standardIdentity |
|
406
|
|
- $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
|
406
|
+ $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
407
|
407
|
|
|
408
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
|
408
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
409
|
409
|
// collect identity / signature for later usage, and to determine if we may have to manipulate TransferEncoding and Charset |
|
410
|
410
|
try |
|
411
|
411
|
{ |
|
412
|
412
|
$acc = Mail\Account::read($this->mail->icServer->ImapServerId); |
|
413
|
413
|
//error_log(__METHOD__.__LINE__.array2string($acc)); |
|
414
|
|
- $_signature = Mail\Account::read_identity($acc['ident_id'],true); |
|
|
414
|
+ $_signature = Mail\Account::read_identity($acc['ident_id'], true); |
|
415
|
415
|
} |
|
416
|
416
|
catch (Exception $e) |
|
417
|
417
|
{ |
|
418
|
|
- $_signature=array(); |
|
|
418
|
+ $_signature = array(); |
|
419
|
419
|
} |
|
420
|
420
|
$signature = $_signature['ident_signature']; |
|
421
|
421
|
if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
|
422
|
422
|
$preferencesArray['disableRulerForSignatureSeparation']) || |
|
423
|
|
- empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='') |
|
|
423
|
+ empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '') |
|
424
|
424
|
{ |
|
425
|
425
|
$disableRuler = true; |
|
426
|
426
|
} |
|
427
|
427
|
$beforePlain = $beforeHtml = ""; |
|
428
|
|
- $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
429
|
|
- $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
430
|
|
- $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
431
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
|
428
|
+ $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
|
429
|
+ $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
|
430
|
+ $sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
|
431
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
432
|
432
|
$sigTextHtml = $beforeHtml.$sigText; |
|
433
|
433
|
$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
|
434
|
434
|
|
|
435
|
|
- $force8bit=false; |
|
436
|
|
- if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
|
435
|
+ $force8bit = false; |
|
|
436
|
+ if (Api\Translation::detect_encoding($sigTextPlain) != 'ascii') $force8bit = true; |
|
437
|
437
|
// initialize the new Api\Mailer object for sending |
|
438
|
438
|
$mailObject = new Api\Mailer(self::$profileID); |
|
439
|
439
|
|
|
440
|
|
- $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); |
|
|
440
|
+ $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime, $force8bit); |
|
441
|
441
|
// Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
|
442
|
|
- $mailObject->Sender = $activeMailProfile['ident_email']; |
|
443
|
|
- $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); |
|
|
442
|
+ $mailObject->Sender = $activeMailProfile['ident_email']; |
|
|
443
|
+ $mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false)); |
|
444
|
444
|
$mailObject->addHeader('X-Mailer', 'mail-Activesync'); |
|
445
|
445
|
|
|
446
|
446
|
|
|
447
|
447
|
// prepare addressee list; moved the adding of addresses to the mailobject down |
|
448
|
448
|
// to |
|
449
|
449
|
|
|
450
|
|
- foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
|
450
|
+ foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
451
|
451
|
if (!$addressObject->valid) continue; |
|
452
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
|
452
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
453
|
453
|
//$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
454
|
454
|
$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
|
455
|
455
|
} |
|
456
|
456
|
// CC |
|
457
|
|
- foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
|
457
|
+ foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
458
|
458
|
if (!$addressObject->valid) continue; |
|
459
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
|
459
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
460
|
460
|
//$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
461
|
461
|
$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
|
462
|
462
|
} |
|
463
|
463
|
// BCC |
|
464
|
|
- foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
|
464
|
+ foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
465
|
465
|
if (!$addressObject->valid) continue; |
|
466
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
|
466
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
467
|
467
|
//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
468
|
468
|
$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
|
469
|
469
|
} |
|
@@ -472,7 +472,7 @@ discard block |
|
|
block discarded – undo |
|
472
|
472
|
$use_orgbody = false; |
|
473
|
473
|
|
|
474
|
474
|
$k = 'Content-Type'; |
|
475
|
|
- $ContentType =$mailObject->getHeader('Content-Type'); |
|
|
475
|
+ $ContentType = $mailObject->getHeader('Content-Type'); |
|
476
|
476
|
//error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
|
477
|
477
|
// if the message is a multipart message, then we should use the sent body |
|
478
|
478
|
if (preg_match("/multipart/i", $ContentType)) { |
|
@@ -492,43 +492,43 @@ discard block |
|
|
block discarded – undo |
|
492
|
492
|
$k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
493
|
493
|
$use_orgbody = true; |
|
494
|
494
|
} |
|
495
|
|
- $Body = $AltBody = ""; |
|
|
495
|
+ $Body = $AltBody = ""; |
|
496
|
496
|
// get body of the transmitted message |
|
497
|
497
|
// if this is a simple message, no structure at all |
|
498
|
498
|
if (preg_match("/text/i", $ContentType)) |
|
499
|
499
|
{ |
|
500
|
|
- $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
|
500
|
+ $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
501
|
501
|
$bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
|
502
|
|
- $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
503
|
|
- if ($simpleBodyType == "text/plain") |
|
|
502
|
+ $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
|
503
|
+ if ($simpleBodyType == "text/plain") |
|
504
|
504
|
{ |
|
505
|
505
|
$Body = $body; |
|
506
|
506
|
$AltBody = "<pre>".nl2br($body)."</pre>"; |
|
507
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
|
507
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
508
|
508
|
} |
|
509
|
509
|
else |
|
510
|
510
|
{ |
|
511
|
511
|
$AltBody = $body; |
|
512
|
|
- $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
513
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
|
512
|
+ $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
|
513
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
514
|
514
|
} |
|
515
|
515
|
} |
|
516
|
516
|
else |
|
517
|
517
|
{ |
|
518
|
518
|
// if this is a structured message |
|
519
|
519
|
// prefer plain over html |
|
520
|
|
- $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
|
520
|
+ $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
521
|
521
|
($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
|
522
|
|
- $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
|
522
|
+ $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
523
|
523
|
($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
|
524
|
524
|
} |
|
525
|
|
- if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
526
|
|
- if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
|
525
|
+ if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
|
526
|
+ if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
527
|
527
|
//error_log(__METHOD__.__LINE__.array2string($mailObject)); |
|
528
|
528
|
// if this is a multipart message with a boundary, we must use the original body |
|
529
|
529
|
//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
|
530
|
530
|
if ($use_orgbody) { |
|
531
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
|
531
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
532
|
532
|
// if it is a ClientSideMeetingRequest, we report it as send at all times |
|
533
|
533
|
if (($cal_body = $mailObject->findBody('calendar')) && |
|
534
|
534
|
($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
|
@@ -537,21 +537,21 @@ discard block |
|
|
block discarded – undo |
|
537
|
537
|
{ |
|
538
|
538
|
$organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
|
539
|
539
|
} |
|
540
|
|
- if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
|
540
|
+ if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
541
|
541
|
$ClientSideMeetingRequest = true; |
|
542
|
542
|
} |
|
543
|
543
|
} |
|
544
|
544
|
// now handle the addressee list |
|
545
|
545
|
$toCount = 0; |
|
546
|
546
|
//error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
|
547
|
|
- foreach((array)$toMailAddr as $address) { |
|
548
|
|
- foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
549
|
|
- $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
|
547
|
+ foreach ((array)$toMailAddr as $address) { |
|
|
548
|
+ foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
|
549
|
+ $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
550
|
550
|
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
|
551
|
551
|
calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
|
552
|
552
|
$organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
|
553
|
553
|
{ |
|
554
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
|
554
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
555
|
555
|
continue; |
|
556
|
556
|
} |
|
557
|
557
|
$mailObject->AddAddress($emailAddress, $addressObject->personal); |
|
@@ -559,29 +559,29 @@ discard block |
|
|
block discarded – undo |
|
559
|
559
|
} |
|
560
|
560
|
} |
|
561
|
561
|
$ccCount = 0; |
|
562
|
|
- foreach((array)$ccMailAddr as $address) { |
|
563
|
|
- foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
564
|
|
- $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
|
562
|
+ foreach ((array)$ccMailAddr as $address) { |
|
|
563
|
+ foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
|
564
|
+ $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
565
|
565
|
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
566
|
566
|
$mailObject->AddCC($emailAddress, $addressObject->personal); |
|
567
|
567
|
$ccCount++; |
|
568
|
568
|
} |
|
569
|
569
|
} |
|
570
|
570
|
$bccCount = 0; |
|
571
|
|
- foreach((array)$bccMailAddr as $address) { |
|
572
|
|
- foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
573
|
|
- $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
|
571
|
+ foreach ((array)$bccMailAddr as $address) { |
|
|
572
|
+ foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
|
573
|
+ $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
574
|
574
|
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
575
|
575
|
$mailObject->AddBCC($emailAddress, $addressObject->personal); |
|
576
|
576
|
$bccCount++; |
|
577
|
577
|
} |
|
578
|
578
|
} |
|
579
|
579
|
// typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
|
580
|
|
- if ($toCount+$ccCount+$bccCount == 0) |
|
|
580
|
+ if ($toCount + $ccCount + $bccCount == 0) |
|
581
|
581
|
{ |
|
582
|
582
|
return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
|
583
|
583
|
} |
|
584
|
|
- if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
|
584
|
+ if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
585
|
585
|
// as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
|
586
|
586
|
/* |
|
587
|
587
|
if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
|
@@ -598,26 +598,26 @@ discard block |
|
|
block discarded – undo |
|
598
|
598
|
{ |
|
599
|
599
|
// now get on, and fetch the original mail |
|
600
|
600
|
$uid = $smartdata->source->itemid; |
|
601
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
|
601
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
602
|
602
|
$this->splitID($smartdata->source->folderid, $account, $folder); |
|
603
|
603
|
|
|
604
|
604
|
$this->mail->reopen($folder); |
|
605
|
605
|
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
|
606
|
|
- $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
607
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
608
|
|
- if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
|
606
|
+ $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
|
607
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
|
608
|
+ if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
609
|
609
|
// may be html |
|
610
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
|
610
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
611
|
611
|
$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
|
612
|
612
|
$isreply = true; |
|
613
|
613
|
} |
|
614
|
614
|
// plain text Message part |
|
615
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
|
615
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
616
|
616
|
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
|
617
|
|
- $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
618
|
|
- $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
619
|
|
- if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
620
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
|
617
|
+ $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
|
618
|
+ $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
|
619
|
+ if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
|
620
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
621
|
621
|
$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
|
622
|
622
|
$isreply = true; |
|
623
|
623
|
} |
|
@@ -625,12 +625,12 @@ discard block |
|
|
block discarded – undo |
|
625
|
625
|
{ |
|
626
|
626
|
$isreply = true; |
|
627
|
627
|
$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
|
628
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
|
628
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
629
|
629
|
} |
|
630
|
630
|
} |
|
631
|
631
|
|
|
632
|
632
|
// how to forward and other prefs |
|
633
|
|
- $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
|
633
|
+ $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
634
|
634
|
|
|
635
|
635
|
// forward ------------------------------------------------------------------------- |
|
636
|
636
|
if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
|
@@ -640,7 +640,7 @@ discard block |
|
|
block discarded – undo |
|
640
|
640
|
{ |
|
641
|
641
|
//force the default for the forwarding -> asmail |
|
642
|
642
|
if (is_array($preferencesArray)) { |
|
643
|
|
- if (!array_key_exists('message_forwarding',$preferencesArray) |
|
|
643
|
+ if (!array_key_exists('message_forwarding', $preferencesArray) |
|
644
|
644
|
|| !isset($preferencesArray['message_forwarding']) |
|
645
|
645
|
|| empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
646
|
646
|
} else { |
|
@@ -648,18 +648,18 @@ discard block |
|
|
block discarded – undo |
|
648
|
648
|
} |
|
649
|
649
|
// construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
|
650
|
650
|
$uid = $smartdata->source->itemid; |
|
651
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
|
651
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
652
|
652
|
$this->splitID($smartdata->source->folderid, $account, $folder); |
|
653
|
653
|
|
|
654
|
654
|
$this->mail->reopen($folder); |
|
655
|
655
|
// receive entire mail (header + body) |
|
656
|
656
|
// get message headers for specified message |
|
657
|
|
- $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
|
657
|
+ $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
658
|
658
|
// build a new mime message, forward entire old mail as file |
|
659
|
659
|
if ($preferencesArray['message_forwarding'] == 'asmail') |
|
660
|
660
|
{ |
|
661
|
|
- $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
662
|
|
- $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
|
661
|
+ $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
|
662
|
+ $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
663
|
663
|
$mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
|
664
|
664
|
$AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
|
665
|
665
|
$Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
|
@@ -669,50 +669,50 @@ discard block |
|
|
block discarded – undo |
|
669
|
669
|
{ |
|
670
|
670
|
// now get on, and fetch the original mail |
|
671
|
671
|
$uid = $smartdata->source->itemid; |
|
672
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
|
672
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
673
|
673
|
$this->splitID($smartdata->source->folderid, $account, $folder); |
|
674
|
674
|
|
|
675
|
675
|
$this->mail->reopen($folder); |
|
676
|
676
|
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
|
677
|
|
- $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
678
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
679
|
|
- if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
|
677
|
+ $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
|
678
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
|
679
|
+ if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
680
|
680
|
// may be html |
|
681
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
|
681
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
682
|
682
|
$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
|
683
|
683
|
$isforward = true; |
|
684
|
684
|
} |
|
685
|
685
|
// plain text Message part |
|
686
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
|
686
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
687
|
687
|
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
|
688
|
|
- $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
689
|
|
- $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
690
|
|
- if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
691
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
|
688
|
+ $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
|
689
|
+ $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
|
690
|
+ if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
|
691
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
692
|
692
|
$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
|
693
|
693
|
$isforward = true; |
|
694
|
694
|
} |
|
695
|
695
|
if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
|
696
|
696
|
{ |
|
697
|
697
|
$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
|
698
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
|
698
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
699
|
699
|
$isforward = true; |
|
700
|
700
|
} |
|
701
|
701
|
// get all the attachments and add them too. |
|
702
|
702
|
// start handle Attachments |
|
703
|
703
|
// $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
|
704
|
|
- $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
|
704
|
+ $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
705
|
705
|
$attachmentNames = false; |
|
706
|
|
- if (is_array($attachments) && count($attachments)>0) |
|
|
706
|
+ if (is_array($attachments) && count($attachments) > 0) |
|
707
|
707
|
{ |
|
708
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
709
|
|
- foreach((array)$attachments as $key => $attachment) |
|
|
708
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
|
709
|
+ foreach ((array)$attachments as $key => $attachment) |
|
710
|
710
|
{ |
|
711
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
|
711
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
712
|
712
|
$attachmentNames .= $attachment['name']."\n"; |
|
713
|
|
- $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
|
713
|
+ $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
714
|
714
|
/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
|
715
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
|
715
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
716
|
716
|
} |
|
717
|
717
|
} |
|
718
|
718
|
} |
|
@@ -727,38 +727,38 @@ discard block |
|
|
block discarded – undo |
|
727
|
727
|
// now set the body |
|
728
|
728
|
if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
|
729
|
729
|
{ |
|
730
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
|
730
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
731
|
731
|
//error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
|
732
|
|
- $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
|
732
|
+ $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
733
|
733
|
} |
|
734
|
734
|
if ($Body && ($text_body = $mailObject->findBody('plain'))) |
|
735
|
735
|
{ |
|
736
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
|
736
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
737
|
737
|
//error_log(__METHOD__.__LINE__.' text:'.$Body); |
|
738
|
|
- $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
|
738
|
+ $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
739
|
739
|
} |
|
740
|
740
|
//advanced debugging |
|
741
|
741
|
// Horde SMTP Class uses utf-8 by default. |
|
742
|
742
|
//ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
743
|
|
- if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
|
743
|
+ if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
744
|
744
|
|
|
745
|
745
|
// set a higher timeout for big messages |
|
746
|
746
|
@set_time_limit(120); |
|
747
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
|
747
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
748
|
748
|
// send |
|
749
|
749
|
$send = true; |
|
750
|
750
|
try { |
|
751
|
751
|
$mailObject->Send(); |
|
752
|
752
|
} |
|
753
|
|
- catch(Exception $e) { |
|
754
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
|
753
|
+ catch (Exception $e) { |
|
|
754
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
755
|
755
|
$send = false; |
|
756
|
756
|
} |
|
757
|
757
|
|
|
758
|
|
- if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
|
758
|
+ if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
759
|
759
|
{ |
|
760
|
760
|
$uid = $smartdata->source->itemid; |
|
761
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
|
761
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
762
|
762
|
$this->splitID($smartdata->source->folderid, $account, $folder); |
|
763
|
763
|
//error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
|
764
|
764
|
$this->mail->reopen($folder); |
|
@@ -766,89 +766,89 @@ discard block |
|
|
block discarded – undo |
|
766
|
766
|
// unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
|
767
|
767
|
if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
|
768
|
768
|
{ |
|
769
|
|
- $this->mail->deleteMessages(array($uid),$folder); |
|
|
769
|
+ $this->mail->deleteMessages(array($uid), $folder); |
|
770
|
770
|
} else { |
|
771
|
|
- $this->mail->flagMessages("answered", array($uid),$folder); |
|
772
|
|
- if ($smartdata_task== "forward") |
|
|
771
|
+ $this->mail->flagMessages("answered", array($uid), $folder); |
|
|
772
|
+ if ($smartdata_task == "forward") |
|
773
|
773
|
{ |
|
774
|
|
- $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
|
774
|
+ $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
775
|
775
|
} |
|
776
|
776
|
} |
|
777
|
777
|
} |
|
778
|
778
|
|
|
779
|
|
- $asf = ($send ? true:false); // initalize accordingly |
|
780
|
|
- if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
|
779
|
+ $asf = ($send ? true : false); // initalize accordingly |
|
|
780
|
+ if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
781
|
781
|
{ |
|
782
|
782
|
$asf = false; |
|
783
|
783
|
$sentFolder = $this->mail->getSentFolder(); |
|
784
|
784
|
if ($this->_sentID) { |
|
785
|
785
|
$folderArray[] = $this->_sentID; |
|
786
|
786
|
} |
|
787
|
|
- else if(isset($sentFolder) && $sentFolder != 'none') |
|
|
787
|
+ else if (isset($sentFolder) && $sentFolder != 'none') |
|
788
|
788
|
{ |
|
789
|
789
|
$folderArray[] = $sentFolder; |
|
790
|
790
|
} |
|
791
|
791
|
// No Sent folder set, try defaults |
|
792
|
792
|
else |
|
793
|
793
|
{ |
|
794
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
|
794
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
795
|
795
|
// we dont try guessing |
|
796
|
796
|
$asf = true; |
|
797
|
797
|
} |
|
798
|
798
|
if (count($folderArray) > 0) { |
|
799
|
|
- foreach((array)$bccMailAddr as $address) { |
|
800
|
|
- foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
801
|
|
- $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
|
799
|
+ foreach ((array)$bccMailAddr as $address) { |
|
|
800
|
+ foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
|
801
|
+ $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
802
|
802
|
$mailAddr[] = array($emailAddress, $addressObject->personal); |
|
803
|
803
|
} |
|
804
|
804
|
} |
|
805
|
|
- $BCCmail=''; |
|
806
|
|
- if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
807
|
|
- foreach($folderArray as $folderName) { |
|
808
|
|
- if($this->mail->isSentFolder($folderName)) { |
|
|
805
|
+ $BCCmail = ''; |
|
|
806
|
+ if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
|
807
|
+ foreach ($folderArray as $folderName) { |
|
|
808
|
+ if ($this->mail->isSentFolder($folderName)) { |
|
809
|
809
|
$flags = '\\Seen'; |
|
810
|
|
- } elseif($this->mail->isDraftFolder($folderName)) { |
|
|
810
|
+ } elseif ($this->mail->isDraftFolder($folderName)) { |
|
811
|
811
|
$flags = '\\Draft'; |
|
812
|
812
|
} else { |
|
813
|
813
|
$flags = ''; |
|
814
|
814
|
} |
|
815
|
815
|
$asf = true; |
|
816
|
816
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
|
817
|
|
- $this->mail->openConnection(self::$profileID,false); |
|
|
817
|
+ $this->mail->openConnection(self::$profileID, false); |
|
818
|
818
|
if ($this->mail->folderExists($folderName)) { |
|
819
|
819
|
try |
|
820
|
820
|
{ |
|
821
|
|
- $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
|
821
|
+ $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
822
|
822
|
$flags); |
|
823
|
823
|
} |
|
824
|
824
|
catch (Api\Exception\WrongUserinput $e) |
|
825
|
825
|
{ |
|
826
|
826
|
//$asf = false; |
|
827
|
|
- 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())); |
|
|
827
|
+ 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())); |
|
828
|
828
|
} |
|
829
|
829
|
} |
|
830
|
830
|
else |
|
831
|
831
|
{ |
|
832
|
832
|
//$asf = false; |
|
833
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
|
833
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
834
|
834
|
} |
|
835
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
|
835
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
836
|
836
|
} |
|
837
|
837
|
//$this->mail->closeConnection(); |
|
838
|
838
|
} |
|
839
|
839
|
} |
|
840
|
840
|
|
|
841
|
|
- $this->debugLevel=0; |
|
|
841
|
+ $this->debugLevel = 0; |
|
842
|
842
|
|
|
843
|
843
|
if ($send && $asf) |
|
844
|
844
|
{ |
|
845
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
|
845
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
846
|
846
|
return true; |
|
847
|
847
|
} |
|
848
|
848
|
else |
|
849
|
849
|
{ |
|
850
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
851
|
|
- return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
|
850
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
|
851
|
+ return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
852
|
852
|
} |
|
853
|
853
|
} |
|
854
|
854
|
|
|
@@ -866,43 +866,43 @@ discard block |
|
|
block discarded – undo |
|
866
|
866
|
public function GetMessage($folderid, $id, $contentparameters) |
|
867
|
867
|
{ |
|
868
|
868
|
//$this->debugLevel=4; |
|
869
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
|
869
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
870
|
870
|
$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
|
871
|
871
|
$mimesupport = $contentparameters->GetMimeSupport(); |
|
872
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
|
872
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
873
|
873
|
$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
|
874
|
874
|
|
|
875
|
875
|
// fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
|
876
|
876
|
if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
|
877
|
877
|
|
|
878
|
878
|
//$this->debugLevel=4; |
|
879
|
|
- if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
880
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
|
879
|
+ if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
|
880
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
881
|
881
|
$account = $_folderName = $xid = null; |
|
882
|
|
- $this->splitID($folderid,$account,$_folderName,$xid); |
|
|
882
|
+ $this->splitID($folderid, $account, $_folderName, $xid); |
|
883
|
883
|
$this->mail->reopen($_folderName); |
|
884
|
|
- $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
|
884
|
+ $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
885
|
885
|
$headers = $messages[$id]; |
|
886
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
|
886
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers)); |
|
887
|
887
|
// StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
|
888
|
888
|
if ($headers) |
|
889
|
889
|
{ |
|
890
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
|
890
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
891
|
891
|
// initialize the object |
|
892
|
892
|
$output = new SyncMail(); |
|
893
|
893
|
//$rawHeaders = $this->mail->getMessageRawHeader($id); |
|
894
|
894
|
// simple style |
|
895
|
895
|
// start AS12 Stuff (bodypreference === false) case = old behaviour |
|
896
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
|
896
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
897
|
897
|
|
|
898
|
898
|
if ($bodypreference === false) { |
|
899
|
|
- $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
900
|
|
- $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
|
899
|
+ $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
|
900
|
+ $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
901
|
901
|
//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
|
902
|
|
- if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
|
902
|
+ if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
903
|
903
|
// remove all other html |
|
904
|
904
|
$body = strip_tags($raw_body); |
|
905
|
|
- if(strlen($body) > $truncsize) { |
|
|
905
|
+ if (strlen($body) > $truncsize) { |
|
906
|
906
|
$body = Utils::Utf8_truncate($body, $truncsize); |
|
907
|
907
|
$output->bodytruncated = 1; |
|
908
|
908
|
} |
|
@@ -916,7 +916,7 @@ discard block |
|
|
block discarded – undo |
|
916
|
916
|
else // style with bodypreferences |
|
917
|
917
|
{ |
|
918
|
918
|
//Select body type preference |
|
919
|
|
- $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
|
919
|
+ $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
920
|
920
|
if ($bodypreference !== false) { |
|
921
|
921
|
// bodypreference can occur multiple times |
|
922
|
922
|
// usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
|
@@ -930,12 +930,12 @@ discard block |
|
|
block discarded – undo |
|
930
|
930
|
} |
|
931
|
931
|
*/ |
|
932
|
932
|
} |
|
933
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
|
933
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
934
|
934
|
// set the protocoll class |
|
935
|
935
|
$output->asbody = new SyncBaseBody(); |
|
936
|
936
|
|
|
937
|
937
|
// return full mime-message without any (charset) conversation directly as stream |
|
938
|
|
- if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
|
938
|
+ if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) |
|
939
|
939
|
{ |
|
940
|
940
|
//SYNC_BODYPREFERENCE_MIME |
|
941
|
941
|
$output->asbody->type = SYNC_BODYPREFERENCE_MIME; |
|
@@ -944,58 +944,58 @@ discard block |
|
|
block discarded – undo |
|
944
|
944
|
fseek($stream, 0, SEEK_SET); |
|
945
|
945
|
$output->asbody->data = $stream; |
|
946
|
946
|
$output->asbody->estimatedDataSize = $fstat['size']; |
|
947
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
|
947
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
948
|
948
|
} |
|
949
|
949
|
else |
|
950
|
950
|
{ |
|
951
|
951
|
// fetch the body (try to gather data only once) |
|
952
|
|
- $css =''; |
|
953
|
|
- $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
954
|
|
- if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
955
|
|
- $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
956
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
957
|
|
- if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
|
952
|
+ $css = ''; |
|
|
953
|
+ $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
|
954
|
+ if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
|
955
|
+ $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
|
956
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
|
957
|
+ if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
958
|
958
|
// may be html |
|
959
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
|
959
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
960
|
960
|
$css = $this->mail->getStyles($bodyStruct); |
|
961
|
|
- $output->nativebodytype=2; |
|
|
961
|
+ $output->nativebodytype = 2; |
|
962
|
962
|
} else { |
|
963
|
963
|
// plain text Message |
|
964
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
965
|
|
- $output->nativebodytype=1; |
|
966
|
|
- $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
967
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
968
|
|
- $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
969
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
|
964
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
|
965
|
+ $output->nativebodytype = 1; |
|
|
966
|
+ $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
|
967
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
|
968
|
+ $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
|
969
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
970
|
970
|
} |
|
971
|
971
|
// whatever format decode (using the correct encoding) |
|
972
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
|
972
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
973
|
973
|
//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
|
974
|
974
|
// prepare plaintextbody |
|
975
|
|
- $plainBody=''; |
|
|
975
|
+ $plainBody = ''; |
|
976
|
976
|
if ($output->nativebodytype == 2) |
|
977
|
977
|
{ |
|
978
|
|
- $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
979
|
|
- if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
|
978
|
+ $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
|
979
|
+ if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
980
|
980
|
{ |
|
981
|
981
|
$plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
|
982
|
982
|
} |
|
983
|
983
|
else |
|
984
|
984
|
{ |
|
985
|
|
- $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
|
985
|
+ $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
986
|
986
|
} |
|
987
|
987
|
} |
|
988
|
988
|
//if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body); |
|
989
|
|
- $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
|
989
|
+ $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
990
|
990
|
// remove all other html |
|
991
|
|
- $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
|
991
|
+ $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
992
|
992
|
$plainBody = strip_tags($plainBody); |
|
993
|
|
- if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
|
993
|
+ if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
994
|
994
|
//$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
|
995
|
995
|
|
|
996
|
|
- if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
|
996
|
+ if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
997
|
997
|
{ |
|
998
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
|
998
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
999
|
999
|
// Send HTML if requested and native type was html |
|
1000
|
1000
|
$output->asbody->type = 2; |
|
1001
|
1001
|
$htmlbody = '<html>'. |
|
@@ -1005,23 +1005,23 @@ discard block |
|
|
block discarded – undo |
|
1005
|
1005
|
$css. |
|
1006
|
1006
|
'</head>'. |
|
1007
|
1007
|
'<body>'; |
|
1008
|
|
- if ($output->nativebodytype==2) |
|
|
1008
|
+ if ($output->nativebodytype == 2) |
|
1009
|
1009
|
{ |
|
1010
|
|
- if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
|
1010
|
+ if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style'); |
|
1011
|
1011
|
// as we fetch html, and body is HTML, we may not need to handle this |
|
1012
|
1012
|
$htmlbody .= $body; |
|
1013
|
1013
|
} |
|
1014
|
1014
|
else |
|
1015
|
1015
|
{ |
|
1016
|
1016
|
// html requested but got only plaintext, so fake html |
|
1017
|
|
- $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
|
1017
|
+ $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
1018
|
1018
|
} |
|
1019
|
1019
|
$htmlbody .= '</body>'. |
|
1020
|
1020
|
'</html>'; |
|
1021
|
1021
|
|
|
1022
|
|
- if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
|
1022
|
+ if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
1023
|
1023
|
{ |
|
1024
|
|
- $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
|
1024
|
+ $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
1025
|
1025
|
$output->asbody->truncated = 1; |
|
1026
|
1026
|
} |
|
1027
|
1027
|
// output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
|
@@ -1032,7 +1032,7 @@ discard block |
|
|
block discarded – undo |
|
1032
|
1032
|
else |
|
1033
|
1033
|
{ |
|
1034
|
1034
|
// Send Plaintext as Fallback or if original body is plainttext |
|
1035
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
|
1035
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
1036
|
1036
|
/* we use plainBody (set above) instead |
|
1037
|
1037
|
$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
|
1038
|
1038
|
$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
|
@@ -1042,7 +1042,7 @@ discard block |
|
|
block discarded – undo |
|
1042
|
1042
|
*/ |
|
1043
|
1043
|
$output->asbody->type = 1; |
|
1044
|
1044
|
$output->nativebodytype = 1; |
|
1045
|
|
- if(isset($truncsize) && |
|
|
1045
|
+ if (isset($truncsize) && |
|
1046
|
1046
|
strlen($plainBody) > $truncsize) |
|
1047
|
1047
|
{ |
|
1048
|
1048
|
$plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
|
@@ -1061,7 +1061,7 @@ discard block |
|
|
block discarded – undo |
|
1061
|
1061
|
} |
|
1062
|
1062
|
} |
|
1063
|
1063
|
// end AS12 Stuff |
|
1064
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
|
1064
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
1065
|
1065
|
$output->read = $headers["flags"]; |
|
1066
|
1066
|
|
|
1067
|
1067
|
$output->flag = new SyncMailFlags(); |
|
@@ -1081,9 +1081,8 @@ discard block |
|
|
block discarded – undo |
|
1081
|
1081
|
$output->lastverexecuted = AS_FORWARD; |
|
1082
|
1082
|
} |
|
1083
|
1083
|
$output->subject = $headers['subject']; |
|
1084
|
|
- $output->importance = $headers['priority'] > 3 ? 0 : |
|
1085
|
|
- ($headers['priority'] < 3 ? 2 : 1) ; |
|
1086
|
|
- $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
|
|
1084
|
+ $output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1); |
|
|
1085
|
+ $output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true); |
|
1087
|
1086
|
$output->to = $headers['to_address']; |
|
1088
|
1087
|
if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
|
1089
|
1088
|
$output->from = $headers['sender_address']; |
|
@@ -1091,8 +1090,8 @@ discard block |
|
|
block discarded – undo |
|
1091
|
1090
|
if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
|
1092
|
1091
|
|
|
1093
|
1092
|
$output->messageclass = "IPM.Note"; |
|
1094
|
|
- if (stripos($headers['mimetype'],'multipart')!== false && |
|
1095
|
|
- stripos($headers['mimetype'],'signed')!== false) |
|
|
1093
|
+ if (stripos($headers['mimetype'], 'multipart') !== false && |
|
|
1094
|
+ stripos($headers['mimetype'], 'signed') !== false) |
|
1096
|
1095
|
{ |
|
1097
|
1096
|
$output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
|
1098
|
1097
|
} |
|
@@ -1101,20 +1100,20 @@ discard block |
|
|
block discarded – undo |
|
1101
|
1100
|
} |
|
1102
|
1101
|
|
|
1103
|
1102
|
// start handle Attachments (include text/calendar multipart alternative) |
|
1104
|
|
- $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
|
1103
|
+ $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
1105
|
1104
|
// Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
|
1106
|
|
- if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
|
1105
|
+ if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
1107
|
1106
|
{ |
|
1108
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
|
1107
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
1109
|
1108
|
//error_log(__METHOD__.__LINE__.array2string($attachments)); |
|
1110
|
1109
|
foreach ($attachments as $key => $attach) |
|
1111
|
1110
|
{ |
|
1112
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
|
1111
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1113
|
1112
|
|
|
1114
|
1113
|
// pass meeting requests to calendar plugin |
|
1115
|
1114
|
if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
|
1116
|
1115
|
isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
|
1117
|
|
- ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
|
1116
|
+ ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
1118
|
1117
|
($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
|
1119
|
1118
|
{ |
|
1120
|
1119
|
//overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
|
@@ -1124,7 +1123,7 @@ discard block |
|
|
block discarded – undo |
|
1124
|
1123
|
$output->messageclass = "IPM.Schedule.Meeting.Request"; |
|
1125
|
1124
|
//$output->messageclass = "IPM.Schedule.Meeting"; |
|
1126
|
1125
|
unset($attachment); |
|
1127
|
|
- continue; // do NOT add attachment as attachment |
|
|
1126
|
+ continue; // do NOT add attachment as attachment |
|
1128
|
1127
|
} |
|
1129
|
1128
|
if (Request::GetProtocolVersion() >= 12.0) { |
|
1130
|
1129
|
$attachment = new SyncBaseAttachment(); |
|
@@ -1132,33 +1131,33 @@ discard block |
|
|
block discarded – undo |
|
1132
|
1131
|
$output->asattachments = array(); |
|
1133
|
1132
|
$attachment->estimatedDataSize = $attach['size']; |
|
1134
|
1133
|
$attachment->method = 1; |
|
1135
|
|
- $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
|
1134
|
+ $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
1136
|
1135
|
} else { |
|
1137
|
1136
|
$attachment = new SyncAttachment(); |
|
1138
|
1137
|
if (!isset($output->attachments) || !is_array($output->attachments)) |
|
1139
|
1138
|
$output->attachments = array(); |
|
1140
|
1139
|
$attachment->attsize = $attach['size']; |
|
1141
|
1140
|
$attachment->attmethod = 1; |
|
1142
|
|
- $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
|
1141
|
+ $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
1143
|
1142
|
} |
|
1144
|
1143
|
|
|
1145
|
1144
|
$attachment->displayname = $attach['name']; |
|
1146
|
1145
|
//error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
|
1147
|
1146
|
|
|
1148
|
|
- $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
|
1147
|
+ $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1149
|
1148
|
//$attachment->isinline=0; // if not inline, do not use isinline |
|
1150
|
|
- if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
|
1149
|
+ if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
1151
|
1150
|
{ |
|
1152
|
1151
|
if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
|
1153
|
1152
|
{ |
|
1154
|
1153
|
$attachment->isinline = true; |
|
1155
|
1154
|
} |
|
1156
|
1155
|
if (Request::GetProtocolVersion() >= 12.0) { |
|
1157
|
|
- $attachment->method=1; |
|
1158
|
|
- $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
|
1156
|
+ $attachment->method = 1; |
|
|
1157
|
+ $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
1159
|
1158
|
} else { |
|
1160
|
|
- $attachment->attmethod=6; |
|
1161
|
|
- $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
|
1159
|
+ $attachment->attmethod = 6; |
|
|
1160
|
+ $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
1162
|
1161
|
} |
|
1163
|
1162
|
// ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."' ".$attachment->contentid); |
|
1164
|
1163
|
$attachment->contenttype = trim($attach['mimeType']); |
|
@@ -1179,7 +1178,7 @@ discard block |
|
|
block discarded – undo |
|
1179
|
1178
|
// Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
|
1180
|
1179
|
$output->internetcpid = INTERNET_CPID_UTF8; |
|
1181
|
1180
|
|
|
1182
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
|
1181
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
1183
|
1182
|
//$this->debugLevel=0; |
|
1184
|
1183
|
return $output; |
|
1185
|
1184
|
} |
|
@@ -1202,30 +1201,30 @@ discard block |
|
|
block discarded – undo |
|
1202
|
1201
|
{ |
|
1203
|
1202
|
if (!class_exists('calendar_zpush')) |
|
1204
|
1203
|
{ |
|
1205
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
|
1204
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
1206
|
1205
|
return null; |
|
1207
|
1206
|
} |
|
1208
|
1207
|
if (!($stat = $this->StatMessage($folderid, $requestid))) |
|
1209
|
1208
|
{ |
|
1210
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
|
1209
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
1211
|
1210
|
return false; |
|
1212
|
1211
|
} |
|
1213
|
1212
|
$ret = false; |
|
1214
|
|
- foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
|
1213
|
+ foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
1215
|
1214
|
{ |
|
1216
|
1215
|
if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
|
1217
|
|
- ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
|
1216
|
+ ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
1218
|
1217
|
{ |
|
1219
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
|
1218
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
1220
|
1219
|
|
|
1221
|
1220
|
// calling backend again with iCal attachment, to let calendar add the event |
|
1222
|
1221
|
$ret = $this->backend->MeetingResponse($attachment['attachment'], |
|
1223
|
|
- $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
|
1222
|
+ $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
1224
|
1223
|
$response); |
|
1225
|
1224
|
break; |
|
1226
|
1225
|
} |
|
1227
|
1226
|
} |
|
1228
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
|
1227
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
1229
|
1228
|
return $ret; |
|
1230
|
1229
|
} |
|
1231
|
1230
|
|
|
@@ -1239,9 +1238,9 @@ discard block |
|
|
block discarded – undo |
|
1239
|
1238
|
* @param string $attname - should contain (folder)id |
|
1240
|
1239
|
* @return SyncItemOperationsAttachment-object |
|
1241
|
1240
|
*/ |
|
1242
|
|
- function GetAttachmentData($fid,$attname) { |
|
1243
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
1244
|
|
- return $this->_GetAttachmentData($fid,$attname); |
|
|
1241
|
+ function GetAttachmentData($fid, $attname) { |
|
|
1242
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
|
1243
|
+ return $this->_GetAttachmentData($fid, $attname); |
|
1245
|
1244
|
} |
|
1246
|
1245
|
|
|
1247
|
1246
|
/** |
|
@@ -1254,9 +1253,9 @@ discard block |
|
|
block discarded – undo |
|
1254
|
1253
|
* @param string $attname - should contain (folder)id |
|
1255
|
1254
|
* @return SyncItemOperationsAttachment-object |
|
1256
|
1255
|
*/ |
|
1257
|
|
- function ItemOperationsGetAttachmentData($fid,$attname) { |
|
1258
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
1259
|
|
- return $this->_GetAttachmentData($fid,$attname); |
|
|
1256
|
+ function ItemOperationsGetAttachmentData($fid, $attname) { |
|
|
1257
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
|
1258
|
+ return $this->_GetAttachmentData($fid, $attname); |
|
1260
|
1259
|
} |
|
1261
|
1260
|
|
|
1262
|
1261
|
/** |
|
@@ -1268,23 +1267,23 @@ discard block |
|
|
block discarded – undo |
|
1268
|
1267
|
* @param string $attname - should contain (folder)id |
|
1269
|
1268
|
* @return SyncItemOperationsAttachment-object |
|
1270
|
1269
|
*/ |
|
1271
|
|
- private function _GetAttachmentData($fid,$attname) |
|
|
1270
|
+ private function _GetAttachmentData($fid, $attname) |
|
1272
|
1271
|
{ |
|
1273
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
|
1272
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
1274
|
1273
|
//error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
|
1275
|
1274
|
list($folderid, $id, $part) = explode(":", $attname); |
|
1276
|
1275
|
|
|
1277
|
1276
|
$this->splitID($folderid, $account, $folder); |
|
1278
|
1277
|
|
|
1279
|
|
- if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
|
1278
|
+ if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1280
|
1279
|
|
|
1281
|
1280
|
$this->mail->reopen($folder); |
|
1282
|
|
- $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
|
1281
|
+ $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
1283
|
1282
|
$SIOattachment = new SyncItemOperationsAttachment(); |
|
1284
|
|
- fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
|
1283
|
+ fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
1285
|
1284
|
$SIOattachment->data = $attachment['attachment']; |
|
1286
|
1285
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
|
1287
|
|
- if (isset($attachment['type']) ) |
|
|
1286
|
+ if (isset($attachment['type'])) |
|
1288
|
1287
|
$SIOattachment->contenttype = $attachment['type']; |
|
1289
|
1288
|
|
|
1290
|
1289
|
unset($attachment); |
|
@@ -1327,17 +1326,17 @@ discard block |
|
|
block discarded – undo |
|
1327
|
1326
|
*/ |
|
1328
|
1327
|
function ChangeMessage($folderid, $id, $message, $contentParameters) |
|
1329
|
1328
|
{ |
|
1330
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
|
1329
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
1331
|
1330
|
//unset($folderid, $id, $message, $contentParameters); |
|
1332
|
1331
|
$account = $folder = null; |
|
1333
|
1332
|
$this->splitID($folderid, $account, $folder); |
|
1334
|
1333
|
if (isset($message->flag)) { |
|
1335
|
1334
|
if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
|
1336
|
|
- $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
1337
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
|
1335
|
+ $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
|
1336
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
1338
|
1337
|
} else { |
|
1339
|
|
- $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
1340
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
|
1338
|
+ $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
|
1339
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
1341
|
1340
|
} |
|
1342
|
1341
|
} |
|
1343
|
1342
|
return $this->StatMessage($folderid, $id); |
|
@@ -1359,23 +1358,23 @@ discard block |
|
|
block discarded – undo |
|
1359
|
1358
|
*/ |
|
1360
|
1359
|
public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
|
1361
|
1360
|
{ |
|
1362
|
|
- unset($contentParameters); // not used, but required by function signature |
|
|
1361
|
+ unset($contentParameters); // not used, but required by function signature |
|
1363
|
1362
|
ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
|
1364
|
1363
|
$account = $srcFolder = $destFolder = null; |
|
1365
|
1364
|
$this->splitID($folderid, $account, $srcFolder); |
|
1366
|
1365
|
$this->splitID($newfolderid, $account, $destFolder); |
|
1367
|
1366
|
ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
|
1368
|
|
- if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
|
1367
|
+ if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1369
|
1368
|
$this->mail->reopen($destFolder); |
|
1370
|
1369
|
$status = $this->mail->getFolderStatus($destFolder); |
|
1371
|
1370
|
$uidNext = $status['uidnext']; |
|
1372
|
1371
|
$this->mail->reopen($srcFolder); |
|
1373
|
1372
|
|
|
1374
|
1373
|
// move message |
|
1375
|
|
- $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
1376
|
|
- 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 |
|
|
1374
|
+ $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
|
1375
|
+ 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 |
|
1377
|
1376
|
// return the new id "as string" |
|
1378
|
|
- return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
|
1377
|
+ return ($rv === true ? $uidNext : $rv[$id]).""; |
|
1379
|
1378
|
} |
|
1380
|
1379
|
|
|
1381
|
1380
|
/** |
|
@@ -1383,7 +1382,7 @@ discard block |
|
|
block discarded – undo |
|
1383
|
1382
|
* |
|
1384
|
1383
|
* @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks |
|
1385
|
1384
|
*/ |
|
1386
|
|
- public function GetMessageList($folderid, $cutoffdate=NULL) |
|
|
1385
|
+ public function GetMessageList($folderid, $cutoffdate = NULL) |
|
1387
|
1386
|
{ |
|
1388
|
1387
|
if ($cutoffdate > 0) |
|
1389
|
1388
|
{ |
|
@@ -1396,8 +1395,8 @@ discard block |
|
|
block discarded – undo |
|
1396
|
1395
|
{ |
|
1397
|
1396
|
$maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
|
1398
|
1397
|
} |
|
1399
|
|
- $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
|
1400
|
|
- if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
|
1398
|
+ $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null); |
|
|
1399
|
+ if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
1401
|
1400
|
} |
|
1402
|
1401
|
return $this->fetchMessages($folderid, $cutoffdate); |
|
1403
|
1402
|
} |
|
@@ -1415,11 +1414,11 @@ discard block |
|
|
block discarded – undo |
|
1415
|
1414
|
* @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject" |
|
1416
|
1415
|
* @return array uid => array StatMessage($folderid, $_id) |
|
1417
|
1416
|
*/ |
|
1418
|
|
- private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false) |
|
|
1417
|
+ private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false) |
|
1419
|
1418
|
{ |
|
1420
|
1419
|
static $headers = array(); |
|
1421
|
1420
|
|
|
1422
|
|
- if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
|
1421
|
+ if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
1423
|
1422
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
1424
|
1423
|
$rv_messages = array(); |
|
1425
|
1424
|
// if the message is still available within the class, we use it instead of fetching it again |
|
@@ -1430,64 +1429,64 @@ discard block |
|
|
block discarded – undo |
|
1430
|
1429
|
} |
|
1431
|
1430
|
else |
|
1432
|
1431
|
{ |
|
1433
|
|
- $headers = array(); // clear cache to not use too much memory |
|
|
1432
|
+ $headers = array(); // clear cache to not use too much memory |
|
1434
|
1433
|
|
|
1435
|
|
- if ($this->debugLevel>1) $starttime = microtime (true); |
|
|
1434
|
+ if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1436
|
1435
|
$this->_connect($this->account); |
|
1437
|
|
- if ($this->debugLevel>1) |
|
|
1436
|
+ if ($this->debugLevel > 1) |
|
1438
|
1437
|
{ |
|
1439
|
1438
|
$endtime = microtime(true) - $starttime; |
|
1440
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
|
1439
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
1441
|
1440
|
} |
|
1442
|
1441
|
$messagelist = $_filter = array(); |
|
1443
|
1442
|
// if not connected, any further action must fail |
|
1444
|
|
- if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
1445
|
|
- if ($this->debugLevel>1) $starttime = microtime (true); |
|
|
1443
|
+ if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
|
1444
|
+ if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1446
|
1445
|
$account = $_folderName = $id = null; |
|
1447
|
|
- $this->splitID($folderid,$account,$_folderName,$id); |
|
1448
|
|
- if ($this->debugLevel>1) |
|
|
1446
|
+ $this->splitID($folderid, $account, $_folderName, $id); |
|
|
1447
|
+ if ($this->debugLevel > 1) |
|
1449
|
1448
|
{ |
|
1450
|
1449
|
$endtime = microtime(true) - $starttime; |
|
1451
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
|
1450
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1452
|
1451
|
} |
|
1453
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1454
|
|
- if ($this->debugLevel>1) $starttime = microtime (true); |
|
1455
|
|
- $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
1456
|
|
- $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
1457
|
|
- if ($this->debugLevel>1) |
|
|
1452
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
|
1453
|
+ if ($this->debugLevel > 1) $starttime = microtime(true); |
|
|
1454
|
+ $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
|
1455
|
+ $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
|
1456
|
+ if ($this->debugLevel > 1) |
|
1458
|
1457
|
{ |
|
1459
|
1458
|
$endtime = microtime(true) - $starttime; |
|
1460
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
|
1459
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1461
|
1460
|
} |
|
1462
|
1461
|
} |
|
1463
|
|
- if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
|
1462
|
+ if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
1464
|
1463
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
|
1465
|
1464
|
$messagelist = array(); |
|
1466
|
|
- if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
|
1465
|
+ if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
1467
|
1466
|
//if ($_returnModHash) $messageFolderHash = array(); |
|
1468
|
1467
|
foreach ((array)$rv_messages['header'] as $k => $vars) |
|
1469
|
1468
|
{ |
|
1470
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
|
1469
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1471
|
1470
|
$headers[$vars['uid']] = $vars; |
|
1472
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
|
1471
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1473
|
1472
|
if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
1474
|
1473
|
if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
1475
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
|
1474
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1476
|
1475
|
$mess = $return_all_headers ? $vars : array(); |
|
1477
|
1476
|
$mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
|
1478
|
1477
|
$mess["id"] = $vars['uid']; |
|
1479
|
1478
|
// 'seen' aka 'read' is the only flag we want to know about |
|
1480
|
1479
|
$mess["flags"] = 0; |
|
1481
|
1480
|
// outlook supports additional flags, set them to 0 |
|
1482
|
|
- if($vars["seen"]) $mess["flags"] = 1; |
|
1483
|
|
- if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
|
1481
|
+ if ($vars["seen"]) $mess["flags"] = 1; |
|
|
1482
|
+ if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
1484
|
1483
|
$messagelist[$vars['uid']] = $mess; |
|
1485
|
1484
|
unset($mess); |
|
1486
|
1485
|
} |
|
1487
|
|
- if ($this->debugLevel>1) |
|
|
1486
|
+ if ($this->debugLevel > 1) |
|
1488
|
1487
|
{ |
|
1489
|
1488
|
$endtime = microtime(true) - $gstarttime; |
|
1490
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
|
1489
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1491
|
1490
|
} |
|
1492
|
1491
|
return $messagelist; |
|
1493
|
1492
|
} |
|
@@ -1538,32 +1537,32 @@ discard block |
|
|
block discarded – undo |
|
1538
|
1537
|
public function getSearchResultsMailbox($_searchquery) |
|
1539
|
1538
|
{ |
|
1540
|
1539
|
//$this->debugLevel=1; |
|
1541
|
|
- $searchquery=$_searchquery->GetDataArray(); |
|
|
1540
|
+ $searchquery = $_searchquery->GetDataArray(); |
|
1542
|
1541
|
if (!is_array($searchquery)) return array(); |
|
1543
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
|
1542
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
1544
|
1543
|
|
|
1545
|
1544
|
if (isset($searchquery['searchrebuildresults'])) { |
|
1546
|
1545
|
$rebuildresults = $searchquery['searchrebuildresults']; |
|
1547
|
1546
|
} else { |
|
1548
|
1547
|
$rebuildresults = false; |
|
1549
|
1548
|
} |
|
1550
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
|
1549
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']'); |
|
1551
|
1550
|
|
|
1552
|
1551
|
if (isset($searchquery['deeptraversal'])) { |
|
1553
|
1552
|
$deeptraversal = $searchquery['deeptraversal']; |
|
1554
|
1553
|
} else { |
|
1555
|
1554
|
$deeptraversal = false; |
|
1556
|
1555
|
} |
|
1557
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
|
1556
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']'); |
|
1558
|
1557
|
|
|
1559
|
1558
|
if (isset($searchquery['searchrange'])) { |
|
1560
|
|
- $range = explode("-",$_searchquery->GetSearchRange()); |
|
1561
|
|
- $start =$range[0] + 1; |
|
|
1559
|
+ $range = explode("-", $_searchquery->GetSearchRange()); |
|
|
1560
|
+ $start = $range[0] + 1; |
|
1562
|
1561
|
$limit = $range[1] - $range[0] + 1; |
|
1563
|
1562
|
} else { |
|
1564
|
1563
|
$range = false; |
|
1565
|
1564
|
} |
|
1566
|
|
- if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
|
1565
|
+ if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']'); |
|
1567
|
1566
|
|
|
1568
|
1567
|
//foreach($searchquery['query'] as $k => $value) { |
|
1569
|
1568
|
// $query = $value; |
|
@@ -1586,15 +1585,15 @@ discard block |
|
|
block discarded – undo |
|
1586
|
1585
|
} |
|
1587
|
1586
|
if (!$folderid) |
|
1588
|
1587
|
{ |
|
1589
|
|
- $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
1590
|
|
- $folderid = $this->createID($account=0,$_folderName); |
|
|
1588
|
+ $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
|
1589
|
+ $folderid = $this->createID($account = 0, $_folderName); |
|
1591
|
1590
|
} |
|
1592
|
|
- $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
1593
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
|
1591
|
+ $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
|
1592
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
1594
|
1593
|
$this->_connect($account); |
|
1595
|
1594
|
// this should not be needed ??? |
|
1596
|
|
- Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
1597
|
|
- $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
|
1595
|
+ Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
|
1596
|
+ $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
1598
|
1597
|
'string'=> $searchText, |
|
1599
|
1598
|
'status'=>'any' |
|
1600
|
1599
|
); |
|
@@ -1609,22 +1608,22 @@ discard block |
|
|
block discarded – undo |
|
1609
|
1608
|
* [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
|
1610
|
1609
|
*/ |
|
1611
|
1610
|
$_filter['range'] = "BETWEEN"; |
|
1612
|
|
- list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
1613
|
|
- list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
1614
|
|
- $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
1615
|
|
- $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
|
1611
|
+ list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
|
1612
|
+ list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
|
1613
|
+ $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
|
1614
|
+ $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
1616
|
1615
|
} |
|
1617
|
1616
|
//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
1618
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1619
|
|
- $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
|
1617
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
|
1618
|
+ $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
1620
|
1619
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
|
1621
|
|
- $list=array(); |
|
|
1620
|
+ $list = array(); |
|
1622
|
1621
|
|
|
1623
|
1622
|
$cnt = count($rv_messages['header']); |
|
1624
|
1623
|
//$list['status'] = 1; |
|
1625
|
1624
|
$list['searchtotal'] = $cnt; |
|
1626
|
1625
|
$list["range"] = $_searchquery->GetSearchRange(); |
|
1627
|
|
- foreach((array)$rv_messages['header'] as $i => $vars) |
|
|
1626
|
+ foreach ((array)$rv_messages['header'] as $i => $vars) |
|
1628
|
1627
|
{ |
|
1629
|
1628
|
$list[] = array( |
|
1630
|
1629
|
"class" => "Email", |
|
@@ -1644,20 +1643,20 @@ discard block |
|
|
block discarded – undo |
|
1644
|
1643
|
* @param string $folder |
|
1645
|
1644
|
* @return string |
|
1646
|
1645
|
*/ |
|
1647
|
|
- private function getParentID($account,$folder) |
|
|
1646
|
+ private function getParentID($account, $folder) |
|
1648
|
1647
|
{ |
|
1649
|
1648
|
$this->_connect($account); |
|
1650
|
|
- if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
|
1649
|
+ if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1651
|
1650
|
|
|
1652
|
1651
|
$mailFolder = $this->folders[$folder]; |
|
1653
|
1652
|
if (!isset($mailFolder)) return false; |
|
1654
|
|
- $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
1655
|
|
- $parent = explode($delimiter,$folder); |
|
|
1653
|
+ $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
|
1654
|
+ $parent = explode($delimiter, $folder); |
|
1656
|
1655
|
array_pop($parent); |
|
1657
|
|
- $parent = implode($delimiter,$parent); |
|
|
1656
|
+ $parent = implode($delimiter, $parent); |
|
1658
|
1657
|
|
|
1659
|
1658
|
$id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
|
1660
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
|
1659
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1661
|
1660
|
return $id; |
|
1662
|
1661
|
} |
|
1663
|
1662
|
|
|
@@ -1677,48 +1676,48 @@ discard block |
|
|
block discarded – undo |
|
1677
|
1676
|
$account = $folder = null; |
|
1678
|
1677
|
$this->splitID($id, $account, $folder); |
|
1679
|
1678
|
} |
|
1680
|
|
- catch(Exception $e) { |
|
1681
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
1682
|
|
- return $folderObj=false; |
|
|
1679
|
+ catch (Exception $e) { |
|
|
1680
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
|
1681
|
+ return $folderObj = false; |
|
1683
|
1682
|
} |
|
1684
|
1683
|
$this->_connect($account); |
|
1685
|
|
- if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
|
1684
|
+ if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1686
|
1685
|
|
|
1687
|
1686
|
$mailFolder = $this->folders[$folder]; |
|
1688
|
|
- if (!isset($mailFolder)) return $folderObj=false; |
|
|
1687
|
+ if (!isset($mailFolder)) return $folderObj = false; |
|
1689
|
1688
|
|
|
1690
|
1689
|
$folderObj = new SyncFolder(); |
|
1691
|
1690
|
$folderObj->serverid = $id; |
|
1692
|
|
- $folderObj->parentid = $this->getParentID($account,$folder); |
|
|
1691
|
+ $folderObj->parentid = $this->getParentID($account, $folder); |
|
1693
|
1692
|
$folderObj->displayname = $mailFolder->shortDisplayName; |
|
1694
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
|
1693
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1695
|
1694
|
// get folder-type |
|
1696
|
|
- foreach($this->folders as $inbox => $mailFolder) break; |
|
|
1695
|
+ foreach ($this->folders as $inbox => $mailFolder) break; |
|
1697
|
1696
|
if ($folder == $inbox) |
|
1698
|
1697
|
{ |
|
1699
|
1698
|
$folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
|
1700
|
1699
|
} |
|
1701
|
|
- elseif($this->mail->isDraftFolder($folder, false, true)) |
|
|
1700
|
+ elseif ($this->mail->isDraftFolder($folder, false, true)) |
|
1702
|
1701
|
{ |
|
1703
|
1702
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
|
1704
|
1703
|
$folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
|
1705
|
1704
|
$folderObj->parentid = 0; // required by devices |
|
1706
|
1705
|
} |
|
1707
|
|
- elseif($this->mail->isTrashFolder($folder, false, true)) |
|
|
1706
|
+ elseif ($this->mail->isTrashFolder($folder, false, true)) |
|
1708
|
1707
|
{ |
|
1709
|
1708
|
$folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
|
1710
|
1709
|
$this->_wasteID = $folder; |
|
1711
|
1710
|
//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
|
1712
|
1711
|
$folderObj->parentid = 0; // required by devices |
|
1713
|
1712
|
} |
|
1714
|
|
- elseif($this->mail->isSentFolder($folder, false, true)) |
|
|
1713
|
+ elseif ($this->mail->isSentFolder($folder, false, true)) |
|
1715
|
1714
|
{ |
|
1716
|
1715
|
$folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
|
1717
|
1716
|
$folderObj->parentid = 0; // required by devices |
|
1718
|
1717
|
$this->_sentID = $folder; |
|
1719
|
1718
|
//error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
|
1720
|
1719
|
} |
|
1721
|
|
- elseif($this->mail->isOutbox($folder, false, true)) |
|
|
1720
|
+ elseif ($this->mail->isOutbox($folder, false, true)) |
|
1722
|
1721
|
{ |
|
1723
|
1722
|
//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
|
1724
|
1723
|
$folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
|
@@ -1730,7 +1729,7 @@ discard block |
|
|
block discarded – undo |
|
1730
|
1729
|
$folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
|
1731
|
1730
|
} |
|
1732
|
1731
|
|
|
1733
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
|
1732
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1734
|
1733
|
return $folderObj; |
|
1735
|
1734
|
} |
|
1736
|
1735
|
|
|
@@ -1778,18 +1777,18 @@ discard block |
|
|
block discarded – undo |
|
1778
|
1777
|
|
|
1779
|
1778
|
if ($type != 'mail') return false; |
|
1780
|
1779
|
|
|
1781
|
|
- if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
|
1780
|
+ if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1782
|
1781
|
|
|
1783
|
1782
|
$this->mail->reopen($folder); |
|
1784
|
1783
|
|
|
1785
|
|
- if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true))) |
|
|
1784
|
+ if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true))) |
|
1786
|
1785
|
{ |
|
1787
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
|
1786
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
1788
|
1787
|
return false; |
|
1789
|
1788
|
} |
|
1790
|
|
- $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
|
1789
|
+ $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1791
|
1790
|
|
|
1792
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
|
1791
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
1793
|
1792
|
return array(); |
|
1794
|
1793
|
} |
|
1795
|
1794
|
|
|
@@ -1802,8 +1801,8 @@ discard block |
|
|
block discarded – undo |
|
1802
|
1801
|
function GetWasteBasket() |
|
1803
|
1802
|
{ |
|
1804
|
1803
|
$this->_connect($this->account); |
|
1805
|
|
- $id = $this->createID($account=0, $this->_wasteID); |
|
1806
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
|
1804
|
+ $id = $this->createID($account = 0, $this->_wasteID); |
|
|
1805
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
1807
|
1806
|
return $id; |
|
1808
|
1807
|
} |
|
1809
|
1808
|
|
|
@@ -1824,7 +1823,7 @@ discard block |
|
|
block discarded – undo |
|
1824
|
1823
|
*/ |
|
1825
|
1824
|
public function DeleteMessage($folderid, $id, $contentParameters) |
|
1826
|
1825
|
{ |
|
1827
|
|
- unset($contentParameters); // not used, but required by function signature |
|
|
1826
|
+ unset($contentParameters); // not used, but required by function signature |
|
1828
|
1827
|
ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
|
1829
|
1828
|
/* |
|
1830
|
1829
|
$this->imap_reopenFolder($folderid); |
|
@@ -1835,7 +1834,7 @@ discard block |
|
|
block discarded – undo |
|
1835
|
1834
|
// we may have to split folderid |
|
1836
|
1835
|
$account = $folder = null; |
|
1837
|
1836
|
$this->splitID($folderid, $account, $folder); |
|
1838
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
|
1837
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
1839
|
1838
|
$_messageUID = (array)$id; |
|
1840
|
1839
|
|
|
1841
|
1840
|
$this->_connect($this->account); |
|
@@ -1847,9 +1846,9 @@ discard block |
|
|
block discarded – undo |
|
1847
|
1846
|
catch (Api\Exception $e) |
|
1848
|
1847
|
{ |
|
1849
|
1848
|
$error = $e->getMessage(); |
|
1850
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
|
1849
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
1851
|
1850
|
// if the server thinks the message does not exist report deletion as success |
|
1852
|
|
- if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
|
1851
|
+ if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
1853
|
1852
|
return false; |
|
1854
|
1853
|
} |
|
1855
|
1854
|
|
|
@@ -1883,15 +1882,15 @@ discard block |
|
|
block discarded – undo |
|
1883
|
1882
|
*/ |
|
1884
|
1883
|
public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
|
1885
|
1884
|
{ |
|
1886
|
|
- unset($contentParameters); // not used, but required by function signature |
|
|
1885
|
+ unset($contentParameters); // not used, but required by function signature |
|
1887
|
1886
|
// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
|
1888
|
1887
|
$account = $folder = null; |
|
1889
|
1888
|
$this->splitID($folderid, $account, $folder); |
|
1890
|
1889
|
|
|
1891
|
1890
|
$_messageUID = (array)$id; |
|
1892
|
1891
|
$this->_connect($this->account); |
|
1893
|
|
- $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
1894
|
|
- ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
|
1892
|
+ $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
|
1893
|
+ ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
1895
|
1894
|
|
|
1896
|
1895
|
return $rv; |
|
1897
|
1896
|
} |
|
@@ -1909,7 +1908,7 @@ discard block |
|
|
block discarded – undo |
|
1909
|
1908
|
*/ |
|
1910
|
1909
|
public function ChangeFolder($id, $oldid, $displayname, $type) |
|
1911
|
1910
|
{ |
|
1912
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
|
1911
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
1913
|
1912
|
$account = $parent_id = null; |
|
1914
|
1913
|
$this->splitID($id, $account, $parentFolder, $app); |
|
1915
|
1914
|
|
|
@@ -1926,17 +1925,17 @@ discard block |
|
|
block discarded – undo |
|
1926
|
1925
|
$this->splitID($oldid, $account, $oldFolder, $app); |
|
1927
|
1926
|
$old_hash = $this->folder2hash($account, $oldFolder); |
|
1928
|
1927
|
} |
|
1929
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid?"=>($oldFolder ($old_hash))":'').", '$displayname', $type)"); |
|
|
1928
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid ? "=>($oldFolder ($old_hash))" : '').", '$displayname', $type)"); |
|
1930
|
1929
|
$this->_connect($this->account); |
|
1931
|
1930
|
try |
|
1932
|
1931
|
{ |
|
1933
|
|
- if ($action=='rename') |
|
|
1932
|
+ if ($action == 'rename') |
|
1934
|
1933
|
{ |
|
1935
|
1934
|
$newFolderName = $this->mail->renameFolder($oldFolder, $parentFolder, $displayname); |
|
1936
|
1935
|
} |
|
1937
|
|
- elseif ($action=='create') |
|
|
1936
|
+ elseif ($action == 'create') |
|
1938
|
1937
|
{ |
|
1939
|
|
- $error=null; |
|
|
1938
|
+ $error = null; |
|
1940
|
1939
|
$newFolderName = $this->mail->createFolder($parentFolder, $displayname, $error); |
|
1941
|
1940
|
} |
|
1942
|
1941
|
} |
|
@@ -1948,7 +1947,7 @@ discard block |
|
|
block discarded – undo |
|
1948
|
1947
|
$newHash = $this->rename_folder_hash($account, $old_hash, $newFolderName); |
|
1949
|
1948
|
$newID = $this->createID($account, $newHash); |
|
1950
|
1949
|
|
|
1951
|
|
- ZLog::Write(LOGLEVEL_DEBUG,":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid?"=>($oldFolder)":'').", '$displayname' => $newFolderName (ID:$newID))"); |
|
|
1950
|
+ ZLog::Write(LOGLEVEL_DEBUG, ":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid ? "=>($oldFolder)" : '').", '$displayname' => $newFolderName (ID:$newID))"); |
|
1952
|
1951
|
return $this->StatFolder($newID); |
|
1953
|
1952
|
} |
|
1954
|
1953
|
|
|
@@ -1961,13 +1960,13 @@ discard block |
|
|
block discarded – undo |
|
1961
|
1960
|
* @throws StatusException could throw specific SYNC_FSSTATUS_* exceptions |
|
1962
|
1961
|
* @return boolean true or false on error |
|
1963
|
1962
|
*/ |
|
1964
|
|
- public function DeleteFolder($id, $parentid=false) |
|
|
1963
|
+ public function DeleteFolder($id, $parentid = false) |
|
1965
|
1964
|
{ |
|
1966
|
1965
|
$account = $parent_id = $app = null; |
|
1967
|
1966
|
$this->splitID($id, $account, $folder, $app); |
|
1968
|
1967
|
$old_hash = $this->folder2hash($account, $folder); |
|
1969
|
1968
|
if ($parentid) $this->splitID($parentid, $account, $parentfolder, $app); |
|
1970
|
|
- ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."( '$id (-> $folder)','$parentid ".($parentid?'(->'.$parentfolder.')':'')."') called!"); |
|
|
1969
|
+ ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."( '$id (-> $folder)','$parentid ".($parentid ? '(->'.$parentfolder.')' : '')."') called!"); |
|
1971
|
1970
|
$ret = $this->mail->deleteFolder($folder); |
|
1972
|
1971
|
if ($ret) $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
|
1973
|
1972
|
return $ret; |
|
@@ -1989,8 +1988,8 @@ discard block |
|
|
block discarded – undo |
|
1989
|
1988
|
$this->_connect($this->account); |
|
1990
|
1989
|
$account = $folder = null; |
|
1991
|
1990
|
$this->splitID($folderid, $account, $folder); |
|
1992
|
|
- $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
1993
|
|
- ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
|
1991
|
+ $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
|
1992
|
+ ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
1994
|
1993
|
|
|
1995
|
1994
|
return $rv; |
|
1996
|
1995
|
} |
|
@@ -2004,17 +2003,17 @@ discard block |
|
|
block discarded – undo |
|
2004
|
2003
|
* @return string |
|
2005
|
2004
|
* @throws Api\Exception\WrongParameter |
|
2006
|
2005
|
*/ |
|
2007
|
|
- private function createID($account,$folder,$id=0) |
|
|
2006
|
+ private function createID($account, $folder, $id = 0) |
|
2008
|
2007
|
{ |
|
2009
|
2008
|
if (!is_numeric($folder)) |
|
2010
|
2009
|
{ |
|
2011
|
2010
|
// convert string $folder in numeric id |
|
2012
|
|
- $folder = $this->folder2hash($account,$f=$folder); |
|
|
2011
|
+ $folder = $this->folder2hash($account, $f = $folder); |
|
2013
|
2012
|
} |
|
2014
|
2013
|
|
|
2015
|
2014
|
$str = $this->backend->createID($account, $folder, $id); |
|
2016
|
2015
|
|
|
2017
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
|
2016
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
2018
|
2017
|
|
|
2019
|
2018
|
return $str; |
|
2020
|
2019
|
} |
|
@@ -2028,14 +2027,14 @@ discard block |
|
|
block discarded – undo |
|
2028
|
2027
|
* @param int &$appid=null (for mail=mail is to be expected) |
|
2029
|
2028
|
* @throws Api\Exception\WrongParameter |
|
2030
|
2029
|
*/ |
|
2031
|
|
- private function splitID($str,&$account,&$folder,&$appid=null) |
|
|
2030
|
+ private function splitID($str, &$account, &$folder, &$appid = null) |
|
2032
|
2031
|
{ |
|
2033
|
2032
|
$this->backend->splitID($str, $account, $folder, $appid); |
|
2034
|
2033
|
|
|
2035
|
2034
|
// convert numeric folder-id back to folder name |
|
2036
|
|
- $folder = $this->hash2folder($account,$f=$folder); |
|
|
2035
|
+ $folder = $this->hash2folder($account, $f = $folder); |
|
2037
|
2036
|
|
|
2038
|
|
- if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
|
2037
|
+ if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$appid)"); |
|
2039
|
2038
|
} |
|
2040
|
2039
|
|
|
2041
|
2040
|
/** |
|
@@ -2052,9 +2051,9 @@ discard block |
|
|
block discarded – undo |
|
2052
|
2051
|
* @param string $folder |
|
2053
|
2052
|
* @return int |
|
2054
|
2053
|
*/ |
|
2055
|
|
- private function folder2hash($account,$folder) |
|
|
2054
|
+ private function folder2hash($account, $folder) |
|
2056
|
2055
|
{ |
|
2057
|
|
- if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
|
2056
|
+ if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
2058
|
2057
|
|
|
2059
|
2058
|
if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
|
2060
|
2059
|
{ |
|
@@ -2075,9 +2074,9 @@ discard block |
|
|
block discarded – undo |
|
2075
|
2074
|
* @param int $index |
|
2076
|
2075
|
* @return string NULL if not used so far |
|
2077
|
2076
|
*/ |
|
2078
|
|
- private function hash2folder($account,$index) |
|
|
2077
|
+ private function hash2folder($account, $index) |
|
2079
|
2078
|
{ |
|
2080
|
|
- if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
|
2079
|
+ if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
2081
|
2080
|
|
|
2082
|
2081
|
return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
|
2083
|
2082
|
} |
|
@@ -2133,9 +2132,9 @@ discard block |
|
|
block discarded – undo |
|
2133
|
2132
|
if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
|
2134
|
2133
|
($hashes = file_get_contents($file))) |
|
2135
|
2134
|
{ |
|
2136
|
|
- $this->folderHashes = json_decode($hashes,true); |
|
|
2135
|
+ $this->folderHashes = json_decode($hashes, true); |
|
2137
|
2136
|
// fallback in case hashes have been serialized instead of being json-encoded |
|
2138
|
|
- if (json_last_error()!=JSON_ERROR_NONE) |
|
|
2137
|
+ if (json_last_error() != JSON_ERROR_NONE) |
|
2139
|
2138
|
{ |
|
2140
|
2139
|
//error_log(__METHOD__.__LINE__." error decoding with json"); |
|
2141
|
2140
|
$this->folderHashes = unserialize($hashes); |
|
@@ -2181,9 +2180,9 @@ discard block |
|
|
block discarded – undo |
|
2181
|
2180
|
* @param boolean $old =false true: return old / pre-15 hash-file |
|
2182
|
2181
|
* @throws Api\Exception\AssertionFailed |
|
2183
|
2182
|
*/ |
|
2184
|
|
- private function hashFile($old=false) |
|
|
2183
|
+ private function hashFile($old = false) |
|
2185
|
2184
|
{ |
|
2186
|
|
- if (!($dev_id=Request::GetDeviceID())) |
|
|
2185
|
+ if (!($dev_id = Request::GetDeviceID())) |
|
2187
|
2186
|
{ |
|
2188
|
2187
|
throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
|
2189
|
2188
|
} |