|
|
|
|
@@ -4,7 +4,7 @@
|
|
|
|
|
*
|
|
|
|
|
* This plugin allows fast switching between accounts.
|
|
|
|
|
*
|
|
|
|
|
* @version 1.0
|
|
|
|
|
* @version 4.4.2
|
|
|
|
|
* @author Boris Gulay
|
|
|
|
|
* @url
|
|
|
|
|
*/
|
|
|
|
|
@@ -69,7 +69,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
{
|
|
|
|
|
$defaultKey = $type . '_mbox_default' . self::MY_POSTFIX;
|
|
|
|
|
$otherKey = $type . '_mbox' . self::MY_POSTFIX;
|
|
|
|
|
$val = $_SESSION[$otherKey] ? $_SESSION[$otherKey] : $_SESSION[$defaultKey];
|
|
|
|
|
$val = isset($_SESSION[$otherKey]) ? $_SESSION[$otherKey] : $_SESSION[$defaultKey];
|
|
|
|
|
$rc->config->set($type . '_mbox', $val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -107,7 +107,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
elseif (ctype_digit($iid_s))
|
|
|
|
|
$iid = intval($iid_s);
|
|
|
|
|
|
|
|
|
|
$accNames = array($_SESSION['global_alias'] ? $_SESSION['global_alias'] : $rc->user->data['username']);
|
|
|
|
|
$accNames = array(isset($_SESSION['global_alias']) ? $_SESSION['global_alias'] : $rc->user->data['username']);
|
|
|
|
|
$accValues = array(-1);
|
|
|
|
|
$accSelected = -1;
|
|
|
|
|
|
|
|
|
|
@@ -159,7 +159,20 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
{
|
|
|
|
|
$iid = $_SESSION['iid' . self::MY_POSTFIX];
|
|
|
|
|
if (!is_numeric($iid) || $iid == -1)
|
|
|
|
|
{
|
|
|
|
|
self::write_log('no identity switch is selected... trying to find related smtp server from the from header');
|
|
|
|
|
$requestFrom = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST);
|
|
|
|
|
if (empty($requestFrom)) {
|
|
|
|
|
self::write_log('no _from post parameter found... falling back to original default config');
|
|
|
|
|
return $args;
|
|
|
|
|
} else {
|
|
|
|
|
$iid = intval($requestFrom);
|
|
|
|
|
if ($iid == 0) {
|
|
|
|
|
self::write_log('falling back to original default config as _from post field is no integer: ' . $_POST['_from']);
|
|
|
|
|
return $args;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rc = rcmail::get_instance();
|
|
|
|
|
|
|
|
|
|
@@ -179,16 +192,32 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
$args['smtp_user'] = $r['username'];
|
|
|
|
|
$args['smtp_pass'] = $r['smtp_auth'] == self::SMTP_AUTH_IMAP ? $rc->decrypt($r['password']) : '';
|
|
|
|
|
$args['smtp_server'] = $r['smtp_host'] ? $r['smtp_host'] : 'localhost'; // Default SMTP host here
|
|
|
|
|
$args['smtp_port'] = $r['smtp_port'] ? $r['smtp_port'] : 587; // Default SMTP port here
|
|
|
|
|
|
|
|
|
|
# In 1.6 smtp_server was renamed to smtp_host and includes port. smtp_port was depricated.
|
|
|
|
|
$verParts = explode('.', RCMAIL_VERSION, 3);
|
|
|
|
|
$paramSmtpHost = 'smtp_host';
|
|
|
|
|
$paramSmtpPort = null;
|
|
|
|
|
if (intval($verParts[0]) <= 1 && intval($verParts[1]) < 6)
|
|
|
|
|
{
|
|
|
|
|
$paramSmtpHost = 'smtp_server';
|
|
|
|
|
$paramSmtpPort = 'smtp_port';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$args[$paramSmtpHost] = $r['smtp_host'] ? $r['smtp_host'] : 'localhost'; // Default SMTP host here
|
|
|
|
|
|
|
|
|
|
if ($r['flags'] & self::DB_SECURE_IMAP_TLS)
|
|
|
|
|
{
|
|
|
|
|
if (strpos($args['smtp_server'], ':') !== false)
|
|
|
|
|
if (strpos($args[$paramSmtpHost], ':') !== false)
|
|
|
|
|
self::write_log('SMTP server already contains protocol, ignoring TLS flag.');
|
|
|
|
|
else
|
|
|
|
|
$args['smtp_server'] = 'tls://' . $args['smtp_server'];
|
|
|
|
|
$args[$paramSmtpHost] = 'tls://' . $args[$paramSmtpHost];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$smtpPort = $r['smtp_port'] ? $r['smtp_port'] : 587; // Default SMTP port here
|
|
|
|
|
if ($paramSmtpPort)
|
|
|
|
|
$args[$paramSmtpPort] = $smtpPort;
|
|
|
|
|
else
|
|
|
|
|
$args[$paramSmtpHost] .= ':' . $smtpPort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
|
@@ -658,6 +687,8 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
$rc->session->remove($k);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$delimiter = isset($config['imap_delimiter']) ? $config['imap_delimiter']:'.';
|
|
|
|
|
$_SESSION['imap_delimiter'] = $delimiter;
|
|
|
|
|
$_SESSION['username'] = $rc->user->data['username'];
|
|
|
|
|
$_SESSION['password'] = $_SESSION['password' . self::MY_POSTFIX];
|
|
|
|
|
$_SESSION['iid' . self::MY_POSTFIX] = -1;
|
|
|
|
|
@@ -665,7 +696,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
foreach (rcube_storage::$folder_types as $type)
|
|
|
|
|
{
|
|
|
|
|
$otherKey = $type . '_mbox' . self::MY_POSTFIX;
|
|
|
|
|
if ($_SESSION[$otherKey])
|
|
|
|
|
if (isset($_SESSION[$otherKey]))
|
|
|
|
|
$rc->session->remove($otherKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -693,7 +724,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
{
|
|
|
|
|
if (strncasecmp($k, 'storage', 7) === 0 && substr_compare($k, self::MY_POSTFIX, -$my_postfix_len, $my_postfix_len) !== 0)
|
|
|
|
|
{
|
|
|
|
|
if (!$_SESSION[$k . self::MY_POSTFIX])
|
|
|
|
|
if (!isset($_SESSION[$k . self::MY_POSTFIX]))
|
|
|
|
|
$_SESSION[$k . self::MY_POSTFIX] = $_SESSION[$k];
|
|
|
|
|
|
|
|
|
|
$rc->session->remove($k);
|
|
|
|
|
@@ -703,7 +734,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
$moreToSave = array('password', 'imap_delimiter');
|
|
|
|
|
foreach ($moreToSave as $k)
|
|
|
|
|
{
|
|
|
|
|
if (!$_SESSION[$k . self::MY_POSTFIX])
|
|
|
|
|
if (!isset($_SESSION[$k . self::MY_POSTFIX]))
|
|
|
|
|
$_SESSION[$k . self::MY_POSTFIX] = $_SESSION[$k];
|
|
|
|
|
|
|
|
|
|
$rc->session->remove($k);
|
|
|
|
|
@@ -724,7 +755,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
if ($ssl && strncasecmp($host, $hostProtocol, strlen($hostProtocol)) !== 0)
|
|
|
|
|
$host = $hostProtocol . $host;
|
|
|
|
|
|
|
|
|
|
$delimiter = $r['imap_delimiter'] ? $r['imap_delimiter'] : '.'; // Default delimiter here
|
|
|
|
|
$delimiter = isset($r['imap_delimiter']) ? $r['imap_delimiter'] : '.'; // Default delimiter here
|
|
|
|
|
|
|
|
|
|
$_SESSION['storage_host'] = $host;
|
|
|
|
|
$_SESSION['storage_ssl'] = $ssl;
|
|
|
|
|
@@ -736,7 +767,7 @@ class ident_switch extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
foreach (rcube_storage::$folder_types as $type)
|
|
|
|
|
{
|
|
|
|
|
if ($r[$type . '_mbox']) {
|
|
|
|
|
if (isset($r[$type . '_mbox'])) {
|
|
|
|
|
$otherKey = $type . '_mbox' . self::MY_POSTFIX;
|
|
|
|
|
$_SESSION[$otherKey] = $r[$type . '_mbox'];
|
|
|
|
|
}
|
|
|
|
|
|