summaryrefslogtreecommitdiff
path: root/inbox_settings.php
diff options
context:
space:
mode:
Diffstat (limited to 'inbox_settings.php')
-rw-r--r--inbox_settings.php101
1 files changed, 71 insertions, 30 deletions
diff --git a/inbox_settings.php b/inbox_settings.php
index 9a800a2..2cb0c7a 100644
--- a/inbox_settings.php
+++ b/inbox_settings.php
@@ -52,33 +52,53 @@ class inbox_settings extends rcube_plugin {
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]))
- continue;
- $fwd_addr = $_POST['fwd_addr'][$idx];
- $fwd_addr = empty($fwd_addr) ? '' : $fwd_addr;
- $do_forward = isset($_POST['do_fwd'][$idx]) ? '1' : '0';
-
- $local_part = $addr;
- $domain_part = '';
- if ($at_separator = strrpos($addr, '@')) {
- $local_part = substr($addr, 0, $at_separator);
- $domain_part = substr($addr, $at_separator + 1);
+ if (!empty($_POST['fwd_iaddr']) && is_array($_POST['fwd_iaddr'])) {
+ foreach ($_POST['fwd_iaddr'] as $idx => $addr) {
+ if (!empty($_POST['fwd_oaddr'][$idx])
+ && !rcube_utils::check_email($_POST['fwd_oaddr'][$idx]))
+ continue;
+
+ $fwd_addr = $_POST['fwd_oaddr'][$idx];
+ $fwd_addr = empty($fwd_addr) ? '' : $fwd_addr;
+ $do_forward = isset($_POST['do_fwd'][$idx]) ? '1' : '0';
+
+ $local_part = $addr;
+ $domain_part = '';
+ if ($at_separator = strrpos($addr, '@')) {
+ $local_part = substr($addr, 0, $at_separator);
+ $domain_part = substr($addr, $at_separator + 1);
+ }
+
+ $success &= is_array($this->run_query('update_forwarder', [
+ '%aa' => $addr,
+ '%al' => $local_part,
+ '%ad' => $domain_part,
+ '%sf' => $do_forward,
+ '%sa' => $fwd_addr
+ ]));
}
+ }
- $success &= is_array($this->run_query('update_forwarder', [
- '%aa' => $addr,
- '%al' => $local_part,
- '%ad' => $domain_part,
- '%sf' => $do_forward,
- '%sa' => $fwd_addr
- ]));
+ if (!empty($_POST['store_addr']) && is_array($_POST['store_addr'])) {
+ foreach ($_POST['store_addr'] as $idx => $addr) {
+ $do_store = isset($_POST['do_store'][$idx]) ? '1' : '0';
+
+ $local_part = $addr;
+ $domain_part = '';
+ if ($at_separator = strrpos($addr, '@')) {
+ $local_part = substr($addr, 0, $at_separator);
+ $domain_part = substr($addr, $at_separator + 1);
+ }
+
+ $success &= is_array($this->run_query('update_stored_address', [
+ '%aa' => $addr,
+ '%al' => $local_part,
+ '%ad' => $domain_part,
+ '%ss' => $do_store
+ ]));
+ }
}
if ($success)
@@ -117,13 +137,13 @@ class inbox_settings extends rcube_plugin {
foreach ($forwarders as $idx => $row) {
$forwarding_form->add('title col-sm-4',
html::label(
- ['class' => 'col-form-label', 'for' => 'fwd_addr_' . $idx],
+ ['class' => 'col-form-label', 'for' => 'fwd_oaddr_' . $idx],
rcube::Q($row[0]))
- . self::get_hiddenfield('addr[' . $idx . ']', $row[0]));
+ . self::get_hiddenfield('fwd_iaddr[' . $idx . ']', $row[0]));
$forwarding_form->add('col-sm-4',
self::get_textfield(
- 'fwd_addr_' . $idx,
- 'fwd_addr[' . $idx . ']',
+ 'fwd_oaddr_' . $idx,
+ 'fwd_oaddr[' . $idx . ']',
$row[1],
['placeholder' => '[email protected]']));
$forwarding_form->add('col-sm-2 offset-1',
@@ -134,14 +154,35 @@ class inbox_settings extends rcube_plugin {
['title' => $this->gettext('fwd_addr')]));
}
+ $storage_addrs = $this->run_query('stored_addresses');
+ if (!is_array($storage_addrs))
+ $stored_addrs = [];
+
+ $storage_form = new html_table(['cols' => 2, 'class' => 'propform']);
+ foreach ($stored_addrs as $idx => $row) {
+ $storage_form->add('title col-sm-8',
+ html::label(
+ ['class' => 'col-form-label', 'for' => 'do_store_' . $idx],
+ rcube::Q($row[0]))
+ . self::get_hiddenfield('store_addr[' . $idx . ']', $row[0]));
+ $storage_form->add('col-sm-2 offset-1',
+ self::get_checkbox(
+ 'do_store_' . $idx,
+ 'do_store[' . $idx . ']',
+ $row[1],
+ ['title' => $this->gettext('store_addr')]));
+ }
+
$form = html::div(['class' => 'formcontent'],
html::tag('fieldset', null,
html::tag('legend', null, rcube::Q($this->gettext('encryption')))
- . $encryption_form->show(null)
- )
+ . $encryption_form->show(null))
. html::tag('fieldset', null,
html::tag('legend', null, rcube::Q($this->gettext('forwarding')))
- . $forwarding_form->show(null)));
+ . $forwarding_form->show(null))
+ . html::tag('fieldset', null,
+ html::tag('legend', null, rcube::Q($this->gettext('storage')))
+ . $storage_form->show(null)));
$save_button = (new html_button([
'type' => 'submit',
'name' => 'save',