Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac32196fc0 | ||
|
|
ebc4324ecd | ||
|
|
c0a92bb436 | ||
|
|
652d1aaa1f | ||
|
|
6f86e64442 | ||
|
|
080a2ee591 | ||
|
|
4a20b77edb | ||
|
|
89791e1f49 |
@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS ident_switch
|
||||
varchar(64),
|
||||
imap_port
|
||||
int
|
||||
CHECK(port > 0 AND port <= 65535),
|
||||
CHECK(imap_port > 0 AND imap_port <= 65535),
|
||||
label
|
||||
varchar(32),
|
||||
flags
|
||||
@@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS ident_switch
|
||||
varchar(64),
|
||||
smtp_port
|
||||
int
|
||||
CHECK(port > 0 AND port <= 65535),
|
||||
CHECK(smtp_port > 0 AND smtp_port <= 65535),
|
||||
UNIQUE KEY user_id_label (user_id, label),
|
||||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_identity_id FOREIGN KEY (iid) REFERENCES identities(identity_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
|
||||
@@ -20,7 +20,7 @@ CREATE TABLE ident_switch
|
||||
varchar(64),
|
||||
imap_port
|
||||
integer
|
||||
CHECK(port > 0 AND port <= 65535),
|
||||
CHECK(imap_port > 0 AND imap_port <= 65535),
|
||||
label
|
||||
varchar(32),
|
||||
flags
|
||||
@@ -31,7 +31,7 @@ CREATE TABLE ident_switch
|
||||
varchar(64),
|
||||
smtp_port
|
||||
integer
|
||||
CHECK(port > 0 AND port <= 65535),
|
||||
CHECK(smtp_port > 0 AND smtp_port <= 65535),
|
||||
UNIQUE (user_id, label)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
CREATE TABLE ident_switch
|
||||
(
|
||||
id
|
||||
serial
|
||||
integer
|
||||
PRIMARY KEY,
|
||||
user_id
|
||||
integer
|
||||
|
||||
@@ -1,25 +1,76 @@
|
||||
ALTER TABLE
|
||||
ident_switch
|
||||
RENAME COLUMN
|
||||
host
|
||||
TO
|
||||
imap_host;
|
||||
PRAGMA foreign_keys=off;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE
|
||||
ident_switch
|
||||
RENAME COLUMN
|
||||
port
|
||||
TO
|
||||
imap_port;
|
||||
ALTER TABLE ident_switch RENAME TO ident_switch_old;
|
||||
|
||||
ALTER TABLE
|
||||
ident_switch
|
||||
ADD COLUMN
|
||||
CREATE TABLE ident_switch
|
||||
(
|
||||
id
|
||||
integer
|
||||
PRIMARY KEY,
|
||||
user_id
|
||||
integer
|
||||
NOT NULL
|
||||
REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
iid
|
||||
integer
|
||||
NOT NULL
|
||||
REFERENCES identities(identity_id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
UNIQUE,
|
||||
username
|
||||
varchar(64),
|
||||
password
|
||||
varchar(64),
|
||||
imap_host
|
||||
varchar(64),
|
||||
imap_port
|
||||
integer
|
||||
CHECK(imap_port > 0 AND imap_port <= 65535),
|
||||
label
|
||||
varchar(32),
|
||||
flags
|
||||
integer
|
||||
NOT NULL
|
||||
DEFAULT(0),
|
||||
smtp_host
|
||||
varchar(64);
|
||||
|
||||
ALTER TABLE
|
||||
ident_switch
|
||||
ADD COLUMN
|
||||
varchar(64),
|
||||
smtp_port
|
||||
int;
|
||||
integer
|
||||
CHECK(smtp_port > 0 AND smtp_port <= 65535),
|
||||
UNIQUE (user_id, label)
|
||||
);
|
||||
CREATE INDEX IX_ident_switch_user_id ON ident_switch(user_id);
|
||||
CREATE INDEX IX_ident_switch_iid on ident_switch(iid);
|
||||
|
||||
INSERT OR ROLLBACK INTO
|
||||
ident_switch (
|
||||
id,
|
||||
user_id,
|
||||
iid,
|
||||
username,
|
||||
password,
|
||||
imap_host,
|
||||
imap_port,
|
||||
label,
|
||||
flags,
|
||||
smtp_host
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
iid,
|
||||
username,
|
||||
password,
|
||||
host,
|
||||
port,
|
||||
label,
|
||||
flags,
|
||||
host,
|
||||
FROM
|
||||
ident_switch_old;
|
||||
|
||||
DROP TABLE
|
||||
ident_switch_old;
|
||||
|
||||
COMMIT;
|
||||
PRAGMA foreign_keys=on;
|
||||
@@ -183,8 +183,6 @@ class ident_switch extends rcube_plugin
|
||||
else
|
||||
$args['smtp_server'] = 'tls://' . $args['smtp_server'];
|
||||
}
|
||||
|
||||
self::write_log(print_r($args, true));
|
||||
}
|
||||
|
||||
return $args;
|
||||
@@ -355,7 +353,7 @@ class ident_switch extends rcube_plugin
|
||||
|
||||
unset($_SESSION['createData' . self::MY_POSTFIX]);
|
||||
if (!$data || count($data) == 0)
|
||||
self::write_log('Object with ident_switch values not found in session for ID = ' . $args['id'] . '.');
|
||||
self::write_log("Object with ident_switch values not found in session for ID = {$args['id']}.");
|
||||
else
|
||||
{
|
||||
$data['id'] = $args['id'];
|
||||
@@ -373,7 +371,7 @@ class ident_switch extends rcube_plugin
|
||||
$q = $rc->db->query($sql, $args['id'], $rc->user->ID);
|
||||
|
||||
if ($rc->db->affected_rows($q))
|
||||
self::write_log('Deleted associated information for identity with ID = ' . $args['id'] . '.');
|
||||
self::write_log("Deleted associated information for identity with ID = {$args['id']}.");
|
||||
|
||||
return $args;
|
||||
}
|
||||
@@ -386,7 +384,10 @@ class ident_switch extends rcube_plugin
|
||||
if (strcasecmp($_SESSION['username'], $rc->user->data['username']) !== 0)
|
||||
{
|
||||
if (isset($_SESSION['iid' . self::MY_POSTFIX]))
|
||||
$rc->output->add_script('plugin_switchIdent_fixIdent(' . $_SESSION['iid' . self::MY_POSTFIX] . ');', 'docready');
|
||||
{
|
||||
$iid = $_SESSION['iid' . self::MY_POSTFIX];
|
||||
$rc->output->add_script("plugin_switchIdent_fixIdent({$iid});", 'docready');
|
||||
}
|
||||
else
|
||||
self::write_log('Special session variable with active identity ID not found.');
|
||||
}
|
||||
@@ -443,7 +444,7 @@ class ident_switch extends rcube_plugin
|
||||
}
|
||||
|
||||
// Get also password
|
||||
$retVal['imap.pass'] = self::get_field_value('imap', 'password', false);
|
||||
$retVal['imap.pass'] = self::get_field_value('imap', 'password', false, true);
|
||||
|
||||
// Parse secure settings
|
||||
$retVal['flags'] = self::DB_ENABLED;
|
||||
@@ -455,11 +456,12 @@ class ident_switch extends rcube_plugin
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
private static function get_field_value($section, $field, $trim = true)
|
||||
private static function get_field_value($section, $field, $trim = true, $html = false)
|
||||
{
|
||||
$retVal = rcube_utils::get_input_value(
|
||||
'_ident_switch_form_' . $section . '_' . $field,
|
||||
rcube_utils::INPUT_POST
|
||||
"_ident_switch_form_{$section}_{$field}",
|
||||
rcube_utils::INPUT_POST,
|
||||
$html
|
||||
);
|
||||
if (!$trim)
|
||||
return $retVal;
|
||||
@@ -554,7 +556,7 @@ class ident_switch extends rcube_plugin
|
||||
$r['username'] = $rIid['email'];
|
||||
}
|
||||
|
||||
self::write_log('Switching mailbox to one for identity with ID = ' . $r['iid'] . ' (username = \'' . $r['username'] . '\').');
|
||||
self::write_log("Switching mailbox to one for identity with ID = {$r['iid']} (username = '{$r['username']}').");
|
||||
|
||||
$def_port = 143; // Default IMAP port here!
|
||||
$ssl = null;
|
||||
@@ -582,7 +584,11 @@ class ident_switch extends rcube_plugin
|
||||
if (!$_SESSION['password' . self::MY_POSTFIX])
|
||||
$_SESSION['password' . self::MY_POSTFIX] = $_SESSION['password'];
|
||||
|
||||
$_SESSION['storage_host'] = $r['imap_host'] ? $r['imap_host'] : 'localhost'; // Default IMAP host here!
|
||||
$host = $r['imap_host'] ? $r['imap_host'] : 'localhost'; // Default IMAP host here!
|
||||
if ($ssl)
|
||||
$host = "{$ssl}://{$host}";
|
||||
|
||||
$_SESSION['storage_host'] = $host;
|
||||
$_SESSION['storage_ssl'] = $ssl;
|
||||
$_SESSION['storage_port'] = $port;
|
||||
$_SESSION['username'] = $r['username'];
|
||||
@@ -594,7 +600,7 @@ class ident_switch extends rcube_plugin
|
||||
else
|
||||
{
|
||||
// TODO: Show message in browser
|
||||
self::write_log('Requested remote mailbox with ID = ' . $identId . ' not found.');
|
||||
self::write_log("Requested remote mailbox with ID = {$identId} not found.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -640,14 +646,14 @@ class ident_switch extends rcube_plugin
|
||||
$cfg = $this->get_preconfig($email);
|
||||
if (is_array($cfg))
|
||||
{
|
||||
self::write_log('Applying predefined configuration for \'' . $email . '\'.');
|
||||
self::write_log("Applying predefined configuration for '{$email}'.");
|
||||
|
||||
if ($cfg['host'])
|
||||
{ // Parse and set host and related
|
||||
$urlArr = parse_url($cfg['host']);
|
||||
|
||||
$record['ident_switch.form.imap.host'] = $urlArr['host'] ? rcube::Q($urlArr['host'], 'url') : '';
|
||||
$record['ident_switch.form.imap.port'] = $urlArr['port'] ? intval($urlArr['port']) : '';
|
||||
$record['ident_switch.form.imap.host'] = $record['ident_switch.form.smtp.host'] = $urlArr['host'] ? rcube::Q($urlArr['host'], 'url') : '';
|
||||
$record['ident_switch.form.imap.port'] = $record['ident_switch.form.smtp.port'] = $urlArr['port'] ? intval($urlArr['port']) : '';
|
||||
|
||||
if (strcasecmp('tls', $urlArr['scheme']) === 0)
|
||||
$record['ident_switch.form.imap.tls'] = true;
|
||||
|
||||
@@ -64,4 +64,4 @@ $labels['err.host.long'] = 'Der Wert in Feld \'Servername\' ist zu lang (max. 64
|
||||
$labels['err.port.num'] = 'Der Wert in Feld \'Port\' muss eine Zahl sein.';
|
||||
|
||||
// Value in \'Port\' field must be between 1 and 65535.
|
||||
$labels['err.port.range'] = 'Der Wert in Feld \'Port\' muss 1 und 65535 liegen.';
|
||||
$labels['err.port.range'] = 'Der Wert in Feld \'Port\' muss zwischen 1 und 65535 liegen.';
|
||||
|
||||
Reference in New Issue
Block a user