@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | $this->backend = $backend; |
98 | 98 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
99 | 99 | { |
100 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
100 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
101 | 101 | // globals preferences add appname varname value |
102 | - $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
|
102 | + $GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user'); |
|
103 | 103 | // save prefs |
104 | 104 | $GLOBALS['egw']->preferences->save_repository(true); |
105 | 105 | } |
106 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
106 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
107 | 107 | |
108 | 108 | if (is_null(self::$profileID)) |
109 | 109 | { |
110 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
111 | - self::$profileID =& egw_cache::getSession('mail','activeSyncProfileID'); |
|
112 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
110 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
111 | + self::$profileID = & egw_cache::getSession('mail', 'activeSyncProfileID'); |
|
112 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
113 | 113 | } |
114 | 114 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
115 | 115 | { |
116 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
116 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
117 | 117 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
118 | 118 | { |
119 | 119 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
124 | 124 | } |
125 | 125 | } |
126 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
126 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
127 | 127 | |
128 | 128 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
129 | 129 | if (!isset($GLOBALS['egw_setup'])) |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | try { |
132 | 132 | emailadmin_account::read(self::$profileID); |
133 | 133 | } |
134 | - catch(Exception $e) { |
|
134 | + catch (Exception $e) { |
|
135 | 135 | unset($e); |
136 | 136 | self::$profileID = emailadmin_account::get_default_acc_id(); |
137 | 137 | } |
138 | 138 | } |
139 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
139 | + if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
140 | 140 | //$this->debugLevel=0; |
141 | 141 | } |
142 | 142 | |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | $this->__construct($this->backend); |
209 | 209 | |
210 | 210 | try { |
211 | - $this->_connect(0,true); |
|
211 | + $this->_connect(0, true); |
|
212 | 212 | $this->_disconnect(); |
213 | 213 | |
214 | 214 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
215 | 215 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
216 | 216 | } |
217 | - catch(Exception $e) { |
|
217 | + catch (Exception $e) { |
|
218 | 218 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
219 | 219 | } |
220 | 220 | if ($errors) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param int $account integer id of account to use |
233 | 233 | * @todo support different accounts |
234 | 234 | */ |
235 | - private function _connect($account=0) |
|
235 | + private function _connect($account = 0) |
|
236 | 236 | { |
237 | 237 | if (is_null($account)) $account = 0; |
238 | 238 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $this->account = $account; |
246 | 246 | // todo: tell mail which account to use |
247 | 247 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
248 | - $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
248 | + $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
249 | 249 | } |
250 | 250 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
251 | - $this->mail->openConnection(self::$profileID,false); |
|
251 | + $this->mail->openConnection(self::$profileID, false); |
|
252 | 252 | |
253 | 253 | $this->_wasteID = $this->mail->getTrashFolder(false); |
254 | 254 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -283,16 +283,16 @@ discard block |
||
283 | 283 | /*foreach($available_accounts as $account)*/ $account = 0; |
284 | 284 | { |
285 | 285 | $this->_connect($account); |
286 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
286 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
287 | 287 | //debugLog(__METHOD__.__LINE__.array2string($this->folders)); |
288 | 288 | |
289 | 289 | foreach ($this->folders as $folder => $folderObj) { |
290 | 290 | $folderlist[] = $f = array( |
291 | - 'id' => $this->createID($account,$folder), |
|
291 | + 'id' => $this->createID($account, $folder), |
|
292 | 292 | 'mod' => $folderObj->shortDisplayName, |
293 | - 'parent' => $this->getParentID($account,$folder), |
|
293 | + 'parent' => $this->getParentID($account, $folder), |
|
294 | 294 | ); |
295 | - if ($this->debugLevel>0) debugLog(__METHOD__."() returning ".array2string($f)); |
|
295 | + if ($this->debugLevel > 0) debugLog(__METHOD__."() returning ".array2string($f)); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | //debugLog(__METHOD__."() returning ".array2string($folderlist)); |
@@ -322,64 +322,64 @@ discard block |
||
322 | 322 | * @todo implement either here or in mail backend |
323 | 323 | * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
324 | 324 | */ |
325 | - public function SendMail($rfc822, $smartdata=array(), $protocolversion = false) |
|
325 | + public function SendMail($rfc822, $smartdata = array(), $protocolversion = false) |
|
326 | 326 | { |
327 | 327 | //$this->debugLevel=3; |
328 | 328 | $ClientSideMeetingRequest = false; |
329 | 329 | $allowSendingInvitations = 'sendifnocalnotif'; |
330 | 330 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
331 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
331 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
332 | 332 | { |
333 | 333 | $allowSendingInvitations = false; |
334 | 334 | } |
335 | 335 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
336 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
336 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
337 | 337 | { |
338 | 338 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
339 | 339 | } |
340 | 340 | |
341 | 341 | if ($protocolversion < 14.0) |
342 | - debugLog("IMAP-SendMail: " . (isset($rfc822) ? $rfc822 : ""). "task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
343 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
342 | + debugLog("IMAP-SendMail: ".(isset($rfc822) ? $rfc822 : "")."task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
343 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
344 | 344 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
345 | 345 | |
346 | 346 | // initialize our mail_bo |
347 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
347 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
348 | 348 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
349 | 349 | // use the standardIdentity |
350 | - $activeMailProfile = mail_bo::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
350 | + $activeMailProfile = mail_bo::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
351 | 351 | |
352 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
352 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
353 | 353 | |
354 | 354 | // initialize the new egw_mailer object for sending |
355 | 355 | $mailObject = new egw_mailer(); |
356 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$rfc822); |
|
356 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $rfc822); |
|
357 | 357 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
358 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
359 | - $mailObject->setFrom($activeMailProfile['ident_email'],$mailObject->EncodeHeader(mail_bo::generateIdentityString($activeMailProfile,false))); |
|
358 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
359 | + $mailObject->setFrom($activeMailProfile['ident_email'], $mailObject->EncodeHeader(mail_bo::generateIdentityString($activeMailProfile, false))); |
|
360 | 360 | $mailObject->AddCustomHeader('X-Mailer: mail-Activesync'); |
361 | 361 | |
362 | 362 | |
363 | 363 | // prepare addressee list; moved the adding of addresses to the mailobject down |
364 | 364 | // to |
365 | 365 | |
366 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
366 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
367 | 367 | if (!$addressObject->valid) continue; |
368 | - if ($this->debugLevel>0) debugLog("Header Sentmail To: ".array2string($addressObject) ); |
|
368 | + if ($this->debugLevel > 0) debugLog("Header Sentmail To: ".array2string($addressObject)); |
|
369 | 369 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
370 | 370 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
371 | 371 | } |
372 | 372 | // CC |
373 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
373 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
374 | 374 | if (!$addressObject->valid) continue; |
375 | - if ($this->debugLevel>0) debugLog("Header Sentmail CC: ".array2string($addressObject) ); |
|
375 | + if ($this->debugLevel > 0) debugLog("Header Sentmail CC: ".array2string($addressObject)); |
|
376 | 376 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
377 | 377 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
378 | 378 | } |
379 | 379 | // BCC |
380 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
380 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
381 | 381 | if (!$addressObject->valid) continue; |
382 | - if ($this->debugLevel>0) debugLog("Header Sentmail BCC: ".array2string($addressObject) ); |
|
382 | + if ($this->debugLevel > 0) debugLog("Header Sentmail BCC: ".array2string($addressObject)); |
|
383 | 383 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
384 | 384 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
385 | 385 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $use_orgbody = false; |
389 | 389 | |
390 | 390 | $k = 'Content-Type'; |
391 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
391 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
392 | 392 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
393 | 393 | // if the message is a multipart message, then we should use the sent body |
394 | 394 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -408,26 +408,26 @@ discard block |
||
408 | 408 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
409 | 409 | $use_orgbody = true; |
410 | 410 | } |
411 | - $Body = $AltBody = ""; |
|
411 | + $Body = $AltBody = ""; |
|
412 | 412 | // get body of the transmitted message |
413 | 413 | // if this is a simple message, no structure at all |
414 | 414 | if (preg_match("/text/i", $ContentType)) |
415 | 415 | { |
416 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
416 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
417 | 417 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
418 | - $body = $bodyObj ?$bodyObj->getContents() : null; |
|
419 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $body); |
|
420 | - if ($simpleBodyType == "text/plain") |
|
418 | + $body = $bodyObj ? $bodyObj->getContents() : null; |
|
419 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $body); |
|
420 | + if ($simpleBodyType == "text/plain") |
|
421 | 421 | { |
422 | 422 | $Body = $body; |
423 | 423 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
424 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
424 | + if ($this->debugLevel > 1) debugLog("IMAP-Sendmail: fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
425 | 425 | } |
426 | 426 | else |
427 | 427 | { |
428 | 428 | $AltBody = $body; |
429 | - $Body = trim(translation::convertHTMLToText($body)); |
|
430 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
429 | + $Body = trim(translation::convertHTMLToText($body)); |
|
430 | + if ($this->debugLevel > 1) debugLog("IMAP-Sendmail: fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | else |
@@ -436,60 +436,60 @@ discard block |
||
436 | 436 | $Body = ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null; |
437 | 437 | $AltBody = ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null; |
438 | 438 | // prefer plain over html |
439 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $Body); |
|
440 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $AltBody); |
|
439 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $Body); |
|
440 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $AltBody); |
|
441 | 441 | } |
442 | - if ($this->debugLevel>1 && $Body) debugLog("IMAP-Sendmail: fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
443 | - if ($this->debugLevel>1 && $AltBody) debugLog("IMAP-Sendmail: fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
442 | + if ($this->debugLevel > 1 && $Body) debugLog("IMAP-Sendmail: fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
443 | + if ($this->debugLevel > 1 && $AltBody) debugLog("IMAP-Sendmail: fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
444 | 444 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
445 | 445 | // if this is a multipart message with a boundary, we must use the original body |
446 | 446 | //if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
447 | 447 | if ($use_orgbody) { |
448 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
448 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
449 | 449 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
450 | - if (stripos($ContentType,'text/calendar') !== false ) |
|
450 | + if (stripos($ContentType, 'text/calendar') !== false) |
|
451 | 451 | { |
452 | 452 | $body = ($text_body = $mailObject->findBody('calendar')) ? $text_body->getContents() : null; |
453 | 453 | $Body = $body; |
454 | 454 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
455 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
455 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
456 | 456 | // try figuring out the METHOD -> [ContentType] => text/calendar; name=meeting.ics; method=REQUEST |
457 | - $tA = explode(' ',$ContentType); |
|
458 | - foreach ((array)$tA as $k => $p) if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); |
|
457 | + $tA = explode(' ', $ContentType); |
|
458 | + foreach ((array)$tA as $k => $p) if (stripos($p, "method=") !== false) $cSMRMethod = trim(str_replace('METHOD=', '', strtoupper($p))); |
|
459 | 459 | $ClientSideMeetingRequest = true; |
460 | 460 | } |
461 | 461 | } |
462 | 462 | // now handle the addressee list |
463 | 463 | $toCount = 0; |
464 | 464 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
465 | - foreach((array)$toMailAddr as $address) { |
|
466 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
467 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
468 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue; |
|
465 | + foreach ((array)$toMailAddr as $address) { |
|
466 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
467 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
468 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress, (isset($cSMRMethod) ? $cSMRMethod : 'REQUEST'))) continue; |
|
469 | 469 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
470 | 470 | $toCount++; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | $ccCount = 0; |
474 | - foreach((array)$ccMailAddr as $address) { |
|
475 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
476 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
474 | + foreach ((array)$ccMailAddr as $address) { |
|
475 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
476 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
477 | 477 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
478 | 478 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
479 | 479 | $ccCount++; |
480 | 480 | } |
481 | 481 | } |
482 | 482 | $bccCount = 0; |
483 | - foreach((array)$bccMailAddr as $address) { |
|
484 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
485 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
483 | + foreach ((array)$bccMailAddr as $address) { |
|
484 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
485 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
486 | 486 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
487 | 487 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
488 | 488 | $bccCount++; |
489 | 489 | } |
490 | 490 | } |
491 | - if ($toCount+$ccCount+$bccCount == 0) return 0; // noone to send mail to |
|
492 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
491 | + if ($toCount + $ccCount + $bccCount == 0) return 0; // noone to send mail to |
|
492 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
493 | 493 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
494 | 494 | /* |
495 | 495 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -497,29 +497,29 @@ discard block |
||
497 | 497 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body (modified):'.$body); |
498 | 498 | */ |
499 | 499 | // add signature!! ----------------------------------------------------------------- |
500 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
500 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
501 | 501 | try |
502 | 502 | { |
503 | 503 | $acc = emailadmin_account::read($this->mail->icServer->ImapServerId); |
504 | 504 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
505 | - $_signature = emailadmin_account::read_identity($acc['ident_id'],true); |
|
505 | + $_signature = emailadmin_account::read_identity($acc['ident_id'], true); |
|
506 | 506 | } |
507 | 507 | catch (Exception $e) |
508 | 508 | { |
509 | - $_signature=array(); |
|
509 | + $_signature = array(); |
|
510 | 510 | } |
511 | 511 | $signature = $_signature['ident_signature']; |
512 | 512 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
513 | 513 | $preferencesArray['disableRulerForSignatureSeparation']) || |
514 | - empty($signature) || trim(translation::convertHTMLToText($signature)) =='') |
|
514 | + empty($signature) || trim(translation::convertHTMLToText($signature)) == '') |
|
515 | 515 | { |
516 | 516 | $disableRuler = true; |
517 | 517 | } |
518 | 518 | $beforePlain = $beforeHtml = ""; |
519 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
520 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
521 | - $sigText = emailadmin_imapbase::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
522 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
519 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
520 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
521 | + $sigText = emailadmin_imapbase::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
522 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
523 | 523 | $sigTextHtml = $beforeHtml.$sigText; |
524 | 524 | $sigTextPlain = $beforePlain.translation::convertHTMLToText($sigText); |
525 | 525 | $isreply = $isforward = false; |
@@ -531,26 +531,26 @@ discard block |
||
531 | 531 | { |
532 | 532 | // now get on, and fetch the original mail |
533 | 533 | $uid = $smartdata['itemid']; |
534 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
534 | + if ($this->debugLevel > 0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
535 | 535 | $this->splitID($smartdata['folderid'], $account, $folder); |
536 | 536 | |
537 | 537 | $this->mail->reopen($folder); |
538 | 538 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
539 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
540 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
541 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
539 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
540 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
541 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
542 | 542 | // may be html |
543 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
543 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
544 | 544 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
545 | 545 | $isreply = true; |
546 | 546 | } |
547 | 547 | // plain text Message part |
548 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
548 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
549 | 549 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
550 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
551 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
552 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
553 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
550 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
551 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
552 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
553 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
554 | 554 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
555 | 555 | $isreply = true; |
556 | 556 | } |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | { |
559 | 559 | $isreply = true; |
560 | 560 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
561 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
561 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
565 | 565 | // how to forward and other prefs |
566 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
566 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
567 | 567 | |
568 | 568 | // forward ------------------------------------------------------------------------- |
569 | 569 | if ($smartdata['task'] == 'forward' && isset($smartdata['itemid']) && |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | { |
574 | 574 | //force the default for the forwarding -> asmail |
575 | 575 | if (is_array($preferencesArray)) { |
576 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
576 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
577 | 577 | || !isset($preferencesArray['message_forwarding']) |
578 | 578 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
579 | 579 | } else { |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | } |
582 | 582 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
583 | 583 | $uid = $smartdata['itemid']; |
584 | - if ($this->debugLevel>0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
584 | + if ($this->debugLevel > 0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
585 | 585 | $this->splitID($smartdata['folderid'], $account, $folder); |
586 | 586 | |
587 | 587 | $this->mail->reopen($folder); |
588 | 588 | // receive entire mail (header + body) |
589 | 589 | // get message headers for specified message |
590 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
590 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
591 | 591 | // build a new mime message, forward entire old mail as file |
592 | 592 | if ($preferencesArray['message_forwarding'] == 'asmail') |
593 | 593 | { |
594 | - $rawHeader=''; |
|
595 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata['itemid'], $_partID,$folder); |
|
596 | - $rawBody = $this->mail->getMessageRawBody($smartdata['itemid'], $_partID,$folder); |
|
594 | + $rawHeader = ''; |
|
595 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata['itemid'], $_partID, $folder); |
|
596 | + $rawBody = $this->mail->getMessageRawBody($smartdata['itemid'], $_partID, $folder); |
|
597 | 597 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
598 | 598 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
599 | 599 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -603,49 +603,49 @@ discard block |
||
603 | 603 | { |
604 | 604 | // now get on, and fetch the original mail |
605 | 605 | $uid = $smartdata['itemid']; |
606 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
606 | + if ($this->debugLevel > 0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
607 | 607 | $this->splitID($smartdata['folderid'], $account, $folder); |
608 | 608 | |
609 | 609 | $this->mail->reopen($folder); |
610 | 610 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
611 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
612 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
613 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
611 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
612 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
613 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
614 | 614 | // may be html |
615 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
615 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
616 | 616 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
617 | 617 | $isforward = true; |
618 | 618 | } |
619 | 619 | // plain text Message part |
620 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
620 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
621 | 621 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
622 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
623 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
624 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
625 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
622 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
623 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
624 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
625 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
626 | 626 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
627 | 627 | $isforward = true; |
628 | 628 | } |
629 | 629 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
630 | 630 | { |
631 | 631 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
632 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
632 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
633 | 633 | $isforward = true; |
634 | 634 | } |
635 | 635 | // get all the attachments and add them too. |
636 | 636 | // start handle Attachments |
637 | 637 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
638 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
638 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
639 | 639 | $attachmentNames = false; |
640 | - if (is_array($attachments) && count($attachments)>0) |
|
640 | + if (is_array($attachments) && count($attachments) > 0) |
|
641 | 641 | { |
642 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
643 | - foreach((array)$attachments as $key => $attachment) |
|
642 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
643 | + foreach ((array)$attachments as $key => $attachment) |
|
644 | 644 | { |
645 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
645 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
646 | 646 | $attachmentNames .= $attachment['name']."\n"; |
647 | 647 | $attachmentData = ''; |
648 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
648 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
649 | 649 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
650 | 650 | //debugLog(__METHOD__.__LINE__.' added part with number:'.$x); |
651 | 651 | } |
@@ -661,18 +661,18 @@ discard block |
||
661 | 661 | // now set the body |
662 | 662 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
663 | 663 | { |
664 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
665 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
664 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
665 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
666 | 666 | } |
667 | 667 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
668 | 668 | { |
669 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
670 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
669 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
670 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
671 | 671 | } |
672 | 672 | //advanced debugging |
673 | 673 | // Horde SMTP Class uses utf-8 by default. |
674 | 674 | //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
675 | - if ($this->debugLevel>2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
675 | + if ($this->debugLevel > 2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
676 | 676 | |
677 | 677 | // set a higher timeout for big messages |
678 | 678 | @set_time_limit(120); |
@@ -682,15 +682,15 @@ discard block |
||
682 | 682 | try { |
683 | 683 | $mailObject->Send(); |
684 | 684 | } |
685 | - catch(phpmailerException $e) { |
|
686 | - debugLog("The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
685 | + catch (phpmailerException $e) { |
|
686 | + debugLog("The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
687 | 687 | $send = false; |
688 | 688 | } |
689 | 689 | |
690 | - if (( $smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
|
690 | + if (($smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
|
691 | 691 | { |
692 | 692 | $uid = $smartdata['itemid']; |
693 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
693 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
694 | 694 | $this->splitID($smartdata['folderid'], $account, $folder); |
695 | 695 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
696 | 696 | $this->mail->reopen($folder); |
@@ -698,25 +698,25 @@ discard block |
||
698 | 698 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
699 | 699 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
700 | 700 | { |
701 | - $this->mail->deleteMessages(array($uid),$folder); |
|
701 | + $this->mail->deleteMessages(array($uid), $folder); |
|
702 | 702 | } else { |
703 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
704 | - if ($smartdata['task']== "forward") |
|
703 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
704 | + if ($smartdata['task'] == "forward") |
|
705 | 705 | { |
706 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
706 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | } |
710 | 710 | |
711 | - $asf = ($send ? true:false); // initalize accordingly |
|
712 | - if (($smartdata['saveinsentitems']==1 || !isset($smartdata['saveinsentitems'])) && $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
711 | + $asf = ($send ? true : false); // initalize accordingly |
|
712 | + if (($smartdata['saveinsentitems'] == 1 || !isset($smartdata['saveinsentitems'])) && $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
713 | 713 | { |
714 | 714 | $asf = false; |
715 | 715 | $sentFolder = $this->mail->getSentFolder(); |
716 | 716 | if ($this->_sentID) { |
717 | 717 | $folderArray[] = $this->_sentID; |
718 | 718 | } |
719 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
719 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
720 | 720 | { |
721 | 721 | $folderArray[] = $sentFolder; |
722 | 722 | } |
@@ -728,43 +728,43 @@ discard block |
||
728 | 728 | $asf = true; |
729 | 729 | } |
730 | 730 | if (count($folderArray) > 0) { |
731 | - foreach((array)$bccMailAddr as $address) { |
|
732 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
733 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
731 | + foreach ((array)$bccMailAddr as $address) { |
|
732 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
733 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
734 | 734 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
735 | 735 | } |
736 | 736 | } |
737 | - $BCCmail=''; |
|
738 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
739 | - foreach($folderArray as $folderName) { |
|
740 | - if($this->mail->isSentFolder($folderName)) { |
|
737 | + $BCCmail = ''; |
|
738 | + if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
739 | + foreach ($folderArray as $folderName) { |
|
740 | + if ($this->mail->isSentFolder($folderName)) { |
|
741 | 741 | $flags = '\\Seen'; |
742 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
742 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
743 | 743 | $flags = '\\Draft'; |
744 | 744 | } else { |
745 | 745 | $flags = ''; |
746 | 746 | } |
747 | 747 | $asf = true; |
748 | 748 | //debugLog(__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
749 | - $this->mail->openConnection(self::$profileID,false); |
|
749 | + $this->mail->openConnection(self::$profileID, false); |
|
750 | 750 | if ($this->mail->folderExists($folderName)) { |
751 | 751 | try |
752 | 752 | { |
753 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
753 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
754 | 754 | $flags); |
755 | 755 | } |
756 | 756 | catch (egw_exception_wrong_userinput $e) |
757 | 757 | { |
758 | 758 | //$asf = false; |
759 | - debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage())); |
|
759 | + debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage())); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | else |
763 | 763 | { |
764 | 764 | //$asf = false; |
765 | - debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
765 | + debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
766 | 766 | } |
767 | - debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
767 | + debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
768 | 768 | } |
769 | 769 | //$this->mail->closeConnection(); |
770 | 770 | } |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | } |
779 | 779 | else |
780 | 780 | { |
781 | - debugLog(__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
782 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
781 | + debugLog(__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
782 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | } |
@@ -791,39 +791,39 @@ discard block |
||
791 | 791 | * |
792 | 792 | * @see activesync_plugin_read::GetMessage() |
793 | 793 | */ |
794 | - public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
794 | + public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
795 | 795 | { |
796 | 796 | //$this->debugLevel=4; |
797 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
797 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
798 | 798 | debugLog(__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
799 | - $rv = $this->splitID($folderid,$account,$_folderName,$xid); |
|
799 | + $rv = $this->splitID($folderid, $account, $_folderName, $xid); |
|
800 | 800 | $this->mail->reopen($_folderName); |
801 | 801 | $stat = $this->StatMessage($folderid, $id); |
802 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
802 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
803 | 803 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
804 | 804 | if ($stat) |
805 | 805 | { |
806 | 806 | debugLog(__METHOD__.__LINE__." Message $id with stat ".array2string($stat)); |
807 | 807 | // initialize the object |
808 | 808 | $output = new SyncMail(); |
809 | - $headers = $this->mail->getMessageHeader($id,'',true,true,$_folderName); |
|
809 | + $headers = $this->mail->getMessageHeader($id, '', true, true, $_folderName); |
|
810 | 810 | if (empty($headers)) |
811 | 811 | { |
812 | 812 | error_log(__METHOD__.__LINE__.' Retrieval of Headers Failed! for .'.$this->account.'/'.$GLOBALS['egw_info']['user']['account_lid'].' ServerID:'.self::$profileID.'FolderID:'.$folderid.'/'.$_folderName.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference).' Stat was:'.array2string($stat)); |
813 | - return $output;//empty object |
|
813 | + return $output; //empty object |
|
814 | 814 | } |
815 | 815 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
816 | 816 | // simple style |
817 | 817 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
818 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
818 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
819 | 819 | if ($bodypreference === false) { |
820 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
821 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
820 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
821 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
822 | 822 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
823 | - if (stripos($body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part |
|
823 | + if (stripos($body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part |
|
824 | 824 | // remove all other html |
825 | 825 | $body = strip_tags($body); |
826 | - if(strlen($body) > $truncsize) { |
|
826 | + if (strlen($body) > $truncsize) { |
|
827 | 827 | $body = utf8_truncate($body, $truncsize); |
828 | 828 | $output->bodytruncated = 1; |
829 | 829 | } |
@@ -837,60 +837,60 @@ discard block |
||
837 | 837 | else // style with bodypreferences |
838 | 838 | { |
839 | 839 | if (isset($bodypreference[1]) && !isset($bodypreference[1]["TruncationSize"])) |
840 | - $bodypreference[1]["TruncationSize"] = 1024*1024; |
|
840 | + $bodypreference[1]["TruncationSize"] = 1024 * 1024; |
|
841 | 841 | if (isset($bodypreference[2]) && !isset($bodypreference[2]["TruncationSize"])) |
842 | - $bodypreference[2]["TruncationSize"] = 1024*1024; |
|
842 | + $bodypreference[2]["TruncationSize"] = 1024 * 1024; |
|
843 | 843 | if (isset($bodypreference[3]) && !isset($bodypreference[3]["TruncationSize"])) |
844 | - $bodypreference[3]["TruncationSize"] = 1024*1024; |
|
844 | + $bodypreference[3]["TruncationSize"] = 1024 * 1024; |
|
845 | 845 | if (isset($bodypreference[4]) && !isset($bodypreference[4]["TruncationSize"])) |
846 | - $bodypreference[4]["TruncationSize"] = 1024*1024; |
|
846 | + $bodypreference[4]["TruncationSize"] = 1024 * 1024; |
|
847 | 847 | // set the protocoll class |
848 | 848 | $output->airsyncbasebody = new SyncAirSyncBaseBody(); |
849 | - if ($this->debugLevel>0) debugLog("airsyncbasebody!"); |
|
849 | + if ($this->debugLevel > 0) debugLog("airsyncbasebody!"); |
|
850 | 850 | // fetch the body (try to gather data only once) |
851 | - $css =''; |
|
852 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
853 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
854 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
855 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
|
856 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
851 | + $css = ''; |
|
852 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
853 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
854 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
855 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
|
856 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
857 | 857 | // may be html |
858 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
858 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
859 | 859 | $css = $this->mail->getStyles($bodyStruct); |
860 | - $output->airsyncbasenativebodytype=2; |
|
860 | + $output->airsyncbasenativebodytype = 2; |
|
861 | 861 | } else { |
862 | 862 | // plain text Message |
863 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
864 | - $output->airsyncbasenativebodytype=1; |
|
865 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
866 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
867 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
868 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
863 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
864 | + $output->airsyncbasenativebodytype = 1; |
|
865 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
866 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
867 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
868 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
869 | 869 | } |
870 | 870 | // whatever format decode (using the correct encoding) |
871 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype==2?' html ':' plain ').$body); |
|
871 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
872 | 872 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
873 | 873 | // prepare plaintextbody |
874 | 874 | if ($output->airsyncbasenativebodytype == 2) |
875 | 875 | { |
876 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
877 | - if($bodyStructplain[0]['error']==1) |
|
876 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
877 | + if ($bodyStructplain[0]['error'] == 1) |
|
878 | 878 | { |
879 | 879 | $plainBody = translation::convertHTMLToText($body); // always display with preserved HTML |
880 | 880 | } |
881 | 881 | else |
882 | 882 | { |
883 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
883 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | //if ($this->debugLevel>0) debugLog("MIME Body".$body); |
887 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
887 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
888 | 888 | // remove all other html |
889 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
889 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
890 | 890 | $plainBody = strip_tags($plainBody); |
891 | - if ($this->debugLevel>3 && $output->airsyncbasenativebodytype==1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
891 | + if ($this->debugLevel > 3 && $output->airsyncbasenativebodytype == 1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
892 | 892 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
893 | - if (isset($bodypreference[4]) && ($mimesupport==2 || ($mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false))) |
|
893 | + if (isset($bodypreference[4]) && ($mimesupport == 2 || ($mimesupport == 1 && stristr($headers['CONTENT-TYPE'], 'signed') !== false))) |
|
894 | 894 | { |
895 | 895 | debugLog(__METHOD__.__LINE__." bodypreference 4 requested"); |
896 | 896 | $output->airsyncbasebody->type = 4; |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | // we create a complete new rfc822 message here to pass a clean one to the client. |
903 | 903 | // this strips a lot of information, but ... |
904 | 904 | $Header = $Body = ''; |
905 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
905 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
906 | 906 | //if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__." Using data from ".$rawHeaders.$rawBody); |
907 | 907 | //$this->mail->parseRawMessageIntoMailObject($mailObject,$rawHeaders.$rawBody,$Header,$Body); |
908 | 908 | //debugLog(__METHOD__.__LINE__.array2string($headers)); |
@@ -915,33 +915,33 @@ discard block |
||
915 | 915 | $mailObject->Subject = $headers['SUBJECT']; |
916 | 916 | $mailObject->MessageID = $headers['MESSAGE-ID']; |
917 | 917 | // from |
918 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM'])) as $addressObject) { |
|
918 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['FROM']) : $headers['FROM'])) as $addressObject) { |
|
919 | 919 | //debugLog(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
920 | 920 | if (!$addressObject->valid) continue; |
921 | - $mailObject->From = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
921 | + $mailObject->From = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
922 | 922 | $mailObject->FromName = $addressObject->personal; |
923 | 923 | //error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
924 | 924 | } |
925 | 925 | // to |
926 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO'])) as $addressObject) { |
|
926 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['TO']) : $headers['TO'])) as $addressObject) { |
|
927 | 927 | //debugLog(__METHOD__.__LINE__.'Address to add (TO):'.array2string($addressObject)); |
928 | 928 | if (!$addressObject->valid) continue; |
929 | - $mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
929 | + $mailObject->AddAddress($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
930 | 930 | } |
931 | 931 | // CC |
932 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC'])) as $addressObject) { |
|
932 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['CC']) : $headers['CC'])) as $addressObject) { |
|
933 | 933 | //debugLog(__METHOD__.__LINE__.'Address to add (CC):'.array2string($addressObject)); |
934 | 934 | if (!$addressObject->valid) continue; |
935 | - $mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
935 | + $mailObject->AddCC($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
936 | 936 | } |
937 | 937 | // AddReplyTo |
938 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO'])) as $addressObject) { |
|
938 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['REPLY-TO']) : $headers['REPLY-TO'])) as $addressObject) { |
|
939 | 939 | //debugLog(__METHOD__.__LINE__.'Address to add (ReplyTO):'.array2string($addressObject)); |
940 | 940 | if (!$addressObject->valid) continue; |
941 | - $mailObject->AddReplyTo($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
941 | + $mailObject->AddReplyTo($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
942 | 942 | } |
943 | 943 | $Header = $Body = ''; // we do not use Header and Body we use the MailObject |
944 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
944 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
945 | 945 | } |
946 | 946 | catch (egw_exception_assertion_failed $e) |
947 | 947 | { |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | $Header = $Body = ''; |
950 | 950 | } |
951 | 951 | |
952 | - if ($this->debugLevel>0) debugLog("MIME Body -> ".$body); // body is retrieved up |
|
953 | - if ($output->airsyncbasenativebodytype==2) { //html |
|
954 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 4"); |
|
952 | + if ($this->debugLevel > 0) debugLog("MIME Body -> ".$body); // body is retrieved up |
|
953 | + if ($output->airsyncbasenativebodytype == 2) { //html |
|
954 | + if ($this->debugLevel > 0) debugLog("HTML Body with requested pref 4"); |
|
955 | 955 | // if we happen to extract css from body. then remove it |
956 | - if ($css) translation::replaceTagsCompletley($body,'style'); |
|
956 | + if ($css) translation::replaceTagsCompletley($body, 'style'); |
|
957 | 957 | $html = '<html>'. |
958 | 958 | '<head>'. |
959 | 959 | '<meta name="Generator" content="Z-Push">'. |
@@ -961,30 +961,30 @@ discard block |
||
961 | 961 | $css. |
962 | 962 | '</head>'. |
963 | 963 | '<body>'. |
964 | - str_replace("\n","<BR>",str_replace("\r","", str_replace("\r\n","<BR>",$body))). |
|
964 | + str_replace("\n", "<BR>", str_replace("\r", "", str_replace("\r\n", "<BR>", $body))). |
|
965 | 965 | '</body>'. |
966 | 966 | '</html>'; |
967 | - $mailObject->setHtmlBody(str_replace("\n","\r\n", str_replace("\r","",$html)),null,false); |
|
968 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
969 | - $mailObject->setBody(empty($plainBody)?strip_tags($body):$plainBody); |
|
967 | + $mailObject->setHtmlBody(str_replace("\n", "\r\n", str_replace("\r", "", $html)), null, false); |
|
968 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
969 | + $mailObject->setBody(empty($plainBody) ? strip_tags($body) : $plainBody); |
|
970 | 970 | } |
971 | - if ($output->airsyncbasenativebodytype==1) { //plain |
|
972 | - if ($this->debugLevel>0) debugLog("Plain Body with requested pref 4"); |
|
971 | + if ($output->airsyncbasenativebodytype == 1) { //plain |
|
972 | + if ($this->debugLevel > 0) debugLog("Plain Body with requested pref 4"); |
|
973 | 973 | $mailObject->setBody($plainBody); |
974 | 974 | } |
975 | 975 | // we still need the attachments to be added ( if there are any ) |
976 | 976 | // start handle Attachments |
977 | 977 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
978 | - $attachments = $this->mail->getMessageAttachments($id, null, null, true, false, true , $_folderName); |
|
979 | - if (is_array($attachments) && count($attachments)>0) |
|
978 | + $attachments = $this->mail->getMessageAttachments($id, null, null, true, false, true, $_folderName); |
|
979 | + if (is_array($attachments) && count($attachments) > 0) |
|
980 | 980 | { |
981 | 981 | debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$id.' found:'.count($attachments)); |
982 | 982 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
983 | - foreach((array)$attachments as $key => $attachment) |
|
983 | + foreach ((array)$attachments as $key => $attachment) |
|
984 | 984 | { |
985 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
985 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
986 | 986 | $attachmentData = ''; |
987 | - $attachmentData = $this->mail->getAttachment($id, $attachment['partID'],0,false,false,$_folderName); |
|
987 | + $attachmentData = $this->mail->getAttachment($id, $attachment['partID'], 0, false, false, $_folderName); |
|
988 | 988 | $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
989 | 989 | } |
990 | 990 | } |
@@ -992,13 +992,13 @@ discard block |
||
992 | 992 | $Header = $mailObject->getMessageHeader(); |
993 | 993 | //debugLog(__METHOD__.__LINE__.' MailObject-Header:'.array2string($Header)); |
994 | 994 | $Body = trim($mailObject->getMessageBody()); // philip thinks this is needed, so lets try if it does any good/harm |
995 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
996 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
995 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
996 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
997 | 997 | $output->airsyncbasebody->data = $Header.self::$LE.self::$LE.$Body; |
998 | 998 | } |
999 | 999 | else if (isset($bodypreference[2])) |
1000 | 1000 | { |
1001 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
|
1001 | + if ($this->debugLevel > 0) debugLog("HTML Body with requested pref 2"); |
|
1002 | 1002 | // Send HTML if requested and native type was html |
1003 | 1003 | $output->airsyncbasebody->type = 2; |
1004 | 1004 | $htmlbody = '<html>'. |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $css. |
1009 | 1009 | '</head>'. |
1010 | 1010 | '<body>'; |
1011 | - if ($output->airsyncbasenativebodytype==2) |
|
1011 | + if ($output->airsyncbasenativebodytype == 2) |
|
1012 | 1012 | { |
1013 | 1013 | // as we fetch html, and body is HTML, we may not need to handle this |
1014 | 1014 | $htmlbody .= $body; |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | else |
1017 | 1017 | { |
1018 | 1018 | // html requested but got only plaintext, so fake html |
1019 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
1019 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
1020 | 1020 | } |
1021 | 1021 | $htmlbody .= '</body>'. |
1022 | 1022 | '</html>'; |
1023 | 1023 | |
1024 | - if(isset($bodypreference[2]["TruncationSize"]) && strlen($html) > $bodypreference[2]["TruncationSize"]) |
|
1024 | + if (isset($bodypreference[2]["TruncationSize"]) && strlen($html) > $bodypreference[2]["TruncationSize"]) |
|
1025 | 1025 | { |
1026 | - $htmlbody = utf8_truncate($htmlbody,$bodypreference[2]["TruncationSize"]); |
|
1026 | + $htmlbody = utf8_truncate($htmlbody, $bodypreference[2]["TruncationSize"]); |
|
1027 | 1027 | $output->airsyncbasebody->truncated = 1; |
1028 | 1028 | } |
1029 | 1029 | $output->airsyncbasebody->data = $htmlbody; |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | else |
1032 | 1032 | { |
1033 | 1033 | // Send Plaintext as Fallback or if original body is plainttext |
1034 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
1034 | + if ($this->debugLevel > 0) debugLog("Plaintext Body:".$plainBody); |
|
1035 | 1035 | /* we use plainBody (set above) instead |
1036 | 1036 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
1037 | 1037 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | //$plain = str_replace("\n","\r\n",str_replace("\r","",$plain)); |
1041 | 1041 | */ |
1042 | 1042 | $output->airsyncbasebody->type = 1; |
1043 | - if(isset($bodypreference[1]["TruncationSize"]) && |
|
1043 | + if (isset($bodypreference[1]["TruncationSize"]) && |
|
1044 | 1044 | strlen($plainBody) > $bodypreference[1]["TruncationSize"]) |
1045 | 1045 | { |
1046 | 1046 | $plainBody = utf8_truncate($plainBody, $bodypreference[1]["TruncationSize"]); |
@@ -1061,21 +1061,20 @@ discard block |
||
1061 | 1061 | debugLog(__METHOD__.__LINE__.' gather Header info:'.$headers['SUBJECT'].' from:'.$headers['DATE']); |
1062 | 1062 | $output->read = $stat["flags"]; |
1063 | 1063 | $output->subject = $this->messages[$id]['subject']; |
1064 | - $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : |
|
1065 | - ($this->messages[$id]['priority'] < 3 ? 2 : 1) ; |
|
1066 | - $output->datereceived = $this->mail->_strtotime($headers['DATE'],'ts',true); |
|
1067 | - $output->displayto = ($headers['TO'] ? $headers['TO']:null); //$stat['FETCHED_HEADER']['to_name'] |
|
1064 | + $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : ($this->messages[$id]['priority'] < 3 ? 2 : 1); |
|
1065 | + $output->datereceived = $this->mail->_strtotime($headers['DATE'], 'ts', true); |
|
1066 | + $output->displayto = ($headers['TO'] ? $headers['TO'] : null); //$stat['FETCHED_HEADER']['to_name'] |
|
1068 | 1067 | // $output->to = $this->messages[$id]['to_address']; //$stat['FETCHED_HEADER']['to_name'] |
1069 | 1068 | // $output->from = $this->messages[$id]['sender_address']; //$stat['FETCHED_HEADER']['sender_name'] |
1070 | 1069 | //error_log(__METHOD__.__LINE__.' To:'.$headers['TO']); |
1071 | 1070 | $output->to = $headers['TO']; |
1072 | 1071 | //error_log(__METHOD__.__LINE__.' From:'.$headers['FROM']); |
1073 | 1072 | $output->from = $headers['FROM']; |
1074 | - $output->cc = ($headers['CC'] ? $headers['CC']:null); |
|
1075 | - $output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null); |
|
1073 | + $output->cc = ($headers['CC'] ? $headers['CC'] : null); |
|
1074 | + $output->reply_to = ($headers['REPLY_TO'] ? $headers['REPLY_TO'] : null); |
|
1076 | 1075 | $output->messageclass = "IPM.Note"; |
1077 | - if (stripos($this->messages[$id]['mimetype'],'multipart')!== false && |
|
1078 | - stripos($this->messages[$id]['mimetype'],'signed')!== false) |
|
1076 | + if (stripos($this->messages[$id]['mimetype'], 'multipart') !== false && |
|
1077 | + stripos($this->messages[$id]['mimetype'], 'signed') !== false) |
|
1079 | 1078 | { |
1080 | 1079 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
1081 | 1080 | } |
@@ -1090,61 +1089,61 @@ discard block |
||
1090 | 1089 | } |
1091 | 1090 | |
1092 | 1091 | $output->internetcpid = 65001; |
1093 | - $output->contentclass="urn:content-classes:message"; |
|
1092 | + $output->contentclass = "urn:content-classes:message"; |
|
1094 | 1093 | // end AS12 Stuff |
1095 | 1094 | |
1096 | 1095 | // start handle Attachments (include text/calendar multipart alternative) |
1097 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
1098 | - if (is_array($attachments) && count($attachments)>0) |
|
1096 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
1097 | + if (is_array($attachments) && count($attachments) > 0) |
|
1099 | 1098 | { |
1100 | 1099 | debugLog(__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
1101 | 1100 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
1102 | 1101 | foreach ($attachments as $key => $attach) |
1103 | 1102 | { |
1104 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1103 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1105 | 1104 | |
1106 | 1105 | // pass meeting requests to calendar plugin |
1107 | 1106 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
1108 | 1107 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
1109 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
1108 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
1110 | 1109 | ($output->meetingrequest = calendar_activesync::meetingRequest($attachment['attachment']))) |
1111 | 1110 | { |
1112 | 1111 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
1113 | - continue; // do NOT add attachment as attachment |
|
1112 | + continue; // do NOT add attachment as attachment |
|
1114 | 1113 | } |
1115 | - if(isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
1114 | + if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
1116 | 1115 | $attachment = new SyncAttachment(); |
1117 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1116 | + } else if (isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1118 | 1117 | $attachment = new SyncAirSyncBaseAttachment(); |
1119 | 1118 | } |
1120 | 1119 | $attachment->attsize = $attach['size']; |
1121 | 1120 | $attachment->displayname = $attach['name']; |
1122 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
1121 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
1123 | 1122 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
1124 | 1123 | $attachment->attmethod = 1; |
1125 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1126 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
1124 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1125 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
1127 | 1126 | { |
1128 | - $attachment->isinline=true; |
|
1129 | - $attachment->attmethod=6; |
|
1130 | - $attachment->contentid= $attach['cid']; |
|
1127 | + $attachment->isinline = true; |
|
1128 | + $attachment->attmethod = 6; |
|
1129 | + $attachment->contentid = $attach['cid']; |
|
1131 | 1130 | // debugLog("'".$part->headers['content-id']."' ".$attachment->contentid); |
1132 | 1131 | $attachment->contenttype = trim($attach['mimeType']); |
1133 | 1132 | // debugLog("'".$part->headers['content-type']."' ".$attachment->contentid); |
1134 | 1133 | } else { |
1135 | - $attachment->attmethod=1; |
|
1134 | + $attachment->attmethod = 1; |
|
1136 | 1135 | } |
1137 | 1136 | |
1138 | 1137 | if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
1139 | 1138 | array_push($output->attachments, $attachment); |
1140 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1139 | + } else if (isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1141 | 1140 | array_push($output->airsyncbaseattachments, $attachment); |
1142 | 1141 | } |
1143 | 1142 | } |
1144 | 1143 | } |
1145 | 1144 | //$this->debugLevel=0; |
1146 | 1145 | // end handle Attachments |
1147 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
1146 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
1148 | 1147 | return $output; |
1149 | 1148 | } |
1150 | 1149 | return false; |
@@ -1174,16 +1173,16 @@ discard block |
||
1174 | 1173 | return false; |
1175 | 1174 | } |
1176 | 1175 | $ret = false; |
1177 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
1176 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
1178 | 1177 | { |
1179 | 1178 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
1180 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
1179 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
1181 | 1180 | { |
1182 | 1181 | debugLog(__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
1183 | 1182 | |
1184 | 1183 | // calling backend again with iCal attachment, to let calendar add the event |
1185 | 1184 | if (($ret = $this->backend->MeetingResponse($attachment['attachment'], |
1186 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
1185 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
1187 | 1186 | $response, $calendarid))) |
1188 | 1187 | { |
1189 | 1188 | $ret = $calendarid; |
@@ -1205,17 +1204,17 @@ discard block |
||
1205 | 1204 | * @param string $attname - should contain (folder)id |
1206 | 1205 | * @return true, prints the content of the attachment |
1207 | 1206 | */ |
1208 | - function GetAttachmentData($fid,$attname) { |
|
1207 | + function GetAttachmentData($fid, $attname) { |
|
1209 | 1208 | debugLog("getAttachmentData: $fid (attname: '$attname')"); |
1210 | 1209 | error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1211 | 1210 | list($folderid, $id, $part) = explode(":", $attname); |
1212 | 1211 | |
1213 | 1212 | $this->splitID($folderid, $account, $folder); |
1214 | 1213 | |
1215 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1214 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1216 | 1215 | |
1217 | 1216 | $this->mail->reopen($folder); |
1218 | - $attachment = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
|
1217 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, false, $folder); |
|
1219 | 1218 | print $attachment['attachment']; |
1220 | 1219 | unset($attachment); |
1221 | 1220 | return true; |
@@ -1231,17 +1230,17 @@ discard block |
||
1231 | 1230 | * @param string $attname - should contain (folder)id |
1232 | 1231 | * @return SyncAirSyncBaseFileAttachment-object |
1233 | 1232 | */ |
1234 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
1233 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
1235 | 1234 | debugLog("ItemOperationsGetAttachmentData: (attname: '$attname')"); |
1236 | 1235 | |
1237 | 1236 | list($folderid, $id, $part) = explode(":", $attname); |
1238 | 1237 | |
1239 | 1238 | $this->splitID($folderid, $account, $folder); |
1240 | 1239 | |
1241 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
1240 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1242 | 1241 | |
1243 | 1242 | $this->mail->reopen($folder); |
1244 | - $att = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
|
1243 | + $att = $this->mail->getAttachment($id, $part, 0, false, false, $folder); |
|
1245 | 1244 | $attachment = new SyncAirSyncBaseFileAttachment(); |
1246 | 1245 | /* |
1247 | 1246 | debugLog(__METHOD__.__LINE__.array2string($att)); |
@@ -1303,17 +1302,17 @@ discard block |
||
1303 | 1302 | $this->splitID($folderid, $account, $srcFolder); |
1304 | 1303 | $this->splitID($newfolderid, $account, $destFolder); |
1305 | 1304 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
1306 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1305 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1307 | 1306 | $this->mail->reopen($destFolder); |
1308 | 1307 | $status = $this->mail->getFolderStatus($destFolder); |
1309 | 1308 | $uidNext = $status['uidnext']; |
1310 | 1309 | $this->mail->reopen($srcFolder); |
1311 | 1310 | |
1312 | 1311 | // move message |
1313 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
1312 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
1314 | 1313 | debugLog(__METHOD__.__LINE__.array2string($rv)); // this may be true, so try using the nextUID value by examine |
1315 | 1314 | // return the new id "as string"" |
1316 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
1315 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
1317 | 1316 | } |
1318 | 1317 | |
1319 | 1318 | /** |
@@ -1321,86 +1320,86 @@ discard block |
||
1321 | 1320 | * |
1322 | 1321 | * @ToDo loop over available email accounts |
1323 | 1322 | */ |
1324 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
1323 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
1325 | 1324 | { |
1326 | 1325 | static $cutdate; |
1327 | - if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1328 | - debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
1326 | + if (!empty($cutoffdate) && $cutoffdate > 0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1327 | + debugLog(__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
1329 | 1328 | if (empty($cutdate)) |
1330 | 1329 | { |
1331 | - $cutdate = egw_time::to('now','ts')-(3600*24*28*3); |
|
1330 | + $cutdate = egw_time::to('now', 'ts') - (3600 * 24 * 28 * 3); |
|
1332 | 1331 | debugLog(__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutdate)); |
1333 | 1332 | } |
1334 | 1333 | return $this->fetchMessages($folderid, $cutdate); |
1335 | 1334 | } |
1336 | 1335 | |
1337 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
|
1336 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL) |
|
1338 | 1337 | { |
1339 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
1338 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
1340 | 1339 | //debugLog(__METHOD__.__LINE__); |
1341 | 1340 | $rv_messages = array(); |
1342 | 1341 | // if the message is still available within the class, we use it instead of fetching it again |
1343 | - if (is_array($_id) && count($_id)==1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
1342 | + if (is_array($_id) && count($_id) == 1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
1344 | 1343 | { |
1345 | 1344 | //debugLog(__METHOD__.__LINE__." the message ".$_id[0]." is still available within the class, we use it instead of fetching it again"); |
1346 | 1345 | $rv_messages = array('header'=>array($this->messages[$_id[0]])); |
1347 | 1346 | } |
1348 | 1347 | if (empty($rv_messages)) |
1349 | 1348 | { |
1350 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1349 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1351 | 1350 | $this->_connect($this->account); |
1352 | - if ($this->debugLevel>1) |
|
1351 | + if ($this->debugLevel > 1) |
|
1353 | 1352 | { |
1354 | 1353 | $endtime = microtime(true) - $starttime; |
1355 | - debugLog(__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
1354 | + debugLog(__METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
1356 | 1355 | } |
1357 | 1356 | $messagelist = array(); |
1358 | 1357 | // if not connected, any further action must fail |
1359 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
1360 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1361 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
1362 | - if ($this->debugLevel>1) |
|
1358 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'type'=>"SINCE", 'string'=> date("d-M-Y", $cutoffdate)); |
|
1359 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1360 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
1361 | + if ($this->debugLevel > 1) |
|
1363 | 1362 | { |
1364 | 1363 | $endtime = microtime(true) - $starttime; |
1365 | - debugLog(__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1364 | + debugLog(__METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1366 | 1365 | } |
1367 | - if ($this->debugLevel>1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1368 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1369 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
1370 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
1371 | - if ($this->debugLevel>1) |
|
1366 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1367 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1368 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
1369 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
1370 | + if ($this->debugLevel > 1) |
|
1372 | 1371 | { |
1373 | 1372 | $endtime = microtime(true) - $starttime; |
1374 | - debugLog(__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1373 | + debugLog(__METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1375 | 1374 | } |
1376 | 1375 | } |
1377 | - if ($_id == NULL && $this->debugLevel>1) debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
1376 | + if ($_id == NULL && $this->debugLevel > 1) debugLog(__METHOD__." found :".count($rv_messages['header'])); |
|
1378 | 1377 | //debugLog(__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
1379 | 1378 | foreach ((array)$rv_messages['header'] as $k => $vars) |
1380 | 1379 | { |
1381 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1380 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1382 | 1381 | $this->messages[$vars['uid']] = $vars; |
1383 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1382 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1384 | 1383 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
1385 | 1384 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
1386 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1385 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1387 | 1386 | $mess["mod"] = $vars['date']; |
1388 | 1387 | $mess["id"] = $vars['uid']; |
1389 | 1388 | // 'seen' aka 'read' is the only flag we want to know about |
1390 | 1389 | $mess["flags"] = 0; |
1391 | 1390 | // outlook supports additional flags, set them to 0 |
1392 | 1391 | $mess["olflags"] = 0; |
1393 | - if($vars["seen"]) $mess["flags"] = 1; |
|
1394 | - if($vars["flagged"]) $mess["olflags"] = 2; |
|
1395 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
1392 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
1393 | + if ($vars["flagged"]) $mess["olflags"] = 2; |
|
1394 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
1396 | 1395 | $messagelist[$vars['uid']] = $mess; |
1397 | 1396 | unset($mess); |
1398 | 1397 | } |
1399 | 1398 | |
1400 | - if ($this->debugLevel>1) |
|
1399 | + if ($this->debugLevel > 1) |
|
1401 | 1400 | { |
1402 | 1401 | $endtime = microtime(true) - $gstarttime; |
1403 | - debugLog(__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1402 | + debugLog(__METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1404 | 1403 | } |
1405 | 1404 | return $messagelist; |
1406 | 1405 | } |
@@ -1414,7 +1413,7 @@ discard block |
||
1414 | 1413 | public function getSearchResultsMailbox($searchquery) |
1415 | 1414 | { |
1416 | 1415 | if (!is_array($searchquery)) return array(); |
1417 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
1416 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
1418 | 1417 | // 19.10.2011 16:28:59 [24502] mail_activesync::getSearchResultsMailbox1408 |
1419 | 1418 | //Array( |
1420 | 1419 | // [query] => Array( |
@@ -1438,22 +1437,22 @@ discard block |
||
1438 | 1437 | } else { |
1439 | 1438 | $rebuildresults = false; |
1440 | 1439 | } |
1441 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1440 | + if ($this->debugLevel > 0) debugLog('RebuildResults ['.$rebuildresults.']'); |
|
1442 | 1441 | |
1443 | 1442 | if (isset($searchquery['deeptraversal'])) { |
1444 | 1443 | $deeptraversal = $searchquery['deeptraversal']; |
1445 | 1444 | } else { |
1446 | 1445 | $deeptraversal = false; |
1447 | 1446 | } |
1448 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1447 | + if ($this->debugLevel > 0) debugLog('DeepTraversal ['.$deeptraversal.']'); |
|
1449 | 1448 | |
1450 | 1449 | if (isset($searchquery['range'])) { |
1451 | - $range = explode("-",$searchquery['range']); |
|
1450 | + $range = explode("-", $searchquery['range']); |
|
1452 | 1451 | $limit = $range[1] - $range[0] + 1; |
1453 | 1452 | } else { |
1454 | 1453 | $range = false; |
1455 | 1454 | } |
1456 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
1455 | + if ($this->debugLevel > 0) debugLog('Range ['.print_r($range, true).']'); |
|
1457 | 1456 | |
1458 | 1457 | //foreach($searchquery['query'] as $k => $value) { |
1459 | 1458 | // $query = $value; |
@@ -1465,38 +1464,38 @@ discard block |
||
1465 | 1464 | // other types may be possible - we support quicksearch first (freeText in subject and from (or TO in Sent Folder)) |
1466 | 1465 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
1467 | 1466 | { |
1468 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10); |
|
1469 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]=true; |
|
1467 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10); |
|
1468 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] = true; |
|
1470 | 1469 | } |
1471 | 1470 | |
1472 | 1471 | if (isset($searchquery['query'][0]['value']['Search:FreeText'])) |
1473 | 1472 | { |
1474 | - $type = (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]?'quick':'subject'); |
|
1473 | + $type = (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] ? 'quick' : 'subject'); |
|
1475 | 1474 | $searchText = $searchquery['query'][0]['value']['Search:FreeText']; |
1476 | 1475 | } |
1477 | 1476 | if (!$folderid) |
1478 | 1477 | { |
1479 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
1480 | - $folderid = $this->createID($account=0,$_folderName); |
|
1478 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
1479 | + $folderid = $this->createID($account = 0, $_folderName); |
|
1481 | 1480 | } |
1482 | 1481 | //if ($searchquery['query'][0]['value'][subquery][0][op]=='Search:GreaterThan'); |
1483 | 1482 | //if (isset($searchquery['query'][0]['value'][subquery][0][value][POOMMAIL:DateReceived])); |
1484 | 1483 | //if ($searchquery['query'][0]['value'][subquery][1][op]=='Search:LessThan'); |
1485 | 1484 | //if (isset($searchquery['query'][0]['value'][subquery][1][value][POOMMAIL:DateReceived])); |
1486 | 1485 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1487 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
1486 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
1488 | 1487 | $this->_connect($account); |
1489 | - $_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]?'quick':'subject'), |
|
1488 | + $_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] ? 'quick' : 'subject'), |
|
1490 | 1489 | 'string'=> $searchText, |
1491 | 1490 | 'status'=>'any', |
1492 | 1491 | ); |
1493 | 1492 | |
1494 | 1493 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1495 | - if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1496 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
1494 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1495 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
1497 | 1496 | //debugLog(__METHOD__.__LINE__.array2string($rv_messages)); |
1498 | - $list=array(); |
|
1499 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
1497 | + $list = array(); |
|
1498 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
1500 | 1499 | { |
1501 | 1500 | $list[] = array( |
1502 | 1501 | "uniqueid" => $folderid.':'.$vars['uid'], |
@@ -1507,7 +1506,7 @@ discard block |
||
1507 | 1506 | } |
1508 | 1507 | //error_log(__METHOD__.__LINE__.array2string($list)); |
1509 | 1508 | //debugLog(__METHOD__.__LINE__.array2string($list)); |
1510 | - return $list;//array('rows'=>$list,'status'=>1,'global_search_status'=>1);//array(); |
|
1509 | + return $list; //array('rows'=>$list,'status'=>1,'global_search_status'=>1);//array(); |
|
1511 | 1510 | } |
1512 | 1511 | |
1513 | 1512 | /** |
@@ -1517,20 +1516,20 @@ discard block |
||
1517 | 1516 | * @param string $folder |
1518 | 1517 | * @return string |
1519 | 1518 | */ |
1520 | - private function getParentID($account,$folder) |
|
1519 | + private function getParentID($account, $folder) |
|
1521 | 1520 | { |
1522 | 1521 | $this->_connect($account); |
1523 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1522 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1524 | 1523 | |
1525 | 1524 | $mailFolder = $this->folders[$folder]; |
1526 | 1525 | if (!isset($mailFolder)) return false; |
1527 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
1528 | - $parent = explode($delimiter,$folder); |
|
1526 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
1527 | + $parent = explode($delimiter, $folder); |
|
1529 | 1528 | array_pop($parent); |
1530 | - $parent = implode($delimiter,$parent); |
|
1529 | + $parent = implode($delimiter, $parent); |
|
1531 | 1530 | |
1532 | 1531 | $id = $parent ? $this->createID($account, $parent) : '0'; |
1533 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1532 | + if ($this->debugLevel > 1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1534 | 1533 | return $id; |
1535 | 1534 | } |
1536 | 1535 | |
@@ -1549,48 +1548,48 @@ discard block |
||
1549 | 1548 | try { |
1550 | 1549 | $this->splitID($id, $account, $folder); |
1551 | 1550 | } |
1552 | - catch(Exception $e) { |
|
1551 | + catch (Exception $e) { |
|
1553 | 1552 | debugLog(__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
1554 | - return $folderObj=false; |
|
1553 | + return $folderObj = false; |
|
1555 | 1554 | } |
1556 | 1555 | $this->_connect($account); |
1557 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1556 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1558 | 1557 | |
1559 | 1558 | $mailFolder = $this->folders[$folder]; |
1560 | - if (!isset($mailFolder)) return $folderObj=false; |
|
1559 | + if (!isset($mailFolder)) return $folderObj = false; |
|
1561 | 1560 | |
1562 | 1561 | $folderObj = new SyncFolder(); |
1563 | 1562 | $folderObj->serverid = $id; |
1564 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
1563 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
1565 | 1564 | $folderObj->displayname = $mailFolder->shortDisplayName; |
1566 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1565 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1567 | 1566 | // get folder-type |
1568 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
1567 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
1569 | 1568 | if ($folder == $inbox) |
1570 | 1569 | { |
1571 | 1570 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
1572 | 1571 | } |
1573 | - elseif($this->mail->isDraftFolder($folder, false)) |
|
1572 | + elseif ($this->mail->isDraftFolder($folder, false)) |
|
1574 | 1573 | { |
1575 | 1574 | //debugLog(__METHOD__.' isDraft'); |
1576 | 1575 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
1577 | 1576 | $folderObj->parentid = 0; // required by devices |
1578 | 1577 | } |
1579 | - elseif($this->mail->isTrashFolder($folder, false)) |
|
1578 | + elseif ($this->mail->isTrashFolder($folder, false)) |
|
1580 | 1579 | { |
1581 | 1580 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
1582 | 1581 | $this->_wasteID = $folder; |
1583 | 1582 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
1584 | 1583 | $folderObj->parentid = 0; // required by devices |
1585 | 1584 | } |
1586 | - elseif($this->mail->isSentFolder($folder, false)) |
|
1585 | + elseif ($this->mail->isSentFolder($folder, false)) |
|
1587 | 1586 | { |
1588 | 1587 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
1589 | 1588 | $folderObj->parentid = 0; // required by devices |
1590 | 1589 | $this->_sentID = $folder; |
1591 | 1590 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
1592 | 1591 | } |
1593 | - elseif($this->mail->isOutbox($folder, false)) |
|
1592 | + elseif ($this->mail->isOutbox($folder, false)) |
|
1594 | 1593 | { |
1595 | 1594 | //debugLog(__METHOD__.' isOutbox'); |
1596 | 1595 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1602,7 +1601,7 @@ discard block |
||
1602 | 1601 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
1603 | 1602 | } |
1604 | 1603 | |
1605 | - if ($this->debugLevel>1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1604 | + if ($this->debugLevel > 1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1606 | 1605 | return $folderObj; |
1607 | 1606 | } |
1608 | 1607 | |
@@ -1649,18 +1648,18 @@ discard block |
||
1649 | 1648 | if (is_numeric($account)) $type = 'mail'; |
1650 | 1649 | if ($type != 'mail') return false; |
1651 | 1650 | |
1652 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1651 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1653 | 1652 | |
1654 | 1653 | $changes = array(); |
1655 | - debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
|
1654 | + debugLog("AlterPingChanges on $folderid ($folder) stat: ".$syncstate); |
|
1656 | 1655 | $this->mail->reopen($folder); |
1657 | 1656 | |
1658 | - $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1657 | + $status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true); |
|
1659 | 1658 | if (!$status) { |
1660 | 1659 | debugLog("AlterPingChanges: could not stat folder $folder "); |
1661 | 1660 | return false; |
1662 | 1661 | } else { |
1663 | - $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1662 | + $newstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1664 | 1663 | |
1665 | 1664 | // message number is different - change occured |
1666 | 1665 | if ($syncstate != $newstate) { |
@@ -1719,7 +1718,7 @@ discard block |
||
1719 | 1718 | $error = $e->getMessage(); |
1720 | 1719 | debugLog(__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
1721 | 1720 | // if the server thinks the message does not exist report deletion as success |
1722 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
1721 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
1723 | 1722 | return false; |
1724 | 1723 | } |
1725 | 1724 | |
@@ -1749,8 +1748,8 @@ discard block |
||
1749 | 1748 | |
1750 | 1749 | $_messageUID = (array)$id; |
1751 | 1750 | $this->_connect($this->account); |
1752 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
1753 | - debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
1751 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
1752 | + debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
1754 | 1753 | |
1755 | 1754 | return $rv; |
1756 | 1755 | } |
@@ -1801,8 +1800,8 @@ discard block |
||
1801 | 1800 | $_messageUID = (array)$id; |
1802 | 1801 | $this->_connect($this->account); |
1803 | 1802 | $this->splitID($folderid, $account, $folder); |
1804 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
1805 | - debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
1803 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
1804 | + debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
1806 | 1805 | |
1807 | 1806 | return $rv; |
1808 | 1807 | } |
@@ -1816,17 +1815,17 @@ discard block |
||
1816 | 1815 | * @return string |
1817 | 1816 | * @throws egw_exception_wrong_parameter |
1818 | 1817 | */ |
1819 | - private function createID($account,$folder,$id=0) |
|
1818 | + private function createID($account, $folder, $id = 0) |
|
1820 | 1819 | { |
1821 | 1820 | if (!is_numeric($folder)) |
1822 | 1821 | { |
1823 | 1822 | // convert string $folder in numeric id |
1824 | - $folder = $this->folder2hash($account,$f=$folder); |
|
1823 | + $folder = $this->folder2hash($account, $f = $folder); |
|
1825 | 1824 | } |
1826 | 1825 | |
1827 | 1826 | $str = $this->backend->createID($account, $folder, $id); |
1828 | 1827 | |
1829 | - if ($this->debugLevel>1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
1828 | + if ($this->debugLevel > 1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
1830 | 1829 | |
1831 | 1830 | return $str; |
1832 | 1831 | } |
@@ -1840,14 +1839,14 @@ discard block |
||
1840 | 1839 | * @param int &$id=null |
1841 | 1840 | * @throws egw_exception_wrong_parameter |
1842 | 1841 | */ |
1843 | - private function splitID($str,&$account,&$folder,&$id=null) |
|
1842 | + private function splitID($str, &$account, &$folder, &$id = null) |
|
1844 | 1843 | { |
1845 | 1844 | $this->backend->splitID($str, $account, $folder, $id); |
1846 | 1845 | |
1847 | 1846 | // convert numeric folder-id back to folder name |
1848 | - $folder = $this->hash2folder($account,$f=$folder); |
|
1847 | + $folder = $this->hash2folder($account, $f = $folder); |
|
1849 | 1848 | |
1850 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
1849 | + if ($this->debugLevel > 1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
1851 | 1850 | } |
1852 | 1851 | |
1853 | 1852 | /** |
@@ -1864,9 +1863,9 @@ discard block |
||
1864 | 1863 | * @param string $folder |
1865 | 1864 | * @return int |
1866 | 1865 | */ |
1867 | - private function folder2hash($account,$folder) |
|
1866 | + private function folder2hash($account, $folder) |
|
1868 | 1867 | { |
1869 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1868 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1870 | 1869 | |
1871 | 1870 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
1872 | 1871 | { |
@@ -1887,9 +1886,9 @@ discard block |
||
1887 | 1886 | * @param int $index |
1888 | 1887 | * @return string NULL if not used so far |
1889 | 1888 | */ |
1890 | - private function hash2folder($account,$index) |
|
1889 | + private function hash2folder($account, $index) |
|
1891 | 1890 | { |
1892 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1891 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1893 | 1892 | |
1894 | 1893 | return $this->folderHashes[$account][$index]; |
1895 | 1894 | } |
@@ -1904,9 +1903,9 @@ discard block |
||
1904 | 1903 | if (file_exists($file = $this->hashFile()) && |
1905 | 1904 | ($hashes = file_get_contents($file))) |
1906 | 1905 | { |
1907 | - $this->folderHashes = json_decode($hashes,true); |
|
1906 | + $this->folderHashes = json_decode($hashes, true); |
|
1908 | 1907 | // fallback in case hashes have been serialized instead of being json-encoded |
1909 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
1908 | + if (json_last_error() != JSON_ERROR_NONE) |
|
1910 | 1909 | { |
1911 | 1910 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
1912 | 1911 | $this->folderHashes = unserialize($hashes); |
@@ -1926,7 +1925,7 @@ discard block |
||
1926 | 1925 | private function storeFolderHashes() |
1927 | 1926 | { |
1928 | 1927 | // make sure $this->folderHashes is an array otherwise json_encode may fail on decode for string,integer,float or boolean |
1929 | - return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes)?$this->folderHashes:array($this->folderHashes)))); |
|
1928 | + return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes) ? $this->folderHashes : array($this->folderHashes)))); |
|
1930 | 1929 | } |
1931 | 1930 | |
1932 | 1931 | /** |