ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24 include_once('./Services/Calendar/classes/class.ilDateList.php');
25 include_once('./Services/Calendar/classes/class.ilTimeZone.php');
26 include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
27 
38 {
39  protected $exclusion = null;
40  protected $cal_id = 0;
41  protected $exclusion_id = 0;
42 
43  protected $db = null;
44 
49  public function __construct($a_exclusion_id = 0)
50  {
51  global $ilDB;
52 
53  $this->db = $ilDB;
54  $this->exclusion_id = $a_exclusion_id;
55 
56  if($this->getId())
57  {
58  $this->read();
59  }
60  }
61 
62 
67  public function getId()
68  {
69  return $this->exclusion_id;
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  return 'EXDATE:'.$this->getDate()->get(IL_CAL_FKT_DATE,'Ymd');
117  }
118 
123  public function save()
124  {
125  global $ilDB;
126 
127  if(!$this->getDate())
128  {
129  return false;
130  }
131 
132  $query = "INSERT INTO cal_rec_exclusion (excl_id,cal_id,excl_date) ".
133  "VALUES( ".
134  $ilDB->quote($next_id = $ilDB->nextId('cal_rec_exclusion'),'integer').', '.
135  $ilDB->quote($this->getEntryId(),'integer').', '.
136  $ilDB->quote($this->getDate()->get(IL_CAL_DATE,'','UTC'),'timestamp').
137  ')';
138  $ilDB->manipulate($query);
139 
140  $this->exclusion_id = $next_id;
141  return $this->getId();
142  }
143 
148  protected function read()
149  {
150  global $ilDB;
151 
152  $query = "SELECT * FROM cal_rec_exclusion WHERE excl_id = ".$ilDB->quote($this->getId(),'integer');
153  $res = $ilDB->query($query);
154  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
155  {
156  $this->cal_id = $row->cal_id;
157  $this->setDate(new ilDate($row->excl_date,IL_CAL_DATE,'UTC'));
158  }
159  }
160 }
161 ?>