5 Commits
4.4 ... 4.4.2

Author SHA1 Message Date
Boris Gulay
5577699dae Fix incompatibility introduced in PR #4.
Closes #88.
2022-08-01 21:55:30 +03:00
Gergely Papp
eb8175fb7c Merged in master (pull request #5)
Fixes for #74, #82

Approved-by: Boris Gulay
2022-02-09 18:16:02 +00:00
Gergely Papp
3e803f65a2 Merged BoresExpress/ident_switch into master 2022-02-01 13:07:49 +01:00
Gergely Papp
5aed4c9947 fixes #74 2021-12-28 16:11:48 +00:00
Gergely Papp
46eba62185 Fixes #82 2021-12-28 16:10:23 +00:00

View File

@@ -4,7 +4,7 @@
* *
* This plugin allows fast switching between accounts. * This plugin allows fast switching between accounts.
* *
* @version 1.0 * @version 4.4.2
* @author Boris Gulay * @author Boris Gulay
* @url * @url
*/ */
@@ -69,7 +69,7 @@ class ident_switch extends rcube_plugin
{ {
$defaultKey = $type . '_mbox_default' . self::MY_POSTFIX; $defaultKey = $type . '_mbox_default' . self::MY_POSTFIX;
$otherKey = $type . '_mbox' . 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); $rc->config->set($type . '_mbox', $val);
} }
@@ -107,7 +107,7 @@ class ident_switch extends rcube_plugin
elseif (ctype_digit($iid_s)) elseif (ctype_digit($iid_s))
$iid = intval($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); $accValues = array(-1);
$accSelected = -1; $accSelected = -1;
@@ -192,16 +192,32 @@ class ident_switch extends rcube_plugin
$args['smtp_user'] = $r['username']; $args['smtp_user'] = $r['username'];
$args['smtp_pass'] = $r['smtp_auth'] == self::SMTP_AUTH_IMAP ? $rc->decrypt($r['password']) : ''; $args['smtp_pass'] = $r['smtp_auth'] == self::SMTP_AUTH_IMAP ? $rc->decrypt($r['password']) : '';
$args['smtp_host'] = $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 ($r['flags'] & self::DB_SECURE_IMAP_TLS)
{ {
if (strpos($args['smtp_host'], ':') !== false) if (strpos($args[$paramSmtpHost], ':') !== false)
self::write_log('SMTP server already contains protocol, ignoring TLS flag.'); self::write_log('SMTP server already contains protocol, ignoring TLS flag.');
else else
$args['smtp_host'] = 'tls://' . $args['smtp_host']; $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; return $args;
@@ -671,6 +687,8 @@ class ident_switch extends rcube_plugin
$rc->session->remove($k); $rc->session->remove($k);
} }
} }
$delimiter = isset($config['imap_delimiter']) ? $config['imap_delimiter']:'.';
$_SESSION['imap_delimiter'] = $delimiter;
$_SESSION['username'] = $rc->user->data['username']; $_SESSION['username'] = $rc->user->data['username'];
$_SESSION['password'] = $_SESSION['password' . self::MY_POSTFIX]; $_SESSION['password'] = $_SESSION['password' . self::MY_POSTFIX];
$_SESSION['iid' . self::MY_POSTFIX] = -1; $_SESSION['iid' . self::MY_POSTFIX] = -1;
@@ -678,7 +696,7 @@ class ident_switch extends rcube_plugin
foreach (rcube_storage::$folder_types as $type) foreach (rcube_storage::$folder_types as $type)
{ {
$otherKey = $type . '_mbox' . self::MY_POSTFIX; $otherKey = $type . '_mbox' . self::MY_POSTFIX;
if ($_SESSION[$otherKey]) if (isset($_SESSION[$otherKey]))
$rc->session->remove($otherKey); $rc->session->remove($otherKey);
} }
} }
@@ -706,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 (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]; $_SESSION[$k . self::MY_POSTFIX] = $_SESSION[$k];
$rc->session->remove($k); $rc->session->remove($k);
@@ -716,7 +734,7 @@ class ident_switch extends rcube_plugin
$moreToSave = array('password', 'imap_delimiter'); $moreToSave = array('password', 'imap_delimiter');
foreach ($moreToSave as $k) foreach ($moreToSave as $k)
{ {
if (!$_SESSION[$k . self::MY_POSTFIX]) if (!isset($_SESSION[$k . self::MY_POSTFIX]))
$_SESSION[$k . self::MY_POSTFIX] = $_SESSION[$k]; $_SESSION[$k . self::MY_POSTFIX] = $_SESSION[$k];
$rc->session->remove($k); $rc->session->remove($k);
@@ -737,7 +755,7 @@ class ident_switch extends rcube_plugin
if ($ssl && strncasecmp($host, $hostProtocol, strlen($hostProtocol)) !== 0) if ($ssl && strncasecmp($host, $hostProtocol, strlen($hostProtocol)) !== 0)
$host = $hostProtocol . $host; $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_host'] = $host;
$_SESSION['storage_ssl'] = $ssl; $_SESSION['storage_ssl'] = $ssl;
@@ -749,7 +767,7 @@ class ident_switch extends rcube_plugin
foreach (rcube_storage::$folder_types as $type) foreach (rcube_storage::$folder_types as $type)
{ {
if ($r[$type . '_mbox']) { if (isset($r[$type . '_mbox'])) {
$otherKey = $type . '_mbox' . self::MY_POSTFIX; $otherKey = $type . '_mbox' . self::MY_POSTFIX;
$_SESSION[$otherKey] = $r[$type . '_mbox']; $_SESSION[$otherKey] = $r[$type . '_mbox'];
} }