getCalendar($calendarId); $plugin->protectCalendar($item); switch ($action) { case 'toggle_day': $startDate = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : ''; if (empty($startDate)) { exit; } $endDate = isset($_REQUEST['end_date']) ? $_REQUEST['end_date'] : ''; if ($startDate == $endDate) { // One day $plugin->toogleDayType($calendarId, $startDate); } else { // A list of days $startDateTime = new DateTime($startDate); $endDateTime = new DateTime($endDate); $diff = $startDateTime->diff($endDateTime); $countDays = $diff->format('%a'); $dayList[] = $startDate; for ($i = 0; $i < $countDays; $i++) { $startDateTime->modify('+1 day'); $dayList[] = $startDateTime->format('Y-m-d'); } foreach ($dayList as $day) { $plugin->toogleDayType($calendarId, $day); } } break; case 'get_events': $list = $plugin->getEvents($calendarId); echo json_encode($list); break; }