diff options
| -rw-r--r-- | inbox_settings.php | 89 | ||||
| -rw-r--r-- | keys.js | 18 | ||||
| -rw-r--r-- | localization/en_US.inc | 3 |
3 files changed, 67 insertions, 43 deletions
diff --git a/inbox_settings.php b/inbox_settings.php index 5a7658b..0df8a49 100644 --- a/inbox_settings.php +++ b/inbox_settings.php @@ -17,6 +17,8 @@ class inbox_settings extends rcube_plugin { $this->register_action('plugin.inbox_settings', [$this, 'render_settings_ui']); $this->register_action('plugin.inbox_keys', [$this, 'render_keys_ui']); + $this->register_action('plugin.inbox_keys_generate', [$this, 'render_generate_ui']); + $this->register_action('plugin.inbox_keys_import', [$this, 'render_import_ui']); $this->register_action('plugin.inbox_keys_delete', [$this, 'delete_selected_keys']); } @@ -79,37 +81,6 @@ class inbox_settings extends rcube_plugin { } } - function render_keys_ui() { - $this->rcmail->output->add_handler('keyslist', [$this, 'render_keys_list']); - $this->rcmail->output->set_pagetitle($this->gettext('inbox_keys')); - $this->rcmail->output->send('inbox_settings.keys'); - } - - function render_keys_list($attrib) { - if (empty($attrib['id'])) - $attrib['id'] = 'rcpgpkeyslist'; - - // info the js needs access to - $this->rcmail->output->add_gui_object('keyslist', $attrib['id']); - $this->rcmail->output->add_label( - 'inbox_settings.confirm_delete_key', 'inbox_settings.deleting_key'); - // the js in question - $this->rcmail->output->include_script('list.js'); - $this->include_script('keys.js'); - - $data = self::label_assoc_2d($this->run_query('keys', [], true)); - if (empty($data)) { - $this->rcmail->output->command( - 'display_message', $this->gettext('no_keys'), 'notice'); - } - - return rcmail_action::table_output( - $attrib, - $data, - ['inbox_settings.fingerprint', 'inbox_settings.comment'], - 'inbox_settings.id'); - } - function render_settings_ui() { $this->register_handler('plugin.body', [$this, 'render_settings_form']); $this->rcmail->output->set_pagetitle($this->gettext('inbox_settings')); @@ -179,10 +150,62 @@ class inbox_settings extends rcube_plugin { return $page_content; } + function render_keys_ui() { + $this->rcmail->output->add_handler('keyslist', [$this, 'render_keys_list']); + $this->rcmail->output->set_pagetitle($this->gettext('inbox_keys')); + $this->rcmail->output->send('inbox_settings.keys'); + } + + function render_keys_list($attrib) { + if (empty($attrib['id'])) + $attrib['id'] = 'rcpgpkeyslist'; + + // info the js needs access to + $this->rcmail->output->add_gui_object('keyslist', $attrib['id']); + $this->rcmail->output->add_label( + 'inbox_settings.confirm_delete_key', 'inbox_settings.deleting_key'); + // the js in question + $this->rcmail->output->include_script('list.js'); + $this->include_script('keys.js'); + + $data = self::label_assoc_2d($this->run_query('keys', [], true)); + if (empty($data)) { + $this->rcmail->output->command( + 'display_message', $this->gettext('no_keys'), 'notice'); + } + + return rcmail_action::table_output( + $attrib, + $data, + ['inbox_settings.fingerprint', 'inbox_settings.comment'], + 'inbox_settings.id'); + } + + function render_generate_ui() { + $this->rcmail->output->add_handler('importform', [$this, 'render_generate_form']); + $this->rcmail->output->set_pagetitle($this->gettext('keygen')); + $this->rcmail->output->send('inbox_settings.key_import'); + } + + function render_generate_form() { + return '<p>Not yet implemented.</p>'; + } + + function render_import_ui() { + $this->rcmail->output->add_handler('importform', [$this, 'render_import_form']); + $this->rcmail->output->set_pagetitle($this->gettext('key_import')); + $this->rcmail->output->send('inbox_settings.key_import'); + } + + function render_import_form() { + return '<p>Not yet implemented.</p>'; + } + function delete_selected_keys() { $this->run_query('delete_keys', ['%k' => $_POST['keys']]); - $this->rcmail->output->set_pagetitle($this->gettext('deleting_key')); - $this->rcmail->output->send('plugin'); + $this->rcmail->output->command( + 'display_message', $this->gettext('keys_deleted'), 'notice'); + $this->rcmail->output->send(); } private static function label_assoc_2d($data) { @@ -1,4 +1,4 @@ -window.rcmail && window.rcmail.addEventListener('init', function () { +window.rcmail && window.rcmail.addEventListener('init', function() { if (rcmail.env.task === 'settings' && rcmail.env.action === 'plugin.inbox_keys') { if (rcmail.gui_objects.keyslist) { @@ -19,30 +19,30 @@ window.rcmail && window.rcmail.addEventListener('init', function () { } }); -rcube_webmail.prototype.inbox_keys_select = function (list) { +rcube_webmail.prototype.inbox_keys_select = function(list) { this.enable_command('plugin.inbox_keys_delete', list.get_selection().length > 0); }; -rcube_webmail.prototype.inbox_keys_generate = function () { - this.inbox_keys_loadframe('&_action=plugin.inbox_keys_generate'); +rcube_webmail.prototype.inbox_keys_generate = function() { + this.goto_url('plugin.inbox_keys_generate'); }; -rcube_webmail.prototype.inbox_keys_import = function () { - this.inbox_keys_loadframe('&_action=plugin.inbox_keys_import'); +rcube_webmail.prototype.inbox_keys_import = function() { + this.goto_url('plugin.inbox_keys_import'); }; -rcube_webmail.prototype.inbox_keys_delete = function () { +rcube_webmail.prototype.inbox_keys_delete = function() { var keys = this.inbox_keys_list.get_selection(); if (!keys.length) return; this.confirm_dialog( this.get_label('inbox_settings.confirm_delete_key'), 'delete', - function (_evt, ref) { + function(_evt, ref) { var lock = ref.display_message( ref.get_label('inbox_settings.deleting_key', 'loading')); + ref.addEventListener('responseafter', () => ref.reload()); ref.http_post('plugin.inbox_keys_delete', {keys}, lock); - ref.reload(); }); }; diff --git a/localization/en_US.inc b/localization/en_US.inc index 7acf909..118dbc4 100644 --- a/localization/en_US.inc +++ b/localization/en_US.inc @@ -12,9 +12,10 @@ $labels['sql_error'] = 'Encountered an error while performing the operation; ple $labels['keygen'] = 'Generate Key'; $labels['key_import'] = 'Import Key'; $labels['key_delete'] = 'Delete Key'; -$labels['no_keys'] = 'There are no encryption keys associated with your account yet.'; +$labels['no_keys'] = 'There are no encryption keys associated with your account yet'; $labels['fingerprint'] = 'Key Fingerprint'; $labels['comment'] = 'Comment'; $labels['confirm_delete_key'] = 'Are you sure you want to remove this encryption key from your account?'; $labels['deleting_key'] = 'Removing encryption key...'; +$labels['keys_deleted'] = 'Encryption key(s) removed' ?> |
