diff --git a/api/src/Mail.php b/api/src/Mail.php index 890b1d4d49..0eb20322d4 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -203,7 +203,7 @@ class Mail public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) { //$_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__.') '.array2string($_oldImapServerObject)); 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; 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 (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); + if (!isset(self::$mailConfig)) self::$mailConfig = Config::read('mail'); return self::$instances[$_profileID]; } @@ -406,7 +406,7 @@ class Mail */ 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; // not nummeric, we assume we only want an empty class object if (!is_numeric($_profileID)) return; @@ -444,7 +444,7 @@ class Mail $_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(); 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) { @@ -536,7 +536,7 @@ class Mail */ 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']; //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); 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) { //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)) { // called via hook @@ -607,7 +607,7 @@ class Mail unset($_ImapServerId); $_ImapServerId = null; } - if (is_null($_ImapServerId)) + if (!isset($_ImapServerId)) { $isConError = array(); $waitOnFailure = array(); @@ -638,10 +638,10 @@ class Mail static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) { //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 // 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(); $folderInfo = array(); @@ -812,7 +812,7 @@ class Mail $rememberFirst=$selectedFound=null; foreach ($allAccountData as $tmpkey => $icServers) { - if (is_null($rememberFirst)) $rememberFirst = $tmpkey; + if (!isset($rememberFirst)) $rememberFirst = $tmpkey; if ($tmpkey == $selectedID) $selectedFound=true; //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); $host = $icServers->acc_imap_host; @@ -834,7 +834,7 @@ class Mail static function generateIdentityString($identity, $fullString=true) { //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 //if (!isset(self::$mailConfig['how2displayIdentities'])) self::$mailConfig['how2displayIdentities']=''; $how2displayIdentities = ''; @@ -1013,7 +1013,7 @@ class Mail $foldersNameSpace = array(); $delimiter = $this->getHierarchyDelimiter(); // 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)); if (is_array($nameSpace)) { foreach($nameSpace as $type => $singleNameSpaceArray) @@ -1073,7 +1073,7 @@ class Mail function getHierarchyDelimiter($_useCache=true) { 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 (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); 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_sent)); //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))); // does the folder exist??? - if (is_null($folderInfoCache) || !isset($folderInfoCache[$_folderName])) + if (!isset($folderInfoCache) || !isset($folderInfoCache[$_folderName])) { try { @@ -1290,7 +1290,7 @@ class Mail static $subscribedFolders = null; static $nameSpace = 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])) { $nsNoPersonal=array(); @@ -1300,9 +1300,9 @@ class Mail } $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(); } @@ -1614,7 +1614,7 @@ class Mail } else { - $address[] = (!is_null($remember)?$headerObject[$key][$remember].' ':'').$ad; + $address[] = (isset($remember)?$headerObject[$key][$remember].' ':'').$ad; $remember=null; } */ @@ -1760,11 +1760,11 @@ class Mail $retValue['header'][$sortOrder[$uid]]['smimeType'] = Mail\Smime::getSmimeType($mailStructureObject); //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 (is_array($headerObject['FLAGS'])) { + if (!empty($headerObject['FLAGS'])) { $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); } //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); 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); } - 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); 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; foreach($headerObject['CC'] as $k => $add) { @@ -1885,7 +1885,7 @@ class Mail static $cachedFolderStatus = null; // 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. - 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); } @@ -1897,12 +1897,12 @@ class Mail //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); $try2useCache = true; 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 if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) { 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; $dReverse=1; $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')),$five,false); @@ -1913,7 +1913,7 @@ class Mail } $try2useCache = false; //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); 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]['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]['filter'] = $_filter; self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult; @@ -2312,12 +2312,12 @@ class Mail } break; 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; break; case 'BEFORE'://startdate //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); $rangeValid = true; break; @@ -2365,12 +2365,12 @@ class Mail $_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset); $test = @json_encode($_string); //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 $x = utf8_encode($_string); $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 $_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); // make sure its utf-8 $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); } @@ -2637,7 +2637,7 @@ class Mail 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])) { //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] 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]))); $delimiter = $this->getHierarchyDelimiter(); @@ -2943,7 +2943,7 @@ class Mail $topFolders = $this->icServer->getMailboxes("", 2, true); // Trigger examination of namespace to retrieve // 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'])) { $prefixes=array(); @@ -3476,7 +3476,7 @@ class Mail error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__); 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 try @@ -3810,7 +3810,7 @@ class Mail */ function folderExists($_folder, $_forceCheck=false) { - static $folderInfo; + static $folderInfo = null; $forceCheck = $_forceCheck; if (empty($_folder)) { @@ -3823,7 +3823,7 @@ class Mail if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; // reduce traffic within the Instance per User; Expire every 5 hours //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)); if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) { @@ -3877,7 +3877,7 @@ class Mail */ function compressFolder($_folderName = false) { - $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); + $folderName = $_folderName ?: $this->sessionData['mailbox']; $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; $trashFolder = $this->getTrashFolder(); @@ -3957,7 +3957,7 @@ class Mail case "mark_as_deleted": //error_log(__METHOD__.' ('.__LINE__.') '); // mark messages as deleted - if (is_null($_messageUID)) $_messageUID='all'; + if (!isset($_messageUID)) $_messageUID='all'; foreach((array)$_messageUID as $key =>$uid) { //flag messages, that are flagged for deletion as seen too @@ -3977,7 +3977,7 @@ class Mail case "remove_immediately": //error_log(__METHOD__.' ('.__LINE__.') '); $updateCache = true; - if (is_null($_messageUID)) $_messageUID='all'; + if (!isset($_messageUID)) $_messageUID='all'; if (is_object($_messageUID)) { $this->flagMessages('delete', $_messageUID, $_folder); @@ -4085,7 +4085,7 @@ class Mail if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); return false; } - $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); + $this->icServer->openMailbox($_folder ?: $this->sessionData['mailbox']); $folder = $this->icServer->getCurrentMailbox(); if (is_array($_messageUID)&& count($_messageUID)>50) { @@ -4251,7 +4251,7 @@ class Mail } $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); //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); $source->openMailbox($sourceFolder); @@ -4793,7 +4793,7 @@ class Mail 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']); // querying contents of body part @@ -4909,7 +4909,7 @@ class Mail } if (empty($_folder)) { - $_folder = $this->sessionData['mailbox']; + $_folder = $this->sessionData['mailbox'] ?? null; } if (empty($this->sessionData['mailbox']) && !empty($_folder)) { @@ -5239,7 +5239,7 @@ class Mail function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) { //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"); if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { $uidsToFetch = new Horde_Imap_Client_Ids(); @@ -5280,7 +5280,7 @@ class Mail } else { - $address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad; + $address[] = (isset($remember)?$envelope[$v][$remember].' ':'').$ad; $remember=null; } } @@ -5372,7 +5372,7 @@ class Mail function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_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(); if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; $uidsToFetch->add($_uid); @@ -5450,10 +5450,10 @@ class Mail function getMessageRawHeader($_uid, $_partID = '', $_folder = '') { 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"); - 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)])) { //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)); $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)); $test = json_encode($style2buffer); @@ -5540,7 +5540,7 @@ class Mail $style2buffer = utf8_encode($style2buffer); } } - $style .= $style2buffer; + $style .= $style2buffer ?? ''; } // clean out comments and stuff $search = array( @@ -5580,7 +5580,7 @@ class Mail { static $rawBody; $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; if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][(string)$_folder][$_uid[0]][(empty($_partID)?'NIL':$_partID)])) @@ -5644,7 +5644,7 @@ class Mail 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(); @@ -5710,7 +5710,7 @@ class Mail 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 (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); + if (empty($_folder)) $_folder = $this->sessionData['mailbox'] ?? $this->icServer->getCurrentMailbox(); $attachments = array(); if (!isset($_structure)) { @@ -5965,7 +5965,7 @@ class Mail 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()); - 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(); 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) { - if (is_null($part)) return null;//new Horde_Mime_Part; + if (!isset($part)) return null;//new Horde_Mime_Part; $encoding = null; $fetchAsBinary = true; if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; @@ -6274,7 +6274,7 @@ class Mail if (empty($headers)) return false; // 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); - if(is_null($preserveHTML)) + if(!isset($preserveHTML)) { $html = static::getdisplayablebody( $mailClass, @@ -6620,7 +6620,7 @@ class Mail */ 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; 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 ($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:')) { @@ -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()); } // no send, save successful, and message_uid present - if ($savefailed===false && $messageUid && is_null($sendOK)) + if ($savefailed===false && $messageUid && !isset($sendOK)) { $importID = $messageUid; $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 (!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'; } @@ -7485,7 +7485,7 @@ class Mail foreach ($_addresses as &$address) { preg_match("/<([^\'\" <>]+)>$/", $address, $matches); - if ($matches[1]) $address = $matches[1]; + if (!empty($matches[1])) $address = $matches[1]; } return $_addresses; } @@ -7620,4 +7620,4 @@ class Mail ); return $this->smime->decrypt($_message, $params); } -} +} \ No newline at end of file diff --git a/api/src/Mail/Account.php b/api/src/Mail/Account.php index 6cb8815024..cac0314603 100644 --- a/api/src/Mail/Account.php +++ b/api/src/Mail/Account.php @@ -526,8 +526,8 @@ class Account implements \ArrayAccess Api\Preferences::setlocale(LC_MESSAGES); $this->smtpTransport = new Horde_Mail_Transport_Smtphorde(array( - 'username' => $params['acc_smtp_username'], - 'password' => $params['acc_smtp_password'], + 'username' => $params['acc_smtp_username'] ?? null, + 'password' => $params['acc_smtp_password'] ?? null, 'host' => $params['acc_smtp_host'], 'port' => $params['acc_smtp_port'], 'secure' => $secure, diff --git a/api/src/Mail/Credentials.php b/api/src/Mail/Credentials.php index d2e54e52f4..bd0c026bed 100644 --- a/api/src/Mail/Credentials.php +++ b/api/src/Mail/Credentials.php @@ -283,7 +283,7 @@ class Credentials 'acc_imap_password' => $password, 'acc_imap_cred_id' => $data['acc_imap_logintype'], // to NOT store it 'acc_imap_account_id' => 'c', - ) + ($data['acc_smtp_auth_session'] ? array( + ) + (!empty($data['acc_smtp_auth_session']) ? array( // only set smtp 'acc_smtp_username' => $username, 'acc_smtp_password' => $password, diff --git a/api/src/Mail/Smime.php b/api/src/Mail/Smime.php index c6e309a414..c221e973ff 100644 --- a/api/src/Mail/Smime.php +++ b/api/src/Mail/Smime.php @@ -295,7 +295,7 @@ class Smime extends Horde_Crypt_Smime // remove other imap stuffs but smime 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( $acc_smime['acc_smime_password'], @@ -305,4 +305,4 @@ class Smime extends Horde_Crypt_Smime } return false; } -} +} \ No newline at end of file diff --git a/api/src/Mailer.php b/api/src/Mailer.php index f6163ef418..1c35365797 100644 --- a/api/src/Mailer.php +++ b/api/src/Mailer.php @@ -1175,7 +1175,7 @@ class Mailer extends Horde_Mime_Mail $encrypt_params = array( 'type' => 'message', 'pubkey' => array_merge( - (array)$params['recipientsCerts'], + (array)($params['recipientsCerts'] ?? []), array($this->account->acc_smime_username => $params['senderPubKey']) ) ); diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 99f72a6d66..5801736c77 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -327,13 +327,13 @@ class mail_compose $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; // 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); $_content['appendix_data'] = ''; } - if ($appendix_data['emails']) + if (!empty($appendix_data['emails'])) { try { 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 (!$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 $actionToProcess = 'compose'; - if($_GET['from'] && $replyID) + if(!empty($_GET['from']) && $replyID) { $_content = array_merge((array)$_content, $this->getComposeFrom( // Parameters needed for fetching appropriate data @@ -382,7 +382,7 @@ class mail_compose } $composeCache = array(); - if (isset($_content['composeID'])&&!empty($_content['composeID'])) + if (!empty($_content['composeID'])) { $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); @@ -407,7 +407,7 @@ class mail_compose } } // VFS Selector was used - if (is_array($_content['selectFromVFSForCompose'])) + if (!empty($_content['selectFromVFSForCompose'])) { $suppressSigOnTop = true; foreach ($_content['selectFromVFSForCompose'] as $i => $path) @@ -422,7 +422,7 @@ class mail_compose unset($_content['selectFromVFSForCompose']); } // check everything that was uploaded - if (is_array($_content['uploadForCompose'])) + if (!empty($_content['uploadForCompose'])) { $suppressSigOnTop = true; foreach ($_content['uploadForCompose'] as $i => &$upload) @@ -487,7 +487,7 @@ class mail_compose // at several locations and not neccesaryly initialized before $acc = Mail\Account::read($composeProfile); $buttonClicked = false; - if ($_content['composeToolbar'] === 'send') + if (!empty($_content['composeToolbar']) && $_content['composeToolbar'] === 'send') { $buttonClicked = $suppressSigOnTop = true; $sendOK = true; @@ -638,7 +638,7 @@ class mail_compose } // 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']); $suppressSigOnTop = true; @@ -662,7 +662,7 @@ class mail_compose $content['is_html'] = false; $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 $isFirstLoad = "switchedplaintohtml"; @@ -831,7 +831,7 @@ class mail_compose // 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 // dialog. - if ($appendix_data['files']) + if (!empty($appendix_data['files'])) { $_REQUEST['preset']['file'] = $appendix_data['files']['file']; $_REQUEST['preset']['type'] = $appendix_data['files']['type']; @@ -897,11 +897,11 @@ class mail_compose } } // handle preset info/values - if (is_array($_REQUEST['preset'])) + if (!empty($_REQUEST['preset'])) { $alreadyProcessed=array(); //_debug_array($_REQUEST); - if ($_REQUEST['preset']['mailto']) { + if (!empty($_REQUEST['preset']['mailto'])) { // handle mailto strings such as // 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 @@ -928,7 +928,7 @@ class mail_compose } } - if ($_REQUEST['preset']['mailtocontactbyid']) { + if (!empty($_REQUEST['preset']['mailtocontactbyid'])) { if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { $contacts_obj = new Api\Contacts(); $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']) && (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) { //always handle mimeType - if ($name=='mimeType' && $_REQUEST['preset'][$name]) + if ($name=='mimeType' && !empty($_REQUEST['preset'][$name])) { $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; } //skip if already processed by "preset Routines" if ($alreadyProcessed[$name]) continue; //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? @@ -1194,17 +1194,17 @@ class mail_compose 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 { - $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 else if (!$content['body']) { - $content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):'').($isFirstLoad === "switchedplaintohtml"?"":""); + $content['body'] = ($isFirstLoad === "switchedplaintohtml"?"":""); } //error_log(__METHOD__.__LINE__.$content['body']); @@ -1389,11 +1389,11 @@ class mail_compose { foreach($content['attachments'] as &$attach) { - $attach['is_dir'] = is_dir($attach['file']); - $attach['filemode_icon'] = !is_dir($attach['file']) && + $attach['is_dir'] = !empty($attach['file']) && 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) - ? Vfs\Sharing::LINK : $content['filemode']; - $attach['filemode_title'] = lang(Vfs\Sharing::$modes[$attach['filemode_icon']]['label']); + ? Vfs\Sharing::LINK : $content['filemode'] ?? ''; + $attach['filemode_title'] = lang(Vfs\Sharing::$modes[$attach['filemode_icon']]['label'] ?? ''); } } @@ -1776,7 +1776,7 @@ class mail_compose continue; } $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; - if(!$foundAddresses[$keyemail]) { + if(empty($foundAddresses[$keyemail])) { $address = $this->mail_bo->decode_header($val,true); $this->sessionData['replyto'][] = $val; $foundAddresses[$keyemail] = true; @@ -1791,7 +1791,7 @@ class mail_compose continue; } $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; - if(!$foundAddresses[$keyemail]) { + if(empty($foundAddresses[$keyemail])) { $address = $this->mail_bo->decode_header($val,true); $this->sessionData['bcc'][] = $val; $foundAddresses[$keyemail] = true; @@ -1808,32 +1808,32 @@ class mail_compose if($bodyParts['0']['mimeType'] == 'text/html') { $this->sessionData['mimeType'] = 'html'; - for($i=0; $i &$bodyPart) { if($i>0) { $this->sessionData['body'] .= '
'; } - if($bodyParts[$i]['mimeType'] == 'text/plain') { + if($bodyPart['mimeType'] == 'text/plain') { #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); - $bodyParts[$i]['body'] = "
".$bodyParts[$i]['body']."
"; + $bodyPart['body'] = "
".$bodyPart['body']."
"; } - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); - $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['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')); - $this->sessionData['body'] .= ($i>0?"
":""). $bodyParts[$i]['body'] ; + if ($bodyPart['charSet']===false) $bodyPart['charSet'] = Mail::detect_encoding($bodyPart['body']); + $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyPart['body'], $bodyPart['charSet']); + #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?"
":""). $bodyPart['body'] ; } $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); } else { $this->sessionData['mimeType'] = 'plain'; - for($i=0; $i &$bodyPart) { if($i>0) { $this->sessionData['body'] .= "
"; } - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); - $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); + if ($bodyPart['charSet']===false) $bodyPart['charSet'] = Mail::detect_encoding($bodyPart['body']); + $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')); - $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'); } @@ -3142,7 +3142,7 @@ class mail_compose 'mail', '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( @@ -3338,10 +3338,10 @@ class mail_compose || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { // mark message as answered $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 // 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 { @@ -3358,7 +3358,7 @@ class mail_compose unset($e); } } 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']); 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)) { $acc_smime = Mail\Smime::get_acc_smime($this->mail_bo->profileID, $params['passphrase']); - $params['senderPrivKey'] = $acc_smime['pkey']; - $params['extracerts'] = $acc_smime['extracerts']; + $params['senderPrivKey'] = $acc_smime['pkey'] ?? null; + $params['extracerts'] = $acc_smime['extracerts'] ?? null; } 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']; } -} +} \ No newline at end of file diff --git a/mail/inc/class.mail_tree.inc.php b/mail/inc/class.mail_tree.inc.php index d5358523ce..79c978ef4b 100644 --- a/mail/inc/class.mail_tree.inc.php +++ b/mail/inc/class.mail_tree.inc.php @@ -573,15 +573,15 @@ class mail_tree 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'].'>'; } - 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'].'>'; } } return implode(' ', $name); } -} +} \ No newline at end of file diff --git a/mail/inc/class.mail_zpush.inc.php b/mail/inc/class.mail_zpush.inc.php index 1832a64c36..20fca0b839 100644 --- a/mail/inc/class.mail_zpush.inc.php +++ b/mail/inc/class.mail_zpush.inc.php @@ -274,7 +274,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, $this->_wasteID = false; $this->_sentID = false; - if (!$this->mail) + if (empty($this->mail)) { $this->account = $account; // 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) ; $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); $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']; - if (isset($headers['cc_addresses']) && $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['cc_addresses'])) $output->cc = $headers['cc_addresses']; + if (!empty($headers['reply_to_address'])) $output->reply_to = $headers['reply_to_address']; $output->messageclass = "IPM.Note"; if (stripos($headers['mimetype'],'multipart')!== false && @@ -1669,7 +1669,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, array_pop($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"); return $id; } @@ -2215,4 +2215,4 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, return $dir.'/'.$dev_id.'.hashes'; } -} +} \ No newline at end of file