Files
Chamilo/plugin/learning_calendar/ajax.php
T
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

44 lines
1.4 KiB
PHP

<?php
/* For license terms, see /license.txt */
require_once __DIR__.'/../../main/inc/global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$calendarId = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
$plugin = LearningCalendarPlugin::create();
$item = $plugin->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;
}