ILIAS  release_8 Revision v8.24
class.ilCalendarRecurrenceExclusion.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
30{
31 protected ?ilDate $exclusion = null;
32 protected int $cal_id = 0;
33 protected int $exclusion_id = 0;
34
35 protected ?ilDBInterface $db;
36
37 public function __construct(int $a_exclusion_id = 0)
38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42 $this->exclusion_id = $a_exclusion_id;
43 if ($this->getId()) {
44 $this->read();
45 }
46 }
47
48 public function getId(): int
49 {
51 }
52
53 public function getEntryId(): int
54 {
55 return $this->cal_id;
56 }
57
58 public function setEntryId(int $a_id)
59 {
60 $this->cal_id = $a_id;
61 }
62
63 public function getDate(): ?ilDate
64 {
65 return $this->exclusion instanceof ilDate ? $this->exclusion : null;
66 }
67
71 public function setDate(?ilDate $dt = null): void
72 {
73 $this->exclusion = $dt;
74 }
75
76 public function toICal(): string
77 {
78 $entry = new ilCalendarEntry($this->getEntryId());
79 $start = $entry->getStart();
80
81 if ($entry->isFullday()) {
82 return 'EXDATE;VALUE=DATE:' . $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd');
83 } else {
84 return 'EXDATE:' .
85 $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC) .
86 'T' . $start->get(IL_CAL_FKT_DATE, 'His', ilTimeZone::UTC) . 'Z';
87 }
88 }
89
90 public function save(): int
91 {
92 if (!$this->getDate()) {
93 return 0;
94 }
95
96 $query = "INSERT INTO cal_rec_exclusion (excl_id,cal_id,excl_date) " .
97 "VALUES( " .
98 $this->db->quote($next_id = $this->db->nextId('cal_rec_exclusion'), 'integer') . ', ' .
99 $this->db->quote($this->getEntryId(), 'integer') . ', ' .
100 $this->db->quote($this->getDate()->get(IL_CAL_DATE, '', 'UTC'), 'timestamp') .
101 ')';
102 $this->db->manipulate($query);
103
104 $this->exclusion_id = $next_id;
105 return $this->getId();
106 }
107
108 protected function read()
109 {
110 $query = "SELECT * FROM cal_rec_exclusion WHERE excl_id = " . $this->db->quote($this->getId(), 'integer');
111 $res = $this->db->query($query);
112 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
113 $this->cal_id = $row->cal_id;
114 $this->setDate(new ilDate((string) $row->excl_date, IL_CAL_DATE));
115 }
116 }
117}
const IL_CAL_DATE
const IL_CAL_FKT_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Stores exclusion dates for calendar recurrences.
setDate(?ilDate $dt=null)
Set exclusion date.
Class for single dates.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query