19 declare(strict_types=1);
    60     public function __construct(
ilDate $seed, 
int $a_type, ?
int $a_user_id = null, 
bool $a_strict_period = 
false)
    64         $this->
logger = $DIC->logger()->cal();
    65         $this->db = $DIC->database();
    66         $this->type = $a_type;
    71         $this->strict_period = $a_strict_period;
    73         $this->
user = $DIC->user();
    74         if ($a_user_id !== null && $a_user_id !== $DIC->user()->getId()) {
    78         $this->weekstart = $this->user_settings->getWeekStart();
    79         if ($this->
user->getTimeZone()) {
    80             $this->timezone = $this->
user->getTimeZone();
   115         return $this->limit_events != -1;
   125         $this->limit_events = $a_limit;
   130         $this->subitems_enabled = $a_status;
   140         $this->filters[] = $a_filter;
   147         $fend = clone $fstart;
   160         $tmp_schedule = array();
   161         $tmp_schedule_fullday = array();
   162         foreach ($this->schedule as $schedule) {
   163             if ($schedule[
'fullday']) {
   164                 if (($f_unix_start == $schedule[
'dstart']) or
   165                     $f_unix_start == $schedule[
'dend'] or
   166                     ($f_unix_start > $schedule[
'dstart'] and $f_unix_end <= $schedule[
'dend'])) {
   169             } elseif (($schedule[
'dstart'] == $unix_start) or
   170                 (($schedule[
'dstart'] <= $unix_start) and ($schedule[
'dend'] > $unix_start)) or
   171                 (($schedule[
'dstart'] >= $unix_start) and ($schedule[
'dstart'] < $unix_end))) {
   177         usort($tmp_schedule, 
function (
$a, 
$b) {
   178             return $a[
'dstart'] <=> 
$b[
'dstart'];
   182         return array_merge($tmp_schedule_fullday, $tmp_schedule);
   191         foreach ($events as $event) {
   192             $ids[] = $event->getEntryId();
   196         $cat_types = array();
   197         foreach (array_unique($cat_map) as $cat_id) {
   199             $cat_types[$cat_id] = $cat->getType();
   203         foreach ($events as $event) {
   207                 foreach ($recs as $rec) {
   209                     foreach ($calc->calculateDateList($this->start, $this->end)->get() as $rec_date) {
   210                         if ($this->type == self::TYPE_PD_UPCOMING &&
   215                         $this->schedule[$counter][
'event'] = $event;
   216                         $this->schedule[$counter][
'dstart'] = $rec_date->get(
IL_CAL_UNIX);
   217                         $this->schedule[$counter][
'dend'] = $this->schedule[$counter][
'dstart'] + 
$duration;
   218                         $this->schedule[$counter][
'fullday'] = $event->isFullday();
   219                         $this->schedule[$counter][
'category_id'] = $cat_map[$event->getEntryId()];
   220                         $this->schedule[$counter][
'category_type'] = $cat_types[$cat_map[$event->getEntryId()]];
   222                         switch ($this->type) {
   224                             case self::TYPE_WEEK:
   227                                     $this->schedule[$counter][
'dstart'],
   231                                 $this->schedule[$counter][
'start_info'] = $tmp_date->get(
   238                                     $this->schedule[$counter][
'dend'],
   242                                 $this->schedule[$counter][
'end_info'] = $tmp_date->get(
   253                         if ($this->type != self::TYPE_PD_UPCOMING &&
   260                 $this->schedule[$counter][
'event'] = $event;
   261                 $this->schedule[$counter][
'dstart'] = $event->getStart()->get(
IL_CAL_UNIX);
   262                 $this->schedule[$counter][
'dend'] = $event->getEnd()->get(
IL_CAL_UNIX);
   263                 $this->schedule[$counter][
'fullday'] = $event->isFullday();
   264                 $this->schedule[$counter][
'category_id'] = $cat_map[$event->getEntryId()];
   265                 $this->schedule[$counter][
'category_type'] = $cat_types[$cat_map[$event->getEntryId()]];
   267                 if (!$event->isFullday()) {
   268                     switch ($this->type) {
   270                         case self::TYPE_WEEK:
   273                                 $this->schedule[$counter][
'dstart'],
   277                             $this->schedule[$counter][
'start_info'] = $tmp_date->get(
   284                             $this->schedule[$counter][
'end_info'] = $tmp_date->get(
   296                 if ($this->type != self::TYPE_PD_UPCOMING &&
   303         if ($this->type == self::TYPE_PD_UPCOMING) {
   306                 $this->schedule = array_slice($this->schedule, 0, $this->
getEventsLimit());
   318         if (!count($a_cats)) {
   321         foreach ($this->filters as $filter) {
   322             $a_cats = $filter->filterCategories($a_cats);
   329         foreach ($this->filters as $filter) {
   330             $res = $filter->modifyEvent($event);
   331             if (
$res === 
false) {
   332                 $this->
logger->notice(
'filtering failed for ' . get_class($filter));
   345         $new_events = array();
   346         foreach ($this->filters as $filter) {
   347             $events_by_filter = $filter->addCustomEvents($start, $end, $categories);
   348             if ($events_by_filter) {
   349                 $new_events = array_merge($new_events, $events_by_filter);
   374         $query = 
"SELECT ce.cal_id cal_id FROM cal_entries ce  " .
   375             "JOIN cal_cat_assignments ca ON ca.cal_id = ce.cal_id " .
   376             "WHERE last_update > " . $this->db->quote($start->
get(
IL_CAL_DATETIME), 
'timestamp') . 
" " .
   377             "AND " . $this->db->in(
'ca.cat_id', $cats, 
false, 
'integer') . 
' ' .
   378             "ORDER BY last_update";
   379         $res = $this->db->query($query);
   386                 $events[] = $valid_event;
   390         foreach ($this->
addCustomEvents($this->start, $this->end, $cats) as $event) {
   410         $query = 
"SELECT ce.cal_id cal_id" .
   411             " FROM cal_entries ce" .
   412             " LEFT JOIN cal_recurrence_rules crr ON (ce.cal_id = crr.cal_id)" .
   413             " JOIN cal_cat_assignments ca ON (ca.cal_id = ce.cal_id)";
   415         if ($this->type != self::TYPE_INBOX) {
   416             $query .= 
" WHERE ((starta <= " . $this->db->quote(
   420                 " AND enda >= " . $this->db->quote($this->start->get(
IL_CAL_DATETIME, 
'', 
'UTC'), 
'timestamp') . 
")" .
   421                 " OR (starta <= " . $this->db->quote($this->end->get(
IL_CAL_DATETIME, 
'', 
'UTC'), 
'timestamp') .
   422                 " AND NOT rule_id IS NULL))";
   425             $query .= 
" WHERE starta >= " . $this->db->quote($date->get(
IL_CAL_DATETIME, 
'', 
'UTC'), 
'timestamp');
   428         $query .= 
" AND " . $this->db->in(
'ca.cat_id', $cats, 
false, 
'integer') .
   431         $res = $this->db->query($query);
   438                 $events[] = $valid_event;
   441         foreach ($this->
addCustomEvents($this->start, $this->end, $cats) as $event) {
   449         switch ($this->type) {
   451                 $this->start = clone $seed;
   452                 $this->end = clone $seed;
   454                 if (!$this->strict_period) {
   463             case self::TYPE_WEEK:
   464                 $this->start = clone $seed;
   466                 $day_diff = $this->weekstart - $start_info[
'isoday'];
   468                 if (abs($day_diff) === 7) {
   473                 if ($this->strict_period) {
   474                     $this->start->increment(
IL_CAL_DAY, $day_diff);
   478                     $this->start->increment(
IL_CAL_DAY, $day_diff);
   485             case self::TYPE_MONTH:
   486                 if ($this->strict_period) {
   487                     $this->start = clone $seed;
   488                     $this->end = clone $seed;
   492                     list($year, $month) = explode(
'-', $year_month);
   494                     $month = (
int) $month;
   499                     $start_unix_time = $this->start->getUnixTime();
   501                     $start_day_of_week = (
int) date(
'w', $start_unix_time);
   503                     $number_days_previous_month = 0;
   506                         $number_days_previous_month = 6;
   507                     } elseif ($start_day_of_week > 0) {
   508                         $number_days_previous_month = $start_day_of_week;
   511                             $number_days_previous_month = $start_day_of_week - 1;
   515                     $this->start->increment(
IL_CAL_DAY, -$number_days_previous_month);
   523                     $end_unix_time = $this->end->getUnixTime();
   525                     $end_day_of_week = (
int) date(
'w', $end_unix_time);
   527                     if ($end_day_of_week > 0) {
   528                         $number_days_next_month = 7 - $end_day_of_week;
   531                             $number_days_next_month = $number_days_next_month - 1;
   534                         $this->end->increment(
IL_CAL_DAY, $number_days_next_month);
   540             case self::TYPE_HALF_YEAR:
   541                 $this->start = clone $seed;
   546             case self::TYPE_PD_UPCOMING:
   547             case self::TYPE_INBOX:
   548                 $this->start = $seed;
   557         $this->start = $a_start;
 
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date 
 
__construct(ilDate $seed, int $a_type, ?int $a_user_id=null, bool $a_strict_period=false)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _getMaxDayOfMonth(int $a_year, int $a_month)
get max day of month 2008,2 => 29 
 
areEventsLimited()
Check if events are limited. 
 
modifyEventByFilters(ilCalendarEntry $event)
 
Calendar schedule filter for consultation hour bookings. 
 
setPeriod(ilDate $a_start, ilDate $a_end)
 
getChangedEvents(bool $a_include_subitem_calendars=false)
get new/changed events 
 
getByDay(ilDate $a_start, string $a_timezone)
 
static _getAppointmentCalendars(array $a_cal_ids)
 
const MODE_PERSONAL_DESKTOP_MEMBERSHIP
 
enabledSubitemCalendars()
 
get(int $a_format, string $a_format_str='', string $a_tz='')
 
increment(string $a_type, int $a_count=1)
 
setEventsLimit(int $a_limit)
 
Stores calendar categories. 
 
static _getRecurrences(int $a_cal_id)
get all recurrences of an appointment 
 
filterCategories(array $a_cats)
 
static _getInstanceByUserId(int $a_user_id)
 
Calendar schedule filter for hidden categories. 
 
Calendar schedule filter interface. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Calendar schedule filter for exercises. 
 
const MODE_PORTFOLIO_CONSULTATION
 
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) ...
 
Calendar schedule filter for booking pool reservations. 
 
ilCalendarUserSettings $user_settings
 
addFilter(ilCalendarScheduleFilter $a_filter)
 
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples 
 
addCustomEvents(ilDate $start, ilDate $end, array $categories)
 
addSubitemCalendars(bool $a_status)
 
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
 
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)