* eMail: reintroduce the ability to set a identity as default;(available only for userDefinedAccounts=false); userDefinedAccounts=true are not longer allowed to save a profile without host as active

This commit is contained in:
Klaus Leithoff 2013-04-23 07:38:55 +00:00
parent 1d167b8662
commit 0daf34ae79
7 changed files with 37 additions and 11 deletions

View File

@ -563,7 +563,7 @@ class ajaxfelamimail
function changeActiveAccount($accountData)
{
if($this->_debug) error_log("ajaxfelamimail::changeActiveAccount");
if($this->_debug) error_log("ajaxfelamimail::changeActiveAccount".array2string($accountData));
require_once(EGW_INCLUDE_ROOT.'/felamimail/inc/class.bopreferences.inc.php');
$boPreferences = CreateObject('felamimail.bopreferences');
$boPreferences->setProfileActive(false);

View File

@ -420,7 +420,7 @@
parent::deleteAccountData($GLOBALS['egw_info']['user']['account_id'], $identity);
}
function setProfileActive($_status, $_identity=NULL)
function setProfileActive($_status, $_identity=NULL, $_identityOnly=false)
{
$this->sessionData = array();
$this->saveSessionData();
@ -428,11 +428,12 @@
{
//error_log(__METHOD__.__LINE__.' change status of Profile '.$_identity.' to '.$_status);
// globals preferences add appname varname value
$GLOBALS['egw']->preferences->add('felamimail','ActiveProfileID',$_identity,'user');
if (!$_identityOnly) $GLOBALS['egw']->preferences->add('felamimail','ActiveProfileID',$_identity,'user');
// save prefs
$GLOBALS['egw']->preferences->save_repository(true);
egw_cache::setSession('felamimail','activeProfileID',$_identity);
if (!$_identityOnly) $GLOBALS['egw']->preferences->save_repository(true);
if (!$_identityOnly) egw_cache::setSession('felamimail','activeProfileID',$_identity);
}
// the parentCall only saves the database value
parent::setProfileActive($GLOBALS['egw_info']['user']['account_id'], $_status, $_identity);
}
}

View File

@ -247,6 +247,11 @@ class felamimail_bo
{
$loadfailed=true;
}
if ($_profileID>0 && empty(self::$instances[$_profileID]->icServer->host))
{
$_profileID = emailadmin_bo::getUserDefaultProfileID();
$loadfailed=true;
}
if ($loadfailed)
{
error_log(__METHOD__.__LINE__." ReRead of the Prefs for ProfileID ".$_profileID.' failed for icServer; trigger new instance. called from:'.function_backtrace());

View File

@ -569,7 +569,16 @@
// not set? -> use default, means full display of all available data
if (!isset(felamimail_bo::$felamimailConfig['how2displayIdentities'])) felamimail_bo::$felamimailConfig['how2displayIdentities'] ='';
$globalIds = 0;
foreach($allIdentities as $key => $singleIdentity) {if ($singleIdentity->id<0){ $globalIds++; }/*else{ unset($allIdentities[$key]);}*/};
$defaultIds = array();
foreach($allIdentities as $key => $singleIdentity) {
if ($singleIdentity->id<0){ $globalIds++; }/*else{ unset($allIdentities[$key]);}*/
// there could be up to 2 default IDS. the activeProfile and another on marking the desired Identity to choose
if(!empty($singleIdentity->default) && $singleIdentity->default==1) $defaultIds[$singleIdentity->id] = $singleIdentity->id;
}
//error_log(__METHOD__.__LINE__.' Identities regarded/marked as default:'.array2string($defaultIds). ' MailProfileActive:'.$this->bofelamimail->profileID);
// if there are 2 defaultIDs, its most likely, that the user choose to set
// the one not being the activeServerProfile to be his default Identity
if (count($defaultIds)>1) unset($defaultIds[$this->bofelamimail->profileID]);
$defaultIdentity = 0;
$identities = array();
foreach($allIdentities as $key => $singleIdentity) {
@ -583,9 +592,9 @@
{
$id_prepend = '('.$singleIdentity->id.') ';
}
//error_log(__METHOD__.__LINE__.':'.$presetId.'->'.$key.'('.$singleIdentity->id.')'.'#'.$iS.'#');
//if ($singleIdentity->default) error_log(__METHOD__.__LINE__.':'.$presetId.'->'.$key.'('.$singleIdentity->id.')'.'#'.$iS.'#');
if (array_search($id_prepend.$iS,$identities)===false) $identities[$singleIdentity->id] = $id_prepend.$iS;
if(!empty($singleIdentity->default) && $singleIdentity->default==1 && $defaultIdentity==0)
if(in_array($singleIdentity->id,$defaultIds) && $defaultIdentity==0)
{
//_debug_array($singleIdentity);
$defaultIdentity = $singleIdentity->id;

View File

@ -363,13 +363,20 @@
$newID = $this->bopreferences->saveAccountData($icServer, $ogServer, $identity);
$identityOnly = empty($icServer->host);
// if you are only allowed to do Identities: everything will be regarded as Identity
if(!$preferences->userDefinedAccounts && $preferences->userDefinedIdentities) $identityOnly = true;
if ($identity->id == 'new') $identity->id = $newID;
if((int)$_POST['active']) {
#$boPreferences->saveAccountData($icServer, $ogServer, $identity);
$this->bopreferences->setProfileActive(false);
$this->bopreferences->setProfileActive(true,$identity->id);
if (($preferences->userDefinedAccounts && !$identityOnly) ||
($preferences->userDefinedIdentities && !$preferences->userDefinedAccounts))
{
$this->bopreferences->setProfileActive(false, NULL,$identityOnly);
$this->bopreferences->setProfileActive(true,$identity->id,$identityOnly);
}
} else {
$this->bopreferences->setProfileActive(false,$identity->id);
$this->bopreferences->setProfileActive(false,$identity->id,$identityOnly);
}
if($_POST['save']) {
@ -388,6 +395,8 @@
$this->t->set_block('body','main');
if ($msg) $this->t->set_var("message", $msg); else $this->t->set_var("message", '');
$this->translate();
if(!$preferences->userDefinedAccounts && $preferences->userDefinedIdentities) $this->t->set_var('lang_use_costum_settings',lang('use as default identity'));
// initalize the folderList array
$folderList = array();

View File

@ -612,6 +612,7 @@ use <a href="%1">emailadmin</a> to create profiles felamimail de benutzen Sie <a
use a signature felamimail de Signatur benutzen
use a signature? felamimail de Eine Signatur benutzen?
use addresses felamimail de Adresse benutzen
use as default identity felamimail de als Standardidentität verwenden
use common preferences max. messages felamimail de Verwende die allgemeine Einstellung für max. Treffer pro Seite
use custom identities felamimail de benutze benutzerdefinierte Identitäten
use custom settings felamimail de benutze angepasste Einstellungen

View File

@ -612,6 +612,7 @@ use <a href="%1">emailadmin</a> to create profiles felamimail en Use <a href="%1
use a signature felamimail en Use signature
use a signature? felamimail en Use signature
use addresses felamimail en Use addresses
use as default identity felamimail en use as default identity
use common preferences max. messages felamimail en Use common preferences max. messages
use custom identities felamimail en Use custom identities
use custom settings felamimail en Use custom settings