4 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionRecord.php");
5 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionField.php");
6 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
7 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php");
8 require_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
9 require_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
10 require_once(
'./Services/Utilities/classes/class.ilConfirmationGUI.php');
11 require_once(
'./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php');
85 $this->record_id =
$_REQUEST[
'record_id'];
95 $this->ctrl->saveParameter($this,
'mode');
96 $this->ctrl->setParameterByClass(
"ildatacollectionrecordlistgui",
"mode",
$_GET[
'mode']);
98 $this->ctrl->saveParameter($this,
'redirect');
99 if ($this->record_id) {
101 if (!$this->record->hasPermissionToEdit($this->parent_obj->ref_id) OR !$this->record->hasPermissionToView($this->parent_obj->ref_id)) {
104 $this->table = $this->record->getTable();
105 $this->table_id = $this->table->getId();
113 $cmd = $this->ctrl->getCmd();
126 if ($this->ctrl->isAsynch()) {
127 echo $this->form->getHTML();
130 $this->tpl->setContent(
"<script>ilDataCollection.strings.add_value='" . $this->lng->txt(
'add_value') .
"';</script>" 131 . $this->form->getHTML());
139 if ($this->ctrl->isAsynch()) {
140 echo $this->form->getHTML();
143 $this->tpl->setContent(
"<script>ilDataCollection.strings.add_value='" . $this->lng->txt(
'add_value') .
"';</script>" 144 . $this->form->getHTML());
151 $conf->setFormAction($this->ctrl->getFormAction($this));
152 $conf->setHeaderText($this->lng->txt(
'dcl_confirm_delete_record'));
155 foreach (
$record->getRecordFields() as $record_field) {
156 $value = $record_field->getExportValue();
158 if (strlen($value) > 150) {
159 $value = substr($value, 0, 100) .
' ...';
161 $text .= $record_field->getField()->getTitle() .
': ' . $value .
"<br>";
164 $conf->addHiddenItem(
'table_id', $this->table_id);
165 $conf->setConfirm($this->lng->txt(
'delete'),
'delete');
166 $conf->setCancel($this->lng->txt(
'cancel'),
'cancelDelete');
167 $this->tpl->setContent($conf->getHTML());
172 $this->ctrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
176 public function delete() {
179 if (!$this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id,
$record)) {
187 $this->ctrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
205 $return =
$record->getRecordFieldValues();
208 if ($this->ctrl->isAsynch()) {
209 echo json_encode($return);
222 $prefix = ($this->ctrl->isAsynch()) ?
'dclajax' :
'dcl';
223 $this->form->setId($prefix . $this->table_id . $this->record_id);
226 $hidden_prop->setValue($this->table_id);
227 $this->form->addItem($hidden_prop);
228 if ($this->record_id) {
230 $hidden_prop->setValue($this->record_id);
231 $this->form->addItem($hidden_prop);
234 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
235 $this->form->setFormAction($this->ctrl->getFormAction($this));
236 $allFields = $this->table->getRecordFields();
239 foreach ($allFields as $field) {
241 if ($item === NULL) {
245 $fieldref = $field->getFieldRef();
248 if (!$field->isNRef()) {
249 $options[
""] = $this->lng->txt(
'dcl_please_select');
252 foreach ($reftable->getRecords() as
$record) {
254 switch ($reffield->getDatatypeId()) {
264 $options[
$record->getId()] = strtotime(
$record->getRecordFieldSingleHTML($fieldref));
266 $options2[
$record->getId()] =
$record->getRecordFieldSingleHTML($fieldref);
269 $value =
$record->getRecordFieldValue($fieldref);
270 if (($json = json_decode($value)) && (json_decode($value) instanceof stdClass)) {
271 $value = $json->title ? $json->title : $json->link;
273 $options[
$record->getId()] = $value;
276 $options[
$record->getId()] =
$record->getRecordFieldValue($fieldref);
284 foreach (
$options as $key => $opt) {
294 if ($reftable->hasPermissionToAddRecord(
$_GET[
'ref_id'])) {
295 $item->addCustomAttribute(
'data-ref="1"');
296 $item->addCustomAttribute(
'data-ref-table-id="' . $reftable->getId() .
'"');
297 $item->addCustomAttribute(
'data-ref-field-id="' . $reffield->getId() .
'"');
302 if ($this->record_id) {
306 $item->setRequired($field->getRequired());
311 if ($this->record_id AND
$record->getId()) {
312 $field_value =
$record->getRecordFieldValue($field->getId());
314 $item->setRequired(
false);
318 if ($this->ctrl->isAsynch()) {
319 $item->setDisabled(
true);
324 $item->setDisabled(
true);
326 $this->form->addItem($item);
329 $this->tpl->addInlineCss($inline_css);
332 if ($this->record_id) {
333 $ownerField = $this->table->getField(
'owner');
335 $this->form->addItem($inputfield);
339 if ($this->record_id) {
340 $this->form->setTitle($this->lng->txt(
"dcl_update_record"));
341 $this->form->addCommandButton(
"save", $this->lng->txt(
"dcl_update_record"));
342 if (!$this->ctrl->isAsynch()) {
343 $this->form->addCommandButton(
"cancelUpdate", $this->lng->txt(
"cancel"));
346 $this->form->setTitle($this->lng->txt(
"dcl_add_new_record"));
347 $this->form->addCommandButton(
"save", $this->lng->txt(
"save"));
348 if (!$this->ctrl->isAsynch()) {
349 $this->form->addCommandButton(
"cancelSave", $this->lng->txt(
"cancel"));
352 $this->ctrl->setParameter($this,
"table_id", $this->table_id);
353 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
365 if ($record_obj->getId()) {
367 $allFields = $this->table->getFields();
368 foreach ($allFields as $field) {
369 $record_obj->fillRecordFieldFormInput($field->getId(),
$this->form);
372 $this->form->setValuesByPost();
401 $valid = $this->form->checkInput();
405 $record_obj->setTableId($this->table_id);
407 $record_obj->setLastEditBy($this->user->getId());
409 $create_mode =
false;
412 $all_fields = $this->table->getRecordFields();
414 $all_fields = $this->table->getEditableFields();
418 foreach ($all_fields as $field) {
420 $value = $this->form->getInput(
"field_" . $field->getId());
421 $field->checkValidity($value, $this->record_id);
424 $item = $this->form->getItemByPostVar(
'field_'.$field->getId());
430 if (!isset($this->record_id)) {
431 if (!($this->table->hasPermissionToAddRecord($this->parent_obj->ref_id))) {
436 $record_obj->setOwner($this->user->getId());
438 $record_obj->setTableId($this->table_id);
439 $record_obj->doCreate();
440 $this->record_id = $record_obj->getId();
443 if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
451 foreach ($all_fields as $field) {
452 $record_obj->setRecordFieldValueFromForm($field->getId(),
$this->form);
459 $this->
sendFailure($this->lng->txt(
'user_not_known'));
463 $record_obj->setOwner($owner_id);
469 $record_obj->doUpdate();
471 $this->ctrl->setParameter($this,
"table_id", $this->table_id);
472 $this->ctrl->setParameter($this,
"record_id", $this->record_id);
474 if (!$this->ctrl->isAsynch()) {
479 if ($this->ctrl->isAsynch()) {
481 $this->record_id = $record_obj->getId();
484 echo $this->tpl->getMessageHTML($this->lng->txt(
'msg_obj_modified'),
'success') . $this->form->getHTML();
487 $this->ctrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
492 $this->form->setValuesByPost();
493 if ($this->ctrl->isAsynch()) {
494 echo $this->form->getHTML();
497 $this->tpl->setContent($this->form->getHTML());
508 if ($force_redirect || (isset(
$_GET[
'redirect']) && !$this->ctrl->isAsynch())) {
509 switch ((
int)
$_GET[
'redirect']) {
510 case self::REDIRECT_DETAIL:
511 $this->ctrl->setParameterByClass(
'ildatacollectionrecordviewgui',
'record_id', $this->record_id);
512 $this->ctrl->setParameterByClass(
'ildatacollectionrecordviewgui',
'table_id', $this->table_id);
513 $this->ctrl->redirectByClass(
"ildatacollectionrecordviewgui",
"renderRecord");
515 case self::REDIRECT_RECORD_LIST:
516 $this->ctrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
519 $this->ctrl->redirectByClass(
"ildatacollectionrecordlistgui",
"listRecords");
526 if (!$this->ctrl->isAsynch()) {
528 $this->ctrl->redirectByClass(
'ildatacollectionrecordlistgui',
'listRecords');
530 echo $this->lng->txt(
'dcl_msg_no_perm_edit');
540 $keep = ($this->ctrl->isAsynch()) ?
false :
true;
541 $this->form->setValuesByPost();
542 if ($this->ctrl->isAsynch()) {
543 echo $this->tpl->getMessageHTML($message,
'failure') . $this->form->getHTML();
547 $this->tpl->setContent($this->form->getHTML());
556 $search =
$_POST[
'search_for'];
559 include_once
'./Services/Search/classes/class.ilQueryParser.php';
561 $query_parser->setMinWordLength(1,
true);
563 $query_parser->parse();
564 if (!$query_parser->validate()) {
565 $html .= $query_parser->getMessage() .
"<br />";
569 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
571 $res = $object_search->performSearch();
573 $res->filter(ROOT_FOLDER_ID,
true);
576 $html .= $this->lng->txt(
'dcl_no_search_results_found_for') .
' ' . $search .
"<br />";
581 $tpl =
new ilTemplate(
"tpl.dcl_tree.html",
true,
true,
"Modules/DataCollection");
582 foreach ((array)$entry[
'refs'] as $reference) {
583 include_once
'./Services/Tree/classes/class.ilPathGUI.php';
585 $tpl->setCurrentBlock(
'result');
586 $tpl->setVariable(
'RESULT_PATH',
$path->getPath(ROOT_FOLDER_ID, $reference) .
" ยป " . $entry[
'title']);
587 $tpl->setVariable(
'RESULT_REF', $reference);
588 $tpl->setVariable(
'FIELD_ID', $dest);
589 $tpl->parseCurrentBlock();
608 foreach ($a_res as $obj_id => $references) {
612 $r[
'obj_id'] = $obj_id;
613 $r[
'refs'] = $references;
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
setFormValues()
Set values from object to form.
static getRecordCache($record_id=0)
Creates a path for a start and endnode.
const INPUTFORMAT_DATETIME
static hasWriteAccess($ref)
static _lookupId($a_user_str)
Lookup id by login.
static _lookupTitle($a_id)
lookup object title
checkAndPerformRedirect($force_redirect=false)
Checkes to what view (table or detail) should be redirected and performs redirect.
const REDIRECT_RECORD_LIST
Possible redirects after saving/updating a record - use GET['redirect'] to set constants.
searchObjects()
This function is only used by the ajax request if searching for ILIAS references. ...
Class ilObjDataCollectionGUI.
static getFieldCache($field_id=0)
if(!is_array($argv)) $options
static _lookupDescription($a_id)
lookup object description
special template class to simplify handling of ITX/PEAR
static getInputField(ilDataCollectionField $field)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilDataCollectionRecordEditGUI.
static sendNotification($a_action, $a_table_id, $a_record_id=NULL)
__construct(ilObjDataCollectionGUI $parent_obj)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
parseSearchResults($a_res)
Parse search results.
cancelUpdate()
Cancel Update.
const INPUTFORMAT_REFERENCE
static _hasWriteAccess($ref)
static getTableCache($table_id=0)
getRecordData($record_id=0)
Return All fields and values from a record ID.
static hasAddRecordAccess($ref)
Confirmation screen class.