Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24a9584d6f | ||
|
|
bcea012af0 | ||
|
|
a437a107ba |
@@ -16,3 +16,6 @@ This plugin allows users to switch between different accounts (including remote)
|
|||||||
* Branch 3.X - for Roundcube v1.3
|
* 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.
|
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.
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ CREATE TABLE IF NOT EXISTS ident_switch
|
|||||||
int(10) UNSIGNED
|
int(10) UNSIGNED
|
||||||
NOT NULL,
|
NOT NULL,
|
||||||
username
|
username
|
||||||
varchar(64)
|
varchar(64),
|
||||||
NOT NULL,
|
|
||||||
password
|
password
|
||||||
varchar(64),
|
varchar(64),
|
||||||
host
|
host
|
||||||
|
|||||||
6
SQL/mysql/2018071600.sql
Normal file
6
SQL/mysql/2018071600.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE
|
||||||
|
ident_switch
|
||||||
|
MODIFY
|
||||||
|
username
|
||||||
|
varchar(64)
|
||||||
|
NULL;
|
||||||
@@ -13,8 +13,7 @@ CREATE TABLE ident_switch
|
|||||||
REFERENCES identities(identity_id) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES identities(identity_id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
UNIQUE,
|
UNIQUE,
|
||||||
username
|
username
|
||||||
varchar(64)
|
varchar(64),
|
||||||
NOT NULL,
|
|
||||||
password
|
password
|
||||||
varchar(64),
|
varchar(64),
|
||||||
host
|
host
|
||||||
|
|||||||
5
SQL/postgres/2018081600.sql
Normal file
5
SQL/postgres/2018081600.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE
|
||||||
|
ident_switch
|
||||||
|
ALTER COLUMN
|
||||||
|
username
|
||||||
|
DROP NOT NULL;
|
||||||
@@ -150,16 +150,29 @@ class ident_switch extends rcube_plugin
|
|||||||
|
|
||||||
function on_smtp_connect($args)
|
function on_smtp_connect($args)
|
||||||
{
|
{
|
||||||
|
$iid = $_SESSION['iid' . self::MY_POSTFIX];
|
||||||
|
if (!is_integer($iid) || $iid == -1)
|
||||||
|
return $args;
|
||||||
|
|
||||||
$rc = rcmail::get_instance();
|
$rc = rcmail::get_instance();
|
||||||
|
|
||||||
// TODO: Rewrite with full settings!
|
$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);
|
||||||
if (strcasecmp($rc->user->data['username'], $_SESSION['username']) !== 0)
|
$r = $rc->db->fetch_assoc($q);
|
||||||
|
if (is_array($r))
|
||||||
{
|
{
|
||||||
if ($args['smtp_user'] == '%u')
|
if (!$r['username'])
|
||||||
$args['smtp_user'] = $rc->user->data['username'];
|
{ // Load email from identity
|
||||||
if ($args['smtp_pass'] == '%p')
|
$sql = 'SELECT email FROM ' . $rc->db->table_name('identities') . ' WHERE identity_id = ?';
|
||||||
$args['smtp_pass'] = $rc->decrypt($_SESSION['password' . self::MY_POSTFIX]);
|
$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;
|
return $args;
|
||||||
@@ -267,7 +280,7 @@ class ident_switch extends rcube_plugin
|
|||||||
// Process boolean fields
|
// Process boolean fields
|
||||||
if (!rcube_utils::get_input_value('_ident_switch_form_enabled', rcube_utils::INPUT_POST))
|
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;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user