@@ -90,23 +90,23 @@ discard block |
||
| 90 | 90 | $this->backend = $backend; |
| 91 | 91 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 92 | 92 | { |
| 93 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 93 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 94 | 94 | // globals preferences add appname varname value |
| 95 | - $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
|
| 95 | + $GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user'); |
|
| 96 | 96 | // save prefs |
| 97 | 97 | $GLOBALS['egw']->preferences->save_repository(true); |
| 98 | 98 | } |
| 99 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 99 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 100 | 100 | |
| 101 | 101 | if (is_null(self::$profileID)) |
| 102 | 102 | { |
| 103 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 104 | - self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
|
| 105 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 103 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 104 | + self::$profileID = & Api\Cache::getSession('mail', 'activeSyncProfileID'); |
|
| 105 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 106 | 106 | } |
| 107 | 107 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 108 | 108 | { |
| 109 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 109 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 110 | 110 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
| 111 | 111 | { |
| 112 | 112 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 119 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 120 | 120 | |
| 121 | 121 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
| 122 | 122 | if (!isset($GLOBALS['egw_setup'])) |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | try { |
| 125 | 125 | Mail\Account::read(self::$profileID); |
| 126 | 126 | } |
| 127 | - catch(Exception $e) { |
|
| 127 | + catch (Exception $e) { |
|
| 128 | 128 | unset($e); |
| 129 | 129 | self::$profileID = Mail\Account::get_default_acc_id(); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 132 | + if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 133 | 133 | //$this->debugLevel=0; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | $this->__construct($this->backend); |
| 243 | 243 | |
| 244 | 244 | try { |
| 245 | - $this->_connect(0,true); |
|
| 245 | + $this->_connect(0, true); |
|
| 246 | 246 | $this->_disconnect(); |
| 247 | 247 | |
| 248 | 248 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
| 249 | 249 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
| 250 | 250 | } |
| 251 | - catch(Exception $e) { |
|
| 251 | + catch (Exception $e) { |
|
| 252 | 252 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
| 253 | 253 | } |
| 254 | 254 | if ($errors) |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param int $account integer id of account to use |
| 267 | 267 | * @todo support different accounts |
| 268 | 268 | */ |
| 269 | - private function _connect($account=0) |
|
| 269 | + private function _connect($account = 0) |
|
| 270 | 270 | { |
| 271 | 271 | if (!$account) $account = self::$profileID ? self::$profileID : 0; |
| 272 | 272 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $this->account = $account; |
| 280 | 280 | // todo: tell mail which account to use |
| 281 | 281 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 282 | - $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 282 | + $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 283 | 283 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 284 | 284 | } |
| 285 | 285 | else |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 288 | 288 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 289 | 289 | } |
| 290 | - $this->mail->openConnection(self::$profileID,false); |
|
| 290 | + $this->mail->openConnection(self::$profileID, false); |
|
| 291 | 291 | |
| 292 | 292 | $this->_wasteID = $this->mail->getTrashFolder(false); |
| 293 | 293 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | private function _disconnect() |
| 304 | 304 | { |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 305 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__); |
|
| 306 | 306 | if ($this->mail) $this->mail->closeConnection(); |
| 307 | 307 | |
| 308 | 308 | unset($this->mail); |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | public function GetFolderList() |
| 319 | 319 | { |
| 320 | 320 | $folderlist = array(); |
| 321 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 321 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__); |
|
| 322 | 322 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 323 | 323 | { |
| 324 | 324 | $this->_connect($account); |
| 325 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 326 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 325 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
| 326 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders)); |
|
| 327 | 327 | |
| 328 | 328 | foreach ($this->folders as $folder => $folderObj) { |
| 329 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 329 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder); |
|
| 330 | 330 | $folderlist[] = $f = array( |
| 331 | - 'id' => $this->createID($account,$folder), |
|
| 331 | + 'id' => $this->createID($account, $folder), |
|
| 332 | 332 | 'mod' => $folderObj->shortDisplayName, |
| 333 | - 'parent' => $this->getParentID($account,$folder), |
|
| 333 | + 'parent' => $this->getParentID($account, $folder), |
|
| 334 | 334 | ); |
| 335 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 335 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f)); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 338 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist)); |
|
| 339 | 339 | |
| 340 | 340 | return $folderlist; |
| 341 | 341 | } |
@@ -384,86 +384,86 @@ discard block |
||
| 384 | 384 | $ClientSideMeetingRequest = false; |
| 385 | 385 | $allowSendingInvitations = 'sendifnocalnotif'; |
| 386 | 386 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 387 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
| 387 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
| 388 | 388 | { |
| 389 | 389 | $allowSendingInvitations = false; |
| 390 | 390 | } |
| 391 | 391 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 392 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
| 392 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
| 393 | 393 | { |
| 394 | 394 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
| 395 | 395 | } |
| 396 | - $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
|
| 396 | + $smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new')); |
|
| 397 | 397 | |
| 398 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
|
| 399 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 398 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.(isset($smartdata->mime) ? $smartdata->mime : "")."task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
|
| 399 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 400 | 400 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 401 | 401 | |
| 402 | 402 | // initialize our Mail |
| 403 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 403 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 404 | 404 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 405 | 405 | // use the standardIdentity |
| 406 | - $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
| 406 | + $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
| 407 | 407 | |
| 408 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 408 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 409 | 409 | // collect identity / signature for later usage, and to determine if we may have to manipulate TransferEncoding and Charset |
| 410 | 410 | try |
| 411 | 411 | { |
| 412 | 412 | $acc = Mail\Account::read($this->mail->icServer->ImapServerId); |
| 413 | 413 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 414 | - $_signature = Mail\Account::read_identity($acc['ident_id'],true); |
|
| 414 | + $_signature = Mail\Account::read_identity($acc['ident_id'], true); |
|
| 415 | 415 | } |
| 416 | 416 | catch (Exception $e) |
| 417 | 417 | { |
| 418 | - $_signature=array(); |
|
| 418 | + $_signature = array(); |
|
| 419 | 419 | } |
| 420 | 420 | $signature = $_signature['ident_signature']; |
| 421 | 421 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
| 422 | 422 | $preferencesArray['disableRulerForSignatureSeparation']) || |
| 423 | - empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='') |
|
| 423 | + empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '') |
|
| 424 | 424 | { |
| 425 | 425 | $disableRuler = true; |
| 426 | 426 | } |
| 427 | 427 | $beforePlain = $beforeHtml = ""; |
| 428 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 429 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
| 430 | - $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
| 431 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 428 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 429 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
| 430 | + $sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
| 431 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 432 | 432 | $sigTextHtml = $beforeHtml.$sigText; |
| 433 | 433 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 434 | 434 | |
| 435 | - $force8bit=false; |
|
| 436 | - if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
| 435 | + $force8bit = false; |
|
| 436 | + if (Api\Translation::detect_encoding($sigTextPlain) != 'ascii') $force8bit = true; |
|
| 437 | 437 | // initialize the new Api\Mailer object for sending |
| 438 | 438 | $mailObject = new Api\Mailer(self::$profileID); |
| 439 | 439 | |
| 440 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); |
|
| 440 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime, $force8bit); |
|
| 441 | 441 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
| 442 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 443 | - $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); |
|
| 442 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 443 | + $mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false)); |
|
| 444 | 444 | $mailObject->addHeader('X-Mailer', 'mail-Activesync'); |
| 445 | 445 | |
| 446 | 446 | |
| 447 | 447 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 448 | 448 | // to |
| 449 | 449 | |
| 450 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 450 | + foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 451 | 451 | if (!$addressObject->valid) continue; |
| 452 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
| 452 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
| 453 | 453 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 454 | 454 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 455 | 455 | } |
| 456 | 456 | // CC |
| 457 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 457 | + foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 458 | 458 | if (!$addressObject->valid) continue; |
| 459 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
| 459 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
| 460 | 460 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 461 | 461 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 462 | 462 | } |
| 463 | 463 | // BCC |
| 464 | - foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 464 | + foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 465 | 465 | if (!$addressObject->valid) continue; |
| 466 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
| 466 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
| 467 | 467 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 468 | 468 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 469 | 469 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | $use_orgbody = false; |
| 473 | 473 | |
| 474 | 474 | $k = 'Content-Type'; |
| 475 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
| 475 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
| 476 | 476 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 477 | 477 | // if the message is a multipart message, then we should use the sent body |
| 478 | 478 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -492,43 +492,43 @@ discard block |
||
| 492 | 492 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
| 493 | 493 | $use_orgbody = true; |
| 494 | 494 | } |
| 495 | - $Body = $AltBody = ""; |
|
| 495 | + $Body = $AltBody = ""; |
|
| 496 | 496 | // get body of the transmitted message |
| 497 | 497 | // if this is a simple message, no structure at all |
| 498 | 498 | if (preg_match("/text/i", $ContentType)) |
| 499 | 499 | { |
| 500 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
| 500 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
| 501 | 501 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
| 502 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
| 503 | - if ($simpleBodyType == "text/plain") |
|
| 502 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
| 503 | + if ($simpleBodyType == "text/plain") |
|
| 504 | 504 | { |
| 505 | 505 | $Body = $body; |
| 506 | 506 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 507 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
| 507 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
| 508 | 508 | } |
| 509 | 509 | else |
| 510 | 510 | { |
| 511 | 511 | $AltBody = $body; |
| 512 | - $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 513 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
| 512 | + $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 513 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | else |
| 517 | 517 | { |
| 518 | 518 | // if this is a structured message |
| 519 | 519 | // prefer plain over html |
| 520 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 520 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 521 | 521 | ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
| 522 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 522 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 523 | 523 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 524 | 524 | } |
| 525 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 526 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 525 | + if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
| 526 | + if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
| 527 | 527 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 528 | 528 | // if this is a multipart message with a boundary, we must use the original body |
| 529 | 529 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 530 | 530 | if ($use_orgbody) { |
| 531 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 531 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 532 | 532 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 533 | 533 | if (($cal_body = $mailObject->findBody('calendar')) && |
| 534 | 534 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -537,21 +537,21 @@ discard block |
||
| 537 | 537 | { |
| 538 | 538 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 539 | 539 | } |
| 540 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 540 | + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 541 | 541 | $ClientSideMeetingRequest = true; |
| 542 | 542 | } |
| 543 | 543 | } |
| 544 | 544 | // now handle the addressee list |
| 545 | 545 | $toCount = 0; |
| 546 | 546 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 547 | - foreach((array)$toMailAddr as $address) { |
|
| 548 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 549 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 547 | + foreach ((array)$toMailAddr as $address) { |
|
| 548 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 549 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 550 | 550 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 551 | 551 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
| 552 | 552 | $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
| 553 | 553 | { |
| 554 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 554 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 555 | 555 | continue; |
| 556 | 556 | } |
| 557 | 557 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
@@ -559,29 +559,29 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | $ccCount = 0; |
| 562 | - foreach((array)$ccMailAddr as $address) { |
|
| 563 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 564 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 562 | + foreach ((array)$ccMailAddr as $address) { |
|
| 563 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 564 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 565 | 565 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 566 | 566 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 567 | 567 | $ccCount++; |
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | $bccCount = 0; |
| 571 | - foreach((array)$bccMailAddr as $address) { |
|
| 572 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 573 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 571 | + foreach ((array)$bccMailAddr as $address) { |
|
| 572 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 573 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 574 | 574 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 575 | 575 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 576 | 576 | $bccCount++; |
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
| 580 | - if ($toCount+$ccCount+$bccCount == 0) |
|
| 580 | + if ($toCount + $ccCount + $bccCount == 0) |
|
| 581 | 581 | { |
| 582 | 582 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 583 | 583 | } |
| 584 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 584 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
| 585 | 585 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 586 | 586 | /* |
| 587 | 587 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -598,26 +598,26 @@ discard block |
||
| 598 | 598 | { |
| 599 | 599 | // now get on, and fetch the original mail |
| 600 | 600 | $uid = $smartdata->source->itemid; |
| 601 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 601 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 602 | 602 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 603 | 603 | |
| 604 | 604 | $this->mail->reopen($folder); |
| 605 | 605 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 606 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 607 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 608 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 606 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 607 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 608 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 609 | 609 | // may be html |
| 610 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 610 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 611 | 611 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 612 | 612 | $isreply = true; |
| 613 | 613 | } |
| 614 | 614 | // plain text Message part |
| 615 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 615 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 616 | 616 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 617 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 618 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 619 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 620 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 617 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 618 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 619 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 620 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 621 | 621 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 622 | 622 | $isreply = true; |
| 623 | 623 | } |
@@ -625,12 +625,12 @@ discard block |
||
| 625 | 625 | { |
| 626 | 626 | $isreply = true; |
| 627 | 627 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 628 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 628 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // how to forward and other prefs |
| 633 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 633 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 634 | 634 | |
| 635 | 635 | // forward ------------------------------------------------------------------------- |
| 636 | 636 | if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | { |
| 641 | 641 | //force the default for the forwarding -> asmail |
| 642 | 642 | if (is_array($preferencesArray)) { |
| 643 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
| 643 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
| 644 | 644 | || !isset($preferencesArray['message_forwarding']) |
| 645 | 645 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
| 646 | 646 | } else { |
@@ -648,18 +648,18 @@ discard block |
||
| 648 | 648 | } |
| 649 | 649 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
| 650 | 650 | $uid = $smartdata->source->itemid; |
| 651 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 651 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 652 | 652 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 653 | 653 | |
| 654 | 654 | $this->mail->reopen($folder); |
| 655 | 655 | // receive entire mail (header + body) |
| 656 | 656 | // get message headers for specified message |
| 657 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 657 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 658 | 658 | // build a new mime message, forward entire old mail as file |
| 659 | 659 | if ($preferencesArray['message_forwarding'] == 'asmail') |
| 660 | 660 | { |
| 661 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
| 662 | - $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
| 661 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
| 662 | + $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
| 663 | 663 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
| 664 | 664 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
| 665 | 665 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -669,50 +669,50 @@ discard block |
||
| 669 | 669 | { |
| 670 | 670 | // now get on, and fetch the original mail |
| 671 | 671 | $uid = $smartdata->source->itemid; |
| 672 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 672 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 673 | 673 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 674 | 674 | |
| 675 | 675 | $this->mail->reopen($folder); |
| 676 | 676 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 677 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 678 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 679 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 677 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 678 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 679 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 680 | 680 | // may be html |
| 681 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 681 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 682 | 682 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 683 | 683 | $isforward = true; |
| 684 | 684 | } |
| 685 | 685 | // plain text Message part |
| 686 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 686 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 687 | 687 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 688 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 689 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 690 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 691 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 688 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 689 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 690 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 691 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 692 | 692 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 693 | 693 | $isforward = true; |
| 694 | 694 | } |
| 695 | 695 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 696 | 696 | { |
| 697 | 697 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 698 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 698 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 699 | 699 | $isforward = true; |
| 700 | 700 | } |
| 701 | 701 | // get all the attachments and add them too. |
| 702 | 702 | // start handle Attachments |
| 703 | 703 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
| 704 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
| 704 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
| 705 | 705 | $attachmentNames = false; |
| 706 | - if (is_array($attachments) && count($attachments)>0) |
|
| 706 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 707 | 707 | { |
| 708 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 709 | - foreach((array)$attachments as $key => $attachment) |
|
| 708 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 709 | + foreach ((array)$attachments as $key => $attachment) |
|
| 710 | 710 | { |
| 711 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 711 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 712 | 712 | $attachmentNames .= $attachment['name']."\n"; |
| 713 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
| 713 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
| 714 | 714 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
| 715 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
| 715 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
| 716 | 716 | } |
| 717 | 717 | } |
| 718 | 718 | } |
@@ -727,38 +727,38 @@ discard block |
||
| 727 | 727 | // now set the body |
| 728 | 728 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 729 | 729 | { |
| 730 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 730 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
| 731 | 731 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 732 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 732 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 733 | 733 | } |
| 734 | 734 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 735 | 735 | { |
| 736 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 736 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
| 737 | 737 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 738 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 738 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 739 | 739 | } |
| 740 | 740 | //advanced debugging |
| 741 | 741 | // Horde SMTP Class uses utf-8 by default. |
| 742 | 742 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 743 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 743 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 744 | 744 | |
| 745 | 745 | // set a higher timeout for big messages |
| 746 | 746 | @set_time_limit(120); |
| 747 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 747 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 748 | 748 | // send |
| 749 | 749 | $send = true; |
| 750 | 750 | try { |
| 751 | 751 | $mailObject->Send(); |
| 752 | 752 | } |
| 753 | - catch(Exception $e) { |
|
| 754 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
| 753 | + catch (Exception $e) { |
|
| 754 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
| 755 | 755 | $send = false; |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 758 | + if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 759 | 759 | { |
| 760 | 760 | $uid = $smartdata->source->itemid; |
| 761 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 761 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 762 | 762 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 763 | 763 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
| 764 | 764 | $this->mail->reopen($folder); |
@@ -766,89 +766,89 @@ discard block |
||
| 766 | 766 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 767 | 767 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 768 | 768 | { |
| 769 | - $this->mail->deleteMessages(array($uid),$folder); |
|
| 769 | + $this->mail->deleteMessages(array($uid), $folder); |
|
| 770 | 770 | } else { |
| 771 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
| 772 | - if ($smartdata_task== "forward") |
|
| 771 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
| 772 | + if ($smartdata_task == "forward") |
|
| 773 | 773 | { |
| 774 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
| 774 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
| 775 | 775 | } |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - $asf = ($send ? true:false); // initalize accordingly |
|
| 780 | - if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 779 | + $asf = ($send ? true : false); // initalize accordingly |
|
| 780 | + if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 781 | 781 | { |
| 782 | 782 | $asf = false; |
| 783 | 783 | $sentFolder = $this->mail->getSentFolder(); |
| 784 | 784 | if ($this->_sentID) { |
| 785 | 785 | $folderArray[] = $this->_sentID; |
| 786 | 786 | } |
| 787 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
| 787 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
| 788 | 788 | { |
| 789 | 789 | $folderArray[] = $sentFolder; |
| 790 | 790 | } |
| 791 | 791 | // No Sent folder set, try defaults |
| 792 | 792 | else |
| 793 | 793 | { |
| 794 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 794 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 795 | 795 | // we dont try guessing |
| 796 | 796 | $asf = true; |
| 797 | 797 | } |
| 798 | 798 | if (count($folderArray) > 0) { |
| 799 | - foreach((array)$bccMailAddr as $address) { |
|
| 800 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 801 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 799 | + foreach ((array)$bccMailAddr as $address) { |
|
| 800 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 801 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 802 | 802 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | - $BCCmail=''; |
|
| 806 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 807 | - foreach($folderArray as $folderName) { |
|
| 808 | - if($this->mail->isSentFolder($folderName)) { |
|
| 805 | + $BCCmail = ''; |
|
| 806 | + if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
| 807 | + foreach ($folderArray as $folderName) { |
|
| 808 | + if ($this->mail->isSentFolder($folderName)) { |
|
| 809 | 809 | $flags = '\\Seen'; |
| 810 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 810 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
| 811 | 811 | $flags = '\\Draft'; |
| 812 | 812 | } else { |
| 813 | 813 | $flags = ''; |
| 814 | 814 | } |
| 815 | 815 | $asf = true; |
| 816 | 816 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 817 | - $this->mail->openConnection(self::$profileID,false); |
|
| 817 | + $this->mail->openConnection(self::$profileID, false); |
|
| 818 | 818 | if ($this->mail->folderExists($folderName)) { |
| 819 | 819 | try |
| 820 | 820 | { |
| 821 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
| 821 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
| 822 | 822 | $flags); |
| 823 | 823 | } |
| 824 | 824 | catch (Api\Exception\WrongUserinput $e) |
| 825 | 825 | { |
| 826 | 826 | //$asf = false; |
| 827 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage())); |
|
| 827 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage())); |
|
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | else |
| 831 | 831 | { |
| 832 | 832 | //$asf = false; |
| 833 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
| 833 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
| 834 | 834 | } |
| 835 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 835 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
| 836 | 836 | } |
| 837 | 837 | //$this->mail->closeConnection(); |
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - $this->debugLevel=0; |
|
| 841 | + $this->debugLevel = 0; |
|
| 842 | 842 | |
| 843 | 843 | if ($send && $asf) |
| 844 | 844 | { |
| 845 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
| 845 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
| 846 | 846 | return true; |
| 847 | 847 | } |
| 848 | 848 | else |
| 849 | 849 | { |
| 850 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
| 851 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 850 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
| 851 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | |
@@ -866,43 +866,43 @@ discard block |
||
| 866 | 866 | public function GetMessage($folderid, $id, $contentparameters) |
| 867 | 867 | { |
| 868 | 868 | //$this->debugLevel=4; |
| 869 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 869 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 870 | 870 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 871 | 871 | $mimesupport = $contentparameters->GetMimeSupport(); |
| 872 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 872 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 873 | 873 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 874 | 874 | |
| 875 | 875 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 876 | 876 | if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
| 877 | 877 | |
| 878 | 878 | //$this->debugLevel=4; |
| 879 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 880 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 879 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 880 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 881 | 881 | $account = $_folderName = $xid = null; |
| 882 | - $this->splitID($folderid,$account,$_folderName,$xid); |
|
| 882 | + $this->splitID($folderid, $account, $_folderName, $xid); |
|
| 883 | 883 | $this->mail->reopen($_folderName); |
| 884 | - $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 884 | + $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 885 | 885 | $headers = $messages[$id]; |
| 886 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 886 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers)); |
|
| 887 | 887 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 888 | 888 | if ($headers) |
| 889 | 889 | { |
| 890 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 890 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 891 | 891 | // initialize the object |
| 892 | 892 | $output = new SyncMail(); |
| 893 | 893 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 894 | 894 | // simple style |
| 895 | 895 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 896 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 896 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 897 | 897 | |
| 898 | 898 | if ($bodypreference === false) { |
| 899 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
| 900 | - $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 899 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
| 900 | + $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 901 | 901 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 902 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 902 | + if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 903 | 903 | // remove all other html |
| 904 | 904 | $body = strip_tags($raw_body); |
| 905 | - if(strlen($body) > $truncsize) { |
|
| 905 | + if (strlen($body) > $truncsize) { |
|
| 906 | 906 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 907 | 907 | $output->bodytruncated = 1; |
| 908 | 908 | } |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | else // style with bodypreferences |
| 917 | 917 | { |
| 918 | 918 | //Select body type preference |
| 919 | - $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
| 919 | + $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
| 920 | 920 | if ($bodypreference !== false) { |
| 921 | 921 | // bodypreference can occur multiple times |
| 922 | 922 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -930,12 +930,12 @@ discard block |
||
| 930 | 930 | } |
| 931 | 931 | */ |
| 932 | 932 | } |
| 933 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 933 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 934 | 934 | // set the protocoll class |
| 935 | 935 | $output->asbody = new SyncBaseBody(); |
| 936 | 936 | |
| 937 | 937 | // return full mime-message without any (charset) conversation directly as stream |
| 938 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
| 938 | + if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) |
|
| 939 | 939 | { |
| 940 | 940 | //SYNC_BODYPREFERENCE_MIME |
| 941 | 941 | $output->asbody->type = SYNC_BODYPREFERENCE_MIME; |
@@ -944,58 +944,58 @@ discard block |
||
| 944 | 944 | fseek($stream, 0, SEEK_SET); |
| 945 | 945 | $output->asbody->data = $stream; |
| 946 | 946 | $output->asbody->estimatedDataSize = $fstat['size']; |
| 947 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 947 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 948 | 948 | } |
| 949 | 949 | else |
| 950 | 950 | { |
| 951 | 951 | // fetch the body (try to gather data only once) |
| 952 | - $css =''; |
|
| 953 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
| 954 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 955 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 956 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 957 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 952 | + $css = ''; |
|
| 953 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
| 954 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 955 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 956 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
| 957 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 958 | 958 | // may be html |
| 959 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 959 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 960 | 960 | $css = $this->mail->getStyles($bodyStruct); |
| 961 | - $output->nativebodytype=2; |
|
| 961 | + $output->nativebodytype = 2; |
|
| 962 | 962 | } else { |
| 963 | 963 | // plain text Message |
| 964 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 965 | - $output->nativebodytype=1; |
|
| 966 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 967 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 968 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 969 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 964 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 965 | + $output->nativebodytype = 1; |
|
| 966 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 967 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 968 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 969 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 970 | 970 | } |
| 971 | 971 | // whatever format decode (using the correct encoding) |
| 972 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 972 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
| 973 | 973 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 974 | 974 | // prepare plaintextbody |
| 975 | - $plainBody=''; |
|
| 975 | + $plainBody = ''; |
|
| 976 | 976 | if ($output->nativebodytype == 2) |
| 977 | 977 | { |
| 978 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 979 | - if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
| 978 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 979 | + if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
| 980 | 980 | { |
| 981 | 981 | $plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
| 982 | 982 | } |
| 983 | 983 | else |
| 984 | 984 | { |
| 985 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
| 985 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
| 986 | 986 | } |
| 987 | 987 | } |
| 988 | 988 | //if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body); |
| 989 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
| 989 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
| 990 | 990 | // remove all other html |
| 991 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
| 991 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
| 992 | 992 | $plainBody = strip_tags($plainBody); |
| 993 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 993 | + if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 994 | 994 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 995 | 995 | |
| 996 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 996 | + if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
| 997 | 997 | { |
| 998 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 998 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 999 | 999 | // Send HTML if requested and native type was html |
| 1000 | 1000 | $output->asbody->type = 2; |
| 1001 | 1001 | $htmlbody = '<html>'. |
@@ -1005,23 +1005,23 @@ discard block |
||
| 1005 | 1005 | $css. |
| 1006 | 1006 | '</head>'. |
| 1007 | 1007 | '<body>'; |
| 1008 | - if ($output->nativebodytype==2) |
|
| 1008 | + if ($output->nativebodytype == 2) |
|
| 1009 | 1009 | { |
| 1010 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1010 | + if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style'); |
|
| 1011 | 1011 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1012 | 1012 | $htmlbody .= $body; |
| 1013 | 1013 | } |
| 1014 | 1014 | else |
| 1015 | 1015 | { |
| 1016 | 1016 | // html requested but got only plaintext, so fake html |
| 1017 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
| 1017 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | $htmlbody .= '</body>'. |
| 1020 | 1020 | '</html>'; |
| 1021 | 1021 | |
| 1022 | - if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1022 | + if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1023 | 1023 | { |
| 1024 | - $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
| 1024 | + $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
| 1025 | 1025 | $output->asbody->truncated = 1; |
| 1026 | 1026 | } |
| 1027 | 1027 | // output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | else |
| 1033 | 1033 | { |
| 1034 | 1034 | // Send Plaintext as Fallback or if original body is plainttext |
| 1035 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1035 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1036 | 1036 | /* we use plainBody (set above) instead |
| 1037 | 1037 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1038 | 1038 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | */ |
| 1043 | 1043 | $output->asbody->type = 1; |
| 1044 | 1044 | $output->nativebodytype = 1; |
| 1045 | - if(isset($truncsize) && |
|
| 1045 | + if (isset($truncsize) && |
|
| 1046 | 1046 | strlen($plainBody) > $truncsize) |
| 1047 | 1047 | { |
| 1048 | 1048 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | } |
| 1062 | 1062 | } |
| 1063 | 1063 | // end AS12 Stuff |
| 1064 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1064 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1065 | 1065 | $output->read = $headers["flags"]; |
| 1066 | 1066 | |
| 1067 | 1067 | $output->flag = new SyncMailFlags(); |
@@ -1081,9 +1081,8 @@ discard block |
||
| 1081 | 1081 | $output->lastverexecuted = AS_FORWARD; |
| 1082 | 1082 | } |
| 1083 | 1083 | $output->subject = $headers['subject']; |
| 1084 | - $output->importance = $headers['priority'] > 3 ? 0 : |
|
| 1085 | - ($headers['priority'] < 3 ? 2 : 1) ; |
|
| 1086 | - $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
|
| 1084 | + $output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1); |
|
| 1085 | + $output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true); |
|
| 1087 | 1086 | $output->to = $headers['to_address']; |
| 1088 | 1087 | if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
| 1089 | 1088 | $output->from = $headers['sender_address']; |
@@ -1091,8 +1090,8 @@ discard block |
||
| 1091 | 1090 | if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
| 1092 | 1091 | |
| 1093 | 1092 | $output->messageclass = "IPM.Note"; |
| 1094 | - if (stripos($headers['mimetype'],'multipart')!== false && |
|
| 1095 | - stripos($headers['mimetype'],'signed')!== false) |
|
| 1093 | + if (stripos($headers['mimetype'], 'multipart') !== false && |
|
| 1094 | + stripos($headers['mimetype'], 'signed') !== false) |
|
| 1096 | 1095 | { |
| 1097 | 1096 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1098 | 1097 | } |
@@ -1101,20 +1100,20 @@ discard block |
||
| 1101 | 1100 | } |
| 1102 | 1101 | |
| 1103 | 1102 | // start handle Attachments (include text/calendar multipart alternative) |
| 1104 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
| 1103 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
| 1105 | 1104 | // Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
| 1106 | - if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
| 1105 | + if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
| 1107 | 1106 | { |
| 1108 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1107 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1109 | 1108 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1110 | 1109 | foreach ($attachments as $key => $attach) |
| 1111 | 1110 | { |
| 1112 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1111 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1113 | 1112 | |
| 1114 | 1113 | // pass meeting requests to calendar plugin |
| 1115 | 1114 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1116 | 1115 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 1117 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
| 1116 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
| 1118 | 1117 | ($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
| 1119 | 1118 | { |
| 1120 | 1119 | //overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
@@ -1124,7 +1123,7 @@ discard block |
||
| 1124 | 1123 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1125 | 1124 | //$output->messageclass = "IPM.Schedule.Meeting"; |
| 1126 | 1125 | unset($attachment); |
| 1127 | - continue; // do NOT add attachment as attachment |
|
| 1126 | + continue; // do NOT add attachment as attachment |
|
| 1128 | 1127 | } |
| 1129 | 1128 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1130 | 1129 | $attachment = new SyncBaseAttachment(); |
@@ -1132,33 +1131,33 @@ discard block |
||
| 1132 | 1131 | $output->asattachments = array(); |
| 1133 | 1132 | $attachment->estimatedDataSize = $attach['size']; |
| 1134 | 1133 | $attachment->method = 1; |
| 1135 | - $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
| 1134 | + $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
| 1136 | 1135 | } else { |
| 1137 | 1136 | $attachment = new SyncAttachment(); |
| 1138 | 1137 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1139 | 1138 | $output->attachments = array(); |
| 1140 | 1139 | $attachment->attsize = $attach['size']; |
| 1141 | 1140 | $attachment->attmethod = 1; |
| 1142 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
| 1141 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
| 1143 | 1142 | } |
| 1144 | 1143 | |
| 1145 | 1144 | $attachment->displayname = $attach['name']; |
| 1146 | 1145 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
| 1147 | 1146 | |
| 1148 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1147 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1149 | 1148 | //$attachment->isinline=0; // if not inline, do not use isinline |
| 1150 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
| 1149 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
| 1151 | 1150 | { |
| 1152 | 1151 | if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
| 1153 | 1152 | { |
| 1154 | 1153 | $attachment->isinline = true; |
| 1155 | 1154 | } |
| 1156 | 1155 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1157 | - $attachment->method=1; |
|
| 1158 | - $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
| 1156 | + $attachment->method = 1; |
|
| 1157 | + $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1159 | 1158 | } else { |
| 1160 | - $attachment->attmethod=6; |
|
| 1161 | - $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
| 1159 | + $attachment->attmethod = 6; |
|
| 1160 | + $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1162 | 1161 | } |
| 1163 | 1162 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1164 | 1163 | $attachment->contenttype = trim($attach['mimeType']); |
@@ -1179,7 +1178,7 @@ discard block |
||
| 1179 | 1178 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1180 | 1179 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1181 | 1180 | |
| 1182 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1181 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
| 1183 | 1182 | //$this->debugLevel=0; |
| 1184 | 1183 | return $output; |
| 1185 | 1184 | } |
@@ -1202,30 +1201,30 @@ discard block |
||
| 1202 | 1201 | { |
| 1203 | 1202 | if (!class_exists('calendar_zpush')) |
| 1204 | 1203 | { |
| 1205 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1204 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1206 | 1205 | return null; |
| 1207 | 1206 | } |
| 1208 | 1207 | if (!($stat = $this->StatMessage($folderid, $requestid))) |
| 1209 | 1208 | { |
| 1210 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1209 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1211 | 1210 | return false; |
| 1212 | 1211 | } |
| 1213 | 1212 | $ret = false; |
| 1214 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
| 1213 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
| 1215 | 1214 | { |
| 1216 | 1215 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1217 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
| 1216 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
| 1218 | 1217 | { |
| 1219 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1218 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1220 | 1219 | |
| 1221 | 1220 | // calling backend again with iCal attachment, to let calendar add the event |
| 1222 | 1221 | $ret = $this->backend->MeetingResponse($attachment['attachment'], |
| 1223 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
| 1222 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
| 1224 | 1223 | $response); |
| 1225 | 1224 | break; |
| 1226 | 1225 | } |
| 1227 | 1226 | } |
| 1228 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1227 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1229 | 1228 | return $ret; |
| 1230 | 1229 | } |
| 1231 | 1230 | |
@@ -1239,9 +1238,9 @@ discard block |
||
| 1239 | 1238 | * @param string $attname - should contain (folder)id |
| 1240 | 1239 | * @return SyncItemOperationsAttachment-object |
| 1241 | 1240 | */ |
| 1242 | - function GetAttachmentData($fid,$attname) { |
|
| 1243 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1244 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1241 | + function GetAttachmentData($fid, $attname) { |
|
| 1242 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1243 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1245 | 1244 | } |
| 1246 | 1245 | |
| 1247 | 1246 | /** |
@@ -1254,9 +1253,9 @@ discard block |
||
| 1254 | 1253 | * @param string $attname - should contain (folder)id |
| 1255 | 1254 | * @return SyncItemOperationsAttachment-object |
| 1256 | 1255 | */ |
| 1257 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1258 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1259 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1256 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
| 1257 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1258 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1260 | 1259 | } |
| 1261 | 1260 | |
| 1262 | 1261 | /** |
@@ -1268,23 +1267,23 @@ discard block |
||
| 1268 | 1267 | * @param string $attname - should contain (folder)id |
| 1269 | 1268 | * @return SyncItemOperationsAttachment-object |
| 1270 | 1269 | */ |
| 1271 | - private function _GetAttachmentData($fid,$attname) |
|
| 1270 | + private function _GetAttachmentData($fid, $attname) |
|
| 1272 | 1271 | { |
| 1273 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1272 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1274 | 1273 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1275 | 1274 | list($folderid, $id, $part) = explode(":", $attname); |
| 1276 | 1275 | |
| 1277 | 1276 | $this->splitID($folderid, $account, $folder); |
| 1278 | 1277 | |
| 1279 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1278 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1280 | 1279 | |
| 1281 | 1280 | $this->mail->reopen($folder); |
| 1282 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
| 1281 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
| 1283 | 1282 | $SIOattachment = new SyncItemOperationsAttachment(); |
| 1284 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1283 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1285 | 1284 | $SIOattachment->data = $attachment['attachment']; |
| 1286 | 1285 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1287 | - if (isset($attachment['type']) ) |
|
| 1286 | + if (isset($attachment['type'])) |
|
| 1288 | 1287 | $SIOattachment->contenttype = $attachment['type']; |
| 1289 | 1288 | |
| 1290 | 1289 | unset($attachment); |
@@ -1327,17 +1326,17 @@ discard block |
||
| 1327 | 1326 | */ |
| 1328 | 1327 | function ChangeMessage($folderid, $id, $message, $contentParameters) |
| 1329 | 1328 | { |
| 1330 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1329 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1331 | 1330 | //unset($folderid, $id, $message, $contentParameters); |
| 1332 | 1331 | $account = $folder = null; |
| 1333 | 1332 | $this->splitID($folderid, $account, $folder); |
| 1334 | 1333 | if (isset($message->flag)) { |
| 1335 | 1334 | if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
| 1336 | - $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
| 1337 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1335 | + $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
| 1336 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1338 | 1337 | } else { |
| 1339 | - $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
| 1340 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
| 1338 | + $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
| 1339 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
| 1341 | 1340 | } |
| 1342 | 1341 | } |
| 1343 | 1342 | return $this->StatMessage($folderid, $id); |
@@ -1359,23 +1358,23 @@ discard block |
||
| 1359 | 1358 | */ |
| 1360 | 1359 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
| 1361 | 1360 | { |
| 1362 | - unset($contentParameters); // not used, but required by function signature |
|
| 1361 | + unset($contentParameters); // not used, but required by function signature |
|
| 1363 | 1362 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
| 1364 | 1363 | $account = $srcFolder = $destFolder = null; |
| 1365 | 1364 | $this->splitID($folderid, $account, $srcFolder); |
| 1366 | 1365 | $this->splitID($newfolderid, $account, $destFolder); |
| 1367 | 1366 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1368 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1367 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1369 | 1368 | $this->mail->reopen($destFolder); |
| 1370 | 1369 | $status = $this->mail->getFolderStatus($destFolder); |
| 1371 | 1370 | $uidNext = $status['uidnext']; |
| 1372 | 1371 | $this->mail->reopen($srcFolder); |
| 1373 | 1372 | |
| 1374 | 1373 | // move message |
| 1375 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
| 1376 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine |
|
| 1374 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
| 1375 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine |
|
| 1377 | 1376 | // return the new id "as string" |
| 1378 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
| 1377 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
| 1379 | 1378 | } |
| 1380 | 1379 | |
| 1381 | 1380 | /** |
@@ -1383,7 +1382,7 @@ discard block |
||
| 1383 | 1382 | * |
| 1384 | 1383 | * @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks |
| 1385 | 1384 | */ |
| 1386 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
| 1385 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
| 1387 | 1386 | { |
| 1388 | 1387 | if ($cutoffdate > 0) |
| 1389 | 1388 | { |
@@ -1396,8 +1395,8 @@ discard block |
||
| 1396 | 1395 | { |
| 1397 | 1396 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1398 | 1397 | } |
| 1399 | - $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
|
| 1400 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1398 | + $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null); |
|
| 1399 | + if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1401 | 1400 | } |
| 1402 | 1401 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1403 | 1402 | } |
@@ -1415,11 +1414,11 @@ discard block |
||
| 1415 | 1414 | * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject" |
| 1416 | 1415 | * @return array uid => array StatMessage($folderid, $_id) |
| 1417 | 1416 | */ |
| 1418 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false) |
|
| 1417 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false) |
|
| 1419 | 1418 | { |
| 1420 | 1419 | static $headers = array(); |
| 1421 | 1420 | |
| 1422 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1421 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
| 1423 | 1422 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1424 | 1423 | $rv_messages = array(); |
| 1425 | 1424 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1430,64 +1429,64 @@ discard block |
||
| 1430 | 1429 | } |
| 1431 | 1430 | else |
| 1432 | 1431 | { |
| 1433 | - $headers = array(); // clear cache to not use too much memory |
|
| 1432 | + $headers = array(); // clear cache to not use too much memory |
|
| 1434 | 1433 | |
| 1435 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1434 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1436 | 1435 | $this->_connect($this->account); |
| 1437 | - if ($this->debugLevel>1) |
|
| 1436 | + if ($this->debugLevel > 1) |
|
| 1438 | 1437 | { |
| 1439 | 1438 | $endtime = microtime(true) - $starttime; |
| 1440 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
| 1439 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
| 1441 | 1440 | } |
| 1442 | 1441 | $messagelist = $_filter = array(); |
| 1443 | 1442 | // if not connected, any further action must fail |
| 1444 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1445 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1443 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1444 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1446 | 1445 | $account = $_folderName = $id = null; |
| 1447 | - $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1448 | - if ($this->debugLevel>1) |
|
| 1446 | + $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1447 | + if ($this->debugLevel > 1) |
|
| 1449 | 1448 | { |
| 1450 | 1449 | $endtime = microtime(true) - $starttime; |
| 1451 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1450 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1452 | 1451 | } |
| 1453 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1454 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1455 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
| 1456 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
| 1457 | - if ($this->debugLevel>1) |
|
| 1452 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1453 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1454 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
| 1455 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
| 1456 | + if ($this->debugLevel > 1) |
|
| 1458 | 1457 | { |
| 1459 | 1458 | $endtime = microtime(true) - $starttime; |
| 1460 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1459 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1461 | 1460 | } |
| 1462 | 1461 | } |
| 1463 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1462 | + if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
| 1464 | 1463 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1465 | 1464 | $messagelist = array(); |
| 1466 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1465 | + if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
| 1467 | 1466 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1468 | 1467 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1469 | 1468 | { |
| 1470 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1469 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1471 | 1470 | $headers[$vars['uid']] = $vars; |
| 1472 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1471 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1473 | 1472 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
| 1474 | 1473 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
| 1475 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1474 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1476 | 1475 | $mess = $return_all_headers ? $vars : array(); |
| 1477 | 1476 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1478 | 1477 | $mess["id"] = $vars['uid']; |
| 1479 | 1478 | // 'seen' aka 'read' is the only flag we want to know about |
| 1480 | 1479 | $mess["flags"] = 0; |
| 1481 | 1480 | // outlook supports additional flags, set them to 0 |
| 1482 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1483 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1481 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
| 1482 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
| 1484 | 1483 | $messagelist[$vars['uid']] = $mess; |
| 1485 | 1484 | unset($mess); |
| 1486 | 1485 | } |
| 1487 | - if ($this->debugLevel>1) |
|
| 1486 | + if ($this->debugLevel > 1) |
|
| 1488 | 1487 | { |
| 1489 | 1488 | $endtime = microtime(true) - $gstarttime; |
| 1490 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1489 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1491 | 1490 | } |
| 1492 | 1491 | return $messagelist; |
| 1493 | 1492 | } |
@@ -1538,32 +1537,32 @@ discard block |
||
| 1538 | 1537 | public function getSearchResultsMailbox($_searchquery) |
| 1539 | 1538 | { |
| 1540 | 1539 | //$this->debugLevel=1; |
| 1541 | - $searchquery=$_searchquery->GetDataArray(); |
|
| 1540 | + $searchquery = $_searchquery->GetDataArray(); |
|
| 1542 | 1541 | if (!is_array($searchquery)) return array(); |
| 1543 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1542 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
| 1544 | 1543 | |
| 1545 | 1544 | if (isset($searchquery['searchrebuildresults'])) { |
| 1546 | 1545 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1547 | 1546 | } else { |
| 1548 | 1547 | $rebuildresults = false; |
| 1549 | 1548 | } |
| 1550 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1549 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']'); |
|
| 1551 | 1550 | |
| 1552 | 1551 | if (isset($searchquery['deeptraversal'])) { |
| 1553 | 1552 | $deeptraversal = $searchquery['deeptraversal']; |
| 1554 | 1553 | } else { |
| 1555 | 1554 | $deeptraversal = false; |
| 1556 | 1555 | } |
| 1557 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1556 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']'); |
|
| 1558 | 1557 | |
| 1559 | 1558 | if (isset($searchquery['searchrange'])) { |
| 1560 | - $range = explode("-",$_searchquery->GetSearchRange()); |
|
| 1561 | - $start =$range[0] + 1; |
|
| 1559 | + $range = explode("-", $_searchquery->GetSearchRange()); |
|
| 1560 | + $start = $range[0] + 1; |
|
| 1562 | 1561 | $limit = $range[1] - $range[0] + 1; |
| 1563 | 1562 | } else { |
| 1564 | 1563 | $range = false; |
| 1565 | 1564 | } |
| 1566 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1565 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']'); |
|
| 1567 | 1566 | |
| 1568 | 1567 | //foreach($searchquery['query'] as $k => $value) { |
| 1569 | 1568 | // $query = $value; |
@@ -1586,15 +1585,15 @@ discard block |
||
| 1586 | 1585 | } |
| 1587 | 1586 | if (!$folderid) |
| 1588 | 1587 | { |
| 1589 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
| 1590 | - $folderid = $this->createID($account=0,$_folderName); |
|
| 1588 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
| 1589 | + $folderid = $this->createID($account = 0, $_folderName); |
|
| 1591 | 1590 | } |
| 1592 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1593 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1591 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1592 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1594 | 1593 | $this->_connect($account); |
| 1595 | 1594 | // this should not be needed ??? |
| 1596 | - Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
| 1597 | - $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
| 1595 | + Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
| 1596 | + $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
| 1598 | 1597 | 'string'=> $searchText, |
| 1599 | 1598 | 'status'=>'any' |
| 1600 | 1599 | ); |
@@ -1609,22 +1608,22 @@ discard block |
||
| 1609 | 1608 | * [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
| 1610 | 1609 | */ |
| 1611 | 1610 | $_filter['range'] = "BETWEEN"; |
| 1612 | - list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
| 1613 | - list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
| 1614 | - $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
| 1615 | - $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
| 1611 | + list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
| 1612 | + list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
| 1613 | + $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
| 1614 | + $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
| 1616 | 1615 | } |
| 1617 | 1616 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1618 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1619 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
| 1617 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1618 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
| 1620 | 1619 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1621 | - $list=array(); |
|
| 1620 | + $list = array(); |
|
| 1622 | 1621 | |
| 1623 | 1622 | $cnt = count($rv_messages['header']); |
| 1624 | 1623 | //$list['status'] = 1; |
| 1625 | 1624 | $list['searchtotal'] = $cnt; |
| 1626 | 1625 | $list["range"] = $_searchquery->GetSearchRange(); |
| 1627 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
| 1626 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
| 1628 | 1627 | { |
| 1629 | 1628 | $list[] = array( |
| 1630 | 1629 | "class" => "Email", |
@@ -1644,20 +1643,20 @@ discard block |
||
| 1644 | 1643 | * @param string $folder |
| 1645 | 1644 | * @return string |
| 1646 | 1645 | */ |
| 1647 | - private function getParentID($account,$folder) |
|
| 1646 | + private function getParentID($account, $folder) |
|
| 1648 | 1647 | { |
| 1649 | 1648 | $this->_connect($account); |
| 1650 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1649 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1651 | 1650 | |
| 1652 | 1651 | $mailFolder = $this->folders[$folder]; |
| 1653 | 1652 | if (!isset($mailFolder)) return false; |
| 1654 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
| 1655 | - $parent = explode($delimiter,$folder); |
|
| 1653 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
| 1654 | + $parent = explode($delimiter, $folder); |
|
| 1656 | 1655 | array_pop($parent); |
| 1657 | - $parent = implode($delimiter,$parent); |
|
| 1656 | + $parent = implode($delimiter, $parent); |
|
| 1658 | 1657 | |
| 1659 | 1658 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1660 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1659 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1661 | 1660 | return $id; |
| 1662 | 1661 | } |
| 1663 | 1662 | |
@@ -1677,48 +1676,48 @@ discard block |
||
| 1677 | 1676 | $account = $folder = null; |
| 1678 | 1677 | $this->splitID($id, $account, $folder); |
| 1679 | 1678 | } |
| 1680 | - catch(Exception $e) { |
|
| 1681 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1682 | - return $folderObj=false; |
|
| 1679 | + catch (Exception $e) { |
|
| 1680 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1681 | + return $folderObj = false; |
|
| 1683 | 1682 | } |
| 1684 | 1683 | $this->_connect($account); |
| 1685 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1684 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1686 | 1685 | |
| 1687 | 1686 | $mailFolder = $this->folders[$folder]; |
| 1688 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 1687 | + if (!isset($mailFolder)) return $folderObj = false; |
|
| 1689 | 1688 | |
| 1690 | 1689 | $folderObj = new SyncFolder(); |
| 1691 | 1690 | $folderObj->serverid = $id; |
| 1692 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
| 1691 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
| 1693 | 1692 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1694 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1693 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1695 | 1694 | // get folder-type |
| 1696 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 1695 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
| 1697 | 1696 | if ($folder == $inbox) |
| 1698 | 1697 | { |
| 1699 | 1698 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
| 1700 | 1699 | } |
| 1701 | - elseif($this->mail->isDraftFolder($folder, false, true)) |
|
| 1700 | + elseif ($this->mail->isDraftFolder($folder, false, true)) |
|
| 1702 | 1701 | { |
| 1703 | 1702 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
| 1704 | 1703 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
| 1705 | 1704 | $folderObj->parentid = 0; // required by devices |
| 1706 | 1705 | } |
| 1707 | - elseif($this->mail->isTrashFolder($folder, false, true)) |
|
| 1706 | + elseif ($this->mail->isTrashFolder($folder, false, true)) |
|
| 1708 | 1707 | { |
| 1709 | 1708 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
| 1710 | 1709 | $this->_wasteID = $folder; |
| 1711 | 1710 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
| 1712 | 1711 | $folderObj->parentid = 0; // required by devices |
| 1713 | 1712 | } |
| 1714 | - elseif($this->mail->isSentFolder($folder, false, true)) |
|
| 1713 | + elseif ($this->mail->isSentFolder($folder, false, true)) |
|
| 1715 | 1714 | { |
| 1716 | 1715 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
| 1717 | 1716 | $folderObj->parentid = 0; // required by devices |
| 1718 | 1717 | $this->_sentID = $folder; |
| 1719 | 1718 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
| 1720 | 1719 | } |
| 1721 | - elseif($this->mail->isOutbox($folder, false, true)) |
|
| 1720 | + elseif ($this->mail->isOutbox($folder, false, true)) |
|
| 1722 | 1721 | { |
| 1723 | 1722 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
| 1724 | 1723 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1730,7 +1729,7 @@ discard block |
||
| 1730 | 1729 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1731 | 1730 | } |
| 1732 | 1731 | |
| 1733 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1732 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1734 | 1733 | return $folderObj; |
| 1735 | 1734 | } |
| 1736 | 1735 | |
@@ -1778,18 +1777,18 @@ discard block |
||
| 1778 | 1777 | |
| 1779 | 1778 | if ($type != 'mail') return false; |
| 1780 | 1779 | |
| 1781 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1780 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1782 | 1781 | |
| 1783 | 1782 | $this->mail->reopen($folder); |
| 1784 | 1783 | |
| 1785 | - if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true))) |
|
| 1784 | + if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true))) |
|
| 1786 | 1785 | { |
| 1787 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
| 1786 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
| 1788 | 1787 | return false; |
| 1789 | 1788 | } |
| 1790 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1789 | + $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1791 | 1790 | |
| 1792 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1791 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1793 | 1792 | return array(); |
| 1794 | 1793 | } |
| 1795 | 1794 | |
@@ -1802,8 +1801,8 @@ discard block |
||
| 1802 | 1801 | function GetWasteBasket() |
| 1803 | 1802 | { |
| 1804 | 1803 | $this->_connect($this->account); |
| 1805 | - $id = $this->createID($account=0, $this->_wasteID); |
|
| 1806 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1804 | + $id = $this->createID($account = 0, $this->_wasteID); |
|
| 1805 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1807 | 1806 | return $id; |
| 1808 | 1807 | } |
| 1809 | 1808 | |
@@ -1824,7 +1823,7 @@ discard block |
||
| 1824 | 1823 | */ |
| 1825 | 1824 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1826 | 1825 | { |
| 1827 | - unset($contentParameters); // not used, but required by function signature |
|
| 1826 | + unset($contentParameters); // not used, but required by function signature |
|
| 1828 | 1827 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1829 | 1828 | /* |
| 1830 | 1829 | $this->imap_reopenFolder($folderid); |
@@ -1835,7 +1834,7 @@ discard block |
||
| 1835 | 1834 | // we may have to split folderid |
| 1836 | 1835 | $account = $folder = null; |
| 1837 | 1836 | $this->splitID($folderid, $account, $folder); |
| 1838 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1837 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1839 | 1838 | $_messageUID = (array)$id; |
| 1840 | 1839 | |
| 1841 | 1840 | $this->_connect($this->account); |
@@ -1847,9 +1846,9 @@ discard block |
||
| 1847 | 1846 | catch (Api\Exception $e) |
| 1848 | 1847 | { |
| 1849 | 1848 | $error = $e->getMessage(); |
| 1850 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1849 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1851 | 1850 | // if the server thinks the message does not exist report deletion as success |
| 1852 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 1851 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
| 1853 | 1852 | return false; |
| 1854 | 1853 | } |
| 1855 | 1854 | |
@@ -1883,15 +1882,15 @@ discard block |
||
| 1883 | 1882 | */ |
| 1884 | 1883 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1885 | 1884 | { |
| 1886 | - unset($contentParameters); // not used, but required by function signature |
|
| 1885 | + unset($contentParameters); // not used, but required by function signature |
|
| 1887 | 1886 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1888 | 1887 | $account = $folder = null; |
| 1889 | 1888 | $this->splitID($folderid, $account, $folder); |
| 1890 | 1889 | |
| 1891 | 1890 | $_messageUID = (array)$id; |
| 1892 | 1891 | $this->_connect($this->account); |
| 1893 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
| 1894 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
| 1892 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
| 1893 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
| 1895 | 1894 | |
| 1896 | 1895 | return $rv; |
| 1897 | 1896 | } |
@@ -1908,7 +1907,7 @@ discard block |
||
| 1908 | 1907 | */ |
| 1909 | 1908 | public function ChangeFolder($id, $oldid, $displayname, $type) |
| 1910 | 1909 | { |
| 1911 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!"); |
|
| 1910 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!"); |
|
| 1912 | 1911 | return false; |
| 1913 | 1912 | } |
| 1914 | 1913 | |
@@ -1923,7 +1922,7 @@ discard block |
||
| 1923 | 1922 | */ |
| 1924 | 1923 | public function DeleteFolder($parentid, $id) |
| 1925 | 1924 | { |
| 1926 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$parentid', '$id') NOT supported!"); |
|
| 1925 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$parentid', '$id') NOT supported!"); |
|
| 1927 | 1926 | return false; |
| 1928 | 1927 | } |
| 1929 | 1928 | |
@@ -1943,8 +1942,8 @@ discard block |
||
| 1943 | 1942 | $this->_connect($this->account); |
| 1944 | 1943 | $account = $folder = null; |
| 1945 | 1944 | $this->splitID($folderid, $account, $folder); |
| 1946 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
| 1947 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1945 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
| 1946 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1948 | 1947 | |
| 1949 | 1948 | return $rv; |
| 1950 | 1949 | } |
@@ -1958,17 +1957,17 @@ discard block |
||
| 1958 | 1957 | * @return string |
| 1959 | 1958 | * @throws Api\Exception\WrongParameter |
| 1960 | 1959 | */ |
| 1961 | - private function createID($account,$folder,$id=0) |
|
| 1960 | + private function createID($account, $folder, $id = 0) |
|
| 1962 | 1961 | { |
| 1963 | 1962 | if (!is_numeric($folder)) |
| 1964 | 1963 | { |
| 1965 | 1964 | // convert string $folder in numeric id |
| 1966 | - $folder = $this->folder2hash($account,$f=$folder); |
|
| 1965 | + $folder = $this->folder2hash($account, $f = $folder); |
|
| 1967 | 1966 | } |
| 1968 | 1967 | |
| 1969 | 1968 | $str = $this->backend->createID($account, $folder, $id); |
| 1970 | 1969 | |
| 1971 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 1970 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 1972 | 1971 | |
| 1973 | 1972 | return $str; |
| 1974 | 1973 | } |
@@ -1982,14 +1981,14 @@ discard block |
||
| 1982 | 1981 | * @param int &$id=null |
| 1983 | 1982 | * @throws Api\Exception\WrongParameter |
| 1984 | 1983 | */ |
| 1985 | - private function splitID($str,&$account,&$folder,&$id=null) |
|
| 1984 | + private function splitID($str, &$account, &$folder, &$id = null) |
|
| 1986 | 1985 | { |
| 1987 | 1986 | $this->backend->splitID($str, $account, $folder, $id); |
| 1988 | 1987 | |
| 1989 | 1988 | // convert numeric folder-id back to folder name |
| 1990 | - $folder = $this->hash2folder($account,$f=$folder); |
|
| 1989 | + $folder = $this->hash2folder($account, $f = $folder); |
|
| 1991 | 1990 | |
| 1992 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
| 1991 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$id)"); |
|
| 1993 | 1992 | } |
| 1994 | 1993 | |
| 1995 | 1994 | /** |
@@ -2006,9 +2005,9 @@ discard block |
||
| 2006 | 2005 | * @param string $folder |
| 2007 | 2006 | * @return int |
| 2008 | 2007 | */ |
| 2009 | - private function folder2hash($account,$folder) |
|
| 2008 | + private function folder2hash($account, $folder) |
|
| 2010 | 2009 | { |
| 2011 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2010 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2012 | 2011 | |
| 2013 | 2012 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2014 | 2013 | { |
@@ -2029,9 +2028,9 @@ discard block |
||
| 2029 | 2028 | * @param int $index |
| 2030 | 2029 | * @return string NULL if not used so far |
| 2031 | 2030 | */ |
| 2032 | - private function hash2folder($account,$index) |
|
| 2031 | + private function hash2folder($account, $index) |
|
| 2033 | 2032 | { |
| 2034 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2033 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2035 | 2034 | |
| 2036 | 2035 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2037 | 2036 | } |
@@ -2068,9 +2067,9 @@ discard block |
||
| 2068 | 2067 | if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
| 2069 | 2068 | ($hashes = file_get_contents($file))) |
| 2070 | 2069 | { |
| 2071 | - $this->folderHashes = json_decode($hashes,true); |
|
| 2070 | + $this->folderHashes = json_decode($hashes, true); |
|
| 2072 | 2071 | // fallback in case hashes have been serialized instead of being json-encoded |
| 2073 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
| 2072 | + if (json_last_error() != JSON_ERROR_NONE) |
|
| 2074 | 2073 | { |
| 2075 | 2074 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
| 2076 | 2075 | $this->folderHashes = unserialize($hashes); |
@@ -2116,9 +2115,9 @@ discard block |
||
| 2116 | 2115 | * @param boolean $old =false true: return old / pre-15 hash-file |
| 2117 | 2116 | * @throws Api\Exception\AssertionFailed |
| 2118 | 2117 | */ |
| 2119 | - private function hashFile($old=false) |
|
| 2118 | + private function hashFile($old = false) |
|
| 2120 | 2119 | { |
| 2121 | - if (!($dev_id=Request::GetDeviceID())) |
|
| 2120 | + if (!($dev_id = Request::GetDeviceID())) |
|
| 2122 | 2121 | { |
| 2123 | 2122 | throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
| 2124 | 2123 | } |
@@ -84,29 +84,47 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function __construct(activesync_backend $backend) |
| 86 | 86 | { |
| 87 | - if ($GLOBALS['egw_setup']) return; |
|
| 87 | + if ($GLOBALS['egw_setup']) |
|
| 88 | + { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | //$this->debugLevel=2; |
| 90 | 93 | $this->backend = $backend; |
| 91 | 94 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 92 | 95 | { |
| 93 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 96 | + if ($this->debugLevel>1) |
|
| 97 | + { |
|
| 98 | + error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 99 | + } |
|
| 94 | 100 | // globals preferences add appname varname value |
| 95 | 101 | $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
| 96 | 102 | // save prefs |
| 97 | 103 | $GLOBALS['egw']->preferences->save_repository(true); |
| 98 | 104 | } |
| 99 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 105 | + if ($this->debugLevel>1) |
|
| 106 | + { |
|
| 107 | + error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 108 | + } |
|
| 100 | 109 | |
| 101 | 110 | if (is_null(self::$profileID)) |
| 102 | 111 | { |
| 103 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 112 | + if ($this->debugLevel>1) |
|
| 113 | + { |
|
| 114 | + error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 115 | + } |
|
| 104 | 116 | self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
| 105 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 117 | + if ($this->debugLevel>1) |
|
| 118 | + { |
|
| 119 | + error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 120 | + } |
|
| 106 | 121 | } |
| 107 | 122 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 108 | 123 | { |
| 109 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 124 | + if ($this->debugLevel>1) |
|
| 125 | + { |
|
| 126 | + error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 127 | + } |
|
| 110 | 128 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
| 111 | 129 | { |
| 112 | 130 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -116,7 +134,10 @@ discard block |
||
| 116 | 134 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
| 117 | 135 | } |
| 118 | 136 | } |
| 119 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 137 | + if ($this->debugLevel>1) |
|
| 138 | + { |
|
| 139 | + error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 140 | + } |
|
| 120 | 141 | |
| 121 | 142 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
| 122 | 143 | if (!isset($GLOBALS['egw_setup'])) |
@@ -129,7 +150,10 @@ discard block |
||
| 129 | 150 | self::$profileID = Mail\Account::get_default_acc_id(); |
| 130 | 151 | } |
| 131 | 152 | } |
| 132 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 153 | + if ($this->debugLevel>0) |
|
| 154 | + { |
|
| 155 | + error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 156 | + } |
|
| 133 | 157 | //$this->debugLevel=0; |
| 134 | 158 | } |
| 135 | 159 | |
@@ -245,8 +269,14 @@ discard block |
||
| 245 | 269 | $this->_connect(0,true); |
| 246 | 270 | $this->_disconnect(); |
| 247 | 271 | |
| 248 | - if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 249 | - if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 272 | + if (!$this->_wasteID) |
|
| 273 | + { |
|
| 274 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 275 | + } |
|
| 276 | + if (!$this->_sentID) |
|
| 277 | + { |
|
| 278 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 279 | + } |
|
| 250 | 280 | } |
| 251 | 281 | catch(Exception $e) { |
| 252 | 282 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
@@ -268,8 +298,14 @@ discard block |
||
| 268 | 298 | */ |
| 269 | 299 | private function _connect($account=0) |
| 270 | 300 | { |
| 271 | - if (!$account) $account = self::$profileID ? self::$profileID : 0; |
|
| 272 | - if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
| 301 | + if (!$account) |
|
| 302 | + { |
|
| 303 | + $account = self::$profileID ? self::$profileID : 0; |
|
| 304 | + } |
|
| 305 | + if ($this->mail && $this->account != $account) |
|
| 306 | + { |
|
| 307 | + $this->_disconnect(); |
|
| 308 | + } |
|
| 273 | 309 | |
| 274 | 310 | $this->_wasteID = false; |
| 275 | 311 | $this->_sentID = false; |
@@ -280,12 +316,18 @@ discard block |
||
| 280 | 316 | // todo: tell mail which account to use |
| 281 | 317 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 282 | 318 | $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
| 283 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 319 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 320 | + { |
|
| 321 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 322 | + } |
|
| 284 | 323 | } |
| 285 | 324 | else |
| 286 | 325 | { |
| 287 | 326 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 288 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 327 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 328 | + { |
|
| 329 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 330 | + } |
|
| 289 | 331 | } |
| 290 | 332 | $this->mail->openConnection(self::$profileID,false); |
| 291 | 333 | |
@@ -302,8 +344,14 @@ discard block |
||
| 302 | 344 | */ |
| 303 | 345 | private function _disconnect() |
| 304 | 346 | { |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 306 | - if ($this->mail) $this->mail->closeConnection(); |
|
| 347 | + if ($this->debugLevel>0) |
|
| 348 | + { |
|
| 349 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 350 | + } |
|
| 351 | + if ($this->mail) |
|
| 352 | + { |
|
| 353 | + $this->mail->closeConnection(); |
|
| 354 | + } |
|
| 307 | 355 | |
| 308 | 356 | unset($this->mail); |
| 309 | 357 | unset($this->account); |
@@ -318,24 +366,43 @@ discard block |
||
| 318 | 366 | public function GetFolderList() |
| 319 | 367 | { |
| 320 | 368 | $folderlist = array(); |
| 321 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 369 | + if ($this->debugLevel>0) |
|
| 370 | + { |
|
| 371 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 372 | + } |
|
| 322 | 373 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 323 | 374 | { |
| 324 | 375 | $this->_connect($account); |
| 325 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 326 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 376 | + if (!isset($this->folders)) |
|
| 377 | + { |
|
| 378 | + $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 379 | + } |
|
| 380 | + if ($this->debugLevel>1) |
|
| 381 | + { |
|
| 382 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 383 | + } |
|
| 327 | 384 | |
| 328 | - foreach ($this->folders as $folder => $folderObj) { |
|
| 329 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 385 | + foreach ($this->folders as $folder => $folderObj) |
|
| 386 | + { |
|
| 387 | + if ($this->debugLevel>1) |
|
| 388 | + { |
|
| 389 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 390 | + } |
|
| 330 | 391 | $folderlist[] = $f = array( |
| 331 | 392 | 'id' => $this->createID($account,$folder), |
| 332 | 393 | 'mod' => $folderObj->shortDisplayName, |
| 333 | 394 | 'parent' => $this->getParentID($account,$folder), |
| 334 | 395 | ); |
| 335 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 396 | + if ($this->debugLevel>1) |
|
| 397 | + { |
|
| 398 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 399 | + } |
|
| 336 | 400 | } |
| 337 | 401 | } |
| 338 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 402 | + if ($this->debugLevel>0) |
|
| 403 | + { |
|
| 404 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 405 | + } |
|
| 339 | 406 | |
| 340 | 407 | return $folderlist; |
| 341 | 408 | } |
@@ -396,11 +463,17 @@ discard block |
||
| 396 | 463 | $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
| 397 | 464 | |
| 398 | 465 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
| 399 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 466 | + if ($this->debugLevel>0) |
|
| 467 | + { |
|
| 468 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 469 | + } |
|
| 400 | 470 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 401 | 471 | |
| 402 | 472 | // initialize our Mail |
| 403 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 473 | + if (!isset($this->mail)) |
|
| 474 | + { |
|
| 475 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 476 | + } |
|
| 404 | 477 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 405 | 478 | // use the standardIdentity |
| 406 | 479 | $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
@@ -428,12 +501,18 @@ discard block |
||
| 428 | 501 | $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
| 429 | 502 | $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 430 | 503 | $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
| 431 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 504 | + if ($this->debugLevel>0) |
|
| 505 | + { |
|
| 506 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 507 | + } |
|
| 432 | 508 | $sigTextHtml = $beforeHtml.$sigText; |
| 433 | 509 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 434 | 510 | |
| 435 | 511 | $force8bit=false; |
| 436 | - if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
| 512 | + if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') |
|
| 513 | + { |
|
| 514 | + $force8bit=true; |
|
| 515 | + } |
|
| 437 | 516 | // initialize the new Api\Mailer object for sending |
| 438 | 517 | $mailObject = new Api\Mailer(self::$profileID); |
| 439 | 518 | |
@@ -447,22 +526,34 @@ discard block |
||
| 447 | 526 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 448 | 527 | // to |
| 449 | 528 | |
| 450 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 451 | - if (!$addressObject->valid) continue; |
|
| 529 | + foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) |
|
| 530 | + { |
|
| 531 | + if (!$addressObject->valid) |
|
| 532 | + { |
|
| 533 | + continue; |
|
| 534 | + } |
|
| 452 | 535 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
| 453 | 536 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 454 | 537 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 455 | 538 | } |
| 456 | 539 | // CC |
| 457 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 458 | - if (!$addressObject->valid) continue; |
|
| 540 | + foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) |
|
| 541 | + { |
|
| 542 | + if (!$addressObject->valid) |
|
| 543 | + { |
|
| 544 | + continue; |
|
| 545 | + } |
|
| 459 | 546 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
| 460 | 547 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 461 | 548 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 462 | 549 | } |
| 463 | 550 | // BCC |
| 464 | - foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 465 | - if (!$addressObject->valid) continue; |
|
| 551 | + foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) |
|
| 552 | + { |
|
| 553 | + if (!$addressObject->valid) |
|
| 554 | + { |
|
| 555 | + continue; |
|
| 556 | + } |
|
| 466 | 557 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
| 467 | 558 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 468 | 559 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
@@ -475,12 +566,14 @@ discard block |
||
| 475 | 566 | $ContentType =$mailObject->getHeader('Content-Type'); |
| 476 | 567 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 477 | 568 | // if the message is a multipart message, then we should use the sent body |
| 478 | - if (preg_match("/multipart/i", $ContentType)) { |
|
| 569 | + if (preg_match("/multipart/i", $ContentType)) |
|
| 570 | + { |
|
| 479 | 571 | $use_orgbody = true; |
| 480 | 572 | } |
| 481 | 573 | |
| 482 | 574 | // save the original content-type header for the body part when forwarding |
| 483 | - if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) { |
|
| 575 | + if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) |
|
| 576 | + { |
|
| 484 | 577 | //continue; // ignore |
| 485 | 578 | } |
| 486 | 579 | // horde/egw_ mailer does everything as utf-8, the following should not be needed |
@@ -489,7 +582,8 @@ discard block |
||
| 489 | 582 | // if the message is a multipart message, then we should use the sent body |
| 490 | 583 | if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') && |
| 491 | 584 | ((isset($smartdata->replacemime) && $smartdata->replacemime == true) || |
| 492 | - $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
| 585 | + $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) |
|
| 586 | + { |
|
| 493 | 587 | $use_orgbody = true; |
| 494 | 588 | } |
| 495 | 589 | $Body = $AltBody = ""; |
@@ -522,12 +616,19 @@ discard block |
||
| 522 | 616 | $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
| 523 | 617 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 524 | 618 | } |
| 525 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 526 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 619 | + if ($this->debugLevel>1 && $Body) |
|
| 620 | + { |
|
| 621 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 622 | + } |
|
| 623 | + if ($this->debugLevel>1 && $AltBody) |
|
| 624 | + { |
|
| 625 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 626 | + } |
|
| 527 | 627 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 528 | 628 | // if this is a multipart message with a boundary, we must use the original body |
| 529 | 629 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 530 | - if ($use_orgbody) { |
|
| 630 | + if ($use_orgbody) |
|
| 631 | + { |
|
| 531 | 632 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
| 532 | 633 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 533 | 634 | if (($cal_body = $mailObject->findBody('calendar')) && |
@@ -537,15 +638,20 @@ discard block |
||
| 537 | 638 | { |
| 538 | 639 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 539 | 640 | } |
| 540 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 641 | + if ($this->debugLevel) |
|
| 642 | + { |
|
| 643 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 644 | + } |
|
| 541 | 645 | $ClientSideMeetingRequest = true; |
| 542 | 646 | } |
| 543 | 647 | } |
| 544 | 648 | // now handle the addressee list |
| 545 | 649 | $toCount = 0; |
| 546 | 650 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 547 | - foreach((array)$toMailAddr as $address) { |
|
| 548 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 651 | + foreach((array)$toMailAddr as $address) |
|
| 652 | + { |
|
| 653 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 654 | + { |
|
| 549 | 655 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 550 | 656 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 551 | 657 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
@@ -559,19 +665,29 @@ discard block |
||
| 559 | 665 | } |
| 560 | 666 | } |
| 561 | 667 | $ccCount = 0; |
| 562 | - foreach((array)$ccMailAddr as $address) { |
|
| 563 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 668 | + foreach((array)$ccMailAddr as $address) |
|
| 669 | + { |
|
| 670 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 671 | + { |
|
| 564 | 672 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 565 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 673 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 674 | + { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 566 | 677 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 567 | 678 | $ccCount++; |
| 568 | 679 | } |
| 569 | 680 | } |
| 570 | 681 | $bccCount = 0; |
| 571 | - foreach((array)$bccMailAddr as $address) { |
|
| 572 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 682 | + foreach((array)$bccMailAddr as $address) |
|
| 683 | + { |
|
| 684 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 685 | + { |
|
| 573 | 686 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 574 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 687 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 688 | + { |
|
| 689 | + continue; |
|
| 690 | + } |
|
| 575 | 691 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 576 | 692 | $bccCount++; |
| 577 | 693 | } |
@@ -581,7 +697,10 @@ discard block |
||
| 581 | 697 | { |
| 582 | 698 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 583 | 699 | } |
| 584 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 700 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) |
|
| 701 | + { |
|
| 702 | + return true; |
|
| 703 | + } |
|
| 585 | 704 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 586 | 705 | /* |
| 587 | 706 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -604,10 +723,17 @@ discard block |
||
| 604 | 723 | $this->mail->reopen($folder); |
| 605 | 724 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 606 | 725 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 607 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 608 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 726 | + if ($this->debugLevel>3) |
|
| 727 | + { |
|
| 728 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 729 | + } |
|
| 730 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 731 | + { |
|
| 609 | 732 | // may be html |
| 610 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 733 | + if ($this->debugLevel>0) |
|
| 734 | + { |
|
| 735 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 736 | + } |
|
| 611 | 737 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 612 | 738 | $isreply = true; |
| 613 | 739 | } |
@@ -616,8 +742,12 @@ discard block |
||
| 616 | 742 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 617 | 743 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 618 | 744 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 619 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 620 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 745 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 746 | + { |
|
| 747 | + if ($this->debugLevel>0) |
|
| 748 | + { |
|
| 749 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 750 | + } |
|
| 621 | 751 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 622 | 752 | $isreply = true; |
| 623 | 753 | } |
@@ -625,7 +755,10 @@ discard block |
||
| 625 | 755 | { |
| 626 | 756 | $isreply = true; |
| 627 | 757 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 628 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 758 | + if ($this->debugLevel>0) |
|
| 759 | + { |
|
| 760 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 761 | + } |
|
| 629 | 762 | } |
| 630 | 763 | } |
| 631 | 764 | |
@@ -639,11 +772,17 @@ discard block |
||
| 639 | 772 | (isset($smartdata->replacemime) && $smartdata->replacemime == false))) |
| 640 | 773 | { |
| 641 | 774 | //force the default for the forwarding -> asmail |
| 642 | - if (is_array($preferencesArray)) { |
|
| 775 | + if (is_array($preferencesArray)) |
|
| 776 | + { |
|
| 643 | 777 | if (!array_key_exists('message_forwarding',$preferencesArray) |
| 644 | 778 | || !isset($preferencesArray['message_forwarding']) |
| 645 | - || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 646 | - } else { |
|
| 779 | + || empty($preferencesArray['message_forwarding'])) |
|
| 780 | + { |
|
| 781 | + $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + else |
|
| 785 | + { |
|
| 647 | 786 | $preferencesArray['message_forwarding'] = 'asmail'; |
| 648 | 787 | } |
| 649 | 788 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
@@ -675,27 +814,44 @@ discard block |
||
| 675 | 814 | $this->mail->reopen($folder); |
| 676 | 815 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 677 | 816 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 678 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 679 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 817 | + if ($this->debugLevel>0) |
|
| 818 | + { |
|
| 819 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 820 | + } |
|
| 821 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 822 | + { |
|
| 680 | 823 | // may be html |
| 681 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 824 | + if ($this->debugLevel>0) |
|
| 825 | + { |
|
| 826 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 827 | + } |
|
| 682 | 828 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 683 | 829 | $isforward = true; |
| 684 | 830 | } |
| 685 | 831 | // plain text Message part |
| 686 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 832 | + if ($this->debugLevel>0) |
|
| 833 | + { |
|
| 834 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 835 | + } |
|
| 687 | 836 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 688 | 837 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 689 | 838 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 690 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 691 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 839 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 840 | + { |
|
| 841 | + if ($this->debugLevel>0) |
|
| 842 | + { |
|
| 843 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 844 | + } |
|
| 692 | 845 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 693 | 846 | $isforward = true; |
| 694 | 847 | } |
| 695 | 848 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 696 | 849 | { |
| 697 | 850 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 698 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 851 | + if ($this->debugLevel>0) |
|
| 852 | + { |
|
| 853 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 854 | + } |
|
| 699 | 855 | $isforward = true; |
| 700 | 856 | } |
| 701 | 857 | // get all the attachments and add them too. |
@@ -708,7 +864,10 @@ discard block |
||
| 708 | 864 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
| 709 | 865 | foreach((array)$attachments as $key => $attachment) |
| 710 | 866 | { |
| 711 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 867 | + if ($this->debugLevel>0) |
|
| 868 | + { |
|
| 869 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 870 | + } |
|
| 712 | 871 | $attachmentNames .= $attachment['name']."\n"; |
| 713 | 872 | $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
| 714 | 873 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
@@ -727,20 +886,29 @@ discard block |
||
| 727 | 886 | // now set the body |
| 728 | 887 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 729 | 888 | { |
| 730 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 889 | + if ($this->debugLevel>1) |
|
| 890 | + { |
|
| 891 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 892 | + } |
|
| 731 | 893 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 732 | 894 | $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 733 | 895 | } |
| 734 | 896 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 735 | 897 | { |
| 736 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 898 | + if ($this->debugLevel>1) |
|
| 899 | + { |
|
| 900 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 901 | + } |
|
| 737 | 902 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 738 | 903 | $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 739 | 904 | } |
| 740 | 905 | //advanced debugging |
| 741 | 906 | // Horde SMTP Class uses utf-8 by default. |
| 742 | 907 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 743 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 908 | + if ($this->debugLevel>2) |
|
| 909 | + { |
|
| 910 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 911 | + } |
|
| 744 | 912 | |
| 745 | 913 | // set a higher timeout for big messages |
| 746 | 914 | @set_time_limit(120); |
@@ -767,7 +935,9 @@ discard block |
||
| 767 | 935 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 768 | 936 | { |
| 769 | 937 | $this->mail->deleteMessages(array($uid),$folder); |
| 770 | - } else { |
|
| 938 | + } |
|
| 939 | + else |
|
| 940 | + { |
|
| 771 | 941 | $this->mail->flagMessages("answered", array($uid),$folder); |
| 772 | 942 | if ($smartdata_task== "forward") |
| 773 | 943 | { |
@@ -781,7 +951,8 @@ discard block |
||
| 781 | 951 | { |
| 782 | 952 | $asf = false; |
| 783 | 953 | $sentFolder = $this->mail->getSentFolder(); |
| 784 | - if ($this->_sentID) { |
|
| 954 | + if ($this->_sentID) |
|
| 955 | + { |
|
| 785 | 956 | $folderArray[] = $this->_sentID; |
| 786 | 957 | } |
| 787 | 958 | else if(isset($sentFolder) && $sentFolder != 'none') |
@@ -795,27 +966,40 @@ discard block |
||
| 795 | 966 | // we dont try guessing |
| 796 | 967 | $asf = true; |
| 797 | 968 | } |
| 798 | - if (count($folderArray) > 0) { |
|
| 799 | - foreach((array)$bccMailAddr as $address) { |
|
| 800 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 969 | + if (count($folderArray) > 0) |
|
| 970 | + { |
|
| 971 | + foreach((array)$bccMailAddr as $address) |
|
| 972 | + { |
|
| 973 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 974 | + { |
|
| 801 | 975 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 802 | 976 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 803 | 977 | } |
| 804 | 978 | } |
| 805 | 979 | $BCCmail=''; |
| 806 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 807 | - foreach($folderArray as $folderName) { |
|
| 808 | - if($this->mail->isSentFolder($folderName)) { |
|
| 980 | + if (count($mailAddr)>0) |
|
| 981 | + { |
|
| 982 | + $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 983 | + } |
|
| 984 | + foreach($folderArray as $folderName) |
|
| 985 | + { |
|
| 986 | + if($this->mail->isSentFolder($folderName)) |
|
| 987 | + { |
|
| 809 | 988 | $flags = '\\Seen'; |
| 810 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 989 | + } |
|
| 990 | + elseif($this->mail->isDraftFolder($folderName)) |
|
| 991 | + { |
|
| 811 | 992 | $flags = '\\Draft'; |
| 812 | - } else { |
|
| 993 | + } |
|
| 994 | + else |
|
| 995 | + { |
|
| 813 | 996 | $flags = ''; |
| 814 | 997 | } |
| 815 | 998 | $asf = true; |
| 816 | 999 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 817 | 1000 | $this->mail->openConnection(self::$profileID,false); |
| 818 | - if ($this->mail->folderExists($folderName)) { |
|
| 1001 | + if ($this->mail->folderExists($folderName)) |
|
| 1002 | + { |
|
| 819 | 1003 | try |
| 820 | 1004 | { |
| 821 | 1005 | $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
@@ -873,17 +1057,26 @@ discard block |
||
| 873 | 1057 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 874 | 1058 | |
| 875 | 1059 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 876 | - if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
|
| 1060 | + if (!$mimesupport && ($key = array_search('4', $bodypreference))) |
|
| 1061 | + { |
|
| 1062 | + unset($bodypreference[$key]); |
|
| 1063 | + } |
|
| 877 | 1064 | |
| 878 | 1065 | //$this->debugLevel=4; |
| 879 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1066 | + if (!isset($this->mail)) |
|
| 1067 | + { |
|
| 1068 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1069 | + } |
|
| 880 | 1070 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
| 881 | 1071 | $account = $_folderName = $xid = null; |
| 882 | 1072 | $this->splitID($folderid,$account,$_folderName,$xid); |
| 883 | 1073 | $this->mail->reopen($_folderName); |
| 884 | 1074 | $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
| 885 | 1075 | $headers = $messages[$id]; |
| 886 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1076 | + if ($this->debugLevel>3) |
|
| 1077 | + { |
|
| 1078 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1079 | + } |
|
| 887 | 1080 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 888 | 1081 | if ($headers) |
| 889 | 1082 | { |
@@ -893,16 +1086,25 @@ discard block |
||
| 893 | 1086 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 894 | 1087 | // simple style |
| 895 | 1088 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 896 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1089 | + if ($this->debugLevel>0) |
|
| 1090 | + { |
|
| 1091 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1092 | + } |
|
| 897 | 1093 | |
| 898 | - if ($bodypreference === false) { |
|
| 1094 | + if ($bodypreference === false) |
|
| 1095 | + { |
|
| 899 | 1096 | $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
| 900 | 1097 | $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 901 | 1098 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 902 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 1099 | + if (stripos($raw_body,'<style')!==false) |
|
| 1100 | + { |
|
| 1101 | + $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); |
|
| 1102 | + } |
|
| 1103 | + // in case there is only a html part |
|
| 903 | 1104 | // remove all other html |
| 904 | 1105 | $body = strip_tags($raw_body); |
| 905 | - if(strlen($body) > $truncsize) { |
|
| 1106 | + if(strlen($body) > $truncsize) |
|
| 1107 | + { |
|
| 906 | 1108 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 907 | 1109 | $output->bodytruncated = 1; |
| 908 | 1110 | } |
@@ -917,7 +1119,8 @@ discard block |
||
| 917 | 1119 | { |
| 918 | 1120 | //Select body type preference |
| 919 | 1121 | $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
| 920 | - if ($bodypreference !== false) { |
|
| 1122 | + if ($bodypreference !== false) |
|
| 1123 | + { |
|
| 921 | 1124 | // bodypreference can occur multiple times |
| 922 | 1125 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
| 923 | 1126 | $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -951,25 +1154,49 @@ discard block |
||
| 951 | 1154 | // fetch the body (try to gather data only once) |
| 952 | 1155 | $css =''; |
| 953 | 1156 | $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
| 954 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1157 | + if ($this->debugLevel>2) |
|
| 1158 | + { |
|
| 1159 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1160 | + } |
|
| 955 | 1161 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 956 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 957 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 1162 | + if ($this->debugLevel>3) |
|
| 1163 | + { |
|
| 1164 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 1165 | + } |
|
| 1166 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 1167 | + { |
|
| 958 | 1168 | // may be html |
| 959 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1169 | + if ($this->debugLevel>0) |
|
| 1170 | + { |
|
| 1171 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1172 | + } |
|
| 960 | 1173 | $css = $this->mail->getStyles($bodyStruct); |
| 961 | 1174 | $output->nativebodytype=2; |
| 962 | - } else { |
|
| 1175 | + } |
|
| 1176 | + else |
|
| 1177 | + { |
|
| 963 | 1178 | // plain text Message |
| 964 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1179 | + if ($this->debugLevel>0) |
|
| 1180 | + { |
|
| 1181 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1182 | + } |
|
| 965 | 1183 | $output->nativebodytype=1; |
| 966 | 1184 | $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
| 967 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1185 | + if ($this->debugLevel>3) |
|
| 1186 | + { |
|
| 1187 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1188 | + } |
|
| 968 | 1189 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 969 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1190 | + if ($this->debugLevel>3) |
|
| 1191 | + { |
|
| 1192 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1193 | + } |
|
| 970 | 1194 | } |
| 971 | 1195 | // whatever format decode (using the correct encoding) |
| 972 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1196 | + if ($this->debugLevel>3) |
|
| 1197 | + { |
|
| 1198 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1199 | + } |
|
| 973 | 1200 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 974 | 1201 | // prepare plaintextbody |
| 975 | 1202 | $plainBody=''; |
@@ -990,12 +1217,18 @@ discard block |
||
| 990 | 1217 | // remove all other html |
| 991 | 1218 | $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
| 992 | 1219 | $plainBody = strip_tags($plainBody); |
| 993 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1220 | + if ($this->debugLevel>3 && $output->nativebodytype==1) |
|
| 1221 | + { |
|
| 1222 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1223 | + } |
|
| 994 | 1224 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 995 | 1225 | |
| 996 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 1226 | + if ($bpReturnType==2) |
|
| 1227 | + { |
|
| 1228 | + //SYNC_BODYPREFERENCE_HTML |
|
| 997 | 1229 | { |
| 998 | 1230 | if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
| 1231 | + } |
|
| 999 | 1232 | // Send HTML if requested and native type was html |
| 1000 | 1233 | $output->asbody->type = 2; |
| 1001 | 1234 | $htmlbody = '<html>'. |
@@ -1007,7 +1240,10 @@ discard block |
||
| 1007 | 1240 | '<body>'; |
| 1008 | 1241 | if ($output->nativebodytype==2) |
| 1009 | 1242 | { |
| 1010 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1243 | + if ($css) |
|
| 1244 | + { |
|
| 1245 | + Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1246 | + } |
|
| 1011 | 1247 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1012 | 1248 | $htmlbody .= $body; |
| 1013 | 1249 | } |
@@ -1032,7 +1268,10 @@ discard block |
||
| 1032 | 1268 | else |
| 1033 | 1269 | { |
| 1034 | 1270 | // Send Plaintext as Fallback or if original body is plainttext |
| 1035 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1271 | + if ($this->debugLevel>0) |
|
| 1272 | + { |
|
| 1273 | + ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1274 | + } |
|
| 1036 | 1275 | /* we use plainBody (set above) instead |
| 1037 | 1276 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1038 | 1277 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1069,7 +1308,9 @@ discard block |
||
| 1069 | 1308 | { |
| 1070 | 1309 | $output->flag->flagstatus = 2; |
| 1071 | 1310 | //$output->flag->flagtype = "Flag for Follow up"; |
| 1072 | - } else { |
|
| 1311 | + } |
|
| 1312 | + else |
|
| 1313 | + { |
|
| 1073 | 1314 | $output->flag->flagstatus = 0; |
| 1074 | 1315 | } |
| 1075 | 1316 | if ($headers['answered']) |
@@ -1085,10 +1326,20 @@ discard block |
||
| 1085 | 1326 | ($headers['priority'] < 3 ? 2 : 1) ; |
| 1086 | 1327 | $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
| 1087 | 1328 | $output->to = $headers['to_address']; |
| 1088 | - if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
|
| 1329 | + if ($headers['to']) |
|
| 1330 | + { |
|
| 1331 | + $output->displayto = $headers['to_address']; |
|
| 1332 | + } |
|
| 1333 | + //$headers['FETCHED_HEADER']['to_name'] |
|
| 1089 | 1334 | $output->from = $headers['sender_address']; |
| 1090 | - if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses']; |
|
| 1091 | - if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
|
| 1335 | + if (isset($headers['cc_addresses']) && $headers['cc_addresses']) |
|
| 1336 | + { |
|
| 1337 | + $output->cc = $headers['cc_addresses']; |
|
| 1338 | + } |
|
| 1339 | + if (isset($headers['reply_to_address']) && $headers['reply_to_address']) |
|
| 1340 | + { |
|
| 1341 | + $output->reply_to = $headers['reply_to_address']; |
|
| 1342 | + } |
|
| 1092 | 1343 | |
| 1093 | 1344 | $output->messageclass = "IPM.Note"; |
| 1094 | 1345 | if (stripos($headers['mimetype'],'multipart')!== false && |
@@ -1096,7 +1347,8 @@ discard block |
||
| 1096 | 1347 | { |
| 1097 | 1348 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1098 | 1349 | } |
| 1099 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1350 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1351 | + { |
|
| 1100 | 1352 | $output->contentclass = "urn:content-classes:message"; |
| 1101 | 1353 | } |
| 1102 | 1354 | |
@@ -1109,7 +1361,10 @@ discard block |
||
| 1109 | 1361 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1110 | 1362 | foreach ($attachments as $key => $attach) |
| 1111 | 1363 | { |
| 1112 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1364 | + if ($this->debugLevel>0) |
|
| 1365 | + { |
|
| 1366 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1367 | + } |
|
| 1113 | 1368 | |
| 1114 | 1369 | // pass meeting requests to calendar plugin |
| 1115 | 1370 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1126,17 +1381,24 @@ discard block |
||
| 1126 | 1381 | unset($attachment); |
| 1127 | 1382 | continue; // do NOT add attachment as attachment |
| 1128 | 1383 | } |
| 1129 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1384 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1385 | + { |
|
| 1130 | 1386 | $attachment = new SyncBaseAttachment(); |
| 1131 | 1387 | if (!isset($output->asattachments) || !is_array($output->asattachments)) |
| 1132 | - $output->asattachments = array(); |
|
| 1388 | + { |
|
| 1389 | + $output->asattachments = array(); |
|
| 1390 | + } |
|
| 1133 | 1391 | $attachment->estimatedDataSize = $attach['size']; |
| 1134 | 1392 | $attachment->method = 1; |
| 1135 | 1393 | $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
| 1136 | - } else { |
|
| 1394 | + } |
|
| 1395 | + else |
|
| 1396 | + { |
|
| 1137 | 1397 | $attachment = new SyncAttachment(); |
| 1138 | 1398 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1139 | - $output->attachments = array(); |
|
| 1399 | + { |
|
| 1400 | + $output->attachments = array(); |
|
| 1401 | + } |
|
| 1140 | 1402 | $attachment->attsize = $attach['size']; |
| 1141 | 1403 | $attachment->attmethod = 1; |
| 1142 | 1404 | $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
@@ -1153,10 +1415,13 @@ discard block |
||
| 1153 | 1415 | { |
| 1154 | 1416 | $attachment->isinline = true; |
| 1155 | 1417 | } |
| 1156 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1418 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1419 | + { |
|
| 1157 | 1420 | $attachment->method=1; |
| 1158 | 1421 | $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
| 1159 | - } else { |
|
| 1422 | + } |
|
| 1423 | + else |
|
| 1424 | + { |
|
| 1160 | 1425 | $attachment->attmethod=6; |
| 1161 | 1426 | $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
| 1162 | 1427 | } |
@@ -1164,9 +1429,12 @@ discard block |
||
| 1164 | 1429 | $attachment->contenttype = trim($attach['mimeType']); |
| 1165 | 1430 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-type']."' ".$attachment->contentid); |
| 1166 | 1431 | } |
| 1167 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1432 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1433 | + { |
|
| 1168 | 1434 | array_push($output->asattachments, $attachment); |
| 1169 | - } else { |
|
| 1435 | + } |
|
| 1436 | + else |
|
| 1437 | + { |
|
| 1170 | 1438 | array_push($output->attachments, $attachment); |
| 1171 | 1439 | } |
| 1172 | 1440 | unset($attachment); |
@@ -1179,8 +1447,11 @@ discard block |
||
| 1179 | 1447 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1180 | 1448 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1181 | 1449 | |
| 1182 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1183 | -//$this->debugLevel=0; |
|
| 1450 | + if ($this->debugLevel>3) |
|
| 1451 | + { |
|
| 1452 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1453 | + } |
|
| 1454 | + //$this->debugLevel=0; |
|
| 1184 | 1455 | return $output; |
| 1185 | 1456 | } |
| 1186 | 1457 | //$this->debugLevel=0; |
@@ -1239,7 +1510,8 @@ discard block |
||
| 1239 | 1510 | * @param string $attname - should contain (folder)id |
| 1240 | 1511 | * @return SyncItemOperationsAttachment-object |
| 1241 | 1512 | */ |
| 1242 | - function GetAttachmentData($fid,$attname) { |
|
| 1513 | + function GetAttachmentData($fid,$attname) |
|
| 1514 | + { |
|
| 1243 | 1515 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1244 | 1516 | return $this->_GetAttachmentData($fid,$attname); |
| 1245 | 1517 | } |
@@ -1254,7 +1526,8 @@ discard block |
||
| 1254 | 1526 | * @param string $attname - should contain (folder)id |
| 1255 | 1527 | * @return SyncItemOperationsAttachment-object |
| 1256 | 1528 | */ |
| 1257 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1529 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
| 1530 | + { |
|
| 1258 | 1531 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1259 | 1532 | return $this->_GetAttachmentData($fid,$attname); |
| 1260 | 1533 | } |
@@ -1276,7 +1549,10 @@ discard block |
||
| 1276 | 1549 | |
| 1277 | 1550 | $this->splitID($folderid, $account, $folder); |
| 1278 | 1551 | |
| 1279 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1552 | + if (!isset($this->mail)) |
|
| 1553 | + { |
|
| 1554 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1555 | + } |
|
| 1280 | 1556 | |
| 1281 | 1557 | $this->mail->reopen($folder); |
| 1282 | 1558 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
@@ -1285,7 +1561,9 @@ discard block |
||
| 1285 | 1561 | $SIOattachment->data = $attachment['attachment']; |
| 1286 | 1562 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1287 | 1563 | if (isset($attachment['type']) ) |
| 1288 | - $SIOattachment->contenttype = $attachment['type']; |
|
| 1564 | + { |
|
| 1565 | + $SIOattachment->contenttype = $attachment['type']; |
|
| 1566 | + } |
|
| 1289 | 1567 | |
| 1290 | 1568 | unset($attachment); |
| 1291 | 1569 | |
@@ -1331,11 +1609,15 @@ discard block |
||
| 1331 | 1609 | //unset($folderid, $id, $message, $contentParameters); |
| 1332 | 1610 | $account = $folder = null; |
| 1333 | 1611 | $this->splitID($folderid, $account, $folder); |
| 1334 | - if (isset($message->flag)) { |
|
| 1335 | - if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
|
| 1612 | + if (isset($message->flag)) |
|
| 1613 | + { |
|
| 1614 | + if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) |
|
| 1615 | + { |
|
| 1336 | 1616 | $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
| 1337 | 1617 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
| 1338 | - } else { |
|
| 1618 | + } |
|
| 1619 | + else |
|
| 1620 | + { |
|
| 1339 | 1621 | $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
| 1340 | 1622 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
| 1341 | 1623 | } |
@@ -1365,7 +1647,10 @@ discard block |
||
| 1365 | 1647 | $this->splitID($folderid, $account, $srcFolder); |
| 1366 | 1648 | $this->splitID($newfolderid, $account, $destFolder); |
| 1367 | 1649 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1368 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1650 | + if (!isset($this->mail)) |
|
| 1651 | + { |
|
| 1652 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1653 | + } |
|
| 1369 | 1654 | $this->mail->reopen($destFolder); |
| 1370 | 1655 | $status = $this->mail->getFolderStatus($destFolder); |
| 1371 | 1656 | $uidNext = $status['uidnext']; |
@@ -1397,7 +1682,10 @@ discard block |
||
| 1397 | 1682 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1398 | 1683 | } |
| 1399 | 1684 | $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
| 1400 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1685 | + if (is_numeric($maximumSyncRangeInDays)) |
|
| 1686 | + { |
|
| 1687 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1688 | + } |
|
| 1401 | 1689 | } |
| 1402 | 1690 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1403 | 1691 | } |
@@ -1419,7 +1707,10 @@ discard block |
||
| 1419 | 1707 | { |
| 1420 | 1708 | static $headers = array(); |
| 1421 | 1709 | |
| 1422 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1710 | + if ($this->debugLevel>1) |
|
| 1711 | + { |
|
| 1712 | + $gstarttime = microtime (true); |
|
| 1713 | + } |
|
| 1423 | 1714 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1424 | 1715 | $rv_messages = array(); |
| 1425 | 1716 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1432,7 +1723,10 @@ discard block |
||
| 1432 | 1723 | { |
| 1433 | 1724 | $headers = array(); // clear cache to not use too much memory |
| 1434 | 1725 | |
| 1435 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1726 | + if ($this->debugLevel>1) |
|
| 1727 | + { |
|
| 1728 | + $starttime = microtime (true); |
|
| 1729 | + } |
|
| 1436 | 1730 | $this->_connect($this->account); |
| 1437 | 1731 | if ($this->debugLevel>1) |
| 1438 | 1732 | { |
@@ -1441,8 +1735,14 @@ discard block |
||
| 1441 | 1735 | } |
| 1442 | 1736 | $messagelist = $_filter = array(); |
| 1443 | 1737 | // if not connected, any further action must fail |
| 1444 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1445 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1738 | + if (!empty($cutoffdate)) |
|
| 1739 | + { |
|
| 1740 | + $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1741 | + } |
|
| 1742 | + if ($this->debugLevel>1) |
|
| 1743 | + { |
|
| 1744 | + $starttime = microtime (true); |
|
| 1745 | + } |
|
| 1446 | 1746 | $account = $_folderName = $id = null; |
| 1447 | 1747 | $this->splitID($folderid,$account,$_folderName,$id); |
| 1448 | 1748 | if ($this->debugLevel>1) |
@@ -1450,8 +1750,14 @@ discard block |
||
| 1450 | 1750 | $endtime = microtime(true) - $starttime; |
| 1451 | 1751 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
| 1452 | 1752 | } |
| 1453 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1454 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1753 | + if ($this->debugLevel>1) |
|
| 1754 | + { |
|
| 1755 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1756 | + } |
|
| 1757 | + if ($this->debugLevel>1) |
|
| 1758 | + { |
|
| 1759 | + $starttime = microtime (true); |
|
| 1760 | + } |
|
| 1455 | 1761 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
| 1456 | 1762 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
| 1457 | 1763 | if ($this->debugLevel>1) |
@@ -1460,27 +1766,56 @@ discard block |
||
| 1460 | 1766 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
| 1461 | 1767 | } |
| 1462 | 1768 | } |
| 1463 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1769 | + if ($_id == NULL && $this->debugLevel>1) |
|
| 1770 | + { |
|
| 1771 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1772 | + } |
|
| 1464 | 1773 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1465 | 1774 | $messagelist = array(); |
| 1466 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1775 | + if (!isset($rv_messages['header'])||empty($rv_messages['header'])) |
|
| 1776 | + { |
|
| 1777 | + return $messagelist; |
|
| 1778 | + } |
|
| 1467 | 1779 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1468 | 1780 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1469 | 1781 | { |
| 1470 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1782 | + if ($this->debugLevel>3) |
|
| 1783 | + { |
|
| 1784 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1785 | + } |
|
| 1471 | 1786 | $headers[$vars['uid']] = $vars; |
| 1472 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1473 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
| 1474 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
| 1475 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1787 | + if ($this->debugLevel>3) |
|
| 1788 | + { |
|
| 1789 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1790 | + } |
|
| 1791 | + if (!empty($vars['deleted'])) |
|
| 1792 | + { |
|
| 1793 | + continue; |
|
| 1794 | + } |
|
| 1795 | + // cut of deleted messages |
|
| 1796 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
| 1797 | + { |
|
| 1798 | + continue; |
|
| 1799 | + } |
|
| 1800 | + // message is out of range for cutoffdate, ignore it |
|
| 1801 | + if ($this->debugLevel>0) |
|
| 1802 | + { |
|
| 1803 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1804 | + } |
|
| 1476 | 1805 | $mess = $return_all_headers ? $vars : array(); |
| 1477 | 1806 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1478 | 1807 | $mess["id"] = $vars['uid']; |
| 1479 | 1808 | // 'seen' aka 'read' is the only flag we want to know about |
| 1480 | 1809 | $mess["flags"] = 0; |
| 1481 | 1810 | // outlook supports additional flags, set them to 0 |
| 1482 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1483 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1811 | + if($vars["seen"]) |
|
| 1812 | + { |
|
| 1813 | + $mess["flags"] = 1; |
|
| 1814 | + } |
|
| 1815 | + if ($this->debugLevel>3) |
|
| 1816 | + { |
|
| 1817 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1818 | + } |
|
| 1484 | 1819 | $messagelist[$vars['uid']] = $mess; |
| 1485 | 1820 | unset($mess); |
| 1486 | 1821 | } |
@@ -1505,9 +1840,18 @@ discard block |
||
| 1505 | 1840 | static function doFlagsMod($headerFlags) |
| 1506 | 1841 | { |
| 1507 | 1842 | $flags = 'nnn'; |
| 1508 | - if ($headerFlags['flagged']) $flags[0] = 'f'; |
|
| 1509 | - if ($headerFlags['answered']) $flags[1] = 'a'; |
|
| 1510 | - if ($headerFlags['forwarded']) $flags[2] = 'f'; |
|
| 1843 | + if ($headerFlags['flagged']) |
|
| 1844 | + { |
|
| 1845 | + $flags[0] = 'f'; |
|
| 1846 | + } |
|
| 1847 | + if ($headerFlags['answered']) |
|
| 1848 | + { |
|
| 1849 | + $flags[1] = 'a'; |
|
| 1850 | + } |
|
| 1851 | + if ($headerFlags['forwarded']) |
|
| 1852 | + { |
|
| 1853 | + $flags[2] = 'f'; |
|
| 1854 | + } |
|
| 1511 | 1855 | //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags)); |
| 1512 | 1856 | return $flags; |
| 1513 | 1857 | } |
@@ -1539,31 +1883,55 @@ discard block |
||
| 1539 | 1883 | { |
| 1540 | 1884 | //$this->debugLevel=1; |
| 1541 | 1885 | $searchquery=$_searchquery->GetDataArray(); |
| 1542 | - if (!is_array($searchquery)) return array(); |
|
| 1543 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1886 | + if (!is_array($searchquery)) |
|
| 1887 | + { |
|
| 1888 | + return array(); |
|
| 1889 | + } |
|
| 1890 | + if ($this->debugLevel>0) |
|
| 1891 | + { |
|
| 1892 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1893 | + } |
|
| 1544 | 1894 | |
| 1545 | - if (isset($searchquery['searchrebuildresults'])) { |
|
| 1895 | + if (isset($searchquery['searchrebuildresults'])) |
|
| 1896 | + { |
|
| 1546 | 1897 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1547 | - } else { |
|
| 1898 | + } |
|
| 1899 | + else |
|
| 1900 | + { |
|
| 1548 | 1901 | $rebuildresults = false; |
| 1549 | 1902 | } |
| 1550 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1903 | + if ($this->debugLevel>0) |
|
| 1904 | + { |
|
| 1905 | + ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1906 | + } |
|
| 1551 | 1907 | |
| 1552 | - if (isset($searchquery['deeptraversal'])) { |
|
| 1908 | + if (isset($searchquery['deeptraversal'])) |
|
| 1909 | + { |
|
| 1553 | 1910 | $deeptraversal = $searchquery['deeptraversal']; |
| 1554 | - } else { |
|
| 1911 | + } |
|
| 1912 | + else |
|
| 1913 | + { |
|
| 1555 | 1914 | $deeptraversal = false; |
| 1556 | 1915 | } |
| 1557 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1916 | + if ($this->debugLevel>0) |
|
| 1917 | + { |
|
| 1918 | + ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1919 | + } |
|
| 1558 | 1920 | |
| 1559 | - if (isset($searchquery['searchrange'])) { |
|
| 1921 | + if (isset($searchquery['searchrange'])) |
|
| 1922 | + { |
|
| 1560 | 1923 | $range = explode("-",$_searchquery->GetSearchRange()); |
| 1561 | 1924 | $start =$range[0] + 1; |
| 1562 | 1925 | $limit = $range[1] - $range[0] + 1; |
| 1563 | - } else { |
|
| 1926 | + } |
|
| 1927 | + else |
|
| 1928 | + { |
|
| 1564 | 1929 | $range = false; |
| 1565 | 1930 | } |
| 1566 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1931 | + if ($this->debugLevel>0) |
|
| 1932 | + { |
|
| 1933 | + ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1934 | + } |
|
| 1567 | 1935 | |
| 1568 | 1936 | //foreach($searchquery['query'] as $k => $value) { |
| 1569 | 1937 | // $query = $value; |
@@ -1615,7 +1983,10 @@ discard block |
||
| 1615 | 1983 | $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
| 1616 | 1984 | } |
| 1617 | 1985 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1618 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1986 | + if ($this->debugLevel>1) |
|
| 1987 | + { |
|
| 1988 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1989 | + } |
|
| 1619 | 1990 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
| 1620 | 1991 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1621 | 1992 | $list=array(); |
@@ -1647,17 +2018,26 @@ discard block |
||
| 1647 | 2018 | private function getParentID($account,$folder) |
| 1648 | 2019 | { |
| 1649 | 2020 | $this->_connect($account); |
| 1650 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2021 | + if (!isset($this->folders)) |
|
| 2022 | + { |
|
| 2023 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2024 | + } |
|
| 1651 | 2025 | |
| 1652 | 2026 | $mailFolder = $this->folders[$folder]; |
| 1653 | - if (!isset($mailFolder)) return false; |
|
| 2027 | + if (!isset($mailFolder)) |
|
| 2028 | + { |
|
| 2029 | + return false; |
|
| 2030 | + } |
|
| 1654 | 2031 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
| 1655 | 2032 | $parent = explode($delimiter,$folder); |
| 1656 | 2033 | array_pop($parent); |
| 1657 | 2034 | $parent = implode($delimiter,$parent); |
| 1658 | 2035 | |
| 1659 | 2036 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1660 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2037 | + if ($this->debugLevel>1) |
|
| 2038 | + { |
|
| 2039 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2040 | + } |
|
| 1661 | 2041 | return $id; |
| 1662 | 2042 | } |
| 1663 | 2043 | |
@@ -1671,7 +2051,10 @@ discard block |
||
| 1671 | 2051 | { |
| 1672 | 2052 | static $last_id = null; |
| 1673 | 2053 | static $folderObj = null; |
| 1674 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
| 2054 | + if (isset($last_id) && $last_id === $id) |
|
| 2055 | + { |
|
| 2056 | + return $folderObj; |
|
| 2057 | + } |
|
| 1675 | 2058 | |
| 1676 | 2059 | try { |
| 1677 | 2060 | $account = $folder = null; |
@@ -1682,18 +2065,30 @@ discard block |
||
| 1682 | 2065 | return $folderObj=false; |
| 1683 | 2066 | } |
| 1684 | 2067 | $this->_connect($account); |
| 1685 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2068 | + if (!isset($this->folders)) |
|
| 2069 | + { |
|
| 2070 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2071 | + } |
|
| 1686 | 2072 | |
| 1687 | 2073 | $mailFolder = $this->folders[$folder]; |
| 1688 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 2074 | + if (!isset($mailFolder)) |
|
| 2075 | + { |
|
| 2076 | + return $folderObj=false; |
|
| 2077 | + } |
|
| 1689 | 2078 | |
| 1690 | 2079 | $folderObj = new SyncFolder(); |
| 1691 | 2080 | $folderObj->serverid = $id; |
| 1692 | 2081 | $folderObj->parentid = $this->getParentID($account,$folder); |
| 1693 | 2082 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1694 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2083 | + if ($this->debugLevel>1) |
|
| 2084 | + { |
|
| 2085 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2086 | + } |
|
| 1695 | 2087 | // get folder-type |
| 1696 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 2088 | + foreach($this->folders as $inbox => $mailFolder) |
|
| 2089 | + { |
|
| 2090 | + break; |
|
| 2091 | + } |
|
| 1697 | 2092 | if ($folder == $inbox) |
| 1698 | 2093 | { |
| 1699 | 2094 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1730,7 +2125,10 @@ discard block |
||
| 1730 | 2125 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1731 | 2126 | } |
| 1732 | 2127 | |
| 1733 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2128 | + if ($this->debugLevel>1) |
|
| 2129 | + { |
|
| 2130 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2131 | + } |
|
| 1734 | 2132 | return $folderObj; |
| 1735 | 2133 | } |
| 1736 | 2134 | |
@@ -1774,11 +2172,20 @@ discard block |
||
| 1774 | 2172 | { |
| 1775 | 2173 | $account = $folder = null; |
| 1776 | 2174 | $this->splitID($folderid, $account, $folder); |
| 1777 | - if (is_numeric($account)) $type = 'mail'; |
|
| 2175 | + if (is_numeric($account)) |
|
| 2176 | + { |
|
| 2177 | + $type = 'mail'; |
|
| 2178 | + } |
|
| 1778 | 2179 | |
| 1779 | - if ($type != 'mail') return false; |
|
| 2180 | + if ($type != 'mail') |
|
| 2181 | + { |
|
| 2182 | + return false; |
|
| 2183 | + } |
|
| 1780 | 2184 | |
| 1781 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2185 | + if (!isset($this->mail)) |
|
| 2186 | + { |
|
| 2187 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2188 | + } |
|
| 1782 | 2189 | |
| 1783 | 2190 | $this->mail->reopen($folder); |
| 1784 | 2191 | |
@@ -1823,7 +2230,7 @@ discard block |
||
| 1823 | 2230 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1824 | 2231 | */ |
| 1825 | 2232 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1826 | - { |
|
| 2233 | + { |
|
| 1827 | 2234 | unset($contentParameters); // not used, but required by function signature |
| 1828 | 2235 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1829 | 2236 | /* |
@@ -1849,7 +2256,10 @@ discard block |
||
| 1849 | 2256 | $error = $e->getMessage(); |
| 1850 | 2257 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
| 1851 | 2258 | // if the server thinks the message does not exist report deletion as success |
| 1852 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 2259 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
| 2260 | + { |
|
| 2261 | + return true; |
|
| 2262 | + } |
|
| 1853 | 2263 | return false; |
| 1854 | 2264 | } |
| 1855 | 2265 | |
@@ -1882,7 +2292,7 @@ discard block |
||
| 1882 | 2292 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1883 | 2293 | */ |
| 1884 | 2294 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1885 | - { |
|
| 2295 | + { |
|
| 1886 | 2296 | unset($contentParameters); // not used, but required by function signature |
| 1887 | 2297 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1888 | 2298 | $account = $folder = null; |
@@ -1968,7 +2378,10 @@ discard block |
||
| 1968 | 2378 | |
| 1969 | 2379 | $str = $this->backend->createID($account, $folder, $id); |
| 1970 | 2380 | |
| 1971 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2381 | + if ($this->debugLevel>1) |
|
| 2382 | + { |
|
| 2383 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2384 | + } |
|
| 1972 | 2385 | |
| 1973 | 2386 | return $str; |
| 1974 | 2387 | } |
@@ -1989,7 +2402,10 @@ discard block |
||
| 1989 | 2402 | // convert numeric folder-id back to folder name |
| 1990 | 2403 | $folder = $this->hash2folder($account,$f=$folder); |
| 1991 | 2404 | |
| 1992 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
| 2405 | + if ($this->debugLevel>1) |
|
| 2406 | + { |
|
| 2407 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
| 2408 | + } |
|
| 1993 | 2409 | } |
| 1994 | 2410 | |
| 1995 | 2411 | /** |
@@ -2008,7 +2424,10 @@ discard block |
||
| 2008 | 2424 | */ |
| 2009 | 2425 | private function folder2hash($account,$folder) |
| 2010 | 2426 | { |
| 2011 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2427 | + if(!isset($this->folderHashes)) |
|
| 2428 | + { |
|
| 2429 | + $this->readFolderHashes(); |
|
| 2430 | + } |
|
| 2012 | 2431 | |
| 2013 | 2432 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2014 | 2433 | { |
@@ -2031,7 +2450,10 @@ discard block |
||
| 2031 | 2450 | */ |
| 2032 | 2451 | private function hash2folder($account,$index) |
| 2033 | 2452 | { |
| 2034 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2453 | + if(!isset($this->folderHashes)) |
|
| 2454 | + { |
|
| 2455 | + $this->readFolderHashes(); |
|
| 2456 | + } |
|
| 2035 | 2457 | |
| 2036 | 2458 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2037 | 2459 | } |
@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @var array |
| 42 | 42 | */ |
| 43 | - var $public_functions = array |
|
| 44 | - ( |
|
| 43 | + var $public_functions = array( |
|
| 45 | 44 | 'index' => True, |
| 46 | 45 | 'displayHeader' => True, |
| 47 | 46 | 'displayMessage' => True, |
@@ -92,17 +91,17 @@ discard block |
||
| 92 | 91 | * @var array |
| 93 | 92 | */ |
| 94 | 93 | var $searchTypes = array( |
| 95 | - 'quick' => 'quicksearch', // lang('quicksearch') |
|
| 96 | - 'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)') |
|
| 97 | - 'subject' => 'subject', // lang('subject') |
|
| 98 | - 'body' => 'message body', // lang('message body') |
|
| 99 | - 'from' => 'from', // lang('from') |
|
| 100 | - 'to' => 'to', // lang('to') |
|
| 101 | - 'cc' => 'cc', // lang('cc') |
|
| 102 | - 'text' => 'whole message', // lang('whole message') |
|
| 103 | - 'larger' => 'greater than', // lang('greater than') |
|
| 104 | - 'smaller' => 'less than', // lang('less than') |
|
| 105 | - 'bydate' => 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)') |
|
| 94 | + 'quick' => 'quicksearch', // lang('quicksearch') |
|
| 95 | + 'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)') |
|
| 96 | + 'subject' => 'subject', // lang('subject') |
|
| 97 | + 'body' => 'message body', // lang('message body') |
|
| 98 | + 'from' => 'from', // lang('from') |
|
| 99 | + 'to' => 'to', // lang('to') |
|
| 100 | + 'cc' => 'cc', // lang('cc') |
|
| 101 | + 'text' => 'whole message', // lang('whole message') |
|
| 102 | + 'larger' => 'greater than', // lang('greater than') |
|
| 103 | + 'smaller' => 'less than', // lang('less than') |
|
| 104 | + 'bydate' => 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)') |
|
| 106 | 105 | ); |
| 107 | 106 | |
| 108 | 107 | /** |
@@ -111,12 +110,12 @@ discard block |
||
| 111 | 110 | * @var array |
| 112 | 111 | */ |
| 113 | 112 | var $statusTypes = array( |
| 114 | - 'any' => 'any status',// lang('any status') |
|
| 115 | - 'flagged' => 'flagged', // lang('flagged') |
|
| 116 | - 'unseen' => 'unread', // lang('unread') |
|
| 117 | - 'answered' => 'replied', // lang('replied') |
|
| 118 | - 'seen' => 'read', // lang('read') |
|
| 119 | - 'deleted' => 'deleted', // lang('deleted') |
|
| 113 | + 'any' => 'any status', // lang('any status') |
|
| 114 | + 'flagged' => 'flagged', // lang('flagged') |
|
| 115 | + 'unseen' => 'unread', // lang('unread') |
|
| 116 | + 'answered' => 'replied', // lang('replied') |
|
| 117 | + 'seen' => 'read', // lang('read') |
|
| 118 | + 'deleted' => 'deleted', // lang('deleted') |
|
| 120 | 119 | ); |
| 121 | 120 | |
| 122 | 121 | /** |
@@ -124,12 +123,12 @@ discard block |
||
| 124 | 123 | * |
| 125 | 124 | * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server |
| 126 | 125 | */ |
| 127 | - function __construct($run_constructor=true) |
|
| 126 | + function __construct($run_constructor = true) |
|
| 128 | 127 | { |
| 129 | 128 | $this->mail_tree = new mail_tree($this); |
| 130 | 129 | if (!$run_constructor) return; |
| 131 | 130 | |
| 132 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 131 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 133 | 132 | // no autohide of the sidebox, as we use it for folderlist now. |
| 134 | 133 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 135 | 134 | |
@@ -145,13 +144,13 @@ discard block |
||
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | try { |
| 148 | - $this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true); |
|
| 147 | + $this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true); |
|
| 149 | 148 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 150 | 149 | //error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer)); |
| 151 | 150 | |
| 152 | 151 | // RegEx to minimize extra openConnection |
| 153 | 152 | $needle = '/^(?!mail)/'; |
| 154 | - if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest()) |
|
| 153 | + if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest()) |
|
| 155 | 154 | { |
| 156 | 155 | //error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 157 | 156 | //openConnection gathers SpecialUseFolderInformation and Delimiter Info |
@@ -164,12 +163,12 @@ discard block |
||
| 164 | 163 | if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index') |
| 165 | 164 | { |
| 166 | 165 | $response = Api\Json\Response::get(); |
| 167 | - $response->call('egw.message',$e->getMessage(),'error'); |
|
| 166 | + $response->call('egw.message', $e->getMessage(), 'error'); |
|
| 168 | 167 | } |
| 169 | 168 | // redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox |
| 170 | - if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false); |
|
| 169 | + if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false); |
|
| 171 | 170 | } |
| 172 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 171 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 173 | 172 | } |
| 174 | 173 | |
| 175 | 174 | /** |
@@ -179,10 +178,10 @@ discard block |
||
| 179 | 178 | * @param boolean $exit If true, will call exit() after opening the wizardpopup |
| 180 | 179 | * @param string $msg_type = 'success' message type |
| 181 | 180 | */ |
| 182 | - static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true) |
|
| 181 | + static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true) |
|
| 183 | 182 | { |
| 184 | 183 | //error_log(__METHOD__."('$message', $exit) ".function_backtrace()); |
| 185 | - $linkData=(self::$icServerID ? array( |
|
| 184 | + $linkData = (self::$icServerID ? array( |
|
| 186 | 185 | 'menuaction' => 'mail.mail_wizard.edit', |
| 187 | 186 | 'acc_id' => self::$icServerID, |
| 188 | 187 | ) : array( |
@@ -196,11 +195,11 @@ discard block |
||
| 196 | 195 | { |
| 197 | 196 | $response = Api\Json\Response::get(); |
| 198 | 197 | $windowName = "editMailAccount".self::$icServerID; |
| 199 | - $response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true); |
|
| 198 | + $response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true); |
|
| 200 | 199 | Framework::message($message, 'error'); |
| 201 | 200 | if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index) |
| 202 | 201 | { |
| 203 | - $response->call('framework.setSidebox','mail',array(),'md5'); |
|
| 202 | + $response->call('framework.setSidebox', 'mail', array(), 'md5'); |
|
| 204 | 203 | } |
| 205 | 204 | if ($exit) |
| 206 | 205 | { |
@@ -210,8 +209,8 @@ discard block |
||
| 210 | 209 | else // regular GET request eg. in idots template |
| 211 | 210 | { |
| 212 | 211 | $windowName = "editMailAccount".self::$icServerID; |
| 213 | - Framework::popup(Framework::link('/index.php',$linkData),$windowName); |
|
| 214 | - $GLOBALS['egw']->framework->render($message,'',true); |
|
| 212 | + Framework::popup(Framework::link('/index.php', $linkData), $windowName); |
|
| 213 | + $GLOBALS['egw']->framework->render($message, '', true); |
|
| 215 | 214 | if ($exit) |
| 216 | 215 | { |
| 217 | 216 | exit(); |
@@ -227,9 +226,9 @@ discard block |
||
| 227 | 226 | * |
| 228 | 227 | * @throws Api\Exception |
| 229 | 228 | */ |
| 230 | - function changeProfile($_icServerID,$unsetCache=false) |
|
| 229 | + function changeProfile($_icServerID, $unsetCache = false) |
|
| 231 | 230 | { |
| 232 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 231 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 233 | 232 | if (self::$icServerID != $_icServerID) |
| 234 | 233 | { |
| 235 | 234 | self::$icServerID = $_icServerID; |
@@ -237,35 +236,35 @@ discard block |
||
| 237 | 236 | if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
| 238 | 237 | |
| 239 | 238 | if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID); |
| 240 | - $this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true); |
|
| 239 | + $this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true); |
|
| 241 | 240 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 242 | 241 | // no icServer Object: something failed big time |
| 243 | - if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
|
| 242 | + if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID) |
|
| 244 | 243 | { |
| 245 | 244 | self::$icServerID = $_icServerID; |
| 246 | 245 | throw new Api\Exception('Profile change failed!'); |
| 247 | 246 | } |
| 248 | 247 | |
| 249 | 248 | // save session varchar |
| 250 | - $oldicServerID =& Api\Cache::getSession('mail','activeProfileID'); |
|
| 249 | + $oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID'); |
|
| 251 | 250 | if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
| 252 | 251 | if (true) $oldicServerID = self::$icServerID; |
| 253 | - if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
|
| 252 | + if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true)) |
|
| 254 | 253 | { |
| 255 | 254 | throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 256 | 255 | } |
| 257 | 256 | |
| 258 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 257 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | /** |
| 262 | 261 | * Ajax function to request next branch of a tree branch |
| 263 | 262 | */ |
| 264 | - static function ajax_tree_autoloading ($_id = null) |
|
| 263 | + static function ajax_tree_autoloading($_id = null) |
|
| 265 | 264 | { |
| 266 | 265 | $mail_ui = new mail_ui(); |
| 267 | 266 | $id = $_id ? $_id : $_GET['id']; |
| 268 | - Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false)); |
|
| 267 | + Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false)); |
|
| 269 | 268 | } |
| 270 | 269 | |
| 271 | 270 | /** |
@@ -274,11 +273,11 @@ discard block |
||
| 274 | 273 | * @param array $content |
| 275 | 274 | * @param type $msg |
| 276 | 275 | */ |
| 277 | - function subscription(array $content=null ,$msg=null) |
|
| 276 | + function subscription(array $content = null, $msg = null) |
|
| 278 | 277 | { |
| 279 | 278 | $stmpl = new Etemplate('mail.subscribe'); |
| 280 | 279 | |
| 281 | - if(is_array($content)) |
|
| 280 | + if (is_array($content)) |
|
| 282 | 281 | { |
| 283 | 282 | $profileId = $content['profileId']; |
| 284 | 283 | } |
@@ -288,14 +287,14 @@ discard block |
||
| 288 | 287 | } |
| 289 | 288 | // Initial tree's options, the rest would be loaded dynamicaly by autoloading, |
| 290 | 289 | // triggered from client-side. Also, we keep this here as |
| 291 | - $sel_options['foldertree'] = $this->mail_tree->getTree(null,$profileId,1,true,false,true); |
|
| 290 | + $sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true); |
|
| 292 | 291 | |
| 293 | 292 | //Get all subscribed folders |
| 294 | 293 | // as getting all subscribed folders is very fast operation |
| 295 | 294 | // we can use it to get a comparison base for folders which |
| 296 | 295 | // got subscribed or unsubscribed by the user |
| 297 | 296 | try { |
| 298 | - $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
|
| 297 | + $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true); |
|
| 299 | 298 | } catch (Exception $ex) { |
| 300 | 299 | Framework::message($ex->getMessage()); |
| 301 | 300 | } |
@@ -306,7 +305,7 @@ discard block |
||
| 306 | 305 | |
| 307 | 306 | foreach ($subscribed as $folder) |
| 308 | 307 | { |
| 309 | - $folderName = $profileId . self::$delimiter . $folder['MAILBOX']; |
|
| 308 | + $folderName = $profileId.self::$delimiter.$folder['MAILBOX']; |
|
| 310 | 309 | array_push($content['foldertree'], $folderName); |
| 311 | 310 | } |
| 312 | 311 | } |
@@ -320,9 +319,9 @@ discard block |
||
| 320 | 319 | { |
| 321 | 320 | // do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself |
| 322 | 321 | $namespace_roots = array($profileId); |
| 323 | - foreach($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 322 | + foreach ($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 324 | 323 | { |
| 325 | - $namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 324 | + $namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 326 | 325 | } |
| 327 | 326 | $to_unsubscribe = $to_subscribe = array(); |
| 328 | 327 | foreach ($content['foldertree'] as $path => $value) |
@@ -330,7 +329,7 @@ discard block |
||
| 330 | 329 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 331 | 330 | if ($node) |
| 332 | 331 | { |
| 333 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 332 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node; |
|
| 334 | 333 | if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
| 335 | 334 | if ($value['value']) $cont[] = $path; |
| 336 | 335 | } |
@@ -340,7 +339,7 @@ discard block |
||
| 340 | 339 | // set foldertree options to basic node in order to avoid initial autoloading |
| 341 | 340 | // from client side, as no options would trigger that. |
| 342 | 341 | $sel_options['foldertree'] = array('id' => '0', 'item'=> array()); |
| 343 | - foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 342 | + foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 344 | 343 | { |
| 345 | 344 | if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true)) |
| 346 | 345 | { |
@@ -376,18 +375,18 @@ discard block |
||
| 376 | 375 | } |
| 377 | 376 | } |
| 378 | 377 | // update foldertree in main window |
| 379 | - $parentFolder='INBOX'; |
|
| 378 | + $parentFolder = 'INBOX'; |
|
| 380 | 379 | $refreshData = array( |
| 381 | 380 | $profileId => lang($parentFolder), |
| 382 | 381 | ); |
| 383 | 382 | $response = Api\Json\Response::get(); |
| 384 | - foreach($refreshData as $folder => &$name) |
|
| 383 | + foreach ($refreshData as $folder => &$name) |
|
| 385 | 384 | { |
| 386 | - $name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true); |
|
| 385 | + $name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true); |
|
| 387 | 386 | } |
| 388 | 387 | // give success/error message to opener and popup itself |
| 389 | 388 | //$response->call('opener.app.mail.subscription_refresh',$refreshData); |
| 390 | - $response->call('opener.app.mail.mail_reloadNode',$refreshData); |
|
| 389 | + $response->call('opener.app.mail.mail_reloadNode', $refreshData); |
|
| 391 | 390 | |
| 392 | 391 | Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type); |
| 393 | 392 | if ($button == 'apply') |
@@ -407,7 +406,7 @@ discard block |
||
| 407 | 406 | |
| 408 | 407 | $readonlys = array(); |
| 409 | 408 | |
| 410 | - $stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2); |
|
| 409 | + $stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 411 | 410 | } |
| 412 | 411 | |
| 413 | 412 | /** |
@@ -416,13 +415,13 @@ discard block |
||
| 416 | 415 | * @param array $content |
| 417 | 416 | * @param string $msg |
| 418 | 417 | */ |
| 419 | - function index(array $content=null,$msg=null) |
|
| 418 | + function index(array $content = null, $msg = null) |
|
| 420 | 419 | { |
| 421 | 420 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 422 | - try { |
|
| 421 | + try { |
|
| 423 | 422 | if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.')); |
| 424 | 423 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 425 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 424 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 426 | 425 | $this->mail_bo->restoreSessionData(); |
| 427 | 426 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 428 | 427 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -443,26 +442,26 @@ discard block |
||
| 443 | 442 | { |
| 444 | 443 | // These only set on first load |
| 445 | 444 | $content[self::$nm_index] = array( |
| 446 | - 'filter' => 'any', // filter is used to choose the mailbox |
|
| 447 | - 'lettersearch' => false, // I show a lettersearch |
|
| 448 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 449 | - 'start' => 0, // IO position in list |
|
| 450 | - 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 451 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 445 | + 'filter' => 'any', // filter is used to choose the mailbox |
|
| 446 | + 'lettersearch' => false, // I show a lettersearch |
|
| 447 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 448 | + 'start' => 0, // IO position in list |
|
| 449 | + 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 450 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 452 | 451 | ); |
| 453 | 452 | } |
| 454 | 453 | if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | // These must always be set, even if $content is an array |
| 458 | - $content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox |
|
| 459 | - $content[self::$nm_index]['no_filter2'] = false; // Disable second filter |
|
| 457 | + $content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox |
|
| 458 | + $content[self::$nm_index]['no_filter2'] = false; // Disable second filter |
|
| 460 | 459 | $content[self::$nm_index]['actions'] = self::get_actions(); |
| 461 | - $content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid |
|
| 460 | + $content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid |
|
| 462 | 461 | $content[self::$nm_index]['placeholder_actions'] = array('composeasnew'); |
| 463 | 462 | $content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows'; |
| 464 | - $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 465 | - $content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 463 | + $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 464 | + $content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 466 | 465 | $content[self::$nm_index]['csv_fields'] = false; |
| 467 | 466 | if ($msg) |
| 468 | 467 | { |
@@ -474,11 +473,11 @@ discard block |
||
| 474 | 473 | unset($content['msg']); |
| 475 | 474 | } |
| 476 | 475 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 477 | - $quota = false;//$this->mail_bo->getQuotaRoot(); |
|
| 478 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 476 | + $quota = false; //$this->mail_bo->getQuotaRoot(); |
|
| 477 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 479 | 478 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 480 | 479 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 481 | - $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 480 | + $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 482 | 481 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 483 | 482 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 484 | 483 | } else { |
@@ -487,43 +486,43 @@ discard block |
||
| 487 | 486 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
| 488 | 487 | } |
| 489 | 488 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 490 | - $vacation = false;//$this->gatherVacation(); |
|
| 489 | + $vacation = false; //$this->gatherVacation(); |
|
| 491 | 490 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 492 | - if($vacation) { |
|
| 493 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
|
| 491 | + if ($vacation) { |
|
| 492 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time())) |
|
| 494 | 493 | { |
| 495 | 494 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
| 496 | 495 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active'); |
| 497 | - $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
|
| 496 | + $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : ''); |
|
| 498 | 497 | } |
| 499 | 498 | } |
| 500 | - if ($vacation==false) |
|
| 499 | + if ($vacation == false) |
|
| 501 | 500 | { |
| 502 | 501 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = ''; |
| 503 | 502 | $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ''; |
| 504 | 503 | } |
| 505 | 504 | //$zstarttime = microtime (true); |
| 506 | - $sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 505 | + $sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 507 | 506 | //$zendtime = microtime(true) - $zstarttime; |
| 508 | 507 | //error_log(__METHOD__.__LINE__. " time used: ".$zendtime); |
| 509 | - $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX'); |
|
| 508 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX'); |
|
| 510 | 509 | // since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters |
| 511 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 510 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 512 | 511 | { |
| 513 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 514 | - 'keyword1' => 'important',//lang('important'), |
|
| 515 | - 'keyword2' => 'job', //lang('job'), |
|
| 516 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 517 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 518 | - 'keyword5' => 'later', //lang('later'), |
|
| 512 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 513 | + 'keyword1' => 'important', //lang('important'), |
|
| 514 | + 'keyword2' => 'job', //lang('job'), |
|
| 515 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 516 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 517 | + 'keyword5' => 'later', //lang('later'), |
|
| 519 | 518 | )); |
| 520 | 519 | } |
| 521 | 520 | else |
| 522 | 521 | { |
| 523 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 524 | - foreach($keywords as &$k) |
|
| 522 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 523 | + foreach ($keywords as &$k) |
|
| 525 | 524 | { |
| 526 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 525 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 527 | 526 | } |
| 528 | 527 | } |
| 529 | 528 | |
@@ -534,8 +533,8 @@ discard block |
||
| 534 | 533 | |
| 535 | 534 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 536 | 535 | { |
| 537 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 538 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 536 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 537 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 539 | 538 | } |
| 540 | 539 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 541 | 540 | { |
@@ -547,14 +546,14 @@ discard block |
||
| 547 | 546 | //error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])); |
| 548 | 547 | $content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']; |
| 549 | 548 | $sel_options['filter'] = $this->statusTypes; |
| 550 | - $sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')); |
|
| 549 | + $sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')); |
|
| 551 | 550 | $content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']; |
| 552 | 551 | |
| 553 | 552 | $etpl = new Etemplate('mail.index'); |
| 554 | 553 | //apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter |
| 555 | 554 | $content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()"; |
| 556 | 555 | // set the actions on tree |
| 557 | - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions()); |
|
| 556 | + $etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions()); |
|
| 558 | 557 | |
| 559 | 558 | // sending preview toolbar actions |
| 560 | 559 | if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
@@ -565,34 +564,34 @@ discard block |
||
| 565 | 564 | //we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....) |
| 566 | 565 | if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search'])) |
| 567 | 566 | { |
| 568 | - $content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')); |
|
| 567 | + $content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject')); |
|
| 569 | 568 | } |
| 570 | 569 | $readonlys = $preserv = array(); |
| 571 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 570 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 572 | 571 | } |
| 573 | 572 | catch (Exception $e) |
| 574 | 573 | { |
| 575 | 574 | // do not exit here. mail-tree should be build. if we exit here, we never get there. |
| 576 | - error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace()); |
|
| 575 | + error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace()); |
|
| 577 | 576 | if (isset($this->mail_bo)) |
| 578 | 577 | { |
| 579 | 578 | if (empty($etpl)) |
| 580 | 579 | { |
| 581 | - $sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 580 | + $sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 582 | 581 | $etpl = new Etemplate('mail.index'); |
| 583 | 582 | } |
| 584 | - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false)); |
|
| 583 | + $etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false)); |
|
| 585 | 584 | } |
| 586 | 585 | $readonlys = $preserv = array(); |
| 587 | - if (empty($content)) $content=array(); |
|
| 586 | + if (empty($content)) $content = array(); |
|
| 588 | 587 | |
| 589 | - self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false); |
|
| 588 | + self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ? false : true), 'error', false); |
|
| 590 | 589 | //return false; |
| 591 | 590 | } |
| 592 | 591 | // Check preview pane is enabled, then show splitter |
| 593 | 592 | if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('splitter', 'template', 'mail.index.nosplitter'); |
| 594 | 593 | |
| 595 | - return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); |
|
| 594 | + return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
| 596 | 595 | } |
| 597 | 596 | |
| 598 | 597 | /** |
@@ -602,11 +601,11 @@ discard block |
||
| 602 | 601 | * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server |
| 603 | 602 | * @return array |
| 604 | 603 | */ |
| 605 | - function get_tree_actions($imap_actions=true) |
|
| 604 | + function get_tree_actions($imap_actions = true) |
|
| 606 | 605 | { |
| 607 | 606 | // Start at 2 so auto-added copy+paste actions show up as second group |
| 608 | 607 | // Needed because there's no 'select all' action to push things down |
| 609 | - $group=1; |
|
| 608 | + $group = 1; |
|
| 610 | 609 | // Set tree actions |
| 611 | 610 | $tree_actions = array( |
| 612 | 611 | 'drop_move_mail' => array( |
@@ -688,12 +687,12 @@ discard block |
||
| 688 | 687 | 'onExecute' => 'javaScript:app.mail.edit_sieve', |
| 689 | 688 | |
| 690 | 689 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 691 | - 'icon' => 'mail/filter', // funnel |
|
| 690 | + 'icon' => 'mail/filter', // funnel |
|
| 692 | 691 | 'hideOnMobile' => true |
| 693 | 692 | ), |
| 694 | 693 | 'vacation' => array( |
| 695 | 694 | 'caption' => 'Vacation notice', |
| 696 | - 'icon' => 'mail/navbar', // mail as in admin |
|
| 695 | + 'icon' => 'mail/navbar', // mail as in admin |
|
| 697 | 696 | 'onExecute' => 'javaScript:app.mail.edit_vacation', |
| 698 | 697 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 699 | 698 | ), |
@@ -734,8 +733,8 @@ discard block |
||
| 734 | 733 | unset($tree_actions['subscribe']); |
| 735 | 734 | unset($tree_actions['unsubscribe']); |
| 736 | 735 | } |
| 737 | - ++$group; // put delete in own group |
|
| 738 | - switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 736 | + ++$group; // put delete in own group |
|
| 737 | + switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 739 | 738 | { |
| 740 | 739 | case 'move_to_trash': |
| 741 | 740 | $tree_actions['empty_trash'] = array( |
@@ -754,7 +753,7 @@ discard block |
||
| 754 | 753 | ); |
| 755 | 754 | break; |
| 756 | 755 | } |
| 757 | - $junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null); |
|
| 756 | + $junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null); |
|
| 758 | 757 | |
| 759 | 758 | //error_log(__METHOD__.__LINE__.$junkFolder); |
| 760 | 759 | if ($junkFolder && !empty($junkFolder)) |
@@ -767,8 +766,8 @@ discard block |
||
| 767 | 766 | 'group' => $group, |
| 768 | 767 | ); |
| 769 | 768 | } |
| 770 | - $tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter |
|
| 771 | - $tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group; |
|
| 769 | + $tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter |
|
| 770 | + $tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group; |
|
| 772 | 771 | |
| 773 | 772 | |
| 774 | 773 | // enforce global (group-specific) ACL |
@@ -803,17 +802,17 @@ discard block |
||
| 803 | 802 | * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed |
| 804 | 803 | * @param {boolean} $_status set true for subscribe and false to unsubscribe |
| 805 | 804 | */ |
| 806 | - public function ajax_foldersubscription($_acc_id,$_folderName, $_status) |
|
| 805 | + public function ajax_foldersubscription($_acc_id, $_folderName, $_status) |
|
| 807 | 806 | { |
| 808 | 807 | //Change the Mail object to related profileId |
| 809 | 808 | $this->changeProfile($_acc_id); |
| 810 | - try{ |
|
| 809 | + try { |
|
| 811 | 810 | $this->mail_bo->icServer->subscribeMailbox($_folderName, $_status); |
| 812 | 811 | $this->mail_bo->resetFolderObjectCache($_acc_id); |
| 813 | - $this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 812 | + $this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 814 | 813 | } catch (Horde_Imap_Client_Exception $ex) { |
| 815 | - error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex)); |
|
| 816 | - Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status)); |
|
| 814 | + error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex)); |
|
| 815 | + Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status)); |
|
| 817 | 816 | } |
| 818 | 817 | } |
| 819 | 818 | |
@@ -825,25 +824,25 @@ discard block |
||
| 825 | 824 | * @param string $_nodeID if of node whos children are requested |
| 826 | 825 | * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default) |
| 827 | 826 | */ |
| 828 | - public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
|
| 827 | + public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null) |
|
| 829 | 828 | { |
| 830 | 829 | $nodeID = $_GET['id']; |
| 831 | 830 | if (!is_null($_nodeID)) $nodeID = $_nodeID; |
| 832 | - $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 831 | + $subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 833 | 832 | $fetchCounters = !is_null($_nodeID); |
| 834 | - list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
|
| 833 | + list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2); |
|
| 835 | 834 | |
| 836 | 835 | if (!empty($_folderName)) $fetchCounters = true; |
| 837 | 836 | |
| 838 | 837 | // Check if it is called for refresh root |
| 839 | 838 | // then we need to reinitialized the index tree |
| 840 | - if(!$nodeID && !$_profileID) |
|
| 839 | + if (!$nodeID && !$_profileID) |
|
| 841 | 840 | { |
| 842 | - $data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 841 | + $data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 843 | 842 | } |
| 844 | 843 | else |
| 845 | 844 | { |
| 846 | - $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 845 | + $data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 847 | 846 | } |
| 848 | 847 | if (!is_null($_nodeID)) return $data; |
| 849 | 848 | Etemplate\Widget\Tree::send_quote_json($data); |
@@ -859,17 +858,17 @@ discard block |
||
| 859 | 858 | */ |
| 860 | 859 | static function findNode($_out, $_nodeID, $childElements = false) |
| 861 | 860 | { |
| 862 | - foreach($_out['item'] as $node) |
|
| 861 | + foreach ($_out['item'] as $node) |
|
| 863 | 862 | { |
| 864 | - if (strcmp($node['id'],$_nodeID)===0) |
|
| 863 | + if (strcmp($node['id'], $_nodeID) === 0) |
|
| 865 | 864 | { |
| 866 | 865 | //error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']); |
| 867 | - return ($childElements?$node['item']:$node); |
|
| 866 | + return ($childElements ? $node['item'] : $node); |
|
| 868 | 867 | } |
| 869 | - elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id'])) |
|
| 868 | + elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id'])) |
|
| 870 | 869 | { |
| 871 | 870 | //error_log(__METHOD__.__LINE__.' descend into '.$node['id']); |
| 872 | - return self::findNode($node,$_nodeID,$childElements); |
|
| 871 | + return self::findNode($node, $_nodeID, $childElements); |
|
| 873 | 872 | } |
| 874 | 873 | } |
| 875 | 874 | } |
@@ -883,7 +882,7 @@ discard block |
||
| 883 | 882 | */ |
| 884 | 883 | private function get_actions() |
| 885 | 884 | { |
| 886 | - static $accArray=array(); // buffer identity names on single request |
|
| 885 | + static $accArray = array(); // buffer identity names on single request |
|
| 887 | 886 | // duplicated from mail_hooks |
| 888 | 887 | static $deleteOptions = array( |
| 889 | 888 | 'move_to_trash' => 'move to trash', |
@@ -894,12 +893,12 @@ discard block |
||
| 894 | 893 | $lastFolderUsedForMove = null; |
| 895 | 894 | $moveactions = array(); |
| 896 | 895 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
| 897 | - $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 896 | + $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 898 | 897 | //error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont)); |
| 899 | 898 | //error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])); |
| 900 | 899 | if (is_null($accArray)) |
| 901 | 900 | { |
| 902 | - foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj) |
|
| 901 | + foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj) |
|
| 903 | 902 | { |
| 904 | 903 | //error_log(__METHOD__.__LINE__.array2string($accountObj)); |
| 905 | 904 | if (!$accountObj->is_imap()) |
@@ -907,22 +906,22 @@ discard block |
||
| 907 | 906 | // not to be used for IMAP Foldertree, as there is no Imap host |
| 908 | 907 | continue; |
| 909 | 908 | } |
| 910 | - $identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
|
| 911 | - $accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead |
|
| 909 | + $identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']); |
|
| 910 | + $accArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); // as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead |
|
| 912 | 911 | } |
| 913 | 912 | } |
| 914 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 913 | + if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array(); |
|
| 915 | 914 | foreach (array_keys($lastFoldersUsedForMoveCont) as $pid) |
| 916 | 915 | { |
| 917 | - if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 916 | + if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 918 | 917 | { |
| 919 | 918 | $_folder = $this->mail_bo->icServer->getCurrentMailbox(); |
| 920 | 919 | //error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace()); |
| 921 | - $counter =1; |
|
| 920 | + $counter = 1; |
|
| 922 | 921 | foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont) |
| 923 | 922 | { |
| 924 | 923 | $moveaction = 'move_'; |
| 925 | - if ($_folder!=$i) |
|
| 924 | + if ($_folder != $i) |
|
| 926 | 925 | { |
| 927 | 926 | $moveaction .= $lastFolderUsedForMoveCont; |
| 928 | 927 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
@@ -933,7 +932,7 @@ discard block |
||
| 933 | 932 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 934 | 933 | $fS['shortDisplayName'] = $i; |
| 935 | 934 | $moveactions[$moveaction] = $fS; |
| 936 | - $counter ++; |
|
| 935 | + $counter++; |
|
| 937 | 936 | } |
| 938 | 937 | else |
| 939 | 938 | { |
@@ -943,9 +942,9 @@ discard block |
||
| 943 | 942 | } |
| 944 | 943 | } |
| 945 | 944 | } |
| 946 | - elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 945 | + elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 947 | 946 | { |
| 948 | - $counter =1; |
|
| 947 | + $counter = 1; |
|
| 949 | 948 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 950 | 949 | { |
| 951 | 950 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
@@ -958,19 +957,19 @@ discard block |
||
| 958 | 957 | $fS['profileName'] = $accArray[$pid]; |
| 959 | 958 | $fS['shortDisplayName'] = $i; |
| 960 | 959 | $moveactions[$moveaction] = $fS; |
| 961 | - $counter ++; |
|
| 960 | + $counter++; |
|
| 962 | 961 | } |
| 963 | 962 | } |
| 964 | 963 | } |
| 965 | 964 | } |
| 966 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 965 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 967 | 966 | $group = 0; |
| 968 | - $actions = array( |
|
| 967 | + $actions = array( |
|
| 969 | 968 | 'open' => array( |
| 970 | 969 | 'caption' => lang('Open'), |
| 971 | 970 | 'icon' => 'view', |
| 972 | 971 | 'group' => ++$group, |
| 973 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open', |
|
| 972 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open', |
|
| 974 | 973 | 'allowOnMultiple' => false, |
| 975 | 974 | 'default' => true, |
| 976 | 975 | 'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet')) |
@@ -1023,20 +1022,20 @@ discard block |
||
| 1023 | 1022 | 'allowOnMultiple' => false, |
| 1024 | 1023 | ) |
| 1025 | 1024 | ); |
| 1026 | - $macounter=0; |
|
| 1025 | + $macounter = 0; |
|
| 1027 | 1026 | if (!empty($moveactions)) |
| 1028 | 1027 | { |
| 1029 | 1028 | //error_log(__METHOD__.__LINE__.array2string($moveactions)); |
| 1030 | - $children=array(); |
|
| 1031 | - $pID=0; |
|
| 1029 | + $children = array(); |
|
| 1030 | + $pID = 0; |
|
| 1032 | 1031 | foreach ($moveactions as $moveaction => $lastFolderUsedForMove) |
| 1033 | 1032 | { |
| 1034 | - $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group); |
|
| 1033 | + $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group); |
|
| 1035 | 1034 | //error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#'); |
| 1036 | 1035 | $children = array_merge($children, |
| 1037 | 1036 | array( |
| 1038 | 1037 | $moveaction => array( |
| 1039 | - 'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''), |
|
| 1038 | + 'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''), |
|
| 1040 | 1039 | 'icon' => 'move', |
| 1041 | 1040 | 'group' => $group, |
| 1042 | 1041 | 'onExecute' => 'javaScript:app.mail.mail_move2folder', |
@@ -1047,7 +1046,7 @@ discard block |
||
| 1047 | 1046 | $pID = $lastFolderUsedForMove['profileID']; |
| 1048 | 1047 | $macounter++; |
| 1049 | 1048 | } |
| 1050 | - $actions['moveto'] = array( |
|
| 1049 | + $actions['moveto'] = array( |
|
| 1051 | 1050 | 'caption' => lang('Move selected to'), |
| 1052 | 1051 | 'icon' => 'move', |
| 1053 | 1052 | 'group' => $group, |
@@ -1090,7 +1089,7 @@ discard block |
||
| 1090 | 1089 | 'icon' => 'tracker/navbar', |
| 1091 | 1090 | 'onExecute' => 'javaScript:app.mail.mail_integrate', |
| 1092 | 1091 | 'popup' => Link::get_registry('tracker', 'add_popup'), |
| 1093 | - 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'), |
|
| 1092 | + 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'), |
|
| 1094 | 1093 | 'allowOnMultiple' => false, |
| 1095 | 1094 | ), |
| 1096 | 1095 | 'calendar' => array( |
@@ -1309,25 +1308,25 @@ discard block |
||
| 1309 | 1308 | * @param array &$rows |
| 1310 | 1309 | * @param array &$readonlys |
| 1311 | 1310 | */ |
| 1312 | - public static function get_rows(&$query,&$rows,&$readonlys) |
|
| 1311 | + public static function get_rows(&$query, &$rows, &$readonlys) |
|
| 1313 | 1312 | { |
| 1314 | - unset($readonlys); // not used, but required by function signature |
|
| 1313 | + unset($readonlys); // not used, but required by function signature |
|
| 1315 | 1314 | |
| 1316 | 1315 | // handle possible profile change in get_rows |
| 1317 | 1316 | if (!empty($query['selectedFolder'])) |
| 1318 | 1317 | { |
| 1319 | - list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1318 | + list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1320 | 1319 | if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) |
| 1321 | 1320 | { |
| 1322 | 1321 | try { |
| 1323 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1322 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1324 | 1323 | $mail_ui->changeProfile($_profileID); |
| 1325 | 1324 | $query['actions'] = $mail_ui->get_actions(); |
| 1326 | 1325 | } |
| 1327 | - catch(Exception $e) |
|
| 1326 | + catch (Exception $e) |
|
| 1328 | 1327 | { |
| 1329 | 1328 | unset($e); |
| 1330 | - $rows=array(); |
|
| 1329 | + $rows = array(); |
|
| 1331 | 1330 | return 0; |
| 1332 | 1331 | } |
| 1333 | 1332 | if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
@@ -1337,12 +1336,12 @@ discard block |
||
| 1337 | 1336 | { |
| 1338 | 1337 | try |
| 1339 | 1338 | { |
| 1340 | - $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1339 | + $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1341 | 1340 | } |
| 1342 | - catch(Exception $e) |
|
| 1341 | + catch (Exception $e) |
|
| 1343 | 1342 | { |
| 1344 | 1343 | unset($e); |
| 1345 | - $rows=array(); |
|
| 1344 | + $rows = array(); |
|
| 1346 | 1345 | return 0; |
| 1347 | 1346 | } |
| 1348 | 1347 | if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
@@ -1353,68 +1352,68 @@ discard block |
||
| 1353 | 1352 | //$query['search'] is the phrase in the searchbox |
| 1354 | 1353 | |
| 1355 | 1354 | $mail_ui->mail_bo->restoreSessionData(); |
| 1356 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1355 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder']; |
|
| 1357 | 1356 | $mail_ui->mail_bo->saveSessionData(); |
| 1358 | 1357 | |
| 1359 | 1358 | $sRToFetch = null; |
| 1360 | - list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2); |
|
| 1361 | - if (strpos($_folderName,self::$delimiter)!==false) |
|
| 1359 | + list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1360 | + if (strpos($_folderName, self::$delimiter) !== false) |
|
| 1362 | 1361 | { |
| 1363 | - list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3); |
|
| 1362 | + list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3); |
|
| 1364 | 1363 | unset($app); |
| 1365 | 1364 | } |
| 1366 | 1365 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1367 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1368 | - $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1366 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName; |
|
| 1367 | + $toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1369 | 1368 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1370 | 1369 | { |
| 1371 | - $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false); |
|
| 1370 | + $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false); |
|
| 1372 | 1371 | } |
| 1373 | 1372 | else |
| 1374 | 1373 | { |
| 1375 | 1374 | // take the extra time on failure |
| 1376 | - if (!$mail_ui->mail_bo->folderExists($_folderName,true)) |
|
| 1375 | + if (!$mail_ui->mail_bo->folderExists($_folderName, true)) |
|
| 1377 | 1376 | { |
| 1378 | 1377 | //error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead'); |
| 1379 | - $query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX'; |
|
| 1378 | + $query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX'; |
|
| 1380 | 1379 | } |
| 1381 | 1380 | } |
| 1382 | 1381 | $mail_ui->mail_bo->saveSessionData(); |
| 1383 | 1382 | $rowsFetched['messages'] = null; |
| 1384 | - $offset = $query['start']+1; // we always start with 1 |
|
| 1383 | + $offset = $query['start'] + 1; // we always start with 1 |
|
| 1385 | 1384 | $maxMessages = $query['num_rows']; |
| 1386 | 1385 | //error_log(__METHOD__.__LINE__.array2string($query)); |
| 1387 | - $sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']); |
|
| 1388 | - if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 1386 | + $sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']); |
|
| 1387 | + if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 1389 | 1388 | { |
| 1390 | 1389 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1391 | 1390 | { |
| 1392 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 1391 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1393 | 1392 | if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1394 | 1393 | { |
| 1395 | - Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true; |
|
| 1394 | + Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true; |
|
| 1396 | 1395 | } |
| 1397 | 1396 | } |
| 1398 | 1397 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 1399 | 1398 | $cutoffdate = $cutoffdate2 = null; |
| 1400 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 1401 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 1399 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 1400 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 1402 | 1401 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 1403 | 1402 | $filter = array( |
| 1404 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 1405 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 1403 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 1404 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 1406 | 1405 | 'string' => $query['search'], |
| 1407 | 1406 | 'status' => 'any', |
| 1408 | 1407 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 1409 | 1408 | ); |
| 1410 | - if ($query['enddate']||$query['startdate']) { |
|
| 1409 | + if ($query['enddate'] || $query['startdate']) { |
|
| 1411 | 1410 | $filter['range'] = "BETWEEN"; |
| 1412 | 1411 | if ($cutoffdate) { |
| 1413 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 1412 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 1414 | 1413 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 1415 | 1414 | } |
| 1416 | 1415 | if ($cutoffdate2) { |
| 1417 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 1416 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 1418 | 1417 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 1419 | 1418 | } |
| 1420 | 1419 | } |
@@ -1427,17 +1426,17 @@ discard block |
||
| 1427 | 1426 | { |
| 1428 | 1427 | $filter['status'] = $query['filter']; |
| 1429 | 1428 | } |
| 1430 | - $reverse = ($query['sort']=='ASC'?false:true); |
|
| 1429 | + $reverse = ($query['sort'] == 'ASC' ? false : true); |
|
| 1431 | 1430 | $prefchanged = false; |
| 1432 | - if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])) |
|
| 1431 | + if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])) |
|
| 1433 | 1432 | { |
| 1434 | 1433 | //error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']); |
| 1435 | - $GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user'); |
|
| 1434 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user'); |
|
| 1436 | 1435 | $prefchanged = true; |
| 1437 | 1436 | } |
| 1438 | - if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'])) |
|
| 1437 | + if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'])) |
|
| 1439 | 1438 | { |
| 1440 | - $GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user'); |
|
| 1439 | + $GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user'); |
|
| 1441 | 1440 | $prefchanged = true; |
| 1442 | 1441 | } |
| 1443 | 1442 | if ($prefchanged) |
@@ -1468,13 +1467,13 @@ discard block |
||
| 1468 | 1467 | $rowsFetched['messages'] = $_sR['count']; |
| 1469 | 1468 | $ids = $_sR['match']->ids; |
| 1470 | 1469 | // if $sR is false, something failed fundamentally |
| 1471 | - if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1472 | - $sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
|
| 1473 | - $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1470 | + if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids)); |
|
| 1471 | + $sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids |
|
| 1472 | + $sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1474 | 1473 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
| 1475 | 1474 | $maxMessages = 75; |
| 1476 | 1475 | $sortResultwH['header'] = array(); |
| 1477 | - if (count($sRToFetch)>0) |
|
| 1476 | + if (count($sRToFetch) > 0) |
|
| 1478 | 1477 | { |
| 1479 | 1478 | //error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch)); |
| 1480 | 1479 | $sortResult = array(); |
@@ -1488,7 +1487,7 @@ discard block |
||
| 1488 | 1487 | $filter, |
| 1489 | 1488 | $sRToFetch, |
| 1490 | 1489 | true, //cacheResult |
| 1491 | - ($query['filter2']?true:false) // fetchPreview |
|
| 1490 | + ($query['filter2'] ? true : false) // fetchPreview |
|
| 1492 | 1491 | ); |
| 1493 | 1492 | } |
| 1494 | 1493 | } |
@@ -1505,30 +1504,30 @@ discard block |
||
| 1505 | 1504 | $filter, |
| 1506 | 1505 | null, // this uids only |
| 1507 | 1506 | true, // cacheResult |
| 1508 | - ($query['filter2']?true:false) // fetchPreview |
|
| 1507 | + ($query['filter2'] ? true : false) // fetchPreview |
|
| 1509 | 1508 | ); |
| 1510 | 1509 | $rowsFetched['messages'] = $sortResultwH['info']['total']; |
| 1511 | 1510 | } |
| 1512 | 1511 | } |
| 1513 | 1512 | catch (Exception $e) |
| 1514 | 1513 | { |
| 1515 | - $sortResultwH=array(); |
|
| 1516 | - $sR=array(); |
|
| 1514 | + $sortResultwH = array(); |
|
| 1515 | + $sR = array(); |
|
| 1517 | 1516 | self::callWizard($e->getMessage(), false, 'error'); |
| 1518 | 1517 | } |
| 1519 | 1518 | $response = Api\Json\Response::get(); |
| 1520 | 1519 | // unlock immediately after fetching the rows |
| 1521 | - if (stripos($_GET['menuaction'],'ajax_get_rows')!==false) |
|
| 1520 | + if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false) |
|
| 1522 | 1521 | { |
| 1523 | 1522 | //error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']); |
| 1524 | 1523 | $response->call('app.mail.unlock_tree'); |
| 1525 | 1524 | } |
| 1526 | 1525 | |
| 1527 | - if (is_array($sR) && count($sR)>0) |
|
| 1526 | + if (is_array($sR) && count($sR) > 0) |
|
| 1528 | 1527 | { |
| 1529 | 1528 | foreach ((array)$sR as $key => $v) |
| 1530 | 1529 | { |
| 1531 | - if (array_key_exists($key,(array)$sortResultwH['header'])==true) |
|
| 1530 | + if (array_key_exists($key, (array)$sortResultwH['header']) == true) |
|
| 1532 | 1531 | { |
| 1533 | 1532 | $sortResult['header'][] = $sortResultwH['header'][$key]; |
| 1534 | 1533 | } |
@@ -1546,12 +1545,12 @@ discard block |
||
| 1546 | 1545 | if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
| 1547 | 1546 | |
| 1548 | 1547 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1549 | - $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
|
| 1550 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1551 | - $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
|
| 1548 | + $cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview'); |
|
| 1549 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1550 | + $rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema); |
|
| 1552 | 1551 | //error_log(__METHOD__.__LINE__.array2string($rows)); |
| 1553 | 1552 | |
| 1554 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1553 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__); |
|
| 1555 | 1554 | return $rowsFetched['messages']; |
| 1556 | 1555 | } |
| 1557 | 1556 | |
@@ -1563,7 +1562,7 @@ discard block |
||
| 1563 | 1562 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1564 | 1563 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1565 | 1564 | */ |
| 1566 | - function createRowID($_folderName, $message_uid, $_prependApp=false) |
|
| 1565 | + function createRowID($_folderName, $message_uid, $_prependApp = false) |
|
| 1567 | 1566 | { |
| 1568 | 1567 | return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp); |
| 1569 | 1568 | } |
@@ -1577,9 +1576,9 @@ discard block |
||
| 1577 | 1576 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1578 | 1577 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1579 | 1578 | */ |
| 1580 | - static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false) |
|
| 1579 | + static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false) |
|
| 1581 | 1580 | { |
| 1582 | - return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1581 | + return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1583 | 1582 | } |
| 1584 | 1583 | |
| 1585 | 1584 | /** |
@@ -1590,13 +1589,13 @@ discard block |
||
| 1590 | 1589 | */ |
| 1591 | 1590 | static function splitRowID($_rowID) |
| 1592 | 1591 | { |
| 1593 | - $res = explode(self::$delimiter,$_rowID); |
|
| 1592 | + $res = explode(self::$delimiter, $_rowID); |
|
| 1594 | 1593 | // as a rowID is perceeded by app::, should be mail! |
| 1595 | 1594 | //error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res)); |
| 1596 | - if (count($res)==4 && is_numeric($res[0]) ) |
|
| 1595 | + if (count($res) == 4 && is_numeric($res[0])) |
|
| 1597 | 1596 | { |
| 1598 | 1597 | // we have an own created rowID; prepend app=mail |
| 1599 | - array_unshift($res,'mail'); |
|
| 1598 | + array_unshift($res, 'mail'); |
|
| 1600 | 1599 | } |
| 1601 | 1600 | return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]); |
| 1602 | 1601 | } |
@@ -1610,56 +1609,56 @@ discard block |
||
| 1610 | 1609 | { |
| 1611 | 1610 | $actions = $this->get_actions(); |
| 1612 | 1611 | $arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print', |
| 1613 | - 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5'); |
|
| 1614 | - foreach( $arrActions as &$act) |
|
| 1612 | + 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5'); |
|
| 1613 | + foreach ($arrActions as &$act) |
|
| 1615 | 1614 | { |
| 1616 | 1615 | //error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act])); |
| 1617 | 1616 | switch ($act) |
| 1618 | 1617 | { |
| 1619 | 1618 | case 'forward': |
| 1620 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1619 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1621 | 1620 | break; |
| 1622 | 1621 | case 'save': |
| 1623 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1622 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1624 | 1623 | |
| 1625 | 1624 | break; |
| 1626 | 1625 | case 'view': |
| 1627 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1626 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1628 | 1627 | break; |
| 1629 | 1628 | case 'flagged': |
| 1630 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1629 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1631 | 1630 | break; |
| 1632 | 1631 | case 'read': |
| 1633 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1632 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1634 | 1633 | break; |
| 1635 | 1634 | case 'label1': |
| 1636 | 1635 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important'); |
| 1637 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1636 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1638 | 1637 | break; |
| 1639 | 1638 | case 'label2': |
| 1640 | 1639 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job'); |
| 1641 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1640 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1642 | 1641 | break; |
| 1643 | 1642 | case 'label3': |
| 1644 | 1643 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal'); |
| 1645 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1644 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1646 | 1645 | break; |
| 1647 | 1646 | case 'label4': |
| 1648 | 1647 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do'); |
| 1649 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1648 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1650 | 1649 | break; |
| 1651 | 1650 | case 'label5': |
| 1652 | 1651 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later'); |
| 1653 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1652 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1654 | 1653 | break; |
| 1655 | 1654 | default: |
| 1656 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1655 | + if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act]; |
|
| 1657 | 1656 | } |
| 1658 | 1657 | } |
| 1659 | 1658 | unset($actionsenabled['drag_mail']); |
| 1660 | 1659 | //error_log(array2string($actionsenabled['view'])); |
| 1661 | - unset($actionsenabled['view']['children']['openastext']);//not supported in preview |
|
| 1662 | - unset($actionsenabled['view']['children']['openashtml']);//not supported in preview |
|
| 1660 | + unset($actionsenabled['view']['children']['openastext']); //not supported in preview |
|
| 1661 | + unset($actionsenabled['view']['children']['openashtml']); //not supported in preview |
|
| 1663 | 1662 | |
| 1664 | 1663 | return $actionsenabled; |
| 1665 | 1664 | } |
@@ -1673,45 +1672,45 @@ discard block |
||
| 1673 | 1672 | * @param array $_folderType used to determine if we need to populate from/to |
| 1674 | 1673 | * @return array populated result array |
| 1675 | 1674 | */ |
| 1676 | - public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
|
| 1675 | + public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0) |
|
| 1677 | 1676 | { |
| 1678 | 1677 | if (Mail::$debugTimes) $starttime = microtime(true); |
| 1679 | 1678 | $rv = array(); |
| 1680 | - $i=0; |
|
| 1681 | - foreach((array)$_headers as $header) |
|
| 1679 | + $i = 0; |
|
| 1680 | + foreach ((array)$_headers as $header) |
|
| 1682 | 1681 | { |
| 1683 | 1682 | $i++; |
| 1684 | 1683 | $data = array(); |
| 1685 | 1684 | //error_log(__METHOD__.array2string($header)); |
| 1686 | 1685 | $message_uid = $header['uid']; |
| 1687 | 1686 | $data['uid'] = $message_uid; |
| 1688 | - $data['row_id']=$this->createRowID($_folderName,$message_uid); |
|
| 1687 | + $data['row_id'] = $this->createRowID($_folderName, $message_uid); |
|
| 1689 | 1688 | |
| 1690 | 1689 | $flags = ""; |
| 1691 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1692 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1693 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1694 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1695 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1696 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1697 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1698 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1699 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1700 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1701 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1690 | + if (!empty($header['recent'])) $flags .= "R"; |
|
| 1691 | + if (!empty($header['flagged'])) $flags .= "F"; |
|
| 1692 | + if (!empty($header['answered'])) $flags .= "A"; |
|
| 1693 | + if (!empty($header['forwarded'])) $flags .= "W"; |
|
| 1694 | + if (!empty($header['deleted'])) $flags .= "D"; |
|
| 1695 | + if (!empty($header['seen'])) $flags .= "S"; |
|
| 1696 | + if (!empty($header['label1'])) $flags .= "1"; |
|
| 1697 | + if (!empty($header['label2'])) $flags .= "2"; |
|
| 1698 | + if (!empty($header['label3'])) $flags .= "3"; |
|
| 1699 | + if (!empty($header['label4'])) $flags .= "4"; |
|
| 1700 | + if (!empty($header['label5'])) $flags .= "5"; |
|
| 1702 | 1701 | |
| 1703 | 1702 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1704 | 1703 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
| 1705 | 1704 | |
| 1706 | 1705 | // the css for this row |
| 1707 | - $is_recent=false; |
|
| 1706 | + $is_recent = false; |
|
| 1708 | 1707 | $css_styles = array("mail"); |
| 1709 | 1708 | if ($header['deleted']) { |
| 1710 | 1709 | $css_styles[] = 'deleted'; |
| 1711 | 1710 | } |
| 1712 | 1711 | if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
| 1713 | 1712 | $css_styles[] = 'recent'; |
| 1714 | - $is_recent=true; |
|
| 1713 | + $is_recent = true; |
|
| 1715 | 1714 | } |
| 1716 | 1715 | if ($header['priority'] < 3) { |
| 1717 | 1716 | $css_styles[] = 'prio_high'; |
@@ -1749,19 +1748,19 @@ discard block |
||
| 1749 | 1748 | if (in_array("subject", $cols)) |
| 1750 | 1749 | { |
| 1751 | 1750 | // filter out undisplayable characters |
| 1752 | - $search = array('[\016]','[\017]', |
|
| 1753 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 1754 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 1751 | + $search = array('[\016]', '[\017]', |
|
| 1752 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 1753 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 1755 | 1754 | $replace = ''; |
| 1756 | 1755 | |
| 1757 | - $header['subject'] = preg_replace($search,$replace,$header['subject']); |
|
| 1756 | + $header['subject'] = preg_replace($search, $replace, $header['subject']); |
|
| 1758 | 1757 | // curly brackets get messed up by the template! |
| 1759 | 1758 | |
| 1760 | 1759 | if (!empty($header['subject'])) { |
| 1761 | 1760 | // make the subject shorter if it is to long |
| 1762 | 1761 | $subject = $header['subject']; |
| 1763 | 1762 | } else { |
| 1764 | - $subject = '('. lang('no subject') .')'; |
|
| 1763 | + $subject = '('.lang('no subject').')'; |
|
| 1765 | 1764 | } |
| 1766 | 1765 | |
| 1767 | 1766 | $data["subject"] = $subject; // the mailsubject |
@@ -1771,53 +1770,53 @@ discard block |
||
| 1771 | 1770 | //error_log(__METHOD__.__LINE__.array2string($header)); |
| 1772 | 1771 | if (in_array("attachments", $cols)) |
| 1773 | 1772 | { |
| 1774 | - if($header['mimetype'] == 'multipart/mixed' || |
|
| 1773 | + if ($header['mimetype'] == 'multipart/mixed' || |
|
| 1775 | 1774 | $header['mimetype'] == 'multipart/signed' || |
| 1776 | 1775 | $header['mimetype'] == 'multipart/related' || |
| 1777 | 1776 | $header['mimetype'] == 'multipart/report' || |
| 1778 | 1777 | $header['mimetype'] == 'text/calendar' || |
| 1779 | 1778 | $header['mimetype'] == 'text/html' || |
| 1780 | - substr($header['mimetype'],0,11) == 'application' || |
|
| 1781 | - substr($header['mimetype'],0,5) == 'audio' || |
|
| 1782 | - substr($header['mimetype'],0,5) == 'video' || |
|
| 1779 | + substr($header['mimetype'], 0, 11) == 'application' || |
|
| 1780 | + substr($header['mimetype'], 0, 5) == 'audio' || |
|
| 1781 | + substr($header['mimetype'], 0, 5) == 'video' || |
|
| 1783 | 1782 | $header['mimetype'] == 'multipart/alternative') |
| 1784 | 1783 | { |
| 1785 | - $image = Api\Html::image('mail','attach'); |
|
| 1784 | + $image = Api\Html::image('mail', 'attach'); |
|
| 1786 | 1785 | $imageHTMLBlock = ''; |
| 1787 | - $datarowid = $this->createRowID($_folderName,$message_uid,true); |
|
| 1786 | + $datarowid = $this->createRowID($_folderName, $message_uid, true); |
|
| 1788 | 1787 | $attachments = $header['attachments']; |
| 1789 | - if (count($attachments)<1) |
|
| 1788 | + if (count($attachments) < 1) |
|
| 1790 | 1789 | { |
| 1791 | 1790 | $image = ' '; |
| 1792 | 1791 | } |
| 1793 | - if (count($attachments)==1) |
|
| 1792 | + if (count($attachments) == 1) |
|
| 1794 | 1793 | { |
| 1795 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1796 | - $image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':'')); |
|
| 1794 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1795 | + $image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : '')); |
|
| 1797 | 1796 | } |
| 1798 | - if (count($attachments)>1) |
|
| 1797 | + if (count($attachments) > 1) |
|
| 1799 | 1798 | { |
| 1800 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1801 | - $image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments))); |
|
| 1799 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1800 | + $image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments))); |
|
| 1802 | 1801 | } |
| 1803 | 1802 | |
| 1804 | 1803 | $attachmentFlag = $image; |
| 1805 | 1804 | } else { |
| 1806 | - $attachmentFlag =' '; |
|
| 1805 | + $attachmentFlag = ' '; |
|
| 1807 | 1806 | } |
| 1808 | 1807 | // show priority flag |
| 1809 | 1808 | if ($header['priority'] < 3) { |
| 1810 | - $image = Api\Html::image('mail','prio_high'); |
|
| 1809 | + $image = Api\Html::image('mail', 'prio_high'); |
|
| 1811 | 1810 | } elseif ($header['priority'] > 3) { |
| 1812 | - $image = Api\Html::image('mail','prio_low'); |
|
| 1811 | + $image = Api\Html::image('mail', 'prio_low'); |
|
| 1813 | 1812 | } else { |
| 1814 | 1813 | $image = ''; |
| 1815 | 1814 | } |
| 1816 | 1815 | // show a flag for flagged messages |
| 1817 | - $imageflagged =''; |
|
| 1816 | + $imageflagged = ''; |
|
| 1818 | 1817 | if ($header['flagged']) |
| 1819 | 1818 | { |
| 1820 | - $imageflagged = Api\Html::image('mail','unread_flagged_small'); |
|
| 1819 | + $imageflagged = Api\Html::image('mail', 'unread_flagged_small'); |
|
| 1821 | 1820 | } |
| 1822 | 1821 | $data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available |
| 1823 | 1822 | } |
@@ -1826,7 +1825,7 @@ discard block |
||
| 1826 | 1825 | if (in_array("toaddress", $cols)) |
| 1827 | 1826 | { |
| 1828 | 1827 | // sent or drafts or template folder means foldertype > 0, use to address instead of from |
| 1829 | - $data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset); |
|
| 1828 | + $data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset); |
|
| 1830 | 1829 | } |
| 1831 | 1830 | |
| 1832 | 1831 | if (in_array("additionaltoaddress", $cols)) |
@@ -1859,29 +1858,29 @@ discard block |
||
| 1859 | 1858 | $data['flags'] = Array(); |
| 1860 | 1859 | if ($header['seen']) $data["flags"]['read'] = 'read'; |
| 1861 | 1860 | foreach ($css_styles as &$flag) { |
| 1862 | - if ($flag!='mail') |
|
| 1861 | + if ($flag != 'mail') |
|
| 1863 | 1862 | { |
| 1864 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 1865 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 1866 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 1867 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 1868 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 1869 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 1863 | + if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; } |
|
| 1864 | + elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; } |
|
| 1865 | + elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; } |
|
| 1866 | + elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; } |
|
| 1867 | + elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; } |
|
| 1868 | + elseif ($flag == 'unseen') {unset($data["flags"]['read']); } |
|
| 1870 | 1869 | else $data["flags"][$flag] = $flag; |
| 1871 | 1870 | } |
| 1872 | 1871 | } |
| 1873 | 1872 | if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
| 1874 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1873 | + if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1875 | 1874 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 1876 | - $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
|
| 1877 | - if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
|
| 1875 | + $data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]); |
|
| 1876 | + if (in_array("bodypreview", $cols) && $header['bodypreview']) |
|
| 1878 | 1877 | { |
| 1879 | 1878 | $data["bodypreview"] = $header['bodypreview']; |
| 1880 | 1879 | } |
| 1881 | 1880 | $rv[] = $data; |
| 1882 | 1881 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 1883 | 1882 | } |
| 1884 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 1883 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__); |
|
| 1885 | 1884 | |
| 1886 | 1885 | // ToDo: call this ONLY if labels change |
| 1887 | 1886 | Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -1896,8 +1895,8 @@ discard block |
||
| 1896 | 1895 | */ |
| 1897 | 1896 | function displayHeader() |
| 1898 | 1897 | { |
| 1899 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1900 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1898 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1899 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1901 | 1900 | |
| 1902 | 1901 | $hA = self::splitRowID($rowID); |
| 1903 | 1902 | $uid = $hA['msgUID']; |
@@ -1911,17 +1910,17 @@ discard block |
||
| 1911 | 1910 | } |
| 1912 | 1911 | |
| 1913 | 1912 | $this->mail_bo->reopen($mailbox); |
| 1914 | - $headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 1913 | + $headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 1915 | 1914 | |
| 1916 | 1915 | // add line breaks to $rawheaders |
| 1917 | - $newRawHeaders = explode("\n",$headers_in); |
|
| 1916 | + $newRawHeaders = explode("\n", $headers_in); |
|
| 1918 | 1917 | reset($newRawHeaders); |
| 1919 | 1918 | |
| 1920 | 1919 | // reset $rawheaders |
| 1921 | - $rawheaders = ""; |
|
| 1920 | + $rawheaders = ""; |
|
| 1922 | 1921 | // create it new, with good line breaks |
| 1923 | 1922 | reset($newRawHeaders); |
| 1924 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 1923 | + while (list($key, $value) = @each($newRawHeaders)) { |
|
| 1925 | 1924 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 1926 | 1925 | } |
| 1927 | 1926 | |
@@ -1933,7 +1932,7 @@ discard block |
||
| 1933 | 1932 | } |
| 1934 | 1933 | |
| 1935 | 1934 | header('Content-type: text/html; charset=iso-8859-1'); |
| 1936 | - print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>'; |
|
| 1935 | + print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>'; |
|
| 1937 | 1936 | |
| 1938 | 1937 | } |
| 1939 | 1938 | |
@@ -1946,10 +1945,10 @@ discard block |
||
| 1946 | 1945 | { |
| 1947 | 1946 | if (is_null($_requesteddata)) $_requesteddata = $_GET; |
| 1948 | 1947 | |
| 1949 | - $preventRedirect=false; |
|
| 1950 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1951 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 1952 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 1948 | + $preventRedirect = false; |
|
| 1949 | + if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1950 | + if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null; |
|
| 1951 | + if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false); |
|
| 1953 | 1952 | |
| 1954 | 1953 | $hA = self::splitRowID($rowID); |
| 1955 | 1954 | $uid = $hA['msgUID']; |
@@ -1973,79 +1972,79 @@ discard block |
||
| 1973 | 1972 | } |
| 1974 | 1973 | if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox))) |
| 1975 | 1974 | { |
| 1976 | - Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft')); |
|
| 1975 | + Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft')); |
|
| 1977 | 1976 | } |
| 1978 | 1977 | $this->mail_bo->reopen($mailbox); |
| 1979 | 1978 | // retrieve the flags of the message, before touching it. |
| 1980 | 1979 | try |
| 1981 | 1980 | { |
| 1982 | - $headers = $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox); |
|
| 1981 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox); |
|
| 1983 | 1982 | } |
| 1984 | 1983 | catch (Api\Exception $e) |
| 1985 | 1984 | { |
| 1986 | 1985 | $error_msg[] = lang("ERROR: Message could not be displayed."); |
| 1987 | - $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
|
| 1986 | + $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID); |
|
| 1988 | 1987 | Framework::message($e->getMessage(), 'error'); |
| 1989 | 1988 | } |
| 1990 | 1989 | if (!empty($uid)) $this->mail_bo->getFlags($uid); |
| 1991 | - $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
|
| 1990 | + $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox); |
|
| 1992 | 1991 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 1993 | - $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
|
| 1992 | + $this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox); |
|
| 1994 | 1993 | $fetchEmbeddedImages = false; |
| 1995 | 1994 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 1996 | 1995 | // we do NOT want to see those, that are embedded in the list of attachments |
| 1997 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 1998 | - $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
|
| 1996 | + if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true; |
|
| 1997 | + $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 1999 | 1998 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 2000 | 1999 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
| 2001 | 2000 | |
| 2002 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 2003 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 2004 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 2001 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 2002 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 2003 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 2005 | 2004 | |
| 2006 | 2005 | //error_log(__METHOD__.__LINE__.$mailBody); |
| 2007 | 2006 | $this->mail_bo->closeConnection(); |
| 2008 | 2007 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 2009 | 2008 | $etpl = new Etemplate('mail.display'); |
| 2010 | - $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
|
| 2009 | + $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false); |
|
| 2011 | 2010 | |
| 2012 | 2011 | // Set up data for taglist widget(s) |
| 2013 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2012 | + if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2014 | 2013 | $sel_options = array(); |
| 2015 | - foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
|
| 2014 | + foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field) |
|
| 2016 | 2015 | { |
| 2017 | 2016 | if (!isset($envelope[$field])) continue; |
| 2018 | - foreach($envelope[$field] as $field_data) |
|
| 2017 | + foreach ($envelope[$field] as $field_data) |
|
| 2019 | 2018 | { |
| 2020 | 2019 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
| 2021 | 2020 | $content[$field][] = $field_data; |
| 2022 | 2021 | $sel_options[$field][] = array( |
| 2023 | 2022 | // taglist requires these - not optional |
| 2024 | 2023 | 'id' => $field_data, |
| 2025 | - 'label' => str_replace('"',"'",$field_data), |
|
| 2024 | + 'label' => str_replace('"', "'", $field_data), |
|
| 2026 | 2025 | ); |
| 2027 | 2026 | } |
| 2028 | 2027 | } |
| 2029 | 2028 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 2030 | 2029 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 2031 | 2030 | if (empty($subject)) $subject = lang('no subject'); |
| 2032 | - $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
|
| 2031 | + $content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg); |
|
| 2033 | 2032 | // Send mail ID so we can use it for actions |
| 2034 | 2033 | $content['mail_id'] = $rowID; |
| 2035 | 2034 | if (!is_array($headers) || !isset($headers['DATE'])) |
| 2036 | 2035 | { |
| 2037 | - $headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:''); |
|
| 2036 | + $headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : ''); |
|
| 2038 | 2037 | } |
| 2039 | - $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true); |
|
| 2038 | + $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true); |
|
| 2040 | 2039 | $content['mail_displaysubject'] = $subject; |
| 2041 | - $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
|
| 2042 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 2043 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 2044 | - $content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData); |
|
| 2040 | + $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID); |
|
| 2041 | + if (!empty($partID)) $linkData['_partID'] = $partID; |
|
| 2042 | + if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions; |
|
| 2043 | + $content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData); |
|
| 2045 | 2044 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 2046 | - $content['mail_id']=$rowID; |
|
| 2047 | - $content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 2048 | - $content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone"); |
|
| 2045 | + $content['mail_id'] = $rowID; |
|
| 2046 | + $content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 2047 | + $content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone"); |
|
| 2049 | 2048 | |
| 2050 | 2049 | // DRAG attachments actions |
| 2051 | 2050 | $etpl->setElementAttribute('mail_displayattachments', 'actions', array( |
@@ -2062,22 +2061,22 @@ discard block |
||
| 2062 | 2061 | $this->changeProfile($rememberServerID); |
| 2063 | 2062 | } |
| 2064 | 2063 | |
| 2065 | - $etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2); |
|
| 2064 | + $etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 2066 | 2065 | } |
| 2067 | 2066 | |
| 2068 | 2067 | /** |
| 2069 | 2068 | * Build actions for display toolbar |
| 2070 | 2069 | */ |
| 2071 | - function getDisplayToolbarActions () |
|
| 2070 | + function getDisplayToolbarActions() |
|
| 2072 | 2071 | { |
| 2073 | 2072 | $actions = $this->get_toolbar_actions(); |
| 2074 | - $actions['mark']['children']['flagged']=array( |
|
| 2073 | + $actions['mark']['children']['flagged'] = array( |
|
| 2075 | 2074 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 2076 | 2075 | 'caption' => 'Flagged', |
| 2077 | 2076 | 'icon' => 'unread_flagged_small', |
| 2078 | 2077 | 'onExecute' => 'javaScript:app.mail.mail_flag', |
| 2079 | 2078 | ); |
| 2080 | - $actions['mark']['children']['unflagged']=array( |
|
| 2079 | + $actions['mark']['children']['unflagged'] = array( |
|
| 2081 | 2080 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 2082 | 2081 | 'caption' => 'Unflagged', |
| 2083 | 2082 | 'icon' => 'read_flagged_small', |
@@ -2089,9 +2088,9 @@ discard block |
||
| 2089 | 2088 | $compose = $actions['composeasnew']; |
| 2090 | 2089 | unset($actions['composeasnew']); |
| 2091 | 2090 | |
| 2092 | - $actions2 = array_reverse($actions,true); |
|
| 2093 | - $actions2['composeasnew']= $compose; |
|
| 2094 | - return array_reverse($actions2,true); |
|
| 2091 | + $actions2 = array_reverse($actions, true); |
|
| 2092 | + $actions2['composeasnew'] = $compose; |
|
| 2093 | + return array_reverse($actions2, true); |
|
| 2095 | 2094 | } |
| 2096 | 2095 | |
| 2097 | 2096 | /** |
@@ -2104,22 +2103,22 @@ discard block |
||
| 2104 | 2103 | * @param boolean $_returnFullHTML flag wether to return HTML or data array |
| 2105 | 2104 | * @return array|string data array or html or empty string |
| 2106 | 2105 | */ |
| 2107 | - static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false) |
|
| 2106 | + static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false) |
|
| 2108 | 2107 | { |
| 2109 | - $attachmentHTMLBlock=''; |
|
| 2108 | + $attachmentHTMLBlock = ''; |
|
| 2110 | 2109 | $attachmentHTML = array(); |
| 2111 | 2110 | if (is_array($attachments) && count($attachments) > 0) { |
| 2112 | - $url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
|
| 2113 | - $url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all')); |
|
| 2111 | + $url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"'); |
|
| 2112 | + $url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all')); |
|
| 2114 | 2113 | |
| 2115 | 2114 | foreach ($attachments as $key => $value) |
| 2116 | 2115 | { |
| 2117 | - $attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)')); |
|
| 2118 | - $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
|
| 2116 | + $attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)')); |
|
| 2117 | + $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8'); |
|
| 2119 | 2118 | //error_log(array2string($value)); |
| 2120 | 2119 | //error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename'])); |
| 2121 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2122 | - $attachmentHTML[$key]['type']=$value['mimeType']; |
|
| 2120 | + if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2121 | + $attachmentHTML[$key]['type'] = $value['mimeType']; |
|
| 2123 | 2122 | $attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']); |
| 2124 | 2123 | $hA = self::splitRowID($rowID); |
| 2125 | 2124 | $uid = $hA['msgUID']; |
@@ -2129,26 +2128,25 @@ discard block |
||
| 2129 | 2128 | $attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array( |
| 2130 | 2129 | $acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true |
| 2131 | 2130 | )); |
| 2132 | - $attachmentHTML[$key]['size']=Vfs::hsize($value['size']); |
|
| 2133 | - $attachmentHTML[$key]['attachment_number']=$key; |
|
| 2134 | - $attachmentHTML[$key]['partID']=$value['partID']; |
|
| 2131 | + $attachmentHTML[$key]['size'] = Vfs::hsize($value['size']); |
|
| 2132 | + $attachmentHTML[$key]['attachment_number'] = $key; |
|
| 2133 | + $attachmentHTML[$key]['partID'] = $value['partID']; |
|
| 2135 | 2134 | $attachmentHTML[$key]['mail_id'] = $rowID; |
| 2136 | - $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; |
|
| 2135 | + $attachmentHTML[$key]['winmailFlag'] = $value['is_winmail']; |
|
| 2137 | 2136 | $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; |
| 2138 | 2137 | |
| 2139 | - switch(strtoupper($value['mimeType'])) |
|
| 2138 | + switch (strtoupper($value['mimeType'])) |
|
| 2140 | 2139 | { |
| 2141 | 2140 | case 'MESSAGE/RFC822': |
| 2142 | - $linkData = array |
|
| 2143 | - ( |
|
| 2141 | + $linkData = array( |
|
| 2144 | 2142 | 'menuaction' => 'mail.mail_ui.displayMessage', |
| 2145 | 2143 | 'mode' => 'display', //message/rfc822 attachments should be opened in display mode |
| 2146 | 2144 | 'id' => $rowID, |
| 2147 | 2145 | 'part' => $value['partID'], |
| 2148 | 2146 | 'is_winmail' => $value['is_winmail'] |
| 2149 | 2147 | ); |
| 2150 | - $windowName = 'displayMessage_'. $rowID.'_'.$value['partID']; |
|
| 2151 | - $linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2148 | + $windowName = 'displayMessage_'.$rowID.'_'.$value['partID']; |
|
| 2149 | + $linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2152 | 2150 | break; |
| 2153 | 2151 | case 'IMAGE/JPEG': |
| 2154 | 2152 | case 'IMAGE/PNG': |
@@ -2159,7 +2157,7 @@ discard block |
||
| 2159 | 2157 | case 'TEXT/HTML': |
| 2160 | 2158 | case 'TEXT/DIRECTORY': |
| 2161 | 2159 | $sfxMimeType = $value['mimeType']; |
| 2162 | - $buff = explode('.',$value['name']); |
|
| 2160 | + $buff = explode('.', $value['name']); |
|
| 2163 | 2161 | $suffix = ''; |
| 2164 | 2162 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2165 | 2163 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2172,49 +2170,47 @@ discard block |
||
| 2172 | 2170 | case 'TEXT/VCARD': |
| 2173 | 2171 | case 'TEXT/CALENDAR': |
| 2174 | 2172 | case 'TEXT/X-VCALENDAR': |
| 2175 | - $linkData = array |
|
| 2176 | - ( |
|
| 2173 | + $linkData = array( |
|
| 2177 | 2174 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2178 | 2175 | 'id' => $rowID, |
| 2179 | 2176 | 'part' => $value['partID'], |
| 2180 | 2177 | 'is_winmail' => $value['is_winmail'], |
| 2181 | 2178 | 'mailbox' => base64_encode($mailbox), |
| 2182 | 2179 | ); |
| 2183 | - $windowName = 'displayAttachment_'. $uid; |
|
| 2180 | + $windowName = 'displayAttachment_'.$uid; |
|
| 2184 | 2181 | $reg = '800x600'; |
| 2185 | 2182 | // handle calendar/vcard |
| 2186 | - if (strtoupper($value['mimeType'])=='TEXT/CALENDAR') |
|
| 2183 | + if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR') |
|
| 2187 | 2184 | { |
| 2188 | - $windowName = 'displayEvent_'. $rowID; |
|
| 2189 | - $reg2 = Link::get_registry('calendar','view_popup'); |
|
| 2190 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2185 | + $windowName = 'displayEvent_'.$rowID; |
|
| 2186 | + $reg2 = Link::get_registry('calendar', 'view_popup'); |
|
| 2187 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2191 | 2188 | } |
| 2192 | - if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD') |
|
| 2189 | + if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD') |
|
| 2193 | 2190 | { |
| 2194 | - $windowName = 'displayContact_'. $rowID; |
|
| 2195 | - $reg2 = Link::get_registry('addressbook','add_popup'); |
|
| 2196 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2191 | + $windowName = 'displayContact_'.$rowID; |
|
| 2192 | + $reg2 = Link::get_registry('addressbook', 'add_popup'); |
|
| 2193 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2197 | 2194 | } |
| 2198 | 2195 | // apply to action |
| 2199 | - list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg)); |
|
| 2200 | - $linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);"; |
|
| 2196 | + list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg)); |
|
| 2197 | + $linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);"; |
|
| 2201 | 2198 | break; |
| 2202 | 2199 | default: |
| 2203 | - $linkData = array |
|
| 2204 | - ( |
|
| 2200 | + $linkData = array( |
|
| 2205 | 2201 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2206 | 2202 | 'id' => $rowID, |
| 2207 | 2203 | 'part' => $value['partID'], |
| 2208 | 2204 | 'is_winmail' => $value['is_winmail'], |
| 2209 | 2205 | 'mailbox' => base64_encode($mailbox), |
| 2210 | 2206 | ); |
| 2211 | - $linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';"; |
|
| 2207 | + $linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';"; |
|
| 2212 | 2208 | break; |
| 2213 | 2209 | } |
| 2214 | 2210 | // we either use mime_data for server-side supported mime-types or mime_url for client-side or download |
| 2215 | 2211 | if (empty($attachmentHTML[$key]['mime_data'])) |
| 2216 | 2212 | { |
| 2217 | - $attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData); |
|
| 2213 | + $attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData); |
|
| 2218 | 2214 | unset($attachmentHTML[$key]['mime_data']); |
| 2219 | 2215 | } |
| 2220 | 2216 | $attachmentHTML[$key]['windowName'] = $windowName; |
@@ -2224,8 +2220,7 @@ discard block |
||
| 2224 | 2220 | ($value['name'] ? $value['name'] : lang('(no subject)')). |
| 2225 | 2221 | '</b></a>'; |
| 2226 | 2222 | |
| 2227 | - $linkData = array |
|
| 2228 | - ( |
|
| 2223 | + $linkData = array( |
|
| 2229 | 2224 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2230 | 2225 | 'mode' => 'save', |
| 2231 | 2226 | 'id' => $rowID, |
@@ -2233,11 +2228,11 @@ discard block |
||
| 2233 | 2228 | 'is_winmail' => $value['is_winmail'], |
| 2234 | 2229 | 'mailbox' => base64_encode($mailbox), |
| 2235 | 2230 | ); |
| 2236 | - $attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>"; |
|
| 2231 | + $attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>"; |
|
| 2237 | 2232 | |
| 2238 | 2233 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 2239 | 2234 | { |
| 2240 | - $link_vfs_save = Egw::link('/index.php',array( |
|
| 2235 | + $link_vfs_save = Egw::link('/index.php', array( |
|
| 2241 | 2236 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2242 | 2237 | 'mode' => 'saveas', |
| 2243 | 2238 | 'name' => $value['name'], |
@@ -2256,19 +2251,19 @@ discard block |
||
| 2256 | 2251 | //$rowID |
| 2257 | 2252 | $ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name']; |
| 2258 | 2253 | } |
| 2259 | - $link_vfs_save = Egw::link('/index.php',array( |
|
| 2254 | + $link_vfs_save = Egw::link('/index.php', array( |
|
| 2260 | 2255 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2261 | 2256 | 'mode' => 'select-dir', |
| 2262 | 2257 | 'method' => 'mail.mail_ui.vfsSaveAttachment', |
| 2263 | 2258 | 'label' => lang('Save all'), |
| 2264 | - )+$ids); |
|
| 2259 | + ) + $ids); |
|
| 2265 | 2260 | $vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>"; |
| 2266 | 2261 | } |
| 2267 | 2262 | $attachmentHTML[$key]['link_save'] .= $vfs_save; |
| 2268 | 2263 | //error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']); |
| 2269 | 2264 | } |
| 2270 | 2265 | } |
| 2271 | - $attachmentHTMLBlock="<table width='100%'>"; |
|
| 2266 | + $attachmentHTMLBlock = "<table width='100%'>"; |
|
| 2272 | 2267 | foreach ((array)$attachmentHTML as $row) |
| 2273 | 2268 | { |
| 2274 | 2269 | $attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>'; |
@@ -2286,7 +2281,7 @@ discard block |
||
| 2286 | 2281 | unset($attachmentHTML[$ikey]['link_save']); |
| 2287 | 2282 | } |
| 2288 | 2283 | } |
| 2289 | - return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML); |
|
| 2284 | + return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML); |
|
| 2290 | 2285 | } |
| 2291 | 2286 | |
| 2292 | 2287 | /** |
@@ -2297,7 +2292,7 @@ discard block |
||
| 2297 | 2292 | */ |
| 2298 | 2293 | function gatherVacation($cachedVacations = array()) |
| 2299 | 2294 | { |
| 2300 | - $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host); |
|
| 2295 | + $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host); |
|
| 2301 | 2296 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 2302 | 2297 | |
| 2303 | 2298 | if ($isVacationEnabled) |
@@ -2310,7 +2305,7 @@ discard block |
||
| 2310 | 2305 | |
| 2311 | 2306 | $cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations; |
| 2312 | 2307 | // Set vacation to the instance cache for particular account with expiration of one day |
| 2313 | - Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24); |
|
| 2308 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24); |
|
| 2314 | 2309 | } |
| 2315 | 2310 | catch (PEAR_Exception $ex) |
| 2316 | 2311 | { |
@@ -2331,36 +2326,36 @@ discard block |
||
| 2331 | 2326 | function quotaDisplay($_usage, $_limit) |
| 2332 | 2327 | { |
| 2333 | 2328 | |
| 2334 | - if($_limit == 0) { |
|
| 2335 | - $quotaPercent=100; |
|
| 2329 | + if ($_limit == 0) { |
|
| 2330 | + $quotaPercent = 100; |
|
| 2336 | 2331 | } else { |
| 2337 | - $quotaPercent=round(($_usage*100)/$_limit); |
|
| 2332 | + $quotaPercent = round(($_usage * 100) / $_limit); |
|
| 2338 | 2333 | } |
| 2339 | 2334 | |
| 2340 | - $quotaLimit=Mail::show_readable_size($_limit*1024); |
|
| 2341 | - $quotaUsage=Mail::show_readable_size($_usage*1024); |
|
| 2335 | + $quotaLimit = Mail::show_readable_size($_limit * 1024); |
|
| 2336 | + $quotaUsage = Mail::show_readable_size($_usage * 1024); |
|
| 2342 | 2337 | |
| 2343 | 2338 | |
| 2344 | - if($quotaPercent > 90 && $_limit>0) { |
|
| 2345 | - $quotaBG='mail-index_QuotaRed'; |
|
| 2346 | - } elseif($quotaPercent > 80 && $_limit>0) { |
|
| 2347 | - $quotaBG='mail-index_QuotaYellow'; |
|
| 2339 | + if ($quotaPercent > 90 && $_limit > 0) { |
|
| 2340 | + $quotaBG = 'mail-index_QuotaRed'; |
|
| 2341 | + } elseif ($quotaPercent > 80 && $_limit > 0) { |
|
| 2342 | + $quotaBG = 'mail-index_QuotaYellow'; |
|
| 2348 | 2343 | } else { |
| 2349 | - $quotaBG='mail-index_QuotaGreen'; |
|
| 2344 | + $quotaBG = 'mail-index_QuotaGreen'; |
|
| 2350 | 2345 | } |
| 2351 | 2346 | |
| 2352 | - if($_limit > 0) { |
|
| 2353 | - $quotaText = $quotaUsage .'/'.$quotaLimit; |
|
| 2347 | + if ($_limit > 0) { |
|
| 2348 | + $quotaText = $quotaUsage.'/'.$quotaLimit; |
|
| 2354 | 2349 | } else { |
| 2355 | 2350 | $quotaText = $quotaUsage; |
| 2356 | 2351 | } |
| 2357 | 2352 | |
| 2358 | - if($quotaPercent > 50) { |
|
| 2353 | + if ($quotaPercent > 50) { |
|
| 2359 | 2354 | } else { |
| 2360 | 2355 | } |
| 2361 | 2356 | $quota['class'] = $quotaBG; |
| 2362 | - $quota['text'] = lang('Quota: %1',$quotaText); |
|
| 2363 | - $quota['percent'] = (string)round(($_usage*100)/$_limit); |
|
| 2357 | + $quota['text'] = lang('Quota: %1', $quotaText); |
|
| 2358 | + $quota['percent'] = (string)round(($_usage * 100) / $_limit); |
|
| 2364 | 2359 | return $quota; |
| 2365 | 2360 | } |
| 2366 | 2361 | |
@@ -2374,12 +2369,12 @@ discard block |
||
| 2374 | 2369 | $uid = $_GET['uid']; |
| 2375 | 2370 | $cid = base64_decode($_GET['cid']); |
| 2376 | 2371 | $partID = urldecode($_GET['partID']); |
| 2377 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2372 | + if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2378 | 2373 | |
| 2379 | 2374 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2380 | 2375 | $this->mail_bo->reopen($mailbox); |
| 2381 | 2376 | |
| 2382 | - $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2377 | + $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2383 | 2378 | |
| 2384 | 2379 | $this->mail_bo->closeConnection(); |
| 2385 | 2380 | |
@@ -2387,8 +2382,8 @@ discard block |
||
| 2387 | 2382 | |
| 2388 | 2383 | if ($attachment) |
| 2389 | 2384 | { |
| 2390 | - header("Content-Type: ". $attachment->getType()); |
|
| 2391 | - header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"'); |
|
| 2385 | + header("Content-Type: ".$attachment->getType()); |
|
| 2386 | + header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"'); |
|
| 2392 | 2387 | //header("Expires: 0"); |
| 2393 | 2388 | // the next headers are for IE and SSL |
| 2394 | 2389 | //header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
@@ -2406,7 +2401,7 @@ discard block |
||
| 2406 | 2401 | |
| 2407 | 2402 | function getAttachment() |
| 2408 | 2403 | { |
| 2409 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2404 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2410 | 2405 | |
| 2411 | 2406 | $hA = self::splitRowID($rowID); |
| 2412 | 2407 | $uid = $hA['msgUID']; |
@@ -2418,11 +2413,11 @@ discard block |
||
| 2418 | 2413 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2419 | 2414 | $this->changeProfile($icServerID); |
| 2420 | 2415 | } |
| 2421 | - $part = $_GET['part']; |
|
| 2416 | + $part = $_GET['part']; |
|
| 2422 | 2417 | $is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0; |
| 2423 | 2418 | |
| 2424 | 2419 | $this->mail_bo->reopen($mailbox); |
| 2425 | - $attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false); |
|
| 2420 | + $attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false); |
|
| 2426 | 2421 | $this->mail_bo->closeConnection(); |
| 2427 | 2422 | if ($rememberServerID != $this->mail_bo->profileID) |
| 2428 | 2423 | { |
@@ -2437,7 +2432,7 @@ discard block |
||
| 2437 | 2432 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type'])) |
| 2438 | 2433 | { |
| 2439 | 2434 | $sfxMimeType = $attachment['type']; |
| 2440 | - $buff = explode('.',$attachment['filename']); |
|
| 2435 | + $buff = explode('.', $attachment['filename']); |
|
| 2441 | 2436 | $suffix = ''; |
| 2442 | 2437 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2443 | 2438 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2449,10 +2444,10 @@ discard block |
||
| 2449 | 2444 | { |
| 2450 | 2445 | //error_log(__METHOD__."about to call calendar_ical"); |
| 2451 | 2446 | $calendar_ical = new calendar_ical(); |
| 2452 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
| 2447 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
| 2453 | 2448 | //error_log(__METHOD__.array2string($eventid)); |
| 2454 | 2449 | if (!$eventid) $eventid = -1; |
| 2455 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
|
| 2450 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']); |
|
| 2456 | 2451 | //error_log(__METHOD__.$event); |
| 2457 | 2452 | if ((int)$event > 0) |
| 2458 | 2453 | { |
@@ -2460,7 +2455,7 @@ discard block |
||
| 2460 | 2455 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 2461 | 2456 | 'cal_id' => $event, |
| 2462 | 2457 | ); |
| 2463 | - Egw::redirect_link('../index.php',$vars); |
|
| 2458 | + Egw::redirect_link('../index.php', $vars); |
|
| 2464 | 2459 | } |
| 2465 | 2460 | //Import failed, download content anyway |
| 2466 | 2461 | } |
@@ -2475,13 +2470,13 @@ discard block |
||
| 2475 | 2470 | { |
| 2476 | 2471 | $vcard['uid'] = trim($vcard['uid']); |
| 2477 | 2472 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2478 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 2473 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
| 2479 | 2474 | } |
| 2480 | 2475 | if (!$contact) $contact = null; |
| 2481 | 2476 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
| 2482 | - if ($contact || count($vcard)>2) |
|
| 2477 | + if ($contact || count($vcard) > 2) |
|
| 2483 | 2478 | { |
| 2484 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']); |
|
| 2479 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']); |
|
| 2485 | 2480 | } |
| 2486 | 2481 | if ((int)$contact > 0) |
| 2487 | 2482 | { |
@@ -2489,14 +2484,14 @@ discard block |
||
| 2489 | 2484 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
| 2490 | 2485 | 'contact_id' => $contact, |
| 2491 | 2486 | ); |
| 2492 | - Egw::redirect_link('../index.php',$vars); |
|
| 2487 | + Egw::redirect_link('../index.php', $vars); |
|
| 2493 | 2488 | } |
| 2494 | 2489 | //Import failed, download content anyway |
| 2495 | 2490 | } |
| 2496 | 2491 | } |
| 2497 | 2492 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
| 2498 | - $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2499 | - Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save"); |
|
| 2493 | + $filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2494 | + Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save"); |
|
| 2500 | 2495 | echo $attachment['attachment']; |
| 2501 | 2496 | |
| 2502 | 2497 | exit(); |
@@ -2511,9 +2506,9 @@ discard block |
||
| 2511 | 2506 | function saveMessage() |
| 2512 | 2507 | { |
| 2513 | 2508 | $display = false; |
| 2514 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2515 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2516 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 2509 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2510 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2511 | + if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location']; |
|
| 2517 | 2512 | |
| 2518 | 2513 | $hA = self::splitRowID($rowID); |
| 2519 | 2514 | $uid = $hA['msgUID']; |
@@ -2541,14 +2536,14 @@ discard block |
||
| 2541 | 2536 | if (!$display) |
| 2542 | 2537 | { |
| 2543 | 2538 | $headers = Horde_Mime_Headers::parseHeaders($message); |
| 2544 | - $subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT'])); |
|
| 2545 | - Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true); |
|
| 2539 | + $subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT'])); |
|
| 2540 | + Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true); |
|
| 2546 | 2541 | echo $message; |
| 2547 | 2542 | } |
| 2548 | 2543 | else |
| 2549 | 2544 | { |
| 2550 | - Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false); |
|
| 2551 | - print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>'; |
|
| 2545 | + Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false); |
|
| 2546 | + print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>'; |
|
| 2552 | 2547 | } |
| 2553 | 2548 | } |
| 2554 | 2549 | |
@@ -2560,18 +2555,18 @@ discard block |
||
| 2560 | 2555 | * @param boolean $close Return javascript to close the window |
| 2561 | 2556 | * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false |
| 2562 | 2557 | */ |
| 2563 | - function vfsSaveMessage($ids,$path, $close = true) |
|
| 2558 | + function vfsSaveMessage($ids, $path, $close = true) |
|
| 2564 | 2559 | { |
| 2565 | 2560 | //error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path); |
| 2566 | 2561 | |
| 2567 | 2562 | if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path))) |
| 2568 | 2563 | { |
| 2569 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();'; |
|
| 2564 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();'; |
|
| 2570 | 2565 | } |
| 2571 | 2566 | Api\Translation::add_app('mail'); |
| 2572 | 2567 | |
| 2573 | 2568 | $rememberServerID = $this->mail_bo->profileID; |
| 2574 | - foreach((array)$ids as $id) |
|
| 2569 | + foreach ((array)$ids as $id) |
|
| 2575 | 2570 | { |
| 2576 | 2571 | $hA = self::splitRowID($id); |
| 2577 | 2572 | $uid = $hA['msgUID']; |
@@ -2582,20 +2577,20 @@ discard block |
||
| 2582 | 2577 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2583 | 2578 | $this->changeProfile($icServerID); |
| 2584 | 2579 | } |
| 2585 | - $message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox); |
|
| 2586 | - $err=null; |
|
| 2587 | - if(Vfs::is_dir($path)) |
|
| 2580 | + $message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox); |
|
| 2581 | + $err = null; |
|
| 2582 | + if (Vfs::is_dir($path)) |
|
| 2588 | 2583 | { |
| 2589 | - $headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox); |
|
| 2590 | - $file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml'; |
|
| 2584 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox); |
|
| 2585 | + $file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml'; |
|
| 2591 | 2586 | } |
| 2592 | 2587 | else |
| 2593 | 2588 | { |
| 2594 | 2589 | $file = $path; |
| 2595 | 2590 | } |
| 2596 | - if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message)) |
|
| 2591 | + if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message)) |
|
| 2597 | 2592 | { |
| 2598 | - $err .= lang('Error saving %1!',$file); |
|
| 2593 | + $err .= lang('Error saving %1!', $file); |
|
| 2599 | 2594 | $succeeded = false; |
| 2600 | 2595 | } |
| 2601 | 2596 | else |
@@ -2605,10 +2600,10 @@ discard block |
||
| 2605 | 2600 | if ($fp) fclose($fp); |
| 2606 | 2601 | if ($succeeded) |
| 2607 | 2602 | { |
| 2608 | - unset($headers['SUBJECT']);//already in filename |
|
| 2603 | + unset($headers['SUBJECT']); //already in filename |
|
| 2609 | 2604 | $infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false); |
| 2610 | - $props = array(array('name' => 'comment','val' => $infoSection)); |
|
| 2611 | - Vfs::proppatch($file,$props); |
|
| 2605 | + $props = array(array('name' => 'comment', 'val' => $infoSection)); |
|
| 2606 | + Vfs::proppatch($file, $props); |
|
| 2612 | 2607 | } |
| 2613 | 2608 | } |
| 2614 | 2609 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2617,9 +2612,9 @@ discard block |
||
| 2617 | 2612 | $this->changeProfile($rememberServerID); |
| 2618 | 2613 | } |
| 2619 | 2614 | |
| 2620 | - if($close) |
|
| 2615 | + if ($close) |
|
| 2621 | 2616 | { |
| 2622 | - Framework::window_close(($err?$err:null)); |
|
| 2617 | + Framework::window_close(($err ? $err : null)); |
|
| 2623 | 2618 | } |
| 2624 | 2619 | else |
| 2625 | 2620 | { |
@@ -2634,15 +2629,15 @@ discard block |
||
| 2634 | 2629 | * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array) |
| 2635 | 2630 | * @return string javascript eg. to close the selector window |
| 2636 | 2631 | */ |
| 2637 | - function vfsSaveAttachment($ids,$path) |
|
| 2632 | + function vfsSaveAttachment($ids, $path) |
|
| 2638 | 2633 | { |
| 2639 | 2634 | //error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');"); |
| 2640 | 2635 | |
| 2641 | 2636 | if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path))) |
| 2642 | 2637 | { |
| 2643 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();'; |
|
| 2638 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();'; |
|
| 2644 | 2639 | } |
| 2645 | - $err=null; |
|
| 2640 | + $err = null; |
|
| 2646 | 2641 | $dupe_count = array(); |
| 2647 | 2642 | $rememberServerID = $this->mail_bo->profileID; |
| 2648 | 2643 | |
@@ -2652,12 +2647,12 @@ discard block |
||
| 2652 | 2647 | * |
| 2653 | 2648 | * @return array an array of parameters |
| 2654 | 2649 | */ |
| 2655 | - $getParams = function ($id) { |
|
| 2656 | - list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
|
| 2657 | - $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
|
| 2650 | + $getParams = function($id) { |
|
| 2651 | + list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8); |
|
| 2652 | + $lId = implode('::', array($app, $user, $serverID, $mailbox, $uid)); |
|
| 2658 | 2653 | $hA = mail_ui::splitRowID($lId); |
| 2659 | 2654 | return array( |
| 2660 | - 'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail, |
|
| 2655 | + 'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail, |
|
| 2661 | 2656 | 'user' => $user, |
| 2662 | 2657 | 'name' => $name, |
| 2663 | 2658 | 'part' => $part, |
@@ -2669,8 +2664,8 @@ discard block |
||
| 2669 | 2664 | |
| 2670 | 2665 | //Examine the first attachment to see if attachment |
| 2671 | 2666 | //is winmail.dat embedded attachments. |
| 2672 | - $isMultipleDownload=is_array($ids); |
|
| 2673 | - $p = $getParams((is_array($ids)?$ids[0]:$ids)); |
|
| 2667 | + $isMultipleDownload = is_array($ids); |
|
| 2668 | + $p = $getParams((is_array($ids) ? $ids[0] : $ids)); |
|
| 2674 | 2669 | if ($p['is_winmail']) |
| 2675 | 2670 | { |
| 2676 | 2671 | if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID) |
@@ -2681,14 +2676,14 @@ discard block |
||
| 2681 | 2676 | // Retrive all embedded attachments at once |
| 2682 | 2677 | // avoids to fetch heavy winmail.dat content |
| 2683 | 2678 | // for each file. |
| 2684 | - $attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']); |
|
| 2679 | + $attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']); |
|
| 2685 | 2680 | } |
| 2686 | 2681 | |
| 2687 | - foreach((array)$ids as $id) |
|
| 2682 | + foreach ((array)$ids as $id) |
|
| 2688 | 2683 | { |
| 2689 | 2684 | $params = $getParams($id); |
| 2690 | 2685 | // when downloading a single file, name is not set |
| 2691 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2686 | + if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2692 | 2687 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2693 | 2688 | { |
| 2694 | 2689 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2706,25 +2701,25 @@ discard block |
||
| 2706 | 2701 | } |
| 2707 | 2702 | else |
| 2708 | 2703 | { |
| 2709 | - $attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false); |
|
| 2704 | + $attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false); |
|
| 2710 | 2705 | } |
| 2711 | 2706 | |
| 2712 | 2707 | $file = $params['name']; |
| 2713 | 2708 | // when $isMultipleDownload the path holds no filename |
| 2714 | - while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2709 | + while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2715 | 2710 | { |
| 2716 | 2711 | $dupe_count[$params['name']]++; |
| 2717 | - $file = pathinfo($params['name'], PATHINFO_FILENAME) . |
|
| 2718 | - ' ('.($dupe_count[$params['name']] + 1).')' . '.' . |
|
| 2712 | + $file = pathinfo($params['name'], PATHINFO_FILENAME). |
|
| 2713 | + ' ('.($dupe_count[$params['name']] + 1).')'.'.'. |
|
| 2719 | 2714 | pathinfo($params['name'], PATHINFO_EXTENSION); |
| 2720 | 2715 | } |
| 2721 | 2716 | $params['name'] = $file; |
| 2722 | 2717 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2723 | 2718 | // when $isMultipleDownload the path holds no filename |
| 2724 | - if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) || |
|
| 2725 | - !fwrite($fp,$attachment['attachment'])) |
|
| 2719 | + if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) || |
|
| 2720 | + !fwrite($fp, $attachment['attachment'])) |
|
| 2726 | 2721 | { |
| 2727 | - $err .= lang('Error saving %1!',$file); |
|
| 2722 | + $err .= lang('Error saving %1!', $file); |
|
| 2728 | 2723 | } |
| 2729 | 2724 | if ($fp) |
| 2730 | 2725 | { |
@@ -2737,21 +2732,21 @@ discard block |
||
| 2737 | 2732 | //error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID); |
| 2738 | 2733 | $this->changeProfile($rememberServerID); |
| 2739 | 2734 | } |
| 2740 | - Framework::window_close(($err?$err:null)); |
|
| 2735 | + Framework::window_close(($err ? $err : null)); |
|
| 2741 | 2736 | } |
| 2742 | 2737 | |
| 2743 | 2738 | /** |
| 2744 | 2739 | * Zip all attachments and send to user |
| 2745 | 2740 | * @param string $message_id = null |
| 2746 | 2741 | */ |
| 2747 | - function download_zip($message_id=null) |
|
| 2742 | + function download_zip($message_id = null) |
|
| 2748 | 2743 | { |
| 2749 | 2744 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2750 | 2745 | // First, get all attachment IDs |
| 2751 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2746 | + if (isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2752 | 2747 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2753 | 2748 | $rememberServerID = $this->mail_bo->profileID; |
| 2754 | - if(!is_numeric($message_id)) |
|
| 2749 | + if (!is_numeric($message_id)) |
|
| 2755 | 2750 | { |
| 2756 | 2751 | $hA = self::splitRowID($message_id); |
| 2757 | 2752 | $message_id = $hA['msgUID']; |
@@ -2769,30 +2764,30 @@ discard block |
||
| 2769 | 2764 | } |
| 2770 | 2765 | // always fetch all, even inline (images) |
| 2771 | 2766 | $fetchEmbeddedImages = true; |
| 2772 | - $attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2767 | + $attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2773 | 2768 | // put them in VFS so they can be zipped |
| 2774 | - $header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox); |
|
| 2769 | + $header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox); |
|
| 2775 | 2770 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2776 | 2771 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2777 | - $temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id"; |
|
| 2778 | - if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path); |
|
| 2772 | + $temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id"; |
|
| 2773 | + if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path); |
|
| 2779 | 2774 | |
| 2780 | 2775 | // Add subject to path, so it gets used as the file name |
| 2781 | - $path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/'; |
|
| 2782 | - if(!Vfs::mkdir($path, 0700, true)) |
|
| 2776 | + $path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/'; |
|
| 2777 | + if (!Vfs::mkdir($path, 0700, true)) |
|
| 2783 | 2778 | { |
| 2784 | - Framework::message("Unable to open temp directory $path",'error'); |
|
| 2779 | + Framework::message("Unable to open temp directory $path", 'error'); |
|
| 2785 | 2780 | return; |
| 2786 | 2781 | } |
| 2787 | 2782 | |
| 2788 | 2783 | $file_list = array(); |
| 2789 | 2784 | $dupe_count = array(); |
| 2790 | 2785 | $this->mail_bo->reopen($mailbox); |
| 2791 | - if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null') |
|
| 2786 | + if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null') |
|
| 2792 | 2787 | { |
| 2793 | - $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true); |
|
| 2788 | + $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true); |
|
| 2794 | 2789 | } |
| 2795 | - foreach($attachments as $file) |
|
| 2790 | + foreach ($attachments as $file) |
|
| 2796 | 2791 | { |
| 2797 | 2792 | if ($file['is_winmail']) |
| 2798 | 2793 | { |
@@ -2805,22 +2800,22 @@ discard block |
||
| 2805 | 2800 | } |
| 2806 | 2801 | else |
| 2807 | 2802 | { |
| 2808 | - $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
|
| 2803 | + $attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true); |
|
| 2809 | 2804 | } |
| 2810 | - $success=true; |
|
| 2805 | + $success = true; |
|
| 2811 | 2806 | if (empty($file['filename'])) $file['filename'] = $file['name']; |
| 2812 | - if(in_array($path.$file['filename'], $file_list)) |
|
| 2807 | + if (in_array($path.$file['filename'], $file_list)) |
|
| 2813 | 2808 | { |
| 2814 | 2809 | $dupe_count[$path.$file['filename']]++; |
| 2815 | - $file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) . |
|
| 2816 | - ' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' . |
|
| 2810 | + $file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME). |
|
| 2811 | + ' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'. |
|
| 2817 | 2812 | pathinfo($file['filename'], PATHINFO_EXTENSION); |
| 2818 | 2813 | } |
| 2819 | - if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) || |
|
| 2814 | + if (!($fp = Vfs::fopen($path.$file['filename'], 'wb')) || |
|
| 2820 | 2815 | !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp))) |
| 2821 | 2816 | { |
| 2822 | - $success=false; |
|
| 2823 | - Framework::message("Unable to zip {$file['filename']}",'error'); |
|
| 2817 | + $success = false; |
|
| 2818 | + Framework::message("Unable to zip {$file['filename']}", 'error'); |
|
| 2824 | 2819 | } |
| 2825 | 2820 | if ($success) $file_list[] = $path.$file['filename']; |
| 2826 | 2821 | if ($fp) fclose($fp); |
@@ -2841,7 +2836,7 @@ discard block |
||
| 2841 | 2836 | exit(); |
| 2842 | 2837 | } |
| 2843 | 2838 | |
| 2844 | - function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null) |
|
| 2839 | + function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null) |
|
| 2845 | 2840 | { |
| 2846 | 2841 | // seems to be needed, as if we open a mail from notification popup that is |
| 2847 | 2842 | // located in a different folder, we experience: could not parse message |
@@ -2853,19 +2848,19 @@ discard block |
||
| 2853 | 2848 | if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions; |
| 2854 | 2849 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 2855 | 2850 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 2856 | - $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox); |
|
| 2851 | + $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox); |
|
| 2857 | 2852 | |
| 2858 | 2853 | //error_log(__METHOD__.__LINE__.array2string($bodyParts)); |
| 2859 | 2854 | // attachments here are only fetched to determine if there is a meeting request |
| 2860 | 2855 | // and if. use the appropriate action. so we do not need embedded images |
| 2861 | 2856 | $fetchEmbeddedImages = false; |
| 2862 | - $attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2857 | + $attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2863 | 2858 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 2864 | 2859 | foreach ($attachments as &$attach) |
| 2865 | 2860 | { |
| 2866 | 2861 | if (strtolower($attach['mimeType']) == 'text/calendar' && |
| 2867 | 2862 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 2868 | - ($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true)))) |
|
| 2863 | + ($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'], $attach['is_winmail'], (strtolower($attach['mimeType']) == 'text/calendar' ? false : true)))) |
|
| 2869 | 2864 | { |
| 2870 | 2865 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2871 | 2866 | Api\Cache::setSession('calendar', 'ical', array( |
@@ -2876,28 +2871,28 @@ discard block |
||
| 2876 | 2871 | )); |
| 2877 | 2872 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 2878 | 2873 | Api\Translation::add_app('calendar'); |
| 2879 | - return ExecMethod( 'calendar.calendar_uiforms.meeting', |
|
| 2880 | - array('event'=>null,'msg'=>'','useSession'=>true) |
|
| 2874 | + return ExecMethod('calendar.calendar_uiforms.meeting', |
|
| 2875 | + array('event'=>null, 'msg'=>'', 'useSession'=>true) |
|
| 2881 | 2876 | ); |
| 2882 | 2877 | } |
| 2883 | 2878 | } |
| 2884 | 2879 | // Compose the content of the frame |
| 2885 | 2880 | $frameHtml = |
| 2886 | 2881 | $this->get_email_header($this->mail_bo->getStyles($bodyParts)). |
| 2887 | - $this->showBody($this->getdisplayableBody($bodyParts,true,false), false); |
|
| 2882 | + $this->showBody($this->getdisplayableBody($bodyParts, true, false), false); |
|
| 2888 | 2883 | //IE10 eats away linebreaks preceeded by a whitespace in PRE sections |
| 2889 | - $frameHtml = str_replace(" \r\n","\r\n",$frameHtml); |
|
| 2884 | + $frameHtml = str_replace(" \r\n", "\r\n", $frameHtml); |
|
| 2890 | 2885 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 2891 | 2886 | |
| 2892 | 2887 | return $frameHtml; |
| 2893 | 2888 | } |
| 2894 | 2889 | |
| 2895 | - static function get_email_header($additionalStyle='') |
|
| 2890 | + static function get_email_header($additionalStyle = '') |
|
| 2896 | 2891 | { |
| 2897 | 2892 | // egw_info[flags][css] already include <style> tags |
| 2898 | 2893 | $GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle); |
| 2899 | - $GLOBALS['egw_info']['flags']['nofooter']=true; |
|
| 2900 | - $GLOBALS['egw_info']['flags']['nonavbar']=true; |
|
| 2894 | + $GLOBALS['egw_info']['flags']['nofooter'] = true; |
|
| 2895 | + $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
|
| 2901 | 2896 | // do NOT include any default CSS |
| 2902 | 2897 | Framework::includeCSS('mail', 'preview', true, true); |
| 2903 | 2898 | |
@@ -2908,35 +2903,35 @@ discard block |
||
| 2908 | 2903 | return $GLOBALS['egw']->framework->header(); |
| 2909 | 2904 | } |
| 2910 | 2905 | |
| 2911 | - function showBody(&$body, $print=true,$fullPageTags=true) |
|
| 2906 | + function showBody(&$body, $print = true, $fullPageTags = true) |
|
| 2912 | 2907 | { |
| 2913 | 2908 | $BeginBody = '<div class="mailDisplayBody"> |
| 2914 | 2909 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 2915 | 2910 | |
| 2916 | 2911 | $EndBody = '</td></tr></table></div>'; |
| 2917 | 2912 | if ($fullPageTags) $EndBody .= "</body></html>"; |
| 2918 | - if ($print) { |
|
| 2919 | - print $BeginBody. $body .$EndBody; |
|
| 2913 | + if ($print) { |
|
| 2914 | + print $BeginBody.$body.$EndBody; |
|
| 2920 | 2915 | } else { |
| 2921 | - return $BeginBody. $body .$EndBody; |
|
| 2916 | + return $BeginBody.$body.$EndBody; |
|
| 2922 | 2917 | } |
| 2923 | 2918 | } |
| 2924 | 2919 | |
| 2925 | - function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true) |
|
| 2920 | + function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true) |
|
| 2926 | 2921 | { |
| 2927 | - $bodyParts = $_bodyParts; |
|
| 2922 | + $bodyParts = $_bodyParts; |
|
| 2928 | 2923 | |
| 2929 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 2930 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 2931 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 2924 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 2925 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 2926 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 2932 | 2927 | |
| 2933 | 2928 | $body = ''; |
| 2934 | 2929 | |
| 2935 | 2930 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 2936 | 2931 | if (empty($bodyParts)) return ""; |
| 2937 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 2932 | + foreach ((array)$bodyParts as $singleBodyPart) { |
|
| 2938 | 2933 | if (!isset($singleBodyPart['body'])) { |
| 2939 | - $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
|
| 2934 | + $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy); |
|
| 2940 | 2935 | $body .= $singleBodyPart['body']; |
| 2941 | 2936 | continue; |
| 2942 | 2937 | } |
@@ -2946,7 +2941,7 @@ discard block |
||
| 2946 | 2941 | $body .= ''; |
| 2947 | 2942 | continue; |
| 2948 | 2943 | } |
| 2949 | - if(!empty($body)) { |
|
| 2944 | + if (!empty($body)) { |
|
| 2950 | 2945 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 2951 | 2946 | } |
| 2952 | 2947 | //error_log($singleBodyPart['body']); |
@@ -2971,28 +2966,28 @@ discard block |
||
| 2971 | 2966 | '(R)', |
| 2972 | 2967 | ); |
| 2973 | 2968 | |
| 2974 | - if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 2969 | + if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 2975 | 2970 | strtoupper($singleBodyPart['charSet']) != 'UTF-8') |
| 2976 | 2971 | { |
| 2977 | - $singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']); |
|
| 2972 | + $singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']); |
|
| 2978 | 2973 | } |
| 2979 | 2974 | //error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']); |
| 2980 | - if ($singleBodyPart['charSet']=='us-ascii') |
|
| 2975 | + if ($singleBodyPart['charSet'] == 'us-ascii') |
|
| 2981 | 2976 | { |
| 2982 | - $orgCharSet=$singleBodyPart['charSet']; |
|
| 2977 | + $orgCharSet = $singleBodyPart['charSet']; |
|
| 2983 | 2978 | $singleBodyPart['charSet'] = Api\Translation::detect_encoding($singleBodyPart['body']); |
| 2984 | 2979 | error_log(__METHOD__.__LINE__.'reports:'.$orgCharSet.' but seems to be:'.$singleBodyPart['charSet']); |
| 2985 | 2980 | } |
| 2986 | - $singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']); |
|
| 2981 | + $singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']); |
|
| 2987 | 2982 | //error_log(__METHOD__.__LINE__.array2string($singleBodyPart)); |
| 2988 | - if($singleBodyPart['mimeType'] == 'text/plain') |
|
| 2983 | + if ($singleBodyPart['mimeType'] == 'text/plain') |
|
| 2989 | 2984 | { |
| 2990 | - $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2985 | + $newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2991 | 2986 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2992 | 2987 | // if empty and charset is utf8 try sanitizing the string in question |
| 2993 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2988 | + if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2994 | 2989 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 2995 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 2990 | + if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES); |
|
| 2996 | 2991 | |
| 2997 | 2992 | // search http[s] links and make them as links available again |
| 2998 | 2993 | // to understand what's going on here, have a look at |
@@ -3020,20 +3015,20 @@ discard block |
||
| 3020 | 3015 | // since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility). |
| 3021 | 3016 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 3022 | 3017 | // dont break lines that start with > (> as the text was processed with htmlentities before) |
| 3023 | - $newBody = "<pre>".Mail::wordwrap($newBody,90,"\n",'>')."</pre>"; |
|
| 3018 | + $newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '>')."</pre>"; |
|
| 3024 | 3019 | } |
| 3025 | 3020 | else |
| 3026 | 3021 | { |
| 3027 | - $alreadyHtmlLawed=false; |
|
| 3028 | - $newBody = $singleBodyPart['body']; |
|
| 3022 | + $alreadyHtmlLawed = false; |
|
| 3023 | + $newBody = $singleBodyPart['body']; |
|
| 3029 | 3024 | //TODO:$newBody = $this->highlightQuotes($newBody); |
| 3030 | 3025 | #error_log(print_r($newBody,true)); |
| 3031 | 3026 | if ($useTidy && extension_loaded('tidy')) |
| 3032 | 3027 | { |
| 3033 | 3028 | $tidy = new tidy(); |
| 3034 | - $cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8'); |
|
| 3029 | + $cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8'); |
|
| 3035 | 3030 | // Found errors. Strip it all so there's some output |
| 3036 | - if($tidy->getStatus() == 2) |
|
| 3031 | + if ($tidy->getStatus() == 2) |
|
| 3037 | 3032 | { |
| 3038 | 3033 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 3039 | 3034 | } |
@@ -3044,7 +3039,7 @@ discard block |
||
| 3044 | 3039 | if (!$preserveHTML) // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
| 3045 | 3040 | { |
| 3046 | 3041 | // filter only the 'body', as we only want that part, if we throw away the Api\Html |
| 3047 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 3042 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 3048 | 3043 | if ($matches[2]) |
| 3049 | 3044 | { |
| 3050 | 3045 | $hasOther = true; |
@@ -3055,7 +3050,7 @@ discard block |
||
| 3055 | 3050 | else |
| 3056 | 3051 | { |
| 3057 | 3052 | // htmLawed filter only the 'body' |
| 3058 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 3053 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 3059 | 3054 | if ($matches[2]) |
| 3060 | 3055 | { |
| 3061 | 3056 | $hasOther = true; |
@@ -3064,10 +3059,10 @@ discard block |
||
| 3064 | 3059 | $htmLawed = new Api\Html\HtmLawed(); |
| 3065 | 3060 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 3066 | 3061 | // as we switched off HTMLaweds tidy functionality |
| 3067 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 3068 | - $newBody = $htmLawed->run($newBody,Mail::$htmLawed_config); |
|
| 3069 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3070 | - $alreadyHtmlLawed=true; |
|
| 3062 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 3063 | + $newBody = $htmLawed->run($newBody, Mail::$htmLawed_config); |
|
| 3064 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 3065 | + $alreadyHtmlLawed = true; |
|
| 3071 | 3066 | } |
| 3072 | 3067 | // do the cleanup, set for the use of purifier |
| 3073 | 3068 | //$newBodyBuff = $newBody; |
@@ -3089,8 +3084,8 @@ discard block |
||
| 3089 | 3084 | } |
| 3090 | 3085 | */ |
| 3091 | 3086 | // removes stuff between http and ?http |
| 3092 | - $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 3093 | - $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http:// |
|
| 3087 | + $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 3088 | + $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http:// |
|
| 3094 | 3089 | // TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK |
| 3095 | 3090 | $newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i', |
| 3096 | 3091 | "\\1@\\2.\\3", |
@@ -3103,7 +3098,7 @@ discard block |
||
| 3103 | 3098 | // create links for inline images |
| 3104 | 3099 | if ($modifyURI) |
| 3105 | 3100 | { |
| 3106 | - $newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 3101 | + $newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 3107 | 3102 | } |
| 3108 | 3103 | // email addresses / mailto links get now activated on client-side |
| 3109 | 3104 | } |
@@ -3115,7 +3110,7 @@ discard block |
||
| 3115 | 3110 | $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i", |
| 3116 | 3111 | "<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body); |
| 3117 | 3112 | |
| 3118 | - $body = preg_replace($nonDisplayAbleCharacters,'',$body); |
|
| 3113 | + $body = preg_replace($nonDisplayAbleCharacters, '', $body); |
|
| 3119 | 3114 | |
| 3120 | 3115 | return $body; |
| 3121 | 3116 | } |
@@ -3130,7 +3125,7 @@ discard block |
||
| 3130 | 3125 | * @param string $_messageType = 'html', message type is either html or plain |
| 3131 | 3126 | * @return string message body including all CID images replaced |
| 3132 | 3127 | */ |
| 3133 | - public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 3128 | + public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 3134 | 3129 | { |
| 3135 | 3130 | if ($_messageType === 'plain') |
| 3136 | 3131 | { |
@@ -3138,7 +3133,7 @@ discard block |
||
| 3138 | 3133 | } |
| 3139 | 3134 | else |
| 3140 | 3135 | { |
| 3141 | - foreach(array('src','url','background') as $type) |
|
| 3136 | + foreach (array('src', 'url', 'background') as $type) |
|
| 3142 | 3137 | { |
| 3143 | 3138 | $_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type); |
| 3144 | 3139 | } |
@@ -3157,7 +3152,7 @@ discard block |
||
| 3157 | 3152 | * - types: {plain|src|url|background} |
| 3158 | 3153 | * @return string returns body content including all CID replacements |
| 3159 | 3154 | */ |
| 3160 | - public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src') |
|
| 3155 | + public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src') |
|
| 3161 | 3156 | { |
| 3162 | 3157 | /** |
| 3163 | 3158 | * Callback for preg_replace_callback function |
@@ -3169,7 +3164,7 @@ discard block |
||
| 3169 | 3164 | * @param string $_type |
| 3170 | 3165 | * @return string|boolean returns the replace |
| 3171 | 3166 | */ |
| 3172 | - $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
|
| 3167 | + $replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type) |
|
| 3173 | 3168 | { |
| 3174 | 3169 | if (!$_type) return false; |
| 3175 | 3170 | $CID = ''; |
@@ -3191,11 +3186,11 @@ discard block |
||
| 3191 | 3186 | break; |
| 3192 | 3187 | } |
| 3193 | 3188 | |
| 3194 | - static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3189 | + static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3195 | 3190 | |
| 3196 | 3191 | if (is_array($matches) && $CID) |
| 3197 | 3192 | { |
| 3198 | - $linkData = array ( |
|
| 3193 | + $linkData = array( |
|
| 3199 | 3194 | 'menuaction' => 'mail.mail_ui.displayImage', |
| 3200 | 3195 | 'uid' => $_uid, |
| 3201 | 3196 | 'mailbox' => base64_encode($_mailbox), |
@@ -3208,7 +3203,7 @@ discard block |
||
| 3208 | 3203 | { |
| 3209 | 3204 | if (!isset($cache[$imageURL])) |
| 3210 | 3205 | { |
| 3211 | - if ($_type !="background") |
|
| 3206 | + if ($_type != "background") |
|
| 3212 | 3207 | { |
| 3213 | 3208 | $bo = Mail::getInstance(false, mail_ui::$icServerID); |
| 3214 | 3209 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
@@ -3249,16 +3244,16 @@ discard block |
||
| 3249 | 3244 | }; |
| 3250 | 3245 | |
| 3251 | 3246 | // return new body content base on chosen type |
| 3252 | - switch($_type) |
|
| 3247 | + switch ($_type) |
|
| 3253 | 3248 | { |
| 3254 | 3249 | case"plain": |
| 3255 | - return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body); |
|
| 3250 | + return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body); |
|
| 3256 | 3251 | case "src": |
| 3257 | - return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3252 | + return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3258 | 3253 | case "url": |
| 3259 | - return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body); |
|
| 3254 | + return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body); |
|
| 3260 | 3255 | case "background": |
| 3261 | - return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3256 | + return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3262 | 3257 | } |
| 3263 | 3258 | } |
| 3264 | 3259 | |
@@ -3266,7 +3261,7 @@ discard block |
||
| 3266 | 3261 | * importMessage |
| 3267 | 3262 | * @param array $content = null an array of content |
| 3268 | 3263 | */ |
| 3269 | - function importMessage($content=null) |
|
| 3264 | + function importMessage($content = null) |
|
| 3270 | 3265 | { |
| 3271 | 3266 | //error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder()); |
| 3272 | 3267 | |
@@ -3288,7 +3283,7 @@ discard block |
||
| 3288 | 3283 | } |
| 3289 | 3284 | $destination = $content['FOLDER'][0]; |
| 3290 | 3285 | |
| 3291 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3286 | + if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2); |
|
| 3292 | 3287 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3293 | 3288 | { |
| 3294 | 3289 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3299,32 +3294,31 @@ discard block |
||
| 3299 | 3294 | $importFailed = false; |
| 3300 | 3295 | try |
| 3301 | 3296 | { |
| 3302 | - $messageUid = $this->importMessageToFolder($file,$destination,$importID); |
|
| 3303 | - $linkData = array |
|
| 3304 | - ( |
|
| 3297 | + $messageUid = $this->importMessageToFolder($file, $destination, $importID); |
|
| 3298 | + $linkData = array( |
|
| 3305 | 3299 | 'id' => $this->createRowID($destination, $messageUid, true), |
| 3306 | 3300 | ); |
| 3307 | 3301 | } |
| 3308 | 3302 | catch (Api\Exception\WrongUserinput $e) |
| 3309 | 3303 | { |
| 3310 | - $importFailed=true; |
|
| 3311 | - $content['msg'] = $e->getMessage(); |
|
| 3304 | + $importFailed = true; |
|
| 3305 | + $content['msg'] = $e->getMessage(); |
|
| 3312 | 3306 | } |
| 3313 | 3307 | if (!$importFailed) |
| 3314 | 3308 | { |
| 3315 | 3309 | list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup')); |
| 3316 | 3310 | if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height); |
| 3317 | - ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
|
| 3311 | + ExecMethod2('mail.mail_ui.displayMessage', $linkData); |
|
| 3318 | 3312 | return; |
| 3319 | 3313 | } |
| 3320 | 3314 | } |
| 3321 | 3315 | if (!is_array($content)) $content = array(); |
| 3322 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3323 | - if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3316 | + if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder(); |
|
| 3317 | + if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true); |
|
| 3324 | 3318 | |
| 3325 | 3319 | $etpl = new Etemplate('mail.importMessage'); |
| 3326 | - $etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport'); |
|
| 3327 | - $etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2); |
|
| 3320 | + $etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport'); |
|
| 3321 | + $etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2); |
|
| 3328 | 3322 | } |
| 3329 | 3323 | |
| 3330 | 3324 | /** |
@@ -3336,7 +3330,7 @@ discard block |
||
| 3336 | 3330 | * @param string $importID ID for the imported message, used by attachments to identify them unambiguously |
| 3337 | 3331 | * @return mixed $messageUID or exception |
| 3338 | 3332 | */ |
| 3339 | - function importMessageToFolder($_formData,&$_folder,$importID='') |
|
| 3333 | + function importMessageToFolder($_formData, &$_folder, $importID = '') |
|
| 3340 | 3334 | { |
| 3341 | 3335 | $importfailed = false; |
| 3342 | 3336 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
@@ -3344,7 +3338,7 @@ discard block |
||
| 3344 | 3338 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3345 | 3339 | try |
| 3346 | 3340 | { |
| 3347 | - $tmpFileName = Mail::checkFileBasics($_formData,$importID); |
|
| 3341 | + $tmpFileName = Mail::checkFileBasics($_formData, $importID); |
|
| 3348 | 3342 | } |
| 3349 | 3343 | catch (Api\Exception\WrongUserinput $e) |
| 3350 | 3344 | { |
@@ -3368,29 +3362,29 @@ discard block |
||
| 3368 | 3362 | if (empty($_folder)) |
| 3369 | 3363 | { |
| 3370 | 3364 | $importfailed = true; |
| 3371 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
|
| 3365 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']); |
|
| 3372 | 3366 | } |
| 3373 | 3367 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3374 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3368 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 3375 | 3369 | if ($importfailed === false) |
| 3376 | 3370 | { |
| 3377 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3371 | + if ($this->mail_bo->folderExists($_folder, true)) { |
|
| 3378 | 3372 | try |
| 3379 | 3373 | { |
| 3380 | 3374 | $messageUid = $this->mail_bo->appendMessage($_folder, |
| 3381 | 3375 | $mailObject->getRaw(), |
| 3382 | - null,'\\Seen'); |
|
| 3376 | + null, '\\Seen'); |
|
| 3383 | 3377 | } |
| 3384 | 3378 | catch (Api\Exception\WrongUserinput $e) |
| 3385 | 3379 | { |
| 3386 | 3380 | $importfailed = true; |
| 3387 | - $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage()); |
|
| 3381 | + $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage()); |
|
| 3388 | 3382 | } |
| 3389 | 3383 | } |
| 3390 | 3384 | else |
| 3391 | 3385 | { |
| 3392 | 3386 | $importfailed = true; |
| 3393 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder); |
|
| 3387 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder); |
|
| 3394 | 3388 | } |
| 3395 | 3389 | } |
| 3396 | 3390 | } |
@@ -3416,9 +3410,9 @@ discard block |
||
| 3416 | 3410 | * $formData['size'] = 2136; |
| 3417 | 3411 | * @return void |
| 3418 | 3412 | */ |
| 3419 | - function importMessageFromVFS2DraftAndEdit($formData='') |
|
| 3413 | + function importMessageFromVFS2DraftAndEdit($formData = '') |
|
| 3420 | 3414 | { |
| 3421 | - $this->importMessageFromVFS2DraftAndDisplay($formData,'edit'); |
|
| 3415 | + $this->importMessageFromVFS2DraftAndDisplay($formData, 'edit'); |
|
| 3422 | 3416 | } |
| 3423 | 3417 | |
| 3424 | 3418 | /** |
@@ -3433,7 +3427,7 @@ discard block |
||
| 3433 | 3427 | * @param string $mode mode to open ImportedMessage display and edit are supported |
| 3434 | 3428 | * @return void |
| 3435 | 3429 | */ |
| 3436 | - function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
|
| 3430 | + function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display') |
|
| 3437 | 3431 | { |
| 3438 | 3432 | if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
| 3439 | 3433 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
@@ -3446,43 +3440,42 @@ discard block |
||
| 3446 | 3440 | $formData['file'] = 'egw-data://'.$formData['data']; |
| 3447 | 3441 | } |
| 3448 | 3442 | // name should be set to meet the requirements of checkFileBasics |
| 3449 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3443 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3450 | 3444 | { |
| 3451 | - $buff = explode('/',$formData['file']); |
|
| 3445 | + $buff = explode('/', $formData['file']); |
|
| 3452 | 3446 | if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
| 3453 | 3447 | } |
| 3454 | 3448 | // type should be set to meet the requirements of checkFileBasics |
| 3455 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3449 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3456 | 3450 | { |
| 3457 | - $buff = explode('.',$formData['file']); |
|
| 3451 | + $buff = explode('.', $formData['file']); |
|
| 3458 | 3452 | $suffix = ''; |
| 3459 | 3453 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 3460 | 3454 | if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
| 3461 | 3455 | } |
| 3462 | 3456 | // size should be set to meet the requirements of checkFileBasics |
| 3463 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3457 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3464 | 3458 | { |
| 3465 | 3459 | $formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics |
| 3466 | 3460 | } |
| 3467 | 3461 | try |
| 3468 | 3462 | { |
| 3469 | - $messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID); |
|
| 3470 | - $linkData = array |
|
| 3471 | - ( |
|
| 3472 | - 'menuaction' => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'), |
|
| 3473 | - 'id' => $this->createRowID($draftFolder,$messageUid,true), |
|
| 3463 | + $messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID); |
|
| 3464 | + $linkData = array( |
|
| 3465 | + 'menuaction' => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'), |
|
| 3466 | + 'id' => $this->createRowID($draftFolder, $messageUid, true), |
|
| 3474 | 3467 | 'deleteDraftOnClose' => 1, |
| 3475 | 3468 | ); |
| 3476 | - if ($mode!='display') |
|
| 3469 | + if ($mode != 'display') |
|
| 3477 | 3470 | { |
| 3478 | 3471 | unset($linkData['deleteDraftOnClose']); |
| 3479 | - $linkData['method'] ='importMessageToMergeAndSend'; |
|
| 3472 | + $linkData['method'] = 'importMessageToMergeAndSend'; |
|
| 3480 | 3473 | } |
| 3481 | 3474 | else |
| 3482 | 3475 | { |
| 3483 | - $linkData['mode']=$mode; |
|
| 3476 | + $linkData['mode'] = $mode; |
|
| 3484 | 3477 | } |
| 3485 | - Egw::redirect_link('/index.php',$linkData); |
|
| 3478 | + Egw::redirect_link('/index.php', $linkData); |
|
| 3486 | 3479 | } |
| 3487 | 3480 | catch (Api\Exception\WrongUserinput $e) |
| 3488 | 3481 | { |
@@ -3497,13 +3490,13 @@ discard block |
||
| 3497 | 3490 | * |
| 3498 | 3491 | * @return xajax response |
| 3499 | 3492 | */ |
| 3500 | - function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
|
| 3493 | + function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null) |
|
| 3501 | 3494 | { |
| 3502 | 3495 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3503 | 3496 | if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
| 3504 | 3497 | if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
| 3505 | 3498 | if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
| 3506 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3499 | + if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions"); |
|
| 3507 | 3500 | if (empty($_messageID)) return ""; |
| 3508 | 3501 | $uidA = self::splitRowID($_messageID); |
| 3509 | 3502 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -3517,7 +3510,7 @@ discard block |
||
| 3517 | 3510 | $this->changeProfile($icServerID); |
| 3518 | 3511 | } |
| 3519 | 3512 | |
| 3520 | - $bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions); |
|
| 3513 | + $bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions); |
|
| 3521 | 3514 | Api\Session::cache_control(true); |
| 3522 | 3515 | //error_log(array2string($bodyResponse)); |
| 3523 | 3516 | echo $bodyResponse; |
@@ -3540,7 +3533,7 @@ discard block |
||
| 3540 | 3533 | $oA = array(); |
| 3541 | 3534 | foreach ($_folder as $_folderName) |
| 3542 | 3535 | { |
| 3543 | - list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
|
| 3536 | + list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2); |
|
| 3544 | 3537 | if (is_numeric($profileID)) |
| 3545 | 3538 | { |
| 3546 | 3539 | if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
@@ -3548,19 +3541,19 @@ discard block |
||
| 3548 | 3541 | { |
| 3549 | 3542 | try |
| 3550 | 3543 | { |
| 3551 | - $fS = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3544 | + $fS = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3552 | 3545 | } |
| 3553 | 3546 | catch (Exception $e) |
| 3554 | 3547 | { |
| 3555 | 3548 | continue; |
| 3556 | 3549 | } |
| 3557 | - if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3550 | + if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']); |
|
| 3558 | 3551 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3559 | 3552 | if ($fS['unseen']) |
| 3560 | 3553 | { |
| 3561 | 3554 | $oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
| 3562 | 3555 | } |
| 3563 | - if ($fS['unseen']==0 && $fS['shortDisplayName']) |
|
| 3556 | + if ($fS['unseen'] == 0 && $fS['shortDisplayName']) |
|
| 3564 | 3557 | { |
| 3565 | 3558 | $oA[$_folderName] = $fS['shortDisplayName']; |
| 3566 | 3559 | } |
@@ -3571,7 +3564,7 @@ discard block |
||
| 3571 | 3564 | if ($oA) |
| 3572 | 3565 | { |
| 3573 | 3566 | $response = Api\Json\Response::get(); |
| 3574 | - $response->call('app.mail.mail_setFolderStatus',$oA); |
|
| 3567 | + $response->call('app.mail.mail_setFolderStatus', $oA); |
|
| 3575 | 3568 | } |
| 3576 | 3569 | } |
| 3577 | 3570 | } |
@@ -3585,14 +3578,14 @@ discard block |
||
| 3585 | 3578 | function ajax_addFolder($_parentFolderName, $_newName) |
| 3586 | 3579 | { |
| 3587 | 3580 | //error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName)); |
| 3588 | - $errorMessage=''; |
|
| 3581 | + $errorMessage = ''; |
|
| 3589 | 3582 | if ($_parentFolderName) |
| 3590 | 3583 | { |
| 3591 | 3584 | $created = false; |
| 3592 | 3585 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName); |
| 3593 | 3586 | //the conversion is handeled by horde, frontend interaction is all utf-8 |
| 3594 | 3587 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3595 | - list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3588 | + list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3596 | 3589 | if (is_numeric($profileID)) |
| 3597 | 3590 | { |
| 3598 | 3591 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
@@ -3632,10 +3625,10 @@ discard block |
||
| 3632 | 3625 | |
| 3633 | 3626 | if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3634 | 3627 | */ |
| 3635 | - $nA = explode($del,$_newName); |
|
| 3628 | + $nA = explode($del, $_newName); |
|
| 3636 | 3629 | |
| 3637 | 3630 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3638 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 3631 | + if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false); |
|
| 3639 | 3632 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3640 | 3633 | |
| 3641 | 3634 | $this->mail_bo->reopen('INBOX'); |
@@ -3643,11 +3636,11 @@ discard block |
||
| 3643 | 3636 | // if newName has delimiter ($del) in it, we need to create the subtree |
| 3644 | 3637 | if (!empty($nA)) |
| 3645 | 3638 | { |
| 3646 | - $c=0; |
|
| 3647 | - foreach($nA as $sTName) |
|
| 3639 | + $c = 0; |
|
| 3640 | + foreach ($nA as $sTName) |
|
| 3648 | 3641 | { |
| 3649 | - $error=null; |
|
| 3650 | - if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3642 | + $error = null; |
|
| 3643 | + if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3651 | 3644 | { |
| 3652 | 3645 | $c++; |
| 3653 | 3646 | } |
@@ -3656,16 +3649,16 @@ discard block |
||
| 3656 | 3649 | $errorMessage .= $error; |
| 3657 | 3650 | } |
| 3658 | 3651 | } |
| 3659 | - if ($c==count($nA)) $created=true; |
|
| 3652 | + if ($c == count($nA)) $created = true; |
|
| 3660 | 3653 | } |
| 3661 | 3654 | if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
| 3662 | 3655 | } |
| 3663 | 3656 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3664 | - if ($created===true) |
|
| 3657 | + if ($created === true) |
|
| 3665 | 3658 | { |
| 3666 | 3659 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3667 | 3660 | $response = Api\Json\Response::get(); |
| 3668 | - if ( $oldFolderInfo['shortDisplayName']) |
|
| 3661 | + if ($oldFolderInfo['shortDisplayName']) |
|
| 3669 | 3662 | { |
| 3670 | 3663 | $nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']); |
| 3671 | 3664 | } |
@@ -3673,14 +3666,14 @@ discard block |
||
| 3673 | 3666 | { |
| 3674 | 3667 | $nodeInfo = array($profileID=>lang('INBOX')); |
| 3675 | 3668 | } |
| 3676 | - $response->call('app.mail.mail_reloadNode',$nodeInfo); |
|
| 3669 | + $response->call('app.mail.mail_reloadNode', $nodeInfo); |
|
| 3677 | 3670 | } |
| 3678 | 3671 | else |
| 3679 | 3672 | { |
| 3680 | 3673 | if ($errorMessage) |
| 3681 | 3674 | { |
| 3682 | 3675 | $response = Api\Json\Response::get(); |
| 3683 | - $response->call('egw.message',$errorMessage); |
|
| 3676 | + $response->call('egw.message', $errorMessage); |
|
| 3684 | 3677 | } |
| 3685 | 3678 | } |
| 3686 | 3679 | } |
@@ -3702,22 +3695,22 @@ discard block |
||
| 3702 | 3695 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3703 | 3696 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3704 | 3697 | $oA = array(); |
| 3705 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3698 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3706 | 3699 | $hasChildren = false; |
| 3707 | 3700 | if (is_numeric($profileID)) |
| 3708 | 3701 | { |
| 3709 | 3702 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3710 | - $pA = explode($del,$folderName); |
|
| 3703 | + $pA = explode($del, $folderName); |
|
| 3711 | 3704 | array_pop($pA); |
| 3712 | - $parentFolder = implode($del,$pA); |
|
| 3713 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 3705 | + $parentFolder = implode($del, $pA); |
|
| 3706 | + if (strtoupper($folderName) != 'INBOX') |
|
| 3714 | 3707 | { |
| 3715 | 3708 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3716 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false); |
|
| 3709 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false); |
|
| 3717 | 3710 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3718 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3711 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3719 | 3712 | { |
| 3720 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3713 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3721 | 3714 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3722 | 3715 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3723 | 3716 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3734,7 +3727,7 @@ discard block |
||
| 3734 | 3727 | else |
| 3735 | 3728 | { |
| 3736 | 3729 | $rv = $this->mail_bo->icServer->subscribeMailbox($folder, false); |
| 3737 | - $fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName)); |
|
| 3730 | + $fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName)); |
|
| 3738 | 3731 | } |
| 3739 | 3732 | } |
| 3740 | 3733 | //error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments)); |
@@ -3744,7 +3737,7 @@ discard block |
||
| 3744 | 3737 | $success = false; |
| 3745 | 3738 | try |
| 3746 | 3739 | { |
| 3747 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3740 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3748 | 3741 | { |
| 3749 | 3742 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3750 | 3743 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3755,11 +3748,11 @@ discard block |
||
| 3755 | 3748 | } |
| 3756 | 3749 | catch (Exception $e) |
| 3757 | 3750 | { |
| 3758 | - $newFolderName=$folderName; |
|
| 3751 | + $newFolderName = $folderName; |
|
| 3759 | 3752 | $msg = $e->getMessage(); |
| 3760 | 3753 | } |
| 3761 | 3754 | $this->mail_bo->reopen($newFolderName); |
| 3762 | - $fS = $this->mail_bo->getFolderStatus($newFolderName,false); |
|
| 3755 | + $fS = $this->mail_bo->getFolderStatus($newFolderName, false); |
|
| 3763 | 3756 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3764 | 3757 | if ($hasChildren) |
| 3765 | 3758 | { |
@@ -3790,12 +3783,12 @@ discard block |
||
| 3790 | 3783 | { |
| 3791 | 3784 | $oA[$_folderName]['desc'] = $fS['shortDisplayName']; |
| 3792 | 3785 | } |
| 3793 | - foreach($fragments as $oldFolderName => $fragment) |
|
| 3786 | + foreach ($fragments as $oldFolderName => $fragment) |
|
| 3794 | 3787 | { |
| 3795 | 3788 | //error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment); |
| 3796 | 3789 | $oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment; |
| 3797 | 3790 | $oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#'; |
| 3798 | - $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false); |
|
| 3791 | + $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false); |
|
| 3799 | 3792 | if ($fS['unseen']) |
| 3800 | 3793 | { |
| 3801 | 3794 | $oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
@@ -3808,20 +3801,20 @@ discard block |
||
| 3808 | 3801 | } |
| 3809 | 3802 | } |
| 3810 | 3803 | } |
| 3811 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 3804 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 3812 | 3805 | { |
| 3813 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 3806 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 3814 | 3807 | $this->mail_bo->saveSessionData(); |
| 3815 | 3808 | } |
| 3816 | 3809 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3817 | 3810 | $response = Api\Json\Response::get(); |
| 3818 | 3811 | if ($oA && $success) |
| 3819 | 3812 | { |
| 3820 | - $response->call('app.mail.mail_setLeaf',$oA); |
|
| 3813 | + $response->call('app.mail.mail_setLeaf', $oA); |
|
| 3821 | 3814 | } |
| 3822 | 3815 | else |
| 3823 | 3816 | { |
| 3824 | - $response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail'); |
|
| 3817 | + $response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail'); |
|
| 3825 | 3818 | } |
| 3826 | 3819 | } |
| 3827 | 3820 | } |
@@ -3833,7 +3826,7 @@ discard block |
||
| 3833 | 3826 | * @param boolean $_subscribedOnly = true |
| 3834 | 3827 | * @return void |
| 3835 | 3828 | */ |
| 3836 | - function ajax_reloadNode($_folderName,$_subscribedOnly=true) |
|
| 3829 | + function ajax_reloadNode($_folderName, $_subscribedOnly = true) |
|
| 3837 | 3830 | { |
| 3838 | 3831 | Api\Translation::add_app('mail'); |
| 3839 | 3832 | $oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']; |
@@ -3844,20 +3837,20 @@ discard block |
||
| 3844 | 3837 | |
| 3845 | 3838 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3846 | 3839 | $this->mail_bo->getHierarchyDelimiter(false); |
| 3847 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3840 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3848 | 3841 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
| 3849 | 3842 | // that we get what we request |
| 3850 | 3843 | if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID); |
| 3851 | 3844 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3852 | 3845 | if (!empty($folderName)) |
| 3853 | 3846 | { |
| 3854 | - $parentFolder=(!empty($folderName)?$folderName:'INBOX'); |
|
| 3855 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3847 | + $parentFolder = (!empty($folderName) ? $folderName : 'INBOX'); |
|
| 3848 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3856 | 3849 | if ($folderInfo['unseen']) |
| 3857 | 3850 | { |
| 3858 | 3851 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')'; |
| 3859 | 3852 | } |
| 3860 | - if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName']) |
|
| 3853 | + if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName']) |
|
| 3861 | 3854 | { |
| 3862 | 3855 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName']; |
| 3863 | 3856 | } |
@@ -3873,11 +3866,11 @@ discard block |
||
| 3873 | 3866 | } |
| 3874 | 3867 | // Send full info back in the response |
| 3875 | 3868 | $response = Api\Json\Response::get(); |
| 3876 | - foreach($refreshData as $folder => &$name) |
|
| 3869 | + foreach ($refreshData as $folder => &$name) |
|
| 3877 | 3870 | { |
| 3878 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true); |
|
| 3871 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true); |
|
| 3879 | 3872 | } |
| 3880 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 3873 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 3881 | 3874 | |
| 3882 | 3875 | } |
| 3883 | 3876 | |
@@ -3893,7 +3886,7 @@ discard block |
||
| 3893 | 3886 | * @param type $_rowid row id from nm |
| 3894 | 3887 | * |
| 3895 | 3888 | */ |
| 3896 | - function ajax_resolveWinmail ($_rowid) |
|
| 3889 | + function ajax_resolveWinmail($_rowid) |
|
| 3897 | 3890 | { |
| 3898 | 3891 | $response = Api\Json\Response::get(); |
| 3899 | 3892 | |
@@ -3901,7 +3894,7 @@ discard block |
||
| 3901 | 3894 | $uid = $idParts['msgUID']; |
| 3902 | 3895 | $mbox = $idParts['folder']; |
| 3903 | 3896 | |
| 3904 | - $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox); |
|
| 3897 | + $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox); |
|
| 3905 | 3898 | if (is_array($attachments)) |
| 3906 | 3899 | { |
| 3907 | 3900 | $attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false); |
@@ -3929,30 +3922,30 @@ discard block |
||
| 3929 | 3922 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3930 | 3923 | $_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target); |
| 3931 | 3924 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3932 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3933 | - list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2); |
|
| 3925 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3926 | + list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2); |
|
| 3934 | 3927 | $hasChildren = false; |
| 3935 | 3928 | if (is_numeric($profileID)) |
| 3936 | 3929 | { |
| 3937 | 3930 | if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection |
| 3938 | - $pA = explode($del,$folderName); |
|
| 3931 | + $pA = explode($del, $folderName); |
|
| 3939 | 3932 | $namePart = array_pop($pA); |
| 3940 | 3933 | $_newName = $namePart; |
| 3941 | - $oldParentFolder = implode($del,$pA); |
|
| 3934 | + $oldParentFolder = implode($del, $pA); |
|
| 3942 | 3935 | $parentFolder = $_newLocation; |
| 3943 | 3936 | |
| 3944 | - if (strtoupper($folderName)!= 'INBOX' && |
|
| 3937 | + if (strtoupper($folderName) != 'INBOX' && |
|
| 3945 | 3938 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 3946 | 3939 | (($oldParentFolder != $parentFolder && |
| 3947 | - strlen($parentFolder)>0 && strlen($folderName)>0 && |
|
| 3948 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 3940 | + strlen($parentFolder) > 0 && strlen($folderName) > 0 && |
|
| 3941 | + strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch |
|
| 3949 | 3942 | { |
| 3950 | 3943 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3951 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3944 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3952 | 3945 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3953 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3946 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3954 | 3947 | { |
| 3955 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3948 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3956 | 3949 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3957 | 3950 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3958 | 3951 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3977,7 +3970,7 @@ discard block |
||
| 3977 | 3970 | $success = false; |
| 3978 | 3971 | try |
| 3979 | 3972 | { |
| 3980 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3973 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3981 | 3974 | { |
| 3982 | 3975 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3983 | 3976 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3989,11 +3982,11 @@ discard block |
||
| 3989 | 3982 | } |
| 3990 | 3983 | catch (Exception $e) |
| 3991 | 3984 | { |
| 3992 | - $newFolderName=$folderName; |
|
| 3985 | + $newFolderName = $folderName; |
|
| 3993 | 3986 | $msg = $e->getMessage(); |
| 3994 | 3987 | } |
| 3995 | 3988 | $this->mail_bo->reopen($parentFolder); |
| 3996 | - $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3989 | + $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3997 | 3990 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3998 | 3991 | if ($hasChildren) |
| 3999 | 3992 | { |
@@ -4014,9 +4007,9 @@ discard block |
||
| 4014 | 4007 | } |
| 4015 | 4008 | } |
| 4016 | 4009 | } |
| 4017 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 4010 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 4018 | 4011 | { |
| 4019 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 4012 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 4020 | 4013 | $this->mail_bo->saveSessionData(); |
| 4021 | 4014 | } |
| 4022 | 4015 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
@@ -4025,26 +4018,26 @@ discard block |
||
| 4025 | 4018 | { |
| 4026 | 4019 | Api\Translation::add_app('mail'); |
| 4027 | 4020 | |
| 4028 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false); |
|
| 4029 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 4021 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false); |
|
| 4022 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 4030 | 4023 | $refreshData = array( |
| 4031 | 4024 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 4032 | 4025 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 4033 | 4026 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 4034 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4035 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4027 | + if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4028 | + if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4036 | 4029 | |
| 4037 | 4030 | // Send full info back in the response |
| 4038 | - foreach($refreshData as $folder => &$name) |
|
| 4031 | + foreach ($refreshData as $folder => &$name) |
|
| 4039 | 4032 | { |
| 4040 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true); |
|
| 4033 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true); |
|
| 4041 | 4034 | } |
| 4042 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4035 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4043 | 4036 | |
| 4044 | 4037 | } |
| 4045 | 4038 | else |
| 4046 | 4039 | { |
| 4047 | - $response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail'); |
|
| 4040 | + $response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail'); |
|
| 4048 | 4041 | } |
| 4049 | 4042 | } |
| 4050 | 4043 | } |
@@ -4064,23 +4057,23 @@ discard block |
||
| 4064 | 4057 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4065 | 4058 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 4066 | 4059 | $oA = array(); |
| 4067 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4060 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4068 | 4061 | $hasChildren = false; |
| 4069 | 4062 | if (is_numeric($profileID)) |
| 4070 | 4063 | { |
| 4071 | 4064 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 4072 | - $pA = explode($del,$folderName); |
|
| 4065 | + $pA = explode($del, $folderName); |
|
| 4073 | 4066 | array_pop($pA); |
| 4074 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 4067 | + if (strtoupper($folderName) != 'INBOX') |
|
| 4075 | 4068 | { |
| 4076 | 4069 | //error_log(__METHOD__.__LINE__."$folderName, implode($del,$pA), $_newName"); |
| 4077 | 4070 | $oA = array(); |
| 4078 | 4071 | $subFolders = array(); |
| 4079 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 4072 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 4080 | 4073 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 4081 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 4074 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 4082 | 4075 | { |
| 4083 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 4076 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 4084 | 4077 | $ftD = array(); |
| 4085 | 4078 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 4086 | 4079 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -4090,24 +4083,24 @@ discard block |
||
| 4090 | 4083 | //error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix"); |
| 4091 | 4084 | foreach ($subFolders as $k => $f) |
| 4092 | 4085 | { |
| 4093 | - $ftD[substr_count($f,$delimiter)][]=$f; |
|
| 4086 | + $ftD[substr_count($f, $delimiter)][] = $f; |
|
| 4094 | 4087 | } |
| 4095 | - krsort($ftD,SORT_NUMERIC);//sort per level |
|
| 4088 | + krsort($ftD, SORT_NUMERIC); //sort per level |
|
| 4096 | 4089 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 4097 | - foreach($ftD as $k => $lc)//collection per level |
|
| 4090 | + foreach ($ftD as $k => $lc)//collection per level |
|
| 4098 | 4091 | { |
| 4099 | - foreach($lc as $f)//folders contained in that level |
|
| 4092 | + foreach ($lc as $f)//folders contained in that level |
|
| 4100 | 4093 | { |
| 4101 | 4094 | try |
| 4102 | 4095 | { |
| 4103 | 4096 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 4104 | 4097 | $this->mail_bo->deleteFolder($f); |
| 4105 | 4098 | $success = true; |
| 4106 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4099 | + if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4107 | 4100 | } |
| 4108 | 4101 | catch (Exception $e) |
| 4109 | 4102 | { |
| 4110 | - $msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage(); |
|
| 4103 | + $msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage(); |
|
| 4111 | 4104 | $success = false; |
| 4112 | 4105 | } |
| 4113 | 4106 | } |
@@ -4138,11 +4131,11 @@ discard block |
||
| 4138 | 4131 | if ($success) |
| 4139 | 4132 | { |
| 4140 | 4133 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 4141 | - $response->call('app.mail.mail_removeLeaf',$oA); |
|
| 4134 | + $response->call('app.mail.mail_removeLeaf', $oA); |
|
| 4142 | 4135 | } |
| 4143 | 4136 | else |
| 4144 | 4137 | { |
| 4145 | - $response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail'); |
|
| 4138 | + $response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail'); |
|
| 4146 | 4139 | } |
| 4147 | 4140 | } |
| 4148 | 4141 | } |
@@ -4156,7 +4149,7 @@ discard block |
||
| 4156 | 4149 | * @param bool $getFolders The client needs the folders for the profile |
| 4157 | 4150 | * @return nothing |
| 4158 | 4151 | */ |
| 4159 | - public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null) |
|
| 4152 | + public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null) |
|
| 4160 | 4153 | { |
| 4161 | 4154 | $response = Api\Json\Response::get(); |
| 4162 | 4155 | |
@@ -4164,7 +4157,7 @@ discard block |
||
| 4164 | 4157 | |
| 4165 | 4158 | if ($icServerID && $icServerID != $previous_id) |
| 4166 | 4159 | { |
| 4167 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4160 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4168 | 4161 | try |
| 4169 | 4162 | { |
| 4170 | 4163 | $mail_ui->changeProfile($icServerID); |
@@ -4180,23 +4173,23 @@ discard block |
||
| 4180 | 4173 | } |
| 4181 | 4174 | } |
| 4182 | 4175 | catch (Exception $e) { |
| 4183 | - self::callWizard($e->getMessage(),true, 'error'); |
|
| 4176 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 4184 | 4177 | } |
| 4185 | 4178 | } |
| 4186 | 4179 | else |
| 4187 | 4180 | { |
| 4188 | - $mail_ui = new mail_ui(true); // run constructor |
|
| 4181 | + $mail_ui = new mail_ui(true); // run constructor |
|
| 4189 | 4182 | } |
| 4190 | 4183 | |
| 4191 | 4184 | // Send full info back in the response |
| 4192 | - if($getFolders) |
|
| 4185 | + if ($getFolders) |
|
| 4193 | 4186 | { |
| 4194 | 4187 | Api\Translation::add_app('mail'); |
| 4195 | 4188 | |
| 4196 | 4189 | $refreshData = array( |
| 4197 | - $icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane']) |
|
| 4190 | + $icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane']) |
|
| 4198 | 4191 | ); |
| 4199 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4192 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4200 | 4193 | } |
| 4201 | 4194 | } |
| 4202 | 4195 | |
@@ -4207,7 +4200,7 @@ discard block |
||
| 4207 | 4200 | * if other than active profile; nothing is done! |
| 4208 | 4201 | * @return nothing |
| 4209 | 4202 | */ |
| 4210 | - public static function ajax_refreshVacationNotice($icServerID=null) |
|
| 4203 | + public static function ajax_refreshVacationNotice($icServerID = null) |
|
| 4211 | 4204 | { |
| 4212 | 4205 | //Get vacation from cache if it's available |
| 4213 | 4206 | $cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']); |
@@ -4225,28 +4218,28 @@ discard block |
||
| 4225 | 4218 | |
| 4226 | 4219 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4227 | 4220 | } catch (Exception $e) { |
| 4228 | - $vacation=false; |
|
| 4221 | + $vacation = false; |
|
| 4229 | 4222 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4230 | 4223 | unset($e); |
| 4231 | 4224 | } |
| 4232 | 4225 | } |
| 4233 | 4226 | |
| 4234 | - if($vacation) { |
|
| 4235 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
|
| 4227 | + if ($vacation) { |
|
| 4228 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date')) |
|
| 4236 | 4229 | { |
| 4237 | 4230 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4238 | 4231 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4239 | - $refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
|
| 4240 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4232 | + $refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : ''); |
|
| 4233 | + if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = ''; |
|
| 4241 | 4234 | } |
| 4242 | 4235 | } |
| 4243 | - if ($vacation==false) |
|
| 4236 | + if ($vacation == false) |
|
| 4244 | 4237 | { |
| 4245 | - $refreshData['vacationnotice'] = ''; |
|
| 4246 | - $refreshData['vacationrange'] = ''; |
|
| 4238 | + $refreshData['vacationnotice'] = ''; |
|
| 4239 | + $refreshData['vacationrange'] = ''; |
|
| 4247 | 4240 | } |
| 4248 | 4241 | $response = Api\Json\Response::get(); |
| 4249 | - $response->call('app.mail.mail_refreshVacationNotice',$refreshData); |
|
| 4242 | + $response->call('app.mail.mail_refreshVacationNotice', $refreshData); |
|
| 4250 | 4243 | } |
| 4251 | 4244 | |
| 4252 | 4245 | /** |
@@ -4256,43 +4249,43 @@ discard block |
||
| 4256 | 4249 | * if other than active profile; nothing is done! |
| 4257 | 4250 | * @return nothing |
| 4258 | 4251 | */ |
| 4259 | - function ajax_refreshFilters($icServerID=null) |
|
| 4252 | + function ajax_refreshFilters($icServerID = null) |
|
| 4260 | 4253 | { |
| 4261 | 4254 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4262 | 4255 | if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
| 4263 | 4256 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4264 | 4257 | { |
| 4265 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4266 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4258 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4259 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4267 | 4260 | } |
| 4268 | 4261 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4269 | 4262 | { |
| 4270 | 4263 | unset($this->searchTypes['quick']); |
| 4271 | 4264 | unset($this->searchTypes['quickwithcc']); |
| 4272 | 4265 | } |
| 4273 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4266 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4274 | 4267 | { |
| 4275 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 4276 | - 'keyword1' => 'important',//lang('important'), |
|
| 4277 | - 'keyword2' => 'job', //lang('job'), |
|
| 4278 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 4279 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 4280 | - 'keyword5' => 'later', //lang('later'), |
|
| 4268 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 4269 | + 'keyword1' => 'important', //lang('important'), |
|
| 4270 | + 'keyword2' => 'job', //lang('job'), |
|
| 4271 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 4272 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 4273 | + 'keyword5' => 'later', //lang('later'), |
|
| 4281 | 4274 | )); |
| 4282 | 4275 | } |
| 4283 | 4276 | else |
| 4284 | 4277 | { |
| 4285 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 4286 | - foreach($keywords as &$k) |
|
| 4278 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 4279 | + foreach ($keywords as &$k) |
|
| 4287 | 4280 | { |
| 4288 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4281 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4289 | 4282 | } |
| 4290 | 4283 | } |
| 4291 | 4284 | |
| 4292 | 4285 | $response = Api\Json\Response::get(); |
| 4293 | - $response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes); |
|
| 4294 | - $response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes); |
|
| 4295 | - $response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'))); |
|
| 4286 | + $response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes); |
|
| 4287 | + $response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes); |
|
| 4288 | + $response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'))); |
|
| 4296 | 4289 | |
| 4297 | 4290 | } |
| 4298 | 4291 | |
@@ -4301,7 +4294,7 @@ discard block |
||
| 4301 | 4294 | * |
| 4302 | 4295 | * @return nothing |
| 4303 | 4296 | */ |
| 4304 | - function ajax_refreshQuotaDisplay($icServerID=null) |
|
| 4297 | + function ajax_refreshQuotaDisplay($icServerID = null) |
|
| 4305 | 4298 | { |
| 4306 | 4299 | //error_log(__METHOD__.__LINE__.array2string($icServerID)); |
| 4307 | 4300 | Api\Translation::add_app('mail'); |
@@ -4321,10 +4314,10 @@ discard block |
||
| 4321 | 4314 | unset($e); |
| 4322 | 4315 | } |
| 4323 | 4316 | |
| 4324 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4317 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4325 | 4318 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4326 | 4319 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 4327 | - $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 4320 | + $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 4328 | 4321 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 4329 | 4322 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 4330 | 4323 | } else { |
@@ -4344,7 +4337,7 @@ discard block |
||
| 4344 | 4337 | } |
| 4345 | 4338 | } |
| 4346 | 4339 | $response = Api\Json\Response::get(); |
| 4347 | - $response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content)); |
|
| 4340 | + $response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content)); |
|
| 4348 | 4341 | } |
| 4349 | 4342 | |
| 4350 | 4343 | /** |
@@ -4366,34 +4359,34 @@ discard block |
||
| 4366 | 4359 | $this->changeProfile($icServerID); |
| 4367 | 4360 | } |
| 4368 | 4361 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4369 | - if(!empty($junkFolder)) { |
|
| 4362 | + if (!empty($junkFolder)) { |
|
| 4370 | 4363 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4371 | 4364 | { |
| 4372 | 4365 | // Lock the tree if the active folder is junk folder |
| 4373 | 4366 | $response->call('app.mail.lock_tree'); |
| 4374 | 4367 | } |
| 4375 | - $this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately'); |
|
| 4368 | + $this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately'); |
|
| 4376 | 4369 | |
| 4377 | 4370 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4378 | - $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4371 | + $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4379 | 4372 | $fStatus = array( |
| 4380 | 4373 | $icServerID.self::$delimiter.$junkFolder => lang($fShortName) |
| 4381 | 4374 | ); |
| 4382 | 4375 | //Call to reset folder status counter, after junkFolder triggered not from Junk folder |
| 4383 | 4376 | //-as we don't have junk folder specific information available on client-side we need to deal with it on server |
| 4384 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4377 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4385 | 4378 | } |
| 4386 | 4379 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4387 | 4380 | { |
| 4388 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false); |
|
| 4389 | - $response->call('egw.message',lang('empty junk')); |
|
| 4390 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4381 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false); |
|
| 4382 | + $response->call('egw.message', lang('empty junk')); |
|
| 4383 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4391 | 4384 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4392 | 4385 | $this->changeProfile($rememberServerID); |
| 4393 | 4386 | } |
| 4394 | 4387 | else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4395 | 4388 | { |
| 4396 | - $response->call('egw.refresh',lang('empty junk'),'mail'); |
|
| 4389 | + $response->call('egw.refresh', lang('empty junk'), 'mail'); |
|
| 4397 | 4390 | } |
| 4398 | 4391 | } |
| 4399 | 4392 | |
@@ -4416,7 +4409,7 @@ discard block |
||
| 4416 | 4409 | $this->changeProfile($icServerID); |
| 4417 | 4410 | } |
| 4418 | 4411 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4419 | - if(!empty($trashFolder)) { |
|
| 4412 | + if (!empty($trashFolder)) { |
|
| 4420 | 4413 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4421 | 4414 | { |
| 4422 | 4415 | // Lock the tree if the active folder is Trash folder |
@@ -4425,25 +4418,25 @@ discard block |
||
| 4425 | 4418 | $this->mail_bo->compressFolder($trashFolder); |
| 4426 | 4419 | |
| 4427 | 4420 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4428 | - $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4421 | + $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4429 | 4422 | $fStatus = array( |
| 4430 | 4423 | $icServerID.self::$delimiter.$trashFolder => lang($fShortName) |
| 4431 | 4424 | ); |
| 4432 | 4425 | //Call to reset folder status counter, after emptyTrash triggered not from Trash folder |
| 4433 | 4426 | //-as we don't have trash folder specific information available on client-side we need to deal with it on server |
| 4434 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4427 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4435 | 4428 | } |
| 4436 | 4429 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4437 | 4430 | { |
| 4438 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false); |
|
| 4439 | - $response->call('egw.message',lang('empty trash')); |
|
| 4440 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4431 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false); |
|
| 4432 | + $response->call('egw.message', lang('empty trash')); |
|
| 4433 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4441 | 4434 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4442 | 4435 | $this->changeProfile($rememberServerID); |
| 4443 | 4436 | } |
| 4444 | 4437 | else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4445 | 4438 | { |
| 4446 | - $response->call('egw.refresh',lang('empty trash'),'mail'); |
|
| 4439 | + $response->call('egw.refresh', lang('empty trash'), 'mail'); |
|
| 4447 | 4440 | } |
| 4448 | 4441 | } |
| 4449 | 4442 | |
@@ -4460,7 +4453,7 @@ discard block |
||
| 4460 | 4453 | |
| 4461 | 4454 | $this->mail_bo->restoreSessionData(); |
| 4462 | 4455 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4463 | - list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4456 | + list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4464 | 4457 | |
| 4465 | 4458 | if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
| 4466 | 4459 | if ($this->mail_bo->folderExists($folderName)) |
@@ -4471,7 +4464,7 @@ discard block |
||
| 4471 | 4464 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4472 | 4465 | $this->changeProfile($icServerID); |
| 4473 | 4466 | } |
| 4474 | - if(!empty($_folderName)) { |
|
| 4467 | + if (!empty($_folderName)) { |
|
| 4475 | 4468 | $this->mail_bo->compressFolder($folderName); |
| 4476 | 4469 | } |
| 4477 | 4470 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4480,7 +4473,7 @@ discard block |
||
| 4480 | 4473 | $this->changeProfile($rememberServerID); |
| 4481 | 4474 | } |
| 4482 | 4475 | $response = Api\Json\Response::get(); |
| 4483 | - $response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail'); |
|
| 4476 | + $response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail'); |
|
| 4484 | 4477 | } |
| 4485 | 4478 | } |
| 4486 | 4479 | |
@@ -4493,10 +4486,10 @@ discard block |
||
| 4493 | 4486 | */ |
| 4494 | 4487 | function ajax_sendMDN($_messageList) |
| 4495 | 4488 | { |
| 4496 | - if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4489 | + if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4497 | 4490 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4498 | 4491 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4499 | - $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
|
| 4492 | + $this->mail_bo->sendMDN($uidA['msgUID'], $folder); |
|
| 4500 | 4493 | } |
| 4501 | 4494 | |
| 4502 | 4495 | /** |
@@ -4508,14 +4501,14 @@ discard block |
||
| 4508 | 4501 | * |
| 4509 | 4502 | * @return xajax response |
| 4510 | 4503 | */ |
| 4511 | - function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
|
| 4504 | + function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true) |
|
| 4512 | 4505 | { |
| 4513 | - if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4506 | + if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4514 | 4507 | Api\Translation::add_app('mail'); |
| 4515 | - $alreadyFlagged=false; |
|
| 4516 | - $flag2check=''; |
|
| 4508 | + $alreadyFlagged = false; |
|
| 4509 | + $flag2check = ''; |
|
| 4517 | 4510 | $filter2toggle = $query = array(); |
| 4518 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4511 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4519 | 4512 | { |
| 4520 | 4513 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4521 | 4514 | { |
@@ -4525,34 +4518,34 @@ discard block |
||
| 4525 | 4518 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4526 | 4519 | { |
| 4527 | 4520 | $query = $_messageList['activeFilters']; |
| 4528 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4521 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4529 | 4522 | { |
| 4530 | 4523 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4531 | 4524 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4532 | 4525 | { |
| 4533 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4534 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4526 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4527 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4535 | 4528 | } |
| 4536 | 4529 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 4537 | 4530 | $cutoffdate = $cutoffdate2 = null; |
| 4538 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4539 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4531 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4532 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4540 | 4533 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4541 | 4534 | $filter = array( |
| 4542 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4543 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4535 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4536 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4544 | 4537 | 'string' => $query['search'], |
| 4545 | - 'status' => 'any',//this is a status change. status will be manipulated later on |
|
| 4538 | + 'status' => 'any', //this is a status change. status will be manipulated later on |
|
| 4546 | 4539 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4547 | 4540 | ); |
| 4548 | - if ($query['enddate']||$query['startdate']) { |
|
| 4541 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4549 | 4542 | $filter['range'] = "BETWEEN"; |
| 4550 | 4543 | if ($cutoffdate) { |
| 4551 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4544 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4552 | 4545 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4553 | 4546 | } |
| 4554 | 4547 | if ($cutoffdate2) { |
| 4555 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4548 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4556 | 4549 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4557 | 4550 | } |
| 4558 | 4551 | } |
@@ -4565,12 +4558,12 @@ discard block |
||
| 4565 | 4558 | // flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder |
| 4566 | 4559 | // should be affected serverside. here. |
| 4567 | 4560 | $messageList = $messageListForToggle = array(); |
| 4568 | - $flag2check = ($_flag=='read'?'seen':$_flag); |
|
| 4569 | - if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4570 | - !($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)) |
|
| 4561 | + $flag2check = ($_flag == 'read' ? 'seen' : $_flag); |
|
| 4562 | + if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4563 | + !($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)) |
|
| 4571 | 4564 | { |
| 4572 | 4565 | $filter2toggle['status'] = array('un'.$_flag); |
| 4573 | - if ($query['filter'] && $query['filter']!='any') |
|
| 4566 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4574 | 4567 | { |
| 4575 | 4568 | $filter2toggle['status'][] = $query['filter']; |
| 4576 | 4569 | } |
@@ -4578,7 +4571,7 @@ discard block |
||
| 4578 | 4571 | $reverse = 1; |
| 4579 | 4572 | $_sRt = $this->mail_bo->getSortedList( |
| 4580 | 4573 | $folder, |
| 4581 | - $sort=0, |
|
| 4574 | + $sort = 0, |
|
| 4582 | 4575 | $reverse, |
| 4583 | 4576 | $filter2toggle, |
| 4584 | 4577 | $rByUid, |
@@ -4586,52 +4579,52 @@ discard block |
||
| 4586 | 4579 | ); |
| 4587 | 4580 | $messageListForToggle = $_sRt['match']->ids; |
| 4588 | 4581 | $filter['status'] = array($_flag); |
| 4589 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4582 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4590 | 4583 | { |
| 4591 | 4584 | $filter['status'][] = $query['filter']; |
| 4592 | 4585 | } |
| 4593 | - $rByUid=true; |
|
| 4586 | + $rByUid = true; |
|
| 4594 | 4587 | $reverse = 1; |
| 4595 | 4588 | $_sR = $this->mail_bo->getSortedList( |
| 4596 | 4589 | $folder, |
| 4597 | - $sort=0, |
|
| 4590 | + $sort = 0, |
|
| 4598 | 4591 | $reverse, |
| 4599 | 4592 | $filter, |
| 4600 | 4593 | $rByUid, |
| 4601 | 4594 | false |
| 4602 | 4595 | ); |
| 4603 | 4596 | $messageList = $_sR['match']->ids; |
| 4604 | - if (count($messageListForToggle)>0) |
|
| 4597 | + if (count($messageListForToggle) > 0) |
|
| 4605 | 4598 | { |
| 4606 | 4599 | $flag2set = (strtolower($_flag)); |
| 4607 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4608 | - $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
|
| 4600 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4601 | + $this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder); |
|
| 4609 | 4602 | } |
| 4610 | - if (count($messageList)>0) |
|
| 4603 | + if (count($messageList) > 0) |
|
| 4611 | 4604 | { |
| 4612 | 4605 | $flag2set = 'un'.$_flag; |
| 4613 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4614 | - $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
|
| 4606 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4607 | + $this->mail_bo->flagMessages($flag2set, $messageList, $folder); |
|
| 4615 | 4608 | } |
| 4616 | - $alreadyFlagged=true; |
|
| 4609 | + $alreadyFlagged = true; |
|
| 4617 | 4610 | } |
| 4618 | 4611 | elseif (!empty($filter) && |
| 4619 | - (!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) || |
|
| 4620 | - (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4621 | - ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))) |
|
| 4612 | + (!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) || |
|
| 4613 | + (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4614 | + ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))) |
|
| 4622 | 4615 | { |
| 4623 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4616 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4624 | 4617 | { |
| 4625 | 4618 | $filter['status'] = $query['filter']; |
| 4626 | 4619 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4627 | - $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
|
| 4620 | + $_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag))); |
|
| 4628 | 4621 | } |
| 4629 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4622 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4630 | 4623 | $rByUid = true; |
| 4631 | 4624 | $reverse = 1; |
| 4632 | 4625 | $_sR = $this->mail_bo->getSortedList( |
| 4633 | 4626 | $folder, |
| 4634 | - $sort=0, |
|
| 4627 | + $sort = 0, |
|
| 4635 | 4628 | $reverse, |
| 4636 | 4629 | $filter, |
| 4637 | 4630 | $rByUid, |
@@ -4643,8 +4636,8 @@ discard block |
||
| 4643 | 4636 | } |
| 4644 | 4637 | else |
| 4645 | 4638 | { |
| 4646 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4647 | - $alreadyFlagged=true; |
|
| 4639 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4640 | + $alreadyFlagged = true; |
|
| 4648 | 4641 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4649 | 4642 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4650 | 4643 | $this->mail_bo->flagMessages($_flag, 'all', $folder); |
@@ -4658,41 +4651,41 @@ discard block |
||
| 4658 | 4651 | } |
| 4659 | 4652 | if (!$alreadyFlagged) |
| 4660 | 4653 | { |
| 4661 | - foreach($_messageList['msg'] as $rowID) |
|
| 4654 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4662 | 4655 | { |
| 4663 | 4656 | $hA = self::splitRowID($rowID); |
| 4664 | 4657 | $messageList[] = $hA['msgUID']; |
| 4665 | 4658 | } |
| 4666 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 4667 | - $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
|
| 4659 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList))); |
|
| 4660 | + $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder); |
|
| 4668 | 4661 | } |
| 4669 | 4662 | } |
| 4670 | 4663 | else |
| 4671 | 4664 | { |
| 4672 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4665 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4673 | 4666 | } |
| 4674 | 4667 | |
| 4675 | 4668 | if ($_sendJsonResponse) |
| 4676 | 4669 | { |
| 4677 | - $flag=array( |
|
| 4678 | - 'label1' => 'important',//lang('important'), |
|
| 4679 | - 'label2' => 'job', //lang('job'), |
|
| 4680 | - 'label3' => 'personal',//lang('personal'), |
|
| 4681 | - 'label4' => 'to do', //lang('to do'), |
|
| 4682 | - 'label5' => 'later', //lang('later'), |
|
| 4670 | + $flag = array( |
|
| 4671 | + 'label1' => 'important', //lang('important'), |
|
| 4672 | + 'label2' => 'job', //lang('job'), |
|
| 4673 | + 'label3' => 'personal', //lang('personal'), |
|
| 4674 | + 'label4' => 'to do', //lang('to do'), |
|
| 4675 | + 'label5' => 'later', //lang('later'), |
|
| 4683 | 4676 | ); |
| 4684 | 4677 | $response = Api\Json\Response::get(); |
| 4685 | 4678 | if (isset($_messageList['msg']) && $_messageList['popup']) |
| 4686 | 4679 | { |
| 4687 | - $response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update'); |
|
| 4680 | + $response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', $_messageList['msg'], lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail', $_messageList['msg'], 'update'); |
|
| 4688 | 4681 | } |
| 4689 | - else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))) |
|
| 4682 | + else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))) |
|
| 4690 | 4683 | { |
| 4691 | - $response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail'); |
|
| 4684 | + $response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail'); |
|
| 4692 | 4685 | } |
| 4693 | 4686 | else |
| 4694 | 4687 | { |
| 4695 | - $response->call('egw.message',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder)); |
|
| 4688 | + $response->call('egw.message', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder)); |
|
| 4696 | 4689 | } |
| 4697 | 4690 | } |
| 4698 | 4691 | } |
@@ -4704,12 +4697,12 @@ discard block |
||
| 4704 | 4697 | * @param string _forceDeleteMethod - method of deletion to be enforced |
| 4705 | 4698 | * @return xajax response |
| 4706 | 4699 | */ |
| 4707 | - function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
|
| 4700 | + function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null) |
|
| 4708 | 4701 | { |
| 4709 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 4702 | + if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod); |
|
| 4710 | 4703 | $error = null; |
| 4711 | - $filtered = false; |
|
| 4712 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4704 | + $filtered = false; |
|
| 4705 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4713 | 4706 | { |
| 4714 | 4707 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4715 | 4708 | { |
@@ -4719,34 +4712,34 @@ discard block |
||
| 4719 | 4712 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4720 | 4713 | { |
| 4721 | 4714 | $query = $_messageList['activeFilters']; |
| 4722 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4715 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4723 | 4716 | { |
| 4724 | 4717 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4725 | 4718 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4726 | 4719 | { |
| 4727 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4728 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4720 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4721 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4729 | 4722 | } |
| 4730 | - $filtered = true; |
|
| 4723 | + $filtered = true; |
|
| 4731 | 4724 | $cutoffdate = $cutoffdate2 = null; |
| 4732 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4733 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4725 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4726 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4734 | 4727 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4735 | 4728 | $filter = array( |
| 4736 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4737 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4729 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4730 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4738 | 4731 | 'string' => $query['search'], |
| 4739 | - 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
|
| 4732 | + 'status' => (!empty($query['filter']) ? $query['filter'] : 'any'), |
|
| 4740 | 4733 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4741 | 4734 | ); |
| 4742 | - if ($query['enddate']||$query['startdate']) { |
|
| 4735 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4743 | 4736 | $filter['range'] = "BETWEEN"; |
| 4744 | 4737 | if ($cutoffdate) { |
| 4745 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4738 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4746 | 4739 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4747 | 4740 | } |
| 4748 | 4741 | if ($cutoffdate2) { |
| 4749 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4742 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4750 | 4743 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4751 | 4744 | } |
| 4752 | 4745 | } |
@@ -4760,7 +4753,7 @@ discard block |
||
| 4760 | 4753 | $rByUid = true; |
| 4761 | 4754 | $_sR = $this->mail_bo->getSortedList( |
| 4762 | 4755 | $folder, |
| 4763 | - $sort=0, |
|
| 4756 | + $sort = 0, |
|
| 4764 | 4757 | $reverse, |
| 4765 | 4758 | $filter, |
| 4766 | 4759 | $rByUid, |
@@ -4770,23 +4763,23 @@ discard block |
||
| 4770 | 4763 | } |
| 4771 | 4764 | else |
| 4772 | 4765 | { |
| 4773 | - $messageList='all'; |
|
| 4766 | + $messageList = 'all'; |
|
| 4774 | 4767 | } |
| 4775 | 4768 | try |
| 4776 | 4769 | { |
| 4777 | 4770 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4778 | - $this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4771 | + $this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4779 | 4772 | } |
| 4780 | 4773 | catch (Api\Exception $e) |
| 4781 | 4774 | { |
| 4782 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4775 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4783 | 4776 | } |
| 4784 | 4777 | } |
| 4785 | 4778 | else |
| 4786 | 4779 | { |
| 4787 | 4780 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4788 | 4781 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4789 | - foreach($_messageList['msg'] as $rowID) |
|
| 4782 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4790 | 4783 | { |
| 4791 | 4784 | $hA = self::splitRowID($rowID); |
| 4792 | 4785 | $messageList[] = $hA['msgUID']; |
@@ -4794,27 +4787,27 @@ discard block |
||
| 4794 | 4787 | try |
| 4795 | 4788 | { |
| 4796 | 4789 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4797 | - $this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4790 | + $this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4798 | 4791 | } |
| 4799 | 4792 | catch (Api\Exception $e) |
| 4800 | 4793 | { |
| 4801 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4794 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4802 | 4795 | } |
| 4803 | 4796 | } |
| 4804 | 4797 | $response = Api\Json\Response::get(); |
| 4805 | 4798 | if (empty($error)) |
| 4806 | 4799 | { |
| 4807 | - $response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg'])); |
|
| 4800 | + $response->call('app.mail.mail_deleteMessagesShowResult', array('egw_message'=>lang('deleted %1 messages in %2', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($_messageList['msg'])), $folder), 'msg'=>$_messageList['msg'])); |
|
| 4808 | 4801 | } |
| 4809 | 4802 | else |
| 4810 | 4803 | { |
| 4811 | - $error = str_replace('\n',"\n",lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)',$error)); |
|
| 4812 | - $response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList)); |
|
| 4804 | + $error = str_replace('\n', "\n", lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)', $error)); |
|
| 4805 | + $response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList)); |
|
| 4813 | 4806 | } |
| 4814 | 4807 | } |
| 4815 | 4808 | else |
| 4816 | 4809 | { |
| 4817 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4810 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4818 | 4811 | } |
| 4819 | 4812 | } |
| 4820 | 4813 | |
@@ -4828,48 +4821,48 @@ discard block |
||
| 4828 | 4821 | * |
| 4829 | 4822 | * @return xajax response |
| 4830 | 4823 | */ |
| 4831 | - function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_') |
|
| 4824 | + function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_') |
|
| 4832 | 4825 | { |
| 4833 | - if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 4826 | + if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 4834 | 4827 | Api\Translation::add_app('mail'); |
| 4835 | 4828 | $folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4836 | 4829 | // only copy or move are supported as method |
| 4837 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 4838 | - list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2); |
|
| 4830 | + if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy'; |
|
| 4831 | + list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2); |
|
| 4839 | 4832 | // check if move2archive was called with the correct archiveFolder |
| 4840 | 4833 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
| 4841 | - if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder) |
|
| 4834 | + if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder) |
|
| 4842 | 4835 | { |
| 4843 | 4836 | error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder"); |
| 4844 | 4837 | $targetProfileID = $this->mail_bo->profileID; |
| 4845 | 4838 | $targetFolder = $archiveFolder; |
| 4846 | 4839 | error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder"); |
| 4847 | 4840 | } |
| 4848 | - $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 4841 | + $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 4849 | 4842 | $changeFolderActions = false; |
| 4850 | 4843 | //error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder"); |
| 4851 | 4844 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont)); |
| 4852 | 4845 | if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])) |
| 4853 | 4846 | { |
| 4854 | 4847 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])); |
| 4855 | - if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3) |
|
| 4848 | + if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3) |
|
| 4856 | 4849 | { |
| 4857 | 4850 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 4858 | - foreach( $keys as &$f) |
|
| 4851 | + foreach ($keys as &$f) |
|
| 4859 | 4852 | { |
| 4860 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4853 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4861 | 4854 | else break; |
| 4862 | 4855 | } |
| 4863 | 4856 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 4864 | 4857 | } |
| 4865 | 4858 | //error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName"); |
| 4866 | - $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName; |
|
| 4859 | + $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName; |
|
| 4867 | 4860 | $changeFolderActions = true; |
| 4868 | 4861 | } |
| 4869 | 4862 | $filtered = false; |
| 4870 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4863 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4871 | 4864 | { |
| 4872 | - $error=false; |
|
| 4865 | + $error = false; |
|
| 4873 | 4866 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4874 | 4867 | { |
| 4875 | 4868 | // we have both messageIds AND allFlag folder information |
@@ -4879,34 +4872,34 @@ discard block |
||
| 4879 | 4872 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4880 | 4873 | { |
| 4881 | 4874 | $query = $_messageList['activeFilters']; |
| 4882 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4875 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4883 | 4876 | { |
| 4884 | 4877 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4885 | 4878 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4886 | 4879 | { |
| 4887 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4888 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4880 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4881 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4889 | 4882 | } |
| 4890 | 4883 | $filtered = true; |
| 4891 | 4884 | $cutoffdate = $cutoffdate2 = null; |
| 4892 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4893 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4885 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4886 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4894 | 4887 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4895 | 4888 | $filter = array( |
| 4896 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4897 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4889 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4890 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4898 | 4891 | 'string' => $query['search'], |
| 4899 | - 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
|
| 4892 | + 'status' => (!empty($query['filter']) ? $query['filter'] : 'any'), |
|
| 4900 | 4893 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4901 | 4894 | ); |
| 4902 | - if ($query['enddate']||$query['startdate']) { |
|
| 4895 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4903 | 4896 | $filter['range'] = "BETWEEN"; |
| 4904 | 4897 | if ($cutoffdate) { |
| 4905 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4898 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4906 | 4899 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4907 | 4900 | } |
| 4908 | 4901 | if ($cutoffdate2) { |
| 4909 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4902 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4910 | 4903 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4911 | 4904 | } |
| 4912 | 4905 | } |
@@ -4919,70 +4912,70 @@ discard block |
||
| 4919 | 4912 | $rByUid = true; |
| 4920 | 4913 | $_sR = $this->mail_bo->getSortedList( |
| 4921 | 4914 | $folder, |
| 4922 | - $sort=0, |
|
| 4915 | + $sort = 0, |
|
| 4923 | 4916 | $reverse, |
| 4924 | 4917 | $filter, |
| 4925 | - $rByUid=true, |
|
| 4918 | + $rByUid = true, |
|
| 4926 | 4919 | false |
| 4927 | 4920 | ); |
| 4928 | 4921 | $messageList = $_sR['match']->ids; |
| 4929 | - foreach($messageList as $uID) |
|
| 4922 | + foreach ($messageList as $uID) |
|
| 4930 | 4923 | { |
| 4931 | 4924 | //error_log(__METHOD__.__LINE__.$uID); |
| 4932 | - if ($_copyOrMove=='move') |
|
| 4925 | + if ($_copyOrMove == 'move') |
|
| 4933 | 4926 | { |
| 4934 | - $messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false); |
|
| 4927 | + $messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false); |
|
| 4935 | 4928 | } |
| 4936 | 4929 | } |
| 4937 | 4930 | } |
| 4938 | 4931 | else |
| 4939 | 4932 | { |
| 4940 | - $messageList='all'; |
|
| 4933 | + $messageList = 'all'; |
|
| 4941 | 4934 | } |
| 4942 | 4935 | try |
| 4943 | 4936 | { |
| 4944 | 4937 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 4945 | - $this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 4938 | + $this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 4946 | 4939 | } |
| 4947 | 4940 | catch (Api\Exception $e) |
| 4948 | 4941 | { |
| 4949 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4942 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4950 | 4943 | } |
| 4951 | 4944 | } |
| 4952 | 4945 | else |
| 4953 | 4946 | { |
| 4954 | 4947 | $messageList = array(); |
| 4955 | - while(count($_messageList['msg']) > 0) |
|
| 4948 | + while (count($_messageList['msg']) > 0) |
|
| 4956 | 4949 | { |
| 4957 | 4950 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4958 | 4951 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4959 | 4952 | $sourceProfileID = $uidA['profileID']; |
| 4960 | 4953 | $moveList = array(); |
| 4961 | - foreach($_messageList['msg'] as $rowID) |
|
| 4954 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4962 | 4955 | { |
| 4963 | 4956 | $hA = self::splitRowID($rowID); |
| 4964 | 4957 | |
| 4965 | 4958 | // If folder changes, stop and move what we've got |
| 4966 | - if($hA['folder'] != $folder) break; |
|
| 4959 | + if ($hA['folder'] != $folder) break; |
|
| 4967 | 4960 | |
| 4968 | 4961 | array_shift($_messageList['msg']); |
| 4969 | 4962 | $messageList[] = $hA['msgUID']; |
| 4970 | 4963 | $moveList[] = $hA['msgUID']; |
| 4971 | - if ($_copyOrMove=='move') |
|
| 4964 | + if ($_copyOrMove == 'move') |
|
| 4972 | 4965 | { |
| 4973 | - $helpvar = explode(self::$delimiter,$rowID); |
|
| 4966 | + $helpvar = explode(self::$delimiter, $rowID); |
|
| 4974 | 4967 | array_shift($helpvar); |
| 4975 | - $messageListForRefresh[]= implode(self::$delimiter,$helpvar); |
|
| 4968 | + $messageListForRefresh[] = implode(self::$delimiter, $helpvar); |
|
| 4976 | 4969 | } |
| 4977 | 4970 | } |
| 4978 | 4971 | try |
| 4979 | 4972 | { |
| 4980 | 4973 | //error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 4981 | - $this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 4974 | + $this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 4982 | 4975 | } |
| 4983 | 4976 | catch (Api\Exception $e) |
| 4984 | 4977 | { |
| 4985 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4978 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4986 | 4979 | } |
| 4987 | 4980 | } |
| 4988 | 4981 | } |
@@ -4995,30 +4988,30 @@ discard block |
||
| 4995 | 4988 | unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]); |
| 4996 | 4989 | $changeFolderActions = true; |
| 4997 | 4990 | } |
| 4998 | - $response->call('egw.message',$error,"error"); |
|
| 4991 | + $response->call('egw.message', $error, "error"); |
|
| 4999 | 4992 | } |
| 5000 | 4993 | else |
| 5001 | 4994 | { |
| 5002 | - if ($_copyOrMove=='copy') |
|
| 4995 | + if ($_copyOrMove == 'copy') |
|
| 5003 | 4996 | { |
| 5004 | - $response->call('egw.message',lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder)); |
|
| 4997 | + $response->call('egw.message', lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder)); |
|
| 5005 | 4998 | } |
| 5006 | 4999 | else |
| 5007 | 5000 | { |
| 5008 | - $response->call('egw.refresh',lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder),'mail',$messageListForRefresh,'delete'); |
|
| 5001 | + $response->call('egw.refresh', lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder), 'mail', $messageListForRefresh, 'delete'); |
|
| 5009 | 5002 | } |
| 5010 | 5003 | } |
| 5011 | 5004 | if ($changeFolderActions == true) |
| 5012 | 5005 | { |
| 5013 | 5006 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont)); |
| 5014 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 5007 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 5015 | 5008 | $actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions()); |
| 5016 | - $response->call('app.mail.mail_rebuildActionsOnList',$actionsnew); |
|
| 5009 | + $response->call('app.mail.mail_rebuildActionsOnList', $actionsnew); |
|
| 5017 | 5010 | } |
| 5018 | 5011 | } |
| 5019 | 5012 | else |
| 5020 | 5013 | { |
| 5021 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5014 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5022 | 5015 | } |
| 5023 | 5016 | } |
| 5024 | 5017 | |
@@ -5028,11 +5021,11 @@ discard block |
||
| 5028 | 5021 | * |
| 5029 | 5022 | * @param type $_id |
| 5030 | 5023 | */ |
| 5031 | - function ajax_folderMgmtTree_autoloading ($_id = null) |
|
| 5024 | + function ajax_folderMgmtTree_autoloading($_id = null) |
|
| 5032 | 5025 | { |
| 5033 | 5026 | $mail_ui = new mail_ui(); |
| 5034 | - $id = $_id? $_id : $_GET['id']; |
|
| 5035 | - Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false)); |
|
| 5027 | + $id = $_id ? $_id : $_GET['id']; |
|
| 5028 | + Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false)); |
|
| 5036 | 5029 | } |
| 5037 | 5030 | |
| 5038 | 5031 | /** |
@@ -5040,15 +5033,15 @@ discard block |
||
| 5040 | 5033 | * |
| 5041 | 5034 | * @param array $content content of dialog |
| 5042 | 5035 | */ |
| 5043 | - function folderManagement (array $content = null) |
|
| 5036 | + function folderManagement(array $content = null) |
|
| 5044 | 5037 | { |
| 5045 | 5038 | $dtmpl = new Etemplate('mail.folder_management'); |
| 5046 | - $profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id']; |
|
| 5047 | - $sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false); |
|
| 5039 | + $profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id']; |
|
| 5040 | + $sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false); |
|
| 5048 | 5041 | |
| 5049 | 5042 | if (!is_array($content)) |
| 5050 | 5043 | { |
| 5051 | - $content = array ('acc_id' => $profileID); |
|
| 5044 | + $content = array('acc_id' => $profileID); |
|
| 5052 | 5045 | } |
| 5053 | 5046 | |
| 5054 | 5047 | $readonlys = array(); |
@@ -5056,7 +5049,7 @@ discard block |
||
| 5056 | 5049 | $preserv = array( |
| 5057 | 5050 | 'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side |
| 5058 | 5051 | ); |
| 5059 | - $dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2); |
|
| 5052 | + $dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 5060 | 5053 | } |
| 5061 | 5054 | |
| 5062 | 5055 | /** |
@@ -5066,11 +5059,11 @@ discard block |
||
| 5066 | 5059 | * |
| 5067 | 5060 | * @param type $_folderName |
| 5068 | 5061 | */ |
| 5069 | - function ajax_folderMgmt_delete ($_folderName) |
|
| 5062 | + function ajax_folderMgmt_delete($_folderName) |
|
| 5070 | 5063 | { |
| 5071 | 5064 | if ($_folderName) |
| 5072 | 5065 | { |
| 5073 | - $success = $this->ajax_deleteFolder($_folderName,true); |
|
| 5066 | + $success = $this->ajax_deleteFolder($_folderName, true); |
|
| 5074 | 5067 | $response = Api\Json\Response::get(); |
| 5075 | 5068 | list(,$folderName) = explode(self::$delimiter, $_folderName); |
| 5076 | 5069 | if ($success) |
@@ -5079,7 +5072,7 @@ discard block |
||
| 5079 | 5072 | } |
| 5080 | 5073 | else |
| 5081 | 5074 | { |
| 5082 | - $res = lang("Failed to delete %1",$folderName); |
|
| 5075 | + $res = lang("Failed to delete %1", $folderName); |
|
| 5083 | 5076 | } |
| 5084 | 5077 | $response->data($res); |
| 5085 | 5078 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @array |
| 123 | 123 | */ |
| 124 | - static $tidy_config = array('clean'=>false,'output-html'=>true,'join-classes'=>true,'join-styles'=>true,'show-body-only'=>"auto",'word-2000'=>true,'wrap'=>0); |
|
| 124 | + static $tidy_config = array('clean'=>false, 'output-html'=>true, 'join-classes'=>true, 'join-styles'=>true, 'show-body-only'=>"auto", 'word-2000'=>true, 'wrap'=>0); |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * static used to configure htmLawed, for use with emails |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | static $htmLawed_config = array('comment'=>1, //remove comments |
| 132 | 132 | 'make_tag_strict' => 3, // 3 is a new own config value, to indicate that transformation is to be performed, but don't transform font as size transformation of numeric sizes to keywords alters the intended result too much |
| 133 | 133 | 'keep_bad'=>2, //remove tags but keep element content (4 and 6 keep element content only if text (pcdata) is valid in parent element as per specs, this may lead to textloss if balance is switched on) |
| 134 | - 'balance'=>1,//turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering) |
|
| 134 | + 'balance'=>1, //turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering) |
|
| 135 | 135 | 'direct_list_nest' => 1, |
| 136 | - 'allow_for_inline' => array('table','div','li','p'),//block elements allowed for nesting when only inline is allowed; Example span does not allow block elements as table; table is the only element tested so far |
|
| 136 | + 'allow_for_inline' => array('table', 'div', 'li', 'p'), //block elements allowed for nesting when only inline is allowed; Example span does not allow block elements as table; table is the only element tested so far |
|
| 137 | 137 | // tidy eats away even some wanted whitespace, so we switch it off; |
| 138 | 138 | // we used it for its compacting and beautifying capabilities, which resulted in better html for further processing |
| 139 | 139 | 'tidy'=>0, |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @array |
| 150 | 150 | */ |
| 151 | - static $aclShortCuts = array('' => array('label'=>'none','title'=>'The user has no rights whatsoever.'), |
|
| 152 | - 'lrs' => array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'), |
|
| 153 | - 'lprs' => array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'), |
|
| 154 | - 'ilprs' => array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'), |
|
| 155 | - 'cdilprsw' => array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'), |
|
| 156 | - 'acdilprsw' => array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'), |
|
| 157 | - 'custom' => array('label'=>'custom','title'=>'User defined combination of rights for the ACL'), |
|
| 151 | + static $aclShortCuts = array('' => array('label'=>'none', 'title'=>'The user has no rights whatsoever.'), |
|
| 152 | + 'lrs' => array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'), |
|
| 153 | + 'lprs' => array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'), |
|
| 154 | + 'ilprs' => array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'), |
|
| 155 | + 'cdilprsw' => array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'), |
|
| 156 | + 'acdilprsw' => array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'), |
|
| 157 | + 'custom' => array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'), |
|
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 197 | 197 | * @return Mail |
| 198 | 198 | */ |
| 199 | - public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 199 | + public static function getInstance($_restoreSession = true, &$_profileID = 0, $_validate = true, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 200 | 200 | { |
| 201 | 201 | //$_restoreSession=false; |
| 202 | 202 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
| 203 | 203 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.'/'.Mail\Account::get_default_acc_id().' for user:'.$GLOBALS['egw_info']['user']['account_lid'].' called from:'.function_backtrace()); |
| 204 | 204 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject)); |
| 205 | - self::$profileDefunct = Cache::getCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),5*1); |
|
| 205 | + self::$profileDefunct = Cache::getCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 5 * 1); |
|
| 206 | 206 | if (isset(self::$profileDefunct[$_profileID]) && strlen(self::$profileDefunct[$_profileID])) |
| 207 | 207 | { |
| 208 | 208 | throw new Exception(__METHOD__." failed to instanciate Mail for Profile #$_profileID Reason:".self::$profileDefunct[$_profileID]); |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | if (!is_object(self::$instances[$_profileID])) |
| 213 | 213 | { |
| 214 | - self::$instances[$_profileID] = new Mail('utf-8',false,$_profileID,false,$_reuseCache); |
|
| 214 | + self::$instances[$_profileID] = new Mail('utf-8', false, $_profileID, false, $_reuseCache); |
|
| 215 | 215 | } |
| 216 | 216 | self::$instances[$_profileID]->icServer = $_oldImapServerObject; |
| 217 | - self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId; |
|
| 218 | - self::$instances[$_profileID]->profileID= $_oldImapServerObject->ImapServerId; |
|
| 217 | + self::$instances[$_profileID]->accountid = $_oldImapServerObject->ImapServerId; |
|
| 218 | + self::$instances[$_profileID]->profileID = $_oldImapServerObject->ImapServerId; |
|
| 219 | 219 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 220 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 220 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 221 | 221 | return self::$instances[$_profileID]; |
| 222 | 222 | } |
| 223 | 223 | if ($_profileID == 0) |
@@ -230,14 +230,14 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | $profileID = Mail\Account::get_default_acc_id(); |
| 232 | 232 | } |
| 233 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 234 | - $_profileID=$profileID; |
|
| 233 | + if ($profileID != $_profileID) $_restoreSession == false; |
|
| 234 | + $_profileID = $profileID; |
|
| 235 | 235 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
| 236 | 236 | } |
| 237 | 237 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 238 | - if ($_oldImapServerObject===true) |
|
| 238 | + if ($_oldImapServerObject === true) |
|
| 239 | 239 | { |
| 240 | - return new Mail('utf-8',false,$_profileID,true,$_reuseCache); |
|
| 240 | + return new Mail('utf-8', false, $_profileID, true, $_reuseCache); |
|
| 241 | 241 | } |
| 242 | 242 | if ($_profileID != 0 && $_validate) |
| 243 | 243 | { |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | //Cache::setSession('mail','activeProfileID',$_profileID); |
| 258 | 258 | } |
| 259 | 259 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace()); |
| 260 | - if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession===false)) |
|
| 260 | + if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession === false)) |
|
| 261 | 261 | { |
| 262 | - self::$instances[$_profileID] = new Mail('utf-8',$_restoreSession,$_profileID,false,$_reuseCache); |
|
| 262 | + self::$instances[$_profileID] = new Mail('utf-8', $_restoreSession, $_profileID, false, $_reuseCache); |
|
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | 265 | { |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | self::$instances[$_profileID]->ogServer = Mail\Account::read($_profileID)->smtpServer(); |
| 271 | 271 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 272 | 272 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 273 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 273 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 274 | 274 | } catch (\Exception $e) |
| 275 | 275 | { |
| 276 | 276 | $newprofileID = Mail\Account::get_default_acc_id(); |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | error_log(__METHOD__.' ('.__LINE__.') '." Loading the Profile for ProfileID ".$_profileID.' failed for icServer; '.$e->getMessage().' Trigger new instance for Default-Profile '.$newprofileID.'. called from:'.function_backtrace()); |
| 279 | 279 | if ($newprofileID) |
| 280 | 280 | { |
| 281 | - self::$instances[$newprofileID] = new Mail('utf-8',false,$newprofileID,false,$_reuseCache); |
|
| 281 | + self::$instances[$newprofileID] = new Mail('utf-8', false, $newprofileID, false, $_reuseCache); |
|
| 282 | 282 | $_profileID = $newprofileID; |
| 283 | 283 | } |
| 284 | 284 | else |
| 285 | 285 | { |
| 286 | - throw new Exception(__METHOD__." failed to load the Profile for ProfileID for $_profileID with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 286 | + throw new Exception(__METHOD__." failed to load the Profile for ProfileID for $_profileID with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | - self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
|
| 289 | + self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate); |
|
| 290 | 290 | } |
| 291 | 291 | self::$instances[$_profileID]->profileID = $_profileID; |
| 292 | 292 | if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param boolean $_testConnection = 0 |
| 303 | 303 | * @return mixed $_profileID or false on failed ConnectionTest |
| 304 | 304 | */ |
| 305 | - public static function storeActiveProfileIDToPref($_icServerObject, $_profileID=0, $_testConnection=true) |
|
| 305 | + public static function storeActiveProfileIDToPref($_icServerObject, $_profileID = 0, $_testConnection = true) |
|
| 306 | 306 | { |
| 307 | 307 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) && !empty($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
| 308 | 308 | { |
@@ -323,12 +323,12 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | if ($oldProfileID != $_profileID) |
| 325 | 325 | { |
| 326 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 327 | - $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
|
| 326 | + if ($oldProfileID && $_profileID == 0) $_profileID = $oldProfileID; |
|
| 327 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveProfileID', $_profileID, 'user'); |
|
| 328 | 328 | // save prefs |
| 329 | 329 | $GLOBALS['egw']->preferences->save_repository(true); |
| 330 | 330 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $_profileID; |
| 331 | - Cache::setSession('mail','activeProfileID',$_profileID); |
|
| 331 | + Cache::setSession('mail', 'activeProfileID', $_profileID); |
|
| 332 | 332 | } |
| 333 | 333 | return $_profileID; |
| 334 | 334 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param int $_acc_id = 0 |
| 344 | 344 | * @return int validated acc_id -> either acc_id given, or first valid one |
| 345 | 345 | */ |
| 346 | - public static function validateProfileID($_acc_id=0) |
|
| 346 | + public static function validateProfileID($_acc_id = 0) |
|
| 347 | 347 | { |
| 348 | 348 | if ($_acc_id) |
| 349 | 349 | { |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | // no account specified or specified account not found or not valid |
| 364 | 364 | // --> search existing account for first valid one and return that |
| 365 | - foreach(Mail\Account::search($only_current_user=true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 365 | + foreach (Mail\Account::search($only_current_user = true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 366 | 366 | { |
| 367 | 367 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 368 | 368 | { |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @param boolean $_oldImapServerObject = false |
| 385 | 385 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 386 | 386 | */ |
| 387 | - private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 387 | + private function __construct($_displayCharset = 'utf-8', $_restoreSession = true, $_profileID = 0, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 388 | 388 | { |
| 389 | 389 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
| 390 | 390 | if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $firstMessage = $this->sessionData['previewMessage']; |
| 405 | 405 | $this->sessionData = array(); |
| 406 | 406 | } |
| 407 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 407 | + if (!$_reuseCache) $this->forcePrefReload($_profileID, !$_reuseCache); |
|
| 408 | 408 | try |
| 409 | 409 | { |
| 410 | 410 | $this->profileID = self::validateProfileID($_profileID); |
@@ -418,11 +418,11 @@ discard block |
||
| 418 | 418 | throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage()); |
| 419 | 419 | } |
| 420 | 420 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($acc->imapServer())); |
| 421 | - $this->icServer = ($_oldImapServerObject?$acc->oldImapServer():$acc->imapServer()); |
|
| 421 | + $this->icServer = ($_oldImapServerObject ? $acc->oldImapServer() : $acc->imapServer()); |
|
| 422 | 422 | $this->ogServer = $acc->smtpServer(); |
| 423 | 423 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 424 | 424 | $this->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 425 | - $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 425 | + $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 426 | 426 | if (isset($this->icServer->ImapServerId) && !empty($this->icServer->ImapServerId)) |
| 427 | 427 | { |
| 428 | 428 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | public static function &forceEAProfileLoad($_profile_id) |
| 441 | 441 | { |
| 442 | 442 | self::unsetCachedObjects($_profile_id); |
| 443 | - $mail = self::getInstance(false, $_profile_id,false); |
|
| 443 | + $mail = self::getInstance(false, $_profile_id, false); |
|
| 444 | 444 | //_debug_array( $_profile_id); |
| 445 | 445 | $mail->icServer = Mail\Account::read($_profile_id)->imapServer(); |
| 446 | 446 | $mail->ogServer = Mail\Account::read($_profile_id)->smtpServer(); |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | * @param int $_profile_id |
| 453 | 453 | * @param boolean $_resetFolderObjects |
| 454 | 454 | */ |
| 455 | - public static function forcePrefReload($_profile_id=null,$_resetFolderObjects=true) |
|
| 455 | + public static function forcePrefReload($_profile_id = null, $_resetFolderObjects = true) |
|
| 456 | 456 | { |
| 457 | 457 | // unset the mail_preferences session object, to force the reload/rebuild |
| 458 | - Cache::setSession('mail','mail_preferences',serialize(array())); |
|
| 459 | - Cache::setSession('emailadmin','session_data',serialize(array())); |
|
| 458 | + Cache::setSession('mail', 'mail_preferences', serialize(array())); |
|
| 459 | + Cache::setSession('emailadmin', 'session_data', serialize(array())); |
|
| 460 | 460 | if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
| 461 | 461 | } |
| 462 | 462 | |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function restoreSessionData() |
| 467 | 467 | { |
| 468 | - $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 469 | - self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 468 | + $this->sessionData = array(); //Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 469 | + self::$activeFolderCache = Cache::getCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 470 | 470 | if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
| 471 | 471 | } |
| 472 | 472 | |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | function saveSessionData() |
| 477 | 477 | { |
| 478 | 478 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 479 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 479 | + if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID] = $this->sessionData['mailbox']; |
|
| 480 | 480 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 481 | 481 | { |
| 482 | - Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
|
| 482 | + Cache::setCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), self::$activeFolderCache, 60 * 60 * 10); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | |
@@ -495,40 +495,40 @@ discard block |
||
| 495 | 495 | * @param int $_profileID = null default profile of user as returned by getUserDefaultProfileID |
| 496 | 496 | * @return void |
| 497 | 497 | */ |
| 498 | - static function unsetCachedObjects($_profileID=null) |
|
| 498 | + static function unsetCachedObjects($_profileID = null) |
|
| 499 | 499 | { |
| 500 | 500 | if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
| 501 | 501 | if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
| 502 | 502 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 503 | - if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
|
| 503 | + if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID, 'tracker_') === false))) |
|
| 504 | 504 | { |
| 505 | 505 | self::resetConnectionErrorCache($_profileID); |
| 506 | - $rawHeadersCache = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 506 | + $rawHeadersCache = Cache::getCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 507 | 507 | if (isset($rawHeadersCache[$_profileID])) |
| 508 | 508 | { |
| 509 | 509 | unset($rawHeadersCache[$_profileID]); |
| 510 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$rawHeadersCache, $expiration=60*60*1); |
|
| 510 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $rawHeadersCache, $expiration = 60 * 60 * 1); |
|
| 511 | 511 | } |
| 512 | - $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*5); |
|
| 512 | + $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 5); |
|
| 513 | 513 | if (isset($HierarchyDelimiterCache[$_profileID])) |
| 514 | 514 | { |
| 515 | 515 | unset($HierarchyDelimiterCache[$_profileID]); |
| 516 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$HierarchyDelimiterCache, $expiration=60*60*24*5); |
|
| 516 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $HierarchyDelimiterCache, $expiration = 60 * 60 * 24 * 5); |
|
| 517 | 517 | } |
| 518 | 518 | //reset folderObject cache, to trigger reload |
| 519 | 519 | self::resetFolderObjectCache($_profileID); |
| 520 | 520 | //reset counter of deleted messages per folder |
| 521 | - $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 521 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 522 | 522 | if (isset($eMailListContainsDeletedMessages[$_profileID])) |
| 523 | 523 | { |
| 524 | 524 | unset($eMailListContainsDeletedMessages[$_profileID]); |
| 525 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$eMailListContainsDeletedMessages, $expiration=60*60*1); |
|
| 525 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $eMailListContainsDeletedMessages, $expiration = 60 * 60 * 1); |
|
| 526 | 526 | } |
| 527 | - $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*1); |
|
| 527 | + $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 1); |
|
| 528 | 528 | if (isset($vacationCached[$_profileID])) |
| 529 | 529 | { |
| 530 | 530 | unset($vacationCached[$_profileID]); |
| 531 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
|
| 531 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $vacationCached, $expiration = 60 * 60 * 24 * 1); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
@@ -536,17 +536,17 @@ discard block |
||
| 536 | 536 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 537 | 537 | { |
| 538 | 538 | // called via hook |
| 539 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account) |
|
| 539 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account) |
|
| 540 | 540 | { |
| 541 | 541 | //error_log(__METHOD__.__LINE__.array2string($account)); |
| 542 | 542 | $account_id = $account['account_id']; |
| 543 | 543 | $_profileID = null; |
| 544 | - self::resetConnectionErrorCache($_profileID,$account_id); |
|
| 545 | - self::resetFolderObjectCache($_profileID,$account_id); |
|
| 546 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),array(), 60*60*1); |
|
| 547 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),array(), 60*60*24*5); |
|
| 548 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),array(), 60*60*1); |
|
| 549 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),array(), 60*60*24*1); |
|
| 544 | + self::resetConnectionErrorCache($_profileID, $account_id); |
|
| 545 | + self::resetFolderObjectCache($_profileID, $account_id); |
|
| 546 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), array(), 60 * 60 * 1); |
|
| 547 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), array(), 60 * 60 * 24 * 5); |
|
| 548 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), array(), 60 * 60 * 1); |
|
| 549 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), array(), 60 * 60 * 24 * 1); |
|
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | * @param int $_ImapServerId the profileID to look for |
| 558 | 558 | * @param int $account_id the egw account to look for |
| 559 | 559 | */ |
| 560 | - static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
|
| 560 | + static function resetConnectionErrorCache($_ImapServerId = null, $account_id = null) |
|
| 561 | 561 | { |
| 562 | 562 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 563 | 563 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
@@ -575,19 +575,19 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | else |
| 577 | 577 | { |
| 578 | - $isConError = Cache::getCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id)); |
|
| 578 | + $isConError = Cache::getCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id)); |
|
| 579 | 579 | if (isset($isConError[$_ImapServerId])) |
| 580 | 580 | { |
| 581 | 581 | unset($isConError[$_ImapServerId]); |
| 582 | 582 | } |
| 583 | - $waitOnFailure = Cache::getCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),null,array(),60*60*2); |
|
| 583 | + $waitOnFailure = Cache::getCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), null, array(), 60 * 60 * 2); |
|
| 584 | 584 | if (isset($waitOnFailure[$_ImapServerId])) |
| 585 | 585 | { |
| 586 | 586 | unset($waitOnFailure[$_ImapServerId]); |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | - Cache::setCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id),$isConError,60*15); |
|
| 590 | - Cache::setCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),$waitOnFailure,60*60*2); |
|
| 589 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id), $isConError, 60 * 15); |
|
| 590 | + Cache::setCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), $waitOnFailure, 60 * 60 * 2); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -596,13 +596,13 @@ discard block |
||
| 596 | 596 | * @param int $_ImapServerId the profileID to look for |
| 597 | 597 | * @param int $account_id the egw account to look for |
| 598 | 598 | */ |
| 599 | - static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
|
| 599 | + static function resetFolderObjectCache($_ImapServerId = null, $account_id = null) |
|
| 600 | 600 | { |
| 601 | 601 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 602 | 602 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
| 603 | 603 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 604 | 604 | // or treat it as not given. we try that path |
| 605 | - if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
|
| 605 | + if (is_null($_ImapServerId) || is_array($_ImapServerId)) |
|
| 606 | 606 | { |
| 607 | 607 | $folders2return = array(); |
| 608 | 608 | $folderInfo = array(); |
@@ -611,12 +611,12 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | else |
| 613 | 613 | { |
| 614 | - $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),null,array(),60*60*1); |
|
| 614 | + $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 615 | 615 | if (!empty($folders2return) && isset($folders2return[$_ImapServerId])) |
| 616 | 616 | { |
| 617 | 617 | unset($folders2return[$_ImapServerId]); |
| 618 | 618 | } |
| 619 | - $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),null,array(),60*60*5); |
|
| 619 | + $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), null, array(), 60 * 60 * 5); |
|
| 620 | 620 | if (!empty($folderInfo) && isset($folderInfo[$_ImapServerId])) |
| 621 | 621 | { |
| 622 | 622 | unset($folderInfo[$_ImapServerId]); |
@@ -628,23 +628,23 @@ discard block |
||
| 628 | 628 | unset($lastFolderUsedForMove[$_ImapServerId]); |
| 629 | 629 | } |
| 630 | 630 | */ |
| 631 | - $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),null,array(),60*60*1); |
|
| 631 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 632 | 632 | if (!empty($folderBasicInfo) && isset($folderBasicInfo[$_ImapServerId])) |
| 633 | 633 | { |
| 634 | 634 | unset($folderBasicInfo[$_ImapServerId]); |
| 635 | 635 | } |
| 636 | - $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),null,array(),60*60*12); |
|
| 636 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), null, array(), 60 * 60 * 12); |
|
| 637 | 637 | if (!empty($_specialUseFolders) && isset($_specialUseFolders[$_ImapServerId])) |
| 638 | 638 | { |
| 639 | 639 | unset($_specialUseFolders[$_ImapServerId]); |
| 640 | - self::$specialUseFolders=null; |
|
| 640 | + self::$specialUseFolders = null; |
|
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),$folders2return, 60*60*1); |
|
| 644 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),$folderInfo,60*60*5); |
|
| 643 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), $folders2return, 60 * 60 * 1); |
|
| 644 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), $folderInfo, 60 * 60 * 5); |
|
| 645 | 645 | //Cache::setCache(Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($account_id),$lastFolderUsedForMove,$expiration=60*60*1); |
| 646 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),$folderBasicInfo,60*60*1); |
|
| 647 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),$_specialUseFolders,60*60*12); |
|
| 646 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), $folderBasicInfo, 60 * 60 * 1); |
|
| 647 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), $_specialUseFolders, 60 * 60 * 12); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
@@ -665,15 +665,15 @@ discard block |
||
| 665 | 665 | * @param string $_profileID the ID of the mailaccount to check for identities, if null current mail-account is used |
| 666 | 666 | * @return array - array(email=>realname) |
| 667 | 667 | */ |
| 668 | - function getUserEMailAddresses($_profileID=null) |
|
| 668 | + function getUserEMailAddresses($_profileID = null) |
|
| 669 | 669 | { |
| 670 | - $acc = Mail\Account::read((!empty($_profileID)?$_profileID:$this->profileID)); |
|
| 670 | + $acc = Mail\Account::read((!empty($_profileID) ? $_profileID : $this->profileID)); |
|
| 671 | 671 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($acc)); |
| 672 | 672 | $identities = Mail\Account::identities($acc); |
| 673 | 673 | |
| 674 | 674 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 675 | 675 | |
| 676 | - foreach($identities as $ik => $ident) { |
|
| 676 | + foreach ($identities as $ik => $ident) { |
|
| 677 | 677 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 678 | 678 | $identity = Mail\Account::read_identity($ik); |
| 679 | 679 | if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
@@ -688,19 +688,19 @@ discard block |
||
| 688 | 688 | * @param boolean $resolve_placeholders wether or not resolve possible placeholders in identities |
| 689 | 689 | * @return array - array(email=>realname) |
| 690 | 690 | */ |
| 691 | - static function getAllIdentities($_accountToSearch=null,$resolve_placeholders=false) |
|
| 691 | + static function getAllIdentities($_accountToSearch = null, $resolve_placeholders = false) |
|
| 692 | 692 | { |
| 693 | 693 | $userEMailAdresses = array(); |
| 694 | - foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
|
| 694 | + foreach (Mail\Account::search($only_current_user = ($_accountToSearch ? $_accountToSearch : true), $just_name = true) as $acc_id => $identity_name) |
|
| 695 | 695 | { |
| 696 | - $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
|
| 697 | - if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']); |
|
| 696 | + $acc = Mail\Account::read($acc_id, ($_accountToSearch ? $_accountToSearch : null)); |
|
| 697 | + if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id, 'ident_id'=>$acc['ident_id'], 'ident_email'=>$acc['ident_email'], 'ident_org'=>$acc['ident_org'], 'ident_realname'=>$acc['ident_realname'], 'ident_signature'=>$acc['ident_signature'], 'ident_name'=>$acc['ident_name']); |
|
| 698 | 698 | |
| 699 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 699 | + foreach (Mail\Account::identities($acc) as $ik => $ident) { |
|
| 700 | 700 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 701 | - $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
|
| 701 | + $identity = Mail\Account::read_identity($ik, $resolve_placeholders); |
|
| 702 | 702 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 703 | - if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']); |
|
| 703 | + if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id, 'ident_id'=>$identity['ident_id'], 'ident_email'=>$identity['ident_email'], 'ident_org'=>$identity['ident_org'], 'ident_realname'=>$identity['ident_realname'], 'ident_signature'=>$identity['ident_signature'], 'ident_name'=>$identity['ident_name']); |
|
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -720,9 +720,9 @@ discard block |
||
| 720 | 720 | $account = Mail\Account::read($account); |
| 721 | 721 | } |
| 722 | 722 | $userEMailAdresses = array(); |
| 723 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 723 | + foreach (Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 724 | 724 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 725 | - $identity = Mail\Account::read_identity($ik,true,null,$account); |
|
| 725 | + $identity = Mail\Account::read_identity($ik, true, null, $account); |
|
| 726 | 726 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 727 | 727 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 728 | 728 | if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
@@ -749,9 +749,9 @@ discard block |
||
| 749 | 749 | function getDefaultIdentity() |
| 750 | 750 | { |
| 751 | 751 | // retrieve the signature accociated with the identity |
| 752 | - $id = $this->getIdentitiesWithAccounts($_accountData=array()); |
|
| 753 | - foreach(Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 754 | - $this->profileID : $_accountData[$id],false,'ident_id') as $accountData) |
|
| 752 | + $id = $this->getIdentitiesWithAccounts($_accountData = array()); |
|
| 753 | + foreach (Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 754 | + $this->profileID : $_accountData[$id], false, 'ident_id') as $accountData) |
|
| 755 | 755 | { |
| 756 | 756 | return $accountData; |
| 757 | 757 | } |
@@ -767,13 +767,13 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | // account select box |
| 769 | 769 | $selectedID = $this->profileID; |
| 770 | - $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
|
| 770 | + $allAccountData = Mail\Account::search($only_current_user = true, false, null); |
|
| 771 | 771 | if ($allAccountData) { |
| 772 | - $rememberFirst=$selectedFound=null; |
|
| 772 | + $rememberFirst = $selectedFound = null; |
|
| 773 | 773 | foreach ($allAccountData as $tmpkey => $icServers) |
| 774 | 774 | { |
| 775 | 775 | if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
| 776 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 776 | + if ($tmpkey == $selectedID) $selectedFound = true; |
|
| 777 | 777 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 778 | 778 | $host = $icServers->acc_imap_host; |
| 779 | 779 | if (empty($host)) continue; |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | - return ($selectedFound?$selectedID:$rememberFirst); |
|
| 784 | + return ($selectedFound ? $selectedID : $rememberFirst); |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | /** |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | * @var boolean $fullString full or false=NamePart only is returned |
| 792 | 792 | * @return string - constructed of identity object data as defined in mailConfig |
| 793 | 793 | */ |
| 794 | - static function generateIdentityString($identity, $fullString=true) |
|
| 794 | + static function generateIdentityString($identity, $fullString = true) |
|
| 795 | 795 | { |
| 796 | 796 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity)); |
| 797 | 797 | //if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
@@ -802,16 +802,16 @@ discard block |
||
| 802 | 802 | { |
| 803 | 803 | case 'email'; |
| 804 | 804 | //$retData = str_replace('@',' ',$identity->emailAddress).($fullString===true?' <'.$identity->emailAddress.'>':''); |
| 805 | - $retData = $identity['ident_email'].($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 805 | + $retData = $identity['ident_email'].($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 806 | 806 | break; |
| 807 | 807 | case 'nameNemail'; |
| 808 | - $retData = (!empty($identity['ident_realname'])?$identity['ident_realname']:substr_replace($identity['ident_email'],'',strpos($identity['ident_email'],'@'))).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 808 | + $retData = (!empty($identity['ident_realname']) ? $identity['ident_realname'] : substr_replace($identity['ident_email'], '', strpos($identity['ident_email'], '@'))).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 809 | 809 | break; |
| 810 | 810 | case 'orgNemail'; |
| 811 | - $retData = (!empty($identity['ident_org'])?$identity['ident_org']:substr_replace($identity['ident_email'],'',0,strpos($identity['ident_email'],'@')+1)).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 811 | + $retData = (!empty($identity['ident_org']) ? $identity['ident_org'] : substr_replace($identity['ident_email'], '', 0, strpos($identity['ident_email'], '@') + 1)).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 812 | 812 | break; |
| 813 | 813 | default: |
| 814 | - $retData = $identity['ident_realname'].(!empty($identity['ident_org'])?' '.$identity['ident_org']:'').($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 814 | + $retData = $identity['ident_realname'].(!empty($identity['ident_org']) ? ' '.$identity['ident_org'] : '').($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 815 | 815 | } |
| 816 | 816 | return $retData; |
| 817 | 817 | } |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | */ |
| 837 | 837 | function reopen($_foldername) |
| 838 | 838 | { |
| 839 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 839 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 840 | 840 | |
| 841 | 841 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 842 | 842 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | $folderOpened = $_foldername; |
| 853 | 853 | //} |
| 854 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 854 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'Folder:'.$_foldername, __METHOD__.' ('.__LINE__.') '); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | |
@@ -862,15 +862,15 @@ discard block |
||
| 862 | 862 | * @throws Horde_Imap_Client_Exception on connection error or authentication failure |
| 863 | 863 | * @throws InvalidArgumentException on missing credentials |
| 864 | 864 | */ |
| 865 | - function openConnection($_icServerID=0) |
|
| 865 | + function openConnection($_icServerID = 0) |
|
| 866 | 866 | { |
| 867 | 867 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 868 | 868 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 869 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 870 | - $mailbox=null; |
|
| 869 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 870 | + $mailbox = null; |
|
| 871 | 871 | try |
| 872 | 872 | { |
| 873 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 873 | + if (isset($this->sessionData['mailbox']) && $this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 874 | 874 | if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
| 875 | 875 | /* |
| 876 | 876 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 898 | 898 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 899 | 899 | } |
| 900 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 900 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'ProfileID:'.$_icServerID, __METHOD__.' ('.__LINE__.') '); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | try |
| 919 | 919 | { |
| 920 | 920 | $this->icServer->getCurrentMailbox(); |
| 921 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 921 | + if (!$this->icServer->hasCapability('QUOTA')) { |
|
| 922 | 922 | $quota = false; |
| 923 | 923 | return false; |
| 924 | 924 | } |
@@ -928,15 +928,15 @@ discard block |
||
| 928 | 928 | { |
| 929 | 929 | //error_log(__METHOD__.array2string($e)); |
| 930 | 930 | //error_log(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
| 931 | - if ($e->getCode()==102) |
|
| 931 | + if ($e->getCode() == 102) |
|
| 932 | 932 | { |
| 933 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 934 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 935 | - throw new Exception(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 933 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 934 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 935 | + throw new Exception(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 939 | - if(is_array($quota)) { |
|
| 939 | + if (is_array($quota)) { |
|
| 940 | 940 | $quota = array( |
| 941 | 941 | 'usage' => $quota['USED'], |
| 942 | 942 | 'limit' => $quota['QMAX'], |
@@ -954,10 +954,10 @@ discard block |
||
| 954 | 954 | * |
| 955 | 955 | * @return int - timeout (either set or default 20/10) |
| 956 | 956 | */ |
| 957 | - static function getTimeOut($_use='IMAP') |
|
| 957 | + static function getTimeOut($_use = 'IMAP') |
|
| 958 | 958 | { |
| 959 | 959 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 960 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 960 | + if (empty($timeout)) $timeout = ($_use == 'SIEVE' ? 10 : 20); // this is the default value |
|
| 961 | 961 | return $timeout; |
| 962 | 962 | } |
| 963 | 963 | |
@@ -978,18 +978,18 @@ discard block |
||
| 978 | 978 | if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
| 979 | 979 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 980 | 980 | if (is_array($nameSpace)) { |
| 981 | - foreach($nameSpace as $type => $singleNameSpaceArray) |
|
| 981 | + foreach ($nameSpace as $type => $singleNameSpaceArray) |
|
| 982 | 982 | { |
| 983 | 983 | foreach ($singleNameSpaceArray as $singleNameSpace) |
| 984 | 984 | { |
| 985 | 985 | $_foldersNameSpace = array(); |
| 986 | - if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) |
|
| 986 | + if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX'))) |
|
| 987 | 987 | { |
| 988 | 988 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 989 | 989 | // uw-imap server with mailbox prefix or dovecot maybe |
| 990 | - $_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:'')); |
|
| 990 | + $_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : '')); |
|
| 991 | 991 | } |
| 992 | - elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 992 | + elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 993 | 993 | { |
| 994 | 994 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 995 | 995 | // uw-imap server with mailbox prefix or dovecot maybe |
@@ -998,9 +998,9 @@ discard block |
||
| 998 | 998 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 999 | 999 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 1000 | 1000 | } |
| 1001 | - $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter); |
|
| 1001 | + $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter); |
|
| 1002 | 1002 | $_foldersNameSpace['type'] = $type; |
| 1003 | - $foldersNameSpace[] =$_foldersNameSpace; |
|
| 1003 | + $foldersNameSpace[] = $_foldersNameSpace; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | //echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>"; |
| 1006 | 1006 | } |
@@ -1018,10 +1018,10 @@ discard block |
||
| 1018 | 1018 | */ |
| 1019 | 1019 | function getFolderPrefixFromNamespace($nameSpace, $folderName) |
| 1020 | 1020 | { |
| 1021 | - foreach($nameSpace as &$singleNameSpace) |
|
| 1021 | + foreach ($nameSpace as &$singleNameSpace) |
|
| 1022 | 1022 | { |
| 1023 | 1023 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 1024 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1024 | + if (substr($folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return ""; |
| 1027 | 1027 | } |
@@ -1032,12 +1032,12 @@ discard block |
||
| 1032 | 1032 | * @var boolean $_useCache |
| 1033 | 1033 | * @return string the hierarchyDelimiter |
| 1034 | 1034 | */ |
| 1035 | - function getHierarchyDelimiter($_useCache=true) |
|
| 1035 | + function getHierarchyDelimiter($_useCache = true) |
|
| 1036 | 1036 | { |
| 1037 | 1037 | static $HierarchyDelimiter = null; |
| 1038 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1039 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1040 | - if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1038 | + if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5); |
|
| 1039 | + if ($_useCache === false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1040 | + if (isset($HierarchyDelimiter[$this->icServer->ImapServerId]) && !empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1043 | 1043 | } |
@@ -1047,17 +1047,17 @@ discard block |
||
| 1047 | 1047 | $this->icServer->getCurrentMailbox(); |
| 1048 | 1048 | $HierarchyDelimiter[$this->icServer->ImapServerId] = $this->icServer->getDelimiter(); |
| 1049 | 1049 | } |
| 1050 | - catch(\Exception $e) |
|
| 1050 | + catch (\Exception $e) |
|
| 1051 | 1051 | { |
| 1052 | - if ($e->getCode()==102) |
|
| 1052 | + if ($e->getCode() == 102) |
|
| 1053 | 1053 | { |
| 1054 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 1055 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 1054 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 1055 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | unset($e); |
| 1058 | 1058 | $HierarchyDelimiter[$this->icServer->ImapServerId] = '/'; |
| 1059 | 1059 | } |
| 1060 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$HierarchyDelimiter, 60*60*24*5); |
|
| 1060 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), $HierarchyDelimiter, 60 * 60 * 24 * 5); |
|
| 1061 | 1061 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | { |
| 1071 | 1071 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1072 | 1072 | static $_specialUseFolders = null; |
| 1073 | - if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1073 | + if (is_null($_specialUseFolders) || empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5); |
|
| 1074 | 1074 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1075 | 1075 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1076 | 1076 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
@@ -1078,20 +1078,20 @@ discard block |
||
| 1078 | 1078 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1079 | 1079 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1080 | 1080 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1081 | - $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
|
| 1081 | + $_specialUseFolders[$this->icServer->ImapServerId] = array(); |
|
| 1082 | 1082 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1083 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
|
| 1083 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash] = 'Trash'; |
|
| 1084 | 1084 | //if (!empty($this->icServer->acc_folder_draft) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft])) |
| 1085 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts'; |
|
| 1085 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft] = 'Drafts'; |
|
| 1086 | 1086 | //if (!empty($this->icServer->acc_folder_sent) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent])) |
| 1087 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent'; |
|
| 1087 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent] = 'Sent'; |
|
| 1088 | 1088 | //if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template])) |
| 1089 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates'; |
|
| 1090 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk'; |
|
| 1091 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive]='Archive'; |
|
| 1089 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template] = 'Templates'; |
|
| 1090 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk] = 'Junk'; |
|
| 1091 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive] = 'Archive'; |
|
| 1092 | 1092 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer)); |
| 1093 | 1093 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1094 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5); |
|
| 1094 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $_specialUseFolders, 60 * 60 * 24 * 5); |
|
| 1095 | 1095 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1096 | 1096 | } |
| 1097 | 1097 | |
@@ -1105,8 +1105,8 @@ discard block |
||
| 1105 | 1105 | function folderIsSelectable($folderToSelect) |
| 1106 | 1106 | { |
| 1107 | 1107 | $retval = true; |
| 1108 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1109 | - if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
|
| 1108 | + if ($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect, false, true))) { |
|
| 1109 | + if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']), 'noselect') !== false) |
|
| 1110 | 1110 | { |
| 1111 | 1111 | $retval = false; |
| 1112 | 1112 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | * |
| 1127 | 1127 | * @throws Exception |
| 1128 | 1128 | */ |
| 1129 | - function _getStatus($folderName,$ignoreStatusCache=false) |
|
| 1129 | + function _getStatus($folderName, $ignoreStatusCache = false) |
|
| 1130 | 1130 | { |
| 1131 | 1131 | static $folderStatus = null; |
| 1132 | 1132 | if (!$ignoreStatusCache && isset($folderStatus[$this->icServer->ImapServerId][$folderName])) |
@@ -1136,11 +1136,11 @@ discard block |
||
| 1136 | 1136 | } |
| 1137 | 1137 | try |
| 1138 | 1138 | { |
| 1139 | - $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName,$ignoreStatusCache); |
|
| 1139 | + $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName, $ignoreStatusCache); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | catch (\Exception $e) |
| 1142 | 1142 | { |
| 1143 | - throw new Exception(__METHOD__.' ('.__LINE__.') '." failed for $folderName with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 1143 | + throw new Exception(__METHOD__.' ('.__LINE__.') '." failed for $folderName with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | return $folderStatus[$this->icServer->ImapServerId][$folderName]; |
| 1146 | 1146 | } |
@@ -1156,10 +1156,10 @@ discard block |
||
| 1156 | 1156 | * @param fetchSubscribedInfo bool fetch Subscribed Info on folder |
| 1157 | 1157 | * @return array |
| 1158 | 1158 | */ |
| 1159 | - function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
|
| 1159 | + function getFolderStatus($_folderName, $ignoreStatusCache = false, $basicInfoOnly = false, $fetchSubscribedInfo = true) |
|
| 1160 | 1160 | { |
| 1161 | 1161 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
| 1162 | - if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID]))) |
|
| 1162 | + if (!is_string($_folderName) || empty($_folderName) || (isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID]))) |
|
| 1163 | 1163 | { |
| 1164 | 1164 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
| 1165 | 1165 | return false; |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | { |
| 1171 | 1171 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1172 | 1172 | } |
| 1173 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1173 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache == false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1174 | 1174 | $retValue = array(); |
| 1175 | 1175 | $retValue['subscribed'] = false; |
| 1176 | 1176 | /* |
@@ -1191,41 +1191,41 @@ discard block |
||
| 1191 | 1191 | { |
| 1192 | 1192 | //error_log(__METHOD__.array2string($e)); |
| 1193 | 1193 | //error_log(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
| 1194 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 1195 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 1196 | - throw new Exception(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 1194 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 1195 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 1196 | + throw new Exception(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | //error_log(__METHOD__.' ('.__LINE__.') '.$_folderName.' '.array2string($ret)); |
| 1199 | 1199 | if (is_array($ret)) |
| 1200 | 1200 | { |
| 1201 | 1201 | $retkeys = array_keys($ret); |
| 1202 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1202 | + if ($retkeys[0] == $_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | else |
| 1205 | 1205 | { |
| 1206 | - $folderInfoCache[$_folderName]=false; |
|
| 1206 | + $folderInfoCache[$_folderName] = false; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | } |
| 1209 | 1209 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1210 | 1210 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1211 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1211 | + if ($ignoreStatusCache || !$folderInfo || !is_array($folderInfo)) { |
|
| 1212 | 1212 | try |
| 1213 | 1213 | { |
| 1214 | - $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
|
| 1214 | + $folderInfo = $this->_getStatus($_folderName, $ignoreStatusCache); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | catch (\Exception $e) |
| 1217 | 1217 | { |
| 1218 | 1218 | //error_log(__METHOD__.array2string($e)); |
| 1219 | - error_log(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
|
| 1220 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 1221 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 1219 | + error_log(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')/*.function_backtrace()*/); |
|
| 1220 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 1221 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 1222 | 1222 | //throw new Exception(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
| 1223 | - $folderInfo=null; |
|
| 1223 | + $folderInfo = null; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | if (!is_array($folderInfo)) |
| 1226 | 1226 | { |
| 1227 | 1227 | // no folder info, but there is a status returned for the folder: something is wrong, try to cope with it |
| 1228 | - $folderInfo = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1228 | + $folderInfo = is_array($folderInfo) ? $folderInfo : array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1229 | 1229 | 'ATTRIBUTES' => ''); |
| 1230 | 1230 | if (!isset($folderInfo['HIERACHY_DELIMITER']) || empty($folderInfo['HIERACHY_DELIMITER']) || (isset($folderInfo['delimiter']) && empty($folderInfo['delimiter']))) |
| 1231 | 1231 | { |
@@ -1237,24 +1237,24 @@ discard block |
||
| 1237 | 1237 | #if(!is_array($folderInfo)) { |
| 1238 | 1238 | # return false; |
| 1239 | 1239 | #} |
| 1240 | - $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER']?$folderInfo['HIERACHY_DELIMITER']:$folderInfo['delimiter']); |
|
| 1241 | - $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES']?$folderInfo['ATTRIBUTES']:$folderInfo['attributes']); |
|
| 1242 | - $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1240 | + $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER'] ? $folderInfo['HIERACHY_DELIMITER'] : $folderInfo['delimiter']); |
|
| 1241 | + $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES'] ? $folderInfo['ATTRIBUTES'] : $folderInfo['attributes']); |
|
| 1242 | + $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1243 | 1243 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1244 | 1244 | $retValue['displayName'] = $_folderName; |
| 1245 | - $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1246 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1247 | - $retValue['displayName'] = lang('INBOX'); |
|
| 1248 | - $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1245 | + $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1246 | + if (strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1247 | + $retValue['displayName'] = lang('INBOX'); |
|
| 1248 | + $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 1251 | - elseif (in_array($retValue['shortName'],self::$autoFolders)) |
|
| 1251 | + elseif (in_array($retValue['shortName'], self::$autoFolders)) |
|
| 1252 | 1252 | { |
| 1253 | 1253 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1254 | 1254 | } |
| 1255 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1255 | + if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName] = $retValue; |
|
| 1256 | 1256 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1257 | - if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
|
| 1257 | + if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']), 'noselect') !== false)) |
|
| 1258 | 1258 | { |
| 1259 | 1259 | return $retValue; |
| 1260 | 1260 | } |
@@ -1267,12 +1267,12 @@ discard block |
||
| 1267 | 1267 | if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
| 1268 | 1268 | if (!empty($nameSpace[$this->profileID])) |
| 1269 | 1269 | { |
| 1270 | - $nsNoPersonal=array(); |
|
| 1271 | - foreach($nameSpace[$this->profileID] as &$ns) |
|
| 1270 | + $nsNoPersonal = array(); |
|
| 1271 | + foreach ($nameSpace[$this->profileID] as &$ns) |
|
| 1272 | 1272 | { |
| 1273 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1273 | + if ($ns['type'] != 'personal') $nsNoPersonal[] = $ns; |
|
| 1274 | 1274 | } |
| 1275 | - $nameSpace[$this->profileID]=$nsNoPersonal; |
|
| 1275 | + $nameSpace[$this->profileID] = $nsNoPersonal; |
|
| 1276 | 1276 | } |
| 1277 | 1277 | if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
| 1278 | 1278 | |
@@ -1281,34 +1281,34 @@ discard block |
||
| 1281 | 1281 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1284 | + if ($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName, $subscribedFolders[$this->profileID])) { |
|
| 1285 | 1285 | $retValue['subscribed'] = true; |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | try |
| 1289 | 1289 | { |
| 1290 | 1290 | //$folderStatus = $this->_getStatus($_folderName,$ignoreStatusCache); |
| 1291 | - $folderStatus = $this->getMailBoxCounters($_folderName,false); |
|
| 1292 | - $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1291 | + $folderStatus = $this->getMailBoxCounters($_folderName, false); |
|
| 1292 | + $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1293 | 1293 | $retValue['recent'] = $folderStatus['RECENT']; |
| 1294 | - $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1295 | - $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1294 | + $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1295 | + $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1296 | 1296 | $retValue['unseen'] = $folderStatus['UNSEEN']; |
| 1297 | 1297 | if (//$retValue['unseen']==0 && |
| 1298 | 1298 | (isset($this->mailPreferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information |
| 1299 | - $this->mailPreferences['trustServersUnseenInfo']==false) || |
|
| 1299 | + $this->mailPreferences['trustServersUnseenInfo'] == false) || |
|
| 1300 | 1300 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1301 | - $this->mailPreferences['trustServersUnseenInfo']==2 && |
|
| 1302 | - $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
|
| 1301 | + $this->mailPreferences['trustServersUnseenInfo'] == 2 && |
|
| 1302 | + $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName, $prefix[$this->profileID][$_folderName]) !== false) |
|
| 1303 | 1303 | ) |
| 1304 | 1304 | { |
| 1305 | 1305 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1306 | 1306 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1307 | 1307 | try |
| 1308 | 1308 | { |
| 1309 | - $byUid=true; |
|
| 1310 | - $_reverse=1; |
|
| 1311 | - $sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse, array('status'=>array('UNSEEN','UNDELETED')),$byUid,false); |
|
| 1309 | + $byUid = true; |
|
| 1310 | + $_reverse = 1; |
|
| 1311 | + $sortResult = $this->getSortedList($_folderName, $_sort = 0, $_reverse, array('status'=>array('UNSEEN', 'UNDELETED')), $byUid, false); |
|
| 1312 | 1312 | $retValue['unseen'] = $sortResult['count']; |
| 1313 | 1313 | } |
| 1314 | 1314 | catch (\Exception $ee) |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | } |
| 1320 | 1320 | catch (\Exception $e) |
| 1321 | 1321 | { |
| 1322 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1322 | + if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(), true)); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | return $retValue; |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | * @param mixed $_fetchPreviews = false (boolean/int) fetch part of the body of the messages requested (if integer the number is assumed to be the number of chars to be returned for preview; if set to true 300 chars are returned (when available)) |
| 1342 | 1342 | * @return array result as array(header=>array,total=>int,first=>int,last=>int) |
| 1343 | 1343 | */ |
| 1344 | - function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
|
| 1344 | + function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly = null, $_cacheResult = true, $_fetchPreviews = false) |
|
| 1345 | 1345 | { |
| 1346 | 1346 | //self::$debug=true; |
| 1347 | 1347 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | $rByUid = true; // try searching by uid. this var will be passed by reference to getSortedList, and may be set to false, if UID retrieval fails |
| 1355 | 1355 | #print "<pre>"; |
| 1356 | 1356 | #$this->icServer->setDebug(true); |
| 1357 | - $total=0; |
|
| 1357 | + $total = 0; |
|
| 1358 | 1358 | if ($_thisUIDOnly === null) |
| 1359 | 1359 | { |
| 1360 | 1360 | if (($_startMessage || $_numberOfMessages) && !isset($_filter['range'])) |
@@ -1367,24 +1367,24 @@ discard block |
||
| 1367 | 1367 | //$_filter['range'] ="$_startMessage:*"; |
| 1368 | 1368 | } |
| 1369 | 1369 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
| 1370 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1370 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1371 | 1371 | //see this example below for a 12 week datefilter (since) |
| 1372 | 1372 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1373 | 1373 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1374 | 1374 | $sortResult = $_sortResult['match']->ids; |
| 1375 | 1375 | //$modseq = $_sortResult['modseq']; |
| 1376 | 1376 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1377 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1377 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly), __METHOD__.' ('.__LINE__.') '); |
|
| 1378 | 1378 | |
| 1379 | 1379 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1380 | 1380 | #$this->icServer->setDebug(false); |
| 1381 | 1381 | #print "</pre>"; |
| 1382 | 1382 | // nothing found |
| 1383 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1383 | + if (!is_array($sortResult) || empty($sortResult)) { |
|
| 1384 | 1384 | $retValue = array(); |
| 1385 | 1385 | $retValue['info']['total'] = 0; |
| 1386 | 1386 | $retValue['info']['first'] = 0; |
| 1387 | - $retValue['info']['last'] = 0; |
|
| 1387 | + $retValue['info']['last'] = 0; |
|
| 1388 | 1388 | return $retValue; |
| 1389 | 1389 | } |
| 1390 | 1390 | |
@@ -1392,54 +1392,54 @@ discard block |
||
| 1392 | 1392 | #_debug_array($sortResult); |
| 1393 | 1393 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1394 | 1394 | //error_log("REVERSE: $reverse"); |
| 1395 | - if($reverse === true) { |
|
| 1396 | - if ($_startMessage<=$total) |
|
| 1395 | + if ($reverse === true) { |
|
| 1396 | + if ($_startMessage <= $total) |
|
| 1397 | 1397 | { |
| 1398 | - $startMessage = $_startMessage-1; |
|
| 1398 | + $startMessage = $_startMessage - 1; |
|
| 1399 | 1399 | } |
| 1400 | 1400 | else |
| 1401 | 1401 | { |
| 1402 | 1402 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1403 | - if ($_startMessage+$_numberOfMessages>$total) |
|
| 1403 | + if ($_startMessage + $_numberOfMessages > $total) |
|
| 1404 | 1404 | { |
| 1405 | - $numberOfMessages = $total%$_numberOfMessages; |
|
| 1405 | + $numberOfMessages = $total % $_numberOfMessages; |
|
| 1406 | 1406 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1407 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1407 | + if ($numberOfMessages > 0 && $numberOfMessages <= $_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1408 | 1408 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1409 | 1409 | } |
| 1410 | - $startMessage=($total-$_numberOfMessages)-1; |
|
| 1410 | + $startMessage = ($total - $_numberOfMessages) - 1; |
|
| 1411 | 1411 | //$retValue['info']['first'] = $startMessage; |
| 1412 | 1412 | //$retValue['info']['last'] = $total; |
| 1413 | 1413 | |
| 1414 | 1414 | } |
| 1415 | - if ($startMessage+$_numberOfMessages>$total) |
|
| 1415 | + if ($startMessage + $_numberOfMessages > $total) |
|
| 1416 | 1416 | { |
| 1417 | - $_numberOfMessages = $_numberOfMessages-($total-($startMessage+$_numberOfMessages)); |
|
| 1417 | + $_numberOfMessages = $_numberOfMessages - ($total - ($startMessage + $_numberOfMessages)); |
|
| 1418 | 1418 | //$retValue['info']['first'] = $startMessage; |
| 1419 | 1419 | //$retValue['info']['last'] = $total; |
| 1420 | 1420 | } |
| 1421 | - if($startMessage > 0) { |
|
| 1422 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1423 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
|
| 1421 | + if ($startMessage > 0) { |
|
| 1422 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + $startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1423 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + $startMessage), -$startMessage); |
|
| 1424 | 1424 | } else { |
| 1425 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1426 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
|
| 1425 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + ($_startMessage - 1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1426 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + ($_startMessage - 1))); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | $sortResult = array_reverse($sortResult); |
| 1429 | 1429 | } else { |
| 1430 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1431 | - $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
|
| 1430 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage - 1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1431 | + $sortResult = array_slice($sortResult, $_startMessage - 1, $_numberOfMessages); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1434 | 1434 | } |
| 1435 | 1435 | else |
| 1436 | 1436 | { |
| 1437 | - $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly:(array)$_thisUIDOnly); |
|
| 1437 | + $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly : (array)$_thisUIDOnly); |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | |
| 1441 | 1441 | // fetch the data for the selected messages |
| 1442 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1442 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1443 | 1443 | try |
| 1444 | 1444 | { |
| 1445 | 1445 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1448,22 +1448,22 @@ discard block |
||
| 1448 | 1448 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 1449 | 1449 | |
| 1450 | 1450 | // Pre-cache the headers we want, 'fetchHeaders' is a label into the cache |
| 1451 | - $fquery->headers('fetchHeaders',array( |
|
| 1452 | - 'DISPOSITION-NOTIFICATION-TO','RETURN-RECEIPT-TO','X-CONFIRM-READING-TO', |
|
| 1453 | - 'DATE','SUBJECT','FROM','TO','CC','REPLY-TO', |
|
| 1451 | + $fquery->headers('fetchHeaders', array( |
|
| 1452 | + 'DISPOSITION-NOTIFICATION-TO', 'RETURN-RECEIPT-TO', 'X-CONFIRM-READING-TO', |
|
| 1453 | + 'DATE', 'SUBJECT', 'FROM', 'TO', 'CC', 'REPLY-TO', |
|
| 1454 | 1454 | 'X-PRIORITY' |
| 1455 | - ),array( |
|
| 1455 | + ), array( |
|
| 1456 | 1456 | // Cache headers, we'll look at them below |
| 1457 | - 'cache' => true,//$_cacheResult, |
|
| 1457 | + 'cache' => true, //$_cacheResult, |
|
| 1458 | 1458 | // Set peek so messages are not flagged as read |
| 1459 | 1459 | 'peek' => true |
| 1460 | 1460 | )); |
| 1461 | 1461 | $fquery->size(); |
| 1462 | 1462 | $fquery->structure(); |
| 1463 | 1463 | $fquery->flags(); |
| 1464 | - $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1464 | + $fquery->imapDate(); // needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1465 | 1465 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1466 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1466 | + if ($_fetchPreviews) $fquery->fullText(array('peek'=>true, 'length'=>((int)$_fetchPreviews < 5000 ? 5000 : $_fetchPreviews), 'start'=>0)); |
|
| 1467 | 1467 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1468 | 1468 | 'ids' => $uidsToFetch, |
| 1469 | 1469 | )); |
@@ -1474,9 +1474,9 @@ discard block |
||
| 1474 | 1474 | $headersNew = array(); |
| 1475 | 1475 | $sortResult = array(); |
| 1476 | 1476 | } |
| 1477 | - if (self::$debug||self::$debugTimes) |
|
| 1477 | + if (self::$debug || self::$debugTimes) |
|
| 1478 | 1478 | { |
| 1479 | - self::logRunTimes($starttime,null,'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter),__METHOD__.' ('.__LINE__.') '); |
|
| 1479 | + self::logRunTimes($starttime, null, 'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter), __METHOD__.' ('.__LINE__.') '); |
|
| 1480 | 1480 | if (self::$debug) |
| 1481 | 1481 | { |
| 1482 | 1482 | $queryString = implode(',', $sortResult); |
@@ -1486,27 +1486,27 @@ discard block |
||
| 1486 | 1486 | |
| 1487 | 1487 | $cnt = 0; |
| 1488 | 1488 | |
| 1489 | - foreach((array)$sortResult as $uid) { |
|
| 1489 | + foreach ((array)$sortResult as $uid) { |
|
| 1490 | 1490 | $sortOrder[$uid] = $cnt++; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | $count = 0; |
| 1494 | 1494 | if (is_object($headersNew)) { |
| 1495 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1496 | - foreach($headersNew->ids() as $id) { |
|
| 1495 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1496 | + foreach ($headersNew->ids() as $id) { |
|
| 1497 | 1497 | $_headerObject = $headersNew->get($id); |
| 1498 | 1498 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1499 | 1499 | $headerObject = array(); |
| 1500 | 1500 | $bodyPreview = null; |
| 1501 | - $uid = $headerObject['UID']= ($_headerObject->getUid()?$_headerObject->getUid():$id); |
|
| 1501 | + $uid = $headerObject['UID'] = ($_headerObject->getUid() ? $_headerObject->getUid() : $id); |
|
| 1502 | 1502 | $headerObject['MSG_NUM'] = $_headerObject->getSeq(); |
| 1503 | 1503 | $headerObject['SIZE'] = $_headerObject->getSize(); |
| 1504 | 1504 | $headerObject['INTERNALDATE'] = $_headerObject->getImapDate(); |
| 1505 | 1505 | |
| 1506 | 1506 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1507 | - $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1507 | + $headerForPrio = $_headerObject->getHeaders('fetchHeaders', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1508 | 1508 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1509 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1509 | + if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1510 | 1510 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1511 | 1511 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1512 | 1512 | if ($_fetchPreviews) |
@@ -1514,16 +1514,16 @@ discard block |
||
| 1514 | 1514 | // on enabled preview $bodyPreview is needed lateron. fetched here, for fallback-reasons |
| 1515 | 1515 | // in case of failed Header-Retrieval |
| 1516 | 1516 | $bodyPreview = $_headerObject->getFullMsg(); |
| 1517 | - if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
|
| 1517 | + if (empty($headerForPrio) || (is_array($headerForPrio) && count($headerForPrio) === 1 && $headerForPrio[''])) |
|
| 1518 | 1518 | { |
| 1519 | 1519 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1520 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1521 | - $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
|
| 1520 | + if ($length === false) $length = strlen($bodyPreview); |
|
| 1521 | + $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0, $length))->toArray(); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1525 | 1525 | if (self::$debug) { |
| 1526 | - error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(),'Y-m-d H:i:s')); |
|
| 1526 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(), 'Y-m-d H:i:s')); |
|
| 1527 | 1527 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1528 | 1528 | } |
| 1529 | 1529 | // message deleted from server but cache still reporting its existence ; may happen on QRESYNC with No permanent modsequences |
@@ -1532,22 +1532,22 @@ discard block |
||
| 1532 | 1532 | $total--; |
| 1533 | 1533 | continue; |
| 1534 | 1534 | } |
| 1535 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1535 | + if (isset($headerForPrio['DISPOSITION-NOTIFICATION-TO'])) { |
|
| 1536 | 1536 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1537 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1537 | + } else if (isset($headerForPrio['RETURN-RECEIPT-TO'])) { |
|
| 1538 | 1538 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1539 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1539 | + } else if (isset($headerForPrio['X-CONFIRM-READING-TO'])) { |
|
| 1540 | 1540 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1541 | 1541 | } /*else $sent_not = "";*/ |
| 1542 | 1542 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1543 | 1543 | $headerObject['DATE'] = $headerForPrio['DATE']; |
| 1544 | - $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT'])?$headerForPrio['SUBJECT'][0]:$headerForPrio['SUBJECT']); |
|
| 1545 | - $headerObject['FROM'] = (array)($headerForPrio['FROM']?$headerForPrio['FROM']:($headerForPrio['REPLY-TO']?$headerForPrio['REPLY-TO']:$headerForPrio['RETURN-PATH'])); |
|
| 1544 | + $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT']) ? $headerForPrio['SUBJECT'][0] : $headerForPrio['SUBJECT']); |
|
| 1545 | + $headerObject['FROM'] = (array)($headerForPrio['FROM'] ? $headerForPrio['FROM'] : ($headerForPrio['REPLY-TO'] ? $headerForPrio['REPLY-TO'] : $headerForPrio['RETURN-PATH'])); |
|
| 1546 | 1546 | $headerObject['TO'] = (array)$headerForPrio['TO']; |
| 1547 | - $headerObject['CC'] = isset($headerForPrio['CC'])?(array)$headerForPrio['CC']:array(); |
|
| 1548 | - $headerObject['REPLY-TO'] = isset($headerForPrio['REPLY-TO'])?(array)$headerForPrio['REPLY-TO']:array(); |
|
| 1549 | - $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY'])?$headerForPrio['X-PRIORITY']:null; |
|
| 1550 | - foreach (array('FROM','TO','CC','REPLY-TO') as $key) |
|
| 1547 | + $headerObject['CC'] = isset($headerForPrio['CC']) ? (array)$headerForPrio['CC'] : array(); |
|
| 1548 | + $headerObject['REPLY-TO'] = isset($headerForPrio['REPLY-TO']) ? (array)$headerForPrio['REPLY-TO'] : array(); |
|
| 1549 | + $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY']) ? $headerForPrio['X-PRIORITY'] : null; |
|
| 1550 | + foreach (array('FROM', 'TO', 'CC', 'REPLY-TO') as $key) |
|
| 1551 | 1551 | { |
| 1552 | 1552 | $address = array(); |
| 1553 | 1553 | foreach ($headerObject[$key] as $k => $ad) |
@@ -1569,13 +1569,13 @@ discard block |
||
| 1569 | 1569 | foreach ($rfcAddr as $_rfcAddr) |
| 1570 | 1570 | { |
| 1571 | 1571 | if (!$_rfcAddr->valid) continue; // skip. not a valid address |
| 1572 | - $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
|
| 1572 | + $address[] = imap_rfc822_write_address($_rfcAddr->mailbox, $_rfcAddr->host, $_rfcAddr->personal); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | } |
| 1575 | 1575 | $headerObject[$key] = $address; |
| 1576 | 1576 | } |
| 1577 | 1577 | $headerObject['FLAGS'] = $_headerObject->getFlags(); |
| 1578 | - $headerObject['BODYPREVIEW']=null; |
|
| 1578 | + $headerObject['BODYPREVIEW'] = null; |
|
| 1579 | 1579 | // this section fetches part of the message-body (if enabled) for some kind of preview |
| 1580 | 1580 | // if we fail to succeed, we fall back to the retrieval of the message-body with |
| 1581 | 1581 | // fetchPartContents (see below, when we iterate over the structure to determine the |
@@ -1587,17 +1587,17 @@ discard block |
||
| 1587 | 1587 | if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
| 1588 | 1588 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1589 | 1589 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1590 | - foreach($base->partIterator() as $part) |
|
| 1590 | + foreach ($base->partIterator() as $part) |
|
| 1591 | 1591 | { |
| 1592 | 1592 | //error_log(__METHOD__.__LINE__.'Part:'.$part->getPrimaryType()); |
| 1593 | - if (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'text') |
|
| 1593 | + if (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'text') |
|
| 1594 | 1594 | { |
| 1595 | 1595 | $charset = $part->getContentTypeParameter('charset'); |
| 1596 | 1596 | $buffer = Mail\Html::convertHTMLToText($part->toString(array( |
| 1597 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1597 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1598 | 1598 | )), $charset, 'utf-8'); |
| 1599 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1600 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1599 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Translation::convert_jsonsafe($buffer), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1600 | + } elseif (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'multipart') |
|
| 1601 | 1601 | { |
| 1602 | 1602 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1603 | 1603 | } |
@@ -1608,12 +1608,12 @@ discard block |
||
| 1608 | 1608 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1609 | 1609 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeMap:'.array2string($mailStructureObject->contentTypeMap())); |
| 1610 | 1610 | //foreach ($_headerObject->getStructure()->getParts() as $p => $part) |
| 1611 | - $headerObject['ATTACHMENTS']=null; |
|
| 1612 | - $skipParts=array(); |
|
| 1613 | - $messageMimeType=''; |
|
| 1611 | + $headerObject['ATTACHMENTS'] = null; |
|
| 1612 | + $skipParts = array(); |
|
| 1613 | + $messageMimeType = ''; |
|
| 1614 | 1614 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1615 | 1615 | { |
| 1616 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1616 | + if ($mime_id == 0 || $messageMimeType === '') $messageMimeType = $mime_type; |
|
| 1617 | 1617 | $part = $mailStructureObject->getPart($mime_id); |
| 1618 | 1618 | $partdisposition = $part->getDisposition(); |
| 1619 | 1619 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1621,16 +1621,16 @@ discard block |
||
| 1621 | 1621 | // drawback here it is talking to the mailserver for each mail thus consuming |
| 1622 | 1622 | // more time than expected; so we call this section only when there is no |
| 1623 | 1623 | // bodypreview could be found (multipart/....) |
| 1624 | - if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
|
| 1624 | + if ($_fetchPreviews && empty($headerObject['BODYPREVIEW']) && ($partPrimaryType == 'text') && |
|
| 1625 | 1625 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1626 | 1626 | ($partdisposition !== 'attachment')) { |
| 1627 | - $_structure=$part; |
|
| 1628 | - $this->fetchPartContents($uid, $_structure, false,true); |
|
| 1629 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1630 | - $charSet=Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1627 | + $_structure = $part; |
|
| 1628 | + $this->fetchPartContents($uid, $_structure, false, true); |
|
| 1629 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1630 | + $charSet = Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1631 | 1631 | // add line breaks to $bodyParts |
| 1632 | 1632 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 1633 | - $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1633 | + $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1634 | 1634 | //error_log(__METHOD__.__LINE__.$headerObject['BODYPREVIEW']); |
| 1635 | 1635 | } |
| 1636 | 1636 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType); |
@@ -1640,28 +1640,28 @@ discard block |
||
| 1640 | 1640 | // the presence of an cid does not necessarily indicate its inline. it may lack the needed |
| 1641 | 1641 | // link to show the image. Considering this: we "list" everything that matches the above criteria |
| 1642 | 1642 | // as attachment in order to not loose/miss information on our data |
| 1643 | - $partdisposition='attachment';//($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1643 | + $partdisposition = 'attachment'; //($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1644 | 1644 | } |
| 1645 | - if ($mime_type=='message/rfc822') |
|
| 1645 | + if ($mime_type == 'message/rfc822') |
|
| 1646 | 1646 | { |
| 1647 | 1647 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1648 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1648 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 1649 | 1649 | } |
| 1650 | 1650 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1651 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1652 | - if ($partdisposition=='attachment' || |
|
| 1653 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
|
| 1654 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
|
| 1655 | - ($partdisposition=='inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1651 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 1652 | + if ($partdisposition == 'attachment' || |
|
| 1653 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && $mime_type == 'image/tiff') || // as we are not able to display tiffs |
|
| 1654 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && empty($cid)) || |
|
| 1655 | + ($partdisposition == 'inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1656 | 1656 | { |
| 1657 | - $headerObject['ATTACHMENTS'][$mime_id]=$part->getAllDispositionParameters(); |
|
| 1658 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=$mime_type; |
|
| 1659 | - $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
|
| 1657 | + $headerObject['ATTACHMENTS'][$mime_id] = $part->getAllDispositionParameters(); |
|
| 1658 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] = $mime_type; |
|
| 1659 | + $headerObject['ATTACHMENTS'][$mime_id]['uid'] = $uid; |
|
| 1660 | 1660 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1661 | - $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
|
| 1662 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1663 | - if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
|
| 1664 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
|
| 1661 | + $headerObject['ATTACHMENTS'][$mime_id]['partID'] = $mime_id; |
|
| 1662 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name'] = $part->getName(); |
|
| 1663 | + if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'], 'winmail.dat') || |
|
| 1664 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] == 'application/ms-tnef') |
|
| 1665 | 1665 | { |
| 1666 | 1666 | $headerObject['ATTACHMENTS'][$mime_id]['is_winmail'] = true; |
| 1667 | 1667 | } |
@@ -1676,57 +1676,57 @@ discard block |
||
| 1676 | 1676 | if (empty($headerObject['UID'])) continue; |
| 1677 | 1677 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1678 | 1678 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1679 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1679 | + if (substr($headerObject['DATE'], -2) === 'UT') { |
|
| 1680 | 1680 | $headerObject['DATE'] .= 'C'; |
| 1681 | 1681 | } |
| 1682 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1682 | + if (substr($headerObject['INTERNALDATE'], -2) === 'UT') { |
|
| 1683 | 1683 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1684 | 1684 | } |
| 1685 | 1685 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1686 | 1686 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1687 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1688 | - $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1689 | - $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1690 | - $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
|
| 1691 | - $retValue['header'][$sortOrder[$uid]]['internaldate']= self::_strtotime($headerObject['INTERNALDATE'],'ts',true); |
|
| 1692 | - $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1693 | - $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1694 | - $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1695 | - $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1696 | - $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
|
| 1687 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][] = $a; } |
|
| 1688 | + $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1689 | + $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1690 | + $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE'] && !($headerObject['DATE'] == 'NIL') ? $headerObject['DATE'] : $headerObject['INTERNALDATE']), 'ts', true); |
|
| 1691 | + $retValue['header'][$sortOrder[$uid]]['internaldate'] = self::_strtotime($headerObject['INTERNALDATE'], 'ts', true); |
|
| 1692 | + $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1693 | + $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1694 | + $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1695 | + $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1696 | + $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY'] ? $headerObject['PRIORITY'] : 3); |
|
| 1697 | 1697 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1698 | 1698 | if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
| 1699 | 1699 | if (is_array($headerObject['FLAGS'])) { |
| 1700 | - $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
|
| 1700 | + $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]], self::prepareFlagsArray($headerObject)); |
|
| 1701 | 1701 | } |
| 1702 | 1702 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1703 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1704 | - $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
|
| 1703 | + if (is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1704 | + $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0], true); |
|
| 1705 | 1705 | } |
| 1706 | - if(is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) { |
|
| 1707 | - $retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0],true); |
|
| 1706 | + if (is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) { |
|
| 1707 | + $retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0], true); |
|
| 1708 | 1708 | } |
| 1709 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1710 | - $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
|
| 1711 | - if (count($headerObject['TO'])>1) |
|
| 1709 | + if (is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1710 | + $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0], true); |
|
| 1711 | + if (count($headerObject['TO']) > 1) |
|
| 1712 | 1712 | { |
| 1713 | - $ki=0; |
|
| 1714 | - foreach($headerObject['TO'] as $k => $add) |
|
| 1713 | + $ki = 0; |
|
| 1714 | + foreach ($headerObject['TO'] as $k => $add) |
|
| 1715 | 1715 | { |
| 1716 | - if ($k==0) continue; |
|
| 1716 | + if ($k == 0) continue; |
|
| 1717 | 1717 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1718 | - $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
|
| 1718 | + $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add, true); |
|
| 1719 | 1719 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1720 | 1720 | $ki++; |
| 1721 | 1721 | } |
| 1722 | 1722 | } |
| 1723 | 1723 | } |
| 1724 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 1725 | - $ki=0; |
|
| 1726 | - foreach($headerObject['CC'] as $k => $add) |
|
| 1724 | + if (is_array($headerObject['CC']) && count($headerObject['CC']) > 0) { |
|
| 1725 | + $ki = 0; |
|
| 1726 | + foreach ($headerObject['CC'] as $k => $add) |
|
| 1727 | 1727 | { |
| 1728 | 1728 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1729 | - $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add,true); |
|
| 1729 | + $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add, true); |
|
| 1730 | 1730 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1731 | 1731 | $ki++; |
| 1732 | 1732 | } |
@@ -1735,27 +1735,27 @@ discard block |
||
| 1735 | 1735 | |
| 1736 | 1736 | $count++; |
| 1737 | 1737 | } |
| 1738 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 1738 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' fetching Headers and stuff for Folder:'.$_folderName, __METHOD__.' ('.__LINE__.') '); |
|
| 1739 | 1739 | //self::$debug=false; |
| 1740 | 1740 | // sort the messages to the requested displayorder |
| 1741 | - if(is_array($retValue['header'])) { |
|
| 1741 | + if (is_array($retValue['header'])) { |
|
| 1742 | 1742 | $countMessages = $total; |
| 1743 | 1743 | if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
| 1744 | 1744 | ksort($retValue['header']); |
| 1745 | 1745 | $retValue['info']['total'] = $total; |
| 1746 | 1746 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1747 | 1747 | $retValue['info']['first'] = $_startMessage; |
| 1748 | - $retValue['info']['last'] = $_startMessage + $count - 1 ; |
|
| 1748 | + $retValue['info']['last'] = $_startMessage + $count - 1; |
|
| 1749 | 1749 | return $retValue; |
| 1750 | 1750 | } else { |
| 1751 | 1751 | $retValue = array(); |
| 1752 | 1752 | $retValue['info']['total'] = 0; |
| 1753 | 1753 | $retValue['info']['first'] = 0; |
| 1754 | - $retValue['info']['last'] = 0; |
|
| 1754 | + $retValue['info']['last'] = 0; |
|
| 1755 | 1755 | return $retValue; |
| 1756 | 1756 | } |
| 1757 | 1757 | } else { |
| 1758 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 1758 | + if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew, TRUE)); |
|
| 1759 | 1759 | $retValue = array(); |
| 1760 | 1760 | $retValue['info']['total'] = 0; |
| 1761 | 1761 | $retValue['info']['first'] = 0; |
@@ -1772,17 +1772,17 @@ discard block |
||
| 1772 | 1772 | */ |
| 1773 | 1773 | static function prepareFlagsArray($headerObject) |
| 1774 | 1774 | { |
| 1775 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 1775 | + if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower', $headerObject['FLAGS']); |
|
| 1776 | 1776 | $retValue = array(); |
| 1777 | 1777 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1778 | 1778 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
| 1779 | - $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1780 | - $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1779 | + $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1780 | + $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1781 | 1781 | $retValue['deleted'] = in_array('\\deleted', $headerFlags); |
| 1782 | - $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1783 | - $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1784 | - $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags)||in_array('mdnsent', $headerFlags); |
|
| 1785 | - $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags)||in_array('mdnnotsent', $headerFlags); |
|
| 1782 | + $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1783 | + $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1784 | + $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags) || in_array('mdnsent', $headerFlags); |
|
| 1785 | + $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags) || in_array('mdnnotsent', $headerFlags); |
|
| 1786 | 1786 | $retValue['label1'] = in_array('$label1', $headerFlags); |
| 1787 | 1787 | $retValue['label2'] = in_array('$label2', $headerFlags); |
| 1788 | 1788 | $retValue['label3'] = in_array('$label3', $headerFlags); |
@@ -1806,12 +1806,12 @@ discard block |
||
| 1806 | 1806 | * @param bool $setSession if set to true the session will be populated with the result of the query |
| 1807 | 1807 | * @return mixed bool/array false or array of ids |
| 1808 | 1808 | */ |
| 1809 | - function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid=true, $setSession=true) |
|
| 1809 | + function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid = true, $setSession = true) |
|
| 1810 | 1810 | { |
| 1811 | 1811 | static $cachedFolderStatus = null; |
| 1812 | 1812 | // in the past we needed examineMailbox to figure out if the server with the serverID support keywords |
| 1813 | 1813 | // this information is filled/provided by examineMailbox; but caching within one request seems o.k. |
| 1814 | - if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) ) |
|
| 1814 | + if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName])) |
|
| 1815 | 1815 | { |
| 1816 | 1816 | $folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName); |
| 1817 | 1817 | } |
@@ -1823,29 +1823,29 @@ discard block |
||
| 1823 | 1823 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1824 | 1824 | $try2useCache = true; |
| 1825 | 1825 | static $eMailListContainsDeletedMessages = null; |
| 1826 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 1826 | + if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 1827 | 1827 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1828 | - if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1828 | + if ($setSession == true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1829 | 1829 | { |
| 1830 | 1830 | if (self::$debugTimes) $starttime = microtime(true); |
| 1831 | - if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 1832 | - $five=true; |
|
| 1833 | - $dReverse=1; |
|
| 1834 | - $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')),$five,false); |
|
| 1831 | + if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 1832 | + $five = true; |
|
| 1833 | + $dReverse = 1; |
|
| 1834 | + $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')), $five, false); |
|
| 1835 | 1835 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
| 1836 | - $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 1837 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 1838 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']); |
|
| 1836 | + $eMailListContainsDeletedMessages[$this->profileID][$_folderName] = $deletedMessages['count']; |
|
| 1837 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), $eMailListContainsDeletedMessages, 60 * 60 * 1); |
|
| 1838 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName], __METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']); |
|
| 1839 | 1839 | } |
| 1840 | 1840 | $try2useCache = false; |
| 1841 | 1841 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1842 | 1842 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1843 | 1843 | { |
| 1844 | - self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 1845 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 1844 | + self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1845 | + if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID] = true; |
|
| 1846 | 1846 | } |
| 1847 | 1847 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1848 | - $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
|
| 1848 | + $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
|
| 1849 | 1849 | if (self::$debug) |
| 1850 | 1850 | { |
| 1851 | 1851 | $query_str = $filter->build(); |
@@ -1853,14 +1853,14 @@ discard block |
||
| 1853 | 1853 | } |
| 1854 | 1854 | //_debug_array($filter); |
| 1855 | 1855 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1856 | - if($this->icServer->hasCapability('SORT')) { |
|
| 1856 | + if ($this->icServer->hasCapability('SORT')) { |
|
| 1857 | 1857 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1858 | 1858 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1859 | 1859 | // there is no messing with the dates) |
| 1860 | 1860 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1861 | 1861 | if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
| 1862 | 1862 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1863 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1863 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE, $sortOrder)) $_reverse = false; // as we reversed the result already |
|
| 1864 | 1864 | if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
| 1865 | 1865 | try |
| 1866 | 1866 | { |
@@ -1868,24 +1868,24 @@ discard block |
||
| 1868 | 1868 | 'sort' => $sortOrder,)); |
| 1869 | 1869 | // if there is an Error, we assume that the server is not capable of sorting |
| 1870 | 1870 | } |
| 1871 | - catch(\Exception $e) |
|
| 1871 | + catch (\Exception $e) |
|
| 1872 | 1872 | { |
| 1873 | 1873 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1874 | 1874 | $resultByUid = false; |
| 1875 | 1875 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1876 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 1876 | + if ($_reverse) array_unshift($sortOrder, Horde_Imap_Client::SORT_REVERSE); |
|
| 1877 | 1877 | try |
| 1878 | 1878 | { |
| 1879 | 1879 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
| 1880 | 1880 | 'sort' => $sortOrder)); |
| 1881 | 1881 | } |
| 1882 | - catch(\Exception $e) |
|
| 1882 | + catch (\Exception $e) |
|
| 1883 | 1883 | { |
| 1884 | 1884 | error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1885 | 1885 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1888 | + if (self::$debug) error_log(__METHOD__.print_r($sortResult, true)); |
|
| 1889 | 1889 | } else { |
| 1890 | 1890 | if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
| 1891 | 1891 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
@@ -1895,12 +1895,12 @@ discard block |
||
| 1895 | 1895 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1896 | 1896 | 'sort' => $sortOrder)*/); |
| 1897 | 1897 | } |
| 1898 | - catch(\Exception $e) |
|
| 1898 | + catch (\Exception $e) |
|
| 1899 | 1899 | { |
| 1900 | 1900 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1901 | 1901 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1902 | - self::$supportsORinQuery[$this->profileID]=false; |
|
| 1903 | - Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
|
| 1902 | + self::$supportsORinQuery[$this->profileID] = false; |
|
| 1903 | + Cache::setCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), self::$supportsORinQuery, 60 * 60 * 10); |
|
| 1904 | 1904 | if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
| 1905 | 1905 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1906 | 1906 | try |
@@ -1908,25 +1908,25 @@ discard block |
||
| 1908 | 1908 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1909 | 1909 | 'sort' => $sortOrder)*/); |
| 1910 | 1910 | } |
| 1911 | - catch(\Exception $e) |
|
| 1911 | + catch (\Exception $e) |
|
| 1912 | 1912 | { |
| 1913 | 1913 | } |
| 1914 | 1914 | } |
| 1915 | - if(is_array($sortResult['match'])) { |
|
| 1915 | + if (is_array($sortResult['match'])) { |
|
| 1916 | 1916 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1917 | 1917 | sort($sortResult['match'], SORT_NUMERIC); |
| 1918 | 1918 | } |
| 1919 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 1919 | + if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter, true)." ->".print_r($sortResult, true)); |
|
| 1920 | 1920 | } |
| 1921 | 1921 | if ($setSession) |
| 1922 | 1922 | { |
| 1923 | 1923 | self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY']; |
| 1924 | - self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1924 | + self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1925 | 1925 | self::$folderStatusCache[$this->profileID][$_folderName]['deleted'] = $eMailListContainsDeletedMessages[$this->profileID][$_folderName]; |
| 1926 | 1926 | self::$folderStatusCache[$this->profileID][$_folderName]['uidnext'] = $folderStatus['UIDNEXT']; |
| 1927 | - self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1927 | + self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1928 | 1928 | self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult; |
| 1929 | - self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1929 | + self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1930 | 1930 | } |
| 1931 | 1931 | //error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
| 1932 | 1932 | //_debug_array($sortResult['match']->ids); |
@@ -1940,12 +1940,12 @@ discard block |
||
| 1940 | 1940 | * @param bool _reverse wether to add REVERSE to the Sort String or not |
| 1941 | 1941 | * @return the sort sequence for horde search |
| 1942 | 1942 | */ |
| 1943 | - function _getSortString($_sort, $_reverse=false) |
|
| 1943 | + function _getSortString($_sort, $_reverse = false) |
|
| 1944 | 1944 | { |
| 1945 | - $_reverse=false; |
|
| 1945 | + $_reverse = false; |
|
| 1946 | 1946 | if (is_numeric($_sort)) |
| 1947 | 1947 | { |
| 1948 | - switch($_sort) { |
|
| 1948 | + switch ($_sort) { |
|
| 1949 | 1949 | case 2: |
| 1950 | 1950 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1951 | 1951 | break; |
@@ -1967,7 +1967,7 @@ discard block |
||
| 1967 | 1967 | } |
| 1968 | 1968 | else |
| 1969 | 1969 | { |
| 1970 | - switch(strtoupper($_sort)) { |
|
| 1970 | + switch (strtoupper($_sort)) { |
|
| 1971 | 1971 | case 'FROMADDRESS': |
| 1972 | 1972 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1973 | 1973 | break; |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | break; |
| 1994 | 1994 | } |
| 1995 | 1995 | } |
| 1996 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 1996 | + if ($_reverse) array_unshift($retValue, Horde_Imap_Client::SORT_REVERSE); |
|
| 1997 | 1997 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1998 | 1998 | return $retValue; |
| 1999 | 1999 | } |
@@ -2006,28 +2006,28 @@ discard block |
||
| 2006 | 2006 | * @param boolean $_supportsOrInQuery wether to use the OR Query on QuickSearch |
| 2007 | 2007 | * @return Horde_Imap_Client_Search_Query the IMAP filter |
| 2008 | 2008 | */ |
| 2009 | - function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery=true) |
|
| 2009 | + function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery = true) |
|
| 2010 | 2010 | { |
| 2011 | 2011 | $imapFilter = new Horde_Imap_Client_Search_Query(); |
| 2012 | 2012 | $imapFilter->charset('UTF-8'); |
| 2013 | 2013 | |
| 2014 | 2014 | //_debug_array($_criterias); |
| 2015 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2016 | - if((!is_array($_criterias) || $_criterias['status']=='any') && |
|
| 2015 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias) ? " none -> returning" : array2string($_criterias))); |
|
| 2016 | + if ((!is_array($_criterias) || $_criterias['status'] == 'any') && |
|
| 2017 | 2017 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 2018 | - (!isset($_criterias['range'])|| empty($_criterias['range']) || |
|
| 2019 | - ( !empty($_criterias['range'])&& ($_criterias['range']!='BETWEEN' && empty($_criterias['date'])|| |
|
| 2020 | - ($_criterias['range']=='BETWEEN' && empty($_criterias['since'])&& empty($_criterias['before'])))))) |
|
| 2018 | + (!isset($_criterias['range']) || empty($_criterias['range']) || |
|
| 2019 | + (!empty($_criterias['range']) && ($_criterias['range'] != 'BETWEEN' && empty($_criterias['date']) || |
|
| 2020 | + ($_criterias['range'] == 'BETWEEN' && empty($_criterias['since']) && empty($_criterias['before'])))))) |
|
| 2021 | 2021 | { |
| 2022 | 2022 | //error_log(__METHOD__.' ('.__LINE__.') returning early Criterias:'.print_r($_criterias, true)); |
| 2023 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2023 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2024 | 2024 | return $imapFilter; |
| 2025 | 2025 | } |
| 2026 | 2026 | $queryValid = false; |
| 2027 | 2027 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 2028 | 2028 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 2029 | 2029 | $statusQueryValid = false; |
| 2030 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 2030 | + foreach ((array)$_criterias['status'] as $k => $criteria) { |
|
| 2031 | 2031 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 2032 | 2032 | $imapStatusFilter->charset('UTF-8'); |
| 2033 | 2033 | $criteria = strtoupper($criteria); |
@@ -2037,12 +2037,12 @@ discard block |
||
| 2037 | 2037 | case 'FLAGGED': |
| 2038 | 2038 | case 'RECENT': |
| 2039 | 2039 | case 'SEEN': |
| 2040 | - $imapStatusFilter->flag($criteria, $set=true); |
|
| 2041 | - $queryValid = $statusQueryValid =true; |
|
| 2040 | + $imapStatusFilter->flag($criteria, $set = true); |
|
| 2041 | + $queryValid = $statusQueryValid = true; |
|
| 2042 | 2042 | break; |
| 2043 | 2043 | case 'READ': |
| 2044 | - $imapStatusFilter->flag('SEEN', $set=true); |
|
| 2045 | - $queryValid = $statusQueryValid =true; |
|
| 2044 | + $imapStatusFilter->flag('SEEN', $set = true); |
|
| 2045 | + $queryValid = $statusQueryValid = true; |
|
| 2046 | 2046 | break; |
| 2047 | 2047 | case 'LABEL1': |
| 2048 | 2048 | case 'KEYWORD1': |
@@ -2054,38 +2054,38 @@ discard block |
||
| 2054 | 2054 | case 'KEYWORD4': |
| 2055 | 2055 | case 'LABEL5': |
| 2056 | 2056 | case 'KEYWORD5': |
| 2057 | - $imapStatusFilter->flag(str_ireplace('KEYWORD','$LABEL',$criteria), $set=true); |
|
| 2058 | - $queryValid = $statusQueryValid =true; |
|
| 2057 | + $imapStatusFilter->flag(str_ireplace('KEYWORD', '$LABEL', $criteria), $set = true); |
|
| 2058 | + $queryValid = $statusQueryValid = true; |
|
| 2059 | 2059 | break; |
| 2060 | 2060 | case 'NEW': |
| 2061 | - $imapStatusFilter->flag('RECENT', $set=true); |
|
| 2062 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2063 | - $queryValid = $statusQueryValid =true; |
|
| 2061 | + $imapStatusFilter->flag('RECENT', $set = true); |
|
| 2062 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2063 | + $queryValid = $statusQueryValid = true; |
|
| 2064 | 2064 | break; |
| 2065 | 2065 | case 'OLD': |
| 2066 | - $imapStatusFilter->flag('RECENT', $set=false); |
|
| 2067 | - $queryValid = $statusQueryValid =true; |
|
| 2066 | + $imapStatusFilter->flag('RECENT', $set = false); |
|
| 2067 | + $queryValid = $statusQueryValid = true; |
|
| 2068 | 2068 | break; |
| 2069 | 2069 | // operate only on system flags |
| 2070 | 2070 | // $systemflags = array( |
| 2071 | 2071 | // 'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'RECENT', 'SEEN' |
| 2072 | 2072 | // ); |
| 2073 | 2073 | case 'UNANSWERED': |
| 2074 | - $imapStatusFilter->flag('ANSWERED', $set=false); |
|
| 2075 | - $queryValid = $statusQueryValid =true; |
|
| 2074 | + $imapStatusFilter->flag('ANSWERED', $set = false); |
|
| 2075 | + $queryValid = $statusQueryValid = true; |
|
| 2076 | 2076 | break; |
| 2077 | 2077 | case 'UNDELETED': |
| 2078 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2078 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2079 | 2079 | $queryValid = true; |
| 2080 | 2080 | break; |
| 2081 | 2081 | case 'UNFLAGGED': |
| 2082 | - $imapStatusFilter->flag('FLAGGED', $set=false); |
|
| 2083 | - $queryValid = $statusQueryValid =true; |
|
| 2082 | + $imapStatusFilter->flag('FLAGGED', $set = false); |
|
| 2083 | + $queryValid = $statusQueryValid = true; |
|
| 2084 | 2084 | break; |
| 2085 | 2085 | case 'UNREAD': |
| 2086 | 2086 | case 'UNSEEN': |
| 2087 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2088 | - $queryValid = $statusQueryValid =true; |
|
| 2087 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2088 | + $queryValid = $statusQueryValid = true; |
|
| 2089 | 2089 | break; |
| 2090 | 2090 | case 'UNLABEL1': |
| 2091 | 2091 | case 'UNKEYWORD1': |
@@ -2097,8 +2097,8 @@ discard block |
||
| 2097 | 2097 | case 'UNKEYWORD4': |
| 2098 | 2098 | case 'UNLABEL5': |
| 2099 | 2099 | case 'UNKEYWORD5': |
| 2100 | - $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD','UNLABEL'),'$LABEL',$criteria), $set=false); |
|
| 2101 | - $queryValid = $statusQueryValid =true; |
|
| 2100 | + $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD', 'UNLABEL'), '$LABEL', $criteria), $set = false); |
|
| 2101 | + $queryValid = $statusQueryValid = true; |
|
| 2102 | 2102 | break; |
| 2103 | 2103 | default: |
| 2104 | 2104 | $statusQueryValid = false; |
@@ -2114,20 +2114,20 @@ discard block |
||
| 2114 | 2114 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2115 | 2115 | $imapSearchFilter->charset('UTF-8'); |
| 2116 | 2116 | |
| 2117 | - if(!empty($_criterias['string'])) { |
|
| 2117 | + if (!empty($_criterias['string'])) { |
|
| 2118 | 2118 | $criteria = strtoupper($_criterias['type']); |
| 2119 | 2119 | switch ($criteria) { |
| 2120 | 2120 | case 'BYDATE': |
| 2121 | 2121 | case 'QUICK': |
| 2122 | 2122 | case 'QUICKWITHCC': |
| 2123 | - $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not=false); |
|
| 2123 | + $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not = false); |
|
| 2124 | 2124 | //$imapSearchFilter->charset('UTF-8'); |
| 2125 | 2125 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2126 | 2126 | $imapFilter2->charset('UTF-8'); |
| 2127 | - if($this->isSentFolder($_folder)) { |
|
| 2128 | - $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
|
| 2127 | + if ($this->isSentFolder($_folder)) { |
|
| 2128 | + $imapFilter2->headerText('TO', $_criterias['string'], $not = false); |
|
| 2129 | 2129 | } else { |
| 2130 | - $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
|
| 2130 | + $imapFilter2->headerText('FROM', $_criterias['string'], $not = false); |
|
| 2131 | 2131 | } |
| 2132 | 2132 | if ($_supportsOrInQuery) |
| 2133 | 2133 | { |
@@ -2137,31 +2137,31 @@ discard block |
||
| 2137 | 2137 | { |
| 2138 | 2138 | $imapSearchFilter->andSearch($imapFilter2); |
| 2139 | 2139 | } |
| 2140 | - if ($_supportsOrInQuery && $criteria=='QUICKWITHCC') |
|
| 2140 | + if ($_supportsOrInQuery && $criteria == 'QUICKWITHCC') |
|
| 2141 | 2141 | { |
| 2142 | 2142 | $imapFilter3 = new Horde_Imap_Client_Search_Query(); |
| 2143 | 2143 | $imapFilter3->charset('UTF-8'); |
| 2144 | - $imapFilter3->headerText('CC', $_criterias['string'], $not=false); |
|
| 2144 | + $imapFilter3->headerText('CC', $_criterias['string'], $not = false); |
|
| 2145 | 2145 | $imapSearchFilter->orSearch($imapFilter3); |
| 2146 | 2146 | } |
| 2147 | 2147 | $queryValid = true; |
| 2148 | 2148 | break; |
| 2149 | 2149 | case 'LARGER': |
| 2150 | 2150 | case 'SMALLER': |
| 2151 | - if (strlen(trim($_criterias['string'])) != strlen((float) trim($_criterias['string']))) |
|
| 2151 | + if (strlen(trim($_criterias['string'])) != strlen((float)trim($_criterias['string']))) |
|
| 2152 | 2152 | { |
| 2153 | 2153 | //examine string to evaluate size |
| 2154 | - $unit = strtoupper(trim(substr(trim($_criterias['string']),strlen((float) trim($_criterias['string']))))); |
|
| 2155 | - $multipleBy = array('KB'=>1024,'K'=>1024, |
|
| 2156 | - 'MB'=>1024*1000,'M'=>1024*1000, |
|
| 2157 | - 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
|
| 2158 | - 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
|
| 2159 | - $numberinBytes=(float)$_criterias['string']; |
|
| 2160 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2154 | + $unit = strtoupper(trim(substr(trim($_criterias['string']), strlen((float)trim($_criterias['string']))))); |
|
| 2155 | + $multipleBy = array('KB'=>1024, 'K'=>1024, |
|
| 2156 | + 'MB'=>1024 * 1000, 'M'=>1024 * 1000, |
|
| 2157 | + 'GB'=>1024 * 1000 * 1000, 'G'=>1024 * 1000 * 1000, |
|
| 2158 | + 'TB'=>1024 * 1000 * 1000 * 1000, 'T'=>1024 * 1000 * 1000 * 1000); |
|
| 2159 | + $numberinBytes = (float)$_criterias['string']; |
|
| 2160 | + if (isset($multipleBy[$unit])) $numberinBytes = (float)$_criterias['string'] * $multipleBy[$unit]; |
|
| 2161 | 2161 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2162 | - $_criterias['string']=$numberinBytes; |
|
| 2162 | + $_criterias['string'] = $numberinBytes; |
|
| 2163 | 2163 | } |
| 2164 | - $imapSearchFilter->size( $_criterias['string'], ($criteria=='LARGER'?true:false), $not=false); |
|
| 2164 | + $imapSearchFilter->size($_criterias['string'], ($criteria == 'LARGER' ? true : false), $not = false); |
|
| 2165 | 2165 | //$imapSearchFilter->charset('UTF-8'); |
| 2166 | 2166 | $queryValid = true; |
| 2167 | 2167 | break; |
@@ -2170,31 +2170,31 @@ discard block |
||
| 2170 | 2170 | case 'CC': |
| 2171 | 2171 | case 'BCC': |
| 2172 | 2172 | case 'SUBJECT': |
| 2173 | - $imapSearchFilter->headerText($criteria, $_criterias['string'], $not=false); |
|
| 2173 | + $imapSearchFilter->headerText($criteria, $_criterias['string'], $not = false); |
|
| 2174 | 2174 | //$imapSearchFilter->charset('UTF-8'); |
| 2175 | 2175 | $queryValid = true; |
| 2176 | 2176 | break; |
| 2177 | 2177 | case 'BODY': |
| 2178 | 2178 | case 'TEXT': |
| 2179 | - $imapSearchFilter->text($_criterias['string'],($criteria=='BODY'?true:false), $not=false); |
|
| 2179 | + $imapSearchFilter->text($_criterias['string'], ($criteria == 'BODY' ? true : false), $not = false); |
|
| 2180 | 2180 | //$imapSearchFilter->charset('UTF-8'); |
| 2181 | 2181 | $queryValid = true; |
| 2182 | 2182 | break; |
| 2183 | 2183 | case 'SINCE': |
| 2184 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2184 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2185 | 2185 | $queryValid = true; |
| 2186 | 2186 | break; |
| 2187 | 2187 | case 'BEFORE': |
| 2188 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2188 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2189 | 2189 | $queryValid = true; |
| 2190 | 2190 | break; |
| 2191 | 2191 | case 'ON': |
| 2192 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2192 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2193 | 2193 | $queryValid = true; |
| 2194 | 2194 | break; |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2197 | + if ($statusQueryValid && !$queryValid) $queryValid = true; |
|
| 2198 | 2198 | if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
| 2199 | 2199 | |
| 2200 | 2200 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
@@ -2203,12 +2203,12 @@ discard block |
||
| 2203 | 2203 | $imapRangeFilter = new Horde_Imap_Client_Search_Query(); |
| 2204 | 2204 | $imapRangeFilter->charset('UTF-8'); |
| 2205 | 2205 | $criteria = strtoupper($_criterias['range']); |
| 2206 | - if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since']==$_criterias['before']) |
|
| 2206 | + if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since'] == $_criterias['before']) |
|
| 2207 | 2207 | { |
| 2208 | - $_criterias['date']=$_criterias['since']; |
|
| 2208 | + $_criterias['date'] = $_criterias['since']; |
|
| 2209 | 2209 | unset($_criterias['since']); |
| 2210 | 2210 | unset($_criterias['before']); |
| 2211 | - $criteria=$_criterias['range']='ON'; |
|
| 2211 | + $criteria = $_criterias['range'] = 'ON'; |
|
| 2212 | 2212 | } |
| 2213 | 2213 | switch ($criteria) { |
| 2214 | 2214 | case 'BETWEEN': |
@@ -2216,7 +2216,7 @@ discard block |
||
| 2216 | 2216 | //enddate |
| 2217 | 2217 | if ($_criterias['since']) |
| 2218 | 2218 | { |
| 2219 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2219 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2220 | 2220 | $rangeValid = true; |
| 2221 | 2221 | } |
| 2222 | 2222 | //startdate |
@@ -2225,28 +2225,28 @@ discard block |
||
| 2225 | 2225 | $imapRangeFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2226 | 2226 | $imapRangeFilter2->charset('UTF-8'); |
| 2227 | 2227 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2228 | - $_criterias['before'] = date("d-M-Y",DateTime::to($_criterias['before'],'ts')+(3600*24)); |
|
| 2229 | - $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2228 | + $_criterias['before'] = date("d-M-Y", DateTime::to($_criterias['before'], 'ts') + (3600 * 24)); |
|
| 2229 | + $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2230 | 2230 | $imapRangeFilter->andSearch($imapRangeFilter2); |
| 2231 | 2231 | $rangeValid = true; |
| 2232 | 2232 | } |
| 2233 | 2233 | break; |
| 2234 | 2234 | case 'SINCE'://enddate |
| 2235 | - $imapRangeFilter->dateSearch(new DateTime(($_criterias['since']?$_criterias['since']:$_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2235 | + $imapRangeFilter->dateSearch(new DateTime(($_criterias['since'] ? $_criterias['since'] : $_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2236 | 2236 | $rangeValid = true; |
| 2237 | 2237 | break; |
| 2238 | 2238 | case 'BEFORE'://startdate |
| 2239 | 2239 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2240 | - $_criterias['before'] = date("d-M-Y",DateTime::to(($_criterias['before']?$_criterias['before']:$_criterias['date']),'ts')+(3600*24)); |
|
| 2241 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2240 | + $_criterias['before'] = date("d-M-Y", DateTime::to(($_criterias['before'] ? $_criterias['before'] : $_criterias['date']), 'ts') + (3600 * 24)); |
|
| 2241 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2242 | 2242 | $rangeValid = true; |
| 2243 | 2243 | break; |
| 2244 | 2244 | case 'ON': |
| 2245 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2245 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2246 | 2246 | $rangeValid = true; |
| 2247 | 2247 | break; |
| 2248 | 2248 | } |
| 2249 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2249 | + if ($rangeValid && !$queryValid) $queryValid = true; |
|
| 2250 | 2250 | if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
| 2251 | 2251 | } |
| 2252 | 2252 | if (self::$debug) |
@@ -2255,8 +2255,8 @@ discard block |
||
| 2255 | 2255 | $query_str = $imapFilter->build(); |
| 2256 | 2256 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2257 | 2257 | } |
| 2258 | - if($queryValid==false) { |
|
| 2259 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2258 | + if ($queryValid == false) { |
|
| 2259 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2260 | 2260 | return $imapFilter; |
| 2261 | 2261 | } else { |
| 2262 | 2262 | return $imapFilter; |
@@ -2270,11 +2270,11 @@ discard block |
||
| 2270 | 2270 | * @param mixed/boolean $_tryIDNConversion (true/false AND FORCE): try IDN Conversion on domainparts of emailADRESSES |
| 2271 | 2271 | * @return mixed - based on the input type |
| 2272 | 2272 | */ |
| 2273 | - static function decode_header($_string, $_tryIDNConversion=false) |
|
| 2273 | + static function decode_header($_string, $_tryIDNConversion = false) |
|
| 2274 | 2274 | { |
| 2275 | 2275 | if (is_array($_string)) |
| 2276 | 2276 | { |
| 2277 | - foreach($_string as $k=>$v) |
|
| 2277 | + foreach ($_string as $k=>$v) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | $_string[$k] = self::decode_header($v, $_tryIDNConversion); |
| 2280 | 2280 | } |
@@ -2282,18 +2282,18 @@ discard block |
||
| 2282 | 2282 | } |
| 2283 | 2283 | else |
| 2284 | 2284 | { |
| 2285 | - $_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset); |
|
| 2285 | + $_string = Mail\Html::decodeMailHeader($_string, self::$displayCharset); |
|
| 2286 | 2286 | $test = @json_encode($_string); |
| 2287 | 2287 | //error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#'); |
| 2288 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2288 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2289 | 2289 | { |
| 2290 | 2290 | // try to fix broken utf8 |
| 2291 | 2291 | $x = utf8_encode($_string); |
| 2292 | 2292 | $test = @json_encode($x); |
| 2293 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2293 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2294 | 2294 | { |
| 2295 | 2295 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 2296 | - $_string = (function_exists('mb_convert_encoding')?mb_convert_encoding($_string,'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$_string):$_string)); |
|
| 2296 | + $_string = (function_exists('mb_convert_encoding') ? mb_convert_encoding($_string, 'UTF-8', 'UTF-8') : (function_exists('iconv') ? @iconv("UTF-8", "UTF-8//IGNORE", $_string) : $_string)); |
|
| 2297 | 2297 | } |
| 2298 | 2298 | else |
| 2299 | 2299 | { |
@@ -2301,7 +2301,7 @@ discard block |
||
| 2301 | 2301 | } |
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | - if ($_tryIDNConversion===true && stripos($_string,'@')!==false) |
|
| 2304 | + if ($_tryIDNConversion === true && stripos($_string, '@') !== false) |
|
| 2305 | 2305 | { |
| 2306 | 2306 | $rfcAddr = self::parseAddressList($_string); |
| 2307 | 2307 | $stringA = array(); |
@@ -2313,11 +2313,11 @@ discard block |
||
| 2313 | 2313 | $stringA = array(); |
| 2314 | 2314 | break; // skip idna conversion if we encounter an error here |
| 2315 | 2315 | } |
| 2316 | - $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
|
| 2316 | + $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox, Horde_Idna::decode($_rfcAddr->host), $_rfcAddr->personal); |
|
| 2317 | 2317 | } |
| 2318 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2318 | + if (!empty($stringA)) $_string = implode(',', $stringA); |
|
| 2319 | 2319 | } |
| 2320 | - if ($_tryIDNConversion==='FORCE') |
|
| 2320 | + if ($_tryIDNConversion === 'FORCE') |
|
| 2321 | 2321 | { |
| 2322 | 2322 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_string.'='.Horde_Idna::decode($_string)); |
| 2323 | 2323 | $_string = Horde_Idna::decode($_string); |
@@ -2333,17 +2333,17 @@ discard block |
||
| 2333 | 2333 | * @param boolean $decode try decoding |
| 2334 | 2334 | * @return mixed - based on the input type |
| 2335 | 2335 | */ |
| 2336 | - function decode_subject($_string,$decode=true) |
|
| 2336 | + function decode_subject($_string, $decode = true) |
|
| 2337 | 2337 | { |
| 2338 | 2338 | #$string = $_string; |
| 2339 | - if($_string=='NIL') |
|
| 2339 | + if ($_string == 'NIL') |
|
| 2340 | 2340 | { |
| 2341 | 2341 | return 'No Subject'; |
| 2342 | 2342 | } |
| 2343 | 2343 | if ($decode) $_string = self::decode_header($_string); |
| 2344 | 2344 | // make sure its utf-8 |
| 2345 | 2345 | $test = @json_encode($_string); |
| 2346 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2346 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2347 | 2347 | { |
| 2348 | 2348 | $_string = utf8_encode($_string); |
| 2349 | 2349 | } |
@@ -2395,18 +2395,18 @@ discard block |
||
| 2395 | 2395 | function createFolder($_parent, $_folderName, &$_error) |
| 2396 | 2396 | { |
| 2397 | 2397 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
| 2398 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2399 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2398 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2399 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2400 | 2400 | |
| 2401 | - if(empty($parent)) { |
|
| 2401 | + if (empty($parent)) { |
|
| 2402 | 2402 | $newFolderName = $folderName; |
| 2403 | 2403 | } else { |
| 2404 | 2404 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2405 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2405 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2406 | 2406 | } |
| 2407 | 2407 | if (empty($newFolderName)) return false; |
| 2408 | 2408 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
| 2409 | - if ($this->folderExists($newFolderName,true)) |
|
| 2409 | + if ($this->folderExists($newFolderName, true)) |
|
| 2410 | 2410 | { |
| 2411 | 2411 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
| 2412 | 2412 | return $newFolderName; |
@@ -2423,7 +2423,7 @@ discard block |
||
| 2423 | 2423 | } |
| 2424 | 2424 | catch (\Exception $e) |
| 2425 | 2425 | { |
| 2426 | - $_error = lang('Could not create Folder %1 Reason: %2',$newFolderName,$e->getMessage()); |
|
| 2426 | + $_error = lang('Could not create Folder %1 Reason: %2', $newFolderName, $e->getMessage()); |
|
| 2427 | 2427 | error_log(__METHOD__.' ('.__LINE__.') '.' create Folder '.$newFolderName.'->'.$e->getMessage().' ('.$e->details.') Namespace:'.array2string($this->icServer->getNameSpaces()).function_backtrace()); |
| 2428 | 2428 | return false; |
| 2429 | 2429 | } |
@@ -2452,15 +2452,15 @@ discard block |
||
| 2452 | 2452 | */ |
| 2453 | 2453 | function renameFolder($_oldFolderName, $_parent, $_folderName) |
| 2454 | 2454 | { |
| 2455 | - $oldFolderName = $_oldFolderName;//$this->_encodeFolderName($_oldFolderName); |
|
| 2456 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2457 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2455 | + $oldFolderName = $_oldFolderName; //$this->_encodeFolderName($_oldFolderName); |
|
| 2456 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2457 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2458 | 2458 | |
| 2459 | - if(empty($parent)) { |
|
| 2459 | + if (empty($parent)) { |
|
| 2460 | 2460 | $newFolderName = $folderName; |
| 2461 | 2461 | } else { |
| 2462 | 2462 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2463 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2463 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2464 | 2464 | } |
| 2465 | 2465 | if (self::$debug) error_log("create folder: $newFolderName"); |
| 2466 | 2466 | try |
@@ -2469,10 +2469,10 @@ discard block |
||
| 2469 | 2469 | } |
| 2470 | 2470 | catch (\Exception $e) |
| 2471 | 2471 | { |
| 2472 | - throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage());; |
|
| 2472 | + throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage()); ; |
|
| 2473 | 2473 | } |
| 2474 | 2474 | // clear FolderExistsInfoCache |
| 2475 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2475 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2476 | 2476 | |
| 2477 | 2477 | return $newFolderName; |
| 2478 | 2478 | |
@@ -2491,15 +2491,15 @@ discard block |
||
| 2491 | 2491 | //$folderName = $this->_encodeFolderName($_folderName); |
| 2492 | 2492 | try |
| 2493 | 2493 | { |
| 2494 | - $this->icServer->subscribeMailbox($_folderName,false); |
|
| 2494 | + $this->icServer->subscribeMailbox($_folderName, false); |
|
| 2495 | 2495 | $this->icServer->deleteMailbox($_folderName); |
| 2496 | 2496 | } |
| 2497 | 2497 | catch (\Exception $e) |
| 2498 | 2498 | { |
| 2499 | - throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage());; |
|
| 2499 | + throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage()); ; |
|
| 2500 | 2500 | } |
| 2501 | 2501 | // clear FolderExistsInfoCache |
| 2502 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2502 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2503 | 2503 | |
| 2504 | 2504 | return true; |
| 2505 | 2505 | } |
@@ -2534,10 +2534,10 @@ discard block |
||
| 2534 | 2534 | * |
| 2535 | 2535 | * @return array with folder objects. eg.: INBOX => {inbox object} |
| 2536 | 2536 | */ |
| 2537 | - function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
|
| 2537 | + function getFolderObjects($_subscribedOnly = false, $_getCounters = false, $_alwaysGetDefaultFolders = false, $_useCacheIfPossible = true) |
|
| 2538 | 2538 | { |
| 2539 | 2539 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
| 2540 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2540 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 2541 | 2541 | static $folders2return; |
| 2542 | 2542 | //$_subscribedOnly=false; |
| 2543 | 2543 | // always use static on single request if info is available; |
@@ -2545,42 +2545,42 @@ discard block |
||
| 2545 | 2545 | // set $_useCacheIfPossible to false ! |
| 2546 | 2546 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2547 | 2547 | { |
| 2548 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2548 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'using static', __METHOD__.' ('.__LINE__.') '); |
|
| 2549 | 2549 | return $folders2return[$this->icServer->ImapServerId]; |
| 2550 | 2550 | } |
| 2551 | 2551 | |
| 2552 | - if ($_subscribedOnly && $_getCounters===false) |
|
| 2552 | + if ($_subscribedOnly && $_getCounters === false) |
|
| 2553 | 2553 | { |
| 2554 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2554 | + if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 2555 | 2555 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2556 | 2556 | { |
| 2557 | 2557 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2558 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2558 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'from Cache', __METHOD__.' ('.__LINE__.') '); |
|
| 2559 | 2559 | return $folders2return[$this->icServer->ImapServerId]; |
| 2560 | 2560 | } |
| 2561 | 2561 | } |
| 2562 | 2562 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2563 | 2563 | static $folderBasicInfo; |
| 2564 | - if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2564 | + if (is_null($folderBasicInfo) || !isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 2565 | 2565 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2566 | 2566 | |
| 2567 | 2567 | $delimiter = $this->getHierarchyDelimiter(); |
| 2568 | 2568 | |
| 2569 | 2569 | $inboxData = new \stdClass; |
| 2570 | - $inboxData->name = 'INBOX'; |
|
| 2570 | + $inboxData->name = 'INBOX'; |
|
| 2571 | 2571 | $inboxData->folderName = 'INBOX'; |
| 2572 | - $inboxData->displayName = lang('INBOX'); |
|
| 2572 | + $inboxData->displayName = lang('INBOX'); |
|
| 2573 | 2573 | $inboxData->delimiter = $delimiter; |
| 2574 | - $inboxData->shortFolderName = 'INBOX'; |
|
| 2575 | - $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2574 | + $inboxData->shortFolderName = 'INBOX'; |
|
| 2575 | + $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2576 | 2576 | $inboxData->subscribed = true; |
| 2577 | - if($_getCounters == true) { |
|
| 2577 | + if ($_getCounters == true) { |
|
| 2578 | 2578 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2579 | 2579 | } |
| 2580 | 2580 | // force unsubscribed by preference showAllFoldersInFolderPane |
| 2581 | 2581 | if ($_subscribedOnly == true && |
| 2582 | 2582 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2583 | - $this->mailPreferences['showAllFoldersInFolderPane']==1) |
|
| 2583 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1) |
|
| 2584 | 2584 | { |
| 2585 | 2585 | $_subscribedOnly = false; |
| 2586 | 2586 | } |
@@ -2593,12 +2593,12 @@ discard block |
||
| 2593 | 2593 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2594 | 2594 | if (is_array($nameSpace)) |
| 2595 | 2595 | { |
| 2596 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2596 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2597 | 2597 | $type = $singleNameSpace['type']; |
| 2598 | 2598 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2599 | - $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2599 | + $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2600 | 2600 | |
| 2601 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 2601 | + if (is_array($singleNameSpace) && $fetchedAllInOneGo == false) { |
|
| 2602 | 2602 | // fetch and sort the subscribed folders |
| 2603 | 2603 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2604 | 2604 | // if a folder is subscribed or not |
@@ -2606,22 +2606,22 @@ discard block |
||
| 2606 | 2606 | { |
| 2607 | 2607 | try |
| 2608 | 2608 | { |
| 2609 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('',0,true); |
|
| 2609 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('', 0, true); |
|
| 2610 | 2610 | if (!empty($subscribedMailboxes)) |
| 2611 | 2611 | { |
| 2612 | 2612 | $fetchedAllInOneGo = true; |
| 2613 | 2613 | } |
| 2614 | 2614 | else |
| 2615 | 2615 | { |
| 2616 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2616 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2617 | 2617 | } |
| 2618 | 2618 | } |
| 2619 | - catch(Exception $e) |
|
| 2619 | + catch (Exception $e) |
|
| 2620 | 2620 | { |
| 2621 | 2621 | continue; |
| 2622 | 2622 | } |
| 2623 | 2623 | //echo "subscribedMailboxes";_debug_array($subscribedMailboxes); |
| 2624 | - $subscribedFoldersPerNS = (!empty($subscribedMailboxes)?array_keys($subscribedMailboxes):array()); |
|
| 2624 | + $subscribedFoldersPerNS = (!empty($subscribedMailboxes) ? array_keys($subscribedMailboxes) : array()); |
|
| 2625 | 2625 | //if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']); |
| 2626 | 2626 | //_debug_array($foldersNameSpace); |
| 2627 | 2627 | //error_log(__METHOD__.__LINE__.array2string($singleNameSpace).':#:'.array2string($subscribedFoldersPerNS)); |
@@ -2631,18 +2631,18 @@ discard block |
||
| 2631 | 2631 | foreach ($subscribedMailboxes as $k => $finfo) |
| 2632 | 2632 | { |
| 2633 | 2633 | //error_log(__METHOD__.__LINE__.$k.':#:'.array2string($finfo)); |
| 2634 | - $subscribedFoldersForCache[$this->icServer->ImapServerId][$k]= |
|
| 2635 | - $folderBasicInfo[$this->icServer->ImapServerId][$k]=array( |
|
| 2634 | + $subscribedFoldersForCache[$this->icServer->ImapServerId][$k] = |
|
| 2635 | + $folderBasicInfo[$this->icServer->ImapServerId][$k] = array( |
|
| 2636 | 2636 | 'MAILBOX'=>$finfo['MAILBOX'], |
| 2637 | 2637 | 'ATTRIBUTES'=>$finfo['ATTRIBUTES'], |
| 2638 | - 'delimiter'=>$finfo['delimiter'],//lowercase for some reason??? |
|
| 2639 | - 'SUBSCRIBED'=>$finfo['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2638 | + 'delimiter'=>$finfo['delimiter'], //lowercase for some reason??? |
|
| 2639 | + 'SUBSCRIBED'=>$finfo['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2640 | 2640 | ); |
| 2641 | - if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k,$foldersNameSpace[$type]['subscribed'])) |
|
| 2641 | + if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k, $foldersNameSpace[$type]['subscribed'])) |
|
| 2642 | 2642 | { |
| 2643 | 2643 | $foldersNameSpace[$type]['subscribed'][] = $k; |
| 2644 | 2644 | } |
| 2645 | - if (empty($foldersNameSpace[$type]['all']) || !in_array($k,$foldersNameSpace[$type]['all'])) |
|
| 2645 | + if (empty($foldersNameSpace[$type]['all']) || !in_array($k, $foldersNameSpace[$type]['all'])) |
|
| 2646 | 2646 | { |
| 2647 | 2647 | $foldersNameSpace[$type]['all'][] = $k; |
| 2648 | 2648 | } |
@@ -2665,7 +2665,7 @@ discard block |
||
| 2665 | 2665 | // that may produce problems, when encountering recursions probably |
| 2666 | 2666 | // horde is handling that, so we do not; keep that in mind! |
| 2667 | 2667 | //$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],2,true); |
| 2668 | - $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2668 | + $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | catch (\Exception $e) |
| 2671 | 2671 | { |
@@ -2683,26 +2683,26 @@ discard block |
||
| 2683 | 2683 | foreach ($allMailboxesExt as $mbx) { |
| 2684 | 2684 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2685 | 2685 | { |
| 2686 | - $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
|
| 2686 | + $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']] = array( |
|
| 2687 | 2687 | 'MAILBOX'=>$mbx['MAILBOX'], |
| 2688 | 2688 | 'ATTRIBUTES'=>$mbx['ATTRIBUTES'], |
| 2689 | - 'delimiter'=>$mbx['delimiter'],//lowercase for some reason??? |
|
| 2690 | - 'SUBSCRIBED'=>$mbx['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2689 | + 'delimiter'=>$mbx['delimiter'], //lowercase for some reason??? |
|
| 2690 | + 'SUBSCRIBED'=>$mbx['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2691 | 2691 | ); |
| 2692 | 2692 | if ($mbx['SUBSCRIBED'] && !isset($subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2693 | 2693 | { |
| 2694 | 2694 | $subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']] = $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]; |
| 2695 | 2695 | } |
| 2696 | 2696 | } |
| 2697 | - if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'],$foldersNameSpace[$type]['subscribed']))) |
|
| 2697 | + if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'], $foldersNameSpace[$type]['subscribed']))) |
|
| 2698 | 2698 | { |
| 2699 | 2699 | $foldersNameSpace[$type]['subscribed'][] = $mbx['MAILBOX']; |
| 2700 | 2700 | } |
| 2701 | 2701 | //echo __METHOD__;_debug_array($mbx); |
| 2702 | 2702 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 2703 | - if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
|
| 2704 | - isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
|
| 2705 | - (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
|
| 2703 | + if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']]) || |
|
| 2704 | + isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']]) || |
|
| 2705 | + (substr($mbx['MAILBOX'], -1) == $foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'], 0, -1)])) |
|
| 2706 | 2706 | ) continue; |
| 2707 | 2707 | |
| 2708 | 2708 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
@@ -2712,7 +2712,7 @@ discard block |
||
| 2712 | 2712 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2713 | 2713 | $allMailboxes = array(); |
| 2714 | 2714 | foreach ((array)$allMailBoxesExtSorted as $mbx) { |
| 2715 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2715 | + if (!in_array($mbx['MAILBOX'], $allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2716 | 2716 | //echo "Result:";_debug_array($allMailboxes); |
| 2717 | 2717 | } |
| 2718 | 2718 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
@@ -2721,57 +2721,57 @@ discard block |
||
| 2721 | 2721 | } |
| 2722 | 2722 | } |
| 2723 | 2723 | //subscribed folders may be used in getFolderStatus |
| 2724 | - Cache::setCache(Cache::INSTANCE,'email','subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$subscribedFoldersForCache,$expiration=60*60*1); |
|
| 2724 | + Cache::setCache(Cache::INSTANCE, 'email', 'subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $subscribedFoldersForCache, $expiration = 60 * 60 * 1); |
|
| 2725 | 2725 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2726 | 2726 | $autoFolderObjects = $folders = array(); |
| 2727 | 2727 | $autofolder_exists = array(); |
| 2728 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2729 | - if(isset($foldersNameSpace[$type])) { |
|
| 2730 | - if($_subscribedOnly) { |
|
| 2731 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2728 | + foreach (array('personal', 'others', 'shared') as $type) { |
|
| 2729 | + if (isset($foldersNameSpace[$type])) { |
|
| 2730 | + if ($_subscribedOnly) { |
|
| 2731 | + if (!empty($foldersNameSpace[$type]['subscribed'])) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2732 | 2732 | } else { |
| 2733 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2733 | + if (!empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2734 | 2734 | } |
| 2735 | - foreach((array)$listOfFolders as $folderName) { |
|
| 2735 | + foreach ((array)$listOfFolders as $folderName) { |
|
| 2736 | 2736 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2737 | 2737 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2738 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2739 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2738 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue; //when subscribedonly, we fetch all folders in one go. |
|
| 2739 | + if ($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all']) || in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2740 | 2740 | #echo "$folderName failed to be here <br>"; |
| 2741 | 2741 | continue; |
| 2742 | 2742 | } |
| 2743 | 2743 | if (isset($folders[$folderName])) continue; |
| 2744 | 2744 | if (isset($autoFolderObjects[$folderName])) continue; |
| 2745 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2745 | + if (empty($delimiter) || $delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2746 | 2746 | $folderParts = explode($delimiter, $folderName); |
| 2747 | 2747 | $shortName = array_pop($folderParts); |
| 2748 | 2748 | |
| 2749 | 2749 | $folderObject = new \stdClass; |
| 2750 | - $folderObject->delimiter = $delimiter; |
|
| 2751 | - $folderObject->folderName = $folderName; |
|
| 2752 | - $folderObject->shortFolderName = $shortName; |
|
| 2753 | - if(!$_subscribedOnly) { |
|
| 2750 | + $folderObject->delimiter = $delimiter; |
|
| 2751 | + $folderObject->folderName = $folderName; |
|
| 2752 | + $folderObject->shortFolderName = $shortName; |
|
| 2753 | + if (!$_subscribedOnly) { |
|
| 2754 | 2754 | #echo $folderName."->".$type."<br>"; |
| 2755 | 2755 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2756 | 2756 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2757 | 2757 | } |
| 2758 | 2758 | |
| 2759 | - if($_getCounters == true) { |
|
| 2759 | + if ($_getCounters == true) { |
|
| 2760 | 2760 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2761 | 2761 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2762 | 2762 | } |
| 2763 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 2763 | + if (strtoupper($folderName) == 'INBOX') { |
|
| 2764 | 2764 | $folderName = 'INBOX'; |
| 2765 | - $folderObject->folderName = 'INBOX'; |
|
| 2766 | - $folderObject->shortFolderName = 'INBOX'; |
|
| 2767 | - $folderObject->displayName = lang('INBOX'); |
|
| 2765 | + $folderObject->folderName = 'INBOX'; |
|
| 2766 | + $folderObject->shortFolderName = 'INBOX'; |
|
| 2767 | + $folderObject->displayName = lang('INBOX'); |
|
| 2768 | 2768 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2769 | - $folderObject->subscribed = true; |
|
| 2769 | + $folderObject->subscribed = true; |
|
| 2770 | 2770 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2771 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 2772 | - $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
|
| 2771 | + } elseif (in_array($shortName, self::$autoFolders)) { |
|
| 2772 | + $tmpfolderparts = explode($delimiter, $folderObject->folderName); |
|
| 2773 | 2773 | array_pop($tmpfolderparts); |
| 2774 | - $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
|
| 2774 | + $folderObject->displayName = implode($delimiter, $tmpfolderparts).$delimiter.lang($shortName); |
|
| 2775 | 2775 | $folderObject->shortDisplayName = lang($shortName); |
| 2776 | 2776 | unset($tmpfolderparts); |
| 2777 | 2777 | } else { |
@@ -2779,13 +2779,13 @@ discard block |
||
| 2779 | 2779 | $folderObject->shortDisplayName = $shortName; |
| 2780 | 2780 | } |
| 2781 | 2781 | //$folderName = $folderName; |
| 2782 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 2782 | + if (in_array($shortName, self::$autoFolders) && self::searchValueInFolderObjects($shortName, $autoFolderObjects) === false) { |
|
| 2783 | 2783 | $autoFolderObjects[$folderName] = $folderObject; |
| 2784 | 2784 | } else { |
| 2785 | 2785 | $folders[$folderName] = $folderObject; |
| 2786 | 2786 | } |
| 2787 | 2787 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2788 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 2788 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); |
|
| 2789 | 2789 | if (isset(self::$specialUseFolders[$folderName])) |
| 2790 | 2790 | { |
| 2791 | 2791 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2794,27 +2794,27 @@ discard block |
||
| 2794 | 2794 | } |
| 2795 | 2795 | } |
| 2796 | 2796 | if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
| 2797 | - uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
|
| 2797 | + uasort($autoFolderObjects, array($this, "sortByAutoFolderPos")); |
|
| 2798 | 2798 | } |
| 2799 | 2799 | // check if some standard folders are missing and need to be created |
| 2800 | 2800 | if (count($autofolder_exists) < count(self::$autoFolders) && $this->check_create_autofolders($autofolder_exists)) |
| 2801 | 2801 | { |
| 2802 | 2802 | // if new folders have been created, re-read folders ignoring the cache |
| 2803 | - return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2803 | + return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2804 | 2804 | } |
| 2805 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 2805 | + if (is_array($folders)) uasort($folders, array($this, "sortByDisplayName")); |
|
| 2806 | 2806 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2807 | 2807 | //_debug_array($folders2return); #exit; |
| 2808 | - $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
|
| 2809 | - if (($_subscribedOnly && $_getCounters===false) || |
|
| 2810 | - ($_subscribedOnly == false && $_getCounters===false && |
|
| 2808 | + $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject, (array)$autoFolderObjects, (array)$folders); |
|
| 2809 | + if (($_subscribedOnly && $_getCounters === false) || |
|
| 2810 | + ($_subscribedOnly == false && $_getCounters === false && |
|
| 2811 | 2811 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2812 | - $this->mailPreferences['showAllFoldersInFolderPane']==1)) |
|
| 2812 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1)) |
|
| 2813 | 2813 | { |
| 2814 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
|
| 2814 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), $folders2return, $expiration = 60 * 60 * 1); |
|
| 2815 | 2815 | } |
| 2816 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
|
| 2817 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 2816 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderBasicInfo, $expiration = 60 * 60 * 1); |
|
| 2817 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') '); |
|
| 2818 | 2818 | return $folders2return[$this->icServer->ImapServerId]; |
| 2819 | 2819 | } |
| 2820 | 2820 | |
@@ -2835,21 +2835,21 @@ discard block |
||
| 2835 | 2835 | * |
| 2836 | 2836 | * @return array arrays of folders |
| 2837 | 2837 | */ |
| 2838 | - function getFolderArrays ($_nodePath = null, $_onlyTopLevel = false, $_search= 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2838 | + function getFolderArrays($_nodePath = null, $_onlyTopLevel = false, $_search = 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2839 | 2839 | { |
| 2840 | 2840 | // delimiter |
| 2841 | 2841 | $delimiter = $this->getHierarchyDelimiter(); |
| 2842 | 2842 | |
| 2843 | - $folders = $nameSpace = array(); |
|
| 2843 | + $folders = $nameSpace = array(); |
|
| 2844 | 2844 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2845 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2846 | - $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
|
| 2845 | + foreach ($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2846 | + $nameSpace[$singleNameSpace['type']] = $singleNameSpace; |
|
| 2847 | 2847 | } |
| 2848 | 2848 | unset($nameSpaceTmp); |
| 2849 | 2849 | |
| 2850 | 2850 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2851 | 2851 | // Get special use folders |
| 2852 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 2852 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); // Set self::$specialUseFolders |
|
| 2853 | 2853 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2854 | 2854 | if ($_onlyTopLevel) // top level leaves |
| 2855 | 2855 | { |
@@ -2860,20 +2860,20 @@ discard block |
||
| 2860 | 2860 | if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
| 2861 | 2861 | if (self::$mailConfig['examineNamespace']) |
| 2862 | 2862 | { |
| 2863 | - $prefixes=array(); |
|
| 2863 | + $prefixes = array(); |
|
| 2864 | 2864 | if (is_array($nameSpace)) |
| 2865 | 2865 | { |
| 2866 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2866 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2867 | 2867 | $type = $singleNameSpace['type']; |
| 2868 | 2868 | |
| 2869 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 2869 | + if (is_array($singleNameSpace) && $singleNameSpace['prefix']) { |
|
| 2870 | 2870 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2871 | 2871 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2872 | - $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
|
| 2872 | + $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search == 0 ? 0 : 2, true); |
|
| 2873 | 2873 | if (is_array($result)) |
| 2874 | 2874 | { |
| 2875 | 2875 | ksort($result); |
| 2876 | - $topFolders = array_merge($topFolders,$result); |
|
| 2876 | + $topFolders = array_merge($topFolders, $result); |
|
| 2877 | 2877 | } |
| 2878 | 2878 | } |
| 2879 | 2879 | } |
@@ -2882,7 +2882,7 @@ discard block |
||
| 2882 | 2882 | |
| 2883 | 2883 | $autofolders = array(); |
| 2884 | 2884 | |
| 2885 | - foreach(self::$specialUseFolders as $path => $folder) |
|
| 2885 | + foreach (self::$specialUseFolders as $path => $folder) |
|
| 2886 | 2886 | { |
| 2887 | 2887 | if ($this->folderExists($path)) |
| 2888 | 2888 | { |
@@ -2890,9 +2890,9 @@ discard block |
||
| 2890 | 2890 | } |
| 2891 | 2891 | } |
| 2892 | 2892 | // Check if the special use folders are there, otherwise try to create them |
| 2893 | - if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders ($autofolders)) |
|
| 2893 | + if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders($autofolders)) |
|
| 2894 | 2894 | { |
| 2895 | - return $this->getFolderArrays ($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2895 | + return $this->getFolderArrays($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2896 | 2896 | } |
| 2897 | 2897 | |
| 2898 | 2898 | // now process topFolders for next level |
@@ -2900,13 +2900,13 @@ discard block |
||
| 2900 | 2900 | { |
| 2901 | 2901 | $pattern = "/\\".$delimiter."/"; |
| 2902 | 2902 | $reference = preg_replace($pattern, '', $node['MAILBOX']); |
| 2903 | - if(!empty($prefixes)) |
|
| 2903 | + if (!empty($prefixes)) |
|
| 2904 | 2904 | { |
| 2905 | 2905 | $reference = ''; |
| 2906 | - $tmpArray = explode($delimiter,$node['MAILBOX']); |
|
| 2907 | - foreach($tmpArray as $p) |
|
| 2906 | + $tmpArray = explode($delimiter, $node['MAILBOX']); |
|
| 2907 | + foreach ($tmpArray as $p) |
|
| 2908 | 2908 | { |
| 2909 | - $reference = empty($reference)?$p:$reference.$delimiter.$p; |
|
| 2909 | + $reference = empty($reference) ? $p : $reference.$delimiter.$p; |
|
| 2910 | 2910 | } |
| 2911 | 2911 | } |
| 2912 | 2912 | $mainFolder = $subFolders = array(); |
@@ -2942,19 +2942,19 @@ discard block |
||
| 2942 | 2942 | $nFolders [$path] = $folder; |
| 2943 | 2943 | } |
| 2944 | 2944 | } |
| 2945 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 2945 | + if (is_array($aFolders)) uasort($aFolders, array($this, 'sortByAutofolder')); |
|
| 2946 | 2946 | //ksort($aFolders); |
| 2947 | 2947 | |
| 2948 | 2948 | // Sort none auto folders base on mailbox name |
| 2949 | - uasort($nFolders,array($this,'sortByMailbox')); |
|
| 2949 | + uasort($nFolders, array($this, 'sortByMailbox')); |
|
| 2950 | 2950 | |
| 2951 | - $subFolders = array_merge($aFolders,$nFolders); |
|
| 2951 | + $subFolders = array_merge($aFolders, $nFolders); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | else |
| 2954 | 2954 | { |
| 2955 | 2955 | if (is_array($subFolders)) ksort($subFolders); |
| 2956 | 2956 | } |
| 2957 | - $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
|
| 2957 | + $folders = array_merge($folders, (array)$mainFolder, (array)$subFolders); |
|
| 2958 | 2958 | } |
| 2959 | 2959 | } |
| 2960 | 2960 | elseif ($_nodePath) // single node |
@@ -2981,9 +2981,9 @@ discard block |
||
| 2981 | 2981 | $folders = $this->icServer->getMailboxes($path, $_search, true); |
| 2982 | 2982 | } |
| 2983 | 2983 | |
| 2984 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 2984 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 2985 | 2985 | } |
| 2986 | - elseif(!$_nodePath) // all |
|
| 2986 | + elseif (!$_nodePath) // all |
|
| 2987 | 2987 | { |
| 2988 | 2988 | if ($_subscribedOnly) |
| 2989 | 2989 | { |
@@ -2999,101 +2999,101 @@ discard block |
||
| 2999 | 2999 | { |
| 3000 | 3000 | // SORTING FOLDERS |
| 3001 | 3001 | //self::$debugTimes=true; |
| 3002 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 3002 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 3003 | 3003 | // Merge of all auto folders and specialusefolders |
| 3004 | 3004 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 3005 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 3005 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 3006 | 3006 | $tmpFolders = $folders; |
| 3007 | - $inboxFolderObject=$inboxSubFolderObjects=$autoFolderObjects=$typeFolderObject=$mySpecialUseFolders=array(); |
|
| 3008 | - $googleMailFolderObject=$googleAutoFolderObjects=$googleSubFolderObjects=array(); |
|
| 3009 | - $isGoogleMail=false; |
|
| 3010 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3007 | + $inboxFolderObject = $inboxSubFolderObjects = $autoFolderObjects = $typeFolderObject = $mySpecialUseFolders = array(); |
|
| 3008 | + $googleMailFolderObject = $googleAutoFolderObjects = $googleSubFolderObjects = array(); |
|
| 3009 | + $isGoogleMail = false; |
|
| 3010 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3011 | 3011 | { |
| 3012 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3012 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF] = $this->getFolderByType($aF, false); |
|
| 3013 | 3013 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3014 | 3014 | } |
| 3015 | 3015 | //error_log(array2string($mySpecialUseFolders)); |
| 3016 | 3016 | foreach ($tmpFolders as $k => $f) { |
| 3017 | - $sorted=false; |
|
| 3018 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 3019 | - if (strtoupper($k)=='INBOX') { |
|
| 3017 | + $sorted = false; |
|
| 3018 | + if (strtoupper(substr($k, 0, 5)) == 'INBOX') { |
|
| 3019 | + if (strtoupper($k) == 'INBOX') { |
|
| 3020 | 3020 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 3021 | - $inboxFolderObject[$k]=$f; |
|
| 3021 | + $inboxFolderObject[$k] = $f; |
|
| 3022 | 3022 | unset($folders[$k]); |
| 3023 | - $sorted=true; |
|
| 3023 | + $sorted = true; |
|
| 3024 | 3024 | } else { |
| 3025 | - $isAutoFolder=false; |
|
| 3026 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3025 | + $isAutoFolder = false; |
|
| 3026 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3027 | 3027 | { |
| 3028 | 3028 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3029 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3030 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3031 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3029 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3030 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3031 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3032 | 3032 | { |
| 3033 | 3033 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 3034 | - $isAutoFolder=true; |
|
| 3035 | - $autoFolderObjects[$k]=$f; |
|
| 3034 | + $isAutoFolder = true; |
|
| 3035 | + $autoFolderObjects[$k] = $f; |
|
| 3036 | 3036 | break; |
| 3037 | 3037 | } |
| 3038 | 3038 | } |
| 3039 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 3039 | + if ($isAutoFolder == false) $inboxSubFolderObjects[$k] = $f; |
|
| 3040 | 3040 | unset($folders[$k]); |
| 3041 | - $sorted=true; |
|
| 3041 | + $sorted = true; |
|
| 3042 | 3042 | } |
| 3043 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 3044 | - $isGoogleMail=true; |
|
| 3045 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 3046 | - $googleMailFolderObject[$k]=$f; |
|
| 3043 | + } elseif (strtoupper(substr($k, 0, 13)) == '[GOOGLE MAIL]') { |
|
| 3044 | + $isGoogleMail = true; |
|
| 3045 | + if (strtoupper($k) == '[GOOGLE MAIL]') { |
|
| 3046 | + $googleMailFolderObject[$k] = $f; |
|
| 3047 | 3047 | unset($folders[$k]); |
| 3048 | - $sorted=true; |
|
| 3048 | + $sorted = true; |
|
| 3049 | 3049 | } else { |
| 3050 | - $isAutoFolder=false; |
|
| 3051 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3050 | + $isAutoFolder = false; |
|
| 3051 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3052 | 3052 | { |
| 3053 | 3053 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3054 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3055 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3056 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3054 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3055 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3056 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3057 | 3057 | { |
| 3058 | 3058 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3059 | - $isAutoFolder=true; |
|
| 3060 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3059 | + $isAutoFolder = true; |
|
| 3060 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3061 | 3061 | break; |
| 3062 | 3062 | } |
| 3063 | 3063 | } |
| 3064 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3064 | + if ($isAutoFolder == false) $googleSubFolderObjects[$k] = $f; |
|
| 3065 | 3065 | unset($folders[$k]); |
| 3066 | - $sorted=true; |
|
| 3066 | + $sorted = true; |
|
| 3067 | 3067 | } |
| 3068 | 3068 | } else { |
| 3069 | - $isAutoFolder=false; |
|
| 3070 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3069 | + $isAutoFolder = false; |
|
| 3070 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3071 | 3071 | { |
| 3072 | 3072 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3073 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3074 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3075 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3073 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3074 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3075 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3076 | 3076 | { |
| 3077 | 3077 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3078 | - $isAutoFolder=true; |
|
| 3079 | - $autoFolderObjects[$k]=$f; |
|
| 3078 | + $isAutoFolder = true; |
|
| 3079 | + $autoFolderObjects[$k] = $f; |
|
| 3080 | 3080 | unset($folders[$k]); |
| 3081 | - $sorted=true; |
|
| 3081 | + $sorted = true; |
|
| 3082 | 3082 | break; |
| 3083 | 3083 | } |
| 3084 | 3084 | } |
| 3085 | 3085 | } |
| 3086 | 3086 | |
| 3087 | - if ($sorted==false) |
|
| 3087 | + if ($sorted == false) |
|
| 3088 | 3088 | { |
| 3089 | - foreach(array('others','shared') as $type) |
|
| 3089 | + foreach (array('others', 'shared') as $type) |
|
| 3090 | 3090 | { |
| 3091 | - if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
|
| 3091 | + if ($nameSpace[$type]['prefix_present'] && $nameSpace[$type]['prefix']) |
|
| 3092 | 3092 | { |
| 3093 | - if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
|
| 3094 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3093 | + if (substr($k, 0, strlen($nameSpace[$type]['prefix'])) == $nameSpace[$type]['prefix'] || |
|
| 3094 | + substr($k, 0, strlen($nameSpace[$type]['prefix']) - strlen($nameSpace[$type]['delimiter'])) == substr($nameSpace[$type]['prefix'], 0, strlen($nameSpace[$type]['delimiter']) * -1)) { |
|
| 3095 | 3095 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3096 | - $typeFolderObject[$type][$k]=$f; |
|
| 3096 | + $typeFolderObject[$type][$k] = $f; |
|
| 3097 | 3097 | unset($folders[$k]); |
| 3098 | 3098 | } |
| 3099 | 3099 | } |
@@ -3104,40 +3104,40 @@ discard block |
||
| 3104 | 3104 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3105 | 3105 | $autoFolderObjectsTmp = $autoFolderObjects; |
| 3106 | 3106 | unset($autoFolderObjects); |
| 3107 | - uasort($autoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3108 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3107 | + uasort($autoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3108 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3109 | 3109 | { |
| 3110 | - foreach($autoFolderObjectsTmp as $k => $f) |
|
| 3110 | + foreach ($autoFolderObjectsTmp as $k => $f) |
|
| 3111 | 3111 | { |
| 3112 | - if($aF && ($mySpecialUseFolders[$aF]==$k || |
|
| 3113 | - substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || |
|
| 3114 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3112 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || |
|
| 3113 | + substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || |
|
| 3114 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) |
|
| 3115 | 3115 | { |
| 3116 | - $autoFolderObjects[$k]=$f; |
|
| 3116 | + $autoFolderObjects[$k] = $f; |
|
| 3117 | 3117 | } |
| 3118 | 3118 | } |
| 3119 | 3119 | } |
| 3120 | 3120 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3121 | 3121 | if (!$isGoogleMail) { |
| 3122 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3122 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$inboxSubFolderObjects, (array)$folders, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3123 | 3123 | } else { |
| 3124 | 3124 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3125 | 3125 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3126 | 3126 | unset($googleAutoFolderObjects); |
| 3127 | - uasort($gAutoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3128 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3127 | + uasort($gAutoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3128 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3129 | 3129 | { |
| 3130 | - foreach($gAutoFolderObjectsTmp as $k => $f) |
|
| 3130 | + foreach ($gAutoFolderObjectsTmp as $k => $f) |
|
| 3131 | 3131 | { |
| 3132 | - if($aF && ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter)) |
|
| 3132 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter)) |
|
| 3133 | 3133 | { |
| 3134 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3134 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3135 | 3135 | } |
| 3136 | 3136 | } |
| 3137 | 3137 | } |
| 3138 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3138 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$folders, (array)$googleMailFolderObject, $googleAutoFolderObjects, $googleSubFolderObjects, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3139 | 3139 | } |
| 3140 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3140 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3141 | 3141 | //self::$debugTimes=false; |
| 3142 | 3142 | } |
| 3143 | 3143 | // Get counter information and add them to each fetched folders array |
@@ -3159,10 +3159,10 @@ discard block |
||
| 3159 | 3159 | * @param array $autofolders_exists existing folders, no need to check their existance again |
| 3160 | 3160 | * @return int number of new folders created |
| 3161 | 3161 | */ |
| 3162 | - function check_create_autofolders(array $autofolders_exists=array()) |
|
| 3162 | + function check_create_autofolders(array $autofolders_exists = array()) |
|
| 3163 | 3163 | { |
| 3164 | 3164 | $num_created = 0; |
| 3165 | - foreach(self::$autoFolders as $folder) |
|
| 3165 | + foreach (self::$autoFolders as $folder) |
|
| 3166 | 3166 | { |
| 3167 | 3167 | $created = false; |
| 3168 | 3168 | if (!in_array($folder, $autofolders_exists) && $this->_getSpecialUseFolder($folder, true, $created) && |
@@ -3187,7 +3187,7 @@ discard block |
||
| 3187 | 3187 | $rv = false; |
| 3188 | 3188 | foreach ($haystack as $k => $v) |
| 3189 | 3189 | { |
| 3190 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3190 | + foreach ($v as &$sv) {if (trim($sv) == trim($needle)) return $k; } |
|
| 3191 | 3191 | } |
| 3192 | 3192 | return $rv; |
| 3193 | 3193 | } |
@@ -3200,9 +3200,9 @@ discard block |
||
| 3200 | 3200 | * @param array $b array of folders |
| 3201 | 3201 | * @return int expect values (0, 1 or -1) |
| 3202 | 3202 | */ |
| 3203 | - function sortByMailbox($a,$b) |
|
| 3203 | + function sortByMailbox($a, $b) |
|
| 3204 | 3204 | { |
| 3205 | - return strcasecmp($a['MAILBOX'],$b['MAILBOX']); |
|
| 3205 | + return strcasecmp($a['MAILBOX'], $b['MAILBOX']); |
|
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | /** |
@@ -3212,13 +3212,13 @@ discard block |
||
| 3212 | 3212 | * @param string $_hDelimiter hierarchy delimiter |
| 3213 | 3213 | * @return array returns an array of data extracted from given node path |
| 3214 | 3214 | */ |
| 3215 | - static function pathToFolderData ($_path, $_hDelimiter) |
|
| 3215 | + static function pathToFolderData($_path, $_hDelimiter) |
|
| 3216 | 3216 | { |
| 3217 | 3217 | if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
| 3218 | 3218 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3219 | 3219 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3220 | 3220 | $name = array_pop($parts); |
| 3221 | - return array ( |
|
| 3221 | + return array( |
|
| 3222 | 3222 | 'name' => $name, |
| 3223 | 3223 | 'mailbox' => $path, |
| 3224 | 3224 | 'parent' => implode($_hDelimiter, $parts), |
@@ -3241,8 +3241,8 @@ discard block |
||
| 3241 | 3241 | // 0, 1 und -1 |
| 3242 | 3242 | $a = self::pathToFolderData($_a['MAILBOX'], $_a['delimiter']); |
| 3243 | 3243 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3244 | - $pos1 = array_search(trim($a['name']),self::$autoFolders); |
|
| 3245 | - $pos2 = array_search(trim($b['name']),self::$autoFolders); |
|
| 3244 | + $pos1 = array_search(trim($a['name']), self::$autoFolders); |
|
| 3245 | + $pos2 = array_search(trim($b['name']), self::$autoFolders); |
|
| 3246 | 3246 | if ($pos1 == $pos2) return 0; |
| 3247 | 3247 | return ($pos1 < $pos2) ? -1 : 1; |
| 3248 | 3248 | } |
@@ -3255,10 +3255,10 @@ discard block |
||
| 3255 | 3255 | * @param object $b array of folderobjects |
| 3256 | 3256 | * @return int expect values (0, 1 or -1) |
| 3257 | 3257 | */ |
| 3258 | - function sortByDisplayName($a,$b) |
|
| 3258 | + function sortByDisplayName($a, $b) |
|
| 3259 | 3259 | { |
| 3260 | 3260 | // 0, 1 und -1 |
| 3261 | - return strcasecmp($a->displayName,$b->displayName); |
|
| 3261 | + return strcasecmp($a->displayName, $b->displayName); |
|
| 3262 | 3262 | } |
| 3263 | 3263 | |
| 3264 | 3264 | /** |
@@ -3269,11 +3269,11 @@ discard block |
||
| 3269 | 3269 | * @param object $b array of folderobjects |
| 3270 | 3270 | * @return int expect values (0, 1 or -1) |
| 3271 | 3271 | */ |
| 3272 | - function sortByAutoFolderPos($a,$b) |
|
| 3272 | + function sortByAutoFolderPos($a, $b) |
|
| 3273 | 3273 | { |
| 3274 | 3274 | // 0, 1 und -1 |
| 3275 | - $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
|
| 3276 | - $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
|
| 3275 | + $pos1 = array_search(trim($a->shortFolderName), self::$autoFolders); |
|
| 3276 | + $pos2 = array_search(trim($b->shortFolderName), self::$autoFolders); |
|
| 3277 | 3277 | if ($pos1 == $pos2) return 0; |
| 3278 | 3278 | return ($pos1 < $pos2) ? -1 : 1; |
| 3279 | 3279 | } |
@@ -3286,7 +3286,7 @@ discard block |
||
| 3286 | 3286 | * @param boolean $_returnObject return the counters as object rather than an array |
| 3287 | 3287 | * @return mixed false or array of counters array(MESSAGES,UNSEEN,RECENT,UIDNEXT,UIDVALIDITY) or object |
| 3288 | 3288 | */ |
| 3289 | - function getMailBoxCounters($folderName,$_returnObject=true) |
|
| 3289 | + function getMailBoxCounters($folderName, $_returnObject = true) |
|
| 3290 | 3290 | { |
| 3291 | 3291 | try |
| 3292 | 3292 | { |
@@ -3298,9 +3298,9 @@ discard block |
||
| 3298 | 3298 | if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
| 3299 | 3299 | return false; |
| 3300 | 3300 | } |
| 3301 | - if(is_array($folderStatus)) { |
|
| 3302 | - if ($_returnObject===false) return $folderStatus; |
|
| 3303 | - $status = new \stdClass; |
|
| 3301 | + if (is_array($folderStatus)) { |
|
| 3302 | + if ($_returnObject === false) return $folderStatus; |
|
| 3303 | + $status = new \stdClass; |
|
| 3304 | 3304 | $status->messages = $folderStatus['MESSAGES']; |
| 3305 | 3305 | $status->unseen = $folderStatus['UNSEEN']; |
| 3306 | 3306 | $status->recent = $folderStatus['RECENT']; |
@@ -3322,42 +3322,42 @@ discard block |
||
| 3322 | 3322 | * @param string $reclevel 0, counter to keep track of the current recursionlevel |
| 3323 | 3323 | * @return array of mailboxes |
| 3324 | 3324 | */ |
| 3325 | - function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
|
| 3325 | + function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0) |
|
| 3326 | 3326 | { |
| 3327 | 3327 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3328 | - $maxreclevel=25; |
|
| 3328 | + $maxreclevel = 25; |
|
| 3329 | 3329 | if ($reclevel > $maxreclevel) { |
| 3330 | - error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3330 | + error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3331 | 3331 | return array(); |
| 3332 | 3332 | } |
| 3333 | 3333 | $reclevel++; |
| 3334 | 3334 | // clean up double delimiters |
| 3335 | - $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox); |
|
| 3335 | + $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox); |
|
| 3336 | 3336 | //get that mailbox in question |
| 3337 | - $mbx = $this->icServer->getMailboxes($_mailbox,1,true); |
|
| 3337 | + $mbx = $this->icServer->getMailboxes($_mailbox, 1, true); |
|
| 3338 | 3338 | $mbxkeys = array_keys($mbx); |
| 3339 | 3339 | #_debug_array($mbx); |
| 3340 | 3340 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3341 | 3341 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3342 | 3342 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3343 | - if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) { |
|
| 3343 | + if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) { |
|
| 3344 | 3344 | // if there are children fetch them |
| 3345 | 3345 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3346 | 3346 | |
| 3347 | - $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
|
| 3347 | + $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false); |
|
| 3348 | 3348 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3349 | 3349 | //_debug_array($buff); |
| 3350 | 3350 | $allMailboxes = array(); |
| 3351 | 3351 | foreach ($buff as $mbxname) { |
| 3352 | 3352 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3353 | - $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
|
| 3353 | + $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']); |
|
| 3354 | 3354 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
| 3355 | - if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3355 | + if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3356 | 3356 | { |
| 3357 | 3357 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3358 | 3358 | } |
| 3359 | 3359 | } |
| 3360 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3360 | + if (!(in_array('\NoSelect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3361 | 3361 | return $allMailboxes; |
| 3362 | 3362 | } else { |
| 3363 | 3363 | return array($_mailbox); |
@@ -3372,18 +3372,18 @@ discard block |
||
| 3372 | 3372 | * @param boolean& $created =null on return true: if folder was just created, false if not |
| 3373 | 3373 | * @return mixed string or false |
| 3374 | 3374 | */ |
| 3375 | - function _getSpecialUseFolder($_type, $_checkexistance=TRUE, &$created=null) |
|
| 3375 | + function _getSpecialUseFolder($_type, $_checkexistance = TRUE, &$created = null) |
|
| 3376 | 3376 | { |
| 3377 | 3377 | static $types = array( |
| 3378 | - 'Drafts' => array('profileKey'=>'acc_folder_draft','autoFolderName'=>'Drafts'), |
|
| 3379 | - 'Template' => array('profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'), |
|
| 3380 | - 'Trash' => array('profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'), |
|
| 3381 | - 'Sent' => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'), |
|
| 3382 | - 'Junk' => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'), |
|
| 3383 | - 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
|
| 3384 | - 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
|
| 3378 | + 'Drafts' => array('profileKey'=>'acc_folder_draft', 'autoFolderName'=>'Drafts'), |
|
| 3379 | + 'Template' => array('profileKey'=>'acc_folder_template', 'autoFolderName'=>'Templates'), |
|
| 3380 | + 'Trash' => array('profileKey'=>'acc_folder_trash', 'autoFolderName'=>'Trash'), |
|
| 3381 | + 'Sent' => array('profileKey'=>'acc_folder_sent', 'autoFolderName'=>'Sent'), |
|
| 3382 | + 'Junk' => array('profileKey'=>'acc_folder_junk', 'autoFolderName'=>'Junk'), |
|
| 3383 | + 'Outbox' => array('profileKey'=>'acc_folder_outbox', 'autoFolderName'=>'Outbox'), |
|
| 3384 | + 'Archive' => array('profileKey'=>'acc_folder_archive', 'autoFolderName'=>'Archive'), |
|
| 3385 | 3385 | ); |
| 3386 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3386 | + if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3387 | 3387 | $created = false; |
| 3388 | 3388 | if (!isset($types[$_type])) |
| 3389 | 3389 | { |
@@ -3405,7 +3405,7 @@ discard block |
||
| 3405 | 3405 | } |
| 3406 | 3406 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3407 | 3407 | if ($_type == 'Archive') { |
| 3408 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3408 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3409 | 3409 | return false; |
| 3410 | 3410 | } else { |
| 3411 | 3411 | return $_folderName; |
@@ -3413,38 +3413,38 @@ discard block |
||
| 3413 | 3413 | |
| 3414 | 3414 | } |
| 3415 | 3415 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3416 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3416 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3417 | 3417 | try |
| 3418 | 3418 | { |
| 3419 | 3419 | $error = null; |
| 3420 | 3420 | if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
| 3421 | 3421 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3422 | 3422 | } |
| 3423 | - catch(Exception $e) |
|
| 3423 | + catch (Exception $e) |
|
| 3424 | 3424 | { |
| 3425 | 3425 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage().':'.function_backtrace()); |
| 3426 | 3426 | $_folderName = false; |
| 3427 | 3427 | } |
| 3428 | 3428 | } |
| 3429 | 3429 | // not sure yet if false is the correct behavior on none |
| 3430 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 3430 | + if ($_folderName == 'none') return 'none'; //false; |
|
| 3431 | 3431 | //no (valid) folder found yet; try specialUseFolders |
| 3432 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 3432 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type, self::$specialUseFolders))) $_folderName = $f; |
|
| 3433 | 3433 | //no specialUseFolder; try some Defaults |
| 3434 | 3434 | if (empty($_folderName) && isset($types[$_type])) |
| 3435 | 3435 | { |
| 3436 | 3436 | $nameSpace = $this->_getNameSpaces(); |
| 3437 | - $prefix=''; |
|
| 3437 | + $prefix = ''; |
|
| 3438 | 3438 | foreach ($nameSpace as $nSp) |
| 3439 | 3439 | { |
| 3440 | - if ($nSp['type']=='personal') |
|
| 3440 | + if ($nSp['type'] == 'personal') |
|
| 3441 | 3441 | { |
| 3442 | 3442 | //error_log(__METHOD__.__LINE__.array2string($nSp)); |
| 3443 | 3443 | $prefix = $nSp['prefix']; |
| 3444 | 3444 | break; |
| 3445 | 3445 | } |
| 3446 | 3446 | } |
| 3447 | - if ($this->folderExists($prefix.$types[$_type]['autoFolderName'],true)) |
|
| 3447 | + if ($this->folderExists($prefix.$types[$_type]['autoFolderName'], true)) |
|
| 3448 | 3448 | { |
| 3449 | 3449 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3450 | 3450 | } |
@@ -3453,11 +3453,11 @@ discard block |
||
| 3453 | 3453 | try |
| 3454 | 3454 | { |
| 3455 | 3455 | $error = null; |
| 3456 | - $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
|
| 3456 | + $this->createFolder('', $prefix.$types[$_type]['autoFolderName'], $error); |
|
| 3457 | 3457 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3458 | 3458 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3459 | 3459 | } |
| 3460 | - catch(Exception $e) |
|
| 3460 | + catch (Exception $e) |
|
| 3461 | 3461 | { |
| 3462 | 3462 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage()); |
| 3463 | 3463 | $_folderName = false; |
@@ -3473,7 +3473,7 @@ discard block |
||
| 3473 | 3473 | * @param boolean $_checkexistance trigger check for existance |
| 3474 | 3474 | * @return mixed string or false |
| 3475 | 3475 | */ |
| 3476 | - function getFolderByType($type, $_checkexistance=false) |
|
| 3476 | + function getFolderByType($type, $_checkexistance = false) |
|
| 3477 | 3477 | { |
| 3478 | 3478 | return $this->_getSpecialUseFolder($type, $_checkexistance); |
| 3479 | 3479 | } |
@@ -3483,7 +3483,7 @@ discard block |
||
| 3483 | 3483 | * @param boolean $_checkexistance trigger check for existance |
| 3484 | 3484 | * @return mixed string or false |
| 3485 | 3485 | */ |
| 3486 | - function getJunkFolder($_checkexistance=TRUE) |
|
| 3486 | + function getJunkFolder($_checkexistance = TRUE) |
|
| 3487 | 3487 | { |
| 3488 | 3488 | return $this->_getSpecialUseFolder('Junk', $_checkexistance); |
| 3489 | 3489 | } |
@@ -3493,7 +3493,7 @@ discard block |
||
| 3493 | 3493 | * @param boolean $_checkexistance trigger check for existance |
| 3494 | 3494 | * @return mixed string or false |
| 3495 | 3495 | */ |
| 3496 | - function getDraftFolder($_checkexistance=TRUE) |
|
| 3496 | + function getDraftFolder($_checkexistance = TRUE) |
|
| 3497 | 3497 | { |
| 3498 | 3498 | return $this->_getSpecialUseFolder('Drafts', $_checkexistance); |
| 3499 | 3499 | } |
@@ -3503,7 +3503,7 @@ discard block |
||
| 3503 | 3503 | * @param boolean $_checkexistance trigger check for existance |
| 3504 | 3504 | * @return mixed string or false |
| 3505 | 3505 | */ |
| 3506 | - function getTemplateFolder($_checkexistance=TRUE) |
|
| 3506 | + function getTemplateFolder($_checkexistance = TRUE) |
|
| 3507 | 3507 | { |
| 3508 | 3508 | return $this->_getSpecialUseFolder('Template', $_checkexistance); |
| 3509 | 3509 | } |
@@ -3513,7 +3513,7 @@ discard block |
||
| 3513 | 3513 | * @param boolean $_checkexistance trigger check for existance |
| 3514 | 3514 | * @return mixed string or false |
| 3515 | 3515 | */ |
| 3516 | - function getTrashFolder($_checkexistance=TRUE) |
|
| 3516 | + function getTrashFolder($_checkexistance = TRUE) |
|
| 3517 | 3517 | { |
| 3518 | 3518 | return $this->_getSpecialUseFolder('Trash', $_checkexistance); |
| 3519 | 3519 | } |
@@ -3523,7 +3523,7 @@ discard block |
||
| 3523 | 3523 | * @param boolean $_checkexistance trigger check for existance |
| 3524 | 3524 | * @return mixed string or false |
| 3525 | 3525 | */ |
| 3526 | - function getSentFolder($_checkexistance=TRUE) |
|
| 3526 | + function getSentFolder($_checkexistance = TRUE) |
|
| 3527 | 3527 | { |
| 3528 | 3528 | return $this->_getSpecialUseFolder('Sent', $_checkexistance); |
| 3529 | 3529 | } |
@@ -3533,7 +3533,7 @@ discard block |
||
| 3533 | 3533 | * @param boolean $_checkexistance trigger check for existance |
| 3534 | 3534 | * @return mixed string or false |
| 3535 | 3535 | */ |
| 3536 | - function getOutboxFolder($_checkexistance=TRUE) |
|
| 3536 | + function getOutboxFolder($_checkexistance = TRUE) |
|
| 3537 | 3537 | { |
| 3538 | 3538 | return $this->_getSpecialUseFolder('Outbox', $_checkexistance); |
| 3539 | 3539 | } |
@@ -3543,7 +3543,7 @@ discard block |
||
| 3543 | 3543 | * @param boolean $_checkexistance trigger check for existance . We do no autocreation for configured Archive folder |
| 3544 | 3544 | * @return mixed string or false |
| 3545 | 3545 | */ |
| 3546 | - function getArchiveFolder($_checkexistance=TRUE) |
|
| 3546 | + function getArchiveFolder($_checkexistance = TRUE) |
|
| 3547 | 3547 | { |
| 3548 | 3548 | return $this->_getSpecialUseFolder('Archive', $_checkexistance); |
| 3549 | 3549 | } |
@@ -3555,10 +3555,10 @@ discard block |
||
| 3555 | 3555 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3556 | 3556 | * @return boolean |
| 3557 | 3557 | */ |
| 3558 | - function isSentFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3558 | + function isSentFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3559 | 3559 | { |
| 3560 | 3560 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3561 | - if(empty($sentFolder)) { |
|
| 3561 | + if (empty($sentFolder)) { |
|
| 3562 | 3562 | return false; |
| 3563 | 3563 | } |
| 3564 | 3564 | // does the folder exist??? |
@@ -3568,13 +3568,13 @@ discard block |
||
| 3568 | 3568 | |
| 3569 | 3569 | if ($_exactMatch) |
| 3570 | 3570 | { |
| 3571 | - if(false !== stripos($_folderName, $sentFolder)&& strlen($_folderName)==strlen($sentFolder)) { |
|
| 3571 | + if (false !== stripos($_folderName, $sentFolder) && strlen($_folderName) == strlen($sentFolder)) { |
|
| 3572 | 3572 | return true; |
| 3573 | 3573 | } else { |
| 3574 | 3574 | return false; |
| 3575 | 3575 | } |
| 3576 | 3576 | } else { |
| 3577 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 3577 | + if (false !== stripos($_folderName, $sentFolder)) { |
|
| 3578 | 3578 | return true; |
| 3579 | 3579 | } else { |
| 3580 | 3580 | return false; |
@@ -3589,9 +3589,9 @@ discard block |
||
| 3589 | 3589 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3590 | 3590 | * @return boolean |
| 3591 | 3591 | */ |
| 3592 | - function isOutbox($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3592 | + function isOutbox($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3593 | 3593 | { |
| 3594 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 3594 | + if (stripos($_folderName, 'Outbox') === false) { |
|
| 3595 | 3595 | return false; |
| 3596 | 3596 | } |
| 3597 | 3597 | // does the folder exist??? |
@@ -3599,13 +3599,13 @@ discard block |
||
| 3599 | 3599 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3600 | 3600 | if ($_exactMatch) |
| 3601 | 3601 | { |
| 3602 | - if(false !== stripos($_folderName, $outboxFolder)&& strlen($_folderName)==strlen($outboxFolder)) { |
|
| 3602 | + if (false !== stripos($_folderName, $outboxFolder) && strlen($_folderName) == strlen($outboxFolder)) { |
|
| 3603 | 3603 | return true; |
| 3604 | 3604 | } else { |
| 3605 | 3605 | return false; |
| 3606 | 3606 | } |
| 3607 | 3607 | } else { |
| 3608 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 3608 | + if (false !== stripos($_folderName, $outboxFolder)) { |
|
| 3609 | 3609 | return true; |
| 3610 | 3610 | } else { |
| 3611 | 3611 | return false; |
@@ -3622,26 +3622,26 @@ discard block |
||
| 3622 | 3622 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3623 | 3623 | * @return boolean |
| 3624 | 3624 | */ |
| 3625 | - function isDraftFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3625 | + function isDraftFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3626 | 3626 | { |
| 3627 | 3627 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3628 | - if(empty($draftFolder)) { |
|
| 3628 | + if (empty($draftFolder)) { |
|
| 3629 | 3629 | return false; |
| 3630 | 3630 | } |
| 3631 | 3631 | // does the folder exist??? |
| 3632 | 3632 | if ($_checkexistance && !$this->folderExists($_folderName)) { |
| 3633 | 3633 | return false; |
| 3634 | 3634 | } |
| 3635 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3635 | + if (is_a($_folderName, "Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3636 | 3636 | if ($_exactMatch) |
| 3637 | 3637 | { |
| 3638 | - if(false !== stripos($_folderName, $draftFolder)&& strlen($_folderName)==strlen($draftFolder)) { |
|
| 3638 | + if (false !== stripos($_folderName, $draftFolder) && strlen($_folderName) == strlen($draftFolder)) { |
|
| 3639 | 3639 | return true; |
| 3640 | 3640 | } else { |
| 3641 | 3641 | return false; |
| 3642 | 3642 | } |
| 3643 | 3643 | } else { |
| 3644 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 3644 | + if (false !== stripos($_folderName, $draftFolder)) { |
|
| 3645 | 3645 | return true; |
| 3646 | 3646 | } else { |
| 3647 | 3647 | return false; |
@@ -3656,10 +3656,10 @@ discard block |
||
| 3656 | 3656 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3657 | 3657 | * @return boolean |
| 3658 | 3658 | */ |
| 3659 | - function isTrashFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3659 | + function isTrashFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3660 | 3660 | { |
| 3661 | 3661 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3662 | - if(empty($trashFolder)) { |
|
| 3662 | + if (empty($trashFolder)) { |
|
| 3663 | 3663 | return false; |
| 3664 | 3664 | } |
| 3665 | 3665 | // does the folder exist??? |
@@ -3669,13 +3669,13 @@ discard block |
||
| 3669 | 3669 | |
| 3670 | 3670 | if ($_exactMatch) |
| 3671 | 3671 | { |
| 3672 | - if(false !== stripos($_folderName, $trashFolder)&& strlen($_folderName)==strlen($trashFolder)) { |
|
| 3672 | + if (false !== stripos($_folderName, $trashFolder) && strlen($_folderName) == strlen($trashFolder)) { |
|
| 3673 | 3673 | return true; |
| 3674 | 3674 | } else { |
| 3675 | 3675 | return false; |
| 3676 | 3676 | } |
| 3677 | 3677 | } else { |
| 3678 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 3678 | + if (false !== stripos($_folderName, $trashFolder)) { |
|
| 3679 | 3679 | return true; |
| 3680 | 3680 | } else { |
| 3681 | 3681 | return false; |
@@ -3690,10 +3690,10 @@ discard block |
||
| 3690 | 3690 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3691 | 3691 | * @return boolean |
| 3692 | 3692 | */ |
| 3693 | - function isTemplateFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3693 | + function isTemplateFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3694 | 3694 | { |
| 3695 | 3695 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3696 | - if(empty($templateFolder)) { |
|
| 3696 | + if (empty($templateFolder)) { |
|
| 3697 | 3697 | return false; |
| 3698 | 3698 | } |
| 3699 | 3699 | // does the folder exist??? |
@@ -3702,13 +3702,13 @@ discard block |
||
| 3702 | 3702 | } |
| 3703 | 3703 | if ($_exactMatch) |
| 3704 | 3704 | { |
| 3705 | - if(false !== stripos($_folderName, $templateFolder)&& strlen($_folderName)==strlen($templateFolder)) { |
|
| 3705 | + if (false !== stripos($_folderName, $templateFolder) && strlen($_folderName) == strlen($templateFolder)) { |
|
| 3706 | 3706 | return true; |
| 3707 | 3707 | } else { |
| 3708 | 3708 | return false; |
| 3709 | 3709 | } |
| 3710 | 3710 | } else { |
| 3711 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 3711 | + if (false !== stripos($_folderName, $templateFolder)) { |
|
| 3712 | 3712 | return true; |
| 3713 | 3713 | } else { |
| 3714 | 3714 | return false; |
@@ -3722,24 +3722,24 @@ discard block |
||
| 3722 | 3722 | * @param boolean $_forceCheck trigger check for existance on icServer |
| 3723 | 3723 | * @return mixed string or false |
| 3724 | 3724 | */ |
| 3725 | - function folderExists($_folder, $_forceCheck=false) |
|
| 3725 | + function folderExists($_folder, $_forceCheck = false) |
|
| 3726 | 3726 | { |
| 3727 | 3727 | static $folderInfo; |
| 3728 | 3728 | $forceCheck = $_forceCheck; |
| 3729 | 3729 | if (empty($_folder)) |
| 3730 | 3730 | { |
| 3731 | 3731 | // this error is more or less without significance, unless we force the check |
| 3732 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3732 | + if ($_forceCheck === true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3733 | 3733 | return false; |
| 3734 | 3734 | } |
| 3735 | 3735 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3736 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3737 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3736 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox") && $_forceCheck === false) return true; |
|
| 3737 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3738 | 3738 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3739 | 3739 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3740 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 3740 | + if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 5); |
|
| 3741 | 3741 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3742 | - if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
|
| 3742 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck === false) |
|
| 3743 | 3743 | { |
| 3744 | 3744 | //error_log(__METHOD__.' ('.__LINE__.') '.' Using cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID); |
| 3745 | 3745 | return $folderInfo[$this->profileID][$_folder]; |
@@ -3755,7 +3755,7 @@ discard block |
||
| 3755 | 3755 | |
| 3756 | 3756 | // does the folder exist??? |
| 3757 | 3757 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3758 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3758 | + if ($forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3759 | 3759 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3760 | 3760 | //return false; |
| 3761 | 3761 | //try to connect |
@@ -3766,18 +3766,18 @@ discard block |
||
| 3766 | 3766 | } |
| 3767 | 3767 | catch (\Exception $e) |
| 3768 | 3768 | { |
| 3769 | - error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 3770 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 3769 | + error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 3770 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 3771 | 3771 | $folderInfo[$this->profileID][$_folder] = false; |
| 3772 | 3772 | } |
| 3773 | 3773 | //error_log(__METHOD__.' ('.__LINE__.') '.' Folder Exists:'.$folderInfo[$this->profileID][$_folder].function_backtrace()); |
| 3774 | 3774 | |
| 3775 | - if(!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3775 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3776 | 3776 | $folderInfo[$this->profileID][$_folder] !== true) |
| 3777 | 3777 | { |
| 3778 | 3778 | $folderInfo[$this->profileID][$_folder] = false; // set to false, whatever it was (to have a valid returnvalue for the static return) |
| 3779 | 3779 | } |
| 3780 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); |
|
| 3780 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, $expiration = 60 * 60 * 5); |
|
| 3781 | 3781 | return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false); |
| 3782 | 3782 | } |
| 3783 | 3783 | |
@@ -3790,14 +3790,14 @@ discard block |
||
| 3790 | 3790 | */ |
| 3791 | 3791 | function compressFolder($_folderName = false) |
| 3792 | 3792 | { |
| 3793 | - $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3794 | - $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3795 | - $trashFolder = $this->getTrashFolder(); |
|
| 3793 | + $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3794 | + $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3795 | + $trashFolder = $this->getTrashFolder(); |
|
| 3796 | 3796 | |
| 3797 | 3797 | $this->icServer->openMailbox($folderName); |
| 3798 | 3798 | |
| 3799 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3800 | - $this->deleteMessages('all',$folderName,'remove_immediately'); |
|
| 3799 | + if (strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3800 | + $this->deleteMessages('all', $folderName, 'remove_immediately'); |
|
| 3801 | 3801 | } else { |
| 3802 | 3802 | $this->icServer->expunge($folderName); |
| 3803 | 3803 | } |
@@ -3813,19 +3813,19 @@ discard block |
||
| 3813 | 3813 | * @return bool true, as we do not handle return values yet |
| 3814 | 3814 | * @throws Exception |
| 3815 | 3815 | */ |
| 3816 | - function deleteMessages($_messageUID, $_folder=NULL, $_forceDeleteMethod='no') |
|
| 3816 | + function deleteMessages($_messageUID, $_folder = NULL, $_forceDeleteMethod = 'no') |
|
| 3817 | 3817 | { |
| 3818 | 3818 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3819 | 3819 | $oldMailbox = ''; |
| 3820 | 3820 | if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
| 3821 | 3821 | if (empty($_messageUID)) |
| 3822 | 3822 | { |
| 3823 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3823 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3824 | 3824 | return false; |
| 3825 | 3825 | } |
| 3826 | - elseif ($_messageUID==='all') |
|
| 3826 | + elseif ($_messageUID === 'all') |
|
| 3827 | 3827 | { |
| 3828 | - $_messageUID= null; |
|
| 3828 | + $_messageUID = null; |
|
| 3829 | 3829 | } |
| 3830 | 3830 | else |
| 3831 | 3831 | { |
@@ -3834,32 +3834,32 @@ discard block |
||
| 3834 | 3834 | $uidsToDelete->add($_messageUID); |
| 3835 | 3835 | } |
| 3836 | 3836 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3837 | - if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted"); |
|
| 3837 | + if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod, array('move_to_trash', "mark_as_deleted", "remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions'] ? $this->mailPreferences['deleteOptions'] : "mark_as_deleted"); |
|
| 3838 | 3838 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3839 | 3839 | $trashFolder = $this->getTrashFolder(); |
| 3840 | - $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3840 | + $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3841 | 3841 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3842 | - if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3842 | + if ((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3843 | 3843 | (strtolower($_folder) == strtolower($draftFolder))) { |
| 3844 | 3844 | $deleteOptions = "remove_immediately"; |
| 3845 | 3845 | } |
| 3846 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3846 | + if ($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3847 | 3847 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3848 | 3848 | $this->icServer->openMailbox($_folder); |
| 3849 | 3849 | } |
| 3850 | 3850 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3851 | 3851 | $updateCache = false; |
| 3852 | - switch($deleteOptions) { |
|
| 3852 | + switch ($deleteOptions) { |
|
| 3853 | 3853 | case "move_to_trash": |
| 3854 | 3854 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3855 | 3855 | $updateCache = true; |
| 3856 | - if(!empty($trashFolder)) { |
|
| 3856 | + if (!empty($trashFolder)) { |
|
| 3857 | 3857 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
| 3858 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 3858 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ".$this->sessionData['mailbox']); |
|
| 3859 | 3859 | // copy messages |
| 3860 | 3860 | try |
| 3861 | 3861 | { |
| 3862 | - $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete,'move'=>true)); |
|
| 3862 | + $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete, 'move'=>true)); |
|
| 3863 | 3863 | } |
| 3864 | 3864 | catch (\Exception $e) |
| 3865 | 3865 | { |
@@ -3871,18 +3871,18 @@ discard block |
||
| 3871 | 3871 | case "mark_as_deleted": |
| 3872 | 3872 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3873 | 3873 | // mark messages as deleted |
| 3874 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3875 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3874 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3875 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3876 | 3876 | { |
| 3877 | 3877 | //flag messages, that are flagged for deletion as seen too |
| 3878 | 3878 | $this->flagMessages('read', $uid, $_folder); |
| 3879 | 3879 | $flags = $this->getFlags($uid); |
| 3880 | 3880 | $this->flagMessages('delete', $uid, $_folder); |
| 3881 | 3881 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3882 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 3882 | + if (strpos(array2string($flags), 'Deleted') !== false) $undelete[] = $uid; |
|
| 3883 | 3883 | unset($flags); |
| 3884 | 3884 | } |
| 3885 | - foreach((array)$undelete as $key =>$uid) |
|
| 3885 | + foreach ((array)$undelete as $key =>$uid) |
|
| 3886 | 3886 | { |
| 3887 | 3887 | $this->flagMessages('undelete', $uid, $_folder); |
| 3888 | 3888 | } |
@@ -3891,14 +3891,14 @@ discard block |
||
| 3891 | 3891 | case "remove_immediately": |
| 3892 | 3892 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3893 | 3893 | $updateCache = true; |
| 3894 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3894 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3895 | 3895 | if (is_object($_messageUID)) |
| 3896 | 3896 | { |
| 3897 | 3897 | $this->flagMessages('delete', $_messageUID, $_folder); |
| 3898 | 3898 | } |
| 3899 | 3899 | else |
| 3900 | 3900 | { |
| 3901 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3901 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3902 | 3902 | { |
| 3903 | 3903 | //flag messages, that are flagged for deletion as seen too |
| 3904 | 3904 | $this->flagMessages('delete', $uid, $_folder); |
@@ -3908,7 +3908,7 @@ discard block |
||
| 3908 | 3908 | $this->icServer->expunge($_folder); |
| 3909 | 3909 | break; |
| 3910 | 3910 | } |
| 3911 | - if($oldMailbox != '') { |
|
| 3911 | + if ($oldMailbox != '') { |
|
| 3912 | 3912 | $this->icServer->openMailbox($oldMailbox); |
| 3913 | 3913 | } |
| 3914 | 3914 | |
@@ -3922,7 +3922,7 @@ discard block |
||
| 3922 | 3922 | * |
| 3923 | 3923 | * @return null/array flags |
| 3924 | 3924 | */ |
| 3925 | - function getFlags ($_messageUID) { |
|
| 3925 | + function getFlags($_messageUID) { |
|
| 3926 | 3926 | try |
| 3927 | 3927 | { |
| 3928 | 3928 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -3935,7 +3935,7 @@ discard block |
||
| 3935 | 3935 | 'ids' => $uidsToFetch, |
| 3936 | 3936 | )); |
| 3937 | 3937 | if (is_object($headersNew)) { |
| 3938 | - foreach($headersNew->ids() as $id) { |
|
| 3938 | + foreach ($headersNew->ids() as $id) { |
|
| 3939 | 3939 | $_headerObject = $headersNew->get($id); |
| 3940 | 3940 | $flags = $_headerObject->getFlags(); |
| 3941 | 3941 | } |
@@ -3958,22 +3958,22 @@ discard block |
||
| 3958 | 3958 | * |
| 3959 | 3959 | * @return null/boolean |
| 3960 | 3960 | */ |
| 3961 | - function getNotifyFlags ($_messageUID, $flags=null) |
|
| 3961 | + function getNotifyFlags($_messageUID, $flags = null) |
|
| 3962 | 3962 | { |
| 3963 | 3963 | if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
| 3964 | 3964 | try |
| 3965 | 3965 | { |
| 3966 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 3966 | + if ($flags === null) $flags = $this->getFlags($_messageUID); |
|
| 3967 | 3967 | } |
| 3968 | 3968 | catch (\Exception $e) |
| 3969 | 3969 | { |
| 3970 | 3970 | return null; |
| 3971 | 3971 | } |
| 3972 | 3972 | |
| 3973 | - if ( stripos( array2string($flags),'MDNSent')!==false) |
|
| 3973 | + if (stripos(array2string($flags), 'MDNSent') !== false) |
|
| 3974 | 3974 | return true; |
| 3975 | 3975 | |
| 3976 | - if ( stripos( array2string($flags),'MDNnotSent')!==false) |
|
| 3976 | + if (stripos(array2string($flags), 'MDNnotSent') !== false) |
|
| 3977 | 3977 | return false; |
| 3978 | 3978 | |
| 3979 | 3979 | return null; |
@@ -3990,45 +3990,45 @@ discard block |
||
| 3990 | 3990 | * |
| 3991 | 3991 | * @return bool true, as we do not handle icserver->setFlags returnValue |
| 3992 | 3992 | */ |
| 3993 | - function flagMessages($_flag, $_messageUID,$_folder=NULL) |
|
| 3993 | + function flagMessages($_flag, $_messageUID, $_folder = NULL) |
|
| 3994 | 3994 | { |
| 3995 | 3995 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3996 | 3996 | if (empty($_messageUID)) |
| 3997 | 3997 | { |
| 3998 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3998 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3999 | 3999 | return false; |
| 4000 | 4000 | } |
| 4001 | - $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
|
| 4001 | + $this->icServer->openMailbox(($_folder ? $_folder : $this->sessionData['mailbox'])); |
|
| 4002 | 4002 | $folder = $this->icServer->getCurrentMailbox(); |
| 4003 | - if (is_array($_messageUID)&& count($_messageUID)>50) |
|
| 4003 | + if (is_array($_messageUID) && count($_messageUID) > 50) |
|
| 4004 | 4004 | { |
| 4005 | - $count = $this->getMailBoxCounters($folder,true); |
|
| 4006 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 4005 | + $count = $this->getMailBoxCounters($folder, true); |
|
| 4006 | + if ($count->messages == count($_messageUID)) $_messageUID = 'all'; |
|
| 4007 | 4007 | } |
| 4008 | 4008 | |
| 4009 | - if ($_messageUID==='all') |
|
| 4009 | + if ($_messageUID === 'all') |
|
| 4010 | 4010 | { |
| 4011 | 4011 | $messageUIDs = array('all'); |
| 4012 | 4012 | } |
| 4013 | 4013 | else |
| 4014 | 4014 | { |
| 4015 | 4015 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 4016 | - $messageUIDs = array_chunk($_messageUID,50,true); |
|
| 4016 | + $messageUIDs = array_chunk($_messageUID, 50, true); |
|
| 4017 | 4017 | } |
| 4018 | 4018 | try |
| 4019 | 4019 | { |
| 4020 | - foreach($messageUIDs as &$uids) |
|
| 4020 | + foreach ($messageUIDs as &$uids) |
|
| 4021 | 4021 | { |
| 4022 | - if ($uids==='all') |
|
| 4022 | + if ($uids === 'all') |
|
| 4023 | 4023 | { |
| 4024 | - $uidsToModify=null; |
|
| 4024 | + $uidsToModify = null; |
|
| 4025 | 4025 | } |
| 4026 | 4026 | else |
| 4027 | 4027 | { |
| 4028 | 4028 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 4029 | 4029 | $uidsToModify->add($uids); |
| 4030 | 4030 | } |
| 4031 | - switch($_flag) { |
|
| 4031 | + switch ($_flag) { |
|
| 4032 | 4032 | case "delete": |
| 4033 | 4033 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 4034 | 4034 | break; |
@@ -4052,7 +4052,7 @@ discard block |
||
| 4052 | 4052 | break; |
| 4053 | 4053 | case "unread": |
| 4054 | 4054 | case "unseen": |
| 4055 | - $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen','\\Answered','$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 4055 | + $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen', '\\Answered', '$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 4056 | 4056 | break; |
| 4057 | 4057 | case "mdnsent": |
| 4058 | 4058 | $ret = $this->icServer->store($folder, array('add'=>array('MDNSent'), 'ids'=> $uidsToModify)); |
@@ -4110,13 +4110,13 @@ discard block |
||
| 4110 | 4110 | } |
| 4111 | 4111 | } |
| 4112 | 4112 | } |
| 4113 | - catch(Exception $e) |
|
| 4113 | + catch (Exception $e) |
|
| 4114 | 4114 | { |
| 4115 | 4115 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4116 | 4116 | } |
| 4117 | 4117 | if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
| 4118 | 4118 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4119 | - self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4119 | + self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder) ? $_folder : $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4120 | 4120 | |
| 4121 | 4121 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox'])); |
| 4122 | 4122 | return true; // as we do not catch/examine setFlags returnValue |
@@ -4137,19 +4137,19 @@ discard block |
||
| 4137 | 4137 | * @return mixed/bool true,false or new uid |
| 4138 | 4138 | * @throws Exception |
| 4139 | 4139 | */ |
| 4140 | - function moveMessages($_foldername, $_messageUID, $deleteAfterMove=true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4140 | + function moveMessages($_foldername, $_messageUID, $deleteAfterMove = true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4141 | 4141 | { |
| 4142 | - $source = Mail\Account::read(($_sourceProfileID?$_sourceProfileID:$this->icServer->ImapServerId))->imapServer(); |
|
| 4142 | + $source = Mail\Account::read(($_sourceProfileID ? $_sourceProfileID : $this->icServer->ImapServerId))->imapServer(); |
|
| 4143 | 4143 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4144 | 4144 | if (empty($_messageUID)) |
| 4145 | 4145 | { |
| 4146 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4146 | + if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',', $_messageUID)); |
|
| 4147 | 4147 | return false; |
| 4148 | 4148 | } |
| 4149 | - elseif ($_messageUID==='all') |
|
| 4149 | + elseif ($_messageUID === 'all') |
|
| 4150 | 4150 | { |
| 4151 | 4151 | //error_log(__METHOD__." all Message(s): ".implode(',',$_messageUID)); |
| 4152 | - $uidsToMove= null; |
|
| 4152 | + $uidsToMove = null; |
|
| 4153 | 4153 | } |
| 4154 | 4154 | else |
| 4155 | 4155 | { |
@@ -4158,7 +4158,7 @@ discard block |
||
| 4158 | 4158 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 4159 | 4159 | $uidsToMove->add($_messageUID); |
| 4160 | 4160 | } |
| 4161 | - $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
|
| 4161 | + $sourceFolder = (!empty($currentFolder) ? $currentFolder : $this->sessionData['mailbox']); |
|
| 4162 | 4162 | //error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId)); |
| 4163 | 4163 | if (!is_null($_targetProfileID) && $_targetProfileID !== $source->ImapServerId) |
| 4164 | 4164 | { |
@@ -4178,19 +4178,19 @@ discard block |
||
| 4178 | 4178 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4179 | 4179 | |
| 4180 | 4180 | if (is_object($headersNew)) { |
| 4181 | - $c=0; |
|
| 4181 | + $c = 0; |
|
| 4182 | 4182 | $retUid = new Horde_Imap_Client_Ids(); |
| 4183 | 4183 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4184 | 4184 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4185 | - foreach($headersNew as &$_headerObject) { |
|
| 4185 | + foreach ($headersNew as &$_headerObject) { |
|
| 4186 | 4186 | $c++; |
| 4187 | 4187 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4188 | 4188 | $date = $_headerObject->getImapDate(); |
| 4189 | - $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4189 | + $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4190 | 4190 | // if the internal Date of the message equals the current date; try using the header date |
| 4191 | - if ($date==$currentDate) |
|
| 4191 | + if ($date == $currentDate) |
|
| 4192 | 4192 | { |
| 4193 | - $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4193 | + $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4194 | 4194 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'.$headerForPrio['DATE']); |
| 4195 | 4195 | $date = new Horde_Imap_Client_DateTime($headerForPrio['DATE']); |
| 4196 | 4196 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'); |
@@ -4199,20 +4199,20 @@ discard block |
||
| 4199 | 4199 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 4200 | 4200 | $body = $_headerObject->getFullMsg(); |
| 4201 | 4201 | $dataNflags[] = array('data'=>$body, 'flags'=>$flags, 'internaldate'=>$date); |
| 4202 | - if ($c==1) |
|
| 4202 | + if ($c == 1) |
|
| 4203 | 4203 | { |
| 4204 | 4204 | $target = Mail\Account::read($_targetProfileID)->imapServer(); |
| 4205 | 4205 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' TargetServer:'.$_targetProfileID.' TargetFolderObject:'.array2string($_foldername)); |
| 4206 | 4206 | $foldername = $target->getMailbox($_foldername); |
| 4207 | 4207 | // make sure the target folder is open and ready |
| 4208 | 4208 | $target->openMailbox($foldername); |
| 4209 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4209 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4210 | 4210 | $retUid->add($ret); |
| 4211 | 4211 | unset($dataNflags); |
| 4212 | 4212 | // sleep 500 miliseconds; AS some sERVERs seem not to be capable of the load this is |
| 4213 | 4213 | // inflicting in them. they "reply" with an unspecific IMAP Error |
| 4214 | - time_nanosleep(0,500000); |
|
| 4215 | - $c=0; |
|
| 4214 | + time_nanosleep(0, 500000); |
|
| 4215 | + $c = 0; |
|
| 4216 | 4216 | } |
| 4217 | 4217 | } |
| 4218 | 4218 | if (isset($dataNflags)) |
@@ -4222,7 +4222,7 @@ discard block |
||
| 4222 | 4222 | $foldername = $target->getMailbox($_foldername); |
| 4223 | 4223 | // make sure the target folder is open and ready |
| 4224 | 4224 | $target->openMailbox($foldername); |
| 4225 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4225 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4226 | 4226 | $retUid->add($ret); |
| 4227 | 4227 | unset($dataNflags); |
| 4228 | 4228 | } |
@@ -4233,7 +4233,7 @@ discard block |
||
| 4233 | 4233 | { |
| 4234 | 4234 | $remember = $this->icServer; |
| 4235 | 4235 | $this->icServer = $source; |
| 4236 | - $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod='remove_immediately'); |
|
| 4236 | + $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod = 'remove_immediately'); |
|
| 4237 | 4237 | $this->icServer = $remember; |
| 4238 | 4238 | } |
| 4239 | 4239 | } |
@@ -4242,7 +4242,7 @@ discard block |
||
| 4242 | 4242 | { |
| 4243 | 4243 | try |
| 4244 | 4244 | { |
| 4245 | - $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove,'move'=>$deleteAfterMove)); |
|
| 4245 | + $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove, 'move'=>$deleteAfterMove)); |
|
| 4246 | 4246 | } |
| 4247 | 4247 | catch (exception $e) |
| 4248 | 4248 | { |
@@ -4262,19 +4262,19 @@ discard block |
||
| 4262 | 4262 | * @param string $format ='' if none is passed, use user prefs |
| 4263 | 4263 | * @return string returns the date as it is parseable by strtotime, or current timestamp if everything fails |
| 4264 | 4264 | */ |
| 4265 | - static function _strtotime($_date='', $format='', $convert2usertime=false) |
|
| 4265 | + static function _strtotime($_date = '', $format = '', $convert2usertime = false) |
|
| 4266 | 4266 | { |
| 4267 | 4267 | try { |
| 4268 | - $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4269 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4268 | + $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4269 | + if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4270 | 4270 | $date2return = $date->format($format); |
| 4271 | 4271 | } |
| 4272 | - catch(\Exception $e) |
|
| 4272 | + catch (\Exception $e) |
|
| 4273 | 4273 | { |
| 4274 | - unset($e); // not used |
|
| 4274 | + unset($e); // not used |
|
| 4275 | 4275 | |
| 4276 | 4276 | // remove last space-separated part and retry |
| 4277 | - $parts = explode(' ',$_date); |
|
| 4277 | + $parts = explode(' ', $_date); |
|
| 4278 | 4278 | if (count($parts) > 1) |
| 4279 | 4279 | { |
| 4280 | 4280 | array_pop($parts); |
@@ -4295,12 +4295,12 @@ discard block |
||
| 4295 | 4295 | * @param mixed $_charset false or string -> Target charset, if false Mail displayCharset will be used |
| 4296 | 4296 | * @return string |
| 4297 | 4297 | */ |
| 4298 | - static function htmlentities($_string, $_charset=false) |
|
| 4298 | + static function htmlentities($_string, $_charset = false) |
|
| 4299 | 4299 | { |
| 4300 | 4300 | //setting the charset (if not given) |
| 4301 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 4301 | + if ($_charset === false) $_charset = self::$displayCharset; |
|
| 4302 | 4302 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4303 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4303 | + if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string, Translation::detect_encoding($_string), $_charset), ENT_QUOTES|ENT_IGNORE, $_charset, false); |
|
| 4304 | 4304 | return $string; |
| 4305 | 4305 | } |
| 4306 | 4306 | |
@@ -4317,21 +4317,21 @@ discard block |
||
| 4317 | 4317 | //$_html = str_replace("\t",' ',$_html); |
| 4318 | 4318 | //error_log(__METHOD__.__LINE__.':'.$_html); |
| 4319 | 4319 | //repair doubleencoded ampersands, and some stuff htmLawed stumbles upon with balancing switched on |
| 4320 | - $_html = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>','</td></font>','<br><td>','<tr></tr>','<o:p></o:p>','<o:p>','</o:p>'), |
|
| 4321 | - array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
|
| 4320 | + $_html = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>', '</td></font>', '<br><td>', '<tr></tr>', '<o:p></o:p>', '<o:p>', '</o:p>'), |
|
| 4321 | + array('&', '<BR>', '<BR>', '<BR>', '</font></td>', '<td>', '', '', '', ''), $_html); |
|
| 4322 | 4322 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4323 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4324 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 4323 | + if (stripos($_html, 'style') !== false) Mail\Html::replaceTagsCompletley($_html, 'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4324 | + if (stripos($_html, 'head') !== false) Mail\Html::replaceTagsCompletley($_html, 'head'); // Strip out stuff in head |
|
| 4325 | 4325 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4326 | 4326 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4327 | 4327 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4328 | 4328 | |
| 4329 | 4329 | if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
| 4330 | 4330 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4331 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4332 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4333 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4334 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 4331 | + if (stripos($_html, '!doctype') !== false) Mail\Html::replaceTagsCompletley($_html, '!doctype'); |
|
| 4332 | + if (stripos($_html, '?xml:namespace') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml:namespace', '/>', false); |
|
| 4333 | + if (stripos($_html, '?xml version') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml version', '\?>', false); |
|
| 4334 | + if (strpos($_html, '!CURSOR') !== false) Mail\Html::replaceTagsCompletley($_html, '!CURSOR'); |
|
| 4335 | 4335 | // htmLawed filter only the 'body' |
| 4336 | 4336 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4337 | 4337 | //if ($matches[2]) |
@@ -4342,16 +4342,16 @@ discard block |
||
| 4342 | 4342 | // purify got switched to htmLawed |
| 4343 | 4343 | // some testcode to test purifying / htmlawed |
| 4344 | 4344 | //$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html; |
| 4345 | - $_html = Html\HtmLawed::purify($_html,self::$htmLawed_config,array(),true); |
|
| 4345 | + $_html = Html\HtmLawed::purify($_html, self::$htmLawed_config, array(), true); |
|
| 4346 | 4346 | //if ($hasOther) $_html = $matches[1]. $_html. $matches[3]; |
| 4347 | 4347 | // clean out comments , should not be needed as purify should do the job. |
| 4348 | 4348 | $search = array( |
| 4349 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4350 | - '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4349 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4350 | + '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4351 | 4351 | ); |
| 4352 | - $_html = preg_replace($search,"",$_html); |
|
| 4352 | + $_html = preg_replace($search, "", $_html); |
|
| 4353 | 4353 | // remove non printable chars |
| 4354 | - $_html = preg_replace('/([\000-\011])/','',$_html); |
|
| 4354 | + $_html = preg_replace('/([\000-\011])/', '', $_html); |
|
| 4355 | 4355 | //error_log(__METHOD__.':'.__LINE__.':'.$_html); |
| 4356 | 4356 | } |
| 4357 | 4357 | |
@@ -4368,12 +4368,12 @@ discard block |
||
| 4368 | 4368 | function getMimePartCharset($_mimePartObject) |
| 4369 | 4369 | { |
| 4370 | 4370 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4371 | - $CharsetFound=false; |
|
| 4371 | + $CharsetFound = false; |
|
| 4372 | 4372 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4373 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4374 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4373 | + if (is_array($_mimePartObject->parameters)) { |
|
| 4374 | + if (isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4375 | 4375 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4376 | - $CharsetFound=true; |
|
| 4376 | + $CharsetFound = true; |
|
| 4377 | 4377 | } |
| 4378 | 4378 | } |
| 4379 | 4379 | // this one is dirty, but until I find something that does the trick of detecting the encoding, .... |
@@ -4392,7 +4392,7 @@ discard block |
||
| 4392 | 4392 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4393 | 4393 | { |
| 4394 | 4394 | // decode the part |
| 4395 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 4395 | + if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage, true)); |
|
| 4396 | 4396 | switch (strtoupper($_encoding)) |
| 4397 | 4397 | { |
| 4398 | 4398 | case 'BASE64': |
@@ -4432,10 +4432,10 @@ discard block |
||
| 4432 | 4432 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4433 | 4433 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4434 | 4434 | $partText = $partCalendar = $partHTML = null; |
| 4435 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 4435 | + if (self::$debug) _debug_array(array("METHOD"=>__METHOD__, "LINE"=>__LINE__, "STRUCTURE"=>$_structure)); |
|
| 4436 | 4436 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4437 | 4437 | $ignore_first_part = true; |
| 4438 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4438 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4439 | 4439 | { |
| 4440 | 4440 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4441 | 4441 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4443,15 +4443,15 @@ discard block |
||
| 4443 | 4443 | if ($ignore_first_part) |
| 4444 | 4444 | { |
| 4445 | 4445 | $ignore_first_part = false; |
| 4446 | - continue; // ignore multipart/alternative itself |
|
| 4446 | + continue; // ignore multipart/alternative itself |
|
| 4447 | 4447 | } |
| 4448 | 4448 | |
| 4449 | 4449 | $mimePart = $_structure->getPart($mime_id); |
| 4450 | 4450 | |
| 4451 | - switch($mimePart->getPrimaryType()) |
|
| 4451 | + switch ($mimePart->getPrimaryType()) |
|
| 4452 | 4452 | { |
| 4453 | 4453 | case 'text': |
| 4454 | - switch($mimePart->getSubType()) |
|
| 4454 | + switch ($mimePart->getSubType()) |
|
| 4455 | 4455 | { |
| 4456 | 4456 | case 'plain': |
| 4457 | 4457 | if ($mimePart->getBytes() > 0) $partText = $mimePart; |
@@ -4464,7 +4464,7 @@ discard block |
||
| 4464 | 4464 | break; |
| 4465 | 4465 | |
| 4466 | 4466 | case 'multipart': |
| 4467 | - switch($mimePart->getSubType()) |
|
| 4467 | + switch ($mimePart->getSubType()) |
|
| 4468 | 4468 | { |
| 4469 | 4469 | case 'related': |
| 4470 | 4470 | case 'mixed': |
@@ -4486,13 +4486,13 @@ discard block |
||
| 4486 | 4486 | } |
| 4487 | 4487 | } |
| 4488 | 4488 | |
| 4489 | - switch($_htmlMode) |
|
| 4489 | + switch ($_htmlMode) |
|
| 4490 | 4490 | { |
| 4491 | 4491 | case 'html_only': |
| 4492 | 4492 | case 'always_display': |
| 4493 | 4493 | if ($partHTML) |
| 4494 | 4494 | { |
| 4495 | - switch($partHTML->getSubType()) |
|
| 4495 | + switch ($partHTML->getSubType()) |
|
| 4496 | 4496 | { |
| 4497 | 4497 | case 'related': |
| 4498 | 4498 | return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
@@ -4504,7 +4504,7 @@ discard block |
||
| 4504 | 4504 | return $this->getTextPart($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
| 4505 | 4505 | } |
| 4506 | 4506 | } |
| 4507 | - elseif ($partText && $_htmlMode=='always_display') |
|
| 4507 | + elseif ($partText && $_htmlMode == 'always_display') |
|
| 4508 | 4508 | { |
| 4509 | 4509 | return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen); |
| 4510 | 4510 | } |
@@ -4550,7 +4550,7 @@ discard block |
||
| 4550 | 4550 | * @param array &$skipParts - passed by reference to have control/knowledge which parts are already fetched |
| 4551 | 4551 | * @return array containing the desired part |
| 4552 | 4552 | */ |
| 4553 | - function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
|
| 4553 | + function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts = array()) |
|
| 4554 | 4554 | { |
| 4555 | 4555 | if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
| 4556 | 4556 | $bodyPart = array(); |
@@ -4559,7 +4559,7 @@ discard block |
||
| 4559 | 4559 | $ignore_first_part = true; |
| 4560 | 4560 | //$skipParts = array(); |
| 4561 | 4561 | //error_log(__METHOD__.__LINE__.array2string($_structure->contentTypeMap())); |
| 4562 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4562 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4563 | 4563 | { |
| 4564 | 4564 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4565 | 4565 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4567,9 +4567,9 @@ discard block |
||
| 4567 | 4567 | { |
| 4568 | 4568 | $ignore_first_part = false; |
| 4569 | 4569 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED FirstPart $mime_id: $mime_type"); |
| 4570 | - continue; // ignore multipart/mixed itself |
|
| 4570 | + continue; // ignore multipart/mixed itself |
|
| 4571 | 4571 | } |
| 4572 | - if (array_key_exists($mime_id,$skipParts)) |
|
| 4572 | + if (array_key_exists($mime_id, $skipParts)) |
|
| 4573 | 4573 | { |
| 4574 | 4574 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED $mime_id: $mime_type"); |
| 4575 | 4575 | continue; |
@@ -4577,11 +4577,11 @@ discard block |
||
| 4577 | 4577 | |
| 4578 | 4578 | $part = $_structure->getPart($mime_id); |
| 4579 | 4579 | |
| 4580 | - switch($part->getPrimaryType()) |
|
| 4580 | + switch ($part->getPrimaryType()) |
|
| 4581 | 4581 | { |
| 4582 | 4582 | case 'multipart': |
| 4583 | 4583 | if ($part->getDisposition() == 'attachment') continue; |
| 4584 | - switch($part->getSubType()) |
|
| 4584 | + switch ($part->getSubType()) |
|
| 4585 | 4585 | { |
| 4586 | 4586 | case 'alternative': |
| 4587 | 4587 | return array($this->getMultipartAlternative($_uid, $part, $_htmlMode, $_preserveSeen)); |
@@ -4597,15 +4597,15 @@ discard block |
||
| 4597 | 4597 | } |
| 4598 | 4598 | break; |
| 4599 | 4599 | case 'application': |
| 4600 | - switch($part->getSubType()) |
|
| 4600 | + switch ($part->getSubType()) |
|
| 4601 | 4601 | { |
| 4602 | 4602 | case 'pgp-encrypted': |
| 4603 | - if (($part = $_structure->getPart($mime_id+1)) && |
|
| 4603 | + if (($part = $_structure->getPart($mime_id + 1)) && |
|
| 4604 | 4604 | $part->getType() == 'application/octet-stream') |
| 4605 | 4605 | { |
| 4606 | 4606 | $this->fetchPartContents($_uid, $part); |
| 4607 | - $skipParts[$mime_id]=$mime_type; |
|
| 4608 | - $skipParts[$mime_id+1]=$part->getType(); |
|
| 4607 | + $skipParts[$mime_id] = $mime_type; |
|
| 4608 | + $skipParts[$mime_id + 1] = $part->getType(); |
|
| 4609 | 4609 | $bodyPart[] = array( |
| 4610 | 4610 | 'body' => $part->getContents(array( |
| 4611 | 4611 | 'stream' => false, |
@@ -4619,15 +4619,15 @@ discard block |
||
| 4619 | 4619 | break; |
| 4620 | 4620 | |
| 4621 | 4621 | case 'text': |
| 4622 | - switch($part->getSubType()) |
|
| 4622 | + switch ($part->getSubType()) |
|
| 4623 | 4623 | { |
| 4624 | 4624 | case 'plain': |
| 4625 | 4625 | case 'html': |
| 4626 | 4626 | case 'calendar': // inline ics/ical files |
| 4627 | - if($part->getDisposition() != 'attachment') |
|
| 4627 | + if ($part->getDisposition() != 'attachment') |
|
| 4628 | 4628 | { |
| 4629 | 4629 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4630 | - $skipParts[$mime_id]=$mime_type; |
|
| 4630 | + $skipParts[$mime_id] = $mime_type; |
|
| 4631 | 4631 | } |
| 4632 | 4632 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$part->type."/".$part->subType.' -> BodyPart:'.array2string($bodyPart[count($bodyPart)-1])); |
| 4633 | 4633 | break; |
@@ -4636,16 +4636,16 @@ discard block |
||
| 4636 | 4636 | |
| 4637 | 4637 | case 'message': |
| 4638 | 4638 | //skip attachments |
| 4639 | - if($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4639 | + if ($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4640 | 4640 | { |
| 4641 | 4641 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4642 | - $skipParts[$mime_id]=$mime_type; |
|
| 4642 | + $skipParts[$mime_id] = $mime_type; |
|
| 4643 | 4643 | } |
| 4644 | 4644 | // do not descend into attached Messages |
| 4645 | - if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4645 | + if ($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4646 | 4646 | { |
| 4647 | 4647 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4648 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 4648 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { $skipParts[$sub_id] = $sub_type; } |
|
| 4649 | 4649 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4650 | 4650 | //break 2; |
| 4651 | 4651 | } |
@@ -4686,13 +4686,13 @@ discard block |
||
| 4686 | 4686 | * @param boolean $_tryDecodingServerside = true; wether to try to fetch Data with BINARY instead of BODY |
| 4687 | 4687 | * @return string|resource |
| 4688 | 4688 | */ |
| 4689 | - function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
|
| 4689 | + function getBodyPart($_uid, $_partID = null, $_folder = null, $_preserveSeen = false, $_stream = false, &$_encoding = null, $_tryDecodingServerside = true) |
|
| 4690 | 4690 | { |
| 4691 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4691 | + if (self::$debug) error_log(__METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4692 | 4692 | |
| 4693 | 4693 | if (empty($_folder)) |
| 4694 | 4694 | { |
| 4695 | - $_folder = (isset($this->sessionData['mailbox'])&&$this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4695 | + $_folder = (isset($this->sessionData['mailbox']) && $this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4696 | 4696 | } |
| 4697 | 4697 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4698 | 4698 | // querying contents of body part |
@@ -4703,11 +4703,11 @@ discard block |
||
| 4703 | 4703 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 4704 | 4704 | $fetchParams = array( |
| 4705 | 4705 | 'peek' => $_preserveSeen, |
| 4706 | - 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4706 | + 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4707 | 4707 | ); |
| 4708 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4708 | + if ($_tryDecodingServerside === false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4709 | 4709 | { |
| 4710 | - $_tryDecodingServerside=false; |
|
| 4710 | + $_tryDecodingServerside = false; |
|
| 4711 | 4711 | $fetchParams = array( |
| 4712 | 4712 | 'peek' => $_preserveSeen, |
| 4713 | 4713 | ); |
@@ -4727,12 +4727,12 @@ discard block |
||
| 4727 | 4727 | } |
| 4728 | 4728 | // if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID]) |
| 4729 | 4729 | // thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID]) |
| 4730 | - if (empty($partToReturn)&&$_tryDecodingServerside===true) |
|
| 4730 | + if (empty($partToReturn) && $_tryDecodingServerside === true) |
|
| 4731 | 4731 | { |
| 4732 | 4732 | error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY'); |
| 4733 | 4733 | $partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false); |
| 4734 | 4734 | } |
| 4735 | - return ($partToReturn?$partToReturn:null); |
|
| 4735 | + return ($partToReturn ? $partToReturn : null); |
|
| 4736 | 4736 | } |
| 4737 | 4737 | |
| 4738 | 4738 | /** |
@@ -4745,13 +4745,13 @@ discard block |
||
| 4745 | 4745 | * @param boolean $_stream = false true return a stream, false return string |
| 4746 | 4746 | * @return array containing the desired text part, mimeType and charset |
| 4747 | 4747 | */ |
| 4748 | - function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode='', $_preserveSeen=false, $_stream=false) |
|
| 4748 | + function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode = '', $_preserveSeen = false, $_stream = false) |
|
| 4749 | 4749 | { |
| 4750 | 4750 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4751 | 4751 | $bodyPart = array(); |
| 4752 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 4752 | + if (self::$debug) _debug_array(array($_structure, function_backtrace())); |
|
| 4753 | 4753 | |
| 4754 | - if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4754 | + if ($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4755 | 4755 | { |
| 4756 | 4756 | $bodyPart = array( |
| 4757 | 4757 | 'error' => 1, |
@@ -4797,10 +4797,10 @@ discard block |
||
| 4797 | 4797 | * @param string $_folder folder to work on |
| 4798 | 4798 | * @return array containing the message body, mimeType and charset |
| 4799 | 4799 | */ |
| 4800 | - function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
|
| 4800 | + function getMessageBody($_uid, $_htmlOptions = '', $_partID = null, Horde_Mime_Part $_structure = null, $_preserveSeen = false, $_folder = '') |
|
| 4801 | 4801 | { |
| 4802 | 4802 | if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
| 4803 | - if($_htmlOptions != '') { |
|
| 4803 | + if ($_htmlOptions != '') { |
|
| 4804 | 4804 | $this->htmlOptions = $_htmlOptions; |
| 4805 | 4805 | } |
| 4806 | 4806 | if (empty($_folder)) |
@@ -4821,7 +4821,7 @@ discard block |
||
| 4821 | 4821 | return array( |
| 4822 | 4822 | array( |
| 4823 | 4823 | 'error' => 1, |
| 4824 | - 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions". 'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4824 | + 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions".'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4825 | 4825 | 'mimeType' => 'text/plain', |
| 4826 | 4826 | 'charSet' => self::$displayCharset, |
| 4827 | 4827 | ) |
@@ -4834,7 +4834,7 @@ discard block |
||
| 4834 | 4834 | //_debug_array($_structure->getMimeId()); exit; |
| 4835 | 4835 | } |
| 4836 | 4836 | |
| 4837 | - switch($_structure->getPrimaryType()) |
|
| 4837 | + switch ($_structure->getPrimaryType()) |
|
| 4838 | 4838 | { |
| 4839 | 4839 | case 'application': |
| 4840 | 4840 | return array( |
@@ -4846,7 +4846,7 @@ discard block |
||
| 4846 | 4846 | ); |
| 4847 | 4847 | |
| 4848 | 4848 | case 'multipart': |
| 4849 | - switch($_structure->getSubType()) |
|
| 4849 | + switch ($_structure->getSubType()) |
|
| 4850 | 4850 | { |
| 4851 | 4851 | case 'alternative': |
| 4852 | 4852 | $bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
@@ -4880,7 +4880,7 @@ discard block |
||
| 4880 | 4880 | $bodyPart = array(); |
| 4881 | 4881 | if ($_structure->getDisposition() != 'attachment') |
| 4882 | 4882 | { |
| 4883 | - switch($_structure->getSubType()) |
|
| 4883 | + switch ($_structure->getSubType()) |
|
| 4884 | 4884 | { |
| 4885 | 4885 | case 'calendar': |
| 4886 | 4886 | // this is handeled in getTextPart |
@@ -4896,11 +4896,11 @@ discard block |
||
| 4896 | 4896 | |
| 4897 | 4897 | case 'attachment': |
| 4898 | 4898 | case 'message': |
| 4899 | - switch($_structure->getSubType()) |
|
| 4899 | + switch ($_structure->getSubType()) |
|
| 4900 | 4900 | { |
| 4901 | 4901 | case 'rfc822': |
| 4902 | 4902 | $newStructure = $_structure->getParts(); |
| 4903 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4903 | + if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]); } |
|
| 4904 | 4904 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4905 | 4905 | } |
| 4906 | 4906 | break; |
@@ -4928,11 +4928,11 @@ discard block |
||
| 4928 | 4928 | { |
| 4929 | 4929 | if (is_array($_bodyParts)) |
| 4930 | 4930 | { |
| 4931 | - foreach($_bodyParts as $singleBodyPart) |
|
| 4931 | + foreach ($_bodyParts as $singleBodyPart) |
|
| 4932 | 4932 | { |
| 4933 | 4933 | if (!isset($singleBodyPart['body'])) { |
| 4934 | 4934 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4935 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 4935 | + foreach ((array)$buff as $val) { $body2return[] = $val; } |
|
| 4936 | 4936 | continue; |
| 4937 | 4937 | } |
| 4938 | 4938 | $body2return[] = $singleBodyPart; |
@@ -4953,14 +4953,14 @@ discard block |
||
| 4953 | 4953 | * @param boolean $useTidy switch to use tidy |
| 4954 | 4954 | * @return string a preformatted string with the mails converted to text |
| 4955 | 4955 | */ |
| 4956 | - static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4956 | + static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4957 | 4957 | { |
| 4958 | - $message=''; |
|
| 4959 | - for($i=0; $i<count($bodyParts); $i++) |
|
| 4958 | + $message = ''; |
|
| 4959 | + for ($i = 0; $i < count($bodyParts); $i++) |
|
| 4960 | 4960 | { |
| 4961 | 4961 | if (!isset($bodyParts[$i]['body'])) { |
| 4962 | 4962 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4963 | - $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
|
| 4963 | + $message .= empty($bodyParts[$i]['body']) ? '' : $bodyParts[$i]['body']; |
|
| 4964 | 4964 | continue; |
| 4965 | 4965 | } |
| 4966 | 4966 | if (isset($bodyParts[$i]['error'])) continue; |
@@ -4985,32 +4985,32 @@ discard block |
||
| 4985 | 4985 | '(R)', |
| 4986 | 4986 | ); |
| 4987 | 4987 | |
| 4988 | - if(($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4988 | + if (($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4989 | 4989 | strtoupper($bodyParts[$i]['charSet']) != 'UTF-8') |
| 4990 | 4990 | { |
| 4991 | - $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
|
| 4991 | + $bodyParts[$i]['body'] = preg_replace($sar, $rar, $bodyParts[$i]['body']); |
|
| 4992 | 4992 | } |
| 4993 | 4993 | |
| 4994 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4994 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4995 | 4995 | // add line breaks to $bodyParts |
| 4996 | 4996 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4997 | - $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4997 | + $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4998 | 4998 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4999 | 4999 | $mailClass->activeMimeType = 'text/plain'; |
| 5000 | 5000 | if ($bodyParts[$i]['mimeType'] == 'text/html') { |
| 5001 | 5001 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 5002 | 5002 | if (!$preserveHTML) |
| 5003 | 5003 | { |
| 5004 | - $alreadyHtmlLawed=false; |
|
| 5004 | + $alreadyHtmlLawed = false; |
|
| 5005 | 5005 | // as Translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space |
| 5006 | - $newBody = str_replace("\n"," ",$newBody); |
|
| 5006 | + $newBody = str_replace("\n", " ", $newBody); |
|
| 5007 | 5007 | // convert HTML to text, as we dont want HTML in infologs |
| 5008 | 5008 | if ($useTidy && extension_loaded('tidy')) |
| 5009 | 5009 | { |
| 5010 | 5010 | $tidy = new tidy(); |
| 5011 | - $cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8'); |
|
| 5011 | + $cleaned = $tidy->repairString($newBody, self::$tidy_config, 'utf8'); |
|
| 5012 | 5012 | // Found errors. Strip it all so there's some output |
| 5013 | - if($tidy->getStatus() == 2) |
|
| 5013 | + if ($tidy->getStatus() == 2) |
|
| 5014 | 5014 | { |
| 5015 | 5015 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 5016 | 5016 | } |
@@ -5021,7 +5021,7 @@ discard block |
||
| 5021 | 5021 | if (!$preserveHTML) |
| 5022 | 5022 | { |
| 5023 | 5023 | // filter only the 'body', as we only want that part, if we throw away the html |
| 5024 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 5024 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 5025 | 5025 | if ($matches[2]) |
| 5026 | 5026 | { |
| 5027 | 5027 | $hasOther = true; |
@@ -5032,7 +5032,7 @@ discard block |
||
| 5032 | 5032 | else |
| 5033 | 5033 | { |
| 5034 | 5034 | // htmLawed filter only the 'body' |
| 5035 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 5035 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 5036 | 5036 | if ($matches[2]) |
| 5037 | 5037 | { |
| 5038 | 5038 | $hasOther = true; |
@@ -5041,17 +5041,17 @@ discard block |
||
| 5041 | 5041 | $htmLawed = new Html\HtmLawed(); |
| 5042 | 5042 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 5043 | 5043 | // as we switched off HTMLaweds tidy functionality |
| 5044 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 5045 | - $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
|
| 5046 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5047 | - $alreadyHtmlLawed=true; |
|
| 5044 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 5045 | + $newBody = $htmLawed->run($newBody, self::$htmLawed_config); |
|
| 5046 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 5047 | + $alreadyHtmlLawed = true; |
|
| 5048 | 5048 | } |
| 5049 | 5049 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 5050 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5050 | + if ($preserveHTML == false) $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, true, true); |
|
| 5051 | 5051 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 5052 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5052 | + if ($preserveHTML == false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5053 | 5053 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 5054 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5054 | + if ($preserveHTML == false) $newBody = str_replace("<br />", "\r\n", $newBody); |
|
| 5055 | 5055 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 5056 | 5056 | } |
| 5057 | 5057 | $message .= $newBody; |
@@ -5060,9 +5060,9 @@ discard block |
||
| 5060 | 5060 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after specialchars):'.$newBody); |
| 5061 | 5061 | //use Mail\Html::convertHTMLToText instead of strip_tags, (even message is plain text) as strip_tags eats away too much |
| 5062 | 5062 | //$newBody = strip_tags($newBody); //we need to fix broken tags (or just stuff like "<800 USD/p" ) |
| 5063 | - $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,false,false); |
|
| 5063 | + $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, false, false); |
|
| 5064 | 5064 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after strip tags):'.$newBody); |
| 5065 | - $newBody = htmlspecialchars_decode($newBody,ENT_QUOTES); |
|
| 5065 | + $newBody = htmlspecialchars_decode($newBody, ENT_QUOTES); |
|
| 5066 | 5066 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body (after hmlspc_decode):'.$newBody); |
| 5067 | 5067 | $message .= $newBody; |
| 5068 | 5068 | //continue; |
@@ -5070,27 +5070,27 @@ discard block |
||
| 5070 | 5070 | return $message; |
| 5071 | 5071 | } |
| 5072 | 5072 | |
| 5073 | - static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false) |
|
| 5073 | + static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith = false) |
|
| 5074 | 5074 | { |
| 5075 | 5075 | $lines = explode("\n", $str); |
| 5076 | 5076 | $newStr = ''; |
| 5077 | - foreach($lines as $line) |
|
| 5077 | + foreach ($lines as $line) |
|
| 5078 | 5078 | { |
| 5079 | 5079 | // replace tabs by 8 space chars, or any tab only counts one char |
| 5080 | 5080 | //$line = str_replace("\t"," ",$line); |
| 5081 | 5081 | //$newStr .= wordwrap($line, $cols, $cut); |
| 5082 | - $allowedLength = $cols-strlen($cut); |
|
| 5082 | + $allowedLength = $cols - strlen($cut); |
|
| 5083 | 5083 | //dont try to break lines with links, chance is we mess up the text is way too big |
| 5084 | - if (strlen($line) > $allowedLength && stripos($line,'href=')===false && |
|
| 5085 | - ($dontbreaklinesstartingwith==false || |
|
| 5084 | + if (strlen($line) > $allowedLength && stripos($line, 'href=') === false && |
|
| 5085 | + ($dontbreaklinesstartingwith == false || |
|
| 5086 | 5086 | ($dontbreaklinesstartingwith && |
| 5087 | - strlen($dontbreaklinesstartingwith)>=1 && |
|
| 5088 | - substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 5087 | + strlen($dontbreaklinesstartingwith) >= 1 && |
|
| 5088 | + substr($line, 0, strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 5089 | 5089 | ) |
| 5090 | 5090 | ) |
| 5091 | 5091 | ) |
| 5092 | 5092 | { |
| 5093 | - $s=explode(" ", $line); |
|
| 5093 | + $s = explode(" ", $line); |
|
| 5094 | 5094 | $line = ""; |
| 5095 | 5095 | $linecnt = 0; |
| 5096 | 5096 | foreach ($s as &$v) { |
@@ -5098,22 +5098,22 @@ discard block |
||
| 5098 | 5098 | // only break long words within the wordboundaries, |
| 5099 | 5099 | // but it may destroy links, so we check for href and dont do it if we find one |
| 5100 | 5100 | // we check for any html within the word, because we do not want to break html by accident |
| 5101 | - if($cnt > $allowedLength && stripos($v,'href=')===false && stripos($v,'onclick=')===false && $cnt == strlen(html_entity_decode($v))) |
|
| 5101 | + if ($cnt > $allowedLength && stripos($v, 'href=') === false && stripos($v, 'onclick=') === false && $cnt == strlen(html_entity_decode($v))) |
|
| 5102 | 5102 | { |
| 5103 | - $v=wordwrap($v, $allowedLength, $cut, true); |
|
| 5103 | + $v = wordwrap($v, $allowedLength, $cut, true); |
|
| 5104 | 5104 | } |
| 5105 | 5105 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5106 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5107 | - $v=$cut.$v; |
|
| 5106 | + if ($linecnt + $cnt > $allowedLength) { |
|
| 5107 | + $v = $cut.$v; |
|
| 5108 | 5108 | #$linecnt = 0; |
| 5109 | - $linecnt =strlen($v)-strlen($cut); |
|
| 5109 | + $linecnt = strlen($v) - strlen($cut); |
|
| 5110 | 5110 | } else { |
| 5111 | 5111 | $linecnt += $cnt; |
| 5112 | 5112 | } |
| 5113 | 5113 | if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
| 5114 | 5114 | } |
| 5115 | 5115 | } |
| 5116 | - $newStr .= $line . "\n"; |
|
| 5116 | + $newStr .= $line."\n"; |
|
| 5117 | 5117 | } |
| 5118 | 5118 | return $newStr; |
| 5119 | 5119 | } |
@@ -5128,12 +5128,12 @@ discard block |
||
| 5128 | 5128 | * @param boolean $_useHeaderInsteadOfEnvelope - force getMessageHeader method to be used for fetching Envelope Information |
| 5129 | 5129 | * @return array the message header |
| 5130 | 5130 | */ |
| 5131 | - function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
|
| 5131 | + function getMessageEnvelope($_uid, $_partID = '', $decode = false, $_folder = '', $_useHeaderInsteadOfEnvelope = false) |
|
| 5132 | 5132 | { |
| 5133 | 5133 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5134 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5134 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5135 | 5135 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5136 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 5136 | + if ((empty($_partID) || $_partID == 'null') && $_useHeaderInsteadOfEnvelope === false) { |
|
| 5137 | 5137 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5138 | 5138 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5139 | 5139 | $uidsToFetch->add($_uid); |
@@ -5146,7 +5146,7 @@ discard block |
||
| 5146 | 5146 | 'ids' => $uidsToFetch, |
| 5147 | 5147 | )); |
| 5148 | 5148 | if (is_object($headersNew)) { |
| 5149 | - foreach($headersNew as &$_headerObject) { |
|
| 5149 | + foreach ($headersNew as &$_headerObject) { |
|
| 5150 | 5150 | $env = $_headerObject->getEnvelope(); |
| 5151 | 5151 | //_debug_array($envFields->singleFields()); |
| 5152 | 5152 | $singleFields = $envFields->singleFields(); |
@@ -5161,34 +5161,34 @@ discard block |
||
| 5161 | 5161 | case 'bcc': |
| 5162 | 5162 | case 'sender': |
| 5163 | 5163 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5164 | - $envelope[$v]=$env->$v->addresses; |
|
| 5164 | + $envelope[$v] = $env->$v->addresses; |
|
| 5165 | 5165 | $address = array(); |
| 5166 | 5166 | if (!is_array($envelope[$v])) break; |
| 5167 | 5167 | foreach ($envelope[$v] as $k => $ad) |
| 5168 | 5168 | { |
| 5169 | - if (stripos($ad,'@')===false) |
|
| 5169 | + if (stripos($ad, '@') === false) |
|
| 5170 | 5170 | { |
| 5171 | - $remember=$k; |
|
| 5171 | + $remember = $k; |
|
| 5172 | 5172 | } |
| 5173 | 5173 | else |
| 5174 | 5174 | { |
| 5175 | - $address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad; |
|
| 5176 | - $remember=null; |
|
| 5175 | + $address[] = (!is_null($remember) ? $envelope[$v][$remember].' ' : '').$ad; |
|
| 5176 | + $remember = null; |
|
| 5177 | 5177 | } |
| 5178 | 5178 | } |
| 5179 | 5179 | $envelope[$v] = $address; |
| 5180 | 5180 | break; |
| 5181 | 5181 | case 'date': |
| 5182 | - $envelope[$v]=DateTime::to($env->$v); |
|
| 5182 | + $envelope[$v] = DateTime::to($env->$v); |
|
| 5183 | 5183 | break; |
| 5184 | 5184 | default: |
| 5185 | - $envelope[$v]=$env->$v; |
|
| 5185 | + $envelope[$v] = $env->$v; |
|
| 5186 | 5186 | } |
| 5187 | 5187 | } |
| 5188 | - $envelope['size']=$_headerObject->getSize(); |
|
| 5188 | + $envelope['size'] = $_headerObject->getSize(); |
|
| 5189 | 5189 | } |
| 5190 | 5190 | } |
| 5191 | - $envelope = array_change_key_case($envelope,CASE_UPPER); |
|
| 5191 | + $envelope = array_change_key_case($envelope, CASE_UPPER); |
|
| 5192 | 5192 | //if ($decode) _debug_array($envelope); |
| 5193 | 5193 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($envelope)); |
| 5194 | 5194 | if ($decode) |
@@ -5196,19 +5196,19 @@ discard block |
||
| 5196 | 5196 | foreach ($envelope as $key => $rvV) |
| 5197 | 5197 | { |
| 5198 | 5198 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5199 | - $envelope[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5199 | + $envelope[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5200 | 5200 | } |
| 5201 | 5201 | } |
| 5202 | 5202 | return $envelope; |
| 5203 | 5203 | } else { |
| 5204 | 5204 | |
| 5205 | - $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
|
| 5205 | + $headers = $this->getMessageHeader($_uid, $_partID, true, true, $_folder); |
|
| 5206 | 5206 | |
| 5207 | 5207 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($headers)); |
| 5208 | 5208 | //_debug_array($headers); |
| 5209 | 5209 | $newData = array( |
| 5210 | 5210 | 'DATE' => $headers['DATE'], |
| 5211 | - 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
|
| 5211 | + 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']) : $headers['SUBJECT']), |
|
| 5212 | 5212 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5213 | 5213 | ); |
| 5214 | 5214 | if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
@@ -5219,11 +5219,11 @@ discard block |
||
| 5219 | 5219 | if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
| 5220 | 5220 | //_debug_array($newData); |
| 5221 | 5221 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5222 | - foreach($recepientList as $recepientType) { |
|
| 5223 | - if(isset($headers[$recepientType])) { |
|
| 5224 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 5222 | + foreach ($recepientList as $recepientType) { |
|
| 5223 | + if (isset($headers[$recepientType])) { |
|
| 5224 | + if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType], true); |
|
| 5225 | 5225 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5226 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5226 | + foreach (self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5227 | 5227 | $addressData = array( |
| 5228 | 5228 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5229 | 5229 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5231,15 +5231,15 @@ discard block |
||
| 5231 | 5231 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5232 | 5232 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5233 | 5233 | ); |
| 5234 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5234 | + if ($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5235 | 5235 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5236 | 5236 | } else { |
| 5237 | 5237 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5238 | 5238 | } |
| 5239 | - $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
|
| 5239 | + $newData[$recepientType][] = ($addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']); //$addressData; |
|
| 5240 | 5240 | } |
| 5241 | 5241 | } else { |
| 5242 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5242 | + if ($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5243 | 5243 | $newData[$recepientType] = $newData['FROM']; |
| 5244 | 5244 | } else { |
| 5245 | 5245 | $newData[$recepientType] = array(); |
@@ -5261,10 +5261,10 @@ discard block |
||
| 5261 | 5261 | * @param string $_folder folder to work on |
| 5262 | 5262 | * @return array|Horde_Mime_Headers message header as array or object |
| 5263 | 5263 | */ |
| 5264 | - function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
|
| 5264 | + function getMessageHeader($_uid, $_partID = '', $decode = false, $preserveUnSeen = false, $_folder = '') |
|
| 5265 | 5265 | { |
| 5266 | 5266 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5267 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5267 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5268 | 5268 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5269 | 5269 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5270 | 5270 | $uidsToFetch->add($_uid); |
@@ -5272,7 +5272,7 @@ discard block |
||
| 5272 | 5272 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5273 | 5273 | if ($_partID != '') |
| 5274 | 5274 | { |
| 5275 | - $fquery->headerText(array('id'=>$_partID,'peek'=>$preserveUnSeen)); |
|
| 5275 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>$preserveUnSeen)); |
|
| 5276 | 5276 | $fquery->structure(); |
| 5277 | 5277 | } |
| 5278 | 5278 | else |
@@ -5285,18 +5285,18 @@ discard block |
||
| 5285 | 5285 | 'ids' => $uidsToFetch, |
| 5286 | 5286 | )); |
| 5287 | 5287 | if (is_object($headersNew)) { |
| 5288 | - foreach($headersNew as $_fetchObject) |
|
| 5288 | + foreach ($headersNew as $_fetchObject) |
|
| 5289 | 5289 | { |
| 5290 | - $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5290 | + $headers = $_fetchObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5291 | 5291 | if ($_partID != '') |
| 5292 | 5292 | { |
| 5293 | 5293 | $mailStructureObject = $_fetchObject->getStructure(); |
| 5294 | 5294 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5295 | 5295 | { |
| 5296 | - if ($mime_id==$_partID) |
|
| 5296 | + if ($mime_id == $_partID) |
|
| 5297 | 5297 | { |
| 5298 | 5298 | //error_log(__METHOD__.' ('.__LINE__.') '."$mime_id == $_partID".array2string($_headerObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray())); |
| 5299 | - $headers = $_fetchObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5299 | + $headers = $_fetchObject->getHeaderText($mime_id, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5300 | 5300 | break; |
| 5301 | 5301 | } |
| 5302 | 5302 | } |
@@ -5309,15 +5309,15 @@ discard block |
||
| 5309 | 5309 | if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
| 5310 | 5310 | return $headers; |
| 5311 | 5311 | } |
| 5312 | - $retValue = is_object($headers) ? $headers->toArray():array(); |
|
| 5312 | + $retValue = is_object($headers) ? $headers->toArray() : array(); |
|
| 5313 | 5313 | if ($size) $retValue['size'] = $size; |
| 5314 | 5314 | } |
| 5315 | - $retValue = array_change_key_case($retValue,CASE_UPPER); |
|
| 5315 | + $retValue = array_change_key_case($retValue, CASE_UPPER); |
|
| 5316 | 5316 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
| 5317 | 5317 | // if SUBJECT is an array, use thelast one, as we assume something with the unfolding for the subject did not work |
| 5318 | 5318 | if (is_array($retValue['SUBJECT'])) |
| 5319 | 5319 | { |
| 5320 | - $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT'])-1]; |
|
| 5320 | + $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT']) - 1]; |
|
| 5321 | 5321 | } |
| 5322 | 5322 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($decode ? self::decode_header($retValue,true):$retValue)); |
| 5323 | 5323 | if ($decode) |
@@ -5325,7 +5325,7 @@ discard block |
||
| 5325 | 5325 | foreach ($retValue as $key => $rvV) |
| 5326 | 5326 | { |
| 5327 | 5327 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5328 | - $retValue[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5328 | + $retValue[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5329 | 5329 | } |
| 5330 | 5330 | } |
| 5331 | 5331 | return $retValue; |
@@ -5342,14 +5342,14 @@ discard block |
||
| 5342 | 5342 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5343 | 5343 | { |
| 5344 | 5344 | static $rawHeaders; |
| 5345 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5345 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5346 | 5346 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5347 | 5347 | |
| 5348 | - if (is_null($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 5349 | - if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5348 | + if (is_null($rawHeaders) || !is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 5349 | + if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5350 | 5350 | { |
| 5351 | 5351 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5352 | - return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5352 | + return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5353 | 5353 | } |
| 5354 | 5354 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5355 | 5355 | $uid = $_uid; |
@@ -5359,7 +5359,7 @@ discard block |
||
| 5359 | 5359 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5360 | 5360 | if ($_partID != '') |
| 5361 | 5361 | { |
| 5362 | - $fquery->headerText(array('id'=>$_partID,'peek'=>true)); |
|
| 5362 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>true)); |
|
| 5363 | 5363 | $fquery->structure(); |
| 5364 | 5364 | } |
| 5365 | 5365 | else |
@@ -5370,14 +5370,14 @@ discard block |
||
| 5370 | 5370 | 'ids' => $uidsToFetch, |
| 5371 | 5371 | )); |
| 5372 | 5372 | if (is_object($headersNew)) { |
| 5373 | - foreach($headersNew as &$_headerObject) { |
|
| 5373 | + foreach ($headersNew as &$_headerObject) { |
|
| 5374 | 5374 | $retValue = $_headerObject->getHeaderText(); |
| 5375 | 5375 | if ($_partID != '') |
| 5376 | 5376 | { |
| 5377 | 5377 | $mailStructureObject = $_headerObject->getStructure(); |
| 5378 | 5378 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5379 | 5379 | { |
| 5380 | - if ($mime_id==$_partID) |
|
| 5380 | + if ($mime_id == $_partID) |
|
| 5381 | 5381 | { |
| 5382 | 5382 | $retValue = $_headerObject->getHeaderText($mime_id); |
| 5383 | 5383 | } |
@@ -5385,8 +5385,8 @@ discard block |
||
| 5385 | 5385 | } |
| 5386 | 5386 | } |
| 5387 | 5387 | } |
| 5388 | - $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]=$retValue; |
|
| 5389 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeaders,60*60*1); |
|
| 5388 | + $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $retValue; |
|
| 5389 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), $rawHeaders, 60 * 60 * 1); |
|
| 5390 | 5390 | return $retValue; |
| 5391 | 5391 | } |
| 5392 | 5392 | |
@@ -5399,25 +5399,25 @@ discard block |
||
| 5399 | 5399 | { |
| 5400 | 5400 | $style = ''; |
| 5401 | 5401 | if (empty($_bodyParts)) return ""; |
| 5402 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5402 | + foreach ((array)$_bodyParts as $singleBodyPart) { |
|
| 5403 | 5403 | if (!isset($singleBodyPart['body'])) { |
| 5404 | 5404 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5405 | 5405 | $style .= $singleBodyPart['body']; |
| 5406 | 5406 | continue; |
| 5407 | 5407 | } |
| 5408 | 5408 | |
| 5409 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5409 | + if ($singleBodyPart['charSet'] === false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5410 | 5410 | $singleBodyPart['body'] = Translation::convert( |
| 5411 | 5411 | $singleBodyPart['body'], |
| 5412 | 5412 | strtolower($singleBodyPart['charSet']) |
| 5413 | 5413 | ); |
| 5414 | 5414 | $ct = 0; |
| 5415 | - $newStyle=array(); |
|
| 5416 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5417 | - if ($ct>0) |
|
| 5415 | + $newStyle = array(); |
|
| 5416 | + if (stripos($singleBodyPart['body'], '<style') !== false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5417 | + if ($ct > 0) |
|
| 5418 | 5418 | { |
| 5419 | 5419 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
| 5420 | - $style2buffer = implode('',$newStyle[0]); |
|
| 5420 | + $style2buffer = implode('', $newStyle[0]); |
|
| 5421 | 5421 | } |
| 5422 | 5422 | if ($style2buffer && strtoupper(self::$displayCharset) == 'UTF-8') |
| 5423 | 5423 | { |
@@ -5425,7 +5425,7 @@ discard block |
||
| 5425 | 5425 | $test = json_encode($style2buffer); |
| 5426 | 5426 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error()); |
| 5427 | 5427 | //if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0) |
| 5428 | - if ($test=="null" && strlen($style2buffer)>0) |
|
| 5428 | + if ($test == "null" && strlen($style2buffer) > 0) |
|
| 5429 | 5429 | { |
| 5430 | 5430 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 5431 | 5431 | error_log(__METHOD__.' ('.__LINE__.') '.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Charset Reported:'.$singleBodyPart['charSet'].' Carset Detected:'.Translation::detect_encoding($style2buffer)); |
@@ -5436,19 +5436,19 @@ discard block |
||
| 5436 | 5436 | } |
| 5437 | 5437 | // clean out comments and stuff |
| 5438 | 5438 | $search = array( |
| 5439 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5439 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5440 | 5440 | // '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
| 5441 | 5441 | // '@<!--[\s\S]*?[ \t\n\r]*--@', // Strip broken multi-line comments including CDATA |
| 5442 | 5442 | ); |
| 5443 | - $style = preg_replace($search,"",$style); |
|
| 5443 | + $style = preg_replace($search, "", $style); |
|
| 5444 | 5444 | |
| 5445 | 5445 | // CSS Security |
| 5446 | 5446 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5447 | - $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
|
| 5448 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 5447 | + $css = preg_replace('/(javascript|expression|-moz-binding)/i', '', $style); |
|
| 5448 | + if (stripos($css, 'script') !== false) Mail\Html::replaceTagsCompletley($css, 'script'); // Strip out script that may be included |
|
| 5449 | 5449 | // we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace |
| 5450 | 5450 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5451 | - $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
|
| 5451 | + $css = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css); |
|
| 5452 | 5452 | //error_log(__METHOD__.' ('.__LINE__.') '.$css); |
| 5453 | 5453 | // TODO: we may have to strip urls and maybe comments and ifs |
| 5454 | 5454 | return $css; |
@@ -5463,16 +5463,16 @@ discard block |
||
| 5463 | 5463 | * @param boolean $_stream =false true: return a stream, false: return string, stream suppresses any caching |
| 5464 | 5464 | * @return string the message body |
| 5465 | 5465 | */ |
| 5466 | - function getMessageRawBody($_uid, $_partID = '', $_folder='', $_stream=false) |
|
| 5466 | + function getMessageRawBody($_uid, $_partID = '', $_folder = '', $_stream = false) |
|
| 5467 | 5467 | { |
| 5468 | 5468 | //TODO: caching einbauen static! |
| 5469 | 5469 | static $rawBody; |
| 5470 | 5470 | if (is_null($rawBody)) $rawBody = array(); |
| 5471 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5472 | - if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5471 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5472 | + if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5473 | 5473 | { |
| 5474 | 5474 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
| 5475 | - return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5475 | + return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5476 | 5476 | } |
| 5477 | 5477 | |
| 5478 | 5478 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -5485,13 +5485,13 @@ discard block |
||
| 5485 | 5485 | if ($_partID != '') |
| 5486 | 5486 | { |
| 5487 | 5487 | $fquery->structure(); |
| 5488 | - $fquery->bodyPart($_partID,array('peek'=>true)); |
|
| 5488 | + $fquery->bodyPart($_partID, array('peek'=>true)); |
|
| 5489 | 5489 | } |
| 5490 | 5490 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5491 | 5491 | 'ids' => $uidsToFetch, |
| 5492 | 5492 | )); |
| 5493 | 5493 | if (is_object($headersNew)) { |
| 5494 | - foreach($headersNew as &$_headerObject) { |
|
| 5494 | + foreach ($headersNew as &$_headerObject) { |
|
| 5495 | 5495 | $body = $_headerObject->getFullMsg($_stream); |
| 5496 | 5496 | if ($_partID != '') |
| 5497 | 5497 | { |
@@ -5499,7 +5499,7 @@ discard block |
||
| 5499 | 5499 | //_debug_array($mailStructureObject->contentTypeMap()); |
| 5500 | 5500 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5501 | 5501 | { |
| 5502 | - if ($mime_id==$_partID) |
|
| 5502 | + if ($mime_id == $_partID) |
|
| 5503 | 5503 | { |
| 5504 | 5504 | $body = $_headerObject->getBodyPart($mime_id, $_stream); |
| 5505 | 5505 | } |
@@ -5510,7 +5510,7 @@ discard block |
||
| 5510 | 5510 | //error_log(__METHOD__.' ('.__LINE__.') '."[$this->icServer->ImapServerId][$_folder][$_uid][".(empty($_partID)?'NIL':$_partID)."]"); |
| 5511 | 5511 | if (!$_stream) |
| 5512 | 5512 | { |
| 5513 | - $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)] = $body; |
|
| 5513 | + $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $body; |
|
| 5514 | 5514 | } |
| 5515 | 5515 | return $body; |
| 5516 | 5516 | } |
@@ -5525,13 +5525,13 @@ discard block |
||
| 5525 | 5525 | * @param Horde_Imap_Client_Fetch_Query $fquery=null default query just structure |
| 5526 | 5526 | * @return Horde_Mime_Part |
| 5527 | 5527 | */ |
| 5528 | - function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
|
| 5528 | + function getStructure($_uid, $_partID = null, $_folder = null, $_preserveSeen = false) |
|
| 5529 | 5529 | { |
| 5530 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5530 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5531 | 5531 | |
| 5532 | 5532 | if (empty($_folder)) |
| 5533 | 5533 | { |
| 5534 | - $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5534 | + $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5535 | 5535 | } |
| 5536 | 5536 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5537 | 5537 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5549,7 +5549,7 @@ discard block |
||
| 5549 | 5549 | 'ids' => $uidsToFetch, |
| 5550 | 5550 | ))->first(); |
| 5551 | 5551 | |
| 5552 | - return is_object($mail)?$mail->getStructure():null; |
|
| 5552 | + return is_object($mail) ? $mail->getStructure() : null; |
|
| 5553 | 5553 | } |
| 5554 | 5554 | catch (\Exception $e) |
| 5555 | 5555 | { |
@@ -5572,14 +5572,14 @@ discard block |
||
| 5572 | 5572 | * @param string $_folder folder to work on |
| 5573 | 5573 | * @return array an array of information about the attachment: array of array(name, size, mimeType, partID, encoding) |
| 5574 | 5574 | */ |
| 5575 | - function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
|
| 5575 | + function getMessageAttachments($_uid, $_partID = null, Horde_Mime_Part $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = false, $resolveTNEF = true, $_folder = '') |
|
| 5576 | 5576 | { |
| 5577 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5578 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5577 | + if (self::$debug) error_log(__METHOD__.":$_uid, $_partID"); |
|
| 5578 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5579 | 5579 | $attachments = array(); |
| 5580 | 5580 | if (!isset($_structure)) |
| 5581 | 5581 | { |
| 5582 | - $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
|
| 5582 | + $_structure = $this->getStructure($_uid, $_partID, $_folder, true); |
|
| 5583 | 5583 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5584 | 5584 | } |
| 5585 | 5585 | if (!$_structure || !$_structure->contentTypeMap()) return array(); |
@@ -5587,7 +5587,7 @@ discard block |
||
| 5587 | 5587 | $skipParts = array(); |
| 5588 | 5588 | $tnefParts = array(); |
| 5589 | 5589 | $skip = 0; |
| 5590 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5590 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5591 | 5591 | { |
| 5592 | 5592 | // skip multipart/encrypted incl. its two sub-parts, as we show 2. sub-part as body to be decrypted client-side |
| 5593 | 5593 | if ($mime_type == 'multipart/encrypted') |
@@ -5595,7 +5595,7 @@ discard block |
||
| 5595 | 5595 | $skip = 2; |
| 5596 | 5596 | continue; |
| 5597 | 5597 | } |
| 5598 | - elseif($skip) |
|
| 5598 | + elseif ($skip) |
|
| 5599 | 5599 | { |
| 5600 | 5600 | $skip--; |
| 5601 | 5601 | continue; |
@@ -5609,10 +5609,10 @@ discard block |
||
| 5609 | 5609 | $partPrimaryType = $part->getPrimaryType(); |
| 5610 | 5610 | // we only want to retrieve the attachments of the current mail, not those of possible |
| 5611 | 5611 | // attached mails |
| 5612 | - if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
|
| 5612 | + if ($mime_type == 'message/rfc822' && $_partID != $mime_id) |
|
| 5613 | 5613 | { |
| 5614 | 5614 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5615 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 5615 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 5616 | 5616 | } |
| 5617 | 5617 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5618 | 5618 | { |
@@ -5620,27 +5620,27 @@ discard block |
||
| 5620 | 5620 | // attachment with no link to show the attachment inline. |
| 5621 | 5621 | // Considering this: we "list" everything that matches the above criteria |
| 5622 | 5622 | // as attachment in order to not loose/miss information on our data |
| 5623 | - $partDisposition='attachment'; |
|
| 5623 | + $partDisposition = 'attachment'; |
|
| 5624 | 5624 | } |
| 5625 | 5625 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5626 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 5626 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 5627 | 5627 | |
| 5628 | 5628 | if ($partDisposition == 'attachment' || |
| 5629 | - (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
|
| 5629 | + (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId() == '') || |
|
| 5630 | 5630 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType != 'image' && $partPrimaryType != 'text' && $partPrimaryType != 'multipart') || |
| 5631 | - ($mime_type=='image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5631 | + ($mime_type == 'image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5632 | 5632 | ($fetchEmbeddedImages && ($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image') || |
| 5633 | 5633 | ($fetchTextCalendar && $partPrimaryType == 'text' && $part->getSubType() == 'calendar')) |
| 5634 | 5634 | { |
| 5635 | 5635 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5636 | 5636 | // we attempt to fetch "ourselves" |
| 5637 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 5637 | + if ($_partID == $part->getMimeId() && $part->getPrimaryType() == 'message') continue; |
|
| 5638 | 5638 | $attachment = $part->getAllDispositionParameters(); |
| 5639 | 5639 | $attachment['disposition'] = $part->getDisposition(); |
| 5640 | 5640 | $attachment['mimeType'] = $mime_type; |
| 5641 | 5641 | $attachment['uid'] = $_uid; |
| 5642 | 5642 | $attachment['partID'] = $mime_id; |
| 5643 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5643 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5644 | 5644 | if ($fetchTextCalendar) |
| 5645 | 5645 | { |
| 5646 | 5646 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
@@ -5650,11 +5650,11 @@ discard block |
||
| 5650 | 5650 | } |
| 5651 | 5651 | $attachment['size'] = $part->getBytes(); |
| 5652 | 5652 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5653 | - if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 5653 | + if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 5654 | 5654 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5655 | 5655 | //typical winmail.dat attachment is |
| 5656 | 5656 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
| 5657 | - if ($resolveTNEF && ($attachment['mimeType']=='application/ms-tnef' || !strcasecmp($attachment['name'],'winmail.dat'))) |
|
| 5657 | + if ($resolveTNEF && ($attachment['mimeType'] == 'application/ms-tnef' || !strcasecmp($attachment['name'], 'winmail.dat'))) |
|
| 5658 | 5658 | { |
| 5659 | 5659 | $tnefParts[] = $attachment; |
| 5660 | 5660 | } |
@@ -5669,31 +5669,31 @@ discard block |
||
| 5669 | 5669 | //error_log(__METHOD__.__LINE__.array2string($tnefParts)); |
| 5670 | 5670 | foreach ($tnefParts as $k => $tnp) |
| 5671 | 5671 | { |
| 5672 | - $tnefResolved=false; |
|
| 5673 | - $tnef_data = $this->getAttachment($tnp['uid'],$tnp['partID'],$k,false); |
|
| 5672 | + $tnefResolved = false; |
|
| 5673 | + $tnef_data = $this->getAttachment($tnp['uid'], $tnp['partID'], $k, false); |
|
| 5674 | 5674 | $myTnef = $this->tnef_decoder($tnef_data['attachment']); |
| 5675 | 5675 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5676 | 5676 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5677 | 5677 | // we need to build Something that meets the needs |
| 5678 | 5678 | if ($myTnef) |
| 5679 | 5679 | { |
| 5680 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5680 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5681 | 5681 | { |
| 5682 | - $tnefResolved=true; |
|
| 5682 | + $tnefResolved = true; |
|
| 5683 | 5683 | $attachment = $part->getAllDispositionParameters(); |
| 5684 | 5684 | $attachment['disposition'] = $part->getDisposition(); |
| 5685 | 5685 | $attachment['mimeType'] = $part->getType(); |
| 5686 | 5686 | $attachment['uid'] = $tnp['uid']; |
| 5687 | 5687 | $attachment['partID'] = $tnp['partID']; |
| 5688 | 5688 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5689 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5689 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5690 | 5690 | $attachment['size'] = $part->getBytes(); |
| 5691 | 5691 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5692 | - if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5692 | + if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5693 | 5693 | $attachments[] = $attachment; |
| 5694 | 5694 | } |
| 5695 | 5695 | } |
| 5696 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 5696 | + if ($tnefResolved === false) $attachments[] = $tnp; |
|
| 5697 | 5697 | } |
| 5698 | 5698 | } |
| 5699 | 5699 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5708,9 +5708,9 @@ discard block |
||
| 5708 | 5708 | * @return boolean|Horde_Mime_part Multipart/Mixed part decoded attachments | |
| 5709 | 5709 | * return false if there's no attachments or failure |
| 5710 | 5710 | */ |
| 5711 | - public function tnef_decoder( $data ) |
|
| 5711 | + public function tnef_decoder($data) |
|
| 5712 | 5712 | { |
| 5713 | - foreach(array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5713 | + foreach (array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5714 | 5714 | { |
| 5715 | 5715 | if (!class_exists($class)) |
| 5716 | 5716 | { |
@@ -5742,7 +5742,7 @@ discard block |
||
| 5742 | 5742 | $tmp_part->setContents($data['stream']); |
| 5743 | 5743 | $tmp_part->setDescription($data['name']); |
| 5744 | 5744 | |
| 5745 | - $type = $data['type'] . '/' . $data['subtype']; |
|
| 5745 | + $type = $data['type'].'/'.$data['subtype']; |
|
| 5746 | 5746 | if (in_array($type, array('application/octet-stream', 'application/base64'))) |
| 5747 | 5747 | { |
| 5748 | 5748 | $type = Horde_Mime_Magic::filenameToMIME($data['name']); |
@@ -5785,24 +5785,24 @@ discard block |
||
| 5785 | 5785 | * |
| 5786 | 5786 | * @return array returns an array of all resolved embeded attachments from winmail.dat |
| 5787 | 5787 | */ |
| 5788 | - function getTnefAttachments ($_uid, $_partID, $_stream=false) |
|
| 5788 | + function getTnefAttachments($_uid, $_partID, $_stream = false) |
|
| 5789 | 5789 | { |
| 5790 | - $tnef_data = $this->getAttachment($_uid, $_partID,0,false); |
|
| 5790 | + $tnef_data = $this->getAttachment($_uid, $_partID, 0, false); |
|
| 5791 | 5791 | $tnef_parts = $this->tnef_decoder($tnef_data['attachment']); |
| 5792 | 5792 | $attachments = array(); |
| 5793 | 5793 | if ($tnef_parts) |
| 5794 | 5794 | { |
| 5795 | - foreach($tnef_parts->getParts() as $mime_id => $part) |
|
| 5795 | + foreach ($tnef_parts->getParts() as $mime_id => $part) |
|
| 5796 | 5796 | { |
| 5797 | 5797 | |
| 5798 | 5798 | $attachment = $part->getAllDispositionParameters(); |
| 5799 | 5799 | $attachment['mimeType'] = $part->getType(); |
| 5800 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5800 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5801 | 5801 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5802 | 5802 | if (empty($attachment['filename'])) |
| 5803 | 5803 | { |
| 5804 | - $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
|
| 5805 | - $attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5804 | + $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? |
|
| 5805 | + $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5806 | 5806 | } |
| 5807 | 5807 | |
| 5808 | 5808 | $attachment['attachment'] = $part->getContents(array('stream'=>$_stream)); |
@@ -5826,10 +5826,10 @@ discard block |
||
| 5826 | 5826 | * |
| 5827 | 5827 | * @return array |
| 5828 | 5828 | */ |
| 5829 | - function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
|
| 5829 | + function getAttachment($_uid, $_partID, $_winmail_nr = 0, $_returnPart = true, $_stream = false, $_folder = null) |
|
| 5830 | 5830 | { |
| 5831 | 5831 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5832 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5832 | + if (!isset($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5833 | 5833 | |
| 5834 | 5834 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5835 | 5835 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5842,36 +5842,36 @@ discard block |
||
| 5842 | 5842 | 'ids' => $uidsToFetch, |
| 5843 | 5843 | )); |
| 5844 | 5844 | if (is_object($headersNew)) { |
| 5845 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 5845 | + foreach ($headersNew as $id=>$_headerObject) { |
|
| 5846 | 5846 | $body = $_headerObject->getFullMsg(); |
| 5847 | 5847 | if ($_partID != '') |
| 5848 | 5848 | { |
| 5849 | 5849 | $mailStructureObject = $_headerObject->getStructure(); |
| 5850 | 5850 | $mailStructureObject->contentTypeMap(); |
| 5851 | 5851 | $part = $mailStructureObject->getPart($_partID); |
| 5852 | - $partDisposition = ($part?$part->getDisposition():'failed'); |
|
| 5853 | - if ($partDisposition=='failed') |
|
| 5852 | + $partDisposition = ($part ? $part->getDisposition() : 'failed'); |
|
| 5853 | + if ($partDisposition == 'failed') |
|
| 5854 | 5854 | { |
| 5855 | 5855 | error_log(__METHOD__.'('.__LINE__.'):'.array2string($_uid).','.$_partID.' ID:'.$id.' HObject:'.array2string($_headerObject).' StructureObject:'.array2string($mailStructureObject->contentTypeMap()).'->'.function_backtrace()); |
| 5856 | 5856 | } |
| 5857 | 5857 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5858 | 5858 | // itself is only triggered to fetch attachments |
| 5859 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 5860 | - if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5859 | + if (empty($partDisposition)) $partDisposition = 'attachment'; |
|
| 5860 | + if ($part && ($partDisposition == 'attachment' || $partDisposition == 'inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5861 | 5861 | { |
| 5862 | 5862 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
| 5863 | 5863 | $structure_mime = $part->getType(); |
| 5864 | 5864 | $filename = $part->getName(); |
| 5865 | 5865 | $charset = $part->getContentTypeParameter('charset'); |
| 5866 | 5866 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5867 | - $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
|
| 5867 | + $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen = true, $structure_mime); |
|
| 5868 | 5868 | if ($_returnPart) return $part; |
| 5869 | 5869 | } |
| 5870 | 5870 | } |
| 5871 | 5871 | } |
| 5872 | 5872 | } |
| 5873 | 5873 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5874 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 5874 | + if ($ext && stripos($filename, '.') === false && stripos($filename, $ext) === false) $filename = trim($filename).'.'.$ext; |
|
| 5875 | 5875 | if (!$part) |
| 5876 | 5876 | { |
| 5877 | 5877 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5889,20 +5889,20 @@ discard block |
||
| 5889 | 5889 | // try guessing the mimetype, if we get the application/octet-stream |
| 5890 | 5890 | if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
| 5891 | 5891 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5892 | - if ( $filename == 'winmail.dat' && $_winmail_nr) |
|
| 5892 | + if ($filename == 'winmail.dat' && $_winmail_nr) |
|
| 5893 | 5893 | { |
| 5894 | 5894 | //by now _uid is of type array |
| 5895 | - $tnefResolved=false; |
|
| 5896 | - $wantedPart=$_uid[0].'@'.$_partID; |
|
| 5895 | + $tnefResolved = false; |
|
| 5896 | + $wantedPart = $_uid[0].'@'.$_partID; |
|
| 5897 | 5897 | $myTnef = $this->tnef_decoder($attachmentData['attachment']); |
| 5898 | 5898 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5899 | 5899 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5900 | 5900 | // we need to build Something that meets the needs |
| 5901 | 5901 | if ($myTnef) |
| 5902 | 5902 | { |
| 5903 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5903 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5904 | 5904 | { |
| 5905 | - $tnefResolved=true; |
|
| 5905 | + $tnefResolved = true; |
|
| 5906 | 5906 | $attachment = $part->getAllDispositionParameters(); |
| 5907 | 5907 | $attachment['mimeType'] = $part->getType(); |
| 5908 | 5908 | //error_log(__METHOD__.__LINE__.'#'.$mime_id.'#'.$filename.'#'.array2string($attachment)); |
@@ -5910,9 +5910,9 @@ discard block |
||
| 5910 | 5910 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5911 | 5911 | { |
| 5912 | 5912 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5913 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5913 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5914 | 5914 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5915 | - if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5915 | + if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5916 | 5916 | $wmattach = $attachment; |
| 5917 | 5917 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5918 | 5918 | |
@@ -5922,7 +5922,7 @@ discard block |
||
| 5922 | 5922 | if ($tnefResolved) |
| 5923 | 5923 | { |
| 5924 | 5924 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5925 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5925 | + if ($ext && stripos($wmattach['filename'], '.') === false && stripos($wmattach['filename'], $ext) === false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5926 | 5926 | $attachmentData = array( |
| 5927 | 5927 | 'type' => $wmattach['mimeType'], |
| 5928 | 5928 | 'filename' => $wmattach['filename'], |
@@ -5946,21 +5946,21 @@ discard block |
||
| 5946 | 5946 | * true: |
| 5947 | 5947 | * @return Horde_Mime_Part |
| 5948 | 5948 | */ |
| 5949 | - function getAttachmentByCID($_uid, $_cid, $_part, $_stream=null) |
|
| 5949 | + function getAttachmentByCID($_uid, $_cid, $_part, $_stream = null) |
|
| 5950 | 5950 | { |
| 5951 | 5951 | // some static variables to avoid fetching the same mail multiple times |
| 5952 | - static $uid=null, $part=null, $structure=null; |
|
| 5952 | + static $uid = null, $part = null, $structure = null; |
|
| 5953 | 5953 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5954 | 5954 | |
| 5955 | - if(empty($_cid)) return false; |
|
| 5955 | + if (empty($_cid)) return false; |
|
| 5956 | 5956 | |
| 5957 | 5957 | if ($_uid != $uid || $_part != $part) |
| 5958 | 5958 | { |
| 5959 | - $structure = $this->getStructure($uid=$_uid, $part=$_part); |
|
| 5959 | + $structure = $this->getStructure($uid = $_uid, $part = $_part); |
|
| 5960 | 5960 | } |
| 5961 | 5961 | /** @var Horde_Mime_Part */ |
| 5962 | 5962 | $attachment = null; |
| 5963 | - foreach($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5963 | + foreach ($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5964 | 5964 | { |
| 5965 | 5965 | $part = $structure->getPart($mime_id); |
| 5966 | 5966 | |
@@ -6012,16 +6012,16 @@ discard block |
||
| 6012 | 6012 | * @param string $_mimetype to decide wether to try to fetch part as binary or not |
| 6013 | 6013 | * @return Horde_Mime_Part |
| 6014 | 6014 | */ |
| 6015 | - public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
|
| 6015 | + public function fetchPartContents($_uid, Horde_Mime_Part $part = null, $_stream = false, $_preserveSeen = false, $_mimetype = null) |
|
| 6016 | 6016 | { |
| 6017 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 6017 | + if (is_null($part)) return null; //new Horde_Mime_Part; |
|
| 6018 | 6018 | $encoding = null; |
| 6019 | 6019 | $fetchAsBinary = true; |
| 6020 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 6020 | + if ($_mimetype && strtolower($_mimetype) == 'message/rfc822') $fetchAsBinary = false; |
|
| 6021 | 6021 | // we need to set content on structure to decode transfer encoding |
| 6022 | 6022 | $part->setContents( |
| 6023 | 6023 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
| 6024 | - array('encoding' => (!$fetchAsBinary&&!$encoding?'8bit':$encoding))); |
|
| 6024 | + array('encoding' => (!$fetchAsBinary && !$encoding ? '8bit' : $encoding))); |
|
| 6025 | 6025 | |
| 6026 | 6026 | return $part; |
| 6027 | 6027 | } |
@@ -6039,17 +6039,17 @@ discard block |
||
| 6039 | 6039 | * @return the id of the message appended or exception |
| 6040 | 6040 | * @throws Exception\WrongUserinput |
| 6041 | 6041 | */ |
| 6042 | - function appendMessage($_folderName, $_header, $_body, $_flags='\\Recent') |
|
| 6042 | + function appendMessage($_folderName, $_header, $_body, $_flags = '\\Recent') |
|
| 6043 | 6043 | { |
| 6044 | 6044 | if (!is_resource($_header)) |
| 6045 | 6045 | { |
| 6046 | - if (stripos($_header,'message-id:')===false) |
|
| 6046 | + if (stripos($_header, 'message-id:') === false) |
|
| 6047 | 6047 | { |
| 6048 | 6048 | $_header = 'Message-ID: <'.self::getRandomString().'@localhost>'."\n".$_header; |
| 6049 | 6049 | } |
| 6050 | 6050 | //error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_header, $_body, $_flags"); |
| 6051 | - $_header = ltrim(str_replace("\n","\r\n",$_header)); |
|
| 6052 | - $_header .= str_replace("\n","\r\n",$_body); |
|
| 6051 | + $_header = ltrim(str_replace("\n", "\r\n", $_header)); |
|
| 6052 | + $_header .= str_replace("\n", "\r\n", $_body); |
|
| 6053 | 6053 | } |
| 6054 | 6054 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 6055 | 6055 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
@@ -6067,7 +6067,7 @@ discard block |
||
| 6067 | 6067 | // searched for the message-id then returning the uid found |
| 6068 | 6068 | //$dataNflags[] = array('data'=>array(array('t'=>'text','v'=>"$header"."$body")), 'flags'=>array($_flags)); |
| 6069 | 6069 | $dataNflags[] = array('data' => $_header, 'flags'=>array($_flags)); |
| 6070 | - $messageid = $this->icServer->append($_folderName,$dataNflags); |
|
| 6070 | + $messageid = $this->icServer->append($_folderName, $dataNflags); |
|
| 6071 | 6071 | } |
| 6072 | 6072 | catch (\Exception $e) |
| 6073 | 6073 | { |
@@ -6079,7 +6079,7 @@ discard block |
||
| 6079 | 6079 | //$messageid = true; // for debug reasons only |
| 6080 | 6080 | if ($messageid === true || empty($messageid)) // try to figure out the message uid |
| 6081 | 6081 | { |
| 6082 | - $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
|
| 6082 | + $list = $this->getHeaders($_folderName, $_startMessage = 1, 1, 'INTERNALDATE', true, array(), null, false); |
|
| 6083 | 6083 | if ($list) |
| 6084 | 6084 | { |
| 6085 | 6085 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
@@ -6119,27 +6119,27 @@ discard block |
||
| 6119 | 6119 | * 'attachments'=>$attachments, |
| 6120 | 6120 | * 'headers'=>$headers,; boolean false on failure |
| 6121 | 6121 | */ |
| 6122 | - static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true) |
|
| 6122 | + static function get_mailcontent(&$mailClass, $uid, $partid = '', $mailbox = '', $preserveHTML = false, $addHeaderSection = true, $includeAttachments = true) |
|
| 6123 | 6123 | { |
| 6124 | 6124 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6125 | - $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
|
| 6125 | + $headers = $mailClass->getMessageHeader($uid, $partid, true, false, $mailbox); |
|
| 6126 | 6126 | if (empty($headers)) return false; |
| 6127 | 6127 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6128 | - $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
|
| 6128 | + $bodyParts = $mailClass->getMessageBody($uid, ($preserveHTML ? 'always_display' : 'only_if_no_text'), $partid, null, false, $mailbox); |
|
| 6129 | 6129 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
| 6130 | - if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html') |
|
| 6130 | + if (!$preserveHTML && $bodyParts[0]['mimeType'] == 'text/html') |
|
| 6131 | 6131 | { |
| 6132 | - foreach($bodyParts as $i => $part) |
|
| 6132 | + foreach ($bodyParts as $i => $part) |
|
| 6133 | 6133 | { |
| 6134 | - if ($bodyParts[$i]['mimeType']=='text/html') |
|
| 6134 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 6135 | 6135 | { |
| 6136 | - $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'],$bodyParts[$i]['charSet'],true,$stripalltags=true); |
|
| 6137 | - $bodyParts[$i]['mimeType']='text/plain'; |
|
| 6136 | + $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'], $bodyParts[$i]['charSet'], true, $stripalltags = true); |
|
| 6137 | + $bodyParts[$i]['mimeType'] = 'text/plain'; |
|
| 6138 | 6138 | } |
| 6139 | 6139 | } |
| 6140 | 6140 | } |
| 6141 | 6141 | //error_log(array2string($bodyParts)); |
| 6142 | - $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
|
| 6142 | + $attachments = $includeAttachments ? $mailClass->getMessageAttachments($uid, $partid, null, true, false, true, $mailbox) : array(); |
|
| 6143 | 6143 | |
| 6144 | 6144 | if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
| 6145 | 6145 | elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
@@ -6150,7 +6150,7 @@ discard block |
||
| 6150 | 6150 | |
| 6151 | 6151 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6152 | 6152 | if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
| 6153 | - $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
|
| 6153 | + $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '', $preserveHTML) : ''); |
|
| 6154 | 6154 | $message = $headdata.$message; |
| 6155 | 6155 | //echo __METHOD__.'<br>'; |
| 6156 | 6156 | //_debug_array($attachments); |
@@ -6166,25 +6166,25 @@ discard block |
||
| 6166 | 6166 | //_debug_array($mailClass->getMessageHeader($uid, $attachment['partID'])); |
| 6167 | 6167 | //_debug_array($mailClass->getMessageBody($uid,'', $attachment['partID'])); |
| 6168 | 6168 | //_debug_array($mailClass->getMessageAttachments($uid, $attachment['partID'])); |
| 6169 | - $mailcontent = self::get_mailcontent($mailClass,$uid,$attachment['partID'],$mailbox); |
|
| 6170 | - $headdata =''; |
|
| 6169 | + $mailcontent = self::get_mailcontent($mailClass, $uid, $attachment['partID'], $mailbox); |
|
| 6170 | + $headdata = ''; |
|
| 6171 | 6171 | if ($mailcontent['headers']) |
| 6172 | 6172 | { |
| 6173 | - $headdata = self::createHeaderInfoSection($mailcontent['headers'],'',$preserveHTML); |
|
| 6173 | + $headdata = self::createHeaderInfoSection($mailcontent['headers'], '', $preserveHTML); |
|
| 6174 | 6174 | } |
| 6175 | 6175 | if ($mailcontent['message']) |
| 6176 | 6176 | { |
| 6177 | - $tempname =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6177 | + $tempname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6178 | 6178 | $attachedMessages[] = array( |
| 6179 | 6179 | 'type' => 'TEXT/PLAIN', |
| 6180 | 6180 | 'name' => $mailcontent['subject'].'.txt', |
| 6181 | 6181 | 'tmp_name' => $tempname, |
| 6182 | 6182 | ); |
| 6183 | - $tmpfile = fopen($tempname,'w'); |
|
| 6184 | - fwrite($tmpfile,$headdata.$mailcontent['message']); |
|
| 6183 | + $tmpfile = fopen($tempname, 'w'); |
|
| 6184 | + fwrite($tmpfile, $headdata.$mailcontent['message']); |
|
| 6185 | 6185 | fclose($tmpfile); |
| 6186 | 6186 | } |
| 6187 | - foreach($mailcontent['attachments'] as &$tmpval) |
|
| 6187 | + foreach ($mailcontent['attachments'] as &$tmpval) |
|
| 6188 | 6188 | { |
| 6189 | 6189 | $attachedMessages[] = $tmpval; |
| 6190 | 6190 | } |
@@ -6192,36 +6192,36 @@ discard block |
||
| 6192 | 6192 | } |
| 6193 | 6193 | else |
| 6194 | 6194 | { |
| 6195 | - $attachments[$num] = array_merge($attachments[$num],$mailClass->getAttachment($uid, $attachment['partID'],0,false,false)); |
|
| 6195 | + $attachments[$num] = array_merge($attachments[$num], $mailClass->getAttachment($uid, $attachment['partID'], 0, false, false)); |
|
| 6196 | 6196 | |
| 6197 | - if (empty($attachments[$num]['attachment'])&&$attachments[$num]['cid']) |
|
| 6197 | + if (empty($attachments[$num]['attachment']) && $attachments[$num]['cid']) |
|
| 6198 | 6198 | { |
| 6199 | - $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'],true); |
|
| 6199 | + $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'], true); |
|
| 6200 | 6200 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6201 | 6201 | } |
| 6202 | 6202 | // no attempt to convert, if we dont know about the charset |
| 6203 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 6203 | + if (isset($attachments[$num]['charset']) && !empty($attachments[$num]['charset'])) { |
|
| 6204 | 6204 | // we do not try guessing the charset, if it is not set |
| 6205 | 6205 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6206 | - Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
|
| 6206 | + Translation::convert($attachments[$num]['attachment'], $attachments[$num]['charset']); |
|
| 6207 | 6207 | } |
| 6208 | - if(in_array($attachments[$num]['name'], $file_list)) |
|
| 6208 | + if (in_array($attachments[$num]['name'], $file_list)) |
|
| 6209 | 6209 | { |
| 6210 | 6210 | $dupe_count[$attachments[$num]['name']]++; |
| 6211 | - $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME) . |
|
| 6212 | - ' ('.($dupe_count[$attachments[$num]['name']] + 1).')' . '.' . |
|
| 6211 | + $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME). |
|
| 6212 | + ' ('.($dupe_count[$attachments[$num]['name']] + 1).')'.'.'. |
|
| 6213 | 6213 | pathinfo($attachments[$num]['name'], PATHINFO_EXTENSION); |
| 6214 | 6214 | } |
| 6215 | 6215 | $attachments[$num]['type'] = $attachments[$num]['mimeType']; |
| 6216 | - $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6217 | - $tmpfile = fopen($attachments[$num]['tmp_name'],'w'); |
|
| 6218 | - fwrite($tmpfile,$attachments[$num]['attachment']); |
|
| 6216 | + $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6217 | + $tmpfile = fopen($attachments[$num]['tmp_name'], 'w'); |
|
| 6218 | + fwrite($tmpfile, $attachments[$num]['attachment']); |
|
| 6219 | 6219 | fclose($tmpfile); |
| 6220 | 6220 | $file_list[] = $attachments[$num]['name']; |
| 6221 | 6221 | unset($attachments[$num]['attachment']); |
| 6222 | 6222 | } |
| 6223 | 6223 | } |
| 6224 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 6224 | + if (is_array($attachedMessages)) $attachments = array_merge($attachments, $attachedMessages); |
|
| 6225 | 6225 | } |
| 6226 | 6226 | return array( |
| 6227 | 6227 | 'mailaddress'=>$mailaddress, |
@@ -6243,10 +6243,10 @@ discard block |
||
| 6243 | 6243 | { |
| 6244 | 6244 | $c = 0; |
| 6245 | 6245 | // use the standardIdentity |
| 6246 | - foreach($_identities as $key => $acc) { |
|
| 6247 | - if ($c==0) $identity = $acc; |
|
| 6246 | + foreach ($_identities as $key => $acc) { |
|
| 6247 | + if ($c == 0) $identity = $acc; |
|
| 6248 | 6248 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6249 | - if ($key==$_profile_id) $identity = $acc; |
|
| 6249 | + if ($key == $_profile_id) $identity = $acc; |
|
| 6250 | 6250 | $c++; |
| 6251 | 6251 | } |
| 6252 | 6252 | return $identity; |
@@ -6258,29 +6258,29 @@ discard block |
||
| 6258 | 6258 | * @param bool createHTML do it with HTML breaks |
| 6259 | 6259 | * @return string a preformatted string with the information of the header worked into it |
| 6260 | 6260 | */ |
| 6261 | - static function createHeaderInfoSection($header,$headline='', $createHTML = false) |
|
| 6261 | + static function createHeaderInfoSection($header, $headline = '', $createHTML = false) |
|
| 6262 | 6262 | { |
| 6263 | 6263 | $headdata = null; |
| 6264 | 6264 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6265 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6266 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6267 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6268 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6269 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6270 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6271 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6272 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6273 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 6265 | + if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML ? "<br />" : "\n"); |
|
| 6266 | + if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6267 | + if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6268 | + if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6269 | + if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6270 | + if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6271 | + if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML ? "<br />" : "\n"); |
|
| 6272 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML ? "<br />" : "\n"); |
|
| 6273 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] != 'normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML ? "<br />" : "\n"); |
|
| 6274 | 6274 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6275 | 6275 | if (!empty($headdata)) |
| 6276 | 6276 | { |
| 6277 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6278 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 6279 | - $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6277 | + if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML ? "<br />" : "\n").$headdata; |
|
| 6278 | + if (empty($headline)) $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '').$headdata; |
|
| 6279 | + $headdata .= ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6280 | 6280 | } |
| 6281 | 6281 | else |
| 6282 | 6282 | { |
| 6283 | - $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6283 | + $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6284 | 6284 | } |
| 6285 | 6285 | return $headdata; |
| 6286 | 6286 | } |
@@ -6293,8 +6293,8 @@ discard block |
||
| 6293 | 6293 | */ |
| 6294 | 6294 | static function adaptSubjectForImport($subject) |
| 6295 | 6295 | { |
| 6296 | - $subject = str_replace('$$','__',($subject?$subject:lang('(no subject)'))); |
|
| 6297 | - $subject = str_ireplace(array('[FWD]','[',']','{','}','<','>'),array('Fwd:',' ',' ',' ',' ',' ',' '),trim($subject)); |
|
| 6296 | + $subject = str_replace('$$', '__', ($subject ? $subject : lang('(no subject)'))); |
|
| 6297 | + $subject = str_ireplace(array('[FWD]', '[', ']', '{', '}', '<', '>'), array('Fwd:', ' ', ' ', ' ', ' ', ' ', ' '), trim($subject)); |
|
| 6298 | 6298 | return $subject; |
| 6299 | 6299 | } |
| 6300 | 6300 | |
@@ -6306,15 +6306,15 @@ discard block |
||
| 6306 | 6306 | static function convertAddressArrayToString($rfcAddressArray) |
| 6307 | 6307 | { |
| 6308 | 6308 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($rfcAddressArray)); |
| 6309 | - $returnAddr =''; |
|
| 6309 | + $returnAddr = ''; |
|
| 6310 | 6310 | if (is_array($rfcAddressArray)) |
| 6311 | 6311 | { |
| 6312 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 6312 | + foreach ((array)$rfcAddressArray as $addressData) { |
|
| 6313 | 6313 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6314 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6314 | + if ($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6315 | 6315 | continue; |
| 6316 | 6316 | } |
| 6317 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6317 | + if (strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6318 | 6318 | continue; |
| 6319 | 6319 | } |
| 6320 | 6320 | if ($addressData['RFC822_EMAIL']) |
@@ -6323,7 +6323,7 @@ discard block |
||
| 6323 | 6323 | } |
| 6324 | 6324 | else |
| 6325 | 6325 | { |
| 6326 | - $emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']); |
|
| 6326 | + $emailaddress = ($addressData['PERSONAL_NAME'] ? $addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>' : $addressData['EMAIL']); |
|
| 6327 | 6327 | $addressObjectA = self::parseAddressList($emailaddress); |
| 6328 | 6328 | } |
| 6329 | 6329 | $addressObject = $addressObjectA[0]; |
@@ -6332,10 +6332,10 @@ discard block |
||
| 6332 | 6332 | //$mb =(string)$addressObject->mailbox; |
| 6333 | 6333 | //$h = (string)$addressObject->host; |
| 6334 | 6334 | //$p = (string)$addressObject->personal; |
| 6335 | - $returnAddr .= (strlen($returnAddr)>0?',':''); |
|
| 6335 | + $returnAddr .= (strlen($returnAddr) > 0 ? ',' : ''); |
|
| 6336 | 6336 | //error_log(__METHOD__.' ('.__LINE__.') '.$p.' <'.$mb.'@'.$h.'>'); |
| 6337 | 6337 | $buff = imap_rfc822_write_address($addressObject->mailbox, Horde_Idna::decode($addressObject->host), $addressObject->personal); |
| 6338 | - $buff = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$buff); |
|
| 6338 | + $buff = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $buff); |
|
| 6339 | 6339 | //error_log(__METHOD__.' ('.__LINE__.') '.' Address: '.$returnAddr); |
| 6340 | 6340 | $returnAddr .= $buff; |
| 6341 | 6341 | } |
@@ -6343,8 +6343,8 @@ discard block |
||
| 6343 | 6343 | else |
| 6344 | 6344 | { |
| 6345 | 6345 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6346 | - $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
|
| 6347 | - $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
|
| 6346 | + $rfcAddressArray = self::decode_header($rfcAddressArray, true); |
|
| 6347 | + $rfcAddressArray = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $rfcAddressArray); |
|
| 6348 | 6348 | if (is_string($rfcAddressArray)) return $rfcAddressArray; |
| 6349 | 6349 | } |
| 6350 | 6350 | return $returnAddr; |
@@ -6358,12 +6358,12 @@ discard block |
||
| 6358 | 6358 | * @param string &$err error-message on error |
| 6359 | 6359 | * @return string/boolean merged content or false on error |
| 6360 | 6360 | */ |
| 6361 | - static function merge($content,$ids,$mimetype='') |
|
| 6361 | + static function merge($content, $ids, $mimetype = '') |
|
| 6362 | 6362 | { |
| 6363 | 6363 | $mergeobj = new Contacts\Merge(); |
| 6364 | 6364 | |
| 6365 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 6366 | - $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
|
| 6365 | + if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ? 'text/plain' : 'text/html'); |
|
| 6366 | + $rv = $mergeobj->merge_string($content, $ids, $err = '', $mimetype, array(), self::$displayCharset); |
|
| 6367 | 6367 | if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
| 6368 | 6368 | if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
| 6369 | 6369 | return $rv; |
@@ -6405,12 +6405,12 @@ discard block |
||
| 6405 | 6405 | else |
| 6406 | 6406 | settype($bytes, 'integer'); |
| 6407 | 6407 | |
| 6408 | - return $bytes . ' ' . $type ; |
|
| 6408 | + return $bytes.' '.$type; |
|
| 6409 | 6409 | } |
| 6410 | 6410 | |
| 6411 | 6411 | static function detect_qp(&$sting) { |
| 6412 | 6412 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6413 | - return preg_match("$needle",$string); |
|
| 6413 | + return preg_match("$needle", $string); |
|
| 6414 | 6414 | } |
| 6415 | 6415 | |
| 6416 | 6416 | /** |
@@ -6423,11 +6423,11 @@ discard block |
||
| 6423 | 6423 | * @param string $_methodNline - Information where the log was taken |
| 6424 | 6424 | * @return void |
| 6425 | 6425 | */ |
| 6426 | - static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
|
| 6426 | + static function logRunTimes($_starttime, $_endtime = null, $_message = '', $_methodNline = '') |
|
| 6427 | 6427 | { |
| 6428 | 6428 | if (is_null($_endtime)) $_endtime = microtime(true); |
| 6429 | 6429 | $usagetime = microtime(true) - $_starttime; |
| 6430 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 6430 | + if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime, 5).'(s) '.($_message ? 'Details:'.$_message : '')); |
|
| 6431 | 6431 | } |
| 6432 | 6432 | |
| 6433 | 6433 | /** |
@@ -6440,9 +6440,9 @@ discard block |
||
| 6440 | 6440 | * |
| 6441 | 6441 | * @throws Exception\WrongUserinput |
| 6442 | 6442 | */ |
| 6443 | - static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
|
| 6443 | + static function checkFileBasics(&$_formData, $IDtoAddToFileName = '', $reqMimeType = 'message/rfc822') |
|
| 6444 | 6444 | { |
| 6445 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6445 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6446 | 6446 | |
| 6447 | 6447 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6448 | 6448 | $importfailed = $tmpFileName = false; |
@@ -6452,7 +6452,7 @@ discard block |
||
| 6452 | 6452 | $importfailed = true; |
| 6453 | 6453 | $alert_msg .= lang("Empty file %1 ignored.", $_formData['name']); |
| 6454 | 6454 | } |
| 6455 | - elseif (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6455 | + elseif (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6456 | 6456 | realpath(dirname($_formData['file'])) == realpath($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6457 | 6457 | { |
| 6458 | 6458 | // ensure existance of eGW temp dir |
@@ -6460,7 +6460,7 @@ discard block |
||
| 6460 | 6460 | // and different from any other temp file location set in php.ini |
| 6461 | 6461 | if (!file_exists($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6462 | 6462 | { |
| 6463 | - @mkdir($GLOBALS['egw_info']['server']['temp_dir'],0700); |
|
| 6463 | + @mkdir($GLOBALS['egw_info']['server']['temp_dir'], 0700); |
|
| 6464 | 6464 | } |
| 6465 | 6465 | |
| 6466 | 6466 | // if we were NOT able to create this temp directory, then make an ERROR report |
@@ -6487,14 +6487,14 @@ discard block |
||
| 6487 | 6487 | // maybe its application/octet-stream -> this may mean that we could not determine the type |
| 6488 | 6488 | // so we check for the suffix too |
| 6489 | 6489 | // trust vfs mime-types, trust the mimetype if it contains a method |
| 6490 | - if ((substr($_formData['file'],0,6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'],'method=')===false) |
|
| 6490 | + if ((substr($_formData['file'], 0, 6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'], 'method=') === false) |
|
| 6491 | 6491 | { |
| 6492 | - $buff = explode('.',$_formData['name']); |
|
| 6492 | + $buff = explode('.', $_formData['name']); |
|
| 6493 | 6493 | $suffix = ''; |
| 6494 | 6494 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 6495 | 6495 | if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
| 6496 | 6496 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6497 | - (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6497 | + (strlen(trim($_formData['type'])) == 0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6498 | 6498 | { |
| 6499 | 6499 | error_log(__METHOD__.' ('.__LINE__.') '.' Data:'.array2string($_formData)); |
| 6500 | 6500 | error_log(__METHOD__.' ('.__LINE__.') '.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType); |
@@ -6509,13 +6509,13 @@ discard block |
||
| 6509 | 6509 | if ($reqMimeType) |
| 6510 | 6510 | { |
| 6511 | 6511 | // so if PHP did not pass any file_type info, then substitute the rfc default value |
| 6512 | - if (substr(strtolower(trim($_formData['type'])),0,strlen($mime_type_default)) != $mime_type_default) |
|
| 6512 | + if (substr(strtolower(trim($_formData['type'])), 0, strlen($mime_type_default)) != $mime_type_default) |
|
| 6513 | 6513 | { |
| 6514 | 6514 | if (!(strtolower(trim($_formData['type'])) == "application/octet-stream" && $sfxMimeType == $reqMimeType)) |
| 6515 | 6515 | { |
| 6516 | 6516 | //error_log("Message rejected, no message/rfc. Is:".$_formData['type']); |
| 6517 | 6517 | $importfailed = true; |
| 6518 | - $alert_msg .= lang("File rejected, no %2. Is:%1",$_formData['type'],$reqMimeType); |
|
| 6518 | + $alert_msg .= lang("File rejected, no %2. Is:%1", $_formData['type'], $reqMimeType); |
|
| 6519 | 6519 | } |
| 6520 | 6520 | if ((strtolower(trim($_formData['type'])) != $reqMimeType && $sfxMimeType == $reqMimeType)) |
| 6521 | 6521 | { |
@@ -6524,17 +6524,17 @@ discard block |
||
| 6524 | 6524 | } |
| 6525 | 6525 | } |
| 6526 | 6526 | // as FreeBSD seems to have problems with the generated temp names we append some more random stuff |
| 6527 | - $randomString = chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)); |
|
| 6527 | + $randomString = chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)); |
|
| 6528 | 6528 | $tmpFileName = $GLOBALS['egw_info']['user']['account_id']. |
| 6529 | 6529 | trim($IDtoAddToFileName).basename($_formData['file']).'_'.$randomString; |
| 6530 | 6530 | |
| 6531 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs') |
|
| 6531 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs') |
|
| 6532 | 6532 | { |
| 6533 | - $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6533 | + $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6534 | 6534 | } |
| 6535 | 6535 | elseif (is_uploaded_file($_formData['file'])) |
| 6536 | 6536 | { |
| 6537 | - move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6537 | + move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6538 | 6538 | } |
| 6539 | 6539 | else |
| 6540 | 6540 | { |
@@ -6543,7 +6543,7 @@ discard block |
||
| 6543 | 6543 | } else { |
| 6544 | 6544 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6545 | 6545 | $importfailed = true; |
| 6546 | - $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
|
| 6546 | + $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.", $_formData['name']); |
|
| 6547 | 6547 | } |
| 6548 | 6548 | if ($importfailed == true) |
| 6549 | 6549 | { |
@@ -6551,7 +6551,7 @@ discard block |
||
| 6551 | 6551 | } |
| 6552 | 6552 | else |
| 6553 | 6553 | { |
| 6554 | - if (parse_url($tmpFileName,PHP_URL_SCHEME) == 'vfs') |
|
| 6554 | + if (parse_url($tmpFileName, PHP_URL_SCHEME) == 'vfs') |
|
| 6555 | 6555 | { |
| 6556 | 6556 | Vfs::load_wrapper('vfs'); |
| 6557 | 6557 | } |
@@ -6576,7 +6576,7 @@ discard block |
||
| 6576 | 6576 | $images = null; |
| 6577 | 6577 | if (preg_match_all("/(src|background)=\"(.*)\"/Ui", $_html2parse, $images) && isset($images[2])) |
| 6578 | 6578 | { |
| 6579 | - foreach($images[2] as $i => $url) |
|
| 6579 | + foreach ($images[2] as $i => $url) |
|
| 6580 | 6580 | { |
| 6581 | 6581 | //$isData = false; |
| 6582 | 6582 | $basedir = $data = ''; |
@@ -6588,20 +6588,20 @@ discard block |
||
| 6588 | 6588 | $filename = basename($url); |
| 6589 | 6589 | if (($directory = dirname($url)) == '.') $directory = ''; |
| 6590 | 6590 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6591 | - $mimeType = MimeMagic::ext2mime($ext); |
|
| 6592 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 6591 | + $mimeType = MimeMagic::ext2mime($ext); |
|
| 6592 | + if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } |
|
| 6593 | 6593 | $myUrl = $directory.$filename; |
| 6594 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6594 | + if ($myUrl[0] == '/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6595 | 6595 | { |
| 6596 | - $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
|
| 6596 | + $basedir = ($_SERVER['HTTPS'] ? 'https://' : 'http://'.$_SERVER['HTTP_HOST']); |
|
| 6597 | 6597 | } |
| 6598 | 6598 | // use vfs instead of url containing webdav.php |
| 6599 | 6599 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6600 | 6600 | // webdav.php urls as vfs |
| 6601 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6601 | + if (strpos($myUrl, '/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6602 | 6602 | { |
| 6603 | 6603 | Vfs::load_wrapper('vfs'); |
| 6604 | - list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
|
| 6604 | + list(,$myUrl) = explode('/webdav.php', $myUrl, 2); |
|
| 6605 | 6605 | $basedir = 'vfs://default'; |
| 6606 | 6606 | $needTempFile = false; |
| 6607 | 6607 | } |
@@ -6614,11 +6614,11 @@ discard block |
||
| 6614 | 6614 | // Strips the url and store it into a temp for further procss |
| 6615 | 6615 | $tmp_url = html_entity_decode($myUrl); |
| 6616 | 6616 | |
| 6617 | - parse_str(parse_url($tmp_url, PHP_URL_QUERY),$URI_params); |
|
| 6617 | + parse_str(parse_url($tmp_url, PHP_URL_QUERY), $URI_params); |
|
| 6618 | 6618 | if ($URI_params['mailbox'] && $URI_params['uid'] && $URI_params['cid']) |
| 6619 | 6619 | { |
| 6620 | 6620 | $mail_bo->reopen(base64_decode($URI_params['mailbox'])); |
| 6621 | - $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']),base64_decode($URI_params['partID']),true); |
|
| 6621 | + $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']), base64_decode($URI_params['partID']), true); |
|
| 6622 | 6622 | $mail_bo->closeConnection(); |
| 6623 | 6623 | if ($attachment) |
| 6624 | 6624 | { |
@@ -6629,32 +6629,32 @@ discard block |
||
| 6629 | 6629 | } |
| 6630 | 6630 | } |
| 6631 | 6631 | |
| 6632 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6633 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6632 | + if (strlen($basedir) > 1 && substr($basedir, -1) != '/' && $myUrl[0] != '/') { $basedir .= '/'; } |
|
| 6633 | + if ($needTempFile && !$attachment && substr($myUrl, 0, 4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6634 | 6634 | } |
| 6635 | - if (substr($url,0,strlen('data:'))=='data:') |
|
| 6635 | + if (substr($url, 0, strlen('data:')) == 'data:') |
|
| 6636 | 6636 | { |
| 6637 | 6637 | //error_log(__METHOD__.' ('.__LINE__.') '.' -> '.$i.': '.array2string($images[$i])); |
| 6638 | 6638 | // we only support base64 encoded data |
| 6639 | - $tmp = substr($url,strlen('data:')); |
|
| 6640 | - list($mimeType,$data_base64) = explode(';base64,',$tmp); |
|
| 6639 | + $tmp = substr($url, strlen('data:')); |
|
| 6640 | + list($mimeType, $data_base64) = explode(';base64,', $tmp); |
|
| 6641 | 6641 | $data = base64_decode($data_base64); |
| 6642 | 6642 | // FF currently does NOT add any mime-type |
| 6643 | 6643 | if (strtolower(substr($mimeType, 0, 6)) != 'image/') |
| 6644 | 6644 | { |
| 6645 | 6645 | $mimeType = MimeMagic::analyze_data($data); |
| 6646 | 6646 | } |
| 6647 | - list($what,$exactly) = explode('/',$mimeType); |
|
| 6647 | + list($what, $exactly) = explode('/', $mimeType); |
|
| 6648 | 6648 | $needTempFile = true; |
| 6649 | - $filename = ($what?$what:'data').$imageC++.'.'.$exactly; |
|
| 6649 | + $filename = ($what ? $what : 'data').$imageC++.'.'.$exactly; |
|
| 6650 | 6650 | } |
| 6651 | 6651 | if ($data || $needTempFile === false) |
| 6652 | 6652 | { |
| 6653 | 6653 | if ($needTempFile) |
| 6654 | 6654 | { |
| 6655 | - $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6656 | - $tmpfile = fopen($attachment_file,'w'); |
|
| 6657 | - fwrite($tmpfile,$data); |
|
| 6655 | + $attachment_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6656 | + $tmpfile = fopen($attachment_file, 'w'); |
|
| 6657 | + fwrite($tmpfile, $data); |
|
| 6658 | 6658 | fclose($tmpfile); |
| 6659 | 6659 | } |
| 6660 | 6660 | else |
@@ -6665,7 +6665,7 @@ discard block |
||
| 6665 | 6665 | // (or similar) in all cases (when cut&paste). This may lead to more attached files, in case |
| 6666 | 6666 | // we use the same image multiple times, but, if we do this, we should try to detect that |
| 6667 | 6667 | // on upload. filename itself is not sufficient to determine the sameness of images |
| 6668 | - $cid = 'cid:' . md5($attachment_file); |
|
| 6668 | + $cid = 'cid:'.md5($attachment_file); |
|
| 6669 | 6669 | if ($_mailObject->AddEmbeddedImage($attachment_file, substr($cid, 4), urldecode($filename), $mimeType) !== null) |
| 6670 | 6670 | { |
| 6671 | 6671 | //$_html2parse = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $_html2parse); |
@@ -6687,10 +6687,10 @@ discard block |
||
| 6687 | 6687 | * @param string& $importID ID for the imported message, used by attachments to identify them unambiguously |
| 6688 | 6688 | * @return mixed array of messages with success and failed messages or exception |
| 6689 | 6689 | */ |
| 6690 | - function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID='') |
|
| 6690 | + function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID = '') |
|
| 6691 | 6691 | { |
| 6692 | 6692 | $importfailed = false; |
| 6693 | - $processStats = array('success'=>array(),'failed'=>array()); |
|
| 6693 | + $processStats = array('success'=>array(), 'failed'=>array()); |
|
| 6694 | 6694 | if (empty($SendAndMergeTocontacts)) |
| 6695 | 6695 | { |
| 6696 | 6696 | $importfailed = true; |
@@ -6731,7 +6731,7 @@ discard block |
||
| 6731 | 6731 | $_folder = $this->getSentFolder(); |
| 6732 | 6732 | } |
| 6733 | 6733 | $delimiter = $this->getHierarchyDelimiter(); |
| 6734 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 6734 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 6735 | 6735 | if ($importfailed === false) |
| 6736 | 6736 | { |
| 6737 | 6737 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6749,9 +6749,9 @@ discard block |
||
| 6749 | 6749 | { |
| 6750 | 6750 | $mailObject->clearReplyTos(); |
| 6751 | 6751 | $activeMailProfiles = $this->mail->getAccountIdentities($this->profileID); |
| 6752 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6752 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6753 | 6753 | |
| 6754 | - $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']),Mail::generateIdentityString($activeMailProfile,false)); |
|
| 6754 | + $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']), Mail::generateIdentityString($activeMailProfile, false)); |
|
| 6755 | 6755 | } |
| 6756 | 6756 | foreach ($SendAndMergeTocontacts as $k => $val) |
| 6757 | 6757 | { |
@@ -6765,12 +6765,12 @@ discard block |
||
| 6765 | 6765 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6766 | 6766 | |
| 6767 | 6767 | // Parse destinations for placeholders |
| 6768 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6768 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6769 | 6769 | { |
| 6770 | 6770 | //error_log('ID ' . $val . ' ' .$type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset)); |
| 6771 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6772 | - $mailObject->addAddress($merged,'',$type); |
|
| 6773 | - if($type == 'to') |
|
| 6771 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6772 | + $mailObject->addAddress($merged, '', $type); |
|
| 6773 | + if ($type == 'to') |
|
| 6774 | 6774 | { |
| 6775 | 6775 | $email = $merged; |
| 6776 | 6776 | } |
@@ -6783,26 +6783,26 @@ discard block |
||
| 6783 | 6783 | //error_log(__METHOD__.' ('.__LINE__.') '.' ID:'.$val.' Data:'.array2string($contact)); |
| 6784 | 6784 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6785 | 6785 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6786 | - if($email) |
|
| 6786 | + if ($email) |
|
| 6787 | 6787 | { |
| 6788 | 6788 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6789 | 6789 | } |
| 6790 | 6790 | } |
| 6791 | 6791 | |
| 6792 | 6792 | $activeMailProfiles = $this->getAccountIdentities($this->profileID); |
| 6793 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6793 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6794 | 6794 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($activeMailProfile)); |
| 6795 | 6795 | $mailObject->setFrom($activeMailProfile['ident_email'], |
| 6796 | - self::generateIdentityString($activeMailProfile,false)); |
|
| 6796 | + self::generateIdentityString($activeMailProfile, false)); |
|
| 6797 | 6797 | |
| 6798 | 6798 | $mailObject->removeHeader('Message-ID'); |
| 6799 | 6799 | $mailObject->removeHeader('Date'); |
| 6800 | 6800 | $mailObject->clearCustomHeaders(); |
| 6801 | 6801 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6802 | 6802 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6803 | - if($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6803 | + if ($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6804 | 6804 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6805 | - if($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6805 | + if ($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6806 | 6806 | |
| 6807 | 6807 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6808 | 6808 | // set a higher timeout for big messages |
@@ -6811,7 +6811,7 @@ discard block |
||
| 6811 | 6811 | try { |
| 6812 | 6812 | $mailObject->send(); |
| 6813 | 6813 | } |
| 6814 | - catch(Exception $e) { |
|
| 6814 | + catch (Exception $e) { |
|
| 6815 | 6815 | $sendOK = false; |
| 6816 | 6816 | $errorInfo = $e->getMessage(); |
| 6817 | 6817 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
@@ -6825,41 +6825,41 @@ discard block |
||
| 6825 | 6825 | $mailObject->clearCustomHeaders(); |
| 6826 | 6826 | |
| 6827 | 6827 | // Parse destinations for placeholders |
| 6828 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6828 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6829 | 6829 | { |
| 6830 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6830 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6831 | 6831 | //error_log($type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$merged); |
| 6832 | - $mailObject->addAddress(trim($merged,'"'),'',$type); |
|
| 6832 | + $mailObject->addAddress(trim($merged, '"'), '', $type); |
|
| 6833 | 6833 | } |
| 6834 | 6834 | |
| 6835 | 6835 | // No addresses from placeholders? Treat it as just a contact ID |
| 6836 | - if (count($mailObject->getAddresses('to',true)) == 0 && |
|
| 6836 | + if (count($mailObject->getAddresses('to', true)) == 0 && |
|
| 6837 | 6837 | is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
| 6838 | 6838 | { |
| 6839 | 6839 | $contact = $bo_merge->contacts->read($val); |
| 6840 | 6840 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6841 | 6841 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6842 | 6842 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6843 | - if($email) |
|
| 6843 | + if ($email) |
|
| 6844 | 6844 | { |
| 6845 | 6845 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6846 | 6846 | } |
| 6847 | 6847 | } |
| 6848 | 6848 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6849 | 6849 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6850 | - if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6850 | + if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6851 | 6851 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6852 | - if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6852 | + if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6853 | 6853 | $_folder = $this->getDraftFolder(); |
| 6854 | 6854 | } |
| 6855 | 6855 | if ($sendOK || $openAsDraft) |
| 6856 | 6856 | { |
| 6857 | - if ($this->folderExists($_folder,true)) |
|
| 6857 | + if ($this->folderExists($_folder, true)) |
|
| 6858 | 6858 | { |
| 6859 | - if($this->isSentFolder($_folder)) |
|
| 6859 | + if ($this->isSentFolder($_folder)) |
|
| 6860 | 6860 | { |
| 6861 | 6861 | $flags = '\\Seen'; |
| 6862 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 6862 | + } elseif ($this->isDraftFolder($_folder)) { |
|
| 6863 | 6863 | $flags = '\\Draft'; |
| 6864 | 6864 | } else { |
| 6865 | 6865 | $flags = ''; |
@@ -6867,7 +6867,7 @@ discard block |
||
| 6867 | 6867 | $savefailed = false; |
| 6868 | 6868 | try |
| 6869 | 6869 | { |
| 6870 | - $messageUid =$this->appendMessage($_folder, |
|
| 6870 | + $messageUid = $this->appendMessage($_folder, |
|
| 6871 | 6871 | $mailObject->getRaw(), |
| 6872 | 6872 | null, |
| 6873 | 6873 | $flags); |
@@ -6875,10 +6875,10 @@ discard block |
||
| 6875 | 6875 | catch (\Exception\WrongUserinput $e) |
| 6876 | 6876 | { |
| 6877 | 6877 | $savefailed = true; |
| 6878 | - $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage()); |
|
| 6878 | + $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", $Subject, $_folder, $e->getMessage()); |
|
| 6879 | 6879 | } |
| 6880 | 6880 | // no send, save successful, and message_uid present |
| 6881 | - if ($savefailed===false && $messageUid && is_null($sendOK)) |
|
| 6881 | + if ($savefailed === false && $messageUid && is_null($sendOK)) |
|
| 6882 | 6882 | { |
| 6883 | 6883 | $importID = $messageUid; |
| 6884 | 6884 | $openComposeWindow = true; |
@@ -6887,20 +6887,20 @@ discard block |
||
| 6887 | 6887 | else |
| 6888 | 6888 | { |
| 6889 | 6889 | $savefailed = true; |
| 6890 | - $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.",$Subject,$_folder); |
|
| 6890 | + $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.", $Subject, $_folder); |
|
| 6891 | 6891 | } |
| 6892 | 6892 | if ($sendOK) |
| 6893 | 6893 | { |
| 6894 | - $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed?' but failed to store to Folder:'.$_folder:''); |
|
| 6894 | + $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed ? ' but failed to store to Folder:'.$_folder : ''); |
|
| 6895 | 6895 | } |
| 6896 | 6896 | else |
| 6897 | 6897 | { |
| 6898 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6898 | + if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6899 | 6899 | } |
| 6900 | 6900 | } |
| 6901 | - if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
|
| 6901 | + if (!is_null($sendOK) && $sendOK === false && is_null($openComposeWindow)) |
|
| 6902 | 6902 | { |
| 6903 | - $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6903 | + $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6904 | 6904 | } |
| 6905 | 6905 | } |
| 6906 | 6906 | } |
@@ -6962,13 +6962,13 @@ discard block |
||
| 6962 | 6962 | * @param boolean $force8bitOnPrimaryPart (default false. force transferEncoding and charset to 8bit/utf8 if we have a textpart as primaryPart) |
| 6963 | 6963 | * @throws Exception\WrongParameter when the required Horde_Mail_Part not found |
| 6964 | 6964 | */ |
| 6965 | - function parseRawMessageIntoMailObject(Mailer $mailer, $message, $force8bitOnPrimaryPart=false) |
|
| 6965 | + function parseRawMessageIntoMailObject(Mailer $mailer, $message, $force8bitOnPrimaryPart = false) |
|
| 6966 | 6966 | { |
| 6967 | 6967 | if (is_string($message) || is_resource($message)) |
| 6968 | 6968 | { |
| 6969 | 6969 | $structure = Horde_Mime_Part::parseMessage($message); |
| 6970 | 6970 | //error_log(__METHOD__.__LINE__.'#'.$structure->getPrimaryType().'#'); |
| 6971 | - if ($force8bitOnPrimaryPart&&$structure->getPrimaryType()=='text') |
|
| 6971 | + if ($force8bitOnPrimaryPart && $structure->getPrimaryType() == 'text') |
|
| 6972 | 6972 | { |
| 6973 | 6973 | $structure->setTransferEncoding('8bit'); |
| 6974 | 6974 | $structure->setCharset('utf-8'); |
@@ -6977,19 +6977,18 @@ discard block |
||
| 6977 | 6977 | //error_log(__METHOD__.__LINE__.':'.array2string($structure)); |
| 6978 | 6978 | |
| 6979 | 6979 | // unfortunately parseMessage does NOT return parsed headers (we assume header is shorter then 8k) |
| 6980 | - $start = is_string($message) ? substr($message, 0, 8192) : |
|
| 6981 | - (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6980 | + $start = is_string($message) ? substr($message, 0, 8192) : (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6982 | 6981 | |
| 6983 | 6982 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6984 | - if ($length===false) $length = strlen($start); |
|
| 6985 | - $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
|
| 6983 | + if ($length === false) $length = strlen($start); |
|
| 6984 | + $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0, $length)); |
|
| 6986 | 6985 | |
| 6987 | - foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6986 | + foreach ($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6988 | 6987 | { |
| 6989 | - foreach((array)$value as $n => $val) |
|
| 6988 | + foreach ((array)$value as $n => $val) |
|
| 6990 | 6989 | { |
| 6991 | 6990 | $overwrite = !$n; |
| 6992 | - switch($header) |
|
| 6991 | + switch ($header) |
|
| 6993 | 6992 | { |
| 6994 | 6993 | case 'Content-Transfer-Encoding': |
| 6995 | 6994 | //as we parse the message and this sets the part with a Content-Transfer-Encoding, we |
@@ -7010,7 +7009,7 @@ discard block |
||
| 7010 | 7009 | } |
| 7011 | 7010 | else |
| 7012 | 7011 | { |
| 7013 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 7012 | + if (($type = gettype($message)) == 'object') $type = get_class($message); |
|
| 7014 | 7013 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 7015 | 7014 | } |
| 7016 | 7015 | } |
@@ -7024,50 +7023,50 @@ discard block |
||
| 7024 | 7023 | * @param string $default_domain |
| 7025 | 7024 | * @return Horde_Mail_Rfc822_List iteratable Horde_Mail_Rfc822_Address objects with attributes mailbox, host, personal and valid |
| 7026 | 7025 | */ |
| 7027 | - public static function parseAddressList($addresses, $default_domain=null) |
|
| 7026 | + public static function parseAddressList($addresses, $default_domain = null) |
|
| 7028 | 7027 | { |
| 7029 | 7028 | $rfc822 = new Horde_Mail_Rfc822(); |
| 7030 | 7029 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 7031 | 7030 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count.function_backtrace()); |
| 7032 | - if ((empty($ret) || $ret->count()==0)&& is_string($addresses) && strlen($addresses)>0) |
|
| 7031 | + if ((empty($ret) || $ret->count() == 0) && is_string($addresses) && strlen($addresses) > 0) |
|
| 7033 | 7032 | { |
| 7034 | 7033 | $matches = array(); |
| 7035 | - preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
|
| 7034 | + preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/", $addresses, $matches); |
|
| 7036 | 7035 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 7037 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 7038 | - $addresses = implode(',',$matches[0]); |
|
| 7036 | + foreach ($matches[0] as &$match) {$match = trim($match, ', '); } |
|
| 7037 | + $addresses = implode(',', $matches[0]); |
|
| 7039 | 7038 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 7040 | 7039 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 7041 | 7040 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count); |
| 7042 | 7041 | } |
| 7043 | - $previousFailed=false; |
|
| 7042 | + $previousFailed = false; |
|
| 7044 | 7043 | $ret2 = new Horde_Mail_Rfc822_List(); |
| 7045 | 7044 | // handle known problems on emailaddresses |
| 7046 | - foreach($ret as $i => $adr) |
|
| 7045 | + foreach ($ret as $i => $adr) |
|
| 7047 | 7046 | { |
| 7048 | 7047 | //mailaddresses enclosed in single quotes like '[email protected]' show up as 'me as mailbox and you.com' as host |
| 7049 | - if ($adr->mailbox && stripos($adr->mailbox,"'")== 0 && |
|
| 7050 | - $adr->host && stripos($adr->host,"'")== (strlen($adr->host) -1)) |
|
| 7048 | + if ($adr->mailbox && stripos($adr->mailbox, "'") == 0 && |
|
| 7049 | + $adr->host && stripos($adr->host, "'") == (strlen($adr->host) - 1)) |
|
| 7051 | 7050 | { |
| 7052 | - $adr->mailbox = str_replace("'","",$adr->mailbox); |
|
| 7053 | - $adr->host = str_replace("'","",$adr->host); |
|
| 7051 | + $adr->mailbox = str_replace("'", "", $adr->mailbox); |
|
| 7052 | + $adr->host = str_replace("'", "", $adr->host); |
|
| 7054 | 7053 | } |
| 7055 | 7054 | // no mailbox or host part as 'Xr\xc3\xa4hlyz, User <[email protected]>' is parsed as 2 addresses separated by ',' |
| 7056 | 7055 | //#'Xr\xc3\xa4hlyz, User <[email protected]>' |
| 7057 | 7056 | //#Horde_Mail_Rfc822_List Object([_data:protected] => Array( |
| 7058 | 7057 | //[0] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => Xr\xc3\xa4hlyz[_host:protected] => [_personal:protected] => ) |
| 7059 | 7058 | //[1] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => mailboxpart1.mailboxpart2[_host:protected] => youthost.com[_personal:protected] => User))[_filter:protected] => Array()[_ptr:protected] => )#2#, |
| 7060 | - if (strlen($adr->mailbox)==0||strlen($adr->host)==0) |
|
| 7059 | + if (strlen($adr->mailbox) == 0 || strlen($adr->host) == 0) |
|
| 7061 | 7060 | { |
| 7062 | - $remember = ($adr->mailbox?$adr->mailbox:($adr->host?$adr->host:'')); |
|
| 7063 | - $previousFailed=true; |
|
| 7061 | + $remember = ($adr->mailbox ? $adr->mailbox : ($adr->host ? $adr->host : '')); |
|
| 7062 | + $previousFailed = true; |
|
| 7064 | 7063 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 7065 | 7064 | } |
| 7066 | 7065 | else |
| 7067 | 7066 | { |
| 7068 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 7067 | + if ($previousFailed && $remember) $adr->personal = $remember.' '.$adr->personal; |
|
| 7069 | 7068 | $remember = ''; |
| 7070 | - $previousFailed=false; |
|
| 7069 | + $previousFailed = false; |
|
| 7071 | 7070 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 7072 | 7071 | $ret2->add($adr); |
| 7073 | 7072 | } |
@@ -7083,7 +7082,7 @@ discard block |
||
| 7083 | 7082 | * @param string $_folder |
| 7084 | 7083 | * @return boolean |
| 7085 | 7084 | */ |
| 7086 | - function sendMDN($uid,$_folder) |
|
| 7085 | + function sendMDN($uid, $_folder) |
|
| 7087 | 7086 | { |
| 7088 | 7087 | $acc = Mail\Account::read($this->profileID); |
| 7089 | 7088 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
@@ -7113,7 +7112,7 @@ discard block |
||
| 7113 | 7112 | */ |
| 7114 | 7113 | function addAccount($_hookValues) |
| 7115 | 7114 | { |
| 7116 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7115 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7117 | 7116 | |
| 7118 | 7117 | } |
| 7119 | 7118 | |
@@ -7127,7 +7126,7 @@ discard block |
||
| 7127 | 7126 | */ |
| 7128 | 7127 | function deleteAccount($_hookValues) |
| 7129 | 7128 | { |
| 7130 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7129 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7131 | 7130 | |
| 7132 | 7131 | } |
| 7133 | 7132 | |
@@ -7141,7 +7140,7 @@ discard block |
||
| 7141 | 7140 | */ |
| 7142 | 7141 | function updateAccount($_hookValues) |
| 7143 | 7142 | { |
| 7144 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7143 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7145 | 7144 | |
| 7146 | 7145 | } |
| 7147 | 7146 | } |