ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAdvancedMDSettingsGUI Class Reference
+ Collaboration diagram for ilAdvancedMDSettingsGUI:

Public Member Functions

 __construct ($a_obj_id=null, $a_obj_type=null, $a_sub_type=null)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 showRecords ()
 show record list More...
 
 showPresentation ()
 
 updateSubstitutions ()
 Update substitution. More...
 
 exportRecords ()
 Export records. More...
 
 showFiles ()
 show export files More...
 
 downloadFile ()
 Download XML file. More...
 
 confirmDeleteFiles ()
 confirm delete files More...
 
 deleteFiles ()
 Delete files. More...
 
 confirmDeleteRecords ()
 Confirm delete. More...
 
 deleteRecords ()
 Permanently delete records. More...
 
 updateRecords ()
 Save records (assigned object typed) More...
 
 confirmDeleteFields ()
 show delete fields confirmation screen More...
 
 deleteFields ()
 delete fields More...
 
 editRecord ()
 Edit one record. More...
 
 editFields ()
 
 updateFields ()
 Update fields. More...
 
 updateRecord ()
 Update record. More...
 
 createRecord ()
 Show
More...
 
 importRecords ()
 
 importRecord ()
 import xml file More...
 
 saveRecord ()
 Save record. More...
 
 editField (ilPropertyFormGUI $a_form=null)
 Edit field. More...
 
 updateField ()
 Update field. More...
 
 createField (ilPropertyFormGUI $a_form=null)
 Show field type selection. More...
 
 saveField ()
 create field More...
 

Protected Member Functions

 getPermissions ()
 
 initImportForm ()
 show import form More...
 
 initFieldForm (ilAdvancedMDFieldDefinition $a_definition)
 init field form More...
 
 initForm ($a_mode)
 Init Form. More...
 
 getSubstitutionFieldPermissions ($a_obj_type, $a_field_id)
 
 initFormSubstitutions ()
 init form table 'substitutions' More...
 
 loadRecordFormData ()
 load record form data More...
 
 initRecordObject ()
 Init record object. More...
 
 setSubTabs ()
 Set sub tabs. More...
 
 getParsedRecordObjects ()
 Get and cache record objects. More...
 

Protected Attributes

 $lng
 
 $tpl
 
 $ctrl
 
 $tabs
 
 $permissions
 
 $obj_id
 
 $obj_type
 
 $sub_type
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

@ilCtrl_Calls ilAdvancedMDSettingsGUI:

Definition at line 16 of file class.ilAdvancedMDSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDSettingsGUI::__construct (   $a_obj_id = null,
  $a_obj_type = null,
  $a_sub_type = null 
)

Constructor.

@access public

Definition at line 33 of file class.ilAdvancedMDSettingsGUI.php.

34 {
35 global $tpl,$lng,$ilCtrl,$ilTabs;
36
37 $this->ctrl = $ilCtrl;
38 $this->lng = $lng;
39 $this->lng->loadLanguageModule('meta');
40 $this->tpl = $tpl;
41 $this->tabs_gui = $ilTabs;
42
43 $this->obj_id = $a_obj_id;
44 $this->obj_type = $a_obj_type;
45 $this->sub_type = $a_sub_type
46 ? $a_sub_type
47 : "-";
48
49 if($this->obj_id &&
50 !$this->obj_type)
51 {
52 $this->obj_type = ilObject::_lookupType($this->obj_id);
53 }
54
55 $this->permissions = ilAdvancedMDPermissionHelper::getInstance();
56 }
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilCtrl
Definition: ilias.php:18

References $ilCtrl, $lng, $tpl, ilObject\_lookupType(), and ilClaimingPermissionHelper\getInstance().

+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteFields()

ilAdvancedMDSettingsGUI::confirmDeleteFields ( )

show delete fields confirmation screen

@access public

Definition at line 617 of file class.ilAdvancedMDSettingsGUI.php.

618 {
619 if(!isset($_POST['field_id']))
620 {
621 ilUtil::sendFailure($this->lng->txt('select_one'));
622 $this->editFields();
623 return false;
624 }
625
626 $this->ctrl->saveParameter($this,'record_id');
627
628 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
629 $c_gui = new ilConfirmationGUI();
630
631 // set confirm/cancel commands
632 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFields"));
633 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_fields_sure"));
634 $c_gui->setCancel($this->lng->txt("cancel"), "editFields");
635 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFields");
636
637 // add items to delete
638 foreach($_POST["field_id"] as $field_id)
639 {
641 $c_gui->addItem("field_id[]", $field_id, $field->getTitle() ? $field->getTitle() : 'No Title');
642 }
643 $this->tpl->setContent($c_gui->getHTML());
644 }
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
Confirmation screen class.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST['username']
Definition: cron.php:12

