ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
24include_once('./Services/Calendar/classes/class.ilDateList.php');
25include_once('./Services/Calendar/classes/class.ilTimeZone.php');
26include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
27include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
28
39{
40 protected $exclusion = null;
41 protected $cal_id = 0;
42 protected $exclusion_id = 0;
43
44 protected $db = null;
45
50 public function __construct($a_exclusion_id = 0)
51 {
52 global $ilDB;
53
54 $this->db = $ilDB;
55 $this->exclusion_id = $a_exclusion_id;
56
57 if ($this->getId()) {
58 $this->read();
59 }
60 }
61
62
67 public function getId()
68 {
70 }
71
76 public function getEntryId()
77 {
78 return $this->cal_id;
79 }
80
86 public function setEntryId($a_id)
87 {
88 $this->cal_id = $a_id;
89 }
90
95 public function getDate()
96 {
97 return $this->exclusion instanceof ilDate ? $this->exclusion : null;
98 }
99
105 public function setDate(ilDate $dt = null)
106 {
107 $this->exclusion = $dt;
108 }
109
114 public function toICal()
115 {
116 $entry = new ilCalendarEntry($this->getEntryId());
117 $start = $entry->getStart();
118
119 if ($entry->isFullday()) {
120 return 'EXDATE;VALUE=DATE:' . $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd');
121 } else {
122 return 'EXDATE:' .
123 $this->getDate()->get(IL_CAL_FKT_DATE, 'Ymd', ilTimeZone::UTC) .
124 'T' . $start->get(IL_CAL_FKT_DATE, 'His', ilTimeZone::UTC) . 'Z';
125 }
126 }
127
132 public function save()
133 {
134 global $ilDB;
135
136 if (!$this->getDate()) {
137 return false;
138 }
139
140 $query = "INSERT INTO cal_rec_exclusion (excl_id,cal_id,excl_date) " .
141 "VALUES( " .
142 $ilDB->quote($next_id = $ilDB->nextId('cal_rec_exclusion'), 'integer') . ', ' .
143 $ilDB->quote($this->getEntryId(), 'integer') . ', ' .
144 $ilDB->quote($this->getDate()->get(IL_CAL_DATE, '', 'UTC'), 'timestamp') .
145 ')';
146 $ilDB->manipulate($query);
147
148 $this->exclusion_id = $next_id;
149 return $this->getId();
150 }
151
156 protected function read()
157 {
158 global $ilDB;
159
160 $query = "SELECT * FROM cal_rec_exclusion WHERE excl_id = " . $ilDB->quote($this->getId(), 'integer');
161 $res = $ilDB->query($query);
162 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
163 $this->cal_id = $row->cal_id;
164 $this->setDate(new ilDate($row->excl_date, IL_CAL_DATE, 'UTC'));
165 }
166 }
167}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_FKT_DATE
Model for a calendar entry.
Stores exclusion dates for calendar recurrences.
setEntryId($a_id)
Set entry id (id of calendar appointment)
setDate(ilDate $dt=null)
Set exclusion date.
Class for single dates.
$query
foreach($_POST as $key=> $value) $res
global $ilDB