summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarson Fleming <[email protected]>2024-12-31 18:47:28 -0800
committerCarson Fleming <[email protected]>2024-12-31 18:47:28 -0800
commit389139c1749904477a22644248ba25f46485827e (patch)
treee978295357261ee2256ff167c0908cb3a874a0d4
parent27cfb2476d94f93bbb1839d179f473bf0e5ef9ec (diff)
downloadrc-inbox-settings-389139c1749904477a22644248ba25f46485827e.tar.gz
skeleton of the final vision
-rw-r--r--config.inc.php.dist12
-rw-r--r--inbox_settings.php15
-rw-r--r--keys.js5
3 files changed, 25 insertions, 7 deletions
diff --git a/config.inc.php.dist b/config.inc.php.dist
index 2bbc70b..e9fb3fc 100644
--- a/config.inc.php.dist
+++ b/config.inc.php.dist
@@ -83,4 +83,16 @@ $config['inbox_settings_keys_query'] = 'SELECT id, fingerprint, comment FROM pgp
// (in case the username is an email address)
// %k - the key IDs being deleted
$config['inbox_settings_delete_keys_query'] = 'DELETE FROM pgp_keys WHERE id IN %k AND username = %u';
+
+// The SQL query used add a PGP key to a user's account.
+// Supported replacement variables:
+// %h - user's IMAP hostname
+// %u - the username (from the session info)
+// %l - the local part of the username
+// (in case the username is an email address)
+// %d - the domain part of the username
+// (in case the username is an email address)
+// %k - the binary key data blob
+// %c - the comment to identify the key
+$config['inbox_settings_add_key_query'] = 'INSERT INTO pgp_keys (username, key_data, comment) VALUES (%u, %k, %c)';
?>
diff --git a/inbox_settings.php b/inbox_settings.php
index 24a3326..7b3ccce 100644
--- a/inbox_settings.php
+++ b/inbox_settings.php
@@ -196,18 +196,23 @@ class inbox_settings extends rcube_plugin {
if (!isset($_POST['import']))
return false;
+ $dearmored_key_data = TODO_magic($_POST['key_data']);
+ $comment = $_POST['comment'];
+ foreach ($dearmored_key_data as $dearmored_key) {
+ $this->run_query('add_key', ['%k' => $dearmored_key, '%c' => $comment]);
+ }
+
+ $this->rcmail->output->command(
+ 'display_message', $this->gettext('keys_imported'), 'notice');
return true;
}
function render_import_ui() {
$this->rcmail->output->set_pagetitle($this->gettext('key_import'));
- if ($this->import_keys()) {
- $this->rcmail->output->command(
- 'display_message', $this->gettext('keys_imported'), 'notice');
+ if ($this->import_keys())
$this->rcmail->output->redirect('plugin.inbox_keys');
- } else {
+ else
$this->rcmail->output->send('inbox_settings.key_import');
- }
}
function delete_selected_keys() {
diff --git a/keys.js b/keys.js
index a596199..72ad6f9 100644
--- a/keys.js
+++ b/keys.js
@@ -13,7 +13,7 @@ window.rcmail && window.rcmail.addEventListener('init', function() {
.focus();
}
- rcmail.register_command('plugin.inbox_keys_generate', () => rcmail.inbox_keys_generate(), true);
+ rcmail.register_command('plugin.inbox_keys_generate', () => rcmail.inbox_keys_generate(), false);
rcmail.register_command('plugin.inbox_keys_import', () => rcmail.inbox_keys_import(), true);
rcmail.register_command('plugin.inbox_keys_delete', () => rcmail.inbox_keys_delete(), false);
}
@@ -24,7 +24,8 @@ rcube_webmail.prototype.inbox_keys_select = function(list) {
};
rcube_webmail.prototype.inbox_keys_generate = function() {
- this.goto_url('plugin.inbox_keys_generate');
+ // TODO: generate the key client-side and post it to the import endpoint,
+ // TODO: then redirect the client to download the generated private key
};
rcube_webmail.prototype.inbox_keys_import = function() {