ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDclRecordEditGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 {
17 
23  const REDIRECT_DETAIL = 2;
27  protected $tableview_id;
31  protected $record_id;
35  protected $table_id;
39  protected $table;
43  protected $parent_obj;
47  protected $record;
51  protected $ctrl;
55  protected $tpl;
59  protected $lng;
63  protected $user;
67  protected $form;
71  protected $tableview;
72 
73 
78  {
79  global $DIC;
80  $ilCtrl = $DIC['ilCtrl'];
81  $tpl = $DIC['tpl'];
82  $lng = $DIC['lng'];
83  $ilUser = $DIC['ilUser'];
84 
85  $this->ctrl = $ilCtrl;
86  $this->tpl = $tpl;
87  $this->lng = $lng;
88  $this->user = $ilUser;
89  $this->parent_obj = $parent_obj;
90  $this->record_id = $_REQUEST['record_id'];
91  $this->table_id = $_REQUEST['table_id'];
92  $this->tableview_id = $_REQUEST['tableview_id'];
93  if (!$this->tableview_id) {
94  $this->tableview_id = ilDclCache::getTableCache($this->table_id)
95  ->getFirstTableViewId($this->parent_obj->ref_id);
96  }
97  $this->tableview = ilDclTableView::findOrGetInstance($this->tableview_id);
98  }
99 
100 
104  public function executeCommand()
105  {
106  $this->getRecord();
107 
108  $cmd = $this->ctrl->getCmd();
109  switch ($cmd) {
110  default:
111  $this->$cmd();
112  break;
113  }
114 
115  return true;
116  }
117 
118 
122  public function getRecord()
123  {
124  if ($_GET['mode']) {
125  $this->ctrl->saveParameter($this, 'mode');
126  $this->ctrl->setParameterByClass("ildclrecordlistgui", "mode", $_GET['mode']);
127  }
128  $this->ctrl->setParameterByClass('ildclrecordlistgui', 'tableview_id', $this->tableview_id);
129  $this->ctrl->saveParameter($this, 'redirect');
130  if ($this->record_id) {
131  $this->record = ilDclCache::getRecordCache($this->record_id);
132  if (!($this->record->hasPermissionToEdit($this->parent_obj->ref_id) and $this->record->hasPermissionToView($this->parent_obj->ref_id)) && !$this->record->hasPermissionToDelete($this->parent_obj->ref_id)) {
133  $this->accessDenied();
134  }
135  $this->table = $this->record->getTable();
136  $this->table_id = $this->table->getId();
137  } else {
138  $this->table = ilDclCache::getTableCache($this->table_id);
140  $this->accessDenied();
141  }
142  }
143  }
144 
145 
149  public function create()
150  {
151  $this->initForm();
152  if ($this->ctrl->isAsynch()) {
153  echo $this->form->getHTML();
154  exit();
155  } else {
156  $this->tpl->setContent(
157  $this->getLanguageJsKeys()
158  . $this->form->getHTML()
159  );
160  }
161  }
162 
163 
167  public function edit()
168  {
169  $this->initForm();
170  $this->cleanupTempFiles();
171 
172  $this->setFormValues();
173  if ($this->ctrl->isAsynch()) {
174  echo $this->form->getHTML();
175  exit();
176  } else {
177  $this->tpl->setContent(
178  $this->getLanguageJsKeys()
179  . $this->form->getHTML()
180  );
181  }
182  }
183 
184 
190  public function confirmDelete()
191  {
192  $conf = new ilConfirmationGUI();
193  $conf->setFormAction($this->ctrl->getFormAction($this));
194  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_record'));
195  $record = ilDclCache::getRecordCache($this->record_id);
196 
197  $all_fields = $this->table->getRecordFields();
198  $record_data = "";
199  foreach ($all_fields as $key => $field) {
200  $field_record = ilDclCache::getRecordFieldCache($record, $field);
201 
202  $record_representation = ilDclCache::getRecordRepresentation($field_record);
203  if ($record_representation->getConfirmationHTML() !== false) {
204  $record_data .= $field->getTitle() . ": " . $record_representation->getConfirmationHTML() . "<br />";
205  }
206  }
207  $conf->addItem('record_id', $record->getId(), $record_data);
208  $conf->addHiddenItem('table_id', $this->table_id);
209  $conf->addHiddenItem('tableview_id', $this->tableview_id);
210  $conf->setConfirm($this->lng->txt('delete'), 'delete');
211  $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
212  $this->tpl->setContent($conf->getHTML());
213  }
214 
215 
219  public function cancelDelete()
220  {
221  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
222  }
223 
224 
228  public function delete()
229  {
230  $record = ilDclCache::getRecordCache($this->record_id);
231 
232  if (!$this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id, $record)) {
233  $this->accessDenied();
234 
235  return;
236  }
237 
238  $record->doDelete();
239  ilUtil::sendSuccess($this->lng->txt("dcl_record_deleted"), true);
240  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
241  }
242 
243 
252  public function getRecordData($record_id = 0)
253  {
254  $record_id = ($record_id) ? $record_id : $_GET['record_id'];
255  $return = array();
256  if ($record_id) {
258  if (is_object($record)) {
259  $return = $record->getRecordFieldValues();
260  }
261  }
262  if ($this->ctrl->isAsynch()) {
263  echo json_encode($return);
264  exit();
265  }
266 
267  return $return;
268  }
269 
270 
276  public function initForm()
277  {
278  $this->form = new ilDclPropertyFormGUI();
279  $prefix = ($this->ctrl->isAsynch()) ? 'dclajax' : 'dcl'; // Used by datacolleciton.js to select input elements
280  $this->form->setId($prefix . $this->table_id . $this->record_id);
281 
282  $hidden_prop = new ilHiddenInputGUI("table_id");
283  $hidden_prop->setValue($this->table_id);
284  $this->form->addItem($hidden_prop);
285  $hidden_prop = new ilHiddenInputGUI("tableview_id");
286  $hidden_prop->setValue($this->tableview_id);
287  $this->form->addItem($hidden_prop);
288  if ($this->record_id) {
289  $hidden_prop = new ilHiddenInputGUI("record_id");
290  $hidden_prop->setValue($this->record_id);
291  $this->form->addItem($hidden_prop);
292  }
293 
294  $this->ctrl->setParameter($this, "record_id", $this->record_id);
295  $this->form->setFormAction($this->ctrl->getFormAction($this));
296  $allFields = $this->table->getRecordFields();
297  $inline_css = '';
298  foreach ($allFields as $field) {
299  $field_setting = $field->getViewSetting($this->tableview_id);
300  if ($field_setting->isVisibleInForm(!$this->record_id)) {
301  $item = ilDclCache::getFieldRepresentation($field)->getInputField($this->form, $this->record_id);
302  if ($item === null) {
303  continue; // Fields calculating values at runtime, e.g. ilDclFormulaFieldModel do not have input
304  }
305 
306  if (!ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id) && $field_setting->isLocked(!$this->record_id)) {
307  $item->setDisabled(true);
308  }
309 
310  $item->setRequired($field_setting->isRequired(!$this->record_id));
311  $default_value = null;
312 
313  // If creation mode
314  if (!$this->record_id) {
315  $default_value = ilDclTableViewBaseDefaultValue::findSingle($field_setting->getFieldObject()->getDatatypeId(), $field_setting->getId());
316 
317  if ($default_value !== null) {
318  if ($item instanceof ilDclCheckboxInputGUI) {
319  $item->setChecked($default_value->getValue());
320  } else {
321  $item->setValue($default_value->getValue());
322  }
323  }
324  }
325  $this->form->addItem($item);
326  }
327  }
328 
329  $this->tpl->addInlineCss($inline_css);
330 
331  // Add possibility to change the owner in edit mode
332  if ($this->record_id) {
333  $field_setting = $this->tableview->getFieldSetting('owner');
334  if ($field_setting->isVisibleEdit()) {
335  $ownerField = $this->table->getField('owner');
336  $inputfield = ilDclCache::getFieldRepresentation($ownerField)->getInputField($this->form);
337 
338  if (!ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id) && $field_setting->isLockedEdit()) {
339  $inputfield->setDisabled(true);
340  } else {
341  $inputfield->setRequired(true);
342  }
343 
344  $this->form->addItem($inputfield);
345  }
346  }
347 
348  // save and cancel commands
349  if ($this->record_id) {
350  $this->form->setTitle($this->lng->txt("dcl_update_record"));
351  $this->form->addCommandButton("save", $this->lng->txt("dcl_update_record"));
352  if (!$this->ctrl->isAsynch()) {
353  $this->form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
354  }
355  } else {
356  $this->form->setTitle($this->lng->txt("dcl_add_new_record"));
357  $this->form->addCommandButton("save", $this->lng->txt("save"));
358  if (!$this->ctrl->isAsynch()) {
359  $this->form->addCommandButton("cancelSave", $this->lng->txt("cancel"));
360  }
361  }
362  $this->ctrl->setParameter($this, "tableview_id", $this->tableview_id);
363  $this->ctrl->setParameter($this, "table_id", $this->table_id);
364  $this->ctrl->setParameter($this, "record_id", $this->record_id);
365  }
366 
367 
373  public function setFormValues()
374  {
375  //Get Record-Values
376  $record_obj = ilDclCache::getRecordCache($this->record_id);
377  if ($record_obj->getId()) {
378  //Get Table Field Definitions
379  $allFields = $this->table->getFields();
380  foreach ($allFields as $field) {
381  if ($field->getDatatypeId() !== ilDclDatatype::INPUTFORMAT_NONE &&
382  $field->getViewSetting($this->tableview_id)->isVisibleEdit()) {
383  $record_obj->fillRecordFieldFormInput($field->getId(), $this->form);
384  }
385  }
386  } else {
387  $this->form->setValuesByPost();
388  }
389 
390  return true;
391  }
392 
393 
397  public function cancelUpdate()
398  {
399  $this->checkAndPerformRedirect(true);
400  }
401 
402 
406  public function cancelSave()
407  {
408  $this->cancelUpdate();
409  }
410 
411 
412  public function saveConfirmation(ilDclBaseRecordModel $record_obj, $filehash)
413  {
414  $permission = ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id);
415  if ($permission) {
416  $all_fields = $this->table->getRecordFields();
417  } else {
418  $all_fields = $this->table->getEditableFields(!$this->record_id);
419  }
420 
421  $date_obj = new ilDateTime(time(), IL_CAL_UNIX);
422  $record_obj->setTableId($this->table_id);
423  $record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
424  $record_obj->setLastEditBy($this->user->getId());
425 
426  $confirmation = new ilConfirmationGUI();
427  $confirmation->setFormAction($this->ctrl->getFormAction($this));
428  $header_text = $this->lng->txt('dcl_confirm_storing_records');
429  if (!$permission && !ilObjDataCollectionAccess::hasEditAccess($this->parent_obj->ref_id)
430  && !$this->table->getEditByOwner()
431  && !$this->table->getEditPerm()
432  ) {
433  $header_text .= " " . $this->lng->txt('dcl_confirm_storing_records_no_permission');
434  }
435  $confirmation->setHeaderText($header_text);
436 
437  $confirmation->setCancel($this->lng->txt('dcl_edit_record'), 'edit');
438  $confirmation->setConfirm($this->lng->txt('dcl_save_record'), 'save');
439 
440  $record_data = "";
441 
442  $empty_fileuploads = array();
443  foreach ($all_fields as $field) {
444  $record_field = $record_obj->getRecordField($field->getId());
446  $record_field->addHiddenItemsToConfirmation($confirmation);
447 
448  if (($record_field instanceof ilDclFileuploadRecordFieldModel || $record_field instanceof ilDclMobRecordFieldModel)
449  && $record_field->getValue() == null
450  ) {
451  $empty_fileuploads['field_' . $field->getId()] = array("name" => "", "type" => "", "tmp_name" => "", "error" => 4, "size" => 0);
452  }
453  $record_representation = ilDclFieldFactory::getRecordRepresentationInstance($record_field);
454 
455  if ($record_representation->getConfirmationHTML() !== false) {
456  $record_data .= $field->getTitle() . ": " . $record_representation->getConfirmationHTML() . "<br />";
457  }
458  }
459 
460  $confirmation->addHiddenItem('ilfilehash', $filehash);
461  $confirmation->addHiddenItem('empty_fileuploads', htmlspecialchars(json_encode($empty_fileuploads)));
462  $confirmation->addHiddenItem('table_id', $this->table_id);
463  $confirmation->addHiddenItem('tableview_id', $this->tableview_id);
464  $confirmation->addItem('save_confirmed', 1, $record_data);
465 
466  if ($this->ctrl->isAsynch()) {
467  echo $confirmation->getHTML();
468  exit();
469  } else {
470  $this->tpl->setContent($confirmation->getHTML());
471  }
472  }
473 
474 
478  public function save()
479  {
480  global $DIC;
481  $ilAppEventHandler = $DIC['ilAppEventHandler'];
482 
483  $this->initForm();
484 
485  // if save confirmation is enabled: Temporary file-uploads need to be handled
486  if ($this->table->getSaveConfirmation() && isset($_POST['save_confirmed']) && isset($_POST['ilfilehash']) && !isset($this->record_id) && !$this->ctrl->isAsynch()) {
488 
489  //handle empty fileuploads, since $_FILES has to have an entry for each fileuploadGUI
490  if (json_decode($_POST['empty_fileuploads']) && $_POST['empty_fileuploads'] != '') {
491  $_FILES = $_FILES + json_decode($_POST['empty_fileuploads'], true);
492  }
493 
494  unset($_SESSION['record_form_values']);
495  }
496 
497  $valid = $this->form->checkInput();
498 
499  $record_obj = ilDclCache::getRecordCache($this->record_id);
500  $unchanged_obj = $record_obj;
501  $date_obj = new ilDateTime(time(), IL_CAL_UNIX);
502  $record_obj->setTableId($this->table_id);
503  $record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
504  $record_obj->setLastEditBy($this->user->getId());
505 
506  $create_mode = !isset($this->record_id);
507 
508  if (ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id) || $create_mode) {
509  $all_fields = $this->table->getRecordFields();
510  } else {
511  $all_fields = $this->table->getEditableFields(!$this->record_id);
512  }
513 
514  //Check if we can create this record.
515  foreach ($all_fields as $field) {
516  try {
517  $field->checkValidityFromForm($this->form, $this->record_id);
518  } catch (ilDclInputException $e) {
519  $valid = false;
520  $item = $this->form->getItemByPostVar('field_' . $field->getId());
521  $item->setAlert($e);
522  }
523  }
524 
525  if (!$valid) {
526  $this->sendFailure($this->lng->txt('form_input_not_valid'));
527 
528  return;
529  }
530 
531  if ($valid) {
532  if ($create_mode) {
533  if (!(ilObjDataCollectionAccess::hasPermissionToAddRecord($this->parent_obj->ref_id, $this->table_id))) {
534  $this->accessDenied();
535 
536  return;
537  }
538 
539  // when save_confirmation is enabled, not yet confirmed and we have not an async-request => prepare for displaying confirmation
540  if ($this->table->getSaveConfirmation() && $this->form->getInput('save_confirmed') == null && !$this->ctrl->isAsynch()) {
541  // temporary store fileuploads (reuse code from ilPropertyFormGUI)
542  $hash = $_POST["ilfilehash"];
543  foreach ($_FILES as $field => $data) {
544  if (is_array($data["tmp_name"])) {
545  foreach ($data["tmp_name"] as $idx => $upload) {
546  if (is_array($upload)) {
547  foreach ($upload as $idx2 => $file) {
548  if ($file && is_uploaded_file($file)) {
549  $file_name = $data["name"][$idx][$idx2];
550  $file_type = $data["type"][$idx][$idx2];
551  $this->form->keepTempFileUpload($hash, $field, $file, $file_name, $file_type, $idx, $idx2);
552  }
553  }
554  } else {
555  if ($upload && is_uploaded_file($upload)) {
556  $file_name = $data["name"][$idx];
557  $file_type = $data["type"][$idx];
558  $this->form->keepTempFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
559  }
560  }
561  }
562  } else {
563  $this->form->keepTempFileUpload($hash, $field, $data["tmp_name"], $data["name"], $data["type"]);
564  }
565  }
566 
567  //edit values, they are valid we already checked them above
568  foreach ($all_fields as $field) {
569  $record_obj->setRecordFieldValueFromForm($field->getId(), $this->form);
570  }
571 
572  $this->saveConfirmation($record_obj, $hash);
573 
574  return;
575  }
576 
577  $record_obj->setOwner($this->user->getId());
578  $record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
579  $record_obj->setTableId($this->table_id);
580  $record_obj->doCreate();
581 
582  $this->record_id = $record_obj->getId();
583  $create_mode = true;
584  } else {
585  if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
586  $this->accessDenied();
587 
588  return;
589  }
590  }
591 
592  //edit values, they are valid we already checked them above
593  foreach ($all_fields as $field) {
594  $field_setting = $field->getViewSetting($this->tableview_id);
595 
596  if ($field_setting->isVisibleInForm($create_mode) &&
597  (!$field_setting->isLocked($create_mode) || ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id))) {
598  // set all visible fields
599  $record_obj->setRecordFieldValueFromForm($field->getId(), $this->form);
600  } elseif ($create_mode) {
601  // set default values when creating
603  $field_setting->getFieldObject()->getDatatypeId(),
604  $field_setting->getId()
605  );
606  if ($default_value !== null) {
607  $record_obj->setRecordFieldValue($field->getId(), $default_value->getValue());
608  }
609  }
610  }
611 
612  // Do we need to set a new owner for this record?
613  if (!$create_mode && $this->tableview->getFieldSetting('owner')->isVisibleEdit()) {
614  $owner_id = ilObjUser::_lookupId($_POST['field_owner']);
615  if (!$owner_id) {
616  $this->sendFailure($this->lng->txt('user_not_known'));
617 
618  return;
619  }
620  $record_obj->setOwner($owner_id);
621  }
622 
623  $dispatchEvent = "update";
624 
625  $dispatchEventData = array(
626  'dcl' => $this->parent_obj->getDataCollectionObject(),
627  'table_id' => $this->table_id,
628  'record_id' => $record_obj->getId(),
629  'record' => $record_obj,
630  );
631 
632  if ($create_mode) {
633  $dispatchEvent = "create";
634  $objDataCollection = new ilObjDataCollection($_GET['ref_id']);
635  $objDataCollection->sendNotification("new_record", $this->table_id, $record_obj->getId());
636  } else {
637  $dispatchEventData['prev_record'] = $unchanged_obj;
638  }
639 
640  $record_obj->doUpdate($create_mode);
641 
642  $ilAppEventHandler->raise(
643  'Modules/DataCollection',
644  $dispatchEvent . 'Record',
645  $dispatchEventData
646  );
647 
648  $this->ctrl->setParameter($this, "table_id", $this->table_id);
649  $this->ctrl->setParameter($this, "tableview_id", $this->tableview_id);
650  $this->ctrl->setParameter($this, "record_id", $this->record_id);
651 
652  if (!$this->ctrl->isAsynch()) {
653  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
654  }
655 
656  $this->checkAndPerformRedirect();
657  if ($this->ctrl->isAsynch()) {
658  // If ajax request, return the form in edit mode again
659  $this->record_id = $record_obj->getId();
660  $this->initForm();
661  $this->setFormValues();
662  echo ilUtil::getSystemMessageHTML($this->lng->txt('msg_obj_modified'), 'success') . $this->form->getHTML();
663  exit();
664  } else {
665  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
666  }
667  } else {
668  // Form not valid...
669  //TODO: URL title flushes on invalid form
670  $this->form->setValuesByPost();
671  if ($this->ctrl->isAsynch()) {
672  echo $this->form->getHTML();
673  exit();
674  } else {
675  $this->tpl->setContent($this->getLanguageJsKeys() . $this->form->getHTML());
676  }
677  }
678  }
679 
680 
685  protected function checkAndPerformRedirect($force_redirect = false)
686  {
687  if ($force_redirect || (isset($_GET['redirect']) && !$this->ctrl->isAsynch())) {
688  switch ((int) $_GET['redirect']) {
689  case self::REDIRECT_DETAIL:
690  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'record_id', $this->record_id);
691  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'table_id', $this->table_id);
692  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'tableview_id', $this->tableview_id);
693  $this->ctrl->redirectByClass("ilDclDetailedViewGUI", "renderRecord");
694  break;
695  case self::REDIRECT_RECORD_LIST:
696  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
697  break;
698  default:
699  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
700  }
701  }
702  }
703 
704 
705  protected function accessDenied()
706  {
707  if (!$this->ctrl->isAsynch()) {
708  ilUtil::sendFailure($this->lng->txt('dcl_msg_no_perm_edit'), true);
709  $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
710  } else {
711  echo $this->lng->txt('dcl_msg_no_perm_edit');
712  exit();
713  }
714  }
715 
716 
720  protected function sendFailure($message)
721  {
722  $keep = ($this->ctrl->isAsynch()) ? false : true;
723  $this->form->setValuesByPost();
724  if ($this->ctrl->isAsynch()) {
725  echo ilUtil::getSystemMessageHTML($message, 'failure') . $this->form->getHTML();
726  exit();
727  } else {
729 
730  // Fill locked fields on edit mode - otherwise they are empty (workaround)
731  if (isset($this->record_id)) {
732  $record_obj = ilDclCache::getRecordCache($this->record_id);
733  if ($record_obj->getId()) {
734  //Get Table Field Definitions
735  $allFields = $this->table->getFields();
736  foreach ($allFields as $field) {
737  $field_setting = $field->getViewSetting($this->tableview_id);
738  if (
739  $field_setting->isLockedEdit() &&
740  $field_setting->isVisibleEdit()
741  ) {
742  $record_obj->fillRecordFieldFormInput($field->getId(), $this->form);
743  }
744  }
745  }
746  }
747 
748  $this->tpl->setContent($this->getLanguageJsKeys() . $this->form->getHTML());
749  }
750  }
751 
752 
756  public function searchObjects()
757  {
758  $search = $_POST['search_for'];
759  $dest = $_POST['dest'];
760  $html = "";
761  $query_parser = new ilQueryParser($search);
762  $query_parser->setMinWordLength(1, true);
763  $query_parser->setCombination(QP_COMBINATION_AND);
764  $query_parser->parse();
765  if (!$query_parser->validate()) {
766  $html .= $query_parser->getMessage() . "<br />";
767  }
768 
769  // only like search since fulltext does not support search with less than 3 characters
770  $object_search = new ilLikeObjectSearch($query_parser);
771  $res = $object_search->performSearch();
772  //$res->setRequiredPermission('copy');
773  $res->filter(ROOT_FOLDER_ID, true);
774 
775  if (!count($results = $res->getResultsByObjId())) {
776  $html .= $this->lng->txt('dcl_no_search_results_found_for') . ' ' . $search . "<br />";
777  }
779 
780  foreach ($results as $entry) {
781  $tpl = new ilTemplate("tpl.dcl_tree.html", true, true, "Modules/DataCollection");
782  foreach ((array) $entry['refs'] as $reference) {
783  $path = new ilPathGUI();
784  $tpl->setCurrentBlock('result');
785  $tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " » " . $entry['title']);
786  $tpl->setVariable('RESULT_REF', $reference);
787  $tpl->setVariable('FIELD_ID', $dest);
788  $tpl->parseCurrentBlock();
789  }
790  $html .= $tpl->get();
791  }
792 
793  echo $html;
794  exit;
795  }
796 
797 
798  protected function getLanguageJsKeys()
799  {
800  return "<script>ilDataCollection.strings.add_value='" . $this->lng->txt('add_value') . "';</script>";
801  }
802 
803 
811  protected function parseSearchResults($a_res)
812  {
813  $rows = array();
814  foreach ($a_res as $obj_id => $references) {
815  $r = array();
816  $r['title'] = ilObject::_lookupTitle($obj_id);
817  $r['desc'] = ilObject::_lookupDescription($obj_id);
818  $r['obj_id'] = $obj_id;
819  $r['refs'] = $references;
820  $rows[] = $r;
821  }
822 
823  return $rows;
824  }
825 
826 
830  protected function cleanupTempFiles()
831  {
832  $ilfilehash = (isset($_POST['ilfilehash'])) ? $_POST['ilfilehash'] : null;
833  if ($ilfilehash != null) {
834  $this->form->cleanupTempFiles($ilfilehash);
835  }
836  }
837 
838 
842  public function getForm()
843  {
844  return $this->form;
845  }
846 }
setFormValues()
Set values from object to form.
Creates a path for a start and endnode.
Class ilDclPropertyFormGUI.
exit
Definition: login.php:29
cleanupTempFiles()
Cleanup temp-files.
$data
Definition: storeScorm.php:23
const IL_CAL_DATETIME
$_SESSION["AccountId"]
static hasPermissionToAddRecord($ref_id, $table_id)
const ROOT_FOLDER_ID
Definition: constants.php:30
$_GET["client_id"]
Class ilDclRecordEditGUI.
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
$valid
Class ilDclBaseFieldModel.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupTitle($a_id)
lookup object title
create()
Create new record gui.
setRecordFieldValue($field_id, $value)
Set a field value.
const IL_CAL_UNIX
static getTableCache($table_id=0)
setCreateDate($a_datetime)
Set Creation Date.
setLastUpdate($a_datetime)
Set Last Update Date.
user()
Definition: user.php:4
static getFieldRepresentation(ilDclBaseFieldModel $field)
__construct(ilObjDataCollectionGUI $parent_obj)
parseSearchResults($a_res)
Parse search results.
This class represents a hidden form property in a property form.
Class ilObjDataCollectionGUI.
foreach($_POST as $key=> $value) $res
searchObjects()
This function is only used by the ajax request if searching for ILIAS references. ...
static rebuildTempFileByHash($hash)
Return temp files.
static _lookupDescription($a_id)
lookup object description
static hasEditAccess($ref, $user_id=0)
Has permission to view and edit all entries event when he is not the owner.
const REDIRECT_RECORD_LIST
Possible redirects after saving/updating a record - use GET[&#39;redirect&#39;] to set constants.
static getRecordCache($record_id=0)
global $DIC
Definition: goto.php:24
confirmDelete()
Delete confirmation.
static getRecordRepresentation(ilDclBaseRecordFieldModel $record_field)
Returns a record representation.
$results
getRecordData($record_id=0)
Return All fields and values from a record ID.
cancelDelete()
Cancel deletion.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$rows
Definition: xhr_table.php:10
static getRecordRepresentationInstance(ilDclBaseRecordFieldModel $record_field)
Get RecordRepresentation from RecordFieldModel.
static getRecordFieldCache($record, $field)
Class ilDclBaseRecordModel.
checkAndPerformRedirect($force_redirect=false)
Checkes to what view (table or detail) should be redirected and performs redirect.
setRecordFieldValueFromForm($field_id, &$form)
Set a field value.
Class ilDclMobRecordFieldModel.
static findOrGetInstance($primary_key, array $add_constructor_args=array())
Class ilDclCheckboxInputGUI.
doUpdate($omit_notification=false)
doUpdate
$message
Definition: xapiexit.php:14
const QP_COMBINATION_AND
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ilUser
Definition: imgupload.php:18
Class ilObjDataCollection.
$_POST["username"]
fillRecordFieldFormInput($field_id, &$form)
Confirmation screen class.