Completed
Push — master ( 3e1f76...0e9327 )
by Klaus
234:48 queued 208:11
created
mail/inc/class.mail_zpush.inc.php 1 patch
Spacing   +343 added lines, -344 removed lines patch added patch discarded remove patch
@@ -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,58 +384,58 @@  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
 
410 410
 		// initialize the new Api\Mailer object for sending
411 411
 		$mailObject = new Api\Mailer(self::$profileID);
412
-		$this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime);
412
+		$this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime);
413 413
 		// Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8
414
-		$mailObject->Sender  = $activeMailProfile['ident_email'];
415
-		$mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false));
414
+		$mailObject->Sender = $activeMailProfile['ident_email'];
415
+		$mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false));
416 416
 		$mailObject->addHeader('X-Mailer', 'mail-Activesync');
417 417
 
418 418
 
419 419
 		// prepare addressee list; moved the adding of addresses to the mailobject down
420 420
 		// to
421 421
 
422
-		foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
422
+		foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
423 423
 			if (!$addressObject->valid) continue;
424
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) );
424
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject));
425 425
 			//$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
426 426
 			$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
427 427
 		}
428 428
 		// CC
429
-		foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
429
+		foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) {
430 430
 			if (!$addressObject->valid) continue;
431
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) );
431
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject));
432 432
 			//$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
433 433
 			$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
434 434
 		}
435 435
 		// BCC
436
-		foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
436
+		foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) {
437 437
 			if (!$addressObject->valid) continue;
438
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) );
438
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject));
439 439
 			//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
440 440
 			$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
441 441
 		}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		$use_orgbody = false;
445 445
 
446 446
 		$k = 'Content-Type';
447
-		$ContentType =$mailObject->getHeader('Content-Type');
447
+		$ContentType = $mailObject->getHeader('Content-Type');
448 448
 		//error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k.  " = ".trim($ContentType));
449 449
 		// if the message is a multipart message, then we should use the sent body
450 450
 		if (preg_match("/multipart/i", $ContentType)) {
@@ -464,43 +464,43 @@  discard block
 block discarded – undo
464 464
 			$k == "Content-Type" && preg_match("/multipart/i", $ContentType))) {
465 465
 			$use_orgbody = true;
466 466
 		}
467
-		$Body =  $AltBody = "";
467
+		$Body = $AltBody = "";
468 468
 		// get body of the transmitted message
469 469
 		// if this is a simple message, no structure at all
470 470
 		if (preg_match("/text/i", $ContentType))
471 471
 		{
472
-			$simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain');
472
+			$simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain');
473 473
 			$bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain');
474
-			$body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null);
475
-			if  ($simpleBodyType == "text/plain")
474
+			$body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null);
475
+			if ($simpleBodyType == "text/plain")
476 476
 			{
477 477
 				$Body = $body;
478 478
 				$AltBody = "<pre>".nl2br($body)."</pre>";
479
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody');
479
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody');
480 480
 			}
481 481
 			else
482 482
 			{
483 483
 				$AltBody = $body;
484
-				$Body =  trim(Api\Mail\Html::convertHTMLToText($body));
485
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body');
484
+				$Body = trim(Api\Mail\Html::convertHTMLToText($body));
485
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body');
486 486
 			}
487 487
 		}
488 488
 		else
489 489
 		{
490 490
 			// if this is a structured message
491 491
 			// prefer plain over html
492
-			$Body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
492
+			$Body = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]",
493 493
 				($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null);
494
-			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i","[$2]",
494
+			$AltBody = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/i", "[$2]",
495 495
 				($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null);
496 496
 		}
497
-		if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body);
498
-		if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody);
497
+		if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body);
498
+		if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody);
499 499
 		//error_log(__METHOD__.__LINE__.array2string($mailObject));
500 500
 		// if this is a multipart message with a boundary, we must use the original body
501 501
 		//if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject));
502 502
         if ($use_orgbody) {
503
-    	    ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
503
+    	    ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType);
504 504
  			// if it is a ClientSideMeetingRequest, we report it as send at all times
505 505
 			if (($cal_body = $mailObject->findBody('calendar')) &&
506 506
 				($cSMRMethod = $cal_body->getContentTypeParameter('method')))
@@ -509,21 +509,21 @@  discard block
 block discarded – undo
509 509
 				{
510 510
 					$organizer = calendar_ical::getIcalOrganizer($cal_body->getContents());
511 511
 				}
512
-				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
512
+				if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer");
513 513
 				$ClientSideMeetingRequest = true;
514 514
 			}
515 515
         }
516 516
 		// now handle the addressee list
517 517
 		$toCount = 0;
518 518
 		//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
519
-		foreach((array)$toMailAddr as $address) {
520
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
521
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
519
+		foreach ((array)$toMailAddr as $address) {
520
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
521
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
522 522
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' &&
523 523
 					calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST',
524 524
 						$organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : ''))
525 525
 				{
526
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app");
526
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app");
527 527
 					continue;
528 528
 				}
529 529
 				$mailObject->AddAddress($emailAddress, $addressObject->personal);
@@ -531,29 +531,29 @@  discard block
 block discarded – undo
531 531
 			}
532 532
 		}
533 533
 		$ccCount = 0;
534
-		foreach((array)$ccMailAddr as $address) {
535
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
536
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
534
+		foreach ((array)$ccMailAddr as $address) {
535
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
536
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
537 537
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
538 538
 				$mailObject->AddCC($emailAddress, $addressObject->personal);
539 539
 				$ccCount++;
540 540
 			}
541 541
 		}
542 542
 		$bccCount = 0;
543
-		foreach((array)$bccMailAddr as $address) {
544
-			foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
545
-				$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
543
+		foreach ((array)$bccMailAddr as $address) {
544
+			foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
545
+				$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
546 546
 				if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
547 547
 				$mailObject->AddBCC($emailAddress, $addressObject->personal);
548 548
 				$bccCount++;
549 549
 			}
550 550
 		}
551 551
 		// typical organizer reply will end here with nothing send --> return true, because we suppressed the send above
552
-		if ($toCount+$ccCount+$bccCount == 0)
552
+		if ($toCount + $ccCount + $bccCount == 0)
553 553
 		{
554 554
 			return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to
555 555
 		}
556
-		if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true;
556
+		if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true;
557 557
 		// as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail
558 558
 /*
559 559
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body);
@@ -561,29 +561,29 @@  discard block
 block discarded – undo
561 561
 		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body (modified):'.$body);
562 562
 */
563 563
 		// add signature!! -----------------------------------------------------------------
564
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile));
564
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile));
565 565
 		try
566 566
 		{
567 567
 			$acc = Mail\Account::read($this->mail->icServer->ImapServerId);
568 568
 			//error_log(__METHOD__.__LINE__.array2string($acc));
569
-			$_signature = Mail\Account::read_identity($acc['ident_id'],true);
569
+			$_signature = Mail\Account::read_identity($acc['ident_id'], true);
570 570
 		}
571 571
 		catch (Exception $e)
572 572
 		{
573
-			$_signature=array();
573
+			$_signature = array();
574 574
 		}
575 575
 		$signature = $_signature['ident_signature'];
576 576
 		if ((isset($preferencesArray['disableRulerForSignatureSeparation']) &&
577 577
 			$preferencesArray['disableRulerForSignatureSeparation']) ||
578
-			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='')
578
+			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '')
579 579
 		{
580 580
 			$disableRuler = true;
581 581
 		}
