*
* The alarm will be added if it doesn't exist, and updated otherwise.
*
- * @param array $alarm An alarm hash. See self::get() for format.
- * @param boolean $keepsnooze Whether to keep the snooze value unchanged.
+ * @param array $alarm An alarm hash. See self::get() for format.
+ * @param boolean $keep Whether to keep the snooze value and notification
+ * status unchanged. If true, the alarm will get
+ * "un-snoozed", and notifications (like mails) are
+ * sent again.
*
* @throws Horde_Alarm_Exception
*/
- public function set(array $alarm, $keepsnooze = false)
+ public function set(array $alarm, $keep = false)
{
if (isset($alarm['mail']['body'])) {
$alarm['mail']['body'] = $this->_toDriver($alarm['mail']['body']);
}
if ($this->exists($alarm['id'], isset($alarm['user']) ? $alarm['user'] : '')) {
- $this->_update($alarm, $keepsnooze);
+ $this->_update($alarm, $keep);
+ if (!$keep) {
+ foreach ($this->_handlers as &$handler) {
+ $handler->reset($alarm);
+ }
+ }
} else {
$this->_add($alarm);
}
abstract public function notify(array $alarm);
/**
+ * Resets the internal status of the handler, so that alarm notifications
+ * are sent again.
+ *
+ * @param array $alarm An alarm hash.
+ */
+ public function reset(array $alarm)
+ {
+ }
+
+ /**
* Returns a human readable description of the handler.
*
* @return string
}
/**
+ * Resets the internal status of the handler, so that alarm notifications
+ * are sent again.
+ *
+ * @param array $alarm An alarm hash.
+ */
+ public function reset(array $alarm)
+ {
+ $alarm['internal']['mail']['sent'] = false;
+ $this->alarm->internal($alarm['id'], $alarm['user'], $alarm['internal']);
+ }
+
+ /**
* Returns a human readable description of the handler.
*
* @return string
Action is required\.
EOR;
+ $regexp = trim(str_replace("\r\n", "\n", $regexp));
- $this->assertRegExp('/' . trim(str_replace("\r\n", "\n", $regexp)) . '/', trim(str_replace("\r\n", "\n", self::$mail->sentOutput)));
+ $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", self::$mail->sentOutput)));
self::$mail->sentOutput = null;
self::$alarm->notify('john', false);
$this->assertNull(self::$mail->sentOutput);
+
+ /* Test re-sending mails after changing the alarm. */
+ self::$alarm->set(self::$alarm->get('personalalarm', 'john'));
+ self::$alarm->notify('john', false);
+ $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", self::$mail->sentOutput)));
}
}