|
|
|
|
@@ -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;
|
|
|
|
|
|