582 582
 		$beforePlain = $beforeHtml = "";
583
-		$beforeHtml = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
584
-		$beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
585
-		$sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
586
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
583
+		$beforeHtml = ($disableRuler ? '&nbsp;<br>' : '&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
584
+		$beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
585
+		$sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
586
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText);
587 587
 		$sigTextHtml = $beforeHtml.$sigText;
588 588
 		$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText);
589 589
 		$isreply = $isforward = false;
@@ -595,26 +595,26 @@  discard block
 block discarded – undo
595 595
 		{
596 596
 			// now get on, and fetch the original mail
597 597
 			$uid = $smartdata->source->itemid;
598
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
598
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
599 599
 			$this->splitID($smartdata->source->folderid, $account, $folder);
600 600
 
601 601
 			$this->mail->reopen($folder);
602 602
 			$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
603
-			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
604
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
605
-		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
603
+			$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
604
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
605
+		    if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
606 606
 				// may be html
607
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
607
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
608 608
 				$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
609 609
 				$isreply = true;
610 610
 			}
611 611
 			// plain text Message part
612
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
612
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
613 613
 			// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
614
-			$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
615
-			$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
616
-			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
617
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
614
+			$bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display');
615
+			$bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
616
+			if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) {
617
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
618 618
 				$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
619 619
 				$isreply = true;
620 620
 			}
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 			{
623 623
 				$isreply = true;
624 624
 				$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
625
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
625
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
626 626
 			}
627 627
 		}
628 628
 
629 629
 		// how to forward and other prefs
630
-		$preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail'];
630
+		$preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail'];
631 631
 
632 632
 		// forward -------------------------------------------------------------------------
633 633
 		if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) &&
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 		{
638 638
 			//force the default for the forwarding -> asmail
639 639
 			if (is_array($preferencesArray)) {
640
-				if (!array_key_exists('message_forwarding',$preferencesArray)
640
+				if (!array_key_exists('message_forwarding', $preferencesArray)
641 641
 					|| !isset($preferencesArray['message_forwarding'])
642 642
 					|| empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail';
643 643
 			} else {
@@ -645,18 +645,18 @@  discard block
 block discarded – undo
645 645
 			}
646 646
 			// construct the uid of the message out of the itemid - seems to be the uid, no construction needed
647 647
 			$uid = $smartdata->source->itemid;
648
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
648
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
649 649
 			$this->splitID($smartdata->source->folderid, $account, $folder);
650 650
 
651 651
 			$this->mail->reopen($folder);
652 652
             // receive entire mail (header + body)
653 653
 			// get message headers for specified message
654
-			$headers	= $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
654
+			$headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder);
655 655
 			// build a new mime message, forward entire old mail as file
656 656
 			if ($preferencesArray['message_forwarding'] == 'asmail')
657 657
 			{
658
-				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder);
659
-				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder);
658
+				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder);
659
+				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder);
660 660
 				$mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822');
661 661
 				$AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml;
662 662
 				$Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain;
@@ -666,50 +666,50 @@  discard block
 block discarded – undo
666 666
 			{
667 667
 				// now get on, and fetch the original mail
668 668
 				$uid = $smartdata->source->itemid;
669
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
669
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
670 670
 				$this->splitID($smartdata->source->folderid, $account, $folder);
671 671
 
672 672
 				$this->mail->reopen($folder);
673 673
 				$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
674
-				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
675
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
676
-				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
674
+				$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
675
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
676
+				if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
677 677
 					// may be html
678
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
678
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml);
679 679
 					$AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml;
680 680
 					$isforward = true;
681 681
 				}
682 682
 				// plain text Message part
683
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
683
+				if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
684 684
 				// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
685
-				$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
686
-				$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
687
-				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
688
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
685
+				$bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display');
686
+				$bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
687
+				if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) {
688
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
689 689
 					$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
690 690
 					$isforward = true;
691 691
 				}
692 692
 				if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody))
693 693
 				{
694 694
 					$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
695
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
695
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
696 696
 					$isforward = true;
697 697
 				}
698 698
 				// get all the attachments and add them too.
699 699
 				// start handle Attachments
700 700
 				//												$_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName=''
701
-				$attachments = $this->mail->getMessageAttachments($uid, null,          null,								true,						false,				 true			, $folder);
701
+				$attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder);
702 702
 				$attachmentNames = false;
703
-				if (is_array($attachments) && count($attachments)>0)
703
+				if (is_array($attachments) && count($attachments) > 0)
704 704
 				{
705
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
706
-					foreach((array)$attachments as $key => $attachment)
705
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments));
706
+					foreach ((array)$attachments as $key => $attachment)
707 707
 					{
708
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
708
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
709 709
 						$attachmentNames .= $attachment['name']."\n";
710
-						$attachmentData	= $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder);
710
+						$attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder);
711 711
 						/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']);
712
-						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x);
712
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x);
713 713
 					}
714 714
 				}
715 715
 			}
@@ -723,36 +723,36 @@  discard block
 block discarded – undo
723 723
 		// now set the body
724 724
 		if ($AltBody && ($html_body = $mailObject->findBody('html')))
725 725
 		{
726
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody);
727
-			$html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
726
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody);
727
+			$html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
728 728
 		}
729 729
 		if ($Body && ($text_body = $mailObject->findBody('plain')))
730 730
 		{
731
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body);
732
-			$text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
731
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body);
732
+			$text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
733 733
 		}
734 734
 		//advanced debugging
735 735
 		// Horde SMTP Class uses utf-8 by default.
736 736
         //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1));
737
-		if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
737
+		if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject));
738 738
 
739 739
 		// set a higher timeout for big messages
740 740
 		@set_time_limit(120);
741
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....');
741
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....');
742 742
 		// send
743 743
 		$send = true;
744 744
 		try {
745 745
 			$mailObject->Send();
746 746
 		}
747
-		catch(Exception $e) {
748
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage());
747
+		catch (Exception $e) {
748
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage());
749 749
 			$send = false;
750 750
 		}
751 751
 
752
-		if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true)
752
+		if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true)
753 753
 		{
754 754
 			$uid = $smartdata->source->itemid;
755
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
755
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid);
756 756
 			$this->splitID($smartdata->source->folderid, $account, $folder);
757 757
 			//error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid);
758 758
 			$this->mail->reopen($folder);
@@ -760,89 +760,89 @@  discard block
 block discarded – undo
760 760
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
761 761
 			if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder))
762 762
 			{
763
-				$this->mail->deleteMessages(array($uid),$folder);
763
+				$this->mail->deleteMessages(array($uid), $folder);
764 764
 			} else {
765
-				$this->mail->flagMessages("answered", array($uid),$folder);
766
-				if ($smartdata_task== "forward")
765
+				$this->mail->flagMessages("answered", array($uid), $folder);
766
+				if ($smartdata_task == "forward")
767 767
 				{
768
-					$this->mail->flagMessages("forwarded", array($uid),$folder);
768
+					$this->mail->flagMessages("forwarded", array($uid), $folder);
769 769
 				}
770 770
 			}
771 771
 		}
772 772
 
