1
0
mirror of https://github.com/EGroupware/egroupware.git synced 2025-04-02 04:07:19 +02:00

* emailadmin: restored capability of storing basic default mail server settings back to config on saving active profiles that are allowed for all apps, groups and users; remove obsolet code

This commit is contained in:
Klaus Leithoff 2011-06-20 15:37:19 +00:00
parent 620c91e755
commit 173cb6e842

View File

@ -324,6 +324,48 @@ class emailadmin_bo extends so_sql
$content = $this->data;
$old = $this->read($content);
$this->data = $content;
if ((!isset($this->data['ea_appname']) || empty($this->data['ea_appname']) ) &&
(!isset($this->data['ea_group']) || empty($this->data['ea_group']) ) &&
(!isset($this->data['ea_user']) || empty($this->data['ea_user']) ) &&
(isset($this->data['ea_active']) && !empty($this->data['ea_active']) && $this->data['ea_active'] ))
{
//error_log(__METHOD__.__LINE__.' Content to save:'.array2string($this->data));
$new_config = array();
foreach(array(
'ea_imap_server' => 'mail_server',
'ea_imap_type' => 'mail_server_type',
'ea_imap_login_type' => 'mail_login_type',
'ea_default_domain' => 'mail_suffix',
'ea_smtp_server' => 'smtp_server',
'ea_smtp_port' => 'smpt_port',
)+($this->data['ea_smtp_auth']=='yes' ? array( //ToDo: if no, we may have to reset config values for that too?
'ea_smtp_auth_username' => 'smtp_auth_user',
'ea_smtp_auth_password' => 'smtp_auth_passwd',
) : array()) as $ea_name => $config_name)
{
if (isset($this->data[$ea_name]))
{
if ($ea_name != 'ea_imap_type')
{
$new_config[$config_name] = $this->data[$ea_name];
}
else // imap type, no pop3 code anymore
{
$new_config[$config_name] = 'imap'.($this->data['ea_imap_tsl_encryption'] ? 's' : '');
}
}
}
if (count($new_config))
{
foreach($new_config as $name => $value)
{
//error_log(__METHOD__.__LINE__.' Saving to config:'."$name,$value,phpgwapi");
config::save_value($name,$value,'phpgwapi');
}
//echo "<p>eGW configuration update: ".print_r($new_config,true)."</p>\n";
}
}
if (!($result = parent::save()))
{
$GLOBALS['egw']->contenthistory->updateTimeStamp('emailadmin_profiles', $this->data['ea_profile_id'], $old === false ? 'add' : 'modify', time());
@ -831,69 +873,6 @@ class emailadmin_bo extends so_sql
//echo "<p>EMailAdmin profile update: ".print_r($profile,true)."</p>\n"; exit;
}
function saveProfile($_globalSettings, $_smtpSettings, $_imapSettings)
{
if(!isset($_imapSettings['imapTLSAuthentication'])) {
$_imapSettings['imapTLSAuthentication'] = true;
}
if(is_array($_globalSettings['ea_stationery_active_templates']) && count($_globalSettings['ea_stationery_active_templates']) > 0)
{
$_globalSettings['ea_stationery_active_templates'] = serialize($_globalSettings['ea_stationery_active_templates']);
}
else
{
$_globalSettings['ea_stationery_active_templates'] = null;
}
if(!isset($_globalSettings['profileID'])) {
$_globalSettings['ea_order'] = count($this->getProfileList()) + 1;
$this->soemailadmin->addProfile($_globalSettings, $_smtpSettings, $_imapSettings);
} else {
$this->soemailadmin->updateProfile($_globalSettings, $_smtpSettings, $_imapSettings);
}
$all = $_globalSettings+$_smtpSettings+$_imapSettings;
if (!$all['ea_user'] && !$all['ea_group'] && !$all['ea_application']) // standard profile update eGW config
{
$new_config = array();
foreach(array(
'imapServer' => 'mail_server',
'imapType' => 'mail_server_type',
'imapLoginType' => 'mail_login_type',
'defaultDomain' => 'mail_suffix',
'smtpServer' => 'smtp_server',
'smtpPort' => 'smtp_port',
)+($all['smtpAuth'] ? array(
'ea_smtp_auth_username' => 'smtp_auth_user',
'ea_smtp_auth_password' => 'smtp_auth_passwd',
) : array()) as $ea_name => $config_name)
{
if (isset($all[$ea_name]))
{
if ($ea_name != 'imapType')
{
$new_config[$config_name] = $all[$ea_name];
}
else // imap type, no pop3 code anymore
{
$new_config[$config_name] = 'imap'.($all['imapTLSEncryption'] ? 's' : '');
}
}
}
if (count($new_config))
{
$config = CreateObject('phpgwapi.config','phpgwapi');
foreach($new_config as $name => $value)
{
$config->save_value($name,$value,'phpgwapi');
}
//echo "<p>eGW configuration update: ".print_r($new_config,true)."</p>\n";
}
}
self::$sessionData = array();
$this->saveSessionData();
}
function saveSessionData()
{