ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCalendarSchedule Class Reference

Represents a list of calendar appointments (including recurring events) for a specific user in a given time range. More...

+ Collaboration diagram for ilCalendarSchedule:

Public Member Functions

 __construct (ilDate $seed, $a_type, $a_user_id=0, $a_strict_period=false)
 Constructor. More...
 
 getEventsLimit ()
 get current limit of events More...
 
 setEventsLimit ($a_limit)
 Set events limit. More...
 
 addSubitemCalendars ($a_status)
 Enable subitem calendars (session calendars for courses) More...
 
 enabledSubitemCalendars ()
 Are subitem calendars enabled. More...
 
 addFilter (ilCalendarScheduleFilter $a_filter)
 Add filter. More...
 
 getByDay (ilDate $a_start, $a_timezone)
 get byday More...
 
 calculate ()
 calculate More...
 
 getScheduledEvents ()
 
 getChangedEvents ($a_include_subitem_calendars=false)
 get new/changed events More...
 
 getEvents ()
 Read events (will be moved to another class, since only active and/or visible calendars are shown) More...
 
 setPeriod (ilDate $a_start, ilDate $a_end)
 Set period. More...
 

Data Fields

const TYPE_DAY = 1
 
const TYPE_WEEK = 2
 
const TYPE_MONTH = 3
 
const TYPE_INBOX = 4
 
const TYPE_HALF_YEAR = 6
 
const TYPE_PD_UPCOMING = 5
 

Protected Member Functions

 areEventsLimited ()
 Check if events are limited. More...
 
 filterCategories (array $a_cats)
 
 modifyEventByFilters (ilCalendarEntry $event)
 
 addCustomEvents (ilDate $start, ilDate $end, array $categories)
 
 initPeriod (ilDate $seed)
 init period of events More...
 

Protected Attributes

 $limit_events = -1
 
 $schedule = array()
 
 $timezone
 
 $weekstart
 
 $type = 0
 
 $subitems_enabled = false
 
 $start = null
 
 $end = null
 
 $user = null
 
 $user_settings = null
 
 $db = null
 
 $filters = array()
 
 $strict_period
 
 $logger
 

Detailed Description

Represents a list of calendar appointments (including recurring events) for a specific user in a given time range.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 36 of file class.ilCalendarSchedule.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarSchedule::__construct ( ilDate  $seed,
  $a_type,
  $a_user_id = 0,
  $a_strict_period = false 
)

Constructor.

public

Parameters
ilDateseed date
inttype of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH)
intuser_id
boolstrict_period true if no extra days needed.

Definition at line 82 of file class.ilCalendarSchedule.php.

References $DIC, $ilDB, $ilUser, ilCalendarCategories\_getInstance(), ilCalendarUserSettings\_getInstanceByUserId(), addFilter(), initPeriod(), ilCalendarCategories\MODE_CONSULTATION, ilCalendarCategories\MODE_PERSONAL_DESKTOP_MEMBERSHIP, ilCalendarCategories\MODE_PORTFOLIO_CONSULTATION, ilCalendarCategories\MODE_REPOSITORY, and user().

