Enigma: Key search and import in dialogs (for better Elastic integration)

pull/6040/head
Aleksander Machniak 7 years ago
parent 3c1b78af48
commit 182aa52ab9

@ -27,6 +27,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
rcmail.register_command('plugin.enigma-key-export', function() { rcmail.enigma_export(); });
rcmail.register_command('plugin.enigma-key-export-selected', function() { rcmail.enigma_export(true); });
rcmail.register_command('plugin.enigma-key-import', function() { rcmail.enigma_key_import(); }, true);
rcmail.register_command('plugin.enigma-key-import-search', function() { rcmail.enigma_key_import_search(); }, true);
rcmail.register_command('plugin.enigma-key-delete', function(props) { return rcmail.enigma_delete(); });
rcmail.register_command('plugin.enigma-key-create', function(props) { return rcmail.enigma_key_create(); }, true);
rcmail.register_command('plugin.enigma-key-save', function(props) { return rcmail.enigma_key_create_save(); }, true);
@ -79,7 +80,39 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
// Display key(s) import form
rcube_webmail.prototype.enigma_key_import = function()
{
this.enigma_loadframe('&_action=plugin.enigmakeys&_a=import');
var dialog = $('<iframe>').attr('src', this.url('plugin.enigmakeys', {_a: 'import', _framed: 1})),
import_func = function(e) {
var win = dialog[0].contentWindow;
win.rcmail.enigma_import();
};
this.enigma_import_dialog = this.simple_dialog(dialog, this.gettext('enigma.importkeys'), import_func, {
button: 'import',
width: 500,
height: 150
});
};
// Display key(s) search/import form
rcube_webmail.prototype.enigma_key_import_search = function()
{
var dialog = $('<iframe>').attr('src', this.url('plugin.enigmakeys', {_a: 'import-search', _framed: 1})),
search_func = function() {
var win = dialog[0].contentWindow;
win.rcmail.enigma_import_search();
};
this.enigma_import_dialog = this.simple_dialog(dialog, this.gettext('enigma.keyimportsearchlabel'), search_func, {
button: 'search',
width: 500,
height: 150
});
};
rcube_webmail.prototype.enigma_import_success = function()
{
var dialog = this.enigma_import_dialog || parent.rcmail.enigma_import_dialog;
dialog.dialog('destroy');
};
// Display key(s) generation form
@ -230,8 +263,7 @@ rcube_webmail.prototype.enigma_export_submit = function(data)
rcube_webmail.prototype.enigma_import = function()
{
var form, file, lock,
id = 'keyexport-' + new Date().getTime(),
iframe = $('<iframe>').attr({name: id, style: 'display:none'});
id = 'keyimport-' + new Date().getTime();
if (form = this.gui_objects.importform) {
file = document.getElementById('rcmimportfile');
@ -241,9 +273,10 @@ rcube_webmail.prototype.enigma_import = function()
}
lock = this.set_busy(true, 'importwait');
iframe.appendTo(document.body);
$(form).attr({target: id, action: this.add_url(form.action, '_unlock', lock)})
.submit();
$('<iframe>').attr({name: id, style: 'display:none'}).appendTo(document.body);
$(form).attr({target: id, action: this.add_url(form.action, '_unlock', lock)}).submit();
return true;
}
};

