ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

Member Function Documentation

◆ accessDenied()

ilDclRecordEditGUI::accessDenied ( )
protected

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

References exit, and ilUtil\sendFailure().

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

644  {
645  if (!$this->ctrl->isAsynch()) {
646  ilUtil::sendFailure($this->lng->txt('dcl_msg_no_perm_edit'), true);
647  $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
648  } else {
649  echo $this->lng->txt('dcl_msg_no_perm_edit');
650  exit();
651  }
652  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
exit
Definition: backend.php:16
+ 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 623 of file class.ilDclRecordEditGUI.php.

References $_GET.

Referenced by cancelUpdate(), and save().

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

◆ cleanupTempFiles()

ilDclRecordEditGUI::cleanupTempFiles ( )
protected

Cleanup temp-files.

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

References $_POST.

Referenced by edit().

753  {
754  $ilfilehash = (isset($_POST['ilfilehash'])) ? $_POST['ilfilehash'] : null;
755  if ($ilfilehash != null) {
756  $this->form->cleanupTempFiles($ilfilehash);
757  }
758  }
$_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 $key, $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)
$key
Definition: croninfo.php:18
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: backend.php:16
+ 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.
cleanupTempFiles()
Cleanup temp-files.
exit
Definition: backend.php:16
+ 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 764 of file class.ilDclRecordEditGUI.php.

References $form.

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

◆ getLanguageJsKeys()

ilDclRecordEditGUI::getLanguageJsKeys ( )
protected

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

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

721  {
722  return "<script>ilDataCollection.strings.add_value='" . $this->lng->txt('add_value') . "';</script>";
723  }
+ 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  }
$_GET["client_id"]
static getRecordCache($record_id=0)
exit
Definition: backend.php:16
+ 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 733 of file class.ilDclRecordEditGUI.php.

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

Referenced by searchObjects().

734  {
735  $rows = array();
736  foreach ($a_res as $obj_id => $references) {
737  $r = array();
738  $r['title'] = ilObject::_lookupTitle($obj_id);
739  $r['desc'] = ilObject::_lookupDescription($obj_id);
740  $r['obj_id'] = $obj_id;
741  $r['refs'] = $references;
742  $rows[] = $r;
743  }
744 
745  return $rows;
746  }
static _lookupTitle($a_id)
lookup object title
$r
Definition: example_031.php:79
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, $form, $ilUser, $table_id, $valid, ilObjUser\_lookupId(), accessDenied(), checkAndPerformRedirect(), ilDclBaseRecordModel\doCreate(), ilDclBaseRecordModel\doUpdate(), exit, ilDclBaseRecordModel\getId(), getLanguageJsKeys(), ilDclCache\getRecordCache(), 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  return;
484  }
485 
486  if ($valid) {
487  if (!isset($this->record_id)) {
488  if (!(ilObjDataCollectionAccess::hasPermissionToAddRecord($this->parent_obj->ref_id, $this->table_id))) {
489  $this->accessDenied();
490  return;
491  }
492 
493  // when save_confirmation is enabled, not yet confirmed and we have not an async-request => prepare for displaying confirmation
494  if ($this->table->getSaveConfirmation() && $this->form->getInput('save_confirmed') == null && !$this->ctrl->isAsynch()) {
495  // temporary store fileuploads (reuse code from ilPropertyFormGUI)
496  $hash = $_POST["ilfilehash"];
497  foreach ($_FILES as $field => $data) {
498  if (is_array($data["tmp_name"])) {
499  foreach ($data["tmp_name"] as $idx => $upload) {
500  if (is_array($upload)) {
501  foreach ($upload as $idx2 => $file) {
502  if ($file && is_uploaded_file($file)) {
503  $file_name = $data["name"][$idx][$idx2];
504  $file_type = $data["type"][$idx][$idx2];
505  $this->form->keepTempFileUpload($hash, $field, $file, $file_name, $file_type, $idx, $idx2);
506  }
507  }
508  } else {
509  if ($upload && is_uploaded_file($upload)) {
510  $file_name = $data["name"][$idx];
511  $file_type = $data["type"][$idx];
512  $this->form->keepTempFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
513  }
514  }
515  }
516  } else {
517  $this->form->keepTempFileUpload($hash, $field, $data["tmp_name"], $data["name"], $data["type"]);
518  }
519  }
520 
521  //edit values, they are valid we already checked them above
522  foreach ($all_fields as $field) {
523  $record_obj->setRecordFieldValueFromForm($field->getId(), $this->form);
524  }
525 
526  $this->saveConfirmation($record_obj, $hash);
527 
528  return;
529  }
530 
531  $record_obj->setOwner($this->user->getId());
532  $record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
533  $record_obj->setTableId($this->table_id);
534  $record_obj->doCreate();
535 
536  $this->record_id = $record_obj->getId();
537  $create_mode = true;
538  } else {
539  if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
540  $this->accessDenied();
541 
542  return;
543  }
544  }
545 
546  //edit values, they are valid we already checked them above
547  foreach ($all_fields as $field) {
548  $record_obj->setRecordFieldValueFromForm($field->getId(), $this->form);
549  }
550 
551  // Do we need to set a new owner for this record?
552  if (!$create_mode) {
553  $owner_id = ilObjUser::_lookupId($_POST['field_owner']);
554  if (!$owner_id) {
555  $this->sendFailure($this->lng->txt('user_not_known'));
556 
557  return;
558  }
559  $record_obj->setOwner($owner_id);
560  }
561 
562  $dispatchEvent = "update";
563 
564  $dispatchEventData = array(
565  'dcl' => $this->parent_obj->getDataCollectionObject(),
566  'table_id' => $this->table_id,
567  'record_id' => $record_obj->getId(),
568  'record' => $record_obj,
569  );
570 
571  if ($create_mode) {
572  $dispatchEvent = "create";
573  ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
574  } else {
575  $dispatchEventData['prev_record'] = $unchanged_obj;
576  }
577 
578  $record_obj->doUpdate($create_mode);
579 
580  $ilAppEventHandler->raise(
581  'Modules/DataCollection',
582  $dispatchEvent . 'Record',
583  $dispatchEventData
584  );
585 
586  $this->ctrl->setParameter($this, "table_id", $this->table_id);
587  $this->ctrl->setParameter($this, "tableview_id", $this->tableview_id);
588  $this->ctrl->setParameter($this, "record_id", $this->record_id);
589 
590  if (!$this->ctrl->isAsynch()) {
591  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
592  }
593 
594  $this->checkAndPerformRedirect();
595  if ($this->ctrl->isAsynch()) {
596  // If ajax request, return the form in edit mode again
597  $this->record_id = $record_obj->getId();
598  $this->initForm();
599  $this->setFormValues();
600  echo $this->tpl->getMessageHTML($this->lng->txt('msg_obj_modified'), 'success') . $this->form->getHTML();
601  exit();
602  } else {
603  $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
604  }
605  } else {
606  // Form not valid...
607  //TODO: URL title flushes on invalid form
608  $this->form->setValuesByPost();
609  if ($this->ctrl->isAsynch()) {
610  echo $this->form->getHTML();
611  exit();
612  } else {
613  $this->tpl->setContent($this->getLanguageJsKeys() . $this->form->getHTML());
614  }
615  }
616  }
setFormValues()
Set values from object to form.
const IL_CAL_DATETIME
$_SESSION["AccountId"]
static hasPermissionToAddRecord($ref_id, $table_id)
global $DIC
Definition: saml.php:7
$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)
Date and time handling
$ilUser
Definition: imgupload.php:18
exit
Definition: backend.php:16
checkAndPerformRedirect($force_redirect=false)
Checkes to what view (table or detail) should be redirected and performs redirect.
$_POST["username"]
$data
Definition: bench.php:6
+ 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 675 of file class.ilDclRecordEditGUI.php.

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

