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();
318 case 'il_dcl_sel_opts':
319 $new_field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'field_id']);
322 $opt->setFieldId($new_field_id);
323 $opt->setOptId($a_rec[
'opt_id']);
324 $opt->setSorting($a_rec[
'sorting']);
325 $opt->setValue($a_rec[
'value']);
329 case 'il_dcl_field_prop':
330 $new_field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'field_id']);
333 $prop->setFieldId($new_field_id);
336 $name = $a_rec[
'name'];
337 if (!isset(
$name) && isset($a_rec[
'datatype_prop_id'])) {
344 6 =>
'reference_link',
347 9 =>
'learning_progress',
348 10 =>
'ILIAS_reference_link',
349 11 =>
'multiple_selection',
351 13 =>
'display_action_menu',
352 14 =>
'link_detail_page',
353 15 =>
'link_detail_page' 356 $name = $properties[$a_rec[
'datatype_prop_id']];
359 $prop->setName(
$name);
362 $value = $a_rec[
'value'];
366 if (in_array($prop->getName(), $refs)) {
367 $new_field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'value']);
368 if ($new_field_id ===
false) {
372 $value = $new_field_id;
375 $prop->setValue($value);
377 $a_mapping->addMapping(
'Modules/DataCollection',
'il_dcl_field_prop', $a_rec[
'id'], $prop->getId());
379 $this->import_temp_refs_props[$prop->getId()] = $a_rec[
'value'];
383 case 'il_dcl_record_field':
384 $record_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_record', $a_rec[
'record_id']);
385 $field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_field', $a_rec[
'field_id']);
386 if ($record_id && $field_id) {
390 $a_mapping->addMapping(
'Modules/DataCollection',
'il_dcl_record_field', $a_rec[
'id'], $record_field->getId());
391 $this->import_record_field_cache[$record_field->getId()] = $record_field;
394 case 'il_dcl_stloc1_value':
395 case 'il_dcl_stloc2_value':
396 case 'il_dcl_stloc3_value':
397 $new_record_field_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_record_field', $a_rec[
'record_field_id']);
398 if ($new_record_field_id) {
400 $record_field = $this->import_record_field_cache[$new_record_field_id];
401 if (is_object($record_field)) {
404 switch ($record_field->getField()->getDatatypeId()) {
407 $new_mob_id = $a_mapping->getMapping(
'Services/MediaObjects',
'mob', $a_rec[
'value']);
408 $value = ($new_mob_id) ? (
int) $new_mob_id : null;
409 $this->import_temp_new_mob_ids[] = $new_mob_id;
412 $new_file_id = $a_mapping->getMapping(
'Modules/File',
'file', $a_rec[
'value']);
413 $value = ($new_file_id) ? (
int) $new_file_id : null;
419 $new_record_id = $a_mapping->getMapping(
'Modules/DataCollection',
'il_dcl_record', $a_rec[
'value']);
420 if ($new_record_id ===
false) {
421 $this->import_temp_refs[$new_record_field_id] = $a_rec[
'value'];
423 $value = ($new_record_id) ? (
int) $new_record_id : null;
429 $value = $a_rec[
'value'];
430 if ($a_entity ==
'il_dcl_stloc3_value' && (is_null($value) || empty($value))) {
431 $value =
'0000-00-00 00:00:00';
434 $record_field->setValue($value,
true);
435 $record_field->doUpdate();
450 foreach ($this->import_temp_new_mob_ids as $new_mob_id) {
453 foreach ($this->import_temp_refs as $record_field_id => $old_record_id) {
454 $new_record_id = $a_mapping->
getMapping(
'Modules/DataCollection',
'il_dcl_record', $old_record_id);
455 $value = ($new_record_id) ? (
int) $new_record_id : null;
457 $record_field = $this->import_record_field_cache[$record_field_id];
458 $record_field->setValue($value,
true);
459 $record_field->doUpdate();
461 foreach ($this->import_temp_refs_props as $field_prop_id => $old_field_id) {
462 $new_field_id = $a_mapping->
getMapping(
'Modules/DataCollection',
'il_dcl_field', $old_field_id);
463 $value = ($new_field_id) ? (
int) $new_field_id : null;
465 $field_prop->setValue($value);
466 $field_prop->update();
486 "description" =>
"text",
487 'is_online' =>
'integer',
488 'rating' =>
'integer',
489 'public_notes' =>
'integer',
490 'approval' =>
'integer',
491 'notification' =>
'integer',
496 'obj_id' =>
'integer',
498 'add_perm' =>
'integer',
499 'edit_perm' =>
'integer',
500 'delete_perm' =>
'integer',
501 'edit_by_owner' =>
'integer',
502 'limited' =>
'integer',
503 'limit_start' =>
'text',
504 'limit_end' =>
'text',
505 'is_visible' =>
'integer',
506 'export_enabled' =>
'integer',
507 'import_enabled' =>
'integer',
508 'default_sort_field_id' =>
'text',
509 'default_sort_field_order' =>
'text',
510 'description' =>
'text',
511 'public_comments' =>
'integer',
512 'view_own_records_perm' =>
'integer',
513 'delete_by_owner' =>
'integer',
514 'save_confirmation' =>
'integer',
515 'table_order' =>
'integer',
517 case 'il_dcl_tableview':
520 'table_id' =>
'integer',
523 'description' =>
'text',
524 'tableview_order' =>
'integer',
529 'table_id' =>
'integer',
531 'description' =>
'text',
532 'datatype_id' =>
'integer',
533 'required' =>
'integer',
534 'is_unique' =>
'integer',
535 'is_locked' =>
'integer',
537 case 'il_dcl_tview_set':
540 'tableview_id' =>
'integer',
542 'visible' =>
'integer',
543 'in_filter' =>
'integer',
544 'filter_value' =>
'text',
545 'filter_changeable' =>
'integer',
547 case 'il_dcl_tfield_set':
550 'table_id' =>
'integer',
552 'field_order' =>
'integer',
553 'exportable' =>
'integer',
555 case 'il_dcl_field_prop':
558 'field_id' =>
'integer',
560 'value' =>
'integer',
562 case 'il_dcl_sel_opts':
565 'field_id' =>
'integer',
566 'opt_id' =>
'integer',
567 'sorting' =>
'integer',
570 case 'il_dcl_record':
573 'table_id' =>
'integer',
575 case 'il_dcl_record_field':
578 'record_id' =>
'integer',
579 'field_id' =>
'integer',
581 case 'il_dcl_stloc1_value':
584 'record_field_id' =>
'integer',
587 case 'il_dcl_stloc2_value':
590 'record_field_id' =>
'integer',
593 case 'il_dcl_stloc3_value':
596 'record_field_id' =>
'integer',
617 if (!$a_rec && !$a_ids) {
622 $set = $this->db->query(
'SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec[
'id'],
'integer') .
' ORDER BY id');
623 $ids = $this->
buildCache(
'il_dcl_table', $set);
626 'il_dcl_table' =>
array(
'ids' => $ids ),
630 $set = $this->db->query(
'SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
631 $ids_records = $this->
buildCache(
'il_dcl_record', $set);
632 $set = $this->db->query(
'SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
633 $ids_fields = $this->
buildCache(
'il_dcl_field', $set);
634 $set = $this->db->query(
'SELECT * FROM il_dcl_tableview WHERE table_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
635 $ids_tableviews = $this->
buildCache(
'il_dcl_tableview', $set);
636 $set = $this->db->query(
'SELECT * FROM il_dcl_tfield_set WHERE table_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
637 $ids_tablefield_settings = $this->
buildCache(
'il_dcl_tfield_set', $set);
640 'il_dcl_field' =>
array(
'ids' => $ids_fields ),
641 'il_dcl_record' =>
array(
'ids' => $ids_records ),
642 'il_dcl_tableview' =>
array(
'ids' => $ids_tableviews ),
643 'il_dcl_tfield_set' =>
array(
'ids' => $ids_tablefield_settings ),
646 $set = $this->db->query(
'SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
647 $prop_ids = $this->
buildCache(
'il_dcl_field_prop', $set);
649 $set = $this->db->query(
'SELECT * FROM il_dcl_sel_opts WHERE field_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
650 $opt_ids = $this->
buildCache(
'il_dcl_sel_opts', $set);
653 'il_dcl_field_prop' =>
array(
'ids' => $prop_ids ),
654 'il_dcl_sel_opts' =>
array(
'ids' => $opt_ids ),
656 case 'il_dcl_record':
657 $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)' 658 .
' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' .
' WHERE rf.record_id = ' 659 . $this->db->quote($a_rec[
'id'],
'integer');
660 $set = $this->db->query($sql);
661 $ids = $this->
buildCache(
'il_dcl_record_field', $set);
663 $set = $this->db->query($sql);
664 while ($rec = $this->db->fetchObject($set)) {
669 '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 ' 670 .
'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) ' 671 .
'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) ' 672 .
'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' .
'WHERE rf.record_id = ' 673 . $this->db->quote($a_rec[
'id'],
'integer');
674 $set = $this->db->query($sql);
676 while ($rec = $this->db->fetchObject($set)) {
677 $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
678 $value =
"value{$stloc}";
680 $this->caches[
"il_dcl_stloc{$stloc}_value"][$rec->record_field_id] =
array(
681 'record_field_id' => $rec->record_field_id,
682 'value' => $rec->{$value}
687 'il_dcl_record_field' =>
array(
'ids' => $ids )
689 case 'il_dcl_tableview':
690 $set = $this->db->query(
'SELECT * FROM il_dcl_tview_set WHERE tableview_id = ' . $this->db->quote($a_rec[
'id'],
'integer'));
691 $ids = $this->
buildCache(
'il_dcl_tview_set', $set);
694 'il_dcl_tview_set' =>
array(
'ids' => $ids )
696 case 'il_dcl_record_field':
697 $record_field_id = $a_rec[
'id'];
698 $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
701 "il_dcl_stloc{$storage_loc}_value" =>
array(
'ids' =>
array( $record_field_id ) )
716 public function readData($a_entity, $a_version, $a_ids)
719 if (!is_array($a_ids)) {
720 $a_ids =
array( $a_ids );
736 foreach ($a_ids as $dcl_id) {
741 'title' => $obj->getTitle(),
742 'description' => $obj->getDescription(),
743 'is_online' => $obj->getOnline(),
744 'rating' => $obj->getRating(),
745 'public_notes' => $obj->getPublicNotes(),
746 'approval' => $obj->getApproval(),
747 'notification' => $obj->getNotification(),
749 $this->caches[
'dcl'][$dcl_id] =
$data;
756 foreach ($a_ids as
$id) {
774 $fields = array_keys($this->
getTypes($a_entity,
''));
776 while ($rec = $this->db->fetchObject($set)) {
778 foreach ($fields as $field) {
779 $data[$field] = $rec->{$field};
782 $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
Create styles array
The data for the language used.
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
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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.