83  {
84  global $DIC;
85 
86  $ilUser = $DIC['ilUser'];
87  $ilDB = $DIC['ilDB'];
88 
89  $this->logger = $DIC->logger()->cal();
90 
91  $this->db = $ilDB;
92 
93  $this->type = $a_type;
94 
95  //this strict period is just to avoid possible side effects.
96  //I there are none, we can get rid of this strict period control and remove it from the constructor
97  //and from the calls in ilCalendarView getEvents.
98  $this->strict_period = $a_strict_period;
99 
100  if (!$a_user_id || $a_user_id == $ilUser->getId()) {
101  $this->user = $ilUser;
102  } else {
103  $this->user = new ilObjUser($a_user_id);
104  }
105  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
106  $this->weekstart = $this->user_settings->getWeekStart();
107  $this->timezone = $this->user->getTimeZone();
108 
109  $this->initPeriod($seed);
110 
111 
112  // category / event filters
113 
114  // portfolio does custom filter handling (booking group ids)
116  // consultation hour calendar views do not mind calendar category visibility
118  // this is the "default" filter which handles currently hidden categories for the user
119  $this->addFilter(new ilCalendarScheduleFilterHidden($this->user->getId()));
120  } else {
121  // handle booking visibility (target object, booked out)
122  //this filter deals with consultation hours
123  $this->addFilter(new ilCalendarScheduleFilterBookings($this->user->getId()));
124  }
125 
127  //this filter deals with booking pool reservations
128  $this->addFilter(new ilCalendarScheduleFilterBookingPool($this->user->getId()));
129  }
130 
133  }
134 
135  $this->addFilter(new ilCalendarScheduleFilterExercise($this->user->getId()));
136  $this->addFilter(new ilCalendarScheduleFilterTimings($this->user->getId()));
137  }
138  }
Calendar schedule filter for individual timings.
Calendar schedule filter for consultation hour bookings.
static _getInstanceByUserId($a_user_id)
get singleton instance
user()
Definition: user.php:4
Calendar schedule filter for hidden categories.
global $DIC
Definition: goto.php:24
Calendar schedule filter for exercises.
static _getInstance($a_usr_id=0)
get singleton instance
initPeriod(ilDate $seed)
init period of events
Calendar schedule filter for booking pool reservations.
addFilter(ilCalendarScheduleFilter $a_filter)
Add filter.
global $ilDB
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomEvents()

ilCalendarSchedule::addCustomEvents ( ilDate  $start,
ilDate  $end,
array  $categories 
)
protected

Definition at line 387 of file class.ilCalendarSchedule.php.

Referenced by getChangedEvents(), and getEvents().

388  {
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);
394  }
395  }
396  return $new_events;
397  }
+ Here is the caller graph for this function:

◆ addFilter()

ilCalendarSchedule::addFilter ( ilCalendarScheduleFilter  $a_filter)

Add filter.

Parameters
ilCalendarScheduleFilter$a_filter

Definition at line 191 of file class.ilCalendarSchedule.php.

Referenced by __construct().

192  {
193  $this->filters[] = $a_filter;
194  }
+ Here is the caller graph for this function:

◆ addSubitemCalendars()

ilCalendarSchedule::addSubitemCalendars (   $a_status)

Enable subitem calendars (session calendars for courses)

Parameters

Definition at line 172 of file class.ilCalendarSchedule.php.

173  {
174  $this->subitems_enabled = $a_status;
175  }

◆ areEventsLimited()

ilCalendarSchedule::areEventsLimited ( )
protected

Check if events are limited.

Returns
type

Definition at line 144 of file class.ilCalendarSchedule.php.

Referenced by calculate().

145  {
146  return $this->limit_events != -1;
147  }
+ Here is the caller graph for this function:

◆ calculate()

ilCalendarSchedule::calculate ( )

calculate

protected

Definition at line 253 of file class.ilCalendarSchedule.php.

References ilCalendarCategoryAssignments\_getAppointmentCalendars(), ilCalendarRecurrences\_getRecurrences(), areEventsLimited(), getEvents(), getEventsLimit(), IL_CAL_FKT_GETDATE, IL_CAL_UNIX, and ilUtil\sortArray().

