summaryrefslogtreecommitdiff
path: root/app/php/facades/EventFacade.php
blob: e7b3abef4b5507b8119d21f451e96aa2985d96d9 (plain)
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
<?php

Prado::using('Application.facades.Facade');

class EventFacade extends Facade {

    public function getEventList($dateFrom=NULL, $dateTo=NULL, $calendars=NULL) {
        $calendarClause = '1=1';
        if ($calendars) {
            $calendarClause = sprintf(
                '_calendar IN (%s)',
                implode(
                    ',',
                    array_map(
                        function($calendar) {
                            return $this->quoteString($calendar->UID);
                        },
                        $calendars
                    )
                )
            );
        }
        return $this->fetchList(
            'getEvents',
            [
                'date_from' => $dateFrom ?: '0000-00-00 00:00:00',
                'date_to' => $dateTo ?: '9999-99-99',
                'calendar_clause' => $calendarClause
            ]
        );
    }

}

?>