Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcea012af0 | ||
|
|
a437a107ba |
@@ -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.
|
||||
|
||||
@@ -11,8 +11,7 @@ CREATE TABLE IF NOT EXISTS ident_switch
|
||||
int(10) UNSIGNED
|
||||
NOT NULL,
|
||||
username
|
||||
varchar(64)
|
||||
NOT NULL,
|
||||
varchar(64),
|
||||
password
|
||||
varchar(64),
|
||||
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
|
||||
UNIQUE,
|
||||
username
|
||||
varchar(64)
|
||||
NOT NULL,
|
||||
varchar(64),
|
||||
password
|
||||
varchar(64),
|
||||
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)
|
||||
{
|
||||
$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;
|
||||
|
||||
Reference in New Issue
Block a user