fix "a ton" of PHP Warning: Undefined array key or variable in mail code

This commit is contained in:
ralf 2022-04-26 18:46:23 +02:00
parent fcf195cf47
commit 917a833f89
8 changed files with 126 additions and 126 deletions

View File

@ -203,7 +203,7 @@ class Mail
public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null)
{ {
//$_restoreSession=false; //$_restoreSession=false;
if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; if (!isset($_reuseCache)) $_reuseCache = $_restoreSession;
//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()); //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());
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject));
self::$profileDefunct = Cache::getCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),5*1); self::$profileDefunct = Cache::getCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),5*1);
@ -295,7 +295,7 @@ class Mail
self::$instances[$_profileID]->profileID = $_profileID; self::$instances[$_profileID]->profileID = $_profileID;
if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna;
//if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID); //if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID);
if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); if (!isset(self::$mailConfig)) self::$mailConfig = Config::read('mail');
return self::$instances[$_profileID]; return self::$instances[$_profileID];
} }
@ -406,7 +406,7 @@ class Mail
*/ */
private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null)
{ {
if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; if (!isset($_reuseCache)) $_reuseCache = $_restoreSession;
if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset;
// not nummeric, we assume we only want an empty class object // not nummeric, we assume we only want an empty class object
if (!is_numeric($_profileID)) return; if (!is_numeric($_profileID)) return;
@ -444,7 +444,7 @@ class Mail
$_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId;
} }
if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); if (!isset(self::$mailConfig)) self::$mailConfig = Config::read('mail');
} }
/** /**
@ -483,7 +483,7 @@ class Mail
{ {
$this->sessionData = array(); $this->sessionData = array();
self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
if (is_array(self::$activeFolderCache[$this->profileID])) if (!empty(self::$activeFolderCache[$this->profileID]))
{ {
foreach (self::$activeFolderCache[$this->profileID] as $key => $value) foreach (self::$activeFolderCache[$this->profileID] as $key => $value)
{ {
@ -536,7 +536,7 @@ class Mail
*/ */
static function unsetCachedObjects($_profileID=null) static function unsetCachedObjects($_profileID=null)
{ {
if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); if (!isset($_profileID)) $_profileID = Mail\Account::get_default_acc_id();
if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id'];
//error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace());
if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false)))
@ -599,7 +599,7 @@ class Mail
static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null)
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id));
if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
if (is_array($_ImapServerId)) if (is_array($_ImapServerId))
{ {
// called via hook // called via hook
@ -607,7 +607,7 @@ class Mail
unset($_ImapServerId); unset($_ImapServerId);
$_ImapServerId = null; $_ImapServerId = null;
} }
if (is_null($_ImapServerId)) if (!isset($_ImapServerId))
{ {
$isConError = array(); $isConError = array();
$waitOnFailure = array(); $waitOnFailure = array();
@ -638,10 +638,10 @@ class Mail
static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) static function resetFolderObjectCache($_ImapServerId=null,$account_id=null)
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace());
if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
// on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId
// or treat it as not given. we try that path // or treat it as not given. we try that path
if (is_null($_ImapServerId)||is_array($_ImapServerId)) if (!isset($_ImapServerId)||is_array($_ImapServerId))
{ {
$folders2return = array(); $folders2return = array();
$folderInfo = array(); $folderInfo = array();
@ -812,7 +812,7 @@ class Mail
$rememberFirst=$selectedFound=null; $rememberFirst=$selectedFound=null;
foreach ($allAccountData as $tmpkey => $icServers) foreach ($allAccountData as $tmpkey => $icServers)
{ {
if (is_null($rememberFirst)) $rememberFirst = $tmpkey; if (!isset($rememberFirst)) $rememberFirst = $tmpkey;
if ($tmpkey == $selectedID) $selectedFound=true; if ($tmpkey == $selectedID) $selectedFound=true;
//error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host));
$host = $icServers->acc_imap_host; $host = $icServers->acc_imap_host;
@ -834,7 +834,7 @@ class Mail
static function generateIdentityString($identity, $fullString=true) static function generateIdentityString($identity, $fullString=true)
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity));
//if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); //if (!isset(self::$mailConfig)) self::$mailConfig = Config::read('mail');
// not set? -> use default, means full display of all available data // not set? -> use default, means full display of all available data
//if (!isset(self::$mailConfig['how2displayIdentities'])) self::$mailConfig['how2displayIdentities']=''; //if (!isset(self::$mailConfig['how2displayIdentities'])) self::$mailConfig['how2displayIdentities']='';
$how2displayIdentities = ''; $how2displayIdentities = '';
@ -1013,7 +1013,7 @@ class Mail
$foldersNameSpace = array(); $foldersNameSpace = array();
$delimiter = $this->getHierarchyDelimiter(); $delimiter = $this->getHierarchyDelimiter();
// TODO: cache by $this->icServer->ImapServerId // TODO: cache by $this->icServer->ImapServerId
if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); if (!isset($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray();
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace));
if (is_array($nameSpace)) { if (is_array($nameSpace)) {
foreach($nameSpace as $type => $singleNameSpaceArray) foreach($nameSpace as $type => $singleNameSpaceArray)
@ -1073,7 +1073,7 @@ class Mail
function getHierarchyDelimiter($_useCache=true) function getHierarchyDelimiter($_useCache=true)
{ {
static $HierarchyDelimiter = null; static $HierarchyDelimiter = null;
if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); if (!isset($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]);
if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId]))
{ {
@ -1108,7 +1108,7 @@ class Mail
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected);
static $_specialUseFolders = null; static $_specialUseFolders = null;
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); if (!isset($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5);
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash));
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent));
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft));
@ -1213,7 +1213,7 @@ class Mail
//error_log(__METHOD__.' ('.__LINE__.') '.$_folderName.' '.array2string(array_keys($folderInfoCache))); //error_log(__METHOD__.' ('.__LINE__.') '.$_folderName.' '.array2string(array_keys($folderInfoCache)));
// does the folder exist??? // does the folder exist???
if (is_null($folderInfoCache) || !isset($folderInfoCache[$_folderName])) if (!isset($folderInfoCache) || !isset($folderInfoCache[$_folderName]))
{ {
try try
{ {
@ -1290,7 +1290,7 @@ class Mail
static $subscribedFolders = null; static $subscribedFolders = null;
static $nameSpace = null; static $nameSpace = null;
static $prefix = null; static $prefix = null;
if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); if (!isset($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces();
if (!empty($nameSpace[$this->profileID])) if (!empty($nameSpace[$this->profileID]))
{ {
$nsNoPersonal=array(); $nsNoPersonal=array();
@ -1300,9 +1300,9 @@ class Mail
} }
$nameSpace[$this->profileID]=$nsNoPersonal; $nameSpace[$this->profileID]=$nsNoPersonal;
} }
if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); if (!isset($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName);
if ($fetchSubscribedInfo && is_null($subscribedFolders) || empty($subscribedFolders[$this->profileID])) if ($fetchSubscribedInfo && !isset($subscribedFolders) || empty($subscribedFolders[$this->profileID]))
{ {
$subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes();
} }
@ -1614,7 +1614,7 @@ class Mail
} }
else else
{ {
$address[] = (!is_null($remember)?$headerObject[$key][$remember].' ':'').$ad; $address[] = (isset($remember)?$headerObject[$key][$remember].' ':'').$ad;
$remember=null; $remember=null;
} }
*/ */
@ -1760,11 +1760,11 @@ class Mail
$retValue['header'][$sortOrder[$uid]]['smimeType'] = Mail\Smime::getSmimeType($mailStructureObject); $retValue['header'][$sortOrder[$uid]]['smimeType'] = Mail\Smime::getSmimeType($mailStructureObject);
//error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]]));
if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO'];
if (is_array($headerObject['FLAGS'])) { if (!empty($headerObject['FLAGS'])) {
$retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject));
} }
//error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from')));
if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { if(!empty($headerObject['FROM'][0])) {
$retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true);
if (count($headerObject['FROM'])>1) if (count($headerObject['FROM'])>1)
{ {
@ -1777,10 +1777,10 @@ class Mail
} }
} }
} }
if(is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) { if(!empty($headerObject['REPLY-TO'][0])) {
$retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0],true); $retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0],true);
} }
if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { if(!empty($headerObject['TO'][0])) {
$retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true);
if (count($headerObject['TO'])>1) if (count($headerObject['TO'])>1)
{ {
@ -1795,7 +1795,7 @@ class Mail
} }
} }
} }
if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { if(!empty($headerObject['CC'])) {
$ki=0; $ki=0;
foreach($headerObject['CC'] as $k => $add) foreach($headerObject['CC'] as $k => $add)
{ {
@ -1885,7 +1885,7 @@ class Mail
static $cachedFolderStatus = null; static $cachedFolderStatus = null;
// in the past we needed examineMailbox to figure out if the server with the serverID support keywords // in the past we needed examineMailbox to figure out if the server with the serverID support keywords
// this information is filled/provided by examineMailbox; but caching within one request seems o.k. // this information is filled/provided by examineMailbox; but caching within one request seems o.k.
if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) ) if (!isset($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) )
{ {
$folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName); $folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName);
} }
@ -1897,12 +1897,12 @@ class Mail
//error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter));
$try2useCache = true; $try2useCache = true;
static $eMailListContainsDeletedMessages = null; static $eMailListContainsDeletedMessages = null;
if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); if (!isset($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1)??[];
// this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED
if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false)))
{ {
if (self::$debugTimes) $starttime = microtime(true); if (self::$debugTimes) $starttime = microtime(true);
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); if (!isset($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);
$five=true; $five=true;
$dReverse=1; $dReverse=1;
$deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')),$five,false); $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')),$five,false);
@ -1913,7 +1913,7 @@ class Mail
} }
$try2useCache = false; $try2useCache = false;
//self::$supportsORinQuery[$this->profileID]=true; //self::$supportsORinQuery[$this->profileID]=true;
if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) if (!isset(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID]))
{ {
self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10);
if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true;
@ -2002,7 +2002,7 @@ class Mail
{ {
self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY']; self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY'];
self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES'];
self::$folderStatusCache[$this->profileID][$_folderName]['deleted'] = $eMailListContainsDeletedMessages[$this->profileID][$_folderName]; self::$folderStatusCache[$this->profileID][$_folderName]['deleted'] = $eMailListContainsDeletedMessages[$this->profileID][$_folderName] ?? [];
self::$folderStatusCache[$this->profileID][$_folderName]['uidnext'] = $folderStatus['UIDNEXT']; self::$folderStatusCache[$this->profileID][$_folderName]['uidnext'] = $folderStatus['UIDNEXT'];
self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter;
self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult; self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult;
@ -2312,12 +2312,12 @@ class Mail
} }
break; break;
case 'SINCE'://enddate case 'SINCE'://enddate
$imapRangeFilter->dateSearch(new DateTime(($_criterias['since']?$_criterias['since']:$_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); $imapRangeFilter->dateSearch(new DateTime(($_criterias['since']??$_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false);
$rangeValid = true; $rangeValid = true;
break; break;
case 'BEFORE'://startdate case 'BEFORE'://startdate
//our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day
$_criterias['before'] = date("d-M-Y",DateTime::to(($_criterias['before']?$_criterias['before']:$_criterias['date']),'ts')+(3600*24)); $_criterias['before'] = date("d-M-Y",DateTime::to(($_criterias['before']??$_criterias['date']),'ts')+(3600*24));
$imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false);
$rangeValid = true; $rangeValid = true;
break; break;
@ -2365,12 +2365,12 @@ class Mail
$_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset); $_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset);
$test = @json_encode($_string); $test = @json_encode($_string);
//error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#'); //error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#');
if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) if (($test=="null" || $test === false || !isset($test)) && strlen($_string)>0)
{ {
// try to fix broken utf8 // try to fix broken utf8
$x = utf8_encode($_string); $x = utf8_encode($_string);
$test = @json_encode($x); $test = @json_encode($x);
if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) if (($test=="null" || $test === false || !isset($test)) && strlen($_string)>0)
{ {
// this should not be needed, unless something fails with charset detection/ wrong charset passed // this should not be needed, unless something fails with charset detection/ wrong charset passed
$_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)); $_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));
@ -2429,7 +2429,7 @@ class Mail
if ($decode) $_string = self::decode_header($_string); if ($decode) $_string = self::decode_header($_string);
// make sure its utf-8 // make sure its utf-8
$test = @json_encode($_string); $test = @json_encode($_string);
if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) if (($test=="null" || $test === false || !isset($test)) && strlen($_string)>0)
{ {
$_string = utf8_encode($_string); $_string = utf8_encode($_string);
} }
@ -2637,7 +2637,7 @@ class Mail
if ($_subscribedOnly && $_getCounters===false) if ($_subscribedOnly && $_getCounters===false)
{ {
if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); if (!isset($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId]));
@ -2647,7 +2647,7 @@ class Mail
} }
// use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId]
static $folderBasicInfo; static $folderBasicInfo;
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); if (!isset($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);
//error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId])));
$delimiter = $this->getHierarchyDelimiter(); $delimiter = $this->getHierarchyDelimiter();
@ -2943,7 +2943,7 @@ class Mail
$topFolders = $this->icServer->getMailboxes("", 2, true); $topFolders = $this->icServer->getMailboxes("", 2, true);
// Trigger examination of namespace to retrieve // Trigger examination of namespace to retrieve
// folders located in other and shared; needed only for some servers // folders located in other and shared; needed only for some servers
if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); if (!isset(self::$mailConfig)) self::$mailConfig = Config::read('mail');
if (!empty(self::$mailConfig['examineNamespace'])) if (!empty(self::$mailConfig['examineNamespace']))
{ {
$prefixes=array(); $prefixes=array();
@ -3476,7 +3476,7 @@ class Mail
error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__); error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__);
return false; return false;
} }
if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders(); if (!isset(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders();
//highest precedence //highest precedence
try try
@ -3810,7 +3810,7 @@ class Mail
*/ */
function folderExists($_folder, $_forceCheck=false) function folderExists($_folder, $_forceCheck=false)
{ {
static $folderInfo; static $folderInfo = null;
$forceCheck = $_forceCheck; $forceCheck = $_forceCheck;
if (empty($_folder)) if (empty($_folder))
{ {
@ -3823,7 +3823,7 @@ class Mail
if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8;
// reduce traffic within the Instance per User; Expire every 5 hours // reduce traffic within the Instance per User; Expire every 5 hours
//error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace());
if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); if (!isset($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5) ?? [];
//error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo));
if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false)
{ {
@ -3877,7 +3877,7 @@ class Mail
*/ */
function compressFolder($_folderName = false) function compressFolder($_folderName = false)
{ {
$folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); $folderName = $_folderName ?: $this->sessionData['mailbox'];
$deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'];
$trashFolder = $this->getTrashFolder(); $trashFolder = $this->getTrashFolder();
@ -3957,7 +3957,7 @@ class Mail
case "mark_as_deleted": case "mark_as_deleted":
//error_log(__METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') ');
// mark messages as deleted // mark messages as deleted
if (is_null($_messageUID)) $_messageUID='all'; if (!isset($_messageUID)) $_messageUID='all';
foreach((array)$_messageUID as $key =>$uid) foreach((array)$_messageUID as $key =>$uid)
{ {
//flag messages, that are flagged for deletion as seen too //flag messages, that are flagged for deletion as seen too
@ -3977,7 +3977,7 @@ class Mail
case "remove_immediately": case "remove_immediately":
//error_log(__METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') ');
$updateCache = true; $updateCache = true;
if (is_null($_messageUID)) $_messageUID='all'; if (!isset($_messageUID)) $_messageUID='all';
if (is_object($_messageUID)) if (is_object($_messageUID))
{ {
$this->flagMessages('delete', $_messageUID, $_folder); $this->flagMessages('delete', $_messageUID, $_folder);
@ -4085,7 +4085,7 @@ class Mail
if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
return false; return false;
} }
$this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); $this->icServer->openMailbox($_folder ?: $this->sessionData['mailbox']);
$folder = $this->icServer->getCurrentMailbox(); $folder = $this->icServer->getCurrentMailbox();
if (is_array($_messageUID)&& count($_messageUID)>50) if (is_array($_messageUID)&& count($_messageUID)>50)
{ {
@ -4251,7 +4251,7 @@ class Mail
} }
$sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']);
//error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId)); //error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId));
if (!is_null($_targetProfileID) && $_targetProfileID !== $source->ImapServerId) if (isset($_targetProfileID) && $_targetProfileID !== $source->ImapServerId)
{ {
$sourceFolder = $source->getMailbox($sourceFolder); $sourceFolder = $source->getMailbox($sourceFolder);
$source->openMailbox($sourceFolder); $source->openMailbox($sourceFolder);
@ -4793,7 +4793,7 @@ class Mail
if (empty($_folder)) if (empty($_folder))
{ {
$_folder = (isset($this->sessionData['mailbox'])&&$this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
} }
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']);
// querying contents of body part // querying contents of body part
@ -4909,7 +4909,7 @@ class Mail
} }
if (empty($_folder)) if (empty($_folder))
{ {
$_folder = $this->sessionData['mailbox']; $_folder = $this->sessionData['mailbox'] ?? null;
} }
if (empty($this->sessionData['mailbox']) && !empty($_folder)) if (empty($this->sessionData['mailbox']) && !empty($_folder))
{ {
@ -5239,7 +5239,7 @@ class Mail
function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false)
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace());
if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); if (empty($_folder)) $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
//error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder");
if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) {
$uidsToFetch = new Horde_Imap_Client_Ids(); $uidsToFetch = new Horde_Imap_Client_Ids();
@ -5280,7 +5280,7 @@ class Mail
} }
else else
{ {
$address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad; $address[] = (isset($remember)?$envelope[$v][$remember].' ':'').$ad;
$remember=null; $remember=null;
} }
} }
@ -5372,7 +5372,7 @@ class Mail
function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='')
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder);
if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); if (empty($_folder)) $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
$uidsToFetch = new Horde_Imap_Client_Ids(); $uidsToFetch = new Horde_Imap_Client_Ids();
if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
$uidsToFetch->add($_uid); $uidsToFetch->add($_uid);
@ -5450,10 +5450,10 @@ class Mail
function getMessageRawHeader($_uid, $_partID = '', $_folder = '') function getMessageRawHeader($_uid, $_partID = '', $_folder = '')
{ {
static $rawHeaders; static $rawHeaders;
if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); if (empty($_folder)) $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
//error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder");
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); if (!isset($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1);
if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
{ {
//error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder");
@ -5527,7 +5527,7 @@ class Mail
//error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle));
$style2buffer = implode('',$newStyle[0]); $style2buffer = implode('',$newStyle[0]);
} }
if ($style2buffer && strtoupper(self::$displayCharset) == 'UTF-8') if (!empty($style2buffer) && strtoupper(self::$displayCharset) == 'UTF-8')
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($style2buffer)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($style2buffer));
$test = json_encode($style2buffer); $test = json_encode($style2buffer);
@ -5540,7 +5540,7 @@ class Mail
$style2buffer = utf8_encode($style2buffer); $style2buffer = utf8_encode($style2buffer);
} }
} }
$style .= $style2buffer; $style .= $style2buffer ?? '';
} }
// clean out comments and stuff // clean out comments and stuff
$search = array( $search = array(
@ -5580,7 +5580,7 @@ class Mail
{ {
static $rawBody; static $rawBody;
$body = null; $body = null;
if (empty($_folder)) $_folder = $this->sessionData['mailbox']?: $this->icServer->getCurrentMailbox(); if (empty($_folder)) $_folder = $this->sessionData['mailbox']?? $this->icServer->getCurrentMailbox();
$_uid = !(is_object($_uid) || is_array($_uid)) ? (array)$_uid : $_uid; $_uid = !(is_object($_uid) || is_array($_uid)) ? (array)$_uid : $_uid;
if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][(string)$_folder][$_uid[0]][(empty($_partID)?'NIL':$_partID)])) if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][(string)$_folder][$_uid[0]][(empty($_partID)?'NIL':$_partID)]))
@ -5644,7 +5644,7 @@ class Mail
if (empty($_folder)) if (empty($_folder))
{ {
$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
} }
$uidsToFetch = new Horde_Imap_Client_Ids(); $uidsToFetch = new Horde_Imap_Client_Ids();
@ -5710,7 +5710,7 @@ class Mail
function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='')
{ {
if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); if (self::$debug) error_log( __METHOD__.":$_uid, $_partID");
if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); if (empty($_folder)) $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
$attachments = array(); $attachments = array();
if (!isset($_structure)) if (!isset($_structure))
{ {
@ -5965,7 +5965,7 @@ class Mail
function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null)
{ {
//error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace());
if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); if (!isset($_folder)) $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox();
$uidsToFetch = new Horde_Imap_Client_Ids(); $uidsToFetch = new Horde_Imap_Client_Ids();
if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid;
@ -6162,7 +6162,7 @@ class Mail
*/ */
public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null)
{ {
if (is_null($part)) return null;//new Horde_Mime_Part; if (!isset($part)) return null;//new Horde_Mime_Part;
$encoding = null; $encoding = null;
$fetchAsBinary = true; $fetchAsBinary = true;
if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false;
@ -6274,7 +6274,7 @@ class Mail
if (empty($headers)) return false; if (empty($headers)) return false;
// dont force retrieval of the textpart, let mailClass preferences decide // dont force retrieval of the textpart, let mailClass preferences decide
$bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox);
if(is_null($preserveHTML)) if(!isset($preserveHTML))
{ {
$html = static::getdisplayablebody( $html = static::getdisplayablebody(
$mailClass, $mailClass,
@ -6620,7 +6620,7 @@ class Mail
*/ */
static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='')
{ {
if (is_null($_endtime)) $_endtime = microtime(true); if (!isset($_endtime)) $_endtime = microtime(true);
$usagetime = microtime(true) - $_starttime; $usagetime = microtime(true) - $_starttime;
if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:''));
} }
@ -6832,7 +6832,7 @@ class Mail
} }
if ( $myUrl[0]!='/' && strlen($basedir) > 1 && !str_ends_with($basedir, '/')) { $basedir .= '/'; } if ( $myUrl[0]!='/' && strlen($basedir) > 1 && !str_ends_with($basedir, '/')) { $basedir .= '/'; }
if ($needTempFile && !$attachment && !str_starts_with($myUrl, "http")) $data = file_get_contents($basedir.urldecode($myUrl)); if ($needTempFile && empty($attachment) && !str_starts_with($myUrl, "http")) $data = file_get_contents($basedir.urldecode($myUrl));
} }
if (str_starts_with($url, 'data:')) if (str_starts_with($url, 'data:'))
{ {
@ -7120,7 +7120,7 @@ class Mail
$alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage()); $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage());
} }
// no send, save successful, and message_uid present // no send, save successful, and message_uid present
if ($savefailed===false && $messageUid && is_null($sendOK)) if ($savefailed===false && $messageUid && !isset($sendOK))
{ {
$importID = $messageUid; $importID = $messageUid;
$openComposeWindow = true; $openComposeWindow = true;
@ -7141,7 +7141,7 @@ class Mail
if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
} }
} }
if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) if (isset($sendOK) && $sendOK===false && !isset($openComposeWindow))
{ {
$processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details';
} }
@ -7485,7 +7485,7 @@ class Mail
foreach ($_addresses as &$address) foreach ($_addresses as &$address)
{ {
preg_match("/<([^\'\" <>]+)>$/", $address, $matches); preg_match("/<([^\'\" <>]+)>$/", $address, $matches);
if ($matches[1]) $address = $matches[1]; if (!empty($matches[1])) $address = $matches[1];
} }
return $_addresses; return $_addresses;
} }
@ -7620,4 +7620,4 @@ class Mail
); );
return $this->smime->decrypt($_message, $params); return $this->smime->decrypt($_message, $params);
} }
} }

