File: status.php

package info (click to toggle)
kronolith 1.1.4-2sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,212 kB
  • ctags: 1,074
  • sloc: php: 4,187; sh: 724; xml: 522; makefile: 96; sql: 42; perl: 20
file content (38 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
 * $Horde: kronolith/status.php,v 1.12.2.5 2005/01/03 11:25:58 jan Exp $
 *
 * Copyright 1999-2005 Charles J. Hagenbuch <chuck@horde.org>
 * Copyright 1999-2005 Jon Parise <jon@horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

// get any alarms in the next hour
$now = mktime();
$current_date = Kronolith::timestampToObject($now);
$events = $calendar->listAlarms($current_date);
$messages = array();
foreach ($events as $eventID) {
	$thisEvent = $calendar->getEventObject($eventID);
    $differential = $thisEvent->getStartTimestamp($now) - $now;
    $key = $thisEvent->getStartTimestamp();
    while (isset($messages[$key])) {
        $key++;
    }
    if ($differential >= -60 && $differential < 60) {
        $messages[$key] = array(sprintf(_("%s is starting now."), $thisEvent->getTitle()), 'kronolith.alarm');
    } else if ($differential < 0 && $now <= $thisEvent->getEndTimestamp()) {
        $messages[$key] = array(sprintf(_("%s is in progress."), $thisEvent->getTitle()), 'kronolith.event');
    } else if ($differential >= 60 && $differential < 7200) {
        $messages[$key] = array(sprintf(_("%s starts in %s"), $thisEvent->getTitle(), Kronolith::secondsToString($differential)), 'kronolith.alarm');
    }
}

ksort($messages);
foreach ($messages as $message) {
    $notification->push($message[0], $message[1]);
}

$notification->notify();