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