mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-16 13:03:16 +01:00
fix editing mail account fills users name and email in empty identity name or email, also appending custom identity name now in brackets to identity
This commit is contained in:
parent
4204bd8aeb
commit
8743953c94
@ -175,6 +175,13 @@ class emailadmin_account implements ArrayAccess
|
||||
*/
|
||||
protected $smtpServer;
|
||||
|
||||
/**
|
||||
* Instance of Horde mail transport
|
||||
*
|
||||
* @var Horde_Mail_Transport_Smtphorde
|
||||
*/
|
||||
protected $smtpTransport;
|
||||
|
||||
/**
|
||||
* Instanciated account object by acc_id, read acts as singelton
|
||||
*
|
||||
@ -239,17 +246,10 @@ class emailadmin_account implements ArrayAccess
|
||||
(!isset($called_for) ? array() : array('acc_smtp_auth_session' => false)) + $params, !isset($called_for)
|
||||
) + $params;
|
||||
}
|
||||
if ((is_null($called_for) || $called_for == $GLOBALS['egw_info']['user']['account_id']) && empty($params['ident_realname']))
|
||||
{
|
||||
$params['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
|
||||
}
|
||||
if ((is_null($called_for) ||$called_for == $GLOBALS['egw_info']['user']['account_id']) && empty($params['ident_email']))
|
||||
{
|
||||
$params['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];
|
||||
}
|
||||
$this->params = $params;
|
||||
unset($this->imapServer);
|
||||
unset($this->smtpServer);
|
||||
unset($this->smtpTransport);
|
||||
|
||||
$this->user = $called_for ? $called_for : $GLOBALS['egw_info']['user']['account_id'];
|
||||
}
|
||||
@ -407,7 +407,7 @@ class emailadmin_account implements ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to instanciate smtp server object
|
||||
* Factory method to instanciate smtp server object / plugin to manage a mail-server from EGroupware
|
||||
*
|
||||
* @param array $params
|
||||
* @return emailadmin_smtp
|
||||
@ -446,6 +446,44 @@ class emailadmin_account implements ArrayAccess
|
||||
return $smtp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horde mail transport object
|
||||
*
|
||||
* @return Horde_Mail_Transport_Smtphorde
|
||||
*/
|
||||
public function smtpTransport()
|
||||
{
|
||||
if (!isset($this->smtpTransport))
|
||||
{
|
||||
$secure = false;
|
||||
switch($this->acc_imap_ssl & ~self::SSL_VERIFY)
|
||||
{
|
||||
case self::SSL_STARTTLS:
|
||||
$secure = 'tls'; // Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3
|
||||
break;
|
||||
case self::SSL_SSL:
|
||||
$secure = 'ssl';
|
||||
break;
|
||||
case self::SSL_TLS:
|
||||
$secure = 'tlsv1'; // since Horde_Smtp-1.3.0 requiring Horde_Socket_Client-1.1.0
|
||||
break;
|
||||
}
|
||||
// Horde use locale for translation of error messages
|
||||
common::setlocale(LC_MESSAGES);
|
||||
|
||||
$this->smtpTransport = new Horde_Mail_Transport_Smtphorde(array(
|
||||
'username' => $this->acc_smtp_username,
|
||||
'password' => $this->acc_smtp_password,
|
||||
'host' => $this->acc_smtp_host,
|
||||
'port' => $this->acc_smtp_port,
|
||||
'secure' => $secure,
|
||||
//'timeout' => self::TIMEOUT,
|
||||
//'debug' => self::DEBUG_LOG,
|
||||
));
|
||||
}
|
||||
return $this->smtpTransport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identities of given or current account (for current user!)
|
||||
*
|
||||
@ -495,7 +533,12 @@ class emailadmin_account implements ArrayAccess
|
||||
{
|
||||
$row = array_merge($row, emailadmin_credentials::from_session($row));
|
||||
}
|
||||
if (empty($row['ident_email'])||strpos($row['ident_email'],'@')===false) $row['ident_email'] = ($user == $GLOBALS['egw_info']['user']['account_id'] && $GLOBALS['egw_info']['user']['account_email']? $GLOBALS['egw_info']['user']['account_email'] :$row['acc_imap_username']);
|
||||
// fill an empty ident_realname or ident_email of current user with data from user account
|
||||
if ($replace_placeholders && (!isset($user) || $user == $GLOBALS['egw_info']['user']['acount_id']))
|
||||
{
|
||||
if (empty($row['ident_realname'])) $row['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
|
||||
if (empty($row['ident_email'])) $row['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];
|
||||
}
|
||||
if ($field != 'name')
|
||||
{
|
||||
$data = $replace_placeholders ? array_merge($row, emailadmin_account::replace_placeholders($row)) : $row;
|
||||
@ -1406,13 +1449,6 @@ class emailadmin_account implements ArrayAccess
|
||||
$account = array_merge($data, self::replace_placeholders($data));
|
||||
//error_log(__METHOD__."() account=".array2string($account).' took '.number_format(microtime(true)-$start,3));
|
||||
}
|
||||
// user specified an own name --> use just it
|
||||
if (!empty($account['ident_name']))
|
||||
{
|
||||
$name = $account['ident_name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($account['ident_email']))
|
||||
{
|
||||
try {
|
||||
@ -1446,14 +1482,18 @@ class emailadmin_account implements ArrayAccess
|
||||
{
|
||||
$name = $account['acc_name'];
|
||||
}
|
||||
if ($account['ident_email'])
|
||||
if (strpos($account['ident_email'], '@') !== false)
|
||||
{
|
||||
$name .= ' <'.$account['ident_email'].'>';
|
||||
}
|
||||
if (stripos($name, $account['acc_name']) === false)
|
||||
elseif(strpos($account['acc_imap_username'], '@') !== false)
|
||||
{
|
||||
$name .= ' '.$account['acc_name'];
|
||||
$name .= ' <'.$account['acc_imap_username'].'>';
|
||||
}
|
||||
// if user added a name of this identity, append it in brackets
|
||||
if (!empty($account['ident_name']))
|
||||
{
|
||||
$name .= ' ('.$account['ident_name'].')';
|
||||
}
|
||||
//error_log(__METHOD__."(".array2string($account).", $replace_placeholders) returning ".array2string($name));
|
||||
return $name;
|
||||
|
Loading…
Reference in New Issue
Block a user