References $_POST, editFields(), ilAdvancedMDFieldDefinition\getInstance(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ confirmDeleteFiles()

ilAdvancedMDSettingsGUI::confirmDeleteFiles ( )

confirm delete files

@access public

Definition at line 386 of file class.ilAdvancedMDSettingsGUI.php.

387 {
388 if(!isset($_POST['file_id']))
389 {
390 ilUtil::sendFailure($this->lng->txt('select_one'));
391 $this->showFiles();
392 return false;
393 }
394
395 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
396 $c_gui = new ilConfirmationGUI();
397
398 // set confirm/cancel commands
399 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
400 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_files_sure"));
401 $c_gui->setCancel($this->lng->txt("cancel"), "showFiles");
402 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
403
404 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
405 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
406 $file_data = $files->readFilesInfo();
407
408
409 // add items to delete
410 foreach($_POST["file_id"] as $file_id)
411 {
412 $info = $file_data[$file_id];
413 $c_gui->addItem("file_id[]", $file_id, is_array($info['name']) ? implode(',',$info['name']) : 'No Records');
414 }
415 $this->tpl->setContent($c_gui->getHTML());
416 }
$info
Definition: example_052.php:80

References $_POST, $info, ilUtil\sendFailure(), and showFiles().

+ Here is the call graph for this function:

◆ confirmDeleteRecords()

ilAdvancedMDSettingsGUI::confirmDeleteRecords ( )

Confirm delete.

@access public

Definition at line 451 of file class.ilAdvancedMDSettingsGUI.php.

452 {
453 if(!isset($_POST['record_id']))
454 {
455 ilUtil::sendFailure($this->lng->txt('select_one'));
456 $this->showRecords();
457 return false;
458 }
459
460 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
461 $c_gui = new ilConfirmationGUI();
462
463 // set confirm/cancel commands
464 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteRecords"));
465 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_record_sure"));
466 $c_gui->setCancel($this->lng->txt("cancel"), "showRecords");
467 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteRecords");
468
469 // add items to delete
470 foreach($_POST["record_id"] as $record_id)
471 {
472 $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
473 $c_gui->addItem("record_id[]", $record_id, $record->getTitle() ? $record->getTitle() : 'No Title');
474 }
475 $this->tpl->setContent($c_gui->getHTML());
476 }
static _getInstanceByRecordId($a_record_id)
Get instance by record id.

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilUtil\sendFailure(), and showRecords().

+ Here is the call graph for this function:

◆ createField()

ilAdvancedMDSettingsGUI::createField ( ilPropertyFormGUI  $a_form = null)

Show field type selection.

@access public

Definition at line 1091 of file class.ilAdvancedMDSettingsGUI.php.

1092 {
1093
1094 if(!$_REQUEST["record_id"] || !$_REQUEST["ftype"])
1095 {
1096 return $this->editFields();
1097 }
1098
1099 $this->ctrl->saveParameter($this,'record_id');
1100 $this->ctrl->saveParameter($this,'ftype');
1101
1102 if(!$a_form)
1103 {
1104 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1105 $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1106 $field_definition->setRecordId($_REQUEST["record_id"]);
1107 $a_form = $this->initFieldForm($field_definition);
1108 }
1109 $this->tpl->setContent($a_form->getHTML());
1110 }
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, editFields(), ilAdvancedMDFieldDefinition\getInstance(), and initFieldForm().

Referenced by saveField().

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

◆ createRecord()

ilAdvancedMDSettingsGUI::createRecord ( )

Show

@access public

Parameters

Definition at line 875 of file class.ilAdvancedMDSettingsGUI.php.

876 {
877 $this->initRecordObject();
878 $this->initForm('create');
879 $this->tpl->setContent($this->form->getHTML());
880 return true;
881 }

References initForm(), and initRecordObject().

Referenced by importRecord(), and saveRecord().

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

◆ deleteFields()

ilAdvancedMDSettingsGUI::deleteFields ( )

delete fields

@access public

Parameters

Definition at line 653 of file class.ilAdvancedMDSettingsGUI.php.

654 {
655 $this->ctrl->saveParameter($this,'record_id');
656
657 if(!isset($_POST['field_id']))
658 {
659 ilUtil::sendFailure($this->lng->txt('select_one'));
660 $this->editFields();
661 return false;
662 }
663
664 // all fields have to be deletable
665 $fail = array();
666 foreach($_POST['field_id'] as $field_id)
667 {
668 if(!$this->getPermissions()->hasPermission(
670 $field_id,
672 {
673 $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
674 $fail[] = $field->getTitle();
675 }
676 }
677 if($fail)
678 {
679 ilUtil::sendFailure($this->lng->txt('msg_no_perm_delete')." ".implode(", ", $fail), true);
680 $this->ctrl->redirect($this, "editFields");
681 }
682
683 foreach($_POST["field_id"] as $field_id)
684 {
686 $field->delete();
687 }
688 ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_fields'), true);
689 $this->ctrl->redirect($this, "editFields");
690 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References $_POST, ilAdvancedMDPermissionHelper\ACTION_FIELD_DELETE, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, editFields(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ deleteFiles()

ilAdvancedMDSettingsGUI::deleteFiles ( )

Delete files.

@access public

Parameters

Definition at line 425 of file class.ilAdvancedMDSettingsGUI.php.

426 {
427 if(!isset($_POST['file_id']))
428 {
429 ilUtil::sendFailure($this->lng->txt('select_one'));
430 $this->editFiles();
431 return false;
432 }
433
434 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
435 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
436
437 foreach($_POST['file_id'] as $file_id)
438 {
439 $files->deleteByFileId((int) $file_id);
440 }
441 ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_files'));
442 $this->showFiles();
443 }

References $_POST, ilUtil\sendFailure(), ilUtil\sendSuccess(), and showFiles().

+ Here is the call graph for this function:

◆ deleteRecords()

ilAdvancedMDSettingsGUI::deleteRecords ( )

Permanently delete records.

@access public

Definition at line 484 of file class.ilAdvancedMDSettingsGUI.php.

485 {
486 if(!isset($_POST['record_id']))
487 {
488 ilUtil::sendFailure($this->lng->txt('select_one'));
489 $this->showRecords();
490 return false;
491 }
492
493 // all records have to be deletable
494 $fail = array();
495 foreach($_POST['record_id'] as $record_id)
496 {
497 // must not delete global records in local context
498 if($this->obj_id)
499 {
500 $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
501 if(!$record->getParentObject())
502 {
503 $fail[] = $record->getTitle();
504 }
505 }
506
507 if(!$this->getPermissions()->hasPermission(
509 $record_id,
511 {
512 $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
513 $fail[] = $record->getTitle();
514 }
515 }
516 if($fail)
517 {
518 ilUtil::sendFailure($this->lng->txt('msg_no_perm_delete')." ".implode(", ", $fail), true);
519 $this->ctrl->redirect($this, "showRecords");
520 }
521
522 foreach($_POST['record_id'] as $record_id)
523 {
524 $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
525 $record->delete();
526 }
527 ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_records'), true);
528 $this->ctrl->redirect($this, "showRecords");
529 }

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_DELETE, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showRecords().

+ Here is the call graph for this function:

◆ downloadFile()

ilAdvancedMDSettingsGUI::downloadFile ( )

Download XML file.

@access public

Parameters

Definition at line 364 of file class.ilAdvancedMDSettingsGUI.php.

365 {
366 if(!isset($_POST['file_id']) or count($_POST['file_id']) != 1)
367 {
368 ilUtil::sendFailure($this->lng->txt('md_adv_select_one_file'));
369 $this->showFiles();
370 return false;
371 }
372
373 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
374 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
375 $abs_path = $files->getAbsolutePathByFileId((int) $_POST['file_id'][0]);
376
377 ilUtil::deliverFile($abs_path,'ilias_meta_data_record.xml','application/xml');
378 }
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

References $_POST, ilUtil\deliverFile(), ilUtil\sendFailure(), and showFiles().

+ Here is the call graph for this function:

◆ editField()

ilAdvancedMDSettingsGUI::editField ( ilPropertyFormGUI  $a_form = null)

Edit field.

@access public

Definition at line 1018 of file class.ilAdvancedMDSettingsGUI.php.

1019 {
1020 if(!$_REQUEST["record_id"] || !$_REQUEST["field_id"])
1021 {
1022 return $this->editFields();
1023 }
1024
1025 $this->ctrl->saveParameter($this,'record_id');
1026 $this->ctrl->saveParameter($this,'field_id');
1027
1028 if(!$a_form)
1029 {
1030 $field_definition = ilAdvancedMDFieldDefinition::getInstance((int)$_REQUEST['field_id']);
1031 $a_form = $this->initFieldForm($field_definition);
1032 }
1033 $this->tpl->setContent($a_form->getHTML());
1034 }

References $_REQUEST, editFields(), ilAdvancedMDFieldDefinition\getInstance(), and initFieldForm().

Referenced by updateField().

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

◆ editFields()

ilAdvancedMDSettingsGUI::editFields ( )

Definition at line 708 of file class.ilAdvancedMDSettingsGUI.php.

709 {
710 global $ilToolbar;
711
712 $this->ctrl->saveParameter($this,'record_id');
713 $this->initRecordObject();
714
715 $perm = $this->getPermissions()->hasPermissions(
717 $this->record->getRecordId(),
718 array(
721 ));
722
723 $filter_warn = array();
725 {
726 // type selection
727 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
728 $types = new ilSelectInputGUI("", "ftype");
729 $options = array();
731 {
732 $field = ilAdvancedMDFieldDefinition::getInstance(null, $type);
733 $options[$type] = $this->lng->txt($field->getTypeTitle());
734
735 if(!$field->isFilterSupported())
736 {
737 $filter_warn[] = $this->lng->txt($field->getTypeTitle());
738 }
739 }
740 $types->setOptions($options);
741 $ilToolbar->addInputItem($types);
742
743 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "createField"));
744
745 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
746 $button = ilSubmitButton::getInstance();
747 $button->setCaption("add");
748 $button->setCommand("createField");
749 $ilToolbar->addButtonInstance($button);
750 }
751
752 // #17092
753 if(sizeof($filter_warn))
754 {
755 ilUtil::sendInfo(sprintf($this->lng->txt("md_adv_field_filter_warning"), implode(", ", $filter_warn)));
756 }
757
758 // show field table
759 include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
760 $fields = ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->record->getRecordId());
761
762 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
764 $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
765 $table_gui->parseDefinitions($fields);
766 if(sizeof($fields))
767 {
768 $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
769 }
770 $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
771 $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
772 $table_gui->setSelectAllCheckbox("field_id");
773
774 $this->tpl->setContent($table_gui->getHTML());
775 }
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
This class represents a selection list property in a property form.
static getInstance()
Factory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!is_array($argv)) $options

References $options, ilAdvancedMDPermissionHelper\ACTION_RECORD_CREATE_FIELD, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDFieldDefinition\getInstance(), ilSubmitButton\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), ilAdvancedMDFieldDefinition\getValidTypes(), initRecordObject(), and ilUtil\sendInfo().

Referenced by confirmDeleteFields(), createField(), deleteFields(), editField(), saveField(), updateField(), and updateFields().

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

◆ editRecord()

ilAdvancedMDSettingsGUI::editRecord ( )

Edit one record.

@access public

Parameters

Definition at line 699 of file class.ilAdvancedMDSettingsGUI.php.

700 {
701 $this->ctrl->saveParameter($this,'record_id');
702 $this->initRecordObject();
703 $this->initForm('edit');
704 $this->tpl->setContent($this->form->getHTML());
705
706 }

References initForm(), and initRecordObject().

Referenced by updateRecord().

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

◆ executeCommand()

ilAdvancedMDSettingsGUI::executeCommand ( )

Execute command.

@access public

Parameters

Definition at line 70 of file class.ilAdvancedMDSettingsGUI.php.

71 {
72 $next_class = $this->ctrl->getNextClass($this);
73 $cmd = $this->ctrl->getCmd();
74
75 if(!$this->obj_id)
76 {
77 $this->setSubTabs();
78 }
79
80 switch($next_class)
81 {
82 default:
83 if(!$cmd)
84 {
85 $cmd = 'showRecords';
86 }
87 $this->$cmd();
88 }
89 }
$cmd
Definition: sahs_server.php:35

References $cmd, and setSubTabs().

+ Here is the call graph for this function:

◆ exportRecords()

ilAdvancedMDSettingsGUI::exportRecords ( )

Export records.

@access public

Definition at line 290 of file class.ilAdvancedMDSettingsGUI.php.

291 {
292 if(!isset($_POST['record_id']))
293 {
294 ilUtil::sendFailure($this->lng->txt('select_one'));
295 $this->showRecords();
296 return false;
297 }
298
299 // all records have to be exportable
300 $fail = array();
301 foreach($_POST['record_id'] as $record_id)
302 {
303 if(!$this->getPermissions()->hasPermission(
305 $record_id,
307 {
308 $record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
309 $fail[] = $record->getTitle();
310 }
311 }
312 if($fail)
313 {
314 ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy')." ".implode(", ", $fail), true);
315 $this->ctrl->redirect($this, "showRecords");
316 }
317
318 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
319 $xml_writer = new ilAdvancedMDRecordXMLWriter($_POST['record_id']);
320 $xml_writer->write();
321
322 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
323 $export_files = new ilAdvancedMDRecordExportFiles($this->obj_id);
324 $export_files->create($xml_writer->xmlDumpMem());
325
326 ilUtil::sendSuccess($this->lng->txt('md_adv_records_exported'));
327 $this->showFiles();
328 }

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EXPORT, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\sendFailure(), ilUtil\sendSuccess(), showFiles(), and showRecords().

+ Here is the call graph for this function:

◆ getParsedRecordObjects()

ilAdvancedMDSettingsGUI::getParsedRecordObjects ( )
protected

Get and cache record objects.

@access protected

Definition at line 1659 of file class.ilAdvancedMDSettingsGUI.php.

1660 {
1661 $res = array();
1662
1663 if($this->obj_type)
1664 {
1665 $selected = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $this->sub_type);
1666 }
1667
1668 foreach(ilAdvancedMDRecord::_getRecords() as $record)
1669 {
1670 $parent_id = $record->getParentObject();
1671
1672 if(!$this->obj_type)
1673 {
1674 if($parent_id)
1675 {
1676 continue;
1677 }
1678 }
1679 else
1680 {
1681 // matching parent object?
1682 if($parent_id &&
1683 $parent_id != $this->obj_id)
1684 {
1685 continue;
1686 }
1687
1688 // only globally activated records for object context
1689 if(!$parent_id &&
1690 !$record->isActive())
1691 {
1692 continue;
1693 }
1694 }
1695
1696 $tmp_arr = array();
1697 $tmp_arr['id'] = $record->getRecordId();
1698 $tmp_arr['active'] = $record->isActive();
1699 $tmp_arr['title'] = $record->getTitle();
1700 $tmp_arr['description'] = $record->getDescription();
1701 $tmp_arr['fields'] = array();
1702 $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
1703
1704 $tmp_arr['perm'] = $this->permissions->hasPermissions(
1706 $record->getRecordId(),
1707 array(
1713 ));
1714
1715 if($this->obj_type)
1716 {
1717 $tmp_arr["readonly"] = !(bool)$parent_id;
1718 $tmp_arr["local"] = $parent_id;
1719
1720 // local records are never optional
1721 $assigned = $optional = false;
1722 foreach($tmp_arr['obj_types'] as $idx => $item)
1723 {
1724 if($item["obj_type"] == $this->obj_type &&
1725 $item["sub_type"] == $this->sub_type)
1726 {
1727 $assigned = true;
1728 $optional = $item["optional"];
1729 $tmp_arr['obj_types'][$idx]['context'] = true;
1730 break;
1731 }
1732 }
1733 if(!$assigned)
1734 {
1735 continue;
1736 }
1737 $tmp_arr['optional'] = $optional;
1738 if($optional)
1739 {
1740 // in object context "active" means selected record
1741 $tmp_arr['active'] = in_array($record->getRecordId(), $selected);
1742 }
1743 }
1744
1745 $res[] = $tmp_arr;
1746 }
1747
1748 return $res;
1749 }
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
static _getRecords()
Get records.

References $res, ilAdvancedMDRecord\_getRecords(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_FIELDS, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDRecord\getObjRecSelection(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

Referenced by showRecords(), and updateRecords().

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

◆ getPermissions()

◆ getSubstitutionFieldPermissions()

ilAdvancedMDSettingsGUI::getSubstitutionFieldPermissions (   $a_obj_type,
  $a_field_id 
)
protected

Definition at line 1329 of file class.ilAdvancedMDSettingsGUI.php.

1330 {
1331 if($a_obj_type == "crs")
1332 {
1333 $perm = $this->getPermissions()->hasPermissions(
1335 $a_field_id,
1336 array(
1342 ));
1343 return array(
1347 );
1348 }
1349 else if($a_obj_type == "cat")
1350 {
1351 $perm = $this->getPermissions()->hasPermissions(
1353 $a_field_id,
1354 array(
1360 ));
1361 return array(
1365 );
1366 }
1367 }

References ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_COURSE_SHOW_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_CATEGORY, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_COURSE, getPermissions(), ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_BOLD, and ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_NEWLINE.

Referenced by initFormSubstitutions(), and updateSubstitutions().

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

◆ importRecord()

ilAdvancedMDSettingsGUI::importRecord ( )

import xml file

@access public

Parameters

Definition at line 925 of file class.ilAdvancedMDSettingsGUI.php.

926 {
927 $this->initImportForm();
928 if(!$this->import_form->checkInput())
929 {
930 $this->import_form->setValuesByPost();
931 $this->createRecord();
932 return false;
933 }
934
935 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
936 $import_files = new ilAdvancedMDRecordImportFiles();
937 if(!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name']))
938 {
939 $this->createRecord();
940 return false;
941 }
942
943 try
944 {
945 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
946 $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
947
948 // local import?
949 if($this->obj_id)
950 {
951 $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
952 }
953
954 // Validate
956 $parser->startParsing();
957
958 // Insert
960 $parser->startParsing();
961 ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'), true);
962 $this->ctrl->redirect($this, "showRecords");
963 }
964 catch(ilSAXParserException $exc)
965 {
966 ilUtil::sendFailure($exc->getMessage(), true);
967 $this->ctrl->redirect($this, "importRecords");
968 }
969
970 // Finally delete import file
971 $import_files->deleteFileByCreationDate($create_time);
972 return true;
973 }
SAX based XML parser for record import files.

References createRecord(), initImportForm(), ilAdvancedMDRecordParser\MODE_INSERT, ilAdvancedMDRecordParser\MODE_INSERT_VALIDATION, ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ importRecords()

ilAdvancedMDSettingsGUI::importRecords ( )

Definition at line 883 of file class.ilAdvancedMDSettingsGUI.php.

884 {
885 // Import Table
886 $this->initImportForm();
887 $this->tpl->setContent($this->import_form->getHTML());
888 }

References initImportForm().

+ Here is the call graph for this function:

◆ initFieldForm()

ilAdvancedMDSettingsGUI::initFieldForm ( ilAdvancedMDFieldDefinition  $a_definition)
protected

init field form

@access protected

Definition at line 1152 of file class.ilAdvancedMDSettingsGUI.php.

1153 {
1154 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1155
1156 $form = new ilPropertyFormGUI();
1157 $form->setFormAction($this->ctrl->getFormAction($this));
1158
1159 $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1160 $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1161 $form->addItem($type);
1162
1163 $a_definition->addToFieldDefinitionForm($form, $this->getPermissions());
1164
1165 if(!$a_definition->getFieldId())
1166 {
1167 $form->setTitle($this->lng->txt('md_adv_create_field'));
1168 $form->addCommandButton('saveField',$this->lng->txt('create'));
1169 }
1170 else
1171 {
1172 $form->setTitle($this->lng->txt('md_adv_edit_field'));
1173 $form->addCommandButton('updateField',$this->lng->txt('save'));
1174 }
1175
1176 $form->addCommandButton('editFields',$this->lng->txt('cancel'));
1177
1178 return $form;
1179 }
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
Add input elements to definition form.
This class represents a non editable value in a property form.
This class represents a property form user interface.

References ilAdvancedMDFieldDefinition\addToFieldDefinitionForm(), ilAdvancedMDFieldDefinition\getFieldId(), getPermissions(), and ilAdvancedMDFieldDefinition\getTypeTitle().

Referenced by createField(), editField(), saveField(), and updateField().

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

◆ initForm()

ilAdvancedMDSettingsGUI::initForm (   $a_mode)
protected

Init Form.

@access protected

Definition at line 1186 of file class.ilAdvancedMDSettingsGUI.php.

1187 {
1188 if(is_object($this->form))
1189 {
1190 return true;
1191 }
1192
1193 $perm = $this->getPermissions()->hasPermissions(
1195 $this->record->getRecordId(),
1196 array(
1204 ));
1205
1206 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1207
1208 $this->form = new ilPropertyFormGUI();
1209 $this->form->setFormAction($this->ctrl->getFormAction($this));
1210
1211
1212 // title
1213 $title = new ilTextInputGUI($this->lng->txt('title'),'title');
1214 $title->setValue($this->record->getTitle());
1215 $title->setSize(20);
1216 $title->setMaxLength(70);
1217 $title->setRequired(true);
1218 $this->form->addItem($title);
1219
1221 {
1222 $title->setDisabled(true);
1223 }
1224
1225 // desc
1226 $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
1227 $desc->setValue($this->record->getDescription());
1228 $desc->setRows(3);
1229 $desc->setCols(50);
1230 $this->form->addItem($desc);
1231
1233 {
1234 $desc->setDisabled(true);
1235 }
1236
1237 // active
1238 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'),'active');
1239 $check->setChecked($this->record->isActive());
1240 $check->setValue(1);
1241 $this->form->addItem($check);
1242
1244 {
1245 $check->setDisabled(true);
1246 }
1247
1248 if(!$this->obj_type)
1249 {
1251 $section->setTitle($this->lng->txt('md_obj_types'));
1252 $this->form->addItem($section);
1253
1254 // see ilAdvancedMDRecordTableGUI::fillRow()
1255 $options = array(
1256 0 => $this->lng->txt("meta_obj_type_inactive"),
1257 1 => $this->lng->txt("meta_obj_type_mandatory"),
1258 2 => $this->lng->txt("meta_obj_type_optional")
1259 );
1260
1261
1262 foreach(ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type)
1263 {
1264 $t = $type["obj_type"].":".$type["sub_type"];
1265 $this->lng->loadLanguageModule($type["obj_type"]);
1266
1267 $type_options = $options;
1268 switch($type["obj_type"])
1269 {
1270 case "orgu":
1271 // currently only optional records for org unit (types)
1272 unset($type_options[1]);
1273 break;
1274 case "prg":
1275 // currently only optional records for study programme (types)
1276 unset($type_options[1]);
1277 break;
1278 case "rcrs":
1279 // optional makes no sense for ecs-courses
1280 unset($type_options[2]);
1281 break;
1282 }
1283
1284 $value = 0;
1285 if($a_mode == "edit")
1286 {
1287 foreach($this->record->getAssignedObjectTypes() as $item)
1288 {
1289 if($item["obj_type"] == $type["obj_type"] &&
1290 $item["sub_type"] == $type["sub_type"])
1291 {
1292 $value = $item["optional"]
1293 ? 2
1294 : 1;
1295 }
1296 }
1297 }
1298
1299 $check = new ilSelectInputGUI($type["text"],'obj_types['.$t.']');
1300 $check->setOptions($type_options);
1301 $check->setValue($value);
1302 $this->form->addItem($check);
1303
1305 {
1306 $check->setDisabled(true);
1307 }
1308 }
1309 }
1310
1311 switch($a_mode)
1312 {
1313 case 'create':
1314 $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1315 $this->form->addCommandButton('saveRecord',$this->lng->txt('add'));
1316 $this->form->addCommandButton('showRecords',$this->lng->txt('cancel'));
1317
1318 return true;
1319
1320 case 'edit':
1321 $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1322 $this->form->addCommandButton('updateRecord',$this->lng->txt('save'));
1323 $this->form->addCommandButton('showRecords',$this->lng->txt('cancel'));
1324
1325 return true;
1326 }
1327 }
$section
Definition: Utf8Test.php:84
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References $options, $section, $t, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

Referenced by createRecord(), and editRecord().

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

◆ initFormSubstitutions()

ilAdvancedMDSettingsGUI::initFormSubstitutions ( )
protected

init form table 'substitutions'

@access protected

Definition at line 1374 of file class.ilAdvancedMDSettingsGUI.php.

1375 {
1376 global $ilAccess;
1377
1378 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1379
1380 if(!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType())
1381 {
1382 return;
1383 }
1384
1385 $this->form = new ilPropertyFormGUI();
1386 $this->form->setFormAction($this->ctrl->getFormAction($this));
1387 #$this->form->setTableWidth('100%');
1388
1389 // substitution
1390 foreach($visible_records as $obj_type => $records)
1391 {
1392 $perm = null;
1393 // :TODO: hardwird ?
1394 if(in_array($obj_type, array("crs", "cat")))
1395 {
1396 $perm = $this->getPermissions()->hasPermissions(
1398 $obj_type,
1399 array(
1403 ));
1404 }
1405
1406 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
1408
1409 // Show section
1411 $section->setTitle($this->lng->txt('objs_'.$obj_type));
1412 $this->form->addItem($section);
1413
1414 $check = new ilCheckboxInputGUI($this->lng->txt('description'),'enabled_desc_'.$obj_type);
1415 $check->setValue(1);
1416 $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1417 $check->setChecked($sub->isDescriptionEnabled() ? true : false);
1418 $this->form->addItem($check);
1419
1421 {
1422 $check->setDisabled(true);
1423 }
1424
1425 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'),'enabled_field_names_'.$obj_type);
1426 $check->setValue(1);
1427 $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1428 $check->setChecked($sub->enabledFieldNames() ? true : false);
1429 $this->form->addItem($check);
1430
1432 {
1433 $check->setDisabled(true);
1434 }
1435
1436 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
1437 #$area->setUseRte(true);
1438 #$area->setRteTagSet('standard');
1439 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
1440 #$area->setRows(5);
1441 #$area->setCols(80);
1442 #$this->form->addItem($area);
1443
1444 if($perm)
1445 {
1447 }
1448
1450 $definitions = $sub->sortDefinitions($definitions);
1451
1452 $counter = 1;
1453 foreach($definitions as $def)
1454 {
1455 $definition_id = $def->getFieldId();
1456
1457 $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id);
1458
1459 $title = ilAdvancedMDRecord::_lookupTitle($def->getRecordId());
1460 $title = $def->getTitle().' ('.$title.')';
1461
1462 $check = new ilCheckboxInputGUI($title,'show['.$obj_type.']['.$definition_id.']');
1463 $check->setValue(1);
1464 $check->setOptionTitle($this->lng->txt('md_adv_show'));
1465 $check->setChecked($sub->isSubstituted($definition_id));
1466
1467 if($perm && !$perm["show"])
1468 {
1469 $check->setDisabled(true);
1470 }
1471
1472 $pos = new ilNumberInputGUI($this->lng->txt('position'),'position['.$obj_type.']['.$definition_id.']');
1473 $pos->setSize(3);
1474 $pos->setMaxLength(4);
1475 $pos->allowDecimals(true);
1476 $pos->setValue(sprintf('%.1f',$counter++));
1477 $check->addSubItem($pos);
1478
1479 if($perm && !$perm_pos)
1480 {
1481 $pos->setDisabled(true);
1482 }
1483
1484 $bold = new ilCheckboxInputGUI($this->lng->txt('bold'),'bold['.$obj_type.']['.$definition_id.']');
1485 $bold->setValue(1);
1486 $bold->setChecked($sub->isBold($definition_id));
1487 $check->addSubItem($bold);
1488
1489 if($perm && !$perm["bold"])
1490 {
1491 $bold->setDisabled(true);
1492 }
1493
1494 $bold = new ilCheckboxInputGUI($this->lng->txt('newline'),'newline['.$obj_type.']['.$definition_id.']');
1495 $bold->setValue(1);
1496 $bold->setChecked($sub->hasNewline($definition_id));
1497 $check->addSubItem($bold);
1498
1499 if($perm && !$perm["newline"])
1500 {
1501 $bold->setDisabled(true);
1502 }
1503
1504
1505 $this->form->addItem($check);
1506 }
1507
1508
1509 // placeholder
1510 /*
1511 $custom = new ilCustomInputGUI($this->lng->txt('md_adv_placeholders'));
1512 $tpl = new ilTemplate('tpl.placeholder_info.html',true,true,'Services/AdvancedMetaData');
1513 foreach($records as $record)
1514 {
1515 foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $definition)
1516 {
1517 $tpl->setCurrentBlock('field');
1518 $tpl->setVariable('FIELD_NAME',$definition->getTitle());
1519 $tpl->setVariable('MODULE_VARS','[IF_F_'.$definition->getFieldId().']...[F_'.$definition->getFieldId().']'.
1520 '[/IF_F_'.$definition->getFieldId().']');
1521 $tpl->parseCurrentBlock();
1522 }
1523
1524 $tpl->setCurrentBlock('record');
1525 $tpl->setVariable('PLACEHOLDER_FOR',$this->lng->txt('md_adv_placeholder_for'));
1526 $tpl->setVariable('TITLE',$record->getTitle());
1527 $tpl->parseCurrentBlock();
1528 }
1529 $custom->setHTML($tpl->get());
1530 $this->form->addItem($custom);
1531 */
1532 }
1533 $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1534
1535 if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
1536 {
1537 $this->form->addCommandButton('updateSubstitutions',$this->lng->txt('save'));
1538 }
1539
1540 return true;
1541 }
static getInstancesByObjType($a_obj_type, $a_active_only=true)
static _lookupTitle($a_record_id)
Lookup title.
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! @access public.
getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
This class represents a number property in a property form.
$records
Definition: simple_test.php:17

References $_REQUEST, $obj_type, $records, $section, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDRecord\_lookupTitle(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ilAdvancedMDFieldDefinition\getInstancesByObjType(), getPermissions(), and getSubstitutionFieldPermissions().

Referenced by showPresentation().

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

◆ initImportForm()

ilAdvancedMDSettingsGUI::initImportForm ( )
protected

show import form

@access protected

Definition at line 895 of file class.ilAdvancedMDSettingsGUI.php.

896 {
897 if(is_object($this->import_form))
898 {
899 return true;
900 }
901
902 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
903 $this->import_form = new ilPropertyFormGUI();
904 $this->import_form->setMultipart(true);
905 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
906
907 // add file property
908 $file = new ilFileInputGUI($this->lng->txt('file'),'file');
909 $file->setSuffixes(array('xml'));
910 $file->setRequired(true);
911 $this->import_form->addItem($file);
912
913 $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
914 $this->import_form->addCommandButton('importRecord',$this->lng->txt('import'));
915 $this->import_form->addCommandButton('showRecords',$this->lng->txt('cancel'));
916 }
print $file
This class represents a file property in a property form.

References $file.

Referenced by importRecord(), and importRecords().

+ Here is the caller graph for this function:

◆ initRecordObject()

ilAdvancedMDSettingsGUI::initRecordObject ( )
protected

Init record object.

@access protected

Definition at line 1606 of file class.ilAdvancedMDSettingsGUI.php.

1607 {
1608 if(!is_object($this->record))
1609 {
1610 $record_id = isset($_GET['record_id'])
1611 ? $_GET['record_id']
1612 : 0;
1613 $this->record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
1614
1615 // bind to parent object (aka local adv md)
1616 if(!$record_id &&
1617 $this->obj_id)
1618 {
1619 $this->record->setParentObject($this->obj_id);
1620 }
1621 }
1622
1623 return $this->record;
1624 }
$_GET["client_id"]

References $_GET, and ilAdvancedMDRecord\_getInstanceByRecordId().

Referenced by createRecord(), editFields(), editRecord(), saveRecord(), and updateRecord().

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

◆ loadRecordFormData()

ilAdvancedMDSettingsGUI::loadRecordFormData ( )
protected

load record form data

@access protected

Definition at line 1548 of file class.ilAdvancedMDSettingsGUI.php.

1549 {
1550 $perm = $this->getPermissions()->hasPermissions(
1552 $this->record->getRecordId(),
1553 array(
1561 ));
1562
1564 {
1565 $this->record->setActive(ilUtil::stripSlashes($_POST['active']));
1566 }
1568 {
1569 $this->record->setTitle(ilUtil::stripSlashes($_POST['title']));
1570 }
1572 {
1573 $this->record->setDescription(ilUtil::stripSlashes($_POST['desc']));
1574 }
1575
1576 if(!$this->obj_type)
1577 {
1579 {
1580 $obj_types = array();
1581 if (is_array($_POST['obj_types']))
1582 {
1583 foreach ($_POST['obj_types'] as $t => $value)
1584 {
1585 if($value)
1586 {
1587 $t = explode(":", $t);
1588 $obj_types[] = array(
1589 "obj_type" => ilUtil::stripSlashes($t[0]),
1590 "sub_type" => ilUtil::stripSlashes($t[1]),
1591 "optional" => ($value > 1)
1592 );
1593 }
1594 }
1595 }
1596 $this->record->setAssignedObjectTypes($obj_types);
1597 }
1598 }
1599 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, $t, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\stripSlashes(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

Referenced by saveRecord(), and updateRecord().

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

◆ saveField()

ilAdvancedMDSettingsGUI::saveField ( )

create field

@access public

Definition at line 1117 of file class.ilAdvancedMDSettingsGUI.php.

1118 {
1119 global $ilErr;
1120
1121 if(!$_REQUEST["record_id"] || !$_REQUEST["ftype"])
1122 {
1123 return $this->editFields();
1124 }
1125
1126 $this->ctrl->saveParameter($this,'record_id');
1127 $this->ctrl->saveParameter($this,'ftype');
1128
1129 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1130 $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1131 $field_definition->setRecordId($_REQUEST["record_id"]);
1132 $form = $this->initFieldForm($field_definition);
1133
1134 if($form->checkInput())
1135 {
1136 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions());
1137 $field_definition->save();
1138
1139 ilUtil::sendSuccess($this->lng->txt('save_settings'), true);
1140 $this->ctrl->redirect($this, "editFields");
1141 }
1142
1143 $form->setValuesByPost();
1144 $this->createField($form);
1145 }
createField(ilPropertyFormGUI $a_form=null)
Show field type selection.

References $_REQUEST, $ilErr, createField(), editFields(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), initFieldForm(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ saveRecord()

ilAdvancedMDSettingsGUI::saveRecord ( )

Save record.

@access public

Parameters

Definition at line 983 of file class.ilAdvancedMDSettingsGUI.php.

984 {
985 global $ilErr;
986
987 $this->initRecordObject();
988 $this->loadRecordFormData();
989
990 if($this->obj_type)
991 {
992 $this->record->setAssignedObjectTypes(array(
993 array(
994 "obj_type"=>$this->obj_type,
995 "sub_type"=>$this->sub_type,
996 "optional"=>false
997 )));
998 }
999
1000 if(!$this->record->validate())
1001 {
1002 ilUtil::sendFailure($this->lng->txt($ilErr->getMessage()));
1003 $this->createRecord();
1004 return false;
1005 }
1006 $this->record->save();
1007
1008 ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'));
1009 $this->showRecords();
1010 }

References $ilErr, createRecord(), initRecordObject(), loadRecordFormData(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showRecords().

+ Here is the call graph for this function:

◆ setSubTabs()

ilAdvancedMDSettingsGUI::setSubTabs ( )
protected

Set sub tabs.

@access protected

Definition at line 1631 of file class.ilAdvancedMDSettingsGUI.php.

1632 {
1633 $this->tabs_gui->clearSubTabs();
1634
1635 $this->tabs_gui->addSubTabTarget("md_adv_record_list",
1636 $this->ctrl->getLinkTarget($this, "showRecords"),
1637 '',
1638 '',
1639 '',
1640 true);
1641
1642
1644 {
1645 $this->tabs_gui->addSubTabTarget("md_adv_presentation",
1646 $this->ctrl->getLinkTarget($this, "showPresentation"));
1647 }
1648
1649 $this->tabs_gui->addSubTabTarget("md_adv_file_list",
1650 $this->ctrl->getLinkTarget($this, "showFiles"),
1651 "showFiles");
1652 }

References ilAdvancedMDRecord\_getAllRecordsByObjectType().

Referenced by executeCommand().

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

◆ showFiles()

ilAdvancedMDSettingsGUI::showFiles ( )

show export files

@access public

Parameters

Definition at line 337 of file class.ilAdvancedMDSettingsGUI.php.

338 {
339 $this->tabs_gui->setSubTabActive('md_adv_file_list');
340
341 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
342 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
343 $file_data = $files->readFilesInfo();
344
345 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
346 $table_gui = new ilAdvancedMDRecordExportFilesTableGUI($this, "showFiles");
347 $table_gui->setTitle($this->lng->txt("md_record_export_table"));
348 $table_gui->parseFiles($file_data);
349 $table_gui->addMultiCommand("downloadFile",$this->lng->txt('download'));
350 $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
351 $table_gui->addCommandButton('showFiles',$this->lng->txt('cancel'));
352 $table_gui->setSelectAllCheckbox("file_id");
353
354 $this->tpl->setContent($table_gui->getHTML());
355 }

Referenced by confirmDeleteFiles(), deleteFiles(), downloadFile(), and exportRecords().

+ Here is the caller graph for this function:

◆ showPresentation()

ilAdvancedMDSettingsGUI::showPresentation ( )

Definition at line 157 of file class.ilAdvancedMDSettingsGUI.php.

158 {
159 if($this->initFormSubstitutions())
160 {
161 if (is_object($this->form))
162 {
163 $this->tabs_gui->setSubTabActive('md_adv_presentation');
164 return $this->tpl->setContent($this->form->getHTML());
165 }
166 }
167 return $this->showRecords();
168 }
initFormSubstitutions()
init form table 'substitutions'

References initFormSubstitutions(), and showRecords().

+ Here is the call graph for this function:

◆ showRecords()

ilAdvancedMDSettingsGUI::showRecords ( )

show record list

@access public

Parameters

Definition at line 98 of file class.ilAdvancedMDSettingsGUI.php.

99 {
100 global $ilToolbar, $ilAccess;
101
102 $perm = $this->getPermissions()->hasPermissions(
104 $_REQUEST["ref_id"],
105 array(
108 ));
109
111 {
112 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
113 $button = ilLinkButton::getInstance();
114 $button->setCaption("add");
115 $button->setUrl($this->ctrl->getLinkTarget($this, "createRecord"));
116 $ilToolbar->addButtonInstance($button);
117
119 {
120 $ilToolbar->addSeparator();
121 }
122 }
123
125 {
126 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
127 $button = ilLinkButton::getInstance();
128 $button->setCaption("import");
129 $button->setUrl($this->ctrl->getLinkTarget($this, "importRecords"));
130 $ilToolbar->addButtonInstance($button);
131 }
132
133 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.show_records.html','Services/AdvancedMetaData');
134
135 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
136 $table_gui = new ilAdvancedMDRecordTableGUI($this, "showRecords", $this->getPermissions(), (bool)$this->obj_id);
137 $table_gui->setTitle($this->lng->txt("md_record_list_table"));
138 $table_gui->setData($this->getParsedRecordObjects());
139
140 // permissions?
141 //$table_gui->addCommandButton('createRecord',$this->lng->txt('add'));
142 $table_gui->addMultiCommand("exportRecords",$this->lng->txt('export'));
143 $table_gui->setSelectAllCheckbox("record_id");
144
145 if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
146 {
147 $table_gui->addMultiCommand("confirmDeleteRecords", $this->lng->txt("delete"));
148 $table_gui->addCommandButton("updateRecords", $this->lng->txt("save"));
149 }
150
151
152 $this->tpl->setVariable('RECORD_TABLE',$table_gui->getHTML());
153
154 return true;
155 }
getParsedRecordObjects()
Get and cache record objects.
static getInstance()
Factory.

References $_REQUEST, ilAdvancedMDPermissionHelper\ACTION_MD_CREATE_RECORD, ilAdvancedMDPermissionHelper\ACTION_MD_IMPORT_RECORDS, ilAdvancedMDPermissionHelper\CONTEXT_MD, ilLinkButton\getInstance(), getParsedRecordObjects(), and getPermissions().

Referenced by confirmDeleteRecords(), deleteRecords(), exportRecords(), saveRecord(), showPresentation(), and updateRecord().

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

◆ updateField()

ilAdvancedMDSettingsGUI::updateField ( )

Update field.

@access public

Definition at line 1042 of file class.ilAdvancedMDSettingsGUI.php.

1043 {
1044 global $ilErr;
1045
1046 if(!$_REQUEST["record_id"] || !$_REQUEST["field_id"])
1047 {
1048 return $this->editFields();
1049 }
1050
1051 $this->ctrl->saveParameter($this,'record_id');
1052 $this->ctrl->saveParameter($this,'field_id');
1053
1054 $confirm = false;
1055 $field_definition = ilAdvancedMDFieldDefinition::getInstance((int)$_REQUEST['field_id']);
1056 $form = $this->initFieldForm($field_definition);
1057 if($form->checkInput())
1058 {
1059 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions());
1060 if(!$field_definition->importDefinitionFormPostValuesNeedsConfirmation())
1061 {
1062 $field_definition->update();
1063
1064 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1065 $this->ctrl->redirect($this, "editFields");
1066 }
1067 else
1068 {
1069 $confirm = true;
1070 }
1071 }
1072
1073 $form->setValuesByPost();
1074
1075 // fields needs confirmation of updated settings
1076 if($confirm)
1077 {
1078 ilUtil::sendInfo($this->lng->txt("md_adv_confirm_definition"));
1079 $field_definition->prepareDefinitionFormConfirmation($form);
1080 }
1081
1082 $this->editField($form);
1083 }
editField(ilPropertyFormGUI $a_form=null)
Edit field.

References $_REQUEST, $ilErr, editField(), editFields(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), initFieldForm(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ updateFields()

ilAdvancedMDSettingsGUI::updateFields ( )

Update fields.

@access public

Definition at line 783 of file class.ilAdvancedMDSettingsGUI.php.

784 {
785 $this->ctrl->saveParameter($this,'record_id');
786
787 if(!isset($_GET['record_id']) or !$_GET['record_id'])
788 {
789 ilUtil::sendFailure($this->lng->txt('select_one'));
790 $this->editFields();
791 return false;
792 }
793
794 include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
796
797 if($this->getPermissions()->hasPermission(
799 $_GET['record_id'],
801 {
802 if(!isset($_POST['position']) or !is_array($_POST['position']))
803 {
804 $this->editFields();
805 return false;
806 }
807 // sort by position
808 asort($_POST['position'],SORT_NUMERIC);
809 $positions = array_flip(array_keys($_POST['position']));
810 foreach($fields as $field)
811 {
812 $field->setPosition($positions[$field->getFieldId()]);
813 $field->update();
814 }
815 }
816
817 foreach($fields as $field)
818 {
819 if($this->getPermissions()->hasPermission(
821 $field->getFieldId(),
824 {
825 $field->setSearchable(isset($_POST['searchable'][$field->getFieldId()]) ? true : false);
826 $field->update();
827 }
828 }
829
830
831 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
832 $this->ctrl->redirect($this, "editFields");
833 }

References $_GET, $_POST, ilAdvancedMDPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, editFields(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilAdvancedMDPermissionHelper\SUBACTION_FIELD_SEARCHABLE.

+ Here is the call graph for this function:

◆ updateRecord()

ilAdvancedMDSettingsGUI::updateRecord ( )

Update record.

@access public

Parameters

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

843 {
844 global $ilErr;
845
846 if(!isset($_GET['record_id']) or !$_GET['record_id'])
847 {
848 ilUtil::sendFailure($this->lng->txt('select_one'));
849 $this->showRecords();
850 return false;
851 }
852 $this->initRecordObject();
853 $this->loadRecordFormData();
854
855 if(!$this->record->validate())
856 {
857 ilUtil::sendFailure($this->lng->txt($ilErr->getMessage()));
858 $this->editRecord();
859 return false;
860 }
861 $this->record->update();
862 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
863 $this->showRecords();
864 return true;
865 }

References $_GET, $ilErr, editRecord(), initRecordObject(), loadRecordFormData(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showRecords().

+ Here is the call graph for this function:

◆ updateRecords()

ilAdvancedMDSettingsGUI::updateRecords ( )

Save records (assigned object typed)

@access public

Parameters

Definition at line 538 of file class.ilAdvancedMDSettingsGUI.php.

539 {
540 $selected_global = array();
541 foreach($this->getParsedRecordObjects() as $item)
542 {
543 $perm = $this->getPermissions()->hasPermissions(
545 $item['id'],
546 array(
550 ));
551
552 if(!$this->obj_type)
553 {
554 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
555
557 {
558 $obj_types = array();
559 if (is_array($_POST['obj_types'][$record_obj->getRecordId()]))
560 {
561 foreach ($_POST['obj_types'][$record_obj->getRecordId()] as $type => $status)
562 {
563 if($status)
564 {
565 $type = explode(":", $type);
566 $obj_types[] = array(
567 "obj_type" => ilUtil::stripSlashes($type[0]),
568 "sub_type" => ilUtil::stripSlashes($type[1]),
569 "optional" => ((int)$status == 2)
570 );
571 }
572 }
573 }
574 $record_obj->setAssignedObjectTypes($obj_types);
575 }
576
578 {
579 $record_obj->setActive(isset($_POST['active'][$record_obj->getRecordId()]));
580 }
581
582 $record_obj->update();
583 }
585 {
586 // global, optional record
587 if($item['readonly'] &&
588 $item['optional'] &&
589 $_POST['active'][$item['id']])
590 {
591 $selected_global[] = $item['id'];
592 }
593 else if($item['local'])
594 {
595 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
596 $record_obj->setActive(isset($_POST['active'][$item['id']]));
597 $record_obj->update();
598 }
599 }
600 }
601
602 if($this->obj_type)
603 {
604 ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $this->sub_type, $selected_global);
605 }
606
607 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
608 $this->ctrl->redirect($this, "showRecords");
609 }
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.

References $_POST, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getParsedRecordObjects(), getPermissions(), ilAdvancedMDRecord\saveObjRecSelection(), ilUtil\sendSuccess(), ilUtil\stripSlashes(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

+ Here is the call graph for this function:

◆ updateSubstitutions()

ilAdvancedMDSettingsGUI::updateSubstitutions ( )

Update substitution.

@access public

Definition at line 176 of file class.ilAdvancedMDSettingsGUI.php.

177 {
178 global $ilAccess;
179
180 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
181 {
182 $this->ctrl->redirect($this, "showPresentation");
183 }
184
186 {
187 $perm = null;
188 // :TODO: hardwired?
189 if(in_array($obj_type, array("crs", "cat")))
190 {
191 $perm = $this->getPermissions()->hasPermissions(
193 $obj_type,
194 array(
198 ));
199 }
200
201 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
203
205 {
206 $sub->enableDescription($_POST['enabled_desc_'.$obj_type]);
207 }
208
210 {
211 $sub->enableFieldNames((int) $_POST['enabled_field_names_'.$obj_type]);
212 }
213
215 $definitions = $sub->sortDefinitions($definitions);
216
217 // gather existing data
218 $counter = 1;
219 $old_sub = array();
220 foreach($definitions as $def)
221 {
222 $field_id = $def->getFieldId();
223 $old_sub[$field_id] = array(
224 "active" => $sub->isSubstituted($field_id),
225 "pos" => $counter++,
226 "bold" => $sub->isBold($field_id),
227 "newline" => $sub->hasNewline($field_id)
228 );
229 }
230
231 $sub->resetSubstitutions(array());
232
233 $new_sub = array();
234 foreach($definitions as $def)
235 {
236 $field_id = $def->getFieldId();
237 $old = $old_sub[$field_id];
238
239 $perm_def = $this->getSubstitutionFieldPermissions($obj_type, $field_id);
240 if($perm_def["show"])
241 {
242 $active = (isset($_POST['show'][$obj_type][$field_id]) && $_POST['show'][$obj_type][$field_id]);
243 }
244 else
245 {
246 $active = $old["active"];
247 }
248
249 if($active)
250 {
251 $new_sub[$field_id] = $old;
252
254 {
255 $new_sub[$field_id]["pos"] = (int)$_POST['position'][$obj_type][$field_id];
256 }
257 if($perm_def["bold"])
258 {
259 $new_sub[$field_id]["bold"] = (isset($_POST['bold'][$obj_type][$field_id]) && $_POST['bold'][$obj_type][$field_id]);
260 }
261 if($perm_def["newline"])
262 {
263 $new_sub[$field_id]["newline"] = (isset($_POST['newline'][$obj_type][$field_id]) && $_POST['newline'][$obj_type][$field_id]);
264 }
265 }
266 }
267
268 if(sizeof($new_sub))
269 {
270 $new_sub = ilUtil::sortArray($new_sub, "pos", "asc", true, true);
271 foreach($new_sub as $field_id => $field)
272 {
273 $sub->appendSubstitution($field_id, $field["bold"], $field["newline"]);
274 }
275 }
276
277 $sub->update();
278 }
279
280
281 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
282 $this->ctrl->redirect($this, "showPresentation");
283 }
static _getActivatedObjTypes()
get activated obj types
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References $_POST, $_REQUEST, $obj_type, ilAdvancedMDRecord\_getActivatedObjTypes(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ilAdvancedMDFieldDefinition\getInstancesByObjType(), getPermissions(), getSubstitutionFieldPermissions(), ilUtil\sendSuccess(), and ilUtil\sortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilAdvancedMDSettingsGUI::$ctrl
protected

Definition at line 20 of file class.ilAdvancedMDSettingsGUI.php.

◆ $lng

ilAdvancedMDSettingsGUI::$lng
protected

Definition at line 18 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by __construct().

◆ $obj_id

ilAdvancedMDSettingsGUI::$obj_id
protected

Definition at line 23 of file class.ilAdvancedMDSettingsGUI.php.

◆ $obj_type

ilAdvancedMDSettingsGUI::$obj_type
protected

Definition at line 24 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by initFormSubstitutions(), and updateSubstitutions().

◆ $permissions

ilAdvancedMDSettingsGUI::$permissions
protected

Definition at line 22 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by getPermissions().

◆ $sub_type

ilAdvancedMDSettingsGUI::$sub_type
protected

Definition at line 25 of file class.ilAdvancedMDSettingsGUI.php.

◆ $tabs

ilAdvancedMDSettingsGUI::$tabs
protected

Definition at line 21 of file class.ilAdvancedMDSettingsGUI.php.

◆ $tpl

ilAdvancedMDSettingsGUI::$tpl
protected

Definition at line 19 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by __construct().


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