コード例 #1
0
ファイル: Admin.php プロジェクト: par-orillonsoft/phpwebsite
 private function getEventJson()
 {
     require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Schedule.php';
     require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Event.php';
     $event_id = filter_input(INPUT_GET, 'event_id', FILTER_VALIDATE_INT);
     $schedule_id = filter_input(INPUT_GET, 'schedule_id', FILTER_VALIDATE_INT);
     if (empty($event_id)) {
         echo json_encode(array('error' => 'No event id'));
         exit;
     }
     $schedule = new Calendar_Schedule($schedule_id);
     $event = new Calendar_Event($event_id, $schedule);
     $repeat_event = !empty($event->repeat_type) ? 1 : 0;
     $repeat_info = explode(':', $event->repeat_type);
     $repeat_type = $repeat_info[0];
     if (isset($repeat_info[1])) {
         $repeat_vars = explode(';', $repeat_info[1]);
     } else {
         $repeat_vars = null;
     }
     if ($event->all_day) {
         $end_hour = $end_minute = 0;
     } else {
         $end_hour = (int) $event->getEndTime('%H');
         $end_minute = (int) $event->getEndTime('%M');
     }
     $json = array('event_id' => $event->id, 'summary' => $event->summary, 'location' => $event->location, 'loc_link' => $event->loc_link, 'description' => $event->getDescription(), 'all_day' => $event->all_day, 'start_date' => $event->getStartTime('%Y/%m/%d'), 'end_date' => $event->getEndTime('%Y/%m/%d'), 'start_hour' => (int) $event->getStartTime('%H'), 'start_minute' => (int) $event->getStartTime('%M'), 'end_hour' => $end_hour, 'end_minute' => $end_minute, 'show_busy' => $event->show_busy, 'repeat_event' => $repeat_event, 'end_repeat_date' => $event->getEndRepeat('%Y/%m/%d'), 'repeat_type' => $repeat_type, 'repeat_vars' => $repeat_vars);
     echo json_encode($json);
     exit;
 }