ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDataCollectionDataSet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12 
16  protected $db;
20  protected $data = array();
26  protected $record_field_ids_2_storage = array();
46  protected $caches
47  = array(
48  'dcl' => array(),
49  'il_dcl_table' => array(),
50  'il_dcl_field' => array(),
51  'il_dcl_field_prop' => array(),
52  'il_dcl_sel_opts' => array(),
53  'il_dcl_record' => array(),
54  'il_dcl_record_field' => array(),
55  'il_dcl_stloc1_value' => array(),
56  'il_dcl_stloc2_value' => array(),
57  'il_dcl_stloc3_value' => array(),
58  'il_dcl_tfield_set' => array(),
59  'il_dcl_tableview' => array(),
60  'il_dcl_tview_set' => array(),
61  );
65  protected $import_dc_object;
69  protected $count_imported_tables = 0;
75  protected $import_record_field_cache = array();
79  protected $user;
83  protected $import_temp_refs = array();
87  protected $import_temp_refs_props = array();
91  protected $import_temp_new_mob_ids = array();
92 
93 
94  public function __construct()
95  {
96  global $DIC;
97  $ilDB = $DIC['ilDB'];
98  $ilUser = $DIC['ilUser'];
99  parent::__construct();
100  $this->db = $ilDB;
101  $this->user = $ilUser;
102  }
103 
104 
108  public function getSupportedVersions()
109  {
110  return array('4.5.0');
111  }
112 
113 
122  public function getCache($a_entity)
123  {
124  if (!in_array($a_entity, array_keys($this->caches))) {
125  throw new ilException("Entity '$a_entity' does not exist in Cache");
126  }
127 
128  return $this->caches[$a_entity];
129  }
130 
131 
138  public function getXmlNamespace($a_entity, $a_schema_version)
139  {
140  return 'http://www.ilias.de/xml/Modules/DataCollection/' . $a_entity;
141  }
142 
143 
151  public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
152  {
153  switch ($a_entity) {
154  case 'dcl':
155  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['id'])) {
156  $new_obj = ilObjectFactory::getInstanceByObjId($new_id, false);
157  } else {
158  $new_obj = new ilObjDataCollection();
159  $new_obj->create(true);
160  }
161  $new_obj->setTitle($a_rec['title']);
162  $new_obj->setDescription($a_rec['description']);
163  $new_obj->setApproval($a_rec['approval']);
164  $new_obj->setPublicNotes($a_rec['public_notes']);
165  $new_obj->setNotification($a_rec['notification']);
166  $new_obj->setPublicNotes($a_rec['public_notes']);
167  $new_obj->setOnline(false);
168  $new_obj->setRating($a_rec['rating']);
169  $new_obj->update(); //clone mode, so no table will be created
170  $this->import_dc_object = $new_obj;
171  $a_mapping->addMapping('Modules/DataCollection', 'dcl', $a_rec['id'], $new_obj->getId());
172  break;
173  case 'il_dcl_table':
174  $table = new ilDclTable();//($this->count_imported_tables > 0) ? new ilDclTable() : ilDclCache::getTableCache($this->import_dc_object->getMainTableId());
175  $table->setTitle($a_rec['title']);
176  $table->setObjId($this->import_dc_object->getId());
177  $table->setDescription($a_rec['description']);
178  $table->setAddPerm($a_rec['add_perm']);
179  $table->setEditPerm($a_rec['edit_perm']);
180  $table->setDeletePerm($a_rec['delete_perm']);
181  $table->setEditByOwner($a_rec['edit_by_owner']);
182  $table->setLimited($a_rec['limited']);
183  $table->setLimitStart($a_rec['limit_start']);
184  $table->setLimitEnd($a_rec['limit_end']);
185  $table->setIsVisible($a_rec['is_visible']);
186  $table->setExportEnabled($a_rec['export_enabled']);
187  $table->setImportEnabled($a_rec['import_enabled']);
188  $table->setDefaultSortField($a_rec['default_sort_field_id']);
189  $table->setDefaultSortFieldOrder($a_rec['default_sort_field_order']);
190  $table->setPublicCommentsEnabled($a_rec['public_comments']);
191  $table->setViewOwnRecordsPerm($a_rec['view_own_records_perm']);
192  $table->setDeleteByOwner($a_rec['delete_by_owner']);
193  $table->setSaveConfirmation($a_rec['save_confirmation']);
194  $table->setOrder($a_rec['table_order']);
195  $table->doCreate(false, false); // false => Do not create views! They are imported later
196  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['id'], $table->getId());
197  break;
198  case 'il_dcl_tableview':
199  $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
200  if ($new_table_id) {
201  $tableview = new ilDclTableView();
202  $tableview->setTitle($a_rec['title']);
203  $tableview->setTableId($new_table_id);
204  $tableview->setDescription($a_rec['description']);
205  $tableview->setTableviewOrder($a_rec['tableview_order']);
206  if (!is_array($a_rec['roles'])) {
207  $a_rec['roles'] = json_decode($a_rec['roles']);
208  }
209  $tableview->setRoles($a_rec['roles']);
210  $tableview->create(false); //do not create default setting as they are imported too
211  }
212  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_tableview', $a_rec['id'], $tableview->getId());
213  $a_mapping->addMapping('Services/COPage', 'pg', 'dclf:' . $a_rec['id'], 'dclf:' . $tableview->getId());
214  break;
215  case 'il_dcl_field':
216  $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
217  if ($new_table_id) {
218  $field = new ilDclBaseFieldModel();
219  $field->setTableId($new_table_id);
220  $field->setDatatypeId($a_rec['datatype_id']);
221  $field->setTitle($a_rec['title']);
222  $field->setDescription($a_rec['description']);
223  $field->setRequired($a_rec['required']);
224  $field->setUnique($a_rec['is_unique']);
225  $field->setLocked($a_rec['is_locked']);
226  $field->doCreate();
227  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['id'], $field->getId());
228  // Check if this field was used as default order by, if so, update to new id
229  $table = ilDclCache::getTableCache($new_table_id);
230  if ($table && $table->getDefaultSortField() == $a_rec['id']) {
231  $table->setDefaultSortField($field->getId());
232  $table->doUpdate();
233  }
234  }
235  break;
236  case 'il_dcl_tfield_set':
237  $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
238  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field']);
239  if ($new_table_id) {
240  $setting = ilDclTableFieldSetting::getInstance($new_table_id, $new_field_id ? $new_field_id : $a_rec['field']);
241  $setting->setFieldOrder($a_rec['field_order']);
242  $setting->setExportable($a_rec['exportable']);
243  $setting->store();
244  }
245  break;
246  case 'il_dcl_tview_set':
247  $new_tableview_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_tableview', $a_rec['tableview_id']);
248  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field']);
249  if ($new_tableview_id) {
250  $setting = new ilDclTableViewFieldSetting();
251  $setting->setTableviewId($new_tableview_id);
252  $setting->setVisible($a_rec['visible']);
253  $setting->setField($new_field_id ? $new_field_id : $a_rec['field']);
254  $setting->setInFilter($a_rec['in_filter']);
255  $setting->setFilterValue($a_rec['filter_value'] ? $a_rec['filter_value'] : null);
256  $setting->setFilterChangeable($a_rec['filter_changeable']);
257  $setting->create();
258  }
259  break;
260  case 'il_dcl_record':
261  $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
262  if ($new_table_id) {
263  $record = new ilDclBaseRecordModel();
264  $record->setTableId($new_table_id);
265  $datetime = new ilDateTime(time(), IL_CAL_UNIX);
266  $record->setCreateDate($datetime);
267  $record->setLastUpdate($datetime);
268  $record->setOwner($this->user->getId());
269  $record->setLastEditBy($this->user->getId());
270  $record->doCreate();
271  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_record', $a_rec['id'], $record->getId());
272  }
273  break;
274  case 'il_dcl_view':
275  $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
276  if ($new_table_id) {
277  //if import contains il_dcl_view, it must origin from an earlier ILIAS Version and therefore contains no tableviews
278  //->create standard view
279  $tableview = ilDclTableView::createOrGetStandardView($new_table_id);
280  if ($a_rec['type'] == 0 && $a_rec['formtype'] == 0) { //set page_object to tableview
281  // This mapping is needed for the import handled by Services/COPage
282  $a_mapping->addMapping('Services/COPage', 'pg', 'dclf:' . $a_rec['id'], 'dclf:' . $tableview->getId());
283  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_view', $a_rec['id'], $tableview->getId());
284  } else {
285  $a_mapping->addMapping(
286  'Modules/DataCollection',
287  'il_dcl_view',
288  $a_rec['id'],
289  array('type' => $a_rec['type'], 'table_id' => $new_table_id, 'tableview_id' => $tableview->getId())
290  );
291  }
292  }
293  break;
294  case 'il_dcl_viewdefinition':
295  $map = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_view', $a_rec['view_id']);
296  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field']);
297  $field = ($new_field_id) ? $new_field_id : $a_rec['field'];
298  switch ($map['type']) {
299  case 1: //visible
300  $viewfield_setting = ilDclTableViewFieldSetting::getInstance($map['tableview_id'], $field);
301  $viewfield_setting->setVisible($a_rec['is_set']);
302  $viewfield_setting->store();
303  break;
304  case 3: //in_filter
305  $viewfield_setting = ilDclTableViewFieldSetting::getInstance($map['tableview_id'], $field);
306  $viewfield_setting->setInFilter($a_rec['is_set']);
307  $viewfield_setting->store();
308  break;
309  case 4: //exportable
310  $tablefield_setting = ilDclTableFieldSetting::getInstance($map['table_id'], $field);
311  $tablefield_setting->setExportable($a_rec['is_set']);
312  $tablefield_setting->setFieldOrder($a_rec['field_order']);
313  $tablefield_setting->store();
314  break;
315  }
316  break;
317  case 'il_dcl_sel_opts':
318  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field_id']);
319  if ($new_field_id) {
320  $opt = new ilDclSelectionOption();
321  $opt->setFieldId($new_field_id);
322  $opt->setOptId($a_rec['opt_id']);
323  $opt->setSorting($a_rec['sorting']);
324  $opt->setValue($a_rec['value']);
325  $opt->store();
326  }
327  break;
328  case 'il_dcl_field_prop':
329  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field_id']);
330  if ($new_field_id) {
331  $prop = new ilDclFieldProperty();
332  $prop->setFieldId($new_field_id);
333 
334  // OLD IMPORT! Backwards-compatibility
335  $name = $a_rec['name'];
336  if (!isset($name) && isset($a_rec['datatype_prop_id'])) {
337  $properties = array(
338  1 => 'length',
339  2 => 'regex',
340  3 => 'table_id',
341  4 => 'url',
342  5 => 'text_area',
343  6 => 'reference_link',
344  7 => 'width',
345  8 => 'height',
346  9 => 'learning_progress',
347  10 => 'ILIAS_reference_link',
348  11 => 'multiple_selection',
349  12 => 'expression',
350  13 => 'display_action_menu',
351  14 => 'link_detail_page',
352  15 => 'link_detail_page',
353  );
354 
355  $name = $properties[$a_rec['datatype_prop_id']];
356  }
357 
358  $prop->setName($name);
359  // For field references, we need to get the new field id of the referenced field
360  // If the field_id does not yet exist (e.g. referenced table not yet created), store temp info and fix before finishing import
361  $value = $a_rec['value'];
363 
364  if (in_array($prop->getName(), $refs)) {
365  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['value']);
366  if ($new_field_id === false) {
367  $value = null;
368  } else {
369  $value = $new_field_id;
370  }
371  }
372  $prop->setValue($value);
373  $prop->save();
374  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_field_prop', $a_rec['id'], $prop->getId());
375  $this->import_temp_refs_props[$prop->getId()] = $a_rec['value'];
376  }
377  break;
378  case 'il_dcl_record_field':
379  $record_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record', $a_rec['record_id']);
380  $field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field_id']);
381  if ($record_id && $field_id) {
382  $record = ilDclCache::getRecordCache($record_id);
383  $field = ilDclCache::getFieldCache($field_id);
384  $record_field = new ilDclBaseRecordFieldModel($record, $field);
385  $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_record_field', $a_rec['id'], $record_field->getId());
386  $this->import_record_field_cache[$record_field->getId()] = $record_field;
387  }
388  break;
389  case 'il_dcl_stloc1_value':
390  case 'il_dcl_stloc2_value':
391  case 'il_dcl_stloc3_value':
392  $new_record_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record_field', $a_rec['record_field_id']);
393  if ($new_record_field_id) {
395  $record_field = $this->import_record_field_cache[$new_record_field_id];
396  if (is_object($record_field)) {
397  // Need to rewrite internal references and lookup new objects if MOB or File
398  // For some fieldtypes it's better to reset the value, e.g. ILIAS_REF
399  switch ($record_field->getField()->getDatatypeId()) {
401  // Check if we got a mapping from old object
402  $new_mob_id = $a_mapping->getMapping('Services/MediaObjects', 'mob', $a_rec['value']);
403  $value = ($new_mob_id) ? (int) $new_mob_id : null;
404  $this->import_temp_new_mob_ids[] = $new_mob_id;
405  break;
407  $new_file_id = $a_mapping->getMapping('Modules/File', 'file', $a_rec['value']);
408  $value = ($new_file_id) ? (int) $new_file_id : null;
409  break;
412  // If we are referencing to a record from a table that is not yet created, return value is always false because the record does exist neither
413  // Solution: Temporary store all references and fix them before finishing the import.
414  $new_record_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record', $a_rec['value']);
415  $this->import_temp_refs[$new_record_field_id] = $a_rec['value'];
416  $value = ($new_record_id) ? (int) $new_record_id : null;
417  break;
419  $value = null;
420  break;
421  default:
422  $value = $a_rec['value'];
423  if ($a_entity == 'il_dcl_stloc3_value' && (is_null($value) || empty($value))) {
424  $value = '0000-00-00 00:00:00';
425  }
426  }
427  $record_field->setValue($value, true);
428  $record_field->doUpdate();
429  }
430  }
431  break;
432  }
433  }
434 
435 
441  public function beforeFinishImport(ilImportMapping $a_mapping)
442  {
443  foreach ($this->import_temp_new_mob_ids as $new_mob_id) {
444  ilObjMediaObject::_saveUsage($new_mob_id, "dcl:html", $a_mapping->getTargetId());
445  }
446  foreach ($this->import_temp_refs as $record_field_id => $old_record_id) {
447  $new_record_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record', $old_record_id);
448  $value = ($new_record_id) ? (int) $new_record_id : null;
450  $record_field = $this->import_record_field_cache[$record_field_id];
451  $record_field->setValue($value, true);
452  $record_field->doUpdate();
453  }
454  foreach ($this->import_temp_refs_props as $field_prop_id => $old_field_id) {
455  $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $old_field_id);
456  $value = ($new_field_id) ? (int) $new_field_id : null;
457  $field_prop = new ilDclFieldProperty($field_prop_id);
458  $field_prop->setValue($value);
459  $field_prop->update();
460  }
461  }
462 
463 
472  protected function getTypes($a_entity, $a_version)
473  {
474  switch ($a_entity) {
475  case 'dcl':
476  return array(
477  "id" => "integer",
478  "title" => "text",
479  "description" => "text",
480  'is_online' => 'integer',
481  'rating' => 'integer',
482  'public_notes' => 'integer',
483  'approval' => 'integer',
484  'notification' => 'integer',
485  );
486  case 'il_dcl_table':
487  return array(
488  'id' => 'integer',
489  'obj_id' => 'integer',
490  'title' => 'text',
491  'add_perm' => 'integer',
492  'edit_perm' => 'integer',
493  'delete_perm' => 'integer',
494  'edit_by_owner' => 'integer',
495  'limited' => 'integer',
496  'limit_start' => 'text',
497  'limit_end' => 'text',
498  'is_visible' => 'integer',
499  'export_enabled' => 'integer',
500  'import_enabled' => 'integer',
501  'default_sort_field_id' => 'text',
502  'default_sort_field_order' => 'text',
503  'description' => 'text',
504  'public_comments' => 'integer',
505  'view_own_records_perm' => 'integer',
506  'delete_by_owner' => 'integer',
507  'save_confirmation' => 'integer',
508  'table_order' => 'integer',
509  );
510  case 'il_dcl_tableview':
511  return array(
512  'id' => 'integer',
513  'table_id' => 'integer',
514  'title' => 'text',
515  'roles' => 'text',
516  'description' => 'text',
517  'tableview_order' => 'integer',
518  );
519  case 'il_dcl_field':
520  return array(
521  'id' => 'integer',
522  'table_id' => 'integer',
523  'title' => 'text',
524  'description' => 'text',
525  'datatype_id' => 'integer',
526  'required' => 'integer',
527  'is_unique' => 'integer',
528  'is_locked' => 'integer',
529  );
530  case 'il_dcl_tview_set':
531  return array(
532  'id' => 'integer',
533  'tableview_id' => 'integer',
534  'field' => 'text',
535  'visible' => 'integer',
536  'in_filter' => 'integer',
537  'filter_value' => 'text',
538  'filter_changeable' => 'integer',
539  );
540  case 'il_dcl_tfield_set':
541  return array(
542  'id' => 'integer',
543  'table_id' => 'integer',
544  'field' => 'text',
545  'field_order' => 'integer',
546  'exportable' => 'integer',
547  );
548  case 'il_dcl_field_prop':
549  return array(
550  'id' => 'integer',
551  'field_id' => 'integer',
552  'name' => 'text',
553  'value' => 'integer',
554  );
555  case 'il_dcl_sel_opts':
556  return array(
557  'id' => 'integer',
558  'field_id' => 'integer',
559  'opt_id' => 'integer',
560  'sorting' => 'integer',
561  'value' => 'text',
562  );
563  case 'il_dcl_record':
564  return array(
565  'id' => 'integer',
566  'table_id' => 'integer',
567  );
568  case 'il_dcl_record_field':
569  return array(
570  'id' => 'integer',
571  'record_id' => 'integer',
572  'field_id' => 'integer',
573  );
574  case 'il_dcl_stloc1_value':
575  return array(
576  'id' => 'integer',
577  'record_field_id' => 'integer',
578  'value' => 'text',
579  );
580  case 'il_dcl_stloc2_value':
581  return array(
582  'id' => 'integer',
583  'record_field_id' => 'integer',
584  'value' => 'text',
585  );
586  case 'il_dcl_stloc3_value':
587  return array(
588  'id' => 'integer',
589  'record_field_id' => 'integer',
590  'value' => 'text',
591  );
592  default:
593  return array();
594  }
595  }
596 
597 
608  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
609  {
610  if (!$a_rec && !$a_ids) {
611  return false;
612  }
613  switch ($a_entity) {
614  case 'dcl':
615  $set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
616  $ids = $this->buildCache('il_dcl_table', $set);
617 
618  return array(
619  'il_dcl_table' => array('ids' => $ids),
620  );
621  break;
622  case 'il_dcl_table':
623  $set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
624  $ids_records = $this->buildCache('il_dcl_record', $set);
625  $set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
626  $ids_fields = $this->buildCache('il_dcl_field', $set);
627  $set = $this->db->query('SELECT * FROM il_dcl_tableview WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
628  $ids_tableviews = $this->buildCache('il_dcl_tableview', $set);
629  $set = $this->db->query('SELECT * FROM il_dcl_tfield_set WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
630  $ids_tablefield_settings = $this->buildCache('il_dcl_tfield_set', $set);
631 
632  return array(
633  'il_dcl_field' => array('ids' => $ids_fields),
634  'il_dcl_record' => array('ids' => $ids_records),
635  'il_dcl_tableview' => array('ids' => $ids_tableviews),
636  'il_dcl_tfield_set' => array('ids' => $ids_tablefield_settings),
637  );
638  case 'il_dcl_field':
639  $set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
640  $prop_ids = $this->buildCache('il_dcl_field_prop', $set);
641 
642  $set = $this->db->query('SELECT * FROM il_dcl_sel_opts WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
643  $opt_ids = $this->buildCache('il_dcl_sel_opts', $set);
644 
645  return array(
646  'il_dcl_field_prop' => array('ids' => $prop_ids),
647  'il_dcl_sel_opts' => array('ids' => $opt_ids),
648  );
649  case 'il_dcl_record':
650  $sql = 'SELECT rf.*, d.storage_location FROM il_dcl_record_field AS rf' . ' INNER JOIN il_dcl_field AS f ON (f.id = rf.field_id)'
651  . ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
652  . $this->db->quote($a_rec['id'], 'integer');
653  $set = $this->db->query($sql);
654  $ids = $this->buildCache('il_dcl_record_field', $set);
655 
656  $set = $this->db->query($sql);
657  while ($rec = $this->db->fetchObject($set)) {
658  $this->record_field_ids_2_storage[$rec->id] = ilDclCache::getFieldCache($rec->field_id)->getStorageLocation();
659  }
660  // Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
661  $sql
662  = 'SELECT rf.id AS record_field_id, st1.value AS value1, st2.value AS value2, st3.value AS value3 FROM il_dcl_record_field AS rf '
663  . 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
664  . 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
665  . 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
666  . $this->db->quote($a_rec['id'], 'integer');
667  $set = $this->db->query($sql);
668 
669  while ($rec = $this->db->fetchObject($set)) {
670  $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
671  $value = "value{$stloc}";
672  // Save reocrd field id. Internal ID is not used currently
673  $this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
674  'record_field_id' => $rec->record_field_id,
675  'value' => $rec->{$value},
676  );
677  }
678 
679  return array(
680  'il_dcl_record_field' => array('ids' => $ids),
681  );
682  case 'il_dcl_tableview':
683  $set = $this->db->query('SELECT * FROM il_dcl_tview_set WHERE tableview_id = ' . $this->db->quote($a_rec['id'], 'integer'));
684  $ids = $this->buildCache('il_dcl_tview_set', $set);
685 
686  return array(
687  'il_dcl_tview_set' => array('ids' => $ids),
688  );
689  case 'il_dcl_record_field':
690  $record_field_id = $a_rec['id'];
691  $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
692 
693  return array(
694  "il_dcl_stloc{$storage_loc}_value" => array('ids' => array($record_field_id)),
695  );
696  }
697 
698  return false;
699  }
700 
701 
709  public function readData($a_entity, $a_version, $a_ids)
710  {
711  $this->data = array();
712  if (!is_array($a_ids)) {
713  $a_ids = array($a_ids);
714  }
715  $this->_readData($a_entity, $a_ids);
716  }
717 
718 
725  protected function _readData($a_entity, $a_ids)
726  {
727  switch ($a_entity) {
728  case 'dcl':
729  foreach ($a_ids as $dcl_id) {
730  if (ilObject::_lookupType($dcl_id) == 'dcl') {
731  $obj = new ilObjDataCollection($dcl_id, false);
732  $data = array(
733  'id' => $dcl_id,
734  'title' => $obj->getTitle(),
735  'description' => $obj->getDescription(),
736  'is_online' => $obj->getOnline(),
737  'rating' => $obj->getRating(),
738  'public_notes' => $obj->getPublicNotes(),
739  'approval' => $obj->getApproval(),
740  'notification' => $obj->getNotification(),
741  );
742  $this->caches['dcl'][$dcl_id] = $data;
743  $this->data[] = $data;
744  }
745  }
746  break;
747  default:
748  $data = $this->getCache($a_entity);
749  foreach ($a_ids as $id) {
750  $this->data[] = $data[$id];
751  }
752  }
753  }
754 
755 
765  protected function buildCache($a_entity, $set)
766  {
767  $fields = array_keys($this->getTypes($a_entity, ''));
768  $ids = array();
769  while ($rec = $this->db->fetchObject($set)) {
770  $data = array();
771  foreach ($fields as $field) {
772  $data[$field] = $rec->{$field};
773  }
774  $id = $rec->id;
775  $this->caches[$a_entity][$id] = $data;
776  $ids[] = $id;
777  }
778 
779  return $ids;
780  }
781 }
getMapping($a_comp, $a_entity, $a_old_id)
Get a mapping.
_readData($a_entity, $a_ids)
Build data array, data is read from cache except dcl object itself.
Class ilDclBaseFieldModel.
static getInstance($table_id, $field)
readData($a_entity, $a_version, $a_ids)
Read data from Cache for a given entity and ID(s)
global $DIC
Definition: saml.php:7
static getFieldCache($field_id=0)
Class ilDclFieldProperty.
if(!array_key_exists('StateId', $_REQUEST)) $id
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Return dependencies form entities to other entities (in our case these are all the DB relations) ...
getCache($a_entity)
Get cached data from a given entity.
const IL_CAL_UNIX
static getTableCache($table_id=0)
Class ilDclBaseFieldModel.
user()
Definition: user.php:4
Class ilDclTableViewFieldSetting.
static getInstance($tableview_id, $field_id)
buildCache($a_entity, $set)
Helper method to build cache for data of all entities.
DataCollection dataset class.
static getRecordCache($record_id=0)
Class ilDclTableView.
Date and time handling
$ilUser
Definition: imgupload.php:18
getTargetId()
get target id
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static createOrGetStandardView($table_id, $create_default_settings=true)
Class ilDclBaseRecordModel.
$this data['403_header']
global $ilDB
Class ilDclSelectionOption.
getTypes($a_entity, $a_version)
Map XML attributes of entities to datatypes (text, integer...)
if(empty($password)) $table
Definition: pwgen.php:24
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getXmlNamespace($a_entity, $a_schema_version)
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
Class ilObjDataCollection.