ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSTimePlace.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23  */
24 
35 {
36  public $room = '';
37  public $begin = '';
38  public $end = '';
39  public $cycle = '';
40 
48  public function __construct()
49  {
50 
51  }
52 
60  public function loadFromJson($a_json)
61  {
62  global $ilLog;
63 
64  if(!is_object($a_json))
65  {
66  $ilLog->write(__METHOD__ . ': Cannot load from JSON. No object given.');
67  throw new ilException('Cannot parse ECSContent.');
68  }
69 
70  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($a_json,true));
71 
72  $this->room = $a_json->room;
73  $this->begin = $a_json->begin;
74  $this->end = $a_json->end;
75  $this->cycle = $a_json->cycle;
76  #$this->day = $a_json->day;
77 
78  $two = new ilDate('2000-01-02',IL_CAL_DATE);
79  if(ilDate::_before(new ilDateTime($this->getUTBegin(),IL_CAL_UNIX), $two))
80  {
81  $this->begin = '';
82  }
83  if(ilDate::_before(new ilDateTime($this->getUTEnd(),IL_CAL_UNIX), $two))
84  {
85  $this->end = '';
86  }
87  }
88 
95  public function setBegin($a_begin)
96  {
97  // is it unix time ?
98  if(is_numeric($a_begin) and $a_begin)
99  {
100  $dt = new ilDateTime($a_begin, IL_CAL_UNIX, ilTimeZone::UTC);
101  $this->end = $dt->get(IL_CAL_DATE);
102  }
103  else
104  {
105  $this->begin = $a_begin;
106  }
107  }
108 
114  public function getBegin()
115  {
116  return $this->begin;
117  }
118 
125  public function getUTBegin()
126  {
127  include_once './Services/Calendar/classes/class.ilDateTime.php';
128  $dt = new ilDateTime($this->begin, IL_CAL_DATE, ilTimeZone::UTC);
129  return $dt->get(IL_CAL_UNIX);
130 
131  }
132 
140  public function setEnd($a_end)
141  {
142  // is it unix time ?
143  if(is_numeric($a_end) and $a_end)
144  {
145  $dt = new ilDateTime($a_end, IL_CAL_UNIX, ilTimeZone::UTC);
146  $this->end = $dt->get(IL_CAL_DATE);
147  }
148  else
149  {
150  $this->end = $a_end;
151  }
152  }
153 
159  public function getEnd()
160  {
161  return $this->end;
162  }
163 
170  public function getUTEnd()
171  {
172  include_once './Services/Calendar/classes/class.ilDateTime.php';
173  $dt = new ilDateTime($this->end, IL_CAL_DATE, ilTimeZone::UTC);
174  return $dt->get(IL_CAL_UNIX);
175  }
176 
184  public function setRoom($a_room)
185  {
186  $this->room = $a_room;
187  }
188 
195  public function getRoom()
196  {
197  return $this->room;
198  }
199 
207  public function setCycle($a_cycle)
208  {
209  $this->cycle = $a_cycle;
210  }
211 
219  public function getCycle()
220  {
221  return $this->cycle;
222  }
223 
224 }
225 ?>