improving ProfileValidation

This commit is contained in:
Klaus Leithoff 2011-08-02 09:00:37 +00:00
parent b186e79362
commit d64bca0330

View File

@ -116,7 +116,7 @@ class felamimail_bo
error_log(__METHOD__.__LINE__.' Validation of profile with ID:'.$_profileID.' failed. Using '.$profileID.' instead.'); error_log(__METHOD__.__LINE__.' Validation of profile with ID:'.$_profileID.' failed. Using '.$profileID.' instead.');
error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']); error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']);
$_profileID = $profileID; $_profileID = $profileID;
$GLOBALS['egw']->preferences->add('felamimail','ActiveProfileID',$_identity,'user'); $GLOBALS['egw']->preferences->add('felamimail','ActiveProfileID',$_profileID,'user');
// save prefs // save prefs
$GLOBALS['egw']->preferences->save_repository(true); $GLOBALS['egw']->preferences->save_repository(true);
egw_cache::setSession('felamimail','activeProfileID',$_profileID); egw_cache::setSession('felamimail','activeProfileID',$_profileID);
@ -159,7 +159,7 @@ class felamimail_bo
$selectedID = $mail->getIdentitiesWithAccounts($identities); $selectedID = $mail->getIdentitiesWithAccounts($identities);
$activeIdentity =& $mail->mailPreferences->getIdentity($_profileID, true); $activeIdentity =& $mail->mailPreferences->getIdentity($_profileID, true);
// if you use user defined accounts you may want to access the profile defined with the emailadmin available to the user // if you use user defined accounts you may want to access the profile defined with the emailadmin available to the user
if ($activeIdentity->id || $_profileID < 0) { // as we validate the profile in question and may need to return an emailadminprofile, we fetch this one all the time
$boemailadmin = new emailadmin_bo(); $boemailadmin = new emailadmin_bo();
$defaultProfile = $boemailadmin->getUserProfile() ; $defaultProfile = $boemailadmin->getUserProfile() ;
//error_log(__METHOD__.__LINE__.array2string($defaultProfile)); //error_log(__METHOD__.__LINE__.array2string($defaultProfile));
@ -170,8 +170,6 @@ class felamimail_bo
if (empty($icServers[$tmpkey]->host)) continue; if (empty($icServers[$tmpkey]->host)) continue;
$identities[$identity->id] = $identity->realName.' '.$identity->organization.' <'.$identity->emailAddress.'>'; $identities[$identity->id] = $identity->realName.' '.$identity->organization.' <'.$identity->emailAddress.'>';
} }
//$identities[0] = $defaultIdentity->realName.' '.$defaultIdentity->organization.' <'.$defaultIdentity->emailAddress.'>';
}
//error_log(__METHOD__.__LINE__.array2string($identities)); //error_log(__METHOD__.__LINE__.array2string($identities));
if (array_key_exists($_profileID,$identities)) if (array_key_exists($_profileID,$identities))
@ -186,7 +184,11 @@ class felamimail_bo
} }
else else
{ {
foreach (array_keys((array)$identities) as $k => $ident) if ($ident <0) $_profileID = $ident; foreach (array_keys((array)$identities) as $k => $ident)
{
//error_log(__METHOD__.__LINE__.' Testing Identity with ID:'.$ident.' for being provided by emailadmin.');
if ($ident <0) $_profileID = $ident;
}
if (self::$debug) error_log(__METHOD__.__LINE__.' Profile Selected (after trying to fetch DefaultProfile):'.array2string($_profileID)); if (self::$debug) error_log(__METHOD__.__LINE__.' Profile Selected (after trying to fetch DefaultProfile):'.array2string($_profileID));
if (!array_key_exists($_profileID,$identities)) if (!array_key_exists($_profileID,$identities))
{ {