254  {
255  $events = $this->getEvents();
256 
257  // we need category type for booking handling
258  $ids = array();
259  foreach ($events as $event) {
260  $ids[] = $event->getEntryId();
261  }
262 
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) {
268  $cat = new ilCalendarCategory($cat_id);
269  $cat_types[$cat_id] = $cat->getType();
270  }
271 
272  $counter = 0;
273  foreach ($events as $event) {
274  // Calculdate recurring events
275  include_once('Services/Calendar/classes/class.ilCalendarRecurrences.php');
276  if ($recs = ilCalendarRecurrences::_getRecurrences($event->getEntryId())) {
277  $duration = $event->getEnd()->get(IL_CAL_UNIX) - $event->getStart()->get(IL_CAL_UNIX);
278  foreach ($recs as $rec) {
279  $calc = new ilCalendarRecurrenceCalculator($event, $rec);
280  foreach ($calc->calculateDateList($this->start, $this->end)->get() as $rec_date) {
281  if ($this->type == self::TYPE_PD_UPCOMING &&
282  $rec_date->get(IL_CAL_UNIX) < time()) {
283  continue;
284  }
285 
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()]];
292 
293  switch ($this->type) {
294  case self::TYPE_DAY:
295  case self::TYPE_WEEK:
296  // store date info (used for calculation of overlapping events)
297  $tmp_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone);
298  $this->schedule[$counter]['start_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
299 
300  $tmp_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone);
301  $this->schedule[$counter]['end_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
302  break;
303 
304  default:
305  break;
306  }
307  $counter++;
308  if ($this->type != self::TYPE_PD_UPCOMING &&
309  $this->areEventsLimited() && $counter >= $this->getEventsLimit()) {
310  break;
311  }
312  }
313  }
314  } else {
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()]];
321 
322  if (!$event->isFullday()) {
323  switch ($this->type) {
324  case self::TYPE_DAY:
325  case self::TYPE_WEEK:
326  // store date info (used for calculation of overlapping events)
327  $tmp_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone);
328  $this->schedule[$counter]['start_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
329 
330  $tmp_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone);
331  $this->schedule[$counter]['end_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
332  break;
333 
334  default:
335  break;
336  }
337  }
338  $counter++;
339  if ($this->type != self::TYPE_PD_UPCOMING &&
340  $this->areEventsLimited() && $counter >= $this->getEventsLimit()) {
341  break;
342  }
343  }
344  }
345 
346  if ($this->type == self::TYPE_PD_UPCOMING) {
347  $this->schedule = ilUtil::sortArray($this->schedule, "dstart", "asc", true);
348  if ($this->areEventsLimited() && sizeof($this->schedule) >= $this->getEventsLimit()) {
349  $this->schedule = array_slice($this->schedule, 0, $this->getEventsLimit());
350  }
351  }
352  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getRecurrences($a_cal_id)
get all recurrences of an appointment
areEventsLimited()
Check if events are limited.
getEventsLimit()
get current limit of events
Stores calendar categories.
const IL_CAL_UNIX
Calculates an ilDateList for a given calendar entry and recurrence rule.
getEvents()
Read events (will be moved to another class, since only active and/or visible calendars are shown) ...
const IL_CAL_FKT_GETDATE
static _getAppointmentCalendars($a_cal_ids)
lookup calendars for appointment ids
+ Here is the call graph for this function:

◆ enabledSubitemCalendars()

ilCalendarSchedule::enabledSubitemCalendars ( )

Are subitem calendars enabled.

Returns

Definition at line 181 of file class.ilCalendarSchedule.php.

References $subitems_enabled.

Referenced by getEvents().

182  {
183  return (bool) $this->subitems_enabled;
184  }
+ Here is the caller graph for this function:

◆ filterCategories()

ilCalendarSchedule::filterCategories ( array  $a_cats)
protected

Definition at line 359 of file class.ilCalendarSchedule.php.

Referenced by getChangedEvents(), and getEvents().

360  {
361  if (!sizeof($a_cats)) {
362  return $a_cats;
363  }
364 
365  foreach ($this->filters as $filter) {
366  if (sizeof($a_cats)) {
367  $a_cats = $filter->filterCategories($a_cats);
368  }
369  }
370 
371  return $a_cats;
372  }
+ Here is the caller graph for this function:

◆ getByDay()

ilCalendarSchedule::getByDay ( ilDate  $a_start,
  $a_timezone 
)

get byday

public

Parameters
ilDatestart

Definition at line 203 of file class.ilCalendarSchedule.php.

