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(),
99 parent::__construct();
110 return array(
'4.5.0');
124 if (!in_array($a_entity, array_keys($this->caches))) {
125 throw new ilException(
"Entity '$a_entity' does not exist in Cache");
128 return $this->caches[$a_entity];
140 return 'http://www.ilias.de/xml/Modules/DataCollection/' . $a_entity;
151 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
155 if ($new_id = $a_mapping->getMapping(
'Services/Container',
'objs', $a_rec[
'id'])) {
159 $new_obj->create(
true);
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']);
170 $this->import_dc_object = $new_obj;
171 $a_mapping->addMapping(
'Modules/DataCollection',
'dcl', $a_rec[
'id'], $new_obj->getId());
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);
196 $a_mapping->addMapping(
'Modules/DataCollection',
'il_dcl_table', $a_rec[
'id'],
$table->getId());
198 case 'il_dcl_tableview':
199 $new_table_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_table', $a_rec[
'table_id']);
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']);
209 $tableview->setRoles($a_rec[
'roles']);
210 $tableview->create(
false);
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());
216 $new_table_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_table', $a_rec[
'table_id']);
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']);
227 $a_mapping->addMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'id'], $field->getId());
230 if (
$table &&
$table->getDefaultSortField() == $a_rec[
'id']) {
231 $table->setDefaultSortField($field->getId());
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']);
241 $setting->setFieldOrder($a_rec[
'field_order']);
242 $setting->setExportable($a_rec[
'exportable']);
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) {
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']);
260 case 'il_dcl_record':
261 $new_table_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_table', $a_rec[
'table_id']);
264 $record->setTableId($new_table_id);
266 $record->setCreateDate($datetime);
267 $record->setLastUpdate($datetime);
268 $record->setOwner($this->
user->getId());
269 $record->setLastEditBy($this->
user->getId());
271 $a_mapping->addMapping(
'Modules/DataCollection',
'il_dcl_record', $a_rec[
'id'], $record->getId());
275 $new_table_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_table', $a_rec[
'table_id']);
280 if ($a_rec[
'type'] == 0 && $a_rec[
'formtype'] == 0) {
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());
285 $a_mapping->addMapping(
286 'Modules/DataCollection',
289 array(
'type' => $a_rec[
'type'],
'table_id' => $new_table_id,
'tableview_id' => $tableview->getId())
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']) {
301 $viewfield_setting->setVisible($a_rec[
'is_set']);
302 $viewfield_setting->store();
306 $viewfield_setting->setInFilter($a_rec[
'is_set']);
307 $viewfield_setting->store();
311 $tablefield_setting->setExportable($a_rec[
'is_set']);
312 $tablefield_setting->setFieldOrder($a_rec[
'field_order']);
313 $tablefield_setting->store();
317 case 'il_dcl_sel_opts':
318 $new_field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'field_id']);
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']);
328 case 'il_dcl_field_prop':
329 $new_field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'field_id']);
332 $prop->setFieldId($new_field_id);
335 $name = $a_rec[
'name'];
336 if (!isset(
$name) && isset($a_rec[
'datatype_prop_id'])) {
343 6 =>
'reference_link',
346 9 =>
'learning_progress',
347 10 =>
'ILIAS_reference_link',
348 11 =>
'multiple_selection',
350 13 =>
'display_action_menu',
351 14 =>
'link_detail_page',
352 15 =>
'link_detail_page',
355 $name = $properties[$a_rec[
'datatype_prop_id']];
358 $prop->setName(
$name);
361 $value = $a_rec[
'value'];
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) {
369 $value = $new_field_id;
372 $prop->setValue($value);
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'];
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) {
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;
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)) {
399 switch ($record_field->getField()->getDatatypeId()) {
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;
407 $new_file_id = $a_mapping->getMapping(
'Modules/File',
'file', $a_rec[
'value']);
408 $value = ($new_file_id) ? (
int) $new_file_id : null;
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;
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';
427 $record_field->setValue($value,
true);
428 $record_field->doUpdate();
443 foreach ($this->import_temp_new_mob_ids as $new_mob_id) {
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();
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;
458 $field_prop->setValue($value);
459 $field_prop->update();
479 "description" =>
"text",
480 'is_online' =>
'integer',
481 'rating' =>
'integer',
482 'public_notes' =>
'integer',
483 'approval' =>
'integer',
484 'notification' =>
'integer',
489 'obj_id' =>
'integer',
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',
510 case 'il_dcl_tableview':
513 'table_id' =>
'integer',
516 'description' =>
'text',
517 'tableview_order' =>
'integer',
522 'table_id' =>
'integer',
524 'description' =>
'text',
525 'datatype_id' =>
'integer',
526 'required' =>
'integer',
527 'is_unique' =>
'integer',
528 'is_locked' =>
'integer',
530 case 'il_dcl_tview_set':
533 'tableview_id' =>
'integer',
535 'visible' =>
'integer',
536 'in_filter' =>
'integer',
537 'filter_value' =>
'text',
538 'filter_changeable' =>
'integer',
540 case 'il_dcl_tfield_set':
543 'table_id' =>
'integer',
545 'field_order' =>
'integer',
546 'exportable' =>
'integer',
548 case 'il_dcl_field_prop':
551 'field_id' =>
'integer',
553 'value' =>
'integer',
555 case 'il_dcl_sel_opts':
558 'field_id' =>
'integer',
559 'opt_id' =>
'integer',
560 'sorting' =>
'integer',
563 case 'il_dcl_record':
566 'table_id' =>
'integer',
568 case 'il_dcl_record_field':
571 'record_id' =>
'integer',
572 'field_id' =>
'integer',
574 case 'il_dcl_stloc1_value':
577 'record_field_id' =>
'integer',
580 case 'il_dcl_stloc2_value':
583 'record_field_id' =>
'integer',
586 case 'il_dcl_stloc3_value':
589 'record_field_id' =>
'integer',
610 if (!$a_rec && !$a_ids) {
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);
619 'il_dcl_table' => array(
'ids' => $ids),
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);
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),
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);
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);
646 'il_dcl_field_prop' => array(
'ids' => $prop_ids),
647 'il_dcl_sel_opts' => array(
'ids' => $opt_ids),
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);
656 $set = $this->db->query($sql);
657 while ($rec = $this->db->fetchObject($set)) {
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);
669 while ($rec = $this->db->fetchObject($set)) {
670 $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
671 $value =
"value{$stloc}";
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},
680 'il_dcl_record_field' => array(
'ids' => $ids),
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);
687 'il_dcl_tview_set' => array(
'ids' => $ids),
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];
694 "il_dcl_stloc{$storage_loc}_value" => array(
'ids' => array($record_field_id)),
709 public function readData($a_entity, $a_version, $a_ids)
711 $this->
data = array();
712 if (!is_array($a_ids)) {
713 $a_ids = array($a_ids);
729 foreach ($a_ids as $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(),
742 $this->caches[
'dcl'][$dcl_id] =
$data;
749 foreach ($a_ids as
$id) {
767 $fields = array_keys($this->
getTypes($a_entity,
''));
769 while ($rec = $this->db->fetchObject($set)) {
771 foreach ($fields as $field) {
772 $data[$field] = $rec->{$field};
775 $this->caches[$a_entity][
$id] =
$data;
$record_field_ids_2_storage
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)
Class ilDclBaseFieldModel.
readData($a_entity, $a_version, $a_ids)
Read data from Cache for a given entity and ID(s)
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) ...
const INPUTFORMAT_REFERENCELIST
getCache($a_entity)
Get cached data from a given entity.
static getTableCache($table_id=0)
Class ilDclBaseFieldModel.
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)
getTargetId()
get target id
const INPUTFORMAT_ILIAS_REF
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)
const INPUTFORMAT_REFERENCE
Class ilDclBaseRecordModel.
Class ilDclSelectionOption.
$import_record_field_cache
getTypes($a_entity, $a_version)
Map XML attributes of entities to datatypes (text, integer...)
if(empty($password)) $table
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getXmlNamespace($a_entity, $a_schema_version)
Class ilObjDataCollection.