4 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionRecord.php");
5 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionField.php");
6 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
7 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php");
33 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
36 $this->record_id =
$_REQUEST[
'record_id'];
37 $this->table_id =
$_GET[
'table_id'];
39 include_once(
"class.ilDataCollectionDatatype.php");
56 $cmd = $ilCtrl->getCmd();
77 $tpl->setContent($this->form->getHTML());
90 $tpl->setContent($this->form->getHTML());
100 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
102 $conf->setFormAction($ilCtrl->getFormAction($this));
103 $conf->setHeaderText($lng->txt(
'dcl_confirm_delete_record'));
107 $conf->addItem(
'record_id', $record->getId(), implode(
", ", $record->getRecordFieldValues()));
108 $conf->addHiddenItem(
'table_id', $this->table_id);
110 $conf->setConfirm($lng->txt(
'delete'),
'delete');
111 $conf->setCancel($lng->txt(
'cancel'),
'cancelDelete');
113 $tpl->setContent($conf->getHTML());
123 $ilCtrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
129 public function delete()
134 if(!$this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id, $record))
142 $ilCtrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
156 $hidden_prop ->setValue($this->table_id);
157 $this->form->addItem($hidden_prop);
159 $ilCtrl->setParameter($this,
"record_id", $this->record_id);
160 $this->form->setFormAction($ilCtrl->getFormAction($this));
161 $allFields = $this->table->getRecordFields();
163 foreach($allFields as $field)
169 $fieldref = $field->getFieldRef();
174 foreach($reftable->getRecords() as $record)
178 $file_obj =
new ilObjFile($record->getRecordFieldValue($fieldref),
false);
179 $options[$record->getId()] = $file_obj->
getFileName();
181 $media_obj =
new ilObjMediaObject($record->getRecordFieldValue($fieldref),
false);
182 $options[$record->getId()] = $media_obj->
getTitle();
184 $options[$record->getId()] = $record->getRecordFieldValue($fieldref);
188 $item->setOptions($options);
196 $item->setRequired($field->getRequired());
199 if ($this->record_id && $record->getId()) {
200 $field_value = $record->getRecordFieldValue($field->getId());
202 $item->setRequired(
false);
209 $item->setDisabled(
true);
211 $this->form->addItem($item);
215 if ($this->record_id) {
216 $ownerField = $this->table->getField(
'owner');
218 $this->form->addItem($inputfield);
222 if(isset($this->record_id))
224 $this->form->setTitle($lng->txt(
"dcl_update_record"));
225 $this->form->addCommandButton(
"save", $lng->txt(
"dcl_update_record"));
226 $this->form->addCommandButton(
"cancelUpdate", $lng->txt(
"cancel"));
230 $this->form->setTitle($lng->txt(
"dcl_add_new_record"));
231 $this->form->addCommandButton(
"save", $lng->txt(
"save"));
232 $this->form->addCommandButton(
"cancelSave", $lng->txt(
"cancel"));
235 $ilCtrl->setParameter($this,
"table_id", $this->table_id);
236 $ilCtrl->setParameter($this,
"record_id", $this->record_id);
251 $allFields = $this->table->getFields();
254 foreach($allFields as $field)
257 $values[
'field_'.$field->getId()] = $value;
261 $this->form->getItemByPostVar(
'field_'.$field->getId())->setImage(
$img);
265 $this->form->setValuesByArray($values);
275 $ilCtrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
296 if($this->form->checkInput())
301 $record_obj->setTableId($this->table_id);
303 $record_obj->setLastEditBy($ilUser->getId());
305 $create_mode =
false;
309 $all_fields = $this->table->getRecordFields();
313 $all_fields = $this->table->getEditableFields();
318 foreach($all_fields as $field)
322 $value = $this->form->getInput(
"field_".$field->getId());
323 $field->checkValidity($value, $this->record_id);
325 $fail .= $field->getTitle().
": ".$e.
"<br>";
337 if(!isset($this->record_id))
339 if(!($this->table->hasPermissionToAddRecord($this->parent_obj->ref_id)))
344 $record_obj->setOwner($ilUser->getId());
346 $record_obj->setTableId($this->table_id);
347 $record_obj->doCreate();
348 $this->record_id = $record_obj->getId();
353 if(!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id))
360 foreach($all_fields as $field)
362 $value = $this->form->getInput(
"field_".$field->getId());
367 $record_obj->setRecordFieldValue($field->getId(), $value);
377 $record_obj->setOwner($owner_id);
384 $record_obj->doUpdate();
387 $ilCtrl->setParameter($this,
"table_id", $this->table_id);
388 $ilCtrl->setParameter($this,
"record_id", $this->record_id);
389 $ilCtrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
394 $this->form->setValuesByPost();
395 $tpl->setContent($this->form->getHTML());
406 $tpl->setContent(
"Access denied");
415 $this->form->setValuesByPost();
416 $tpl->setContent($this->form->getHTML());
425 $search =
$_POST[
'search_for'];
428 include_once
'./Services/Search/classes/class.ilQueryParser.php';
430 $query_parser->setMinWordLength(1,
true);
432 $query_parser->parse();
433 if(!$query_parser->validate())
435 $html .= $query_parser->getMessage().
"<br />";
439 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
441 $res = $object_search->performSearch();
443 $res->filter(ROOT_FOLDER_ID,
true);
447 $html .= $lng->txt(
'dcl_no_search_results_found_for'). $search.
"<br />";
452 $tpl =
new ilTemplate(
"tpl.dcl_tree.html",
true,
true,
"Modules/DataCollection");
453 foreach((array) $entry[
'refs'] as $reference)
455 include_once
'./Services/Tree/classes/class.ilPathGUI.php';
458 $tpl->setCurrentBlock(
'result');
459 $tpl->setVariable(
'RESULT_PATH',
$path->getPath(ROOT_FOLDER_ID, $reference).
" > ".$entry[
'title']);
460 $tpl->setVariable(
'RESULT_REF',$reference);
461 $tpl->setVariable(
'FIELD_ID', $dest);
462 $tpl->parseCurrentBlock();
464 $html .=
$tpl->get();
479 foreach($a_res as $obj_id => $references)
483 $r[
'obj_id'] = $obj_id;
484 $r[
'refs'] = $references;
489 return $rows ? $rows : array();