diff options
Diffstat (limited to 'inbox_settings.php')
| -rw-r--r-- | inbox_settings.php | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/inbox_settings.php b/inbox_settings.php index 5e96974..d7fdc4b 100644 --- a/inbox_settings.php +++ b/inbox_settings.php @@ -50,11 +50,13 @@ class inbox_settings extends rcube_plugin { return; $encrypt_inbox = isset($_POST['encrypt_inbox']) ? '1' : '0'; - $this->run_query('update_encryption', ['%se' => $encrypt_inbox]); + if (!is_array($this->run_query('update_encryption', ['%se' => $encrypt_inbox]))) + return; if (empty($_POST['addr']) || !is_array($_POST['addr'])) return; + $success = true; foreach ($_POST['addr'] as $idx => $addr) { if (!empty($_POST['fwd_addr'][$idx]) && !rcube_utils::check_email($_POST['fwd_addr'][$idx])) @@ -71,17 +73,18 @@ class inbox_settings extends rcube_plugin { $domain_part = substr($addr, $at_separator + 1); } - $this->run_query('update_forwarder', [ + $success &= is_array($this->run_query('update_forwarder', [ '%aa' => $addr, '%al' => $local_part, '%ad' => $domain_part, '%sf' => $do_forward, '%sa' => $fwd_addr - ]); + ])); } - $this->rcmail->output->command( - 'display_message', $this->gettext('settings_saved'), 'notice'); + if ($success) + $this->rcmail->output->command( + 'display_message', $this->gettext('settings_saved'), 'notice'); } function render_settings_ui() { @@ -95,6 +98,8 @@ class inbox_settings extends rcube_plugin { $page_title = html::tag('h1', 'voice', rcube::Q($this->gettext('inbox_settings'))); $encryption_result = $this->run_query('encryption_enabled'); $encrypt_inbox = 0; + if (!is_array($encryption_result)) + $encryption_result = []; if (!empty($encryption_result) && !empty($encryption_result[0])) $encrypt_inbox = $encryption_result[0][0] ? 1 : 0; @@ -106,6 +111,9 @@ class inbox_settings extends rcube_plugin { 'rcmfd_encrypt_inbox', 'encrypt_inbox', $encrypt_inbox)); $forwarders = $this->run_query('forwarding_addresses'); + if (!is_array($forwarders)) + $forwarders = []; + $forwarding_form = new html_table(['cols' => 3, 'class' => 'propform']); foreach ($forwarders as $idx => $row) { $forwarding_form->add('title col-sm-4', @@ -174,12 +182,14 @@ class inbox_settings extends rcube_plugin { $this->include_script('openpgp.min.js'); $this->include_script('keys.js'); - $data = self::label_assoc_2d($this->run_query('keys', [], true)); - if (empty($data)) { + $data = $this->run_query('keys', [], true); + if (!is_array($data)) + $data = []; + else if (empty($data)) $this->rcmail->output->command( 'display_message', $this->gettext('no_keys'), 'notice'); - } + $data = self::label_assoc_2d($data); return rcmail_action::table_output( $attrib, $data, @@ -218,11 +228,12 @@ class inbox_settings extends rcube_plugin { if (empty($comment)) $comment = null; foreach ($dearmored_key_data as $parsed_key) { - $this->run_query( + if (!is_array($this->run_query( 'add_key', ['%f' => $parsed_key['fingerprint'], '%k' => $parsed_key['data_blob'], - '%c' => $comment]); + '%c' => $comment]))) + return false; } $this->rcmail->output->command( @@ -239,9 +250,10 @@ class inbox_settings extends rcube_plugin { } function delete_selected_keys() { - $this->run_query('delete_keys', ['%k' => $_POST['keys']]); - $this->rcmail->output->command( - 'display_message', $this->gettext('keys_deleted'), 'notice'); + if (is_array($this->run_query('delete_keys', ['%k' => $_POST['keys']]))) + $this->rcmail->output->command( + 'display_message', $this->gettext('keys_deleted'), 'notice'); + $this->rcmail->output->send(); } @@ -293,7 +305,7 @@ class inbox_settings extends rcube_plugin { if (!($sql = $this->rcmail->config->get('inbox_settings_' . $qid . '_query'))) { $this->rcmail->output->command( 'display_message', $this->gettext('no_query'), 'error'); - return []; + return null; } if ($dsn = $this->rcmail->config->get('inbox_settings_db_dsn')) { @@ -306,7 +318,7 @@ class inbox_settings extends rcube_plugin { if ($db->is_error()) { $this->rcmail->output->command( 'display_message', $this->gettext('no_db'), 'error'); - return []; + return null; } $local_part = $this->rcmail->user->get_username('local'); @@ -327,7 +339,7 @@ class inbox_settings extends rcube_plugin { if ($db->is_error($result)) { $this->rcmail->output->command( 'display_message', $this->gettext('sql_error'), 'error'); - return []; + return null; } $ndresult = []; |
