diff --git a/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyFieldModel.php new file mode 100644 index 000000000000..6fc1d5f175b3 --- /dev/null +++ b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyFieldModel.php @@ -0,0 +1,44 @@ +getId()} ON (filter_record_field_{$this->getId()}.record_id = record.id AND filter_record_field_{$this->getId()}.field_id = " + . $this->db->quote($this->getId(), 'integer') . ") "; + $join_str .= "INNER JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS filter_stloc_{$this->getId()} ON (filter_stloc_{$this->getId()}.record_field_id = filter_record_field_{$this->getId()}.id AND filter_stloc_{$this->getId()}.value LIKE " + . $this->db->quote("%$filter_value%", 'text') . ") "; + + $sql_obj = new ilDclRecordQueryObject(); + $sql_obj->setJoinStatement($join_str); + + return $sql_obj; + } + + public function getValidFieldProperties(): array + { + return [ + ilDclBaseFieldModel::PROP_REFERENCE, + ilDclBaseFieldModel::PROP_N_REFERENCE + ]; + } +} diff --git a/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyFieldRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyFieldRepresentation.php new file mode 100644 index 000000000000..48214239c91f --- /dev/null +++ b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyFieldRepresentation.php @@ -0,0 +1,134 @@ +getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) { + $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId()); + } else { + $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId()); + } + + $this->setupInputField($input, $this->getField()); + + $options = []; + if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) { + $options[''] = $this->lng->txt('dcl_please_select'); + } + + $value = null; + $copy_id = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE); + $copy_field = ilDclCache::getFieldCache($copy_id); + if ($copy_field->getTableId() !== 0) { + $copy_table = ilDclCache::getTableCache($copy_field->getTableId()); + foreach ($copy_table->getRecords() as $record) { + $option = $record->getRecordField($copy_field->getId())->getPlainText(); + if (!in_array($option, $options)) { + $options[$option] = $option; + } + } + } else { + $input->setAlert($this->lng->txt('dcl_origin_not_found')); + } + + if ($record_id !== null) { + $value = ilDclCache::getRecordCache($record_id)->getRecordFieldValue($this->getField()->getId()); + if ($value !== '' && !array_key_exists($value, $options)) { + $options[$value] = $value . ' ' . $this->lng->txt('dcl_deprecated_copy'); + } + } + + $input->setOptions($options); + + return $input; + } + + public function addFilterInputFieldToTable(ilTable2GUI $table) + { + $input = $table->addFilterItemByMetaType( + "filter_" . $this->getField()->getId(), + ilTable2GUI::FILTER_TEXT, + false, + $this->getField()->getId() + ); + $input->setSubmitFormOnEnter(true); + + $this->setupFilterInputField($input); + + return $this->getFilterInputFieldValue($input); + } + + public function passThroughFilter(ilDclBaseRecordModel $record, $filter): bool + { + $pass = parent::passThroughFilter($record, $filter); + + $value = $record->getRecordFieldValue($this->getField()->getId()); + if (!$filter || strpos(strtolower($value), strtolower($filter)) !== false) { + $pass = true; + } + + return $pass; + } + + protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption + { + $datetype_title = $this->getField()->getDatatype()->getTitle(); + if ($datetype_title === 'copy') { + $datetype_title = 'copy_field'; + } + $opt = new ilRadioOption($this->lng->txt('dcl_' . $datetype_title), $this->getField()->getDatatypeId()); + $opt->setInfo($this->lng->txt('dcl_' . $datetype_title . '_desc')); + + $options = []; + $tables = $dcl->getTables(); + foreach ($tables as $table) { + foreach ($table->getRecordFields() as $field) { + if (in_array($field->getDatatypeId(), self::VALID_TYPES)) { + $options[$field->getId()] = $table->getTitle() . ' -> ' . $field->getTitle(); + } + } + } + + $prop_table_selection = new ilSelectInputGUI( + $this->lng->txt('dcl_copy_title'), + 'prop_' . ilDclBaseFieldModel::PROP_REFERENCE + ); + $prop_table_selection->setOptions($options); + $opt->addSubItem($prop_table_selection); + + $prop_multi_select = new ilDclCheckboxInputGUI( + $this->lng->txt('dcl_multiple_selection'), + 'prop_' . ilDclBaseFieldModel::PROP_N_REFERENCE + ); + $opt->addSubItem($prop_multi_select); + + return $opt; + } +} diff --git a/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyRecordFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyRecordFieldModel.php new file mode 100644 index 000000000000..d1eb1abdf956 --- /dev/null +++ b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyRecordFieldModel.php @@ -0,0 +1,34 @@ +getInput('field_' . $this->getField()->getId()); + if (is_array($value)) { + $value = implode(', ', $value); + } + $this->setValue($value); + } +} diff --git a/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyRecordRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyRecordRepresentation.php new file mode 100644 index 000000000000..b10710beeeb6 --- /dev/null +++ b/components/ILIAS/DataCollection/classes/Fields/Copy/class.ilDclCopyRecordRepresentation.php @@ -0,0 +1,29 @@ +getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) { + $value = [$value]; + } + + return parent::parseFormInput($value); + } +} diff --git a/components/ILIAS/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php b/components/ILIAS/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php index 6dd6cdf4dd06..191ef7681070 100755 --- a/components/ILIAS/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php +++ b/components/ILIAS/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php @@ -288,4 +288,26 @@ public function step_16(): void [ilDclDatatype::INPUTFORMAT_PLUGIN] ); } + + public function step_17(): void + { + $id = false; + $stmt = $this->db->queryF('SELECT id FROM il_dcl_datatype WHERE id LIKE %s', [ilDBConstants::T_INTEGER], [17]); + if ($row = $this->db->fetchAssoc($stmt)) { + $id = true; + } + + if (!$id) { + $this->db->insert( + 'il_dcl_datatype', + [ + 'id' => [ilDBConstants::T_INTEGER, 17], + 'title' => [ilDBConstants::T_TEXT, 'copy'], + 'ildb_type' => [ilDBConstants::T_TEXT, ilDBConstants::T_TEXT], + 'storage_location' => [ilDBConstants::T_INTEGER, 1], + 'sort' => [ilDBConstants::T_INTEGER, 85], + ] + ); + } + } } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 9dc01b31db66..c32b8b28b5d3 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -8608,6 +8608,9 @@ dcl#:#dcl_confirm_delete_table#:#Wollen Sie diese Tabelle einschließlich Inhalt dcl#:#dcl_confirm_storing_records#:#Bitte überprüfen Sie die Angaben vor dem Speichern. dcl#:#dcl_confirm_storing_records_no_permission#:#Sie haben keine Rechte, den Datensatz später nochmals zu bearbeiten. dcl#:#dcl_copy#:#Datensammlung kopieren +dcl#:#dcl_copy_field#:#Kopie +dcl#:#dcl_copy_field_desc#:#Kopieren von Auswahloptionen, die in einem anderen Feld einer Tabelle gepflegt werden +dcl#:#dcl_copy_title#:#Kopie von Tabelle und Feld dcl#:#dcl_create_date#:#Erstellungsdatum dcl#:#dcl_create_entry_rules#:#Eintragserstellung dcl#:#dcl_create_field#:#Feld hinzufügen @@ -8632,6 +8635,7 @@ dcl#:#dcl_delete_tables_no_selection#:#Zum Löschen muss mindestens eine Tabelle dcl#:#dcl_delete_views#:#Ansichten löschen dcl#:#dcl_delete_views_no_selection#:#Zum Löschen muss mindestens eine Ansicht ausgewählt werden. dcl#:#dcl_deleted_records#:#Es wurden %s Datensätze gelöscht. +dcl#:#dcl_deprecated_copy#:#(Veraltet) dcl#:#dcl_desc#:#Absteigend ↓ dcl#:#dcl_description#:#Beschreibung dcl#:#dcl_detailed_view#:#Einzelansicht @@ -8757,6 +8761,7 @@ dcl#:#dcl_number#:#Ganze Zahlen dcl#:#dcl_number_desc#:#Eingabe ganzer Zahlen mit bis zu 9 Ziffern. Nicht erlaubt sind Brüche und Dezimalzahlen. dcl#:#dcl_online_info#:#Datensammlung ist veröffentlicht und kann von allen Personen mit dem Recht „Lesezugriff" und „Eintragen" genutzt werden. Andernfalls ist das Objekt nur für Personen mit dem Recht „Einstellungen bearbeiten" verfügbar. dcl#:#dcl_order#:#Sortierung +dcl#:#dcl_origin_not_found#:#Urprungsfeld konnte nicht gefunden werden! dcl#:#dcl_own_entries#:#Nur eigene Einträge dcl#:#dcl_owner#:#Eigener Eintrag von dcl#:#dcl_owner_description#:#Eigene Einträge bleiben stets sichtbar. diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index e3ffd435689e..71a513850608 100755 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -8609,6 +8609,9 @@ dcl#:#dcl_confirm_delete_table#:#Do you really want to delete this table with it dcl#:#dcl_confirm_storing_records#:#Please validate and confirm your input. dcl#:#dcl_confirm_storing_records_no_permission#:#You have no permission to change the record afterwards. dcl#:#dcl_copy#:#Copy Data Collection +dcl#:#dcl_copy_field#:#Copy +dcl#:#dcl_copy_field_desc#:#Field to copy options stored in a different field of a table. +dcl#:#dcl_copy_title#:#Copy of table and field dcl#:#dcl_create_date#:#Creation Date dcl#:#dcl_create_entry_rules#:#Entry Creation dcl#:#dcl_create_field#:#Create Field @@ -8633,6 +8636,7 @@ dcl#:#dcl_delete_tables_no_selection#:#Please select at least one table to delet dcl#:#dcl_delete_views#:#Delete Views dcl#:#dcl_delete_views_no_selection#:#Please select at least one view to delete dcl#:#dcl_deleted_records#:#Successfully deleted %s Entries +dcl#:#dcl_deprecated_copy#:#(Deprecated) dcl#:#dcl_desc#:#Descending Order (DESC) dcl#:#dcl_description#:#Field Description dcl#:#dcl_detailed_view#:#Single @@ -8758,6 +8762,7 @@ dcl#:#dcl_number#:#Integer dcl#:#dcl_number_desc#:#Field for integer values (max. 9 digits). No decimals or fractions. dcl#:#dcl_online_info#:#Only if the Data Collection is online, users are able to use the Data Collection. dcl#:#dcl_order#:#Order +dcl#:#dcl_origin_not_found#:#Origin field was not found! dcl#:#dcl_own_entries#:#Only own entries dcl#:#dcl_owner#:#Owner dcl#:#dcl_owner_description#:#The owner of the entry.