From: Jan Schneider Date: Wed, 14 Apr 2010 09:57:24 +0000 (+0200) Subject: Don't reset snooze when passively updating the alarms. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=85d1bb753c83162a002c109aa14309ec42f18f76;p=horde.git Don't reset snooze when passively updating the alarms. --- diff --git a/framework/Alarm/lib/Horde/Alarm.php b/framework/Alarm/lib/Horde/Alarm.php index 1c951ef60..dc6c8bcd7 100644 --- a/framework/Alarm/lib/Horde/Alarm.php +++ b/framework/Alarm/lib/Horde/Alarm.php @@ -129,19 +129,22 @@ class Horde_Alarm * * 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 array $alarm An alarm hash. See self::get() for format. + * @param boolean $keepsnooze Whether to keep the snooze value unchanged. * * @return TODO */ - public function set($alarm) + public function set($alarm, $keepsnooze = false) { if (isset($alarm['mail']['body'])) { $alarm['mail']['body'] = $this->_toDriver($alarm['mail']['body']); } - return $this->exists($alarm['id'], isset($alarm['user']) ? $alarm['user'] : '') - ? $this->_update($alarm) - : $this->_add($alarm); + if ($this->exists($alarm['id'], isset($alarm['user']) ? $alarm['user'] : '')) { + $this->_update($alarm, $keepsnooze); + } else { + $this->_add($alarm); + } } /** @@ -320,7 +323,7 @@ class Horde_Alarm } foreach ($alarms as $alarm) { - $this->set($alarm); + $this->set($alarm, true); } } diff --git a/framework/Alarm/lib/Horde/Alarm/Sql.php b/framework/Alarm/lib/Horde/Alarm/Sql.php index a4e417a7e..b5915da82 100644 --- a/framework/Alarm/lib/Horde/Alarm/Sql.php +++ b/framework/Alarm/lib/Horde/Alarm/Sql.php @@ -212,12 +212,16 @@ class Horde_Alarm_Sql extends Horde_Alarm /** * Updates an alarm hash in the backend. * - * @param array $alarm An alarm hash. + * @param array $alarm An alarm hash. + * @param boolean $keepsnooze Whether to keep the snooze value unchanged. + * + * @throws Horde_Alarm_Exception */ - protected function _update($alarm) + protected function _update($alarm, $keepsnooze = false) { - $query = sprintf('UPDATE %s set alarm_start = ?, alarm_end = ?, alarm_methods = ?, alarm_params = ?, alarm_title = ?, alarm_text = ?, alarm_snooze = NULL WHERE alarm_id = ? AND %s', + $query = sprintf('UPDATE %s set alarm_start = ?, alarm_end = ?, alarm_methods = ?, alarm_params = ?, alarm_title = ?, alarm_text = ?%s WHERE alarm_id = ? AND %s', $this->_params['table'], + $keepsnooze ? '' : ', alarm_snooze = NULL', isset($alarm['user']) ? 'alarm_uid = ?' : '(alarm_uid = ? OR alarm_uid IS NULL)'); $values = array((string)$alarm['start']->setTimezone('UTC'), empty($alarm['end']) ? null : (string)$alarm['end']->setTimezone('UTC'),