is_a compatibility vs. php5.3.8 resolving to instanceof operator

This commit is contained in:
Klaus Leithoff 2011-09-12 14:06:30 +00:00
parent 74524a9be1
commit 791590bb31
6 changed files with 31 additions and 30 deletions

View File

@ -42,7 +42,7 @@
self::saveSessionData(); self::saveSessionData();
} }
//error_log(__METHOD__.print_r($this->sessionData,true)); //error_log(__METHOD__.print_r($this->sessionData,true));
if (isset($this->sessionData['profileData']) && is_a($this->sessionData['profileData'],'ea_preferences')) if (isset($this->sessionData['profileData']) && ($this->sessionData['profileData'] instanceof ea_preferences))
{ {
//error_log(__METHOD__." Restore Session ".function_backtrace()); //error_log(__METHOD__." Restore Session ".function_backtrace());
$this->profileData = $this->sessionData['profileData']; $this->profileData = $this->sessionData['profileData'];
@ -89,7 +89,7 @@
function getAccountData(&$_profileData, $_accountID=NULL) function getAccountData(&$_profileData, $_accountID=NULL)
{ {
#echo "<p>backtrace: ".function_backtrace()."</p>\n"; #echo "<p>backtrace: ".function_backtrace()."</p>\n";
if(!is_a($_profileData, 'ea_preferences')) if(!($_profileData instanceof ea_preferences))
die(__FILE__.': '.__LINE__); die(__FILE__.': '.__LINE__);
$accountData = parent::getAccountData($GLOBALS['egw_info']['user']['account_id'],$_accountID); $accountData = parent::getAccountData($GLOBALS['egw_info']['user']['account_id'],$_accountID);
@ -141,7 +141,7 @@
function getAllAccountData(&$_profileData) function getAllAccountData(&$_profileData)
{ {
if(!is_a($_profileData, 'ea_preferences')) if(!($_profileData instanceof ea_preferences))
die(__FILE__.': '.__LINE__); die(__FILE__.': '.__LINE__);
$AllAccountData = parent::getAccountData($GLOBALS['egw_info']['user']['account_id'],'all'); $AllAccountData = parent::getAccountData($GLOBALS['egw_info']['user']['account_id'],'all');
#_debug_array($accountData); #_debug_array($accountData);
@ -192,7 +192,7 @@
function getUserDefinedIdentities() function getUserDefinedIdentities()
{ {
$profileData = $this->boemailadmin->getUserProfile('felamimail'); $profileData = $this->boemailadmin->getUserProfile('felamimail');
if(!is_a($profileData, 'ea_preferences') || !is_a($profileData->ic_server[0], 'defaultimap')) { if(!($profileData instanceof ea_preferences) || !($profileData->ic_server[0] instanceof defaultimap)) {
return false; return false;
} }
if($profileData->userDefinedAccounts || $profileData->userDefinedIdentities) if($profileData->userDefinedAccounts || $profileData->userDefinedIdentities)
@ -220,11 +220,11 @@
*/ */
function getPreferences($getUserDefinedProfiles=true,$_profileID=0,$_appName='felamimail') function getPreferences($getUserDefinedProfiles=true,$_profileID=0,$_appName='felamimail')
{ {
if (isset($this->sessionData['profileData']) && is_a($this->sessionData['profileData'],'ea_preferences')) if (isset($this->sessionData['profileData']) && ($this->sessionData['profileData'] instanceof ea_preferences))
{ {
$this->profileData = $this->sessionData['profileData']; $this->profileData = $this->sessionData['profileData'];
} }
if(!is_a($this->profileData,'ea_preferences')) if(!($this->profileData instanceof ea_preferences))
{ {
$GLOBALS['egw']->preferences->read_repository(); $GLOBALS['egw']->preferences->read_repository();
$userPreferences = $GLOBALS['egw_info']['user']['preferences']['felamimail']; $userPreferences = $GLOBALS['egw_info']['user']['preferences']['felamimail'];
@ -237,7 +237,7 @@
$ogProfileID = array_shift($ogServerKeys); $ogProfileID = array_shift($ogServerKeys);
//error_log(__METHOD__.__LINE__.array2string($profileData)); //error_log(__METHOD__.__LINE__.array2string($profileData));
if(!is_a($profileData, 'ea_preferences') || !is_a($profileData->ic_server[$icProfileID], 'defaultimap')) if(!($profileData instanceof ea_preferences) || !($profileData->ic_server[$icProfileID] instanceof defaultimap))
{ {
return false; return false;
} }
@ -256,17 +256,17 @@
foreach ((array)$allAccountData as $k => $accountData) foreach ((array)$allAccountData as $k => $accountData)
{ {
// set defined IMAP server // set defined IMAP server
if(is_a($accountData['icServer'],'defaultimap')) if(($accountData['icServer'] instanceof defaultimap))
{ {
$profileData->setIncomingServer($accountData['icServer'],$k); $profileData->setIncomingServer($accountData['icServer'],$k);
$userPrefs = $this->mergeUserAndProfilePrefs($userPreferences,$profileData,$k); $userPrefs = $this->mergeUserAndProfilePrefs($userPreferences,$profileData,$k);
//$profileData->setPreferences($userPrefs,$k); //$profileData->setPreferences($userPrefs,$k);
} }
// set defined SMTP Server // set defined SMTP Server
if(is_a($accountData['ogServer'],'defaultsmtp')) if(($accountData['ogServer'] instanceof defaultsmtp))
$profileData->setOutgoingServer($accountData['ogServer'],$k); $profileData->setOutgoingServer($accountData['ogServer'],$k);
if(is_a($accountData['identity'],'ea_identity')) if(($accountData['identity'] instanceof ea_identity))
$profileData->setIdentity($profileData->identities[$icProfileID],$k); $profileData->setIdentity($profileData->identities[$icProfileID],$k);
if (empty($_profileID)) if (empty($_profileID))
{ {
@ -281,7 +281,7 @@
if($setAsActive) if($setAsActive)
{ {
// replace the global defined IMAP Server // replace the global defined IMAP Server
if(is_a($accountData['icServer'],'defaultimap')) if(($accountData['icServer'] instanceof defaultimap))
{ {
$profileID = $k; $profileID = $k;
$profileData->setIncomingServer($accountData['icServer'],0); $profileData->setIncomingServer($accountData['icServer'],0);
@ -290,11 +290,11 @@
} }
// replace the global defined SMTP Server // replace the global defined SMTP Server
if(is_a($accountData['ogServer'],'defaultsmtp')) if(($accountData['ogServer'] instanceof defaultsmtp))
$profileData->setOutgoingServer($accountData['ogServer'],0); $profileData->setOutgoingServer($accountData['ogServer'],0);
// replace the global defined identity // replace the global defined identity
if(is_a($accountData['identity'],'ea_identity')) { if(($accountData['identity'] instanceof ea_identity)) {
//_debug_array($profileData); //_debug_array($profileData);
$rememberIdentities = $profileData->identities; $rememberIdentities = $profileData->identities;
$profileData->setIdentity($accountData['identity'],0); $profileData->setIdentity($accountData['identity'],0);

View File

@ -404,7 +404,7 @@ class felamimail_bo
{ {
if ($this->mailPreferences) { if ($this->mailPreferences) {
$icServer = $this->mailPreferences->getIncomingServer($this->profileID); $icServer = $this->mailPreferences->getIncomingServer($this->profileID);
if(is_a($icServer,'defaultimap')) { if(($icServer instanceof defaultimap)) {
// if not connected, try opening an admin connection // if not connected, try opening an admin connection
if (!$icServer->_connected) $this->openConnection($this->profileID,true); if (!$icServer->_connected) $this->openConnection($this->profileID,true);
$icServer->addAccount($_hookValues); $icServer->addAccount($_hookValues);
@ -412,7 +412,7 @@ class felamimail_bo
} }
$ogServer = $this->mailPreferences->getOutgoingServer($this->profileID); $ogServer = $this->mailPreferences->getOutgoingServer($this->profileID);
if(is_a($ogServer,'defaultsmtp')) { if(($ogServer instanceof defaultsmtp)) {
$ogServer->addAccount($_hookValues); $ogServer->addAccount($_hookValues);
} }
} }
@ -725,7 +725,7 @@ class felamimail_bo
{ {
if ($this->mailPreferences) { if ($this->mailPreferences) {
$icServer = $this->mailPreferences->getIncomingServer($this->profileID); $icServer = $this->mailPreferences->getIncomingServer($this->profileID);
if(is_a($icServer,'defaultimap')) { if(($icServer instanceof defaultimap)) {
//try to connect with admin rights, when not connected //try to connect with admin rights, when not connected
if (!$icServer->_connected) $this->openConnection($this->profileID,true); if (!$icServer->_connected) $this->openConnection($this->profileID,true);
$icServer->deleteAccount($_hookValues); $icServer->deleteAccount($_hookValues);
@ -733,7 +733,7 @@ class felamimail_bo
} }
$ogServer = $this->mailPreferences->getOutgoingServer($this->profileID); $ogServer = $this->mailPreferences->getOutgoingServer($this->profileID);
if(is_a($ogServer,'defaultsmtp')) { if(($ogServer instanceof defaultsmtp)) {
$ogServer->deleteAccount($_hookValues); $ogServer->deleteAccount($_hookValues);
} }
} }
@ -1608,7 +1608,7 @@ class felamimail_bo
// does the folder exist??? // does the folder exist???
$folderInfo = $this->icServer->getMailboxes('', $_folderName, true); $folderInfo = $this->icServer->getMailboxes('', $_folderName, true);
if(is_a($folderInfo, 'PEAR_Error') || !is_array($folderInfo[0])) { if(($folderInfo instanceof PEAR_Error) || !is_array($folderInfo[0])) {
if (self::$debug) error_log(__METHOD__." returned Info for folder $_folderName:".print_r($folderInfo->message,true)); if (self::$debug) error_log(__METHOD__." returned Info for folder $_folderName:".print_r($folderInfo->message,true));
return false; return false;
} }
@ -2287,7 +2287,7 @@ class felamimail_bo
function getHierarchyDelimiter() function getHierarchyDelimiter()
{ {
$HierarchyDelimiter = '/'; $HierarchyDelimiter = '/';
if(is_a($this->icServer,'defaultimap')) if(($this->icServer instanceof defaultimap))
{ {
$HierarchyDelimiter = $this->icServer->getHierarchyDelimiter(); $HierarchyDelimiter = $this->icServer->getHierarchyDelimiter();
if (PEAR::isError($HierarchyDelimiter)) $HierarchyDelimiter = '/'; if (PEAR::isError($HierarchyDelimiter)) $HierarchyDelimiter = '/';
@ -2574,6 +2574,7 @@ class felamimail_bo
if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { if(substr($headerObject['INTERNALDATE'],-2) === 'UT') {
$headerObject['INTERNALDATE'] .= 'C'; $headerObject['INTERNALDATE'] .= 'C';
} }
//error_log(__METHOD__.__LINE__.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE']);
//error_log(__METHOD__.__LINE__.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); //error_log(__METHOD__.__LINE__.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']);
$retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']);
$retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE'];
@ -3274,10 +3275,10 @@ class felamimail_bo
//try to connect //try to connect
if (!$this->icServer->_connected) $this->openConnection($this->profileID,false); if (!$this->icServer->_connected) $this->openConnection($this->profileID,false);
} }
if(is_a($this->icServer,'defaultimap')) $folderInfo[$_folder] = $this->icServer->mailboxExist($_folder); if(($this->icServer instanceof defaultimap)) $folderInfo[$_folder] = $this->icServer->mailboxExist($_folder);
//error_log(__METHOD__.__LINE__.' Folder Exists:'.$folderInfo[$_folder].function_backtrace()); //error_log(__METHOD__.__LINE__.' Folder Exists:'.$folderInfo[$_folder].function_backtrace());
if(is_a($folderInfo[$_folder], 'PEAR_Error') || $folderInfo[$_folder] !== true) if(($folderInfo[$_folder] instanceof PEAR_Error) || $folderInfo[$_folder] !== true)
{ {
return false; return false;
} else { } else {
@ -3488,12 +3489,12 @@ class felamimail_bo
function updateAccount($_hookValues) function updateAccount($_hookValues)
{ {
if (is_object($this->mailPreferences)) $icServer = $this->mailPreferences->getIncomingServer(0); if (is_object($this->mailPreferences)) $icServer = $this->mailPreferences->getIncomingServer(0);
if(is_a($icServer,'defaultimap')) { if(($icServer instanceof defaultimap)) {
$icServer->updateAccount($_hookValues); $icServer->updateAccount($_hookValues);
} }
if (is_object($this->mailPreferences)) $ogServer = $this->mailPreferences->getOutgoingServer(0); if (is_object($this->mailPreferences)) $ogServer = $this->mailPreferences->getOutgoingServer(0);
if(is_a($ogServer,'defaultsmtp')) { if(($ogServer instanceof defaultsmtp)) {
$ogServer->updateAccount($_hookValues); $ogServer->updateAccount($_hookValues);
} }
} }

View File

@ -830,7 +830,7 @@ class felamimail_hooks
} }
if (is_object($preferences)) $icServer = $preferences->getIncomingServer($profileID); if (is_object($preferences)) $icServer = $preferences->getIncomingServer($profileID);
if(is_a($icServer, 'defaultimap')) { if(($icServer instanceof defaultimap)) {
if($icServer->enableSieve) if($icServer->enableSieve)
{ {
$linkData = array $linkData = array
@ -859,7 +859,7 @@ class felamimail_hooks
} }
if (is_object($preferences)) $ogServer = $preferences->getOutgoingServer(0); if (is_object($preferences)) $ogServer = $preferences->getOutgoingServer(0);
if(is_a($ogServer, 'defaultsmtp')) { if(($ogServer instanceof defaultsmtp)) {
if($ogServer->editForwardingAddress) if($ogServer->editForwardingAddress)
{ {
$linkData = array $linkData = array

View File

@ -730,7 +730,7 @@ class uifelamimail
$refreshURL = $GLOBALS['egw']->link('/index.php',$linkData); $refreshURL = $GLOBALS['egw']->link('/index.php',$linkData);
$this->t->set_var('reloadView',$refreshURL); $this->t->set_var('reloadView',$refreshURL);
// display a warning if vacation notice is active // display a warning if vacation notice is active
if(is_a($imapServer,'defaultimap') && $imapServer->enableSieve) { if(($imapServer instanceof defaultimap) && $imapServer->enableSieve) {
$imapServer->retrieveRules($imapServer->scriptName); $imapServer->retrieveRules($imapServer->scriptName);
$vacation = $imapServer->getVacation($imapServer->scriptName); $vacation = $imapServer->getVacation($imapServer->scriptName);
//_debug_array($vacation); //_debug_array($vacation);

View File

@ -126,7 +126,7 @@
$mailPrefs = $this->bofelamimail->getMailPreferences(); $mailPrefs = $this->bofelamimail->getMailPreferences();
$ogServer = $mailPrefs->getOutgoingServer(0); $ogServer = $mailPrefs->getOutgoingServer(0);
if(!is_a($ogServer, 'defaultsmtp') || !$ogServer->editForwardingAddress) { if(!($ogServer instanceof defaultsmtp) || !$ogServer->editForwardingAddress) {
die('You should not be here!'); die('You should not be here!');
} }

View File

@ -87,9 +87,9 @@
$icServer =& $this->bofelamimail->icServer; $icServer =& $this->bofelamimail->icServer;
if(is_a($icServer,'defaultimap') && $icServer->enableSieve) { if(($icServer instanceof defaultimap) && $icServer->enableSieve) {
$this->bosieve =& $icServer; $this->bosieve =& $icServer;
$this->timed_vacation = is_a($icServer,'cyrusimap') && $icServer->enableCyrusAdmin && $this->timed_vacation = ($icServer instanceof cyrusimap) && $icServer->enableCyrusAdmin &&
$icServer->adminUsername && $icServer->adminPassword; $icServer->adminUsername && $icServer->adminPassword;
} else { } else {
die('Sieve not activated'); die('Sieve not activated');
@ -572,7 +572,7 @@
$newVacation['status'] = get_var('vacationStatus',array('POST')); $newVacation['status'] = get_var('vacationStatus',array('POST'));
if (empty($preferences->preferences['prefpreventforwarding']) || if (empty($preferences->preferences['prefpreventforwarding']) ||
$preferences->preferences['prefpreventforwarding'] == 0 ) # || $preferences->preferences['prefpreventforwarding'] == 0 ) # ||
#is_a($ogServer, 'defaultsmtp') || $ogServer->editForwardingAddress) #($ogServer instanceof defaultsmtp) || $ogServer->editForwardingAddress)
{ {
$newVacation['forwards'] = get_var('vacation_forwards',array('POST')); $newVacation['forwards'] = get_var('vacation_forwards',array('POST'));
} }