676  {
677  $search = $_POST['search_for'];
678  $dest = $_POST['dest'];
679  $html = "";
680  include_once './Services/Search/classes/class.ilQueryParser.php';
681  $query_parser = new ilQueryParser($search);
682  $query_parser->setMinWordLength(1, true);
683  $query_parser->setCombination(QP_COMBINATION_AND);
684  $query_parser->parse();
685  if (!$query_parser->validate()) {
686  $html .= $query_parser->getMessage() . "<br />";
687  }
688 
689  // only like search since fulltext does not support search with less than 3 characters
690  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
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  include_once './Services/Tree/classes/class.ilPathGUI.php';
705  $path = new ilPathGUI();
706  $tpl->setCurrentBlock('result');
707  $tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " ยป " . $entry['title']);
708  $tpl->setVariable('RESULT_REF', $reference);
709  $tpl->setVariable('FIELD_ID', $dest);
710  $tpl->parseCurrentBlock();
711  }
712  $html .= $tpl->get();
713  }
714 
715  echo $html;
716  exit;
717  }
Creates a path for a start and endnode.
$path
Definition: aliased.php:25
parseSearchResults($a_res)
Parse search results.
foreach($_POST as $key=> $value) $res
special template class to simplify handling of ITX/PEAR
exit
Definition: backend.php:16
$results
Definition: svg-scanner.php:47
const QP_COMBINATION_AND
$_POST["username"]
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ sendFailure()

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

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

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

Referenced by save().

659  {
660  $keep = ($this->ctrl->isAsynch()) ? false : true;
661  $this->form->setValuesByPost();
662  if ($this->ctrl->isAsynch()) {
663  echo $this->tpl->getMessageHTML($message, 'failure') . $this->form->getHTML();
664  exit();
665  } else {
667  $this->tpl->setContent($this->getLanguageJsKeys() . $this->form->getHTML());
668  }
669  }
catch(Exception $e) $message
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
exit
Definition: backend.php:16
+ 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: