ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSessionDataSet Class Reference

Session data set class. More...

+ Inheritance diagram for ilSessionDataSet:
+ Collaboration diagram for ilSessionDataSet:

Public Member Functions

 __construct ()
 
 setTargetId (int $target_id)
 
 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record (export) More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 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 fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
 readDidacticTemplateType ($a_obj_ids)
 
 applyDidacticTemplate (ilObject $rep_object, $tpl_id)
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 

Private Attributes

 $logger = null
 
 $target_id = 0
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

Detailed Description

Session data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilSessionDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilSessionDataSet::__construct ( )

Definition at line 25 of file class.ilSessionDataSet.php.

References $DIC.

26  {
27  global $DIC;
28 
29  parent::__construct();
30  $this->logger = $DIC->logger()->sess();
31  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ applyDidacticTemplate()

ilSessionDataSet::applyDidacticTemplate ( ilObject  $rep_object,
  $tpl_id 
)
protected
Parameters
ilObject$rep_object
$tpl_id

Definition at line 427 of file class.ilSessionDataSet.php.

References $template, ilObject\applyDidacticTemplate(), and ilDidacticTemplateSettings\getInstanceByObjectType().

Referenced by importRecord().

428  {
429  $this->logger->debug('Apply didactic template');
430 
431  if ((int) $tpl_id == 0) {
432  $this->logger->debug('Default permissions');
433  // Default template
434  return;
435  }
436 
437  $templates = ilDidacticTemplateSettings::getInstanceByObjectType('sess')->getTemplates();
438  foreach ($templates as $template) {
439  if ($template->isAutoGenerated()) {
440  $this->logger->debug('Apply first auto generated');
441  $rep_object->applyDidacticTemplate($template->getId());
442  }
443  }
444  }
$template
applyDidacticTemplate($a_tpl_id)
Apply template.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDependencies()

ilSessionDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 286 of file class.ilSessionDataSet.php.

287  {
288  switch ($a_entity) {
289  case "sess":
290  return array(
291  "sess_item" => array("ids" => $a_rec["Id"])
292  );
293  }
294 
295  return false;
296  }

◆ getSupportedVersions()

ilSessionDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

Definition at line 47 of file class.ilSessionDataSet.php.

48  {
49  return array("4.1.0", "5.0.0", "5.1.0", '5.4.0');
50  }

◆ getTypes()

ilSessionDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters

Definition at line 69 of file class.ilSessionDataSet.php.

70  {
71  if ($a_entity == "sess") {
72  switch ($a_version) {
73  case "4.1.0":
74  return array(
75  "Id" => "integer",
76  "Title" => "text",
77  "Description" => "text",
78  "Location" => "text",
79  "TutorName" => "text",
80  "TutorEmail" => "text",
81  "TutorPhone" => "text",
82  "Details" => "text",
83  "Registration" => "integer",
84  "EventStart" => "text",
85  "EventEnd" => "text",
86  "StartingTime" => "integer",
87  "EndingTime" => "integer",
88  "Fulltime" => "integer"
89  );
90  case "5.0.0":
91  return array(
92  "Id" => "integer",
93  "Title" => "text",
94  "Description" => "text",
95  "Location" => "text",
96  "TutorName" => "text",
97  "TutorEmail" => "text",
98  "TutorPhone" => "text",
99  "Details" => "text",
100  "Registration" => "integer",
101  "EventStart" => "text",
102  "EventEnd" => "text",
103  "StartingTime" => "integer",
104  "EndingTime" => "integer",
105  "Fulltime" => "integer",
106  "LimitedRegistration" => "integer",
107  "WaitingList" => "integer",
108  "LimitUsers" => "integer"
109  );
110  case "5.1.0":
111  return array(
112  "Id" => "integer",
113  "Title" => "text",
114  "Description" => "text",
115  "Location" => "text",
116  "TutorName" => "text",
117  "TutorEmail" => "text",
118  "TutorPhone" => "text",
119  "Details" => "text",
120  "Registration" => "integer",
121  "EventStart" => "text",
122  "EventEnd" => "text",
123  "StartingTime" => "integer",
124  "EndingTime" => "integer",
125  "Fulltime" => "integer",
126  "LimitedRegistration" => "integer",
127  "WaitingList" => "integer",
128  "AutoWait" => "integer",
129  "LimitUsers" => "integer",
130  "MinUsers" => "integer"
131  );
132  case "5.4.0":
133  return array(
134  "Id" => "integer",
135  "Title" => "text",
136  "Description" => "text",
137  "Location" => "text",
138  "TutorName" => "text",
139  "TutorEmail" => "text",
140  "TutorPhone" => "text",
141  "Details" => "text",
142  "Registration" => "integer",
143  "EventStart" => "text",
144  "EventEnd" => "text",
145  "StartingTime" => "integer",
146  "EndingTime" => "integer",
147  "Fulltime" => "integer",
148  "LimitedRegistration" => "integer",
149  "WaitingList" => "integer",
150  "AutoWait" => "integer",
151  "LimitUsers" => "integer",
152  "MinUsers" => "integer",
153  'MailMembers' => 'integer',
154  'ShowMembers' => 'integer',
155  'Type' => 'integer'
156  );
157  }
158  }
159 
160  if ($a_entity == "sess_item") {
161  switch ($a_version) {
162  case "4.1.0":
163  case "5.0.0":
164  case "5.1.0":
165  case "5.4.0":
166  return array(
167  "SessionId" => "integer",
168  "ItemId" => "text",
169  );
170  }
171  }
172  }

◆ getXmlNamespace()

ilSessionDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

Definition at line 58 of file class.ilSessionDataSet.php.

59  {
60  return "http://www.ilias.de/xml/Modules/Session/" . $a_entity;
61  }

◆ getXmlRecord()

ilSessionDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record (export)

Parameters
arrayabstract data record
Returns
array xml record

Definition at line 262 of file class.ilSessionDataSet.php.

References ilObject\_lookupObjId().

263  {
264  if ($a_entity == "sess") {
265  // convert server dates to utc
266  if (!$a_set["Fulltime"]) {
267  // nothing has to be done here, since the dates are already stored in UTC
268  #$start = new ilDateTime($a_set["EventStart"], IL_CAL_DATETIME);
269  #$a_set["EventStart"] = $start->get(IL_CAL_DATETIME,'','UTC');
270  #$end = new ilDateTime($a_set["EventEnd"], IL_CAL_DATETIME);
271  #$a_set["EventEnd"] = $end->get(IL_CAL_DATETIME,'','UTC');
272  }
273  }
274  if ($a_entity == "sess_item") {
275  // make ref id an object id
276  $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
277  }
278  return $a_set;
279  }
static _lookupObjId($a_id)
+ Here is the call graph for this function:

◆ importRecord()

ilSessionDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters

Definition at line 305 of file class.ilSessionDataSet.php.

References $end, $start, ilObject\_getAllReferences(), ilEventItems\addItem(), applyDidacticTemplate(), ilObjectFactory\getInstanceByRefId(), IL_CAL_DATETIME, and IL_CAL_UNIX.

306  {
307  switch ($a_entity) {
308  case "sess":
309  include_once("./Modules/Session/classes/class.ilObjSession.php");
310  include_once("./Modules/Session/classes/class.ilSessionAppointment.php");
311 
312  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
313  $refs = ilObject::_getAllReferences($new_id);
314  $newObj = ilObjectFactory::getInstanceByRefId(end($refs), false);
315  } else {
316  $this->logger->debug('Session creation without existing instance');
317  $newObj = new ilObjSession();
318  $newObj->setType("sess");
319  $newObj->create(true);
320  $newObj->createReference();
321  $newObj->putInTree($this->target_id);
322  $newObj->setPermissions($this->target_id);
323  }
324  $newObj->setTitle($a_rec["Title"]);
325  $newObj->setDescription($a_rec["Description"]);
326  $newObj->setLocation($a_rec["Location"]);
327  $newObj->setName($a_rec["TutorName"]);
328  $newObj->setPhone($a_rec["TutorPhone"]);
329  $newObj->setEmail($a_rec["TutorEmail"]);
330  $newObj->setDetails($a_rec["Details"]);
331 
332  switch ($a_schema_version) {
333  case "5.0.0":
334  case "5.1.0":
335  $newObj->setRegistrationType($a_rec["Registration"]);
336 
337  $newObj->enableRegistrationUserLimit($a_rec["LimitedRegistration"]);
338  $newObj->setRegistrationMaxUsers($a_rec["LimitUsers"]);
339  $newObj->enableRegistrationWaitingList($a_rec["WaitingList"]);
340 
341  if (isset($a_rec["MinUsers"])) {
342  $newObj->setRegistrationMinUsers($a_rec["MinUsers"]);
343  }
344 
345  if (isset($a_rec["AutoWait"])) {
346  $newObj->setWaitingListAutoFill($a_rec["AutoWait"]);
347  }
348  break;
349  case '5.4.0':
350  if (isset($a_rec['MailMembers'])) {
351  $newObj->setMailToMembersType($a_rec['MailMembers']);
352  }
353  if (isset($a_rec['ShowMembers'])) {
354  $newObj->setShowMembers($a_rec['ShowMembers']);
355  }
356  $this->applyDidacticTemplate($newObj, $a_rec['Type']);
357  break;
358  }
359 
360  $newObj->update(true);
361 
362  $start = new ilDateTime($a_rec["EventStart"], IL_CAL_DATETIME, "UTC");
363  $end = new ilDateTime($a_rec["EventEnd"], IL_CAL_DATETIME, "UTC");
364 //echo "<br>".$start->get(IL_CAL_UNIX);
365 //echo "<br>".$start->get(IL_CAL_DATETIME);
366  $app = new ilSessionAppointment();
367  $app->setStart($a_rec["EventStart"]);
368  $app->setEnd($a_rec["EventEnd"]);
369  $app->setStartingTime($start->get(IL_CAL_UNIX));
370  $app->setEndingTime($end->get(IL_CAL_UNIX));
371  $app->toggleFullTime($a_rec["Fulltime"]);
372  $app->setSessionId($newObj->getId());
373  $app->create();
374 
375  //$newObj->setAppointments(array($app));
376  //$newObj->update();
377 
378  $this->current_obj = $newObj;
379  $a_mapping->addMapping("Modules/Session", "sess", $a_rec["Id"], $newObj->getId());
380  $a_mapping->addMapping('Services/Object', 'objs', $a_rec['Id'], $newObj->getId());
381  $a_mapping->addMapping('Services/AdvancedMetaData', 'parent', $a_rec['Id'], $newObj->getId());
382  $a_mapping->addMapping(
383  "Services/MetaData",
384  "md",
385  $a_rec["Id"] . ":0:sess",
386  $newObj->getId() . ":0:sess"
387  );
388 
389 
390 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
391  break;
392 
393  case "sess_item":
394 
395  if ($obj_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['ItemId'])) {
396  $ref_id = current(ilObject::_getAllReferences($obj_id));
397  include_once './Modules/Session/classes/class.ilEventItems.php';
398  $evi = new ilEventItems($this->current_obj->getId());
399  $evi->addItem($ref_id);
400  $evi->update();
401  }
402  break;
403  }
404  }
applyDidacticTemplate(ilObject $rep_object, $tpl_id)
const IL_CAL_DATETIME
const IL_CAL_UNIX
static _getAllReferences($a_id)
get all reference ids of object
$start
Definition: bench.php:8
Date and time handling
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
addItem($a_item_ref_id)
Add one item.
class ilEvent
class ilSessionAppointment
+ Here is the call graph for this function:

