summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/managesieve/lib/rcube_sieve_script.php40
-rw-r--r--plugins/managesieve/localization/en_GB.inc5
-rw-r--r--plugins/managesieve/localization/en_US.inc5
-rw-r--r--plugins/managesieve/localization/pl_PL.inc5
-rw-r--r--plugins/managesieve/managesieve.js6
-rw-r--r--plugins/managesieve/managesieve.php44
6 files changed, 104 insertions, 1 deletions
diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php
index aa3b9ab6e..66bedb52b 100644
--- a/plugins/managesieve/lib/rcube_sieve_script.php
+++ b/plugins/managesieve/lib/rcube_sieve_script.php
@@ -403,6 +403,20 @@ class rcube_sieve_script
$action_script .= self::escape_string($action['name']) . ' ' . self::escape_string($action['value']);
break;
+ case 'notify':
+ array_push($exts, 'enotify');
+ $action_script .= 'notify';
+ foreach (array('from', 'importance', 'options', 'message') as $n_tag) {
+ if (!empty($action[$n_tag])) {
+ $action_script .= " :$n_tag " . self::escape_string($action[$n_tag]);
+ }
+ }
+ $method = (!empty($action['address']) && !empty($action['body'])) ?
+ sprintf('mailto:%s?body=%s', $action['address'], rawurlencode($action['body'])) :
+ $action['method'];
+ $action_script .= " " . self::escape_string($method);
+ break;
+
case 'vacation':
array_push($exts, 'vacation');
$action_script .= 'vacation';
@@ -840,6 +854,32 @@ class rcube_sieve_script
// $result[] = array('type' => 'require', 'target' => $tokens);
break;
+ case 'notify':
+ $notify = array('type' => 'notify', 'method' => array_pop($tokens));
+
+ // Parameters: :from, :importance, :options, :message
+ for ($i=0, $len=count($tokens); $i<$len; $i++) {
+ $tok = strtolower($tokens[$i]);
+ if ($tok[0] == ':') {
+ $notify[substr($tok, 1)] = $tokens[$i+1];
+ }
+ }
+ $method_components = parse_url($notify['method']);
+ if ($method_components['scheme'] == 'mailto') {
+ $notify['address'] = $method_components['path'];
+ $method_params = array();
+ parse_str($method_components['query'], $method_params);
+ $method_params = array_change_key_case($method_params, CASE_LOWER);
+ /* magic_quotes_gpc and magic_quotes_sybase affect the output of parse_str */
+ if (ini_get('magic_quotes_gpc') || ini_get('magic_quotes_sybase')) {
+ array_map('stripslashes', $method_params);
+ }
+ $notify['body'] = $method_params['body'];
+ }
+
+ $result[] = $notify;
+ break;
+
}
if ($separator == $end)
diff --git a/plugins/managesieve/localization/en_GB.inc b/plugins/managesieve/localization/en_GB.inc
index 6859f5fff..7b02c8218 100644
--- a/plugins/managesieve/localization/en_GB.inc
+++ b/plugins/managesieve/localization/en_GB.inc
@@ -97,6 +97,11 @@ $labels['setvariable'] = 'Set variable';
$labels['setvarname'] = 'Variable name:';
$labels['setvarvalue'] = 'Variable value:';
$labels['setvarmodifiers'] = 'Modifiers:';
+$labels['notify'] = 'Send notification';
+$labels['notifyaddress'] = 'To e-mail address:';
+$labels['notifybody'] = 'Notification body:';
+$labels['notifysubject'] = 'Notification subject:';
+$labels['notifyfrom'] = 'Notification sender:';
$labels['filtercreate'] = 'Create filter';
$labels['usedata'] = 'Use following data in the filter:';
$labels['nextstep'] = 'Next Step';
diff --git a/plugins/managesieve/localization/en_US.inc b/plugins/managesieve/localization/en_US.inc
index 191291338..bcef9139e 100644
--- a/plugins/managesieve/localization/en_US.inc
+++ b/plugins/managesieve/localization/en_US.inc
@@ -88,6 +88,11 @@ $labels['varlowerfirst'] = 'first character lower-case';
$labels['varupperfirst'] = 'first character upper-case';
$labels['varquotewildcard'] = 'quote special characters';
$labels['varlength'] = 'length';
+$labels['notify'] = 'Send notification';
+$labels['notifyaddress'] = 'To e-mail address:';
+$labels['notifybody'] = 'Notification body:';
+$labels['notifysubject'] = 'Notification subject:';
+$labels['notifyfrom'] = 'Notification sender:';
$labels['filtercreate'] = 'Create filter';
$labels['usedata'] = 'Use following data in the filter:';
$labels['nextstep'] = 'Next Step';
diff --git a/plugins/managesieve/localization/pl_PL.inc b/plugins/managesieve/localization/pl_PL.inc
index 0b4cb6073..5b51900e6 100644
--- a/plugins/managesieve/localization/pl_PL.inc
+++ b/plugins/managesieve/localization/pl_PL.inc
@@ -103,6 +103,11 @@ $labels['varlowerfirst'] = 'pierwsza litera mała (:lowerfirst)';
$labels['varupperfirst'] = 'pierwsza litera duża (:upperfirst)';
$labels['varquotewildcard'] = 'anulowane znaki specjalne (:quotewildcard)';
$labels['varlength'] = 'długość (:length)';
+$labels['notify'] = 'Wyślij powiadomienie';
+$labels['notifyaddress'] = 'Na adres e-mail:';
+$labels['notifybody'] = 'Treść powiadomienia:';
+$labels['notifysubject'] = 'Temat powiadomienia:';
+$labels['notifyfrom'] = 'Nadawca powiadomienia:';
$labels['filtercreate'] = 'Utwórz filtr';
$labels['usedata'] = 'Użyj następujących danych do utworzenia filtra:';
$labels['nextstep'] = 'Następny krok';
diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js
index f447719a2..bbc10793c 100644
--- a/plugins/managesieve/managesieve.js
+++ b/plugins/managesieve/managesieve.js
@@ -639,7 +639,8 @@ function action_type_select(id)
target_area: document.getElementById('action_target_area' + id),
flags: document.getElementById('action_flags' + id),
vacation: document.getElementById('action_vacation' + id),
- set: document.getElementById('action_set' + id)
+ set: document.getElementById('action_set' + id),
+ notify: document.getElementById('action_notify' + id)
};
if (obj.value == 'fileinto' || obj.value == 'fileinto_copy') {
@@ -660,6 +661,9 @@ function action_type_select(id)
else if (obj.value == 'set') {
enabled.set = 1;
}
+ else if (obj.value == 'notify') {
+ enabled.notify = 1;
+ }
for (var x in elems) {
elems[x].style.display = !enabled[x] ? 'none' : 'inline';
diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index e7828f1da..16c451845 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -625,6 +625,10 @@ class managesieve extends rcube_plugin
$varnames = get_input_value('_action_varname', RCUBE_INPUT_POST);
$varvalues = get_input_value('_action_varvalue', RCUBE_INPUT_POST);
$varmods = get_input_value('_action_varmods', RCUBE_INPUT_POST);
+ $notifyaddrs = get_input_value('_action_notifyaddress', RCUBE_INPUT_POST);
+ $notifybodies = get_input_value('_action_notifybody', RCUBE_INPUT_POST);
+ $notifymessages = get_input_value('_action_notifymessage', RCUBE_INPUT_POST);
+ $notifyfrom = get_input_value('_action_notifyfrom', RCUBE_INPUT_POST);
// we need a "hack" for radiobuttons
foreach ($sizeitems as $item)
@@ -878,6 +882,22 @@ class managesieve extends rcube_plugin
$this->errors['actions'][$i]['value'] = $this->gettext('cannotbeempty');
}
break;
+
+ case 'notify':
+ if (empty($notifyaddrs[$idx])) {
+ $this->errors['actions'][$i]['address'] = $this->gettext('cannotbeempty');
+ }
+ else if (!check_email($notifyaddrs[$idx])) {
+ $this->errors['actions'][$i]['address'] = $this->gettext('noemailwarning');
+ }
+ if (!empty($notifyfrom[$idx]) && !check_email($notifyfrom[$idx])) {
+ $this->errors['actions'][$i]['from'] = $this->gettext('noemailwarning');
+ }
+ $this->form['actions'][$i]['address'] = $notifyaddrs[$idx];
+ $this->form['actions'][$i]['body'] = $notifybodies[$idx];
+ $this->form['actions'][$i]['message'] = $notifymessages[$idx];
+ $this->form['actions'][$i]['from'] = $notifyfrom[$idx];
+ break;
}
$this->form['actions'][$i]['type'] = $type;
@@ -1479,6 +1499,9 @@ class managesieve extends rcube_plugin
if (in_array('variables', $this->exts)) {
$select_action->add(Q($this->gettext('setvariable')), 'set');
}
+ if (in_array('enotify', $this->exts)) {
+ $select_action->add(Q($this->gettext('notify')), 'notify');
+ }
$select_action->add(Q($this->gettext('rulestop')), 'stop');
$select_type = $action['type'];
@@ -1571,6 +1594,27 @@ class managesieve extends rcube_plugin
}
$out .= '</div>';
+ // notify
+ // skip :options tag - not used by the mailto method
+ $out .= '<div id="action_notify' .$id.'" style="display:' .($action['type']=='notify' ? 'inline' : 'none') .'">';
+ $out .= '<span class="label">' .Q($this->gettext('notifyaddress')) . '</span><br />'
+ .'<input type="text" name="_action_notifyaddress['.$id.']" id="action_notifyaddress'.$id.'" '
+ .'value="' . Q($action['address']) . '" size="35" '
+ . $this->error_class($id, 'action', 'address', 'action_notifyaddress') .' />';
+ $out .= '<br /><span class="label">'. Q($this->gettext('notifybody')) .'</span><br />'
+ .'<textarea name="_action_notifybody['.$id.']" id="action_notifybody' .$id. '" '
+ .'rows="3" cols="35" '. $this->error_class($id, 'action', 'method', 'action_notifybody') . '>'
+ . Q($action['body'], 'strict', false) . "</textarea>\n";
+ $out .= '<br /><span class="label">' .Q($this->gettext('notifysubject')) . '</span><br />'
+ .'<input type="text" name="_action_notifymessage['.$id.']" id="action_notifymessage'.$id.'" '
+ .'value="' . Q($action['message']) . '" size="35" '
+ . $this->error_class($id, 'action', 'message', 'action_notifymessage') .' />';
+ $out .= '<br /><span class="label">' .Q($this->gettext('notifyfrom')) . '</span><br />'
+ .'<input type="text" name="_action_notifyfrom['.$id.']" id="action_notifyfrom'.$id.'" '
+ .'value="' . Q($action['from']) . '" size="35" '
+ . $this->error_class($id, 'action', 'from', 'action_notifyfrom') .' />';
+ $out .= '</div>';
+
// mailbox select
if ($action['type'] == 'fileinto')
$mailbox = $this->mod_mailbox($action['target'], 'out');