@ -59,6 +59,10 @@ class enigma_ui
$this->key_import();
break;
case 'import-search':
$this->key_import_search();
break;
case 'export':
$this->key_export();
break;
@ -225,7 +229,9 @@ class enigma_ui
// add some labels to client
$this->rc->output->add_label('enigma.keyremoveconfirm', 'enigma.keyremoving',
'enigma.keyexportprompt', 'enigma.withprivkeys', 'enigma.onlypubkeys', 'enigma.exportkeys'
'enigma.keyexportprompt', 'enigma.withprivkeys', 'enigma.onlypubkeys',
'enigma.exportkeys', 'enigma.importkeys', 'enigma.keyimportsearchlabel',
'import', 'search'
);
return $out;
@ -557,12 +563,11 @@ class enigma_ui
if ($result['imported']) {
$this->rc->output->command('parent.enigma_list', 1);
}
else {
$this->rc->output->command('parent.enigma_loadframe');
}
$this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation',
array('new' => $result['imported'], 'old' => $result['unchanged']));
$this->rc->output->command('parent.enigma_import_success');
}
else if ($result instanceof enigma_error && $result->getCode() == enigma_error::BADPASS) {
$this->password_prompt($result);
@ -570,7 +575,6 @@ class enigma_ui
else {
$this->rc->output->show_message('enigma.keysimportfailed', 'error');
}
$this->rc->output->send('iframe');
}
else if ($err = $_FILES['_file']['error']) {
@ -588,10 +592,21 @@ class enigma_ui
'importform' => array($this, 'tpl_key_import_form'),
));
$this->rc->output->set_pagetitle($this->enigma->gettext('keyimport'));
$this->rc->output->send('enigma.keyimport');
}
/**
* Key import-search (page) handler
*/
private function key_import_search()
{
$this->rc->output->add_handlers(array(
'importform' => array($this, 'tpl_key_import_form'),
));
$this->rc->output->send('enigma.keysearch');
}
/**
* Template object for key import (upload) form
*/
@ -599,42 +614,62 @@ class enigma_ui
{
$attrib += array('id' => 'rcmKeyImportForm');
$upload = new html_inputfield(array('type' => 'file', 'name' => '_file',
'id' => 'rcmimportfile', 'size' => 30));
$search = new html_inputfield(array('type' => 'text', 'name' => '_search',
'id' => 'rcmimportsearch', 'size' => 30));
if (empty($attrib['part']) || $attrib['part'] == 'import') {
$title = $this->enigma->gettext('keyimportlabel');
$upload = new html_inputfield(array('type' => 'file', 'name' => '_file',
'id' => 'rcmimportfile', 'size' => 30));
$upload_button = new html_button(array(
'class' => 'button import',
'onclick' => "return rcmail.command('plugin.enigma-import','',this,event)",
));
$upload_button = new html_button(array(
'class' => 'button import',
'onclick' => "return rcmail.command('plugin.enigma-import','',this,event)",
));
$search_button = new html_button(array(
'class' => 'button search',
'onclick' => "return rcmail.command('plugin.enigma-import-search','',this,event)",
));
$form = html::div(null,
rcube::Q($this->enigma->gettext('keyimporttext'), 'show')
. html::br() . html::br() . $upload->show()
. (empty($attrib['part']) ? html::br() . html::br() . $upload_button->show($this->rc->gettext('import')) : '')
);
$upload_form = html::div(null,
rcube::Q($this->enigma->gettext('keyimporttext'), 'show')
. html::br() . html::br() . $upload->show()
. html::br() . html::br() . $upload_button->show($this->rc->gettext('import'))
);
if (empty($attrib['part'])) {
$form = html::tag('fieldset', '', html::tag('legend', null, $title) . $form);
}
else {
$this->rc->output->set_pagetitle($title);
}
}
$search_form = html::div(null,
rcube::Q($this->enigma->gettext('keyimportsearchtext'), 'show')
. html::br() . html::br() . $search->show()
. html::br() . html::br() . $search_button->show($this->rc->gettext('search'))
);
if (empty($attrib['part']) || $attrib['part'] == 'search') {
$title = $this->enigma->gettext('keyimportsearchlabel');
$search = new html_inputfield(array('type' => 'text', 'name' => '_search',
'id' => 'rcmimportsearch', 'size' => 30));
$search_button = new html_button(array(
'class' => 'button search',
'onclick' => "return rcmail.command('plugin.enigma-import-search','',this,event)",
));
$form = html::div(null,
rcube::Q($this->enigma->gettext('keyimportsearchtext'), 'show')
. html::br() . html::br() . $search->show()
. (empty($attrib['part']) ? html::br() . html::br() . $search_button->show($this->rc->gettext('search')) : '')
);
if (empty($attrib['part'])) {
$form = html::tag('fieldset', '', html::tag('legend', null, $title) . $form);
}
else {
$this->rc->output->set_pagetitle($title);
}
$form = html::tag('fieldset', '', html::tag('legend', null, $this->enigma->gettext('keyimportlabel')) . $upload_form)
. html::tag('fieldset', '', html::tag('legend', null, $this->enigma->gettext('keyimportsearchlabel')) . $search_form);
$this->rc->output->include_script('publickey.js');
}
$this->rc->output->add_label('selectimportfile', 'importwait', 'nopubkeyfor', 'nopubkeyforsender',
'encryptnoattachments','encryptedsendialog','searchpubkeyservers', 'importpubkeys',
'encryptpubkeysfound', 'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired',
'keyrevoked', 'keyimportsuccess', 'keyservererror');
$this->rc->output->add_gui_object('importform', $attrib['id']);
$this->rc->output->include_script('publickey.js');
$out = $this->rc->output->form_tag(array(
'action' => $this->rc->url(array('action' => $this->rc->action, 'a' => 'import')),

@ -244,3 +244,11 @@ div.enigmascreen
width: 5px;
background-position: -166px 0;
}
#keystoolbar a.search {
background: url(../../../../skins/classic/images/abook_toolbar.png) -170px 0 no-repeat transparent;
}
#keystoolbar a.searchSel {
background: url(../../../../skins/classic/images/abook_toolbar.png) -170px -32px no-repeat transparent;
}

