summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarson Fleming <[email protected]>2024-12-30 21:33:34 -0800
committerCarson Fleming <[email protected]>2024-12-30 21:33:34 -0800
commitf21b2d31596ab6eab0b9acbf181e95cafd795422 (patch)
treef43e13cb9a689a211945b9303a91c57c3bbac0e4
parenteb5b7cd2b30567381caab3d50378d0de4ce28abd (diff)
downloadrc-inbox-settings-f21b2d31596ab6eab0b9acbf181e95cafd795422.tar.gz
progress & cleanup
-rw-r--r--inbox_settings.php89
-rw-r--r--keys.js18
-rw-r--r--localization/en_US.inc3
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) {
diff --git a/keys.js b/keys.js
index 8ef23d3..6d69377 100644
--- a/keys.js
+++ b/keys.js
@@ -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'
?>