/**
  * Execute any math functions inside a token
  *
  * @param string $token
  *
  * @return string
  */
 protected function calculateFunctions($token)
 {
     if (isset(self::$cache_math_function_tokens[$this->field->getId()][$token])) {
         $result = self::$cache_math_function_tokens[$this->field->getId()][$token];
         if ($result === false) {
             return $token;
         }
     } else {
         $pattern = '#';
         foreach (self::getFunctions() as $function) {
             $pattern .= "({$function})\\(([^)]*)\\)|";
         }
         if (!preg_match_all(rtrim($pattern, '|') . '#', $token, $result)) {
             // No functions found inside token, just return token again
             self::$cache_math_function_tokens[$this->field->getId()][$token] = false;
             return $token;
         }
     }
     // Function found inside token, calculate!
     foreach ($result[0] as $k => $to_replace) {
         $function_args = $this->getFunctionArgs($k, $result);
         $function = $function_args['function'];
         $args = $this->substituteFieldValues($function_args['args']);
         $token = str_replace($to_replace, $this->calculateFunction($function, $args), $token);
     }
     return $token;
 }
 /**
  * Load the value
  */
 protected function loadValue()
 {
     if ($this->value === NULL) {
         $datatype = $this->field->getDatatype();
         $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = " . $this->db->quote($this->id, "integer");
         $set = $this->db->query($query);
         $rec = $this->db->fetchAssoc($set);
         $this->value = $rec['value'];
     }
 }
 /**
  * Load the value
  */
 protected function loadValue()
 {
     if ($this->value === NULL) {
         $datatype = $this->field->getDatatype();
         switch ($datatype->getId()) {
             case ilDataCollectionDatatype::INPUTFORMAT_RATING:
                 return true;
         }
         $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = " . $this->db->quote($this->id, "integer");
         $set = $this->db->query($query);
         $rec = $this->db->fetchAssoc($set);
         $this->value = $rec['value'];
     }
 }
 /**
  * @param ilDataCollectionField $a_set
  */
 public function fillRow(ilDataCollectionField $a_set)
 {
     global $lng, $ilCtrl;
     if (!$a_set->isStandardField()) {
         $this->tpl->setVariable('FIELD_ID', $a_set->getId());
     }
     $this->tpl->setVariable('NAME', 'order[' . $a_set->getId() . ']');
     $this->tpl->setVariable('VALUE', $this->order);
     $this->tpl->setVariable('CHECKBOX_VISIBLE', 'visible[' . $a_set->getId() . ']');
     if ($a_set->isVisible()) {
         $this->tpl->setVariable('CHECKBOX_VISIBLE_CHECKED', 'checked');
     }
     /* Don't enable setting filter for MOB fields or reference fields that reference a MOB field */
     $show_filter = true;
     $show_exportable = true;
     if ($a_set->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB || $a_set->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE) {
         $show_filter = false;
     }
     if ($a_set->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
         $ref_field = ilDataCollectionCache::getFieldCache((int) $a_set->getFieldRef());
         if ($ref_field && ($ref_field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB || $ref_field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE)) {
             $show_filter = false;
         }
     }
     if ($a_set->getId() == 'comments') {
         $show_filter = false;
         $show_exportable = false;
     }
     if ($show_filter) {
         $this->tpl->setVariable('CHECKBOX_FILTERABLE', 'filterable[' . $a_set->getId() . ']');
         if ($a_set->isFilterable()) {
             $this->tpl->setVariable('CHECKBOX_FILTERABLE_CHECKED', 'checked');
         }
     } else {
         $this->tpl->setVariable('NO_FILTER', '');
     }
     if ($show_exportable) {
         $this->tpl->setVariable('CHECKBOX_EXPORTABLE', 'exportable[' . $a_set->getId() . ']');
         if ($a_set->getExportable()) {
             $this->tpl->setVariable('CHECKBOX_EXPORTABLE_CHECKED', 'checked');
         }
     } else {
         $this->tpl->setVariable('NO_FILTER_EXPORTABLE', '');
     }
     if (!$a_set->isStandardField()) {
         $this->tpl->setVariable('CHECKBOX_NAME_LOCKED', 'locked[' . $a_set->getId() . ']');
         if ($a_set->getLocked()) {
             $this->tpl->setVariable('CHECKBOX_CHECKED_LOCKED', 'checked');
         }
     } else {
         $this->tpl->setVariable('NOT_LOCKED', '');
     }
     $this->order = $this->order + 10;
     $this->tpl->setVariable('ORDER_NAME', 'order[' . $a_set->getId() . ']');
     $this->tpl->setVariable('ORDER_VALUE', $this->order);
     $this->tpl->setVariable('TITLE', $a_set->getTitle());
     $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
     $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
     if (!$a_set->isStandardField()) {
         switch ($a_set->getRequired()) {
             case 0:
                 $required = ilUtil::getImagePath('icon_not_ok.svg');
                 break;
             case 1:
                 $required = ilUtil::getImagePath('icon_ok.svg');
                 break;
         }
         switch ($a_set->isUnique()) {
             case 0:
                 $uniq = ilUtil::getImagePath('icon_not_ok.svg');
                 break;
             case 1:
                 $uniq = ilUtil::getImagePath('icon_ok.svg');
                 break;
         }
         $this->tpl->setVariable('REQUIRED', $required);
         $this->tpl->setVariable('UNIQUE', $uniq);
     } else {
         $this->tpl->setVariable('NO_REQUIRED', '');
         $this->tpl->setVariable('NO_UNIQUE', '');
     }
     $ilCtrl->setParameterByClass('ildatacollectionfieldeditgui', 'field_id', $a_set->getId());
     if (!$a_set->isStandardField()) {
         include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
         $alist = new ilAdvancedSelectionListGUI();
         $alist->setId($a_set->getId());
         $alist->setListTitle($lng->txt('actions'));
         if ($this->table->hasPermissionToFields($this->parent_obj->parent_obj->ref_id)) {
             $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass('ildatacollectionfieldeditgui', 'edit'));
             $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass('ildatacollectionfieldeditgui', 'confirmDelete'));
         }
         $this->tpl->setVariable('ACTIONS', $alist->getHTML());
     }
 }
 /**
  * Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollection; $x->cloneStructure($id))
  *
  * @param $original_id The original ID of the dataselection you want to clone it's structure
  */
 public function cloneStructure($original_id)
 {
     $original = new ilObjDataCollection($original_id);
     $this->setApproval($original->getApproval());
     $this->setNotification($original->getNotification());
     $this->setPublicNotes($original->getPublicNotes());
     $this->setRating($original->getRating());
     // delete old tables.
     foreach ($this->getTables() as $table) {
         $table->doDelete(true);
     }
     // add new tables.
     foreach ($original->getTables() as $table) {
         $new_table = new ilDataCollectionTable();
         $new_table->setObjId($this->getId());
         $new_table->cloneStructure($table);
         if ($table->getId() == $original->getMainTableId()) {
             $this->setMainTableId($new_table->getId());
         }
     }
     // update because maintable id is now set.
     $this->doUpdate();
     // Set new field-ID of referenced fields
     foreach ($original->getTables() as $origTable) {
         foreach ($origTable->getRecordFields() as $origField) {
             if ($origField->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
                 $newRefId = NULL;
                 $origFieldRefObj = ilDataCollectionCache::getFieldCache($origField->getFieldRef());
                 $origRefTable = ilDataCollectionCache::getTableCache($origFieldRefObj->getTableId());
                 // Lookup the new ID of the referenced field in the actual DC
                 $tableId = ilDataCollectionTable::_getTableIdByTitle($origRefTable->getTitle(), $this->getId());
                 $fieldId = ilDataCollectionField::_getFieldIdByTitle($origFieldRefObj->getTitle(), $tableId);
                 $field = ilDataCollectionCache::getFieldCache($fieldId);
                 $newRefId = $field->getId();
                 // Set the new refID in the actual DC
                 $tableId = ilDataCollectionTable::_getTableIdByTitle($origTable->getTitle(), $this->getId());
                 $fieldId = ilDataCollectionField::_getFieldIdByTitle($origField->getTitle(), $tableId);
                 $field = ilDataCollectionCache::getFieldCache($fieldId);
                 $field->setPropertyvalue($newRefId, ilDataCollectionField::PROPERTYID_REFERENCE);
                 $field->doUpdate();
             }
         }
     }
 }
 /**
  * initEditCustomForm
  *
  * @param string $a_mode values: create | edit
  */
 public function initForm($a_mode = "create")
 {
     global $ilCtrl, $lng;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     if ($a_mode == "edit") {
         $this->form->setTitle($lng->txt('dcl_edit_field'));
         $hidden_prop = new ilHiddenInputGUI("field_id");
         $this->form->addItem($hidden_prop);
         $this->form->setFormAction($ilCtrl->getFormAction($this), "update");
         $this->form->addCommandButton('update', $lng->txt('dcl_update_field'));
     } else {
         $this->form->setTitle($lng->txt('dcl_new_field'));
         $hidden_prop = new ilHiddenInputGUI("table_id");
         $hidden_prop->setValue($this->field_obj->getTableId());
         $this->form->addItem($hidden_prop);
         $this->form->setFormAction($ilCtrl->getFormAction($this), "save");
         $this->form->addCommandButton('save', $lng->txt('dcl_create_field'));
     }
     $this->form->addCommandButton('cancel', $lng->txt('cancel'));
     $text_prop = new ilTextInputGUI($lng->txt("title"), "title");
     $text_prop->setRequired(true);
     $text_prop->setInfo(sprintf($lng->txt('fieldtitle_allow_chars'), ilDataCollectionField::_getTitleValidChars(false)));
     $text_prop->setValidationRegexp(ilDataCollectionField::_getTitleValidChars(true));
     $this->form->addItem($text_prop);
     $edit_datatype = new ilRadioGroupInputGUI($lng->txt('dcl_datatype'), 'datatype');
     foreach (ilDataCollectionDatatype::getAllDatatypes() as $datatype) {
         $opt = new ilRadioOption($lng->txt('dcl_' . $datatype['title']), $datatype['id']);
         foreach (ilDataCollectionDatatype::getProperties($datatype['id']) as $property) {
             //Type Reference: List Tabels
             if ($datatype['id'] == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE and $property['id'] == ilDataCollectionField::PROPERTYID_REFERENCE) {
                 // Get Tables
                 require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php";
                 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
                 foreach ($tables as $table) {
                     foreach ($table->getRecordFields() as $field) {
                         //referencing references may lead to endless loops.
                         if ($field->getDatatypeId() != ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
                             $options[$field->getId()] = $table->getTitle() . "->" . $field->getTitle();
                         }
                     }
                 }
                 $table_selection = new ilSelectInputGUI('', 'prop_' . $property['id']);
                 $table_selection->setOptions($options);
                 //$table_selection->setValue($this->table_id);
                 $opt->addSubItem($table_selection);
             } elseif ($datatype['id'] == ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST and $property['id'] == ilDataCollectionField::PROPERTYID_REFERENCELIST) {
                 // Get Tables
                 require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php";
                 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
                 foreach ($tables as $table) {
                     foreach ($table->getRecordFields() as $field) {
                         //referencing references may lead to endless loops.
                         if ($field->getDatatypeId() != ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST) {
                             $options[$field->getId()] = $table->getTitle() . "->" . $field->getTitle();
                         }
                     }
                 }
                 $table_selection = new ilSelectInputGUI('', 'prop_' . $property['id']);
                 $table_selection->setOptions($options);
                 $opt->addSubItem($table_selection);
             } elseif ($property['datatype_id'] == $datatype['id']) {
                 if ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
                     $subitem = new ilCheckboxInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']);
                     $opt->addSubItem($subitem);
                 } else {
                     $subitem = new ilTextInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']);
                     $opt->addSubItem($subitem);
                 }
             }
         }
         $edit_datatype->addOption($opt);
     }
     $edit_datatype->setRequired(true);
     //you can't change type but we still need it in POST
     if ($a_mode == "edit") {
         $edit_datatype->setDisabled(true);
     }
     $this->form->addItem($edit_datatype);
     // Description
     $text_prop = new ilTextAreaInputGUI($lng->txt("dcl_field_description"), "description");
     $this->form->addItem($text_prop);
     // Required
     $cb = new ilCheckboxInputGUI($lng->txt("dcl_field_required"), "required");
     $this->form->addItem($cb);
     //Unique
     $cb = new ilCheckboxInputGUI($lng->txt("dcl_unique"), "unique");
     $this->form->addItem($cb);
 }
 static function passThroughFilter(ilDataCollectionRecord $record, ilDataCollectionField $field, $filter)
 {
     $pass = false;
     $type_id = $field->getDatatypeId();
     $value = $record->getRecordFieldValue($field->getId());
     switch ($type_id) {
         case ilDataCollectionDatatype::INPUTFORMAT_TEXT:
             if (!$filter || strpos(strtolower($value), strtolower($filter)) !== false) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_NUMBER:
             if ((!$filter['from'] || $value >= $filter['from']) && (!$filter['to'] || $value <= $filter['to'])) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN:
             if ($filter == "checked" && $value == 1 || $filter == "not_checked" && $value == 0 || $filter == '' || !$filter) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_DATETIME:
             if ((!$filter['from'] || $value >= $filter['from']) && (!$filter['to'] || $value <= $filter['to'])) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_FILE:
             if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
                 $pass = true;
                 break;
             }
             $file_obj = new ilObjFile($value, false);
             $file_name = $file_obj->getTitle();
             if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_REFERENCE:
             $props = $field->getProperties();
             if ($filter && $props[ilDataCollectionField::PROPERTYID_N_REFERENCE] && is_array($value) && in_array($filter, $value)) {
                 $pass = true;
             }
             if (!$filter || $filter == $value) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_RATING:
             if (!$filter || $filter <= $value['avg']) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF:
             $obj_id = ilObject::_lookupObjId($value);
             if (!$filter || strpos(strtolower(ilObject::_lookupTitle($obj_id)), strtolower($filter)) !== false) {
                 $pass = true;
             }
             break;
         case ilDataCollectionDatatype::INPUTFORMAT_MOB:
             $m_obj = new ilObjMediaObject($value, false);
             $file_name = $m_obj->getTitle();
             if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
                 $pass = true;
             }
             break;
     }
     //for the fields owner and last edit by, we check the name, not the ID
     if (($field->getId() == "owner" || $field->getId() == "last_edit_by") && $filter) {
         $pass = false;
         $user = new ilObjUser($value);
         if (strpos($user->getFullname(), $filter) !== false) {
             $pass = true;
         }
     }
     return $pass;
 }
 public static function buildFieldFromRecord($rec)
 {
     $fields_cache =& self::$fields_cache;
     if (isset($fields_cache[$rec["id"]])) {
         return $fields_cache[$rec["id"]];
     }
     $field = new ilDataCollectionField();
     $field->setId($rec["id"]);
     $field->setTableId($rec["table_id"]);
     $field->setTitle($rec["title"]);
     $field->setDescription($rec["description"]);
     $field->setDatatypeId($rec["datatype_id"]);
     $field->setRequired($rec["required"]);
     $field->setUnique($rec["is_unique"]);
     $field->setLocked($rec["is_locked"]);
     $fields_cache[$rec["id"]] = $field;
     return $field;
 }
 /**
  * initEditCustomForm
  *
  * @param string $a_mode values: create | edit
  */
 public function initForm($a_mode = "create")
 {
     global $ilCtrl, $lng;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     if ($a_mode == "edit") {
         $this->form->setTitle($lng->txt('dcl_edit_field'));
         $hidden_prop = new ilHiddenInputGUI("field_id");
         $this->form->addItem($hidden_prop);
         $this->form->setFormAction($ilCtrl->getFormAction($this), "update");
         $this->form->addCommandButton('update', $lng->txt('dcl_update_field'));
     } else {
         $this->form->setTitle($lng->txt('dcl_new_field'));
         $hidden_prop = new ilHiddenInputGUI("table_id");
         $hidden_prop->setValue($this->field_obj->getTableId());
         $this->form->addItem($hidden_prop);
         $this->form->setFormAction($ilCtrl->getFormAction($this), "save");
         $this->form->addCommandButton('save', $lng->txt('dcl_create_field'));
     }
     $this->form->addCommandButton('cancel', $lng->txt('cancel'));
     $text_prop = new ilTextInputGUI($lng->txt("title"), "title");
     $text_prop->setRequired(true);
     $text_prop->setInfo(sprintf($lng->txt('fieldtitle_allow_chars'), ilDataCollectionField::_getTitleValidChars(false)));
     $text_prop->setValidationRegexp(ilDataCollectionField::_getTitleValidChars(true));
     $this->form->addItem($text_prop);
     $edit_datatype = new ilRadioGroupInputGUI($lng->txt('dcl_datatype'), 'datatype');
     foreach (ilDataCollectionDatatype::getAllDatatypes() as $datatype) {
         $opt = new ilRadioOption($lng->txt('dcl_' . $datatype['title']), $datatype['id']);
         foreach (ilDataCollectionDatatype::getProperties($datatype['id']) as $property) {
             //Type Reference: List Tabels
             if ($datatype['id'] == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE and $property['id'] == ilDataCollectionField::PROPERTYID_REFERENCE) {
                 $options = array();
                 // Get Tables
                 require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php";
                 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
                 foreach ($tables as $table) {
                     foreach ($table->getRecordFields() as $field) {
                         //referencing references may lead to endless loops.
                         if ($field->getDatatypeId() != ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
                             $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
                         }
                     }
                 }
                 $table_selection = new ilSelectInputGUI('', 'prop_' . $property['id']);
                 $table_selection->setOptions($options);
                 //$table_selection->setValue($this->table_id);
                 $opt->addSubItem($table_selection);
             } elseif ($datatype['id'] == ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST and $property['id'] == ilDataCollectionField::PROPERTYID_N_REFERENCE) {
                 // Get Tables
                 require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php";
                 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
                 foreach ($tables as $table) {
                     foreach ($table->getRecordFields() as $field) {
                         //referencing references may lead to endless loops.
                         if ($field->getDatatypeId() != ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST) {
                             $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
                         }
                     }
                 }
                 $table_selection = new ilSelectInputGUI('', 'prop_' . $property['id']);
                 $table_selection->setOptions($options);
                 $opt->addSubItem($table_selection);
             } elseif ($property['id'] == ilDataCollectionField::PROPERTYID_FORMULA_EXPRESSION) {
                 $table = ilDataCollectionCache::getTableCache((int) $_GET['table_id']);
                 $fields = array();
                 foreach ($table->getFieldsForFormula() as $f) {
                     $placeholder = $f->isStandardField() ? $f->getId() : $f->getTitle();
                     $fields[] = '<a class="dclPropExpressionField" data-placeholder="' . $placeholder . '">' . $f->getTitle() . '</a>';
                 }
                 $subitem = new ilTextAreaInputGUI($lng->txt('dcl_prop_expression'), 'prop_' . $property['id']);
                 $operators = implode(', ', array_keys(ilDclExpressionParser::getOperators()));
                 $functions = implode(', ', ilDclExpressionParser::getFunctions());
                 $subitem->setInfo(sprintf($lng->txt('dcl_prop_expression_info'), $operators, $functions, implode('<br>', $fields)));
                 $opt->addSubItem($subitem);
             } elseif ($property['datatype_id'] == $datatype['id']) {
                 //All other Types: List properties saved in propertie definition table
                 if ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
                     $subitem = new ilCheckboxInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']);
                     $opt->addSubItem($subitem);
                 } elseif ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_NUMBER) {
                     $subitem = new ilNumberInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']);
                     // TODO: Nicer way to add additional info to fields (need changes in language-logic)
                     /*if($lng->txt('dcl_'.$property['title'].'_info') != '-dcl_'.$property['title'].'_info-') {
                     			$subitem->setInfo($lng->txt('dcl_'.$property['title'].'_info'));
                     		}*/
                     $subitem->setSize(5);
                     if ($property['title'] == 'length') {
                         $subitem->setMaxValue(4000);
                         $subitem->setInfo($lng->txt('dcl_' . $property['title'] . '_info'));
                     }
                     $opt->addSubItem($subitem);
                 } elseif ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_NON_EDITABLE_VALUE) {
                     $subitem = new ilNonEditableValueGUI($lng->txt('dcl_' . $property['title']));
                     $subitem->setValue(implode(', ', ilDataCollectionDatatype::$mob_suffixes));
                     $opt->addSubItem($subitem);
                 } else {
                     $subitem = new ilTextInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']);
                     // TODO: Nicer way to add additional info to fields (need changes in language-logic)
                     /*if($lng->txt('dcl_'.$property['title'].'_info') != '-dcl_'.$property['title'].'_info-') {
                     			$subitem->setInfo($lng->txt('dcl_'.$property['title'].'_info'));
                     		}*/
                     if ($property['title'] == 'regex') {
                         $subitem->setInfo($lng->txt('dcl_' . $property['title'] . '_info'));
                     }
                     $opt->addSubItem($subitem);
                 }
             }
         }
         $edit_datatype->addOption($opt);
     }
     $edit_datatype->setRequired(true);
     //you can't change type but we still need it in POST
     if ($a_mode == "edit") {
         $edit_datatype->setDisabled(true);
     }
     $this->form->addItem($edit_datatype);
     // Description
     $text_prop = new ilTextAreaInputGUI($lng->txt("dcl_field_description"), "description");
     $this->form->addItem($text_prop);
     // Required
     $cb = new ilCheckboxInputGUI($lng->txt("dcl_field_required"), "required");
     $this->form->addItem($cb);
     //Unique
     $cb = new ilCheckboxInputGUI($lng->txt("dcl_unique"), "unique");
     $this->form->addItem($cb);
 }
 /**
  *  saveRecordListViewdefinition
  *
  * @param string $a_mode values: create | update
  */
 public function save($a_mode = "create")
 {
     global $ilCtrl, $lng;
     $this->initForm();
     if ($this->form->checkInput()) {
         //Get fields
         require_once "./Modules/DataCollection/classes/class.ilDataCollectionField.php";
         $fields = ilDataCollectionField::getAll($this->table_id);
         //TODO tabledefs global definieren
         $tabledefinition = array("id" => array("title" => $lng->txt("id")), "table_id" => array("title" => $lng->txt("dcl_table_id")), "create_date" => array("title" => $lng->txt("create_date")), "last_update" => array("title" => $lng->txt("last_update")), "owner" => array("title" => $lng->txt("owner")));
         // Array zusammenführen TODO
         foreach ($fields as $key => $value) {
             $tabledefinition[$key] = $value;
         }
         foreach ($tabledefinition as $key => $field) {
             if ($this->form->getInput("visible_" . $key)) {
                 $this->view_obj->setArrFieldOrder($this->form->getInput("order_" . $key), $key);
             }
         }
         $this->view_obj->doCreate();
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->redirect($this, "edit");
     } else {
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), false);
         $this->form_gui->setValuesByPost();
         $this->tpl->setContent($this->form_gui->getHTML());
     }
 }
 /**
  * @return array|mixed|string
  */
 public function getHTML()
 {
     $values = $this->getValue();
     $record_field = $this;
     if (!$values or !count($values)) {
         return "";
     }
     $html = "";
     $cut = false;
     $tpl = new ilTemplate("tpl.reference_hover.html", true, true, "Modules/DataCollection");
     $tpl->setCurrentBlock("reference_list");
     $elements = array();
     foreach ($values as $value) {
         $ref_record = ilDataCollectionCache::getRecordCache($value);
         if (!$ref_record->getTableId() or !$record_field->getField() or !$record_field->getField()->getTableId()) {
             //the referenced record_field does not seem to exist.
             $record_field->setValue(NULL);
             $record_field->doUpdate();
         } else {
             $elements[] = array('value' => $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()), 'sort' => $ref_record->getRecordFieldSortingValue($this->getField()->getFieldRef()));
         }
     }
     //sort fetched elements
     $is_numeric = false;
     $ref_field = new ilDataCollectionField($record_field->getField()->getFieldRef());
     switch ($ref_field->getDatatypeId()) {
         case ilDataCollectionDatatype::INPUTFORMAT_DATETIME:
         case ilDataCollectionDatatype::INPUTFORMAT_NUMBER:
             $is_numeric = true;
             break;
     }
     $elements = ilUtil::sortArray($elements, 'sort', 'asc', $is_numeric);
     //concat
     foreach ($elements as $element) {
         if (strlen($html) < $this->max_reference_length) {
             $html .= $element['value'] . ", ";
         } else {
             $cut = true;
         }
         $tpl->setCurrentBlock("reference");
         $tpl->setVariable("CONTENT", $element['value']);
         $tpl->parseCurrentBlock();
     }
     $html = substr($html, 0, -2);
     if ($cut) {
         $html .= "...";
     }
     $tpl->setVariable("RECORD_ID", $this->getRecord()->getId());
     $tpl->setVariable("ALL", $html);
     $tpl->parseCurrentBlock();
     return $tpl->get();
 }
