Skip to content

Commit

Permalink
[jan] Allow to set vaction with only start or end date, if Sieve date…
Browse files Browse the repository at this point in the history
… extension is available.
  • Loading branch information
yunosh committed May 8, 2017
1 parent 103a1d8 commit 38efa90
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
2 changes: 2 additions & 0 deletions ingo/docs/CHANGES
Expand Up @@ -2,6 +2,8 @@
v4.0.0-git
----------

[jan] Allow to set vaction with only start or end date, if Sieve date extension
is available.
[jan] Add support for Sieve date extension to vacation messages (Request
#12520).
[mjr] Export active vacation messages via the timeObjects API (Request #10885).
Expand Down
50 changes: 37 additions & 13 deletions ingo/lib/Script/Sieve/Action/Vacation.php
Expand Up @@ -53,14 +53,14 @@ public function __construct($vars = array())
*/
public function generate()
{
if (empty($this->_vars['start']) || empty($this->_vars['end'])) {
return $this->_vacationCode();
}

if ($this->_vars['date']) {
return $this->_dateCheck();
}

if (empty($this->_vars['start']) || empty($this->_vars['end'])) {
return $this->_vacationCode();
}

return $this->_regexCheck();
}

Expand Down Expand Up @@ -178,15 +178,39 @@ protected function _regexCheck()
*/
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 }";
$start = empty($this->_vars['start']) ? null : $this->_vars['start'];
$end = empty($this->_vars['end']) ? null : $this->_vars['end'];
$code = '';
if ($start || $end) {
$code .= 'if ';
}
if ($start && $end) {
$code .= 'allof ( ';
}
if ($start) {
$code .= 'currentdate :zone '
. date('O', $this->_vars['start']) . ' :value "ge" "date" "'
. date('Y-m-d', $this->_vars['start']) . '"';
}
if ($start && $end) {
$code .= ",\n" . ' ';
}
if ($end) {
$code .= 'currentdate :zone '
. date('O', $this->_vars['end']) . ' :value "le" "date" "'
. date('Y-m-d', $this->_vars['end']) . '"';
}
if ($start && $end) {
$code .= ' )';
}
if ($start || $end) {
$code .= " {\n" . ' ';
}
$code .= $this->_vacationCode();
if ($start || $end) {
$code .= "\n }";
}
return $code;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions ingo/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/apache">ASL</license>
<notes>
* [jan] Allow to set vaction with only start or end date, if Sieve date extension is available.
* [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.
Expand Down Expand Up @@ -1778,6 +1779,7 @@
</stability>
<license uri="http://www.horde.org/licenses/apache">ASL</license>
<notes>
* [jan] Allow to set vaction with only start or end date, if Sieve date extension is available.
* [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.
Expand Down

0 comments on commit 38efa90

Please sign in to comment.