82 public function __construct(
ilDate $seed, $a_type, $a_user_id = 0, $a_strict_period =
false)
89 $this->logger = $DIC->logger()->cal();
93 $this->type = $a_type;
98 $this->strict_period = $a_strict_period;
100 if (!$a_user_id || $a_user_id ==
$ilUser->getId()) {
106 $this->weekstart = $this->user_settings->getWeekStart();
107 $this->timezone = $this->
user->getTimeZone();
146 return $this->limit_events != -1;
164 $this->limit_events = $a_limit;
174 $this->subitems_enabled = $a_status;
193 $this->filters[] = $a_filter;
207 $fend = clone $fstart;
220 $tmp_schedule = array();
221 $tmp_schedule_fullday = array();
223 if ($schedule[
'fullday']) {
224 if (($f_unix_start == $schedule[
'dstart']) or
225 $f_unix_start == $schedule[
'dend'] or
226 ($f_unix_start > $schedule[
'dstart'] and $f_unix_end <= $schedule[
'dend'])) {
229 } elseif (($schedule[
'dstart'] == $unix_start) or
230 (($schedule[
'dstart'] <= $unix_start) and ($schedule[
'dend'] > $unix_start)) or
231 (($schedule[
'dstart'] >= $unix_start) and ($schedule[
'dstart'] < $unix_end))) {
237 usort($tmp_schedule,
function (
$a,
$b) {
238 return $a[
'dstart'] <=>
$b[
'dstart'];
242 $schedules = array_merge($tmp_schedule_fullday, $tmp_schedule);
259 foreach ($events as $event) {
260 $ids[] = $event->getEntryId();
263 include_once(
'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
265 include_once(
'Services/Calendar/classes/class.ilCalendarCategory.php');
266 $cat_types = array();
267 foreach (array_unique($cat_map) as $cat_id) {
269 $cat_types[$cat_id] = $cat->getType();
273 foreach ($events as $event) {
275 include_once(
'Services/Calendar/classes/class.ilCalendarRecurrences.php');
278 foreach ($recs as $rec) {
280 foreach ($calc->calculateDateList($this->start, $this->end)->get() as $rec_date) {
281 if ($this->type == self::TYPE_PD_UPCOMING &&
286 $this->schedule[$counter][
'event'] = $event;
287 $this->schedule[$counter][
'dstart'] = $rec_date->get(
IL_CAL_UNIX);
288 $this->schedule[$counter][
'dend'] = $this->schedule[$counter][
'dstart'] + $duration;
289 $this->schedule[$counter][
'fullday'] = $event->isFullday();
290 $this->schedule[$counter][
'category_id'] = $cat_map[$event->getEntryId()];
291 $this->schedule[$counter][
'category_type'] = $cat_types[$cat_map[$event->getEntryId()]];
293 switch ($this->type) {
295 case self::TYPE_WEEK:
298 $this->schedule[$counter][
'start_info'] = $tmp_date->get(
IL_CAL_FKT_GETDATE,
'', $this->timezone);
301 $this->schedule[$counter][
'end_info'] = $tmp_date->get(
IL_CAL_FKT_GETDATE,
'', $this->timezone);
308 if ($this->type != self::TYPE_PD_UPCOMING &&
315 $this->schedule[$counter][
'event'] = $event;
316 $this->schedule[$counter][
'dstart'] = $event->getStart()->get(
IL_CAL_UNIX);
317 $this->schedule[$counter][
'dend'] = $event->getEnd()->get(
IL_CAL_UNIX);
318 $this->schedule[$counter][
'fullday'] = $event->isFullday();
319 $this->schedule[$counter][
'category_id'] = $cat_map[$event->getEntryId()];
320 $this->schedule[$counter][
'category_type'] = $cat_types[$cat_map[$event->getEntryId()]];
322 if (!$event->isFullday()) {
323 switch ($this->type) {
325 case self::TYPE_WEEK:
328 $this->schedule[$counter][
'start_info'] = $tmp_date->get(
IL_CAL_FKT_GETDATE,
'', $this->timezone);
331 $this->schedule[$counter][
'end_info'] = $tmp_date->get(
IL_CAL_FKT_GETDATE,
'', $this->timezone);
339 if ($this->type != self::TYPE_PD_UPCOMING &&
346 if ($this->type == self::TYPE_PD_UPCOMING) {
349 $this->schedule = array_slice($this->schedule, 0, $this->
getEventsLimit());
361 if (!
sizeof($a_cats)) {
365 foreach ($this->filters as $filter) {
366 if (
sizeof($a_cats)) {
367 $a_cats = $filter->filterCategories($a_cats);
376 foreach ($this->filters as $filter) {
377 $res = $filter->modifyEvent($event);
379 $this->logger->info(
'filtering failed for ' . get_class($filter));
389 $new_events = array();
390 foreach ($this->filters as $filter) {
391 $events_by_filter = $filter->addCustomEvents($start, $end, $categories);
392 if ($events_by_filter) {
393 $new_events = array_merge($new_events, $events_by_filter);
411 $ilDB = $DIC[
'ilDB'];
413 include_once(
'./Services/Calendar/classes/class.ilCalendarCategories.php');
424 $query =
"SELECT ce.cal_id cal_id FROM cal_entries ce " .
425 "JOIN cal_cat_assignments ca ON ca.cal_id = ce.cal_id " .
427 "AND " .
$ilDB->in(
'ca.cat_id', $cats,
false,
'integer') .
' ' .
428 "ORDER BY last_update";
435 $events[] = $valid_event;
439 foreach ($this->
addCustomEvents($this->start, $this->end, $cats) as $event) {
443 return $events ? $events : array();
456 $ilDB = $DIC[
'ilDB'];
458 include_once(
'./Services/Calendar/classes/class.ilCalendarCategories.php');
467 $query =
"SELECT ce.cal_id cal_id" .
468 " FROM cal_entries ce" .
469 " LEFT JOIN cal_recurrence_rules crr ON (ce.cal_id = crr.cal_id)" .
470 " JOIN cal_cat_assignments ca ON (ca.cal_id = ce.cal_id)";
472 if ($this->type != self::TYPE_INBOX) {
473 $query .=
" WHERE ((starta <= " . $this->db->quote($this->end->get(
IL_CAL_DATETIME,
'',
'UTC'),
'timestamp') .
474 " AND enda >= " . $this->db->quote($this->start->get(
IL_CAL_DATETIME,
'',
'UTC'),
'timestamp') .
")" .
475 " OR (starta <= " . $this->db->quote($this->end->get(
IL_CAL_DATETIME,
'',
'UTC'),
'timestamp') .
476 " AND NOT rule_id IS NULL))";
479 $query .=
" WHERE starta >= " . $this->db->quote($date->get(
IL_CAL_DATETIME,
'',
'UTC'),
'timestamp');
482 $query .=
" AND " .
$ilDB->in(
'ca.cat_id', $cats,
false,
'integer') .
492 $events[] = $valid_event;
496 foreach ($this->
addCustomEvents($this->start, $this->end, $cats) as $event) {
512 switch ($this->type) {
514 $this->start = clone $seed;
515 $this->end = clone $seed;
517 if (!$this->strict_period) {
526 case self::TYPE_WEEK:
527 $this->start = clone $seed;
529 $day_diff = $this->weekstart - $start_info[
'isoday'];
531 if ($day_diff == 7) {
536 if ($this->strict_period) {
537 $this->start->increment(
IL_CAL_DAY, $day_diff);
541 $this->start->increment(
IL_CAL_DAY, $day_diff);
548 case self::TYPE_MONTH:
549 if ($this->strict_period) {
550 $this->start = clone $seed;
551 $this->end = clone $seed;
555 list($year, $month) = explode(
'-', $year_month);
560 $start_unix_time = $this->start->getUnixTime();
562 $start_day_of_week = (int) date(
'w', $start_unix_time);
564 $number_days_previous_month = 0;
567 $number_days_previous_month = 6;
568 } elseif ($start_day_of_week > 0) {
569 $number_days_previous_month = $start_day_of_week;
572 $number_days_previous_month = $start_day_of_week - 1;
576 $this->start->increment(
IL_CAL_DAY, -$number_days_previous_month);
581 $end_unix_time = $this->end->getUnixTime();
583 $end_day_of_week = (int) date(
'w', $end_unix_time);
585 if ($end_day_of_week > 0) {
586 $number_days_next_month = 7 - $end_day_of_week;
589 $number_days_next_month = $number_days_next_month - 1;
592 $this->end->increment(
IL_CAL_DAY, $number_days_next_month);
598 case self::TYPE_HALF_YEAR:
599 $this->start = clone $seed;
604 case self::TYPE_PD_UPCOMING:
605 case self::TYPE_INBOX:
606 $this->start = $seed;
623 $this->start = $a_start;
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
Calendar schedule filter for individual timings.
static _getRecurrences($a_cal_id)
get all recurrences of an appointment
Model for a calendar entry.
__construct(ilDate $seed, $a_type, $a_user_id=0, $a_strict_period=false)
Constructor.
areEventsLimited()
Check if events are limited.
modifyEventByFilters(ilCalendarEntry $event)
getEventsLimit()
get current limit of events
Calendar schedule filter for consultation hour bookings.
setPeriod(ilDate $a_start, ilDate $a_end)
Set period.
const MODE_PERSONAL_DESKTOP_MEMBERSHIP
static _getInstanceByUserId($a_user_id)
get singleton instance
enabledSubitemCalendars()
Are subitem calendars enabled.
addSubitemCalendars($a_status)
Enable subitem calendars (session calendars for courses)
Stores calendar categories.
filterCategories(array $a_cats)
setEventsLimit($a_limit)
Set events limit.
getByDay(ilDate $a_start, $a_timezone)
get byday
get($a_format, $a_format_str='', $a_tz='')
get formatted date
static _getMaxDayOfMonth($a_year, $a_month)
get max day of month 2008,2 => 29
Calendar schedule filter for hidden categories.
Calendar schedule filter interface.
foreach($_POST as $key=> $value) $res
Calculates an ilDateList for a given calendar entry and recurrence rule.
Calendar schedule filter for exercises.
const MODE_PORTFOLIO_CONSULTATION
get($a_format, $a_format_str='', $a_tz='')
get formatted date
increment($a_type, $a_count=1)
increment
static _getInstance($a_usr_id=0)
get singleton instance
getEvents()
Read events (will be moved to another class, since only active and/or visible calendars are shown) ...
initPeriod(ilDate $seed)
init period of events
Calendar schedule filter for booking pool reservations.
addFilter(ilCalendarScheduleFilter $a_filter)
Add filter.
getChangedEvents($a_include_subitem_calendars=false)
get new/changed events
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
addCustomEvents(ilDate $start, ilDate $end, array $categories)
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
static _getAppointmentCalendars($a_cal_ids)
lookup calendars for appointment ids