File: tree_alarms.php

package info (click to toggle)
kronolith2 2.1.4-1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 5,560 kB
  • ctags: 2,171
  • sloc: php: 8,755; xml: 1,049; sql: 258; makefile: 65
file content (73 lines) | stat: -rw-r--r-- 2,799 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

$block_name = _("Menu Alarms");
$block_type = 'tree';

/**
 * $Horde: kronolith/lib/Block/tree_alarms.php,v 1.1.2.4 2006/04/27 03:59:51 chuck Exp $
 *
 * @package Horde_Block
 */
class Horde_Block_kronolith_tree_alarms extends Horde_Block {

    var $_app = 'kronolith';

    function _buildTree(&$tree, $indent = 0, $parent = null)
    {
        @define('KRONOLITH_BASE', dirname(__FILE__) . '/../..');
        require_once KRONOLITH_BASE . '/lib/base.php';

        $now = time();
        $alarmCount = 0;
        $alarms = Kronolith::listAlarms(new Horde_Date($now), $GLOBALS['display_calendars']);
        foreach ($alarms as $calId => $calAlarms) {
            $GLOBALS['kronolith']->open($calId);
            foreach ($calAlarms as $eventId) {
                $event = &$GLOBALS['kronolith']->getEvent($eventId);
                if (is_a($event, 'PEAR_Error')) {
                    $GLOBALS['notification']->push($event);
                    return;
                }
                $eventDate = $event->nextRecurrence($now);
                if ($eventDate && $event->hasException($eventDate->year, $eventDate->month, $eventDate->mday)) {
                    continue;
                }

                $alarmCount++;
                $url = Util::addParameter(Horde::applicationUrl('viewevent.php'),
                                          array('eventID' => $eventId,
                                                'calendar' => $calId));

                $tree->addNode($parent . $calId . $eventId,
                               $parent,
                               $event->getTitle(),
                               $indent + 1,
                               false,
                               array('icon' => 'alarm.png',
                                     'icondir' => $GLOBALS['registry']->getImageDir(),
                                     'title' => $event->getTooltip(),
                                     'url' => $url));
            }
        }

        if ($registry->get('url', $parent)) {
            $purl = $registry->get('url', $parent);
        } elseif ($registry->get('status', $parent) == 'heading' ||
                  !$registry->get('webroot')) {
            $purl = null;
        } else {
            $purl = Horde::url($registry->getInitialPage($parent));
        }
        $pnode_params = array('url' => $purl,
                              'icon' => $registry->get('icon', $parent),
                              'icondir' => '');
        $pnode_name = $registry->get('name', $parent);
        if ($alarmCount) {
            $pnode_name = '<strong>' . $pnode_name . '</strong>';
        }

        $tree->addNode($parent, $registry->get('menu_parent', $parent),
                       $pnode_name, $indent, false, $pnode_params);
    }

}