Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b424b4348 | ||
|
|
6705312240 | ||
|
|
05ea494fa6 | ||
|
|
5a704f2717 | ||
|
|
01edffa66b | ||
|
|
9367409f36 | ||
|
|
bbf28eed57 | ||
|
|
ec71910156 | ||
|
|
f700593730 | ||
|
|
9db4f48593 | ||
|
|
2b9c43858e | ||
|
|
95716183d7 | ||
|
|
40e7f5664e | ||
|
|
ea62869891 |
@@ -3,4 +3,9 @@ ident_switch plugin for Roundcube
|
|||||||
|
|
||||||
This plugin allows users to switch between different accounts (including remote) in single Roundcube session.
|
This plugin allows users to switch between different accounts (including remote) in single Roundcube session.
|
||||||
|
|
||||||
*Inspired by identities_imap plugin that is no longer supported.*
|
*Inspired by identities_imap plugin that is no longer supported.*
|
||||||
|
|
||||||
|
### Where to start ###
|
||||||
|
* In settigs interface create new identity.
|
||||||
|
* For all identities except default you will see new section of settings - IMAP. Enter data required to connect to remote server. Don't forget to check Enabled check box.
|
||||||
|
* After you have created at least one identity with active IMAP settings you will see combobox in the top right corner instead of plain text field with account name. It will allows you to switch to another account.
|
||||||
@@ -18,16 +18,14 @@ CREATE TABLE ident_switch
|
|||||||
password
|
password
|
||||||
varchar(64),
|
varchar(64),
|
||||||
host
|
host
|
||||||
varchar(64)
|
varchar(64),
|
||||||
NOT NULL,
|
|
||||||
port
|
port
|
||||||
integer
|
integer
|
||||||
CHECK(port > 0 AND port <= 65535),
|
CHECK(port > 0 AND port <= 65535),
|
||||||
delimiter
|
delimiter
|
||||||
char(1),
|
char(1),
|
||||||
label
|
label
|
||||||
varchar(32)
|
varchar(32),
|
||||||
NOT NULL,
|
|
||||||
flags
|
flags
|
||||||
integer
|
integer
|
||||||
NOT NULL
|
NOT NULL
|
||||||
|
|||||||
11
SQL/postgres/2016052000.sql
Normal file
11
SQL/postgres/2016052000.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
ALTER TABLE
|
||||||
|
ident_switch
|
||||||
|
ALTER COLUMN
|
||||||
|
host
|
||||||
|
DROP NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
ident_switch
|
||||||
|
ALTER COLUMN
|
||||||
|
label
|
||||||
|
DROP NOT NULL;
|
||||||
@@ -1,14 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* This is part of identity_imap plugin
|
* This is part of identity_imap plugin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
if ($('#plugin-ident_switch-account').size() > 0) {
|
var $truName = $('.topright .username');
|
||||||
$('#plugin-ident_switch-account').prependTo('.topright');
|
if ($truName.size() > 0) {
|
||||||
$('.topright .username').hide();
|
$sw = $('#plugin-ident_switch-account');
|
||||||
$('#plugin-ident_switch-account').show();
|
if ($sw.size() > 0) {
|
||||||
|
$sw.prependTo('.topright');
|
||||||
|
$truName.hide();
|
||||||
|
$('#plugin-ident_switch-account').show();
|
||||||
|
console.log("Doing replace.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $enFld = $("INPUT[name='_ident_switch.form.enabled']");
|
||||||
|
if ($enFld.size() == 1)
|
||||||
|
$enFld.change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function plugin_switchIdent_enabled_onChange(e) {
|
||||||
|
var $enFld = $("INPUT[name='_ident_switch.form.enabled']");
|
||||||
|
$("INPUT[name!='_ident_switch.form.enabled']", $enFld.parents("FIELDSET")).prop("disabled", !$enFld.is(":checked"));
|
||||||
|
}
|
||||||
|
|
||||||
function plugin_switchIdent_switch(val) {
|
function plugin_switchIdent_switch(val) {
|
||||||
console.log("qwe1");
|
console.log("qwe1");
|
||||||
rcmail.http_post('plugin.ident_switch.switch', { '_ident-id': val });
|
rcmail.http_post('plugin.ident_switch.switch', { '_ident-id': val });
|
||||||
|
|||||||
103
ident_switch.php
103
ident_switch.php
@@ -67,17 +67,26 @@ class ident_switch extends rcube_plugin
|
|||||||
if (strcasecmp($_SESSION['username'], $r['username']) === 0)
|
if (strcasecmp($_SESSION['username'], $r['username']) === 0)
|
||||||
$opts['selected'] = 'selected';
|
$opts['selected'] = 'selected';
|
||||||
|
|
||||||
|
// Make label
|
||||||
|
$lbl = $r['label'];
|
||||||
|
if (!$lbl)
|
||||||
|
{
|
||||||
|
if (strpos($r['username'], '@') === false)
|
||||||
|
$lbl = $r['username'] . '@' . ($r['host'] ? $r['host'] : 'localhost');
|
||||||
|
else
|
||||||
|
$lbl = $r['username'];
|
||||||
|
}
|
||||||
|
|
||||||
$sOpt .= html::tag(
|
$sOpt .= html::tag(
|
||||||
'option',
|
'option',
|
||||||
$opts,
|
$opts,
|
||||||
$r['label']
|
rcube::Q($lbl)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render UI if user has extra accounts
|
// Render UI if user has extra accounts
|
||||||
if (!empty($sOpt))
|
if (!empty($sOpt))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Add main account
|
// Add main account
|
||||||
$opts = array('value' => -1);
|
$opts = array('value' => -1);
|
||||||
if (strcasecmp($_SESSION['username'], $rc->user->data['username']) === 0)
|
if (strcasecmp($_SESSION['username'], $rc->user->data['username']) === 0)
|
||||||
@@ -125,13 +134,18 @@ class ident_switch extends rcube_plugin
|
|||||||
function on_identity_form($args)
|
function on_identity_form($args)
|
||||||
{
|
{
|
||||||
$rc = rcmail::get_instance();
|
$rc = rcmail::get_instance();
|
||||||
|
|
||||||
|
// Do now show options for default identity
|
||||||
|
if (strcasecmp($args['record']['email'], $rc->user->data['username']) === 0)
|
||||||
|
return $args;
|
||||||
|
|
||||||
$this->add_texts('localization');
|
$this->add_texts('localization');
|
||||||
|
|
||||||
// Create our field set
|
// Create our field set
|
||||||
$args['form']['ident_switch'] = array(
|
$args['form']['ident_switch'] = array(
|
||||||
'name' => $this->gettext('form.caption'),
|
'name' => $this->gettext('form.caption'),
|
||||||
'content' => array(
|
'content' => array(
|
||||||
'ident_switch.form.enabled' => array('type' => 'checkbox'),
|
'ident_switch.form.enabled' => array('type' => 'checkbox', 'onchange' => 'plugin_switchIdent_enabled_onChange();'),
|
||||||
'ident_switch.form.label' => array('type' => 'text', 'size' => 32),
|
'ident_switch.form.label' => array('type' => 'text', 'size' => 32),
|
||||||
'ident_switch.form.host' => array('type' => 'text', 'size' => 64),
|
'ident_switch.form.host' => array('type' => 'text', 'size' => 64),
|
||||||
'ident_switch.form.secure' => array('type' => 'checkbox'),
|
'ident_switch.form.secure' => array('type' => 'checkbox'),
|
||||||
@@ -168,9 +182,57 @@ class ident_switch extends rcube_plugin
|
|||||||
{
|
{
|
||||||
$rc = rcmail::get_instance();
|
$rc = rcmail::get_instance();
|
||||||
|
|
||||||
// TODO: check field values
|
// Check field values
|
||||||
|
$noErrors = false;
|
||||||
|
|
||||||
$sql = 'SELECT NULL FROM ' . $rc->db->table_name($this->table) . ' WHERE iid = ? AND user_id = ?';
|
$fLabel = self::ntrim(get_input_value('_ident_switch_form_label', RCUBE_INPUT_POST));
|
||||||
|
if (strlen($fLabel) > 32)
|
||||||
|
$rc->output->show_message('err.label.long', 'error');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fHost = self::ntrim(get_input_value('_ident_switch_form_host', RCUBE_INPUT_POST));
|
||||||
|
if (strlen($fHost) > 64)
|
||||||
|
$rc->output->show_message('err.host.long', 'error');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fPort = self::ntrim(get_input_value('_ident_switch_form_port', RCUBE_INPUT_POST));
|
||||||
|
if ($fPort && !ctype_digit($fPort))
|
||||||
|
$rc->output->show_message('err.port.num', 'error');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($fPort && ($fPort <= 0 || $fPort > 65535))
|
||||||
|
$rc->output->show_message('err.port.num', 'error');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fUser = self::ntrim(get_input_value('_ident_switch_form_username', RCUBE_INPUT_POST));
|
||||||
|
if (strlen($fUser) > 64)
|
||||||
|
$rc->output->show_message('err.user.long', 'error');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!$fUser)
|
||||||
|
$rc->output->show_message('err.user.empty', 'error');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fDelim = self::ntrim(get_input_value('_ident_switch_form_delimiter', RCUBE_INPUT_POST));
|
||||||
|
if (strlen($fDelim) > 1)
|
||||||
|
$rc->output->show_message('err.delim.long', 'error');
|
||||||
|
else
|
||||||
|
$noErrors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$noErrors)
|
||||||
|
{
|
||||||
|
//$rc->output->send();
|
||||||
|
$args['abort'] = true;
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT password FROM ' . $rc->db->table_name($this->table) . ' WHERE iid = ? AND user_id = ?';
|
||||||
$q = $rc->db->query($sql, $args['id'], $rc->user->ID);
|
$q = $rc->db->query($sql, $args['id'], $rc->user->ID);
|
||||||
$r = $rc->db->fetch_assoc($q);
|
$r = $rc->db->fetch_assoc($q);
|
||||||
if ($r)
|
if ($r)
|
||||||
@@ -193,15 +255,20 @@ class ident_switch extends rcube_plugin
|
|||||||
if (get_input_value('_ident_switch_form_secure', RCUBE_INPUT_POST))
|
if (get_input_value('_ident_switch_form_secure', RCUBE_INPUT_POST))
|
||||||
$flags |= $this->db_secure;
|
$flags |= $this->db_secure;
|
||||||
|
|
||||||
|
// Do we need to update pwd?
|
||||||
|
$fPass = get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST);
|
||||||
|
if ($fPass != $r['password'])
|
||||||
|
$fPass = $rc->encrypt($fPass);
|
||||||
|
|
||||||
$rc->db->query(
|
$rc->db->query(
|
||||||
$sql,
|
$sql,
|
||||||
$flags,
|
$flags,
|
||||||
get_input_value('_ident_switch_form_label', RCUBE_INPUT_POST),
|
$fLabel,
|
||||||
get_input_value('_ident_switch_form_host', RCUBE_INPUT_POST),
|
$fHost,
|
||||||
get_input_value('_ident_switch_form_port', RCUBE_INPUT_POST),
|
$fPort,
|
||||||
get_input_value('_ident_switch_form_username', RCUBE_INPUT_POST),
|
$fUser,
|
||||||
$rc->encrypt(get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST)),
|
$fPass,
|
||||||
get_input_value('_ident_switch_form_delimiter', RCUBE_INPUT_POST),
|
$fDelim,
|
||||||
$rc->user->ID,
|
$rc->user->ID,
|
||||||
$args['id']
|
$args['id']
|
||||||
);
|
);
|
||||||
@@ -298,7 +365,7 @@ class ident_switch extends rcube_plugin
|
|||||||
}
|
}
|
||||||
$_SESSION['password' . $this->my_postfix] = $_SESSION['password'];
|
$_SESSION['password' . $this->my_postfix] = $_SESSION['password'];
|
||||||
|
|
||||||
$_SESSION['storage_host'] = $r['host'];
|
$_SESSION['storage_host'] = $r['host'] ? $r['host'] : 'localhost'; // Default host here!
|
||||||
$_SESSION['storage_ssl'] = $ssl;
|
$_SESSION['storage_ssl'] = $ssl;
|
||||||
$_SESSION['storage_port'] = $port;
|
$_SESSION['storage_port'] = $port;
|
||||||
$_SESSION['username'] = $r['username'];
|
$_SESSION['username'] = $r['username'];
|
||||||
@@ -322,4 +389,16 @@ class ident_switch extends rcube_plugin
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function ntrim($str)
|
||||||
|
{
|
||||||
|
if (is_null($str))
|
||||||
|
return $str;
|
||||||
|
|
||||||
|
$s = trim($str);
|
||||||
|
if (!$s)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,14 @@ $labels['form.enabled'] = 'Enabled';
|
|||||||
// Label
|
// Label
|
||||||
$labels['form.label'] = 'Label';
|
$labels['form.label'] = 'Label';
|
||||||
|
|
||||||
// Server URI
|
// Server host name
|
||||||
$labels['form.server']='Server URI';
|
$labels['form.host']='Server host name';
|
||||||
|
|
||||||
|
// Secure connection (SSL/TLS)
|
||||||
|
$labels['form.secure']='Secure connection (SSL/TLS)';
|
||||||
|
|
||||||
|
// Port
|
||||||
|
$labels['form.port']='Port';
|
||||||
|
|
||||||
// Username
|
// Username
|
||||||
$labels['form.username'] = 'Username';
|
$labels['form.username'] = 'Username';
|
||||||
|
|||||||
32
localization/ru_RU.inc
Normal file
32
localization/ru_RU.inc
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Localization file for ident_switch plugin
|
||||||
|
*/
|
||||||
|
$labels = array();
|
||||||
|
|
||||||
|
// IMAP
|
||||||
|
$labels['form.caption'] = 'IMAP';
|
||||||
|
|
||||||
|
// Enabled
|
||||||
|
$labels['form.enabled'] = 'Включено';
|
||||||
|
|
||||||
|
// Label
|
||||||
|
$labels['form.label'] = 'Название';
|
||||||
|
|
||||||
|
// Server host name
|
||||||
|
$labels['form.host'] = 'Адрес сервера';
|
||||||
|
|
||||||
|
// Secure connection (SSL/TLS)
|
||||||
|
$labels['form.secure'] = 'Безопасное соединение (SSL/TLS)';
|
||||||
|
|
||||||
|
// Port
|
||||||
|
$labels['form.port'] = 'Порт';
|
||||||
|
|
||||||
|
// Username
|
||||||
|
$labels['form.username'] = 'Имя пользователя';
|
||||||
|
|
||||||
|
// Passwotrd
|
||||||
|
$labels['form.password'] = 'Пароль';
|
||||||
|
|
||||||
|
// Folder hierarchy delimiter
|
||||||
|
$labels['form.delimiter'] = 'Разделитель в иерархии папок';
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* This file is part of Roundcube "identities_imap" plugin.
|
|
||||||
*
|
|
||||||
* Your are not allowed to distribute this file or parts of it.
|
|
||||||
*
|
|
||||||
* This file is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2012 - 2014 Roland 'Rosali' Liebl - all rights reserved
|
|
||||||
* dev-team [at] myroundcube [dot] com
|
|
||||||
* http://myroundcube.com
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#accounts{position:absolute; top:63px; left:18px;}.remotehint{z-index:-1; position:absolute; top:7px; margin-left:auto; left:210px; width:400px; border-radius:5px; padding:4px; -moz-border-radius:5px; border:1px solid #DEEEFC; background:#F2F9FF; text-align:center; color:#3F70BA; display:inline;}.classic{top:2px;}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* This file is part of Roundcube "identities_imap" plugin.
|
|
||||||
*
|
|
||||||
* Your are not allowed to distribute this file or parts of it.
|
|
||||||
*
|
|
||||||
* This file is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2012 - 2014 Roland 'Rosali' Liebl - all rights reserved
|
|
||||||
* dev-team [at] myroundcube [dot] com
|
|
||||||
* http://myroundcube.com
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
select.deco{height:18px; font-size:12px; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; color:#fff; background:#444; border:1px solid #ababab;}.remotehint{z-index:1; position:absolute; top:1px; margin-left:auto; left:50%; margin-left:-200px; width:400px; border-radius:5px; padding:4px; -moz-border-radius:5px; border:1px solid #DEEEFC; background:#F2F9FF; text-align:center; color:#3F70BA; display:inline;}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* This file is part of Roundcube "##PLUGIN##" plugin.
|
|
||||||
*
|
|
||||||
* Your are not allowed to distribute this file or parts of it.
|
|
||||||
*
|
|
||||||
* This file is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2012 - ##YEAR## Roland 'Rosali' Liebl - all rights reserved
|
|
||||||
* dev-team [at] myroundcube [dot] com
|
|
||||||
* http://myroundcube.com
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
select.deco{}#taskbar .remotehint{position:absolute; top:52px; left:50%; margin-left:-200px; width:400px; padding:0px; border:1px solid #DEEEFC; background-color:#F2F9FF; text-align:center; font-size:10px; color:#3F70BA;}
|
|
||||||
Reference in New Issue
Block a user