View File

@ -526,8 +526,8 @@ class Account implements \ArrayAccess
Api\Preferences::setlocale(LC_MESSAGES); Api\Preferences::setlocale(LC_MESSAGES);
$this->smtpTransport = new Horde_Mail_Transport_Smtphorde(array( $this->smtpTransport = new Horde_Mail_Transport_Smtphorde(array(
'username' => $params['acc_smtp_username'], 'username' => $params['acc_smtp_username'] ?? null,
'password' => $params['acc_smtp_password'], 'password' => $params['acc_smtp_password'] ?? null,
'host' => $params['acc_smtp_host'], 'host' => $params['acc_smtp_host'],
'port' => $params['acc_smtp_port'], 'port' => $params['acc_smtp_port'],
'secure' => $secure, 'secure' => $secure,

View File

@ -283,7 +283,7 @@ class Credentials
'acc_imap_password' => $password, 'acc_imap_password' => $password,
'acc_imap_cred_id' => $data['acc_imap_logintype'], // to NOT store it 'acc_imap_cred_id' => $data['acc_imap_logintype'], // to NOT store it
'acc_imap_account_id' => 'c', 'acc_imap_account_id' => 'c',
) + ($data['acc_smtp_auth_session'] ? array( ) + (!empty($data['acc_smtp_auth_session']) ? array(
// only set smtp // only set smtp
'acc_smtp_username' => $username, 'acc_smtp_username' => $username,
'acc_smtp_password' => $password, 'acc_smtp_password' => $password,

View File

@ -295,7 +295,7 @@ class Smime extends Horde_Crypt_Smime
// remove other imap stuffs but smime // remove other imap stuffs but smime
if (!preg_match("/acc_smime/", $key)) unset($acc_smime[$key]); if (!preg_match("/acc_smime/", $key)) unset($acc_smime[$key]);
} }
if ($acc_smime['acc_smime_password']) if (!empty($acc_smime['acc_smime_password']))
{ {
$extracted = self::extractCertPKCS12( $extracted = self::extractCertPKCS12(
$acc_smime['acc_smime_password'], $acc_smime['acc_smime_password'],
@ -305,4 +305,4 @@ class Smime extends Horde_Crypt_Smime
} }
return false; return false;
} }
} }

View File

@ -1175,7 +1175,7 @@ class Mailer extends Horde_Mime_Mail
$encrypt_params = array( $encrypt_params = array(
'type' => 'message', 'type' => 'message',
'pubkey' => array_merge( 'pubkey' => array_merge(
(array)$params['recipientsCerts'], (array)($params['recipientsCerts'] ?? []),
array($this->account->acc_smime_username => $params['senderPubKey']) array($this->account->acc_smime_username => $params['senderPubKey'])
) )
); );

View File

@ -327,13 +327,13 @@ class mail_compose
$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
// fetch appendix data which is an assistance input value consisiting of json data // fetch appendix data which is an assistance input value consisiting of json data
if ($_content['appendix_data']) if (!empty($_content['appendix_data']))
{ {
$appendix_data = json_decode($_content['appendix_data'], true); $appendix_data = json_decode($_content['appendix_data'], true);
$_content['appendix_data'] = ''; $_content['appendix_data'] = '';
} }
if ($appendix_data['emails']) if (!empty($appendix_data['emails']))
{ {
try { try {
if ($appendix_data['emails']['processedmail_id']) $_content['processedmail_id'] .= ','.$appendix_data['emails']['processedmail_id']; if ($appendix_data['emails']['processedmail_id']) $_content['processedmail_id'] .= ','.$appendix_data['emails']['processedmail_id'];
@ -350,11 +350,11 @@ class mail_compose
} }
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; if (empty($replyID) && isset($_GET['id'])) $replyID = $_GET['id'];
// Process different places we can use as a start for composing an email // Process different places we can use as a start for composing an email
$actionToProcess = 'compose'; $actionToProcess = 'compose';
if($_GET['from'] && $replyID) if(!empty($_GET['from']) && $replyID)
{ {
$_content = array_merge((array)$_content, $this->getComposeFrom( $_content = array_merge((array)$_content, $this->getComposeFrom(
// Parameters needed for fetching appropriate data // Parameters needed for fetching appropriate data
@ -382,7 +382,7 @@ class mail_compose
} }
$composeCache = array(); $composeCache = array();
if (isset($_content['composeID'])&&!empty($_content['composeID'])) if (!empty($_content['composeID']))
{ {
$isFirstLoad = false; $isFirstLoad = false;
$composeCache = Api\Cache::getCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2); $composeCache = Api\Cache::getCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2);
@ -407,7 +407,7 @@ class mail_compose
} }
} }
// VFS Selector was used // VFS Selector was used
if (is_array($_content['selectFromVFSForCompose'])) if (!empty($_content['selectFromVFSForCompose']))
{ {
$suppressSigOnTop = true; $suppressSigOnTop = true;
foreach ($_content['selectFromVFSForCompose'] as $i => $path) foreach ($_content['selectFromVFSForCompose'] as $i => $path)
@ -422,7 +422,7 @@ class mail_compose
unset($_content['selectFromVFSForCompose']); unset($_content['selectFromVFSForCompose']);
} }
// check everything that was uploaded // check everything that was uploaded
if (is_array($_content['uploadForCompose'])) if (!empty($_content['uploadForCompose']))
{ {
$suppressSigOnTop = true; $suppressSigOnTop = true;
foreach ($_content['uploadForCompose'] as $i => &$upload) foreach ($_content['uploadForCompose'] as $i => &$upload)
@ -487,7 +487,7 @@ class mail_compose
// at several locations and not neccesaryly initialized before // at several locations and not neccesaryly initialized before
$acc = Mail\Account::read($composeProfile); $acc = Mail\Account::read($composeProfile);
$buttonClicked = false; $buttonClicked = false;
if ($_content['composeToolbar'] === 'send') if (!empty($_content['composeToolbar']) && $_content['composeToolbar'] === 'send')
{ {
$buttonClicked = $suppressSigOnTop = true; $buttonClicked = $suppressSigOnTop = true;
$sendOK = true; $sendOK = true;
@ -638,7 +638,7 @@ class mail_compose
} }
// user might have switched desired mimetype, so we should convert // user might have switched desired mimetype, so we should convert
if ($content['is_html'] && $content['mimeType']=='plain') if (!empty($content['is_html']) && $content['mimeType'] === 'plain')
{ {
//error_log(__METHOD__.__LINE__.$content['mail_htmltext']); //error_log(__METHOD__.__LINE__.$content['mail_htmltext']);
$suppressSigOnTop = true; $suppressSigOnTop = true;
@ -662,7 +662,7 @@ class mail_compose
$content['is_html'] = false; $content['is_html'] = false;
$content['is_plain'] = true; $content['is_plain'] = true;
} }
if ($content['is_plain'] && $content['mimeType']=='html') if (!empty($content['is_plain']) && $content['mimeType'] === 'html')
{ {
// the possible font span should only be applied on first load or on switch plain->html // the possible font span should only be applied on first load or on switch plain->html
$isFirstLoad = "switchedplaintohtml"; $isFirstLoad = "switchedplaintohtml";
@ -831,7 +831,7 @@ class mail_compose
// On submit reads external_vcard widget's value and addes them as attachments. // On submit reads external_vcard widget's value and addes them as attachments.
// this happens when we send vcards from addressbook to an opened compose // this happens when we send vcards from addressbook to an opened compose
// dialog. // dialog.
if ($appendix_data['files']) if (!empty($appendix_data['files']))
{ {
$_REQUEST['preset']['file'] = $appendix_data['files']['file']; $_REQUEST['preset']['file'] = $appendix_data['files']['file'];
$_REQUEST['preset']['type'] = $appendix_data['files']['type']; $_REQUEST['preset']['type'] = $appendix_data['files']['type'];
@ -897,11 +897,11 @@ class mail_compose
} }
} }
// handle preset info/values // handle preset info/values
if (is_array($_REQUEST['preset'])) if (!empty($_REQUEST['preset']))
{ {
$alreadyProcessed=array(); $alreadyProcessed=array();
//_debug_array($_REQUEST); //_debug_array($_REQUEST);
if ($_REQUEST['preset']['mailto']) { if (!empty($_REQUEST['preset']['mailto'])) {
// handle mailto strings such as // handle mailto strings such as
// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
// the above string may be htmlentyty encoded, then multiple body tags are supported // the above string may be htmlentyty encoded, then multiple body tags are supported
@ -928,7 +928,7 @@ class mail_compose
} }
} }
if ($_REQUEST['preset']['mailtocontactbyid']) { if (!empty($_REQUEST['preset']['mailtocontactbyid'])) {
if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
$contacts_obj = new Api\Contacts(); $contacts_obj = new Api\Contacts();
$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
@ -1002,7 +1002,7 @@ class mail_compose
} }
} }
if (isset($_REQUEST['preset']['file'])) if (!empty($_REQUEST['preset']['file']))
{ {
$content['filemode'] = !empty($_REQUEST['preset']['filemode']) && $content['filemode'] = !empty($_REQUEST['preset']['filemode']) &&
(isset(Vfs\Sharing::$modes[$_REQUEST['preset']['filemode']]) || isset(Vfs\HiddenUploadSharing::$modes[$_REQUEST['preset']['filemode']])) ? (isset(Vfs\Sharing::$modes[$_REQUEST['preset']['filemode']]) || isset(Vfs\HiddenUploadSharing::$modes[$_REQUEST['preset']['filemode']])) ?
@ -1026,14 +1026,14 @@ class mail_compose
foreach(array('to','cc','bcc','subject','body','mimeType') as $name) foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
{ {
//always handle mimeType //always handle mimeType
if ($name=='mimeType' && $_REQUEST['preset'][$name]) if ($name=='mimeType' && !empty($_REQUEST['preset'][$name]))
{ {
$_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; $_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
} }
//skip if already processed by "preset Routines" //skip if already processed by "preset Routines"
if ($alreadyProcessed[$name]) continue; if ($alreadyProcessed[$name]) continue;
//error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]); //error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]);
if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name]; if (!empty($_REQUEST['preset'][$name])) $content[$name] = $_REQUEST['preset'][$name];
} }
} }
// is the to address set already? // is the to address set already?
@ -1194,17 +1194,17 @@ class mail_compose
if ($insertSigOnTop === 'below') if ($insertSigOnTop === 'below')
{ {
$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)); $content['body'] = $content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true));
} }
else else
{ {
$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body']; $content['body'] = $before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
} }
} }
// Skip this part if we're merging, it would add an extra line at the top // Skip this part if we're merging, it would add an extra line at the top
else if (!$content['body']) else if (!$content['body'])
{ {
$content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):'').($isFirstLoad === "switchedplaintohtml"?"</span>":""); $content['body'] = ($isFirstLoad === "switchedplaintohtml"?"</span>":"");
} }
//error_log(__METHOD__.__LINE__.$content['body']); //error_log(__METHOD__.__LINE__.$content['body']);
@ -1389,11 +1389,11 @@ class mail_compose
{ {
foreach($content['attachments'] as &$attach) foreach($content['attachments'] as &$attach)
{ {
$attach['is_dir'] = is_dir($attach['file']); $attach['is_dir'] = !empty($attach['file']) && is_dir($attach['file']);
$attach['filemode_icon'] = !is_dir($attach['file']) && $attach['filemode_icon'] = !empty($attach['file']) && !is_dir($attach['file']) && !empty($content['filemode']) &&
($content['filemode'] == Vfs\Sharing::READONLY || $content['filemode'] == Vfs\Sharing::WRITABLE) ($content['filemode'] == Vfs\Sharing::READONLY || $content['filemode'] == Vfs\Sharing::WRITABLE)
? Vfs\Sharing::LINK : $content['filemode']; ? Vfs\Sharing::LINK : $content['filemode'] ?? '';
$attach['filemode_title'] = lang(Vfs\Sharing::$modes[$attach['filemode_icon']]['label']); $attach['filemode_title'] = lang(Vfs\Sharing::$modes[$attach['filemode_icon']]['label'] ?? '');
} }
} }
@ -1776,7 +1776,7 @@ class mail_compose
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
if(!$foundAddresses[$keyemail]) { if(empty($foundAddresses[$keyemail])) {
$address = $this->mail_bo->decode_header($val,true); $address = $this->mail_bo->decode_header($val,true);
$this->sessionData['replyto'][] = $val; $this->sessionData['replyto'][] = $val;
$foundAddresses[$keyemail] = true; $foundAddresses[$keyemail] = true;
@ -1791,7 +1791,7 @@ class mail_compose
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
if(!$foundAddresses[$keyemail]) { if(empty($foundAddresses[$keyemail])) {
$address = $this->mail_bo->decode_header($val,true); $address = $this->mail_bo->decode_header($val,true);
$this->sessionData['bcc'][] = $val; $this->sessionData['bcc'][] = $val;
$foundAddresses[$keyemail] = true; $foundAddresses[$keyemail] = true;
@ -1808,32 +1808,32 @@ class mail_compose
if($bodyParts['0']['mimeType'] == 'text/html') { if($bodyParts['0']['mimeType'] == 'text/html') {
$this->sessionData['mimeType'] = 'html'; $this->sessionData['mimeType'] = 'html';
for($i=0; $i<count($bodyParts); $i++) { foreach($bodyParts as $i => &$bodyPart) {
if($i>0) { if($i>0) {
$this->sessionData['body'] .= '<hr>'; $this->sessionData['body'] .= '<hr>';
} }
if($bodyParts[$i]['mimeType'] == 'text/plain') { if($bodyPart['mimeType'] == 'text/plain') {
#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; $bodyPart['body'] = "<pre>".$bodyPart['body']."</pre>";
} }
if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); if ($bodyPart['charSet']===false) $bodyPart['charSet'] = Mail::detect_encoding($bodyPart['body']);
$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyPart['body'], $bodyPart['charSet']);
#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyPart['body'] . 'a' , strtoupper($bodyPart['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyPart['body'] ;
} }
$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
} else { } else {
$this->sessionData['mimeType'] = 'plain'; $this->sessionData['mimeType'] = 'plain';
for($i=0; $i<count($bodyParts); $i++) { foreach($bodyParts as $i => &$bodyPart) {
if($i>0) { if($i>0) {
$this->sessionData['body'] .= "<hr>"; $this->sessionData['body'] .= "<hr>";
} }
if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); if ($bodyPart['charSet']===false) $bodyPart['charSet'] = Mail::detect_encoding($bodyPart['body']);
$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); $bodyPart['body'] = Api\Translation::convert_jsonsafe($bodyPart['body'], $bodyPart['charSet']);
#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyPart['body'] ;
} }
$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
} }
@ -3142,7 +3142,7 @@ class mail_compose
'mail', 'mail',
'smime_passphrase', 'smime_passphrase',
$_formData['smime_passphrase'], $_formData['smime_passphrase'],
(int)($GLOBALS['egw_info']['user']['preferences']['mail']['smime_pass_exp']?:10) * 60 (int)($GLOBALS['egw_info']['user']['preferences']['mail']['smime_pass_exp']??10) * 60
); );
} }
$smime_success = $this->_encrypt( $smime_success = $this->_encrypt(
@ -3338,10 +3338,10 @@ class mail_compose
|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
// mark message as answered // mark message as answered
$mail_bo->openConnection(); $mail_bo->openConnection();
$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); $mail_bo->reopen($this->sessionData['messageFolder'] ?? $this->sessionData['sourceFolder']);
// if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send // if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send
// unless your templatefolder is a subfolder of your draftfolder, and the message is in there // unless your templatefolder is a subfolder of your draftfolder, and the message is in there
if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder'])) if (!empty($this->sessionData['messageFolder']) && $mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder']))
{ {
try // message may be deleted already, as it maybe done by autosave try // message may be deleted already, as it maybe done by autosave
{ {
@ -3358,7 +3358,7 @@ class mail_compose
unset($e); unset($e);
} }
} else { } else {
$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); $mail_bo->flagMessages("answered", $this->sessionData['uid'], $this->sessionData['messageFolder'] ?? $this->sessionData['sourceFolder']);
//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
{ {
@ -3860,8 +3860,8 @@ class mail_compose
if (isset($sender) && ($type == Mail\Smime::TYPE_SIGN || $type == Mail\Smime::TYPE_SIGN_ENCRYPT)) if (isset($sender) && ($type == Mail\Smime::TYPE_SIGN || $type == Mail\Smime::TYPE_SIGN_ENCRYPT))
{ {
$acc_smime = Mail\Smime::get_acc_smime($this->mail_bo->profileID, $params['passphrase']); $acc_smime = Mail\Smime::get_acc_smime($this->mail_bo->profileID, $params['passphrase']);
$params['senderPrivKey'] = $acc_smime['pkey']; $params['senderPrivKey'] = $acc_smime['pkey'] ?? null;
$params['extracerts'] = $acc_smime['extracerts']; $params['extracerts'] = $acc_smime['extracerts'] ?? null;
} }
if (isset($recipients) && ($type == Mail\Smime::TYPE_ENCRYPT || $type == Mail\Smime::TYPE_SIGN_ENCRYPT)) if (isset($recipients) && ($type == Mail\Smime::TYPE_ENCRYPT || $type == Mail\Smime::TYPE_SIGN_ENCRYPT))
@ -3917,4 +3917,4 @@ class mail_compose
} }
return $this->sessionData['attachments']; return $this->sessionData['attachments'];
} }
} }

View File

@ -573,15 +573,15 @@ class mail_tree
if ($identLabel & self::IDENT_EMAIL || empty($name)) if ($identLabel & self::IDENT_EMAIL || empty($name))
{ {
if ($_fullString && (strpos($_account['ident_email'], '@') !== false || trim($_account['ident_email']) !='')) if ($_fullString && trim($_account['ident_email']))
{ {
$name[] = ' <'.$_account['ident_email'].'>'; $name[] = ' <'.$_account['ident_email'].'>';
} }
elseif(strpos($_account['acc_imap_username'], '@') !== false || trim($_account['acc_imap_username']) !='') elseif (!empty($_account['acc_imap_username']) && trim($_account['acc_imap_username']))
{ {
$name[] = ' <'.$_account['acc_imap_username'].'>'; $name[] = ' <'.$_account['acc_imap_username'].'>';
} }
} }
return implode(' ', $name); return implode(' ', $name);
} }
} }

View File

@ -274,7 +274,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$this->_wasteID = false; $this->_wasteID = false;
$this->_sentID = false; $this->_sentID = false;
if (!$this->mail) if (empty($this->mail))
{ {
$this->account = $account; $this->account = $account;
// todo: tell mail which account to use // todo: tell mail which account to use
@ -1089,10 +1089,10 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
($headers['priority'] < 3 ? 2 : 1) ; ($headers['priority'] < 3 ? 2 : 1) ;
$output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true);
$output->to = $headers['to_address']; $output->to = $headers['to_address'];
if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] if (!empty($headers['to'])) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name']
$output->from = $headers['sender_address']; $output->from = $headers['sender_address'];
if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses']; if (!empty($headers['cc_addresses'])) $output->cc = $headers['cc_addresses'];
if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; if (!empty($headers['reply_to_address'])) $output->reply_to = $headers['reply_to_address'];
$output->messageclass = "IPM.Note"; $output->messageclass = "IPM.Note";
if (stripos($headers['mimetype'],'multipart')!== false && if (stripos($headers['mimetype'],'multipart')!== false &&
@ -1669,7 +1669,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
array_pop($parent); array_pop($parent);
$parent = implode($delimiter,$parent); $parent = implode($delimiter,$parent);
$id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; $id = $parent && !empty($this->folders[$parent]) ? $this->createID($account, $parent) : '0';
if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id");
return $id; return $id;
} }
@ -2215,4 +2215,4 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
return $dir.'/'.$dev_id.'.hashes'; return $dir.'/'.$dev_id.'.hashes';
} }
} }