예제 #12
0
 /**
  * @param ilDataCollectionTable $original
  */
 public function cloneStructure(ilDataCollectionTable $original)
 {
     $this->setTitle($original->getTitle());
     $this->setDescription($original->getDescription());
     $this->setIsVisible($original->getIsVisible());
     $this->setEditByOwner($original->getEditByOwner());
     $this->setAddPerm($original->getAddPerm());
     $this->setEditPerm($original->getEditPerm());
     $this->setDeletePerm($original->getDeletePerm());
     $this->setLimited($original->getLimited());
     $this->setLimitStart($original->getLimitStart());
     $this->setLimitEnd($original->getLimitEnd());
     $this->setViewOwnRecordsPerm($original->getViewOwnRecordsPerm());
     $this->setExportEnabled($original->getExportEnabled());
     $this->setPublicCommentsEnabled($original->getPublicCommentsEnabled());
     $this->setDefaultSortFieldOrder($original->getDefaultSortFieldOrder());
     $this->doCreate();
     // reset stdFields to get new for the created object
     $default_sort_field = 0;
     // Clone standard-fields
     $org_std_fields = $original->getStandardFields();
     foreach ($this->getStandardFields() as $element_key => $std_field) {
         $std_field->cloneStructure($org_std_fields[$element_key]);
         if ($std_field->getId() == $original->getDefaultSortField()) {
             $default_sort_field = $std_field->getId();
         }
     }
     // Clone fields
     $new_fields = array();
     foreach ($original->getFields() as $orig_field) {
         if (!$orig_field->isStandardField()) {
             $new_field = new ilDataCollectionField();
             $new_field->setTableId($this->getId());
             $new_field->cloneStructure($orig_field->getId());
             $new_fields[$orig_field->getId()] = $new_field;
             if ($orig_field->getId() == $original->getDefaultSortField()) {
                 $default_sort_field = $new_field->getId();
             }
         }
     }
     $this->setDefaultSortField($default_sort_field);
     $this->doUpdate();
     //TODO: Find better way to copy data (include referenced data)
     // Clone Records with recordfields
     /*foreach($original->getRecords() as $orig_record){
     			$new_record = new ilDataCollectionRecord();
     			$new_record->setTableId($this->getId());
     			$new_record->cloneStructure($orig_record->getId(), $new_fields);
     		}*/
     if ($old_view_id = ilDataCollectionRecordViewViewdefinition::getIdByTableId($original->getId())) {
         $old_view = new ilDataCollectionRecordViewViewdefinition($old_view_id);
         $old_view->setTableId($original->getId());
         $viewdef = new ilDataCollectionRecordViewViewdefinition();
         $viewdef->setTableId($this->id);
         $viewdef->setXMLContent($old_view->getXMLContent(false));
         $viewdef->create();
     }
 }
 /**
  * @param ilDataCollectionField $originalField
  */
 public function cloneProperties(ilDataCollectionField $originalField)
 {
     $orgProps = $originalField->getProperties();
     if ($orgProps == NULL) {
         return;
     }
     foreach ($orgProps as $id => $value) {
         $fieldprop_obj = new ilDataCollectionFieldProp();
         $fieldprop_obj->setDatatypePropertyId($id);
         $fieldprop_obj->setFieldId($this->getId());
         // If reference field, we must reset the referenced field, otherwise it will point to the old ID
         if ($originalField->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE && $id == ilDataCollectionField::PROPERTYID_REFERENCE) {
             $value = NULL;
         }
         $fieldprop_obj->setValue($value);
         $fieldprop_obj->doCreate();
     }
 }
 /**
  * fill row 
  *
  * @access public
  * @param $a_set
  */
 public function fillRow(ilDataCollectionField $a_set)
 {
     global $lng, $ilCtrl;
     $this->tpl->setVariable('NAME', "order[" . $a_set->getId() . "]");
     $this->tpl->setVariable('VALUE', $this->order);
     $this->tpl->setVariable("CHECKBOX_VISIBLE", "visible[" . $a_set->getId() . "]");
     if ($a_set->isVisible()) {
         $this->tpl->setVariable("CHECKBOX_VISIBLE_CHECKED", "checked");
     }
     $this->tpl->setVariable("CHECKBOX_FILTERABLE", "filterable[" . $a_set->getId() . "]");
     if ($a_set->isFilterable()) {
         $this->tpl->setVariable("CHECKBOX_FILTERABLE_CHECKED", "checked");
     }
     if (!$a_set->isStandardField()) {
         $this->tpl->setVariable("CHECKBOX_NAME_LOCKED", "locked[" . $a_set->getId() . "]");
         if ($a_set->getLocked()) {
             $this->tpl->setVariable("CHECKBOX_CHECKED_LOCKED", "checked");
         }
     } else {
         $this->tpl->setVariable("NOT_LOCKED", "-");
     }
     $this->order = $this->order + 10;
     $this->tpl->setVariable("ORDER_NAME", "order[" . $a_set->getId() . "]");
     $this->tpl->setVariable("ORDER_VALUE", $this->order);
     $this->tpl->setVariable('TITLE', $a_set->getTitle());
     $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
     $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
     if (!$a_set->isStandardField()) {
         switch ($a_set->getRequired()) {
             case 0:
                 $required = ilUtil::getImagePath('icon_not_ok.png');
                 break;
             case 1:
                 $required = ilUtil::getImagePath('icon_ok.png');
                 break;
         }
         switch ($a_set->isUnique()) {
             case 0:
                 $uniq = ilUtil::getImagePath('icon_not_ok.png');
                 break;
             case 1:
                 $uniq = ilUtil::getImagePath('icon_ok.png');
                 break;
         }
         $this->tpl->setVariable('REQUIRED', $required);
         $this->tpl->setVariable('UNIQUE', $uniq);
     } else {
         $this->tpl->setVariable('NO_REQUIRED', "-");
         $this->tpl->setVariable('NO_UNIQUE', "-");
     }
     $ilCtrl->setParameterByClass("ildatacollectionfieldeditgui", "field_id", $a_set->getId());
     if (!$a_set->isStandardField()) {
         include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
         $alist = new ilAdvancedSelectionListGUI();
         $alist->setId($a_set->getId());
         $alist->setListTitle($lng->txt("actions"));
         if ($this->table->hasPermissionToFields($this->parent_obj->parent_obj->ref_id)) {
             $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass("ildatacollectionfieldeditgui", 'edit'));
             $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass("ildatacollectionfieldeditgui", 'confirmDelete'));
         }
         $this->tpl->setVariable("ACTIONS", $alist->getHTML());
     }
 }
 public function cloneStructure($original_id)
 {
     $original = ilDataCollectionCache::getTableCache($original_id);
     $this->setEditByOwner($original->getEditByOwner());
     $this->setAddPerm($original->getAddPerm());
     $this->setEditPerm($original->getEditPerm());
     $this->setDeletePerm($original->getDeletePerm());
     $this->setLimited($original->getLimited());
     $this->setLimitStart($original->getLimitStart());
     $this->setLimitEnd($original->getLimitEnd());
     $this->setTitle($original->getTitle());
     $this->doCreate();
     //clone fields.
     foreach ($original->getRecordFields() as $field) {
         $new_field = new ilDataCollectionField();
         $new_field->setTableId($this->getId());
         $new_field->cloneStructure($field->getId());
     }
     if ($old_view_id = ilDataCollectionRecordViewViewdefinition::getIdByTableId($original_id)) {
         $old_view = new ilDataCollectionRecordViewViewdefinition($old_view_id);
         $old_view->setTableId($original_id);
         $viewdef = new ilDataCollectionRecordViewViewdefinition();
         $viewdef->setTableId($this->id);
         $viewdef->setXMLContent($old_view->getXMLContent(false));
         $viewdef->create();
     }
 }
 /**
  * @param ilDataCollectionField $field
  * @param array                 $warnings
  *
  * @return bool
  */
 private function checkImportType($field, &$warnings)
 {
     global $lng;
     if (in_array($field->getDatatypeId(), $this->supported_import_datatypes)) {
         return true;
     } else {
         $warnings[] = $field->getTitle() . ": " . $lng->txt("dcl_not_supported_in_import");
         return false;
     }
 }
 /**
  * @param string          $a_entity
  * @param                 $a_types
  * @param array           $a_rec
  * @param ilImportMapping $a_mapping
  * @param string          $a_schema_version
  */
 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case 'dcl':
             // Calling new_obj->create() will create the main table for us
             $new_obj = new ilObjDataCollection();
             $new_obj->setTitle($a_rec['title']);
             $new_obj->setDescription($a_rec['description']);
             $new_obj->setApproval($a_rec['approval']);
             $new_obj->setPublicNotes($a_rec['public_notes']);
             $new_obj->setNotification($a_rec['notification']);
             $new_obj->setPublicNotes($a_rec['public_notes']);
             $new_obj->setOnline(false);
             $new_obj->setRating($a_rec['rating']);
             $new_obj->create();
             $this->import_dc_object = $new_obj;
             $a_mapping->addMapping('Modules/DataCollection', 'dcl', $a_rec['id'], $new_obj->getId());
             break;
         case 'il_dcl_table':
             // If maintable, update. Other tables must be created as well
             $table = $this->count_imported_tables > 0 ? new ilDataCollectionTable() : ilDataCollectionCache::getTableCache($this->import_dc_object->getMainTableId());
             $table->setTitle($a_rec['title']);
             $table->setObjId($this->import_dc_object->getId());
             $table->setDescription($a_rec['description']);
             $table->setAddPerm($a_rec['add_perm']);
             $table->setEditPerm($a_rec['edit_perm']);
             $table->setDeletePerm($a_rec['delete_perm']);
             $table->setEditByOwner($a_rec['edit_by_owner']);
             $table->setLimited($a_rec['limited']);
             $table->setLimitStart($a_rec['limit_start']);
             $table->setLimitEnd($a_rec['limit_end']);
             $table->setIsVisible($a_rec['is_visible']);
             $table->setExportEnabled($a_rec['export_enabled']);
             $table->setDefaultSortField($a_rec['default_sort_field_id']);
             $table->setDefaultSortFieldOrder($a_rec['default_sort_field_order']);
             $table->setPublicCommentsEnabled($a_rec['public_comments']);
             $table->setViewOwnRecordsPerm($a_rec['view_own_records_perm']);
             if ($this->count_imported_tables > 0) {
                 $table->doCreate(false);
                 // false => Do not create views! They are imported later
             } else {
                 $table->doUpdate();
                 $this->count_imported_tables++;
                 // Delete views from maintable because we want to import them from the xml data
                 $set = $this->db->query('SELECT * FROM il_dcl_view WHERE table_id = ' . $this->db->quote($table->getId(), 'integer'));
                 $view_ids = array();
                 while ($row = $this->db->fetchObject($set)) {
                     $view_ids[] = $row->id;
                 }
                 if (count($view_ids)) {
                     $this->db->manipulate("DELETE FROM il_dcl_viewdefinition WHERE view_id IN (" . implode(',', $view_ids) . ")");
                 }
                 $this->db->manipulate("DELETE FROM il_dcl_view WHERE table_id = " . $this->db->quote($table->getId(), 'integer'));
             }
             $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['id'], $table->getId());
             break;
         case 'il_dcl_field':
             $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
             if ($new_table_id) {
                 $field = new ilDataCollectionField();
                 $field->setTableId($new_table_id);
                 $field->setDatatypeId($a_rec['datatype_id']);
                 $field->setTitle($a_rec['title']);
                 $field->setDescription($a_rec['description']);
                 $field->setRequired($a_rec['required']);
                 $field->setUnique($a_rec['is_unique']);
                 $field->setLocked($a_rec['is_locked']);
                 $field->doCreate();
                 $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['id'], $field->getId());
                 // Check if this field was used as default order by, if so, update to new id
                 $table = ilDataCollectionCache::getTableCache($new_table_id);
                 if ($table && $table->getDefaultSortField() == $a_rec['id']) {
                     $table->setDefaultSortField($field->getId());
                     $table->doUpdate();
                 }
             }
             break;
         case 'il_dcl_record':
             $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
             if ($new_table_id) {
                 $record = new ilDataCollectionRecord();
                 $record->setTableId($new_table_id);
                 $datetime = new ilDateTime(time(), IL_CAL_UNIX);
                 $record->setCreateDate($datetime);
                 $record->setLastUpdate($datetime);
                 $record->setOwner($this->user->getId());
                 $record->setLastEditBy($this->user->getId());
                 $record->doCreate();
                 $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_record', $a_rec['id'], $record->getId());
             }
             break;
         case 'il_dcl_view':
             $new_table_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_table', $a_rec['table_id']);
             if ($new_table_id) {
                 if ($a_rec['type'] == 0 && $a_rec['formtype'] == 0) {
                     // RecordViewViewDefinition: Create a new RecordViewViewdefinition. Note that the associated Page object is NOT created.
                     // Creation of the Page object is handled by the import of Services/COPage
                     $definition = new ilDataCollectionRecordViewViewdefinition();
                     $definition->setTableId($new_table_id);
                     $definition->create(true);
                     // DO not create DB entries for page object
                     // This mapping is needed for the import handled by Services/COPage
                     $a_mapping->addMapping('Services/COPage', 'pg', 'dclf:' . $a_rec['id'], 'dclf:' . $definition->getId());
                     $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_view', $a_rec['id'], $definition->getId());
                 } else {
                     // Other definitions - grab next ID from il_dcl_view
                     $view_id = $this->db->nextId("il_dcl_view");
                     $sql = "INSERT INTO il_dcl_view (id, table_id, type, formtype) VALUES (" . $this->db->quote($view_id, "integer") . ", " . $this->db->quote($new_table_id, "integer") . ", " . $this->db->quote($a_rec['type'], "integer") . ", " . $this->db->quote($a_rec['formtype'], "integer") . ")";
                     $this->db->manipulate($sql);
                     $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_view', $a_rec['id'], $view_id);
                 }
             }
             break;
         case 'il_dcl_viewdefinition':
             $new_view_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_view', $a_rec['view_id']);
             $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field']);
             $field = $new_field_id ? $new_field_id : $a_rec['field'];
             if ($new_view_id) {
                 $sql = 'INSERT INTO il_dcl_viewdefinition (view_id, field, field_order, is_set) VALUES (' . $this->db->quote($new_view_id, 'integer') . ', ' . $this->db->quote($field, 'text') . ', ' . $this->db->quote($a_rec['field_order'], 'integer') . ', ' . $this->db->quote($a_rec['is_set'], 'integer') . ')';
                 $this->db->manipulate($sql);
             }
             break;
         case 'il_dcl_field_prop':
             $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field_id']);
             if ($new_field_id) {
                 $prop = new ilDataCollectionFieldProp();
                 $prop->setFieldId($new_field_id);
                 $prop->setDatatypePropertyId($a_rec['datatype_prop_id']);
                 // For field references, we need to get the new field id of the referenced field
                 // If the field_id does not yet exist (e.g. referenced table not yet created), store temp info and fix before finishing import
                 $value = $a_rec['value'];
                 $refs = array(ilDataCollectionField::PROPERTYID_REFERENCE, ilDataCollectionField::PROPERTYID_N_REFERENCE);
                 $fix_refs = false;
                 if (in_array($prop->getDatatypePropertyId(), $refs)) {
                     $new_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['value']);
                     if ($new_field_id === false) {
                         $value = NULL;
                         $fix_refs = true;
                     }
                 }
                 $prop->setValue($value);
                 $prop->doCreate();
                 $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_field_prop', $a_rec['id'], $prop->getId());
                 if ($fix_refs) {
                     $this->import_temp_refs_props[$prop->getId()] = $a_rec['value'];
                 }
             }
             break;
         case 'il_dcl_record_field':
             $record_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record', $a_rec['record_id']);
             $field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_field', $a_rec['field_id']);
             if ($record_id && $field_id) {
                 $record = ilDataCollectionCache::getRecordCache($record_id);
                 $field = ilDataCollectionCache::getFieldCache($field_id);
                 $record_field = new ilDataCollectionRecordField($record, $field);
                 // Created in constructor if not existing
                 $a_mapping->addMapping('Modules/DataCollection', 'il_dcl_record_field', $a_rec['id'], $record_field->getId());
                 $this->import_record_field_cache[$record_field->getId()] = $record_field;
             }
             break;
         case 'il_dcl_stloc1_value':
         case 'il_dcl_stloc2_value':
         case 'il_dcl_stloc3_value':
             $new_record_field_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record_field', $a_rec['record_field_id']);
             if ($new_record_field_id) {
                 /** @var ilDataCollectionRecordField $record_field */
                 $record_field = $this->import_record_field_cache[$new_record_field_id];
                 if (is_object($record_field)) {
                     // Need to rewrite internal references and lookup new objects if MOB or File
                     // For some fieldtypes it's better to reset the value, e.g. ILIAS_REF
                     switch ($record_field->getField()->getDatatypeId()) {
                         case ilDataCollectionDatatype::INPUTFORMAT_MOB:
                             // Check if we got a mapping from old object
                             $new_mob_id = $a_mapping->getMapping('Services/MediaObjects', 'mob', $a_rec['value']);
                             $value = $new_mob_id ? (int) $new_mob_id : NULL;
                             $this->import_temp_new_mob_ids[] = $new_mob_id;
                             break;
                         case ilDataCollectionDatatype::INPUTFORMAT_FILE:
                             $new_file_id = $a_mapping->getMapping('Modules/File', 'file', $a_rec['value']);
                             $value = $new_file_id ? (int) $new_file_id : NULL;
                             break;
                         case ilDataCollectionDatatype::INPUTFORMAT_REFERENCE:
                         case ilDataCollectioNDatatype::INPUTFORMAT_REFERENCELIST:
                             // 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
                             // Solution: Temporary store all references and fix them before finishing the import.
                             $new_record_id = $a_mapping->getMapping('Modules/DataCollection', 'il_dcl_record', $a_rec['value']);
                             if ($new_record_id === false) {
                                 $this->import_temp_refs[$new_record_field_id] = $a_rec['value'];
                             }
                             $value = $new_record_id ? (int) $new_record_id : NULL;
                             break;
                         case ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF:
                             $value = NULL;
                             break;
                         default:
                             $value = $a_rec['value'];
                             if ($a_entity == 'il_dcl_stloc3_value' && (is_null($value) || empty($value))) {
                                 $value = '0000-00-00 00:00:00';
                             }
                     }
                     $record_field->setValue($value, true);
                     $record_field->doUpdate();
                 }
             }
             break;
     }
 }