References Vendor\Package\$a, Vendor\Package\$b, $schedule, $start, $timezone, ilDateTime\DAY, ilDate\get(), ilDateTime\get(), IL_CAL_DATETIME, IL_CAL_UNIX, and ilDateTime\increment().

204  {
206  $fstart = new ilDate($a_start->get(IL_CAL_UNIX), IL_CAL_UNIX);
207  $fend = clone $fstart;
208 
209  $f_unix_start = $fstart->get(IL_CAL_UNIX);
210  $fend->increment(ilDateTime::DAY, 1);
211  $f_unix_end = $fend->get(IL_CAL_UNIX);
212 
213  $unix_start = $start->get(IL_CAL_UNIX);
214  $start->increment(ilDateTime::DAY, 1);
215  $unix_end = $start->get(IL_CAL_UNIX);
216 
217  $counter = 0;
218 
219  $tmp_date = new ilDateTime($unix_start, IL_CAL_UNIX, $this->timezone);
220  $tmp_schedule = array();
221  $tmp_schedule_fullday = array();
222  foreach ($this->schedule as $schedule) {
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'])) {
227  $tmp_schedule_fullday[] = $schedule;
228  }
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))) {
232  $tmp_schedule[] = $schedule;
233  }
234  }
235 
236  //order non full day events by starting date;
237  usort($tmp_schedule, function ($a, $b) {
238  return $a['dstart'] <=> $b['dstart'];
239  });
240 
241  //merge both arrays keeping the full day events first and then rest ordered by starting date.
242  $schedules = array_merge($tmp_schedule_fullday, $tmp_schedule);
243 
244  return $schedules;
245  }
const IL_CAL_DATETIME
const IL_CAL_UNIX
get($a_format, $a_format_str='', $a_tz='')
get formatted date
Class for single dates.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
increment($a_type, $a_count=1)
increment
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:

◆ getChangedEvents()

ilCalendarSchedule::getChangedEvents (   $a_include_subitem_calendars = false)

get new/changed events

Parameters
bool$a_include_subitem_calendarsE.g include session calendars of courses.
Returns
object $events[] Array of changed events protected

Definition at line 407 of file class.ilCalendarSchedule.php.

References $DIC, $ilDB, $query, $res, $start, ilCalendarCategories\_getInstance(), addCustomEvents(), ilDBConstants\FETCHMODE_OBJECT, filterCategories(), IL_CAL_DATE, IL_CAL_DATETIME, IL_CAL_MONTH, modifyEventByFilters(), and user().

408  {
409  global $DIC;
410 
411  $ilDB = $DIC['ilDB'];
412 
413  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
414  $cats = ilCalendarCategories::_getInstance($this->user->getId())->getCategories($a_include_subitem_calendars);
415  $cats = $this->filterCategories($cats);
416 
417  if (!count($cats)) {
418  return array();
419  }
420 
421  $start = new ilDate(date('Y-m-d', time()), IL_CAL_DATE);
422  $start->increment(IL_CAL_MONTH, -1);
423 
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 " .
426  "WHERE last_update > " . $ilDB->quote($start->get(IL_CAL_DATETIME), 'timestamp') . " " .
427  "AND " . $ilDB->in('ca.cat_id', $cats, false, 'integer') . ' ' .
428  "ORDER BY last_update";
429  $res = $this->db->query($query);
430 
431  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
432  $event = new ilCalendarEntry($row->cal_id);
433  $valid_event = $this->modifyEventByFilters($event);
434  if ($valid_event) {
435  $events[] = $valid_event;
436  }
437  }
438 
439  foreach ($this->addCustomEvents($this->start, $this->end, $cats) as $event) {
440  $events[] = $event;
441  }
442 
443  return $events ? $events : array();
444  }
Model for a calendar entry.
modifyEventByFilters(ilCalendarEntry $event)
const IL_CAL_DATETIME
const IL_CAL_MONTH
user()
Definition: user.php:4
Class for single dates.
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
static _getInstance($a_usr_id=0)
get singleton instance
const IL_CAL_DATE
global $ilDB
addCustomEvents(ilDate $start, ilDate $end, array $categories)
+ Here is the call graph for this function:

