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);
256 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
257 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
258 foreach($tables as
$table)
260 foreach($table->getRecordFields() as $field)
265 $options[$field->getId()] = $table->getTitle().
"->".$field->getTitle();
271 'prop_'.$property[
'id']
273 $table_selection->setOptions(
$options);
274 $opt->addSubItem($table_selection);
277 elseif($property[
'datatype_id'] == $datatype[
'id'])
281 $subitem =
new ilCheckboxInputGUI($lng->txt(
'dcl_'.$property[
'title']),
'prop_'.$property[
'id']);
285 $subitem =
new ilNumberInputGUI($lng->txt(
'dcl_'.$property[
'title']),
'prop_'.$property[
'id']);
287 if ($property[
'title'] ==
'length') {
288 $subitem->setMaxValue(4000);
290 $opt->addSubItem($subitem);
292 $subitem =
new ilTextInputGUI($lng->txt(
'dcl_'.$property[
'title']),
'prop_'.$property[
'id']);
301 $edit_datatype->addOption($opt);
303 $edit_datatype->setRequired(
true);
306 if($a_mode ==
"edit")
308 $edit_datatype->setDisabled(
true);
310 $this->form->addItem($edit_datatype);
313 $text_prop =
new ilTextAreaInputGUI($lng->txt(
"dcl_field_description"),
"description");
314 $this->form->addItem($text_prop);
318 $this->form->addItem($cb);
322 $this->form->addItem($cb);
332 'table_id' => $this->field_obj->getTableId(),
333 'field_id' => $this->field_obj->getId(),
334 'title' => $this->field_obj->getTitle(),
335 'datatype' => $this->field_obj->getDatatypeId(),
336 'description' => $this->field_obj->getDescription(),
337 'required' => $this->field_obj->getRequired(),
338 'unique' => $this->field_obj->isUnique(),
341 $propertyvalues = $this->field_obj->getPropertyvalues();
349 $values[
'prop_'.$property[
'id']] = $propertyvalues[$property[
'id']];
353 $this->form->setValuesByArray($values);
364 public function save($a_mode =
"create")
369 if(!$this->table->hasPermissionToFields($this->parent_obj->ref_id)){
374 $this->
initForm($a_mode ==
"update"?
"edit":
"create");
377 $title = $this->form->getInput(
"title");
378 if($a_mode !=
"create" && $title != $this->field_obj->getTitle())
381 $this->field_obj->setTitle($title);
382 $this->field_obj->setDescription($this->form->getInput(
"description"));
383 $this->field_obj->setDatatypeId($this->form->getInput(
"datatype"));
384 $this->field_obj->setRequired($this->form->getInput(
"required"));
385 $this->field_obj->setUnique($this->form->getInput(
"unique"));
387 if($a_mode ==
"update")
389 $this->field_obj->doUpdate();
393 $this->field_obj->setVisible(
true);
394 $this->field_obj->setOrder($this->table->getNewOrder());
395 $this->field_obj->doCreate();
399 include_once(
"./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php");
403 $fieldprop_obj->setDatatypePropertyId($property[
'id']);
404 $fieldprop_obj->setFieldId($this->field_obj->getId());
405 $fieldprop_obj->setValue($this->form->getInput(
"prop_".$property[
'id']));
407 if($a_mode ==
"update")
409 $fieldprop_obj->doUpdate();
413 $fieldprop_obj->doCreate();
418 $ilCtrl->setParameter($this,
"field_id", $this->field_obj->getId());
420 if($a_mode ==
"update")
426 $this->table->addField($this->field_obj);
427 $this->table->buildOrderFields();
430 $ilCtrl->redirectByClass(strtolower(
"ilDataCollectionFieldListGUI"),
"listFields");
434 $this->form->setValuesByPost();
435 $tpl->setContent($this->form->getHTML());
446 $return = $this->form->checkInput();
450 && (int) $this->form->getInput(
'prop_'.ilDataCollectionField::PROPERTYID_LENGTH) > 200
453 $inputObj->setAlert($lng->txt(
"form_msg_value_too_high"));
458 if ($a_mode ==
'create') {
459 if ($title = $this->form->getInput(
'title')) {
461 $inputObj = $this->form->getItemByPostVar(
'title');
462 $inputObj->setAlert($lng->txt(
"dcl_field_title_unique"));
479 $tpl->setContent(
"Access Denied");