public function publicevents($request, $json=true, $calendars=null, $offset=30)
    {
        $calendarsSupplied = false;
        if ($calendars) {
            $calendarsSupplied = true;
        }

        $events = PublicEvent::get()
            ->filter(array(
                'StartDateTime:GreaterThan' => $this->eventlistOffsetDate('start', $request->postVar('start'), $offset),
                'EndDateTime:LessThan' => $this->eventlistOffsetDate('end', $request->postVar('end'), $offset),
            ));

        //If shaded events are enabled we need to filter shaded calendars out
        //note that this only takes effect when no calendars have been supplied
        //if calendars are supplied, this needs to be taken care of from that method
        $sC = CalendarConfig::subpackage_settings('calendars');
        if ($sC['shading']) {
            if (!$calendars) {
                $calendars = PublicCalendar::get();
                $calendars = $calendars->filter(array(
                    'shaded' => false
                ));
            }
        }


        if ($calendars) {
            $calIDList = $calendars->getIdList();
            //adding in 0 to allow for showing events without a calendar
            if (!$calendarsSupplied) {
                $calIDList[0] = 0;
            }

            //Debug::dump($calIDList);
            $events = $events->filter('CalendarID', $calIDList);
        }

        $result = array();
        if ($events) {
            foreach ($events as $event) {
                $calendar = $event->Calendar();

                $bgColor = '#999'; //default
            $textColor = '#FFF'; //default
            $borderColor = '#555';

                if ($calendar->exists()) {
                    $bgColor = $calendar->getColorWithHash();
                    $textColor = '#FFF';
                    $borderColor = $calendar->getColorWithHash();
                }

                $resultArr = self::format_event_for_fullcalendar($event);
                $resultArr = array_merge($resultArr, array(
                'backgroundColor' => $bgColor,
                'textColor' => '#FFF',
                'borderColor' => $borderColor,
            ));
                $result[] = $resultArr;
            }
        }

        if ($json) {
            $response = new SS_HTTPResponse(Convert::array2json($result));
            $response->addHeader('Content-Type', 'application/json');
            return $response;
        } else {
            return $result;
        }
    }
public function publicevents($request, $json=true, $calendars=null, $offset=30)
    {
        $calendarsSupplied = false;
        if ($calendars) {
            $calendarsSupplied = true;
        }

        $events = PublicEvent::get()
            ->filter(array(
                'StartDateTime:GreaterThan' => $this->eventlistOffsetDate('start', $request->postVar('start'), $offset),
                'EndDateTime:LessThan' => $this->eventlistOffsetDate('end', $request->postVar('end'), $offset),
            ));

        //If shaded events are enabled we need to filter shaded calendars out
        //note that this only takes effect when no calendars have been supplied
        //if calendars are supplied, this needs to be taken care of from that method
        $sC = CalendarConfig::subpackage_settings('calendars');
        if ($sC['shading']) {
            if (!$calendars) {
                $calendars = PublicCalendar::get();
                $calendars = $calendars->filter(array(
                    'shaded' => false
                ));
            }
        }


        if ($calendars) {
            $calIDList = $calendars->getIdList();
            //adding in 0 to allow for showing events without a calendar
            if (!$calendarsSupplied) {
                $calIDList[0] = 0;
            }

            //Debug::dump($calIDList);
            $events = $events->filter('CalendarID', $calIDList);
        }

        $result = array();
        if ($events) {
            foreach ($events as $event) {
                $calendar = $event->Calendar();

                $bgColor = '#999'; //default
            $textColor = '#FFF'; //default
            $borderColor = '#555';

                if ($calendar->exists()) {
                    $bgColor = $calendar->getColorWithHash();
                    $textColor = '#FFF';
                    $borderColor = $calendar->getColorWithHash();
                }

                $resultArr = self::format_event_for_fullcalendar($event);
                $resultArr = array_merge($resultArr, array(
                'backgroundColor' => $bgColor,
                'textColor' => '#FFF',
                'borderColor' => $borderColor,
            ));
                $result[] = $resultArr;
            }
        }

        if ($json) {
            $response = new SS_HTTPResponse(Convert::array2json($result));
            $response->addHeader('Content-Type', 'application/json');
            return $response;
        } else {
            return $result;
        }
    }
public function publicevents ( $ request , $ json = true , $ calendars = null , $ offset = 30 ) { $ calendarsSupplied = false ; if ( $ calendars ) { $ calendarsSupplied = true ; } $ events = PublicEvent :: get ( ) -> filter ( array ( 'StartDateTime:GreaterThan' => $ this -> eventlistOffsetDate ( 'start' , $ request -> postVar ( 'start' ) , $ offset ) , 'EndDateTime:LessThan' => $ this -> eventlistOffsetDate ( 'end' , $ request -> postVar ( 'end' ) , $ offset ) , ) ) ; //If shaded events are enabled we need to filter shaded calendars out //note that this only takes effect when no calendars have been supplied //if calendars are supplied, this needs to be taken care of from that method $ sC = CalendarConfig :: subpackage_settings ( 'calendars' ) ; if ( $ sC [ 'shading' ] ) { if ( ! $ calendars ) { $ calendars = PublicCalendar :: get ( ) ; $ calendars = $ calendars -> filter ( array ( 'shaded' => false ) ) ; } } if ( $ calendars ) { $ calIDList = $ calendars -> getIdList ( ) ; //adding in 0 to allow for showing events without a calendar if ( ! $ calendarsSupplied ) { $ calIDList [ 0 ] = 0 ; } //Debug::dump($calIDList); $ events = $ events -> filter ( 'CalendarID' , $ calIDList ) ; } $ result = array ( ) ; if ( $ events ) { foreach ( $ events as $ event ) { $ calendar = $ event -> Calendar ( ) ; $ bgColor = '#999' ; //default $ textColor = '#FFF' ; //default $ borderColor = '#555' ; if ( $ calendar -> exists ( ) ) { $ bgColor = $ calendar -> getColorWithHash ( ) ; $ textColor = '#FFF' ; $ borderColor = $ calendar -> getColorWithHash ( ) ; } $ resultArr = self :: format_event_for_fullcalendar ( $ event ) ; $ resultArr = array_merge ( $ resultArr , array ( 'backgroundColor' => $ bgColor , 'textColor' => '#FFF' , 'borderColor' => $ borderColor , ) ) ; $ result [ ] = $ resultArr ; } } if ( $ json ) { $ response = new SS_HTTPResponse ( Convert :: array2json ( $ result ) ) ; $ response -> addHeader ( 'Content-Type' , 'application/json' ) ; return $ response ; } else { return $ result ; } }
Handles returning the JSON events data for a time range.

@param SS_HTTPRequest $request
@return SS_HTTPResponse
Handles returning the JSON events data for a time range .