82 $this->record_id = $_REQUEST[
'record_id'];
83 $this->table_id = $_REQUEST[
'table_id'];
84 $this->tableview_id = $_REQUEST[
'tableview_id'];
95 $cmd = $this->ctrl->getCmd();
112 $this->ctrl->saveParameter($this,
'mode');
113 $this->ctrl->setParameterByClass(
"ildclrecordlistgui",
"mode",
$_GET[
'mode']);
115 $this->ctrl->setParameterByClass(
'ildclrecordlistgui',
'tableview_id', $this->tableview_id);
116 $this->ctrl->saveParameter($this,
'redirect');
117 if ($this->record_id) {
119 if (!$this->record->hasPermissionToEdit($this->parent_obj->ref_id)
or !$this->record->hasPermissionToView($this->parent_obj->ref_id)) {
122 $this->table = $this->record->getTable();
123 $this->table_id = $this->table->getId();
139 if ($this->ctrl->isAsynch()) {
140 echo $this->form->getHTML();
143 $this->tpl->setContent(
145 . $this->form->getHTML()
160 if ($this->ctrl->isAsynch()) {
161 echo $this->form->getHTML();
164 $this->tpl->setContent(
166 . $this->form->getHTML()
180 $conf->setFormAction($this->ctrl->getFormAction($this));
181 $conf->setHeaderText($this->lng->txt(
'dcl_confirm_delete_record'));
184 $all_fields = $this->table->getRecordFields();
186 foreach ($all_fields as
$key => $field) {
190 if ($record_representation->getConfirmationHTML() !==
false) {
191 $record_data .= $field->getTitle() .
": " . $record_representation->getConfirmationHTML() .
"<br />";
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());
208 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
215 public function delete()
219 if (!$this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id,
$record)) {
226 ilUtil::sendSuccess($this->lng->txt(
"dcl_record_deleted"),
true);
227 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
246 $return =
$record->getRecordFieldValues();
249 if ($this->ctrl->isAsynch()) {
250 echo json_encode($return);
266 $prefix = ($this->ctrl->isAsynch()) ?
'dclajax' :
'dcl';
267 $this->form->setId($prefix . $this->table_id . $this->record_id);
270 $hidden_prop->setValue($this->table_id);
271 $this->form->addItem($hidden_prop);
273 $hidden_prop->setValue($this->tableview_id);
274 $this->form->addItem($hidden_prop);
275 if ($this->record_id) {
277 $hidden_prop->setValue($this->record_id);
278 $this->form->addItem($hidden_prop);
281 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
282 $this->form->setFormAction($this->ctrl->getFormAction($this));
283 $allFields = $this->table->getRecordFields();
285 foreach ($allFields as $field) {
287 if ($item === null) {
292 $item->setDisabled(
true);
294 $this->form->addItem($item);
297 $this->tpl->addInlineCss($inline_css);
300 if ($this->record_id) {
301 $ownerField = $this->table->getField(
'owner');
303 $this->form->addItem($inputfield);
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"));
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"));
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);
335 if ($record_obj->getId()) {
337 $allFields = $this->table->getFields();
338 foreach ($allFields as $field) {
339 $record_obj->fillRecordFieldFormInput($field->getId(),
$this->form);
342 $this->form->setValuesByPost();
371 $all_fields = $this->table->getRecordFields();
373 $all_fields = $this->table->getEditableFields();
382 $confirmation->setFormAction($this->ctrl->getFormAction($this));
383 $header_text = $this->lng->txt(
'dcl_confirm_storing_records');
385 && !$this->table->getEditByOwner()
386 && !$this->table->getEditPerm()
388 $header_text .=
" " . $this->lng->txt(
'dcl_confirm_storing_records_no_permission');
390 $confirmation->setHeaderText($header_text);
392 $confirmation->setCancel($this->lng->txt(
'dcl_edit_record'),
'edit');
393 $confirmation->setConfirm($this->lng->txt(
'dcl_save_record'),
'save');
397 $empty_fileuploads = array();
398 foreach ($all_fields as $field) {
401 $record_field->addHiddenItemsToConfirmation($confirmation);
404 && $record_field->getValue() == null
406 $empty_fileuploads[
'field_' . $field->getId()] = array(
"name" =>
"",
"type" =>
"",
"tmp_name" =>
"",
"error" => 4,
"size" => 0);
410 if ($record_representation->getConfirmationHTML() !==
false) {
411 $record_data .= $field->getTitle() .
": " . $record_representation->getConfirmationHTML() .
"<br />";
415 $confirmation->addHiddenItem(
'ilfilehash', $filehash);
416 $confirmation->addHiddenItem(
'empty_fileuploads', htmlspecialchars(json_encode($empty_fileuploads)));
417 $confirmation->addHiddenItem(
'table_id', $this->table_id);
418 $confirmation->addHiddenItem(
'tableview_id', $this->tableview_id);
419 $confirmation->addItem(
'save_confirmed', 1, $record_data);
421 if ($this->ctrl->isAsynch()) {
422 echo $confirmation->getHTML();
425 $this->tpl->setContent($confirmation->getHTML());
436 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
442 if ($this->table->getSaveConfirmation() && isset(
$_POST[
'save_confirmed']) && isset(
$_POST[
'ilfilehash']) && !isset($this->record_id) && !$this->ctrl->isAsynch()) {
446 if (json_decode(
$_POST[
'empty_fileuploads']) &&
$_POST[
'empty_fileuploads'] !=
'') {
447 $_FILES = $_FILES + json_decode(
$_POST[
'empty_fileuploads'],
true);
453 $valid = $this->form->checkInput();
456 $unchanged_obj = $record_obj;
462 $create_mode =
false;
465 $all_fields = $this->table->getRecordFields();
467 $all_fields = $this->table->getEditableFields();
471 foreach ($all_fields as $field) {
473 $field->checkValidityFromForm($this->form, $this->record_id);
476 $item = $this->form->getItemByPostVar(
'field_' . $field->getId());
482 $this->
sendFailure($this->lng->txt(
'form_input_not_valid'));
487 if (!isset($this->record_id)) {
494 if ($this->table->getSaveConfirmation() && $this->form->getInput(
'save_confirmed') == null && !$this->ctrl->isAsynch()) {
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);
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);
517 $this->form->keepTempFileUpload($hash, $field,
$data[
"tmp_name"],
$data[
"name"],
$data[
"type"]);
522 foreach ($all_fields as $field) {
526 $this->saveConfirmation($record_obj, $hash);
536 $this->record_id = $record_obj->
getId();
547 foreach ($all_fields as $field) {
555 $this->
sendFailure($this->lng->txt(
'user_not_known'));
562 $dispatchEvent =
"update";
564 $dispatchEventData = array(
565 'dcl' => $this->parent_obj->getDataCollectionObject(),
567 'record_id' => $record_obj->
getId(),
568 'record' => $record_obj,
572 $dispatchEvent =
"create";
573 ilObjDataCollection::sendNotification(
"new_record", $this->table_id, $record_obj->
getId());
575 $dispatchEventData[
'prev_record'] = $unchanged_obj;
578 $record_obj->
doUpdate($create_mode);
580 $ilAppEventHandler->raise(
581 'Modules/DataCollection',
582 $dispatchEvent .
'Record',
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);
590 if (!$this->ctrl->isAsynch()) {
591 ilUtil::sendSuccess($this->lng->txt(
"msg_obj_modified"),
true);
595 if ($this->ctrl->isAsynch()) {
597 $this->record_id = $record_obj->
getId();
600 echo $this->tpl->getMessageHTML($this->lng->txt(
'msg_obj_modified'),
'success') . $this->form->getHTML();
603 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
608 $this->form->setValuesByPost();
609 if ($this->ctrl->isAsynch()) {
610 echo $this->form->getHTML();
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");
633 case self::REDIRECT_RECORD_LIST:
634 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
637 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
645 if (!$this->ctrl->isAsynch()) {
647 $this->ctrl->redirectByClass(
'ildclrecordlistgui',
'listRecords');
649 echo $this->lng->txt(
'dcl_msg_no_perm_edit');
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();
677 $search =
$_POST[
'search_for'];
680 include_once
'./Services/Search/classes/class.ilQueryParser.php';
682 $query_parser->setMinWordLength(1,
true);
684 $query_parser->parse();
685 if (!$query_parser->validate()) {
686 $html .= $query_parser->getMessage() .
"<br />";
690 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
692 $res = $object_search->performSearch();
694 $res->filter(ROOT_FOLDER_ID,
true);
697 $html .= $this->lng->txt(
'dcl_no_search_results_found_for') .
' ' . $search .
"<br />";
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';
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();
722 return "<script>ilDataCollection.strings.add_value='" . $this->lng->txt(
'add_value') .
"';</script>";
736 foreach ($a_res as $obj_id => $references) {
740 $r[
'obj_id'] = $obj_id;
741 $r[
'refs'] = $references;
754 $ilfilehash = (isset(
$_POST[
'ilfilehash'])) ?
$_POST[
'ilfilehash'] : null;
755 if ($ilfilehash != null) {
756 $this->form->cleanupTempFiles($ilfilehash);
setFormValues()
Set values from object to form.
Creates a path for a start and endnode.
static hasAddRecordAccess($ref, $user_id=0)
cleanupTempFiles()
Cleanup temp-files.
Class ilDclBaseFieldModel.
static hasPermissionToAddRecord($ref_id, $table_id)
Class ilDclRecordEditGUI.
cancelUpdate()
Cancel Update.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupTitle($a_id)
lookup object title
create()
Create new record gui.
static getTableCache($table_id=0)
setLastEditBy($last_edit_by)
setCreateDate($a_datetime)
Set Creation Date.
setLastUpdate($a_datetime)
Set Last Update Date.
static getFieldRepresentation(ilDclBaseFieldModel $field)
__construct(ilObjDataCollectionGUI $parent_obj)
parseSearchResults($a_res)
Parse search results.
Class ilObjDataCollectionGUI.
getRecordField($field_id)
catch(Exception $e) $message
foreach($_POST as $key=> $value) $res
setOwner($a_id)
Set Owner.
searchObjects()
This function is only used by the ajax request if searching for ILIAS references. ...
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['redirect'] to set constants.
special template class to simplify handling of ITX/PEAR
static hasWriteAccess($ref, $user_id=0)
static getRecordCache($record_id=0)
confirmDelete()
Delete confirmation.
static getRecordRepresentation(ilDclBaseRecordFieldModel $record_field)
Returns a record representation.
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.
hasPermissionToEdit($ref_id)
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.
doUpdate($omit_notification=false)
doUpdate
setTableId($a_id)
Set Table ID.
Confirmation screen class.