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