◆ getEvents()

ilCalendarSchedule::getEvents ( )

Read events (will be moved to another class, since only active and/or visible calendars are shown)

protected

Definition at line 452 of file class.ilCalendarSchedule.php.

References $DIC, $ilDB, $query, $res, ilCalendarCategories\_getInstance(), addCustomEvents(), enabledSubitemCalendars(), ilDBConstants\FETCHMODE_OBJECT, filterCategories(), IL_CAL_DATETIME, IL_CAL_UNIX, modifyEventByFilters(), and user().

Referenced by calculate().

453  {
454  global $DIC;
455 
456  $ilDB = $DIC['ilDB'];
457 
458  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
459  $cats = ilCalendarCategories::_getInstance($this->user->getId())->getCategories($this->enabledSubitemCalendars());
460  $cats = $this->filterCategories($cats);
461 
462  if (!count($cats)) {
463  return array();
464  }
465 
466  // TODO: optimize
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)";
471 
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))";
477  } else {
478  $date = new ilDateTime(mktime(0, 0, 0), IL_CAL_UNIX);
479  $query .= " WHERE starta >= " . $this->db->quote($date->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp');
480  }
481 
482  $query .= " AND " . $ilDB->in('ca.cat_id', $cats, false, 'integer') .
483  " ORDER BY starta";
484 
485  $res = $this->db->query($query);
486 
487  $events = array();
488  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
489  $event = new ilCalendarEntry($row->cal_id);
490  $valid_event = $this->modifyEventByFilters($event);
491  if ($valid_event) {
492  $events[] = $valid_event;
493  }
494  }
495 
496  foreach ($this->addCustomEvents($this->start, $this->end, $cats) as $event) {
497  $events[] = $event;
498  }
499 
500  return $events;
501  }
Model for a calendar entry.
modifyEventByFilters(ilCalendarEntry $event)
const IL_CAL_DATETIME
enabledSubitemCalendars()
Are subitem calendars enabled.
const IL_CAL_UNIX
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
static _getInstance($a_usr_id=0)
get singleton instance
global $ilDB
addCustomEvents(ilDate $start, ilDate $end, array $categories)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEventsLimit()

ilCalendarSchedule::getEventsLimit ( )

get current limit of events

Returns
type

Definition at line 153 of file class.ilCalendarSchedule.php.

References $limit_events.

Referenced by calculate().

154  {
155  return $this->limit_events;
156  }
+ Here is the caller graph for this function:

◆ getScheduledEvents()

ilCalendarSchedule::getScheduledEvents ( )

Definition at line 354 of file class.ilCalendarSchedule.php.

References $schedule.

355  {
356  return (array) $this->schedule;
357  }

◆ initPeriod()

ilCalendarSchedule::initPeriod ( ilDate  $seed)
protected

init period of events

protected

Parameters
ilDateseed
Returns

Definition at line 510 of file class.ilCalendarSchedule.php.