773
-		$asf = ($send ? true:false); // initalize accordingly
774
-		if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */  $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only')
773
+		$asf = ($send ? true : false); // initalize accordingly
774
+		if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */  $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only')
775 775
 		{
776 776
 			$asf = false;
777 777
 			$sentFolder = $this->mail->getSentFolder();
778 778
 			if ($this->_sentID) {
779 779
 				$folderArray[] = $this->_sentID;
780 780
 			}
781
-			else if(isset($sentFolder) && $sentFolder != 'none')
781
+			else if (isset($sentFolder) && $sentFolder != 'none')
782 782
 			{
783 783
 				$folderArray[] = $sentFolder;
784 784
 			}
785 785
 			// No Sent folder set, try defaults
786 786
 			else
787 787
 			{
788
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set");
788
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set");
789 789
 				// we dont try guessing
790 790
 				$asf = true;
791 791
 			}
792 792
 			if (count($folderArray) > 0) {
793
-				foreach((array)$bccMailAddr as $address) {
794
-					foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
795
-						$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
793
+				foreach ((array)$bccMailAddr as $address) {
794
+					foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) {
795
+						$emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : '');
796 796
 						$mailAddr[] = array($emailAddress, $addressObject->personal);
797 797
 					}
798 798
 				}
799
-				$BCCmail='';
800
-				if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
801
-				foreach($folderArray as $folderName) {
802
-					if($this->mail->isSentFolder($folderName)) {
799
+				$BCCmail = '';
800
+				if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr);
801
+				foreach ($folderArray as $folderName) {
802
+					if ($this->mail->isSentFolder($folderName)) {
803 803
 						$flags = '\\Seen';
804
-					} elseif($this->mail->isDraftFolder($folderName)) {
804
+					} elseif ($this->mail->isDraftFolder($folderName)) {
805 805
 						$flags = '\\Draft';
806 806
 					} else {
807 807
 						$flags = '';
808 808
 					}
809 809
 					$asf = true;
810 810
 					//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer));
811
-					$this->mail->openConnection(self::$profileID,false);
811
+					$this->mail->openConnection(self::$profileID, false);
812 812
 					if ($this->mail->folderExists($folderName)) {
813 813
 						try
814 814
 						{
815
-							$this->mail->appendMessage($folderName,$mailObject->getRaw(), null,
815
+							$this->mail->appendMessage($folderName, $mailObject->getRaw(), null,
816 816
 									$flags);
817 817
 						}
818 818
 						catch (Api\Exception\WrongUserinput $e)
819 819
 						{
820 820
 							//$asf = false;
821
-							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()));
821
+							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()));
822 822
 						}
823 823
 					}
824 824
 					else
825 825
 					{
826 826
 						//$asf = false;
827
-						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName));
827
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName));
828 828
 					}
829
-			        ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed"));
829
+			        ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed"));
830 830
 				}
831 831
 				//$this->mail->closeConnection();
832 832
 			}
833 833
 		}
834 834
 
835
-		$this->debugLevel=0;
835
+		$this->debugLevel = 0;
836 836
 
837 837
 		if ($send && $asf)
838 838
 		{
839
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully');
839
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully');
840 840
 			return true;
841 841
 		}
842 842
 		else
843 843
 		{
844
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":""));
845
-			return ($ClientSideMeetingRequest ? true : 120);   //MAIL Submission failed, see MS-ASCMD
844
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : ""));
845
+			return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD
846 846
 		}
847 847
 	}
848 848
 
@@ -860,43 +860,43 @@  discard block
 block discarded – undo
860 860
 	public function GetMessage($folderid, $id, $contentparameters)
861 861
 	{
862 862
 		//$this->debugLevel=4;
863
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters));
863
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters));
864 864
 		$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
865 865
 		$mimesupport = $contentparameters->GetMimeSupport();
866
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport));
866
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport));
867 867
 		$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */
868 868
 
869 869
 		// fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0
870 870
 		if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]);
871 871
 
872 872
 		//$this->debugLevel=4;
873
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
874
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
873
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
874
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference));
875 875
 		$account = $_folderName = $xid = null;
876
-		$this->splitID($folderid,$account,$_folderName,$xid);
876
+		$this->splitID($folderid, $account, $_folderName, $xid);
877 877
 		$this->mail->reopen($_folderName);
878
-		$messages = $this->fetchMessages($folderid, NULL, $id, true);	// true: return all headers
878
+		$messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers
879 879
 		$headers = $messages[$id];
880
-		if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers));
880
+		if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers));
881 881
 		// StatMessage should reopen the folder in question, so we dont need folderids in the following statements.
882 882
 		if ($headers)
883 883
 		{
884
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers));
884
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers));
885 885
 			// initialize the object
886 886
 			$output = new SyncMail();
887 887
 			//$rawHeaders = $this->mail->getMessageRawHeader($id);
888 888
 			// simple style
889 889
 			// start AS12 Stuff (bodypreference === false) case = old behaviour
890
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
890
+			if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers));
891 891
 
892 892
 			if ($bodypreference === false) {
893
-				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
894
-				$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
893
+				$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName);
894
+				$raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
895 895
 				//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
896
-				if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
896
+				if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
897 897
 				// remove all other html
898 898
 				$body = strip_tags($raw_body);
899
-				if(strlen($body) > $truncsize) {
899
+				if (strlen($body) > $truncsize) {
900 900
 					$body = Utils::Utf8_truncate($body, $truncsize);
901 901
 					$output->bodytruncated = 1;
902 902
 				}
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			else // style with bodypreferences
911 911
 			{
912 912
 				//Select body type preference
913
-				$bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN;
913
+				$bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN;
914 914
 				if ($bodypreference !== false) {
915 915
 					// bodypreference can occur multiple times
916 916
 					// usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference);
@@ -924,12 +924,12 @@  discard block
 block discarded – undo
924 924
 					}
925 925
 */
926 926
 				}
927
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType));
927
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType));
928 928
 				// set the protocoll class
929 929
 				$output->asbody = new SyncBaseBody();
930 930
 
931 931
 				// return full mime-message without any (charset) conversation directly as stream
932
-				if ($bpReturnType==SYNC_BODYPREFERENCE_MIME)
932
+				if ($bpReturnType == SYNC_BODYPREFERENCE_MIME)
933 933
 				{
934 934
 					//SYNC_BODYPREFERENCE_MIME
935 935
 					$output->asbody->type = SYNC_BODYPREFERENCE_MIME;
@@ -938,58 +938,58 @@  discard block
 block discarded – undo
938 938
 					fseek($stream, 0, SEEK_SET);
939 939
 					$output->asbody->data = $stream;
940 940
 					$output->asbody->estimatedDataSize = $fstat['size'];
941
-					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]");
941
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]");
942 942
 				}
943 943
 				else
944 944
 				{
945 945
 					// fetch the body (try to gather data only once)
946
-					$css ='';
947
-					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
948
-					if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
949
-					$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
950
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
951
-					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
946
+					$css = '';
947
+					$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName);
948
+					if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
949
+					$body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false);
950
+					if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body);
951
+					if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) {
952 952
 						// may be html
953
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
953
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)');
954 954
 						$css = $this->mail->getStyles($bodyStruct);
955
-						$output->nativebodytype=2;
955
+						$output->nativebodytype = 2;
956 956
 					} else {
957 957
 						// plain text Message
958
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
959
-						$output->nativebodytype=1;
960
-						$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
961
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
962
-						$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
963
-						if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
958
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)');
959
+						$output->nativebodytype = 1;
960
+						$bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text');
961
+						if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
962
+						$body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false);
963
+						if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body);
964 964
 					}