◆ readData()

ilSessionDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

Definition at line 180 of file class.ilSessionDataSet.php.

References $DIC, $ilDB, ilDataSet\getDirectDataFromQuery(), and readDidacticTemplateType().

181  {
182  global $DIC;
183 
184  $ilDB = $DIC['ilDB'];
185 
186  if (!is_array($a_ids)) {
187  $a_ids = array($a_ids);
188  }
189 
190  if ($a_entity == "sess") {
191  switch ($a_version) {
192  case "4.1.0":
193  $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, od.description description, " .
194  " location, tutor_name, tutor_email, tutor_phone, details, registration, " .
195  " e_start event_start, e_end event_end, starting_time, ending_time, fulltime " .
196  " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
197  " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
198  "WHERE " .
199  $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
200  break;
201  case "5.0.0":
202  $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, " .
203  " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, " .
204  " reg_limited limited_registration, reg_waiting_list waiting_list, " .
205  " reg_limit_users limit_users, " .
206  " e_start event_start, e_end event_end, starting_time, ending_time, fulltime " .
207  " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
208  " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
209  " JOIN object_description odes ON (ev.obj_id = odes.obj_id) " .
210  "WHERE " .
211  $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
212  break;
213  case "5.1.0":
214  $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, " .
215  " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, " .
216  " reg_limited limited_registration, reg_waiting_list waiting_list, reg_auto_wait auto_wait, " .
217  " reg_limit_users limit_users, reg_min_users min_users, " .
218  " e_start event_start, e_end event_end, starting_time, ending_time, fulltime " .
219  " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
220  " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
221  " JOIN object_description odes ON (ev.obj_id = odes.obj_id) " .
222  "WHERE " .
223  $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
224  break;
225  case "5.4.0":
226  $this->getDirectDataFromQuery($q = "SELECT ev.obj_id id, od.title title, odes.description description, " .
227  " location, tutor_name, tutor_email, tutor_phone, details, reg_type registration, " .
228  " reg_limited limited_registration, reg_waiting_list waiting_list, reg_auto_wait auto_wait, " .
229  " reg_limit_users limit_users, reg_min_users min_users, " .
230  " e_start event_start, e_end event_end, starting_time, ending_time, fulltime, mail_members, show_members " .
231  " FROM event ev JOIN object_data od ON (ev.obj_id = od.obj_id) " .
232  " JOIN event_appointment ea ON (ev.obj_id = ea.event_id) " .
233  " JOIN object_description odes ON (ev.obj_id = odes.obj_id) " .
234  "WHERE " .
235  $ilDB->in("ev.obj_id", $a_ids, false, "integer"));
236 
237  $this->readDidacticTemplateType($a_ids);
238  break;
239  }
240  }
241 
242  if ($a_entity == "sess_item") {
243  switch ($a_version) {
244  case "4.1.0":
245  case "5.0.0":
246  case "5.1.0":
247  $this->getDirectDataFromQuery($q = "SELECT event_id session_id, item_id " .
248  " FROM event_items " .
249  "WHERE " .
250  $ilDB->in("event_id", $a_ids, false, "integer"));
251  break;
252  }
253  }
254  }
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 ...
global $DIC
Definition: saml.php:7
global $ilDB
readDidacticTemplateType($a_obj_ids)
+ Here is the call graph for this function:

