summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarson Fleming <[email protected]>2024-12-30 04:00:35 -0800
committerCarson Fleming <[email protected]>2024-12-30 04:00:35 -0800
commit649608f336a2b6810886bc291b31126a48a1bba6 (patch)
tree9ef9b77bb5ef8144b6129d5445cdffde403c1640
parent090370ed5b4906fd718cb46871b0e7bce20ef314 (diff)
downloadrc-inbox-settings-649608f336a2b6810886bc291b31126a48a1bba6.tar.gz
potentially working stub
-rw-r--r--config.inc.php.dist10
-rw-r--r--inbox_settings.php14
2 files changed, 17 insertions, 7 deletions
diff --git a/config.inc.php.dist b/config.inc.php.dist
index af79ba0..394086b 100644
--- a/config.inc.php.dist
+++ b/config.inc.php.dist
@@ -62,4 +62,14 @@ $config['inbox_settings_forwarding_addresses_query'] = 'SELECT addr, fwd_addr, a
// %sf - whether forwarding is set for this address (boolean)
// %sa - the new forwarding address (string)
$config['inbox_settings_update_forwarder_query'] = 'UPDATE forwarders SET fwd_addr = %sf, active = %sa WHERE addr = %fa';
+
+// The SQL query used to select a user's PGP keys.
+// 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)
+$config['inbox_settings_keys_query'] = 'SELECT id, fingerprint, comment FROM pgp_keys WHERE username = %u';
?>
diff --git a/inbox_settings.php b/inbox_settings.php
index c0b2017..3f8b45d 100644
--- a/inbox_settings.php
+++ b/inbox_settings.php
@@ -89,14 +89,14 @@ class inbox_settings extends rcube_plugin {
$attrib['id'] = 'rcpgpkeyslist';
// info the js needs access to
- $this->rc->output->add_gui_object('keyslist', $attrib['id']);
- $this->rc->output->include_script('list.js');
+ $this->rcmail->output->add_gui_object('keyslist', $attrib['id']);
+ $this->rcmail->output->include_script('list.js');
- // $this->rc->output->add_label('inbox_settings.a', 'inbox_settings.b');
+ // $this->rcmail->output->add_label('inbox_settings.a', 'inbox_settings.b');
- $data = [[1, 'DEADBEEF', 'placeholder comment']];
+ $data = run_query('keys', $assoc = true);
- return rcmail_action::table_output($attrib, $data, ['name', 'comment'], 'id');
+ return rcmail_action::table_output($attrib, $data, ['fingerprint', 'comment'], 'id');
}
function render_settings_ui() {
@@ -192,7 +192,7 @@ class inbox_settings extends rcube_plugin {
return (new html_inputfield(['type' => 'hidden', 'name' => $name]))->show($value);
}
- private function run_query($qid, $substitutions = []) {
+ private function run_query($qid, $substitutions = [], $assoc = false) {
if (!($sql = $this->rcmail->config->get('inbox_settings_' . $qid . '_query'))) {
$this->rcmail->output->command(
'display_message', $this->gettext('no_query'), 'error');
@@ -234,7 +234,7 @@ class inbox_settings extends rcube_plugin {
}
$ndresult = [];
- while ($row = $db->fetch_array($result))
+ while ($row = $assoc ? $db->fetch_assoc($result) : $db->fetch_array($result))
$ndresult[] = $row;
return $ndresult;