ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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");
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 }
87 }
88
89 if ($a_entity == "sess_item")
90 {
91 switch ($a_version)
92 {
93 case "4.1.0":
94 case "5.0.0":
95 return array(
96 "SessionId" => "integer",
97 "ItemId" => "text",
98 );
99 }
100 }
101
102 }
103
110 function readData($a_entity, $a_version, $a_ids, $a_field = "")
111 {
112 global $ilDB;
113
114 if (!is_array($a_ids))
115 {
116 $a_ids = array($a_ids);
117 }
118
119 if ($a_entity == "sess")
120 {
121 switch ($a_version)
122 {
123 case "4.1.0":
124 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, od.description description, ".
125 " location, tutor_name, tutor_email, tutor_phone, details, registration, ".
126 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime ".
127 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) ".
128 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) ".
129 "WHERE ".
130 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
131 break;
132 case "5.0.0":
133 $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, ".
134 " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, ".
135 " reg_limited limited_registration, reg_waiting_list waiting_list, ".
136 " reg_limit_users limit_users, ".
137 " e_start event_start, e_end event_end, starting_time, ending_time, fulltime ".
138 " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) ".
139 " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) ".
140 " JOIN object_description odes ON (ev.obj_id = odes.obj_id) ".
141 "WHERE ".
142 $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
143 break;
144 }
145 }
146
147 if ($a_entity == "sess_item")
148 {
149 switch ($a_version)
150 {
151 case "4.1.0":
152 case "5.0.0":
153 $this->getDirectDataFromQuery($q = "SELECT event_id session_id, item_id ".
154 " FROM event_items ".
155 "WHERE ".
156 $ilDB->in("event_id", $a_ids, false, "integer"));
157 break;
158 }
159 }
160
161 }
162
169 function getXmlRecord($a_entity, $a_version, $a_set)
170 {
171 if ($a_entity == "sess")
172 {
173 // convert server dates to utc
174 if(!$a_set["Fulltime"])
175 {
176 // nothing has to be done here, since the dates are already stored in UTC
177 #$start = new ilDateTime($a_set["EventStart"], IL_CAL_DATETIME);
178 #$a_set["EventStart"] = $start->get(IL_CAL_DATETIME,'','UTC');
179 #$end = new ilDateTime($a_set["EventEnd"], IL_CAL_DATETIME);
180 #$a_set["EventEnd"] = $end->get(IL_CAL_DATETIME,'','UTC');
181 }
182 }
183 if ($a_entity == "sess_item")
184 {
185 // make ref id an object id
186 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
187 }
188 return $a_set;
189 }
190
191
192
196 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
197 {
198 switch ($a_entity)
199 {
200 case "sess":
201 return array (
202 "sess_item" => array("ids" => $a_rec["Id"])
203 );
204 }
205
206 return false;
207 }
208
209
216 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
217 {
218 switch ($a_entity)
219 {
220 case "sess":
221 include_once("./Modules/Session/classes/class.ilObjSession.php");
222 include_once("./Modules/Session/classes/class.ilSessionAppointment.php");
223
224 if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
225 {
226 $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
227 }
228 else
229 {
230 $newObj = new ilObjSession();
231 $newObj->setType("sess");
232 $newObj->create(true);
233 }
234 $newObj->setTitle($a_rec["Title"]);
235 $newObj->setDescription($a_rec["Description"]);
236 $newObj->setLocation($a_rec["Location"]);
237 $newObj->setName($a_rec["TutorName"]);
238 $newObj->setPhone($a_rec["TutorPhone"]);
239 $newObj->setEmail($a_rec["TutorEmail"]);
240 $newObj->setDetails($a_rec["Details"]);
241
242 if($a_schema_version == "5.0.0")
243 {
244 $newObj->setRegistrationType($a_rec["Registration"]);
245
246 $newObj->enableRegistrationUserLimit($a_rec["LimitedRegistration"]);
247 $newObj->setRegistrationMaxUsers($a_rec["LimitUsers"]);
248 $newObj->enableRegistrationWaitingList($a_rec["WaitingList"]);
249 }
250
251 $newObj->update();
252
253 $start = new ilDateTime($a_rec["EventStart"], IL_CAL_DATETIME, "UTC");
254 $end = new ilDateTime($a_rec["EventEnd"], IL_CAL_DATETIME, "UTC");
255//echo "<br>".$start->get(IL_CAL_UNIX);
256//echo "<br>".$start->get(IL_CAL_DATETIME);
257 $app = new ilSessionAppointment();
258 $app->setStart($a_rec["EventStart"]);
259 $app->setEnd($a_rec["EventEnd"]);
260 $app->setStartingTime($start->get(IL_CAL_UNIX));
261 $app->setEndingTime($end->get(IL_CAL_UNIX));
262 $app->toggleFullTime($a_rec["Fulltime"]);
263 $app->setSessionId($newObj->getId());
264 $app->create();
265
266 //$newObj->setAppointments(array($app));
267 //$newObj->update();
268
269 $this->current_obj = $newObj;
270 $a_mapping->addMapping("Modules/Session", "sess", $a_rec["Id"], $newObj->getId());
271//var_dump($a_mapping->mappings["Services/News"]["news_context"]);
272 break;
273
274 case "sess_item":
275
276 if($obj_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['ItemId']))
277 {
278 $ref_id = current(ilObject::_getAllReferences($obj_id));
279 include_once './Modules/Session/classes/class.ilEventItems.php';
280 $evi = new ilEventItems($this->current_obj->getId());
281 $evi->addItem($ref_id);
282 $evi->update();
283 }
284 break;
285 }
286 }
287}
288?>
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