Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24a9584d6f | ||
|
|
bcea012af0 |
@@ -16,3 +16,6 @@ This plugin allows users to switch between different accounts (including remote)
|
||||
* Branch 3.X - for Roundcube v1.3
|
||||
|
||||
Please specify verion like "~2.0" in your composer.json file for ident_switch requirement. In this case you will stay inside compatible branch until you manually update ypur Roundcube installation.
|
||||
|
||||
### Switching SMTP ###
|
||||
Plugin also switched SMTP credentials but only for server specified in general config. You should use %u and %p substitutions for user and password to make it work. This substitutions are replaced by username and password for selected IMAP account.
|
||||
|
||||
@@ -150,16 +150,29 @@ class ident_switch extends rcube_plugin
|
||||
|
||||
function on_smtp_connect($args)
|
||||
{
|
||||
$iid = $_SESSION['iid' . self::MY_POSTFIX];
|
||||
if (!is_integer($iid) || $iid == -1)
|
||||
return $args;
|
||||
|
||||
$rc = rcmail::get_instance();
|
||||
|
||||
// TODO: Rewrite with full settings!
|
||||
|
||||
if (strcasecmp($rc->user->data['username'], $_SESSION['username']) !== 0)
|
||||
$sql = 'SELECT host, flags, port, username, password, iid FROM ' . $rc->db->table_name(self::TABLE) . ' WHERE iid = ? AND user_id = ?';
|
||||
$q = $rc->db->query($sql, $iid ,$rc->user->ID);
|
||||
$r = $rc->db->fetch_assoc($q);
|
||||
if (is_array($r))
|
||||
{
|
||||
if ($args['smtp_user'] == '%u')
|
||||
$args['smtp_user'] = $rc->user->data['username'];
|
||||
if ($args['smtp_pass'] == '%p')
|
||||
$args['smtp_pass'] = $rc->decrypt($_SESSION['password' . self::MY_POSTFIX]);
|
||||
if (!$r['username'])
|
||||
{ // Load email from identity
|
||||
$sql = 'SELECT email FROM ' . $rc->db->table_name('identities') . ' WHERE identity_id = ?';
|
||||
$q = $rc->db->query($sql, $r['iid']);
|
||||
$rIid = $rc->db->fetch_assoc($q);
|
||||
|
||||
$r['username'] = $rIid['email'];
|
||||
}
|
||||
|
||||
// Exactly the same in core SMTP handler
|
||||
$args['smtp_user'] = str_replace('%u', $r['username'], $args['smtp_user']);
|
||||
$args['smtp_pass'] = str_replace('%p', $rc->decrypt($r['password']), $args['smtp_pass']);
|
||||
}
|
||||
|
||||
return $args;
|
||||
@@ -267,7 +280,7 @@ class ident_switch extends rcube_plugin
|
||||
// Process boolean fields
|
||||
if (!rcube_utils::get_input_value('_ident_switch_form_enabled', rcube_utils::INPUT_POST))
|
||||
{
|
||||
self::sw_imap_off($args['iid']);
|
||||
self::sw_imap_off($args['id']);
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user