@@ -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 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 196 | 196 | * @return Mail |
| 197 | 197 | */ |
| 198 | - public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 198 | + public static function getInstance($_restoreSession = true, &$_profileID = 0, $_validate = true, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 199 | 199 | { |
| 200 | 200 | //$_restoreSession=false; |
| 201 | 201 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
@@ -205,13 +205,13 @@ discard block |
||
| 205 | 205 | { |
| 206 | 206 | if (!is_object(self::$instances[$_profileID])) |
| 207 | 207 | { |
| 208 | - self::$instances[$_profileID] = new Mail('utf-8',false,$_profileID,false,$_reuseCache); |
|
| 208 | + self::$instances[$_profileID] = new Mail('utf-8', false, $_profileID, false, $_reuseCache); |
|
| 209 | 209 | } |
| 210 | 210 | self::$instances[$_profileID]->icServer = $_oldImapServerObject; |
| 211 | - self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId; |
|
| 212 | - self::$instances[$_profileID]->profileID= $_oldImapServerObject->ImapServerId; |
|
| 211 | + self::$instances[$_profileID]->accountid = $_oldImapServerObject->ImapServerId; |
|
| 212 | + self::$instances[$_profileID]->profileID = $_oldImapServerObject->ImapServerId; |
|
| 213 | 213 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 214 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 214 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 215 | 215 | return self::$instances[$_profileID]; |
| 216 | 216 | } |
| 217 | 217 | if ($_profileID == 0) |
@@ -224,14 +224,14 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | $profileID = Mail\Account::get_default_acc_id(); |
| 226 | 226 | } |
| 227 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 228 | - $_profileID=$profileID; |
|
| 227 | + if ($profileID != $_profileID) $_restoreSession == false; |
|
| 228 | + $_profileID = $profileID; |
|
| 229 | 229 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
| 230 | 230 | } |
| 231 | 231 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 232 | - if ($_oldImapServerObject===true) |
|
| 232 | + if ($_oldImapServerObject === true) |
|
| 233 | 233 | { |
| 234 | - return new Mail('utf-8',false,$_profileID,true,$_reuseCache); |
|
| 234 | + return new Mail('utf-8', false, $_profileID, true, $_reuseCache); |
|
| 235 | 235 | } |
| 236 | 236 | if ($_profileID != 0 && $_validate) |
| 237 | 237 | { |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | //Cache::setSession('mail','activeProfileID',$_profileID); |
| 252 | 252 | } |
| 253 | 253 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace()); |
| 254 | - if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession===false)) |
|
| 254 | + if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession === false)) |
|
| 255 | 255 | { |
| 256 | - self::$instances[$_profileID] = new Mail('utf-8',$_restoreSession,$_profileID,false,$_reuseCache); |
|
| 256 | + self::$instances[$_profileID] = new Mail('utf-8', $_restoreSession, $_profileID, false, $_reuseCache); |
|
| 257 | 257 | } |
| 258 | 258 | else |
| 259 | 259 | { |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | self::$instances[$_profileID]->ogServer = Mail\Account::read($_profileID)->smtpServer(); |
| 265 | 265 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 266 | 266 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 267 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 267 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 268 | 268 | } catch (\Exception $e) |
| 269 | 269 | { |
| 270 | 270 | $newprofileID = Mail\Account::get_default_acc_id(); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | 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()); |
| 273 | 273 | if ($newprofileID) |
| 274 | 274 | { |
| 275 | - self::$instances[$newprofileID] = new Mail('utf-8',false,$newprofileID,false,$_reuseCache); |
|
| 275 | + self::$instances[$newprofileID] = new Mail('utf-8', false, $newprofileID, false, $_reuseCache); |
|
| 276 | 276 | $_profileID = $newprofileID; |
| 277 | 277 | } |
| 278 | 278 | else |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | throw $e; |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | - self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
|
| 283 | + self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate); |
|
| 284 | 284 | } |
| 285 | 285 | self::$instances[$_profileID]->profileID = $_profileID; |
| 286 | 286 | if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param boolean $_testConnection = 0 |
| 297 | 297 | * @return mixed $_profileID or false on failed ConnectionTest |
| 298 | 298 | */ |
| 299 | - public static function storeActiveProfileIDToPref($_icServerObject, $_profileID=0, $_testConnection=true) |
|
| 299 | + public static function storeActiveProfileIDToPref($_icServerObject, $_profileID = 0, $_testConnection = true) |
|
| 300 | 300 | { |
| 301 | 301 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) && !empty($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
| 302 | 302 | { |
@@ -317,12 +317,12 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | if ($oldProfileID != $_profileID) |
| 319 | 319 | { |
| 320 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 321 | - $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
|
| 320 | + if ($oldProfileID && $_profileID == 0) $_profileID = $oldProfileID; |
|
| 321 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveProfileID', $_profileID, 'user'); |
|
| 322 | 322 | // save prefs |
| 323 | 323 | $GLOBALS['egw']->preferences->save_repository(true); |
| 324 | 324 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $_profileID; |
| 325 | - Cache::setSession('mail','activeProfileID',$_profileID); |
|
| 325 | + Cache::setSession('mail', 'activeProfileID', $_profileID); |
|
| 326 | 326 | } |
| 327 | 327 | return $_profileID; |
| 328 | 328 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * @param int $_acc_id = 0 |
| 338 | 338 | * @return int validated acc_id -> either acc_id given, or first valid one |
| 339 | 339 | */ |
| 340 | - public static function validateProfileID($_acc_id=0) |
|
| 340 | + public static function validateProfileID($_acc_id = 0) |
|
| 341 | 341 | { |
| 342 | 342 | if ($_acc_id) |
| 343 | 343 | { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | // no account specified or specified account not found or not valid |
| 358 | 358 | // --> search existing account for first valid one and return that |
| 359 | - foreach(Mail\Account::search($only_current_user=true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 359 | + foreach (Mail\Account::search($only_current_user = true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 360 | 360 | { |
| 361 | 361 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 362 | 362 | { |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param boolean $_oldImapServerObject = false |
| 379 | 379 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 380 | 380 | */ |
| 381 | - private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 381 | + private function __construct($_displayCharset = 'utf-8', $_restoreSession = true, $_profileID = 0, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 382 | 382 | { |
| 383 | 383 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
| 384 | 384 | if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $firstMessage = $this->sessionData['previewMessage']; |
| 399 | 399 | $this->sessionData = array(); |
| 400 | 400 | } |
| 401 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 401 | + if (!$_reuseCache) $this->forcePrefReload($_profileID, !$_reuseCache); |
|
| 402 | 402 | try |
| 403 | 403 | { |
| 404 | 404 | $this->profileID = self::validateProfileID($_profileID); |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | catch (\Exception $e) |
| 411 | 411 | { |
| 412 | - throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage());; |
|
| 412 | + throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage()); ; |
|
| 413 | 413 | } |
| 414 | 414 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($acc->imapServer())); |
| 415 | - $this->icServer = ($_oldImapServerObject?$acc->oldImapServer():$acc->imapServer()); |
|
| 415 | + $this->icServer = ($_oldImapServerObject ? $acc->oldImapServer() : $acc->imapServer()); |
|
| 416 | 416 | $this->ogServer = $acc->smtpServer(); |
| 417 | 417 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 418 | 418 | $this->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 419 | - $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 419 | + $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 420 | 420 | if (isset($this->icServer->ImapServerId) && !empty($this->icServer->ImapServerId)) |
| 421 | 421 | { |
| 422 | 422 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | public static function &forceEAProfileLoad($_profile_id) |
| 435 | 435 | { |
| 436 | 436 | self::unsetCachedObjects($_profile_id); |
| 437 | - $mail = self::getInstance(false, $_profile_id,false); |
|
| 437 | + $mail = self::getInstance(false, $_profile_id, false); |
|
| 438 | 438 | //_debug_array( $_profile_id); |
| 439 | 439 | $mail->icServer = Mail\Account::read($_profile_id)->imapServer(); |
| 440 | 440 | $mail->ogServer = Mail\Account::read($_profile_id)->smtpServer(); |
@@ -446,11 +446,11 @@ discard block |
||
| 446 | 446 | * @param int $_profile_id |
| 447 | 447 | * @param boolean $_resetFolderObjects |
| 448 | 448 | */ |
| 449 | - public static function forcePrefReload($_profile_id=null,$_resetFolderObjects=true) |
|
| 449 | + public static function forcePrefReload($_profile_id = null, $_resetFolderObjects = true) |
|
| 450 | 450 | { |
| 451 | 451 | // unset the mail_preferences session object, to force the reload/rebuild |
| 452 | - Cache::setSession('mail','mail_preferences',serialize(array())); |
|
| 453 | - Cache::setSession('emailadmin','session_data',serialize(array())); |
|
| 452 | + Cache::setSession('mail', 'mail_preferences', serialize(array())); |
|
| 453 | + Cache::setSession('emailadmin', 'session_data', serialize(array())); |
|
| 454 | 454 | if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
| 455 | 455 | } |
| 456 | 456 | |
@@ -459,8 +459,8 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | function restoreSessionData() |
| 461 | 461 | { |
| 462 | - $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 463 | - self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 462 | + $this->sessionData = array(); //Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 463 | + self::$activeFolderCache = Cache::getCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 464 | 464 | if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -470,10 +470,10 @@ discard block |
||
| 470 | 470 | function saveSessionData() |
| 471 | 471 | { |
| 472 | 472 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 473 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 473 | + if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID] = $this->sessionData['mailbox']; |
|
| 474 | 474 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 475 | 475 | { |
| 476 | - Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
|
| 476 | + Cache::setCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), self::$activeFolderCache, 60 * 60 * 10); |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
@@ -489,40 +489,40 @@ discard block |
||
| 489 | 489 | * @param int $_profileID = null default profile of user as returned by getUserDefaultProfileID |
| 490 | 490 | * @return void |
| 491 | 491 | */ |
| 492 | - static function unsetCachedObjects($_profileID=null) |
|
| 492 | + static function unsetCachedObjects($_profileID = null) |
|
| 493 | 493 | { |
| 494 | 494 | if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
| 495 | 495 | if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
| 496 | 496 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 497 | - if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
|
| 497 | + if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID, 'tracker_') === false))) |
|
| 498 | 498 | { |
| 499 | 499 | self::resetConnectionErrorCache($_profileID); |
| 500 | - $rawHeadersCache = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 500 | + $rawHeadersCache = Cache::getCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 501 | 501 | if (isset($rawHeadersCache[$_profileID])) |
| 502 | 502 | { |
| 503 | 503 | unset($rawHeadersCache[$_profileID]); |
| 504 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$rawHeadersCache, $expiration=60*60*1); |
|
| 504 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $rawHeadersCache, $expiration = 60 * 60 * 1); |
|
| 505 | 505 | } |
| 506 | - $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*5); |
|
| 506 | + $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 5); |
|
| 507 | 507 | if (isset($HierarchyDelimiterCache[$_profileID])) |
| 508 | 508 | { |
| 509 | 509 | unset($HierarchyDelimiterCache[$_profileID]); |
| 510 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$HierarchyDelimiterCache, $expiration=60*60*24*5); |
|
| 510 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $HierarchyDelimiterCache, $expiration = 60 * 60 * 24 * 5); |
|
| 511 | 511 | } |
| 512 | 512 | //reset folderObject cache, to trigger reload |
| 513 | 513 | self::resetFolderObjectCache($_profileID); |
| 514 | 514 | //reset counter of deleted messages per folder |
| 515 | - $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 515 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 516 | 516 | if (isset($eMailListContainsDeletedMessages[$_profileID])) |
| 517 | 517 | { |
| 518 | 518 | unset($eMailListContainsDeletedMessages[$_profileID]); |
| 519 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$eMailListContainsDeletedMessages, $expiration=60*60*1); |
|
| 519 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $eMailListContainsDeletedMessages, $expiration = 60 * 60 * 1); |
|
| 520 | 520 | } |
| 521 | - $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*1); |
|
| 521 | + $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 1); |
|
| 522 | 522 | if (isset($vacationCached[$_profileID])) |
| 523 | 523 | { |
| 524 | 524 | unset($vacationCached[$_profileID]); |
| 525 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
|
| 525 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $vacationCached, $expiration = 60 * 60 * 24 * 1); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
@@ -530,17 +530,17 @@ discard block |
||
| 530 | 530 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 531 | 531 | { |
| 532 | 532 | // called via hook |
| 533 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account) |
|
| 533 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account) |
|
| 534 | 534 | { |
| 535 | 535 | //error_log(__METHOD__.__LINE__.array2string($account)); |
| 536 | 536 | $account_id = $account['account_id']; |
| 537 | 537 | $_profileID = null; |
| 538 | - self::resetConnectionErrorCache($_profileID,$account_id); |
|
| 539 | - self::resetFolderObjectCache($_profileID,$account_id); |
|
| 540 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),array(), 60*60*1); |
|
| 541 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),array(), 60*60*24*5); |
|
| 542 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),array(), 60*60*1); |
|
| 543 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),array(), 60*60*24*1); |
|
| 538 | + self::resetConnectionErrorCache($_profileID, $account_id); |
|
| 539 | + self::resetFolderObjectCache($_profileID, $account_id); |
|
| 540 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), array(), 60 * 60 * 1); |
|
| 541 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), array(), 60 * 60 * 24 * 5); |
|
| 542 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), array(), 60 * 60 * 1); |
|
| 543 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), array(), 60 * 60 * 24 * 1); |
|
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | } |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | * @param int $_ImapServerId the profileID to look for |
| 552 | 552 | * @param int $account_id the egw account to look for |
| 553 | 553 | */ |
| 554 | - static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
|
| 554 | + static function resetConnectionErrorCache($_ImapServerId = null, $account_id = null) |
|
| 555 | 555 | { |
| 556 | 556 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 557 | 557 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
@@ -569,19 +569,19 @@ discard block |
||
| 569 | 569 | } |
| 570 | 570 | else |
| 571 | 571 | { |
| 572 | - $isConError = Cache::getCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id)); |
|
| 572 | + $isConError = Cache::getCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id)); |
|
| 573 | 573 | if (isset($isConError[$_ImapServerId])) |
| 574 | 574 | { |
| 575 | 575 | unset($isConError[$_ImapServerId]); |
| 576 | 576 | } |
| 577 | - $waitOnFailure = Cache::getCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),null,array(),60*60*2); |
|
| 577 | + $waitOnFailure = Cache::getCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), null, array(), 60 * 60 * 2); |
|
| 578 | 578 | if (isset($waitOnFailure[$_ImapServerId])) |
| 579 | 579 | { |
| 580 | 580 | unset($waitOnFailure[$_ImapServerId]); |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | - Cache::setCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id),$isConError,60*15); |
|
| 584 | - Cache::setCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),$waitOnFailure,60*60*2); |
|
| 583 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id), $isConError, 60 * 15); |
|
| 584 | + Cache::setCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), $waitOnFailure, 60 * 60 * 2); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | /** |
@@ -590,13 +590,13 @@ discard block |
||
| 590 | 590 | * @param int $_ImapServerId the profileID to look for |
| 591 | 591 | * @param int $account_id the egw account to look for |
| 592 | 592 | */ |
| 593 | - static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
|
| 593 | + static function resetFolderObjectCache($_ImapServerId = null, $account_id = null) |
|
| 594 | 594 | { |
| 595 | 595 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 596 | 596 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
| 597 | 597 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 598 | 598 | // or treat it as not given. we try that path |
| 599 | - if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
|
| 599 | + if (is_null($_ImapServerId) || is_array($_ImapServerId)) |
|
| 600 | 600 | { |
| 601 | 601 | $folders2return = array(); |
| 602 | 602 | $folderInfo = array(); |
@@ -605,12 +605,12 @@ discard block |
||
| 605 | 605 | } |
| 606 | 606 | else |
| 607 | 607 | { |
| 608 | - $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),null,array(),60*60*1); |
|
| 608 | + $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 609 | 609 | if (!empty($folders2return) && isset($folders2return[$_ImapServerId])) |
| 610 | 610 | { |
| 611 | 611 | unset($folders2return[$_ImapServerId]); |
| 612 | 612 | } |
| 613 | - $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),null,array(),60*60*5); |
|
| 613 | + $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), null, array(), 60 * 60 * 5); |
|
| 614 | 614 | if (!empty($folderInfo) && isset($folderInfo[$_ImapServerId])) |
| 615 | 615 | { |
| 616 | 616 | unset($folderInfo[$_ImapServerId]); |
@@ -622,23 +622,23 @@ discard block |
||
| 622 | 622 | unset($lastFolderUsedForMove[$_ImapServerId]); |
| 623 | 623 | } |
| 624 | 624 | */ |
| 625 | - $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),null,array(),60*60*1); |
|
| 625 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 626 | 626 | if (!empty($folderBasicInfo) && isset($folderBasicInfo[$_ImapServerId])) |
| 627 | 627 | { |
| 628 | 628 | unset($folderBasicInfo[$_ImapServerId]); |
| 629 | 629 | } |
| 630 | - $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),null,array(),60*60*12); |
|
| 630 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), null, array(), 60 * 60 * 12); |
|
| 631 | 631 | if (!empty($_specialUseFolders) && isset($_specialUseFolders[$_ImapServerId])) |
| 632 | 632 | { |
| 633 | 633 | unset($_specialUseFolders[$_ImapServerId]); |
| 634 | - self::$specialUseFolders=null; |
|
| 634 | + self::$specialUseFolders = null; |
|
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),$folders2return, 60*60*1); |
|
| 638 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),$folderInfo,60*60*5); |
|
| 637 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), $folders2return, 60 * 60 * 1); |
|
| 638 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), $folderInfo, 60 * 60 * 5); |
|
| 639 | 639 | //Cache::setCache(Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($account_id),$lastFolderUsedForMove,$expiration=60*60*1); |
| 640 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),$folderBasicInfo,60*60*1); |
|
| 641 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),$_specialUseFolders,60*60*12); |
|
| 640 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), $folderBasicInfo, 60 * 60 * 1); |
|
| 641 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), $_specialUseFolders, 60 * 60 * 12); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -659,15 +659,15 @@ discard block |
||
| 659 | 659 | * @param string $_profileID the ID of the mailaccount to check for identities, if null current mail-account is used |
| 660 | 660 | * @return array - array(email=>realname) |
| 661 | 661 | */ |
| 662 | - function getUserEMailAddresses($_profileID=null) |
|
| 662 | + function getUserEMailAddresses($_profileID = null) |
|
| 663 | 663 | { |
| 664 | - $acc = Mail\Account::read((!empty($_profileID)?$_profileID:$this->profileID)); |
|
| 664 | + $acc = Mail\Account::read((!empty($_profileID) ? $_profileID : $this->profileID)); |
|
| 665 | 665 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($acc)); |
| 666 | 666 | $identities = Mail\Account::identities($acc); |
| 667 | 667 | |
| 668 | 668 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 669 | 669 | |
| 670 | - foreach($identities as $ik => $ident) { |
|
| 670 | + foreach ($identities as $ik => $ident) { |
|
| 671 | 671 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 672 | 672 | $identity = Mail\Account::read_identity($ik); |
| 673 | 673 | if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
@@ -682,19 +682,19 @@ discard block |
||
| 682 | 682 | * @param boolean $resolve_placeholders wether or not resolve possible placeholders in identities |
| 683 | 683 | * @return array - array(email=>realname) |
| 684 | 684 | */ |
| 685 | - static function getAllIdentities($_accountToSearch=null,$resolve_placeholders=false) |
|
| 685 | + static function getAllIdentities($_accountToSearch = null, $resolve_placeholders = false) |
|
| 686 | 686 | { |
| 687 | 687 | $userEMailAdresses = array(); |
| 688 | - foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
|
| 688 | + foreach (Mail\Account::search($only_current_user = ($_accountToSearch ? $_accountToSearch : true), $just_name = true) as $acc_id => $identity_name) |
|
| 689 | 689 | { |
| 690 | - $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
|
| 691 | - 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']); |
|
| 690 | + $acc = Mail\Account::read($acc_id, ($_accountToSearch ? $_accountToSearch : null)); |
|
| 691 | + 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']); |
|
| 692 | 692 | |
| 693 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 693 | + foreach (Mail\Account::identities($acc) as $ik => $ident) { |
|
| 694 | 694 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 695 | - $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
|
| 695 | + $identity = Mail\Account::read_identity($ik, $resolve_placeholders); |
|
| 696 | 696 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 697 | - 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']); |
|
| 697 | + 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']); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -714,9 +714,9 @@ discard block |
||
| 714 | 714 | $account = Mail\Account::read($account); |
| 715 | 715 | } |
| 716 | 716 | $userEMailAdresses = array(); |
| 717 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 717 | + foreach (Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 718 | 718 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 719 | - $identity = Mail\Account::read_identity($ik,true,null,$account); |
|
| 719 | + $identity = Mail\Account::read_identity($ik, true, null, $account); |
|
| 720 | 720 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 721 | 721 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 722 | 722 | if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
@@ -743,9 +743,9 @@ discard block |
||
| 743 | 743 | function getDefaultIdentity() |
| 744 | 744 | { |
| 745 | 745 | // retrieve the signature accociated with the identity |
| 746 | - $id = $this->getIdentitiesWithAccounts($_accountData=array()); |
|
| 747 | - foreach(Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 748 | - $this->profileID : $_accountData[$id],false,'ident_id') as $accountData) |
|
| 746 | + $id = $this->getIdentitiesWithAccounts($_accountData = array()); |
|
| 747 | + foreach (Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 748 | + $this->profileID : $_accountData[$id], false, 'ident_id') as $accountData) |
|
| 749 | 749 | { |
| 750 | 750 | return $accountData; |
| 751 | 751 | } |
@@ -761,13 +761,13 @@ discard block |
||
| 761 | 761 | { |
| 762 | 762 | // account select box |
| 763 | 763 | $selectedID = $this->profileID; |
| 764 | - $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
|
| 764 | + $allAccountData = Mail\Account::search($only_current_user = true, false, null); |
|
| 765 | 765 | if ($allAccountData) { |
| 766 | - $rememberFirst=$selectedFound=null; |
|
| 766 | + $rememberFirst = $selectedFound = null; |
|
| 767 | 767 | foreach ($allAccountData as $tmpkey => $icServers) |
| 768 | 768 | { |
| 769 | 769 | if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
| 770 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 770 | + if ($tmpkey == $selectedID) $selectedFound = true; |
|
| 771 | 771 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 772 | 772 | $host = $icServers->acc_imap_host; |
| 773 | 773 | if (empty($host)) continue; |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | - return ($selectedFound?$selectedID:$rememberFirst); |
|
| 778 | + return ($selectedFound ? $selectedID : $rememberFirst); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | * @var boolean $fullString full or false=NamePart only is returned |
| 786 | 786 | * @return string - constructed of identity object data as defined in mailConfig |
| 787 | 787 | */ |
| 788 | - static function generateIdentityString($identity, $fullString=true) |
|
| 788 | + static function generateIdentityString($identity, $fullString = true) |
|
| 789 | 789 | { |
| 790 | 790 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity)); |
| 791 | 791 | //if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
@@ -796,16 +796,16 @@ discard block |
||
| 796 | 796 | { |
| 797 | 797 | case 'email'; |
| 798 | 798 | //$retData = str_replace('@',' ',$identity->emailAddress).($fullString===true?' <'.$identity->emailAddress.'>':''); |
| 799 | - $retData = $identity['ident_email'].($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 799 | + $retData = $identity['ident_email'].($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 800 | 800 | break; |
| 801 | 801 | case 'nameNemail'; |
| 802 | - $retData = (!empty($identity['ident_realname'])?$identity['ident_realname']:substr_replace($identity['ident_email'],'',strpos($identity['ident_email'],'@'))).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 802 | + $retData = (!empty($identity['ident_realname']) ? $identity['ident_realname'] : substr_replace($identity['ident_email'], '', strpos($identity['ident_email'], '@'))).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 803 | 803 | break; |
| 804 | 804 | case 'orgNemail'; |
| 805 | - $retData = (!empty($identity['ident_org'])?$identity['ident_org']:substr_replace($identity['ident_email'],'',0,strpos($identity['ident_email'],'@')+1)).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 805 | + $retData = (!empty($identity['ident_org']) ? $identity['ident_org'] : substr_replace($identity['ident_email'], '', 0, strpos($identity['ident_email'], '@') + 1)).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 806 | 806 | break; |
| 807 | 807 | default: |
| 808 | - $retData = $identity['ident_realname'].(!empty($identity['ident_org'])?' '.$identity['ident_org']:'').($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 808 | + $retData = $identity['ident_realname'].(!empty($identity['ident_org']) ? ' '.$identity['ident_org'] : '').($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 809 | 809 | } |
| 810 | 810 | return $retData; |
| 811 | 811 | } |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | */ |
| 831 | 831 | function reopen($_foldername) |
| 832 | 832 | { |
| 833 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 833 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 834 | 834 | |
| 835 | 835 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 836 | 836 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | } |
| 846 | 846 | $folderOpened = $_foldername; |
| 847 | 847 | //} |
| 848 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 848 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'Folder:'.$_foldername, __METHOD__.' ('.__LINE__.') '); |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | |
@@ -856,15 +856,15 @@ discard block |
||
| 856 | 856 | * @throws Horde_Imap_Client_Exception on connection error or authentication failure |
| 857 | 857 | * @throws InvalidArgumentException on missing credentials |
| 858 | 858 | */ |
| 859 | - function openConnection($_icServerID=0) |
|
| 859 | + function openConnection($_icServerID = 0) |
|
| 860 | 860 | { |
| 861 | 861 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 862 | 862 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 863 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 864 | - $mailbox=null; |
|
| 863 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 864 | + $mailbox = null; |
|
| 865 | 865 | try |
| 866 | 866 | { |
| 867 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 867 | + if (isset($this->sessionData['mailbox']) && $this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 868 | 868 | if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
| 869 | 869 | /* |
| 870 | 870 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 892 | 892 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 893 | 893 | } |
| 894 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 894 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'ProfileID:'.$_icServerID, __METHOD__.' ('.__LINE__.') '); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | /** |
@@ -905,13 +905,13 @@ discard block |
||
| 905 | 905 | static $quota; |
| 906 | 906 | if (isset($quota)) return $quota; |
| 907 | 907 | $this->icServer->getCurrentMailbox(); |
| 908 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 908 | + if (!$this->icServer->hasCapability('QUOTA')) { |
|
| 909 | 909 | $quota = false; |
| 910 | 910 | return false; |
| 911 | 911 | } |
| 912 | 912 | $quota = $this->icServer->getStorageQuotaRoot('INBOX'); |
| 913 | 913 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 914 | - if(is_array($quota)) { |
|
| 914 | + if (is_array($quota)) { |
|
| 915 | 915 | $quota = array( |
| 916 | 916 | 'usage' => $quota['USED'], |
| 917 | 917 | 'limit' => $quota['QMAX'], |
@@ -929,10 +929,10 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @return int - timeout (either set or default 20/10) |
| 931 | 931 | */ |
| 932 | - static function getTimeOut($_use='IMAP') |
|
| 932 | + static function getTimeOut($_use = 'IMAP') |
|
| 933 | 933 | { |
| 934 | 934 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 935 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 935 | + if (empty($timeout)) $timeout = ($_use == 'SIEVE' ? 10 : 20); // this is the default value |
|
| 936 | 936 | return $timeout; |
| 937 | 937 | } |
| 938 | 938 | |
@@ -953,18 +953,18 @@ discard block |
||
| 953 | 953 | if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
| 954 | 954 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 955 | 955 | if (is_array($nameSpace)) { |
| 956 | - foreach($nameSpace as $type => $singleNameSpaceArray) |
|
| 956 | + foreach ($nameSpace as $type => $singleNameSpaceArray) |
|
| 957 | 957 | { |
| 958 | 958 | foreach ($singleNameSpaceArray as $singleNameSpace) |
| 959 | 959 | { |
| 960 | 960 | $_foldersNameSpace = array(); |
| 961 | - if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) |
|
| 961 | + if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX'))) |
|
| 962 | 962 | { |
| 963 | 963 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 964 | 964 | // uw-imap server with mailbox prefix or dovecot maybe |
| 965 | - $_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:'')); |
|
| 965 | + $_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : '')); |
|
| 966 | 966 | } |
| 967 | - elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 967 | + elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 968 | 968 | { |
| 969 | 969 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 970 | 970 | // uw-imap server with mailbox prefix or dovecot maybe |
@@ -973,9 +973,9 @@ discard block |
||
| 973 | 973 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 974 | 974 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 975 | 975 | } |
| 976 | - $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter); |
|
| 976 | + $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter); |
|
| 977 | 977 | $_foldersNameSpace['type'] = $type; |
| 978 | - $foldersNameSpace[] =$_foldersNameSpace; |
|
| 978 | + $foldersNameSpace[] = $_foldersNameSpace; |
|
| 979 | 979 | } |
| 980 | 980 | //echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>"; |
| 981 | 981 | } |
@@ -993,10 +993,10 @@ discard block |
||
| 993 | 993 | */ |
| 994 | 994 | function getFolderPrefixFromNamespace($nameSpace, $folderName) |
| 995 | 995 | { |
| 996 | - foreach($nameSpace as &$singleNameSpace) |
|
| 996 | + foreach ($nameSpace as &$singleNameSpace) |
|
| 997 | 997 | { |
| 998 | 998 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 999 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 999 | + if (substr($folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1000 | 1000 | } |
| 1001 | 1001 | return ""; |
| 1002 | 1002 | } |
@@ -1007,12 +1007,12 @@ discard block |
||
| 1007 | 1007 | * @var boolean $_useCache |
| 1008 | 1008 | * @return string the hierarchyDelimiter |
| 1009 | 1009 | */ |
| 1010 | - function getHierarchyDelimiter($_useCache=true) |
|
| 1010 | + function getHierarchyDelimiter($_useCache = true) |
|
| 1011 | 1011 | { |
| 1012 | 1012 | static $HierarchyDelimiter = null; |
| 1013 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1014 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1015 | - if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1013 | + if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5); |
|
| 1014 | + if ($_useCache === false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1015 | + if (isset($HierarchyDelimiter[$this->icServer->ImapServerId]) && !empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1016 | 1016 | { |
| 1017 | 1017 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1018 | 1018 | } |
@@ -1022,12 +1022,12 @@ discard block |
||
| 1022 | 1022 | $this->icServer->getCurrentMailbox(); |
| 1023 | 1023 | $HierarchyDelimiter[$this->icServer->ImapServerId] = $this->icServer->getDelimiter(); |
| 1024 | 1024 | } |
| 1025 | - catch(\Exception $e) |
|
| 1025 | + catch (\Exception $e) |
|
| 1026 | 1026 | { |
| 1027 | 1027 | unset($e); |
| 1028 | 1028 | $HierarchyDelimiter[$this->icServer->ImapServerId] = '/'; |
| 1029 | 1029 | } |
| 1030 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$HierarchyDelimiter, 60*60*24*5); |
|
| 1030 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), $HierarchyDelimiter, 60 * 60 * 24 * 5); |
|
| 1031 | 1031 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | { |
| 1041 | 1041 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1042 | 1042 | static $_specialUseFolders = null; |
| 1043 | - 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); |
|
| 1043 | + 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); |
|
| 1044 | 1044 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1045 | 1045 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1046 | 1046 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
@@ -1048,20 +1048,20 @@ discard block |
||
| 1048 | 1048 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1049 | 1049 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1050 | 1050 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1051 | - $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
|
| 1051 | + $_specialUseFolders[$this->icServer->ImapServerId] = array(); |
|
| 1052 | 1052 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1053 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
|
| 1053 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash] = 'Trash'; |
|
| 1054 | 1054 | //if (!empty($this->icServer->acc_folder_draft) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft])) |
| 1055 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts'; |
|
| 1055 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft] = 'Drafts'; |
|
| 1056 | 1056 | //if (!empty($this->icServer->acc_folder_sent) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent])) |
| 1057 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent'; |
|
| 1057 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent] = 'Sent'; |
|
| 1058 | 1058 | //if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template])) |
| 1059 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates'; |
|
| 1060 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk'; |
|
| 1061 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive]='Archive'; |
|
| 1059 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template] = 'Templates'; |
|
| 1060 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk] = 'Junk'; |
|
| 1061 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive] = 'Archive'; |
|
| 1062 | 1062 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer)); |
| 1063 | 1063 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1064 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5); |
|
| 1064 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $_specialUseFolders, 60 * 60 * 24 * 5); |
|
| 1065 | 1065 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
@@ -1075,8 +1075,8 @@ discard block |
||
| 1075 | 1075 | function folderIsSelectable($folderToSelect) |
| 1076 | 1076 | { |
| 1077 | 1077 | $retval = true; |
| 1078 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1079 | - if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
|
| 1078 | + if ($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect, false, true))) { |
|
| 1079 | + if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']), 'noselect') !== false) |
|
| 1080 | 1080 | { |
| 1081 | 1081 | $retval = false; |
| 1082 | 1082 | } |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | * |
| 1097 | 1097 | * @throws Exception |
| 1098 | 1098 | */ |
| 1099 | - function _getStatus($folderName,$ignoreStatusCache=false) |
|
| 1099 | + function _getStatus($folderName, $ignoreStatusCache = false) |
|
| 1100 | 1100 | { |
| 1101 | 1101 | static $folderStatus = null; |
| 1102 | 1102 | if (!$ignoreStatusCache && isset($folderStatus[$this->icServer->ImapServerId][$folderName])) |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | } |
| 1107 | 1107 | try |
| 1108 | 1108 | { |
| 1109 | - $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName,$ignoreStatusCache); |
|
| 1109 | + $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName, $ignoreStatusCache); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | catch (\Exception $e) |
| 1112 | 1112 | { |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | * @param fetchSubscribedInfo bool fetch Subscribed Info on folder |
| 1127 | 1127 | * @return array |
| 1128 | 1128 | */ |
| 1129 | - function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
|
| 1129 | + function getFolderStatus($_folderName, $ignoreStatusCache = false, $basicInfoOnly = false, $fetchSubscribedInfo = true) |
|
| 1130 | 1130 | { |
| 1131 | 1131 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
| 1132 | 1132 | if (!is_string($_folderName) || empty($_folderName)) // something is wrong. Do not proceed |
@@ -1139,7 +1139,7 @@ discard block |
||
| 1139 | 1139 | { |
| 1140 | 1140 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1141 | 1141 | } |
| 1142 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1142 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache == false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1143 | 1143 | $retValue = array(); |
| 1144 | 1144 | $retValue['subscribed'] = false; |
| 1145 | 1145 | /* |
@@ -1157,28 +1157,28 @@ discard block |
||
| 1157 | 1157 | if (is_array($ret)) |
| 1158 | 1158 | { |
| 1159 | 1159 | $retkeys = array_keys($ret); |
| 1160 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1160 | + if ($retkeys[0] == $_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | else |
| 1163 | 1163 | { |
| 1164 | - $folderInfoCache[$_folderName]=false; |
|
| 1164 | + $folderInfoCache[$_folderName] = false; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | } |
| 1167 | 1167 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1168 | 1168 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1169 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1169 | + if ($ignoreStatusCache || !$folderInfo || !is_array($folderInfo)) { |
|
| 1170 | 1170 | try |
| 1171 | 1171 | { |
| 1172 | - $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
|
| 1172 | + $folderInfo = $this->_getStatus($_folderName, $ignoreStatusCache); |
|
| 1173 | 1173 | } |
| 1174 | 1174 | catch (\Exception $e) |
| 1175 | 1175 | { |
| 1176 | - $folderInfo=null; |
|
| 1176 | + $folderInfo = null; |
|
| 1177 | 1177 | } |
| 1178 | 1178 | if (!is_array($folderInfo)) |
| 1179 | 1179 | { |
| 1180 | 1180 | // no folder info, but there is a status returned for the folder: something is wrong, try to cope with it |
| 1181 | - $folderInfo = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1181 | + $folderInfo = is_array($folderInfo) ? $folderInfo : array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1182 | 1182 | 'ATTRIBUTES' => ''); |
| 1183 | 1183 | if (!isset($folderInfo['HIERACHY_DELIMITER']) || empty($folderInfo['HIERACHY_DELIMITER']) || (isset($folderInfo['delimiter']) && empty($folderInfo['delimiter']))) |
| 1184 | 1184 | { |
@@ -1190,24 +1190,24 @@ discard block |
||
| 1190 | 1190 | #if(!is_array($folderInfo)) { |
| 1191 | 1191 | # return false; |
| 1192 | 1192 | #} |
| 1193 | - $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER']?$folderInfo['HIERACHY_DELIMITER']:$folderInfo['delimiter']); |
|
| 1194 | - $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES']?$folderInfo['ATTRIBUTES']:$folderInfo['attributes']); |
|
| 1195 | - $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1193 | + $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER'] ? $folderInfo['HIERACHY_DELIMITER'] : $folderInfo['delimiter']); |
|
| 1194 | + $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES'] ? $folderInfo['ATTRIBUTES'] : $folderInfo['attributes']); |
|
| 1195 | + $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1196 | 1196 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1197 | 1197 | $retValue['displayName'] = $_folderName; |
| 1198 | - $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1199 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1200 | - $retValue['displayName'] = lang('INBOX'); |
|
| 1201 | - $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1198 | + $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1199 | + if (strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1200 | + $retValue['displayName'] = lang('INBOX'); |
|
| 1201 | + $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 1204 | - elseif (in_array($retValue['shortName'],self::$autoFolders)) |
|
| 1204 | + elseif (in_array($retValue['shortName'], self::$autoFolders)) |
|
| 1205 | 1205 | { |
| 1206 | 1206 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1207 | 1207 | } |
| 1208 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1208 | + if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName] = $retValue; |
|
| 1209 | 1209 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1210 | - if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
|
| 1210 | + if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']), 'noselect') !== false)) |
|
| 1211 | 1211 | { |
| 1212 | 1212 | return $retValue; |
| 1213 | 1213 | } |
@@ -1220,12 +1220,12 @@ discard block |
||
| 1220 | 1220 | if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
| 1221 | 1221 | if (!empty($nameSpace[$this->profileID])) |
| 1222 | 1222 | { |
| 1223 | - $nsNoPersonal=array(); |
|
| 1224 | - foreach($nameSpace[$this->profileID] as &$ns) |
|
| 1223 | + $nsNoPersonal = array(); |
|
| 1224 | + foreach ($nameSpace[$this->profileID] as &$ns) |
|
| 1225 | 1225 | { |
| 1226 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1226 | + if ($ns['type'] != 'personal') $nsNoPersonal[] = $ns; |
|
| 1227 | 1227 | } |
| 1228 | - $nameSpace[$this->profileID]=$nsNoPersonal; |
|
| 1228 | + $nameSpace[$this->profileID] = $nsNoPersonal; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
| 1231 | 1231 | |
@@ -1234,32 +1234,32 @@ discard block |
||
| 1234 | 1234 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1237 | + if ($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName, $subscribedFolders[$this->profileID])) { |
|
| 1238 | 1238 | $retValue['subscribed'] = true; |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | try |
| 1242 | 1242 | { |
| 1243 | 1243 | //$folderStatus = $this->_getStatus($_folderName,$ignoreStatusCache); |
| 1244 | - $folderStatus = $this->getMailBoxCounters($_folderName,false); |
|
| 1245 | - $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1244 | + $folderStatus = $this->getMailBoxCounters($_folderName, false); |
|
| 1245 | + $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1246 | 1246 | $retValue['recent'] = $folderStatus['RECENT']; |
| 1247 | - $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1248 | - $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1247 | + $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1248 | + $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1249 | 1249 | $retValue['unseen'] = $folderStatus['UNSEEN']; |
| 1250 | 1250 | if (//$retValue['unseen']==0 && |
| 1251 | 1251 | (isset($this->mailPreferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information |
| 1252 | - $this->mailPreferences['trustServersUnseenInfo']==false) || |
|
| 1252 | + $this->mailPreferences['trustServersUnseenInfo'] == false) || |
|
| 1253 | 1253 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1254 | - $this->mailPreferences['trustServersUnseenInfo']==2 && |
|
| 1255 | - $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
|
| 1254 | + $this->mailPreferences['trustServersUnseenInfo'] == 2 && |
|
| 1255 | + $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName, $prefix[$this->profileID][$_folderName]) !== false) |
|
| 1256 | 1256 | ) |
| 1257 | 1257 | { |
| 1258 | 1258 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1259 | 1259 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1260 | 1260 | try |
| 1261 | 1261 | { |
| 1262 | - $sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse=1, array('status'=>array('UNSEEN','UNDELETED')),$byUid=true,false); |
|
| 1262 | + $sortResult = $this->getSortedList($_folderName, $_sort = 0, $_reverse = 1, array('status'=>array('UNSEEN', 'UNDELETED')), $byUid = true, false); |
|
| 1263 | 1263 | $retValue['unseen'] = $sortResult['count']; |
| 1264 | 1264 | } |
| 1265 | 1265 | catch (\Exception $ee) |
@@ -1270,7 +1270,7 @@ discard block |
||
| 1270 | 1270 | } |
| 1271 | 1271 | catch (\Exception $e) |
| 1272 | 1272 | { |
| 1273 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1273 | + if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(), true)); |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | 1276 | return $retValue; |
@@ -1292,7 +1292,7 @@ discard block |
||
| 1292 | 1292 | * @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)) |
| 1293 | 1293 | * @return array result as array(header=>array,total=>int,first=>int,last=>int) |
| 1294 | 1294 | */ |
| 1295 | - function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
|
| 1295 | + function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly = null, $_cacheResult = true, $_fetchPreviews = false) |
|
| 1296 | 1296 | { |
| 1297 | 1297 | //self::$debug=true; |
| 1298 | 1298 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
@@ -1305,7 +1305,7 @@ discard block |
||
| 1305 | 1305 | $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 |
| 1306 | 1306 | #print "<pre>"; |
| 1307 | 1307 | #$this->icServer->setDebug(true); |
| 1308 | - $total=0; |
|
| 1308 | + $total = 0; |
|
| 1309 | 1309 | if ($_thisUIDOnly === null) |
| 1310 | 1310 | { |
| 1311 | 1311 | if (($_startMessage || $_numberOfMessages) && !isset($_filter['range'])) |
@@ -1318,24 +1318,24 @@ discard block |
||
| 1318 | 1318 | //$_filter['range'] ="$_startMessage:*"; |
| 1319 | 1319 | } |
| 1320 | 1320 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
| 1321 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1321 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1322 | 1322 | //see this example below for a 12 week datefilter (since) |
| 1323 | 1323 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1324 | 1324 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1325 | 1325 | $sortResult = $_sortResult['match']->ids; |
| 1326 | 1326 | //$modseq = $_sortResult['modseq']; |
| 1327 | 1327 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1328 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1328 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly), __METHOD__.' ('.__LINE__.') '); |
|
| 1329 | 1329 | |
| 1330 | 1330 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1331 | 1331 | #$this->icServer->setDebug(false); |
| 1332 | 1332 | #print "</pre>"; |
| 1333 | 1333 | // nothing found |
| 1334 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1334 | + if (!is_array($sortResult) || empty($sortResult)) { |
|
| 1335 | 1335 | $retValue = array(); |
| 1336 | 1336 | $retValue['info']['total'] = 0; |
| 1337 | 1337 | $retValue['info']['first'] = 0; |
| 1338 | - $retValue['info']['last'] = 0; |
|
| 1338 | + $retValue['info']['last'] = 0; |
|
| 1339 | 1339 | return $retValue; |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -1343,54 +1343,54 @@ discard block |
||
| 1343 | 1343 | #_debug_array($sortResult); |
| 1344 | 1344 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1345 | 1345 | //error_log("REVERSE: $reverse"); |
| 1346 | - if($reverse === true) { |
|
| 1347 | - if ($_startMessage<=$total) |
|
| 1346 | + if ($reverse === true) { |
|
| 1347 | + if ($_startMessage <= $total) |
|
| 1348 | 1348 | { |
| 1349 | - $startMessage = $_startMessage-1; |
|
| 1349 | + $startMessage = $_startMessage - 1; |
|
| 1350 | 1350 | } |
| 1351 | 1351 | else |
| 1352 | 1352 | { |
| 1353 | 1353 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1354 | - if ($_startMessage+$_numberOfMessages>$total) |
|
| 1354 | + if ($_startMessage + $_numberOfMessages > $total) |
|
| 1355 | 1355 | { |
| 1356 | - $numberOfMessages = $total%$_numberOfMessages; |
|
| 1356 | + $numberOfMessages = $total % $_numberOfMessages; |
|
| 1357 | 1357 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1358 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1358 | + if ($numberOfMessages > 0 && $numberOfMessages <= $_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1359 | 1359 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1360 | 1360 | } |
| 1361 | - $startMessage=($total-$_numberOfMessages)-1; |
|
| 1361 | + $startMessage = ($total - $_numberOfMessages) - 1; |
|
| 1362 | 1362 | //$retValue['info']['first'] = $startMessage; |
| 1363 | 1363 | //$retValue['info']['last'] = $total; |
| 1364 | 1364 | |
| 1365 | 1365 | } |
| 1366 | - if ($startMessage+$_numberOfMessages>$total) |
|
| 1366 | + if ($startMessage + $_numberOfMessages > $total) |
|
| 1367 | 1367 | { |
| 1368 | - $_numberOfMessages = $_numberOfMessages-($total-($startMessage+$_numberOfMessages)); |
|
| 1368 | + $_numberOfMessages = $_numberOfMessages - ($total - ($startMessage + $_numberOfMessages)); |
|
| 1369 | 1369 | //$retValue['info']['first'] = $startMessage; |
| 1370 | 1370 | //$retValue['info']['last'] = $total; |
| 1371 | 1371 | } |
| 1372 | - if($startMessage > 0) { |
|
| 1373 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1374 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
|
| 1372 | + if ($startMessage > 0) { |
|
| 1373 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + $startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1374 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + $startMessage), -$startMessage); |
|
| 1375 | 1375 | } else { |
| 1376 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1377 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
|
| 1376 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + ($_startMessage - 1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1377 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + ($_startMessage - 1))); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | $sortResult = array_reverse($sortResult); |
| 1380 | 1380 | } else { |
| 1381 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1382 | - $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
|
| 1381 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage - 1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1382 | + $sortResult = array_slice($sortResult, $_startMessage - 1, $_numberOfMessages); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1385 | 1385 | } |
| 1386 | 1386 | else |
| 1387 | 1387 | { |
| 1388 | - $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly:(array)$_thisUIDOnly); |
|
| 1388 | + $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly : (array)$_thisUIDOnly); |
|
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | 1391 | |
| 1392 | 1392 | // fetch the data for the selected messages |
| 1393 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1393 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1394 | 1394 | try |
| 1395 | 1395 | { |
| 1396 | 1396 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1399,22 +1399,22 @@ discard block |
||
| 1399 | 1399 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 1400 | 1400 | |
| 1401 | 1401 | // Pre-cache the headers we want, 'fetchHeaders' is a label into the cache |
| 1402 | - $fquery->headers('fetchHeaders',array( |
|
| 1403 | - 'DISPOSITION-NOTIFICATION-TO','RETURN-RECEIPT-TO','X-CONFIRM-READING-TO', |
|
| 1404 | - 'DATE','SUBJECT','FROM','TO','CC', |
|
| 1402 | + $fquery->headers('fetchHeaders', array( |
|
| 1403 | + 'DISPOSITION-NOTIFICATION-TO', 'RETURN-RECEIPT-TO', 'X-CONFIRM-READING-TO', |
|
| 1404 | + 'DATE', 'SUBJECT', 'FROM', 'TO', 'CC', |
|
| 1405 | 1405 | 'X-PRIORITY' |
| 1406 | - ),array( |
|
| 1406 | + ), array( |
|
| 1407 | 1407 | // Cache headers, we'll look at them below |
| 1408 | - 'cache' => true,//$_cacheResult, |
|
| 1408 | + 'cache' => true, //$_cacheResult, |
|
| 1409 | 1409 | // Set peek so messages are not flagged as read |
| 1410 | 1410 | 'peek' => true |
| 1411 | 1411 | )); |
| 1412 | 1412 | $fquery->size(); |
| 1413 | 1413 | $fquery->structure(); |
| 1414 | 1414 | $fquery->flags(); |
| 1415 | - $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1415 | + $fquery->imapDate(); // needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1416 | 1416 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1417 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1417 | + if ($_fetchPreviews) $fquery->fullText(array('peek'=>true, 'length'=>((int)$_fetchPreviews < 5000 ? 5000 : $_fetchPreviews), 'start'=>0)); |
|
| 1418 | 1418 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1419 | 1419 | 'ids' => $uidsToFetch, |
| 1420 | 1420 | )); |
@@ -1425,9 +1425,9 @@ discard block |
||
| 1425 | 1425 | $headersNew = array(); |
| 1426 | 1426 | $sortResult = array(); |
| 1427 | 1427 | } |
| 1428 | - if (self::$debug||self::$debugTimes) |
|
| 1428 | + if (self::$debug || self::$debugTimes) |
|
| 1429 | 1429 | { |
| 1430 | - self::logRunTimes($starttime,null,'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter),__METHOD__.' ('.__LINE__.') '); |
|
| 1430 | + self::logRunTimes($starttime, null, 'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter), __METHOD__.' ('.__LINE__.') '); |
|
| 1431 | 1431 | if (self::$debug) |
| 1432 | 1432 | { |
| 1433 | 1433 | $queryString = implode(',', $sortResult); |
@@ -1437,27 +1437,27 @@ discard block |
||
| 1437 | 1437 | |
| 1438 | 1438 | $cnt = 0; |
| 1439 | 1439 | |
| 1440 | - foreach((array)$sortResult as $uid) { |
|
| 1440 | + foreach ((array)$sortResult as $uid) { |
|
| 1441 | 1441 | $sortOrder[$uid] = $cnt++; |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | $count = 0; |
| 1445 | 1445 | if (is_object($headersNew)) { |
| 1446 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1447 | - foreach($headersNew->ids() as $id) { |
|
| 1446 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1447 | + foreach ($headersNew->ids() as $id) { |
|
| 1448 | 1448 | $_headerObject = $headersNew->get($id); |
| 1449 | 1449 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1450 | 1450 | $headerObject = array(); |
| 1451 | 1451 | $bodyPreview = null; |
| 1452 | - $uid = $headerObject['UID']= ($_headerObject->getUid()?$_headerObject->getUid():$id); |
|
| 1452 | + $uid = $headerObject['UID'] = ($_headerObject->getUid() ? $_headerObject->getUid() : $id); |
|
| 1453 | 1453 | $headerObject['MSG_NUM'] = $_headerObject->getSeq(); |
| 1454 | 1454 | $headerObject['SIZE'] = $_headerObject->getSize(); |
| 1455 | 1455 | $headerObject['INTERNALDATE'] = $_headerObject->getImapDate(); |
| 1456 | 1456 | |
| 1457 | 1457 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1458 | - $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1458 | + $headerForPrio = $_headerObject->getHeaders('fetchHeaders', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1459 | 1459 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1460 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1460 | + if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1461 | 1461 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1462 | 1462 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1463 | 1463 | if ($_fetchPreviews) |
@@ -1465,16 +1465,16 @@ discard block |
||
| 1465 | 1465 | // on enabled preview $bodyPreview is needed lateron. fetched here, for fallback-reasons |
| 1466 | 1466 | // in case of failed Header-Retrieval |
| 1467 | 1467 | $bodyPreview = $_headerObject->getFullMsg(); |
| 1468 | - if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
|
| 1468 | + if (empty($headerForPrio) || (is_array($headerForPrio) && count($headerForPrio) === 1 && $headerForPrio[''])) |
|
| 1469 | 1469 | { |
| 1470 | 1470 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1471 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1472 | - $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
|
| 1471 | + if ($length === false) $length = strlen($bodyPreview); |
|
| 1472 | + $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0, $length))->toArray(); |
|
| 1473 | 1473 | } |
| 1474 | 1474 | } |
| 1475 | 1475 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1476 | 1476 | if (self::$debug) { |
| 1477 | - 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')); |
|
| 1477 | + 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')); |
|
| 1478 | 1478 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1479 | 1479 | } |
| 1480 | 1480 | // message deleted from server but cache still reporting its existence ; may happen on QRESYNC with No permanent modsequences |
@@ -1483,21 +1483,21 @@ discard block |
||
| 1483 | 1483 | $total--; |
| 1484 | 1484 | continue; |
| 1485 | 1485 | } |
| 1486 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1486 | + if (isset($headerForPrio['DISPOSITION-NOTIFICATION-TO'])) { |
|
| 1487 | 1487 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1488 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1488 | + } else if (isset($headerForPrio['RETURN-RECEIPT-TO'])) { |
|
| 1489 | 1489 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1490 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1490 | + } else if (isset($headerForPrio['X-CONFIRM-READING-TO'])) { |
|
| 1491 | 1491 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1492 | 1492 | } /*else $sent_not = "";*/ |
| 1493 | 1493 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1494 | 1494 | $headerObject['DATE'] = $headerForPrio['DATE']; |
| 1495 | - $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT'])?$headerForPrio['SUBJECT'][0]:$headerForPrio['SUBJECT']); |
|
| 1496 | - $headerObject['FROM'] = (array)($headerForPrio['FROM']?$headerForPrio['FROM']:($headerForPrio['REPLY-TO']?$headerForPrio['REPLY-TO']:$headerForPrio['RETURN-PATH'])); |
|
| 1495 | + $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT']) ? $headerForPrio['SUBJECT'][0] : $headerForPrio['SUBJECT']); |
|
| 1496 | + $headerObject['FROM'] = (array)($headerForPrio['FROM'] ? $headerForPrio['FROM'] : ($headerForPrio['REPLY-TO'] ? $headerForPrio['REPLY-TO'] : $headerForPrio['RETURN-PATH'])); |
|
| 1497 | 1497 | $headerObject['TO'] = (array)$headerForPrio['TO']; |
| 1498 | - $headerObject['CC'] = isset($headerForPrio['CC'])?(array)$headerForPrio['CC']:array(); |
|
| 1499 | - $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY'])?$headerForPrio['X-PRIORITY']:null; |
|
| 1500 | - foreach (array('FROM','TO','CC') as $key) |
|
| 1498 | + $headerObject['CC'] = isset($headerForPrio['CC']) ? (array)$headerForPrio['CC'] : array(); |
|
| 1499 | + $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY']) ? $headerForPrio['X-PRIORITY'] : null; |
|
| 1500 | + foreach (array('FROM', 'TO', 'CC') as $key) |
|
| 1501 | 1501 | { |
| 1502 | 1502 | $address = array(); |
| 1503 | 1503 | foreach ($headerObject[$key] as $k => $ad) |
@@ -1519,13 +1519,13 @@ discard block |
||
| 1519 | 1519 | foreach ($rfcAddr as $_rfcAddr) |
| 1520 | 1520 | { |
| 1521 | 1521 | if (!$_rfcAddr->valid) continue; // skip. not a valid address |
| 1522 | - $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
|
| 1522 | + $address[] = imap_rfc822_write_address($_rfcAddr->mailbox, $_rfcAddr->host, $_rfcAddr->personal); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | } |
| 1525 | 1525 | $headerObject[$key] = $address; |
| 1526 | 1526 | } |
| 1527 | 1527 | $headerObject['FLAGS'] = $_headerObject->getFlags(); |
| 1528 | - $headerObject['BODYPREVIEW']=null; |
|
| 1528 | + $headerObject['BODYPREVIEW'] = null; |
|
| 1529 | 1529 | // this section fetches part of the message-body (if enabled) for some kind of preview |
| 1530 | 1530 | // if we fail to succeed, we fall back to the retrieval of the message-body with |
| 1531 | 1531 | // fetchPartContents (see below, when we iterate over the structure to determine the |
@@ -1537,17 +1537,17 @@ discard block |
||
| 1537 | 1537 | if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
| 1538 | 1538 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1539 | 1539 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1540 | - foreach($base->partIterator() as $part) |
|
| 1540 | + foreach ($base->partIterator() as $part) |
|
| 1541 | 1541 | { |
| 1542 | 1542 | //error_log(__METHOD__.__LINE__.'Part:'.$part->getPrimaryType()); |
| 1543 | - if (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'text') |
|
| 1543 | + if (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'text') |
|
| 1544 | 1544 | { |
| 1545 | 1545 | $charset = $part->getContentTypeParameter('charset'); |
| 1546 | 1546 | $buffer = Mail\Html::convertHTMLToText($part->toString(array( |
| 1547 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1547 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1548 | 1548 | )), $charset, 'utf-8'); |
| 1549 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1550 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1549 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Translation::convert_jsonsafe($buffer), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1550 | + } elseif (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'multipart') |
|
| 1551 | 1551 | { |
| 1552 | 1552 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1553 | 1553 | } |
@@ -1558,12 +1558,12 @@ discard block |
||
| 1558 | 1558 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1559 | 1559 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeMap:'.array2string($mailStructureObject->contentTypeMap())); |
| 1560 | 1560 | //foreach ($_headerObject->getStructure()->getParts() as $p => $part) |
| 1561 | - $headerObject['ATTACHMENTS']=null; |
|
| 1562 | - $skipParts=array(); |
|
| 1563 | - $messageMimeType=''; |
|
| 1561 | + $headerObject['ATTACHMENTS'] = null; |
|
| 1562 | + $skipParts = array(); |
|
| 1563 | + $messageMimeType = ''; |
|
| 1564 | 1564 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1565 | 1565 | { |
| 1566 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1566 | + if ($mime_id == 0 || $messageMimeType === '') $messageMimeType = $mime_type; |
|
| 1567 | 1567 | $part = $mailStructureObject->getPart($mime_id); |
| 1568 | 1568 | $partdisposition = $part->getDisposition(); |
| 1569 | 1569 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1571,16 +1571,16 @@ discard block |
||
| 1571 | 1571 | // drawback here it is talking to the mailserver for each mail thus consuming |
| 1572 | 1572 | // more time than expected; so we call this section only when there is no |
| 1573 | 1573 | // bodypreview could be found (multipart/....) |
| 1574 | - if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
|
| 1574 | + if ($_fetchPreviews && empty($headerObject['BODYPREVIEW']) && ($partPrimaryType == 'text') && |
|
| 1575 | 1575 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1576 | 1576 | ($partdisposition !== 'attachment')) { |
| 1577 | - $_structure=$part; |
|
| 1578 | - $this->fetchPartContents($uid, $_structure, false,true); |
|
| 1579 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1580 | - $charSet=Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1577 | + $_structure = $part; |
|
| 1578 | + $this->fetchPartContents($uid, $_structure, false, true); |
|
| 1579 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1580 | + $charSet = Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1581 | 1581 | // add line breaks to $bodyParts |
| 1582 | 1582 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 1583 | - $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1583 | + $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1584 | 1584 | //error_log(__METHOD__.__LINE__.$headerObject['BODYPREVIEW']); |
| 1585 | 1585 | } |
| 1586 | 1586 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType); |
@@ -1590,28 +1590,28 @@ discard block |
||
| 1590 | 1590 | // the presence of an cid does not necessarily indicate its inline. it may lack the needed |
| 1591 | 1591 | // link to show the image. Considering this: we "list" everything that matches the above criteria |
| 1592 | 1592 | // as attachment in order to not loose/miss information on our data |
| 1593 | - $partdisposition='attachment';//($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1593 | + $partdisposition = 'attachment'; //($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1594 | 1594 | } |
| 1595 | - if ($mime_type=='message/rfc822') |
|
| 1595 | + if ($mime_type == 'message/rfc822') |
|
| 1596 | 1596 | { |
| 1597 | 1597 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1598 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1598 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 1599 | 1599 | } |
| 1600 | 1600 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1601 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1602 | - if ($partdisposition=='attachment' || |
|
| 1603 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
|
| 1604 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
|
| 1605 | - ($partdisposition=='inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1601 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 1602 | + if ($partdisposition == 'attachment' || |
|
| 1603 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && $mime_type == 'image/tiff') || // as we are not able to display tiffs |
|
| 1604 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && empty($cid)) || |
|
| 1605 | + ($partdisposition == 'inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1606 | 1606 | { |
| 1607 | - $headerObject['ATTACHMENTS'][$mime_id]=$part->getAllDispositionParameters(); |
|
| 1608 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=$mime_type; |
|
| 1609 | - $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
|
| 1607 | + $headerObject['ATTACHMENTS'][$mime_id] = $part->getAllDispositionParameters(); |
|
| 1608 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] = $mime_type; |
|
| 1609 | + $headerObject['ATTACHMENTS'][$mime_id]['uid'] = $uid; |
|
| 1610 | 1610 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1611 | - $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
|
| 1612 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1613 | - if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
|
| 1614 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
|
| 1611 | + $headerObject['ATTACHMENTS'][$mime_id]['partID'] = $mime_id; |
|
| 1612 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name'] = $part->getName(); |
|
| 1613 | + if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'], 'winmail.dat') || |
|
| 1614 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] == 'application/ms-tnef') |
|
| 1615 | 1615 | { |
| 1616 | 1616 | $headerObject['ATTACHMENTS'][$mime_id]['is_winmail'] = true; |
| 1617 | 1617 | } |
@@ -1626,54 +1626,54 @@ discard block |
||
| 1626 | 1626 | if (empty($headerObject['UID'])) continue; |
| 1627 | 1627 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1628 | 1628 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1629 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1629 | + if (substr($headerObject['DATE'], -2) === 'UT') { |
|
| 1630 | 1630 | $headerObject['DATE'] .= 'C'; |
| 1631 | 1631 | } |
| 1632 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1632 | + if (substr($headerObject['INTERNALDATE'], -2) === 'UT') { |
|
| 1633 | 1633 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1634 | 1634 | } |
| 1635 | 1635 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1636 | 1636 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1637 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1638 | - $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1639 | - $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1640 | - $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
|
| 1641 | - $retValue['header'][$sortOrder[$uid]]['internaldate']= self::_strtotime($headerObject['INTERNALDATE'],'ts',true); |
|
| 1642 | - $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1643 | - $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1644 | - $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1645 | - $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1646 | - $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
|
| 1637 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][] = $a; } |
|
| 1638 | + $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1639 | + $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1640 | + $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE'] && !($headerObject['DATE'] == 'NIL') ? $headerObject['DATE'] : $headerObject['INTERNALDATE']), 'ts', true); |
|
| 1641 | + $retValue['header'][$sortOrder[$uid]]['internaldate'] = self::_strtotime($headerObject['INTERNALDATE'], 'ts', true); |
|
| 1642 | + $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1643 | + $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1644 | + $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1645 | + $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1646 | + $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY'] ? $headerObject['PRIORITY'] : 3); |
|
| 1647 | 1647 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1648 | 1648 | if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
| 1649 | 1649 | if (is_array($headerObject['FLAGS'])) { |
| 1650 | - $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
|
| 1650 | + $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]], self::prepareFlagsArray($headerObject)); |
|
| 1651 | 1651 | } |
| 1652 | 1652 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1653 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1654 | - $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
|
| 1653 | + if (is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1654 | + $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0], true); |
|
| 1655 | 1655 | } |
| 1656 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1657 | - $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
|
| 1658 | - if (count($headerObject['TO'])>1) |
|
| 1656 | + if (is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1657 | + $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0], true); |
|
| 1658 | + if (count($headerObject['TO']) > 1) |
|
| 1659 | 1659 | { |
| 1660 | - $ki=0; |
|
| 1661 | - foreach($headerObject['TO'] as $k => $add) |
|
| 1660 | + $ki = 0; |
|
| 1661 | + foreach ($headerObject['TO'] as $k => $add) |
|
| 1662 | 1662 | { |
| 1663 | - if ($k==0) continue; |
|
| 1663 | + if ($k == 0) continue; |
|
| 1664 | 1664 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1665 | - $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
|
| 1665 | + $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add, true); |
|
| 1666 | 1666 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1667 | 1667 | $ki++; |
| 1668 | 1668 | } |
| 1669 | 1669 | } |
| 1670 | 1670 | } |
| 1671 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 1672 | - $ki=0; |
|
| 1673 | - foreach($headerObject['CC'] as $k => $add) |
|
| 1671 | + if (is_array($headerObject['CC']) && count($headerObject['CC']) > 0) { |
|
| 1672 | + $ki = 0; |
|
| 1673 | + foreach ($headerObject['CC'] as $k => $add) |
|
| 1674 | 1674 | { |
| 1675 | 1675 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1676 | - $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add,true); |
|
| 1676 | + $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add, true); |
|
| 1677 | 1677 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1678 | 1678 | $ki++; |
| 1679 | 1679 | } |
@@ -1682,27 +1682,27 @@ discard block |
||
| 1682 | 1682 | |
| 1683 | 1683 | $count++; |
| 1684 | 1684 | } |
| 1685 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 1685 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' fetching Headers and stuff for Folder:'.$_folderName, __METHOD__.' ('.__LINE__.') '); |
|
| 1686 | 1686 | //self::$debug=false; |
| 1687 | 1687 | // sort the messages to the requested displayorder |
| 1688 | - if(is_array($retValue['header'])) { |
|
| 1688 | + if (is_array($retValue['header'])) { |
|
| 1689 | 1689 | $countMessages = $total; |
| 1690 | 1690 | if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
| 1691 | 1691 | ksort($retValue['header']); |
| 1692 | 1692 | $retValue['info']['total'] = $total; |
| 1693 | 1693 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1694 | 1694 | $retValue['info']['first'] = $_startMessage; |
| 1695 | - $retValue['info']['last'] = $_startMessage + $count - 1 ; |
|
| 1695 | + $retValue['info']['last'] = $_startMessage + $count - 1; |
|
| 1696 | 1696 | return $retValue; |
| 1697 | 1697 | } else { |
| 1698 | 1698 | $retValue = array(); |
| 1699 | 1699 | $retValue['info']['total'] = 0; |
| 1700 | 1700 | $retValue['info']['first'] = 0; |
| 1701 | - $retValue['info']['last'] = 0; |
|
| 1701 | + $retValue['info']['last'] = 0; |
|
| 1702 | 1702 | return $retValue; |
| 1703 | 1703 | } |
| 1704 | 1704 | } else { |
| 1705 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 1705 | + if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew, TRUE)); |
|
| 1706 | 1706 | $retValue = array(); |
| 1707 | 1707 | $retValue['info']['total'] = 0; |
| 1708 | 1708 | $retValue['info']['first'] = 0; |
@@ -1719,17 +1719,17 @@ discard block |
||
| 1719 | 1719 | */ |
| 1720 | 1720 | static function prepareFlagsArray($headerObject) |
| 1721 | 1721 | { |
| 1722 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 1722 | + if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower', $headerObject['FLAGS']); |
|
| 1723 | 1723 | $retValue = array(); |
| 1724 | 1724 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1725 | 1725 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
| 1726 | - $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1727 | - $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1726 | + $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1727 | + $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1728 | 1728 | $retValue['deleted'] = in_array('\\deleted', $headerFlags); |
| 1729 | - $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1730 | - $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1731 | - $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags)||in_array('mdnsent', $headerFlags); |
|
| 1732 | - $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags)||in_array('mdnnotsent', $headerFlags); |
|
| 1729 | + $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1730 | + $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1731 | + $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags) || in_array('mdnsent', $headerFlags); |
|
| 1732 | + $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags) || in_array('mdnnotsent', $headerFlags); |
|
| 1733 | 1733 | $retValue['label1'] = in_array('$label1', $headerFlags); |
| 1734 | 1734 | $retValue['label2'] = in_array('$label2', $headerFlags); |
| 1735 | 1735 | $retValue['label3'] = in_array('$label3', $headerFlags); |
@@ -1753,12 +1753,12 @@ discard block |
||
| 1753 | 1753 | * @param bool $setSession if set to true the session will be populated with the result of the query |
| 1754 | 1754 | * @return mixed bool/array false or array of ids |
| 1755 | 1755 | */ |
| 1756 | - function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid=true, $setSession=true) |
|
| 1756 | + function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid = true, $setSession = true) |
|
| 1757 | 1757 | { |
| 1758 | 1758 | static $cachedFolderStatus = null; |
| 1759 | 1759 | // in the past we needed examineMailbox to figure out if the server with the serverID support keywords |
| 1760 | 1760 | // this information is filled/provided by examineMailbox; but caching within one request seems o.k. |
| 1761 | - if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) ) |
|
| 1761 | + if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName])) |
|
| 1762 | 1762 | { |
| 1763 | 1763 | $folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName); |
| 1764 | 1764 | } |
@@ -1770,27 +1770,27 @@ discard block |
||
| 1770 | 1770 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1771 | 1771 | $try2useCache = true; |
| 1772 | 1772 | static $eMailListContainsDeletedMessages = null; |
| 1773 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 1773 | + if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 1774 | 1774 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1775 | - if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1775 | + if ($setSession == true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1776 | 1776 | { |
| 1777 | 1777 | if (self::$debugTimes) $starttime = microtime(true); |
| 1778 | - 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); |
|
| 1779 | - $deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false); |
|
| 1778 | + 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); |
|
| 1779 | + $deletedMessages = $this->getSortedList($_folderName, 0, $three = 1, array('status'=>array('DELETED')), $five = true, false); |
|
| 1780 | 1780 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
| 1781 | - $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 1782 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 1783 | - 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']); |
|
| 1781 | + $eMailListContainsDeletedMessages[$this->profileID][$_folderName] = $deletedMessages['count']; |
|
| 1782 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), $eMailListContainsDeletedMessages, 60 * 60 * 1); |
|
| 1783 | + 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']); |
|
| 1784 | 1784 | } |
| 1785 | 1785 | $try2useCache = false; |
| 1786 | 1786 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1787 | 1787 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1788 | 1788 | { |
| 1789 | - self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 1790 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 1789 | + self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1790 | + if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID] = true; |
|
| 1791 | 1791 | } |
| 1792 | 1792 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1793 | - $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
|
| 1793 | + $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
|
| 1794 | 1794 | if (self::$debug) |
| 1795 | 1795 | { |
| 1796 | 1796 | $query_str = $filter->build(); |
@@ -1798,14 +1798,14 @@ discard block |
||
| 1798 | 1798 | } |
| 1799 | 1799 | //_debug_array($filter); |
| 1800 | 1800 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1801 | - if($this->icServer->hasCapability('SORT')) { |
|
| 1801 | + if ($this->icServer->hasCapability('SORT')) { |
|
| 1802 | 1802 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1803 | 1803 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1804 | 1804 | // there is no messing with the dates) |
| 1805 | 1805 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1806 | 1806 | if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
| 1807 | 1807 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1808 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1808 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE, $sortOrder)) $_reverse = false; // as we reversed the result already |
|
| 1809 | 1809 | if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
| 1810 | 1810 | try |
| 1811 | 1811 | { |
@@ -1813,24 +1813,24 @@ discard block |
||
| 1813 | 1813 | 'sort' => $sortOrder,)); |
| 1814 | 1814 | // if there is an Error, we assume that the server is not capable of sorting |
| 1815 | 1815 | } |
| 1816 | - catch(\Exception $e) |
|
| 1816 | + catch (\Exception $e) |
|
| 1817 | 1817 | { |
| 1818 | 1818 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1819 | 1819 | $resultByUid = false; |
| 1820 | 1820 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1821 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 1821 | + if ($_reverse) array_unshift($sortOrder, Horde_Imap_Client::SORT_REVERSE); |
|
| 1822 | 1822 | try |
| 1823 | 1823 | { |
| 1824 | 1824 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
| 1825 | 1825 | 'sort' => $sortOrder)); |
| 1826 | 1826 | } |
| 1827 | - catch(\Exception $e) |
|
| 1827 | + catch (\Exception $e) |
|
| 1828 | 1828 | { |
| 1829 | 1829 | error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1830 | 1830 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1831 | 1831 | } |
| 1832 | 1832 | } |
| 1833 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1833 | + if (self::$debug) error_log(__METHOD__.print_r($sortResult, true)); |
|
| 1834 | 1834 | } else { |
| 1835 | 1835 | if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
| 1836 | 1836 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
@@ -1840,12 +1840,12 @@ discard block |
||
| 1840 | 1840 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1841 | 1841 | 'sort' => $sortOrder)*/); |
| 1842 | 1842 | } |
| 1843 | - catch(\Exception $e) |
|
| 1843 | + catch (\Exception $e) |
|
| 1844 | 1844 | { |
| 1845 | 1845 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1846 | 1846 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1847 | - self::$supportsORinQuery[$this->profileID]=false; |
|
| 1848 | - Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
|
| 1847 | + self::$supportsORinQuery[$this->profileID] = false; |
|
| 1848 | + Cache::setCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), self::$supportsORinQuery, 60 * 60 * 10); |
|
| 1849 | 1849 | if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
| 1850 | 1850 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1851 | 1851 | try |
@@ -1853,25 +1853,25 @@ discard block |
||
| 1853 | 1853 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1854 | 1854 | 'sort' => $sortOrder)*/); |
| 1855 | 1855 | } |
| 1856 | - catch(\Exception $e) |
|
| 1856 | + catch (\Exception $e) |
|
| 1857 | 1857 | { |
| 1858 | 1858 | } |
| 1859 | 1859 | } |
| 1860 | - if(is_array($sortResult['match'])) { |
|
| 1860 | + if (is_array($sortResult['match'])) { |
|
| 1861 | 1861 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1862 | 1862 | sort($sortResult['match'], SORT_NUMERIC); |
| 1863 | 1863 | } |
| 1864 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 1864 | + if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter, true)." ->".print_r($sortResult, true)); |
|
| 1865 | 1865 | } |
| 1866 | 1866 | if ($setSession) |
| 1867 | 1867 | { |
| 1868 | 1868 | self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY']; |
| 1869 | - self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1869 | + self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1870 | 1870 | self::$folderStatusCache[$this->profileID][$_folderName]['deleted'] = $eMailListContainsDeletedMessages[$this->profileID][$_folderName]; |
| 1871 | 1871 | self::$folderStatusCache[$this->profileID][$_folderName]['uidnext'] = $folderStatus['UIDNEXT']; |
| 1872 | - self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1872 | + self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1873 | 1873 | self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult; |
| 1874 | - self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1874 | + self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1875 | 1875 | } |
| 1876 | 1876 | //error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
| 1877 | 1877 | //_debug_array($sortResult['match']->ids); |
@@ -1885,12 +1885,12 @@ discard block |
||
| 1885 | 1885 | * @param bool _reverse wether to add REVERSE to the Sort String or not |
| 1886 | 1886 | * @return the sort sequence for horde search |
| 1887 | 1887 | */ |
| 1888 | - function _getSortString($_sort, $_reverse=false) |
|
| 1888 | + function _getSortString($_sort, $_reverse = false) |
|
| 1889 | 1889 | { |
| 1890 | - $_reverse=false; |
|
| 1890 | + $_reverse = false; |
|
| 1891 | 1891 | if (is_numeric($_sort)) |
| 1892 | 1892 | { |
| 1893 | - switch($_sort) { |
|
| 1893 | + switch ($_sort) { |
|
| 1894 | 1894 | case 2: |
| 1895 | 1895 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1896 | 1896 | break; |
@@ -1912,7 +1912,7 @@ discard block |
||
| 1912 | 1912 | } |
| 1913 | 1913 | else |
| 1914 | 1914 | { |
| 1915 | - switch(strtoupper($_sort)) { |
|
| 1915 | + switch (strtoupper($_sort)) { |
|
| 1916 | 1916 | case 'FROMADDRESS': |
| 1917 | 1917 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1918 | 1918 | break; |
@@ -1938,7 +1938,7 @@ discard block |
||
| 1938 | 1938 | break; |
| 1939 | 1939 | } |
| 1940 | 1940 | } |
| 1941 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 1941 | + if ($_reverse) array_unshift($retValue, Horde_Imap_Client::SORT_REVERSE); |
|
| 1942 | 1942 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1943 | 1943 | return $retValue; |
| 1944 | 1944 | } |
@@ -1951,28 +1951,28 @@ discard block |
||
| 1951 | 1951 | * @param boolean $_supportsOrInQuery wether to use the OR Query on QuickSearch |
| 1952 | 1952 | * @return Horde_Imap_Client_Search_Query the IMAP filter |
| 1953 | 1953 | */ |
| 1954 | - function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery=true) |
|
| 1954 | + function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery = true) |
|
| 1955 | 1955 | { |
| 1956 | 1956 | $imapFilter = new Horde_Imap_Client_Search_Query(); |
| 1957 | 1957 | $imapFilter->charset('UTF-8'); |
| 1958 | 1958 | |
| 1959 | 1959 | //_debug_array($_criterias); |
| 1960 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 1961 | - if((!is_array($_criterias) || $_criterias['status']=='any') && |
|
| 1960 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias) ? " none -> returning" : array2string($_criterias))); |
|
| 1961 | + if ((!is_array($_criterias) || $_criterias['status'] == 'any') && |
|
| 1962 | 1962 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 1963 | - (!isset($_criterias['range'])|| empty($_criterias['range']) || |
|
| 1964 | - ( !empty($_criterias['range'])&& ($_criterias['range']!='BETWEEN' && empty($_criterias['date'])|| |
|
| 1965 | - ($_criterias['range']=='BETWEEN' && empty($_criterias['since'])&& empty($_criterias['before'])))))) |
|
| 1963 | + (!isset($_criterias['range']) || empty($_criterias['range']) || |
|
| 1964 | + (!empty($_criterias['range']) && ($_criterias['range'] != 'BETWEEN' && empty($_criterias['date']) || |
|
| 1965 | + ($_criterias['range'] == 'BETWEEN' && empty($_criterias['since']) && empty($_criterias['before'])))))) |
|
| 1966 | 1966 | { |
| 1967 | 1967 | //error_log(__METHOD__.' ('.__LINE__.') returning early Criterias:'.print_r($_criterias, true)); |
| 1968 | - $imapFilter->flag('DELETED', $set=false); |
|
| 1968 | + $imapFilter->flag('DELETED', $set = false); |
|
| 1969 | 1969 | return $imapFilter; |
| 1970 | 1970 | } |
| 1971 | 1971 | $queryValid = false; |
| 1972 | 1972 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 1973 | 1973 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 1974 | 1974 | $statusQueryValid = false; |
| 1975 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 1975 | + foreach ((array)$_criterias['status'] as $k => $criteria) { |
|
| 1976 | 1976 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 1977 | 1977 | $imapStatusFilter->charset('UTF-8'); |
| 1978 | 1978 | $criteria = strtoupper($criteria); |
@@ -1982,12 +1982,12 @@ discard block |
||
| 1982 | 1982 | case 'FLAGGED': |
| 1983 | 1983 | case 'RECENT': |
| 1984 | 1984 | case 'SEEN': |
| 1985 | - $imapStatusFilter->flag($criteria, $set=true); |
|
| 1986 | - $queryValid = $statusQueryValid =true; |
|
| 1985 | + $imapStatusFilter->flag($criteria, $set = true); |
|
| 1986 | + $queryValid = $statusQueryValid = true; |
|
| 1987 | 1987 | break; |
| 1988 | 1988 | case 'READ': |
| 1989 | - $imapStatusFilter->flag('SEEN', $set=true); |
|
| 1990 | - $queryValid = $statusQueryValid =true; |
|
| 1989 | + $imapStatusFilter->flag('SEEN', $set = true); |
|
| 1990 | + $queryValid = $statusQueryValid = true; |
|
| 1991 | 1991 | break; |
| 1992 | 1992 | case 'LABEL1': |
| 1993 | 1993 | case 'KEYWORD1': |
@@ -1999,38 +1999,38 @@ discard block |
||
| 1999 | 1999 | case 'KEYWORD4': |
| 2000 | 2000 | case 'LABEL5': |
| 2001 | 2001 | case 'KEYWORD5': |
| 2002 | - $imapStatusFilter->flag(str_ireplace('KEYWORD','$LABEL',$criteria), $set=true); |
|
| 2003 | - $queryValid = $statusQueryValid =true; |
|
| 2002 | + $imapStatusFilter->flag(str_ireplace('KEYWORD', '$LABEL', $criteria), $set = true); |
|
| 2003 | + $queryValid = $statusQueryValid = true; |
|
| 2004 | 2004 | break; |
| 2005 | 2005 | case 'NEW': |
| 2006 | - $imapStatusFilter->flag('RECENT', $set=true); |
|
| 2007 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2008 | - $queryValid = $statusQueryValid =true; |
|
| 2006 | + $imapStatusFilter->flag('RECENT', $set = true); |
|
| 2007 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2008 | + $queryValid = $statusQueryValid = true; |
|
| 2009 | 2009 | break; |
| 2010 | 2010 | case 'OLD': |
| 2011 | - $imapStatusFilter->flag('RECENT', $set=false); |
|
| 2012 | - $queryValid = $statusQueryValid =true; |
|
| 2011 | + $imapStatusFilter->flag('RECENT', $set = false); |
|
| 2012 | + $queryValid = $statusQueryValid = true; |
|
| 2013 | 2013 | break; |
| 2014 | 2014 | // operate only on system flags |
| 2015 | 2015 | // $systemflags = array( |
| 2016 | 2016 | // 'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'RECENT', 'SEEN' |
| 2017 | 2017 | // ); |
| 2018 | 2018 | case 'UNANSWERED': |
| 2019 | - $imapStatusFilter->flag('ANSWERED', $set=false); |
|
| 2020 | - $queryValid = $statusQueryValid =true; |
|
| 2019 | + $imapStatusFilter->flag('ANSWERED', $set = false); |
|
| 2020 | + $queryValid = $statusQueryValid = true; |
|
| 2021 | 2021 | break; |
| 2022 | 2022 | case 'UNDELETED': |
| 2023 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2023 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2024 | 2024 | $queryValid = true; |
| 2025 | 2025 | break; |
| 2026 | 2026 | case 'UNFLAGGED': |
| 2027 | - $imapStatusFilter->flag('FLAGGED', $set=false); |
|
| 2028 | - $queryValid = $statusQueryValid =true; |
|
| 2027 | + $imapStatusFilter->flag('FLAGGED', $set = false); |
|
| 2028 | + $queryValid = $statusQueryValid = true; |
|
| 2029 | 2029 | break; |
| 2030 | 2030 | case 'UNREAD': |
| 2031 | 2031 | case 'UNSEEN': |
| 2032 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2033 | - $queryValid = $statusQueryValid =true; |
|
| 2032 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2033 | + $queryValid = $statusQueryValid = true; |
|
| 2034 | 2034 | break; |
| 2035 | 2035 | case 'UNLABEL1': |
| 2036 | 2036 | case 'UNKEYWORD1': |
@@ -2042,8 +2042,8 @@ discard block |
||
| 2042 | 2042 | case 'UNKEYWORD4': |
| 2043 | 2043 | case 'UNLABEL5': |
| 2044 | 2044 | case 'UNKEYWORD5': |
| 2045 | - $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD','UNLABEL'),'$LABEL',$criteria), $set=false); |
|
| 2046 | - $queryValid = $statusQueryValid =true; |
|
| 2045 | + $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD', 'UNLABEL'), '$LABEL', $criteria), $set = false); |
|
| 2046 | + $queryValid = $statusQueryValid = true; |
|
| 2047 | 2047 | break; |
| 2048 | 2048 | default: |
| 2049 | 2049 | $statusQueryValid = false; |
@@ -2059,20 +2059,20 @@ discard block |
||
| 2059 | 2059 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2060 | 2060 | $imapSearchFilter->charset('UTF-8'); |
| 2061 | 2061 | |
| 2062 | - if(!empty($_criterias['string'])) { |
|
| 2062 | + if (!empty($_criterias['string'])) { |
|
| 2063 | 2063 | $criteria = strtoupper($_criterias['type']); |
| 2064 | 2064 | switch ($criteria) { |
| 2065 | 2065 | case 'BYDATE': |
| 2066 | 2066 | case 'QUICK': |
| 2067 | 2067 | case 'QUICKWITHCC': |
| 2068 | - $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not=false); |
|
| 2068 | + $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not = false); |
|
| 2069 | 2069 | //$imapSearchFilter->charset('UTF-8'); |
| 2070 | 2070 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2071 | 2071 | $imapFilter2->charset('UTF-8'); |
| 2072 | - if($this->isSentFolder($_folder)) { |
|
| 2073 | - $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
|
| 2072 | + if ($this->isSentFolder($_folder)) { |
|
| 2073 | + $imapFilter2->headerText('TO', $_criterias['string'], $not = false); |
|
| 2074 | 2074 | } else { |
| 2075 | - $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
|
| 2075 | + $imapFilter2->headerText('FROM', $_criterias['string'], $not = false); |
|
| 2076 | 2076 | } |
| 2077 | 2077 | if ($_supportsOrInQuery) |
| 2078 | 2078 | { |
@@ -2082,31 +2082,31 @@ discard block |
||
| 2082 | 2082 | { |
| 2083 | 2083 | $imapSearchFilter->andSearch($imapFilter2); |
| 2084 | 2084 | } |
| 2085 | - if ($_supportsOrInQuery && $criteria=='QUICKWITHCC') |
|
| 2085 | + if ($_supportsOrInQuery && $criteria == 'QUICKWITHCC') |
|
| 2086 | 2086 | { |
| 2087 | 2087 | $imapFilter3 = new Horde_Imap_Client_Search_Query(); |
| 2088 | 2088 | $imapFilter3->charset('UTF-8'); |
| 2089 | - $imapFilter3->headerText('CC', $_criterias['string'], $not=false); |
|
| 2089 | + $imapFilter3->headerText('CC', $_criterias['string'], $not = false); |
|
| 2090 | 2090 | $imapSearchFilter->orSearch($imapFilter3); |
| 2091 | 2091 | } |
| 2092 | 2092 | $queryValid = true; |
| 2093 | 2093 | break; |
| 2094 | 2094 | case 'LARGER': |
| 2095 | 2095 | case 'SMALLER': |
| 2096 | - if (strlen(trim($_criterias['string'])) != strlen((float) trim($_criterias['string']))) |
|
| 2096 | + if (strlen(trim($_criterias['string'])) != strlen((float)trim($_criterias['string']))) |
|
| 2097 | 2097 | { |
| 2098 | 2098 | //examine string to evaluate size |
| 2099 | - $unit = strtoupper(trim(substr(trim($_criterias['string']),strlen((float) trim($_criterias['string']))))); |
|
| 2100 | - $multipleBy = array('KB'=>1024,'K'=>1024, |
|
| 2101 | - 'MB'=>1024*1000,'M'=>1024*1000, |
|
| 2102 | - 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
|
| 2103 | - 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
|
| 2104 | - $numberinBytes=(float)$_criterias['string']; |
|
| 2105 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2099 | + $unit = strtoupper(trim(substr(trim($_criterias['string']), strlen((float)trim($_criterias['string']))))); |
|
| 2100 | + $multipleBy = array('KB'=>1024, 'K'=>1024, |
|
| 2101 | + 'MB'=>1024 * 1000, 'M'=>1024 * 1000, |
|
| 2102 | + 'GB'=>1024 * 1000 * 1000, 'G'=>1024 * 1000 * 1000, |
|
| 2103 | + 'TB'=>1024 * 1000 * 1000 * 1000, 'T'=>1024 * 1000 * 1000 * 1000); |
|
| 2104 | + $numberinBytes = (float)$_criterias['string']; |
|
| 2105 | + if (isset($multipleBy[$unit])) $numberinBytes = (float)$_criterias['string'] * $multipleBy[$unit]; |
|
| 2106 | 2106 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2107 | - $_criterias['string']=$numberinBytes; |
|
| 2107 | + $_criterias['string'] = $numberinBytes; |
|
| 2108 | 2108 | } |
| 2109 | - $imapSearchFilter->size( $_criterias['string'], ($criteria=='LARGER'?true:false), $not=false); |
|
| 2109 | + $imapSearchFilter->size($_criterias['string'], ($criteria == 'LARGER' ? true : false), $not = false); |
|
| 2110 | 2110 | //$imapSearchFilter->charset('UTF-8'); |
| 2111 | 2111 | $queryValid = true; |
| 2112 | 2112 | break; |
@@ -2115,31 +2115,31 @@ discard block |
||
| 2115 | 2115 | case 'CC': |
| 2116 | 2116 | case 'BCC': |
| 2117 | 2117 | case 'SUBJECT': |
| 2118 | - $imapSearchFilter->headerText($criteria, $_criterias['string'], $not=false); |
|
| 2118 | + $imapSearchFilter->headerText($criteria, $_criterias['string'], $not = false); |
|
| 2119 | 2119 | //$imapSearchFilter->charset('UTF-8'); |
| 2120 | 2120 | $queryValid = true; |
| 2121 | 2121 | break; |
| 2122 | 2122 | case 'BODY': |
| 2123 | 2123 | case 'TEXT': |
| 2124 | - $imapSearchFilter->text($_criterias['string'],($criteria=='BODY'?true:false), $not=false); |
|
| 2124 | + $imapSearchFilter->text($_criterias['string'], ($criteria == 'BODY' ? true : false), $not = false); |
|
| 2125 | 2125 | //$imapSearchFilter->charset('UTF-8'); |
| 2126 | 2126 | $queryValid = true; |
| 2127 | 2127 | break; |
| 2128 | 2128 | case 'SINCE': |
| 2129 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2129 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2130 | 2130 | $queryValid = true; |
| 2131 | 2131 | break; |
| 2132 | 2132 | case 'BEFORE': |
| 2133 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2133 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2134 | 2134 | $queryValid = true; |
| 2135 | 2135 | break; |
| 2136 | 2136 | case 'ON': |
| 2137 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2137 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2138 | 2138 | $queryValid = true; |
| 2139 | 2139 | break; |
| 2140 | 2140 | } |
| 2141 | 2141 | } |
| 2142 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2142 | + if ($statusQueryValid && !$queryValid) $queryValid = true; |
|
| 2143 | 2143 | if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
| 2144 | 2144 | |
| 2145 | 2145 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
@@ -2148,12 +2148,12 @@ discard block |
||
| 2148 | 2148 | $imapRangeFilter = new Horde_Imap_Client_Search_Query(); |
| 2149 | 2149 | $imapRangeFilter->charset('UTF-8'); |
| 2150 | 2150 | $criteria = strtoupper($_criterias['range']); |
| 2151 | - if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since']==$_criterias['before']) |
|
| 2151 | + if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since'] == $_criterias['before']) |
|
| 2152 | 2152 | { |
| 2153 | - $_criterias['date']=$_criterias['since']; |
|
| 2153 | + $_criterias['date'] = $_criterias['since']; |
|
| 2154 | 2154 | unset($_criterias['since']); |
| 2155 | 2155 | unset($_criterias['before']); |
| 2156 | - $criteria=$_criterias['range']='ON'; |
|
| 2156 | + $criteria = $_criterias['range'] = 'ON'; |
|
| 2157 | 2157 | } |
| 2158 | 2158 | switch ($criteria) { |
| 2159 | 2159 | case 'BETWEEN': |
@@ -2161,7 +2161,7 @@ discard block |
||
| 2161 | 2161 | //enddate |
| 2162 | 2162 | if ($_criterias['since']) |
| 2163 | 2163 | { |
| 2164 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2164 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2165 | 2165 | $rangeValid = true; |
| 2166 | 2166 | } |
| 2167 | 2167 | //startdate |
@@ -2170,28 +2170,28 @@ discard block |
||
| 2170 | 2170 | $imapRangeFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2171 | 2171 | $imapRangeFilter2->charset('UTF-8'); |
| 2172 | 2172 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2173 | - $_criterias['before'] = date("d-M-Y",DateTime::to($_criterias['before'],'ts')+(3600*24)); |
|
| 2174 | - $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2173 | + $_criterias['before'] = date("d-M-Y", DateTime::to($_criterias['before'], 'ts') + (3600 * 24)); |
|
| 2174 | + $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2175 | 2175 | $imapRangeFilter->andSearch($imapRangeFilter2); |
| 2176 | 2176 | $rangeValid = true; |
| 2177 | 2177 | } |
| 2178 | 2178 | break; |
| 2179 | 2179 | case 'SINCE'://enddate |
| 2180 | - $imapRangeFilter->dateSearch(new DateTime(($_criterias['since']?$_criterias['since']:$_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2180 | + $imapRangeFilter->dateSearch(new DateTime(($_criterias['since'] ? $_criterias['since'] : $_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2181 | 2181 | $rangeValid = true; |
| 2182 | 2182 | break; |
| 2183 | 2183 | case 'BEFORE'://startdate |
| 2184 | 2184 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2185 | - $_criterias['before'] = date("d-M-Y",DateTime::to(($_criterias['before']?$_criterias['before']:$_criterias['date']),'ts')+(3600*24)); |
|
| 2186 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2185 | + $_criterias['before'] = date("d-M-Y", DateTime::to(($_criterias['before'] ? $_criterias['before'] : $_criterias['date']), 'ts') + (3600 * 24)); |
|
| 2186 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2187 | 2187 | $rangeValid = true; |
| 2188 | 2188 | break; |
| 2189 | 2189 | case 'ON': |
| 2190 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2190 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2191 | 2191 | $rangeValid = true; |
| 2192 | 2192 | break; |
| 2193 | 2193 | } |
| 2194 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2194 | + if ($rangeValid && !$queryValid) $queryValid = true; |
|
| 2195 | 2195 | if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
| 2196 | 2196 | } |
| 2197 | 2197 | if (self::$debug) |
@@ -2200,8 +2200,8 @@ discard block |
||
| 2200 | 2200 | $query_str = $imapFilter->build(); |
| 2201 | 2201 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2202 | 2202 | } |
| 2203 | - if($queryValid==false) { |
|
| 2204 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2203 | + if ($queryValid == false) { |
|
| 2204 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2205 | 2205 | return $imapFilter; |
| 2206 | 2206 | } else { |
| 2207 | 2207 | return $imapFilter; |
@@ -2215,11 +2215,11 @@ discard block |
||
| 2215 | 2215 | * @param mixed/boolean $_tryIDNConversion (true/false AND FORCE): try IDN Conversion on domainparts of emailADRESSES |
| 2216 | 2216 | * @return mixed - based on the input type |
| 2217 | 2217 | */ |
| 2218 | - static function decode_header($_string, $_tryIDNConversion=false) |
|
| 2218 | + static function decode_header($_string, $_tryIDNConversion = false) |
|
| 2219 | 2219 | { |
| 2220 | 2220 | if (is_array($_string)) |
| 2221 | 2221 | { |
| 2222 | - foreach($_string as $k=>$v) |
|
| 2222 | + foreach ($_string as $k=>$v) |
|
| 2223 | 2223 | { |
| 2224 | 2224 | $_string[$k] = self::decode_header($v, $_tryIDNConversion); |
| 2225 | 2225 | } |
@@ -2227,18 +2227,18 @@ discard block |
||
| 2227 | 2227 | } |
| 2228 | 2228 | else |
| 2229 | 2229 | { |
| 2230 | - $_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset); |
|
| 2230 | + $_string = Mail\Html::decodeMailHeader($_string, self::$displayCharset); |
|
| 2231 | 2231 | $test = @json_encode($_string); |
| 2232 | 2232 | //error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#'); |
| 2233 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2233 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2234 | 2234 | { |
| 2235 | 2235 | // try to fix broken utf8 |
| 2236 | 2236 | $x = utf8_encode($_string); |
| 2237 | 2237 | $test = @json_encode($x); |
| 2238 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2238 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2239 | 2239 | { |
| 2240 | 2240 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 2241 | - $_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)); |
|
| 2241 | + $_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)); |
|
| 2242 | 2242 | } |
| 2243 | 2243 | else |
| 2244 | 2244 | { |
@@ -2246,7 +2246,7 @@ discard block |
||
| 2246 | 2246 | } |
| 2247 | 2247 | } |
| 2248 | 2248 | |
| 2249 | - if ($_tryIDNConversion===true && stripos($_string,'@')!==false) |
|
| 2249 | + if ($_tryIDNConversion === true && stripos($_string, '@') !== false) |
|
| 2250 | 2250 | { |
| 2251 | 2251 | $rfcAddr = self::parseAddressList($_string); |
| 2252 | 2252 | $stringA = array(); |
@@ -2258,11 +2258,11 @@ discard block |
||
| 2258 | 2258 | $stringA = array(); |
| 2259 | 2259 | break; // skip idna conversion if we encounter an error here |
| 2260 | 2260 | } |
| 2261 | - $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
|
| 2261 | + $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox, Horde_Idna::decode($_rfcAddr->host), $_rfcAddr->personal); |
|
| 2262 | 2262 | } |
| 2263 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2263 | + if (!empty($stringA)) $_string = implode(',', $stringA); |
|
| 2264 | 2264 | } |
| 2265 | - if ($_tryIDNConversion==='FORCE') |
|
| 2265 | + if ($_tryIDNConversion === 'FORCE') |
|
| 2266 | 2266 | { |
| 2267 | 2267 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_string.'='.Horde_Idna::decode($_string)); |
| 2268 | 2268 | $_string = Horde_Idna::decode($_string); |
@@ -2278,17 +2278,17 @@ discard block |
||
| 2278 | 2278 | * @param boolean $decode try decoding |
| 2279 | 2279 | * @return mixed - based on the input type |
| 2280 | 2280 | */ |
| 2281 | - function decode_subject($_string,$decode=true) |
|
| 2281 | + function decode_subject($_string, $decode = true) |
|
| 2282 | 2282 | { |
| 2283 | 2283 | #$string = $_string; |
| 2284 | - if($_string=='NIL') |
|
| 2284 | + if ($_string == 'NIL') |
|
| 2285 | 2285 | { |
| 2286 | 2286 | return 'No Subject'; |
| 2287 | 2287 | } |
| 2288 | 2288 | if ($decode) $_string = self::decode_header($_string); |
| 2289 | 2289 | // make sure its utf-8 |
| 2290 | 2290 | $test = @json_encode($_string); |
| 2291 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2291 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2292 | 2292 | { |
| 2293 | 2293 | $_string = utf8_encode($_string); |
| 2294 | 2294 | } |
@@ -2340,18 +2340,18 @@ discard block |
||
| 2340 | 2340 | function createFolder($_parent, $_folderName, &$_error) |
| 2341 | 2341 | { |
| 2342 | 2342 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
| 2343 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2344 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2343 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2344 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2345 | 2345 | |
| 2346 | - if(empty($parent)) { |
|
| 2346 | + if (empty($parent)) { |
|
| 2347 | 2347 | $newFolderName = $folderName; |
| 2348 | 2348 | } else { |
| 2349 | 2349 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2350 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2350 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2351 | 2351 | } |
| 2352 | 2352 | if (empty($newFolderName)) return false; |
| 2353 | 2353 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
| 2354 | - if ($this->folderExists($newFolderName,true)) |
|
| 2354 | + if ($this->folderExists($newFolderName, true)) |
|
| 2355 | 2355 | { |
| 2356 | 2356 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
| 2357 | 2357 | return $newFolderName; |
@@ -2368,7 +2368,7 @@ discard block |
||
| 2368 | 2368 | } |
| 2369 | 2369 | catch (\Exception $e) |
| 2370 | 2370 | { |
| 2371 | - $_error = lang('Could not create Folder %1 Reason: %2',$newFolderName,$e->getMessage()); |
|
| 2371 | + $_error = lang('Could not create Folder %1 Reason: %2', $newFolderName, $e->getMessage()); |
|
| 2372 | 2372 | error_log(__METHOD__.' ('.__LINE__.') '.' create Folder '.$newFolderName.'->'.$e->getMessage().' ('.$e->details.') Namespace:'.array2string($this->icServer->getNameSpaces()).function_backtrace()); |
| 2373 | 2373 | return false; |
| 2374 | 2374 | } |
@@ -2397,15 +2397,15 @@ discard block |
||
| 2397 | 2397 | */ |
| 2398 | 2398 | function renameFolder($_oldFolderName, $_parent, $_folderName) |
| 2399 | 2399 | { |
| 2400 | - $oldFolderName = $_oldFolderName;//$this->_encodeFolderName($_oldFolderName); |
|
| 2401 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2402 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2400 | + $oldFolderName = $_oldFolderName; //$this->_encodeFolderName($_oldFolderName); |
|
| 2401 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2402 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2403 | 2403 | |
| 2404 | - if(empty($parent)) { |
|
| 2404 | + if (empty($parent)) { |
|
| 2405 | 2405 | $newFolderName = $folderName; |
| 2406 | 2406 | } else { |
| 2407 | 2407 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2408 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2408 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2409 | 2409 | } |
| 2410 | 2410 | if (self::$debug) error_log("create folder: $newFolderName"); |
| 2411 | 2411 | try |
@@ -2414,10 +2414,10 @@ discard block |
||
| 2414 | 2414 | } |
| 2415 | 2415 | catch (\Exception $e) |
| 2416 | 2416 | { |
| 2417 | - throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage());; |
|
| 2417 | + throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage()); ; |
|
| 2418 | 2418 | } |
| 2419 | 2419 | // clear FolderExistsInfoCache |
| 2420 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2420 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2421 | 2421 | |
| 2422 | 2422 | return $newFolderName; |
| 2423 | 2423 | |
@@ -2436,15 +2436,15 @@ discard block |
||
| 2436 | 2436 | //$folderName = $this->_encodeFolderName($_folderName); |
| 2437 | 2437 | try |
| 2438 | 2438 | { |
| 2439 | - $this->icServer->subscribeMailbox($_folderName,false); |
|
| 2439 | + $this->icServer->subscribeMailbox($_folderName, false); |
|
| 2440 | 2440 | $this->icServer->deleteMailbox($_folderName); |
| 2441 | 2441 | } |
| 2442 | 2442 | catch (\Exception $e) |
| 2443 | 2443 | { |
| 2444 | - throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage());; |
|
| 2444 | + throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage()); ; |
|
| 2445 | 2445 | } |
| 2446 | 2446 | // clear FolderExistsInfoCache |
| 2447 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2447 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2448 | 2448 | |
| 2449 | 2449 | return true; |
| 2450 | 2450 | } |
@@ -2479,10 +2479,10 @@ discard block |
||
| 2479 | 2479 | * |
| 2480 | 2480 | * @return array with folder objects. eg.: INBOX => {inbox object} |
| 2481 | 2481 | */ |
| 2482 | - function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
|
| 2482 | + function getFolderObjects($_subscribedOnly = false, $_getCounters = false, $_alwaysGetDefaultFolders = false, $_useCacheIfPossible = true) |
|
| 2483 | 2483 | { |
| 2484 | 2484 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
| 2485 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2485 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 2486 | 2486 | static $folders2return; |
| 2487 | 2487 | //$_subscribedOnly=false; |
| 2488 | 2488 | // always use static on single request if info is available; |
@@ -2490,42 +2490,42 @@ discard block |
||
| 2490 | 2490 | // set $_useCacheIfPossible to false ! |
| 2491 | 2491 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2492 | 2492 | { |
| 2493 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2493 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'using static', __METHOD__.' ('.__LINE__.') '); |
|
| 2494 | 2494 | return $folders2return[$this->icServer->ImapServerId]; |
| 2495 | 2495 | } |
| 2496 | 2496 | |
| 2497 | - if ($_subscribedOnly && $_getCounters===false) |
|
| 2497 | + if ($_subscribedOnly && $_getCounters === false) |
|
| 2498 | 2498 | { |
| 2499 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2499 | + if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 2500 | 2500 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2501 | 2501 | { |
| 2502 | 2502 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2503 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2503 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'from Cache', __METHOD__.' ('.__LINE__.') '); |
|
| 2504 | 2504 | return $folders2return[$this->icServer->ImapServerId]; |
| 2505 | 2505 | } |
| 2506 | 2506 | } |
| 2507 | 2507 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2508 | 2508 | static $folderBasicInfo; |
| 2509 | - 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); |
|
| 2509 | + 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); |
|
| 2510 | 2510 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2511 | 2511 | |
| 2512 | 2512 | $delimiter = $this->getHierarchyDelimiter(); |
| 2513 | 2513 | |
| 2514 | 2514 | $inboxData = new \stdClass; |
| 2515 | - $inboxData->name = 'INBOX'; |
|
| 2515 | + $inboxData->name = 'INBOX'; |
|
| 2516 | 2516 | $inboxData->folderName = 'INBOX'; |
| 2517 | - $inboxData->displayName = lang('INBOX'); |
|
| 2517 | + $inboxData->displayName = lang('INBOX'); |
|
| 2518 | 2518 | $inboxData->delimiter = $delimiter; |
| 2519 | - $inboxData->shortFolderName = 'INBOX'; |
|
| 2520 | - $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2519 | + $inboxData->shortFolderName = 'INBOX'; |
|
| 2520 | + $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2521 | 2521 | $inboxData->subscribed = true; |
| 2522 | - if($_getCounters == true) { |
|
| 2522 | + if ($_getCounters == true) { |
|
| 2523 | 2523 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2524 | 2524 | } |
| 2525 | 2525 | // force unsubscribed by preference showAllFoldersInFolderPane |
| 2526 | 2526 | if ($_subscribedOnly == true && |
| 2527 | 2527 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2528 | - $this->mailPreferences['showAllFoldersInFolderPane']==1) |
|
| 2528 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1) |
|
| 2529 | 2529 | { |
| 2530 | 2530 | $_subscribedOnly = false; |
| 2531 | 2531 | } |
@@ -2538,12 +2538,12 @@ discard block |
||
| 2538 | 2538 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2539 | 2539 | if (is_array($nameSpace)) |
| 2540 | 2540 | { |
| 2541 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2541 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2542 | 2542 | $type = $singleNameSpace['type']; |
| 2543 | 2543 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2544 | - $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2544 | + $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2545 | 2545 | |
| 2546 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 2546 | + if (is_array($singleNameSpace) && $fetchedAllInOneGo == false) { |
|
| 2547 | 2547 | // fetch and sort the subscribed folders |
| 2548 | 2548 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2549 | 2549 | // if a folder is subscribed or not |
@@ -2551,22 +2551,22 @@ discard block |
||
| 2551 | 2551 | { |
| 2552 | 2552 | try |
| 2553 | 2553 | { |
| 2554 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('',0,true); |
|
| 2554 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('', 0, true); |
|
| 2555 | 2555 | if (!empty($subscribedMailboxes)) |
| 2556 | 2556 | { |
| 2557 | 2557 | $fetchedAllInOneGo = true; |
| 2558 | 2558 | } |
| 2559 | 2559 | else |
| 2560 | 2560 | { |
| 2561 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2561 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2562 | 2562 | } |
| 2563 | 2563 | } |
| 2564 | - catch(Exception $e) |
|
| 2564 | + catch (Exception $e) |
|
| 2565 | 2565 | { |
| 2566 | 2566 | continue; |
| 2567 | 2567 | } |
| 2568 | 2568 | //echo "subscribedMailboxes";_debug_array($subscribedMailboxes); |
| 2569 | - $subscribedFoldersPerNS = (!empty($subscribedMailboxes)?array_keys($subscribedMailboxes):array()); |
|
| 2569 | + $subscribedFoldersPerNS = (!empty($subscribedMailboxes) ? array_keys($subscribedMailboxes) : array()); |
|
| 2570 | 2570 | //if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']); |
| 2571 | 2571 | //_debug_array($foldersNameSpace); |
| 2572 | 2572 | //error_log(__METHOD__.__LINE__.array2string($singleNameSpace).':#:'.array2string($subscribedFoldersPerNS)); |
@@ -2576,18 +2576,18 @@ discard block |
||
| 2576 | 2576 | foreach ($subscribedMailboxes as $k => $finfo) |
| 2577 | 2577 | { |
| 2578 | 2578 | //error_log(__METHOD__.__LINE__.$k.':#:'.array2string($finfo)); |
| 2579 | - $subscribedFoldersForCache[$this->icServer->ImapServerId][$k]= |
|
| 2580 | - $folderBasicInfo[$this->icServer->ImapServerId][$k]=array( |
|
| 2579 | + $subscribedFoldersForCache[$this->icServer->ImapServerId][$k] = |
|
| 2580 | + $folderBasicInfo[$this->icServer->ImapServerId][$k] = array( |
|
| 2581 | 2581 | 'MAILBOX'=>$finfo['MAILBOX'], |
| 2582 | 2582 | 'ATTRIBUTES'=>$finfo['ATTRIBUTES'], |
| 2583 | - 'delimiter'=>$finfo['delimiter'],//lowercase for some reason??? |
|
| 2584 | - 'SUBSCRIBED'=>$finfo['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2583 | + 'delimiter'=>$finfo['delimiter'], //lowercase for some reason??? |
|
| 2584 | + 'SUBSCRIBED'=>$finfo['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2585 | 2585 | ); |
| 2586 | - if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k,$foldersNameSpace[$type]['subscribed'])) |
|
| 2586 | + if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k, $foldersNameSpace[$type]['subscribed'])) |
|
| 2587 | 2587 | { |
| 2588 | 2588 | $foldersNameSpace[$type]['subscribed'][] = $k; |
| 2589 | 2589 | } |
| 2590 | - if (empty($foldersNameSpace[$type]['all']) || !in_array($k,$foldersNameSpace[$type]['all'])) |
|
| 2590 | + if (empty($foldersNameSpace[$type]['all']) || !in_array($k, $foldersNameSpace[$type]['all'])) |
|
| 2591 | 2591 | { |
| 2592 | 2592 | $foldersNameSpace[$type]['all'][] = $k; |
| 2593 | 2593 | } |
@@ -2610,7 +2610,7 @@ discard block |
||
| 2610 | 2610 | // that may produce problems, when encountering recursions probably |
| 2611 | 2611 | // horde is handling that, so we do not; keep that in mind! |
| 2612 | 2612 | //$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],2,true); |
| 2613 | - $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2613 | + $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | catch (\Exception $e) |
| 2616 | 2616 | { |
@@ -2628,26 +2628,26 @@ discard block |
||
| 2628 | 2628 | foreach ($allMailboxesExt as $mbx) { |
| 2629 | 2629 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2630 | 2630 | { |
| 2631 | - $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
|
| 2631 | + $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']] = array( |
|
| 2632 | 2632 | 'MAILBOX'=>$mbx['MAILBOX'], |
| 2633 | 2633 | 'ATTRIBUTES'=>$mbx['ATTRIBUTES'], |
| 2634 | - 'delimiter'=>$mbx['delimiter'],//lowercase for some reason??? |
|
| 2635 | - 'SUBSCRIBED'=>$mbx['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2634 | + 'delimiter'=>$mbx['delimiter'], //lowercase for some reason??? |
|
| 2635 | + 'SUBSCRIBED'=>$mbx['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2636 | 2636 | ); |
| 2637 | 2637 | if ($mbx['SUBSCRIBED'] && !isset($subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2638 | 2638 | { |
| 2639 | 2639 | $subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']] = $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]; |
| 2640 | 2640 | } |
| 2641 | 2641 | } |
| 2642 | - if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'],$foldersNameSpace[$type]['subscribed']))) |
|
| 2642 | + if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'], $foldersNameSpace[$type]['subscribed']))) |
|
| 2643 | 2643 | { |
| 2644 | 2644 | $foldersNameSpace[$type]['subscribed'][] = $mbx['MAILBOX']; |
| 2645 | 2645 | } |
| 2646 | 2646 | //echo __METHOD__;_debug_array($mbx); |
| 2647 | 2647 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 2648 | - if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
|
| 2649 | - isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
|
| 2650 | - (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
|
| 2648 | + if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']]) || |
|
| 2649 | + isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']]) || |
|
| 2650 | + (substr($mbx['MAILBOX'], -1) == $foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'], 0, -1)])) |
|
| 2651 | 2651 | ) continue; |
| 2652 | 2652 | |
| 2653 | 2653 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
@@ -2657,7 +2657,7 @@ discard block |
||
| 2657 | 2657 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2658 | 2658 | $allMailboxes = array(); |
| 2659 | 2659 | foreach ((array)$allMailBoxesExtSorted as $mbx) { |
| 2660 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2660 | + if (!in_array($mbx['MAILBOX'], $allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2661 | 2661 | //echo "Result:";_debug_array($allMailboxes); |
| 2662 | 2662 | } |
| 2663 | 2663 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
@@ -2666,57 +2666,57 @@ discard block |
||
| 2666 | 2666 | } |
| 2667 | 2667 | } |
| 2668 | 2668 | //subscribed folders may be used in getFolderStatus |
| 2669 | - Cache::setCache(Cache::INSTANCE,'email','subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$subscribedFoldersForCache,$expiration=60*60*1); |
|
| 2669 | + Cache::setCache(Cache::INSTANCE, 'email', 'subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $subscribedFoldersForCache, $expiration = 60 * 60 * 1); |
|
| 2670 | 2670 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2671 | 2671 | $autoFolderObjects = $folders = array(); |
| 2672 | 2672 | $autofolder_exists = array(); |
| 2673 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2674 | - if(isset($foldersNameSpace[$type])) { |
|
| 2675 | - if($_subscribedOnly) { |
|
| 2676 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2673 | + foreach (array('personal', 'others', 'shared') as $type) { |
|
| 2674 | + if (isset($foldersNameSpace[$type])) { |
|
| 2675 | + if ($_subscribedOnly) { |
|
| 2676 | + if (!empty($foldersNameSpace[$type]['subscribed'])) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2677 | 2677 | } else { |
| 2678 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2678 | + if (!empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2679 | 2679 | } |
| 2680 | - foreach((array)$listOfFolders as $folderName) { |
|
| 2680 | + foreach ((array)$listOfFolders as $folderName) { |
|
| 2681 | 2681 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2682 | 2682 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2683 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2684 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2683 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue; //when subscribedonly, we fetch all folders in one go. |
|
| 2684 | + if ($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all']) || in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2685 | 2685 | #echo "$folderName failed to be here <br>"; |
| 2686 | 2686 | continue; |
| 2687 | 2687 | } |
| 2688 | 2688 | if (isset($folders[$folderName])) continue; |
| 2689 | 2689 | if (isset($autoFolderObjects[$folderName])) continue; |
| 2690 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2690 | + if (empty($delimiter) || $delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2691 | 2691 | $folderParts = explode($delimiter, $folderName); |
| 2692 | 2692 | $shortName = array_pop($folderParts); |
| 2693 | 2693 | |
| 2694 | 2694 | $folderObject = new \stdClass; |
| 2695 | - $folderObject->delimiter = $delimiter; |
|
| 2696 | - $folderObject->folderName = $folderName; |
|
| 2697 | - $folderObject->shortFolderName = $shortName; |
|
| 2698 | - if(!$_subscribedOnly) { |
|
| 2695 | + $folderObject->delimiter = $delimiter; |
|
| 2696 | + $folderObject->folderName = $folderName; |
|
| 2697 | + $folderObject->shortFolderName = $shortName; |
|
| 2698 | + if (!$_subscribedOnly) { |
|
| 2699 | 2699 | #echo $folderName."->".$type."<br>"; |
| 2700 | 2700 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2701 | 2701 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | - if($_getCounters == true) { |
|
| 2704 | + if ($_getCounters == true) { |
|
| 2705 | 2705 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2706 | 2706 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2707 | 2707 | } |
| 2708 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 2708 | + if (strtoupper($folderName) == 'INBOX') { |
|
| 2709 | 2709 | $folderName = 'INBOX'; |
| 2710 | - $folderObject->folderName = 'INBOX'; |
|
| 2711 | - $folderObject->shortFolderName = 'INBOX'; |
|
| 2712 | - $folderObject->displayName = lang('INBOX'); |
|
| 2710 | + $folderObject->folderName = 'INBOX'; |
|
| 2711 | + $folderObject->shortFolderName = 'INBOX'; |
|
| 2712 | + $folderObject->displayName = lang('INBOX'); |
|
| 2713 | 2713 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2714 | - $folderObject->subscribed = true; |
|
| 2714 | + $folderObject->subscribed = true; |
|
| 2715 | 2715 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2716 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 2717 | - $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
|
| 2716 | + } elseif (in_array($shortName, self::$autoFolders)) { |
|
| 2717 | + $tmpfolderparts = explode($delimiter, $folderObject->folderName); |
|
| 2718 | 2718 | array_pop($tmpfolderparts); |
| 2719 | - $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
|
| 2719 | + $folderObject->displayName = implode($delimiter, $tmpfolderparts).$delimiter.lang($shortName); |
|
| 2720 | 2720 | $folderObject->shortDisplayName = lang($shortName); |
| 2721 | 2721 | unset($tmpfolderparts); |
| 2722 | 2722 | } else { |
@@ -2724,13 +2724,13 @@ discard block |
||
| 2724 | 2724 | $folderObject->shortDisplayName = $shortName; |
| 2725 | 2725 | } |
| 2726 | 2726 | //$folderName = $folderName; |
| 2727 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 2727 | + if (in_array($shortName, self::$autoFolders) && self::searchValueInFolderObjects($shortName, $autoFolderObjects) === false) { |
|
| 2728 | 2728 | $autoFolderObjects[$folderName] = $folderObject; |
| 2729 | 2729 | } else { |
| 2730 | 2730 | $folders[$folderName] = $folderObject; |
| 2731 | 2731 | } |
| 2732 | 2732 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2733 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 2733 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); |
|
| 2734 | 2734 | if (isset(self::$specialUseFolders[$folderName])) |
| 2735 | 2735 | { |
| 2736 | 2736 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2739,27 +2739,27 @@ discard block |
||
| 2739 | 2739 | } |
| 2740 | 2740 | } |
| 2741 | 2741 | if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
| 2742 | - uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
|
| 2742 | + uasort($autoFolderObjects, array($this, "sortByAutoFolderPos")); |
|
| 2743 | 2743 | } |
| 2744 | 2744 | // check if some standard folders are missing and need to be created |
| 2745 | 2745 | if (count($autofolder_exists) < count(self::$autoFolders) && $this->check_create_autofolders($autofolder_exists)) |
| 2746 | 2746 | { |
| 2747 | 2747 | // if new folders have been created, re-read folders ignoring the cache |
| 2748 | - return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2748 | + return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2749 | 2749 | } |
| 2750 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 2750 | + if (is_array($folders)) uasort($folders, array($this, "sortByDisplayName")); |
|
| 2751 | 2751 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2752 | 2752 | //_debug_array($folders2return); #exit; |
| 2753 | - $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
|
| 2754 | - if (($_subscribedOnly && $_getCounters===false) || |
|
| 2755 | - ($_subscribedOnly == false && $_getCounters===false && |
|
| 2753 | + $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject, (array)$autoFolderObjects, (array)$folders); |
|
| 2754 | + if (($_subscribedOnly && $_getCounters === false) || |
|
| 2755 | + ($_subscribedOnly == false && $_getCounters === false && |
|
| 2756 | 2756 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2757 | - $this->mailPreferences['showAllFoldersInFolderPane']==1)) |
|
| 2757 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1)) |
|
| 2758 | 2758 | { |
| 2759 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
|
| 2759 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), $folders2return, $expiration = 60 * 60 * 1); |
|
| 2760 | 2760 | } |
| 2761 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
|
| 2762 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 2761 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderBasicInfo, $expiration = 60 * 60 * 1); |
|
| 2762 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') '); |
|
| 2763 | 2763 | return $folders2return[$this->icServer->ImapServerId]; |
| 2764 | 2764 | } |
| 2765 | 2765 | |
@@ -2780,21 +2780,21 @@ discard block |
||
| 2780 | 2780 | * |
| 2781 | 2781 | * @return array arrays of folders |
| 2782 | 2782 | */ |
| 2783 | - function getFolderArrays ($_nodePath = null, $_onlyTopLevel = false, $_search= 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2783 | + function getFolderArrays($_nodePath = null, $_onlyTopLevel = false, $_search = 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2784 | 2784 | { |
| 2785 | 2785 | // delimiter |
| 2786 | 2786 | $delimiter = $this->getHierarchyDelimiter(); |
| 2787 | 2787 | |
| 2788 | - $folders = $nameSpace = array(); |
|
| 2788 | + $folders = $nameSpace = array(); |
|
| 2789 | 2789 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2790 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2791 | - $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
|
| 2790 | + foreach ($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2791 | + $nameSpace[$singleNameSpace['type']] = $singleNameSpace; |
|
| 2792 | 2792 | } |
| 2793 | 2793 | unset($nameSpaceTmp); |
| 2794 | 2794 | |
| 2795 | 2795 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2796 | 2796 | // Get special use folders |
| 2797 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 2797 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); // Set self::$specialUseFolders |
|
| 2798 | 2798 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2799 | 2799 | if ($_onlyTopLevel) // top level leaves |
| 2800 | 2800 | { |
@@ -2805,20 +2805,20 @@ discard block |
||
| 2805 | 2805 | if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
| 2806 | 2806 | if (self::$mailConfig['examineNamespace']) |
| 2807 | 2807 | { |
| 2808 | - $prefixes=array(); |
|
| 2808 | + $prefixes = array(); |
|
| 2809 | 2809 | if (is_array($nameSpace)) |
| 2810 | 2810 | { |
| 2811 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2811 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2812 | 2812 | $type = $singleNameSpace['type']; |
| 2813 | 2813 | |
| 2814 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 2814 | + if (is_array($singleNameSpace) && $singleNameSpace['prefix']) { |
|
| 2815 | 2815 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2816 | 2816 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2817 | - $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
|
| 2817 | + $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search == 0 ? 0 : 2, true); |
|
| 2818 | 2818 | if (is_array($result)) |
| 2819 | 2819 | { |
| 2820 | 2820 | ksort($result); |
| 2821 | - $topFolders = array_merge($topFolders,$result); |
|
| 2821 | + $topFolders = array_merge($topFolders, $result); |
|
| 2822 | 2822 | } |
| 2823 | 2823 | } |
| 2824 | 2824 | } |
@@ -2827,7 +2827,7 @@ discard block |
||
| 2827 | 2827 | |
| 2828 | 2828 | $autofolders = array(); |
| 2829 | 2829 | |
| 2830 | - foreach(self::$specialUseFolders as $path => $folder) |
|
| 2830 | + foreach (self::$specialUseFolders as $path => $folder) |
|
| 2831 | 2831 | { |
| 2832 | 2832 | if ($this->folderExists($path)) |
| 2833 | 2833 | { |
@@ -2835,9 +2835,9 @@ discard block |
||
| 2835 | 2835 | } |
| 2836 | 2836 | } |
| 2837 | 2837 | // Check if the special use folders are there, otherwise try to create them |
| 2838 | - if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders ($autofolders)) |
|
| 2838 | + if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders($autofolders)) |
|
| 2839 | 2839 | { |
| 2840 | - return $this->getFolderArrays ($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2840 | + return $this->getFolderArrays($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2841 | 2841 | } |
| 2842 | 2842 | |
| 2843 | 2843 | // now process topFolders for next level |
@@ -2845,13 +2845,13 @@ discard block |
||
| 2845 | 2845 | { |
| 2846 | 2846 | $pattern = "/\\".$delimiter."/"; |
| 2847 | 2847 | $reference = preg_replace($pattern, '', $node['MAILBOX']); |
| 2848 | - if(!empty($prefixes)) |
|
| 2848 | + if (!empty($prefixes)) |
|
| 2849 | 2849 | { |
| 2850 | 2850 | $reference = ''; |
| 2851 | - $tmpArray = explode($delimiter,$node['MAILBOX']); |
|
| 2852 | - foreach($tmpArray as $p) |
|
| 2851 | + $tmpArray = explode($delimiter, $node['MAILBOX']); |
|
| 2852 | + foreach ($tmpArray as $p) |
|
| 2853 | 2853 | { |
| 2854 | - $reference = empty($reference)?$p:$reference.$delimiter.$p; |
|
| 2854 | + $reference = empty($reference) ? $p : $reference.$delimiter.$p; |
|
| 2855 | 2855 | } |
| 2856 | 2856 | } |
| 2857 | 2857 | $mainFolder = $subFolders = array(); |
@@ -2887,19 +2887,19 @@ discard block |
||
| 2887 | 2887 | $nFolders [$path] = $folder; |
| 2888 | 2888 | } |
| 2889 | 2889 | } |
| 2890 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 2890 | + if (is_array($aFolders)) uasort($aFolders, array($this, 'sortByAutofolder')); |
|
| 2891 | 2891 | //ksort($aFolders); |
| 2892 | 2892 | |
| 2893 | 2893 | // Sort none auto folders base on mailbox name |
| 2894 | - uasort($nFolders,array($this,'sortByMailbox')); |
|
| 2894 | + uasort($nFolders, array($this, 'sortByMailbox')); |
|
| 2895 | 2895 | |
| 2896 | - $subFolders = array_merge($aFolders,$nFolders); |
|
| 2896 | + $subFolders = array_merge($aFolders, $nFolders); |
|
| 2897 | 2897 | } |
| 2898 | 2898 | else |
| 2899 | 2899 | { |
| 2900 | 2900 | if (is_array($subFolders)) ksort($subFolders); |
| 2901 | 2901 | } |
| 2902 | - $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
|
| 2902 | + $folders = array_merge($folders, (array)$mainFolder, (array)$subFolders); |
|
| 2903 | 2903 | } |
| 2904 | 2904 | } |
| 2905 | 2905 | elseif ($_nodePath) // single node |
@@ -2926,9 +2926,9 @@ discard block |
||
| 2926 | 2926 | $folders = $this->icServer->getMailboxes($path, $_search, true); |
| 2927 | 2927 | } |
| 2928 | 2928 | |
| 2929 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 2929 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 2930 | 2930 | } |
| 2931 | - elseif(!$_nodePath) // all |
|
| 2931 | + elseif (!$_nodePath) // all |
|
| 2932 | 2932 | { |
| 2933 | 2933 | if ($_subscribedOnly) |
| 2934 | 2934 | { |
@@ -2944,101 +2944,101 @@ discard block |
||
| 2944 | 2944 | { |
| 2945 | 2945 | // SORTING FOLDERS |
| 2946 | 2946 | //self::$debugTimes=true; |
| 2947 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2947 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 2948 | 2948 | // Merge of all auto folders and specialusefolders |
| 2949 | 2949 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 2950 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 2950 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 2951 | 2951 | $tmpFolders = $folders; |
| 2952 | - $inboxFolderObject=$inboxSubFolderObjects=$autoFolderObjects=$typeFolderObject=$mySpecialUseFolders=array(); |
|
| 2953 | - $googleMailFolderObject=$googleAutoFolderObjects=$googleSubFolderObjects=array(); |
|
| 2954 | - $isGoogleMail=false; |
|
| 2955 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 2952 | + $inboxFolderObject = $inboxSubFolderObjects = $autoFolderObjects = $typeFolderObject = $mySpecialUseFolders = array(); |
|
| 2953 | + $googleMailFolderObject = $googleAutoFolderObjects = $googleSubFolderObjects = array(); |
|
| 2954 | + $isGoogleMail = false; |
|
| 2955 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 2956 | 2956 | { |
| 2957 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 2957 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF] = $this->getFolderByType($aF, false); |
|
| 2958 | 2958 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2959 | 2959 | } |
| 2960 | 2960 | //error_log(array2string($mySpecialUseFolders)); |
| 2961 | 2961 | foreach ($tmpFolders as $k => $f) { |
| 2962 | - $sorted=false; |
|
| 2963 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 2964 | - if (strtoupper($k)=='INBOX') { |
|
| 2962 | + $sorted = false; |
|
| 2963 | + if (strtoupper(substr($k, 0, 5)) == 'INBOX') { |
|
| 2964 | + if (strtoupper($k) == 'INBOX') { |
|
| 2965 | 2965 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 2966 | - $inboxFolderObject[$k]=$f; |
|
| 2966 | + $inboxFolderObject[$k] = $f; |
|
| 2967 | 2967 | unset($folders[$k]); |
| 2968 | - $sorted=true; |
|
| 2968 | + $sorted = true; |
|
| 2969 | 2969 | } else { |
| 2970 | - $isAutoFolder=false; |
|
| 2971 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 2970 | + $isAutoFolder = false; |
|
| 2971 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 2972 | 2972 | { |
| 2973 | 2973 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2974 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 2975 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 2976 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 2974 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 2975 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 2976 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 2977 | 2977 | { |
| 2978 | 2978 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 2979 | - $isAutoFolder=true; |
|
| 2980 | - $autoFolderObjects[$k]=$f; |
|
| 2979 | + $isAutoFolder = true; |
|
| 2980 | + $autoFolderObjects[$k] = $f; |
|
| 2981 | 2981 | break; |
| 2982 | 2982 | } |
| 2983 | 2983 | } |
| 2984 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 2984 | + if ($isAutoFolder == false) $inboxSubFolderObjects[$k] = $f; |
|
| 2985 | 2985 | unset($folders[$k]); |
| 2986 | - $sorted=true; |
|
| 2986 | + $sorted = true; |
|
| 2987 | 2987 | } |
| 2988 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 2989 | - $isGoogleMail=true; |
|
| 2990 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 2991 | - $googleMailFolderObject[$k]=$f; |
|
| 2988 | + } elseif (strtoupper(substr($k, 0, 13)) == '[GOOGLE MAIL]') { |
|
| 2989 | + $isGoogleMail = true; |
|
| 2990 | + if (strtoupper($k) == '[GOOGLE MAIL]') { |
|
| 2991 | + $googleMailFolderObject[$k] = $f; |
|
| 2992 | 2992 | unset($folders[$k]); |
| 2993 | - $sorted=true; |
|
| 2993 | + $sorted = true; |
|
| 2994 | 2994 | } else { |
| 2995 | - $isAutoFolder=false; |
|
| 2996 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 2995 | + $isAutoFolder = false; |
|
| 2996 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 2997 | 2997 | { |
| 2998 | 2998 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2999 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3000 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3001 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 2999 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3000 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3001 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3002 | 3002 | { |
| 3003 | 3003 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3004 | - $isAutoFolder=true; |
|
| 3005 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3004 | + $isAutoFolder = true; |
|
| 3005 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3006 | 3006 | break; |
| 3007 | 3007 | } |
| 3008 | 3008 | } |
| 3009 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3009 | + if ($isAutoFolder == false) $googleSubFolderObjects[$k] = $f; |
|
| 3010 | 3010 | unset($folders[$k]); |
| 3011 | - $sorted=true; |
|
| 3011 | + $sorted = true; |
|
| 3012 | 3012 | } |
| 3013 | 3013 | } else { |
| 3014 | - $isAutoFolder=false; |
|
| 3015 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3014 | + $isAutoFolder = false; |
|
| 3015 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3016 | 3016 | { |
| 3017 | 3017 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3018 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3019 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3020 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3018 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3019 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3020 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3021 | 3021 | { |
| 3022 | 3022 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3023 | - $isAutoFolder=true; |
|
| 3024 | - $autoFolderObjects[$k]=$f; |
|
| 3023 | + $isAutoFolder = true; |
|
| 3024 | + $autoFolderObjects[$k] = $f; |
|
| 3025 | 3025 | unset($folders[$k]); |
| 3026 | - $sorted=true; |
|
| 3026 | + $sorted = true; |
|
| 3027 | 3027 | break; |
| 3028 | 3028 | } |
| 3029 | 3029 | } |
| 3030 | 3030 | } |
| 3031 | 3031 | |
| 3032 | - if ($sorted==false) |
|
| 3032 | + if ($sorted == false) |
|
| 3033 | 3033 | { |
| 3034 | - foreach(array('others','shared') as $type) |
|
| 3034 | + foreach (array('others', 'shared') as $type) |
|
| 3035 | 3035 | { |
| 3036 | - if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
|
| 3036 | + if ($nameSpace[$type]['prefix_present'] && $nameSpace[$type]['prefix']) |
|
| 3037 | 3037 | { |
| 3038 | - if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
|
| 3039 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3038 | + if (substr($k, 0, strlen($nameSpace[$type]['prefix'])) == $nameSpace[$type]['prefix'] || |
|
| 3039 | + substr($k, 0, strlen($nameSpace[$type]['prefix']) - strlen($nameSpace[$type]['delimiter'])) == substr($nameSpace[$type]['prefix'], 0, strlen($nameSpace[$type]['delimiter']) * -1)) { |
|
| 3040 | 3040 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3041 | - $typeFolderObject[$type][$k]=$f; |
|
| 3041 | + $typeFolderObject[$type][$k] = $f; |
|
| 3042 | 3042 | unset($folders[$k]); |
| 3043 | 3043 | } |
| 3044 | 3044 | } |
@@ -3049,40 +3049,40 @@ discard block |
||
| 3049 | 3049 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3050 | 3050 | $autoFolderObjectsTmp = $autoFolderObjects; |
| 3051 | 3051 | unset($autoFolderObjects); |
| 3052 | - uasort($autoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3053 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3052 | + uasort($autoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3053 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3054 | 3054 | { |
| 3055 | - foreach($autoFolderObjectsTmp as $k => $f) |
|
| 3055 | + foreach ($autoFolderObjectsTmp as $k => $f) |
|
| 3056 | 3056 | { |
| 3057 | - if($aF && ($mySpecialUseFolders[$aF]==$k || |
|
| 3058 | - substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || |
|
| 3059 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3057 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || |
|
| 3058 | + substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || |
|
| 3059 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) |
|
| 3060 | 3060 | { |
| 3061 | - $autoFolderObjects[$k]=$f; |
|
| 3061 | + $autoFolderObjects[$k] = $f; |
|
| 3062 | 3062 | } |
| 3063 | 3063 | } |
| 3064 | 3064 | } |
| 3065 | 3065 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3066 | 3066 | if (!$isGoogleMail) { |
| 3067 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3067 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$inboxSubFolderObjects, (array)$folders, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3068 | 3068 | } else { |
| 3069 | 3069 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3070 | 3070 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3071 | 3071 | unset($googleAutoFolderObjects); |
| 3072 | - uasort($gAutoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3073 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3072 | + uasort($gAutoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3073 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3074 | 3074 | { |
| 3075 | - foreach($gAutoFolderObjectsTmp as $k => $f) |
|
| 3075 | + foreach ($gAutoFolderObjectsTmp as $k => $f) |
|
| 3076 | 3076 | { |
| 3077 | - if($aF && ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter)) |
|
| 3077 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter)) |
|
| 3078 | 3078 | { |
| 3079 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3079 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3080 | 3080 | } |
| 3081 | 3081 | } |
| 3082 | 3082 | } |
| 3083 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3083 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$folders, (array)$googleMailFolderObject, $googleAutoFolderObjects, $googleSubFolderObjects, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3084 | 3084 | } |
| 3085 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3085 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3086 | 3086 | //self::$debugTimes=false; |
| 3087 | 3087 | } |
| 3088 | 3088 | // Get counter information and add them to each fetched folders array |
@@ -3104,10 +3104,10 @@ discard block |
||
| 3104 | 3104 | * @param array $autofolders_exists existing folders, no need to check their existance again |
| 3105 | 3105 | * @return int number of new folders created |
| 3106 | 3106 | */ |
| 3107 | - function check_create_autofolders(array $autofolders_exists=array()) |
|
| 3107 | + function check_create_autofolders(array $autofolders_exists = array()) |
|
| 3108 | 3108 | { |
| 3109 | 3109 | $num_created = 0; |
| 3110 | - foreach(self::$autoFolders as $folder) |
|
| 3110 | + foreach (self::$autoFolders as $folder) |
|
| 3111 | 3111 | { |
| 3112 | 3112 | $created = false; |
| 3113 | 3113 | if (!in_array($folder, $autofolders_exists) && $this->_getSpecialUseFolder($folder, true, $created) && |
@@ -3132,7 +3132,7 @@ discard block |
||
| 3132 | 3132 | $rv = false; |
| 3133 | 3133 | foreach ($haystack as $k => $v) |
| 3134 | 3134 | { |
| 3135 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3135 | + foreach ($v as &$sv) {if (trim($sv) == trim($needle)) return $k; } |
|
| 3136 | 3136 | } |
| 3137 | 3137 | return $rv; |
| 3138 | 3138 | } |
@@ -3145,9 +3145,9 @@ discard block |
||
| 3145 | 3145 | * @param array $b array of folders |
| 3146 | 3146 | * @return int expect values (0, 1 or -1) |
| 3147 | 3147 | */ |
| 3148 | - function sortByMailbox($a,$b) |
|
| 3148 | + function sortByMailbox($a, $b) |
|
| 3149 | 3149 | { |
| 3150 | - return strcasecmp($a['MAILBOX'],$b['MAILBOX']); |
|
| 3150 | + return strcasecmp($a['MAILBOX'], $b['MAILBOX']); |
|
| 3151 | 3151 | } |
| 3152 | 3152 | |
| 3153 | 3153 | /** |
@@ -3157,13 +3157,13 @@ discard block |
||
| 3157 | 3157 | * @param string $_hDelimiter hierarchy delimiter |
| 3158 | 3158 | * @return array returns an array of data extracted from given node path |
| 3159 | 3159 | */ |
| 3160 | - static function pathToFolderData ($_path, $_hDelimiter) |
|
| 3160 | + static function pathToFolderData($_path, $_hDelimiter) |
|
| 3161 | 3161 | { |
| 3162 | 3162 | if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
| 3163 | 3163 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3164 | 3164 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3165 | 3165 | $name = array_pop($parts); |
| 3166 | - return array ( |
|
| 3166 | + return array( |
|
| 3167 | 3167 | 'name' => $name, |
| 3168 | 3168 | 'mailbox' => $path, |
| 3169 | 3169 | 'parent' => implode($_hDelimiter, $parts), |
@@ -3186,8 +3186,8 @@ discard block |
||
| 3186 | 3186 | // 0, 1 und -1 |
| 3187 | 3187 | $a = self::pathToFolderData($_a['MAILBOX'], $_a['delimiter']); |
| 3188 | 3188 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3189 | - $pos1 = array_search(trim($a['name']),self::$autoFolders); |
|
| 3190 | - $pos2 = array_search(trim($b['name']),self::$autoFolders); |
|
| 3189 | + $pos1 = array_search(trim($a['name']), self::$autoFolders); |
|
| 3190 | + $pos2 = array_search(trim($b['name']), self::$autoFolders); |
|
| 3191 | 3191 | if ($pos1 == $pos2) return 0; |
| 3192 | 3192 | return ($pos1 < $pos2) ? -1 : 1; |
| 3193 | 3193 | } |
@@ -3200,10 +3200,10 @@ discard block |
||
| 3200 | 3200 | * @param object $b array of folderobjects |
| 3201 | 3201 | * @return int expect values (0, 1 or -1) |
| 3202 | 3202 | */ |
| 3203 | - function sortByDisplayName($a,$b) |
|
| 3203 | + function sortByDisplayName($a, $b) |
|
| 3204 | 3204 | { |
| 3205 | 3205 | // 0, 1 und -1 |
| 3206 | - return strcasecmp($a->displayName,$b->displayName); |
|
| 3206 | + return strcasecmp($a->displayName, $b->displayName); |
|
| 3207 | 3207 | } |
| 3208 | 3208 | |
| 3209 | 3209 | /** |
@@ -3214,11 +3214,11 @@ discard block |
||
| 3214 | 3214 | * @param object $b array of folderobjects |
| 3215 | 3215 | * @return int expect values (0, 1 or -1) |
| 3216 | 3216 | */ |
| 3217 | - function sortByAutoFolderPos($a,$b) |
|
| 3217 | + function sortByAutoFolderPos($a, $b) |
|
| 3218 | 3218 | { |
| 3219 | 3219 | // 0, 1 und -1 |
| 3220 | - $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
|
| 3221 | - $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
|
| 3220 | + $pos1 = array_search(trim($a->shortFolderName), self::$autoFolders); |
|
| 3221 | + $pos2 = array_search(trim($b->shortFolderName), self::$autoFolders); |
|
| 3222 | 3222 | if ($pos1 == $pos2) return 0; |
| 3223 | 3223 | return ($pos1 < $pos2) ? -1 : 1; |
| 3224 | 3224 | } |
@@ -3231,7 +3231,7 @@ discard block |
||
| 3231 | 3231 | * @param boolean $_returnObject return the counters as object rather than an array |
| 3232 | 3232 | * @return mixed false or array of counters array(MESSAGES,UNSEEN,RECENT,UIDNEXT,UIDVALIDITY) or object |
| 3233 | 3233 | */ |
| 3234 | - function getMailBoxCounters($folderName,$_returnObject=true) |
|
| 3234 | + function getMailBoxCounters($folderName, $_returnObject = true) |
|
| 3235 | 3235 | { |
| 3236 | 3236 | try |
| 3237 | 3237 | { |
@@ -3243,9 +3243,9 @@ discard block |
||
| 3243 | 3243 | if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
| 3244 | 3244 | return false; |
| 3245 | 3245 | } |
| 3246 | - if(is_array($folderStatus)) { |
|
| 3247 | - if ($_returnObject===false) return $folderStatus; |
|
| 3248 | - $status = new \stdClass; |
|
| 3246 | + if (is_array($folderStatus)) { |
|
| 3247 | + if ($_returnObject === false) return $folderStatus; |
|
| 3248 | + $status = new \stdClass; |
|
| 3249 | 3249 | $status->messages = $folderStatus['MESSAGES']; |
| 3250 | 3250 | $status->unseen = $folderStatus['UNSEEN']; |
| 3251 | 3251 | $status->recent = $folderStatus['RECENT']; |
@@ -3267,42 +3267,42 @@ discard block |
||
| 3267 | 3267 | * @param string $reclevel 0, counter to keep track of the current recursionlevel |
| 3268 | 3268 | * @return array of mailboxes |
| 3269 | 3269 | */ |
| 3270 | - function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
|
| 3270 | + function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0) |
|
| 3271 | 3271 | { |
| 3272 | 3272 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3273 | - $maxreclevel=25; |
|
| 3273 | + $maxreclevel = 25; |
|
| 3274 | 3274 | if ($reclevel > $maxreclevel) { |
| 3275 | - error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3275 | + error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3276 | 3276 | return array(); |
| 3277 | 3277 | } |
| 3278 | 3278 | $reclevel++; |
| 3279 | 3279 | // clean up double delimiters |
| 3280 | - $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox); |
|
| 3280 | + $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox); |
|
| 3281 | 3281 | //get that mailbox in question |
| 3282 | - $mbx = $this->icServer->getMailboxes($_mailbox,1,true); |
|
| 3282 | + $mbx = $this->icServer->getMailboxes($_mailbox, 1, true); |
|
| 3283 | 3283 | $mbxkeys = array_keys($mbx); |
| 3284 | 3284 | #_debug_array($mbx); |
| 3285 | 3285 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3286 | 3286 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3287 | 3287 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3288 | - 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"]))) { |
|
| 3288 | + 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"]))) { |
|
| 3289 | 3289 | // if there are children fetch them |
| 3290 | 3290 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3291 | 3291 | |
| 3292 | - $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
|
| 3292 | + $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false); |
|
| 3293 | 3293 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3294 | 3294 | //_debug_array($buff); |
| 3295 | 3295 | $allMailboxes = array(); |
| 3296 | 3296 | foreach ($buff as $mbxname) { |
| 3297 | 3297 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3298 | - $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
|
| 3298 | + $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']); |
|
| 3299 | 3299 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
| 3300 | - if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3300 | + if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3301 | 3301 | { |
| 3302 | 3302 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3303 | 3303 | } |
| 3304 | 3304 | } |
| 3305 | - 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']; |
|
| 3305 | + 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']; |
|
| 3306 | 3306 | return $allMailboxes; |
| 3307 | 3307 | } else { |
| 3308 | 3308 | return array($_mailbox); |
@@ -3317,18 +3317,18 @@ discard block |
||
| 3317 | 3317 | * @param boolean& $created =null on return true: if folder was just created, false if not |
| 3318 | 3318 | * @return mixed string or false |
| 3319 | 3319 | */ |
| 3320 | - function _getSpecialUseFolder($_type, $_checkexistance=TRUE, &$created=null) |
|
| 3320 | + function _getSpecialUseFolder($_type, $_checkexistance = TRUE, &$created = null) |
|
| 3321 | 3321 | { |
| 3322 | 3322 | static $types = array( |
| 3323 | - 'Drafts' => array('profileKey'=>'acc_folder_draft','autoFolderName'=>'Drafts'), |
|
| 3324 | - 'Template' => array('profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'), |
|
| 3325 | - 'Trash' => array('profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'), |
|
| 3326 | - 'Sent' => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'), |
|
| 3327 | - 'Junk' => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'), |
|
| 3328 | - 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
|
| 3329 | - 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
|
| 3323 | + 'Drafts' => array('profileKey'=>'acc_folder_draft', 'autoFolderName'=>'Drafts'), |
|
| 3324 | + 'Template' => array('profileKey'=>'acc_folder_template', 'autoFolderName'=>'Templates'), |
|
| 3325 | + 'Trash' => array('profileKey'=>'acc_folder_trash', 'autoFolderName'=>'Trash'), |
|
| 3326 | + 'Sent' => array('profileKey'=>'acc_folder_sent', 'autoFolderName'=>'Sent'), |
|
| 3327 | + 'Junk' => array('profileKey'=>'acc_folder_junk', 'autoFolderName'=>'Junk'), |
|
| 3328 | + 'Outbox' => array('profileKey'=>'acc_folder_outbox', 'autoFolderName'=>'Outbox'), |
|
| 3329 | + 'Archive' => array('profileKey'=>'acc_folder_archive', 'autoFolderName'=>'Archive'), |
|
| 3330 | 3330 | ); |
| 3331 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3331 | + if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3332 | 3332 | $created = false; |
| 3333 | 3333 | if (!isset($types[$_type])) |
| 3334 | 3334 | { |
@@ -3350,7 +3350,7 @@ discard block |
||
| 3350 | 3350 | } |
| 3351 | 3351 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3352 | 3352 | if ($_type == 'Archive') { |
| 3353 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3353 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3354 | 3354 | return false; |
| 3355 | 3355 | } else { |
| 3356 | 3356 | return $_folderName; |
@@ -3358,38 +3358,38 @@ discard block |
||
| 3358 | 3358 | |
| 3359 | 3359 | } |
| 3360 | 3360 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3361 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3361 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3362 | 3362 | try |
| 3363 | 3363 | { |
| 3364 | 3364 | $error = null; |
| 3365 | 3365 | if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
| 3366 | 3366 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3367 | 3367 | } |
| 3368 | - catch(Exception $e) |
|
| 3368 | + catch (Exception $e) |
|
| 3369 | 3369 | { |
| 3370 | 3370 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage().':'.function_backtrace()); |
| 3371 | 3371 | $_folderName = false; |
| 3372 | 3372 | } |
| 3373 | 3373 | } |
| 3374 | 3374 | // not sure yet if false is the correct behavior on none |
| 3375 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 3375 | + if ($_folderName == 'none') return 'none'; //false; |
|
| 3376 | 3376 | //no (valid) folder found yet; try specialUseFolders |
| 3377 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 3377 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type, self::$specialUseFolders))) $_folderName = $f; |
|
| 3378 | 3378 | //no specialUseFolder; try some Defaults |
| 3379 | 3379 | if (empty($_folderName) && isset($types[$_type])) |
| 3380 | 3380 | { |
| 3381 | 3381 | $nameSpace = $this->_getNameSpaces(); |
| 3382 | - $prefix=''; |
|
| 3382 | + $prefix = ''; |
|
| 3383 | 3383 | foreach ($nameSpace as $nSp) |
| 3384 | 3384 | { |
| 3385 | - if ($nSp['type']=='personal') |
|
| 3385 | + if ($nSp['type'] == 'personal') |
|
| 3386 | 3386 | { |
| 3387 | 3387 | //error_log(__METHOD__.__LINE__.array2string($nSp)); |
| 3388 | 3388 | $prefix = $nSp['prefix']; |
| 3389 | 3389 | break; |
| 3390 | 3390 | } |
| 3391 | 3391 | } |
| 3392 | - if ($this->folderExists($prefix.$types[$_type]['autoFolderName'],true)) |
|
| 3392 | + if ($this->folderExists($prefix.$types[$_type]['autoFolderName'], true)) |
|
| 3393 | 3393 | { |
| 3394 | 3394 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3395 | 3395 | } |
@@ -3398,11 +3398,11 @@ discard block |
||
| 3398 | 3398 | try |
| 3399 | 3399 | { |
| 3400 | 3400 | $error = null; |
| 3401 | - $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
|
| 3401 | + $this->createFolder('', $prefix.$types[$_type]['autoFolderName'], $error); |
|
| 3402 | 3402 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3403 | 3403 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3404 | 3404 | } |
| 3405 | - catch(Exception $e) |
|
| 3405 | + catch (Exception $e) |
|
| 3406 | 3406 | { |
| 3407 | 3407 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage()); |
| 3408 | 3408 | $_folderName = false; |
@@ -3418,7 +3418,7 @@ discard block |
||
| 3418 | 3418 | * @param boolean $_checkexistance trigger check for existance |
| 3419 | 3419 | * @return mixed string or false |
| 3420 | 3420 | */ |
| 3421 | - function getFolderByType($type, $_checkexistance=false) |
|
| 3421 | + function getFolderByType($type, $_checkexistance = false) |
|
| 3422 | 3422 | { |
| 3423 | 3423 | return $this->_getSpecialUseFolder($type, $_checkexistance); |
| 3424 | 3424 | } |
@@ -3428,7 +3428,7 @@ discard block |
||
| 3428 | 3428 | * @param boolean $_checkexistance trigger check for existance |
| 3429 | 3429 | * @return mixed string or false |
| 3430 | 3430 | */ |
| 3431 | - function getJunkFolder($_checkexistance=TRUE) |
|
| 3431 | + function getJunkFolder($_checkexistance = TRUE) |
|
| 3432 | 3432 | { |
| 3433 | 3433 | return $this->_getSpecialUseFolder('Junk', $_checkexistance); |
| 3434 | 3434 | } |
@@ -3438,7 +3438,7 @@ discard block |
||
| 3438 | 3438 | * @param boolean $_checkexistance trigger check for existance |
| 3439 | 3439 | * @return mixed string or false |
| 3440 | 3440 | */ |
| 3441 | - function getDraftFolder($_checkexistance=TRUE) |
|
| 3441 | + function getDraftFolder($_checkexistance = TRUE) |
|
| 3442 | 3442 | { |
| 3443 | 3443 | return $this->_getSpecialUseFolder('Drafts', $_checkexistance); |
| 3444 | 3444 | } |
@@ -3448,7 +3448,7 @@ discard block |
||
| 3448 | 3448 | * @param boolean $_checkexistance trigger check for existance |
| 3449 | 3449 | * @return mixed string or false |
| 3450 | 3450 | */ |
| 3451 | - function getTemplateFolder($_checkexistance=TRUE) |
|
| 3451 | + function getTemplateFolder($_checkexistance = TRUE) |
|
| 3452 | 3452 | { |
| 3453 | 3453 | return $this->_getSpecialUseFolder('Template', $_checkexistance); |
| 3454 | 3454 | } |
@@ -3458,7 +3458,7 @@ discard block |
||
| 3458 | 3458 | * @param boolean $_checkexistance trigger check for existance |
| 3459 | 3459 | * @return mixed string or false |
| 3460 | 3460 | */ |
| 3461 | - function getTrashFolder($_checkexistance=TRUE) |
|
| 3461 | + function getTrashFolder($_checkexistance = TRUE) |
|
| 3462 | 3462 | { |
| 3463 | 3463 | return $this->_getSpecialUseFolder('Trash', $_checkexistance); |
| 3464 | 3464 | } |
@@ -3468,7 +3468,7 @@ discard block |
||
| 3468 | 3468 | * @param boolean $_checkexistance trigger check for existance |
| 3469 | 3469 | * @return mixed string or false |
| 3470 | 3470 | */ |
| 3471 | - function getSentFolder($_checkexistance=TRUE) |
|
| 3471 | + function getSentFolder($_checkexistance = TRUE) |
|
| 3472 | 3472 | { |
| 3473 | 3473 | return $this->_getSpecialUseFolder('Sent', $_checkexistance); |
| 3474 | 3474 | } |
@@ -3478,7 +3478,7 @@ discard block |
||
| 3478 | 3478 | * @param boolean $_checkexistance trigger check for existance |
| 3479 | 3479 | * @return mixed string or false |
| 3480 | 3480 | */ |
| 3481 | - function getOutboxFolder($_checkexistance=TRUE) |
|
| 3481 | + function getOutboxFolder($_checkexistance = TRUE) |
|
| 3482 | 3482 | { |
| 3483 | 3483 | return $this->_getSpecialUseFolder('Outbox', $_checkexistance); |
| 3484 | 3484 | } |
@@ -3488,7 +3488,7 @@ discard block |
||
| 3488 | 3488 | * @param boolean $_checkexistance trigger check for existance . We do no autocreation for configured Archive folder |
| 3489 | 3489 | * @return mixed string or false |
| 3490 | 3490 | */ |
| 3491 | - function getArchiveFolder($_checkexistance=TRUE) |
|
| 3491 | + function getArchiveFolder($_checkexistance = TRUE) |
|
| 3492 | 3492 | { |
| 3493 | 3493 | return $this->_getSpecialUseFolder('Archive', $_checkexistance); |
| 3494 | 3494 | } |
@@ -3499,10 +3499,10 @@ discard block |
||
| 3499 | 3499 | * @param boolean $_checkexistance trigger check for existance |
| 3500 | 3500 | * @return boolean |
| 3501 | 3501 | */ |
| 3502 | - function isSentFolder($_folderName, $_checkexistance=TRUE) |
|
| 3502 | + function isSentFolder($_folderName, $_checkexistance = TRUE) |
|
| 3503 | 3503 | { |
| 3504 | 3504 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3505 | - if(empty($sentFolder)) { |
|
| 3505 | + if (empty($sentFolder)) { |
|
| 3506 | 3506 | return false; |
| 3507 | 3507 | } |
| 3508 | 3508 | // does the folder exist??? |
@@ -3510,7 +3510,7 @@ discard block |
||
| 3510 | 3510 | return false; |
| 3511 | 3511 | } |
| 3512 | 3512 | |
| 3513 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 3513 | + if (false !== stripos($_folderName, $sentFolder)) { |
|
| 3514 | 3514 | return true; |
| 3515 | 3515 | } else { |
| 3516 | 3516 | return false; |
@@ -3523,15 +3523,15 @@ discard block |
||
| 3523 | 3523 | * @param boolean $_checkexistance trigger check for existance |
| 3524 | 3524 | * @return boolean |
| 3525 | 3525 | */ |
| 3526 | - function isOutbox($_folderName, $_checkexistance=TRUE) |
|
| 3526 | + function isOutbox($_folderName, $_checkexistance = TRUE) |
|
| 3527 | 3527 | { |
| 3528 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 3528 | + if (stripos($_folderName, 'Outbox') === false) { |
|
| 3529 | 3529 | return false; |
| 3530 | 3530 | } |
| 3531 | 3531 | // does the folder exist??? |
| 3532 | 3532 | if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) { |
| 3533 | 3533 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3534 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 3534 | + if (false !== stripos($_folderName, $outboxFolder)) { |
|
| 3535 | 3535 | return true; |
| 3536 | 3536 | } else { |
| 3537 | 3537 | return false; |
@@ -3546,18 +3546,18 @@ discard block |
||
| 3546 | 3546 | * @param boolean $_checkexistance trigger check for existance |
| 3547 | 3547 | * @return boolean |
| 3548 | 3548 | */ |
| 3549 | - function isDraftFolder($_folderName, $_checkexistance=TRUE) |
|
| 3549 | + function isDraftFolder($_folderName, $_checkexistance = TRUE) |
|
| 3550 | 3550 | { |
| 3551 | 3551 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3552 | - if(empty($draftFolder)) { |
|
| 3552 | + if (empty($draftFolder)) { |
|
| 3553 | 3553 | return false; |
| 3554 | 3554 | } |
| 3555 | 3555 | // does the folder exist??? |
| 3556 | 3556 | if ($_checkexistance && !$this->folderExists($_folderName)) { |
| 3557 | 3557 | return false; |
| 3558 | 3558 | } |
| 3559 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3560 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 3559 | + if (is_a($_folderName, "Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3560 | + if (false !== stripos($_folderName, $draftFolder)) { |
|
| 3561 | 3561 | return true; |
| 3562 | 3562 | } else { |
| 3563 | 3563 | return false; |
@@ -3570,10 +3570,10 @@ discard block |
||
| 3570 | 3570 | * @param boolean $_checkexistance trigger check for existance |
| 3571 | 3571 | * @return boolean |
| 3572 | 3572 | */ |
| 3573 | - function isTrashFolder($_folderName, $_checkexistance=TRUE) |
|
| 3573 | + function isTrashFolder($_folderName, $_checkexistance = TRUE) |
|
| 3574 | 3574 | { |
| 3575 | 3575 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3576 | - if(empty($trashFolder)) { |
|
| 3576 | + if (empty($trashFolder)) { |
|
| 3577 | 3577 | return false; |
| 3578 | 3578 | } |
| 3579 | 3579 | // does the folder exist??? |
@@ -3581,7 +3581,7 @@ discard block |
||
| 3581 | 3581 | return false; |
| 3582 | 3582 | } |
| 3583 | 3583 | |
| 3584 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 3584 | + if (false !== stripos($_folderName, $trashFolder)) { |
|
| 3585 | 3585 | return true; |
| 3586 | 3586 | } else { |
| 3587 | 3587 | return false; |
@@ -3594,10 +3594,10 @@ discard block |
||
| 3594 | 3594 | * @param boolean $_checkexistance trigger check for existance |
| 3595 | 3595 | * @return boolean |
| 3596 | 3596 | */ |
| 3597 | - function isTemplateFolder($_folderName, $_checkexistance=TRUE) |
|
| 3597 | + function isTemplateFolder($_folderName, $_checkexistance = TRUE) |
|
| 3598 | 3598 | { |
| 3599 | 3599 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3600 | - if(empty($templateFolder)) { |
|
| 3600 | + if (empty($templateFolder)) { |
|
| 3601 | 3601 | return false; |
| 3602 | 3602 | } |
| 3603 | 3603 | // does the folder exist??? |
@@ -3605,7 +3605,7 @@ discard block |
||
| 3605 | 3605 | return false; |
| 3606 | 3606 | } |
| 3607 | 3607 | |
| 3608 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 3608 | + if (false !== stripos($_folderName, $templateFolder)) { |
|
| 3609 | 3609 | return true; |
| 3610 | 3610 | } else { |
| 3611 | 3611 | return false; |
@@ -3618,24 +3618,24 @@ discard block |
||
| 3618 | 3618 | * @param boolean $_forceCheck trigger check for existance on icServer |
| 3619 | 3619 | * @return mixed string or false |
| 3620 | 3620 | */ |
| 3621 | - function folderExists($_folder, $_forceCheck=false) |
|
| 3621 | + function folderExists($_folder, $_forceCheck = false) |
|
| 3622 | 3622 | { |
| 3623 | 3623 | static $folderInfo; |
| 3624 | 3624 | $forceCheck = $_forceCheck; |
| 3625 | 3625 | if (empty($_folder)) |
| 3626 | 3626 | { |
| 3627 | 3627 | // this error is more or less without significance, unless we force the check |
| 3628 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3628 | + if ($_forceCheck === true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3629 | 3629 | return false; |
| 3630 | 3630 | } |
| 3631 | 3631 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3632 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3633 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3632 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox") && $_forceCheck === false) return true; |
|
| 3633 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3634 | 3634 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3635 | 3635 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3636 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 3636 | + if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 5); |
|
| 3637 | 3637 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3638 | - if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
|
| 3638 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck === false) |
|
| 3639 | 3639 | { |
| 3640 | 3640 | //error_log(__METHOD__.' ('.__LINE__.') '.' Using cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID); |
| 3641 | 3641 | return $folderInfo[$this->profileID][$_folder]; |
@@ -3651,7 +3651,7 @@ discard block |
||
| 3651 | 3651 | |
| 3652 | 3652 | // does the folder exist??? |
| 3653 | 3653 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3654 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3654 | + if ($forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3655 | 3655 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3656 | 3656 | //return false; |
| 3657 | 3657 | //try to connect |
@@ -3667,12 +3667,12 @@ discard block |
||
| 3667 | 3667 | } |
| 3668 | 3668 | //error_log(__METHOD__.' ('.__LINE__.') '.' Folder Exists:'.$folderInfo[$this->profileID][$_folder].function_backtrace()); |
| 3669 | 3669 | |
| 3670 | - if(!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3670 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3671 | 3671 | $folderInfo[$this->profileID][$_folder] !== true) |
| 3672 | 3672 | { |
| 3673 | 3673 | $folderInfo[$this->profileID][$_folder] = false; // set to false, whatever it was (to have a valid returnvalue for the static return) |
| 3674 | 3674 | } |
| 3675 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); |
|
| 3675 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, $expiration = 60 * 60 * 5); |
|
| 3676 | 3676 | return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false); |
| 3677 | 3677 | } |
| 3678 | 3678 | |
@@ -3685,14 +3685,14 @@ discard block |
||
| 3685 | 3685 | */ |
| 3686 | 3686 | function compressFolder($_folderName = false) |
| 3687 | 3687 | { |
| 3688 | - $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3689 | - $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3690 | - $trashFolder = $this->getTrashFolder(); |
|
| 3688 | + $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3689 | + $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3690 | + $trashFolder = $this->getTrashFolder(); |
|
| 3691 | 3691 | |
| 3692 | 3692 | $this->icServer->openMailbox($folderName); |
| 3693 | 3693 | |
| 3694 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3695 | - $this->deleteMessages('all',$folderName,'remove_immediately'); |
|
| 3694 | + if (strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3695 | + $this->deleteMessages('all', $folderName, 'remove_immediately'); |
|
| 3696 | 3696 | } else { |
| 3697 | 3697 | $this->icServer->expunge($folderName); |
| 3698 | 3698 | } |
@@ -3708,19 +3708,19 @@ discard block |
||
| 3708 | 3708 | * @return bool true, as we do not handle return values yet |
| 3709 | 3709 | * @throws Exception |
| 3710 | 3710 | */ |
| 3711 | - function deleteMessages($_messageUID, $_folder=NULL, $_forceDeleteMethod='no') |
|
| 3711 | + function deleteMessages($_messageUID, $_folder = NULL, $_forceDeleteMethod = 'no') |
|
| 3712 | 3712 | { |
| 3713 | 3713 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3714 | 3714 | $oldMailbox = ''; |
| 3715 | 3715 | if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
| 3716 | 3716 | if (empty($_messageUID)) |
| 3717 | 3717 | { |
| 3718 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3718 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3719 | 3719 | return false; |
| 3720 | 3720 | } |
| 3721 | - elseif ($_messageUID==='all') |
|
| 3721 | + elseif ($_messageUID === 'all') |
|
| 3722 | 3722 | { |
| 3723 | - $_messageUID= null; |
|
| 3723 | + $_messageUID = null; |
|
| 3724 | 3724 | } |
| 3725 | 3725 | else |
| 3726 | 3726 | { |
@@ -3729,32 +3729,32 @@ discard block |
||
| 3729 | 3729 | $uidsToDelete->add($_messageUID); |
| 3730 | 3730 | } |
| 3731 | 3731 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3732 | - 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"); |
|
| 3732 | + 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"); |
|
| 3733 | 3733 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3734 | 3734 | $trashFolder = $this->getTrashFolder(); |
| 3735 | - $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3735 | + $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3736 | 3736 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3737 | - if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3737 | + if ((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3738 | 3738 | (strtolower($_folder) == strtolower($draftFolder))) { |
| 3739 | 3739 | $deleteOptions = "remove_immediately"; |
| 3740 | 3740 | } |
| 3741 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3741 | + if ($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3742 | 3742 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3743 | 3743 | $this->icServer->openMailbox($_folder); |
| 3744 | 3744 | } |
| 3745 | 3745 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3746 | 3746 | $updateCache = false; |
| 3747 | - switch($deleteOptions) { |
|
| 3747 | + switch ($deleteOptions) { |
|
| 3748 | 3748 | case "move_to_trash": |
| 3749 | 3749 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3750 | 3750 | $updateCache = true; |
| 3751 | - if(!empty($trashFolder)) { |
|
| 3751 | + if (!empty($trashFolder)) { |
|
| 3752 | 3752 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
| 3753 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 3753 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ".$this->sessionData['mailbox']); |
|
| 3754 | 3754 | // copy messages |
| 3755 | 3755 | try |
| 3756 | 3756 | { |
| 3757 | - $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete,'move'=>true)); |
|
| 3757 | + $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete, 'move'=>true)); |
|
| 3758 | 3758 | } |
| 3759 | 3759 | catch (\Exception $e) |
| 3760 | 3760 | { |
@@ -3766,18 +3766,18 @@ discard block |
||
| 3766 | 3766 | case "mark_as_deleted": |
| 3767 | 3767 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3768 | 3768 | // mark messages as deleted |
| 3769 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3770 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3769 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3770 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3771 | 3771 | { |
| 3772 | 3772 | //flag messages, that are flagged for deletion as seen too |
| 3773 | 3773 | $this->flagMessages('read', $uid, $_folder); |
| 3774 | 3774 | $flags = $this->getFlags($uid); |
| 3775 | 3775 | $this->flagMessages('delete', $uid, $_folder); |
| 3776 | 3776 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3777 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 3777 | + if (strpos(array2string($flags), 'Deleted') !== false) $undelete[] = $uid; |
|
| 3778 | 3778 | unset($flags); |
| 3779 | 3779 | } |
| 3780 | - foreach((array)$undelete as $key =>$uid) |
|
| 3780 | + foreach ((array)$undelete as $key =>$uid) |
|
| 3781 | 3781 | { |
| 3782 | 3782 | $this->flagMessages('undelete', $uid, $_folder); |
| 3783 | 3783 | } |
@@ -3786,14 +3786,14 @@ discard block |
||
| 3786 | 3786 | case "remove_immediately": |
| 3787 | 3787 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3788 | 3788 | $updateCache = true; |
| 3789 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3789 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3790 | 3790 | if (is_object($_messageUID)) |
| 3791 | 3791 | { |
| 3792 | 3792 | $this->flagMessages('delete', $_messageUID, $_folder); |
| 3793 | 3793 | } |
| 3794 | 3794 | else |
| 3795 | 3795 | { |
| 3796 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3796 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3797 | 3797 | { |
| 3798 | 3798 | //flag messages, that are flagged for deletion as seen too |
| 3799 | 3799 | $this->flagMessages('delete', $uid, $_folder); |
@@ -3803,7 +3803,7 @@ discard block |
||
| 3803 | 3803 | $this->icServer->expunge($_folder); |
| 3804 | 3804 | break; |
| 3805 | 3805 | } |
| 3806 | - if($oldMailbox != '') { |
|
| 3806 | + if ($oldMailbox != '') { |
|
| 3807 | 3807 | $this->icServer->openMailbox($oldMailbox); |
| 3808 | 3808 | } |
| 3809 | 3809 | |
@@ -3817,7 +3817,7 @@ discard block |
||
| 3817 | 3817 | * |
| 3818 | 3818 | * @return null/array flags |
| 3819 | 3819 | */ |
| 3820 | - function getFlags ($_messageUID) { |
|
| 3820 | + function getFlags($_messageUID) { |
|
| 3821 | 3821 | try |
| 3822 | 3822 | { |
| 3823 | 3823 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -3830,7 +3830,7 @@ discard block |
||
| 3830 | 3830 | 'ids' => $uidsToFetch, |
| 3831 | 3831 | )); |
| 3832 | 3832 | if (is_object($headersNew)) { |
| 3833 | - foreach($headersNew->ids() as $id) { |
|
| 3833 | + foreach ($headersNew->ids() as $id) { |
|
| 3834 | 3834 | $_headerObject = $headersNew->get($id); |
| 3835 | 3835 | $flags = $_headerObject->getFlags(); |
| 3836 | 3836 | } |
@@ -3853,22 +3853,22 @@ discard block |
||
| 3853 | 3853 | * |
| 3854 | 3854 | * @return null/boolean |
| 3855 | 3855 | */ |
| 3856 | - function getNotifyFlags ($_messageUID, $flags=null) |
|
| 3856 | + function getNotifyFlags($_messageUID, $flags = null) |
|
| 3857 | 3857 | { |
| 3858 | 3858 | if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
| 3859 | 3859 | try |
| 3860 | 3860 | { |
| 3861 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 3861 | + if ($flags === null) $flags = $this->getFlags($_messageUID); |
|
| 3862 | 3862 | } |
| 3863 | 3863 | catch (\Exception $e) |
| 3864 | 3864 | { |
| 3865 | 3865 | return null; |
| 3866 | 3866 | } |
| 3867 | 3867 | |
| 3868 | - if ( stripos( array2string($flags),'MDNSent')!==false) |
|
| 3868 | + if (stripos(array2string($flags), 'MDNSent') !== false) |
|
| 3869 | 3869 | return true; |
| 3870 | 3870 | |
| 3871 | - if ( stripos( array2string($flags),'MDNnotSent')!==false) |
|
| 3871 | + if (stripos(array2string($flags), 'MDNnotSent') !== false) |
|
| 3872 | 3872 | return false; |
| 3873 | 3873 | |
| 3874 | 3874 | return null; |
@@ -3885,45 +3885,45 @@ discard block |
||
| 3885 | 3885 | * |
| 3886 | 3886 | * @return bool true, as we do not handle icserver->setFlags returnValue |
| 3887 | 3887 | */ |
| 3888 | - function flagMessages($_flag, $_messageUID,$_folder=NULL) |
|
| 3888 | + function flagMessages($_flag, $_messageUID, $_folder = NULL) |
|
| 3889 | 3889 | { |
| 3890 | 3890 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3891 | 3891 | if (empty($_messageUID)) |
| 3892 | 3892 | { |
| 3893 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3893 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3894 | 3894 | return false; |
| 3895 | 3895 | } |
| 3896 | - $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
|
| 3896 | + $this->icServer->openMailbox(($_folder ? $_folder : $this->sessionData['mailbox'])); |
|
| 3897 | 3897 | $folder = $this->icServer->getCurrentMailbox(); |
| 3898 | - if (is_array($_messageUID)&& count($_messageUID)>50) |
|
| 3898 | + if (is_array($_messageUID) && count($_messageUID) > 50) |
|
| 3899 | 3899 | { |
| 3900 | - $count = $this->getMailBoxCounters($folder,true); |
|
| 3901 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 3900 | + $count = $this->getMailBoxCounters($folder, true); |
|
| 3901 | + if ($count->messages == count($_messageUID)) $_messageUID = 'all'; |
|
| 3902 | 3902 | } |
| 3903 | 3903 | |
| 3904 | - if ($_messageUID==='all') |
|
| 3904 | + if ($_messageUID === 'all') |
|
| 3905 | 3905 | { |
| 3906 | 3906 | $messageUIDs = array('all'); |
| 3907 | 3907 | } |
| 3908 | 3908 | else |
| 3909 | 3909 | { |
| 3910 | 3910 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 3911 | - $messageUIDs = array_chunk($_messageUID,50,true); |
|
| 3911 | + $messageUIDs = array_chunk($_messageUID, 50, true); |
|
| 3912 | 3912 | } |
| 3913 | 3913 | try |
| 3914 | 3914 | { |
| 3915 | - foreach($messageUIDs as &$uids) |
|
| 3915 | + foreach ($messageUIDs as &$uids) |
|
| 3916 | 3916 | { |
| 3917 | - if ($uids==='all') |
|
| 3917 | + if ($uids === 'all') |
|
| 3918 | 3918 | { |
| 3919 | - $uidsToModify=null; |
|
| 3919 | + $uidsToModify = null; |
|
| 3920 | 3920 | } |
| 3921 | 3921 | else |
| 3922 | 3922 | { |
| 3923 | 3923 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 3924 | 3924 | $uidsToModify->add($uids); |
| 3925 | 3925 | } |
| 3926 | - switch($_flag) { |
|
| 3926 | + switch ($_flag) { |
|
| 3927 | 3927 | case "delete": |
| 3928 | 3928 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 3929 | 3929 | break; |
@@ -3947,7 +3947,7 @@ discard block |
||
| 3947 | 3947 | break; |
| 3948 | 3948 | case "unread": |
| 3949 | 3949 | case "unseen": |
| 3950 | - $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen','\\Answered','$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 3950 | + $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen', '\\Answered', '$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 3951 | 3951 | break; |
| 3952 | 3952 | case "mdnsent": |
| 3953 | 3953 | $ret = $this->icServer->store($folder, array('add'=>array('MDNSent'), 'ids'=> $uidsToModify)); |
@@ -4005,13 +4005,13 @@ discard block |
||
| 4005 | 4005 | } |
| 4006 | 4006 | } |
| 4007 | 4007 | } |
| 4008 | - catch(Exception $e) |
|
| 4008 | + catch (Exception $e) |
|
| 4009 | 4009 | { |
| 4010 | 4010 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4011 | 4011 | } |
| 4012 | 4012 | if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
| 4013 | 4013 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4014 | - self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4014 | + self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder) ? $_folder : $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4015 | 4015 | |
| 4016 | 4016 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox'])); |
| 4017 | 4017 | return true; // as we do not catch/examine setFlags returnValue |
@@ -4032,19 +4032,19 @@ discard block |
||
| 4032 | 4032 | * @return mixed/bool true,false or new uid |
| 4033 | 4033 | * @throws Exception |
| 4034 | 4034 | */ |
| 4035 | - function moveMessages($_foldername, $_messageUID, $deleteAfterMove=true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4035 | + function moveMessages($_foldername, $_messageUID, $deleteAfterMove = true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4036 | 4036 | { |
| 4037 | - $source = Mail\Account::read(($_sourceProfileID?$_sourceProfileID:$this->icServer->ImapServerId))->imapServer(); |
|
| 4037 | + $source = Mail\Account::read(($_sourceProfileID ? $_sourceProfileID : $this->icServer->ImapServerId))->imapServer(); |
|
| 4038 | 4038 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4039 | 4039 | if (empty($_messageUID)) |
| 4040 | 4040 | { |
| 4041 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4041 | + if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',', $_messageUID)); |
|
| 4042 | 4042 | return false; |
| 4043 | 4043 | } |
| 4044 | - elseif ($_messageUID==='all') |
|
| 4044 | + elseif ($_messageUID === 'all') |
|
| 4045 | 4045 | { |
| 4046 | 4046 | //error_log(__METHOD__." all Message(s): ".implode(',',$_messageUID)); |
| 4047 | - $uidsToMove= null; |
|
| 4047 | + $uidsToMove = null; |
|
| 4048 | 4048 | } |
| 4049 | 4049 | else |
| 4050 | 4050 | { |
@@ -4053,7 +4053,7 @@ discard block |
||
| 4053 | 4053 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 4054 | 4054 | $uidsToMove->add($_messageUID); |
| 4055 | 4055 | } |
| 4056 | - $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
|
| 4056 | + $sourceFolder = (!empty($currentFolder) ? $currentFolder : $this->sessionData['mailbox']); |
|
| 4057 | 4057 | //error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId)); |
| 4058 | 4058 | if (!is_null($_targetProfileID) && $_targetProfileID !== $source->ImapServerId) |
| 4059 | 4059 | { |
@@ -4073,19 +4073,19 @@ discard block |
||
| 4073 | 4073 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4074 | 4074 | |
| 4075 | 4075 | if (is_object($headersNew)) { |
| 4076 | - $c=0; |
|
| 4076 | + $c = 0; |
|
| 4077 | 4077 | $retUid = new Horde_Imap_Client_Ids(); |
| 4078 | 4078 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4079 | 4079 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4080 | - foreach($headersNew as &$_headerObject) { |
|
| 4080 | + foreach ($headersNew as &$_headerObject) { |
|
| 4081 | 4081 | $c++; |
| 4082 | 4082 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4083 | 4083 | $date = $_headerObject->getImapDate(); |
| 4084 | - $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4084 | + $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4085 | 4085 | // if the internal Date of the message equals the current date; try using the header date |
| 4086 | - if ($date==$currentDate) |
|
| 4086 | + if ($date == $currentDate) |
|
| 4087 | 4087 | { |
| 4088 | - $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4088 | + $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4089 | 4089 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'.$headerForPrio['DATE']); |
| 4090 | 4090 | $date = new Horde_Imap_Client_DateTime($headerForPrio['DATE']); |
| 4091 | 4091 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'); |
@@ -4094,20 +4094,20 @@ discard block |
||
| 4094 | 4094 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 4095 | 4095 | $body = $_headerObject->getFullMsg(); |
| 4096 | 4096 | $dataNflags[] = array('data'=>$body, 'flags'=>$flags, 'internaldate'=>$date); |
| 4097 | - if ($c==1) |
|
| 4097 | + if ($c == 1) |
|
| 4098 | 4098 | { |
| 4099 | 4099 | $target = Mail\Account::read($_targetProfileID)->imapServer(); |
| 4100 | 4100 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' TargetServer:'.$_targetProfileID.' TargetFolderObject:'.array2string($_foldername)); |
| 4101 | 4101 | $foldername = $target->getMailbox($_foldername); |
| 4102 | 4102 | // make sure the target folder is open and ready |
| 4103 | 4103 | $target->openMailbox($foldername); |
| 4104 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4104 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4105 | 4105 | $retUid->add($ret); |
| 4106 | 4106 | unset($dataNflags); |
| 4107 | 4107 | // sleep 500 miliseconds; AS some sERVERs seem not to be capable of the load this is |
| 4108 | 4108 | // inflicting in them. they "reply" with an unspecific IMAP Error |
| 4109 | - time_nanosleep(0,500000); |
|
| 4110 | - $c=0; |
|
| 4109 | + time_nanosleep(0, 500000); |
|
| 4110 | + $c = 0; |
|
| 4111 | 4111 | } |
| 4112 | 4112 | } |
| 4113 | 4113 | if (isset($dataNflags)) |
@@ -4117,7 +4117,7 @@ discard block |
||
| 4117 | 4117 | $foldername = $target->getMailbox($_foldername); |
| 4118 | 4118 | // make sure the target folder is open and ready |
| 4119 | 4119 | $target->openMailbox($foldername); |
| 4120 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4120 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4121 | 4121 | $retUid->add($ret); |
| 4122 | 4122 | unset($dataNflags); |
| 4123 | 4123 | } |
@@ -4128,7 +4128,7 @@ discard block |
||
| 4128 | 4128 | { |
| 4129 | 4129 | $remember = $this->icServer; |
| 4130 | 4130 | $this->icServer = $source; |
| 4131 | - $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod='remove_immediately'); |
|
| 4131 | + $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod = 'remove_immediately'); |
|
| 4132 | 4132 | $this->icServer = $remember; |
| 4133 | 4133 | } |
| 4134 | 4134 | } |
@@ -4137,7 +4137,7 @@ discard block |
||
| 4137 | 4137 | { |
| 4138 | 4138 | try |
| 4139 | 4139 | { |
| 4140 | - $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove,'move'=>$deleteAfterMove)); |
|
| 4140 | + $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove, 'move'=>$deleteAfterMove)); |
|
| 4141 | 4141 | } |
| 4142 | 4142 | catch (exception $e) |
| 4143 | 4143 | { |
@@ -4157,19 +4157,19 @@ discard block |
||
| 4157 | 4157 | * @param string $format ='' if none is passed, use user prefs |
| 4158 | 4158 | * @return string returns the date as it is parseable by strtotime, or current timestamp if everything fails |
| 4159 | 4159 | */ |
| 4160 | - static function _strtotime($_date='', $format='', $convert2usertime=false) |
|
| 4160 | + static function _strtotime($_date = '', $format = '', $convert2usertime = false) |
|
| 4161 | 4161 | { |
| 4162 | 4162 | try { |
| 4163 | - $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4164 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4163 | + $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4164 | + if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4165 | 4165 | $date2return = $date->format($format); |
| 4166 | 4166 | } |
| 4167 | - catch(\Exception $e) |
|
| 4167 | + catch (\Exception $e) |
|
| 4168 | 4168 | { |
| 4169 | - unset($e); // not used |
|
| 4169 | + unset($e); // not used |
|
| 4170 | 4170 | |
| 4171 | 4171 | // remove last space-separated part and retry |
| 4172 | - $parts = explode(' ',$_date); |
|
| 4172 | + $parts = explode(' ', $_date); |
|
| 4173 | 4173 | if (count($parts) > 1) |
| 4174 | 4174 | { |
| 4175 | 4175 | array_pop($parts); |
@@ -4190,12 +4190,12 @@ discard block |
||
| 4190 | 4190 | * @param mixed $_charset false or string -> Target charset, if false Mail displayCharset will be used |
| 4191 | 4191 | * @return string |
| 4192 | 4192 | */ |
| 4193 | - static function htmlentities($_string, $_charset=false) |
|
| 4193 | + static function htmlentities($_string, $_charset = false) |
|
| 4194 | 4194 | { |
| 4195 | 4195 | //setting the charset (if not given) |
| 4196 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 4196 | + if ($_charset === false) $_charset = self::$displayCharset; |
|
| 4197 | 4197 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4198 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4198 | + if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string, Translation::detect_encoding($_string), $_charset), ENT_QUOTES|ENT_IGNORE, $_charset, false); |
|
| 4199 | 4199 | return $string; |
| 4200 | 4200 | } |
| 4201 | 4201 | |
@@ -4212,21 +4212,21 @@ discard block |
||
| 4212 | 4212 | //$_html = str_replace("\t",' ',$_html); |
| 4213 | 4213 | //error_log(__METHOD__.__LINE__.':'.$_html); |
| 4214 | 4214 | //repair doubleencoded ampersands, and some stuff htmLawed stumbles upon with balancing switched on |
| 4215 | - $_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>'), |
|
| 4216 | - array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
|
| 4215 | + $_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>'), |
|
| 4216 | + array('&', '<BR>', '<BR>', '<BR>', '</font></td>', '<td>', '', '', '', ''), $_html); |
|
| 4217 | 4217 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4218 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4219 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 4218 | + if (stripos($_html, 'style') !== false) Mail\Html::replaceTagsCompletley($_html, 'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4219 | + if (stripos($_html, 'head') !== false) Mail\Html::replaceTagsCompletley($_html, 'head'); // Strip out stuff in head |
|
| 4220 | 4220 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4221 | 4221 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4222 | 4222 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4223 | 4223 | |
| 4224 | 4224 | if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
| 4225 | 4225 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4226 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4227 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4228 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4229 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 4226 | + if (stripos($_html, '!doctype') !== false) Mail\Html::replaceTagsCompletley($_html, '!doctype'); |
|
| 4227 | + if (stripos($_html, '?xml:namespace') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml:namespace', '/>', false); |
|
| 4228 | + if (stripos($_html, '?xml version') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml version', '\?>', false); |
|
| 4229 | + if (strpos($_html, '!CURSOR') !== false) Mail\Html::replaceTagsCompletley($_html, '!CURSOR'); |
|
| 4230 | 4230 | // htmLawed filter only the 'body' |
| 4231 | 4231 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4232 | 4232 | //if ($matches[2]) |
@@ -4237,16 +4237,16 @@ discard block |
||
| 4237 | 4237 | // purify got switched to htmLawed |
| 4238 | 4238 | // some testcode to test purifying / htmlawed |
| 4239 | 4239 | //$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html; |
| 4240 | - $_html = Html\HtmLawed::purify($_html,self::$htmLawed_config,array(),true); |
|
| 4240 | + $_html = Html\HtmLawed::purify($_html, self::$htmLawed_config, array(), true); |
|
| 4241 | 4241 | //if ($hasOther) $_html = $matches[1]. $_html. $matches[3]; |
| 4242 | 4242 | // clean out comments , should not be needed as purify should do the job. |
| 4243 | 4243 | $search = array( |
| 4244 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4245 | - '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4244 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4245 | + '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4246 | 4246 | ); |
| 4247 | - $_html = preg_replace($search,"",$_html); |
|
| 4247 | + $_html = preg_replace($search, "", $_html); |
|
| 4248 | 4248 | // remove non printable chars |
| 4249 | - $_html = preg_replace('/([\000-\011])/','',$_html); |
|
| 4249 | + $_html = preg_replace('/([\000-\011])/', '', $_html); |
|
| 4250 | 4250 | //error_log(__METHOD__.':'.__LINE__.':'.$_html); |
| 4251 | 4251 | } |
| 4252 | 4252 | |
@@ -4263,12 +4263,12 @@ discard block |
||
| 4263 | 4263 | function getMimePartCharset($_mimePartObject) |
| 4264 | 4264 | { |
| 4265 | 4265 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4266 | - $CharsetFound=false; |
|
| 4266 | + $CharsetFound = false; |
|
| 4267 | 4267 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4268 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4269 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4268 | + if (is_array($_mimePartObject->parameters)) { |
|
| 4269 | + if (isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4270 | 4270 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4271 | - $CharsetFound=true; |
|
| 4271 | + $CharsetFound = true; |
|
| 4272 | 4272 | } |
| 4273 | 4273 | } |
| 4274 | 4274 | // this one is dirty, but until I find something that does the trick of detecting the encoding, .... |
@@ -4287,7 +4287,7 @@ discard block |
||
| 4287 | 4287 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4288 | 4288 | { |
| 4289 | 4289 | // decode the part |
| 4290 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 4290 | + if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage, true)); |
|
| 4291 | 4291 | switch (strtoupper($_encoding)) |
| 4292 | 4292 | { |
| 4293 | 4293 | case 'BASE64': |
@@ -4327,10 +4327,10 @@ discard block |
||
| 4327 | 4327 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4328 | 4328 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4329 | 4329 | $partText = $partCalendar = $partHTML = null; |
| 4330 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 4330 | + if (self::$debug) _debug_array(array("METHOD"=>__METHOD__, "LINE"=>__LINE__, "STRUCTURE"=>$_structure)); |
|
| 4331 | 4331 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4332 | 4332 | $ignore_first_part = true; |
| 4333 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4333 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4334 | 4334 | { |
| 4335 | 4335 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4336 | 4336 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4338,15 +4338,15 @@ discard block |
||
| 4338 | 4338 | if ($ignore_first_part) |
| 4339 | 4339 | { |
| 4340 | 4340 | $ignore_first_part = false; |
| 4341 | - continue; // ignore multipart/alternative itself |
|
| 4341 | + continue; // ignore multipart/alternative itself |
|
| 4342 | 4342 | } |
| 4343 | 4343 | |
| 4344 | 4344 | $mimePart = $_structure->getPart($mime_id); |
| 4345 | 4345 | |
| 4346 | - switch($mimePart->getPrimaryType()) |
|
| 4346 | + switch ($mimePart->getPrimaryType()) |
|
| 4347 | 4347 | { |
| 4348 | 4348 | case 'text': |
| 4349 | - switch($mimePart->getSubType()) |
|
| 4349 | + switch ($mimePart->getSubType()) |
|
| 4350 | 4350 | { |
| 4351 | 4351 | case 'plain': |
| 4352 | 4352 | if ($mimePart->getBytes() > 0) $partText = $mimePart; |
@@ -4359,7 +4359,7 @@ discard block |
||
| 4359 | 4359 | break; |
| 4360 | 4360 | |
| 4361 | 4361 | case 'multipart': |
| 4362 | - switch($mimePart->getSubType()) |
|
| 4362 | + switch ($mimePart->getSubType()) |
|
| 4363 | 4363 | { |
| 4364 | 4364 | case 'related': |
| 4365 | 4365 | case 'mixed': |
@@ -4381,13 +4381,13 @@ discard block |
||
| 4381 | 4381 | } |
| 4382 | 4382 | } |
| 4383 | 4383 | |
| 4384 | - switch($_htmlMode) |
|
| 4384 | + switch ($_htmlMode) |
|
| 4385 | 4385 | { |
| 4386 | 4386 | case 'html_only': |
| 4387 | 4387 | case 'always_display': |
| 4388 | 4388 | if ($partHTML) |
| 4389 | 4389 | { |
| 4390 | - switch($partHTML->getSubType()) |
|
| 4390 | + switch ($partHTML->getSubType()) |
|
| 4391 | 4391 | { |
| 4392 | 4392 | case 'related': |
| 4393 | 4393 | return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
@@ -4399,7 +4399,7 @@ discard block |
||
| 4399 | 4399 | return $this->getTextPart($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
| 4400 | 4400 | } |
| 4401 | 4401 | } |
| 4402 | - elseif ($partText && $_htmlMode=='always_display') |
|
| 4402 | + elseif ($partText && $_htmlMode == 'always_display') |
|
| 4403 | 4403 | { |
| 4404 | 4404 | return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen); |
| 4405 | 4405 | } |
@@ -4445,7 +4445,7 @@ discard block |
||
| 4445 | 4445 | * @param array &$skipParts - passed by reference to have control/knowledge which parts are already fetched |
| 4446 | 4446 | * @return array containing the desired part |
| 4447 | 4447 | */ |
| 4448 | - function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
|
| 4448 | + function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts = array()) |
|
| 4449 | 4449 | { |
| 4450 | 4450 | if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
| 4451 | 4451 | $bodyPart = array(); |
@@ -4454,7 +4454,7 @@ discard block |
||
| 4454 | 4454 | $ignore_first_part = true; |
| 4455 | 4455 | //$skipParts = array(); |
| 4456 | 4456 | //error_log(__METHOD__.__LINE__.array2string($_structure->contentTypeMap())); |
| 4457 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4457 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4458 | 4458 | { |
| 4459 | 4459 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4460 | 4460 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4462,9 +4462,9 @@ discard block |
||
| 4462 | 4462 | { |
| 4463 | 4463 | $ignore_first_part = false; |
| 4464 | 4464 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED FirstPart $mime_id: $mime_type"); |
| 4465 | - continue; // ignore multipart/mixed itself |
|
| 4465 | + continue; // ignore multipart/mixed itself |
|
| 4466 | 4466 | } |
| 4467 | - if (array_key_exists($mime_id,$skipParts)) |
|
| 4467 | + if (array_key_exists($mime_id, $skipParts)) |
|
| 4468 | 4468 | { |
| 4469 | 4469 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED $mime_id: $mime_type"); |
| 4470 | 4470 | continue; |
@@ -4472,11 +4472,11 @@ discard block |
||
| 4472 | 4472 | |
| 4473 | 4473 | $part = $_structure->getPart($mime_id); |
| 4474 | 4474 | |
| 4475 | - switch($part->getPrimaryType()) |
|
| 4475 | + switch ($part->getPrimaryType()) |
|
| 4476 | 4476 | { |
| 4477 | 4477 | case 'multipart': |
| 4478 | 4478 | if ($part->getDisposition() == 'attachment') continue; |
| 4479 | - switch($part->getSubType()) |
|
| 4479 | + switch ($part->getSubType()) |
|
| 4480 | 4480 | { |
| 4481 | 4481 | case 'alternative': |
| 4482 | 4482 | return array($this->getMultipartAlternative($_uid, $part, $_htmlMode, $_preserveSeen)); |
@@ -4492,15 +4492,15 @@ discard block |
||
| 4492 | 4492 | } |
| 4493 | 4493 | break; |
| 4494 | 4494 | case 'application': |
| 4495 | - switch($part->getSubType()) |
|
| 4495 | + switch ($part->getSubType()) |
|
| 4496 | 4496 | { |
| 4497 | 4497 | case 'pgp-encrypted': |
| 4498 | - if (($part = $_structure->getPart($mime_id+1)) && |
|
| 4498 | + if (($part = $_structure->getPart($mime_id + 1)) && |
|
| 4499 | 4499 | $part->getType() == 'application/octet-stream') |
| 4500 | 4500 | { |
| 4501 | 4501 | $this->fetchPartContents($_uid, $part); |
| 4502 | - $skipParts[$mime_id]=$mime_type; |
|
| 4503 | - $skipParts[$mime_id+1]=$part->getType(); |
|
| 4502 | + $skipParts[$mime_id] = $mime_type; |
|
| 4503 | + $skipParts[$mime_id + 1] = $part->getType(); |
|
| 4504 | 4504 | $bodyPart[] = array( |
| 4505 | 4505 | 'body' => $part->getContents(array( |
| 4506 | 4506 | 'stream' => false, |
@@ -4514,15 +4514,15 @@ discard block |
||
| 4514 | 4514 | break; |
| 4515 | 4515 | |
| 4516 | 4516 | case 'text': |
| 4517 | - switch($part->getSubType()) |
|
| 4517 | + switch ($part->getSubType()) |
|
| 4518 | 4518 | { |
| 4519 | 4519 | case 'plain': |
| 4520 | 4520 | case 'html': |
| 4521 | 4521 | case 'calendar': // inline ics/ical files |
| 4522 | - if($part->getDisposition() != 'attachment') |
|
| 4522 | + if ($part->getDisposition() != 'attachment') |
|
| 4523 | 4523 | { |
| 4524 | 4524 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4525 | - $skipParts[$mime_id]=$mime_type; |
|
| 4525 | + $skipParts[$mime_id] = $mime_type; |
|
| 4526 | 4526 | } |
| 4527 | 4527 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$part->type."/".$part->subType.' -> BodyPart:'.array2string($bodyPart[count($bodyPart)-1])); |
| 4528 | 4528 | break; |
@@ -4531,16 +4531,16 @@ discard block |
||
| 4531 | 4531 | |
| 4532 | 4532 | case 'message': |
| 4533 | 4533 | //skip attachments |
| 4534 | - if($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4534 | + if ($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4535 | 4535 | { |
| 4536 | 4536 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4537 | - $skipParts[$mime_id]=$mime_type; |
|
| 4537 | + $skipParts[$mime_id] = $mime_type; |
|
| 4538 | 4538 | } |
| 4539 | 4539 | // do not descend into attached Messages |
| 4540 | - if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4540 | + if ($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4541 | 4541 | { |
| 4542 | 4542 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4543 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 4543 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { $skipParts[$sub_id] = $sub_type; } |
|
| 4544 | 4544 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4545 | 4545 | //break 2; |
| 4546 | 4546 | } |
@@ -4581,13 +4581,13 @@ discard block |
||
| 4581 | 4581 | * @param boolean $_tryDecodingServerside = true; wether to try to fetch Data with BINARY instead of BODY |
| 4582 | 4582 | * @return string|resource |
| 4583 | 4583 | */ |
| 4584 | - function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
|
| 4584 | + function getBodyPart($_uid, $_partID = null, $_folder = null, $_preserveSeen = false, $_stream = false, &$_encoding = null, $_tryDecodingServerside = true) |
|
| 4585 | 4585 | { |
| 4586 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4586 | + if (self::$debug) error_log(__METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4587 | 4587 | |
| 4588 | 4588 | if (empty($_folder)) |
| 4589 | 4589 | { |
| 4590 | - $_folder = (isset($this->sessionData['mailbox'])&&$this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4590 | + $_folder = (isset($this->sessionData['mailbox']) && $this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4591 | 4591 | } |
| 4592 | 4592 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4593 | 4593 | // querying contents of body part |
@@ -4598,11 +4598,11 @@ discard block |
||
| 4598 | 4598 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 4599 | 4599 | $fetchParams = array( |
| 4600 | 4600 | 'peek' => $_preserveSeen, |
| 4601 | - 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4601 | + 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4602 | 4602 | ); |
| 4603 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4603 | + if ($_tryDecodingServerside === false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4604 | 4604 | { |
| 4605 | - $_tryDecodingServerside=false; |
|
| 4605 | + $_tryDecodingServerside = false; |
|
| 4606 | 4606 | $fetchParams = array( |
| 4607 | 4607 | 'peek' => $_preserveSeen, |
| 4608 | 4608 | ); |
@@ -4622,12 +4622,12 @@ discard block |
||
| 4622 | 4622 | } |
| 4623 | 4623 | // if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID]) |
| 4624 | 4624 | // thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID]) |
| 4625 | - if (empty($partToReturn)&&$_tryDecodingServerside===true) |
|
| 4625 | + if (empty($partToReturn) && $_tryDecodingServerside === true) |
|
| 4626 | 4626 | { |
| 4627 | 4627 | error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY'); |
| 4628 | 4628 | $partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false); |
| 4629 | 4629 | } |
| 4630 | - return ($partToReturn?$partToReturn:null); |
|
| 4630 | + return ($partToReturn ? $partToReturn : null); |
|
| 4631 | 4631 | } |
| 4632 | 4632 | |
| 4633 | 4633 | /** |
@@ -4640,13 +4640,13 @@ discard block |
||
| 4640 | 4640 | * @param boolean $_stream = false true return a stream, false return string |
| 4641 | 4641 | * @return array containing the desired text part, mimeType and charset |
| 4642 | 4642 | */ |
| 4643 | - function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode='', $_preserveSeen=false, $_stream=false) |
|
| 4643 | + function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode = '', $_preserveSeen = false, $_stream = false) |
|
| 4644 | 4644 | { |
| 4645 | 4645 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4646 | 4646 | $bodyPart = array(); |
| 4647 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 4647 | + if (self::$debug) _debug_array(array($_structure, function_backtrace())); |
|
| 4648 | 4648 | |
| 4649 | - if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4649 | + if ($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4650 | 4650 | { |
| 4651 | 4651 | $bodyPart = array( |
| 4652 | 4652 | 'error' => 1, |
@@ -4692,10 +4692,10 @@ discard block |
||
| 4692 | 4692 | * @param string $_folder folder to work on |
| 4693 | 4693 | * @return array containing the message body, mimeType and charset |
| 4694 | 4694 | */ |
| 4695 | - function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
|
| 4695 | + function getMessageBody($_uid, $_htmlOptions = '', $_partID = null, Horde_Mime_Part $_structure = null, $_preserveSeen = false, $_folder = '') |
|
| 4696 | 4696 | { |
| 4697 | 4697 | if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
| 4698 | - if($_htmlOptions != '') { |
|
| 4698 | + if ($_htmlOptions != '') { |
|
| 4699 | 4699 | $this->htmlOptions = $_htmlOptions; |
| 4700 | 4700 | } |
| 4701 | 4701 | if (empty($_folder)) |
@@ -4716,7 +4716,7 @@ discard block |
||
| 4716 | 4716 | return array( |
| 4717 | 4717 | array( |
| 4718 | 4718 | 'error' => 1, |
| 4719 | - 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions". 'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4719 | + 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions".'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4720 | 4720 | 'mimeType' => 'text/plain', |
| 4721 | 4721 | 'charSet' => self::$displayCharset, |
| 4722 | 4722 | ) |
@@ -4729,7 +4729,7 @@ discard block |
||
| 4729 | 4729 | //_debug_array($_structure->getMimeId()); exit; |
| 4730 | 4730 | } |
| 4731 | 4731 | |
| 4732 | - switch($_structure->getPrimaryType()) |
|
| 4732 | + switch ($_structure->getPrimaryType()) |
|
| 4733 | 4733 | { |
| 4734 | 4734 | case 'application': |
| 4735 | 4735 | return array( |
@@ -4741,7 +4741,7 @@ discard block |
||
| 4741 | 4741 | ); |
| 4742 | 4742 | |
| 4743 | 4743 | case 'multipart': |
| 4744 | - switch($_structure->getSubType()) |
|
| 4744 | + switch ($_structure->getSubType()) |
|
| 4745 | 4745 | { |
| 4746 | 4746 | case 'alternative': |
| 4747 | 4747 | $bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
@@ -4775,7 +4775,7 @@ discard block |
||
| 4775 | 4775 | $bodyPart = array(); |
| 4776 | 4776 | if ($_structure->getDisposition() != 'attachment') |
| 4777 | 4777 | { |
| 4778 | - switch($_structure->getSubType()) |
|
| 4778 | + switch ($_structure->getSubType()) |
|
| 4779 | 4779 | { |
| 4780 | 4780 | case 'calendar': |
| 4781 | 4781 | // this is handeled in getTextPart |
@@ -4791,11 +4791,11 @@ discard block |
||
| 4791 | 4791 | |
| 4792 | 4792 | case 'attachment': |
| 4793 | 4793 | case 'message': |
| 4794 | - switch($_structure->getSubType()) |
|
| 4794 | + switch ($_structure->getSubType()) |
|
| 4795 | 4795 | { |
| 4796 | 4796 | case 'rfc822': |
| 4797 | 4797 | $newStructure = $_structure->getParts(); |
| 4798 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4798 | + if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]); } |
|
| 4799 | 4799 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4800 | 4800 | } |
| 4801 | 4801 | break; |
@@ -4823,11 +4823,11 @@ discard block |
||
| 4823 | 4823 | { |
| 4824 | 4824 | if (is_array($_bodyParts)) |
| 4825 | 4825 | { |
| 4826 | - foreach($_bodyParts as $singleBodyPart) |
|
| 4826 | + foreach ($_bodyParts as $singleBodyPart) |
|
| 4827 | 4827 | { |
| 4828 | 4828 | if (!isset($singleBodyPart['body'])) { |
| 4829 | 4829 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4830 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 4830 | + foreach ((array)$buff as $val) { $body2return[] = $val; } |
|
| 4831 | 4831 | continue; |
| 4832 | 4832 | } |
| 4833 | 4833 | $body2return[] = $singleBodyPart; |
@@ -4848,14 +4848,14 @@ discard block |
||
| 4848 | 4848 | * @param boolean $useTidy switch to use tidy |
| 4849 | 4849 | * @return string a preformatted string with the mails converted to text |
| 4850 | 4850 | */ |
| 4851 | - static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4851 | + static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4852 | 4852 | { |
| 4853 | - $message=''; |
|
| 4854 | - for($i=0; $i<count($bodyParts); $i++) |
|
| 4853 | + $message = ''; |
|
| 4854 | + for ($i = 0; $i < count($bodyParts); $i++) |
|
| 4855 | 4855 | { |
| 4856 | 4856 | if (!isset($bodyParts[$i]['body'])) { |
| 4857 | 4857 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4858 | - $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
|
| 4858 | + $message .= empty($bodyParts[$i]['body']) ? '' : $bodyParts[$i]['body']; |
|
| 4859 | 4859 | continue; |
| 4860 | 4860 | } |
| 4861 | 4861 | if (isset($bodyParts[$i]['error'])) continue; |
@@ -4880,32 +4880,32 @@ discard block |
||
| 4880 | 4880 | '(R)', |
| 4881 | 4881 | ); |
| 4882 | 4882 | |
| 4883 | - if(($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4883 | + if (($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4884 | 4884 | strtoupper($bodyParts[$i]['charSet']) != 'UTF-8') |
| 4885 | 4885 | { |
| 4886 | - $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
|
| 4886 | + $bodyParts[$i]['body'] = preg_replace($sar, $rar, $bodyParts[$i]['body']); |
|
| 4887 | 4887 | } |
| 4888 | 4888 | |
| 4889 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4889 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4890 | 4890 | // add line breaks to $bodyParts |
| 4891 | 4891 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4892 | - $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4892 | + $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4893 | 4893 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4894 | 4894 | $mailClass->activeMimeType = 'text/plain'; |
| 4895 | 4895 | if ($bodyParts[$i]['mimeType'] == 'text/html') { |
| 4896 | 4896 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 4897 | 4897 | if (!$preserveHTML) |
| 4898 | 4898 | { |
| 4899 | - $alreadyHtmlLawed=false; |
|
| 4899 | + $alreadyHtmlLawed = false; |
|
| 4900 | 4900 | // as Translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space |
| 4901 | - $newBody = str_replace("\n"," ",$newBody); |
|
| 4901 | + $newBody = str_replace("\n", " ", $newBody); |
|
| 4902 | 4902 | // convert HTML to text, as we dont want HTML in infologs |
| 4903 | 4903 | if ($useTidy && extension_loaded('tidy')) |
| 4904 | 4904 | { |
| 4905 | 4905 | $tidy = new tidy(); |
| 4906 | - $cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8'); |
|
| 4906 | + $cleaned = $tidy->repairString($newBody, self::$tidy_config, 'utf8'); |
|
| 4907 | 4907 | // Found errors. Strip it all so there's some output |
| 4908 | - if($tidy->getStatus() == 2) |
|
| 4908 | + if ($tidy->getStatus() == 2) |
|
| 4909 | 4909 | { |
| 4910 | 4910 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 4911 | 4911 | } |
@@ -4916,7 +4916,7 @@ discard block |
||
| 4916 | 4916 | if (!$preserveHTML) |
| 4917 | 4917 | { |
| 4918 | 4918 | // filter only the 'body', as we only want that part, if we throw away the html |
| 4919 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 4919 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 4920 | 4920 | if ($matches[2]) |
| 4921 | 4921 | { |
| 4922 | 4922 | $hasOther = true; |
@@ -4927,7 +4927,7 @@ discard block |
||
| 4927 | 4927 | else |
| 4928 | 4928 | { |
| 4929 | 4929 | // htmLawed filter only the 'body' |
| 4930 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 4930 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 4931 | 4931 | if ($matches[2]) |
| 4932 | 4932 | { |
| 4933 | 4933 | $hasOther = true; |
@@ -4936,17 +4936,17 @@ discard block |
||
| 4936 | 4936 | $htmLawed = new Html\HtmLawed(); |
| 4937 | 4937 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 4938 | 4938 | // as we switched off HTMLaweds tidy functionality |
| 4939 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 4940 | - $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
|
| 4941 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 4942 | - $alreadyHtmlLawed=true; |
|
| 4939 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 4940 | + $newBody = $htmLawed->run($newBody, self::$htmLawed_config); |
|
| 4941 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 4942 | + $alreadyHtmlLawed = true; |
|
| 4943 | 4943 | } |
| 4944 | 4944 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 4945 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 4945 | + if ($preserveHTML == false) $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, true, true); |
|
| 4946 | 4946 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 4947 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 4947 | + if ($preserveHTML == false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 4948 | 4948 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 4949 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 4949 | + if ($preserveHTML == false) $newBody = str_replace("<br />", "\r\n", $newBody); |
|
| 4950 | 4950 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 4951 | 4951 | } |
| 4952 | 4952 | $message .= $newBody; |
@@ -4955,9 +4955,9 @@ discard block |
||
| 4955 | 4955 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after specialchars):'.$newBody); |
| 4956 | 4956 | //use Mail\Html::convertHTMLToText instead of strip_tags, (even message is plain text) as strip_tags eats away too much |
| 4957 | 4957 | //$newBody = strip_tags($newBody); //we need to fix broken tags (or just stuff like "<800 USD/p" ) |
| 4958 | - $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,false,false); |
|
| 4958 | + $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, false, false); |
|
| 4959 | 4959 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after strip tags):'.$newBody); |
| 4960 | - $newBody = htmlspecialchars_decode($newBody,ENT_QUOTES); |
|
| 4960 | + $newBody = htmlspecialchars_decode($newBody, ENT_QUOTES); |
|
| 4961 | 4961 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body (after hmlspc_decode):'.$newBody); |
| 4962 | 4962 | $message .= $newBody; |
| 4963 | 4963 | //continue; |
@@ -4965,27 +4965,27 @@ discard block |
||
| 4965 | 4965 | return $message; |
| 4966 | 4966 | } |
| 4967 | 4967 | |
| 4968 | - static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false) |
|
| 4968 | + static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith = false) |
|
| 4969 | 4969 | { |
| 4970 | 4970 | $lines = explode("\n", $str); |
| 4971 | 4971 | $newStr = ''; |
| 4972 | - foreach($lines as $line) |
|
| 4972 | + foreach ($lines as $line) |
|
| 4973 | 4973 | { |
| 4974 | 4974 | // replace tabs by 8 space chars, or any tab only counts one char |
| 4975 | 4975 | //$line = str_replace("\t"," ",$line); |
| 4976 | 4976 | //$newStr .= wordwrap($line, $cols, $cut); |
| 4977 | - $allowedLength = $cols-strlen($cut); |
|
| 4977 | + $allowedLength = $cols - strlen($cut); |
|
| 4978 | 4978 | //dont try to break lines with links, chance is we mess up the text is way too big |
| 4979 | - if (strlen($line) > $allowedLength && stripos($line,'href=')===false && |
|
| 4980 | - ($dontbreaklinesstartingwith==false || |
|
| 4979 | + if (strlen($line) > $allowedLength && stripos($line, 'href=') === false && |
|
| 4980 | + ($dontbreaklinesstartingwith == false || |
|
| 4981 | 4981 | ($dontbreaklinesstartingwith && |
| 4982 | - strlen($dontbreaklinesstartingwith)>=1 && |
|
| 4983 | - substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 4982 | + strlen($dontbreaklinesstartingwith) >= 1 && |
|
| 4983 | + substr($line, 0, strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 4984 | 4984 | ) |
| 4985 | 4985 | ) |
| 4986 | 4986 | ) |
| 4987 | 4987 | { |
| 4988 | - $s=explode(" ", $line); |
|
| 4988 | + $s = explode(" ", $line); |
|
| 4989 | 4989 | $line = ""; |
| 4990 | 4990 | $linecnt = 0; |
| 4991 | 4991 | foreach ($s as &$v) { |
@@ -4993,22 +4993,22 @@ discard block |
||
| 4993 | 4993 | // only break long words within the wordboundaries, |
| 4994 | 4994 | // but it may destroy links, so we check for href and dont do it if we find one |
| 4995 | 4995 | // we check for any html within the word, because we do not want to break html by accident |
| 4996 | - if($cnt > $allowedLength && stripos($v,'href=')===false && stripos($v,'onclick=')===false && $cnt == strlen(html_entity_decode($v))) |
|
| 4996 | + if ($cnt > $allowedLength && stripos($v, 'href=') === false && stripos($v, 'onclick=') === false && $cnt == strlen(html_entity_decode($v))) |
|
| 4997 | 4997 | { |
| 4998 | - $v=wordwrap($v, $allowedLength, $cut, true); |
|
| 4998 | + $v = wordwrap($v, $allowedLength, $cut, true); |
|
| 4999 | 4999 | } |
| 5000 | 5000 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5001 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5002 | - $v=$cut.$v; |
|
| 5001 | + if ($linecnt + $cnt > $allowedLength) { |
|
| 5002 | + $v = $cut.$v; |
|
| 5003 | 5003 | #$linecnt = 0; |
| 5004 | - $linecnt =strlen($v)-strlen($cut); |
|
| 5004 | + $linecnt = strlen($v) - strlen($cut); |
|
| 5005 | 5005 | } else { |
| 5006 | 5006 | $linecnt += $cnt; |
| 5007 | 5007 | } |
| 5008 | 5008 | if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
| 5009 | 5009 | } |
| 5010 | 5010 | } |
| 5011 | - $newStr .= $line . "\n"; |
|
| 5011 | + $newStr .= $line."\n"; |
|
| 5012 | 5012 | } |
| 5013 | 5013 | return $newStr; |
| 5014 | 5014 | } |
@@ -5023,12 +5023,12 @@ discard block |
||
| 5023 | 5023 | * @param boolean $_useHeaderInsteadOfEnvelope - force getMessageHeader method to be used for fetching Envelope Information |
| 5024 | 5024 | * @return array the message header |
| 5025 | 5025 | */ |
| 5026 | - function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
|
| 5026 | + function getMessageEnvelope($_uid, $_partID = '', $decode = false, $_folder = '', $_useHeaderInsteadOfEnvelope = false) |
|
| 5027 | 5027 | { |
| 5028 | 5028 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5029 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5029 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5030 | 5030 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5031 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 5031 | + if ((empty($_partID) || $_partID == 'null') && $_useHeaderInsteadOfEnvelope === false) { |
|
| 5032 | 5032 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5033 | 5033 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5034 | 5034 | $uidsToFetch->add($_uid); |
@@ -5041,7 +5041,7 @@ discard block |
||
| 5041 | 5041 | 'ids' => $uidsToFetch, |
| 5042 | 5042 | )); |
| 5043 | 5043 | if (is_object($headersNew)) { |
| 5044 | - foreach($headersNew as &$_headerObject) { |
|
| 5044 | + foreach ($headersNew as &$_headerObject) { |
|
| 5045 | 5045 | $env = $_headerObject->getEnvelope(); |
| 5046 | 5046 | //_debug_array($envFields->singleFields()); |
| 5047 | 5047 | $singleFields = $envFields->singleFields(); |
@@ -5056,34 +5056,34 @@ discard block |
||
| 5056 | 5056 | case 'bcc': |
| 5057 | 5057 | case 'sender': |
| 5058 | 5058 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5059 | - $envelope[$v]=$env->$v->addresses; |
|
| 5059 | + $envelope[$v] = $env->$v->addresses; |
|
| 5060 | 5060 | $address = array(); |
| 5061 | 5061 | if (!is_array($envelope[$v])) break; |
| 5062 | 5062 | foreach ($envelope[$v] as $k => $ad) |
| 5063 | 5063 | { |
| 5064 | - if (stripos($ad,'@')===false) |
|
| 5064 | + if (stripos($ad, '@') === false) |
|
| 5065 | 5065 | { |
| 5066 | - $remember=$k; |
|
| 5066 | + $remember = $k; |
|
| 5067 | 5067 | } |
| 5068 | 5068 | else |
| 5069 | 5069 | { |
| 5070 | - $address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad; |
|
| 5071 | - $remember=null; |
|
| 5070 | + $address[] = (!is_null($remember) ? $envelope[$v][$remember].' ' : '').$ad; |
|
| 5071 | + $remember = null; |
|
| 5072 | 5072 | } |
| 5073 | 5073 | } |
| 5074 | 5074 | $envelope[$v] = $address; |
| 5075 | 5075 | break; |
| 5076 | 5076 | case 'date': |
| 5077 | - $envelope[$v]=DateTime::to($env->$v); |
|
| 5077 | + $envelope[$v] = DateTime::to($env->$v); |
|
| 5078 | 5078 | break; |
| 5079 | 5079 | default: |
| 5080 | - $envelope[$v]=$env->$v; |
|
| 5080 | + $envelope[$v] = $env->$v; |
|
| 5081 | 5081 | } |
| 5082 | 5082 | } |
| 5083 | - $envelope['size']=$_headerObject->getSize(); |
|
| 5083 | + $envelope['size'] = $_headerObject->getSize(); |
|
| 5084 | 5084 | } |
| 5085 | 5085 | } |
| 5086 | - $envelope = array_change_key_case($envelope,CASE_UPPER); |
|
| 5086 | + $envelope = array_change_key_case($envelope, CASE_UPPER); |
|
| 5087 | 5087 | //if ($decode) _debug_array($envelope); |
| 5088 | 5088 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($envelope)); |
| 5089 | 5089 | if ($decode) |
@@ -5091,19 +5091,19 @@ discard block |
||
| 5091 | 5091 | foreach ($envelope as $key => $rvV) |
| 5092 | 5092 | { |
| 5093 | 5093 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5094 | - $envelope[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5094 | + $envelope[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5095 | 5095 | } |
| 5096 | 5096 | } |
| 5097 | 5097 | return $envelope; |
| 5098 | 5098 | } else { |
| 5099 | 5099 | |
| 5100 | - $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
|
| 5100 | + $headers = $this->getMessageHeader($_uid, $_partID, true, true, $_folder); |
|
| 5101 | 5101 | |
| 5102 | 5102 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($headers)); |
| 5103 | 5103 | //_debug_array($headers); |
| 5104 | 5104 | $newData = array( |
| 5105 | 5105 | 'DATE' => $headers['DATE'], |
| 5106 | - 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
|
| 5106 | + 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']) : $headers['SUBJECT']), |
|
| 5107 | 5107 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5108 | 5108 | ); |
| 5109 | 5109 | if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
@@ -5114,11 +5114,11 @@ discard block |
||
| 5114 | 5114 | if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
| 5115 | 5115 | //_debug_array($newData); |
| 5116 | 5116 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5117 | - foreach($recepientList as $recepientType) { |
|
| 5118 | - if(isset($headers[$recepientType])) { |
|
| 5119 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 5117 | + foreach ($recepientList as $recepientType) { |
|
| 5118 | + if (isset($headers[$recepientType])) { |
|
| 5119 | + if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType], true); |
|
| 5120 | 5120 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5121 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5121 | + foreach (self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5122 | 5122 | $addressData = array( |
| 5123 | 5123 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5124 | 5124 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5126,15 +5126,15 @@ discard block |
||
| 5126 | 5126 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5127 | 5127 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5128 | 5128 | ); |
| 5129 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5129 | + if ($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5130 | 5130 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5131 | 5131 | } else { |
| 5132 | 5132 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5133 | 5133 | } |
| 5134 | - $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
|
| 5134 | + $newData[$recepientType][] = ($addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']); //$addressData; |
|
| 5135 | 5135 | } |
| 5136 | 5136 | } else { |
| 5137 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5137 | + if ($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5138 | 5138 | $newData[$recepientType] = $newData['FROM']; |
| 5139 | 5139 | } else { |
| 5140 | 5140 | $newData[$recepientType] = array(); |
@@ -5156,10 +5156,10 @@ discard block |
||
| 5156 | 5156 | * @param string $_folder folder to work on |
| 5157 | 5157 | * @return array|Horde_Mime_Headers message header as array or object |
| 5158 | 5158 | */ |
| 5159 | - function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
|
| 5159 | + function getMessageHeader($_uid, $_partID = '', $decode = false, $preserveUnSeen = false, $_folder = '') |
|
| 5160 | 5160 | { |
| 5161 | 5161 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5162 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5162 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5163 | 5163 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5164 | 5164 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5165 | 5165 | $uidsToFetch->add($_uid); |
@@ -5167,7 +5167,7 @@ discard block |
||
| 5167 | 5167 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5168 | 5168 | if ($_partID != '') |
| 5169 | 5169 | { |
| 5170 | - $fquery->headerText(array('id'=>$_partID,'peek'=>$preserveUnSeen)); |
|
| 5170 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>$preserveUnSeen)); |
|
| 5171 | 5171 | $fquery->structure(); |
| 5172 | 5172 | } |
| 5173 | 5173 | else |
@@ -5180,18 +5180,18 @@ discard block |
||
| 5180 | 5180 | 'ids' => $uidsToFetch, |
| 5181 | 5181 | )); |
| 5182 | 5182 | if (is_object($headersNew)) { |
| 5183 | - foreach($headersNew as $_fetchObject) |
|
| 5183 | + foreach ($headersNew as $_fetchObject) |
|
| 5184 | 5184 | { |
| 5185 | - $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5185 | + $headers = $_fetchObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5186 | 5186 | if ($_partID != '') |
| 5187 | 5187 | { |
| 5188 | 5188 | $mailStructureObject = $_fetchObject->getStructure(); |
| 5189 | 5189 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5190 | 5190 | { |
| 5191 | - if ($mime_id==$_partID) |
|
| 5191 | + if ($mime_id == $_partID) |
|
| 5192 | 5192 | { |
| 5193 | 5193 | //error_log(__METHOD__.' ('.__LINE__.') '."$mime_id == $_partID".array2string($_headerObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray())); |
| 5194 | - $headers = $_fetchObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5194 | + $headers = $_fetchObject->getHeaderText($mime_id, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5195 | 5195 | break; |
| 5196 | 5196 | } |
| 5197 | 5197 | } |
@@ -5204,15 +5204,15 @@ discard block |
||
| 5204 | 5204 | if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
| 5205 | 5205 | return $headers; |
| 5206 | 5206 | } |
| 5207 | - $retValue = is_object($headers) ? $headers->toArray():array(); |
|
| 5207 | + $retValue = is_object($headers) ? $headers->toArray() : array(); |
|
| 5208 | 5208 | if ($size) $retValue['size'] = $size; |
| 5209 | 5209 | } |
| 5210 | - $retValue = array_change_key_case($retValue,CASE_UPPER); |
|
| 5210 | + $retValue = array_change_key_case($retValue, CASE_UPPER); |
|
| 5211 | 5211 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
| 5212 | 5212 | // if SUBJECT is an array, use thelast one, as we assume something with the unfolding for the subject did not work |
| 5213 | 5213 | if (is_array($retValue['SUBJECT'])) |
| 5214 | 5214 | { |
| 5215 | - $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT'])-1]; |
|
| 5215 | + $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT']) - 1]; |
|
| 5216 | 5216 | } |
| 5217 | 5217 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($decode ? self::decode_header($retValue,true):$retValue)); |
| 5218 | 5218 | if ($decode) |
@@ -5220,7 +5220,7 @@ discard block |
||
| 5220 | 5220 | foreach ($retValue as $key => $rvV) |
| 5221 | 5221 | { |
| 5222 | 5222 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5223 | - $retValue[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5223 | + $retValue[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5224 | 5224 | } |
| 5225 | 5225 | } |
| 5226 | 5226 | return $retValue; |
@@ -5237,14 +5237,14 @@ discard block |
||
| 5237 | 5237 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5238 | 5238 | { |
| 5239 | 5239 | static $rawHeaders; |
| 5240 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5240 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5241 | 5241 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5242 | 5242 | |
| 5243 | - 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); |
|
| 5244 | - if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5243 | + 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); |
|
| 5244 | + if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5245 | 5245 | { |
| 5246 | 5246 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5247 | - return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5247 | + return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5248 | 5248 | } |
| 5249 | 5249 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5250 | 5250 | $uid = $_uid; |
@@ -5254,7 +5254,7 @@ discard block |
||
| 5254 | 5254 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5255 | 5255 | if ($_partID != '') |
| 5256 | 5256 | { |
| 5257 | - $fquery->headerText(array('id'=>$_partID,'peek'=>true)); |
|
| 5257 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>true)); |
|
| 5258 | 5258 | $fquery->structure(); |
| 5259 | 5259 | } |
| 5260 | 5260 | else |
@@ -5265,14 +5265,14 @@ discard block |
||
| 5265 | 5265 | 'ids' => $uidsToFetch, |
| 5266 | 5266 | )); |
| 5267 | 5267 | if (is_object($headersNew)) { |
| 5268 | - foreach($headersNew as &$_headerObject) { |
|
| 5268 | + foreach ($headersNew as &$_headerObject) { |
|
| 5269 | 5269 | $retValue = $_headerObject->getHeaderText(); |
| 5270 | 5270 | if ($_partID != '') |
| 5271 | 5271 | { |
| 5272 | 5272 | $mailStructureObject = $_headerObject->getStructure(); |
| 5273 | 5273 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5274 | 5274 | { |
| 5275 | - if ($mime_id==$_partID) |
|
| 5275 | + if ($mime_id == $_partID) |
|
| 5276 | 5276 | { |
| 5277 | 5277 | $retValue = $_headerObject->getHeaderText($mime_id); |
| 5278 | 5278 | } |
@@ -5280,8 +5280,8 @@ discard block |
||
| 5280 | 5280 | } |
| 5281 | 5281 | } |
| 5282 | 5282 | } |
| 5283 | - $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]=$retValue; |
|
| 5284 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeaders,60*60*1); |
|
| 5283 | + $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $retValue; |
|
| 5284 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), $rawHeaders, 60 * 60 * 1); |
|
| 5285 | 5285 | return $retValue; |
| 5286 | 5286 | } |
| 5287 | 5287 | |
@@ -5294,25 +5294,25 @@ discard block |
||
| 5294 | 5294 | { |
| 5295 | 5295 | $style = ''; |
| 5296 | 5296 | if (empty($_bodyParts)) return ""; |
| 5297 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5297 | + foreach ((array)$_bodyParts as $singleBodyPart) { |
|
| 5298 | 5298 | if (!isset($singleBodyPart['body'])) { |
| 5299 | 5299 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5300 | 5300 | $style .= $singleBodyPart['body']; |
| 5301 | 5301 | continue; |
| 5302 | 5302 | } |
| 5303 | 5303 | |
| 5304 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5304 | + if ($singleBodyPart['charSet'] === false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5305 | 5305 | $singleBodyPart['body'] = Translation::convert( |
| 5306 | 5306 | $singleBodyPart['body'], |
| 5307 | 5307 | strtolower($singleBodyPart['charSet']) |
| 5308 | 5308 | ); |
| 5309 | 5309 | $ct = 0; |
| 5310 | - $newStyle=array(); |
|
| 5311 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5312 | - if ($ct>0) |
|
| 5310 | + $newStyle = array(); |
|
| 5311 | + if (stripos($singleBodyPart['body'], '<style') !== false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5312 | + if ($ct > 0) |
|
| 5313 | 5313 | { |
| 5314 | 5314 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
| 5315 | - $style2buffer = implode('',$newStyle[0]); |
|
| 5315 | + $style2buffer = implode('', $newStyle[0]); |
|
| 5316 | 5316 | } |
| 5317 | 5317 | if ($style2buffer && strtoupper(self::$displayCharset) == 'UTF-8') |
| 5318 | 5318 | { |
@@ -5320,7 +5320,7 @@ discard block |
||
| 5320 | 5320 | $test = json_encode($style2buffer); |
| 5321 | 5321 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error()); |
| 5322 | 5322 | //if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0) |
| 5323 | - if ($test=="null" && strlen($style2buffer)>0) |
|
| 5323 | + if ($test == "null" && strlen($style2buffer) > 0) |
|
| 5324 | 5324 | { |
| 5325 | 5325 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 5326 | 5326 | error_log(__METHOD__.' ('.__LINE__.') '.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Charset Reported:'.$singleBodyPart['charSet'].' Carset Detected:'.Translation::detect_encoding($style2buffer)); |
@@ -5331,19 +5331,19 @@ discard block |
||
| 5331 | 5331 | } |
| 5332 | 5332 | // clean out comments and stuff |
| 5333 | 5333 | $search = array( |
| 5334 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5334 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5335 | 5335 | // '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
| 5336 | 5336 | // '@<!--[\s\S]*?[ \t\n\r]*--@', // Strip broken multi-line comments including CDATA |
| 5337 | 5337 | ); |
| 5338 | - $style = preg_replace($search,"",$style); |
|
| 5338 | + $style = preg_replace($search, "", $style); |
|
| 5339 | 5339 | |
| 5340 | 5340 | // CSS Security |
| 5341 | 5341 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5342 | - $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
|
| 5343 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 5342 | + $css = preg_replace('/(javascript|expression|-moz-binding)/i', '', $style); |
|
| 5343 | + if (stripos($css, 'script') !== false) Mail\Html::replaceTagsCompletley($css, 'script'); // Strip out script that may be included |
|
| 5344 | 5344 | // 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 |
| 5345 | 5345 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5346 | - $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
|
| 5346 | + $css = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css); |
|
| 5347 | 5347 | //error_log(__METHOD__.' ('.__LINE__.') '.$css); |
| 5348 | 5348 | // TODO: we may have to strip urls and maybe comments and ifs |
| 5349 | 5349 | return $css; |
@@ -5357,16 +5357,16 @@ discard block |
||
| 5357 | 5357 | * @param string $_folder folder to work on |
| 5358 | 5358 | * @return string the message body |
| 5359 | 5359 | */ |
| 5360 | - function getMessageRawBody($_uid, $_partID = '', $_folder='') |
|
| 5360 | + function getMessageRawBody($_uid, $_partID = '', $_folder = '') |
|
| 5361 | 5361 | { |
| 5362 | 5362 | //TODO: caching einbauen static! |
| 5363 | 5363 | static $rawBody; |
| 5364 | 5364 | if (is_null($rawBody)) $rawBody = array(); |
| 5365 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5366 | - if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5365 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5366 | + if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5367 | 5367 | { |
| 5368 | 5368 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
| 5369 | - return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5369 | + return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5370 | 5370 | } |
| 5371 | 5371 | |
| 5372 | 5372 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -5379,13 +5379,13 @@ discard block |
||
| 5379 | 5379 | if ($_partID != '') |
| 5380 | 5380 | { |
| 5381 | 5381 | $fquery->structure(); |
| 5382 | - $fquery->bodyPart($_partID,array('peek'=>true)); |
|
| 5382 | + $fquery->bodyPart($_partID, array('peek'=>true)); |
|
| 5383 | 5383 | } |
| 5384 | 5384 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5385 | 5385 | 'ids' => $uidsToFetch, |
| 5386 | 5386 | )); |
| 5387 | 5387 | if (is_object($headersNew)) { |
| 5388 | - foreach($headersNew as &$_headerObject) { |
|
| 5388 | + foreach ($headersNew as &$_headerObject) { |
|
| 5389 | 5389 | $body = $_headerObject->getFullMsg(); |
| 5390 | 5390 | if ($_partID != '') |
| 5391 | 5391 | { |
@@ -5393,7 +5393,7 @@ discard block |
||
| 5393 | 5393 | //_debug_array($mailStructureObject->contentTypeMap()); |
| 5394 | 5394 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5395 | 5395 | { |
| 5396 | - if ($mime_id==$_partID) |
|
| 5396 | + if ($mime_id == $_partID) |
|
| 5397 | 5397 | { |
| 5398 | 5398 | $body = $_headerObject->getBodyPart($mime_id); |
| 5399 | 5399 | } |
@@ -5402,7 +5402,7 @@ discard block |
||
| 5402 | 5402 | } |
| 5403 | 5403 | } |
| 5404 | 5404 | //error_log(__METHOD__.' ('.__LINE__.') '."[$this->icServer->ImapServerId][$_folder][$_uid][".(empty($_partID)?'NIL':$_partID)."]"); |
| 5405 | - $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)] = $body; |
|
| 5405 | + $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $body; |
|
| 5406 | 5406 | return $body; |
| 5407 | 5407 | } |
| 5408 | 5408 | |
@@ -5416,13 +5416,13 @@ discard block |
||
| 5416 | 5416 | * @param Horde_Imap_Client_Fetch_Query $fquery=null default query just structure |
| 5417 | 5417 | * @return Horde_Mime_Part |
| 5418 | 5418 | */ |
| 5419 | - function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
|
| 5419 | + function getStructure($_uid, $_partID = null, $_folder = null, $_preserveSeen = false) |
|
| 5420 | 5420 | { |
| 5421 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5421 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5422 | 5422 | |
| 5423 | 5423 | if (empty($_folder)) |
| 5424 | 5424 | { |
| 5425 | - $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5425 | + $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5426 | 5426 | } |
| 5427 | 5427 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5428 | 5428 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5440,7 +5440,7 @@ discard block |
||
| 5440 | 5440 | 'ids' => $uidsToFetch, |
| 5441 | 5441 | ))->first(); |
| 5442 | 5442 | |
| 5443 | - return is_object($mail)?$mail->getStructure():null; |
|
| 5443 | + return is_object($mail) ? $mail->getStructure() : null; |
|
| 5444 | 5444 | } |
| 5445 | 5445 | catch (\Exception $e) |
| 5446 | 5446 | { |
@@ -5463,14 +5463,14 @@ discard block |
||
| 5463 | 5463 | * @param string $_folder folder to work on |
| 5464 | 5464 | * @return array an array of information about the attachment: array of array(name, size, mimeType, partID, encoding) |
| 5465 | 5465 | */ |
| 5466 | - function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
|
| 5466 | + function getMessageAttachments($_uid, $_partID = null, Horde_Mime_Part $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = false, $resolveTNEF = true, $_folder = '') |
|
| 5467 | 5467 | { |
| 5468 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5469 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5468 | + if (self::$debug) error_log(__METHOD__.":$_uid, $_partID"); |
|
| 5469 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5470 | 5470 | $attachments = array(); |
| 5471 | 5471 | if (!isset($_structure)) |
| 5472 | 5472 | { |
| 5473 | - $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
|
| 5473 | + $_structure = $this->getStructure($_uid, $_partID, $_folder, true); |
|
| 5474 | 5474 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5475 | 5475 | } |
| 5476 | 5476 | if (!$_structure || !$_structure->contentTypeMap()) return array(); |
@@ -5478,7 +5478,7 @@ discard block |
||
| 5478 | 5478 | $skipParts = array(); |
| 5479 | 5479 | $tnefParts = array(); |
| 5480 | 5480 | $skip = 0; |
| 5481 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5481 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5482 | 5482 | { |
| 5483 | 5483 | // skip multipart/encrypted incl. its two sub-parts, as we show 2. sub-part as body to be decrypted client-side |
| 5484 | 5484 | if ($mime_type == 'multipart/encrypted') |
@@ -5486,7 +5486,7 @@ discard block |
||
| 5486 | 5486 | $skip = 2; |
| 5487 | 5487 | continue; |
| 5488 | 5488 | } |
| 5489 | - elseif($skip) |
|
| 5489 | + elseif ($skip) |
|
| 5490 | 5490 | { |
| 5491 | 5491 | $skip--; |
| 5492 | 5492 | continue; |
@@ -5500,10 +5500,10 @@ discard block |
||
| 5500 | 5500 | $partPrimaryType = $part->getPrimaryType(); |
| 5501 | 5501 | // we only want to retrieve the attachments of the current mail, not those of possible |
| 5502 | 5502 | // attached mails |
| 5503 | - if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
|
| 5503 | + if ($mime_type == 'message/rfc822' && $_partID != $mime_id) |
|
| 5504 | 5504 | { |
| 5505 | 5505 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5506 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 5506 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 5507 | 5507 | } |
| 5508 | 5508 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5509 | 5509 | { |
@@ -5511,27 +5511,27 @@ discard block |
||
| 5511 | 5511 | // attachment with no link to show the attachment inline. |
| 5512 | 5512 | // Considering this: we "list" everything that matches the above criteria |
| 5513 | 5513 | // as attachment in order to not loose/miss information on our data |
| 5514 | - $partDisposition='attachment'; |
|
| 5514 | + $partDisposition = 'attachment'; |
|
| 5515 | 5515 | } |
| 5516 | 5516 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5517 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 5517 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 5518 | 5518 | |
| 5519 | 5519 | if ($partDisposition == 'attachment' || |
| 5520 | - (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
|
| 5520 | + (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId() == '') || |
|
| 5521 | 5521 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType != 'image' && $partPrimaryType != 'text' && $partPrimaryType != 'multipart') || |
| 5522 | - ($mime_type=='image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5522 | + ($mime_type == 'image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5523 | 5523 | ($fetchEmbeddedImages && ($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image') || |
| 5524 | 5524 | ($fetchTextCalendar && $partPrimaryType == 'text' && $part->getSubType() == 'calendar')) |
| 5525 | 5525 | { |
| 5526 | 5526 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5527 | 5527 | // we attempt to fetch "ourselves" |
| 5528 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 5528 | + if ($_partID == $part->getMimeId() && $part->getPrimaryType() == 'message') continue; |
|
| 5529 | 5529 | $attachment = $part->getAllDispositionParameters(); |
| 5530 | 5530 | $attachment['disposition'] = $part->getDisposition(); |
| 5531 | 5531 | $attachment['mimeType'] = $mime_type; |
| 5532 | 5532 | $attachment['uid'] = $_uid; |
| 5533 | 5533 | $attachment['partID'] = $mime_id; |
| 5534 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5534 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5535 | 5535 | if ($fetchTextCalendar) |
| 5536 | 5536 | { |
| 5537 | 5537 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
@@ -5541,11 +5541,11 @@ discard block |
||
| 5541 | 5541 | } |
| 5542 | 5542 | $attachment['size'] = $part->getBytes(); |
| 5543 | 5543 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5544 | - 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); |
|
| 5544 | + 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); |
|
| 5545 | 5545 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5546 | 5546 | //typical winmail.dat attachment is |
| 5547 | 5547 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
| 5548 | - if ($resolveTNEF && ($attachment['mimeType']=='application/ms-tnef' || !strcasecmp($attachment['name'],'winmail.dat'))) |
|
| 5548 | + if ($resolveTNEF && ($attachment['mimeType'] == 'application/ms-tnef' || !strcasecmp($attachment['name'], 'winmail.dat'))) |
|
| 5549 | 5549 | { |
| 5550 | 5550 | $tnefParts[] = $attachment; |
| 5551 | 5551 | } |
@@ -5560,31 +5560,31 @@ discard block |
||
| 5560 | 5560 | //error_log(__METHOD__.__LINE__.array2string($tnefParts)); |
| 5561 | 5561 | foreach ($tnefParts as $k => $tnp) |
| 5562 | 5562 | { |
| 5563 | - $tnefResolved=false; |
|
| 5564 | - $tnef_data = $this->getAttachment($tnp['uid'],$tnp['partID'],$k,false); |
|
| 5563 | + $tnefResolved = false; |
|
| 5564 | + $tnef_data = $this->getAttachment($tnp['uid'], $tnp['partID'], $k, false); |
|
| 5565 | 5565 | $myTnef = $this->tnef_decoder($tnef_data['attachment']); |
| 5566 | 5566 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5567 | 5567 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5568 | 5568 | // we need to build Something that meets the needs |
| 5569 | 5569 | if ($myTnef) |
| 5570 | 5570 | { |
| 5571 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5571 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5572 | 5572 | { |
| 5573 | - $tnefResolved=true; |
|
| 5573 | + $tnefResolved = true; |
|
| 5574 | 5574 | $attachment = $part->getAllDispositionParameters(); |
| 5575 | 5575 | $attachment['disposition'] = $part->getDisposition(); |
| 5576 | 5576 | $attachment['mimeType'] = $part->getType(); |
| 5577 | 5577 | $attachment['uid'] = $tnp['uid']; |
| 5578 | 5578 | $attachment['partID'] = $tnp['partID']; |
| 5579 | 5579 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5580 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5580 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5581 | 5581 | $attachment['size'] = $part->getBytes(); |
| 5582 | 5582 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5583 | - 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']); |
|
| 5583 | + 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']); |
|
| 5584 | 5584 | $attachments[] = $attachment; |
| 5585 | 5585 | } |
| 5586 | 5586 | } |
| 5587 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 5587 | + if ($tnefResolved === false) $attachments[] = $tnp; |
|
| 5588 | 5588 | } |
| 5589 | 5589 | } |
| 5590 | 5590 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5599,9 +5599,9 @@ discard block |
||
| 5599 | 5599 | * @return boolean|Horde_Mime_part Multipart/Mixed part decoded attachments | |
| 5600 | 5600 | * return false if there's no attachments or failure |
| 5601 | 5601 | */ |
| 5602 | - public function tnef_decoder( $data ) |
|
| 5602 | + public function tnef_decoder($data) |
|
| 5603 | 5603 | { |
| 5604 | - foreach(array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5604 | + foreach (array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5605 | 5605 | { |
| 5606 | 5606 | if (!class_exists($class)) |
| 5607 | 5607 | { |
@@ -5633,7 +5633,7 @@ discard block |
||
| 5633 | 5633 | $tmp_part->setContents($data['stream']); |
| 5634 | 5634 | $tmp_part->setDescription($data['name']); |
| 5635 | 5635 | |
| 5636 | - $type = $data['type'] . '/' . $data['subtype']; |
|
| 5636 | + $type = $data['type'].'/'.$data['subtype']; |
|
| 5637 | 5637 | if (in_array($type, array('application/octet-stream', 'application/base64'))) |
| 5638 | 5638 | { |
| 5639 | 5639 | $type = Horde_Mime_Magic::filenameToMIME($data['name']); |
@@ -5676,24 +5676,24 @@ discard block |
||
| 5676 | 5676 | * |
| 5677 | 5677 | * @return array returns an array of all resolved embeded attachments from winmail.dat |
| 5678 | 5678 | */ |
| 5679 | - function getTnefAttachments ($_uid, $_partID, $_stream=false) |
|
| 5679 | + function getTnefAttachments($_uid, $_partID, $_stream = false) |
|
| 5680 | 5680 | { |
| 5681 | - $tnef_data = $this->getAttachment($_uid, $_partID,0,false); |
|
| 5681 | + $tnef_data = $this->getAttachment($_uid, $_partID, 0, false); |
|
| 5682 | 5682 | $tnef_parts = $this->tnef_decoder($tnef_data['attachment']); |
| 5683 | 5683 | $attachments = array(); |
| 5684 | 5684 | if ($tnef_parts) |
| 5685 | 5685 | { |
| 5686 | - foreach($tnef_parts->getParts() as $mime_id => $part) |
|
| 5686 | + foreach ($tnef_parts->getParts() as $mime_id => $part) |
|
| 5687 | 5687 | { |
| 5688 | 5688 | |
| 5689 | 5689 | $attachment = $part->getAllDispositionParameters(); |
| 5690 | 5690 | $attachment['mimeType'] = $part->getType(); |
| 5691 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5691 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5692 | 5692 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5693 | 5693 | if (empty($attachment['filename'])) |
| 5694 | 5694 | { |
| 5695 | - $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
|
| 5696 | - $attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5695 | + $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? |
|
| 5696 | + $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5697 | 5697 | } |
| 5698 | 5698 | |
| 5699 | 5699 | $attachment['attachment'] = $part->getContents(array('stream'=>$_stream)); |
@@ -5717,10 +5717,10 @@ discard block |
||
| 5717 | 5717 | * |
| 5718 | 5718 | * @return array |
| 5719 | 5719 | */ |
| 5720 | - function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
|
| 5720 | + function getAttachment($_uid, $_partID, $_winmail_nr = 0, $_returnPart = true, $_stream = false, $_folder = null) |
|
| 5721 | 5721 | { |
| 5722 | 5722 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5723 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5723 | + if (!isset($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5724 | 5724 | |
| 5725 | 5725 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5726 | 5726 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5733,36 +5733,36 @@ discard block |
||
| 5733 | 5733 | 'ids' => $uidsToFetch, |
| 5734 | 5734 | )); |
| 5735 | 5735 | if (is_object($headersNew)) { |
| 5736 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 5736 | + foreach ($headersNew as $id=>$_headerObject) { |
|
| 5737 | 5737 | $body = $_headerObject->getFullMsg(); |
| 5738 | 5738 | if ($_partID != '') |
| 5739 | 5739 | { |
| 5740 | 5740 | $mailStructureObject = $_headerObject->getStructure(); |
| 5741 | 5741 | $mailStructureObject->contentTypeMap(); |
| 5742 | 5742 | $part = $mailStructureObject->getPart($_partID); |
| 5743 | - $partDisposition = ($part?$part->getDisposition():'failed'); |
|
| 5744 | - if ($partDisposition=='failed') |
|
| 5743 | + $partDisposition = ($part ? $part->getDisposition() : 'failed'); |
|
| 5744 | + if ($partDisposition == 'failed') |
|
| 5745 | 5745 | { |
| 5746 | 5746 | error_log(__METHOD__.'('.__LINE__.'):'.array2string($_uid).','.$_partID.' ID:'.$id.' HObject:'.array2string($_headerObject).' StructureObject:'.array2string($mailStructureObject->contentTypeMap()).'->'.function_backtrace()); |
| 5747 | 5747 | } |
| 5748 | 5748 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5749 | 5749 | // itself is only triggered to fetch attachments |
| 5750 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 5751 | - if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5750 | + if (empty($partDisposition)) $partDisposition = 'attachment'; |
|
| 5751 | + if ($part && ($partDisposition == 'attachment' || $partDisposition == 'inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5752 | 5752 | { |
| 5753 | 5753 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
| 5754 | 5754 | $structure_mime = $part->getType(); |
| 5755 | 5755 | $filename = $part->getName(); |
| 5756 | 5756 | $charset = $part->getContentTypeParameter('charset'); |
| 5757 | 5757 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5758 | - $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
|
| 5758 | + $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen = true, $structure_mime); |
|
| 5759 | 5759 | if ($_returnPart) return $part; |
| 5760 | 5760 | } |
| 5761 | 5761 | } |
| 5762 | 5762 | } |
| 5763 | 5763 | } |
| 5764 | 5764 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5765 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 5765 | + if ($ext && stripos($filename, '.') === false && stripos($filename, $ext) === false) $filename = trim($filename).'.'.$ext; |
|
| 5766 | 5766 | if (!$part) |
| 5767 | 5767 | { |
| 5768 | 5768 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5780,20 +5780,20 @@ discard block |
||
| 5780 | 5780 | // try guessing the mimetype, if we get the application/octet-stream |
| 5781 | 5781 | if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
| 5782 | 5782 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5783 | - if ( $filename == 'winmail.dat' && $_winmail_nr) |
|
| 5783 | + if ($filename == 'winmail.dat' && $_winmail_nr) |
|
| 5784 | 5784 | { |
| 5785 | 5785 | //by now _uid is of type array |
| 5786 | - $tnefResolved=false; |
|
| 5787 | - $wantedPart=$_uid[0].'@'.$_partID; |
|
| 5786 | + $tnefResolved = false; |
|
| 5787 | + $wantedPart = $_uid[0].'@'.$_partID; |
|
| 5788 | 5788 | $myTnef = $this->tnef_decoder($attachmentData['attachment']); |
| 5789 | 5789 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5790 | 5790 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5791 | 5791 | // we need to build Something that meets the needs |
| 5792 | 5792 | if ($myTnef) |
| 5793 | 5793 | { |
| 5794 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5794 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5795 | 5795 | { |
| 5796 | - $tnefResolved=true; |
|
| 5796 | + $tnefResolved = true; |
|
| 5797 | 5797 | $attachment = $part->getAllDispositionParameters(); |
| 5798 | 5798 | $attachment['mimeType'] = $part->getType(); |
| 5799 | 5799 | //error_log(__METHOD__.__LINE__.'#'.$mime_id.'#'.$filename.'#'.array2string($attachment)); |
@@ -5801,9 +5801,9 @@ discard block |
||
| 5801 | 5801 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5802 | 5802 | { |
| 5803 | 5803 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5804 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5804 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5805 | 5805 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5806 | - 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']); |
|
| 5806 | + 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']); |
|
| 5807 | 5807 | $wmattach = $attachment; |
| 5808 | 5808 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5809 | 5809 | |
@@ -5813,7 +5813,7 @@ discard block |
||
| 5813 | 5813 | if ($tnefResolved) |
| 5814 | 5814 | { |
| 5815 | 5815 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5816 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5816 | + if ($ext && stripos($wmattach['filename'], '.') === false && stripos($wmattach['filename'], $ext) === false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5817 | 5817 | $attachmentData = array( |
| 5818 | 5818 | 'type' => $wmattach['mimeType'], |
| 5819 | 5819 | 'filename' => $wmattach['filename'], |
@@ -5837,21 +5837,21 @@ discard block |
||
| 5837 | 5837 | * true: |
| 5838 | 5838 | * @return Horde_Mime_Part |
| 5839 | 5839 | */ |
| 5840 | - function getAttachmentByCID($_uid, $_cid, $_part, $_stream=null) |
|
| 5840 | + function getAttachmentByCID($_uid, $_cid, $_part, $_stream = null) |
|
| 5841 | 5841 | { |
| 5842 | 5842 | // some static variables to avoid fetching the same mail multiple times |
| 5843 | - static $uid=null, $part=null, $structure=null; |
|
| 5843 | + static $uid = null, $part = null, $structure = null; |
|
| 5844 | 5844 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5845 | 5845 | |
| 5846 | - if(empty($_cid)) return false; |
|
| 5846 | + if (empty($_cid)) return false; |
|
| 5847 | 5847 | |
| 5848 | 5848 | if ($_uid != $uid || $_part != $part) |
| 5849 | 5849 | { |
| 5850 | - $structure = $this->getStructure($uid=$_uid, $part=$_part); |
|
| 5850 | + $structure = $this->getStructure($uid = $_uid, $part = $_part); |
|
| 5851 | 5851 | } |
| 5852 | 5852 | /** @var Horde_Mime_Part */ |
| 5853 | 5853 | $attachment = null; |
| 5854 | - foreach($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5854 | + foreach ($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5855 | 5855 | { |
| 5856 | 5856 | $part = $structure->getPart($mime_id); |
| 5857 | 5857 | |
@@ -5903,16 +5903,16 @@ discard block |
||
| 5903 | 5903 | * @param string $_mimetype to decide wether to try to fetch part as binary or not |
| 5904 | 5904 | * @return Horde_Mime_Part |
| 5905 | 5905 | */ |
| 5906 | - public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
|
| 5906 | + public function fetchPartContents($_uid, Horde_Mime_Part $part = null, $_stream = false, $_preserveSeen = false, $_mimetype = null) |
|
| 5907 | 5907 | { |
| 5908 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 5908 | + if (is_null($part)) return null; //new Horde_Mime_Part; |
|
| 5909 | 5909 | $encoding = null; |
| 5910 | 5910 | $fetchAsBinary = true; |
| 5911 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 5911 | + if ($_mimetype && strtolower($_mimetype) == 'message/rfc822') $fetchAsBinary = false; |
|
| 5912 | 5912 | // we need to set content on structure to decode transfer encoding |
| 5913 | 5913 | $part->setContents( |
| 5914 | 5914 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
| 5915 | - array('encoding' => (!$fetchAsBinary&&!$encoding?'8bit':$encoding))); |
|
| 5915 | + array('encoding' => (!$fetchAsBinary && !$encoding ? '8bit' : $encoding))); |
|
| 5916 | 5916 | |
| 5917 | 5917 | return $part; |
| 5918 | 5918 | } |
@@ -5930,17 +5930,17 @@ discard block |
||
| 5930 | 5930 | * @return the id of the message appended or exception |
| 5931 | 5931 | * @throws Exception\WrongUserinput |
| 5932 | 5932 | */ |
| 5933 | - function appendMessage($_folderName, $_header, $_body, $_flags='\\Recent') |
|
| 5933 | + function appendMessage($_folderName, $_header, $_body, $_flags = '\\Recent') |
|
| 5934 | 5934 | { |
| 5935 | 5935 | if (!is_resource($_header)) |
| 5936 | 5936 | { |
| 5937 | - if (stripos($_header,'message-id:')===false) |
|
| 5937 | + if (stripos($_header, 'message-id:') === false) |
|
| 5938 | 5938 | { |
| 5939 | 5939 | $_header = 'Message-ID: <'.self::getRandomString().'@localhost>'."\n".$_header; |
| 5940 | 5940 | } |
| 5941 | 5941 | //error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_header, $_body, $_flags"); |
| 5942 | - $_header = ltrim(str_replace("\n","\r\n",$_header)); |
|
| 5943 | - $_header .= str_replace("\n","\r\n",$_body); |
|
| 5942 | + $_header = ltrim(str_replace("\n", "\r\n", $_header)); |
|
| 5943 | + $_header .= str_replace("\n", "\r\n", $_body); |
|
| 5944 | 5944 | } |
| 5945 | 5945 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 5946 | 5946 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
@@ -5958,7 +5958,7 @@ discard block |
||
| 5958 | 5958 | // searched for the message-id then returning the uid found |
| 5959 | 5959 | //$dataNflags[] = array('data'=>array(array('t'=>'text','v'=>"$header"."$body")), 'flags'=>array($_flags)); |
| 5960 | 5960 | $dataNflags[] = array('data' => $_header, 'flags'=>array($_flags)); |
| 5961 | - $messageid = $this->icServer->append($_folderName,$dataNflags); |
|
| 5961 | + $messageid = $this->icServer->append($_folderName, $dataNflags); |
|
| 5962 | 5962 | } |
| 5963 | 5963 | catch (\Exception $e) |
| 5964 | 5964 | { |
@@ -5970,7 +5970,7 @@ discard block |
||
| 5970 | 5970 | //$messageid = true; // for debug reasons only |
| 5971 | 5971 | if ($messageid === true || empty($messageid)) // try to figure out the message uid |
| 5972 | 5972 | { |
| 5973 | - $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
|
| 5973 | + $list = $this->getHeaders($_folderName, $_startMessage = 1, 1, 'INTERNALDATE', true, array(), null, false); |
|
| 5974 | 5974 | if ($list) |
| 5975 | 5975 | { |
| 5976 | 5976 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
@@ -6010,27 +6010,27 @@ discard block |
||
| 6010 | 6010 | * 'attachments'=>$attachments, |
| 6011 | 6011 | * 'headers'=>$headers,; boolean false on failure |
| 6012 | 6012 | */ |
| 6013 | - static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true) |
|
| 6013 | + static function get_mailcontent(&$mailClass, $uid, $partid = '', $mailbox = '', $preserveHTML = false, $addHeaderSection = true, $includeAttachments = true) |
|
| 6014 | 6014 | { |
| 6015 | 6015 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6016 | - $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
|
| 6016 | + $headers = $mailClass->getMessageHeader($uid, $partid, true, false, $mailbox); |
|
| 6017 | 6017 | if (empty($headers)) return false; |
| 6018 | 6018 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6019 | - $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
|
| 6019 | + $bodyParts = $mailClass->getMessageBody($uid, ($preserveHTML ? 'always_display' : 'only_if_no_text'), $partid, null, false, $mailbox); |
|
| 6020 | 6020 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
| 6021 | - if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html') |
|
| 6021 | + if (!$preserveHTML && $bodyParts[0]['mimeType'] == 'text/html') |
|
| 6022 | 6022 | { |
| 6023 | - foreach($bodyParts as $i => $part) |
|
| 6023 | + foreach ($bodyParts as $i => $part) |
|
| 6024 | 6024 | { |
| 6025 | - if ($bodyParts[$i]['mimeType']=='text/html') |
|
| 6025 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 6026 | 6026 | { |
| 6027 | - $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'],$bodyParts[$i]['charSet'],true,$stripalltags=true); |
|
| 6028 | - $bodyParts[$i]['mimeType']='text/plain'; |
|
| 6027 | + $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'], $bodyParts[$i]['charSet'], true, $stripalltags = true); |
|
| 6028 | + $bodyParts[$i]['mimeType'] = 'text/plain'; |
|
| 6029 | 6029 | } |
| 6030 | 6030 | } |
| 6031 | 6031 | } |
| 6032 | 6032 | //error_log(array2string($bodyParts)); |
| 6033 | - $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
|
| 6033 | + $attachments = $includeAttachments ? $mailClass->getMessageAttachments($uid, $partid, null, true, false, true, $mailbox) : array(); |
|
| 6034 | 6034 | |
| 6035 | 6035 | if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
| 6036 | 6036 | elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
@@ -6041,7 +6041,7 @@ discard block |
||
| 6041 | 6041 | |
| 6042 | 6042 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6043 | 6043 | if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
| 6044 | - $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
|
| 6044 | + $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '', $preserveHTML) : ''); |
|
| 6045 | 6045 | $message = $headdata.$message; |
| 6046 | 6046 | //echo __METHOD__.'<br>'; |
| 6047 | 6047 | //_debug_array($attachments); |
@@ -6057,25 +6057,25 @@ discard block |
||
| 6057 | 6057 | //_debug_array($mailClass->getMessageHeader($uid, $attachment['partID'])); |
| 6058 | 6058 | //_debug_array($mailClass->getMessageBody($uid,'', $attachment['partID'])); |
| 6059 | 6059 | //_debug_array($mailClass->getMessageAttachments($uid, $attachment['partID'])); |
| 6060 | - $mailcontent = self::get_mailcontent($mailClass,$uid,$attachment['partID'],$mailbox); |
|
| 6061 | - $headdata =''; |
|
| 6060 | + $mailcontent = self::get_mailcontent($mailClass, $uid, $attachment['partID'], $mailbox); |
|
| 6061 | + $headdata = ''; |
|
| 6062 | 6062 | if ($mailcontent['headers']) |
| 6063 | 6063 | { |
| 6064 | - $headdata = self::createHeaderInfoSection($mailcontent['headers'],'',$preserveHTML); |
|
| 6064 | + $headdata = self::createHeaderInfoSection($mailcontent['headers'], '', $preserveHTML); |
|
| 6065 | 6065 | } |
| 6066 | 6066 | if ($mailcontent['message']) |
| 6067 | 6067 | { |
| 6068 | - $tempname =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6068 | + $tempname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6069 | 6069 | $attachedMessages[] = array( |
| 6070 | 6070 | 'type' => 'TEXT/PLAIN', |
| 6071 | 6071 | 'name' => $mailcontent['subject'].'.txt', |
| 6072 | 6072 | 'tmp_name' => $tempname, |
| 6073 | 6073 | ); |
| 6074 | - $tmpfile = fopen($tempname,'w'); |
|
| 6075 | - fwrite($tmpfile,$headdata.$mailcontent['message']); |
|
| 6074 | + $tmpfile = fopen($tempname, 'w'); |
|
| 6075 | + fwrite($tmpfile, $headdata.$mailcontent['message']); |
|
| 6076 | 6076 | fclose($tmpfile); |
| 6077 | 6077 | } |
| 6078 | - foreach($mailcontent['attachments'] as &$tmpval) |
|
| 6078 | + foreach ($mailcontent['attachments'] as &$tmpval) |
|
| 6079 | 6079 | { |
| 6080 | 6080 | $attachedMessages[] = $tmpval; |
| 6081 | 6081 | } |
@@ -6083,36 +6083,36 @@ discard block |
||
| 6083 | 6083 | } |
| 6084 | 6084 | else |
| 6085 | 6085 | { |
| 6086 | - $attachments[$num] = array_merge($attachments[$num],$mailClass->getAttachment($uid, $attachment['partID'],0,false,false)); |
|
| 6086 | + $attachments[$num] = array_merge($attachments[$num], $mailClass->getAttachment($uid, $attachment['partID'], 0, false, false)); |
|
| 6087 | 6087 | |
| 6088 | - if (empty($attachments[$num]['attachment'])&&$attachments[$num]['cid']) |
|
| 6088 | + if (empty($attachments[$num]['attachment']) && $attachments[$num]['cid']) |
|
| 6089 | 6089 | { |
| 6090 | - $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'],true); |
|
| 6090 | + $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'], true); |
|
| 6091 | 6091 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6092 | 6092 | } |
| 6093 | 6093 | // no attempt to convert, if we dont know about the charset |
| 6094 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 6094 | + if (isset($attachments[$num]['charset']) && !empty($attachments[$num]['charset'])) { |
|
| 6095 | 6095 | // we do not try guessing the charset, if it is not set |
| 6096 | 6096 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6097 | - Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
|
| 6097 | + Translation::convert($attachments[$num]['attachment'], $attachments[$num]['charset']); |
|
| 6098 | 6098 | } |
| 6099 | - if(in_array($attachments[$num]['name'], $file_list)) |
|
| 6099 | + if (in_array($attachments[$num]['name'], $file_list)) |
|
| 6100 | 6100 | { |
| 6101 | 6101 | $dupe_count[$attachments[$num]['name']]++; |
| 6102 | - $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME) . |
|
| 6103 | - ' ('.($dupe_count[$attachments[$num]['name']] + 1).')' . '.' . |
|
| 6102 | + $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME). |
|
| 6103 | + ' ('.($dupe_count[$attachments[$num]['name']] + 1).')'.'.'. |
|
| 6104 | 6104 | pathinfo($attachments[$num]['name'], PATHINFO_EXTENSION); |
| 6105 | 6105 | } |
| 6106 | 6106 | $attachments[$num]['type'] = $attachments[$num]['mimeType']; |
| 6107 | - $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6108 | - $tmpfile = fopen($attachments[$num]['tmp_name'],'w'); |
|
| 6109 | - fwrite($tmpfile,$attachments[$num]['attachment']); |
|
| 6107 | + $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6108 | + $tmpfile = fopen($attachments[$num]['tmp_name'], 'w'); |
|
| 6109 | + fwrite($tmpfile, $attachments[$num]['attachment']); |
|
| 6110 | 6110 | fclose($tmpfile); |
| 6111 | 6111 | $file_list[] = $attachments[$num]['name']; |
| 6112 | 6112 | unset($attachments[$num]['attachment']); |
| 6113 | 6113 | } |
| 6114 | 6114 | } |
| 6115 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 6115 | + if (is_array($attachedMessages)) $attachments = array_merge($attachments, $attachedMessages); |
|
| 6116 | 6116 | } |
| 6117 | 6117 | return array( |
| 6118 | 6118 | 'mailaddress'=>$mailaddress, |
@@ -6134,10 +6134,10 @@ discard block |
||
| 6134 | 6134 | { |
| 6135 | 6135 | $c = 0; |
| 6136 | 6136 | // use the standardIdentity |
| 6137 | - foreach($_identities as $key => $acc) { |
|
| 6138 | - if ($c==0) $identity = $acc; |
|
| 6137 | + foreach ($_identities as $key => $acc) { |
|
| 6138 | + if ($c == 0) $identity = $acc; |
|
| 6139 | 6139 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6140 | - if ($key==$_profile_id) $identity = $acc; |
|
| 6140 | + if ($key == $_profile_id) $identity = $acc; |
|
| 6141 | 6141 | $c++; |
| 6142 | 6142 | } |
| 6143 | 6143 | return $identity; |
@@ -6149,29 +6149,29 @@ discard block |
||
| 6149 | 6149 | * @param bool createHTML do it with HTML breaks |
| 6150 | 6150 | * @return string a preformatted string with the information of the header worked into it |
| 6151 | 6151 | */ |
| 6152 | - static function createHeaderInfoSection($header,$headline='', $createHTML = false) |
|
| 6152 | + static function createHeaderInfoSection($header, $headline = '', $createHTML = false) |
|
| 6153 | 6153 | { |
| 6154 | 6154 | $headdata = null; |
| 6155 | 6155 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6156 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6157 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6158 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6159 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6160 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6161 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6162 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6163 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6164 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 6156 | + if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML ? "<br />" : "\n"); |
|
| 6157 | + if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6158 | + if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6159 | + if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6160 | + if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6161 | + if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6162 | + if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML ? "<br />" : "\n"); |
|
| 6163 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML ? "<br />" : "\n"); |
|
| 6164 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] != 'normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML ? "<br />" : "\n"); |
|
| 6165 | 6165 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6166 | 6166 | if (!empty($headdata)) |
| 6167 | 6167 | { |
| 6168 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6169 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 6170 | - $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6168 | + if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML ? "<br />" : "\n").$headdata; |
|
| 6169 | + if (empty($headline)) $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '').$headdata; |
|
| 6170 | + $headdata .= ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6171 | 6171 | } |
| 6172 | 6172 | else |
| 6173 | 6173 | { |
| 6174 | - $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6174 | + $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6175 | 6175 | } |
| 6176 | 6176 | return $headdata; |
| 6177 | 6177 | } |
@@ -6184,8 +6184,8 @@ discard block |
||
| 6184 | 6184 | */ |
| 6185 | 6185 | static function adaptSubjectForImport($subject) |
| 6186 | 6186 | { |
| 6187 | - $subject = str_replace('$$','__',($subject?$subject:lang('(no subject)'))); |
|
| 6188 | - $subject = str_ireplace(array('[FWD]','[',']','{','}','<','>'),array('Fwd:',' ',' ',' ',' ',' ',' '),trim($subject)); |
|
| 6187 | + $subject = str_replace('$$', '__', ($subject ? $subject : lang('(no subject)'))); |
|
| 6188 | + $subject = str_ireplace(array('[FWD]', '[', ']', '{', '}', '<', '>'), array('Fwd:', ' ', ' ', ' ', ' ', ' ', ' '), trim($subject)); |
|
| 6189 | 6189 | return $subject; |
| 6190 | 6190 | } |
| 6191 | 6191 | |
@@ -6197,15 +6197,15 @@ discard block |
||
| 6197 | 6197 | static function convertAddressArrayToString($rfcAddressArray) |
| 6198 | 6198 | { |
| 6199 | 6199 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($rfcAddressArray)); |
| 6200 | - $returnAddr =''; |
|
| 6200 | + $returnAddr = ''; |
|
| 6201 | 6201 | if (is_array($rfcAddressArray)) |
| 6202 | 6202 | { |
| 6203 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 6203 | + foreach ((array)$rfcAddressArray as $addressData) { |
|
| 6204 | 6204 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6205 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6205 | + if ($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6206 | 6206 | continue; |
| 6207 | 6207 | } |
| 6208 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6208 | + if (strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6209 | 6209 | continue; |
| 6210 | 6210 | } |
| 6211 | 6211 | if ($addressData['RFC822_EMAIL']) |
@@ -6214,7 +6214,7 @@ discard block |
||
| 6214 | 6214 | } |
| 6215 | 6215 | else |
| 6216 | 6216 | { |
| 6217 | - $emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']); |
|
| 6217 | + $emailaddress = ($addressData['PERSONAL_NAME'] ? $addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>' : $addressData['EMAIL']); |
|
| 6218 | 6218 | $addressObjectA = self::parseAddressList($emailaddress); |
| 6219 | 6219 | } |
| 6220 | 6220 | $addressObject = $addressObjectA[0]; |
@@ -6223,10 +6223,10 @@ discard block |
||
| 6223 | 6223 | //$mb =(string)$addressObject->mailbox; |
| 6224 | 6224 | //$h = (string)$addressObject->host; |
| 6225 | 6225 | //$p = (string)$addressObject->personal; |
| 6226 | - $returnAddr .= (strlen($returnAddr)>0?',':''); |
|
| 6226 | + $returnAddr .= (strlen($returnAddr) > 0 ? ',' : ''); |
|
| 6227 | 6227 | //error_log(__METHOD__.' ('.__LINE__.') '.$p.' <'.$mb.'@'.$h.'>'); |
| 6228 | 6228 | $buff = imap_rfc822_write_address($addressObject->mailbox, Horde_Idna::decode($addressObject->host), $addressObject->personal); |
| 6229 | - $buff = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$buff); |
|
| 6229 | + $buff = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $buff); |
|
| 6230 | 6230 | //error_log(__METHOD__.' ('.__LINE__.') '.' Address: '.$returnAddr); |
| 6231 | 6231 | $returnAddr .= $buff; |
| 6232 | 6232 | } |
@@ -6234,8 +6234,8 @@ discard block |
||
| 6234 | 6234 | else |
| 6235 | 6235 | { |
| 6236 | 6236 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6237 | - $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
|
| 6238 | - $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
|
| 6237 | + $rfcAddressArray = self::decode_header($rfcAddressArray, true); |
|
| 6238 | + $rfcAddressArray = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $rfcAddressArray); |
|
| 6239 | 6239 | if (is_string($rfcAddressArray)) return $rfcAddressArray; |
| 6240 | 6240 | } |
| 6241 | 6241 | return $returnAddr; |
@@ -6249,12 +6249,12 @@ discard block |
||
| 6249 | 6249 | * @param string &$err error-message on error |
| 6250 | 6250 | * @return string/boolean merged content or false on error |
| 6251 | 6251 | */ |
| 6252 | - static function merge($content,$ids,$mimetype='') |
|
| 6252 | + static function merge($content, $ids, $mimetype = '') |
|
| 6253 | 6253 | { |
| 6254 | 6254 | $mergeobj = new Contacts\Merge(); |
| 6255 | 6255 | |
| 6256 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 6257 | - $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
|
| 6256 | + if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ? 'text/plain' : 'text/html'); |
|
| 6257 | + $rv = $mergeobj->merge_string($content, $ids, $err = '', $mimetype, array(), self::$displayCharset); |
|
| 6258 | 6258 | if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
| 6259 | 6259 | if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
| 6260 | 6260 | return $rv; |
@@ -6296,12 +6296,12 @@ discard block |
||
| 6296 | 6296 | else |
| 6297 | 6297 | settype($bytes, 'integer'); |
| 6298 | 6298 | |
| 6299 | - return $bytes . ' ' . $type ; |
|
| 6299 | + return $bytes.' '.$type; |
|
| 6300 | 6300 | } |
| 6301 | 6301 | |
| 6302 | 6302 | static function detect_qp(&$sting) { |
| 6303 | 6303 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6304 | - return preg_match("$needle",$string); |
|
| 6304 | + return preg_match("$needle", $string); |
|
| 6305 | 6305 | } |
| 6306 | 6306 | |
| 6307 | 6307 | /** |
@@ -6314,11 +6314,11 @@ discard block |
||
| 6314 | 6314 | * @param string $_methodNline - Information where the log was taken |
| 6315 | 6315 | * @return void |
| 6316 | 6316 | */ |
| 6317 | - static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
|
| 6317 | + static function logRunTimes($_starttime, $_endtime = null, $_message = '', $_methodNline = '') |
|
| 6318 | 6318 | { |
| 6319 | 6319 | if (is_null($_endtime)) $_endtime = microtime(true); |
| 6320 | 6320 | $usagetime = microtime(true) - $_starttime; |
| 6321 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 6321 | + if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime, 5).'(s) '.($_message ? 'Details:'.$_message : '')); |
|
| 6322 | 6322 | } |
| 6323 | 6323 | |
| 6324 | 6324 | /** |
@@ -6331,9 +6331,9 @@ discard block |
||
| 6331 | 6331 | * |
| 6332 | 6332 | * @throws Exception\WrongUserinput |
| 6333 | 6333 | */ |
| 6334 | - static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
|
| 6334 | + static function checkFileBasics(&$_formData, $IDtoAddToFileName = '', $reqMimeType = 'message/rfc822') |
|
| 6335 | 6335 | { |
| 6336 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6336 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6337 | 6337 | |
| 6338 | 6338 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6339 | 6339 | $importfailed = $tmpFileName = false; |
@@ -6343,7 +6343,7 @@ discard block |
||
| 6343 | 6343 | $importfailed = true; |
| 6344 | 6344 | $alert_msg .= lang("Empty file %1 ignored.", $_formData['name']); |
| 6345 | 6345 | } |
| 6346 | - elseif (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6346 | + elseif (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6347 | 6347 | realpath(dirname($_formData['file'])) == realpath($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6348 | 6348 | { |
| 6349 | 6349 | // ensure existance of eGW temp dir |
@@ -6351,7 +6351,7 @@ discard block |
||
| 6351 | 6351 | // and different from any other temp file location set in php.ini |
| 6352 | 6352 | if (!file_exists($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6353 | 6353 | { |
| 6354 | - @mkdir($GLOBALS['egw_info']['server']['temp_dir'],0700); |
|
| 6354 | + @mkdir($GLOBALS['egw_info']['server']['temp_dir'], 0700); |
|
| 6355 | 6355 | } |
| 6356 | 6356 | |
| 6357 | 6357 | // if we were NOT able to create this temp directory, then make an ERROR report |
@@ -6378,14 +6378,14 @@ discard block |
||
| 6378 | 6378 | // maybe its application/octet-stream -> this may mean that we could not determine the type |
| 6379 | 6379 | // so we check for the suffix too |
| 6380 | 6380 | // trust vfs mime-types, trust the mimetype if it contains a method |
| 6381 | - if ((substr($_formData['file'],0,6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'],'method=')===false) |
|
| 6381 | + if ((substr($_formData['file'], 0, 6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'], 'method=') === false) |
|
| 6382 | 6382 | { |
| 6383 | - $buff = explode('.',$_formData['name']); |
|
| 6383 | + $buff = explode('.', $_formData['name']); |
|
| 6384 | 6384 | $suffix = ''; |
| 6385 | 6385 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 6386 | 6386 | if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
| 6387 | 6387 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6388 | - (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6388 | + (strlen(trim($_formData['type'])) == 0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6389 | 6389 | { |
| 6390 | 6390 | error_log(__METHOD__.' ('.__LINE__.') '.' Data:'.array2string($_formData)); |
| 6391 | 6391 | error_log(__METHOD__.' ('.__LINE__.') '.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType); |
@@ -6400,13 +6400,13 @@ discard block |
||
| 6400 | 6400 | if ($reqMimeType) |
| 6401 | 6401 | { |
| 6402 | 6402 | // so if PHP did not pass any file_type info, then substitute the rfc default value |
| 6403 | - if (substr(strtolower(trim($_formData['type'])),0,strlen($mime_type_default)) != $mime_type_default) |
|
| 6403 | + if (substr(strtolower(trim($_formData['type'])), 0, strlen($mime_type_default)) != $mime_type_default) |
|
| 6404 | 6404 | { |
| 6405 | 6405 | if (!(strtolower(trim($_formData['type'])) == "application/octet-stream" && $sfxMimeType == $reqMimeType)) |
| 6406 | 6406 | { |
| 6407 | 6407 | //error_log("Message rejected, no message/rfc. Is:".$_formData['type']); |
| 6408 | 6408 | $importfailed = true; |
| 6409 | - $alert_msg .= lang("File rejected, no %2. Is:%1",$_formData['type'],$reqMimeType); |
|
| 6409 | + $alert_msg .= lang("File rejected, no %2. Is:%1", $_formData['type'], $reqMimeType); |
|
| 6410 | 6410 | } |
| 6411 | 6411 | if ((strtolower(trim($_formData['type'])) != $reqMimeType && $sfxMimeType == $reqMimeType)) |
| 6412 | 6412 | { |
@@ -6415,17 +6415,17 @@ discard block |
||
| 6415 | 6415 | } |
| 6416 | 6416 | } |
| 6417 | 6417 | // as FreeBSD seems to have problems with the generated temp names we append some more random stuff |
| 6418 | - $randomString = chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)); |
|
| 6418 | + $randomString = chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)); |
|
| 6419 | 6419 | $tmpFileName = $GLOBALS['egw_info']['user']['account_id']. |
| 6420 | 6420 | trim($IDtoAddToFileName).basename($_formData['file']).'_'.$randomString; |
| 6421 | 6421 | |
| 6422 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs') |
|
| 6422 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs') |
|
| 6423 | 6423 | { |
| 6424 | - $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6424 | + $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6425 | 6425 | } |
| 6426 | 6426 | elseif (is_uploaded_file($_formData['file'])) |
| 6427 | 6427 | { |
| 6428 | - move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6428 | + move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6429 | 6429 | } |
| 6430 | 6430 | else |
| 6431 | 6431 | { |
@@ -6434,7 +6434,7 @@ discard block |
||
| 6434 | 6434 | } else { |
| 6435 | 6435 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6436 | 6436 | $importfailed = true; |
| 6437 | - $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
|
| 6437 | + $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.", $_formData['name']); |
|
| 6438 | 6438 | } |
| 6439 | 6439 | if ($importfailed == true) |
| 6440 | 6440 | { |
@@ -6442,7 +6442,7 @@ discard block |
||
| 6442 | 6442 | } |
| 6443 | 6443 | else |
| 6444 | 6444 | { |
| 6445 | - if (parse_url($tmpFileName,PHP_URL_SCHEME) == 'vfs') |
|
| 6445 | + if (parse_url($tmpFileName, PHP_URL_SCHEME) == 'vfs') |
|
| 6446 | 6446 | { |
| 6447 | 6447 | Vfs::load_wrapper('vfs'); |
| 6448 | 6448 | } |
@@ -6467,7 +6467,7 @@ discard block |
||
| 6467 | 6467 | $images = null; |
| 6468 | 6468 | if (preg_match_all("/(src|background)=\"(.*)\"/Ui", $_html2parse, $images) && isset($images[2])) |
| 6469 | 6469 | { |
| 6470 | - foreach($images[2] as $i => $url) |
|
| 6470 | + foreach ($images[2] as $i => $url) |
|
| 6471 | 6471 | { |
| 6472 | 6472 | //$isData = false; |
| 6473 | 6473 | $basedir = $data = ''; |
@@ -6479,20 +6479,20 @@ discard block |
||
| 6479 | 6479 | $filename = basename($url); |
| 6480 | 6480 | if (($directory = dirname($url)) == '.') $directory = ''; |
| 6481 | 6481 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6482 | - $mimeType = MimeMagic::ext2mime($ext); |
|
| 6483 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 6482 | + $mimeType = MimeMagic::ext2mime($ext); |
|
| 6483 | + if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } |
|
| 6484 | 6484 | $myUrl = $directory.$filename; |
| 6485 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6485 | + if ($myUrl[0] == '/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6486 | 6486 | { |
| 6487 | - $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
|
| 6487 | + $basedir = ($_SERVER['HTTPS'] ? 'https://' : 'http://'.$_SERVER['HTTP_HOST']); |
|
| 6488 | 6488 | } |
| 6489 | 6489 | // use vfs instead of url containing webdav.php |
| 6490 | 6490 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6491 | 6491 | // webdav.php urls as vfs |
| 6492 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6492 | + if (strpos($myUrl, '/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6493 | 6493 | { |
| 6494 | 6494 | Vfs::load_wrapper('vfs'); |
| 6495 | - list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
|
| 6495 | + list(,$myUrl) = explode('/webdav.php', $myUrl, 2); |
|
| 6496 | 6496 | $basedir = 'vfs://default'; |
| 6497 | 6497 | $needTempFile = false; |
| 6498 | 6498 | } |
@@ -6505,11 +6505,11 @@ discard block |
||
| 6505 | 6505 | // Strips the url and store it into a temp for further procss |
| 6506 | 6506 | $tmp_url = html_entity_decode($myUrl); |
| 6507 | 6507 | |
| 6508 | - parse_str(parse_url($tmp_url, PHP_URL_QUERY),$URI_params); |
|
| 6508 | + parse_str(parse_url($tmp_url, PHP_URL_QUERY), $URI_params); |
|
| 6509 | 6509 | if ($URI_params['mailbox'] && $URI_params['uid'] && $URI_params['cid']) |
| 6510 | 6510 | { |
| 6511 | 6511 | $mail_bo->reopen(base64_decode($URI_params['mailbox'])); |
| 6512 | - $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']),base64_decode($URI_params['partID']),true); |
|
| 6512 | + $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']), base64_decode($URI_params['partID']), true); |
|
| 6513 | 6513 | $mail_bo->closeConnection(); |
| 6514 | 6514 | if ($attachment) |
| 6515 | 6515 | { |
@@ -6520,32 +6520,32 @@ discard block |
||
| 6520 | 6520 | } |
| 6521 | 6521 | } |
| 6522 | 6522 | |
| 6523 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6524 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6523 | + if (strlen($basedir) > 1 && substr($basedir, -1) != '/' && $myUrl[0] != '/') { $basedir .= '/'; } |
|
| 6524 | + if ($needTempFile && !$attachment && substr($myUrl, 0, 4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6525 | 6525 | } |
| 6526 | - if (substr($url,0,strlen('data:'))=='data:') |
|
| 6526 | + if (substr($url, 0, strlen('data:')) == 'data:') |
|
| 6527 | 6527 | { |
| 6528 | 6528 | //error_log(__METHOD__.' ('.__LINE__.') '.' -> '.$i.': '.array2string($images[$i])); |
| 6529 | 6529 | // we only support base64 encoded data |
| 6530 | - $tmp = substr($url,strlen('data:')); |
|
| 6531 | - list($mimeType,$data_base64) = explode(';base64,',$tmp); |
|
| 6530 | + $tmp = substr($url, strlen('data:')); |
|
| 6531 | + list($mimeType, $data_base64) = explode(';base64,', $tmp); |
|
| 6532 | 6532 | $data = base64_decode($data_base64); |
| 6533 | 6533 | // FF currently does NOT add any mime-type |
| 6534 | 6534 | if (strtolower(substr($mimeType, 0, 6)) != 'image/') |
| 6535 | 6535 | { |
| 6536 | 6536 | $mimeType = MimeMagic::analyze_data($data); |
| 6537 | 6537 | } |
| 6538 | - list($what,$exactly) = explode('/',$mimeType); |
|
| 6538 | + list($what, $exactly) = explode('/', $mimeType); |
|
| 6539 | 6539 | $needTempFile = true; |
| 6540 | - $filename = ($what?$what:'data').$imageC++.'.'.$exactly; |
|
| 6540 | + $filename = ($what ? $what : 'data').$imageC++.'.'.$exactly; |
|
| 6541 | 6541 | } |
| 6542 | 6542 | if ($data || $needTempFile === false) |
| 6543 | 6543 | { |
| 6544 | 6544 | if ($needTempFile) |
| 6545 | 6545 | { |
| 6546 | - $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6547 | - $tmpfile = fopen($attachment_file,'w'); |
|
| 6548 | - fwrite($tmpfile,$data); |
|
| 6546 | + $attachment_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6547 | + $tmpfile = fopen($attachment_file, 'w'); |
|
| 6548 | + fwrite($tmpfile, $data); |
|
| 6549 | 6549 | fclose($tmpfile); |
| 6550 | 6550 | } |
| 6551 | 6551 | else |
@@ -6556,7 +6556,7 @@ discard block |
||
| 6556 | 6556 | // (or similar) in all cases (when cut&paste). This may lead to more attached files, in case |
| 6557 | 6557 | // we use the same image multiple times, but, if we do this, we should try to detect that |
| 6558 | 6558 | // on upload. filename itself is not sufficient to determine the sameness of images |
| 6559 | - $cid = 'cid:' . md5($attachment_file); |
|
| 6559 | + $cid = 'cid:'.md5($attachment_file); |
|
| 6560 | 6560 | if ($_mailObject->AddEmbeddedImage($attachment_file, substr($cid, 4), urldecode($filename), $mimeType) !== null) |
| 6561 | 6561 | { |
| 6562 | 6562 | //$_html2parse = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $_html2parse); |
@@ -6578,10 +6578,10 @@ discard block |
||
| 6578 | 6578 | * @param string& $importID ID for the imported message, used by attachments to identify them unambiguously |
| 6579 | 6579 | * @return mixed array of messages with success and failed messages or exception |
| 6580 | 6580 | */ |
| 6581 | - function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID='') |
|
| 6581 | + function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID = '') |
|
| 6582 | 6582 | { |
| 6583 | 6583 | $importfailed = false; |
| 6584 | - $processStats = array('success'=>array(),'failed'=>array()); |
|
| 6584 | + $processStats = array('success'=>array(), 'failed'=>array()); |
|
| 6585 | 6585 | if (empty($SendAndMergeTocontacts)) |
| 6586 | 6586 | { |
| 6587 | 6587 | $importfailed = true; |
@@ -6622,7 +6622,7 @@ discard block |
||
| 6622 | 6622 | $_folder = $this->getSentFolder(); |
| 6623 | 6623 | } |
| 6624 | 6624 | $delimiter = $this->getHierarchyDelimiter(); |
| 6625 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 6625 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 6626 | 6626 | if ($importfailed === false) |
| 6627 | 6627 | { |
| 6628 | 6628 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6640,9 +6640,9 @@ discard block |
||
| 6640 | 6640 | { |
| 6641 | 6641 | $mailObject->clearReplyTos(); |
| 6642 | 6642 | $activeMailProfiles = $this->mail->getAccountIdentities($this->profileID); |
| 6643 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6643 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6644 | 6644 | |
| 6645 | - $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']),Mail::generateIdentityString($activeMailProfile,false)); |
|
| 6645 | + $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']), Mail::generateIdentityString($activeMailProfile, false)); |
|
| 6646 | 6646 | } |
| 6647 | 6647 | foreach ($SendAndMergeTocontacts as $k => $val) |
| 6648 | 6648 | { |
@@ -6656,12 +6656,12 @@ discard block |
||
| 6656 | 6656 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6657 | 6657 | |
| 6658 | 6658 | // Parse destinations for placeholders |
| 6659 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6659 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6660 | 6660 | { |
| 6661 | 6661 | //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)); |
| 6662 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6663 | - $mailObject->addAddress($merged,'',$type); |
|
| 6664 | - if($type == 'to') |
|
| 6662 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6663 | + $mailObject->addAddress($merged, '', $type); |
|
| 6664 | + if ($type == 'to') |
|
| 6665 | 6665 | { |
| 6666 | 6666 | $email = $merged; |
| 6667 | 6667 | } |
@@ -6674,26 +6674,26 @@ discard block |
||
| 6674 | 6674 | //error_log(__METHOD__.' ('.__LINE__.') '.' ID:'.$val.' Data:'.array2string($contact)); |
| 6675 | 6675 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6676 | 6676 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6677 | - if($email) |
|
| 6677 | + if ($email) |
|
| 6678 | 6678 | { |
| 6679 | 6679 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6680 | 6680 | } |
| 6681 | 6681 | } |
| 6682 | 6682 | |
| 6683 | 6683 | $activeMailProfiles = $this->getAccountIdentities($this->profileID); |
| 6684 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6684 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6685 | 6685 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($activeMailProfile)); |
| 6686 | 6686 | $mailObject->setFrom($activeMailProfile['ident_email'], |
| 6687 | - self::generateIdentityString($activeMailProfile,false)); |
|
| 6687 | + self::generateIdentityString($activeMailProfile, false)); |
|
| 6688 | 6688 | |
| 6689 | 6689 | $mailObject->removeHeader('Message-ID'); |
| 6690 | 6690 | $mailObject->removeHeader('Date'); |
| 6691 | 6691 | $mailObject->clearCustomHeaders(); |
| 6692 | 6692 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6693 | 6693 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6694 | - 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)); |
|
| 6694 | + 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)); |
|
| 6695 | 6695 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6696 | - 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)); |
|
| 6696 | + 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)); |
|
| 6697 | 6697 | |
| 6698 | 6698 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6699 | 6699 | // set a higher timeout for big messages |
@@ -6702,7 +6702,7 @@ discard block |
||
| 6702 | 6702 | try { |
| 6703 | 6703 | $mailObject->send(); |
| 6704 | 6704 | } |
| 6705 | - catch(Exception $e) { |
|
| 6705 | + catch (Exception $e) { |
|
| 6706 | 6706 | $sendOK = false; |
| 6707 | 6707 | $errorInfo = $e->getMessage(); |
| 6708 | 6708 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
@@ -6716,41 +6716,41 @@ discard block |
||
| 6716 | 6716 | $mailObject->clearCustomHeaders(); |
| 6717 | 6717 | |
| 6718 | 6718 | // Parse destinations for placeholders |
| 6719 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6719 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6720 | 6720 | { |
| 6721 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6721 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6722 | 6722 | //error_log($type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$merged); |
| 6723 | - $mailObject->addAddress(trim($merged,'"'),'',$type); |
|
| 6723 | + $mailObject->addAddress(trim($merged, '"'), '', $type); |
|
| 6724 | 6724 | } |
| 6725 | 6725 | |
| 6726 | 6726 | // No addresses from placeholders? Treat it as just a contact ID |
| 6727 | - if (count($mailObject->getAddresses('to',true)) == 0 && |
|
| 6727 | + if (count($mailObject->getAddresses('to', true)) == 0 && |
|
| 6728 | 6728 | is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
| 6729 | 6729 | { |
| 6730 | 6730 | $contact = $bo_merge->contacts->read($val); |
| 6731 | 6731 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6732 | 6732 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6733 | 6733 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6734 | - if($email) |
|
| 6734 | + if ($email) |
|
| 6735 | 6735 | { |
| 6736 | 6736 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6737 | 6737 | } |
| 6738 | 6738 | } |
| 6739 | 6739 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6740 | 6740 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6741 | - 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)); |
|
| 6741 | + 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)); |
|
| 6742 | 6742 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6743 | - 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)); |
|
| 6743 | + 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)); |
|
| 6744 | 6744 | $_folder = $this->getDraftFolder(); |
| 6745 | 6745 | } |
| 6746 | 6746 | if ($sendOK || $openAsDraft) |
| 6747 | 6747 | { |
| 6748 | - if ($this->folderExists($_folder,true)) |
|
| 6748 | + if ($this->folderExists($_folder, true)) |
|
| 6749 | 6749 | { |
| 6750 | - if($this->isSentFolder($_folder)) |
|
| 6750 | + if ($this->isSentFolder($_folder)) |
|
| 6751 | 6751 | { |
| 6752 | 6752 | $flags = '\\Seen'; |
| 6753 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 6753 | + } elseif ($this->isDraftFolder($_folder)) { |
|
| 6754 | 6754 | $flags = '\\Draft'; |
| 6755 | 6755 | } else { |
| 6756 | 6756 | $flags = ''; |
@@ -6758,7 +6758,7 @@ discard block |
||
| 6758 | 6758 | $savefailed = false; |
| 6759 | 6759 | try |
| 6760 | 6760 | { |
| 6761 | - $messageUid =$this->appendMessage($_folder, |
|
| 6761 | + $messageUid = $this->appendMessage($_folder, |
|
| 6762 | 6762 | $mailObject->getRaw(), |
| 6763 | 6763 | null, |
| 6764 | 6764 | $flags); |
@@ -6766,10 +6766,10 @@ discard block |
||
| 6766 | 6766 | catch (\Exception\WrongUserinput $e) |
| 6767 | 6767 | { |
| 6768 | 6768 | $savefailed = true; |
| 6769 | - $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage()); |
|
| 6769 | + $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", $Subject, $_folder, $e->getMessage()); |
|
| 6770 | 6770 | } |
| 6771 | 6771 | // no send, save successful, and message_uid present |
| 6772 | - if ($savefailed===false && $messageUid && is_null($sendOK)) |
|
| 6772 | + if ($savefailed === false && $messageUid && is_null($sendOK)) |
|
| 6773 | 6773 | { |
| 6774 | 6774 | $importID = $messageUid; |
| 6775 | 6775 | $openComposeWindow = true; |
@@ -6778,20 +6778,20 @@ discard block |
||
| 6778 | 6778 | else |
| 6779 | 6779 | { |
| 6780 | 6780 | $savefailed = true; |
| 6781 | - $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.",$Subject,$_folder); |
|
| 6781 | + $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.", $Subject, $_folder); |
|
| 6782 | 6782 | } |
| 6783 | 6783 | if ($sendOK) |
| 6784 | 6784 | { |
| 6785 | - $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed?' but failed to store to Folder:'.$_folder:''); |
|
| 6785 | + $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed ? ' but failed to store to Folder:'.$_folder : ''); |
|
| 6786 | 6786 | } |
| 6787 | 6787 | else |
| 6788 | 6788 | { |
| 6789 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6789 | + if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6790 | 6790 | } |
| 6791 | 6791 | } |
| 6792 | - if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
|
| 6792 | + if (!is_null($sendOK) && $sendOK === false && is_null($openComposeWindow)) |
|
| 6793 | 6793 | { |
| 6794 | - $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6794 | + $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6795 | 6795 | } |
| 6796 | 6796 | } |
| 6797 | 6797 | } |
@@ -6861,19 +6861,18 @@ discard block |
||
| 6861 | 6861 | //error_log(__METHOD__.__LINE__.':'.array2string($structure)); |
| 6862 | 6862 | |
| 6863 | 6863 | // unfortunately parseMessage does NOT return parsed headers (we assume header is shorter then 8k) |
| 6864 | - $start = is_string($message) ? substr($message, 0, 8192) : |
|
| 6865 | - (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6864 | + $start = is_string($message) ? substr($message, 0, 8192) : (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6866 | 6865 | |
| 6867 | 6866 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6868 | - if ($length===false) $length = strlen($start); |
|
| 6869 | - $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
|
| 6867 | + if ($length === false) $length = strlen($start); |
|
| 6868 | + $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0, $length)); |
|
| 6870 | 6869 | |
| 6871 | - foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6870 | + foreach ($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6872 | 6871 | { |
| 6873 | - foreach((array)$value as $n => $val) |
|
| 6872 | + foreach ((array)$value as $n => $val) |
|
| 6874 | 6873 | { |
| 6875 | 6874 | $overwrite = !$n; |
| 6876 | - switch($header) |
|
| 6875 | + switch ($header) |
|
| 6877 | 6876 | { |
| 6878 | 6877 | case 'Content-Transfer-Encoding': |
| 6879 | 6878 | //as we parse the message and this sets the part with a Content-Transfer-Encoding, we |
@@ -6894,7 +6893,7 @@ discard block |
||
| 6894 | 6893 | } |
| 6895 | 6894 | else |
| 6896 | 6895 | { |
| 6897 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 6896 | + if (($type = gettype($message)) == 'object') $type = get_class($message); |
|
| 6898 | 6897 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 6899 | 6898 | } |
| 6900 | 6899 | } |
@@ -6908,50 +6907,50 @@ discard block |
||
| 6908 | 6907 | * @param string $default_domain |
| 6909 | 6908 | * @return Horde_Mail_Rfc822_List iteratable Horde_Mail_Rfc822_Address objects with attributes mailbox, host, personal and valid |
| 6910 | 6909 | */ |
| 6911 | - public static function parseAddressList($addresses, $default_domain=null) |
|
| 6910 | + public static function parseAddressList($addresses, $default_domain = null) |
|
| 6912 | 6911 | { |
| 6913 | 6912 | $rfc822 = new Horde_Mail_Rfc822(); |
| 6914 | 6913 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 6915 | 6914 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count.function_backtrace()); |
| 6916 | - if ((empty($ret) || $ret->count()==0)&& is_string($addresses) && strlen($addresses)>0) |
|
| 6915 | + if ((empty($ret) || $ret->count() == 0) && is_string($addresses) && strlen($addresses) > 0) |
|
| 6917 | 6916 | { |
| 6918 | 6917 | $matches = array(); |
| 6919 | - preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
|
| 6918 | + preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/", $addresses, $matches); |
|
| 6920 | 6919 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 6921 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 6922 | - $addresses = implode(',',$matches[0]); |
|
| 6920 | + foreach ($matches[0] as &$match) {$match = trim($match, ', '); } |
|
| 6921 | + $addresses = implode(',', $matches[0]); |
|
| 6923 | 6922 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 6924 | 6923 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 6925 | 6924 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count); |
| 6926 | 6925 | } |
| 6927 | - $previousFailed=false; |
|
| 6926 | + $previousFailed = false; |
|
| 6928 | 6927 | $ret2 = new Horde_Mail_Rfc822_List(); |
| 6929 | 6928 | // handle known problems on emailaddresses |
| 6930 | - foreach($ret as $i => $adr) |
|
| 6929 | + foreach ($ret as $i => $adr) |
|
| 6931 | 6930 | { |
| 6932 | 6931 | //mailaddresses enclosed in single quotes like '[email protected]' show up as 'me as mailbox and you.com' as host |
| 6933 | - if ($adr->mailbox && stripos($adr->mailbox,"'")== 0 && |
|
| 6934 | - $adr->host && stripos($adr->host,"'")== (strlen($adr->host) -1)) |
|
| 6932 | + if ($adr->mailbox && stripos($adr->mailbox, "'") == 0 && |
|
| 6933 | + $adr->host && stripos($adr->host, "'") == (strlen($adr->host) - 1)) |
|
| 6935 | 6934 | { |
| 6936 | - $adr->mailbox = str_replace("'","",$adr->mailbox); |
|
| 6937 | - $adr->host = str_replace("'","",$adr->host); |
|
| 6935 | + $adr->mailbox = str_replace("'", "", $adr->mailbox); |
|
| 6936 | + $adr->host = str_replace("'", "", $adr->host); |
|
| 6938 | 6937 | } |
| 6939 | 6938 | // no mailbox or host part as 'Xr\xc3\xa4hlyz, User <[email protected]>' is parsed as 2 addresses separated by ',' |
| 6940 | 6939 | //#'Xr\xc3\xa4hlyz, User <[email protected]>' |
| 6941 | 6940 | //#Horde_Mail_Rfc822_List Object([_data:protected] => Array( |
| 6942 | 6941 | //[0] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => Xr\xc3\xa4hlyz[_host:protected] => [_personal:protected] => ) |
| 6943 | 6942 | //[1] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => mailboxpart1.mailboxpart2[_host:protected] => youthost.com[_personal:protected] => User))[_filter:protected] => Array()[_ptr:protected] => )#2#, |
| 6944 | - if (strlen($adr->mailbox)==0||strlen($adr->host)==0) |
|
| 6943 | + if (strlen($adr->mailbox) == 0 || strlen($adr->host) == 0) |
|
| 6945 | 6944 | { |
| 6946 | - $remember = ($adr->mailbox?$adr->mailbox:($adr->host?$adr->host:'')); |
|
| 6947 | - $previousFailed=true; |
|
| 6945 | + $remember = ($adr->mailbox ? $adr->mailbox : ($adr->host ? $adr->host : '')); |
|
| 6946 | + $previousFailed = true; |
|
| 6948 | 6947 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 6949 | 6948 | } |
| 6950 | 6949 | else |
| 6951 | 6950 | { |
| 6952 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 6951 | + if ($previousFailed && $remember) $adr->personal = $remember.' '.$adr->personal; |
|
| 6953 | 6952 | $remember = ''; |
| 6954 | - $previousFailed=false; |
|
| 6953 | + $previousFailed = false; |
|
| 6955 | 6954 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 6956 | 6955 | $ret2->add($adr); |
| 6957 | 6956 | } |
@@ -6967,7 +6966,7 @@ discard block |
||
| 6967 | 6966 | * @param string $_folder |
| 6968 | 6967 | * @return boolean |
| 6969 | 6968 | */ |
| 6970 | - function sendMDN($uid,$_folder) |
|
| 6969 | + function sendMDN($uid, $_folder) |
|
| 6971 | 6970 | { |
| 6972 | 6971 | $acc = Mail\Account::read($this->profileID); |
| 6973 | 6972 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
@@ -6997,7 +6996,7 @@ discard block |
||
| 6997 | 6996 | */ |
| 6998 | 6997 | function addAccount($_hookValues) |
| 6999 | 6998 | { |
| 7000 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 6999 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7001 | 7000 | |
| 7002 | 7001 | } |
| 7003 | 7002 | |
@@ -7011,7 +7010,7 @@ discard block |
||
| 7011 | 7010 | */ |
| 7012 | 7011 | function deleteAccount($_hookValues) |
| 7013 | 7012 | { |
| 7014 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7013 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7015 | 7014 | |
| 7016 | 7015 | } |
| 7017 | 7016 | |
@@ -7025,7 +7024,7 @@ discard block |
||
| 7025 | 7024 | */ |
| 7026 | 7025 | function updateAccount($_hookValues) |
| 7027 | 7026 | { |
| 7028 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7027 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7029 | 7028 | |
| 7030 | 7029 | } |
| 7031 | 7030 | } |
@@ -198,7 +198,10 @@ discard block |
||
| 198 | 198 | public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) |
| 199 | 199 | { |
| 200 | 200 | //$_restoreSession=false; |
| 201 | - if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
|
| 201 | + if (is_null($_reuseCache)) |
|
| 202 | + { |
|
| 203 | + $_reuseCache = $_restoreSession; |
|
| 204 | + } |
|
| 202 | 205 | //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()); |
| 203 | 206 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject)); |
| 204 | 207 | if ($_oldImapServerObject instanceof Mail\Imap) |
@@ -224,9 +227,15 @@ discard block |
||
| 224 | 227 | { |
| 225 | 228 | $profileID = Mail\Account::get_default_acc_id(); |
| 226 | 229 | } |
| 227 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 230 | + if ($profileID!=$_profileID) |
|
| 231 | + { |
|
| 232 | + $_restoreSession==false; |
|
| 233 | + } |
|
| 228 | 234 | $_profileID=$profileID; |
| 229 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
|
| 235 | + if (self::$debug) |
|
| 236 | + { |
|
| 237 | + error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
|
| 238 | + } |
|
| 230 | 239 | } |
| 231 | 240 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 232 | 241 | if ($_oldImapServerObject===true) |
@@ -265,7 +274,8 @@ discard block |
||
| 265 | 274 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 266 | 275 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 267 | 276 | self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
| 268 | - } catch (\Exception $e) |
|
| 277 | + } |
|
| 278 | + catch (\Exception $e) |
|
| 269 | 279 | { |
| 270 | 280 | $newprofileID = Mail\Account::get_default_acc_id(); |
| 271 | 281 | // try loading the default profile for the user |
@@ -283,9 +293,15 @@ discard block |
||
| 283 | 293 | self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
| 284 | 294 | } |
| 285 | 295 | self::$instances[$_profileID]->profileID = $_profileID; |
| 286 | - if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
|
| 296 | + if (!isset(self::$instances[$_profileID]->idna2)) |
|
| 297 | + { |
|
| 298 | + self::$instances[$_profileID]->idna2 = new Horde_Idna; |
|
| 299 | + } |
|
| 287 | 300 | //if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID); |
| 288 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 301 | + if (is_null(self::$mailConfig)) |
|
| 302 | + { |
|
| 303 | + self::$mailConfig = Config::read('mail'); |
|
| 304 | + } |
|
| 289 | 305 | return self::$instances[$_profileID]; |
| 290 | 306 | } |
| 291 | 307 | |
@@ -310,14 +326,20 @@ discard block |
||
| 310 | 326 | } |
| 311 | 327 | catch (\Exception $e) |
| 312 | 328 | { |
| 313 | - if ($_profileID != Mail\Account::get_default_acc_id()) $_profileID = Mail\Account::get_default_acc_id(); |
|
| 329 | + if ($_profileID != Mail\Account::get_default_acc_id()) |
|
| 330 | + { |
|
| 331 | + $_profileID = Mail\Account::get_default_acc_id(); |
|
| 332 | + } |
|
| 314 | 333 | error_log(__METHOD__.__LINE__.' '.$e->getMessage()); |
| 315 | 334 | return false; |
| 316 | 335 | } |
| 317 | 336 | } |
| 318 | 337 | if ($oldProfileID != $_profileID) |
| 319 | 338 | { |
| 320 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 339 | + if ($oldProfileID && $_profileID==0) |
|
| 340 | + { |
|
| 341 | + $_profileID = $oldProfileID; |
|
| 342 | + } |
|
| 321 | 343 | $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
| 322 | 344 | // save prefs |
| 323 | 345 | $GLOBALS['egw']->preferences->save_repository(true); |
@@ -347,11 +369,17 @@ discard block |
||
| 347 | 369 | { |
| 348 | 370 | return $_acc_id; |
| 349 | 371 | } |
| 350 | - if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); |
|
| 372 | + if (self::$debug) |
|
| 373 | + { |
|
| 374 | + error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); |
|
| 375 | + } |
|
| 351 | 376 | } |
| 352 | 377 | catch (\Exception $e) { |
| 353 | 378 | unset($e); |
| 354 | - if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!"); |
|
| 379 | + if (self::$debug) |
|
| 380 | + { |
|
| 381 | + error_log(__METHOD__."($_acc_id) account NOT found!"); |
|
| 382 | + } |
|
| 355 | 383 | } |
| 356 | 384 | } |
| 357 | 385 | // no account specified or specified account not found or not valid |
@@ -360,11 +388,17 @@ discard block |
||
| 360 | 388 | { |
| 361 | 389 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 362 | 390 | { |
| 363 | - if (self::$debug && $_acc_id) error_log(__METHOD__."($_acc_id) using $acc_id instead"); |
|
| 391 | + if (self::$debug && $_acc_id) |
|
| 392 | + { |
|
| 393 | + error_log(__METHOD__."($_acc_id) using $acc_id instead"); |
|
| 394 | + } |
|
| 364 | 395 | return $acc_id; |
| 365 | 396 | } |
| 366 | 397 | } |
| 367 | - if (self::$debug) error_log(__METHOD__."($_acc_id) NO valid account found!"); |
|
| 398 | + if (self::$debug) |
|
| 399 | + { |
|
| 400 | + error_log(__METHOD__."($_acc_id) NO valid account found!"); |
|
| 401 | + } |
|
| 368 | 402 | return 0; |
| 369 | 403 | } |
| 370 | 404 | |
@@ -380,10 +414,19 @@ discard block |
||
| 380 | 414 | */ |
| 381 | 415 | private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
| 382 | 416 | { |
| 383 | - if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
|
| 384 | - if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
|
| 417 | + if (is_null($_reuseCache)) |
|
| 418 | + { |
|
| 419 | + $_reuseCache = $_restoreSession; |
|
| 420 | + } |
|
| 421 | + if (!empty($_displayCharset)) |
|
| 422 | + { |
|
| 423 | + self::$displayCharset = $_displayCharset; |
|
| 424 | + } |
|
| 385 | 425 | // not nummeric, we assume we only want an empty class object |
| 386 | - if (!is_numeric($_profileID)) return true; |
|
| 426 | + if (!is_numeric($_profileID)) |
|
| 427 | + { |
|
| 428 | + return true; |
|
| 429 | + } |
|
| 387 | 430 | if ($_restoreSession) |
| 388 | 431 | { |
| 389 | 432 | //error_log(__METHOD__." Session restore ".function_backtrace()); |
@@ -398,7 +441,10 @@ discard block |
||
| 398 | 441 | $firstMessage = $this->sessionData['previewMessage']; |
| 399 | 442 | $this->sessionData = array(); |
| 400 | 443 | } |
| 401 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 444 | + if (!$_reuseCache) |
|
| 445 | + { |
|
| 446 | + $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 447 | + } |
|
| 402 | 448 | try |
| 403 | 449 | { |
| 404 | 450 | $this->profileID = self::validateProfileID($_profileID); |
@@ -422,7 +468,10 @@ discard block |
||
| 422 | 468 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
| 423 | 469 | } |
| 424 | 470 | |
| 425 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 471 | + if (is_null(self::$mailConfig)) |
|
| 472 | + { |
|
| 473 | + self::$mailConfig = Config::read('mail'); |
|
| 474 | + } |
|
| 426 | 475 | } |
| 427 | 476 | |
| 428 | 477 | /** |
@@ -451,7 +500,10 @@ discard block |
||
| 451 | 500 | // unset the mail_preferences session object, to force the reload/rebuild |
| 452 | 501 | Cache::setSession('mail','mail_preferences',serialize(array())); |
| 453 | 502 | Cache::setSession('emailadmin','session_data',serialize(array())); |
| 454 | - if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
|
| 503 | + if ($_resetFolderObjects) |
|
| 504 | + { |
|
| 505 | + self::resetFolderObjectCache($_profile_id); |
|
| 506 | + } |
|
| 455 | 507 | } |
| 456 | 508 | |
| 457 | 509 | /** |
@@ -461,7 +513,10 @@ discard block |
||
| 461 | 513 | { |
| 462 | 514 | $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
| 463 | 515 | self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
| 464 | - if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
|
| 516 | + if (!empty(self::$activeFolderCache[$this->profileID])) |
|
| 517 | + { |
|
| 518 | + $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
|
| 519 | + } |
|
| 465 | 520 | } |
| 466 | 521 | |
| 467 | 522 | /** |
@@ -470,7 +525,10 @@ discard block |
||
| 470 | 525 | function saveSessionData() |
| 471 | 526 | { |
| 472 | 527 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 473 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 528 | + if (!empty($this->sessionData['mailbox'])) |
|
| 529 | + { |
|
| 530 | + self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 531 | + } |
|
| 474 | 532 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 475 | 533 | { |
| 476 | 534 | Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
@@ -491,8 +549,14 @@ discard block |
||
| 491 | 549 | */ |
| 492 | 550 | static function unsetCachedObjects($_profileID=null) |
| 493 | 551 | { |
| 494 | - if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
|
| 495 | - if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
|
| 552 | + if (is_null($_profileID)) |
|
| 553 | + { |
|
| 554 | + $_profileID = Mail\Account::get_default_acc_id(); |
|
| 555 | + } |
|
| 556 | + if (is_array($_profileID) && $_profileID['account_id']) |
|
| 557 | + { |
|
| 558 | + $account_id = $_profileID['account_id']; |
|
| 559 | + } |
|
| 496 | 560 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 497 | 561 | if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
| 498 | 562 | { |
@@ -525,7 +589,10 @@ discard block |
||
| 525 | 589 | Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
| 526 | 590 | } |
| 527 | 591 | |
| 528 | - if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
|
| 592 | + if (isset(self::$instances[$_profileID])) |
|
| 593 | + { |
|
| 594 | + unset(self::$instances[$_profileID]); |
|
| 595 | + } |
|
| 529 | 596 | } |
| 530 | 597 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 531 | 598 | { |
@@ -554,7 +621,10 @@ discard block |
||
| 554 | 621 | static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
| 555 | 622 | { |
| 556 | 623 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 557 | - if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 624 | + if (is_null($account_id)) |
|
| 625 | + { |
|
| 626 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 627 | + } |
|
| 558 | 628 | if (is_array($_ImapServerId)) |
| 559 | 629 | { |
| 560 | 630 | // called via hook |
@@ -593,7 +663,10 @@ discard block |
||
| 593 | 663 | static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
| 594 | 664 | { |
| 595 | 665 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 596 | - if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 666 | + if (is_null($account_id)) |
|
| 667 | + { |
|
| 668 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 669 | + } |
|
| 597 | 670 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 598 | 671 | // or treat it as not given. we try that path |
| 599 | 672 | if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
@@ -667,10 +740,14 @@ discard block |
||
| 667 | 740 | |
| 668 | 741 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 669 | 742 | |
| 670 | - foreach($identities as $ik => $ident) { |
|
| 743 | + foreach($identities as $ik => $ident) |
|
| 744 | + { |
|
| 671 | 745 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 672 | 746 | $identity = Mail\Account::read_identity($ik); |
| 673 | - if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
|
| 747 | + if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) |
|
| 748 | + { |
|
| 749 | + $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
|
| 750 | + } |
|
| 674 | 751 | } |
| 675 | 752 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
| 676 | 753 | return $userEMailAdresses; |
@@ -688,13 +765,20 @@ discard block |
||
| 688 | 765 | foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
| 689 | 766 | { |
| 690 | 767 | $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
| 691 | - 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']); |
|
| 768 | + if (!$resolve_placeholders) |
|
| 769 | + { |
|
| 770 | + $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']); |
|
| 771 | + } |
|
| 692 | 772 | |
| 693 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 773 | + foreach(Mail\Account::identities($acc) as $ik => $ident) |
|
| 774 | + { |
|
| 694 | 775 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 695 | 776 | $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
| 696 | 777 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 697 | - 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']); |
|
| 778 | + if (!isset($userEMailAdresses[$identity['ident_id']])) |
|
| 779 | + { |
|
| 780 | + $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']); |
|
| 781 | + } |
|
| 698 | 782 | } |
| 699 | 783 | } |
| 700 | 784 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -714,12 +798,16 @@ discard block |
||
| 714 | 798 | $account = Mail\Account::read($account); |
| 715 | 799 | } |
| 716 | 800 | $userEMailAdresses = array(); |
| 717 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 801 | + foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) |
|
| 802 | + { |
|
| 718 | 803 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 719 | 804 | $identity = Mail\Account::read_identity($ik,true,null,$account); |
| 720 | 805 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 721 | 806 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 722 | - if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
|
| 807 | + if (empty($identity['ident_id'])) |
|
| 808 | + { |
|
| 809 | + $identity['ident_id'] = $identity['acc_id']; |
|
| 810 | + } |
|
| 723 | 811 | if (!isset($userEMailAdresses[$identity['ident_id']])) |
| 724 | 812 | { |
| 725 | 813 | $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$identity['acc_id'], |
@@ -762,15 +850,25 @@ discard block |
||
| 762 | 850 | // account select box |
| 763 | 851 | $selectedID = $this->profileID; |
| 764 | 852 | $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
| 765 | - if ($allAccountData) { |
|
| 853 | + if ($allAccountData) |
|
| 854 | + { |
|
| 766 | 855 | $rememberFirst=$selectedFound=null; |
| 767 | 856 | foreach ($allAccountData as $tmpkey => $icServers) |
| 768 | 857 | { |
| 769 | - if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
|
| 770 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 858 | + if (is_null($rememberFirst)) |
|
| 859 | + { |
|
| 860 | + $rememberFirst = $tmpkey; |
|
| 861 | + } |
|
| 862 | + if ($tmpkey == $selectedID) |
|
| 863 | + { |
|
| 864 | + $selectedFound=true; |
|
| 865 | + } |
|
| 771 | 866 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 772 | 867 | $host = $icServers->acc_imap_host; |
| 773 | - if (empty($host)) continue; |
|
| 868 | + if (empty($host)) |
|
| 869 | + { |
|
| 870 | + continue; |
|
| 871 | + } |
|
| 774 | 872 | $identities[$icServers->acc_id] = $icServers['ident_realname'].' '.$icServers['ident_org'].' <'.$icServers['ident_email'].'>'; |
| 775 | 873 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 776 | 874 | } |
@@ -830,7 +928,10 @@ discard block |
||
| 830 | 928 | */ |
| 831 | 929 | function reopen($_foldername) |
| 832 | 930 | { |
| 833 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 931 | + if (self::$debugTimes) |
|
| 932 | + { |
|
| 933 | + $starttime = microtime (true); |
|
| 934 | + } |
|
| 834 | 935 | |
| 835 | 936 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 836 | 937 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -840,12 +941,16 @@ discard block |
||
| 840 | 941 | //{ |
| 841 | 942 | //error_log( __METHOD__.' ('.__LINE__.') '." $_foldername ".function_backtrace()); |
| 842 | 943 | //error_log(__METHOD__.' ('.__LINE__.') '.' Connected with icServer for Profile:'.$this->profileID.'?'.print_r($this->icServer->_connected,true)); |
| 843 | - if ($this->folderIsSelectable($_foldername)) { |
|
| 944 | + if ($this->folderIsSelectable($_foldername)) |
|
| 945 | + { |
|
| 844 | 946 | $this->icServer->openMailbox($_foldername); |
| 845 | 947 | } |
| 846 | 948 | $folderOpened = $_foldername; |
| 847 | 949 | //} |
| 848 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 950 | + if (self::$debugTimes) |
|
| 951 | + { |
|
| 952 | + self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 953 | + } |
|
| 849 | 954 | } |
| 850 | 955 | |
| 851 | 956 | |
@@ -860,13 +965,22 @@ discard block |
||
| 860 | 965 | { |
| 861 | 966 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 862 | 967 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 863 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 968 | + if (self::$debugTimes) |
|
| 969 | + { |
|
| 970 | + $starttime = microtime (true); |
|
| 971 | + } |
|
| 864 | 972 | $mailbox=null; |
| 865 | 973 | try |
| 866 | 974 | { |
| 867 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 868 | - if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
|
| 869 | -/* |
|
| 975 | + if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) |
|
| 976 | + { |
|
| 977 | + $mailbox = $this->sessionData['mailbox']; |
|
| 978 | + } |
|
| 979 | + if (empty($mailbox)) |
|
| 980 | + { |
|
| 981 | + $mailbox = $this->icServer->getCurrentMailbox(); |
|
| 982 | + } |
|
| 983 | + /* |
|
| 870 | 984 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
| 871 | 985 | { |
| 872 | 986 | $this->icServer->openMailbox($mailbox); |
@@ -891,7 +1005,10 @@ discard block |
||
| 891 | 1005 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 892 | 1006 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 893 | 1007 | } |
| 894 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 1008 | + if (self::$debugTimes) |
|
| 1009 | + { |
|
| 1010 | + self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 1011 | + } |
|
| 895 | 1012 | } |
| 896 | 1013 | |
| 897 | 1014 | /** |
@@ -903,20 +1020,27 @@ discard block |
||
| 903 | 1020 | function getQuotaRoot() |
| 904 | 1021 | { |
| 905 | 1022 | static $quota; |
| 906 | - if (isset($quota)) return $quota; |
|
| 1023 | + if (isset($quota)) |
|
| 1024 | + { |
|
| 1025 | + return $quota; |
|
| 1026 | + } |
|
| 907 | 1027 | $this->icServer->getCurrentMailbox(); |
| 908 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 1028 | + if(!$this->icServer->hasCapability('QUOTA')) |
|
| 1029 | + { |
|
| 909 | 1030 | $quota = false; |
| 910 | 1031 | return false; |
| 911 | 1032 | } |
| 912 | 1033 | $quota = $this->icServer->getStorageQuotaRoot('INBOX'); |
| 913 | 1034 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 914 | - if(is_array($quota)) { |
|
| 1035 | + if(is_array($quota)) |
|
| 1036 | + { |
|
| 915 | 1037 | $quota = array( |
| 916 | 1038 | 'usage' => $quota['USED'], |
| 917 | 1039 | 'limit' => $quota['QMAX'], |
| 918 | 1040 | ); |
| 919 | - } else { |
|
| 1041 | + } |
|
| 1042 | + else |
|
| 1043 | + { |
|
| 920 | 1044 | $quota = false; |
| 921 | 1045 | } |
| 922 | 1046 | return $quota; |
@@ -932,7 +1056,11 @@ discard block |
||
| 932 | 1056 | static function getTimeOut($_use='IMAP') |
| 933 | 1057 | { |
| 934 | 1058 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 935 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 1059 | + if (empty($timeout)) |
|
| 1060 | + { |
|
| 1061 | + $timeout = ($_use=='SIEVE'?10:20); |
|
| 1062 | + } |
|
| 1063 | + // this is the default value |
|
| 936 | 1064 | return $timeout; |
| 937 | 1065 | } |
| 938 | 1066 | |
@@ -950,9 +1078,13 @@ discard block |
||
| 950 | 1078 | $foldersNameSpace = array(); |
| 951 | 1079 | $delimiter = $this->getHierarchyDelimiter(); |
| 952 | 1080 | // TODO: cache by $this->icServer->ImapServerId |
| 953 | - if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
|
| 1081 | + if (is_null($nameSpace)) |
|
| 1082 | + { |
|
| 1083 | + $nameSpace = $this->icServer->getNameSpaceArray(); |
|
| 1084 | + } |
|
| 954 | 1085 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 955 | - if (is_array($nameSpace)) { |
|
| 1086 | + if (is_array($nameSpace)) |
|
| 1087 | + { |
|
| 956 | 1088 | foreach($nameSpace as $type => $singleNameSpaceArray) |
| 957 | 1089 | { |
| 958 | 1090 | foreach ($singleNameSpaceArray as $singleNameSpace) |
@@ -969,7 +1101,9 @@ discard block |
||
| 969 | 1101 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 970 | 1102 | // uw-imap server with mailbox prefix or dovecot maybe |
| 971 | 1103 | $_foldersNameSpace['prefix'] = 'mail'; |
| 972 | - } else { |
|
| 1104 | + } |
|
| 1105 | + else |
|
| 1106 | + { |
|
| 973 | 1107 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 974 | 1108 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 975 | 1109 | } |
@@ -996,7 +1130,10 @@ discard block |
||
| 996 | 1130 | foreach($nameSpace as &$singleNameSpace) |
| 997 | 1131 | { |
| 998 | 1132 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 999 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1133 | + if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) |
|
| 1134 | + { |
|
| 1135 | + return $singleNameSpace['prefix']; |
|
| 1136 | + } |
|
| 1000 | 1137 | } |
| 1001 | 1138 | return ""; |
| 1002 | 1139 | } |
@@ -1010,8 +1147,14 @@ discard block |
||
| 1010 | 1147 | function getHierarchyDelimiter($_useCache=true) |
| 1011 | 1148 | { |
| 1012 | 1149 | static $HierarchyDelimiter = null; |
| 1013 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1014 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1150 | + if (is_null($HierarchyDelimiter)) |
|
| 1151 | + { |
|
| 1152 | + $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1153 | + } |
|
| 1154 | + if ($_useCache===false) |
|
| 1155 | + { |
|
| 1156 | + unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1157 | + } |
|
| 1015 | 1158 | if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
| 1016 | 1159 | { |
| 1017 | 1160 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
@@ -1040,14 +1183,19 @@ discard block |
||
| 1040 | 1183 | { |
| 1041 | 1184 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1042 | 1185 | static $_specialUseFolders = null; |
| 1043 | - 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); |
|
| 1186 | + if (is_null($_specialUseFolders)||empty($_specialUseFolders)) |
|
| 1187 | + { |
|
| 1188 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1189 | + } |
|
| 1044 | 1190 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1045 | 1191 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1046 | 1192 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
| 1047 | 1193 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template)); |
| 1048 | 1194 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1049 | 1195 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1050 | - return $_specialUseFolders[$this->icServer->ImapServerId]; |
|
| 1196 | + { |
|
| 1197 | + return $_specialUseFolders[$this->icServer->ImapServerId]; |
|
| 1198 | + } |
|
| 1051 | 1199 | $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
| 1052 | 1200 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1053 | 1201 | $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
@@ -1075,7 +1223,8 @@ discard block |
||
| 1075 | 1223 | function folderIsSelectable($folderToSelect) |
| 1076 | 1224 | { |
| 1077 | 1225 | $retval = true; |
| 1078 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1226 | + if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) |
|
| 1227 | + { |
|
| 1079 | 1228 | if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
| 1080 | 1229 | { |
| 1081 | 1230 | $retval = false; |
@@ -1128,18 +1277,27 @@ discard block |
||
| 1128 | 1277 | */ |
| 1129 | 1278 | function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
| 1130 | 1279 | { |
| 1131 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
|
| 1132 | - if (!is_string($_folderName) || empty($_folderName)) // something is wrong. Do not proceed |
|
| 1280 | + if (self::$debug) |
|
| 1281 | + { |
|
| 1282 | + error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
|
| 1283 | + } |
|
| 1284 | + if (!is_string($_folderName) || empty($_folderName)) |
|
| 1285 | + { |
|
| 1286 | + // something is wrong. Do not proceed |
|
| 1133 | 1287 | { |
| 1134 | 1288 | return false; |
| 1135 | 1289 | } |
| 1290 | + } |
|
| 1136 | 1291 | static $folderInfoCache = null; // reduce traffic on single request |
| 1137 | 1292 | static $folderBasicInfo = null; |
| 1138 | 1293 | if (isset($folderBasicInfo[$this->profileID])) |
| 1139 | 1294 | { |
| 1140 | 1295 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1141 | 1296 | } |
| 1142 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1297 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) |
|
| 1298 | + { |
|
| 1299 | + return $folderInfoCache[$_folderName]; |
|
| 1300 | + } |
|
| 1143 | 1301 | $retValue = array(); |
| 1144 | 1302 | $retValue['subscribed'] = false; |
| 1145 | 1303 | /* |
@@ -1157,7 +1315,10 @@ discard block |
||
| 1157 | 1315 | if (is_array($ret)) |
| 1158 | 1316 | { |
| 1159 | 1317 | $retkeys = array_keys($ret); |
| 1160 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1318 | + if ($retkeys[0]==$_folderName) |
|
| 1319 | + { |
|
| 1320 | + $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1321 | + } |
|
| 1161 | 1322 | } |
| 1162 | 1323 | else |
| 1163 | 1324 | { |
@@ -1166,7 +1327,8 @@ discard block |
||
| 1166 | 1327 | } |
| 1167 | 1328 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1168 | 1329 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1169 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1330 | + if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) |
|
| 1331 | + { |
|
| 1170 | 1332 | try |
| 1171 | 1333 | { |
| 1172 | 1334 | $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
@@ -1196,7 +1358,8 @@ discard block |
||
| 1196 | 1358 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1197 | 1359 | $retValue['displayName'] = $_folderName; |
| 1198 | 1360 | $retValue['shortDisplayName'] = $retValue['shortName']; |
| 1199 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1361 | + if(strtoupper($retValue['shortName']) == 'INBOX') |
|
| 1362 | + { |
|
| 1200 | 1363 | $retValue['displayName'] = lang('INBOX'); |
| 1201 | 1364 | $retValue['shortDisplayName'] = lang('INBOX'); |
| 1202 | 1365 | } |
@@ -1205,7 +1368,10 @@ discard block |
||
| 1205 | 1368 | { |
| 1206 | 1369 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1207 | 1370 | } |
| 1208 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1371 | + if ($folderInfo) |
|
| 1372 | + { |
|
| 1373 | + $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1374 | + } |
|
| 1209 | 1375 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1210 | 1376 | if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
| 1211 | 1377 | { |
@@ -1217,24 +1383,34 @@ discard block |
||
| 1217 | 1383 | static $subscribedFolders = null; |
| 1218 | 1384 | static $nameSpace = null; |
| 1219 | 1385 | static $prefix = null; |
| 1220 | - if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
|
| 1386 | + if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) |
|
| 1387 | + { |
|
| 1388 | + $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
|
| 1389 | + } |
|
| 1221 | 1390 | if (!empty($nameSpace[$this->profileID])) |
| 1222 | 1391 | { |
| 1223 | 1392 | $nsNoPersonal=array(); |
| 1224 | 1393 | foreach($nameSpace[$this->profileID] as &$ns) |
| 1225 | 1394 | { |
| 1226 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1395 | + if ($ns['type']!='personal') |
|
| 1396 | + { |
|
| 1397 | + $nsNoPersonal[]=$ns; |
|
| 1398 | + } |
|
| 1227 | 1399 | } |
| 1228 | 1400 | $nameSpace[$this->profileID]=$nsNoPersonal; |
| 1229 | 1401 | } |
| 1230 | - if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
|
| 1402 | + if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) |
|
| 1403 | + { |
|
| 1404 | + $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
|
| 1405 | + } |
|
| 1231 | 1406 | |
| 1232 | 1407 | if ($fetchSubscribedInfo && is_null($subscribedFolders) || empty($subscribedFolders[$this->profileID])) |
| 1233 | 1408 | { |
| 1234 | 1409 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1235 | 1410 | } |
| 1236 | 1411 | |
| 1237 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1412 | + if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) |
|
| 1413 | + { |
|
| 1238 | 1414 | $retValue['subscribed'] = true; |
| 1239 | 1415 | } |
| 1240 | 1416 | |
@@ -1253,8 +1429,7 @@ discard block |
||
| 1253 | 1429 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1254 | 1430 | $this->mailPreferences['trustServersUnseenInfo']==2 && |
| 1255 | 1431 | $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
| 1256 | - ) |
|
| 1257 | - { |
|
| 1432 | + ) { |
|
| 1258 | 1433 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1259 | 1434 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1260 | 1435 | try |
@@ -1264,13 +1439,19 @@ discard block |
||
| 1264 | 1439 | } |
| 1265 | 1440 | catch (\Exception $ee) |
| 1266 | 1441 | { |
| 1267 | - if (self::$debug) error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested."); |
|
| 1442 | + if (self::$debug) |
|
| 1443 | + { |
|
| 1444 | + error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested."); |
|
| 1445 | + } |
|
| 1268 | 1446 | } |
| 1269 | 1447 | } |
| 1270 | 1448 | } |
| 1271 | 1449 | catch (\Exception $e) |
| 1272 | 1450 | { |
| 1273 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1451 | + if (self::$debug) |
|
| 1452 | + { |
|
| 1453 | + error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1454 | + } |
|
| 1274 | 1455 | } |
| 1275 | 1456 | |
| 1276 | 1457 | return $retValue; |
@@ -1295,8 +1476,14 @@ discard block |
||
| 1295 | 1476 | function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
| 1296 | 1477 | { |
| 1297 | 1478 | //self::$debug=true; |
| 1298 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
|
| 1299 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly"); |
|
| 1479 | + if (self::$debug) |
|
| 1480 | + { |
|
| 1481 | + error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
|
| 1482 | + } |
|
| 1483 | + if (self::$debug) |
|
| 1484 | + { |
|
| 1485 | + error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly"); |
|
| 1486 | + } |
|
| 1300 | 1487 | $reverse = (bool)$_reverse; |
| 1301 | 1488 | // get the list of messages to fetch |
| 1302 | 1489 | $this->reopen($_folderName); |
@@ -1317,21 +1504,34 @@ discard block |
||
| 1317 | 1504 | //$_filter['range'] ="$start:$end"; |
| 1318 | 1505 | //$_filter['range'] ="$_startMessage:*"; |
| 1319 | 1506 | } |
| 1320 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
|
| 1321 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1507 | + if (self::$debug) |
|
| 1508 | + { |
|
| 1509 | + error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
|
| 1510 | + } |
|
| 1511 | + if (self::$debug||self::$debugTimes) |
|
| 1512 | + { |
|
| 1513 | + $starttime = microtime (true); |
|
| 1514 | + } |
|
| 1322 | 1515 | //see this example below for a 12 week datefilter (since) |
| 1323 | 1516 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1324 | 1517 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1325 | 1518 | $sortResult = $_sortResult['match']->ids; |
| 1326 | 1519 | //$modseq = $_sortResult['modseq']; |
| 1327 | 1520 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1328 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1521 | + if (self::$debug||self::$debugTimes) |
|
| 1522 | + { |
|
| 1523 | + self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1524 | + } |
|
| 1329 | 1525 | |
| 1330 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1526 | + if (self::$debug) |
|
| 1527 | + { |
|
| 1528 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1529 | + } |
|
| 1331 | 1530 | #$this->icServer->setDebug(false); |
| 1332 | 1531 | #print "</pre>"; |
| 1333 | 1532 | // nothing found |
| 1334 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1533 | + if(!is_array($sortResult) || empty($sortResult)) |
|
| 1534 | + { |
|
| 1335 | 1535 | $retValue = array(); |
| 1336 | 1536 | $retValue['info']['total'] = 0; |
| 1337 | 1537 | $retValue['info']['first'] = 0; |
@@ -1343,7 +1543,8 @@ discard block |
||
| 1343 | 1543 | #_debug_array($sortResult); |
| 1344 | 1544 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1345 | 1545 | //error_log("REVERSE: $reverse"); |
| 1346 | - if($reverse === true) { |
|
| 1546 | + if($reverse === true) |
|
| 1547 | + { |
|
| 1347 | 1548 | if ($_startMessage<=$total) |
| 1348 | 1549 | { |
| 1349 | 1550 | $startMessage = $_startMessage-1; |
@@ -1355,7 +1556,10 @@ discard block |
||
| 1355 | 1556 | { |
| 1356 | 1557 | $numberOfMessages = $total%$_numberOfMessages; |
| 1357 | 1558 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1358 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1559 | + if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) |
|
| 1560 | + { |
|
| 1561 | + $_numberOfMessages = $numberOfMessages; |
|
| 1562 | + } |
|
| 1359 | 1563 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1360 | 1564 | } |
| 1361 | 1565 | $startMessage=($total-$_numberOfMessages)-1; |
@@ -1369,19 +1573,36 @@ discard block |
||
| 1369 | 1573 | //$retValue['info']['first'] = $startMessage; |
| 1370 | 1574 | //$retValue['info']['last'] = $total; |
| 1371 | 1575 | } |
| 1372 | - if($startMessage > 0) { |
|
| 1373 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1576 | + if($startMessage > 0) |
|
| 1577 | + { |
|
| 1578 | + if (self::$debug) |
|
| 1579 | + { |
|
| 1580 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1581 | + } |
|
| 1374 | 1582 | $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
| 1375 | - } else { |
|
| 1376 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1583 | + } |
|
| 1584 | + else |
|
| 1585 | + { |
|
| 1586 | + if (self::$debug) |
|
| 1587 | + { |
|
| 1588 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1589 | + } |
|
| 1377 | 1590 | $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
| 1378 | 1591 | } |
| 1379 | 1592 | $sortResult = array_reverse($sortResult); |
| 1380 | - } else { |
|
| 1381 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1593 | + } |
|
| 1594 | + else |
|
| 1595 | + { |
|
| 1596 | + if (self::$debug) |
|
| 1597 | + { |
|
| 1598 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1599 | + } |
|
| 1382 | 1600 | $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
| 1383 | 1601 | } |
| 1384 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1602 | + if (self::$debug) |
|
| 1603 | + { |
|
| 1604 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1605 | + } |
|
| 1385 | 1606 | } |
| 1386 | 1607 | else |
| 1387 | 1608 | { |
@@ -1390,7 +1611,10 @@ discard block |
||
| 1390 | 1611 | |
| 1391 | 1612 | |
| 1392 | 1613 | // fetch the data for the selected messages |
| 1393 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1614 | + if (self::$debug||self::$debugTimes) |
|
| 1615 | + { |
|
| 1616 | + $starttime = microtime(true); |
|
| 1617 | + } |
|
| 1394 | 1618 | try |
| 1395 | 1619 | { |
| 1396 | 1620 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1414,7 +1638,10 @@ discard block |
||
| 1414 | 1638 | $fquery->flags(); |
| 1415 | 1639 | $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
| 1416 | 1640 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1417 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1641 | + if ($_fetchPreviews) |
|
| 1642 | + { |
|
| 1643 | + $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1644 | + } |
|
| 1418 | 1645 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1419 | 1646 | 'ids' => $uidsToFetch, |
| 1420 | 1647 | )); |
@@ -1437,14 +1664,20 @@ discard block |
||
| 1437 | 1664 | |
| 1438 | 1665 | $cnt = 0; |
| 1439 | 1666 | |
| 1440 | - foreach((array)$sortResult as $uid) { |
|
| 1667 | + foreach((array)$sortResult as $uid) |
|
| 1668 | + { |
|
| 1441 | 1669 | $sortOrder[$uid] = $cnt++; |
| 1442 | 1670 | } |
| 1443 | 1671 | |
| 1444 | 1672 | $count = 0; |
| 1445 | - if (is_object($headersNew)) { |
|
| 1446 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1447 | - foreach($headersNew->ids() as $id) { |
|
| 1673 | + if (is_object($headersNew)) |
|
| 1674 | + { |
|
| 1675 | + if (self::$debug||self::$debugTimes) |
|
| 1676 | + { |
|
| 1677 | + $starttime = microtime(true); |
|
| 1678 | + } |
|
| 1679 | + foreach($headersNew->ids() as $id) |
|
| 1680 | + { |
|
| 1448 | 1681 | $_headerObject = $headersNew->get($id); |
| 1449 | 1682 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1450 | 1683 | $headerObject = array(); |
@@ -1457,7 +1690,10 @@ discard block |
||
| 1457 | 1690 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1458 | 1691 | $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
| 1459 | 1692 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1460 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1693 | + if (empty($headerForPrio)) |
|
| 1694 | + { |
|
| 1695 | + $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1696 | + } |
|
| 1461 | 1697 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1462 | 1698 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1463 | 1699 | if ($_fetchPreviews) |
@@ -1468,12 +1704,16 @@ discard block |
||
| 1468 | 1704 | if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
| 1469 | 1705 | { |
| 1470 | 1706 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1471 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1707 | + if ($length===false) |
|
| 1708 | + { |
|
| 1709 | + $length = strlen($bodyPreview); |
|
| 1710 | + } |
|
| 1472 | 1711 | $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
| 1473 | 1712 | } |
| 1474 | 1713 | } |
| 1475 | 1714 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1476 | - if (self::$debug) { |
|
| 1715 | + if (self::$debug) |
|
| 1716 | + { |
|
| 1477 | 1717 | 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')); |
| 1478 | 1718 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1479 | 1719 | } |
@@ -1483,11 +1723,16 @@ discard block |
||
| 1483 | 1723 | $total--; |
| 1484 | 1724 | continue; |
| 1485 | 1725 | } |
| 1486 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1726 | + if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) |
|
| 1727 | + { |
|
| 1487 | 1728 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1488 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1729 | + } |
|
| 1730 | + else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) |
|
| 1731 | + { |
|
| 1489 | 1732 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1490 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1733 | + } |
|
| 1734 | + else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) |
|
| 1735 | + { |
|
| 1491 | 1736 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1492 | 1737 | } /*else $sent_not = "";*/ |
| 1493 | 1738 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
@@ -1518,7 +1763,11 @@ discard block |
||
| 1518 | 1763 | $rfcAddr = self::parseAddressList($ad); // does some fixing of known problems too |
| 1519 | 1764 | foreach ($rfcAddr as $_rfcAddr) |
| 1520 | 1765 | { |
| 1521 | - if (!$_rfcAddr->valid) continue; // skip. not a valid address |
|
| 1766 | + if (!$_rfcAddr->valid) |
|
| 1767 | + { |
|
| 1768 | + continue; |
|
| 1769 | + } |
|
| 1770 | + // skip. not a valid address |
|
| 1522 | 1771 | $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
| 1523 | 1772 | } |
| 1524 | 1773 | } |
@@ -1534,7 +1783,10 @@ discard block |
||
| 1534 | 1783 | { |
| 1535 | 1784 | // $bodyPreview is populated at the beginning of the loop, as it may be |
| 1536 | 1785 | // needed to parse the Headers of the Message |
| 1537 | - if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
|
| 1786 | + if (empty($bodyPreview)) |
|
| 1787 | + { |
|
| 1788 | + $bodyPreview = $_headerObject->getFullMsg(); |
|
| 1789 | + } |
|
| 1538 | 1790 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1539 | 1791 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1540 | 1792 | foreach($base->partIterator() as $part) |
@@ -1547,7 +1799,8 @@ discard block |
||
| 1547 | 1799 | 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
| 1548 | 1800 | )), $charset, 'utf-8'); |
| 1549 | 1801 | $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
| 1550 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1802 | + } |
|
| 1803 | + elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1551 | 1804 | { |
| 1552 | 1805 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1553 | 1806 | } |
@@ -1563,7 +1816,10 @@ discard block |
||
| 1563 | 1816 | $messageMimeType=''; |
| 1564 | 1817 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1565 | 1818 | { |
| 1566 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1819 | + if ($mime_id==0 || $messageMimeType==='') |
|
| 1820 | + { |
|
| 1821 | + $messageMimeType = $mime_type; |
|
| 1822 | + } |
|
| 1567 | 1823 | $part = $mailStructureObject->getPart($mime_id); |
| 1568 | 1824 | $partdisposition = $part->getDisposition(); |
| 1569 | 1825 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1573,7 +1829,8 @@ discard block |
||
| 1573 | 1829 | // bodypreview could be found (multipart/....) |
| 1574 | 1830 | if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
| 1575 | 1831 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1576 | - ($partdisposition !== 'attachment')) { |
|
| 1832 | + ($partdisposition !== 'attachment')) |
|
| 1833 | + { |
|
| 1577 | 1834 | $_structure=$part; |
| 1578 | 1835 | $this->fetchPartContents($uid, $_structure, false,true); |
| 1579 | 1836 | $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
@@ -1595,10 +1852,19 @@ discard block |
||
| 1595 | 1852 | if ($mime_type=='message/rfc822') |
| 1596 | 1853 | { |
| 1597 | 1854 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1598 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1855 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 1856 | + { |
|
| 1857 | +if ($sub_id != $mime_id) |
|
| 1858 | + { |
|
| 1859 | + $skipParts[$sub_id] = $sub_type; |
|
| 1860 | + } |
|
| 1861 | + } |
|
| 1599 | 1862 | } |
| 1600 | 1863 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1601 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1864 | + if (array_key_exists($mime_id,$skipParts)) |
|
| 1865 | + { |
|
| 1866 | + continue; |
|
| 1867 | + } |
|
| 1602 | 1868 | if ($partdisposition=='attachment' || |
| 1603 | 1869 | ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
| 1604 | 1870 | ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
@@ -1609,7 +1875,10 @@ discard block |
||
| 1609 | 1875 | $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
| 1610 | 1876 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1611 | 1877 | $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
| 1612 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1878 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name'])) |
|
| 1879 | + { |
|
| 1880 | + $headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1881 | + } |
|
| 1613 | 1882 | if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
| 1614 | 1883 | $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
| 1615 | 1884 | { |
@@ -1623,18 +1892,27 @@ discard block |
||
| 1623 | 1892 | //error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (plain):'.array2string($mailStructureObject->findBody('plain'))); |
| 1624 | 1893 | //error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (html):'.array2string($mailStructureObject->findBody('html'))); |
| 1625 | 1894 | //if($count == 0) error_log(__METHOD__.array2string($headerObject)); |
| 1626 | - if (empty($headerObject['UID'])) continue; |
|
| 1895 | + if (empty($headerObject['UID'])) |
|
| 1896 | + { |
|
| 1897 | + continue; |
|
| 1898 | + } |
|
| 1627 | 1899 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1628 | 1900 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1629 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1901 | + if(substr($headerObject['DATE'],-2) === 'UT') |
|
| 1902 | + { |
|
| 1630 | 1903 | $headerObject['DATE'] .= 'C'; |
| 1631 | 1904 | } |
| 1632 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1905 | + if(substr($headerObject['INTERNALDATE'],-2) === 'UT') |
|
| 1906 | + { |
|
| 1633 | 1907 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1634 | 1908 | } |
| 1635 | 1909 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1636 | 1910 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1637 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1911 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) |
|
| 1912 | + { |
|
| 1913 | + foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a; |
|
| 1914 | + } |
|
| 1915 | + } |
|
| 1638 | 1916 | $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
| 1639 | 1917 | $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
| 1640 | 1918 | $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
@@ -1645,22 +1923,31 @@ discard block |
||
| 1645 | 1923 | $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
| 1646 | 1924 | $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
| 1647 | 1925 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1648 | - if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
|
| 1649 | - if (is_array($headerObject['FLAGS'])) { |
|
| 1926 | + if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) |
|
| 1927 | + { |
|
| 1928 | + $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
|
| 1929 | + } |
|
| 1930 | + if (is_array($headerObject['FLAGS'])) |
|
| 1931 | + { |
|
| 1650 | 1932 | $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
| 1651 | 1933 | } |
| 1652 | 1934 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1653 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1935 | + if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) |
|
| 1936 | + { |
|
| 1654 | 1937 | $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
| 1655 | 1938 | } |
| 1656 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1939 | + if(is_array($headerObject['TO']) && $headerObject['TO'][0]) |
|
| 1940 | + { |
|
| 1657 | 1941 | $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
| 1658 | 1942 | if (count($headerObject['TO'])>1) |
| 1659 | 1943 | { |
| 1660 | 1944 | $ki=0; |
| 1661 | 1945 | foreach($headerObject['TO'] as $k => $add) |
| 1662 | 1946 | { |
| 1663 | - if ($k==0) continue; |
|
| 1947 | + if ($k==0) |
|
| 1948 | + { |
|
| 1949 | + continue; |
|
| 1950 | + } |
|
| 1664 | 1951 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1665 | 1952 | $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
| 1666 | 1953 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
@@ -1668,7 +1955,8 @@ discard block |
||
| 1668 | 1955 | } |
| 1669 | 1956 | } |
| 1670 | 1957 | } |
| 1671 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 1958 | + if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) |
|
| 1959 | + { |
|
| 1672 | 1960 | $ki=0; |
| 1673 | 1961 | foreach($headerObject['CC'] as $k => $add) |
| 1674 | 1962 | { |
@@ -1682,27 +1970,41 @@ discard block |
||
| 1682 | 1970 | |
| 1683 | 1971 | $count++; |
| 1684 | 1972 | } |
| 1685 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 1973 | + if (self::$debug||self::$debugTimes) |
|
| 1974 | + { |
|
| 1975 | + self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 1976 | + } |
|
| 1686 | 1977 | //self::$debug=false; |
| 1687 | 1978 | // sort the messages to the requested displayorder |
| 1688 | - if(is_array($retValue['header'])) { |
|
| 1979 | + if(is_array($retValue['header'])) |
|
| 1980 | + { |
|
| 1689 | 1981 | $countMessages = $total; |
| 1690 | - if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
|
| 1982 | + if (isset($_filter['range'])) |
|
| 1983 | + { |
|
| 1984 | + $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
|
| 1985 | + } |
|
| 1691 | 1986 | ksort($retValue['header']); |
| 1692 | 1987 | $retValue['info']['total'] = $total; |
| 1693 | 1988 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1694 | 1989 | $retValue['info']['first'] = $_startMessage; |
| 1695 | 1990 | $retValue['info']['last'] = $_startMessage + $count - 1 ; |
| 1696 | 1991 | return $retValue; |
| 1697 | - } else { |
|
| 1992 | + } |
|
| 1993 | + else |
|
| 1994 | + { |
|
| 1698 | 1995 | $retValue = array(); |
| 1699 | 1996 | $retValue['info']['total'] = 0; |
| 1700 | 1997 | $retValue['info']['first'] = 0; |
| 1701 | 1998 | $retValue['info']['last'] = 0; |
| 1702 | 1999 | return $retValue; |
| 1703 | 2000 | } |
| 1704 | - } else { |
|
| 1705 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 2001 | + } |
|
| 2002 | + else |
|
| 2003 | + { |
|
| 2004 | + if ($headersNew == null && empty($_thisUIDOnly)) |
|
| 2005 | + { |
|
| 2006 | + error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 2007 | + } |
|
| 1706 | 2008 | $retValue = array(); |
| 1707 | 2009 | $retValue['info']['total'] = 0; |
| 1708 | 2010 | $retValue['info']['first'] = 0; |
@@ -1719,7 +2021,10 @@ discard block |
||
| 1719 | 2021 | */ |
| 1720 | 2022 | static function prepareFlagsArray($headerObject) |
| 1721 | 2023 | { |
| 1722 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 2024 | + if (is_array($headerObject['FLAGS'])) |
|
| 2025 | + { |
|
| 2026 | + $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 2027 | + } |
|
| 1723 | 2028 | $retValue = array(); |
| 1724 | 2029 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1725 | 2030 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
@@ -1770,24 +2075,43 @@ discard block |
||
| 1770 | 2075 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1771 | 2076 | $try2useCache = true; |
| 1772 | 2077 | static $eMailListContainsDeletedMessages = null; |
| 1773 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2078 | + if (is_null($eMailListContainsDeletedMessages)) |
|
| 2079 | + { |
|
| 2080 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2081 | + } |
|
| 1774 | 2082 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1775 | 2083 | if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
| 1776 | 2084 | { |
| 1777 | - if (self::$debugTimes) $starttime = microtime(true); |
|
| 1778 | - 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); |
|
| 2085 | + if (self::$debugTimes) |
|
| 2086 | + { |
|
| 2087 | + $starttime = microtime(true); |
|
| 2088 | + } |
|
| 2089 | + if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) |
|
| 2090 | + { |
|
| 2091 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2092 | + } |
|
| 1779 | 2093 | $deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false); |
| 1780 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
|
| 2094 | + if (self::$debug) |
|
| 2095 | + { |
|
| 2096 | + error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
|
| 2097 | + } |
|
| 1781 | 2098 | $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
| 1782 | 2099 | Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
| 1783 | - 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']); |
|
| 2100 | + if (self::$debugTimes) |
|
| 2101 | + { |
|
| 2102 | + self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') '); |
|
| 2103 | + } |
|
| 2104 | + //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']); |
|
| 1784 | 2105 | } |
| 1785 | 2106 | $try2useCache = false; |
| 1786 | 2107 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1787 | 2108 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1788 | 2109 | { |
| 1789 | 2110 | self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
| 1790 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 2111 | + if (!isset(self::$supportsORinQuery[$this->profileID])) |
|
| 2112 | + { |
|
| 2113 | + self::$supportsORinQuery[$this->profileID]=true; |
|
| 2114 | + } |
|
| 1791 | 2115 | } |
| 1792 | 2116 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1793 | 2117 | $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
@@ -1798,15 +2122,26 @@ discard block |
||
| 1798 | 2122 | } |
| 1799 | 2123 | //_debug_array($filter); |
| 1800 | 2124 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1801 | - if($this->icServer->hasCapability('SORT')) { |
|
| 2125 | + if($this->icServer->hasCapability('SORT')) |
|
| 2126 | + { |
|
| 1802 | 2127 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1803 | 2128 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1804 | 2129 | // there is no messing with the dates) |
| 1805 | 2130 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1806 | - if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
|
| 2131 | + if (self::$debug) |
|
| 2132 | + { |
|
| 2133 | + error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
|
| 2134 | + } |
|
| 1807 | 2135 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1808 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1809 | - if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
|
| 2136 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) |
|
| 2137 | + { |
|
| 2138 | + $_reverse=false; |
|
| 2139 | + } |
|
| 2140 | + // as we reversed the result already |
|
| 2141 | + if (self::$debug) |
|
| 2142 | + { |
|
| 2143 | + error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
|
| 2144 | + } |
|
| 1810 | 2145 | try |
| 1811 | 2146 | { |
| 1812 | 2147 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
@@ -1818,7 +2153,10 @@ discard block |
||
| 1818 | 2153 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1819 | 2154 | $resultByUid = false; |
| 1820 | 2155 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1821 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 2156 | + if ($_reverse) |
|
| 2157 | + { |
|
| 2158 | + array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 2159 | + } |
|
| 1822 | 2160 | try |
| 1823 | 2161 | { |
| 1824 | 2162 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
@@ -1830,9 +2168,17 @@ discard block |
||
| 1830 | 2168 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1831 | 2169 | } |
| 1832 | 2170 | } |
| 1833 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1834 | - } else { |
|
| 1835 | - if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
|
| 2171 | + if (self::$debug) |
|
| 2172 | + { |
|
| 2173 | + error_log(__METHOD__.print_r($sortResult,true)); |
|
| 2174 | + } |
|
| 2175 | + } |
|
| 2176 | + else |
|
| 2177 | + { |
|
| 2178 | + if (self::$debug) |
|
| 2179 | + { |
|
| 2180 | + error_log(__METHOD__." Mailserver has NO SORT Capability"); |
|
| 2181 | + } |
|
| 1836 | 2182 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1837 | 2183 | //if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
| 1838 | 2184 | try |
@@ -1846,7 +2192,10 @@ discard block |
||
| 1846 | 2192 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1847 | 2193 | self::$supportsORinQuery[$this->profileID]=false; |
| 1848 | 2194 | Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
| 1849 | - if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
|
| 2195 | + if (self::$debug) |
|
| 2196 | + { |
|
| 2197 | + error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
|
| 2198 | + } |
|
| 1850 | 2199 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1851 | 2200 | try |
| 1852 | 2201 | { |
@@ -1857,11 +2206,15 @@ discard block |
||
| 1857 | 2206 | { |
| 1858 | 2207 | } |
| 1859 | 2208 | } |
| 1860 | - if(is_array($sortResult['match'])) { |
|
| 2209 | + if(is_array($sortResult['match'])) |
|
| 2210 | + { |
|
| 1861 | 2211 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1862 | 2212 | sort($sortResult['match'], SORT_NUMERIC); |
| 1863 | 2213 | } |
| 1864 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 2214 | + if (self::$debug) |
|
| 2215 | + { |
|
| 2216 | + error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 2217 | + } |
|
| 1865 | 2218 | } |
| 1866 | 2219 | if ($setSession) |
| 1867 | 2220 | { |
@@ -1890,7 +2243,8 @@ discard block |
||
| 1890 | 2243 | $_reverse=false; |
| 1891 | 2244 | if (is_numeric($_sort)) |
| 1892 | 2245 | { |
| 1893 | - switch($_sort) { |
|
| 2246 | + switch($_sort) |
|
| 2247 | + { |
|
| 1894 | 2248 | case 2: |
| 1895 | 2249 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1896 | 2250 | break; |
@@ -1912,7 +2266,8 @@ discard block |
||
| 1912 | 2266 | } |
| 1913 | 2267 | else |
| 1914 | 2268 | { |
| 1915 | - switch(strtoupper($_sort)) { |
|
| 2269 | + switch(strtoupper($_sort)) |
|
| 2270 | + { |
|
| 1916 | 2271 | case 'FROMADDRESS': |
| 1917 | 2272 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1918 | 2273 | break; |
@@ -1938,7 +2293,10 @@ discard block |
||
| 1938 | 2293 | break; |
| 1939 | 2294 | } |
| 1940 | 2295 | } |
| 1941 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 2296 | + if ($_reverse) |
|
| 2297 | + { |
|
| 2298 | + array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 2299 | + } |
|
| 1942 | 2300 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1943 | 2301 | return $retValue; |
| 1944 | 2302 | } |
@@ -1957,7 +2315,10 @@ discard block |
||
| 1957 | 2315 | $imapFilter->charset('UTF-8'); |
| 1958 | 2316 | |
| 1959 | 2317 | //_debug_array($_criterias); |
| 1960 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2318 | + if (self::$debug) |
|
| 2319 | + { |
|
| 2320 | + error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2321 | + } |
|
| 1961 | 2322 | if((!is_array($_criterias) || $_criterias['status']=='any') && |
| 1962 | 2323 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 1963 | 2324 | (!isset($_criterias['range'])|| empty($_criterias['range']) || |
@@ -1972,11 +2333,13 @@ discard block |
||
| 1972 | 2333 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 1973 | 2334 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 1974 | 2335 | $statusQueryValid = false; |
| 1975 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 2336 | + foreach((array)$_criterias['status'] as $k => $criteria) |
|
| 2337 | + { |
|
| 1976 | 2338 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 1977 | 2339 | $imapStatusFilter->charset('UTF-8'); |
| 1978 | 2340 | $criteria = strtoupper($criteria); |
| 1979 | - switch ($criteria) { |
|
| 2341 | + switch ($criteria) |
|
| 2342 | + { |
|
| 1980 | 2343 | case 'ANSWERED': |
| 1981 | 2344 | case 'DELETED': |
| 1982 | 2345 | case 'FLAGGED': |
@@ -2059,9 +2422,11 @@ discard block |
||
| 2059 | 2422 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2060 | 2423 | $imapSearchFilter->charset('UTF-8'); |
| 2061 | 2424 | |
| 2062 | - if(!empty($_criterias['string'])) { |
|
| 2425 | + if(!empty($_criterias['string'])) |
|
| 2426 | + { |
|
| 2063 | 2427 | $criteria = strtoupper($_criterias['type']); |
| 2064 | - switch ($criteria) { |
|
| 2428 | + switch ($criteria) |
|
| 2429 | + { |
|
| 2065 | 2430 | case 'BYDATE': |
| 2066 | 2431 | case 'QUICK': |
| 2067 | 2432 | case 'QUICKWITHCC': |
@@ -2069,9 +2434,12 @@ discard block |
||
| 2069 | 2434 | //$imapSearchFilter->charset('UTF-8'); |
| 2070 | 2435 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2071 | 2436 | $imapFilter2->charset('UTF-8'); |
| 2072 | - if($this->isSentFolder($_folder)) { |
|
| 2437 | + if($this->isSentFolder($_folder)) |
|
| 2438 | + { |
|
| 2073 | 2439 | $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
| 2074 | - } else { |
|
| 2440 | + } |
|
| 2441 | + else |
|
| 2442 | + { |
|
| 2075 | 2443 | $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
| 2076 | 2444 | } |
| 2077 | 2445 | if ($_supportsOrInQuery) |
@@ -2102,7 +2470,10 @@ discard block |
||
| 2102 | 2470 | 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
| 2103 | 2471 | 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
| 2104 | 2472 | $numberinBytes=(float)$_criterias['string']; |
| 2105 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2473 | + if (isset($multipleBy[$unit])) |
|
| 2474 | + { |
|
| 2475 | + $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2476 | + } |
|
| 2106 | 2477 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2107 | 2478 | $_criterias['string']=$numberinBytes; |
| 2108 | 2479 | } |
@@ -2139,8 +2510,14 @@ discard block |
||
| 2139 | 2510 | break; |
| 2140 | 2511 | } |
| 2141 | 2512 | } |
| 2142 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2143 | - if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
|
| 2513 | + if ($statusQueryValid && !$queryValid) |
|
| 2514 | + { |
|
| 2515 | + $queryValid=true; |
|
| 2516 | + } |
|
| 2517 | + if ($queryValid) |
|
| 2518 | + { |
|
| 2519 | + $imapFilter->andSearch($imapSearchFilter); |
|
| 2520 | + } |
|
| 2144 | 2521 | |
| 2145 | 2522 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
| 2146 | 2523 | { |
@@ -2155,7 +2532,8 @@ discard block |
||
| 2155 | 2532 | unset($_criterias['before']); |
| 2156 | 2533 | $criteria=$_criterias['range']='ON'; |
| 2157 | 2534 | } |
| 2158 | - switch ($criteria) { |
|
| 2535 | + switch ($criteria) |
|
| 2536 | + { |
|
| 2159 | 2537 | case 'BETWEEN': |
| 2160 | 2538 | //try to be smart about missing |
| 2161 | 2539 | //enddate |
@@ -2191,8 +2569,14 @@ discard block |
||
| 2191 | 2569 | $rangeValid = true; |
| 2192 | 2570 | break; |
| 2193 | 2571 | } |
| 2194 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2195 | - if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
|
| 2572 | + if ($rangeValid && !$queryValid) |
|
| 2573 | + { |
|
| 2574 | + $queryValid=true; |
|
| 2575 | + } |
|
| 2576 | + if ($rangeValid) |
|
| 2577 | + { |
|
| 2578 | + $imapFilter->andSearch($imapRangeFilter); |
|
| 2579 | + } |
|
| 2196 | 2580 | } |
| 2197 | 2581 | if (self::$debug) |
| 2198 | 2582 | { |
@@ -2200,10 +2584,13 @@ discard block |
||
| 2200 | 2584 | $query_str = $imapFilter->build(); |
| 2201 | 2585 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2202 | 2586 | } |
| 2203 | - if($queryValid==false) { |
|
| 2587 | + if($queryValid==false) |
|
| 2588 | + { |
|
| 2204 | 2589 | $imapFilter->flag('DELETED', $set=false); |
| 2205 | 2590 | return $imapFilter; |
| 2206 | - } else { |
|
| 2591 | + } |
|
| 2592 | + else |
|
| 2593 | + { |
|
| 2207 | 2594 | return $imapFilter; |
| 2208 | 2595 | } |
| 2209 | 2596 | } |
@@ -2260,7 +2647,10 @@ discard block |
||
| 2260 | 2647 | } |
| 2261 | 2648 | $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
| 2262 | 2649 | } |
| 2263 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2650 | + if (!empty($stringA)) |
|
| 2651 | + { |
|
| 2652 | + $_string = implode(',',$stringA); |
|
| 2653 | + } |
|
| 2264 | 2654 | } |
| 2265 | 2655 | if ($_tryIDNConversion==='FORCE') |
| 2266 | 2656 | { |
@@ -2285,7 +2675,10 @@ discard block |
||
| 2285 | 2675 | { |
| 2286 | 2676 | return 'No Subject'; |
| 2287 | 2677 | } |
| 2288 | - if ($decode) $_string = self::decode_header($_string); |
|
| 2678 | + if ($decode) |
|
| 2679 | + { |
|
| 2680 | + $_string = self::decode_header($_string); |
|
| 2681 | + } |
|
| 2289 | 2682 | // make sure its utf-8 |
| 2290 | 2683 | $test = @json_encode($_string); |
| 2291 | 2684 | if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
@@ -2323,7 +2716,8 @@ discard block |
||
| 2323 | 2716 | * @param string _parent the parent foldername |
| 2324 | 2717 | * @return ISO-8859-1 / UTF7-IMAP encoded string |
| 2325 | 2718 | */ |
| 2326 | - function _encodeFolderName($_folderName) { |
|
| 2719 | + function _encodeFolderName($_folderName) |
|
| 2720 | + { |
|
| 2327 | 2721 | return Translation::convert($_folderName, self::$displayCharset, 'ISO-8859-1'); |
| 2328 | 2722 | #return Translation::convert($_folderName, self::$displayCharset, 'UTF7-IMAP'); |
| 2329 | 2723 | } |
@@ -2339,21 +2733,36 @@ discard block |
||
| 2339 | 2733 | */ |
| 2340 | 2734 | function createFolder($_parent, $_folderName, &$_error) |
| 2341 | 2735 | { |
| 2342 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
|
| 2736 | + if (self::$debug) |
|
| 2737 | + { |
|
| 2738 | + error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
|
| 2739 | + } |
|
| 2343 | 2740 | $parent = $_parent;//$this->_encodeFolderName($_parent); |
| 2344 | 2741 | $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
| 2345 | 2742 | |
| 2346 | - if(empty($parent)) { |
|
| 2743 | + if(empty($parent)) |
|
| 2744 | + { |
|
| 2347 | 2745 | $newFolderName = $folderName; |
| 2348 | - } else { |
|
| 2746 | + } |
|
| 2747 | + else |
|
| 2748 | + { |
|
| 2349 | 2749 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2350 | 2750 | $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
| 2351 | 2751 | } |
| 2352 | - if (empty($newFolderName)) return false; |
|
| 2353 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
|
| 2752 | + if (empty($newFolderName)) |
|
| 2753 | + { |
|
| 2754 | + return false; |
|
| 2755 | + } |
|
| 2756 | + if (self::$debug) |
|
| 2757 | + { |
|
| 2758 | + error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
|
| 2759 | + } |
|
| 2354 | 2760 | if ($this->folderExists($newFolderName,true)) |
| 2355 | 2761 | { |
| 2356 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
|
| 2762 | + if (self::$debug) |
|
| 2763 | + { |
|
| 2764 | + error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
|
| 2765 | + } |
|
| 2357 | 2766 | return $newFolderName; |
| 2358 | 2767 | } |
| 2359 | 2768 | try |
@@ -2401,13 +2810,19 @@ discard block |
||
| 2401 | 2810 | $parent = $_parent;//$this->_encodeFolderName($_parent); |
| 2402 | 2811 | $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
| 2403 | 2812 | |
| 2404 | - if(empty($parent)) { |
|
| 2813 | + if(empty($parent)) |
|
| 2814 | + { |
|
| 2405 | 2815 | $newFolderName = $folderName; |
| 2406 | - } else { |
|
| 2816 | + } |
|
| 2817 | + else |
|
| 2818 | + { |
|
| 2407 | 2819 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2408 | 2820 | $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
| 2409 | 2821 | } |
| 2410 | - if (self::$debug) error_log("create folder: $newFolderName"); |
|
| 2822 | + if (self::$debug) |
|
| 2823 | + { |
|
| 2824 | + error_log("create folder: $newFolderName"); |
|
| 2825 | + } |
|
| 2411 | 2826 | try |
| 2412 | 2827 | { |
| 2413 | 2828 | $this->icServer->renameMailbox($oldFolderName, $newFolderName); |
@@ -2481,8 +2896,14 @@ discard block |
||
| 2481 | 2896 | */ |
| 2482 | 2897 | function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
| 2483 | 2898 | { |
| 2484 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
|
| 2485 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2899 | + if (self::$debug) |
|
| 2900 | + { |
|
| 2901 | + error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
|
| 2902 | + } |
|
| 2903 | + if (self::$debugTimes) |
|
| 2904 | + { |
|
| 2905 | + $starttime = microtime (true); |
|
| 2906 | + } |
|
| 2486 | 2907 | static $folders2return; |
| 2487 | 2908 | //$_subscribedOnly=false; |
| 2488 | 2909 | // always use static on single request if info is available; |
@@ -2490,23 +2911,35 @@ discard block |
||
| 2490 | 2911 | // set $_useCacheIfPossible to false ! |
| 2491 | 2912 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2492 | 2913 | { |
| 2493 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2914 | + if (self::$debugTimes) |
|
| 2915 | + { |
|
| 2916 | + self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2917 | + } |
|
| 2494 | 2918 | return $folders2return[$this->icServer->ImapServerId]; |
| 2495 | 2919 | } |
| 2496 | 2920 | |
| 2497 | 2921 | if ($_subscribedOnly && $_getCounters===false) |
| 2498 | 2922 | { |
| 2499 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2923 | + if (is_null($folders2return)) |
|
| 2924 | + { |
|
| 2925 | + $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2926 | + } |
|
| 2500 | 2927 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2501 | 2928 | { |
| 2502 | 2929 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2503 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2930 | + if (self::$debugTimes) |
|
| 2931 | + { |
|
| 2932 | + self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2933 | + } |
|
| 2504 | 2934 | return $folders2return[$this->icServer->ImapServerId]; |
| 2505 | 2935 | } |
| 2506 | 2936 | } |
| 2507 | 2937 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2508 | 2938 | static $folderBasicInfo; |
| 2509 | - 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); |
|
| 2939 | + if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) |
|
| 2940 | + { |
|
| 2941 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2942 | + } |
|
| 2510 | 2943 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2511 | 2944 | |
| 2512 | 2945 | $delimiter = $this->getHierarchyDelimiter(); |
@@ -2519,7 +2952,8 @@ discard block |
||
| 2519 | 2952 | $inboxData->shortFolderName = 'INBOX'; |
| 2520 | 2953 | $inboxData->shortDisplayName = lang('INBOX'); |
| 2521 | 2954 | $inboxData->subscribed = true; |
| 2522 | - if($_getCounters == true) { |
|
| 2955 | + if($_getCounters == true) |
|
| 2956 | + { |
|
| 2523 | 2957 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2524 | 2958 | } |
| 2525 | 2959 | // force unsubscribed by preference showAllFoldersInFolderPane |
@@ -2538,12 +2972,14 @@ discard block |
||
| 2538 | 2972 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2539 | 2973 | if (is_array($nameSpace)) |
| 2540 | 2974 | { |
| 2541 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2975 | + foreach($nameSpace as $k => $singleNameSpace) |
|
| 2976 | + { |
|
| 2542 | 2977 | $type = $singleNameSpace['type']; |
| 2543 | 2978 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2544 | 2979 | $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
| 2545 | 2980 | |
| 2546 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 2981 | + if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) |
|
| 2982 | + { |
|
| 2547 | 2983 | // fetch and sort the subscribed folders |
| 2548 | 2984 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2549 | 2985 | // if a folder is subscribed or not |
@@ -2594,8 +3030,12 @@ discard block |
||
| 2594 | 3030 | } |
| 2595 | 3031 | } |
| 2596 | 3032 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($foldersNameSpace[$type]['subscribed'])); |
| 2597 | - if (!is_array($foldersNameSpace[$type]['all'])) $foldersNameSpace[$type]['all'] = array(); |
|
| 2598 | - if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) { |
|
| 3033 | + if (!is_array($foldersNameSpace[$type]['all'])) |
|
| 3034 | + { |
|
| 3035 | + $foldersNameSpace[$type]['all'] = array(); |
|
| 3036 | + } |
|
| 3037 | + if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) |
|
| 3038 | + { |
|
| 2599 | 3039 | continue; |
| 2600 | 3040 | } |
| 2601 | 3041 | |
@@ -2625,7 +3065,8 @@ discard block |
||
| 2625 | 3065 | } |
| 2626 | 3066 | |
| 2627 | 3067 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($allMailboxesExt)); |
| 2628 | - foreach ($allMailboxesExt as $mbx) { |
|
| 3068 | + foreach ($allMailboxesExt as $mbx) |
|
| 3069 | + { |
|
| 2629 | 3070 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2630 | 3071 | { |
| 2631 | 3072 | $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
@@ -2648,20 +3089,33 @@ discard block |
||
| 2648 | 3089 | if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
| 2649 | 3090 | isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
| 2650 | 3091 | (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
| 2651 | - ) continue; |
|
| 3092 | + ) |
|
| 3093 | + { |
|
| 3094 | + continue; |
|
| 3095 | + } |
|
| 2652 | 3096 | |
| 2653 | 3097 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
| 2654 | 3098 | $allMailBoxesExtSorted[$mbx['MAILBOX']] = $mbx; |
| 2655 | 3099 | } |
| 2656 | - if (is_array($allMailBoxesExtSorted)) ksort($allMailBoxesExtSorted); |
|
| 3100 | + if (is_array($allMailBoxesExtSorted)) |
|
| 3101 | + { |
|
| 3102 | + ksort($allMailBoxesExtSorted); |
|
| 3103 | + } |
|
| 2657 | 3104 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2658 | 3105 | $allMailboxes = array(); |
| 2659 | - foreach ((array)$allMailBoxesExtSorted as $mbx) { |
|
| 2660 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 3106 | + foreach ((array)$allMailBoxesExtSorted as $mbx) |
|
| 3107 | + { |
|
| 3108 | + if (!in_array($mbx['MAILBOX'],$allMailboxes)) |
|
| 3109 | + { |
|
| 3110 | + $allMailboxes[] = $mbx['MAILBOX']; |
|
| 3111 | + } |
|
| 2661 | 3112 | //echo "Result:";_debug_array($allMailboxes); |
| 2662 | 3113 | } |
| 2663 | 3114 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
| 2664 | - if (is_array($foldersNameSpace[$type]['all'])) sort($foldersNameSpace[$type]['all']); |
|
| 3115 | + if (is_array($foldersNameSpace[$type]['all'])) |
|
| 3116 | + { |
|
| 3117 | + sort($foldersNameSpace[$type]['all']); |
|
| 3118 | + } |
|
| 2665 | 3119 | } |
| 2666 | 3120 | } |
| 2667 | 3121 | } |
@@ -2670,24 +3124,50 @@ discard block |
||
| 2670 | 3124 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2671 | 3125 | $autoFolderObjects = $folders = array(); |
| 2672 | 3126 | $autofolder_exists = array(); |
| 2673 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2674 | - if(isset($foldersNameSpace[$type])) { |
|
| 2675 | - if($_subscribedOnly) { |
|
| 2676 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2677 | - } else { |
|
| 2678 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2679 | - } |
|
| 2680 | - foreach((array)$listOfFolders as $folderName) { |
|
| 3127 | + foreach( array('personal', 'others', 'shared') as $type) |
|
| 3128 | + { |
|
| 3129 | + if(isset($foldersNameSpace[$type])) |
|
| 3130 | + { |
|
| 3131 | + if($_subscribedOnly) |
|
| 3132 | + { |
|
| 3133 | + if( !empty($foldersNameSpace[$type]['subscribed']) ) |
|
| 3134 | + { |
|
| 3135 | + $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 3136 | + } |
|
| 3137 | + } |
|
| 3138 | + else |
|
| 3139 | + { |
|
| 3140 | + if( !empty($foldersNameSpace[$type]['all'])) |
|
| 3141 | + { |
|
| 3142 | + $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 3143 | + } |
|
| 3144 | + } |
|
| 3145 | + foreach((array)$listOfFolders as $folderName) |
|
| 3146 | + { |
|
| 2681 | 3147 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2682 | 3148 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2683 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2684 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 3149 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) |
|
| 3150 | + { |
|
| 3151 | + continue; |
|
| 3152 | + } |
|
| 3153 | + //when subscribedonly, we fetch all folders in one go. |
|
| 3154 | + if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) |
|
| 3155 | + { |
|
| 2685 | 3156 | #echo "$folderName failed to be here <br>"; |
| 2686 | 3157 | continue; |
| 2687 | 3158 | } |
| 2688 | - if (isset($folders[$folderName])) continue; |
|
| 2689 | - if (isset($autoFolderObjects[$folderName])) continue; |
|
| 2690 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 3159 | + if (isset($folders[$folderName])) |
|
| 3160 | + { |
|
| 3161 | + continue; |
|
| 3162 | + } |
|
| 3163 | + if (isset($autoFolderObjects[$folderName])) |
|
| 3164 | + { |
|
| 3165 | + continue; |
|
| 3166 | + } |
|
| 3167 | + if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) |
|
| 3168 | + { |
|
| 3169 | + $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 3170 | + } |
|
| 2691 | 3171 | $folderParts = explode($delimiter, $folderName); |
| 2692 | 3172 | $shortName = array_pop($folderParts); |
| 2693 | 3173 | |
@@ -2695,17 +3175,20 @@ discard block |
||
| 2695 | 3175 | $folderObject->delimiter = $delimiter; |
| 2696 | 3176 | $folderObject->folderName = $folderName; |
| 2697 | 3177 | $folderObject->shortFolderName = $shortName; |
| 2698 | - if(!$_subscribedOnly) { |
|
| 3178 | + if(!$_subscribedOnly) |
|
| 3179 | + { |
|
| 2699 | 3180 | #echo $folderName."->".$type."<br>"; |
| 2700 | 3181 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2701 | 3182 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2702 | 3183 | } |
| 2703 | 3184 | |
| 2704 | - if($_getCounters == true) { |
|
| 3185 | + if($_getCounters == true) |
|
| 3186 | + { |
|
| 2705 | 3187 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2706 | 3188 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2707 | 3189 | } |
| 2708 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 3190 | + if(strtoupper($folderName) == 'INBOX') |
|
| 3191 | + { |
|
| 2709 | 3192 | $folderName = 'INBOX'; |
| 2710 | 3193 | $folderObject->folderName = 'INBOX'; |
| 2711 | 3194 | $folderObject->shortFolderName = 'INBOX'; |
@@ -2713,24 +3196,34 @@ discard block |
||
| 2713 | 3196 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2714 | 3197 | $folderObject->subscribed = true; |
| 2715 | 3198 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2716 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 3199 | + } |
|
| 3200 | + elseif (in_array($shortName,self::$autoFolders)) |
|
| 3201 | + { |
|
| 2717 | 3202 | $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
| 2718 | 3203 | array_pop($tmpfolderparts); |
| 2719 | 3204 | $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
| 2720 | 3205 | $folderObject->shortDisplayName = lang($shortName); |
| 2721 | 3206 | unset($tmpfolderparts); |
| 2722 | - } else { |
|
| 3207 | + } |
|
| 3208 | + else |
|
| 3209 | + { |
|
| 2723 | 3210 | $folderObject->displayName = $folderObject->folderName; |
| 2724 | 3211 | $folderObject->shortDisplayName = $shortName; |
| 2725 | 3212 | } |
| 2726 | 3213 | //$folderName = $folderName; |
| 2727 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 3214 | + if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) |
|
| 3215 | + { |
|
| 2728 | 3216 | $autoFolderObjects[$folderName] = $folderObject; |
| 2729 | - } else { |
|
| 3217 | + } |
|
| 3218 | + else |
|
| 3219 | + { |
|
| 2730 | 3220 | $folders[$folderName] = $folderObject; |
| 2731 | 3221 | } |
| 2732 | 3222 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2733 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 3223 | + if (!isset(self::$specialUseFolders)) |
|
| 3224 | + { |
|
| 3225 | + $this->getSpecialUseFolders (); |
|
| 3226 | + } |
|
| 2734 | 3227 | if (isset(self::$specialUseFolders[$folderName])) |
| 2735 | 3228 | { |
| 2736 | 3229 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2738,7 +3231,8 @@ discard block |
||
| 2738 | 3231 | } |
| 2739 | 3232 | } |
| 2740 | 3233 | } |
| 2741 | - if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
|
| 3234 | + if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) |
|
| 3235 | + { |
|
| 2742 | 3236 | uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
| 2743 | 3237 | } |
| 2744 | 3238 | // check if some standard folders are missing and need to be created |
@@ -2747,7 +3241,10 @@ discard block |
||
| 2747 | 3241 | // if new folders have been created, re-read folders ignoring the cache |
| 2748 | 3242 | return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
| 2749 | 3243 | } |
| 2750 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 3244 | + if (is_array($folders)) |
|
| 3245 | + { |
|
| 3246 | + uasort($folders,array($this,"sortByDisplayName")); |
|
| 3247 | + } |
|
| 2751 | 3248 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2752 | 3249 | //_debug_array($folders2return); #exit; |
| 2753 | 3250 | $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
@@ -2759,7 +3256,10 @@ discard block |
||
| 2759 | 3256 | Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
| 2760 | 3257 | } |
| 2761 | 3258 | Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
| 2762 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 3259 | + if (self::$debugTimes) |
|
| 3260 | + { |
|
| 3261 | + self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 3262 | + } |
|
| 2763 | 3263 | return $folders2return[$this->icServer->ImapServerId]; |
| 2764 | 3264 | } |
| 2765 | 3265 | |
@@ -2787,31 +3287,44 @@ discard block |
||
| 2787 | 3287 | |
| 2788 | 3288 | $folders = $nameSpace = array(); |
| 2789 | 3289 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2790 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 3290 | + foreach($nameSpaceTmp as $k => $singleNameSpace) |
|
| 3291 | + { |
|
| 2791 | 3292 | $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
| 2792 | 3293 | } |
| 2793 | 3294 | unset($nameSpaceTmp); |
| 2794 | 3295 | |
| 2795 | 3296 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2796 | 3297 | // Get special use folders |
| 2797 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 3298 | + if (!isset(self::$specialUseFolders)) |
|
| 3299 | + { |
|
| 3300 | + $this->getSpecialUseFolders (); |
|
| 3301 | + } |
|
| 3302 | + // Set self::$specialUseFolders |
|
| 2798 | 3303 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2799 | - if ($_onlyTopLevel) // top level leaves |
|
| 3304 | + if ($_onlyTopLevel) |
|
| 3305 | + { |
|
| 3306 | + // top level leaves |
|
| 2800 | 3307 | { |
| 2801 | 3308 | // Get top mailboxes of icServer |
| 2802 | 3309 | $topFolders = $this->icServer->getMailboxes("", 2, true); |
| 3310 | + } |
|
| 2803 | 3311 | // Trigger examination of namespace to retrieve |
| 2804 | 3312 | // folders located in other and shared; needed only for some servers |
| 2805 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 3313 | + if (is_null(self::$mailConfig)) |
|
| 3314 | + { |
|
| 3315 | + self::$mailConfig = Config::read('mail'); |
|
| 3316 | + } |
|
| 2806 | 3317 | if (self::$mailConfig['examineNamespace']) |
| 2807 | 3318 | { |
| 2808 | 3319 | $prefixes=array(); |
| 2809 | 3320 | if (is_array($nameSpace)) |
| 2810 | 3321 | { |
| 2811 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 3322 | + foreach($nameSpace as $k => $singleNameSpace) |
|
| 3323 | + { |
|
| 2812 | 3324 | $type = $singleNameSpace['type']; |
| 2813 | 3325 | |
| 2814 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 3326 | + if(is_array($singleNameSpace) && $singleNameSpace['prefix']) |
|
| 3327 | + { |
|
| 2815 | 3328 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2816 | 3329 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2817 | 3330 | $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
@@ -2887,7 +3400,10 @@ discard block |
||
| 2887 | 3400 | $nFolders [$path] = $folder; |
| 2888 | 3401 | } |
| 2889 | 3402 | } |
| 2890 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 3403 | + if (is_array($aFolders)) |
|
| 3404 | + { |
|
| 3405 | + uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 3406 | + } |
|
| 2891 | 3407 | //ksort($aFolders); |
| 2892 | 3408 | |
| 2893 | 3409 | // Sort none auto folders base on mailbox name |
@@ -2897,12 +3413,17 @@ discard block |
||
| 2897 | 3413 | } |
| 2898 | 3414 | else |
| 2899 | 3415 | { |
| 2900 | - if (is_array($subFolders)) ksort($subFolders); |
|
| 3416 | + if (is_array($subFolders)) |
|
| 3417 | + { |
|
| 3418 | + ksort($subFolders); |
|
| 3419 | + } |
|
| 2901 | 3420 | } |
| 2902 | 3421 | $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
| 2903 | 3422 | } |
| 2904 | 3423 | } |
| 2905 | - elseif ($_nodePath) // single node |
|
| 3424 | + elseif ($_nodePath) |
|
| 3425 | + { |
|
| 3426 | + // single node |
|
| 2906 | 3427 | { |
| 2907 | 3428 | switch ($_search) |
| 2908 | 3429 | { |
@@ -2910,6 +3431,7 @@ discard block |
||
| 2910 | 3431 | case 0: |
| 2911 | 3432 | case 2: |
| 2912 | 3433 | $path = $_nodePath.''.$delimiter; |
| 3434 | + } |
|
| 2913 | 3435 | break; |
| 2914 | 3436 | // Node itself |
| 2915 | 3437 | // shouldn't contain next level delimiter |
@@ -2928,11 +3450,14 @@ discard block |
||
| 2928 | 3450 | |
| 2929 | 3451 | uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
| 2930 | 3452 | } |
| 2931 | - elseif(!$_nodePath) // all |
|
| 3453 | + elseif(!$_nodePath) |
|
| 3454 | + { |
|
| 3455 | + // all |
|
| 2932 | 3456 | { |
| 2933 | 3457 | if ($_subscribedOnly) |
| 2934 | 3458 | { |
| 2935 | 3459 | $folders = $this->icServer->listSubscribedMailboxes('', 0, true); |
| 3460 | + } |
|
| 2936 | 3461 | } |
| 2937 | 3462 | else |
| 2938 | 3463 | { |
@@ -2944,7 +3469,10 @@ discard block |
||
| 2944 | 3469 | { |
| 2945 | 3470 | // SORTING FOLDERS |
| 2946 | 3471 | //self::$debugTimes=true; |
| 2947 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 3472 | + if (self::$debugTimes) |
|
| 3473 | + { |
|
| 3474 | + $starttime = microtime (true); |
|
| 3475 | + } |
|
| 2948 | 3476 | // Merge of all auto folders and specialusefolders |
| 2949 | 3477 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 2950 | 3478 | uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
@@ -2954,73 +3482,103 @@ discard block |
||
| 2954 | 3482 | $isGoogleMail=false; |
| 2955 | 3483 | foreach($autoFoldersTmp as $afk=>$aF) |
| 2956 | 3484 | { |
| 2957 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3485 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) |
|
| 3486 | + { |
|
| 3487 | + $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3488 | + } |
|
| 2958 | 3489 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2959 | 3490 | } |
| 2960 | 3491 | //error_log(array2string($mySpecialUseFolders)); |
| 2961 | - foreach ($tmpFolders as $k => $f) { |
|
| 3492 | + foreach ($tmpFolders as $k => $f) |
|
| 3493 | + { |
|
| 2962 | 3494 | $sorted=false; |
| 2963 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 2964 | - if (strtoupper($k)=='INBOX') { |
|
| 3495 | + if (strtoupper(substr($k,0,5))=='INBOX') |
|
| 3496 | + { |
|
| 3497 | + if (strtoupper($k)=='INBOX') |
|
| 3498 | + { |
|
| 2965 | 3499 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 2966 | 3500 | $inboxFolderObject[$k]=$f; |
| 2967 | 3501 | unset($folders[$k]); |
| 2968 | 3502 | $sorted=true; |
| 2969 | - } else { |
|
| 3503 | + } |
|
| 3504 | + else |
|
| 3505 | + { |
|
| 2970 | 3506 | $isAutoFolder=false; |
| 2971 | 3507 | foreach($autoFoldersTmp as $afk=>$aF) |
| 2972 | 3508 | { |
| 2973 | 3509 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2974 | 3510 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 2975 | 3511 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
| 2976 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3512 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3513 | + { |
|
| 3514 | + // k is parent of an autofolder |
|
| 2977 | 3515 | { |
| 2978 | 3516 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 2979 | 3517 | $isAutoFolder=true; |
| 3518 | + } |
|
| 2980 | 3519 | $autoFolderObjects[$k]=$f; |
| 2981 | 3520 | break; |
| 2982 | 3521 | } |
| 2983 | 3522 | } |
| 2984 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 3523 | + if ($isAutoFolder==false) |
|
| 3524 | + { |
|
| 3525 | + $inboxSubFolderObjects[$k]=$f; |
|
| 3526 | + } |
|
| 2985 | 3527 | unset($folders[$k]); |
| 2986 | 3528 | $sorted=true; |
| 2987 | 3529 | } |
| 2988 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 3530 | + } |
|
| 3531 | + elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') |
|
| 3532 | + { |
|
| 2989 | 3533 | $isGoogleMail=true; |
| 2990 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 3534 | + if (strtoupper($k)=='[GOOGLE MAIL]') |
|
| 3535 | + { |
|
| 2991 | 3536 | $googleMailFolderObject[$k]=$f; |
| 2992 | 3537 | unset($folders[$k]); |
| 2993 | 3538 | $sorted=true; |
| 2994 | - } else { |
|
| 3539 | + } |
|
| 3540 | + else |
|
| 3541 | + { |
|
| 2995 | 3542 | $isAutoFolder=false; |
| 2996 | 3543 | foreach($autoFoldersTmp as $afk=>$aF) |
| 2997 | 3544 | { |
| 2998 | 3545 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2999 | 3546 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3000 | 3547 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
| 3001 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3548 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3549 | + { |
|
| 3550 | + // k is parent of an autofolder |
|
| 3002 | 3551 | { |
| 3003 | 3552 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3004 | 3553 | $isAutoFolder=true; |
| 3554 | + } |
|
| 3005 | 3555 | $googleAutoFolderObjects[$k]=$f; |
| 3006 | 3556 | break; |
| 3007 | 3557 | } |
| 3008 | 3558 | } |
| 3009 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3559 | + if ($isAutoFolder==false) |
|
| 3560 | + { |
|
| 3561 | + $googleSubFolderObjects[$k]=$f; |
|
| 3562 | + } |
|
| 3010 | 3563 | unset($folders[$k]); |
| 3011 | 3564 | $sorted=true; |
| 3012 | 3565 | } |
| 3013 | - } else { |
|
| 3566 | + } |
|
| 3567 | + else |
|
| 3568 | + { |
|
| 3014 | 3569 | $isAutoFolder=false; |
| 3015 | 3570 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3016 | 3571 | { |
| 3017 | 3572 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3018 | 3573 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3019 | 3574 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
| 3020 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3575 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3576 | + { |
|
| 3577 | + // k is parent of an autofolder |
|
| 3021 | 3578 | { |
| 3022 | 3579 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3023 | 3580 | $isAutoFolder=true; |
| 3581 | + } |
|
| 3024 | 3582 | $autoFolderObjects[$k]=$f; |
| 3025 | 3583 | unset($folders[$k]); |
| 3026 | 3584 | $sorted=true; |
@@ -3036,7 +3594,8 @@ discard block |
||
| 3036 | 3594 | if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
| 3037 | 3595 | { |
| 3038 | 3596 | if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
| 3039 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3597 | + substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) |
|
| 3598 | + { |
|
| 3040 | 3599 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3041 | 3600 | $typeFolderObject[$type][$k]=$f; |
| 3042 | 3601 | unset($folders[$k]); |
@@ -3063,9 +3622,12 @@ discard block |
||
| 3063 | 3622 | } |
| 3064 | 3623 | } |
| 3065 | 3624 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3066 | - if (!$isGoogleMail) { |
|
| 3625 | + if (!$isGoogleMail) |
|
| 3626 | + { |
|
| 3067 | 3627 | $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
| 3068 | - } else { |
|
| 3628 | + } |
|
| 3629 | + else |
|
| 3630 | + { |
|
| 3069 | 3631 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3070 | 3632 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3071 | 3633 | unset($googleAutoFolderObjects); |
@@ -3082,7 +3644,10 @@ discard block |
||
| 3082 | 3644 | } |
| 3083 | 3645 | $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
| 3084 | 3646 | } |
| 3085 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3647 | + if (self::$debugTimes) |
|
| 3648 | + { |
|
| 3649 | + self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3650 | + } |
|
| 3086 | 3651 | //self::$debugTimes=false; |
| 3087 | 3652 | } |
| 3088 | 3653 | // Get counter information and add them to each fetched folders array |
@@ -3132,7 +3697,13 @@ discard block |
||
| 3132 | 3697 | $rv = false; |
| 3133 | 3698 | foreach ($haystack as $k => $v) |
| 3134 | 3699 | { |
| 3135 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3700 | + foreach($v as &$sv) |
|
| 3701 | + { |
|
| 3702 | +if (trim($sv)==trim($needle)) |
|
| 3703 | + { |
|
| 3704 | + return $k; |
|
| 3705 | + } |
|
| 3706 | + } |
|
| 3136 | 3707 | } |
| 3137 | 3708 | return $rv; |
| 3138 | 3709 | } |
@@ -3159,7 +3730,10 @@ discard block |
||
| 3159 | 3730 | */ |
| 3160 | 3731 | static function pathToFolderData ($_path, $_hDelimiter) |
| 3161 | 3732 | { |
| 3162 | - if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
|
| 3733 | + if (!strpos($_path, self::DELIMITER)) |
|
| 3734 | + { |
|
| 3735 | + $_path = self::DELIMITER.$_path; |
|
| 3736 | + } |
|
| 3163 | 3737 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3164 | 3738 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3165 | 3739 | $name = array_pop($parts); |
@@ -3188,7 +3762,10 @@ discard block |
||
| 3188 | 3762 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3189 | 3763 | $pos1 = array_search(trim($a['name']),self::$autoFolders); |
| 3190 | 3764 | $pos2 = array_search(trim($b['name']),self::$autoFolders); |
| 3191 | - if ($pos1 == $pos2) return 0; |
|
| 3765 | + if ($pos1 == $pos2) |
|
| 3766 | + { |
|
| 3767 | + return 0; |
|
| 3768 | + } |
|
| 3192 | 3769 | return ($pos1 < $pos2) ? -1 : 1; |
| 3193 | 3770 | } |
| 3194 | 3771 | |
@@ -3219,7 +3796,10 @@ discard block |
||
| 3219 | 3796 | // 0, 1 und -1 |
| 3220 | 3797 | $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
| 3221 | 3798 | $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
| 3222 | - if ($pos1 == $pos2) return 0; |
|
| 3799 | + if ($pos1 == $pos2) |
|
| 3800 | + { |
|
| 3801 | + return 0; |
|
| 3802 | + } |
|
| 3223 | 3803 | return ($pos1 < $pos2) ? -1 : 1; |
| 3224 | 3804 | } |
| 3225 | 3805 | |
@@ -3240,11 +3820,18 @@ discard block |
||
| 3240 | 3820 | } |
| 3241 | 3821 | catch (\Exception $e) |
| 3242 | 3822 | { |
| 3243 | - if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
|
| 3823 | + if (self::$debug) |
|
| 3824 | + { |
|
| 3825 | + error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
|
| 3826 | + } |
|
| 3244 | 3827 | return false; |
| 3245 | 3828 | } |
| 3246 | - if(is_array($folderStatus)) { |
|
| 3247 | - if ($_returnObject===false) return $folderStatus; |
|
| 3829 | + if(is_array($folderStatus)) |
|
| 3830 | + { |
|
| 3831 | + if ($_returnObject===false) |
|
| 3832 | + { |
|
| 3833 | + return $folderStatus; |
|
| 3834 | + } |
|
| 3248 | 3835 | $status = new \stdClass; |
| 3249 | 3836 | $status->messages = $folderStatus['MESSAGES']; |
| 3250 | 3837 | $status->unseen = $folderStatus['UNSEEN']; |
@@ -3271,7 +3858,8 @@ discard block |
||
| 3271 | 3858 | { |
| 3272 | 3859 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3273 | 3860 | $maxreclevel=25; |
| 3274 | - if ($reclevel > $maxreclevel) { |
|
| 3861 | + if ($reclevel > $maxreclevel) |
|
| 3862 | + { |
|
| 3275 | 3863 | error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
| 3276 | 3864 | return array(); |
| 3277 | 3865 | } |
@@ -3285,7 +3873,8 @@ discard block |
||
| 3285 | 3873 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3286 | 3874 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3287 | 3875 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3288 | - 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"]))) { |
|
| 3876 | + 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"]))) |
|
| 3877 | + { |
|
| 3289 | 3878 | // if there are children fetch them |
| 3290 | 3879 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3291 | 3880 | |
@@ -3293,7 +3882,8 @@ discard block |
||
| 3293 | 3882 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3294 | 3883 | //_debug_array($buff); |
| 3295 | 3884 | $allMailboxes = array(); |
| 3296 | - foreach ($buff as $mbxname) { |
|
| 3885 | + foreach ($buff as $mbxname) |
|
| 3886 | + { |
|
| 3297 | 3887 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3298 | 3888 | $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
| 3299 | 3889 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
@@ -3302,9 +3892,14 @@ discard block |
||
| 3302 | 3892 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3303 | 3893 | } |
| 3304 | 3894 | } |
| 3305 | - 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']; |
|
| 3895 | + if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 3896 | + { |
|
| 3897 | + $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3898 | + } |
|
| 3306 | 3899 | return $allMailboxes; |
| 3307 | - } else { |
|
| 3900 | + } |
|
| 3901 | + else |
|
| 3902 | + { |
|
| 3308 | 3903 | return array($_mailbox); |
| 3309 | 3904 | } |
| 3310 | 3905 | } |
@@ -3328,14 +3923,21 @@ discard block |
||
| 3328 | 3923 | 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
| 3329 | 3924 | 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
| 3330 | 3925 | ); |
| 3331 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3926 | + if ($_type == 'Templates') |
|
| 3927 | + { |
|
| 3928 | + $_type = 'Template'; |
|
| 3929 | + } |
|
| 3930 | + // for some reason self::$autofolders uses 'Templates'! |
|
| 3332 | 3931 | $created = false; |
| 3333 | 3932 | if (!isset($types[$_type])) |
| 3334 | 3933 | { |
| 3335 | 3934 | error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__); |
| 3336 | 3935 | return false; |
| 3337 | 3936 | } |
| 3338 | - if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders(); |
|
| 3937 | + if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) |
|
| 3938 | + { |
|
| 3939 | + self::$specialUseFolders = $this->getSpecialUseFolders(); |
|
| 3940 | + } |
|
| 3339 | 3941 | |
| 3340 | 3942 | //highest precedence |
| 3341 | 3943 | try |
@@ -3345,25 +3947,39 @@ discard block |
||
| 3345 | 3947 | catch (\Exception $e) |
| 3346 | 3948 | { |
| 3347 | 3949 | // we know that outbox is not supported, but we use this here, as we autocreate expected SpecialUseFolders in this function |
| 3348 | - if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); |
|
| 3950 | + if ($_type != 'Outbox') |
|
| 3951 | + { |
|
| 3952 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); |
|
| 3953 | + } |
|
| 3349 | 3954 | $_folderName = false; |
| 3350 | 3955 | } |
| 3351 | 3956 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3352 | - if ($_type == 'Archive') { |
|
| 3353 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3957 | + if ($_type == 'Archive') |
|
| 3958 | + { |
|
| 3959 | + if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) |
|
| 3960 | + { |
|
| 3354 | 3961 | return false; |
| 3355 | - } else { |
|
| 3962 | + } |
|
| 3963 | + else |
|
| 3964 | + { |
|
| 3356 | 3965 | return $_folderName; |
| 3357 | 3966 | } |
| 3358 | 3967 | |
| 3359 | 3968 | } |
| 3360 | 3969 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3361 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3970 | + if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) |
|
| 3971 | + { |
|
| 3362 | 3972 | try |
| 3363 | 3973 | { |
| 3364 | 3974 | $error = null; |
| 3365 | - if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
|
| 3366 | - if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 3975 | + if (($_folderName = $this->createFolder('', $_folderName, $error))) |
|
| 3976 | + { |
|
| 3977 | + $created = true; |
|
| 3978 | + } |
|
| 3979 | + if ($error) |
|
| 3980 | + { |
|
| 3981 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 3982 | + } |
|
| 3367 | 3983 | } |
| 3368 | 3984 | catch(Exception $e) |
| 3369 | 3985 | { |
@@ -3372,9 +3988,16 @@ discard block |
||
| 3372 | 3988 | } |
| 3373 | 3989 | } |
| 3374 | 3990 | // not sure yet if false is the correct behavior on none |
| 3375 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 3991 | + if ($_folderName =='none') |
|
| 3992 | + { |
|
| 3993 | + return 'none' ; |
|
| 3994 | + } |
|
| 3995 | + //false; |
|
| 3376 | 3996 | //no (valid) folder found yet; try specialUseFolders |
| 3377 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 3997 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) |
|
| 3998 | + { |
|
| 3999 | + $_folderName = $f; |
|
| 4000 | + } |
|
| 3378 | 4001 | //no specialUseFolder; try some Defaults |
| 3379 | 4002 | if (empty($_folderName) && isset($types[$_type])) |
| 3380 | 4003 | { |
@@ -3400,7 +4023,10 @@ discard block |
||
| 3400 | 4023 | $error = null; |
| 3401 | 4024 | $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
| 3402 | 4025 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3403 | - if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4026 | + if ($error) |
|
| 4027 | + { |
|
| 4028 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4029 | + } |
|
| 3404 | 4030 | } |
| 3405 | 4031 | catch(Exception $e) |
| 3406 | 4032 | { |
@@ -3502,17 +4128,22 @@ discard block |
||
| 3502 | 4128 | function isSentFolder($_folderName, $_checkexistance=TRUE) |
| 3503 | 4129 | { |
| 3504 | 4130 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3505 | - if(empty($sentFolder)) { |
|
| 4131 | + if(empty($sentFolder)) |
|
| 4132 | + { |
|
| 3506 | 4133 | return false; |
| 3507 | 4134 | } |
| 3508 | 4135 | // does the folder exist??? |
| 3509 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4136 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4137 | + { |
|
| 3510 | 4138 | return false; |
| 3511 | 4139 | } |
| 3512 | 4140 | |
| 3513 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 4141 | + if(false !== stripos($_folderName, $sentFolder)) |
|
| 4142 | + { |
|
| 3514 | 4143 | return true; |
| 3515 | - } else { |
|
| 4144 | + } |
|
| 4145 | + else |
|
| 4146 | + { |
|
| 3516 | 4147 | return false; |
| 3517 | 4148 | } |
| 3518 | 4149 | } |
@@ -3525,15 +4156,20 @@ discard block |
||
| 3525 | 4156 | */ |
| 3526 | 4157 | function isOutbox($_folderName, $_checkexistance=TRUE) |
| 3527 | 4158 | { |
| 3528 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 4159 | + if (stripos($_folderName, 'Outbox')===false) |
|
| 4160 | + { |
|
| 3529 | 4161 | return false; |
| 3530 | 4162 | } |
| 3531 | 4163 | // does the folder exist??? |
| 3532 | - if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) { |
|
| 4164 | + if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) |
|
| 4165 | + { |
|
| 3533 | 4166 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3534 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 4167 | + if(false !== stripos($_folderName, $outboxFolder)) |
|
| 4168 | + { |
|
| 3535 | 4169 | return true; |
| 3536 | - } else { |
|
| 4170 | + } |
|
| 4171 | + else |
|
| 4172 | + { |
|
| 3537 | 4173 | return false; |
| 3538 | 4174 | } |
| 3539 | 4175 | } |
@@ -3549,17 +4185,25 @@ discard block |
||
| 3549 | 4185 | function isDraftFolder($_folderName, $_checkexistance=TRUE) |
| 3550 | 4186 | { |
| 3551 | 4187 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3552 | - if(empty($draftFolder)) { |
|
| 4188 | + if(empty($draftFolder)) |
|
| 4189 | + { |
|
| 3553 | 4190 | return false; |
| 3554 | 4191 | } |
| 3555 | 4192 | // does the folder exist??? |
| 3556 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4193 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4194 | + { |
|
| 3557 | 4195 | return false; |
| 3558 | 4196 | } |
| 3559 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3560 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 4197 | + if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) |
|
| 4198 | + { |
|
| 4199 | + $_folderName = $_folderName->utf8; |
|
| 4200 | + } |
|
| 4201 | + if(false !== stripos($_folderName, $draftFolder)) |
|
| 4202 | + { |
|
| 3561 | 4203 | return true; |
| 3562 | - } else { |
|
| 4204 | + } |
|
| 4205 | + else |
|
| 4206 | + { |
|
| 3563 | 4207 | return false; |
| 3564 | 4208 | } |
| 3565 | 4209 | } |
@@ -3573,17 +4217,22 @@ discard block |
||
| 3573 | 4217 | function isTrashFolder($_folderName, $_checkexistance=TRUE) |
| 3574 | 4218 | { |
| 3575 | 4219 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3576 | - if(empty($trashFolder)) { |
|
| 4220 | + if(empty($trashFolder)) |
|
| 4221 | + { |
|
| 3577 | 4222 | return false; |
| 3578 | 4223 | } |
| 3579 | 4224 | // does the folder exist??? |
| 3580 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4225 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4226 | + { |
|
| 3581 | 4227 | return false; |
| 3582 | 4228 | } |
| 3583 | 4229 | |
| 3584 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 4230 | + if(false !== stripos($_folderName, $trashFolder)) |
|
| 4231 | + { |
|
| 3585 | 4232 | return true; |
| 3586 | - } else { |
|
| 4233 | + } |
|
| 4234 | + else |
|
| 4235 | + { |
|
| 3587 | 4236 | return false; |
| 3588 | 4237 | } |
| 3589 | 4238 | } |
@@ -3597,17 +4246,22 @@ discard block |
||
| 3597 | 4246 | function isTemplateFolder($_folderName, $_checkexistance=TRUE) |
| 3598 | 4247 | { |
| 3599 | 4248 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3600 | - if(empty($templateFolder)) { |
|
| 4249 | + if(empty($templateFolder)) |
|
| 4250 | + { |
|
| 3601 | 4251 | return false; |
| 3602 | 4252 | } |
| 3603 | 4253 | // does the folder exist??? |
| 3604 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4254 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4255 | + { |
|
| 3605 | 4256 | return false; |
| 3606 | 4257 | } |
| 3607 | 4258 | |
| 3608 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 4259 | + if(false !== stripos($_folderName, $templateFolder)) |
|
| 4260 | + { |
|
| 3609 | 4261 | return true; |
| 3610 | - } else { |
|
| 4262 | + } |
|
| 4263 | + else |
|
| 4264 | + { |
|
| 3611 | 4265 | return false; |
| 3612 | 4266 | } |
| 3613 | 4267 | } |
@@ -3625,15 +4279,27 @@ discard block |
||
| 3625 | 4279 | if (empty($_folder)) |
| 3626 | 4280 | { |
| 3627 | 4281 | // this error is more or less without significance, unless we force the check |
| 3628 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 4282 | + if ($_forceCheck===true) |
|
| 4283 | + { |
|
| 4284 | + error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 4285 | + } |
|
| 3629 | 4286 | return false; |
| 3630 | 4287 | } |
| 3631 | 4288 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3632 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3633 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 4289 | + if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) |
|
| 4290 | + { |
|
| 4291 | + return true; |
|
| 4292 | + } |
|
| 4293 | + if (is_a($_folder,"Horde_Imap_Client_Mailbox")) |
|
| 4294 | + { |
|
| 4295 | + $_folder = $_folder->utf8; |
|
| 4296 | + } |
|
| 3634 | 4297 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3635 | 4298 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3636 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 4299 | + if (is_null($folderInfo)) |
|
| 4300 | + { |
|
| 4301 | + $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 4302 | + } |
|
| 3637 | 4303 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3638 | 4304 | if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
| 3639 | 4305 | { |
@@ -3651,7 +4317,8 @@ discard block |
||
| 3651 | 4317 | |
| 3652 | 4318 | // does the folder exist??? |
| 3653 | 4319 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3654 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 4320 | + if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) |
|
| 4321 | + { |
|
| 3655 | 4322 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3656 | 4323 | //return false; |
| 3657 | 4324 | //try to connect |
@@ -3691,9 +4358,12 @@ discard block |
||
| 3691 | 4358 | |
| 3692 | 4359 | $this->icServer->openMailbox($folderName); |
| 3693 | 4360 | |
| 3694 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 4361 | + if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") |
|
| 4362 | + { |
|
| 3695 | 4363 | $this->deleteMessages('all',$folderName,'remove_immediately'); |
| 3696 | - } else { |
|
| 4364 | + } |
|
| 4365 | + else |
|
| 4366 | + { |
|
| 3697 | 4367 | $this->icServer->expunge($folderName); |
| 3698 | 4368 | } |
| 3699 | 4369 | } |
@@ -3712,10 +4382,16 @@ discard block |
||
| 3712 | 4382 | { |
| 3713 | 4383 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3714 | 4384 | $oldMailbox = ''; |
| 3715 | - if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
|
| 4385 | + if (is_null($_folder) || empty($_folder)) |
|
| 4386 | + { |
|
| 4387 | + $_folder = $this->sessionData['mailbox']; |
|
| 4388 | + } |
|
| 3716 | 4389 | if (empty($_messageUID)) |
| 3717 | 4390 | { |
| 3718 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4391 | + if (self::$debug) |
|
| 4392 | + { |
|
| 4393 | + error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4394 | + } |
|
| 3719 | 4395 | return false; |
| 3720 | 4396 | } |
| 3721 | 4397 | elseif ($_messageUID==='all') |
@@ -3725,32 +4401,48 @@ discard block |
||
| 3725 | 4401 | else |
| 3726 | 4402 | { |
| 3727 | 4403 | $uidsToDelete = new Horde_Imap_Client_Ids(); |
| 3728 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4404 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4405 | + { |
|
| 4406 | + $_messageUID = (array)$_messageUID; |
|
| 4407 | + } |
|
| 3729 | 4408 | $uidsToDelete->add($_messageUID); |
| 3730 | 4409 | } |
| 3731 | 4410 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3732 | - 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"); |
|
| 4411 | + if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) |
|
| 4412 | + { |
|
| 4413 | + $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted"); |
|
| 4414 | + } |
|
| 3733 | 4415 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3734 | 4416 | $trashFolder = $this->getTrashFolder(); |
| 3735 | 4417 | $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
| 3736 | 4418 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3737 | 4419 | if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
| 3738 | - (strtolower($_folder) == strtolower($draftFolder))) { |
|
| 4420 | + (strtolower($_folder) == strtolower($draftFolder))) |
|
| 4421 | + { |
|
| 3739 | 4422 | $deleteOptions = "remove_immediately"; |
| 3740 | 4423 | } |
| 3741 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 4424 | + if($this->icServer->getCurrentMailbox() != $_folder) |
|
| 4425 | + { |
|
| 3742 | 4426 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3743 | 4427 | $this->icServer->openMailbox($_folder); |
| 3744 | 4428 | } |
| 3745 | 4429 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3746 | 4430 | $updateCache = false; |
| 3747 | - switch($deleteOptions) { |
|
| 4431 | + switch($deleteOptions) |
|
| 4432 | + { |
|
| 3748 | 4433 | case "move_to_trash": |
| 3749 | 4434 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3750 | 4435 | $updateCache = true; |
| 3751 | - if(!empty($trashFolder)) { |
|
| 3752 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
|
| 3753 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 4436 | + if(!empty($trashFolder)) |
|
| 4437 | + { |
|
| 4438 | + if (self::$debug) |
|
| 4439 | + { |
|
| 4440 | + error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
|
| 4441 | + } |
|
| 4442 | + if (self::$debug) |
|
| 4443 | + { |
|
| 4444 | + error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 4445 | + } |
|
| 3754 | 4446 | // copy messages |
| 3755 | 4447 | try |
| 3756 | 4448 | { |
@@ -3766,7 +4458,10 @@ discard block |
||
| 3766 | 4458 | case "mark_as_deleted": |
| 3767 | 4459 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3768 | 4460 | // mark messages as deleted |
| 3769 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 4461 | + if (is_null($_messageUID)) |
|
| 4462 | + { |
|
| 4463 | + $_messageUID='all'; |
|
| 4464 | + } |
|
| 3770 | 4465 | foreach((array)$_messageUID as $key =>$uid) |
| 3771 | 4466 | { |
| 3772 | 4467 | //flag messages, that are flagged for deletion as seen too |
@@ -3774,7 +4469,10 @@ discard block |
||
| 3774 | 4469 | $flags = $this->getFlags($uid); |
| 3775 | 4470 | $this->flagMessages('delete', $uid, $_folder); |
| 3776 | 4471 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3777 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 4472 | + if (strpos( array2string($flags),'Deleted')!==false) |
|
| 4473 | + { |
|
| 4474 | + $undelete[] = $uid; |
|
| 4475 | + } |
|
| 3778 | 4476 | unset($flags); |
| 3779 | 4477 | } |
| 3780 | 4478 | foreach((array)$undelete as $key =>$uid) |
@@ -3786,7 +4484,10 @@ discard block |
||
| 3786 | 4484 | case "remove_immediately": |
| 3787 | 4485 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3788 | 4486 | $updateCache = true; |
| 3789 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 4487 | + if (is_null($_messageUID)) |
|
| 4488 | + { |
|
| 4489 | + $_messageUID='all'; |
|
| 4490 | + } |
|
| 3790 | 4491 | if (is_object($_messageUID)) |
| 3791 | 4492 | { |
| 3792 | 4493 | $this->flagMessages('delete', $_messageUID, $_folder); |
@@ -3803,7 +4504,8 @@ discard block |
||
| 3803 | 4504 | $this->icServer->expunge($_folder); |
| 3804 | 4505 | break; |
| 3805 | 4506 | } |
| 3806 | - if($oldMailbox != '') { |
|
| 4507 | + if($oldMailbox != '') |
|
| 4508 | + { |
|
| 3807 | 4509 | $this->icServer->openMailbox($oldMailbox); |
| 3808 | 4510 | } |
| 3809 | 4511 | |
@@ -3817,11 +4519,15 @@ discard block |
||
| 3817 | 4519 | * |
| 3818 | 4520 | * @return null/array flags |
| 3819 | 4521 | */ |
| 3820 | - function getFlags ($_messageUID) { |
|
| 4522 | + function getFlags ($_messageUID) |
|
| 4523 | + { |
|
| 3821 | 4524 | try |
| 3822 | 4525 | { |
| 3823 | 4526 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 3824 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4527 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4528 | + { |
|
| 4529 | + $_messageUID = (array)$_messageUID; |
|
| 4530 | + } |
|
| 3825 | 4531 | $uidsToFetch->add($_messageUID); |
| 3826 | 4532 | $_folderName = $this->icServer->getCurrentMailbox(); |
| 3827 | 4533 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -3829,8 +4535,10 @@ discard block |
||
| 3829 | 4535 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 3830 | 4536 | 'ids' => $uidsToFetch, |
| 3831 | 4537 | )); |
| 3832 | - if (is_object($headersNew)) { |
|
| 3833 | - foreach($headersNew->ids() as $id) { |
|
| 4538 | + if (is_object($headersNew)) |
|
| 4539 | + { |
|
| 4540 | + foreach($headersNew->ids() as $id) |
|
| 4541 | + { |
|
| 3834 | 4542 | $_headerObject = $headersNew->get($id); |
| 3835 | 4543 | $flags = $_headerObject->getFlags(); |
| 3836 | 4544 | } |
@@ -3855,10 +4563,16 @@ discard block |
||
| 3855 | 4563 | */ |
| 3856 | 4564 | function getNotifyFlags ($_messageUID, $flags=null) |
| 3857 | 4565 | { |
| 3858 | - if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
|
| 4566 | + if (self::$debug) |
|
| 4567 | + { |
|
| 4568 | + error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
|
| 4569 | + } |
|
| 3859 | 4570 | try |
| 3860 | 4571 | { |
| 3861 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 4572 | + if($flags===null) |
|
| 4573 | + { |
|
| 4574 | + $flags = $this->getFlags($_messageUID); |
|
| 4575 | + } |
|
| 3862 | 4576 | } |
| 3863 | 4577 | catch (\Exception $e) |
| 3864 | 4578 | { |
@@ -3866,10 +4580,14 @@ discard block |
||
| 3866 | 4580 | } |
| 3867 | 4581 | |
| 3868 | 4582 | if ( stripos( array2string($flags),'MDNSent')!==false) |
| 3869 | - return true; |
|
| 4583 | + { |
|
| 4584 | + return true; |
|
| 4585 | + } |
|
| 3870 | 4586 | |
| 3871 | 4587 | if ( stripos( array2string($flags),'MDNnotSent')!==false) |
| 3872 | - return false; |
|
| 4588 | + { |
|
| 4589 | + return false; |
|
| 4590 | + } |
|
| 3873 | 4591 | |
| 3874 | 4592 | return null; |
| 3875 | 4593 | } |
@@ -3890,7 +4608,10 @@ discard block |
||
| 3890 | 4608 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3891 | 4609 | if (empty($_messageUID)) |
| 3892 | 4610 | { |
| 3893 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4611 | + if (self::$debug) |
|
| 4612 | + { |
|
| 4613 | + error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4614 | + } |
|
| 3894 | 4615 | return false; |
| 3895 | 4616 | } |
| 3896 | 4617 | $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
@@ -3898,7 +4619,10 @@ discard block |
||
| 3898 | 4619 | if (is_array($_messageUID)&& count($_messageUID)>50) |
| 3899 | 4620 | { |
| 3900 | 4621 | $count = $this->getMailBoxCounters($folder,true); |
| 3901 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 4622 | + if ($count->messages == count($_messageUID)) |
|
| 4623 | + { |
|
| 4624 | + $_messageUID='all'; |
|
| 4625 | + } |
|
| 3902 | 4626 | } |
| 3903 | 4627 | |
| 3904 | 4628 | if ($_messageUID==='all') |
@@ -3907,7 +4631,10 @@ discard block |
||
| 3907 | 4631 | } |
| 3908 | 4632 | else |
| 3909 | 4633 | { |
| 3910 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4634 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4635 | + { |
|
| 4636 | + $_messageUID = (array)$_messageUID; |
|
| 4637 | + } |
|
| 3911 | 4638 | $messageUIDs = array_chunk($_messageUID,50,true); |
| 3912 | 4639 | } |
| 3913 | 4640 | try |
@@ -3923,7 +4650,8 @@ discard block |
||
| 3923 | 4650 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 3924 | 4651 | $uidsToModify->add($uids); |
| 3925 | 4652 | } |
| 3926 | - switch($_flag) { |
|
| 4653 | + switch($_flag) |
|
| 4654 | + { |
|
| 3927 | 4655 | case "delete": |
| 3928 | 4656 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 3929 | 4657 | break; |
@@ -4009,7 +4737,10 @@ discard block |
||
| 4009 | 4737 | { |
| 4010 | 4738 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4011 | 4739 | } |
| 4012 | - if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
|
| 4740 | + if ($folder instanceof Horde_Imap_Client_Mailbox) |
|
| 4741 | + { |
|
| 4742 | + $_folder = $folder->utf8; |
|
| 4743 | + } |
|
| 4013 | 4744 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4014 | 4745 | self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
| 4015 | 4746 | |
@@ -4038,7 +4769,10 @@ discard block |
||
| 4038 | 4769 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4039 | 4770 | if (empty($_messageUID)) |
| 4040 | 4771 | { |
| 4041 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4772 | + if (self::$debug) |
|
| 4773 | + { |
|
| 4774 | + error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4775 | + } |
|
| 4042 | 4776 | return false; |
| 4043 | 4777 | } |
| 4044 | 4778 | elseif ($_messageUID==='all') |
@@ -4050,7 +4784,10 @@ discard block |
||
| 4050 | 4784 | { |
| 4051 | 4785 | //error_log(__METHOD__." Message(s): ".implode(',',$_messageUID)); |
| 4052 | 4786 | $uidsToMove = new Horde_Imap_Client_Ids(); |
| 4053 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4787 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4788 | + { |
|
| 4789 | + $_messageUID = (array)$_messageUID; |
|
| 4790 | + } |
|
| 4054 | 4791 | $uidsToMove->add($_messageUID); |
| 4055 | 4792 | } |
| 4056 | 4793 | $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
@@ -4072,12 +4809,14 @@ discard block |
||
| 4072 | 4809 | |
| 4073 | 4810 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4074 | 4811 | |
| 4075 | - if (is_object($headersNew)) { |
|
| 4812 | + if (is_object($headersNew)) |
|
| 4813 | + { |
|
| 4076 | 4814 | $c=0; |
| 4077 | 4815 | $retUid = new Horde_Imap_Client_Ids(); |
| 4078 | 4816 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4079 | 4817 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4080 | - foreach($headersNew as &$_headerObject) { |
|
| 4818 | + foreach($headersNew as &$_headerObject) |
|
| 4819 | + { |
|
| 4081 | 4820 | $c++; |
| 4082 | 4821 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4083 | 4822 | $date = $_headerObject->getImapDate(); |
@@ -4161,7 +4900,11 @@ discard block |
||
| 4161 | 4900 | { |
| 4162 | 4901 | try { |
| 4163 | 4902 | $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
| 4164 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4903 | + if ($convert2usertime) |
|
| 4904 | + { |
|
| 4905 | + $date->setUser(); |
|
| 4906 | + } |
|
| 4907 | + // convert to user-time |
|
| 4165 | 4908 | $date2return = $date->format($format); |
| 4166 | 4909 | } |
| 4167 | 4910 | catch(\Exception $e) |
@@ -4193,9 +4936,15 @@ discard block |
||
| 4193 | 4936 | static function htmlentities($_string, $_charset=false) |
| 4194 | 4937 | { |
| 4195 | 4938 | //setting the charset (if not given) |
| 4196 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 4939 | + if ($_charset===false) |
|
| 4940 | + { |
|
| 4941 | + $_charset = self::$displayCharset; |
|
| 4942 | + } |
|
| 4197 | 4943 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4198 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4944 | + if (empty($string) && !empty($_string)) |
|
| 4945 | + { |
|
| 4946 | + $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4947 | + } |
|
| 4199 | 4948 | return $string; |
| 4200 | 4949 | } |
| 4201 | 4950 | |
@@ -4215,18 +4964,41 @@ discard block |
||
| 4215 | 4964 | $_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>'), |
| 4216 | 4965 | array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
| 4217 | 4966 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4218 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4219 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 4967 | + if (stripos($_html,'style')!==false) |
|
| 4968 | + { |
|
| 4969 | + Mail\Html::replaceTagsCompletley($_html,'style'); |
|
| 4970 | + } |
|
| 4971 | + // clean out empty or pagewide style definitions / left over tags |
|
| 4972 | + if (stripos($_html,'head')!==false) |
|
| 4973 | + { |
|
| 4974 | + Mail\Html::replaceTagsCompletley($_html,'head'); |
|
| 4975 | + } |
|
| 4976 | + // Strip out stuff in head |
|
| 4220 | 4977 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4221 | 4978 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4222 | 4979 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4223 | 4980 | |
| 4224 | - if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
|
| 4981 | + if (get_magic_quotes_gpc() === 1) |
|
| 4982 | + { |
|
| 4983 | + $_html = stripslashes($_html); |
|
| 4984 | + } |
|
| 4225 | 4985 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4226 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4227 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4228 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4229 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 4986 | + if (stripos($_html,'!doctype')!==false) |
|
| 4987 | + { |
|
| 4988 | + Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4989 | + } |
|
| 4990 | + if (stripos($_html,'?xml:namespace')!==false) |
|
| 4991 | + { |
|
| 4992 | + Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4993 | + } |
|
| 4994 | + if (stripos($_html,'?xml version')!==false) |
|
| 4995 | + { |
|
| 4996 | + Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4997 | + } |
|
| 4998 | + if (strpos($_html,'!CURSOR')!==false) |
|
| 4999 | + { |
|
| 5000 | + Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 5001 | + } |
|
| 4230 | 5002 | // htmLawed filter only the 'body' |
| 4231 | 5003 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4232 | 5004 | //if ($matches[2]) |
@@ -4265,8 +5037,10 @@ discard block |
||
| 4265 | 5037 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4266 | 5038 | $CharsetFound=false; |
| 4267 | 5039 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4268 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4269 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 5040 | + if(is_array($_mimePartObject->parameters)) |
|
| 5041 | + { |
|
| 5042 | + if(isset($_mimePartObject->parameters['CHARSET'])) |
|
| 5043 | + { |
|
| 4270 | 5044 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4271 | 5045 | $CharsetFound=true; |
| 4272 | 5046 | } |
@@ -4287,7 +5061,10 @@ discard block |
||
| 4287 | 5061 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4288 | 5062 | { |
| 4289 | 5063 | // decode the part |
| 4290 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 5064 | + if (self::$debug) |
|
| 5065 | + { |
|
| 5066 | + error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 5067 | + } |
|
| 4291 | 5068 | switch (strtoupper($_encoding)) |
| 4292 | 5069 | { |
| 4293 | 5070 | case 'BASE64': |
@@ -4327,13 +5104,19 @@ discard block |
||
| 4327 | 5104 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4328 | 5105 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4329 | 5106 | $partText = $partCalendar = $partHTML = null; |
| 4330 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 5107 | + if (self::$debug) |
|
| 5108 | + { |
|
| 5109 | + _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 5110 | + } |
|
| 4331 | 5111 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4332 | 5112 | $ignore_first_part = true; |
| 4333 | 5113 | foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
| 4334 | 5114 | { |
| 4335 | 5115 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4336 | - if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5116 | + if (self::$debug) |
|
| 5117 | + { |
|
| 5118 | + echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5119 | + } |
|
| 4337 | 5120 | |
| 4338 | 5121 | if ($ignore_first_part) |
| 4339 | 5122 | { |
@@ -4349,11 +5132,17 @@ discard block |
||
| 4349 | 5132 | switch($mimePart->getSubType()) |
| 4350 | 5133 | { |
| 4351 | 5134 | case 'plain': |
| 4352 | - if ($mimePart->getBytes() > 0) $partText = $mimePart; |
|
| 5135 | + if ($mimePart->getBytes() > 0) |
|
| 5136 | + { |
|
| 5137 | + $partText = $mimePart; |
|
| 5138 | + } |
|
| 4353 | 5139 | break; |
| 4354 | 5140 | |
| 4355 | 5141 | case 'html': |
| 4356 | - if ($mimePart->getBytes() > 0) $partHTML = $mimePart; |
|
| 5142 | + if ($mimePart->getBytes() > 0) |
|
| 5143 | + { |
|
| 5144 | + $partHTML = $mimePart; |
|
| 5145 | + } |
|
| 4357 | 5146 | break; |
| 4358 | 5147 | } |
| 4359 | 5148 | break; |
@@ -4366,7 +5155,10 @@ discard block |
||
| 4366 | 5155 | if (count($mimePart->getParts()) > 1) |
| 4367 | 5156 | { |
| 4368 | 5157 | // in a multipart alternative we treat the multipart/related as html part |
| 4369 | - if (self::$debug) error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts"); |
|
| 5158 | + if (self::$debug) |
|
| 5159 | + { |
|
| 5160 | + error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts"); |
|
| 5161 | + } |
|
| 4370 | 5162 | $partHTML = $mimePart; |
| 4371 | 5163 | break 3; // GET OUT OF LOOP, will be processed according to type |
| 4372 | 5164 | } |
@@ -4447,9 +5239,15 @@ discard block |
||
| 4447 | 5239 | */ |
| 4448 | 5240 | function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
| 4449 | 5241 | { |
| 4450 | - if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
|
| 5242 | + if (self::$debug) |
|
| 5243 | + { |
|
| 5244 | + echo __METHOD__."$_uid, $_htmlMode<br>"; |
|
| 5245 | + } |
|
| 4451 | 5246 | $bodyPart = array(); |
| 4452 | - if (self::$debug) _debug_array($_structure); |
|
| 5247 | + if (self::$debug) |
|
| 5248 | + { |
|
| 5249 | + _debug_array($_structure); |
|
| 5250 | + } |
|
| 4453 | 5251 | |
| 4454 | 5252 | $ignore_first_part = true; |
| 4455 | 5253 | //$skipParts = array(); |
@@ -4457,7 +5255,10 @@ discard block |
||
| 4457 | 5255 | foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
| 4458 | 5256 | { |
| 4459 | 5257 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4460 | - if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5258 | + if (self::$debug) |
|
| 5259 | + { |
|
| 5260 | + echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5261 | + } |
|
| 4461 | 5262 | if ($ignore_first_part) |
| 4462 | 5263 | { |
| 4463 | 5264 | $ignore_first_part = false; |
@@ -4475,7 +5276,10 @@ discard block |
||
| 4475 | 5276 | switch($part->getPrimaryType()) |
| 4476 | 5277 | { |
| 4477 | 5278 | case 'multipart': |
| 4478 | - if ($part->getDisposition() == 'attachment') continue; |
|
| 5279 | + if ($part->getDisposition() == 'attachment') |
|
| 5280 | + { |
|
| 5281 | + continue; |
|
| 5282 | + } |
|
| 4479 | 5283 | switch($part->getSubType()) |
| 4480 | 5284 | { |
| 4481 | 5285 | case 'alternative': |
@@ -4540,7 +5344,9 @@ discard block |
||
| 4540 | 5344 | if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
| 4541 | 5345 | { |
| 4542 | 5346 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4543 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 5347 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 5348 | + { |
|
| 5349 | +$skipParts[$sub_id] = $sub_type;} |
|
| 4544 | 5350 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4545 | 5351 | //break 2; |
| 4546 | 5352 | } |
@@ -4583,7 +5389,10 @@ discard block |
||
| 4583 | 5389 | */ |
| 4584 | 5390 | function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
| 4585 | 5391 | { |
| 4586 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 5392 | + if (self::$debug) |
|
| 5393 | + { |
|
| 5394 | + error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 5395 | + } |
|
| 4587 | 5396 | |
| 4588 | 5397 | if (empty($_folder)) |
| 4589 | 5398 | { |
@@ -4592,7 +5401,10 @@ discard block |
||
| 4592 | 5401 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4593 | 5402 | // querying contents of body part |
| 4594 | 5403 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 4595 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 5404 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 5405 | + { |
|
| 5406 | + $_uid = (array)$_uid; |
|
| 5407 | + } |
|
| 4596 | 5408 | $uidsToFetch->add($_uid); |
| 4597 | 5409 | |
| 4598 | 5410 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -4600,9 +5412,12 @@ discard block |
||
| 4600 | 5412 | 'peek' => $_preserveSeen, |
| 4601 | 5413 | 'decode' => true, // try decode on server, does NOT neccessary work |
| 4602 | 5414 | ); |
| 4603 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 5415 | + if ($_tryDecodingServerside===false) |
|
| 5416 | + { |
|
| 5417 | + // || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4604 | 5418 | { |
| 4605 | 5419 | $_tryDecodingServerside=false; |
| 5420 | + } |
|
| 4606 | 5421 | $fetchParams = array( |
| 4607 | 5422 | 'peek' => $_preserveSeen, |
| 4608 | 5423 | ); |
@@ -4644,7 +5459,10 @@ discard block |
||
| 4644 | 5459 | { |
| 4645 | 5460 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4646 | 5461 | $bodyPart = array(); |
| 4647 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 5462 | + if (self::$debug) |
|
| 5463 | + { |
|
| 5464 | + _debug_array(array($_structure,function_backtrace())); |
|
| 5465 | + } |
|
| 4648 | 5466 | |
| 4649 | 5467 | if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
| 4650 | 5468 | { |
@@ -4694,8 +5512,12 @@ discard block |
||
| 4694 | 5512 | */ |
| 4695 | 5513 | function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
| 4696 | 5514 | { |
| 4697 | - if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
|
| 4698 | - if($_htmlOptions != '') { |
|
| 5515 | + if (self::$debug) |
|
| 5516 | + { |
|
| 5517 | + echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
|
| 5518 | + } |
|
| 5519 | + if($_htmlOptions != '') |
|
| 5520 | + { |
|
| 4699 | 5521 | $this->htmlOptions = $_htmlOptions; |
| 4700 | 5522 | } |
| 4701 | 5523 | if (empty($_folder)) |
@@ -4784,7 +5606,9 @@ discard block |
||
| 4784 | 5606 | default: |
| 4785 | 5607 | $bodyPart = array($this->getTextPart($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
| 4786 | 5608 | } |
| 4787 | - } else { |
|
| 5609 | + } |
|
| 5610 | + else |
|
| 5611 | + { |
|
| 4788 | 5612 | // what if the structure->disposition is attachment ,... |
| 4789 | 5613 | } |
| 4790 | 5614 | return self::normalizeBodyParts($bodyPart); |
@@ -4795,13 +5619,18 @@ discard block |
||
| 4795 | 5619 | { |
| 4796 | 5620 | case 'rfc822': |
| 4797 | 5621 | $newStructure = $_structure->getParts(); |
| 4798 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 5622 | + if (self::$debug) |
|
| 5623 | + { |
|
| 5624 | +echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4799 | 5625 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4800 | 5626 | } |
| 4801 | 5627 | break; |
| 4802 | 5628 | |
| 4803 | 5629 | default: |
| 4804 | - if (self::$debug) _debug_array($_structure); |
|
| 5630 | + if (self::$debug) |
|
| 5631 | + { |
|
| 5632 | + _debug_array($_structure); |
|
| 5633 | + } |
|
| 4805 | 5634 | return array( |
| 4806 | 5635 | array( |
| 4807 | 5636 | 'body' => lang('The mimeparser can not parse this message.').$_structure->getType(), |
@@ -4825,9 +5654,12 @@ discard block |
||
| 4825 | 5654 | { |
| 4826 | 5655 | foreach($_bodyParts as $singleBodyPart) |
| 4827 | 5656 | { |
| 4828 | - if (!isset($singleBodyPart['body'])) { |
|
| 5657 | + if (!isset($singleBodyPart['body'])) |
|
| 5658 | + { |
|
| 4829 | 5659 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4830 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 5660 | + foreach ((array)$buff as $val) |
|
| 5661 | + { |
|
| 5662 | +$body2return[] = $val;} |
|
| 4831 | 5663 | continue; |
| 4832 | 5664 | } |
| 4833 | 5665 | $body2return[] = $singleBodyPart; |
@@ -4853,13 +5685,20 @@ discard block |
||
| 4853 | 5685 | $message=''; |
| 4854 | 5686 | for($i=0; $i<count($bodyParts); $i++) |
| 4855 | 5687 | { |
| 4856 | - if (!isset($bodyParts[$i]['body'])) { |
|
| 5688 | + if (!isset($bodyParts[$i]['body'])) |
|
| 5689 | + { |
|
| 4857 | 5690 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4858 | 5691 | $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
| 4859 | 5692 | continue; |
| 4860 | 5693 | } |
| 4861 | - if (isset($bodyParts[$i]['error'])) continue; |
|
| 4862 | - if (empty($bodyParts[$i]['body'])) continue; |
|
| 5694 | + if (isset($bodyParts[$i]['error'])) |
|
| 5695 | + { |
|
| 5696 | + continue; |
|
| 5697 | + } |
|
| 5698 | + if (empty($bodyParts[$i]['body'])) |
|
| 5699 | + { |
|
| 5700 | + continue; |
|
| 5701 | + } |
|
| 4863 | 5702 | // some characterreplacements, as they fail to translate |
| 4864 | 5703 | $sar = array( |
| 4865 | 5704 | '@(\x84|\x93|\x94)@', |
@@ -4886,13 +5725,17 @@ discard block |
||
| 4886 | 5725 | $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
| 4887 | 5726 | } |
| 4888 | 5727 | |
| 4889 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 5728 | + if ($bodyParts[$i]['charSet']===false) |
|
| 5729 | + { |
|
| 5730 | + $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 5731 | + } |
|
| 4890 | 5732 | // add line breaks to $bodyParts |
| 4891 | 5733 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4892 | 5734 | $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 4893 | 5735 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4894 | 5736 | $mailClass->activeMimeType = 'text/plain'; |
| 4895 | - if ($bodyParts[$i]['mimeType'] == 'text/html') { |
|
| 5737 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 5738 | + { |
|
| 4896 | 5739 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 4897 | 5740 | if (!$preserveHTML) |
| 4898 | 5741 | { |
@@ -4938,15 +5781,28 @@ discard block |
||
| 4938 | 5781 | // as we switched off HTMLaweds tidy functionality |
| 4939 | 5782 | $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
| 4940 | 5783 | $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
| 4941 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5784 | + if ($hasOther && $preserveHTML) |
|
| 5785 | + { |
|
| 5786 | + $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5787 | + } |
|
| 4942 | 5788 | $alreadyHtmlLawed=true; |
| 4943 | 5789 | } |
| 4944 | 5790 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 4945 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5791 | + if ($preserveHTML==false) |
|
| 5792 | + { |
|
| 5793 | + $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5794 | + } |
|
| 4946 | 5795 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 4947 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5796 | + if ($preserveHTML==false) |
|
| 5797 | + { |
|
| 5798 | + $newBody = nl2br($newBody); |
|
| 5799 | + } |
|
| 5800 | + // we need this, as htmLawed removes \r\n |
|
| 4948 | 5801 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 4949 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5802 | + if ($preserveHTML==false) |
|
| 5803 | + { |
|
| 5804 | + $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5805 | + } |
|
| 4950 | 5806 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 4951 | 5807 | } |
| 4952 | 5808 | $message .= $newBody; |
@@ -4983,12 +5839,12 @@ discard block |
||
| 4983 | 5839 | substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
| 4984 | 5840 | ) |
| 4985 | 5841 | ) |
| 4986 | - ) |
|
| 4987 | - { |
|
| 5842 | + ) { |
|
| 4988 | 5843 | $s=explode(" ", $line); |
| 4989 | 5844 | $line = ""; |
| 4990 | 5845 | $linecnt = 0; |
| 4991 | - foreach ($s as &$v) { |
|
| 5846 | + foreach ($s as &$v) |
|
| 5847 | + { |
|
| 4992 | 5848 | $cnt = strlen($v); |
| 4993 | 5849 | // only break long words within the wordboundaries, |
| 4994 | 5850 | // but it may destroy links, so we check for href and dont do it if we find one |
@@ -4998,14 +5854,20 @@ discard block |
||
| 4998 | 5854 | $v=wordwrap($v, $allowedLength, $cut, true); |
| 4999 | 5855 | } |
| 5000 | 5856 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5001 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5857 | + if ($linecnt+$cnt > $allowedLength) |
|
| 5858 | + { |
|
| 5002 | 5859 | $v=$cut.$v; |
| 5003 | 5860 | #$linecnt = 0; |
| 5004 | 5861 | $linecnt =strlen($v)-strlen($cut); |
| 5005 | - } else { |
|
| 5862 | + } |
|
| 5863 | + else |
|
| 5864 | + { |
|
| 5006 | 5865 | $linecnt += $cnt; |
| 5007 | 5866 | } |
| 5008 | - if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
|
| 5867 | + if (strlen($v)) |
|
| 5868 | + { |
|
| 5869 | + $line .= (strlen($line) ? " " : "").$v; |
|
| 5870 | + } |
|
| 5009 | 5871 | } |
| 5010 | 5872 | } |
| 5011 | 5873 | $newStr .= $line . "\n"; |
@@ -5026,11 +5888,18 @@ discard block |
||
| 5026 | 5888 | function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
| 5027 | 5889 | { |
| 5028 | 5890 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5029 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5891 | + if (empty($_folder)) |
|
| 5892 | + { |
|
| 5893 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5894 | + } |
|
| 5030 | 5895 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5031 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 5896 | + if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) |
|
| 5897 | + { |
|
| 5032 | 5898 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5033 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 5899 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 5900 | + { |
|
| 5901 | + $_uid = (array)$_uid; |
|
| 5902 | + } |
|
| 5034 | 5903 | $uidsToFetch->add($_uid); |
| 5035 | 5904 | |
| 5036 | 5905 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5040,8 +5909,10 @@ discard block |
||
| 5040 | 5909 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5041 | 5910 | 'ids' => $uidsToFetch, |
| 5042 | 5911 | )); |
| 5043 | - if (is_object($headersNew)) { |
|
| 5044 | - foreach($headersNew as &$_headerObject) { |
|
| 5912 | + if (is_object($headersNew)) |
|
| 5913 | + { |
|
| 5914 | + foreach($headersNew as &$_headerObject) |
|
| 5915 | + { |
|
| 5045 | 5916 | $env = $_headerObject->getEnvelope(); |
| 5046 | 5917 | //_debug_array($envFields->singleFields()); |
| 5047 | 5918 | $singleFields = $envFields->singleFields(); |
@@ -5058,7 +5929,10 @@ discard block |
||
| 5058 | 5929 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5059 | 5930 | $envelope[$v]=$env->$v->addresses; |
| 5060 | 5931 | $address = array(); |
| 5061 | - if (!is_array($envelope[$v])) break; |
|
| 5932 | + if (!is_array($envelope[$v])) |
|
| 5933 | + { |
|
| 5934 | + break; |
|
| 5935 | + } |
|
| 5062 | 5936 | foreach ($envelope[$v] as $k => $ad) |
| 5063 | 5937 | { |
| 5064 | 5938 | if (stripos($ad,'@')===false) |
@@ -5095,7 +5969,9 @@ discard block |
||
| 5095 | 5969 | } |
| 5096 | 5970 | } |
| 5097 | 5971 | return $envelope; |
| 5098 | - } else { |
|
| 5972 | + } |
|
| 5973 | + else |
|
| 5974 | + { |
|
| 5099 | 5975 | |
| 5100 | 5976 | $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
| 5101 | 5977 | |
@@ -5106,19 +5982,43 @@ discard block |
||
| 5106 | 5982 | 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
| 5107 | 5983 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5108 | 5984 | ); |
| 5109 | - if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
|
| 5110 | - if (isset($headers['REFERENCES'])) $newData['REFERENCES'] = $headers['REFERENCES']; |
|
| 5111 | - if (isset($headers['THREAD-TOPIC'])) $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC']; |
|
| 5112 | - if (isset($headers['THREAD-INDEX'])) $newData['THREAD-INDEX'] = $headers['THREAD-INDEX']; |
|
| 5113 | - if (isset($headers['LIST-ID'])) $newData['LIST-ID'] = $headers['LIST-ID']; |
|
| 5114 | - if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
|
| 5985 | + if (isset($headers['IN-REPLY-TO'])) |
|
| 5986 | + { |
|
| 5987 | + $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
|
| 5988 | + } |
|
| 5989 | + if (isset($headers['REFERENCES'])) |
|
| 5990 | + { |
|
| 5991 | + $newData['REFERENCES'] = $headers['REFERENCES']; |
|
| 5992 | + } |
|
| 5993 | + if (isset($headers['THREAD-TOPIC'])) |
|
| 5994 | + { |
|
| 5995 | + $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC']; |
|
| 5996 | + } |
|
| 5997 | + if (isset($headers['THREAD-INDEX'])) |
|
| 5998 | + { |
|
| 5999 | + $newData['THREAD-INDEX'] = $headers['THREAD-INDEX']; |
|
| 6000 | + } |
|
| 6001 | + if (isset($headers['LIST-ID'])) |
|
| 6002 | + { |
|
| 6003 | + $newData['LIST-ID'] = $headers['LIST-ID']; |
|
| 6004 | + } |
|
| 6005 | + if (isset($headers['SIZE'])) |
|
| 6006 | + { |
|
| 6007 | + $newData['SIZE'] = $headers['SIZE']; |
|
| 6008 | + } |
|
| 5115 | 6009 | //_debug_array($newData); |
| 5116 | 6010 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5117 | - foreach($recepientList as $recepientType) { |
|
| 5118 | - if(isset($headers[$recepientType])) { |
|
| 5119 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 6011 | + foreach($recepientList as $recepientType) |
|
| 6012 | + { |
|
| 6013 | + if(isset($headers[$recepientType])) |
|
| 6014 | + { |
|
| 6015 | + if ($decode) |
|
| 6016 | + { |
|
| 6017 | + $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 6018 | + } |
|
| 5120 | 6019 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5121 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 6020 | + foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) |
|
| 6021 | + { |
|
| 5122 | 6022 | $addressData = array( |
| 5123 | 6023 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5124 | 6024 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5126,17 +6026,25 @@ discard block |
||
| 5126 | 6026 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5127 | 6027 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5128 | 6028 | ); |
| 5129 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 6029 | + if($addressData['PERSONAL_NAME'] != 'NIL') |
|
| 6030 | + { |
|
| 5130 | 6031 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5131 | - } else { |
|
| 6032 | + } |
|
| 6033 | + else |
|
| 6034 | + { |
|
| 5132 | 6035 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5133 | 6036 | } |
| 5134 | 6037 | $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
| 5135 | 6038 | } |
| 5136 | - } else { |
|
| 5137 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 6039 | + } |
|
| 6040 | + else |
|
| 6041 | + { |
|
| 6042 | + if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') |
|
| 6043 | + { |
|
| 5138 | 6044 | $newData[$recepientType] = $newData['FROM']; |
| 5139 | - } else { |
|
| 6045 | + } |
|
| 6046 | + else |
|
| 6047 | + { |
|
| 5140 | 6048 | $newData[$recepientType] = array(); |
| 5141 | 6049 | } |
| 5142 | 6050 | } |
@@ -5159,9 +6067,15 @@ discard block |
||
| 5159 | 6067 | function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
| 5160 | 6068 | { |
| 5161 | 6069 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5162 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6070 | + if (empty($_folder)) |
|
| 6071 | + { |
|
| 6072 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6073 | + } |
|
| 5163 | 6074 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5164 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6075 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6076 | + { |
|
| 6077 | + $_uid = (array)$_uid; |
|
| 6078 | + } |
|
| 5165 | 6079 | $uidsToFetch->add($_uid); |
| 5166 | 6080 | |
| 5167 | 6081 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5179,7 +6093,8 @@ discard block |
||
| 5179 | 6093 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5180 | 6094 | 'ids' => $uidsToFetch, |
| 5181 | 6095 | )); |
| 5182 | - if (is_object($headersNew)) { |
|
| 6096 | + if (is_object($headersNew)) |
|
| 6097 | + { |
|
| 5183 | 6098 | foreach($headersNew as $_fetchObject) |
| 5184 | 6099 | { |
| 5185 | 6100 | $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
@@ -5201,11 +6116,17 @@ discard block |
||
| 5201 | 6116 | } |
| 5202 | 6117 | if ($decode === 'object') |
| 5203 | 6118 | { |
| 5204 | - if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
|
| 6119 | + if (is_object($headers)) |
|
| 6120 | + { |
|
| 6121 | + $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
|
| 6122 | + } |
|
| 5205 | 6123 | return $headers; |
| 5206 | 6124 | } |
| 5207 | 6125 | $retValue = is_object($headers) ? $headers->toArray():array(); |
| 5208 | - if ($size) $retValue['size'] = $size; |
|
| 6126 | + if ($size) |
|
| 6127 | + { |
|
| 6128 | + $retValue['size'] = $size; |
|
| 6129 | + } |
|
| 5209 | 6130 | } |
| 5210 | 6131 | $retValue = array_change_key_case($retValue,CASE_UPPER); |
| 5211 | 6132 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
@@ -5237,10 +6158,16 @@ discard block |
||
| 5237 | 6158 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5238 | 6159 | { |
| 5239 | 6160 | static $rawHeaders; |
| 5240 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6161 | + if (empty($_folder)) |
|
| 6162 | + { |
|
| 6163 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6164 | + } |
|
| 5241 | 6165 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5242 | 6166 | |
| 5243 | - 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); |
|
| 6167 | + if (is_null($rawHeaders)||!is_array($rawHeaders)) |
|
| 6168 | + { |
|
| 6169 | + $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 6170 | + } |
|
| 5244 | 6171 | if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
| 5245 | 6172 | { |
| 5246 | 6173 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
@@ -5248,7 +6175,10 @@ discard block |
||
| 5248 | 6175 | } |
| 5249 | 6176 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5250 | 6177 | $uid = $_uid; |
| 5251 | - if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid; |
|
| 6178 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6179 | + { |
|
| 6180 | + $uid = (array)$_uid; |
|
| 6181 | + } |
|
| 5252 | 6182 | $uidsToFetch->add($uid); |
| 5253 | 6183 | |
| 5254 | 6184 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5264,8 +6194,10 @@ discard block |
||
| 5264 | 6194 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5265 | 6195 | 'ids' => $uidsToFetch, |
| 5266 | 6196 | )); |
| 5267 | - if (is_object($headersNew)) { |
|
| 5268 | - foreach($headersNew as &$_headerObject) { |
|
| 6197 | + if (is_object($headersNew)) |
|
| 6198 | + { |
|
| 6199 | + foreach($headersNew as &$_headerObject) |
|
| 6200 | + { |
|
| 5269 | 6201 | $retValue = $_headerObject->getHeaderText(); |
| 5270 | 6202 | if ($_partID != '') |
| 5271 | 6203 | { |
@@ -5293,22 +6225,33 @@ discard block |
||
| 5293 | 6225 | static function &getStyles($_bodyParts) |
| 5294 | 6226 | { |
| 5295 | 6227 | $style = ''; |
| 5296 | - if (empty($_bodyParts)) return ""; |
|
| 5297 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5298 | - if (!isset($singleBodyPart['body'])) { |
|
| 6228 | + if (empty($_bodyParts)) |
|
| 6229 | + { |
|
| 6230 | + return ""; |
|
| 6231 | + } |
|
| 6232 | + foreach((array)$_bodyParts as $singleBodyPart) |
|
| 6233 | + { |
|
| 6234 | + if (!isset($singleBodyPart['body'])) |
|
| 6235 | + { |
|
| 5299 | 6236 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5300 | 6237 | $style .= $singleBodyPart['body']; |
| 5301 | 6238 | continue; |
| 5302 | 6239 | } |
| 5303 | 6240 | |
| 5304 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 6241 | + if ($singleBodyPart['charSet']===false) |
|
| 6242 | + { |
|
| 6243 | + $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 6244 | + } |
|
| 5305 | 6245 | $singleBodyPart['body'] = Translation::convert( |
| 5306 | 6246 | $singleBodyPart['body'], |
| 5307 | 6247 | strtolower($singleBodyPart['charSet']) |
| 5308 | 6248 | ); |
| 5309 | 6249 | $ct = 0; |
| 5310 | 6250 | $newStyle=array(); |
| 5311 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 6251 | + if (stripos($singleBodyPart['body'],'<style')!==false) |
|
| 6252 | + { |
|
| 6253 | + $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 6254 | + } |
|
| 5312 | 6255 | if ($ct>0) |
| 5313 | 6256 | { |
| 5314 | 6257 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
@@ -5340,7 +6283,11 @@ discard block |
||
| 5340 | 6283 | // CSS Security |
| 5341 | 6284 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5342 | 6285 | $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
| 5343 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 6286 | + if (stripos($css,'script')!==false) |
|
| 6287 | + { |
|
| 6288 | + Mail\Html::replaceTagsCompletley($css,'script'); |
|
| 6289 | + } |
|
| 6290 | + // Strip out script that may be included |
|
| 5344 | 6291 | // 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 |
| 5345 | 6292 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5346 | 6293 | $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
@@ -5361,8 +6308,14 @@ discard block |
||
| 5361 | 6308 | { |
| 5362 | 6309 | //TODO: caching einbauen static! |
| 5363 | 6310 | static $rawBody; |
| 5364 | - if (is_null($rawBody)) $rawBody = array(); |
|
| 5365 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6311 | + if (is_null($rawBody)) |
|
| 6312 | + { |
|
| 6313 | + $rawBody = array(); |
|
| 6314 | + } |
|
| 6315 | + if (empty($_folder)) |
|
| 6316 | + { |
|
| 6317 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6318 | + } |
|
| 5366 | 6319 | if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
| 5367 | 6320 | { |
| 5368 | 6321 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
@@ -5371,7 +6324,10 @@ discard block |
||
| 5371 | 6324 | |
| 5372 | 6325 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5373 | 6326 | $uid = $_uid; |
| 5374 | - if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid; |
|
| 6327 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6328 | + { |
|
| 6329 | + $uid = (array)$_uid; |
|
| 6330 | + } |
|
| 5375 | 6331 | $uidsToFetch->add($uid); |
| 5376 | 6332 | |
| 5377 | 6333 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5384,8 +6340,10 @@ discard block |
||
| 5384 | 6340 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5385 | 6341 | 'ids' => $uidsToFetch, |
| 5386 | 6342 | )); |
| 5387 | - if (is_object($headersNew)) { |
|
| 5388 | - foreach($headersNew as &$_headerObject) { |
|
| 6343 | + if (is_object($headersNew)) |
|
| 6344 | + { |
|
| 6345 | + foreach($headersNew as &$_headerObject) |
|
| 6346 | + { |
|
| 5389 | 6347 | $body = $_headerObject->getFullMsg(); |
| 5390 | 6348 | if ($_partID != '') |
| 5391 | 6349 | { |
@@ -5418,14 +6376,20 @@ discard block |
||
| 5418 | 6376 | */ |
| 5419 | 6377 | function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
| 5420 | 6378 | { |
| 5421 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 6379 | + if (self::$debug) |
|
| 6380 | + { |
|
| 6381 | + error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 6382 | + } |
|
| 5422 | 6383 | |
| 5423 | 6384 | if (empty($_folder)) |
| 5424 | 6385 | { |
| 5425 | 6386 | $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
| 5426 | 6387 | } |
| 5427 | 6388 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5428 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6389 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6390 | + { |
|
| 6391 | + $_uid = (array)$_uid; |
|
| 6392 | + } |
|
| 5429 | 6393 | $uidsToFetch->add($_uid); |
| 5430 | 6394 | try |
| 5431 | 6395 | { |
@@ -5434,7 +6398,10 @@ discard block |
||
| 5434 | 6398 | // $fquery->envelope(); |
| 5435 | 6399 | // $fquery->size(); |
| 5436 | 6400 | $_fquery->structure(); |
| 5437 | - if ($_partID) $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen)); |
|
| 6401 | + if ($_partID) |
|
| 6402 | + { |
|
| 6403 | + $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen)); |
|
| 6404 | + } |
|
| 5438 | 6405 | |
| 5439 | 6406 | $mail = $this->icServer->fetch($_folder, $_fquery, array( |
| 5440 | 6407 | 'ids' => $uidsToFetch, |
@@ -5465,16 +6432,28 @@ discard block |
||
| 5465 | 6432 | */ |
| 5466 | 6433 | function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
| 5467 | 6434 | { |
| 5468 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5469 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6435 | + if (self::$debug) |
|
| 6436 | + { |
|
| 6437 | + error_log( __METHOD__.":$_uid, $_partID"); |
|
| 6438 | + } |
|
| 6439 | + if (empty($_folder)) |
|
| 6440 | + { |
|
| 6441 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6442 | + } |
|
| 5470 | 6443 | $attachments = array(); |
| 5471 | 6444 | if (!isset($_structure)) |
| 5472 | 6445 | { |
| 5473 | 6446 | $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
| 5474 | 6447 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5475 | 6448 | } |
| 5476 | - if (!$_structure || !$_structure->contentTypeMap()) return array(); |
|
| 5477 | - if (!empty($_partID)) $_structure = $_structure->getPart($_partID); |
|
| 6449 | + if (!$_structure || !$_structure->contentTypeMap()) |
|
| 6450 | + { |
|
| 6451 | + return array(); |
|
| 6452 | + } |
|
| 6453 | + if (!empty($_partID)) |
|
| 6454 | + { |
|
| 6455 | + $_structure = $_structure->getPart($_partID); |
|
| 6456 | + } |
|
| 5478 | 6457 | $skipParts = array(); |
| 5479 | 6458 | $tnefParts = array(); |
| 5480 | 6459 | $skip = 0; |
@@ -5503,7 +6482,13 @@ discard block |
||
| 5503 | 6482 | if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
| 5504 | 6483 | { |
| 5505 | 6484 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5506 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 6485 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 6486 | + { |
|
| 6487 | +if ($sub_id != $mime_id) |
|
| 6488 | + { |
|
| 6489 | + $skipParts[$sub_id] = $sub_type; |
|
| 6490 | + } |
|
| 6491 | + } |
|
| 5507 | 6492 | } |
| 5508 | 6493 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5509 | 6494 | { |
@@ -5514,7 +6499,10 @@ discard block |
||
| 5514 | 6499 | $partDisposition='attachment'; |
| 5515 | 6500 | } |
| 5516 | 6501 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5517 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 6502 | + if (array_key_exists($mime_id,$skipParts)) |
|
| 6503 | + { |
|
| 6504 | + continue; |
|
| 6505 | + } |
|
| 5518 | 6506 | |
| 5519 | 6507 | if ($partDisposition == 'attachment' || |
| 5520 | 6508 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
@@ -5525,23 +6513,41 @@ discard block |
||
| 5525 | 6513 | { |
| 5526 | 6514 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5527 | 6515 | // we attempt to fetch "ourselves" |
| 5528 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 6516 | + if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') |
|
| 6517 | + { |
|
| 6518 | + continue; |
|
| 6519 | + } |
|
| 5529 | 6520 | $attachment = $part->getAllDispositionParameters(); |
| 5530 | 6521 | $attachment['disposition'] = $part->getDisposition(); |
| 5531 | 6522 | $attachment['mimeType'] = $mime_type; |
| 5532 | 6523 | $attachment['uid'] = $_uid; |
| 5533 | 6524 | $attachment['partID'] = $mime_id; |
| 5534 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 6525 | + if (!isset($attachment['name'])||empty($attachment['name'])) |
|
| 6526 | + { |
|
| 6527 | + $attachment['name'] = $part->getName(); |
|
| 6528 | + } |
|
| 5535 | 6529 | if ($fetchTextCalendar) |
| 5536 | 6530 | { |
| 5537 | 6531 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
| 5538 | 6532 | $method = $part->getContentTypeParameter('method'); |
| 5539 | - if ($method) $attachment['method'] = $method; |
|
| 5540 | - if (!isset($attachment['name'])) $attachment['name'] = 'event.ics'; |
|
| 6533 | + if ($method) |
|
| 6534 | + { |
|
| 6535 | + $attachment['method'] = $method; |
|
| 6536 | + } |
|
| 6537 | + if (!isset($attachment['name'])) |
|
| 6538 | + { |
|
| 6539 | + $attachment['name'] = 'event.ics'; |
|
| 6540 | + } |
|
| 5541 | 6541 | } |
| 5542 | 6542 | $attachment['size'] = $part->getBytes(); |
| 5543 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5544 | - 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); |
|
| 6543 | + if (($cid = $part->getContentId())) |
|
| 6544 | + { |
|
| 6545 | + $attachment['cid'] = $cid; |
|
| 6546 | + } |
|
| 6547 | + if (empty($attachment['name'])) |
|
| 6548 | + { |
|
| 6549 | + $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 6550 | + } |
|
| 5545 | 6551 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5546 | 6552 | //typical winmail.dat attachment is |
| 5547 | 6553 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
@@ -5577,14 +6583,26 @@ discard block |
||
| 5577 | 6583 | $attachment['uid'] = $tnp['uid']; |
| 5578 | 6584 | $attachment['partID'] = $tnp['partID']; |
| 5579 | 6585 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5580 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 6586 | + if (!isset($attachment['name'])||empty($attachment['name'])) |
|
| 6587 | + { |
|
| 6588 | + $attachment['name'] = $part->getName(); |
|
| 6589 | + } |
|
| 5581 | 6590 | $attachment['size'] = $part->getBytes(); |
| 5582 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5583 | - 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']); |
|
| 6591 | + if (($cid = $part->getContentId())) |
|
| 6592 | + { |
|
| 6593 | + $attachment['cid'] = $cid; |
|
| 6594 | + } |
|
| 6595 | + if (empty($attachment['name'])) |
|
| 6596 | + { |
|
| 6597 | + $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6598 | + } |
|
| 5584 | 6599 | $attachments[] = $attachment; |
| 5585 | 6600 | } |
| 5586 | 6601 | } |
| 5587 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 6602 | + if ($tnefResolved===false) |
|
| 6603 | + { |
|
| 6604 | + $attachments[]=$tnp; |
|
| 6605 | + } |
|
| 5588 | 6606 | } |
| 5589 | 6607 | } |
| 5590 | 6608 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5688,8 +6706,14 @@ discard block |
||
| 5688 | 6706 | |
| 5689 | 6707 | $attachment = $part->getAllDispositionParameters(); |
| 5690 | 6708 | $attachment['mimeType'] = $part->getType(); |
| 5691 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5692 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 6709 | + if (!isset($attachment['filename'])||empty($attachment['filename'])) |
|
| 6710 | + { |
|
| 6711 | + $attachment['filename'] = $part->getName(); |
|
| 6712 | + } |
|
| 6713 | + if (($cid = $part->getContentId())) |
|
| 6714 | + { |
|
| 6715 | + $attachment['cid'] = $cid; |
|
| 6716 | + } |
|
| 5693 | 6717 | if (empty($attachment['filename'])) |
| 5694 | 6718 | { |
| 5695 | 6719 | $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
@@ -5701,7 +6725,10 @@ discard block |
||
| 5701 | 6725 | $attachments[$_uid.'@'.$_partID.'@'.$mime_id] = $attachment; |
| 5702 | 6726 | } |
| 5703 | 6727 | } |
| 5704 | - if (!is_array($attachments)) return false; |
|
| 6728 | + if (!is_array($attachments)) |
|
| 6729 | + { |
|
| 6730 | + return false; |
|
| 6731 | + } |
|
| 5705 | 6732 | return $attachments; |
| 5706 | 6733 | } |
| 5707 | 6734 | |
@@ -5720,10 +6747,16 @@ discard block |
||
| 5720 | 6747 | function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
| 5721 | 6748 | { |
| 5722 | 6749 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5723 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6750 | + if (!isset($_folder)) |
|
| 6751 | + { |
|
| 6752 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6753 | + } |
|
| 5724 | 6754 | |
| 5725 | 6755 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5726 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6756 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6757 | + { |
|
| 6758 | + $_uid = (array)$_uid; |
|
| 6759 | + } |
|
| 5727 | 6760 | $uidsToFetch->add($_uid); |
| 5728 | 6761 | |
| 5729 | 6762 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5732,8 +6765,10 @@ discard block |
||
| 5732 | 6765 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5733 | 6766 | 'ids' => $uidsToFetch, |
| 5734 | 6767 | )); |
| 5735 | - if (is_object($headersNew)) { |
|
| 5736 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 6768 | + if (is_object($headersNew)) |
|
| 6769 | + { |
|
| 6770 | + foreach($headersNew as $id=>$_headerObject) |
|
| 6771 | + { |
|
| 5737 | 6772 | $body = $_headerObject->getFullMsg(); |
| 5738 | 6773 | if ($_partID != '') |
| 5739 | 6774 | { |
@@ -5747,7 +6782,10 @@ discard block |
||
| 5747 | 6782 | } |
| 5748 | 6783 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5749 | 6784 | // itself is only triggered to fetch attachments |
| 5750 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 6785 | + if (empty($partDisposition)) |
|
| 6786 | + { |
|
| 6787 | + $partDisposition='attachment'; |
|
| 6788 | + } |
|
| 5751 | 6789 | if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
| 5752 | 6790 | { |
| 5753 | 6791 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
@@ -5756,13 +6794,19 @@ discard block |
||
| 5756 | 6794 | $charset = $part->getContentTypeParameter('charset'); |
| 5757 | 6795 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5758 | 6796 | $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
| 5759 | - if ($_returnPart) return $part; |
|
| 6797 | + if ($_returnPart) |
|
| 6798 | + { |
|
| 6799 | + return $part; |
|
| 6800 | + } |
|
| 5760 | 6801 | } |
| 5761 | 6802 | } |
| 5762 | 6803 | } |
| 5763 | 6804 | } |
| 5764 | 6805 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5765 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 6806 | + if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) |
|
| 6807 | + { |
|
| 6808 | + $filename = trim($filename).'.'.$ext; |
|
| 6809 | + } |
|
| 5766 | 6810 | if (!$part) |
| 5767 | 6811 | { |
| 5768 | 6812 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5778,7 +6822,10 @@ discard block |
||
| 5778 | 6822 | ); |
| 5779 | 6823 | |
| 5780 | 6824 | // try guessing the mimetype, if we get the application/octet-stream |
| 5781 | - if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
|
| 6825 | + if (strtolower($attachmentData['type']) == 'application/octet-stream') |
|
| 6826 | + { |
|
| 6827 | + $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
|
| 6828 | + } |
|
| 5782 | 6829 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5783 | 6830 | if ( $filename == 'winmail.dat' && $_winmail_nr) |
| 5784 | 6831 | { |
@@ -5801,9 +6848,18 @@ discard block |
||
| 5801 | 6848 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5802 | 6849 | { |
| 5803 | 6850 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5804 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5805 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5806 | - 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']); |
|
| 6851 | + if (!isset($attachment['filename'])||empty($attachment['filename'])) |
|
| 6852 | + { |
|
| 6853 | + $attachment['filename'] = $part->getName(); |
|
| 6854 | + } |
|
| 6855 | + if (($cid = $part->getContentId())) |
|
| 6856 | + { |
|
| 6857 | + $attachment['cid'] = $cid; |
|
| 6858 | + } |
|
| 6859 | + if (empty($attachment['filename'])) |
|
| 6860 | + { |
|
| 6861 | + $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6862 | + } |
|
| 5807 | 6863 | $wmattach = $attachment; |
| 5808 | 6864 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5809 | 6865 | |
@@ -5813,7 +6869,10 @@ discard block |
||
| 5813 | 6869 | if ($tnefResolved) |
| 5814 | 6870 | { |
| 5815 | 6871 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5816 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 6872 | + if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) |
|
| 6873 | + { |
|
| 6874 | + $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 6875 | + } |
|
| 5817 | 6876 | $attachmentData = array( |
| 5818 | 6877 | 'type' => $wmattach['mimeType'], |
| 5819 | 6878 | 'filename' => $wmattach['filename'], |
@@ -5843,7 +6902,10 @@ discard block |
||
| 5843 | 6902 | static $uid=null, $part=null, $structure=null; |
| 5844 | 6903 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5845 | 6904 | |
| 5846 | - if(empty($_cid)) return false; |
|
| 6905 | + if(empty($_cid)) |
|
| 6906 | + { |
|
| 6907 | + return false; |
|
| 6908 | + } |
|
| 5847 | 6909 | |
| 5848 | 6910 | if ($_uid != $uid || $_part != $part) |
| 5849 | 6911 | { |
@@ -5868,13 +6930,19 @@ discard block |
||
| 5868 | 6930 | $attachment = $part; |
| 5869 | 6931 | } |
| 5870 | 6932 | // everything else we only consider after we checked all |
| 5871 | - if (!isset($attachment)) $attachment = $part; |
|
| 6933 | + if (!isset($attachment)) |
|
| 6934 | + { |
|
| 6935 | + $attachment = $part; |
|
| 6936 | + } |
|
| 5872 | 6937 | // do we want content fetched, can be done later, if not needed |
| 5873 | 6938 | if (isset($_stream)) |
| 5874 | 6939 | { |
| 5875 | 6940 | $this->fetchPartContents($_uid, $attachment, $_stream); |
| 5876 | 6941 | } |
| 5877 | - if (isset($attachment)) break; |
|
| 6942 | + if (isset($attachment)) |
|
| 6943 | + { |
|
| 6944 | + break; |
|
| 6945 | + } |
|
| 5878 | 6946 | } |
| 5879 | 6947 | } |
| 5880 | 6948 | // set name as filename, if not set |
@@ -5905,10 +6973,17 @@ discard block |
||
| 5905 | 6973 | */ |
| 5906 | 6974 | public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
| 5907 | 6975 | { |
| 5908 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 6976 | + if (is_null($part)) |
|
| 6977 | + { |
|
| 6978 | + return null; |
|
| 6979 | + } |
|
| 6980 | + //new Horde_Mime_Part; |
|
| 5909 | 6981 | $encoding = null; |
| 5910 | 6982 | $fetchAsBinary = true; |
| 5911 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 6983 | + if ($_mimetype && strtolower($_mimetype)=='message/rfc822') |
|
| 6984 | + { |
|
| 6985 | + $fetchAsBinary = false; |
|
| 6986 | + } |
|
| 5912 | 6987 | // we need to set content on structure to decode transfer encoding |
| 5913 | 6988 | $part->setContents( |
| 5914 | 6989 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
@@ -5945,7 +7020,10 @@ discard block |
||
| 5945 | 7020 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 5946 | 7021 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
| 5947 | 7022 | // for flags at all) |
| 5948 | - if (empty($_flags)) $_flags = '\\Recent'; |
|
| 7023 | + if (empty($_flags)) |
|
| 7024 | + { |
|
| 7025 | + $_flags = '\\Recent'; |
|
| 7026 | + } |
|
| 5949 | 7027 | //if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags); |
| 5950 | 7028 | //if (!is_array($_flags)) $_flags = (array) $_flags; |
| 5951 | 7029 | try |
@@ -5962,18 +7040,27 @@ discard block |
||
| 5962 | 7040 | } |
| 5963 | 7041 | catch (\Exception $e) |
| 5964 | 7042 | { |
| 5965 | - if (self::$debug) error_log("Could not append Message: ".$e->getMessage()); |
|
| 7043 | + if (self::$debug) |
|
| 7044 | + { |
|
| 7045 | + error_log("Could not append Message: ".$e->getMessage()); |
|
| 7046 | + } |
|
| 5966 | 7047 | throw new Exception\WrongUserinput(lang("Could not append Message:").' '.$e->getMessage().': '.$e->details); |
| 5967 | 7048 | //return false; |
| 5968 | 7049 | } |
| 5969 | 7050 | //error_log(__METHOD__.' ('.__LINE__.') '.' appended UID:'.$messageid); |
| 5970 | 7051 | //$messageid = true; // for debug reasons only |
| 5971 | - if ($messageid === true || empty($messageid)) // try to figure out the message uid |
|
| 7052 | + if ($messageid === true || empty($messageid)) |
|
| 7053 | + { |
|
| 7054 | + // try to figure out the message uid |
|
| 5972 | 7055 | { |
| 5973 | 7056 | $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
| 7057 | + } |
|
| 5974 | 7058 | if ($list) |
| 5975 | 7059 | { |
| 5976 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
|
| 7060 | + if (self::$debug) |
|
| 7061 | + { |
|
| 7062 | + error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
|
| 7063 | + } |
|
| 5977 | 7064 | $messageid = $list['header'][0]['uid']; |
| 5978 | 7065 | } |
| 5979 | 7066 | } |
@@ -6014,7 +7101,10 @@ discard block |
||
| 6014 | 7101 | { |
| 6015 | 7102 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6016 | 7103 | $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
| 6017 | - if (empty($headers)) return false; |
|
| 7104 | + if (empty($headers)) |
|
| 7105 | + { |
|
| 7106 | + return false; |
|
| 7107 | + } |
|
| 6018 | 7108 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6019 | 7109 | $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
| 6020 | 7110 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
@@ -6032,15 +7122,30 @@ discard block |
||
| 6032 | 7122 | //error_log(array2string($bodyParts)); |
| 6033 | 7123 | $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
| 6034 | 7124 | |
| 6035 | - if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
|
| 6036 | - elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
|
| 6037 | - elseif (isset($headers['SENDER'])) $mailaddress = $headers['SENDER']; |
|
| 6038 | - if (isset($headers['CC'])) $mailaddress .= ','.$headers['CC']; |
|
| 7125 | + if ($mailClass->isSentFolder($mailbox)) |
|
| 7126 | + { |
|
| 7127 | + $mailaddress = $headers['TO']; |
|
| 7128 | + } |
|
| 7129 | + elseif (isset($headers['FROM'])) |
|
| 7130 | + { |
|
| 7131 | + $mailaddress = $headers['FROM']; |
|
| 7132 | + } |
|
| 7133 | + elseif (isset($headers['SENDER'])) |
|
| 7134 | + { |
|
| 7135 | + $mailaddress = $headers['SENDER']; |
|
| 7136 | + } |
|
| 7137 | + if (isset($headers['CC'])) |
|
| 7138 | + { |
|
| 7139 | + $mailaddress .= ','.$headers['CC']; |
|
| 7140 | + } |
|
| 6039 | 7141 | //_debug_array(array($headers,$mailaddress)); |
| 6040 | 7142 | $subject = $headers['SUBJECT']; |
| 6041 | 7143 | |
| 6042 | 7144 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6043 | - if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
|
| 7145 | + if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') |
|
| 7146 | + { |
|
| 7147 | + $message = '<pre>'.$message.'</pre>'; |
|
| 7148 | + } |
|
| 6044 | 7149 | $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
| 6045 | 7150 | $message = $headdata.$message; |
| 6046 | 7151 | //echo __METHOD__.'<br>'; |
@@ -6091,7 +7196,8 @@ discard block |
||
| 6091 | 7196 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6092 | 7197 | } |
| 6093 | 7198 | // no attempt to convert, if we dont know about the charset |
| 6094 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 7199 | + if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) |
|
| 7200 | + { |
|
| 6095 | 7201 | // we do not try guessing the charset, if it is not set |
| 6096 | 7202 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6097 | 7203 | Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
@@ -6112,7 +7218,10 @@ discard block |
||
| 6112 | 7218 | unset($attachments[$num]['attachment']); |
| 6113 | 7219 | } |
| 6114 | 7220 | } |
| 6115 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 7221 | + if (is_array($attachedMessages)) |
|
| 7222 | + { |
|
| 7223 | + $attachments = array_merge($attachments,$attachedMessages); |
|
| 7224 | + } |
|
| 6116 | 7225 | } |
| 6117 | 7226 | return array( |
| 6118 | 7227 | 'mailaddress'=>$mailaddress, |
@@ -6134,10 +7243,17 @@ discard block |
||
| 6134 | 7243 | { |
| 6135 | 7244 | $c = 0; |
| 6136 | 7245 | // use the standardIdentity |
| 6137 | - foreach($_identities as $key => $acc) { |
|
| 6138 | - if ($c==0) $identity = $acc; |
|
| 7246 | + foreach($_identities as $key => $acc) |
|
| 7247 | + { |
|
| 7248 | + if ($c==0) |
|
| 7249 | + { |
|
| 7250 | + $identity = $acc; |
|
| 7251 | + } |
|
| 6139 | 7252 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6140 | - if ($key==$_profile_id) $identity = $acc; |
|
| 7253 | + if ($key==$_profile_id) |
|
| 7254 | + { |
|
| 7255 | + $identity = $acc; |
|
| 7256 | + } |
|
| 6141 | 7257 | $c++; |
| 6142 | 7258 | } |
| 6143 | 7259 | return $identity; |
@@ -6153,20 +7269,53 @@ discard block |
||
| 6153 | 7269 | { |
| 6154 | 7270 | $headdata = null; |
| 6155 | 7271 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6156 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6157 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6158 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6159 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6160 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6161 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6162 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6163 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6164 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 7272 | + if ($header['SUBJECT']) |
|
| 7273 | + { |
|
| 7274 | + $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 7275 | + } |
|
| 7276 | + if ($header['FROM']) |
|
| 7277 | + { |
|
| 7278 | + $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7279 | + } |
|
| 7280 | + if ($header['SENDER']) |
|
| 7281 | + { |
|
| 7282 | + $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7283 | + } |
|
| 7284 | + if ($header['TO']) |
|
| 7285 | + { |
|
| 7286 | + $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7287 | + } |
|
| 7288 | + if ($header['CC']) |
|
| 7289 | + { |
|
| 7290 | + $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7291 | + } |
|
| 7292 | + if ($header['BCC']) |
|
| 7293 | + { |
|
| 7294 | + $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7295 | + } |
|
| 7296 | + if ($header['DATE']) |
|
| 7297 | + { |
|
| 7298 | + $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 7299 | + } |
|
| 7300 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') |
|
| 7301 | + { |
|
| 7302 | + $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 7303 | + } |
|
| 7304 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') |
|
| 7305 | + { |
|
| 7306 | + $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 7307 | + } |
|
| 6165 | 7308 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6166 | 7309 | if (!empty($headdata)) |
| 6167 | 7310 | { |
| 6168 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6169 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 7311 | + if (!empty($headline) && $headline != 'SUPPRESS') |
|
| 7312 | + { |
|
| 7313 | + $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 7314 | + } |
|
| 7315 | + if (empty($headline)) |
|
| 7316 | + { |
|
| 7317 | + $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 7318 | + } |
|
| 6170 | 7319 | $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
| 6171 | 7320 | } |
| 6172 | 7321 | else |
@@ -6200,12 +7349,15 @@ discard block |
||
| 6200 | 7349 | $returnAddr =''; |
| 6201 | 7350 | if (is_array($rfcAddressArray)) |
| 6202 | 7351 | { |
| 6203 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 7352 | + foreach((array)$rfcAddressArray as $addressData) |
|
| 7353 | + { |
|
| 6204 | 7354 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6205 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 7355 | + if($addressData['MAILBOX_NAME'] == 'NIL') |
|
| 7356 | + { |
|
| 6206 | 7357 | continue; |
| 6207 | 7358 | } |
| 6208 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 7359 | + if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') |
|
| 7360 | + { |
|
| 6209 | 7361 | continue; |
| 6210 | 7362 | } |
| 6211 | 7363 | if ($addressData['RFC822_EMAIL']) |
@@ -6219,7 +7371,10 @@ discard block |
||
| 6219 | 7371 | } |
| 6220 | 7372 | $addressObject = $addressObjectA[0]; |
| 6221 | 7373 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject)); |
| 6222 | - if (!$addressObject->valid) continue; |
|
| 7374 | + if (!$addressObject->valid) |
|
| 7375 | + { |
|
| 7376 | + continue; |
|
| 7377 | + } |
|
| 6223 | 7378 | //$mb =(string)$addressObject->mailbox; |
| 6224 | 7379 | //$h = (string)$addressObject->host; |
| 6225 | 7380 | //$p = (string)$addressObject->personal; |
@@ -6236,7 +7391,10 @@ discard block |
||
| 6236 | 7391 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6237 | 7392 | $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
| 6238 | 7393 | $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
| 6239 | - if (is_string($rfcAddressArray)) return $rfcAddressArray; |
|
| 7394 | + if (is_string($rfcAddressArray)) |
|
| 7395 | + { |
|
| 7396 | + return $rfcAddressArray; |
|
| 7397 | + } |
|
| 6240 | 7398 | } |
| 6241 | 7399 | return $returnAddr; |
| 6242 | 7400 | } |
@@ -6253,10 +7411,19 @@ discard block |
||
| 6253 | 7411 | { |
| 6254 | 7412 | $mergeobj = new Contacts\Merge(); |
| 6255 | 7413 | |
| 6256 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 7414 | + if (empty($mimetype)) |
|
| 7415 | + { |
|
| 7416 | + $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 7417 | + } |
|
| 6257 | 7418 | $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
| 6258 | - if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
|
| 6259 | - if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
|
| 7419 | + if (empty($rv) && !empty($content) && !empty($err)) |
|
| 7420 | + { |
|
| 7421 | + $rv = $content; |
|
| 7422 | + } |
|
| 7423 | + if (!empty($err) && !empty($content) && !empty($ids)) |
|
| 7424 | + { |
|
| 7425 | + error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
|
| 7426 | + } |
|
| 6260 | 7427 | return $rv; |
| 6261 | 7428 | } |
| 6262 | 7429 | |
@@ -6293,13 +7460,15 @@ discard block |
||
| 6293 | 7460 | settype($bytes, 'integer'); |
| 6294 | 7461 | $bytes /= 10; |
| 6295 | 7462 | } |
| 6296 | - else |
|
| 6297 | - settype($bytes, 'integer'); |
|
| 7463 | + else { |
|
| 7464 | + settype($bytes, 'integer'); |
|
| 7465 | + } |
|
| 6298 | 7466 | |
| 6299 | 7467 | return $bytes . ' ' . $type ; |
| 6300 | 7468 | } |
| 6301 | 7469 | |
| 6302 | - static function detect_qp(&$sting) { |
|
| 7470 | + static function detect_qp(&$sting) |
|
| 7471 | + { |
|
| 6303 | 7472 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6304 | 7473 | return preg_match("$needle",$string); |
| 6305 | 7474 | } |
@@ -6316,9 +7485,15 @@ discard block |
||
| 6316 | 7485 | */ |
| 6317 | 7486 | static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
| 6318 | 7487 | { |
| 6319 | - if (is_null($_endtime)) $_endtime = microtime(true); |
|
| 7488 | + if (is_null($_endtime)) |
|
| 7489 | + { |
|
| 7490 | + $_endtime = microtime(true); |
|
| 7491 | + } |
|
| 6320 | 7492 | $usagetime = microtime(true) - $_starttime; |
| 6321 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 7493 | + if (self::$debugTimes) |
|
| 7494 | + { |
|
| 7495 | + error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 7496 | + } |
|
| 6322 | 7497 | } |
| 6323 | 7498 | |
| 6324 | 7499 | /** |
@@ -6333,7 +7508,10 @@ discard block |
||
| 6333 | 7508 | */ |
| 6334 | 7509 | static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
| 6335 | 7510 | { |
| 6336 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 7511 | + if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') |
|
| 7512 | + { |
|
| 7513 | + return $_formData['file']; |
|
| 7514 | + } |
|
| 6337 | 7515 | |
| 6338 | 7516 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6339 | 7517 | $importfailed = $tmpFileName = false; |
@@ -6382,8 +7560,15 @@ discard block |
||
| 6382 | 7560 | { |
| 6383 | 7561 | $buff = explode('.',$_formData['name']); |
| 6384 | 7562 | $suffix = ''; |
| 6385 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 6386 | - if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
|
| 7563 | + if (is_array($buff)) |
|
| 7564 | + { |
|
| 7565 | + $suffix = array_pop($buff); |
|
| 7566 | + } |
|
| 7567 | + // take the last extension to check with ext2mime |
|
| 7568 | + if (!empty($suffix)) |
|
| 7569 | + { |
|
| 7570 | + $sfxMimeType = MimeMagic::ext2mime($suffix); |
|
| 7571 | + } |
|
| 6387 | 7572 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6388 | 7573 | (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
| 6389 | 7574 | { |
@@ -6431,7 +7616,9 @@ discard block |
||
| 6431 | 7616 | { |
| 6432 | 7617 | rename($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); |
| 6433 | 7618 | } |
| 6434 | - } else { |
|
| 7619 | + } |
|
| 7620 | + else |
|
| 7621 | + { |
|
| 6435 | 7622 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6436 | 7623 | $importfailed = true; |
| 6437 | 7624 | $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
@@ -6477,21 +7664,32 @@ discard block |
||
| 6477 | 7664 | if (substr($url, 0, 5) !== 'data:') |
| 6478 | 7665 | { |
| 6479 | 7666 | $filename = basename($url); |
| 6480 | - if (($directory = dirname($url)) == '.') $directory = ''; |
|
| 7667 | + if (($directory = dirname($url)) == '.') |
|
| 7668 | + { |
|
| 7669 | + $directory = ''; |
|
| 7670 | + } |
|
| 6481 | 7671 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6482 | 7672 | $mimeType = MimeMagic::ext2mime($ext); |
| 6483 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 7673 | + if ( strlen($directory) > 1 && substr($directory,-1) != '/') |
|
| 7674 | + { |
|
| 7675 | +$directory .= '/'; } |
|
| 6484 | 7676 | $myUrl = $directory.$filename; |
| 6485 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 7677 | + if ($myUrl[0]=='/') |
|
| 7678 | + { |
|
| 7679 | + // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6486 | 7680 | { |
| 6487 | 7681 | $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
| 6488 | 7682 | } |
| 7683 | + } |
|
| 6489 | 7684 | // use vfs instead of url containing webdav.php |
| 6490 | 7685 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6491 | 7686 | // webdav.php urls as vfs |
| 6492 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 7687 | + if (strpos($myUrl,'/webdav.php') !== false) |
|
| 7688 | + { |
|
| 7689 | + // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6493 | 7690 | { |
| 6494 | 7691 | Vfs::load_wrapper('vfs'); |
| 7692 | + } |
|
| 6495 | 7693 | list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
| 6496 | 7694 | $basedir = 'vfs://default'; |
| 6497 | 7695 | $needTempFile = false; |
@@ -6520,8 +7718,13 @@ discard block |
||
| 6520 | 7718 | } |
| 6521 | 7719 | } |
| 6522 | 7720 | |
| 6523 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6524 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 7721 | + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') |
|
| 7722 | + { |
|
| 7723 | +$basedir .= '/'; } |
|
| 7724 | + if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") |
|
| 7725 | + { |
|
| 7726 | + $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 7727 | + } |
|
| 6525 | 7728 | } |
| 6526 | 7729 | if (substr($url,0,strlen('data:'))=='data:') |
| 6527 | 7730 | { |
@@ -6622,7 +7825,10 @@ discard block |
||
| 6622 | 7825 | $_folder = $this->getSentFolder(); |
| 6623 | 7826 | } |
| 6624 | 7827 | $delimiter = $this->getHierarchyDelimiter(); |
| 6625 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 7828 | + if($_folder=='INBOX'.$delimiter) |
|
| 7829 | + { |
|
| 7830 | + $_folder='INBOX'; |
|
| 7831 | + } |
|
| 6626 | 7832 | if ($importfailed === false) |
| 6627 | 7833 | { |
| 6628 | 7834 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6651,7 +7857,9 @@ discard block |
||
| 6651 | 7857 | //error_log(__METHOD__.' ('.__LINE__.') '.' Id To Merge:'.$val); |
| 6652 | 7858 | if (/*$GLOBALS['egw_info']['flags']['currentapp'] == 'addressbook' &&*/ |
| 6653 | 7859 | count($SendAndMergeTocontacts) > 1 && $val && |
| 6654 | - (is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) // do the merge |
|
| 7860 | + (is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) |
|
| 7861 | + { |
|
| 7862 | + // do the merge |
|
| 6655 | 7863 | { |
| 6656 | 7864 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6657 | 7865 | |
@@ -6660,6 +7868,7 @@ discard block |
||
| 6660 | 7868 | { |
| 6661 | 7869 | //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)); |
| 6662 | 7870 | $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
| 7871 | + } |
|
| 6663 | 7872 | $mailObject->addAddress($merged,'',$type); |
| 6664 | 7873 | if($type == 'to') |
| 6665 | 7874 | { |
@@ -6691,9 +7900,15 @@ discard block |
||
| 6691 | 7900 | $mailObject->clearCustomHeaders(); |
| 6692 | 7901 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6693 | 7902 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6694 | - 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)); |
|
| 7903 | + if($text_body) |
|
| 7904 | + { |
|
| 7905 | + $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 7906 | + } |
|
| 6695 | 7907 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6696 | - 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)); |
|
| 7908 | + if($html_body) |
|
| 7909 | + { |
|
| 7910 | + $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 7911 | + } |
|
| 6697 | 7912 | |
| 6698 | 7913 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6699 | 7914 | // set a higher timeout for big messages |
@@ -6708,9 +7923,12 @@ discard block |
||
| 6708 | 7923 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
| 6709 | 7924 | } |
| 6710 | 7925 | } |
| 6711 | - elseif (!$k) // 1. entry, further entries will fail for apps other then addressbook |
|
| 7926 | + elseif (!$k) |
|
| 7927 | + { |
|
| 7928 | + // 1. entry, further entries will fail for apps other then addressbook |
|
| 6712 | 7929 | { |
| 6713 | 7930 | $openAsDraft = true; |
| 7931 | + } |
|
| 6714 | 7932 | $mailObject->removeHeader('Message-ID'); |
| 6715 | 7933 | $mailObject->removeHeader('Date'); |
| 6716 | 7934 | $mailObject->clearCustomHeaders(); |
@@ -6725,9 +7943,12 @@ discard block |
||
| 6725 | 7943 | |
| 6726 | 7944 | // No addresses from placeholders? Treat it as just a contact ID |
| 6727 | 7945 | if (count($mailObject->getAddresses('to',true)) == 0 && |
| 6728 | - is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
|
| 7946 | + is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) |
|
| 7947 | + { |
|
| 7948 | + // do the merge |
|
| 6729 | 7949 | { |
| 6730 | 7950 | $contact = $bo_merge->contacts->read($val); |
| 7951 | + } |
|
| 6731 | 7952 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6732 | 7953 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6733 | 7954 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
@@ -6738,9 +7959,15 @@ discard block |
||
| 6738 | 7959 | } |
| 6739 | 7960 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6740 | 7961 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6741 | - 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)); |
|
| 7962 | + if (!empty($Body)) |
|
| 7963 | + { |
|
| 7964 | + $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 7965 | + } |
|
| 6742 | 7966 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6743 | - 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)); |
|
| 7967 | + if (!empty($AltBody)) |
|
| 7968 | + { |
|
| 7969 | + $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 7970 | + } |
|
| 6744 | 7971 | $_folder = $this->getDraftFolder(); |
| 6745 | 7972 | } |
| 6746 | 7973 | if ($sendOK || $openAsDraft) |
@@ -6748,11 +7975,15 @@ discard block |
||
| 6748 | 7975 | if ($this->folderExists($_folder,true)) |
| 6749 | 7976 | { |
| 6750 | 7977 | if($this->isSentFolder($_folder)) |
| 6751 | - { |
|
| 7978 | + { |
|
| 6752 | 7979 | $flags = '\\Seen'; |
| 6753 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 7980 | + } |
|
| 7981 | + elseif($this->isDraftFolder($_folder)) |
|
| 7982 | + { |
|
| 6754 | 7983 | $flags = '\\Draft'; |
| 6755 | - } else { |
|
| 7984 | + } |
|
| 7985 | + else |
|
| 7986 | + { |
|
| 6756 | 7987 | $flags = ''; |
| 6757 | 7988 | } |
| 6758 | 7989 | $savefailed = false; |
@@ -6786,7 +8017,10 @@ discard block |
||
| 6786 | 8017 | } |
| 6787 | 8018 | else |
| 6788 | 8019 | { |
| 6789 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 8020 | + if (!$openComposeWindow) |
|
| 8021 | + { |
|
| 8022 | + $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 8023 | + } |
|
| 6790 | 8024 | } |
| 6791 | 8025 | } |
| 6792 | 8026 | if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
@@ -6834,7 +8068,10 @@ discard block |
||
| 6834 | 8068 | $tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmpFileName); |
| 6835 | 8069 | break; |
| 6836 | 8070 | } |
| 6837 | - if (!isset($message)) $message = fopen($tmpFileName, 'r'); |
|
| 8071 | + if (!isset($message)) |
|
| 8072 | + { |
|
| 8073 | + $message = fopen($tmpFileName, 'r'); |
|
| 8074 | + } |
|
| 6838 | 8075 | |
| 6839 | 8076 | if (!$message) |
| 6840 | 8077 | { |
@@ -6865,7 +8102,10 @@ discard block |
||
| 6865 | 8102 | (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
| 6866 | 8103 | |
| 6867 | 8104 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6868 | - if ($length===false) $length = strlen($start); |
|
| 8105 | + if ($length===false) |
|
| 8106 | + { |
|
| 8107 | + $length = strlen($start); |
|
| 8108 | + } |
|
| 6869 | 8109 | $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
| 6870 | 8110 | |
| 6871 | 8111 | foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
@@ -6894,7 +8134,10 @@ discard block |
||
| 6894 | 8134 | } |
| 6895 | 8135 | else |
| 6896 | 8136 | { |
| 6897 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 8137 | + if (($type = gettype($message)) == 'object') |
|
| 8138 | + { |
|
| 8139 | + $type = get_class ($message); |
|
| 8140 | + } |
|
| 6898 | 8141 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 6899 | 8142 | } |
| 6900 | 8143 | } |
@@ -6918,7 +8161,9 @@ discard block |
||
| 6918 | 8161 | $matches = array(); |
| 6919 | 8162 | preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
| 6920 | 8163 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 6921 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 8164 | + foreach ($matches[0] as &$match) |
|
| 8165 | + { |
|
| 8166 | +$match = trim($match,', ');} |
|
| 6922 | 8167 | $addresses = implode(',',$matches[0]); |
| 6923 | 8168 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 6924 | 8169 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
@@ -6949,7 +8194,10 @@ discard block |
||
| 6949 | 8194 | } |
| 6950 | 8195 | else |
| 6951 | 8196 | { |
| 6952 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 8197 | + if ($previousFailed && $remember) |
|
| 8198 | + { |
|
| 8199 | + $adr->personal = $remember. ' ' . $adr->personal; |
|
| 8200 | + } |
|
| 6953 | 8201 | $remember = ''; |
| 6954 | 8202 | $previousFailed=false; |
| 6955 | 8203 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
@@ -6971,7 +8219,10 @@ discard block |
||
| 6971 | 8219 | { |
| 6972 | 8220 | $acc = Mail\Account::read($this->profileID); |
| 6973 | 8221 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
| 6974 | - if (self::$debug) error_log(__METHOD__.__LINE__.array2string($identity)); |
|
| 8222 | + if (self::$debug) |
|
| 8223 | + { |
|
| 8224 | + error_log(__METHOD__.__LINE__.array2string($identity)); |
|
| 8225 | + } |
|
| 6975 | 8226 | $headers = $this->getMessageHeader($uid, '', 'object', true, $_folder); |
| 6976 | 8227 | |
| 6977 | 8228 | $mdn = new Horde_Mime_Mdn($headers); |