* eMail: allow user to view / change its ActiveProfileID (quite useful if you have a basic misconfiguration)

This commit is contained in:
Klaus Leithoff 2013-05-08 11:19:49 +00:00
parent dbe205bdea
commit 8b4224acbc
2 changed files with 58 additions and 1 deletions

View File

@ -470,11 +470,24 @@ class felamimail_bo
return $bofelamimail;
}
public static function forcePrefReload()
public static function forcePrefReload($hook_data=null)
{
// unset the fm_preferences session object, to force the reload/rebuild
$GLOBALS['egw']->session->appsession('fm_preferences','felamimail',serialize(array()));
$GLOBALS['egw']->session->appsession('session_data','emailadmin',serialize(array()));
// this section takes care for setting the ActiveProfileID accordingly
if (!empty($hook_data) && $hook_data['type']=='user')
{
if (isset($hook_data['prefs']['ActiveProfileID']) && $hook_data['prefs']['ActiveProfileID'] != $GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'])
{
//error_log(__METHOD__.__LINE__.array2string(array_keys($hook_data['prefs'])));
$icServerID = $hook_data['prefs']['ActiveProfileID'];
$bopreferences = CreateObject('felamimail.bopreferences',true);
$bopreferences->setProfileActive(false);
if ($icServerID>0) $bopreferences->setProfileActive(true,$icServerID);
}
if (empty($hook_data['prefs']['ActiveProfileID'])) return lang('Error').': '.lang("Active ProfileID should not be empty");
}
}
function _getNameSpaces()

View File

@ -118,7 +118,40 @@ class felamimail_hooks
$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'];
$bofelamimail = felamimail_bo::getInstance(true,$profileID);
$identities = array();
if ($GLOBALS['type'] === 'user')
{
// gather profile data
$imapServer =& $bofelamimail->icServer;
//error_log(__METHOD__.__LINE__.array2string($imapServer));
// account select box
$selectedID = $bofelamimail->getIdentitiesWithAccounts($identities);
}
$profileID = $GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'] = $bofelamimail->profileID;
if ($GLOBALS['type'] === 'user')
{
$preferences =& $bofelamimail->mailPreferences;
$activeIdentity =& $preferences->getIdentity($profileID, true);
//error_log(__METHOD__.__LINE__.' ActiveIdentity for profileID'.$icServerID.'->'.array2string($activeIdentity));
// the data needed here are collected at the start of this function
if (!isset($activeIdentity->id) && $selectedID == $profileID) {
$identities[$profileID] = $activeIdentity->realName.' '.$activeIdentity->organization.' <'.$activeIdentity->emailAddress.'>';
}
// if you use user defined accounts you may want to access the profile defined with the emailadmin available to the user
if ($activeIdentity->id) {
$boemailadmin = new emailadmin_bo();
$defaultProfile = $boemailadmin->getUserProfile() ;
//error_log(__METHOD__.__LINE__.array2string($defaultProfile));
$identitys =& $defaultProfile->identities;
$icServers =& $defaultProfile->ic_server;
foreach ($identitys as $tmpkey => $identity)
{
if (empty($icServers[$tmpkey]->host)) continue;
$identities[$identity->id] = $identity->realName.' '.$identity->organization.' <'.$identity->emailAddress.'>';
}
//$identities[0] = $defaultIdentity->realName.' '.$defaultIdentity->organization.' <'.$defaultIdentity->emailAddress.'>';
}
}
if($bofelamimail->openConnection($profileID)) {
$folderObjects = $bofelamimail->getFolderObjects(true, false);
foreach($folderObjects as $folderName => $folderInfo) {
@ -322,6 +355,16 @@ class felamimail_hooks
'xmlrpc' => False,
'admin' => False
),
'ActiveProfileID' => array(
'type' => 'select',
'label' => 'Active Mail Profile',
'help' => 'view / select your currently active mailprofile (this is a user only setting)',
'name' => 'ActiveProfileID',
'values' => $identities,
'xmlrpc' => True,
'admin' => False,
'default'=> $profileID,
),
'message_forwarding' => array(
'type' => 'select',
'label' => 'how to forward messages',
@ -718,6 +761,7 @@ class felamimail_hooks
),
);
if (!$GLOBALS['egw_info']['apps']['stylite']) unset($settingsArray['attachVCardAtCompose']);
if (!($GLOBALS['type'] === 'user')) unset($settingsArray['ActiveProfileID']);
return $settingsArray;
}