ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSessionDataSet.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/DataSet/classes/class.ilDataSet.php");
5
14{
21 public function getSupportedVersions()
22 {
23 return array("4.1.0", "5.0.0", "5.1.0");
24 }
25
32 function getXmlNamespace($a_entity, $a_schema_version)
33 {
34 return "http://www.ilias.de/xml/Modules/Session/".$a_entity;
35 }
36
43 protected function getTypes($a_entity, $a_version)
44 {
45 if ($a_entity == "sess")
46 {
47 switch ($a_version)
48 {
49 case "4.1.0":
50 return array(
51 "Id" => "integer",
52 "Title" => "text",
53 "Description" => "text",
54 "Location" => "text",
55 "TutorName" => "text",
56 "TutorEmail" => "text",
57 "TutorPhone" => "text",
58 "Details" => "text",
59 "Registration" => "integer",
60 "EventStart" => "text",
61 "EventEnd" => "text",
62 "StartingTime" => "integer",
63 "EndingTime" => "integer",
64 "Fulltime" => "integer"
65 );
66 case "5.0.0":
67 return array(
68 "Id" => "integer",
69 "Title" => "text",
70 "Description" => "text",
71 "Location" => "text",
72 "TutorName" => "text",
73 "TutorEmail" => "text",
74 "TutorPhone" => "text",
75 "Details" => "text",
76 "Registration" => "integer",
77 "EventStart" => "text",
78 "EventEnd" => "text",
79 "StartingTime" => "integer",
80 "EndingTime" => "integer",
81 "Fulltime" => "integer",
82 "LimitedRegistration" => "integer",
83 "WaitingList" => "integer",
84 "LimitUsers" => "integer"
85 );
86 case "5.1.0":
87 return array(
88 "Id" => "integer",
89 "Title" => "text",
90 "Description" => "text",
91 "Location" => "text",
92 "TutorName" => "text",
93 "TutorEmail" => "text",
94 "TutorPhone" => "text",
95 "Details" => "text",
96 "Registration" => "integer",
97 "EventStart" => "text",
98 "EventEnd" => "text",
99 "StartingTime" => "integer",
100 "EndingTime" => "integer",
101 "Fulltime" => "integer",
102 "LimitedRegistration" => "integer",
103 "WaitingList" => "integer",
104 "AutoWait" => "integer",
105 "LimitUsers" => "integer",
106 "MinUsers" => "integer"
107 );
108 }
109 }
110
111 if ($a_entity == "sess_item")
112 {
113 switch ($a_version)
114 {
115 case "4.1.0":
116 case "5.0.0":
117 case "5.1.0":
118 return array(
119 "SessionId" => "integer",
120 "ItemId" => "text",
121 );
122 }
123 }
124
125 }
126
133 function readData($a_entity, $a_version, $a_ids, $a_field = "")
134 {
135 global $ilDB;
136
137 if (!is_array($a_ids))
138 {
139 $a_ids = array($a_ids);
140 }
141
142 if ($a_entity == "sess")
143 {
144 switch ($a_version)
145 {
146 case "4.1.0":
147 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, od.description description, ".
148 " location, tutor_name, tutor_email, tutor_phone, details, registration, ".
149 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime ".
150 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) ".
151 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) ".
152 "WHERE ".
153 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
154 break;
155 case "5.0.0":
156 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, ".
157 " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, ".
158 " reg_limited limited_registration, reg_waiting_list waiting_list, ".
159 " reg_limit_users limit_users, ".
160 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime ".
161 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) ".
162 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) ".
163 " JOIN object_description odes ON (ev.obj_id = odes.obj_id) ".
164 "WHERE ".
165 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
166 break;
167 case "5.1.0":
168 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, ".
169 " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, ".
170 " reg_limited limited_registration, reg_waiting_list waiting_list, reg_auto_wait auto_wait, ".
171 " reg_limit_users limit_users, reg_min_users min_users, ".
172 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime ".
173 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) ".
174 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) ".
175 " JOIN object_description odes ON (ev.obj_id = odes.obj_id) ".
176 "WHERE ".
177 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
178 break;
179 }
180 }
181
182 if ($a_entity == "sess_item")
183 {
184 switch ($a_version)
185 {
186 case "4.1.0":
187 case "5.0.0":
188 case "5.1.0":
189 $this->getDirectDataFromQuery($q = "SELECT event_id session_id, item_id ".
190 " FROM event_items ".
191 "WHERE ".
192 $ilDB->in("event_id", $a_ids, false, "integer"));
193 break;
194 }
195 }
196
197 }
198
205 function getXmlRecord($a_entity, $a_version, $a_set)
206 {
207 if ($a_entity == "sess")
208 {
209 // convert server dates to utc
210 if(!$a_set["Fulltime"])
211 {
212 // nothing has to be done here, since the dates are already stored in UTC
213 #$start = new ilDateTime($a_set["EventStart"], IL_CAL_DATETIME);
214 #$a_set["EventStart"] = $start->get(IL_CAL_DATETIME,'','UTC');
215 #$end = new ilDateTime($a_set["EventEnd"], IL_CAL_DATETIME);
216 #$a_set["EventEnd"] = $end->get(IL_CAL_DATETIME,'','UTC');
217 }
218 }
219 if ($a_entity == "sess_item")
220 {
221 // make ref id an object id
222 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
223 }
224 return $a_set;
225 }
226
227
228
232 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
233 {
234 switch ($a_entity)
235 {
236 case "sess":
237 return array (
238 "sess_item" => array("ids" => $a_rec["Id"])
239 );
240 }
241
242 return false;
243 }
244
245
252 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
253 {
254 switch ($a_entity)
255 {
256 case "sess":
257 include_once("./Modules/Session/classes/class.ilObjSession.php");
258 include_once("./Modules/Session/classes/class.ilSessionAppointment.php");
259
260 if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
261 {
262 $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
263 }
264 else
265 {
266 $newObj = new ilObjSession();
267 $newObj->setType("sess");
268 $newObj->create(true);
269 }
270 $newObj->setTitle($a_rec["Title"]);
271 $newObj->setDescription($a_rec["Description"]);
272 $newObj->setLocation($a_rec["Location"]);
273 $newObj->setName($a_rec["TutorName"]);
274 $newObj->setPhone($a_rec["TutorPhone"]);
275 $newObj->setEmail($a_rec["TutorEmail"]);
276 $newObj->setDetails($a_rec["Details"]);
277
278 switch ($a_schema_version)
279 {
280 case "5.0.0":
281 case "5.1.0":
282 $newObj->setRegistrationType($a_rec["Registration"]);
283
284 $newObj->enableRegistrationUserLimit($a_rec["LimitedRegistration"]);
285 $newObj->setRegistrationMaxUsers($a_rec["LimitUsers"]);
286 $newObj->enableRegistrationWaitingList($a_rec["WaitingList"]);
287
288 if(isset($a_rec["MinUsers"])) {
289 $newObj->setRegistrationMinUsers($a_rec["MinUsers"]);
290 }
291
292 if(isset($a_rec["AutoWait"])) {
293 $newObj->setWaitingListAutoFill($a_rec["AutoWait"]);
294 }
295 break;
296 }
297
298 $newObj->update();
299
300 $start = new ilDateTime($a_rec["EventStart"], IL_CAL_DATETIME, "UTC");
301 $end = new ilDateTime($a_rec["EventEnd"], IL_CAL_DATETIME, "UTC");
302//echo "<br>".$start->get(IL_CAL_UNIX);
303//echo "<br>".$start->get(IL_CAL_DATETIME);
304 $app = new ilSessionAppointment();
305 $app->setStart($a_rec["EventStart"]);
306 $app->setEnd($a_rec["EventEnd"]);
307 $app->setStartingTime($start->get(IL_CAL_UNIX));
308 $app->setEndingTime($end->get(IL_CAL_UNIX));
309 $app->toggleFullTime($a_rec["Fulltime"]);
310 $app->setSessionId($newObj->getId());
311 $app->create();
312
313 //$newObj->setAppointments(array($app));
314 //$newObj->update();
315
316 $this->current_obj = $newObj;
317 $a_mapping->addMapping("Modules/Session", "sess", $a_rec["Id"], $newObj->getId());
318//var_dump($a_mapping->mappings["Services/News"]["news_context"]);
319 break;
320
321 case "sess_item":
322
323 if($obj_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['ItemId']))
324 {
325 $ref_id = current(ilObject::_getAllReferences($obj_id));
326 include_once './Modules/Session/classes/class.ilEventItems.php';
327 $evi = new ilEventItems($this->current_obj->getId());
328 $evi->addItem($ref_id);
329 $evi->update();
330 }
331 break;
332 }
333 }
334}
335?>
const IL_CAL_UNIX
const IL_CAL_DATETIME
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
@classDescription Date and time handling
class ilEvent
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
class ilSessionAppointment
Session data set class.
getTypes($a_entity, $a_version)
Get field types for entity.
getSupportedVersions()
Get supported versions.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record (export)
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
$ref_id
Definition: sahs_server.php:39
global $ilDB