From 2a3c067a8595082558172ddf8e42414c32e7a688 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Mon, 30 Dec 2024 20:40:48 -0800 Subject: this seems sketchy but we ball --- inbox_settings.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'inbox_settings.php') diff --git a/inbox_settings.php b/inbox_settings.php index 2a720d1..a0b36b5 100644 --- a/inbox_settings.php +++ b/inbox_settings.php @@ -17,6 +17,7 @@ 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_delete', [$this, 'delete_selected_keys']); } function scrub_encryption_preference($params) { @@ -90,6 +91,9 @@ class inbox_settings extends rcube_plugin { // 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'); @@ -175,6 +179,12 @@ class inbox_settings extends rcube_plugin { return $page_content; } + function delete_selected_keys() { + run_query('delete_keys', $_POST['keys']); + $this->rcmail->output->set_pagetitle($this->gettext('deleting_key')); + $this->rcmail->output->send('plugin'); + } + private static function label_assoc_2d($data) { $labeled_data = []; foreach ($data as $row) { @@ -242,7 +252,7 @@ class inbox_settings extends rcube_plugin { $sql = str_replace('%h', $db->quote($host, 'text'), $sql); foreach ($substitutions as $key => $value) { - $sql = str_replace($key, $db->quote($value, 'text'), $sql); + $sql = str_replace($key, self::quote_replacement($db, $value), $sql); } $result = $db->query($sql); @@ -259,6 +269,13 @@ class inbox_settings extends rcube_plugin { return $ndresult; } + private static function quote_replacement($db, $value) { + if (!is_array($value)) return $db->quote($value, 'text'); + return '(' . implode(', ', array_map(function ($inner) { + return self::quote_replacement($db, $inner); + }, $value)) . ')'; + } + private static function parse_dsn($dsn) { if (strpos($dsn, '%')) { // parse DSN and replace variables in hostname -- cgit v1.2.3