3 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionField.php");
4 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php");
5 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
6 require_once
"class.ilDataCollectionCache.php";
39 $this->obj_id = $a_parent_obj->obj_id;
40 $this->parent_obj = $a_parent_obj;
46 $this->field_id =
$_GET[
'field_id'];
56 $ilCtrl->redirectByClass(
"ilDataCollectionGUI",
"listFields");
58 $ilCtrl->saveParameter($this,
"table_id");
72 $cmd = $ilCtrl->getCmd();
74 if(!$this->table->hasPermissionToFields($this->parent_obj->ref_id)){
82 $this->
save(
"update");
100 $tpl->setContent($this->form->getHTML());
113 $tpl->setContent($this->form->getHTML());
122 $tpl->setContent(
"Permission denied");
134 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
136 $conf->setFormAction($ilCtrl->getFormAction($this));
137 $conf->setHeaderText($lng->txt(
'dcl_confirm_delete_field'));
139 $conf->addItem(
'field_id', (
int) $this->field_obj->getId(), $this->field_obj->getTitle());
141 $conf->setConfirm($lng->txt(
'delete'),
'delete');
142 $conf->setCancel($lng->txt(
'cancel'),
'cancelDelete');
144 $tpl->setContent($conf->getHTML());
154 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
160 public function delete()
164 $this->table->deleteField($this->field_obj->getId());
165 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
174 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
186 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
189 if($a_mode ==
"edit")
191 $this->form->setTitle($lng->txt(
'dcl_edit_field'));
193 $this->form->addItem($hidden_prop);
195 $this->form->setFormAction($ilCtrl->getFormAction($this),
"update");
197 $this->form->addCommandButton(
'update', $lng->txt(
'dcl_update_field'));
201 $this->form->setTitle($lng->txt(
'dcl_new_field'));
203 $hidden_prop->setValue($this->field_obj->getTableId());
204 $this->form->addItem($hidden_prop);
206 $this->form->setFormAction($ilCtrl->getFormAction($this),
"save");
208 $this->form->addCommandButton(
'save', $lng->txt(
'dcl_create_field'));
210 $this->form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
216 $this->form->addItem($text_prop);
222 $opt =
new ilRadioOption($lng->txt(
'dcl_'.$datatype[
'title']), $datatype[
'id']);
230 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
231 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
232 foreach($tables as
$table)
234 foreach($table->getRecordFields() as $field)
239 $options[$field->getId()] = $table->getTitle().
"->".$field->getTitle();
245 'prop_'.$property[
'id']
247 $table_selection->setOptions($options);
249 $opt->addSubItem($table_selection);
254 elseif($property[
'datatype_id'] == $datatype[
'id'])
258 $subitem =
new ilCheckboxInputGUI($lng->txt(
'dcl_'.$property[
'title']),
'prop_'.$property[
'id']);
263 $subitem =
new ilTextInputGUI($lng->txt(
'dcl_'.$property[
'title']),
'prop_'.$property[
'id']);
268 $edit_datatype->addOption($opt);
270 $edit_datatype->setRequired(
true);
273 if($a_mode ==
"edit")
275 $edit_datatype->setDisabled(
true);
277 $this->form->addItem($edit_datatype);
280 $text_prop =
new ilTextAreaInputGUI($lng->txt(
"dcl_field_description"),
"description");
281 $this->form->addItem($text_prop);
285 $this->form->addItem($cb);
289 $this->form->addItem($cb);
299 'table_id' => $this->field_obj->getTableId(),
300 'field_id' => $this->field_obj->getId(),
301 'title' => $this->field_obj->getTitle(),
302 'datatype' => $this->field_obj->getDatatypeId(),
303 'description' => $this->field_obj->getDescription(),
304 'required' => $this->field_obj->getRequired(),
305 'unique' => $this->field_obj->isUnique(),
308 $propertyvalues = $this->field_obj->getPropertyvalues();
316 $values[
'prop_'.$property[
'id']] = $propertyvalues[$property[
'id']];
320 $this->form->setValuesByArray($values);
331 public function save($a_mode =
"create")
336 if(!$this->table->hasPermissionToFields($this->parent_obj->ref_id)){
341 $this->
initForm($a_mode ==
"update"?
"edit":
"create");
344 $title = $this->form->getInput(
"title");
345 if($a_mode !=
"create" &&
$title != $this->field_obj->getTitle())
348 $this->field_obj->setTitle(
$title);
349 $this->field_obj->setDescription($this->form->getInput(
"description"));
350 $this->field_obj->setDatatypeId($this->form->getInput(
"datatype"));
351 $this->field_obj->setRequired($this->form->getInput(
"required"));
352 $this->field_obj->setUnique($this->form->getInput(
"unique"));
354 if($a_mode ==
"update")
356 $this->field_obj->doUpdate();
360 $this->field_obj->setVisible(
true);
361 $this->field_obj->setOrder($this->table->getNewOrder());
362 $this->field_obj->doCreate();
366 include_once(
"./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php");
370 $fieldprop_obj->setDatatypePropertyId($property[
'id']);
371 $fieldprop_obj->setFieldId($this->field_obj->getId());
372 $fieldprop_obj->setValue($this->form->getInput(
"prop_".$property[
'id']));
373 if($a_mode ==
"update")
375 $fieldprop_obj->doUpdate();
379 $fieldprop_obj->doCreate();
384 $ilCtrl->setParameter($this,
"field_id", $this->field_obj->getId());
386 if($a_mode ==
"update")
392 $this->table->addField($this->field_obj);
393 $this->table->buildOrderFields();
396 $ilCtrl->redirectByClass(strtolower(
"ilDataCollectionFieldListGUI"),
"listFields");
401 $this->form->setValuesByPost();
402 $tpl->setContent($this->form->getHTML());
413 $return = $this->form->checkInput();
417 && (int) $this->form->getInput(
'prop_'.ilDataCollectionField::PROPERTYID_LENGTH) > 200
420 $inputObj->setAlert($lng->txt(
"form_msg_value_too_high"));
425 if ($a_mode ==
'create') {
426 if (
$title = $this->form->getInput(
'title')) {
428 $inputObj = $this->form->getItemByPostVar(
'title');
429 $inputObj->setAlert($lng->txt(
"dcl_field_title_unique"));
446 $tpl->setContent(
"Access Denied");