ILIAS  release_7 Revision v7.30-3-g800a261c036
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

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

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 }
user()
Definition: user.php:4
static findOrGetInstance($primary_key, array $add_constructor_args=array())
static getTableCache($table_id=0)
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18

References $DIC, $ilUser, $lng, $parent_obj, $tpl, ActiveRecord\findOrGetInstance(), ilDclCache\getTableCache(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ accessDenied()

ilDclRecordEditGUI::accessDenied ( )
protected

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

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 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
exit
Definition: login.php:29

References exit, and ilUtil\sendFailure().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelDelete()

ilDclRecordEditGUI::cancelDelete ( )

Cancel deletion.

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

220 {
221 $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
222 }

◆ cancelSave()

ilDclRecordEditGUI::cancelSave ( )

Cancel Save.

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

407 {
408 $this->cancelUpdate();
409 }

References cancelUpdate().

+ Here is the call graph for this function:

◆ cancelUpdate()

ilDclRecordEditGUI::cancelUpdate ( )

Cancel Update.

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

398 {
399 $this->checkAndPerformRedirect(true);
400 }
checkAndPerformRedirect($force_redirect=false)
Checkes to what view (table or detail) should be redirected and performs redirect.

References checkAndPerformRedirect().

Referenced by cancelSave().

+ 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 685 of file class.ilDclRecordEditGUI.php.

686 {
687 if ($force_redirect || (isset($_GET['redirect']) && !$this->ctrl->isAsynch())) {
688 switch ((int) $_GET['redirect']) {
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;
696 $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
697 break;
698 default:
699 $this->ctrl->redirectByClass("ildclrecordlistgui", "listRecords");
700 }
701 }
702 }
$_GET["client_id"]
const REDIRECT_RECORD_LIST
Possible redirects after saving/updating a record - use GET['redirect'] to set constants.

References $_GET, REDIRECT_DETAIL, and REDIRECT_RECORD_LIST.

Referenced by cancelUpdate(), and save().

+ Here is the caller graph for this function:

◆ cleanupTempFiles()

ilDclRecordEditGUI::cleanupTempFiles ( )
protected

Cleanup temp-files.

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

831 {
832 $ilfilehash = (isset($_POST['ilfilehash'])) ? $_POST['ilfilehash'] : null;
833 if ($ilfilehash != null) {
834 $this->form->cleanupTempFiles($ilfilehash);
835 }
836 }
$_POST["username"]

References $_POST.

Referenced by edit().

+ Here is the caller graph for this function:

◆ confirmDelete()

ilDclRecordEditGUI::confirmDelete ( )

Delete confirmation.

Exceptions
ilDclException

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

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 }
Confirmation screen class.
static getRecordFieldCache($record, $field)
static getRecordCache($record_id=0)
static getRecordRepresentation(ilDclBaseRecordFieldModel $record_field)
Returns a record representation.

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

+ Here is the call graph for this function:

◆ create()

ilDclRecordEditGUI::create ( )

Create new record gui.

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

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 }

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

+ Here is the call graph for this function:

◆ delete()

ilDclRecordEditGUI::delete ( )

Remove record.

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

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 }

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

+ Here is the call graph for this function:

◆ edit()

ilDclRecordEditGUI::edit ( )

Record edit gui.

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

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 }
setFormValues()
Set values from object to form.
cleanupTempFiles()
Cleanup temp-files.

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

+ Here is the call graph for this function:

◆ executeCommand()

ilDclRecordEditGUI::executeCommand ( )
Returns
bool

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

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 }

References getRecord().

+ Here is the call graph for this function:

◆ getForm()

ilDclRecordEditGUI::getForm ( )
Returns
ilDclPropertyFormGUI

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

843 {
844 return $this->form;
845 }

References $form.

◆ getLanguageJsKeys()

ilDclRecordEditGUI::getLanguageJsKeys ( )
protected

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

799 {
800 return "<script>ilDataCollection.strings.add_value='" . $this->lng->txt('add_value') . "';</script>";
801 }

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

+ Here is the caller graph for this function:

◆ getRecord()

ilDclRecordEditGUI::getRecord ( )

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

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 }

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

Referenced by executeCommand().

+ 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 252 of file class.ilDclRecordEditGUI.php.

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 }

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

+ Here is the call graph for this function:

◆ initForm()

ilDclRecordEditGUI::initForm ( )

init Form

@move move parts to RecordRepresentationGUI

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

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 }
static getFieldRepresentation(ilDclBaseFieldModel $field)
Class ilDclCheckboxInputGUI.
Class ilDclPropertyFormGUI.
This class represents a hidden form property in a property form.

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

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

+ 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 811 of file class.ilDclRecordEditGUI.php.

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 }
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
$rows
Definition: xhr_table.php:10

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

Referenced by searchObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDclRecordEditGUI::save ( )

Save record.

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

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
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 }
$_SESSION["AccountId"]
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
Class ilDclBaseFieldModel.
static rebuildTempFileByHash($hash)
Return temp files.
static hasPermissionToAddRecord($ref_id, $table_id)
Class ilObjDataCollection.
static _lookupId($a_user_str)
Lookup id by login.
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
$valid
$data
Definition: storeScorm.php:23

References $_GET, $_POST, $_SESSION, $data, $DIC, Vendor\Package\$e, $valid, ilObjUser\_lookupId(), accessDenied(), checkAndPerformRedirect(), ilDclBaseRecordModel\doCreate(), ilDclBaseRecordModel\doUpdate(), exit, ilDclTableViewBaseDefaultValue\findSingle(), 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\setRecordFieldValue(), ilDclBaseRecordModel\setRecordFieldValueFromForm(), ilDclBaseRecordModel\setTableId(), and user().

+ 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 756 of file class.ilDclRecordEditGUI.php.

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 }
const QP_COMBINATION_AND
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseSearchResults($a_res)
Parse search results.
Creates a path for a start and endnode.
special template class to simplify handling of ITX/PEAR
const ROOT_FOLDER_ID
Definition: constants.php:30
$results
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ sendFailure()

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

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

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 }
$message
Definition: xapiexit.php:14

References $message, exit, ilDclBaseRecordModel\fillRecordFieldFormInput(), ilDclBaseRecordModel\getId(), getLanguageJsKeys(), ilDclCache\getRecordCache(), ilUtil\getSystemMessageHTML(), and ilUtil\sendFailure().

Referenced by save().

+ 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 373 of file class.ilDclRecordEditGUI.php.

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 }

References ilDclCache\getRecordCache(), and ilDclDatatype\INPUTFORMAT_NONE.

Referenced by edit(), and save().

+ 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 51 of file class.ilDclRecordEditGUI.php.

◆ $form

ilDclRecordEditGUI::$form
protected

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

Referenced by getForm().

◆ $lng

ilDclRecordEditGUI::$lng
protected

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

Referenced by __construct().

◆ $parent_obj

ilDclRecordEditGUI::$parent_obj
protected

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

Referenced by __construct().

◆ $record

ilDclRecordEditGUI::$record
protected

◆ $record_id

ilDclRecordEditGUI::$record_id
protected

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

Referenced by getRecordData().

◆ $table

ilDclRecordEditGUI::$table
protected

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

◆ $table_id

ilDclRecordEditGUI::$table_id
protected

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

◆ $tableview

ilDclRecordEditGUI::$tableview
protected

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

◆ $tableview_id

ilDclRecordEditGUI::$tableview_id
protected

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

◆ $tpl

ilDclRecordEditGUI::$tpl
protected

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

Referenced by __construct(), and searchObjects().

◆ $user

ilDclRecordEditGUI::$user
protected

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

◆ REDIRECT_DETAIL

const ilDclRecordEditGUI::REDIRECT_DETAIL = 2

◆ 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.

Referenced by checkAndPerformRedirect().


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