References $start, ilCalendarUtil\_getMaxDayOfMonth(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_FKT_DATE, IL_CAL_FKT_GETDATE, IL_CAL_MONTH, IL_CAL_SECOND, IL_CAL_WEEK, ilDateTime\increment(), ilCalendarSettings\WEEK_START_MONDAY, and ilCalendarSettings\WEEK_START_SUNDAY.

Referenced by __construct().

511  {
512  switch ($this->type) {
513  case self::TYPE_DAY:
514  $this->start = clone $seed;
515  $this->end = clone $seed;
516  //this strict period is just to avoid possible side effects.
517  if (!$this->strict_period) {
518  $this->start->increment(IL_CAL_DAY, -2);
519  $this->end->increment(IL_CAL_DAY, 2);
520  } else {
521  $this->end->increment(IL_CAL_DAY, 1);
522  $this->end->increment(IL_CAL_SECOND, -1);
523  }
524  break;
525 
526  case self::TYPE_WEEK:
527  $this->start = clone $seed;
528  $start_info = $this->start->get(IL_CAL_FKT_GETDATE, '', 'UTC');
529  $day_diff = $this->weekstart - $start_info['isoday'];
530 
531  if ($day_diff == 7) {
532  $day_diff = 0;
533  }
534 
535  //this strict period is just to avoid possible side effects.
536  if ($this->strict_period) {
537  $this->start->increment(IL_CAL_DAY, $day_diff);
538  $this->end = clone $this->start;
539  $this->end->increment(IL_CAL_WEEK); #22173
540  } else {
541  $this->start->increment(IL_CAL_DAY, $day_diff);
542  $this->start->increment(IL_CAL_DAY, -1);
543  $this->end = clone $this->start;
544  $this->end->increment(IL_CAL_DAY, 9);
545  }
546  break;
547 
548  case self::TYPE_MONTH:
549  if ($this->strict_period) {
550  $this->start = clone $seed;
551  $this->end = clone $seed;
552  $this->end->increment(IL_CAL_MONTH, 1);
553  } else {
554  $year_month = $seed->get(IL_CAL_FKT_DATE, 'Y-m', 'UTC');
555  list($year, $month) = explode('-', $year_month);
556 
557  #21716
558  $this->start = new ilDate($year_month . '-01', IL_CAL_DATE);
559 
560  $start_unix_time = $this->start->getUnixTime();
561 
562  $start_day_of_week = (int) date('w', $start_unix_time);
563 
564  $number_days_previous_month = 0;
565 
566  if ($start_day_of_week === 0 && $this->weekstart === ilCalendarSettings::WEEK_START_MONDAY) {
567  $number_days_previous_month = 6;
568  } elseif ($start_day_of_week > 0) {
569  $number_days_previous_month = $start_day_of_week;
570 
571  if ($this->weekstart === ilCalendarSettings::WEEK_START_MONDAY) {
572  $number_days_previous_month = $start_day_of_week - 1;
573  }
574  }
575 
576  $this->start->increment(IL_CAL_DAY, -$number_days_previous_month);
577 
578  #21716
579  $this->end = new ilDate($year_month . '-' . ilCalendarUtil::_getMaxDayOfMonth($year, $month), IL_CAL_DATE);
580 
581  $end_unix_time = $this->end->getUnixTime();
582 
583  $end_day_of_week = (int) date('w', $end_unix_time);
584 
585  if ($end_day_of_week > 0) {
586  $number_days_next_month = 7 - $end_day_of_week;
587 
588  if ($this->weekstart == ilCalendarSettings::WEEK_START_SUNDAY) {
589  $number_days_next_month = $number_days_next_month - 1;
590  }
591 
592  $this->end->increment(IL_CAL_DAY, $number_days_next_month);
593  }
594  }
595 
596  break;
597 
598  case self::TYPE_HALF_YEAR:
599  $this->start = clone $seed;
600  $this->end = clone $this->start;
601  $this->end->increment(IL_CAL_MONTH, 6);
602  break;
603 
604  case self::TYPE_PD_UPCOMING:
605  case self::TYPE_INBOX:
606  $this->start = $seed;
607  $this->end = clone $this->start;
608  $this->end->increment(IL_CAL_MONTH, 12);
609  break;
610  }
611 
612  return true;
613  }
const IL_CAL_MONTH
const IL_CAL_WEEK
static _getMaxDayOfMonth($a_year, $a_month)
get max day of month 2008,2 => 29
const IL_CAL_DAY
Class for single dates.
const IL_CAL_FKT_DATE
const IL_CAL_SECOND
increment($a_type, $a_count=1)
increment
const IL_CAL_FKT_GETDATE
const IL_CAL_DATE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modifyEventByFilters()

ilCalendarSchedule::modifyEventByFilters ( ilCalendarEntry  $event)
protected

Definition at line 374 of file class.ilCalendarSchedule.php.

References $res.

Referenced by getChangedEvents(), and getEvents().

375  {
376  foreach ($this->filters as $filter) {
377  $res = $filter->modifyEvent($event);
378  if (!$res) {
379  $this->logger->info('filtering failed for ' . get_class($filter));
380  return false;
381  }
382  $event = $res;
383  }
384  return $event;
385  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ setEventsLimit()

ilCalendarSchedule::setEventsLimit (   $a_limit)

Set events limit.

Parameters
type$a_limit

Definition at line 162 of file class.ilCalendarSchedule.php.

163  {
164  $this->limit_events = $a_limit;
165  }

◆ setPeriod()

ilCalendarSchedule::setPeriod ( ilDate  $a_start,
ilDate  $a_end 
)

Set period.

Parameters
ilDatestart
ilDateend
Returns

Definition at line 621 of file class.ilCalendarSchedule.php.

622  {
623  $this->start = $a_start;
624  $this->end = $a_end;
625  }

Field Documentation

◆ $db

ilCalendarSchedule::$db = null
protected

Definition at line 59 of file class.ilCalendarSchedule.php.

◆ $end

ilCalendarSchedule::$end = null
protected

Definition at line 56 of file class.ilCalendarSchedule.php.

◆ $filters

ilCalendarSchedule::$filters = array()
protected

Definition at line 60 of file class.ilCalendarSchedule.php.

◆ $limit_events

ilCalendarSchedule::$limit_events = -1
protected

Definition at line 47 of file class.ilCalendarSchedule.php.

Referenced by getEventsLimit().

◆ $logger

ilCalendarSchedule::$logger
protected

Definition at line 70 of file class.ilCalendarSchedule.php.

◆ $schedule

ilCalendarSchedule::$schedule = array()
protected

Definition at line 48 of file class.ilCalendarSchedule.php.

Referenced by getByDay(), and getScheduledEvents().

◆ $start

ilCalendarSchedule::$start = null
protected

Definition at line 55 of file class.ilCalendarSchedule.php.

Referenced by getByDay(), getChangedEvents(), and initPeriod().

◆ $strict_period

ilCalendarSchedule::$strict_period
protected

Definition at line 65 of file class.ilCalendarSchedule.php.

◆ $subitems_enabled

ilCalendarSchedule::$subitems_enabled = false
protected

Definition at line 53 of file class.ilCalendarSchedule.php.

Referenced by enabledSubitemCalendars().

◆ $timezone

ilCalendarSchedule::$timezone
protected

Definition at line 49 of file class.ilCalendarSchedule.php.

Referenced by getByDay().

◆ $type

ilCalendarSchedule::$type = 0
protected

Definition at line 51 of file class.ilCalendarSchedule.php.

◆ $user

ilCalendarSchedule::$user = null
protected

Definition at line 57 of file class.ilCalendarSchedule.php.

◆ $user_settings

ilCalendarSchedule::$user_settings = null
protected

Definition at line 58 of file class.ilCalendarSchedule.php.

◆ $weekstart

ilCalendarSchedule::$weekstart
protected

Definition at line 50 of file class.ilCalendarSchedule.php.

◆ TYPE_DAY

const ilCalendarSchedule::TYPE_DAY = 1

◆ TYPE_HALF_YEAR

const ilCalendarSchedule::TYPE_HALF_YEAR = 6

Definition at line 42 of file class.ilCalendarSchedule.php.

Referenced by ilCalendarViewGUI\getEvents().

◆ TYPE_INBOX

const ilCalendarSchedule::TYPE_INBOX = 4

Definition at line 41 of file class.ilCalendarSchedule.php.

Referenced by ilCalendarBlockGUI\getOverview().

◆ TYPE_MONTH

◆ TYPE_PD_UPCOMING

const ilCalendarSchedule::TYPE_PD_UPCOMING = 5

Definition at line 45 of file class.ilCalendarSchedule.php.

Referenced by ilCalendarBlockGUI\getEvents().

◆ TYPE_WEEK

const ilCalendarSchedule::TYPE_WEEK = 2

The documentation for this class was generated from the following file: