diff --git a/ingo/basic.php b/ingo/basic.php
index 3c5d61d0eca..6889b4d1499 100644
--- a/ingo/basic.php
+++ b/ingo/basic.php
@@ -18,7 +18,7 @@
*/
require_once __DIR__ . '/lib/Application.php';
-Horde_Registry::appInit('ingo');
+Horde_Registry::appInit('ingo', array('timezone' => true));
$vars = $injector->getInstance('Horde_Variables');
diff --git a/ingo/config/backends.php b/ingo/config/backends.php
index ed4ad7b0fed..532310b2b42 100644
--- a/ingo/config/backends.php
+++ b/ingo/config/backends.php
@@ -289,6 +289,11 @@
Ingo::RULE_ALL => array(
'driver' => 'sieve',
'params' => array(
+ // If false, use less reliable regular expression parsing of
+ // Received: headers instead of the standardized 'date' and
+ // 'relational' extensions for date-limiting vacation messages.
+ 'date' => true,
+
// If true, use the deprecated 'imapflags' extension to set
// flag status instead of the newer, standardized
// 'imap4flags'.
diff --git a/ingo/docs/CHANGES b/ingo/docs/CHANGES
index 1f16e659014..50d90754757 100644
--- a/ingo/docs/CHANGES
+++ b/ingo/docs/CHANGES
@@ -2,6 +2,8 @@
v3.3.0-git
----------
+[jan] Add support for Sieve date extension to vacation messages (Request
+ #12520).
[mjr] Export active vacation messages via the timeObjects API (Request #10885).
[mms] Added a NoSQL (MongoDB) driver for the storage backend.
[mms] Rule code has been separated from the storage backend drivers.
diff --git a/ingo/docs/UPGRADING b/ingo/docs/UPGRADING
index 666eab7c9fd..026c3f7a9ca 100644
--- a/ingo/docs/UPGRADING
+++ b/ingo/docs/UPGRADING
@@ -51,6 +51,14 @@ Configuration Options (conf.php)
Added a NoSQL (MongoDB) driver for the storage backend.
+Backend Configuration (backends.php)
+------------------------------------
+
+The Sieve driver now uses the 'date' and 'relational' extensions for timed
+vacation messages by default. If using a Sieve version that doesn't support
+those extensions, set 'date' to false in the sieve script parameters to use the
+older regular expression parsing (see backends.php).
+
Upgrading Ingo From 3.1.x To 3.2
================================
diff --git a/ingo/lib/Script/Sieve.php b/ingo/lib/Script/Sieve.php
index 2171a9785e0..d999cb6ce53 100644
--- a/ingo/lib/Script/Sieve.php
+++ b/ingo/lib/Script/Sieve.php
@@ -345,7 +345,8 @@ protected function _addVacationBlocks(Ingo_Rule $rule)
'end_year' => $rule->end_year,
'end_month' => $rule->end_month,
'end_day' => $rule->end_day,
- 'reason' => $rule->reason
+ 'reason' => $rule->reason,
+ 'date' => !empty($this->_params['date']),
));
if ($rule->ignore_list) {
diff --git a/ingo/lib/Script/Sieve/Action/Vacation.php b/ingo/lib/Script/Sieve/Action/Vacation.php
index 1deba5f7829..d0c1c980ea9 100644
--- a/ingo/lib/Script/Sieve/Action/Vacation.php
+++ b/ingo/lib/Script/Sieve/Action/Vacation.php
@@ -52,6 +52,24 @@ public function __construct($vars = array())
* @return string A Sieve script snippet.
*/
public function generate()
+ {
+ if (empty($this->_vars['start']) || empty($this->_vars['end'])) {
+ return $this->_vacationCode();
+ }
+
+ if ($this->_vars['date']) {
+ return $this->_dateCheck();
+ }
+
+ return $this->_regexCheck();
+ }
+
+ /**
+ * Uses regular expression parsing to limit vacation messages by date.
+ *
+ * @return string A Sieve script snippet.
+ */
+ protected function _regexCheck()
{
$start_year = $this->_vars['start_year'];
$start_month = $this->_vars['start_month'];
@@ -63,9 +81,7 @@ public function generate()
$code = '';
- if (empty($this->_vars['start']) || empty($this->_vars['end'])) {
- return $this->_vacationCode();
- } elseif ($end_year > $start_year + 1) {
+ if ($end_year > $start_year + 1) {
$code .= 'if ' . $this->_yearCheck($start_year + 1, $end_year - 1)
. " {\n"
. ' ' . $this->_vacationCode()
@@ -148,12 +164,31 @@ public function generate()
. $this->_vacationCode()
. "\n }\n";
}
- $code .= " }";
+ $code .= ' }';
}
return $code;
}
+ /**
+ * Uses 'date' and 'relative' extensions to limit vacation messages by
+ * date.
+ *
+ * @return string A Sieve script snippet.
+ */
+ protected function _dateCheck()
+ {
+ return 'if allof ( currentdate :zone '
+ . date('O', $this->_vars['start']) . ' :value "ge" "date" "'
+ . date('Y-m-d', $this->_vars['start']) . "\",\n"
+ . ' currentdate :zone '
+ . date('O', $this->_vars['end']) . ' :value "le" "date" "'
+ . date('Y-m-d', $this->_vars['end']) . "\" ) {\n"
+ . ' '
+ . $this->_vacationCode()
+ . "\n }";
+ }
+
/**
* Checks if the rule parameters are valid.
*
@@ -175,6 +210,10 @@ public function check()
*/
public function requires()
{
+ if ($this->_vars['date']) {
+ return array('vacation', 'date', 'relational');
+ }
+
return array('vacation', 'regex');
}
diff --git a/ingo/package.xml b/ingo/package.xml
index ceccde5f26a..bc301149ed3 100644
--- a/ingo/package.xml
+++ b/ingo/package.xml
@@ -33,6 +33,7 @@
ASL
+* [jan] Add support for Sieve date extension to vacation messages (Request #12520).
* [mjr] Export active vacation messages via the timeObjects API (Request #10885).
* [mms] Added a NoSQL (MongoDB) driver for the storage backend.
* [mms] Rule code has been separated from the storage backend drivers.
@@ -1747,6 +1748,7 @@
ASL
+* [jan] Add support for Sieve date extension to vacation messages (Request #12520).
* [mjr] Export active vacation messages via the timeObjects API (Request #10885).
* [mms] Added a NoSQL (MongoDB) driver for the storage backend.
* [mms] Rule code has been separated from the storage backend drivers.