Skip to content

Commit

Permalink
Fix creating the initial alarm entry for a recurring event.
Browse files Browse the repository at this point in the history
Don't assume we are always creating a recurrence series that
starts in the future.
  • Loading branch information
mrubinsk committed Mar 6, 2014
1 parent e872ca7 commit c58b297
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions kronolith/lib/Event.php
Expand Up @@ -2044,6 +2044,29 @@ public function toAlarm($time, $user = null, $prefs = null)
if ($eventDate && $this->recurrence->hasException($eventDate->year, $eventDate->month, $eventDate->mday)) {
return;
}
$start = clone $eventDate;
$diff = Date_Calc::dateDiff(
$this->start->mday,
$this->start->month,
$this->start->year,
$this->end->mday,
$this->end->month,
$this->end->year
);
if ($diff == -1) {
$diff = 0;
}
$end = new Horde_Date(array(
'year' => $start->year,
'month' => $start->month,
'mday' => $start->mday + $diff,
'hour' => $this->end->hour,
'min' => $this->end->min,
'sec' => $this->end->sec)
);
} else {
$start = clone $this->start;
$end = clone $this->end;
}

$serverName = $_SERVER['SERVER_NAME'];
Expand All @@ -2060,7 +2083,6 @@ public function toAlarm($time, $user = null, $prefs = null)
}

$methods = !empty($this->methods) ? $this->methods : @unserialize($prefs->getValue('event_alarms'));
$start = clone $this->start;
$start->min -= $this->alarm;
if (isset($methods['notify'])) {
$methods['notify']['show'] = array(
Expand Down Expand Up @@ -2119,11 +2141,12 @@ public function toAlarm($time, $user = null, $prefs = null)
}
$methods['desktop']['url'] = strval($this->getViewUrl(array(), true, false));
}

$alarm = array(
'id' => $this->uid,
'user' => $user,
'start' => $start,
'end' => $this->end,
'end' => $end,
'methods' => array_keys($methods),
'params' => $methods,
'title' => $this->getTitle($user),
Expand Down

0 comments on commit c58b297

Please sign in to comment.