83 $this->record_id = $_REQUEST[
'record_id'];
84 $this->table_id = $_REQUEST[
'table_id'];
85 $this->tableview_id = $_REQUEST[
'tableview_id'];
96 $cmd = $this->ctrl->getCmd();
113 $this->ctrl->saveParameter($this,
'mode');
114 $this->ctrl->setParameterByClass(
"ildclrecordlistgui",
"mode",
$_GET[
'mode']);
116 $this->ctrl->setParameterByClass(
'ildclrecordlistgui',
'tableview_id', $this->tableview_id);
117 $this->ctrl->saveParameter($this,
'redirect');
118 if ($this->record_id) {
120 if (!$this->record->hasPermissionToEdit($this->parent_obj->ref_id) or !$this->record->hasPermissionToView($this->parent_obj->ref_id)) {
123 $this->table = $this->record->getTable();
124 $this->table_id = $this->table->getId();
140 if ($this->ctrl->isAsynch()) {
141 echo $this->form->getHTML();
145 . $this->form->getHTML());
159 if ($this->ctrl->isAsynch()) {
160 echo $this->form->getHTML();
164 . $this->form->getHTML());
177 $conf->setFormAction($this->ctrl->getFormAction($this));
178 $conf->setHeaderText($this->lng->txt(
'dcl_confirm_delete_record'));
181 $all_fields = $this->table->getRecordFields();
183 foreach ($all_fields as
$key=>$field) {
187 if ($record_representation->getConfirmationHTML() !==
false) {
188 $record_data .= $field->getTitle() .
": " . $record_representation->getConfirmationHTML() .
"<br />";
191 $conf->addItem(
'record_id',
$record->getId(), $record_data);
192 $conf->addHiddenItem(
'table_id', $this->table_id);
193 $conf->addHiddenItem(
'tableview_id', $this->tableview_id);
194 $conf->setConfirm($this->lng->txt(
'delete'),
'delete');
195 $conf->setCancel($this->lng->txt(
'cancel'),
'cancelDelete');
196 $this->tpl->setContent($conf->getHTML());
205 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
212 public function delete()
216 if (!$this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id,
$record)) {
224 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
243 $return =
$record->getRecordFieldValues();
246 if ($this->ctrl->isAsynch()) {
247 echo json_encode($return);
263 $prefix = ($this->ctrl->isAsynch()) ?
'dclajax' :
'dcl';
264 $this->form->setId($prefix . $this->table_id . $this->record_id);
267 $hidden_prop->setValue($this->table_id);
268 $this->form->addItem($hidden_prop);
270 $hidden_prop->setValue($this->tableview_id);
271 $this->form->addItem($hidden_prop);
272 if ($this->record_id) {
274 $hidden_prop->setValue($this->record_id);
275 $this->form->addItem($hidden_prop);
278 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
279 $this->form->setFormAction($this->ctrl->getFormAction($this));
280 $allFields = $this->table->getRecordFields();
282 foreach ($allFields as $field) {
284 if ($item === null) {
289 $item->setDisabled(
true);
291 $this->form->addItem($item);
294 $this->tpl->addInlineCss($inline_css);
297 if ($this->record_id) {
298 $ownerField = $this->table->getField(
'owner');
300 $this->form->addItem($inputfield);
305 if ($this->record_id) {
306 $this->form->setTitle($this->lng->txt(
"dcl_update_record"));
307 $this->form->addCommandButton(
"save", $this->lng->txt(
"dcl_update_record"));
308 if (!$this->ctrl->isAsynch()) {
309 $this->form->addCommandButton(
"cancelUpdate", $this->lng->txt(
"cancel"));
312 $this->form->setTitle($this->lng->txt(
"dcl_add_new_record"));
313 $this->form->addCommandButton(
"save", $this->lng->txt(
"save"));
314 if (!$this->ctrl->isAsynch()) {
315 $this->form->addCommandButton(
"cancelSave", $this->lng->txt(
"cancel"));
318 $this->ctrl->setParameter($this,
"tableview_id", $this->tableview_id);
319 $this->ctrl->setParameter($this,
"table_id", $this->table_id);
320 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
333 if ($record_obj->getId()) {
335 $allFields = $this->table->getFields();
336 foreach ($allFields as $field) {
337 $record_obj->fillRecordFieldFormInput($field->getId(),
$this->form);
340 $this->form->setValuesByPost();
368 $all_fields = $this->table->getRecordFields();
370 $all_fields = $this->table->getEditableFields();
379 $confirmation->setFormAction($this->ctrl->getFormAction($this));
380 $header_text = $this->lng->txt(
'dcl_confirm_storing_records');
382 && !$this->table->getEditByOwner() && !$this->table->getEditPerm()) {
383 $header_text .=
" " . $this->lng->txt(
'dcl_confirm_storing_records_no_permission');
385 $confirmation->setHeaderText($header_text);
387 $confirmation->setCancel($this->lng->txt(
'dcl_edit_record'),
'edit');
388 $confirmation->setConfirm($this->lng->txt(
'dcl_save_record'),
'save');
392 $empty_fileuploads =
array();
393 foreach ($all_fields as $field) {
396 $record_field->addHiddenItemsToConfirmation($confirmation);
399 && $record_field->getValue() == null) {
400 $empty_fileuploads[
'field_' . $field->getId()] =
array(
"name" =>
"",
"type" =>
"",
"tmp_name" =>
"",
"error" => 4,
"size" => 0);
404 if ($record_representation->getConfirmationHTML() !==
false) {
405 $record_data .= $field->getTitle() .
": " . $record_representation->getConfirmationHTML() .
"<br />";
409 $confirmation->addHiddenItem(
'ilfilehash', $filehash);
410 $confirmation->addHiddenItem(
'empty_fileuploads', htmlspecialchars(json_encode($empty_fileuploads)));
411 $confirmation->addHiddenItem(
'table_id', $this->table_id);
412 $confirmation->addHiddenItem(
'tableview_id', $this->tableview_id);
413 $confirmation->addItem(
'save_confirmed', 1, $record_data);
415 if ($this->ctrl->isAsynch()) {
416 echo $confirmation->getHTML();
419 $this->tpl->setContent($confirmation->getHTML());
429 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
435 if ($this->table->getSaveConfirmation() && isset(
$_POST[
'save_confirmed']) && isset(
$_POST[
'ilfilehash']) && !isset($this->record_id) && !$this->ctrl->isAsynch()) {
439 if (json_decode(
$_POST[
'empty_fileuploads']) &&
$_POST[
'empty_fileuploads'] !=
'') {
440 $_FILES = $_FILES + json_decode(
$_POST[
'empty_fileuploads'],
true);
446 $valid = $this->form->checkInput();
449 $unchanged_obj = $record_obj;
455 $create_mode =
false;
458 $all_fields = $this->table->getRecordFields();
460 $all_fields = $this->table->getEditableFields();
464 foreach ($all_fields as $field) {
466 $field->checkValidityFromForm($this->form, $this->record_id);
469 $item = $this->form->getItemByPostVar(
'field_' . $field->getId());
475 $this->
sendFailure($this->lng->txt(
'form_input_not_valid'));
480 if (!isset($this->record_id)) {
487 if ($this->table->getSaveConfirmation() && $this->form->getInput(
'save_confirmed') == null && !$this->ctrl->isAsynch()) {
489 $hash =
$_POST[
"ilfilehash"];
490 foreach ($_FILES as $field =>
$data) {
491 if (is_array(
$data[
"tmp_name"])) {
492 foreach (
$data[
"tmp_name"] as $idx => $upload) {
493 if (is_array($upload)) {
494 foreach ($upload as $idx2 =>
$file) {
496 $file_name =
$data[
"name"][$idx][$idx2];
497 $file_type =
$data[
"type"][$idx][$idx2];
498 $this->form->keepTempFileUpload($hash, $field,
$file, $file_name, $file_type, $idx, $idx2);
501 } elseif ($upload && is_uploaded_file($upload)) {
502 $file_name =
$data[
"name"][$idx];
503 $file_type =
$data[
"type"][$idx];
504 $this->form->keepTempFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
508 $this->form->keepTempFileUpload($hash, $field,
$data[
"tmp_name"],
$data[
"name"],
$data[
"type"]);
513 foreach ($all_fields as $field) {
517 $this->saveConfirmation($record_obj, $hash);
526 $this->record_id = $record_obj->
getId();
537 foreach ($all_fields as $field) {
545 $this->
sendFailure($this->lng->txt(
'user_not_known'));
552 $dispatchEvent =
"update";
554 $dispatchEventData =
array(
555 'dcl' => $this->parent_obj->getDataCollectionObject(),
557 'record_id' => $record_obj->
getId(),
558 'record' => $record_obj,
562 $dispatchEvent =
"create";
563 ilObjDataCollection::sendNotification(
"new_record", $this->table_id, $record_obj->
getId());
565 $dispatchEventData[
'prev_record'] = $unchanged_obj;
568 $record_obj->
doUpdate($create_mode);
570 $ilAppEventHandler->raise(
571 'Modules/DataCollection',
572 $dispatchEvent .
'Record',
576 $this->ctrl->setParameter($this,
"table_id", $this->table_id);
577 $this->ctrl->setParameter($this,
"tableview_id", $this->tableview_id);
578 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
580 if (!$this->ctrl->isAsynch()) {
585 if ($this->ctrl->isAsynch()) {
587 $this->record_id = $record_obj->
getId();
590 echo $this->tpl->getMessageHTML($this->lng->txt(
'msg_obj_modified'),
'success') . $this->form->getHTML();
593 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
598 $this->form->setValuesByPost();
599 if ($this->ctrl->isAsynch()) {
600 echo $this->form->getHTML();
615 if ($force_redirect || (isset(
$_GET[
'redirect']) && !$this->ctrl->isAsynch())) {
616 switch ((
int)
$_GET[
'redirect']) {
617 case self::REDIRECT_DETAIL:
618 $this->ctrl->setParameterByClass(
'ilDclDetailedViewGUI',
'record_id', $this->record_id);
619 $this->ctrl->setParameterByClass(
'ilDclDetailedViewGUI',
'table_id', $this->table_id);
620 $this->ctrl->setParameterByClass(
'ilDclDetailedViewGUI',
'tableview_id', $this->tableview_id);
621 $this->ctrl->redirectByClass(
"ilDclDetailedViewGUI",
"renderRecord");
623 case self::REDIRECT_RECORD_LIST:
624 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
627 $this->ctrl->redirectByClass(
"ildclrecordlistgui",
"listRecords");
635 if (!$this->ctrl->isAsynch()) {
637 $this->ctrl->redirectByClass(
'ildclrecordlistgui',
'listRecords');
639 echo $this->lng->txt(
'dcl_msg_no_perm_edit');
650 $keep = ($this->ctrl->isAsynch()) ?
false :
true;
651 $this->form->setValuesByPost();
652 if ($this->ctrl->isAsynch()) {
653 echo $this->tpl->getMessageHTML(
$message,
'failure') . $this->form->getHTML();
666 $search =
$_POST[
'search_for'];
669 include_once
'./Services/Search/classes/class.ilQueryParser.php';
671 $query_parser->setMinWordLength(1,
true);
673 $query_parser->parse();
674 if (!$query_parser->validate()) {
675 $html .= $query_parser->getMessage() .
"<br />";
679 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
681 $res = $object_search->performSearch();
683 $res->filter(ROOT_FOLDER_ID,
true);
686 $html .= $this->lng->txt(
'dcl_no_search_results_found_for') .
' ' . $search .
"<br />";
691 $tpl =
new ilTemplate(
"tpl.dcl_tree.html",
true,
true,
"Modules/DataCollection");
692 foreach ((
array) $entry[
'refs'] as $reference) {
693 include_once
'./Services/Tree/classes/class.ilPathGUI.php';
695 $tpl->setCurrentBlock(
'result');
696 $tpl->setVariable(
'RESULT_PATH',
$path->getPath(ROOT_FOLDER_ID, $reference) .
" ยป " . $entry[
'title']);
697 $tpl->setVariable(
'RESULT_REF', $reference);
698 $tpl->setVariable(
'FIELD_ID', $dest);
699 $tpl->parseCurrentBlock();
710 return "<script>ilDataCollection.strings.add_value='" . $this->lng->txt(
'add_value') .
"';</script>";
724 foreach ($a_res as $obj_id => $references) {
728 $r[
'obj_id'] = $obj_id;
729 $r[
'refs'] = $references;
742 $ilfilehash = (isset(
$_POST[
'ilfilehash'])) ?
$_POST[
'ilfilehash'] : null;
743 if ($ilfilehash != null) {
744 $this->form->cleanupTempFiles($ilfilehash);
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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.
Create styles array
The data for the language used.
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
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
setTableId($a_id)
Set Table ID.
Confirmation screen class.