Skip to content

Commit

Permalink
Fix subtracting alarm time (Bug #13584).
Browse files Browse the repository at this point in the history
We only need to subtract the alarm where we set the alarm time. The start date
and time for the event always keeps the same. This fixes several issues with
notification text and links, and alarm messages, especially if the alarm time
is longer than a day.
  • Loading branch information
yunosh committed Sep 23, 2014
1 parent 0d092b2 commit 0ded4b5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kronolith/lib/Event.php
Expand Up @@ -2186,7 +2186,6 @@ public function toAlarm($time, $user = null, $prefs = null)
}

$methods = !empty($this->methods) ? $this->methods : @unserialize($prefs->getValue('event_alarms'));
$start->min -= $this->alarm;
if (isset($methods['notify'])) {
$methods['notify']['show'] = array(
'__app' => $GLOBALS['registry']->getApp(),
Expand All @@ -2210,7 +2209,7 @@ public function toAlarm($time, $user = null, $prefs = null)
$methods['notify']['subtitle'] = sprintf(_("From %s to %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')) . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')) . '</strong>');
}
} else {
$methods['notify']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')), $this->start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>');
$methods['notify']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')), $start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>');
}
}
if (isset($methods['mail'])) {
Expand Down Expand Up @@ -2241,15 +2240,17 @@ public function toAlarm($time, $user = null, $prefs = null)
$methods['desktop']['subtitle'] = sprintf(_("From %s to %s"), $start->strftime($prefs->getValue('date_format')), $end->strftime($prefs->getValue('date_format')));
}
} else {
$methods['desktop']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), $start->strftime($prefs->getValue('date_format')), $this->start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'), $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'));
$methods['desktop']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), $start->strftime($prefs->getValue('date_format')), $start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'), $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'));
}
$methods['desktop']['url'] = strval($this->getViewUrl(array(), true, false));
}

$alarmStart = clone $start;
$alarmStart->min -= $this->alarm;
$alarm = array(
'id' => $this->uid,
'user' => $user,
'start' => $start,
'start' => $alarmStart,
'end' => $end,
'methods' => array_keys($methods),
'params' => $methods,
Expand Down

0 comments on commit 0ded4b5

Please sign in to comment.