◆ readDidacticTemplateType()

ilSessionDataSet::readDidacticTemplateType (   $a_obj_ids)
protected
Parameters
int[]$a_obj_ids

Definition at line 409 of file class.ilSessionDataSet.php.

References ilObject\_getAllReferences(), data, and ilDidacticTemplateObjSettings\lookupTemplateId().

Referenced by readData().

410  {
411  $ref_ids = [];
412  $counter = 0;
413  foreach ($a_obj_ids as $obj_id) {
414  $ref_ids = ilObject::_getAllReferences($obj_id);
415  foreach ($ref_ids as $ref_id) {
417  $this->data[$counter++]['Type'] = (int) $tpl_id;
418  break;
419  }
420  }
421  }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
static _getAllReferences($a_id)
get all reference ids of object
$this data['403_header']
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTargetId()

ilSessionDataSet::setTargetId ( int  $target_id)
Parameters
int$target_id

Definition at line 36 of file class.ilSessionDataSet.php.

References $target_id.

37  {
38  $this->target_id = $target_id;
39  }

Field Documentation

◆ $logger

ilSessionDataSet::$logger = null
private

Definition at line 18 of file class.ilSessionDataSet.php.

◆ $target_id

ilSessionDataSet::$target_id = 0
private

Definition at line 23 of file class.ilSessionDataSet.php.

Referenced by setTargetId().


The documentation for this class was generated from the following file: