ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilDclRecordEditGUI Class Reference

Class ilDclRecordEditGUI. More...

+ Collaboration diagram for ilDclRecordEditGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $parent_obj)
 
 executeCommand ()
 
 getRecord ()
 
 create ()
 Create new record gui. More...
 
 edit ()
 Record edit gui. More...
 
 confirmDelete ()
 Delete confirmation. More...
 
 cancelDelete ()
 Cancel deletion. More...
 
 delete ()
 Remove record. More...
 
 getRecordData ($record_id=0)
 Return All fields and values from a record ID. More...
 
 initForm ()
 init Form More...
 
 setFormValues ()
 Set values from object to form. More...
 
 cancelUpdate ()
 Cancel Update. More...
 
 cancelSave ()
 Cancel Save. More...
 
 save ()
 Save record. More...
 
 searchObjects ()
 This function is only used by the ajax request if searching for ILIAS references. More...
 
 getForm ()
 

Data Fields

const REDIRECT_RECORD_LIST = 1
 Possible redirects after saving/updating a record - use GET['redirect'] to set constants. More...
 
const REDIRECT_DETAIL = 2
 

Protected Member Functions

 checkAndPerformRedirect ($force_redirect=false)
 Checkes to what view (table or detail) should be redirected and performs redirect. More...
 
 accessDenied ()
 
 sendFailure ($message)
 
 getLanguageJsKeys ()
 
 parseSearchResults ($a_res)
 Parse search results. More...
 
 cleanupTempFiles ()
 Cleanup temp-files. More...
 

Protected Attributes

 $record_id
 
 $table_id
 
 $table
 
 $parent_obj
 
 $record
 
 $ctrl
 
 $tpl
 
 $lng
 
 $user
 
 $form
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclRecordEditGUI::__construct ( ilObjDataCollectionGUI  $parent_obj)
Parameters
ilObjDataCollectionGUI$parent_obj

Definition at line 69 of file class.ilDclRecordEditGUI.php.

References $DIC, $ilCtrl, $ilUser, $lng, $parent_obj, $tpl, and user().

70  {
71  global $DIC;
72  $ilCtrl = $DIC['ilCtrl'];
73  $tpl = $DIC['tpl'];
74  $lng = $DIC['lng'];
75  $ilUser = $DIC['ilUser'];
76 
77  $this->ctrl = $ilCtrl;
78  $this->tpl = $tpl;
79  $this->lng = $lng;
80  $this->user = $ilUser;
81  $this->parent_obj = $parent_obj;
82  $this->record_id = $_REQUEST['record_id'];
83  $this->table_id = $_REQUEST['table_id'];
84  $this->tableview_id = $_REQUEST['tableview_id'];
85  }
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ accessDenied()

ilDclRecordEditGUI::accessDenied ( )
protected

Definition at line 645 of file class.ilDclRecordEditGUI.php.

References exit, and ilUtil\sendFailure().

Referenced by delete(), getRecord(), and save().

646  {
647  if (!$this->ctrl->isAsynch()) {
648  ilUtil::sendFailure($this->lng->txt('dcl_msg_no_perm_edit'), true);
649  $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
650  } else {
651  echo $this->lng->txt('dcl_msg_no_perm_edit');
652  exit();
653  }
654  }
exit
Definition: login.php:29
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelDelete()

ilDclRecordEditGUI::cancelDelete ( )

Cancel deletion.

Definition at line 206 of file class.ilDclRecordEditGUI.php.

207  {
208  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
209  }

◆ cancelSave()

◆ cancelUpdate()

ilDclRecordEditGUI::cancelUpdate ( )

Cancel Update.

Definition at line 352 of file class.ilDclRecordEditGUI.php.

References checkAndPerformRedirect().

Referenced by cancelSave().

353  {
354  $this->checkAndPerformRedirect(true);
355  }
checkAndPerformRedirect($force_redirect=false)
Checkes to what view (table or detail) should be redirected and performs redirect.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAndPerformRedirect()

ilDclRecordEditGUI::checkAndPerformRedirect (   $force_redirect = false)
protected

Checkes to what view (table or detail) should be redirected and performs redirect.

Definition at line 625 of file class.ilDclRecordEditGUI.php.

References $_GET.

Referenced by cancelUpdate(), and save().

626  {
627  if ($force_redirect || (isset($_GET['redirect']) && !$this->ctrl->isAsynch())) {
628  switch ((int) $_GET['redirect']) {
629  case self::REDIRECT_DETAIL:
630  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'record_id', $this->record_id);
631  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'table_id', $this->table_id);
632  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'tableview_id', $this->tableview_id);
633  $this->ctrl->redirectByClass("ilDclDetailedViewGUI", "renderRecord");
634  break;
635  case self::REDIRECT_RECORD_LIST:
636  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
637  break;
638  default:
639  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
640  }
641  }
642  }
$_GET["client_id"]
+ Here is the caller graph for this function:

◆ cleanupTempFiles()

ilDclRecordEditGUI::cleanupTempFiles ( )
protected

Cleanup temp-files.

Definition at line 751 of file class.ilDclRecordEditGUI.php.

References $_POST.

Referenced by edit().

752  {
753  $ilfilehash = (isset($_POST['ilfilehash'])) ? $_POST['ilfilehash'] : null;
754  if ($ilfilehash != null) {
755  $this->form->cleanupTempFiles($ilfilehash);
756  }
757  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDclRecordEditGUI::confirmDelete ( )

Delete confirmation.

Exceptions
ilDclException

Definition at line 177 of file class.ilDclRecordEditGUI.php.

References $record, ilDclCache\getRecordCache(), ilDclCache\getRecordFieldCache(), and ilDclCache\getRecordRepresentation().

178  {
179  $conf = new ilConfirmationGUI();
180  $conf->setFormAction($this->ctrl->getFormAction($this));
181  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_record'));
182  $record = ilDclCache::getRecordCache($this->record_id);
183 
184  $all_fields = $this->table->getRecordFields();
185  $record_data = "";
186  foreach ($all_fields as $key => $field) {
187  $field_record = ilDclCache::getRecordFieldCache($record, $field);
188 
189  $record_representation = ilDclCache::getRecordRepresentation($field_record);
190  if ($record_representation->getConfirmationHTML() !== false) {
191  $record_data .= $field->getTitle() . ": " . $record_representation->getConfirmationHTML() . "<br />";
192  }
193  }
194  $conf->addItem('record_id', $record->getId(), $record_data);
195  $conf->addHiddenItem('table_id', $this->table_id);
196  $conf->addHiddenItem('tableview_id', $this->tableview_id);
197  $conf->setConfirm($this->lng->txt('delete'), 'delete');
198  $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
199  $this->tpl->setContent($conf->getHTML());
200  }
static getRecordCache($record_id=0)
static getRecordRepresentation(ilDclBaseRecordFieldModel $record_field)
Returns a record representation.
static getRecordFieldCache($record, $field)
Confirmation screen class.
+ Here is the call graph for this function:

◆ create()

ilDclRecordEditGUI::create ( )

Create new record gui.

Definition at line 136 of file class.ilDclRecordEditGUI.php.

References exit, getLanguageJsKeys(), and initForm().

137  {
138  $this->initForm();
139  if ($this->ctrl->isAsynch()) {
140  echo $this->form->getHTML();
141  exit();
142  } else {
143  $this->tpl->setContent(
144  $this->getLanguageJsKeys()
145  . $this->form->getHTML()
146  );
147  }
148  }
exit
Definition: login.php:29
+ Here is the call graph for this function:

◆ delete()

ilDclRecordEditGUI::delete ( )

Remove record.

Definition at line 215 of file class.ilDclRecordEditGUI.php.

References $record, accessDenied(), and ilDclCache\getRecordCache().

216  {
217  $record = ilDclCache::getRecordCache($this->record_id);
218 
219  if (!$this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id, $record)) {
220  $this->accessDenied();
221 
222  return;
223  }
224 
225  $record->doDelete();
226  ilUtil::sendSuccess($this->lng->txt("dcl_record_deleted"), true);
227  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
228  }
static getRecordCache($record_id=0)
+ Here is the call graph for this function:

◆ edit()

ilDclRecordEditGUI::edit ( )

Record edit gui.

Definition at line 154 of file class.ilDclRecordEditGUI.php.

References cleanupTempFiles(), exit, getLanguageJsKeys(), initForm(), and setFormValues().

155  {
156  $this->initForm();
157  $this->cleanupTempFiles();
158 
159  $this->setFormValues();
160  if ($this->ctrl->isAsynch()) {
161  echo $this->form->getHTML();
162  exit();
163  } else {
164  $this->tpl->setContent(
165  $this->getLanguageJsKeys()
166  . $this->form->getHTML()
167  );
168  }
169  }
setFormValues()
Set values from object to form.
exit
Definition: login.php:29
cleanupTempFiles()
Cleanup temp-files.
+ Here is the call graph for this function:

◆ executeCommand()

ilDclRecordEditGUI::executeCommand ( )
Returns
bool

Definition at line 91 of file class.ilDclRecordEditGUI.php.

References getRecord().

92  {
93  $this->getRecord();
94 
95  $cmd = $this->ctrl->getCmd();
96  switch ($cmd) {
97  default:
98  $this->$cmd();
99  break;
100  }
101 
102  return true;
103  }
+ Here is the call graph for this function:

◆ getForm()

ilDclRecordEditGUI::getForm ( )
Returns
ilDclPropertyFormGUI

Definition at line 763 of file class.ilDclRecordEditGUI.php.

References $form.

764  {
765  return $this->form;
766  }

◆ getLanguageJsKeys()

ilDclRecordEditGUI::getLanguageJsKeys ( )
protected

Definition at line 719 of file class.ilDclRecordEditGUI.php.

Referenced by create(), edit(), save(), and sendFailure().

720  {
721  return "<script>ilDataCollection.strings.add_value='" . $this->lng->txt('add_value') . "';</script>";
722  }
+ Here is the caller graph for this function:

◆ getRecord()

ilDclRecordEditGUI::getRecord ( )

Definition at line 109 of file class.ilDclRecordEditGUI.php.

References $_GET, accessDenied(), ilDclCache\getRecordCache(), ilDclCache\getTableCache(), and ilObjDataCollectionAccess\hasAddRecordAccess().

Referenced by executeCommand().

110  {
111  if ($_GET['mode']) {
112  $this->ctrl->saveParameter($this, 'mode');
113  $this->ctrl->setParameterByClass("ildclrecordlistgui", "mode", $_GET['mode']);
114  }
115  $this->ctrl->setParameterByClass('ildclrecordlistgui', 'tableview_id', $this->tableview_id);
116  $this->ctrl->saveParameter($this, 'redirect');
117  if ($this->record_id) {
118  $this->record = ilDclCache::getRecordCache($this->record_id);
119  if (!$this->record->hasPermissionToEdit($this->parent_obj->ref_id) or !$this->record->hasPermissionToView($this->parent_obj->ref_id)) {
120  $this->accessDenied();
121  }
122  $this->table = $this->record->getTable();
123  $this->table_id = $this->table->getId();
124  } else {
125  $this->table = ilDclCache::getTableCache($this->table_id);
127  $this->accessDenied();
128  }
129  }
130  }
$_GET["client_id"]
static getTableCache($table_id=0)
static getRecordCache($record_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecordData()

ilDclRecordEditGUI::getRecordData (   $record_id = 0)

Return All fields and values from a record ID.

If this method is requested over AJAX, data is returned in JSON format

Parameters
int$record_id
Returns
array

Definition at line 239 of file class.ilDclRecordEditGUI.php.

References $_GET, $record, $record_id, exit, and ilDclCache\getRecordCache().

240  {
241  $record_id = ($record_id) ? $record_id : $_GET['record_id'];
242  $return = array();
243  if ($record_id) {
245  if (is_object($record)) {
246  $return = $record->getRecordFieldValues();
247  }
248  }
249  if ($this->ctrl->isAsynch()) {
250  echo json_encode($return);
251  exit();
252  }
253 
254  return $return;
255  }
exit
Definition: login.php:29
$_GET["client_id"]
static getRecordCache($record_id=0)
+ Here is the call graph for this function:

◆ initForm()

ilDclRecordEditGUI::initForm ( )

init Form

move parts to RecordRepresentationGUI

Definition at line 263 of file class.ilDclRecordEditGUI.php.

References ilDclCache\getFieldRepresentation(), and ilObjDataCollectionAccess\hasWriteAccess().

Referenced by create(), edit(), and save().

264  {
265  $this->form = new ilDclPropertyFormGUI();
266  $prefix = ($this->ctrl->isAsynch()) ? 'dclajax' : 'dcl'; // Used by datacolleciton.js to select input elements
267  $this->form->setId($prefix . $this->table_id . $this->record_id);
268 
269  $hidden_prop = new ilHiddenInputGUI("table_id");
270  $hidden_prop->setValue($this->table_id);
271  $this->form->addItem($hidden_prop);
272  $hidden_prop = new ilHiddenInputGUI("tableview_id");
273  $hidden_prop->setValue($this->tableview_id);
274  $this->form->addItem($hidden_prop);
275  if ($this->record_id) {
276  $hidden_prop = new ilHiddenInputGUI("record_id");
277  $hidden_prop->setValue($this->record_id);
278  $this->form->addItem($hidden_prop);
279  }
280 
281  $this->ctrl->setParameter($this, "record_id", $this->record_id);
282  $this->form->setFormAction($this->ctrl->getFormAction($this));
283  $allFields = $this->table->getRecordFields();
284  $inline_css = '';
285  foreach ($allFields as $field) {
286  $item = ilDclCache::getFieldRepresentation($field)->getInputField($this->form, $this->record_id);
287  if ($item === null) {
288  continue; // Fields calculating values at runtime, e.g. ilDclFormulaFieldModel do not have input
289  }
290 
291  if (!ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id) && $field->getLocked()) {
292  $item->setDisabled(true);
293  }
294  $this->form->addItem($item);
295  }
296 
297  $this->tpl->addInlineCss($inline_css);
298 
299  // Add possibility to change the owner in edit mode
300  if ($this->record_id) {
301  $ownerField = $this->table->getField('owner');
302  $inputfield = ilDclCache::getFieldRepresentation($ownerField)->getInputField($this->form);
303  $this->form->addItem($inputfield);
304  }
305 
306  // save and cancel commands
307  if ($this->record_id) {
308  $this->form->setTitle($this->lng->txt("dcl_update_record"));
309  $this->form->addCommandButton("save", $this->lng->txt("dcl_update_record"));
310  if (!$this->ctrl->isAsynch()) {
311  $this->form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
312  }
313  } else {
314  $this->form->setTitle($this->lng->txt("dcl_add_new_record"));
315  $this->form->addCommandButton("save", $this->lng->txt("save"));
316  if (!$this->ctrl->isAsynch()) {
317  $this->form->addCommandButton("cancelSave", $this->lng->txt("cancel"));
318  }
319  }
320  $this->ctrl->setParameter($this, "tableview_id", $this->tableview_id);
321  $this->ctrl->setParameter($this, "table_id", $this->table_id);
322  $this->ctrl->setParameter($this, "record_id", $this->record_id);
323  }
Class ilDclPropertyFormGUI.
static getFieldRepresentation(ilDclBaseFieldModel $field)
This class represents a hidden form property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseSearchResults()

ilDclRecordEditGUI::parseSearchResults (   $a_res)
protected

Parse search results.

Parameters
ilObject[]$a_res
Returns
array

Definition at line 732 of file class.ilDclRecordEditGUI.php.

References $rows, ilObject\_lookupDescription(), and ilObject\_lookupTitle().

Referenced by searchObjects().

733  {
734  $rows = array();
735  foreach ($a_res as $obj_id => $references) {
736  $r = array();
737  $r['title'] = ilObject::_lookupTitle($obj_id);
738  $r['desc'] = ilObject::_lookupDescription($obj_id);
739  $r['obj_id'] = $obj_id;
740  $r['refs'] = $references;
741  $rows[] = $r;
742  }
743 
744  return $rows;
745  }
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
$rows
Definition: xhr_table.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDclRecordEditGUI::save ( )

Save record.

Definition at line 433 of file class.ilDclRecordEditGUI.php.

References $_POST, $_SESSION, $data, $DIC, Vendor\Package\$e, $form, $ilUser, $table_id, $valid, ilObjUser\_lookupId(), accessDenied(), checkAndPerformRedirect(), ilDclBaseRecordModel\doCreate(), ilDclBaseRecordModel\doUpdate(), exit, ilDclBaseRecordModel\getId(), getLanguageJsKeys(), ilDclCache\getRecordCache(), ilUtil\getSystemMessageHTML(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ilDclBaseRecordModel\hasPermissionToEdit(), ilObjDataCollectionAccess\hasWriteAccess(), IL_CAL_DATETIME, IL_CAL_UNIX, initForm(), ilDclPropertyFormGUI\rebuildTempFileByHash(), sendFailure(), ilDclBaseRecordModel\setCreateDate(), setFormValues(), ilDclBaseRecordModel\setLastEditBy(), ilDclBaseRecordModel\setLastUpdate(), ilDclBaseRecordModel\setOwner(), ilDclBaseRecordModel\setRecordFieldValueFromForm(), ilDclBaseRecordModel\setTableId(), and user().

434  {
435  global $DIC;
436  $ilAppEventHandler = $DIC['ilAppEventHandler'];
437  $ilUser = $DIC['ilUser'];
438 
439  $this->initForm();
440 
441  // if save confirmation is enabled: Temporary file-uploads need to be handled
442  if ($this->table->getSaveConfirmation() && isset($_POST['save_confirmed']) && isset($_POST['ilfilehash']) && !isset($this->record_id) && !$this->ctrl->isAsynch()) {
444 
445  //handle empty fileuploads, since $_FILES has to have an entry for each fileuploadGUI
446  if (json_decode($_POST['empty_fileuploads']) && $_POST['empty_fileuploads'] != '') {
447  $_FILES = $_FILES + json_decode($_POST['empty_fileuploads'], true);
448  }
449 
450  unset($_SESSION['record_form_values']);
451  }
452 
453  $valid = $this->form->checkInput();
454 
455  $record_obj = ilDclCache::getRecordCache($this->record_id);
456  $unchanged_obj = $record_obj;
457  $date_obj = new ilDateTime(time(), IL_CAL_UNIX);
458  $record_obj->setTableId($this->table_id);
459  $record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
460  $record_obj->setLastEditBy($this->user->getId());
461 
462  $create_mode = false;
463 
464  if (ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id)) {
465  $all_fields = $this->table->getRecordFields();
466  } else {
467  $all_fields = $this->table->getEditableFields();
468  }
469 
470  //Check if we can create this record.
471  foreach ($all_fields as $field) {
472  try {
473  $field->checkValidityFromForm($this->form, $this->record_id);
474  } catch (ilDclInputException $e) {
475  $valid = false;
476  $item = $this->form->getItemByPostVar('field_' . $field->getId());
477  $item->setAlert($e);
478  }
479  }
480 
481  if (!$valid) {
482  $this->sendFailure($this->lng->txt('form_input_not_valid'));
483 
484  return;
485  }
486 
487  if ($valid) {
488  if (!isset($this->record_id)) {
489  if (!(ilObjDataCollectionAccess::hasPermissionToAddRecord($this->parent_obj->ref_id, $this->table_id))) {
490  $this->accessDenied();
491 
492  return;
493  }
494 
495  // when save_confirmation is enabled, not yet confirmed and we have not an async-request => prepare for displaying confirmation
496  if ($this->table->getSaveConfirmation() && $this->form->getInput('save_confirmed') == null && !$this->ctrl->isAsynch()) {
497  // temporary store fileuploads (reuse code from ilPropertyFormGUI)
498  $hash = $_POST["ilfilehash"];
499  foreach ($_FILES as $field => $data) {
500  if (is_array($data["tmp_name"])) {
501  foreach ($data["tmp_name"] as $idx => $upload) {
502  if (is_array($upload)) {
503  foreach ($upload as $idx2 => $file) {
504  if ($file && is_uploaded_file($file)) {
505  $file_name = $data["name"][$idx][$idx2];
506  $file_type = $data["type"][$idx][$idx2];
507  $this->form->keepTempFileUpload($hash, $field, $file, $file_name, $file_type, $idx, $idx2);
508  }
509  }
510  } else {
511  if ($upload && is_uploaded_file($upload)) {
512  $file_name = $data["name"][$idx];
513  $file_type = $data["type"][$idx];
514  $this->form->keepTempFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
515  }
516  }
517  }
518  } else {
519  $this->form->keepTempFileUpload($hash, $field, $data["tmp_name"], $data["name"], $data["type"]);
520  }
521  }
522 
523  //edit values, they are valid we already checked them above
524  foreach ($all_fields as $field) {
525  $record_obj->setRecordFieldValueFromForm($field->getId(), $this->form);
526  }
527 
528  $this->saveConfirmation($record_obj, $hash);
529 
530  return;
531  }
532 
533  $record_obj->setOwner($this->user->getId());
534  $record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
535  $record_obj->setTableId($this->table_id);
536  $record_obj->doCreate();
537 
538  $this->record_id = $record_obj->getId();
539  $create_mode = true;
540  } else {
541  if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
542  $this->accessDenied();
543 
544  return;
545  }
546  }
547 
548  //edit values, they are valid we already checked them above
549  foreach ($all_fields as $field) {
550  $record_obj->setRecordFieldValueFromForm($field->getId(), $this->form);
551  }
552 
553  // Do we need to set a new owner for this record?
554  if (!$create_mode) {
555  $owner_id = ilObjUser::_lookupId($_POST['field_owner']);
556  if (!$owner_id) {
557  $this->sendFailure($this->lng->txt('user_not_known'));
558 
559  return;
560  }
561  $record_obj->setOwner($owner_id);
562  }
563 
564  $dispatchEvent = "update";
565 
566  $dispatchEventData = array(
567  'dcl' => $this->parent_obj->getDataCollectionObject(),
568  'table_id' => $this->table_id,
569  'record_id' => $record_obj->getId(),
570  'record' => $record_obj,
571  );
572 
573  if ($create_mode) {
574  $dispatchEvent = "create";
575  ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
576  } else {
577  $dispatchEventData['prev_record'] = $unchanged_obj;
578  }
579 
580  $record_obj->doUpdate($create_mode);
581 
582  $ilAppEventHandler->raise(
583  'Modules/DataCollection',
584  $dispatchEvent . 'Record',
585  $dispatchEventData
586  );
587 
588  $this->ctrl->setParameter($this, "table_id", $this->table_id);
589  $this->ctrl->setParameter($this, "tableview_id", $this->tableview_id);
590  $this->ctrl->setParameter($this, "record_id", $this->record_id);
591 
592  if (!$this->ctrl->isAsynch()) {
593  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
594  }
595 
596  $this->checkAndPerformRedirect();
597  if ($this->ctrl->isAsynch()) {
598  // If ajax request, return the form in edit mode again
599  $this->record_id = $record_obj->getId();
600  $this->initForm();
601  $this->setFormValues();
602  echo ilUtil::getSystemMessageHTML($this->lng->txt('msg_obj_modified'), 'success') . $this->form->getHTML();
603  exit();
604  } else {
605  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
606  }
607  } else {
608  // Form not valid...
609  //TODO: URL title flushes on invalid form
610  $this->form->setValuesByPost();
611  if ($this->ctrl->isAsynch()) {
612  echo $this->form->getHTML();
613  exit();
614  } else {
615  $this->tpl->setContent($this->getLanguageJsKeys() . $this->form->getHTML());
616  }
617  }
618  }
setFormValues()
Set values from object to form.
exit
Definition: login.php:29
$data
Definition: storeScorm.php:23
const IL_CAL_DATETIME
$_SESSION["AccountId"]
static hasPermissionToAddRecord($ref_id, $table_id)
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.
const IL_CAL_UNIX
user()
Definition: user.php:4
static rebuildTempFileByHash($hash)
Return temp files.
static getRecordCache($record_id=0)
$ilUser
Definition: imgupload.php:18
checkAndPerformRedirect($force_redirect=false)
Checkes to what view (table or detail) should be redirected and performs redirect.
$DIC
Definition: xapitoken.php:46
$_POST["username"]
+ Here is the call graph for this function:

◆ searchObjects()

ilDclRecordEditGUI::searchObjects ( )

This function is only used by the ajax request if searching for ILIAS references.

It builds the html for the search results.

Definition at line 677 of file class.ilDclRecordEditGUI.php.

References $_POST, $res, $results, $tpl, exit, parseSearchResults(), and QP_COMBINATION_AND.

678  {
679  $search = $_POST['search_for'];
680  $dest = $_POST['dest'];
681  $html = "";
682  $query_parser = new ilQueryParser($search);
683  $query_parser->setMinWordLength(1, true);
684  $query_parser->setCombination(QP_COMBINATION_AND);
685  $query_parser->parse();
686  if (!$query_parser->validate()) {
687  $html .= $query_parser->getMessage() . "<br />";
688  }
689 
690  // only like search since fulltext does not support search with less than 3 characters
691  $object_search = new ilLikeObjectSearch($query_parser);
692  $res = $object_search->performSearch();
693  //$res->setRequiredPermission('copy');
694  $res->filter(ROOT_FOLDER_ID, true);
695 
696  if (!count($results = $res->getResultsByObjId())) {
697  $html .= $this->lng->txt('dcl_no_search_results_found_for') . ' ' . $search . "<br />";
698  }
700 
701  foreach ($results as $entry) {
702  $tpl = new ilTemplate("tpl.dcl_tree.html", true, true, "Modules/DataCollection");
703  foreach ((array) $entry['refs'] as $reference) {
704  $path = new ilPathGUI();
705  $tpl->setCurrentBlock('result');
706  $tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " ยป " . $entry['title']);
707  $tpl->setVariable('RESULT_REF', $reference);
708  $tpl->setVariable('FIELD_ID', $dest);
709  $tpl->parseCurrentBlock();
710  }
711  $html .= $tpl->get();
712  }
713 
714  echo $html;
715  exit;
716  }
Creates a path for a start and endnode.
exit
Definition: login.php:29
parseSearchResults($a_res)
Parse search results.
foreach($_POST as $key=> $value) $res
$results
const QP_COMBINATION_AND
$_POST["username"]
+ Here is the call graph for this function:

◆ sendFailure()

ilDclRecordEditGUI::sendFailure (   $message)
protected
Parameters
$message

Definition at line 660 of file class.ilDclRecordEditGUI.php.

References $message, exit, getLanguageJsKeys(), ilUtil\getSystemMessageHTML(), and ilUtil\sendFailure().

Referenced by save().

661  {
662  $keep = ($this->ctrl->isAsynch()) ? false : true;
663  $this->form->setValuesByPost();
664  if ($this->ctrl->isAsynch()) {
665  echo ilUtil::getSystemMessageHTML($message, 'failure') . $this->form->getHTML();
666  exit();
667  } else {
669  $this->tpl->setContent($this->getLanguageJsKeys() . $this->form->getHTML());
670  }
671  }
exit
Definition: login.php:29
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$message
Definition: xapiexit.php:14
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFormValues()

ilDclRecordEditGUI::setFormValues ( )

Set values from object to form.

Returns
bool

Definition at line 331 of file class.ilDclRecordEditGUI.php.

References $form, and ilDclCache\getRecordCache().

Referenced by edit(), and save().

332  {
333  //Get Record-Values
334  $record_obj = ilDclCache::getRecordCache($this->record_id);
335  if ($record_obj->getId()) {
336  //Get Table Field Definitions
337  $allFields = $this->table->getFields();
338  foreach ($allFields as $field) {
339  $record_obj->fillRecordFieldFormInput($field->getId(), $this->form);
340  }
341  } else {
342  $this->form->setValuesByPost();
343  }
344 
345  return true;
346  }
static getRecordCache($record_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilDclRecordEditGUI::$ctrl
protected

Definition at line 47 of file class.ilDclRecordEditGUI.php.

◆ $form

ilDclRecordEditGUI::$form
protected

Definition at line 63 of file class.ilDclRecordEditGUI.php.

Referenced by getForm(), save(), and setFormValues().

◆ $lng

ilDclRecordEditGUI::$lng
protected

Definition at line 55 of file class.ilDclRecordEditGUI.php.

Referenced by __construct().

◆ $parent_obj

ilDclRecordEditGUI::$parent_obj
protected

Definition at line 39 of file class.ilDclRecordEditGUI.php.

Referenced by __construct().

◆ $record

ilDclRecordEditGUI::$record
protected

Definition at line 43 of file class.ilDclRecordEditGUI.php.

Referenced by confirmDelete(), delete(), and getRecordData().

◆ $record_id

ilDclRecordEditGUI::$record_id
protected

Definition at line 27 of file class.ilDclRecordEditGUI.php.

Referenced by getRecordData().

◆ $table

ilDclRecordEditGUI::$table
protected

Definition at line 35 of file class.ilDclRecordEditGUI.php.

◆ $table_id

ilDclRecordEditGUI::$table_id
protected

Definition at line 31 of file class.ilDclRecordEditGUI.php.

Referenced by save().

◆ $tpl

ilDclRecordEditGUI::$tpl
protected

Definition at line 51 of file class.ilDclRecordEditGUI.php.

Referenced by __construct(), and searchObjects().

◆ $user

ilDclRecordEditGUI::$user
protected

Definition at line 59 of file class.ilDclRecordEditGUI.php.

◆ REDIRECT_DETAIL

const ilDclRecordEditGUI::REDIRECT_DETAIL = 2

Definition at line 23 of file class.ilDclRecordEditGUI.php.

Referenced by ilDclDetailedViewGUI\renderRecord().

◆ REDIRECT_RECORD_LIST

const ilDclRecordEditGUI::REDIRECT_RECORD_LIST = 1

Possible redirects after saving/updating a record - use GET['redirect'] to set constants.

Definition at line 22 of file class.ilDclRecordEditGUI.php.


The documentation for this class was generated from the following file: