ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public 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 switch ($a_version) {
47 case "4.1.0":
48 return array(
49 "Id" => "integer",
50 "Title" => "text",
51 "Description" => "text",
52 "Location" => "text",
53 "TutorName" => "text",
54 "TutorEmail" => "text",
55 "TutorPhone" => "text",
56 "Details" => "text",
57 "Registration" => "integer",
58 "EventStart" => "text",
59 "EventEnd" => "text",
60 "StartingTime" => "integer",
61 "EndingTime" => "integer",
62 "Fulltime" => "integer"
63 );
64 case "5.0.0":
65 return array(
66 "Id" => "integer",
67 "Title" => "text",
68 "Description" => "text",
69 "Location" => "text",
70 "TutorName" => "text",
71 "TutorEmail" => "text",
72 "TutorPhone" => "text",
73 "Details" => "text",
74 "Registration" => "integer",
75 "EventStart" => "text",
76 "EventEnd" => "text",
77 "StartingTime" => "integer",
78 "EndingTime" => "integer",
79 "Fulltime" => "integer",
80 "LimitedRegistration" => "integer",
81 "WaitingList" => "integer",
82 "LimitUsers" => "integer"
83 );
84 case "5.1.0":
85 return array(
86 "Id" => "integer",
87 "Title" => "text",
88 "Description" => "text",
89 "Location" => "text",
90 "TutorName" => "text",
91 "TutorEmail" => "text",
92 "TutorPhone" => "text",
93 "Details" => "text",
94 "Registration" => "integer",
95 "EventStart" => "text",
96 "EventEnd" => "text",
97 "StartingTime" => "integer",
98 "EndingTime" => "integer",
99 "Fulltime" => "integer",
100 "LimitedRegistration" => "integer",
101 "WaitingList" => "integer",
102 "AutoWait" => "integer",
103 "LimitUsers" => "integer",
104 "MinUsers" => "integer"
105 );
106 }
107 }
108
109 if ($a_entity == "sess_item") {
110 switch ($a_version) {
111 case "4.1.0":
112 case "5.0.0":
113 case "5.1.0":
114 return array(
115 "SessionId" => "integer",
116 "ItemId" => "text",
117 );
118 }
119 }
120 }
121
128 public function readData($a_entity, $a_version, $a_ids, $a_field = "")
129 {
130 global $ilDB;
131
132 if (!is_array($a_ids)) {
133 $a_ids = array($a_ids);
134 }
135
136 if ($a_entity == "sess") {
137 switch ($a_version) {
138 case "4.1.0":
139 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, od.description description, " .
140 " location, tutor_name, tutor_email, tutor_phone, details, registration, " .
141 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime " .
142 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
143 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
144 "WHERE " .
145 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
146 break;
147 case "5.0.0":
148 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, " .
149 " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, " .
150 " reg_limited limited_registration, reg_waiting_list waiting_list, " .
151 " reg_limit_users limit_users, " .
152 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime " .
153 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
154 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
155 " JOIN object_description odes ON (ev.obj_id = odes.obj_id) " .
156 "WHERE " .
157 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
158 break;
159 case "5.1.0":
160 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, " .
161 " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, " .
162 " reg_limited limited_registration, reg_waiting_list waiting_list, reg_auto_wait auto_wait, " .
163 " reg_limit_users limit_users, reg_min_users min_users, " .
164 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime " .
165 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
166 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
167 " JOIN object_description odes ON (ev.obj_id = odes.obj_id) " .
168 "WHERE " .
169 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
170 break;
171 }
172 }
173
174 if ($a_entity == "sess_item") {
175 switch ($a_version) {
176 case "4.1.0":
177 case "5.0.0":
178 case "5.1.0":
179 $this->getDirectDataFromQuery($q = "SELECT event_id session_id, item_id " .
180 " FROM event_items " .
181 "WHERE " .
182 $ilDB->in("event_id", $a_ids, false, "integer"));
183 break;
184 }
185 }
186 }
187
194 public function getXmlRecord($a_entity, $a_version, $a_set)
195 {
196 if ($a_entity == "sess") {
197 // convert server dates to utc
198 if (!$a_set["Fulltime"]) {
199 // nothing has to be done here, since the dates are already stored in UTC
200 #$start = new ilDateTime($a_set["EventStart"], IL_CAL_DATETIME);
201 #$a_set["EventStart"] = $start->get(IL_CAL_DATETIME,'','UTC');
202 #$end = new ilDateTime($a_set["EventEnd"], IL_CAL_DATETIME);
203 #$a_set["EventEnd"] = $end->get(IL_CAL_DATETIME,'','UTC');
204 }
205 }
206 if ($a_entity == "sess_item") {
207 // make ref id an object id
208 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
209 }
210 return $a_set;
211 }
212
213
214
218 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
219 {
220 switch ($a_entity) {
221 case "sess":
222 return array(
223 "sess_item" => array("ids" => $a_rec["Id"])
224 );
225 }
226
227 return false;
228 }
229
230
237 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
238 {
239 switch ($a_entity) {
240 case "sess":
241 include_once("./Modules/Session/classes/class.ilObjSession.php");
242 include_once("./Modules/Session/classes/class.ilSessionAppointment.php");
243
244 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
245 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
246 } else {
247 $newObj = new ilObjSession();
248 $newObj->setType("sess");
249 $newObj->create(true);
250 }
251 $newObj->setTitle($a_rec["Title"]);
252 $newObj->setDescription($a_rec["Description"]);
253 $newObj->setLocation($a_rec["Location"]);
254 $newObj->setName($a_rec["TutorName"]);
255 $newObj->setPhone($a_rec["TutorPhone"]);
256 $newObj->setEmail($a_rec["TutorEmail"]);
257 $newObj->setDetails($a_rec["Details"]);
258
259 switch ($a_schema_version) {
260 case "5.0.0":
261 case "5.1.0":
262 $newObj->setRegistrationType($a_rec["Registration"]);
263
264 $newObj->enableRegistrationUserLimit($a_rec["LimitedRegistration"]);
265 $newObj->setRegistrationMaxUsers($a_rec["LimitUsers"]);
266 $newObj->enableRegistrationWaitingList($a_rec["WaitingList"]);
267
268 if (isset($a_rec["MinUsers"])) {
269 $newObj->setRegistrationMinUsers($a_rec["MinUsers"]);
270 }
271
272 if (isset($a_rec["AutoWait"])) {
273 $newObj->setWaitingListAutoFill($a_rec["AutoWait"]);
274 }
275 break;
276 }
277
278 $newObj->update(true);
279
280 $start = new ilDateTime($a_rec["EventStart"], IL_CAL_DATETIME, "UTC");
281 $end = new ilDateTime($a_rec["EventEnd"], IL_CAL_DATETIME, "UTC");
282//echo "<br>".$start->get(IL_CAL_UNIX);
283//echo "<br>".$start->get(IL_CAL_DATETIME);
284 $app = new ilSessionAppointment();
285 $app->setStart($a_rec["EventStart"]);
286 $app->setEnd($a_rec["EventEnd"]);
287 $app->setStartingTime($start->get(IL_CAL_UNIX));
288 $app->setEndingTime($end->get(IL_CAL_UNIX));
289 $app->toggleFullTime($a_rec["Fulltime"]);
290 $app->setSessionId($newObj->getId());
291 $app->create();
292
293 //$newObj->setAppointments(array($app));
294 //$newObj->update();
295
296 $this->current_obj = $newObj;
297 $a_mapping->addMapping("Modules/Session", "sess", $a_rec["Id"], $newObj->getId());
298 $a_mapping->addMapping('Services/Object', 'objs', $a_rec['Id'], $newObj->getId());
299 $a_mapping->addMapping('Services/AdvancedMetaData', 'parent', $a_rec['Id'], $newObj->getId());
300 $a_mapping->addMapping(
301 "Services/MetaData",
302 "md",
303 $a_rec["Id"] . ":0:sess",
304 $newObj->getId() . ":0:sess"
305 );
306
307
308//var_dump($a_mapping->mappings["Services/News"]["news_context"]);
309 break;
310
311 case "sess_item":
312
313 if ($obj_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['ItemId'])) {
314 $ref_id = current(ilObject::_getAllReferences($obj_id));
315 include_once './Modules/Session/classes/class.ilEventItems.php';
316 $evi = new ilEventItems($this->current_obj->getId());
317 $evi->addItem($ref_id);
318 $evi->update();
319 }
320 break;
321 }
322 }
323}
An exception for terminatinating execution or to throw for unit testing.
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, $a_set=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
static 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.
$end
Definition: saml1-acs.php:18
global $ilDB