@ -6,10 +6,8 @@
</head>
<body class="iframe">
<div id="keyimport-title" class="boxtitle"><roundcube:label name="enigma.importkeys" /></div>
<div id="import-form" class="boxcontent">
<roundcube:object name="importform" id="keyimportform" />
<roundcube:object name="importform" id="keyimportform" part="import" />
</div>
</body>

@ -21,6 +21,7 @@
<div id="keystoolbar">
<roundcube:button command="plugin.enigma-key-create" type="link" class="buttonPas create" classAct="button create" classSel="button createSel" title="enigma.createkeys" content=" " />
<roundcube:button command="plugin.enigma-key-import" type="link" class="buttonPas import" classAct="button import" classSel="button importSel" title="enigma.importkeys" content=" " />
<roundcube:button command="plugin.enigma-key-import-search" type="link" class="buttonPas search" classAct="button search" classSel="button searchSel" title="enigma.keyimportsearchlabel" content=" " />
<span class="dropbutton">
<roundcube:button command="plugin.enigma-key-export" type="link" class="buttonPas export" classAct="button export" classSel="button exportSel" title="enigma.exportkeys" content=" " />
<span id="exportmenulink" onclick="rcmail_ui.show_popup('exportmenu');return false"></span>

@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
</head>
<body class="iframe">
<div id="import-form" class="boxcontent">
<roundcube:object name="importform" id="keyimportform" part="search" />
</div>
</body>
</html>

@ -3,7 +3,7 @@
<h1 class="voice"><roundcube:label name="enigma.importkeys" /></h1>
<div class="formcontent">
<roundcube:object name="importform" class="propform" />
<roundcube:object name="importform" class="propform" part="import" />
</div>
<roundcube:include file="includes/footer.html" />

@ -52,6 +52,9 @@
class="button delete disabled" classAct="button delete"
label="delete" title="enigma.keyremove" innerClass="inner" />
<span class="spacer"></span>
<roundcube:button command="plugin.enigma-key-import-search" type="link"
class="button search disabled" classAct="button search"
label="search" title="enigma.keyimportsearchlabel" innerClass="inner" />
<roundcube:button command="plugin.enigma-key-import" type="link"
class="button import disabled" classAct="button import"
label="import" title="enigma.importkeys" innerClass="inner" />