965 965
 					// whatever format decode (using the correct encoding)
966
-					if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body);
966
+					if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body);
967 967
 					//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
968 968
 					// prepare plaintextbody
969
-					$plainBody='';
969
+					$plainBody = '';
970 970
 					if ($output->nativebodytype == 2)
971 971
 					{
972
-						$bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
973
-						if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1)
972
+						$bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text');
973
+						if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1)
974 974
 						{
975 975
 							$plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML
976 976
 						}
977 977
 						else
978 978
 						{
979
-							$plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false);
979
+							$plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false);
980 980
 						}
981 981
 					}
982 982
 					//if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body);
983
-					$plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body));
983
+					$plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body));
984 984
 					// remove all other html
985
-					$plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody);
985
+					$plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody);
986 986
 					$plainBody = strip_tags($plainBody);
987
-					if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody);
987
+					if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody);
988 988
 					//$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that?
989 989
 
990
-					if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML
990
+					if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML
991 991
 					{
992
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
992
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2");
993 993
 						// Send HTML if requested and native type was html
994 994
 						$output->asbody->type = 2;
995 995
 						$htmlbody = '<html>'.
@@ -999,23 +999,23 @@  discard block
 block discarded – undo
999 999
 							$css.
1000 1000
 							'</head>'.
1001 1001
 							'<body>';
1002
-						if ($output->nativebodytype==2)
1002
+						if ($output->nativebodytype == 2)
1003 1003
 						{
1004
-							if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style');
1004
+							if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style');
1005 1005
 							// as we fetch html, and body is HTML, we may not need to handle this
1006 1006
 							$htmlbody .= $body;
1007 1007
 						}
1008 1008
 						else
1009 1009
 						{
1010 1010
 							// html requested but got only plaintext, so fake html
1011
-							$htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody)));
1011
+							$htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody)));
1012 1012
 						}
1013 1013
 						$htmlbody .= '</body>'.
1014 1014
 								'</html>';
1015 1015
 
1016
-						if(isset($truncsize) && strlen($htmlbody) > $truncsize)
1016
+						if (isset($truncsize) && strlen($htmlbody) > $truncsize)
1017 1017
 						{
1018
-							$htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize);
1018
+							$htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize);
1019 1019
 							$output->asbody->truncated = 1;
1020 1020
 						}
1021 1021
 						// output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested.
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 					else
1027 1027
 					{
1028 1028
 						// Send Plaintext as Fallback or if original body is plainttext
1029
-						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1029
+						if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody);
1030 1030
 						/* we use plainBody (set above) instead
1031 1031
 						$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
1032 1032
 						$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 						*/
1037 1037
 						$output->asbody->type = 1;
1038 1038
 						$output->nativebodytype = 1;
1039
-						if(isset($truncsize) &&
1039
+						if (isset($truncsize) &&
1040 1040
 							strlen($plainBody) > $truncsize)
1041 1041
 						{
1042 1042
 							$plainBody = Utils::Utf8_truncate($plainBody, $truncsize);
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 				}
1056 1056
 			}
1057 1057
 			// end AS12 Stuff
1058
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']);
1058
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']);
1059 1059
 			$output->read = $headers["flags"];
1060 1060
 
1061 1061
 			$output->flag = new SyncMailFlags();
@@ -1075,9 +1075,8 @@  discard block
 block discarded – undo
1075 1075
 				$output->lastverexecuted = AS_FORWARD;
1076 1076
 			}
1077 1077
 			$output->subject = $headers['subject'];
1078
-			$output->importance = $headers['priority'] > 3 ? 0 :
1079
-				($headers['priority'] < 3 ? 2 : 1) ;
1080
-			$output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true);
1078
+			$output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1);
1079
+			$output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true);
1081 1080
 			$output->to = $headers['to_address'];
1082 1081
 			if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name']
1083 1082
 			$output->from = $headers['sender_address'];
@@ -1085,8 +1084,8 @@  discard block
 block discarded – undo
1085 1084
 			if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address'];
1086 1085
 
1087 1086
 			$output->messageclass = "IPM.Note";
1088
-			if (stripos($headers['mimetype'],'multipart')!== false &&
1089
-				stripos($headers['mimetype'],'signed')!== false)
1087
+			if (stripos($headers['mimetype'], 'multipart') !== false &&
1088
+				stripos($headers['mimetype'], 'signed') !== false)
1090 1089
 			{
1091 1090
 				$output->messageclass = "IPM.Note.SMIME.MultipartSigned";
1092 1091
 			}
@@ -1095,20 +1094,20 @@  discard block
 block discarded – undo
1095 1094
 			}
1096 1095
 
1097 1096
 			// start handle Attachments (include text/calendar multipart alternative)
1098
-			$attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName);
1097
+			$attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName);
1099 1098
 			// Attachments should not needed for MIME messages, so skip this part if bpReturnType==4
1100
-			if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0)
1099
+			if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0)
1101 1100
 			{
1102
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments));
1101
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments));
1103 1102
 				//error_log(__METHOD__.__LINE__.array2string($attachments));
1104 1103
 				foreach ($attachments as $key => $attach)
1105 1104
 				{
1106
-					if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1105
+					if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach));
1107 1106
 
1108 1107
 					// pass meeting requests to calendar plugin
1109 1108
 					if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
1110 1109
 						isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
1111
-						($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) &&
1110
+						($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) &&
1112 1111
 						($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment'])))
1113 1112
 					{
1114 1113
 						//overwrite the globalobjId from calendar object, as: if you delete the mail, that is
@@ -1118,7 +1117,7 @@  discard block
 block discarded – undo
1118 1117
 						$output->messageclass = "IPM.Schedule.Meeting.Request";
1119 1118
 						//$output->messageclass = "IPM.Schedule.Meeting";
1120 1119
 						unset($attachment);
1121
-						continue;	// do NOT add attachment as attachment
1120
+						continue; // do NOT add attachment as attachment
1122 1121
 					}
1123 1122
 					if (Request::GetProtocolVersion() >= 12.0) {
1124 1123
 						$attachment = new SyncBaseAttachment();
@@ -1126,33 +1125,33 @@  discard block
 block discarded – undo
1126 1125
 							$output->asattachments = array();
1127 1126
 						$attachment->estimatedDataSize = $attach['size'];
1128 1127
 						$attachment->method = 1;
1129
-						$attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID'];
1128
+						$attachment->filereference = $folderid.":".$id.":".$attach['partID'];
1130 1129
 					} else {
1131 1130
 						$attachment = new SyncAttachment();
1132 1131
 						if (!isset($output->attachments) || !is_array($output->attachments))
1133 1132
 							$output->attachments = array();
1134 1133
 						$attachment->attsize = $attach['size'];
1135 1134
 						$attachment->attmethod = 1;
1136
-						$attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key;
1135
+						$attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key;
1137 1136
 					}
1138 1137
 
1139 1138
 					$attachment->displayname = $attach['name'];
1140 1139
 					//error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']);
1141 1140
 
1142
-					$attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : "";
1141
+					$attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : "";
1143 1142
 					//$attachment->isinline=0; // if not inline, do not use isinline
1144
-					if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' )
1143
+					if (!empty($attach['cid']) && $attach['cid'] <> 'NIL')
1145 1144
 					{
1146 1145
 						if ($bpReturnType != 4 && $attach['disposition'] == 'inline')
1147 1146
 						{
1148 1147
 							$attachment->isinline = true;
1149 1148
 						}
1150 1149
 						if (Request::GetProtocolVersion() >= 12.0) {
1151
-							$attachment->method=1;
1152
-							$attachment->contentid= str_replace(array("<",">"), "",$attach['cid']);
1150
+							$attachment->method = 1;
1151
+							$attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']);
1153 1152
 						} else {
1154
-							$attachment->attmethod=6;
1155
-							$attachment->attoid = str_replace(array("<",">"), "",$attach['cid']);
1153
+							$attachment->attmethod = 6;
1154
+							$attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']);
1156 1155
 						}
1157 1156
 						//	ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."'  ".$attachment->contentid);
1158 1157
 						$attachment->contenttype = trim($attach['mimeType']);
@@ -1173,7 +1172,7 @@  discard block
 block discarded – undo
1173 1172
             // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
1174 1173
             $output->internetcpid = INTERNET_CPID_UTF8;
1175 1174
 
1176
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output));
1175
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output));
1177 1176
 //$this->debugLevel=0;
1178 1177
 			return $output;
1179 1178
 		}
@@ -1196,30 +1195,30 @@  discard block
 block discarded – undo
1196 1195
 	{
1197 1196
 		if (!class_exists('calendar_zpush'))
1198 1197
 		{
1199
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!");
1198
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!");
1200 1199
 			return null;
1201 1200
 		}
1202 1201
 		if (!($stat = $this->StatMessage($folderid, $requestid)))
1203 1202
 		{
1204
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)");
1203
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)");
1205 1204
 			return false;
1206 1205
 		}
1207 1206
 		$ret = false;
1208
-		foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach)
1207
+		foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach)
1209 1208
 		{
1210 1209
 			if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' &&
1211
-				($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false)))
1210
+				($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false)))
1212 1211
 			{
1213
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')");
1212
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')");
1214 1213
 
1215 1214
 				// calling backend again with iCal attachment, to let calendar add the event
1216 1215
 				$ret = $this->backend->MeetingResponse($attachment['attachment'],
1217
-					$this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']),
1216
+					$this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']),
1218 1217
 					$response);
1219 1218
 				break;
1220 1219
 			}
1221 1220
 		}
1222
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret));
1221
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret));
1223 1222
 		return $ret;
1224 1223
 	}
1225 1224
 
@@ -1233,9 +1232,9 @@  discard block
 block discarded – undo
1233 1232
      * @param string $attname - should contain (folder)id
1234 1233
 	 * @return SyncItemOperationsAttachment-object
1235 1234
 	 */
1236
-	function GetAttachmentData($fid,$attname) {
1237
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1238
-		return $this->_GetAttachmentData($fid,$attname);
1235
+	function GetAttachmentData($fid, $attname) {
1236
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')");
1237
+		return $this->_GetAttachmentData($fid, $attname);
1239 1238
 	}
1240 1239
 
1241 1240
 	/**
@@ -1248,9 +1247,9 @@  discard block
 block discarded – undo
1248 1247
      * @param string $attname - should contain (folder)id
1249 1248
 	 * @return SyncItemOperationsAttachment-object
1250 1249
 	 */
1251
-	function ItemOperationsGetAttachmentData($fid,$attname) {
1252
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')");
1253
-		return $this->_GetAttachmentData($fid,$attname);
1250
+	function ItemOperationsGetAttachmentData($fid, $attname) {
1251
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')");
1252
+		return $this->_GetAttachmentData($fid, $attname);
1254 1253
 	}
1255 1254
 
1256 1255
 	/**
@@ -1262,23 +1261,23 @@  discard block
 block discarded – undo
1262 1261
      * @param string $attname - should contain (folder)id
1263 1262
 	 * @return SyncItemOperationsAttachment-object
1264 1263
 	 */
1265
-	private function _GetAttachmentData($fid,$attname)
1264
+	private function _GetAttachmentData($fid, $attname)
1266 1265
 	{
1267
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace());
1266
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace());
1268 1267
 		//error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')");
1269 1268
 		list($folderid, $id, $part) = explode(":", $attname);
1270 1269
 
1271 1270
 		$this->splitID($folderid, $account, $folder);
1272 1271
 
1273
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1272
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1274 1273
 
1275 1274
 		$this->mail->reopen($folder);
1276
-		$attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder);
1275
+		$attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder);
1277 1276
 		$SIOattachment = new SyncItemOperationsAttachment();
1278
-		fseek($attachment['attachment'], 0, SEEK_SET);	// z-push requires stream seeked to start
1277
+		fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start
1279 1278
 		$SIOattachment->data = $attachment['attachment'];
1280 1279
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']);
1281
-		if (isset($attachment['type']) )
1280
+		if (isset($attachment['type']))
1282 1281
 			$SIOattachment->contenttype = $attachment['type'];
1283 1282
 
1284 1283
 		unset($attachment);
@@ -1321,17 +1320,17 @@  discard block
 block discarded – undo
1321 1320
 	 */
1322 1321
 	function ChangeMessage($folderid, $id, $message, $contentParameters)
1323 1322
 	{
1324
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters));
1323
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters));
1325 1324
 		//unset($folderid, $id, $message, $contentParameters);
1326 1325
 		$account = $folder = null;
1327 1326
 		$this->splitID($folderid, $account, $folder);
1328 1327
 		if (isset($message->flag)) {
1329 1328
 			if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) {
1330
-				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder);
1331
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1329
+				$rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder);
1330
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv);
1332 1331
 			} else {
1333
-				$rv = $this->mail->flagMessages("unflagged", $id,$folder);
1334
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv);
1332
+				$rv = $this->mail->flagMessages("unflagged", $id, $folder);
1333
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv);
1335 1334
 			}
1336 1335
 		}
1337 1336
 		return $this->StatMessage($folderid, $id);
@@ -1353,23 +1352,23 @@  discard block
 block discarded – undo
1353 1352
 	 */
1354 1353
 	public function MoveMessage($folderid, $id, $newfolderid, $contentParameters)
1355 1354
 	{
1356
-		unset($contentParameters);	// not used, but required by function signature
1355
+		unset($contentParameters); // not used, but required by function signature
1357 1356
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid'  id: '$id'  dfid: '$newfolderid' )");
1358 1357
 		$account = $srcFolder = $destFolder = null;
1359 1358
 		$this->splitID($folderid, $account, $srcFolder);
1360 1359
 		$this->splitID($newfolderid, $account, $destFolder);
1361 1360
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder'  id: '$id'  DestFolder: '$destFolder' )");
1362
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1361
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1363 1362
 		$this->mail->reopen($destFolder);
1364 1363
 		$status = $this->mail->getFolderStatus($destFolder);
1365 1364
 		$uidNext = $status['uidnext'];
1366 1365
 		$this->mail->reopen($srcFolder);
1367 1366
 
1368 1367
 		// move message
1369
-		$rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true);
1370
-		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
1368
+		$rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true);
1369
+		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
1371 1370
 		// return the new id "as string"
1372
-		return ($rv===true ? $uidNext : $rv[$id]) . "";
1371
+		return ($rv === true ? $uidNext : $rv[$id])."";
1373 1372
 	}
1374 1373
 
