ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarRecurrenceExclusion.php
Go to the documentation of this file.
1<?php
24{
25 protected ?ilDate $exclusion = null;
26 protected int $cal_id = 0;
27 protected int $exclusion_id = 0;
28
29 protected ?ilDBInterface $db;
30
31 public function __construct(int $a_exclusion_id = 0)
32 {
33 global $DIC;
34
35 $this->db = $DIC->database();
36 $this->exclusion_id = $a_exclusion_id;
37 if ($this->getId()) {
38 $this->read();
39 }
40 }
41
42 public function getId(): int
43 {
45 }
46
47 public function getEntryId(): int
48 {
49 return $this->cal_id;
50 }
51
52 public function setEntryId(int $a_id)
53 {
54 $this->cal_id = $a_id;
55 }
56
57 public function getDate(): ?ilDate
58 {
59 return $this->exclusion instanceof ilDate ? $this->exclusion : null;
60 }
61
65 public function setDate(?ilDate $dt = null): void
66 {
67 $this->exclusion = $dt;
68 }
69
70 public function toICal(): string
71 {
72 $entry = new ilCalendarEntry($this->getEntryId());
73 $start = $entry->getStart();
74
75 if ($entry->isFullday()) {
76 return 'EXDATE;VALUE=DATE:' . $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd');
77 } else {
78 return 'EXDATE:' .
79 $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC) .
80 'T' . $start->get(IL_CAL_FKT_DATE, 'His', ilTimeZone::UTC) . 'Z';
81 }
82 }
83
84 public function save(): int
85 {
86 if (!$this->getDate()) {
87 return 0;
88 }
89
90 $query = "INSERT INTO cal_rec_exclusion (excl_id,cal_id,excl_date) " .
91 "VALUES( " .
92 $this->db->quote($next_id = $this->db->nextId('cal_rec_exclusion'), 'integer') . ', ' .
93 $this->db->quote($this->getEntryId(), 'integer') . ', ' .
94 $this->db->quote($this->getDate()->get(IL_CAL_DATE, '', 'UTC'), 'timestamp') .
95 ')';
96 $this->db->manipulate($query);
97
98 $this->exclusion_id = $next_id;
99 return $this->getId();
100 }
101
102 protected function read()
103 {
104 $query = "SELECT * FROM cal_rec_exclusion WHERE excl_id = " . $this->db->quote($this->getId(), 'integer');
105 $res = $this->db->query($query);
106 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
107 $this->cal_id = $row->cal_id;
108 $this->setDate(new ilDate((string) $row->excl_date, IL_CAL_DATE));
109 }
110 }
111}
const IL_CAL_DATE
const IL_CAL_FKT_DATE
Model for a calendar entry.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDate(?ilDate $dt=null)
Set exclusion date.
Class for single dates.
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26