@ -0,0 +1,9 @@
<roundcube:include file="includes/layout.html" />
<h1 class="voice"><roundcube:label name="enigma.keyimportsearchlabel" /></h1>
<div class="formcontent">
<roundcube:object name="importform" class="propform" part="search" />
</div>
<roundcube:include file="includes/footer.html" />

@ -176,15 +176,10 @@ p.enigmaattachment a {
z-index: 10;
}
#keystoolbar a.button
{
background: url(enigma_icons.png) 0 0 no-repeat transparent;
}
#keystoolbar a.import {
background-position: center 0;
background: url(enigma_icons.png) center 0 no-repeat transparent;
}
#keystoolbar a.export {
background-position: center -40px;
background: url(enigma_icons.png) center -40px no-repeat transparent;
}

@ -4,12 +4,12 @@
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
</head>
<body class="iframe">
<body class="iframe fullheight">
<h1 class="boxtitle"><roundcube:label name="enigma.importkeys" /></h1>
<h1 class="voice"><roundcube:label name="enigma.importkeys" /></h1>
<div id="import-form" class="boxcontent">
<roundcube:object name="importform" class="propform" id="keyimportform" />
<roundcube:object name="importform" class="propform" id="keyimportform" part="import" />
</div>
<roundcube:include file="/includes/footer.html" />

@ -14,6 +14,7 @@
<!-- toolbar -->
<h2 id="aria-label-toolbar" class="voice"><roundcube:label name="arialabeltoolbar" /></h2>
<div id="keystoolbar" class="toolbar" role="toolbar" aria-labelledby="aria-label-toolbar">
<roundcube:button command="plugin.enigma-key-import-search" type="link" class="button search disabled" classAct="button search" classSel="button search pressed" label="search" title="enigma.keyimportsearchlabel" />
<roundcube:button command="plugin.enigma-key-import" type="link" class="button import disabled" classAct="button import" classSel="button import pressed" label="import" title="enigma.importkeys" />
<span class="dropbutton">
<roundcube:button command="plugin.enigma-key-export" type="link" class="button export disabled" classAct="button export" classSel="button export pressed" label="export" title="enigma.exportkeys" />
@ -34,7 +35,7 @@
<label for="quicksearchbox" class="voice"><roundcube:label name="arialabelmailquicksearchbox" /></label>
<roundcube:object name="searchform" id="quicksearchbox" />
<a id="searchmenulink" class="iconbutton searchicon" > </a>
<roundcube:button command="reset-search" id="searchreset" class="iconbutton reset" title="resetsearch" label="resetsearch" />
<roundcube:button command="reset-search" id="searchreset" type="link" class="iconbutton reset" title="resetsearch" label="resetsearch" />
</div>
<roundcube:include file="/includes/settingstabs.html" />
@ -70,7 +71,7 @@
<div id="keyoptions" class="popupmenu">
<ul class="toolbarmenu">
<li><roundcube:button class="deletelink" command="plugin.enigma-key-delete" label="enigma.keyremove" target="_blank" classAct="deletelink active" /></li>
<li><roundcube:button class="deletelink" type="link" command="plugin.enigma-key-delete" label="enigma.keyremove" target="_blank" classAct="deletelink active" /></li>
<!--
<li><roundcube:button class="disablelink" command="enigma.key-disable" label="enigma.keydisable" target="_blank" classAct="disablelink active" /></li>
<li><roundcube:button class="revokelink" command="enigma.key-revoke" label="enigma.keyrevoke" classAct="revokelink active" /></li>

@ -0,0 +1,18 @@
<roundcube:object name="doctype" value="html5" />
<html>
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
</head>
<body class="iframe fullheight">
<h1 class="voice"><roundcube:label name="enigma.importkeys" /></h1>
<div id="import-form" class="boxcontent">
<roundcube:object name="importform" class="propform" id="keyimportform" part="search" />
</div>
<roundcube:include file="/includes/footer.html" />
</body>
</html>
Loading…
Cancel
Save