1375 1374
 	/**
@@ -1377,7 +1376,7 @@  discard block
 block discarded – undo
1377 1376
 	 *
1378 1377
 	 *  @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks
1379 1378
 	 */
1380
-	public function GetMessageList($folderid, $cutoffdate=NULL)
1379
+	public function GetMessageList($folderid, $cutoffdate = NULL)
1381 1380
 	{
1382 1381
 		if ($cutoffdate > 0)
1383 1382
 		{
@@ -1390,8 +1389,8 @@  discard block
 block discarded – undo
1390 1389
 			{
1391 1390
 				$maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange'];
1392 1391
 			}
1393
-			$cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null);
1394
-			if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
1392
+			$cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null);
1393
+			if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
1395 1394
 		}
1396 1395
 		return $this->fetchMessages($folderid, $cutoffdate);
1397 1396
 	}
@@ -1409,11 +1408,11 @@  discard block
 block discarded – undo
1409 1408
 	 * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject"
1410 1409
 	 * @return array uid => array StatMessage($folderid, $_id)
1411 1410
 	 */
1412
-	private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false)
1411
+	private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false)
1413 1412
 	{
1414 1413
 		static $headers = array();
1415 1414
 
1416
-		if ($this->debugLevel>1) $gstarttime = microtime (true);
1415
+		if ($this->debugLevel > 1) $gstarttime = microtime(true);
1417 1416
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__);
1418 1417
 		$rv_messages = array();
1419 1418
 		// if the message is still available within the class, we use it instead of fetching it again
@@ -1424,64 +1423,64 @@  discard block
 block discarded – undo
1424 1423
 		}
1425 1424
 		else
1426 1425
 		{
1427
-			$headers = array();	// clear cache to not use too much memory
1426
+			$headers = array(); // clear cache to not use too much memory
1428 1427
 
1429
-			if ($this->debugLevel>1) $starttime = microtime (true);
1428
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1430 1429
 			$this->_connect($this->account);
1431
-			if ($this->debugLevel>1)
1430
+			if ($this->debugLevel > 1)
1432 1431
 			{
1433 1432
 				$endtime = microtime(true) - $starttime;
1434
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account);
1433
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account);
1435 1434
 			}
1436 1435
 			$messagelist = $_filter = array();
1437 1436
 			// if not connected, any further action must fail
1438
-			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate));
1439
-			if ($this->debugLevel>1) $starttime = microtime (true);
1437
+			if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate));
1438
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1440 1439
 			$account = $_folderName = $id = null;
1441
-			$this->splitID($folderid,$account,$_folderName,$id);
1442
-			if ($this->debugLevel>1)
1440
+			$this->splitID($folderid, $account, $_folderName, $id);
1441
+			if ($this->debugLevel > 1)
1443 1442
 			{
1444 1443
 				$endtime = microtime(true) - $starttime;
1445
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid);
1444
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid);
1446 1445
 			}
1447
-			if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1448
-			if ($this->debugLevel>1) $starttime = microtime (true);
1449
-			$_numberOfMessages = (empty($cutoffdate)?250:99999);
1450
-			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id);
1451
-			if ($this->debugLevel>1)
1446
+			if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1447
+			if ($this->debugLevel > 1) $starttime = microtime(true);
1448
+			$_numberOfMessages = (empty($cutoffdate) ? 250 : 99999);
1449
+			$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id);
1450
+			if ($this->debugLevel > 1)
1452 1451
 			{
1453 1452
 				$endtime = microtime(true) - $starttime;
1454
-				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1453
+				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName);
1455 1454
 			}
1456 1455
 		}
1457
-		if ($_id == NULL && $this->debugLevel>1)  ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header']));
1456
+		if ($_id == NULL && $this->debugLevel > 1)  ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header']));
1458 1457
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages));
1459 1458
 		$messagelist = array();
1460
-		if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist;
1459
+		if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist;
1461 1460
 		//if ($_returnModHash) $messageFolderHash = array();
1462 1461
 		foreach ((array)$rv_messages['header'] as $k => $vars)
1463 1462
 		{
1464
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1463
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']);
1465 1464
 			$headers[$vars['uid']] = $vars;
1466
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1465
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars));
1467 1466
 			if (!empty($vars['deleted'])) continue; // cut of deleted messages
1468 1467
 			if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it
1469
-			if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1468
+			if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']);
1470 1469
 			$mess = $return_all_headers ? $vars : array();
1471 1470
 			$mess["mod"] = self::doFlagsMod($vars).$vars['date'];
1472 1471
 			$mess["id"] = $vars['uid'];
1473 1472
 			// 'seen' aka 'read' is the only flag we want to know about
1474 1473
 			$mess["flags"] = 0;
1475 1474
 			// outlook supports additional flags, set them to 0
1476
-			if($vars["seen"]) $mess["flags"] = 1;
1477
-			if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess));
1475
+			if ($vars["seen"]) $mess["flags"] = 1;
1476
+			if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess));
1478 1477
 			$messagelist[$vars['uid']] = $mess;
1479 1478
 			unset($mess);
1480 1479
 		}
1481
-		if ($this->debugLevel>1)
1480
+		if ($this->debugLevel > 1)
1482 1481
 		{
1483 1482
 			$endtime = microtime(true) - $gstarttime;
1484
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1483
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id);
1485 1484
 		}
1486 1485
 		return $messagelist;
1487 1486
 	}
@@ -1532,32 +1531,32 @@  discard block
 block discarded – undo
1532 1531
 	public function getSearchResultsMailbox($_searchquery)
1533 1532
 	{
1534 1533
 		//$this->debugLevel=1;
1535
-		$searchquery=$_searchquery->GetDataArray();
1534
+		$searchquery = $_searchquery->GetDataArray();
1536 1535
 		if (!is_array($searchquery)) return array();
1537
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery));
1536
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery));
1538 1537
 
1539 1538
 		if (isset($searchquery['searchrebuildresults'])) {
1540 1539
 			$rebuildresults = $searchquery['searchrebuildresults'];
1541 1540
 		} else {
1542 1541
 			$rebuildresults = false;
1543 1542
 		}
1544
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'RebuildResults ['.$rebuildresults.']' );
1543
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']');
1545 1544
 
1546 1545
 		if (isset($searchquery['deeptraversal'])) {
1547 1546
 			$deeptraversal = $searchquery['deeptraversal'];
1548 1547
 		} else {
1549 1548
 			$deeptraversal = false;
1550 1549
 		}
1551
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'DeepTraversal ['.$deeptraversal.']' );
1550
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']');
1552 1551
 
1553 1552
 		if (isset($searchquery['searchrange'])) {
1554
-			$range = explode("-",$_searchquery->GetSearchRange());
1555
-			$start =$range[0] + 1;
1553
+			$range = explode("-", $_searchquery->GetSearchRange());
1554
+			$start = $range[0] + 1;
1556 1555
 			$limit = $range[1] - $range[0] + 1;
1557 1556
 		} else {
1558 1557
 			$range = false;
1559 1558
 		}
1560
-		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,  'Range ['.print_r($range, true).']' );
1559
+		if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']');
1561 1560
 
1562 1561
 		//foreach($searchquery['query'] as $k => $value) {
1563 1562
 		//	$query = $value;
@@ -1580,15 +1579,15 @@  discard block
 block discarded – undo
1580 1579
 		}
1581 1580
 		if (!$folderid)
1582 1581
 		{
1583
-			$_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX');
1584
-			$folderid = $this->createID($account=0,$_folderName);
1582
+			$_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX');
1583
+			$folderid = $this->createID($account = 0, $_folderName);
1585 1584
 		}
1586
-		$rv = $this->splitID($folderid,$account,$_folderName,$id);
1587
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName);
1585
+		$rv = $this->splitID($folderid, $account, $_folderName, $id);
1586
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName);
1588 1587
 		$this->_connect($account);
1589 1588
 		// this should not be needed ???
1590
-		Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible)
1591
-		$_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'),
1589
+		Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible)
1590
+		$_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'),
1592 1591
 						 'string'=> $searchText,
1593 1592
 						 'status'=>'any'
1594 1593
 						);
@@ -1603,22 +1602,22 @@  discard block
 block discarded – undo
1603 1602
 		 * 		[searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE
1604 1603
 		 */
1605 1604
 			$_filter['range'] = "BETWEEN";
1606
-			list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']);
1607
-			list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']);
1608
-			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts'));
1609
-			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts'));
1605
+			list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']);
1606
+			list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']);
1607
+			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts'));
1608
+			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts'));
1610 1609
 		}
1611 1610
 		//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
1612
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1613
-		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL);
1611
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
1612
+		$rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL);
1614 1613
 		//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages));
1615
-		$list=array();
1614
+		$list = array();
1616 1615
 
1617 1616
 		$cnt = count($rv_messages['header']);
1618 1617
 		//$list['status'] = 1;
1619 1618
 		$list['searchtotal'] = $cnt;
1620 1619
 		$list["range"] = $_searchquery->GetSearchRange();
1621
-		foreach((array)$rv_messages['header'] as $i => $vars)
1620
+		foreach ((array)$rv_messages['header'] as $i => $vars)
1622 1621
 		{
1623 1622
 			$list[] = array(
1624 1623
 				"class" => "Email",
@@ -1638,20 +1637,20 @@  discard block
 block discarded – undo
1638 1637
 	 * @param string $folder
1639 1638
 	 * @return string
1640 1639
 	 */
1641
-	private function getParentID($account,$folder)
1640
+	private function getParentID($account, $folder)
1642 1641
 	{
1643 1642
 		$this->_connect($account);
1644
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1643
+		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false);
1645 1644
 
1646 1645
 		$mailFolder = $this->folders[$folder];
1647 1646
 		if (!isset($mailFolder)) return false;
1648
-		$delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter());
1649
-		$parent = explode($delimiter,$folder);
1647
+		$delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter());
1648
+		$parent = explode($delimiter, $folder);
1650 1649
 		array_pop($parent);
1651
-		$parent = implode($delimiter,$parent);
1650
+		$parent = implode($delimiter, $parent);
1652 1651
 
1653 1652
 		$id = $parent ? $this->createID($account, $parent) : '0';
1654
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
1653
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id");
1655 1654
 		return $id;
1656 1655
 	}
1657 1656
 
@@ -1671,48 +1670,48 @@  discard block
 block discarded – undo
1671 1670
 			$account = $folder = null;
1672 1671
 			$this->splitID($id, $account, $folder);
1673 1672
 		}
1674
-		catch(Exception $e) {
1675
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage());
1676
-			return $folderObj=false;
1673
+		catch (Exception $e) {
1674
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage());
1675
+			return $folderObj = false;
1677 1676
 		}
1678 1677
 		$this->_connect($account);
1679
-		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false);
1678
+		if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false);
1680 1679
 
1681 1680
 		$mailFolder = $this->folders[$folder];
1682
-		if (!isset($mailFolder)) return $folderObj=false;
1681
+		if (!isset($mailFolder)) return $folderObj = false;
1683 1682
 
1684 1683
 		$folderObj = new SyncFolder();
1685 1684
 		$folderObj->serverid = $id;
1686
-		$folderObj->parentid = $this->getParentID($account,$folder);
1685
+		$folderObj->parentid = $this->getParentID($account, $folder);
1687 1686
 		$folderObj->displayname = $mailFolder->shortDisplayName;
1688
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
1687
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder");
1689 1688
 		// get folder-type
1690
-		foreach($this->folders as $inbox => $mailFolder) break;
1689
+		foreach ($this->folders as $inbox => $mailFolder) break;
1691 1690
 		if ($folder == $inbox)
1692 1691
 		{
1693 1692
 			$folderObj->type = SYNC_FOLDER_TYPE_INBOX;
1694 1693
 		}
1695
-		elseif($this->mail->isDraftFolder($folder, false, true))
1694
+		elseif ($this->mail->isDraftFolder($folder, false, true))
1696 1695
 		{
1697 1696
 			//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft');
1698 1697
 			$folderObj->type = SYNC_FOLDER_TYPE_DRAFTS;
1699 1698
 			$folderObj->parentid = 0; // required by devices
1700 1699
 		}
1701
-		elseif($this->mail->isTrashFolder($folder, false, true))
1700
+		elseif ($this->mail->isTrashFolder($folder, false, true))
1702 1701
 		{
1703 1702
 			$folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET;
1704 1703
 			$this->_wasteID = $folder;
1705 1704
 			//error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID);
1706 1705
 			$folderObj->parentid = 0; // required by devices
1707 1706
 		}
1708
-		elseif($this->mail->isSentFolder($folder, false, true))
1707
+		elseif ($this->mail->isSentFolder($folder, false, true))
1709 1708
 		{
1710 1709
 			$folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL;
1711 1710
 			$folderObj->parentid = 0; // required by devices
1712 1711
 			$this->_sentID = $folder;
1713 1712
 			//error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID);
1714 1713
 		}
1715
-		elseif($this->mail->isOutbox($folder, false, true))
1714
+		elseif ($this->mail->isOutbox($folder, false, true))
1716 1715
 		{
1717 1716
 			//ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox');
1718 1717
 			$folderObj->type = SYNC_FOLDER_TYPE_OUTBOX;
@@ -1724,7 +1723,7 @@  discard block
 block discarded – undo
1724 1723
 			$folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL;
1725 1724
 		}
1726 1725
 
1727
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
1726
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname");
1728 1727
 		return $folderObj;
1729 1728
 	}
1730 1729
 
@@ -1772,18 +1771,18 @@  discard block
 block discarded – undo
1772 1771
 
1773 1772
 		if ($type != 'mail') return false;
1774 1773
 
1775
-		if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true);
1774
+		if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true);
1776 1775
 
1777 1776
         $this->mail->reopen($folder);
1778 1777
 
1779
-		if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true)))
1778
+		if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true)))
1780 1779
 		{
1781
-            ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder ");
1780
+            ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder ");
1782 1781
             return false;
1783 1782
         }
1784
-		$syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1783
+		$syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity'];
1785 1784
 
1786
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
1785
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate));
1787 1786
 		return array();
1788 1787
 	}
1789 1788
 
@@ -1796,8 +1795,8 @@  discard block
 block discarded – undo
1796 1795
 	function GetWasteBasket()
1797 1796
 	{
1798 1797
 		$this->_connect($this->account);
1799
-		$id = $this->createID($account=0, $this->_wasteID);
1800
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID");
1798
+		$id = $this->createID($account = 0, $this->_wasteID);
1799
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID");
1801 1800
 		return $id;
1802 1801
 	}
1803 1802
 
@@ -1818,7 +1817,7 @@  discard block
 block discarded – undo
1818 1817
      */
1819 1818
     public function DeleteMessage($folderid, $id, $contentParameters)
1820 1819
 	{
1821
-		unset($contentParameters);	// not used, but required by function signature
1820
+		unset($contentParameters); // not used, but required by function signature
1822 1821
 		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid'  id: '$id' )");
1823 1822
 		/*
1824 1823
 		$this->imap_reopenFolder($folderid);
@@ -1829,7 +1828,7 @@  discard block
 block discarded – undo
1829 1828
 		// we may have to split folderid
1830 1829
 		$account = $folder = null;
1831 1830
 		$this->splitID($folderid, $account, $folder);
1832
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder);
1831
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder);
1833 1832
 		$_messageUID = (array)$id;
1834 1833
 
1835 1834
 		$this->_connect($this->account);
@@ -1841,9 +1840,9 @@  discard block
 block discarded – undo
1841 1840
 		catch (Api\Exception $e)
1842 1841
 		{
1843 1842
 			$error = $e->getMessage();
1844
-			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1843
+			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error);
1845 1844
 			// if the server thinks the message does not exist report deletion as success
1846
-			if (stripos($error,'[NONEXISTENT]')!==false) return true;
1845
+			if (stripos($error, '[NONEXISTENT]') !== false) return true;
1847 1846
 			return false;
1848 1847
 		}
1849 1848
 
@@ -1877,15 +1876,15 @@  discard block
 block discarded – undo
1877 1876
      */
1878 1877
     public function SetReadFlag($folderid, $id, $flags, $contentParameters)
1879 1878
 	{
1880
-		unset($contentParameters);	// not used, but required by function signature
1879
+		unset($contentParameters); // not used, but required by function signature
1881 1880
 		// ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid'  id: '$id'  flags: '$flags' )");
1882 1881
 		$account = $folder = null;
1883 1882
 		$this->splitID($folderid, $account, $folder);
1884 1883
 
1885 1884
 		$_messageUID = (array)$id;
1886 1885
 		$this->_connect($this->account);
1887
-		$rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder);
1888
-		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv);
1886
+		$rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder);
1887
+		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv);
1889 1888
 
1890 1889
 		return $rv;
1891 1890
 	}
@@ -1902,7 +1901,7 @@  discard block
 block discarded – undo
1902 1901
 	 */
1903 1902
 	public function ChangeFolder($id, $oldid, $displayname, $type)
1904 1903
 	{
1905
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!");
1904
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!");
1906 1905
 		return false;
1907 1906
 	}
1908 1907
 
@@ -1917,7 +1916,7 @@  discard block
 block discarded – undo
1917 1916
 	 */
1918 1917
 	public function DeleteFolder($parentid, $id)
1919 1918
 	{
1920
-		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$parentid', '$id') NOT supported!");
1919
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$parentid', '$id') NOT supported!");
1921 1920
 		return false;
1922 1921
 	}
1923 1922
 
@@ -1937,8 +1936,8 @@  discard block
 block discarded – undo
1937 1936
 		$this->_connect($this->account);
1938 1937
 		$account = $folder = null;
1939 1938
 		$this->splitID($folderid, $account, $folder);
1940
-		$rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder);
1941
-		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv);
1939
+		$rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder);
1940
+		ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv);
1942 1941
 
1943 1942
 		return $rv;
1944 1943
 	}
@@ -1952,17 +1951,17 @@  discard block
 block discarded – undo
1952 1951
 	 * @return string
1953 1952
 	 * @throws Api\Exception\WrongParameter
1954 1953
 	 */
1955
-	private function createID($account,$folder,$id=0)
1954
+	private function createID($account, $folder, $id = 0)
1956 1955
 	{
1957 1956
 		if (!is_numeric($folder))
1958 1957
 		{
1959 1958
 			// convert string $folder in numeric id
1960
-			$folder = $this->folder2hash($account,$f=$folder);
1959
+			$folder = $this->folder2hash($account, $f = $folder);
1961 1960
 		}
1962 1961
 
1963 1962
 		$str = $this->backend->createID($account, $folder, $id);
1964 1963
 
1965
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
1964
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'");
1966 1965
 
1967 1966
 		return $str;
1968 1967
 	}
@@ -1976,14 +1975,14 @@  discard block
 block discarded – undo
1976 1975
 	 * @param int &$id=null
1977 1976
 	 * @throws Api\Exception\WrongParameter
1978 1977
 	 */
1979
-	private function splitID($str,&$account,&$folder,&$id=null)
1978
+	private function splitID($str, &$account, &$folder, &$id = null)
1980 1979
 	{
1981 1980
 		$this->backend->splitID($str, $account, $folder, $id);
1982 1981
 
1983 1982
 		// convert numeric folder-id back to folder name
1984
-		$folder = $this->hash2folder($account,$f=$folder);
1983
+		$folder = $this->hash2folder($account, $f = $folder);
1985 1984
 
1986
-		if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)");
1985
+		if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$id)");
1987 1986
 	}
1988 1987
 
1989 1988
 	/**
@@ -2000,9 +1999,9 @@  discard block
 block discarded – undo
2000 1999
 	 * @param string $folder
2001 2000
 	 * @return int
2002 2001
 	 */
2003
-	private function folder2hash($account,$folder)
2002
+	private function folder2hash($account, $folder)
2004 2003
 	{
2005
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2004
+		if (!isset($this->folderHashes)) $this->readFolderHashes();
2006 2005
 
2007 2006
 		if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false)
2008 2007
 		{
@@ -2023,9 +2022,9 @@  discard block
 block discarded – undo
2023 2022
 	 * @param int $index
2024 2023
 	 * @return string NULL if not used so far
2025 2024
 	 */
2026
-	private function hash2folder($account,$index)
2025
+	private function hash2folder($account, $index)
2027 2026
 	{
2028
-		if(!isset($this->folderHashes)) $this->readFolderHashes();
2027
+		if (!isset($this->folderHashes)) $this->readFolderHashes();
2029 2028
 
2030 2029
 		return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null;
2031 2030
 	}
@@ -2062,9 +2061,9 @@  discard block
 block discarded – undo
2062 2061
 			if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) &&
2063 2062
 				($hashes = file_get_contents($file)))
2064 2063
 			{
2065
-				$this->folderHashes = json_decode($hashes,true);
2064
+				$this->folderHashes = json_decode($hashes, true);
2066 2065
 				// fallback in case hashes have been serialized instead of being json-encoded
2067
-				if (json_last_error()!=JSON_ERROR_NONE)
2066
+				if (json_last_error() != JSON_ERROR_NONE)
2068 2067
 				{
2069 2068
 					//error_log(__METHOD__.__LINE__." error decoding with json");
2070 2069
 					$this->folderHashes = unserialize($hashes);
@@ -2110,9 +2109,9 @@  discard block
 block discarded – undo
2110 2109
 	 * @param boolean $old =false true: return old / pre-15 hash-file
2111 2110
 	 * @throws Api\Exception\AssertionFailed
2112 2111
 	 */
2113
-	private function hashFile($old=false)
2112
+	private function hashFile($old = false)
2114 2113
 	{
2115
-		if (!($dev_id=Request::GetDeviceID()))
2114
+		if (!($dev_id = Request::GetDeviceID()))
2116 2115
 		{
2117 2116
 			throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!");
2118 2117
 		}
Please login to merge, or discard this patch.