Skip to content

Commit

Permalink
Procmail and Maildrop support either start or end too.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed May 8, 2017
1 parent b90d8f9 commit 598b813
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
3 changes: 1 addition & 2 deletions ingo/docs/CHANGES
Expand Up @@ -2,8 +2,7 @@
v4.0.0-git
----------

[jan] Allow to set vaction with only start or end date, if Sieve date extension
is available.
[jan] Allow to set vaction with only start or end date, if supported.
[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
11 changes: 8 additions & 3 deletions ingo/lib/Script/Maildrop/Recipe.php
Expand Up @@ -154,12 +154,17 @@ public function __construct($params = array(), $scriptparams = array())
}

// Rule : Start/End of vacation
if (($start != 0) && ($end !== 0)) {
if ($start != 0 || $end != 0) {
$this->_action[] = ' flock "$HOME/vacationprocess.lock" {';
$this->_action[] = ' current_time=time';
$this->_action[] = ' if ( \ ';
$this->_action[] = ' ($current_time >= ' . $start . ') && \ ';
$this->_action[] = ' ($current_time <= ' . $end . ')) ';
if ($start != 0) {
$this->_action[] = ' ($current_time >= ' . $start
. ($end != 0 ? ') && \ ' : ') ');
}
if ($end != 0) {
$this->_action[] = ' ($current_time <= ' . $end . ')) ';
}
$this->_action[] = ' {';
}
$this->_action[] = ' cc "' . str_replace('"', '\\"', sprintf(
Expand Down
23 changes: 17 additions & 6 deletions ingo/lib/Script/Procmail/Recipe.php
Expand Up @@ -148,8 +148,6 @@ public function __construct($params = array(), $scriptparams = array())

case 'Ingo_Rule_System_Vacation':
$days = $params['action-value']['days'];
$timed = !empty($params['action-value']['start']) &&
!empty($params['action-value']['end']);
$this->_action[] = '{';
foreach ($params['action-value']['addresses'] as $address) {
if (empty($address)) {
Expand All @@ -174,9 +172,11 @@ public function __construct($params = array(), $scriptparams = array())
. 'test $FILEDATE -le $DATE && '
. 'rm ${VACATION_DIR:-.}/\'.vacation.' . $address . '\'`';
}
if ($timed) {
if (!empty($params['action-value']['start'])) {
$this->_action[] = ' START='
. $params['action-value']['start'];
}
if (!empty($params['action-value']['end'])) {
$this->_action[] = ' END='
. $params['action-value']['end'];
}
Expand All @@ -186,9 +186,20 @@ public function __construct($params = array(), $scriptparams = array())
$this->_action[] = '';
$this->_action[] =
' :0 Wc: ${VACATION_DIR:-.}/vacation.lock';
if ($timed) {
$this->_action[] =
' * ? test $DATE -gt $START && test $END -gt $DATE';
if (!empty($params['action-value']['start']) ||
!empty($params['action-value']['end'])) {
$test = ' * ?';
if (!empty($params['action-value']['start'])) {
$test .= ' test $DATE -gt $START';
}
if (!empty($params['action-value']['start']) &&
!empty($params['action-value']['end'])) {
$test .= ' &&';
}
if (!empty($params['action-value']['end'])) {
$test .= ' test $END -gt $DATE';
}
$this->_action[] = $test;
}
$this->_action[] = ' {';
$this->_action[] = ' :0 Wh';
Expand Down
4 changes: 2 additions & 2 deletions ingo/package.xml
Expand Up @@ -33,7 +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] Allow to set vaction with only start or end date, if supported.
* [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 @@ -1779,7 +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] Allow to set vaction with only start or end date, if supported.
* [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 598b813

Please sign in to comment.