ILIAS  release_7 Revision v7.30-3-g800a261c036
ilAdvancedMDSettingsGUI Class Reference
+ Collaboration diagram for ilAdvancedMDSettingsGUI:

Public Member Functions

 __construct ($a_ref_id=null, $a_obj_type=null, $a_sub_type=null)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 showRecords ()
 show record list More...
 
 updateSubstitutions ()
 Update substitution. More...
 
 exportRecords ()
 Export records. 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 (ilPropertyFormGUI $form=null)
 Edit one record. More...
 
 updateFields ()
 Update fields. More...
 
 updateRecord ()
 Update record. More...
 
 createRecord (ilPropertyFormGUI $form=null)
 Show. More...
 
 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...
 
 editComplexOption (ilPropertyFormGUI $a_form=null)
 
 updateComplexOption ()
 

Data Fields

const CONTEXT_ADMINISTRATION = 1
 
const CONTEXT_OBJECT = 2
 

Protected Member Functions

 getPermissions ()
 
 showPresentation ()
 
 showFiles ()
 Show export files. More...
 
 editFields ()
 
 importRecords ()
 
 setRecordSubTabs (int $level=1, bool $show_settings=false)
 Set subtabs for record editing/creation. More...
 
 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 ()
 
 initRecordObject ()
 Init record object. More...
 
 setSubTabs (int $context)
 Set sub tabs. More...
 
 getParsedRecordObjects ()
 Get and cache record objects. More...
 
 initComplexOptionForm (ilAdvancedMDFieldDefinition $a_def)
 
 initLanguage (int $record_id)
 
 showLanguageSwitch (int $record_id, string $target)
 

Protected Attributes

const TAB_RECORD_SETTINGS = 'editRecord'
 
const TAB_TRANSLATION = 'translations'
 
 $lng
 
 $tpl
 
 $ctrl
 
 $tabs_gui
 
 $permissions
 
 $ref_id = null
 
 $obj_id = null
 
 $obj_type = null
 
 $sub_type = null
 
 $request
 
 $ui_factory
 
 $ui_renderer
 
 $toolbar
 
 $record
 

Private Attributes

 $context = null
 
 $logger = null
 
 $active_language = ''
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

@access public

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

95 {
96 global $DIC;
97
98 $tpl = $DIC['tpl'];
99 $lng = $DIC['lng'];
100 $ilCtrl = $DIC['ilCtrl'];
101 $ilTabs = $DIC->tabs();
102
103 $this->ctrl = $ilCtrl;
104 $this->lng = $lng;
105 $this->lng->loadLanguageModule('meta');
106 $this->tpl = $tpl;
107 $this->tabs_gui = $ilTabs;
108
109 $this->toolbar = $DIC->toolbar();
110 $this->ui_factory = $DIC->ui()->factory();
111 $this->ui_renderer = $DIC->ui()->renderer();
112 $this->request = $DIC->http()->request();
113
114 $this->logger = $GLOBALS['DIC']->logger()->amet();
115
116 $this->ref_id = $a_ref_id;
117 if ($this->ref_id) {
118 $this->obj_id = ilObject::_lookupObjId($a_ref_id);
119 }
120
121 if (!$this->ref_id) {
122 $this->context = self::CONTEXT_ADMINISTRATION;
123 } else {
124 $this->context = self::CONTEXT_OBJECT;
125 }
126
127
128 $this->obj_type = $a_obj_type;
129 $this->sub_type = $a_sub_type
130 ? $a_sub_type
131 : "-";
132
133 if (
134 $this->obj_id &&
135 !$this->obj_type) {
136 $this->obj_type = ilObject::_lookupType($this->obj_id);
137 }
138
139 $this->permissions = ilAdvancedMDPermissionHelper::getInstance();
140 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
global $DIC
Definition: goto.php:24

References $DIC, $GLOBALS, $lng, $tpl, ilObject\_lookupObjId(), ilObject\_lookupType(), CONTEXT_ADMINISTRATION, CONTEXT_OBJECT, 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 697 of file class.ilAdvancedMDSettingsGUI.php.

698 {
699 if (!isset($_POST['field_id'])) {
700 ilUtil::sendFailure($this->lng->txt('select_one'));
701 $this->editFields();
702 return false;
703 }
704
705 $this->initRecordObject();
706 $this->setRecordSubTabs(2);
707
708 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
709 $c_gui = new ilConfirmationGUI();
710
711 // set confirm/cancel commands
712 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFields"));
713 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_fields_sure"));
714 $c_gui->setCancel($this->lng->txt("cancel"), "editFields");
715 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFields");
716
717 // add items to delete
718 foreach ($_POST["field_id"] as $field_id) {
720 $c_gui->addItem("field_id[]", $field_id, $field->getTitle() ? $field->getTitle() : 'No Title');
721 }
722 $this->tpl->setContent($c_gui->getHTML());
723 }
$_POST["username"]
static getInstance($a_field_id, $a_type=null, string $language='')
Get definition instance by type.
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
Confirmation screen class.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

◆ confirmDeleteFiles()

ilAdvancedMDSettingsGUI::confirmDeleteFiles ( )

confirm delete files

@access public

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

464 {
465 if (!isset($_POST['file_id'])) {
466 ilUtil::sendFailure($this->lng->txt('select_one'));
467 $this->showFiles();
468 return false;
469 }
470
471 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
472 $c_gui = new ilConfirmationGUI();
473
474 // set confirm/cancel commands
475 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
476 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_files_sure"));
477 $c_gui->setCancel($this->lng->txt("cancel"), "showFiles");
478 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
479
480 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
481 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
482 $file_data = $files->readFilesInfo();
483
484
485 // add items to delete
486 foreach ($_POST["file_id"] as $file_id) {
487 $info = $file_data[$file_id];
488 $c_gui->addItem("file_id[]", $file_id, is_array($info['name']) ? implode(',', $info['name']) : 'No Records');
489 }
490 $this->tpl->setContent($c_gui->getHTML());
491 }

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

+ Here is the call graph for this function:

◆ confirmDeleteRecords()

ilAdvancedMDSettingsGUI::confirmDeleteRecords ( )

Confirm delete.

@access public

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

530 {
531 $this->initRecordObject();
532 $this->setRecordSubTabs();
533
534 if (!isset($_POST['record_id'])) {
535 ilUtil::sendFailure($this->lng->txt('select_one'));
536 $this->showRecords();
537 return false;
538 }
539
540 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
541 $c_gui = new ilConfirmationGUI();
542
543 // set confirm/cancel commands
544 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteRecords"));
545 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_record_sure"));
546 $c_gui->setCancel($this->lng->txt("cancel"), "showRecords");
547 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteRecords");
548
549 // add items to delete
550 foreach ($_POST["record_id"] as $record_id) {
552 $c_gui->addItem("record_id[]", $record_id, $record->getTitle() ? $record->getTitle() : 'No Title');
553 }
554 $this->tpl->setContent($c_gui->getHTML());
555 }
static _getInstanceByRecordId($a_record_id)
Get instance by record id.

References $_POST, $record, ilAdvancedMDRecord\_getInstanceByRecordId(), initRecordObject(), ilUtil\sendFailure(), setRecordSubTabs(), 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 1253 of file class.ilAdvancedMDSettingsGUI.php.

1254 {
1255 $this->initRecordObject();
1256 $this->ctrl->saveParameter($this, 'ftype');
1257 $this->setRecordSubTabs(2);
1258
1259 if (!$_REQUEST["record_id"] || !$_REQUEST["ftype"]) {
1260 return $this->editFields();
1261 }
1262
1263
1264 if (!$a_form) {
1265 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1266 $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]);
1267 $field_definition->setRecordId($_REQUEST["record_id"]);
1268 $a_form = $this->initFieldForm($field_definition);
1269 }
1270 $this->tpl->setContent($a_form->getHTML());
1271 }
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form

References editFields(), ilAdvancedMDFieldDefinition\getInstance(), initFieldForm(), initRecordObject(), and setRecordSubTabs().

Referenced by saveField().

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

◆ createRecord()

ilAdvancedMDSettingsGUI::createRecord ( ilPropertyFormGUI  $form = null)

Show.

@access public

Parameters

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

978 {
979 $this->initRecordObject();
980 $this->setRecordSubTabs();
981 if (!$form instanceof ilPropertyFormGUI) {
982 $this->initForm('create');
983 }
984 $this->tpl->setContent($this->form->getHTML());
985 return true;
986 }
This class represents a property form user interface.

References initForm(), initRecordObject(), and setRecordSubTabs().

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 732 of file class.ilAdvancedMDSettingsGUI.php.

733 {
734 $this->ctrl->saveParameter($this, 'record_id');
735
736 if (!isset($_POST['field_id'])) {
737 ilUtil::sendFailure($this->lng->txt('select_one'));
738 $this->editFields();
739 return false;
740 }
741
742 // all fields have to be deletable
743 $fail = array();
744 foreach ($_POST['field_id'] as $field_id) {
745 if (!$this->getPermissions()->hasPermission(
747 $field_id,
749 )) {
751 $fail[] = $field->getTitle();
752 }
753 }
754 if ($fail) {
755 ilUtil::sendFailure($this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
756 $this->ctrl->redirect($this, "editFields");
757 }
758
759 foreach ($_POST["field_id"] as $field_id) {
761 $field->delete();
762 }
763 ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_fields'), true);
764 $this->ctrl->redirect($this, "editFields");
765 }

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

+ Here is the call graph for this function:

◆ deleteFiles()

ilAdvancedMDSettingsGUI::deleteFiles ( )

Delete files.

@access public

Parameters

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

501 {
502 if (!isset($_POST['file_id'])) {
503 ilUtil::sendFailure($this->lng->txt('select_one'));
504 $this->editFiles();
505 return false;
506 }
507
508 if (!$GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
509 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
510 $GLOBALS['DIC']->ctrl()->redirect($this, 'showFiles');
511 }
512
513 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
514 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
515
516 foreach ($_POST['file_id'] as $file_id) {
517 $files->deleteByFileId((int) $file_id);
518 }
519 ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_files'));
520 $this->showFiles();
521 }

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

+ Here is the call graph for this function:

◆ deleteRecords()

ilAdvancedMDSettingsGUI::deleteRecords ( )

Permanently delete records.

@access public

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

564 {
565 if (!isset($_POST['record_id'])) {
566 ilUtil::sendFailure($this->lng->txt('select_one'));
567 $this->showRecords();
568 return false;
569 }
570
571 // all records have to be deletable
572 $fail = array();
573 foreach ($_POST['record_id'] as $record_id) {
574 // must not delete global records in local context
575 if ($this->context == self::CONTEXT_OBJECT) {
577 if (!$record->getParentObject()) {
578 $fail[] = $record->getTitle();
579 }
580 }
581
582 if (!$this->getPermissions()->hasPermission(
584 $record_id,
586 )) {
588 $fail[] = $record->getTitle();
589 }
590 }
591 if ($fail) {
592 ilUtil::sendFailure($this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
593 $this->ctrl->redirect($this, "showRecords");
594 }
595
596 foreach ($_POST['record_id'] as $record_id) {
598 $record->delete();
599 }
600 ilUtil::sendSuccess($this->lng->txt('md_adv_deleted_records'), true);
601 $this->ctrl->redirect($this, "showRecords");
602 }

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

+ Here is the call graph for this function:

◆ downloadFile()

ilAdvancedMDSettingsGUI::downloadFile ( )

Download XML file.

@access public

Parameters

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

443 {
444 if (!isset($_POST['file_id']) or count($_POST['file_id']) != 1) {
445 ilUtil::sendFailure($this->lng->txt('md_adv_select_one_file'));
446 $this->showFiles();
447 return false;
448 }
449
450 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
451 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
452 $abs_path = $files->getAbsolutePathByFileId((int) $_POST['file_id'][0]);
453
454 ilUtil::deliverFile($abs_path, 'ilias_meta_data_record.xml', 'application/xml');
455 }
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:

◆ editComplexOption()

ilAdvancedMDSettingsGUI::editComplexOption ( ilPropertyFormGUI  $a_form = null)

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

2031 {
2032 $field_definition = ilAdvancedMDFieldDefinition::getInstance((int) $_REQUEST['field_id']);
2033 if (!$field_definition->hasComplexOptions()) {
2034 $this->ctrl->redirect($this, "editField");
2035 }
2036
2037 if (!$a_form) {
2038 $a_form = $this->initComplexOptionForm($field_definition);
2039 }
2040
2041 $this->tpl->setContent($a_form->getHTML());
2042 }
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)

References ilAdvancedMDFieldDefinition\getInstance(), and initComplexOptionForm().

+ Here is the call graph for this function:

◆ editField()

ilAdvancedMDSettingsGUI::editField ( ilPropertyFormGUI  $a_form = null)

Edit field.

@access public

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

1173 {
1174 $record_id = (int) ($this->request->getQueryParams()['record_id'] ?? 0);
1175 $field_id = (int) ($this->request->getQueryParams()['field_id'] ?? 0);
1176 if (!$record_id || !$field_id) {
1177 return $this->editFields();
1178 }
1179 $this->ctrl->saveParameter($this, 'field_id');
1180 $this->ctrl->saveParameter($this, 'record_id');
1181 $this->initRecordObject();
1182 $this->setRecordSubTabs(2);
1183
1184 $field_definition = ilAdvancedMDFieldDefinition::getInstance((int) $field_id);
1185
1186 if (!$a_form instanceof ilPropertyFormGUI) {
1187 $this->initLanguage($this->record->getRecordId());
1188 $this->showLanguageSwitch($this->record->getRecordId(), 'editField');
1189 $a_form = $this->initFieldForm($field_definition);
1190 }
1191 $table = null;
1192 if ($field_definition->hasComplexOptions()) {
1193 $table = $field_definition->getComplexOptionsOverview($this, "editField");
1194 }
1195 $this->tpl->setContent($a_form->getHTML() . $table);
1196 }
showLanguageSwitch(int $record_id, string $target)

References editFields(), ilAdvancedMDFieldDefinition\getInstance(), initFieldForm(), initLanguage(), initRecordObject(), setRecordSubTabs(), and showLanguageSwitch().

Referenced by updateField().

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

◆ editFields()

ilAdvancedMDSettingsGUI::editFields ( )
protected

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

793 {
794 global $DIC;
795
796 $record_id = $this->request->getQueryParams()['record_id'] ?? 0;
797
798 $this->ctrl->saveParameter($this, 'record_id');
799 $this->initRecordObject();
800 $this->setRecordSubTabs();
801 $this->initLanguage($record_id);
802 $this->showLanguageSwitch($record_id, 'editFields');
803
804
805 $perm = $this->getPermissions()->hasPermissions(
807 $this->record->getRecordId(),
808 array(
811 )
812 );
813
814 $filter_warn = array();
816 // type selection
817 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
818 $types = new ilSelectInputGUI("", "ftype");
819 $options = array();
822 $options[$type] = $this->lng->txt($field->getTypeTitle());
823
824 if (!$field->isFilterSupported()) {
825 $filter_warn[] = $this->lng->txt($field->getTypeTitle());
826 }
827 }
828 $types->setOptions($options);
829
830 if (count($this->toolbar->getItems())) {
831 $this->toolbar->addSeparator();
832 }
833 $this->toolbar->addInputItem($types);
834
835 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, "createField"));
836
837 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
838 $button = ilSubmitButton::getInstance();
839 $button->setCaption("add");
840 $button->setCommand("createField");
841 $this->toolbar->addButtonInstance($button);
842 }
843
844 // #17092
845 if (sizeof($filter_warn)) {
846 ilUtil::sendInfo(sprintf($this->lng->txt("md_adv_field_filter_warning"), implode(", ", $filter_warn)));
847 }
848
849 // show field table
850 include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
851 $fields = ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->record->getRecordId(), false, $this->active_language);
852
853 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
854 $table_gui = new ilAdvancedMDFieldTableGUI(
855 $this,
856 'editFields',
857 $this->getPermissions(),
859 $this->active_language
860 );
861 $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
862 $table_gui->parseDefinitions($fields);
863 if (sizeof($fields)) {
864 $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
865 }
866 $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
867 $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
868 $table_gui->setSelectAllCheckbox("field_id");
869
870 $this->tpl->setContent($table_gui->getHTML());
871 }
static getInstancesByRecordId($a_record_id, $a_only_searchable=false, string $language='')
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.
$type

References $DIC, $type, ilAdvancedMDPermissionHelper\ACTION_RECORD_CREATE_FIELD, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDFieldDefinition\getInstance(), ilSubmitButton\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), ilAdvancedMDFieldDefinition\getValidTypes(), initLanguage(), initRecordObject(), ilUtil\sendInfo(), setRecordSubTabs(), and showLanguageSwitch().

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 ( ilPropertyFormGUI  $form = null)

Edit one record.

@access public

Parameters

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

775 {
776 $record_id = $this->request->getQueryParams()['record_id'] ?? 0;
777 if (!$record_id) {
778 $this->ctrl->redirect($this, 'showRecords');
779 }
780 $this->initRecordObject();
781 $this->setRecordSubTabs(1, true);
782 $this->tabs_gui->activateTab(self::TAB_RECORD_SETTINGS);
783
784 if (!$form instanceof ilPropertyFormGUI) {
785 $this->initLanguage($record_id);
786 $this->showLanguageSwitch($record_id, 'editRecord');
787 $this->initForm('edit');
788 }
789 $this->tpl->setContent($this->form->getHTML());
790 }

References initForm(), initLanguage(), initRecordObject(), setRecordSubTabs(), and showLanguageSwitch().

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 157 of file class.ilAdvancedMDSettingsGUI.php.

158 {
159 $next_class = $this->ctrl->getNextClass($this);
160 $cmd = $this->ctrl->getCmd();
161 switch ($next_class) {
162
163 case strtolower(ilAdvancedMDRecordTranslationGUI::class):
164 $record = $this->initRecordObject();
165 $this->setRecordSubTabs(1, true);
166 $int_gui = new \ilAdvancedMDRecordTranslationGUI($record);
167 $this->ctrl->forwardCommand($int_gui);
168 break;
169
170 case "ilpropertyformgui":
171 $this->initRecordObject();
172 $this->initForm(
173 $this->record->getRecordId() > 0 ? 'edit' : 'create'
174 );
175 $GLOBALS['DIC']->ctrl()->forwardCommand($this->form);
176 break;
177
178 default:
179 if (!$cmd) {
180 $cmd = 'showRecords';
181 }
182 $this->$cmd();
183 }
184 }

References $GLOBALS, $record, initForm(), initRecordObject(), and setRecordSubTabs().

+ Here is the call graph for this function:

◆ exportRecords()

ilAdvancedMDSettingsGUI::exportRecords ( )

Export records.

@access public

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

373 {
374 if (!isset($_POST['record_id'])) {
375 ilUtil::sendFailure($this->lng->txt('select_one'));
376 $this->showRecords();
377 return false;
378 }
379
380 // all records have to be exportable
381 $fail = array();
382 foreach ($_POST['record_id'] as $record_id) {
383 if (!$this->getPermissions()->hasPermission(
385 $record_id,
387 )) {
389 $fail[] = $record->getTitle();
390 }
391 }
392 if ($fail) {
393 ilUtil::sendFailure($this->lng->txt('msg_no_perm_copy') . " " . implode(", ", $fail), true);
394 $this->ctrl->redirect($this, "showRecords");
395 }
396
397 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
398 $xml_writer = new ilAdvancedMDRecordXMLWriter($_POST['record_id']);
399 $xml_writer->write();
400
401 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
402 $export_files = new ilAdvancedMDRecordExportFiles($this->obj_id);
403 $export_files->create($xml_writer->xmlDumpMem());
404
405 ilUtil::sendSuccess($this->lng->txt('md_adv_records_exported'));
406 $this->showFiles();
407 }

References $_POST, $record, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EXPORT, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getPermissions(), ilUtil\sendFailure(), 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 1931 of file class.ilAdvancedMDSettingsGUI.php.

1932 {
1933 $res = array();
1934
1935 if ($this->context == self::CONTEXT_OBJECT) {
1936 $selected = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $this->sub_type);
1937 }
1938
1940 $orderings = new ilAdvancedMDRecordObjectOrderings();
1941 $records = $orderings->sortRecords($records, $this->obj_id);
1942
1943 $position = 0;
1944 foreach ($records as $record) {
1945 $parent_id = $record->getParentObject();
1946
1947 if ($this->context == self::CONTEXT_ADMINISTRATION) {
1948 if ($parent_id) {
1949 continue;
1950 }
1951 } else {
1952 // does not match current object
1953 if ($parent_id && $parent_id != $this->obj_id) {
1954 continue;
1955 }
1956
1957 // inactive records only in administration
1958 if (!$parent_id && !$record->isActive()) {
1959 continue;
1960 }
1961 // scope needs to match in object context
1962 if (
1964 $this->ref_id,
1965 $record->getScopes()
1966 )
1967 ) {
1968 continue;
1969 }
1970 }
1971
1972 $tmp_arr = array();
1973 $tmp_arr['id'] = $record->getRecordId();
1974 $tmp_arr['active'] = $record->isActive();
1975 $tmp_arr['title'] = $record->getTitle();
1976 $tmp_arr['description'] = $record->getDescription();
1977 $tmp_arr['fields'] = array();
1978 $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
1979 $position += 10;
1980 $tmp_arr['position'] = $position;
1981
1982 $tmp_arr['perm'] = $this->permissions->hasPermissions(
1984 $record->getRecordId(),
1985 array(
1991 )
1992 );
1993
1994 if ($this->obj_type) {
1995 $tmp_arr["readonly"] = !(bool) $parent_id;
1996 $tmp_arr["local"] = $parent_id;
1997
1998 // local records are never optional
1999 $assigned = $optional = false;
2000 foreach ($tmp_arr['obj_types'] as $idx => $item) {
2001 if ($item["obj_type"] == $this->obj_type &&
2002 $item["sub_type"] == $this->sub_type) {
2003 $assigned = true;
2004 $optional = $item["optional"];
2005 $tmp_arr['obj_types'][$idx]['context'] = true;
2006 break;
2007 }
2008 }
2009 if (!$assigned) {
2010 continue;
2011 }
2012 $tmp_arr['optional'] = $optional;
2013 if ($optional) {
2014 // in object context "active" means selected record
2015 $tmp_arr['active'] = in_array($record->getRecordId(), $selected);
2016 }
2017 }
2018
2019 $res[] = $tmp_arr;
2020 }
2021
2022 return $res;
2023 }
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
static _getRecords()
Get records.
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
foreach($_POST as $key=> $value) $res

References $record, $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(), ilAdvancedMDRecord\isFilteredByScope(), 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 1526 of file class.ilAdvancedMDSettingsGUI.php.

1527 {
1528 if ($a_obj_type == "crs") {
1529 $perm = $this->getPermissions()->hasPermissions(
1531 $a_field_id,
1532 array(
1538 )
1539 );
1540 return array(
1544 );
1545 } elseif ($a_obj_type == "cat") {
1546 $perm = $this->getPermissions()->hasPermissions(
1548 $a_field_id,
1549 array(
1555 )
1556 );
1557 return array(
1561 );
1562 } elseif ($a_obj_type == "sess") {
1563 $perm = $this->getPermissions()->hasPermissions(
1565 $a_field_id,
1566 array(
1572 )
1573 );
1574 return array(
1578 );
1579 } elseif ($a_obj_type == "grp") {
1580 $perm = $this->getPermissions()->hasPermissions(
1582 $a_field_id,
1583 array(
1589 )
1590 );
1591 return array(
1595 );
1596 } elseif ($a_obj_type == "iass") {
1597 $perm = $this->getPermissions()->hasPermissions(
1599 $a_field_id,
1600 array(
1606 )
1607 );
1608 return array(
1612 );
1613 } elseif ($a_obj_type == "exc") {
1614 $perm = $this->getPermissions()->hasPermissions(
1616 $a_field_id,
1617 array(
1623 )
1624 );
1625 return array(
1629 );
1630 }
1631 }

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\ACTION_SUBSTITUTION_EXERCISE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_EXERCISE_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_GROUP_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_GROUP_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_IASS_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_IASS_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SESSION_SHOW_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_CATEGORY, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_COURSE, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_EXERCISE, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_GROUP, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_IASS, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_SESSION, 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 1080 of file class.ilAdvancedMDSettingsGUI.php.

1081 {
1082 $this->initImportForm();
1083 if (!$this->import_form->checkInput()) {
1084 $this->import_form->setValuesByPost();
1085 $this->importRecords();
1086 return false;
1087 }
1088
1089 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
1090 $import_files = new ilAdvancedMDRecordImportFiles();
1091 if (!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name'])) {
1092 $this->createRecord();
1093 return false;
1094 }
1095
1096 try {
1097 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
1098 $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
1099
1100 // local import?
1101 if ($this->context == self::CONTEXT_OBJECT) {
1102 $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
1103 }
1104
1105 // Validate
1107 $parser->startParsing();
1108
1109 // Insert
1110 $parser->setMode(ilAdvancedMDRecordParser::MODE_INSERT);
1111 $parser->startParsing();
1112 ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'), true);
1113 $this->ctrl->redirect($this, "showRecords");
1114 } catch (ilSAXParserException $exc) {
1115 ilUtil::sendFailure($exc->getMessage(), true);
1116 $this->ctrl->redirect($this, "importRecords");
1117 }
1118
1119 // Finally delete import file
1120 $import_files->deleteFileByCreationDate($create_time);
1121 return true;
1122 }
SAX based XML parser for record import files.
createRecord(ilPropertyFormGUI $form=null)
Show.

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

+ Here is the call graph for this function:

◆ importRecords()

ilAdvancedMDSettingsGUI::importRecords ( )
protected

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

989 {
990 $this->initRecordObject();
991 $this->setRecordSubtabs();
992
993 // Import Table
994 $this->initImportForm();
995 $this->tpl->setContent($this->import_form->getHTML());
996 }

References initImportForm(), and initRecordObject().

Referenced by importRecord().

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

◆ initComplexOptionForm()

ilAdvancedMDSettingsGUI::initComplexOptionForm ( ilAdvancedMDFieldDefinition  $a_def)
protected

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

2045 {
2046 $this->ctrl->saveParameter($this, "record_id");
2047 $this->ctrl->saveParameter($this, "field_id");
2048 $this->ctrl->saveParameter($this, "oid");
2049
2050 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2051 $form = new ilPropertyFormGUI();
2052 $form->setTitle($this->lng->txt("md_adv_edit_complex_option"));
2053 $form->setFormAction($this->ctrl->getFormAction($this, "updateComplexOption"));
2054
2055 $a_def->initOptionForm($form, $_REQUEST["oid"]);
2056
2057 $form->addCommandButton("updateComplexOption", $this->lng->txt("save"));
2058 $form->addCommandButton("editField", $this->lng->txt("cancel"));
2059
2060 return $form;
2061 }

Referenced by editComplexOption(), and updateComplexOption().

+ Here is the caller graph for this function:

◆ initFieldForm()

ilAdvancedMDSettingsGUI::initFieldForm ( ilAdvancedMDFieldDefinition  $a_definition)
protected

init field form

@access protected

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

1318 {
1319 $is_creation_mode = $a_definition->getFieldId() ? false : true;
1320
1321 $form = new ilPropertyFormGUI();
1322 $form->setFormAction($this->ctrl->getFormAction($this));
1323
1324 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1325 if ($is_creation_mode) {
1326 $form->setDescription($a_definition->getDescription());
1327 } else {
1328 $form->setDescription($translations->getFormTranslationInfo(
1329 $a_definition->getFieldId(),
1330 $this->active_language
1331 ));
1332 }
1333 $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1334 $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1335 $form->addItem($type);
1336 $a_definition->addToFieldDefinitionForm($form, $this->getPermissions(), $this->active_language);
1337
1338 if ($is_creation_mode) {
1339 $form->setTitle($this->lng->txt('md_adv_create_field'));
1340 $form->addCommandButton('saveField', $this->lng->txt('create'));
1341 } else {
1342 $form->setTitle($this->lng->txt('md_adv_edit_field'));
1343 $form->addCommandButton('updateField', $this->lng->txt('save'));
1344 }
1345
1346 $form->addCommandButton('editFields', $this->lng->txt('cancel'));
1347
1348 return $form;
1349 }
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
Add input elements to definition form.
This class represents a non editable value in a property form.

References $type, ilAdvancedMDFieldDefinition\addToFieldDefinitionForm(), ilAdvancedMDFieldDefinition\getDescription(), ilAdvancedMDFieldDefinition\getFieldId(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), 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 1356 of file class.ilAdvancedMDSettingsGUI.php.

1357 {
1358 if (is_object($this->form)) {
1359 return true;
1360 }
1361
1362 $perm = $this->getPermissions()->hasPermissions(
1364 $this->record->getRecordId(),
1365 array(
1373 )
1374 );
1375
1376 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1377
1378 $this->form = new ilPropertyFormGUI();
1379
1380 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1381 $this->form->setDescription($translations->getFormTranslationInfo($this->active_language));
1382 $this->form->setFormAction($this->ctrl->getFormAction($this));
1383
1384
1385 // title
1386 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
1387 $title->setValue($this->record->getTitle());
1388 $title->setSize(20);
1389 $title->setMaxLength(70);
1390 $title->setRequired(true);
1391
1393 $title->setDisabled(true);
1394 }
1395 $this->form->addItem($title);
1396 $translations->modifyTranslationInfoForTitle($this->form, $title, $this->active_language);
1397
1398
1399 // desc
1400 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
1401 $desc->setValue($this->record->getDescription());
1402 $desc->setRows(3);
1403
1405 $desc->setDisabled(true);
1406 }
1407 $this->form->addItem($desc);
1408 $translations->modifyTranslationInfoForDescription($this->form, $desc, $this->active_language);
1409
1410 // active
1411 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'), 'active');
1412 $check->setChecked($this->record->isActive());
1413 $check->setValue(1);
1414 $this->form->addItem($check);
1415
1417 $check->setDisabled(true);
1418 }
1419
1420 if (!$this->obj_type) {
1421 // scope
1422 $scope = new ilCheckboxInputGUI($this->lng->txt('md_adv_scope'), 'scope');
1423 $scope->setInfo($this->lng->txt('md_adv_scope_info'));
1424 $scope->setChecked($this->record->enabledScope());
1425 $scope->setValue(1);
1426 $this->form->addItem($scope);
1427
1428 $subitems = new ilRepositorySelector2InputGUI(
1429 $this->lng->txt('md_adv_scope_objects'),
1430 "scope_containers",
1431 true
1432 );
1433 $subitems->setValue($this->record->getScopeRefIds());
1434 $exp = $subitems->getExplorerGUI();
1435
1436 $definition = $GLOBALS['DIC']['objDefinition'];
1437 $white_list = [];
1438 foreach ($definition->getAllRepositoryTypes() as $type) {
1439 if ($definition->isContainer($type)) {
1440 $white_list[] = $type;
1441 }
1442 }
1443
1444
1445 $exp->setTypeWhiteList($white_list);
1446 $exp->setSkipRootNode(false);
1447 $exp->setRootId(ROOT_FOLDER_ID);
1448 $scope->addSubItem($subitems);
1449 }
1450
1451 if (!$this->obj_type) {
1453 $section->setTitle($this->lng->txt('md_obj_types'));
1454 $this->form->addItem($section);
1455
1456 // see ilAdvancedMDRecordTableGUI::fillRow()
1457 $options = array(
1458 0 => $this->lng->txt("meta_obj_type_inactive"),
1459 1 => $this->lng->txt("meta_obj_type_mandatory"),
1460 2 => $this->lng->txt("meta_obj_type_optional")
1461 );
1462
1463
1465 $t = $type["obj_type"] . ":" . $type["sub_type"];
1466 $this->lng->loadLanguageModule($type["obj_type"]);
1467
1468 $type_options = $options;
1469 switch ($type["obj_type"]) {
1470 case "orgu":
1471 // currently only optional records for org unit (types)
1472 unset($type_options[1]);
1473 break;
1474 case "prg":
1475 // currently only optional records for study programme (types)
1476 unset($type_options[1]);
1477 break;
1478 case "rcrs":
1479 // optional makes no sense for ecs-courses
1480 unset($type_options[2]);
1481 break;
1482 }
1483
1484 $value = 0;
1485 if ($a_mode == "edit") {
1486 foreach ($this->record->getAssignedObjectTypes() as $item) {
1487 if ($item["obj_type"] == $type["obj_type"] &&
1488 $item["sub_type"] == $type["sub_type"]) {
1489 $value = $item["optional"]
1490 ? 2
1491 : 1;
1492 }
1493 }
1494 }
1495
1496 $sel_name = 'obj_types__' . $t;
1497 $check = new ilSelectInputGUI($type['text'], $sel_name);
1498 //$check = new ilSelectInputGUI($type["text"], 'obj_types[' . $t . ']');
1499 $check->setOptions($type_options);
1500 $check->setValue($value);
1501 $this->form->addItem($check);
1502
1504 $check->setDisabled(true);
1505 }
1506 }
1507 }
1508
1509 switch ($a_mode) {
1510 case 'create':
1511 $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1512 $this->form->addCommandButton('saveRecord', $this->lng->txt('add'));
1513 $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1514
1515 return true;
1516
1517 case 'edit':
1518 $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1519 $this->form->addCommandButton('updateRecord', $this->lng->txt('save'));
1520 $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1521
1522 return true;
1523 }
1524 }
$section
Definition: Utf8Test.php:83
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.
const ROOT_FOLDER_ID
Definition: constants.php:30

References $GLOBALS, $section, $type, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDRecordTranslations\getInstanceByRecordId(), getPermissions(), ROOT_FOLDER_ID, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

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

+ 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 1638 of file class.ilAdvancedMDSettingsGUI.php.

1639 {
1640 global $DIC;
1641
1642 $ilAccess = $DIC['ilAccess'];
1643
1644 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1645
1646 if (!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType()) {
1647 return;
1648 }
1649
1650 $this->form = new ilPropertyFormGUI();
1651 $this->form->setFormAction($this->ctrl->getFormAction($this));
1652 #$this->form->setTableWidth('100%');
1653
1654 // substitution
1655 foreach ($visible_records as $obj_type => $records) {
1656 $perm = null;
1657
1658 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
1659 $perm = $this->getPermissions()->hasPermissions(
1661 $obj_type,
1662 array(
1666 )
1667 );
1668 }
1669
1671
1672 // Show section
1674 $section->setTitle($this->lng->txt('objs_' . $obj_type));
1675 $this->form->addItem($section);
1676
1677 $check = new ilCheckboxInputGUI($this->lng->txt('description'), 'enabled_desc_' . $obj_type);
1678 $check->setValue(1);
1679 $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1680 $check->setChecked($sub->isDescriptionEnabled() ? true : false);
1681 $this->form->addItem($check);
1682
1684 $check->setDisabled(true);
1685 }
1686
1687 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'), 'enabled_field_names_' . $obj_type);
1688 $check->setValue(1);
1689 $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1690 $check->setChecked($sub->enabledFieldNames() ? true : false);
1691 $this->form->addItem($check);
1692
1694 $check->setDisabled(true);
1695 }
1696
1697 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
1698 #$area->setUseRte(true);
1699 #$area->setRteTagSet('standard');
1700 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
1701 #$area->setRows(5);
1702 #$area->setCols(80);
1703 #$this->form->addItem($area);
1704
1705 if ($perm) {
1707 }
1708
1710 $definitions = $sub->sortDefinitions($definitions);
1711
1712 $counter = 1;
1713 foreach ($definitions as $def) {
1714 $definition_id = $def->getFieldId();
1715
1716 $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id);
1717
1718 $title = ilAdvancedMDRecord::_lookupTitle($def->getRecordId());
1719 $title = $def->getTitle() . ' (' . $title . ')';
1720
1721 $check = new ilCheckboxInputGUI($title, 'show[' . $obj_type . '][' . $definition_id . ']');
1722 $check->setValue(1);
1723 $check->setOptionTitle($this->lng->txt('md_adv_show'));
1724 $check->setChecked($sub->isSubstituted($definition_id));
1725
1726 if ($perm && !$perm["show"]) {
1727 $check->setDisabled(true);
1728 }
1729
1730 $pos = new ilNumberInputGUI($this->lng->txt('position'), 'position[' . $obj_type . '][' . $definition_id . ']');
1731 $pos->setSize(3);
1732 $pos->setMaxLength(4);
1733 $pos->allowDecimals(true);
1734 $pos->setValue(sprintf('%.1f', $counter++));
1735 $check->addSubItem($pos);
1736
1737 if ($perm && !$perm_pos) {
1738 $pos->setDisabled(true);
1739 }
1740
1741 $bold = new ilCheckboxInputGUI($this->lng->txt('bold'), 'bold[' . $obj_type . '][' . $definition_id . ']');
1742 $bold->setValue(1);
1743 $bold->setChecked($sub->isBold($definition_id));
1744 $check->addSubItem($bold);
1745
1746 if ($perm && !$perm["bold"]) {
1747 $bold->setDisabled(true);
1748 }
1749
1750 $bold = new ilCheckboxInputGUI($this->lng->txt('newline'), 'newline[' . $obj_type . '][' . $definition_id . ']');
1751 $bold->setValue(1);
1752 $bold->setChecked($sub->hasNewline($definition_id));
1753 $check->addSubItem($bold);
1754
1755 if ($perm && !$perm["newline"]) {
1756 $bold->setDisabled(true);
1757 }
1758
1759
1760 $this->form->addItem($check);
1761 }
1762
1763
1764 // placeholder
1765 /*
1766 $custom = new ilCustomInputGUI($this->lng->txt('md_adv_placeholders'));
1767 $tpl = new ilTemplate('tpl.placeholder_info.html',true,true,'Services/AdvancedMetaData');
1768 foreach($records as $record)
1769 {
1770 foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $definition)
1771 {
1772 $tpl->setCurrentBlock('field');
1773 $tpl->setVariable('FIELD_NAME',$definition->getTitle());
1774 $tpl->setVariable('MODULE_VARS','[IF_F_'.$definition->getFieldId().']...[F_'.$definition->getFieldId().']'.
1775 '[/IF_F_'.$definition->getFieldId().']');
1776 $tpl->parseCurrentBlock();
1777 }
1778
1779 $tpl->setCurrentBlock('record');
1780 $tpl->setVariable('PLACEHOLDER_FOR',$this->lng->txt('md_adv_placeholder_for'));
1781 $tpl->setVariable('TITLE',$record->getTitle());
1782 $tpl->parseCurrentBlock();
1783 }
1784 $custom->setHTML($tpl->get());
1785 $this->form->addItem($custom);
1786 */
1787 }
1788 $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1789
1790 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
1791 $this->form->addCommandButton('updateSubstitutions', $this->lng->txt('save'));
1792 }
1793
1794 return true;
1795 }
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.

References $DIC, $obj_type, $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 1051 of file class.ilAdvancedMDSettingsGUI.php.

1052 {
1053 if (is_object($this->import_form)) {
1054 return true;
1055 }
1056
1057 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1058 $this->import_form = new ilPropertyFormGUI();
1059 $this->import_form->setMultipart(true);
1060 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
1061
1062 // add file property
1063 $file = new ilFileInputGUI($this->lng->txt('file'), 'file');
1064 $file->setSuffixes(array('xml'));
1065 $file->setRequired(true);
1066 $this->import_form->addItem($file);
1067
1068 $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
1069 $this->import_form->addCommandButton('importRecord', $this->lng->txt('import'));
1070 $this->import_form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1071 }
This class represents a file property in a property form.

Referenced by importRecord(), and importRecords().

+ Here is the caller graph for this function:

◆ initLanguage()

ilAdvancedMDSettingsGUI::initLanguage ( int  $record_id)
protected
Parameters
int$record_id

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

2082 {
2084 // read active language
2085 $default = '';
2086 foreach ($translations->getTranslations() as $translation) {
2087 if ($translation->getLangKey() == $translations->getDefaultLanguage()) {
2088 $default = $translation->getLangKey();
2089 }
2090 }
2091 $active = $this->request->getQueryParams()['mdlang'] ?? $default;
2092 $this->active_language = $active;
2093 }

References ilAdvancedMDRecordTranslations\getInstanceByRecordId().

Referenced by editField(), editFields(), editRecord(), saveField(), updateField(), and updateRecord().

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

◆ initRecordObject()

ilAdvancedMDSettingsGUI::initRecordObject ( )
protected

Init record object.

@access protected

Returns
ilAdvancedMDRecord

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

1874 {
1875 if (!$this->record instanceof ilAdvancedMDRecord) {
1876 $record_id = $this->request->getQueryParams()['record_id'] ?? 0;
1877 $this->record = ilAdvancedMDRecord::_getInstanceByRecordId($record_id);
1878 $this->ctrl->saveParameter($this, 'record_id');
1879
1880 // bind to parent object (aka local adv md)
1881 if (!$record_id &&
1882 $this->obj_id) {
1883 $this->record->setParentObject($this->obj_id);
1884 }
1885 }
1886 return $this->record;
1887 }

References $record, and ilAdvancedMDRecord\_getInstanceByRecordId().

Referenced by confirmDeleteFields(), confirmDeleteRecords(), createField(), createRecord(), editField(), editFields(), editRecord(), executeCommand(), importRecords(), saveField(), saveRecord(), updateField(), and updateRecord().

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

◆ loadRecordFormData()

ilAdvancedMDSettingsGUI::loadRecordFormData ( )
protected
Returns
ilAdvancedMDRecord

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

1801 {
1802 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1803
1804 $perm = $this->getPermissions()->hasPermissions(
1806 $this->record->getRecordId(),
1807 array(
1815 )
1816 );
1817
1819 $this->record->setActive(ilUtil::stripSlashes($_POST['active']));
1820 }
1822 if (
1823 $translations->getDefaultTranslation() == null ||
1824 $translations->getDefaultTranslation()->getLangKey() == $this->active_language
1825 ) {
1826 $this->record->setTitle(ilUtil::stripSlashes($_POST['title']));
1827 }
1828 }
1830 if (
1831 $translations->getDefaultTranslation() == null ||
1832 $translations->getDefaultTranslation()->getLangKey() == $this->active_language) {
1833 $this->record->setDescription(ilUtil::stripSlashes($_POST['desc']));
1834 }
1835 }
1836
1837 if (!$this->obj_type) {
1839 $obj_types = [];
1841 $t = $type["obj_type"] . ":" . $type["sub_type"];
1842 $value = $this->form->getInput('obj_types__' . $t);
1843 if (!$value) {
1844 continue;
1845 }
1846 $obj_types[] = [
1847 'obj_type' => $type['obj_type'],
1848 'sub_type' => $type['sub_type'],
1849 'optional' => ($value > 1)
1850 ];
1851 }
1852 $this->record->setAssignedObjectTypes($obj_types);
1853 }
1854 }
1855
1856 $scopes = [];
1857 foreach ((array) $_POST['scope_containers_sel'] as $ref_id) {
1858 $scope = new ilAdvancedMDRecordScope();
1859 $scope->setRefId($ref_id);
1860 $scopes[] = $scope;
1861 }
1862 $this->record->setScopes($_POST['scope'] ? $scopes : []);
1863 $this->record->enableScope($_POST['scope'] ? true : false);
1864 return $this->record;
1865 }
Scope restrictions for advanced md records.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, $record, $ref_id, $type, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDRecordTranslations\getInstanceByRecordId(), 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 1278 of file class.ilAdvancedMDSettingsGUI.php.

1279 {
1280 $record_id = $this->request->getQueryParams()['record_id'];
1281 $ftype = $this->request->getQueryParams()['ftype'];
1282
1283 if (!$record_id || !$ftype) {
1284 return $this->editFields();
1285 }
1286
1287 $this->initRecordObject();
1288 $this->initLanguage($record_id);
1289 $this->ctrl->saveParameter($this, 'ftype');
1290
1291 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1292 $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $ftype);
1293 $field_definition->setRecordId($record_id);
1294 $form = $this->initFieldForm($field_definition);
1295
1296 if ($form->checkInput()) {
1297 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1298 $field_definition->save();
1299
1300 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($record_id);
1301 $translations->read();
1302 $translations->updateFromForm($field_definition->getFieldId(), $this->active_language, $form);
1303
1304 ilUtil::sendSuccess($this->lng->txt('save_settings'), true);
1305 $this->ctrl->redirect($this, "editFields");
1306 }
1307
1308 $form->setValuesByPost();
1309 $this->createField($form);
1310 }
createField(ilPropertyFormGUI $a_form=null)
Show field type selection.

References createField(), editFields(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getPermissions(), initFieldForm(), initLanguage(), and initRecordObject().

+ Here is the call graph for this function:

◆ saveRecord()

ilAdvancedMDSettingsGUI::saveRecord ( )

Save record.

@access public

Parameters

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

1133 {
1134 $this->initRecordObject();
1135 $this->initForm('create');
1136 if (!$this->form->checkInput()) {
1137 ilUtil::sendFailure($this->lng->txt('err_check_input'));
1138 $this->createRecord($this->form);
1139 return false;
1140 }
1141
1142 $record = $this->loadRecordFormData();
1143 if ($this->obj_type) {
1144 $this->record->setAssignedObjectTypes(array(
1145 array(
1146 "obj_type" => $this->obj_type,
1147 "sub_type" => $this->sub_type,
1148 "optional" => false
1149 )));
1150 }
1151
1152 $record->setDefaultLanguage($this->lng->getDefaultLanguage());
1153 $record->save();
1154
1155 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($record->getRecordId());
1156 $translations->addTranslationEntry($record->getDefaultLanguage(), true);
1157 $translations->updateTranslations(
1158 $record->getDefaultLanguage(),
1159 $this->form->getInput('title'),
1160 $this->form->getInput('desc')
1161 );
1162 ilUtil::sendSuccess($this->lng->txt('md_adv_added_new_record'), true);
1163 $this->ctrl->redirect($this, 'showRecords');
1164 }

References $record, createRecord(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), initForm(), initRecordObject(), loadRecordFormData(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ setRecordSubTabs()

ilAdvancedMDSettingsGUI::setRecordSubTabs ( int  $level = 1,
bool  $show_settings = false 
)
protected

Set subtabs for record editing/creation.

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

1002 {
1003 $this->tabs_gui->clearTargets();
1004 $this->tabs_gui->clearSubTabs();
1005
1006 if ($level == 1) {
1007 $this->tabs_gui->setBackTarget(
1008 $this->lng->txt('md_adv_record_list'),
1009 $this->ctrl->getLinkTarget($this, 'showRecords')
1010 );
1011
1012 if ($show_settings) {
1013 $this->tabs_gui->addTab(
1014 self::TAB_RECORD_SETTINGS,
1015 $this->lng->txt('settings'),
1016 $this->ctrl->getLinkTarget($this, self::TAB_RECORD_SETTINGS)
1017 );
1018 $this->ctrl->setParameterByClass(
1019 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1020 'record_id',
1021 $this->record->getRecordId()
1022 );
1023 $this->lng->loadLanguageModule('obj');
1024 $this->tabs_gui->addTab(
1025 self::TAB_TRANSLATION,
1026 $this->lng->txt('obj_multilinguality'),
1027 $this->ctrl->getLinkTargetByClass(
1028 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1029 ''
1030 )
1031 );
1032 }
1033 }
1034 if ($level == 2) {
1035 $this->tabs_gui->setBack2Target(
1036 $this->lng->txt('md_adv_record_list'),
1037 $this->ctrl->getLinkTarget($this, 'showRecords')
1038 );
1039 $this->tabs_gui->setBackTarget(
1040 $this->lng->txt('md_adv_field_list'),
1041 $this->ctrl->getLinkTarget($this, 'editFields')
1042 );
1043 }
1044 }

Referenced by confirmDeleteFields(), confirmDeleteRecords(), createField(), createRecord(), editField(), editFields(), editRecord(), and executeCommand().

+ Here is the caller graph for this function:

◆ setSubTabs()

ilAdvancedMDSettingsGUI::setSubTabs ( int  $context)
protected

Set sub tabs.

@access protected

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

1895 {
1896 if ($context == self::CONTEXT_OBJECT) {
1897 return;
1898 }
1899
1900 $this->tabs_gui->clearSubTabs();
1901
1902 $this->tabs_gui->addSubTabTarget(
1903 "md_adv_record_list",
1904 $this->ctrl->getLinkTarget($this, "showRecords"),
1905 '',
1906 '',
1907 '',
1908 true
1909 );
1910
1911
1913 $this->tabs_gui->addSubTabTarget(
1914 "md_adv_presentation",
1915 $this->ctrl->getLinkTarget($this, "showPresentation")
1916 );
1917 }
1918
1919 $this->tabs_gui->addSubTabTarget(
1920 "md_adv_file_list",
1921 $this->ctrl->getLinkTarget($this, "showFiles"),
1922 "showFiles"
1923 );
1924 }

References $context, and ilAdvancedMDRecord\_getAllRecordsByObjectType().

Referenced by showFiles(), showPresentation(), and showRecords().

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

◆ showFiles()

ilAdvancedMDSettingsGUI::showFiles ( )
protected

Show export files.

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

413 {
414 $this->setSubTabs($this->context);
415 $this->tabs_gui->setSubTabActive('md_adv_file_list');
416
417 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
418 $files = new ilAdvancedMDRecordExportFiles($this->obj_id);
419 $file_data = $files->readFilesInfo();
420
421 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
422 $table_gui = new ilAdvancedMDRecordExportFilesTableGUI($this, "showFiles");
423 $table_gui->setTitle($this->lng->txt("md_record_export_table"));
424 $table_gui->parseFiles($file_data);
425 $table_gui->addMultiCommand("downloadFile", $this->lng->txt('download'));
426
427 if ($GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
428 $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
429 }
430 $table_gui->setSelectAllCheckbox("file_id");
431
432 $this->tpl->setContent($table_gui->getHTML());
433 }
setSubTabs(int $context)
Set sub tabs.

References $GLOBALS, and setSubTabs().

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

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

◆ showLanguageSwitch()

ilAdvancedMDSettingsGUI::showLanguageSwitch ( int  $record_id,
string  $target 
)
protected
Parameters
int$record_id

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

2098 : void
2099 {
2101
2102 if (count($translations->getTranslations()) <= 1) {
2103 return;
2104 }
2105 $actions = [];
2106 foreach ($translations->getTranslations() as $translation) {
2107 $this->ctrl->setParameter($this, 'mdlang', $translation->getLangKey());
2108 $actions[$translation->getLangKey()] = $this->ctrl->getLinkTarget(
2109 $this,
2110 $target
2111 );
2112 }
2113 $this->ctrl->setParameter($this, 'mdlang', $this->active_language);
2114 $view_control = $this->ui_factory->viewControl()->mode(
2115 $actions,
2116 $this->lng->txt('meta_aria_language_selection')
2117 )->withActive($this->active_language);
2118 $this->toolbar->addComponent($view_control);
2119 }

References ilAdvancedMDRecordTranslations\getInstanceByRecordId().

Referenced by editField(), editFields(), editRecord(), updateField(), and updateRecord().

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

◆ showPresentation()

ilAdvancedMDSettingsGUI::showPresentation ( )
protected
Returns
bool

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

254 {
255 $this->setSubTabs($this->context);
256 if ($this->initFormSubstitutions()) {
257 if (is_object($this->form)) {
258 $this->tabs_gui->setSubTabActive('md_adv_presentation');
259 return $this->tpl->setContent($this->form->getHTML());
260 }
261 }
262 return $this->showRecords();
263 }
initFormSubstitutions()
init form table 'substitutions'

References initFormSubstitutions(), setSubTabs(), and showRecords().

+ Here is the call graph for this function:

◆ showRecords()

ilAdvancedMDSettingsGUI::showRecords ( )

show record list

@access public

Parameters

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

194 {
195 global $DIC;
196
197 $ilToolbar = $DIC['ilToolbar'];
198 $ilAccess = $DIC['ilAccess'];
199
200 $this->setSubTabs($this->context);
201
202 $perm = $this->getPermissions()->hasPermissions(
204 $_REQUEST["ref_id"],
205 array(
208 )
209 );
210
212 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
213 $button = ilLinkButton::getInstance();
214 $button->setCaption("add");
215 $button->setUrl($this->ctrl->getLinkTarget($this, "createRecord"));
216 $ilToolbar->addButtonInstance($button);
217
219 $ilToolbar->addSeparator();
220 }
221 }
222
224 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
225 $button = ilLinkButton::getInstance();
226 $button->setCaption("import");
227 $button->setUrl($this->ctrl->getLinkTarget($this, "importRecords"));
228 $ilToolbar->addButtonInstance($button);
229 }
230
231 include_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
232 $table_gui = new ilAdvancedMDRecordTableGUI($this, "showRecords", $this->getPermissions(), (bool) $this->obj_id);
233 $table_gui->setTitle($this->lng->txt("md_record_list_table"));
234 $table_gui->setData($this->getParsedRecordObjects());
235
236 // permissions?
237 //$table_gui->addCommandButton('createRecord',$this->lng->txt('add'));
238 $table_gui->addMultiCommand("exportRecords", $this->lng->txt('export'));
239 $table_gui->setSelectAllCheckbox("record_id");
240
241 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
242 $table_gui->addMultiCommand("confirmDeleteRecords", $this->lng->txt("delete"));
243 $table_gui->addCommandButton("updateRecords", $this->lng->txt("save"));
244 }
245
246 $DIC->ui()->mainTemplate()->setContent($table_gui->getHTML());
247 return true;
248 }
getParsedRecordObjects()
Get and cache record objects.
static getInstance()
Factory.

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

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

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

◆ updateComplexOption()

ilAdvancedMDSettingsGUI::updateComplexOption ( )

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

2064 {
2065 $field_definition = ilAdvancedMDFieldDefinition::getInstance((int) $_REQUEST['field_id']);
2066 if ($field_definition->hasComplexOptions()) {
2067 $form = $this->initComplexOptionForm($field_definition);
2068 if ($form->checkInput() &&
2069 $field_definition->updateComplexOption($form, $_REQUEST["oid"])) {
2070 $field_definition->update();
2071 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2072 }
2073 }
2074
2075 $this->ctrl->redirect($this, "editField");
2076 }

References ilAdvancedMDFieldDefinition\getInstance(), and initComplexOptionForm().

+ Here is the call graph for this function:

◆ updateField()

ilAdvancedMDSettingsGUI::updateField ( )

Update field.

@access public

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

1205 {
1206 $record_id = $this->request->getQueryParams()['record_id'] ?? 0;
1207 $field_id = $this->request->getQueryParams()['field_id'] ?? 0;
1208 $this->ctrl->saveParameter($this, 'record_id');
1209 $this->ctrl->saveParameter($this, 'field_id');
1210
1211 if (!$record_id || !$field_id) {
1212 return $this->editFields();
1213 }
1214
1215 $this->initRecordObject();
1216 $this->initLanguage($record_id);
1217 $this->showLanguageSwitch($record_id, 'editField');
1218
1219 $confirm = false;
1220 $field_definition = ilAdvancedMDFieldDefinition::getInstance((int) $field_id);
1221 $form = $this->initFieldForm($field_definition);
1222 if ($form->checkInput()) {
1223 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1224 if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1225 $field_definition->update();
1226 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1227 $translations->updateFromForm($field_id, $this->active_language, $form);
1228
1229 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1230 $this->ctrl->redirect($this, 'editField');
1231 } else {
1232 $confirm = true;
1233 }
1234 }
1235
1236 $form->setValuesByPost();
1237
1238 // fields needs confirmation of updated settings
1239 if ($confirm) {
1240 ilUtil::sendInfo($this->lng->txt("md_adv_confirm_definition"));
1241 $field_definition->prepareDefinitionFormConfirmation($form);
1242 }
1243
1244 $this->editField($form);
1245 }
editField(ilPropertyFormGUI $a_form=null)
Edit field.

References editField(), editFields(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getPermissions(), initFieldForm(), initLanguage(), initRecordObject(), ilUtil\sendInfo(), and showLanguageSwitch().

+ Here is the call graph for this function:

◆ updateFields()

ilAdvancedMDSettingsGUI::updateFields ( )

Update fields.

@access public

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

880 {
881 $this->ctrl->saveParameter($this, 'record_id');
882
883 if (!isset($_GET['record_id']) or !$_GET['record_id']) {
884 ilUtil::sendFailure($this->lng->txt('select_one'));
885 $this->editFields();
886 return false;
887 }
888
889 include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
891
892 if ($this->getPermissions()->hasPermission(
894 $_GET['record_id'],
896 )) {
897 if (!isset($_POST['position']) or !is_array($_POST['position'])) {
898 $this->editFields();
899 return false;
900 }
901 // sort by position
902 asort($_POST['position'], SORT_NUMERIC);
903 $positions = array_flip(array_keys($_POST['position']));
904 foreach ($fields as $field) {
905 $field->setPosition($positions[$field->getFieldId()]);
906 $field->update();
907 }
908 }
909
910 foreach ($fields as $field) {
911 if ($this->getPermissions()->hasPermission(
913 $field->getFieldId(),
916 )) {
917 $field->setSearchable(isset($_POST['searchable'][$field->getFieldId()]) ? true : false);
918 $field->update();
919 }
920 }
921
922 if ($this->request->getQueryParams()['mdlang']) {
923 $this->ctrl->setParameter($this, 'mdlang', $this->request->getQueryParams()['mdlang']);
924 }
925 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
926 $this->ctrl->redirect($this, "editFields");
927 }
$_GET["client_id"]

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(), and ilAdvancedMDPermissionHelper\SUBACTION_FIELD_SEARCHABLE.

+ Here is the call graph for this function:

◆ updateRecord()

ilAdvancedMDSettingsGUI::updateRecord ( )

Update record.

@access public

Parameters

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

937 {
938 $record_id = $this->request->getQueryParams()['record_id'] ?? 0;
939 if (!$record_id) {
940 $this->ctrl->redirect($this, 'showRecords');
941 }
942 $this->initRecordObject();
943 $this->initLanguage($record_id);
944 $this->showLanguageSwitch($record_id, 'editRecord');
945
946 $this->initForm('edit');
947 if (!$this->form->checkInput()) {
948 ilUtil::sendFailure($this->lng->txt('err_check_input'));
949 $this->form->setValuesByPost();
950 $this->editRecord($this->form);
951 return false;
952 }
953
954 $this->loadRecordFormData();
955 $this->record->update();
956
957 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
958 $translations->updateTranslations(
959 $this->active_language,
960 $this->form->getInput('title'),
961 $this->form->getInput('desc')
962 );
963
964 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
965 $this->ctrl->redirect($this, 'editRecord');
966 return true;
967 }
editRecord(ilPropertyFormGUI $form=null)
Edit one record.

References editRecord(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), initForm(), initLanguage(), initRecordObject(), loadRecordFormData(), ilUtil\sendFailure(), and showLanguageSwitch().

+ Here is the call graph for this function:

◆ updateRecords()

ilAdvancedMDSettingsGUI::updateRecords ( )

Save records (assigned object typed)

@access public

Parameters

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

612 {
613 // sort positions and renumber
614 $positions = $_POST['pos'];
615 asort($positions, SORT_NUMERIC);
616
617 $sorted_positions = [];
618 $i = 1;
619 foreach ($positions as $record_id => $pos) {
620 $sorted_positions[$record_id] = $i++;
621 }
622 $selected_global = array();
623 foreach ($this->getParsedRecordObjects() as $item) {
624 $perm = $this->getPermissions()->hasPermissions(
626 $item['id'],
627 array(
631 )
632 );
633
634 if ($this->context == self::CONTEXT_ADMINISTRATION) {
635 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
636
638 $obj_types = array();
639 if (is_array($_POST['obj_types'][$record_obj->getRecordId()])) {
640 foreach ($_POST['obj_types'][$record_obj->getRecordId()] as $type => $status) {
641 if ($status) {
642 $type = explode(":", $type);
643 $obj_types[] = array(
644 "obj_type" => ilUtil::stripSlashes($type[0]),
645 "sub_type" => ilUtil::stripSlashes($type[1]),
646 "optional" => ((int) $status == 2)
647 );
648 }
649 }
650 }
651 $record_obj->setAssignedObjectTypes($obj_types);
652 }
653
655 $record_obj->setActive(isset($_POST['active'][$record_obj->getRecordId()]));
656 }
657
658 $record_obj->setGlobalPosition((int) $sorted_positions[$record_obj->getRecordId()]);
659 $record_obj->update();
661 // global, optional record
662 if ($item['readonly'] &&
663 $item['optional'] &&
664 $_POST['active'][$item['id']]) {
665 $selected_global[] = $item['id'];
666 } elseif ($item['local']) {
667 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
668 $record_obj->setActive(isset($_POST['active'][$item['id']]));
669 $record_obj->update();
670 }
671 }
672
673 // save local sorting
674 if ($this->context == self::CONTEXT_OBJECT) {
675 global $DIC;
676
677 $local_position = new \ilAdvancedMDRecordObjectOrdering($item['id'], $this->obj_id, $DIC->database());
678 $local_position->setPosition((int) $sorted_positions[$item['id']]);
679 $local_position->save();
680 }
681 }
682
683 if ($this->obj_type) {
684 ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $this->sub_type, $selected_global);
685 }
686
687 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
688 $this->ctrl->redirect($this, "showRecords");
689 }
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
$i
Definition: metadata.php:24

References $_POST, $DIC, $i, $type, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, getParsedRecordObjects(), getPermissions(), ilAdvancedMDRecord\saveObjRecSelection(), 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 271 of file class.ilAdvancedMDSettingsGUI.php.

272 {
273 global $DIC;
274
275 $ilAccess = $DIC['ilAccess'];
276
277 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
278 $this->ctrl->redirect($this, "showPresentation");
279 }
280
282 $perm = null;
283
284 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
285 $perm = $this->getPermissions()->hasPermissions(
287 $obj_type,
288 array(
292 )
293 );
294 }
295
296 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
298
300 $sub->enableDescription($_POST['enabled_desc_' . $obj_type]);
301 }
302
304 $sub->enableFieldNames((int) $_POST['enabled_field_names_' . $obj_type]);
305 }
306
308 $definitions = $sub->sortDefinitions($definitions);
309
310 // gather existing data
311 $counter = 1;
312 $old_sub = array();
313 foreach ($definitions as $def) {
314 $field_id = $def->getFieldId();
315 $old_sub[$field_id] = array(
316 "active" => $sub->isSubstituted($field_id),
317 "pos" => $counter++,
318 "bold" => $sub->isBold($field_id),
319 "newline" => $sub->hasNewline($field_id)
320 );
321 }
322
323 $sub->resetSubstitutions(array());
324
325 $new_sub = array();
326 foreach ($definitions as $def) {
327 $field_id = $def->getFieldId();
328 $old = $old_sub[$field_id];
329
330 $perm_def = $this->getSubstitutionFieldPermissions($obj_type, $field_id);
331 if ($perm_def["show"]) {
332 $active = (isset($_POST['show'][$obj_type][$field_id]) && $_POST['show'][$obj_type][$field_id]);
333 } else {
334 $active = $old["active"];
335 }
336
337 if ($active) {
338 $new_sub[$field_id] = $old;
339
341 $new_sub[$field_id]["pos"] = (int) $_POST['position'][$obj_type][$field_id];
342 }
343 if ($perm_def["bold"]) {
344 $new_sub[$field_id]["bold"] = (isset($_POST['bold'][$obj_type][$field_id]) && $_POST['bold'][$obj_type][$field_id]);
345 }
346 if ($perm_def["newline"]) {
347 $new_sub[$field_id]["newline"] = (isset($_POST['newline'][$obj_type][$field_id]) && $_POST['newline'][$obj_type][$field_id]);
348 }
349 }
350 }
351
352 if (sizeof($new_sub)) {
353 $new_sub = ilUtil::sortArray($new_sub, "pos", "asc", true, true);
354 foreach ($new_sub as $field_id => $field) {
355 $sub->appendSubstitution($field_id, $field["bold"], $field["newline"]);
356 }
357 }
358
359 $sub->update();
360 }
361
362
363 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
364 $this->ctrl->redirect($this, "showPresentation");
365 }
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, $DIC, $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(), and ilUtil\sortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $active_language

ilAdvancedMDSettingsGUI::$active_language = ''
private

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

◆ $context

ilAdvancedMDSettingsGUI::$context = null
private

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

Referenced by setSubTabs().

◆ $ctrl

ilAdvancedMDSettingsGUI::$ctrl
protected

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

◆ $lng

ilAdvancedMDSettingsGUI::$lng
protected

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

Referenced by __construct().

◆ $logger

ilAdvancedMDSettingsGUI::$logger = null
private

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

◆ $obj_id

ilAdvancedMDSettingsGUI::$obj_id = null
protected

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

◆ $obj_type

ilAdvancedMDSettingsGUI::$obj_type = null
protected

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

Referenced by initFormSubstitutions(), and updateSubstitutions().

◆ $permissions

ilAdvancedMDSettingsGUI::$permissions
protected

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

Referenced by getPermissions().

◆ $record

◆ $ref_id

ilAdvancedMDSettingsGUI::$ref_id = null
protected

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

Referenced by loadRecordFormData().

◆ $request

ilAdvancedMDSettingsGUI::$request
protected

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

◆ $sub_type

ilAdvancedMDSettingsGUI::$sub_type = null
protected

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

◆ $tabs_gui

ilAdvancedMDSettingsGUI::$tabs_gui
protected

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

◆ $toolbar

ilAdvancedMDSettingsGUI::$toolbar
protected

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

◆ $tpl

ilAdvancedMDSettingsGUI::$tpl
protected

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

Referenced by __construct().

◆ $ui_factory

ilAdvancedMDSettingsGUI::$ui_factory
protected

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

◆ $ui_renderer

ilAdvancedMDSettingsGUI::$ui_renderer
protected

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

◆ CONTEXT_ADMINISTRATION

const ilAdvancedMDSettingsGUI::CONTEXT_ADMINISTRATION = 1

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

Referenced by __construct().

◆ CONTEXT_OBJECT

const ilAdvancedMDSettingsGUI::CONTEXT_OBJECT = 2

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

Referenced by __construct().

◆ TAB_RECORD_SETTINGS

const ilAdvancedMDSettingsGUI::TAB_RECORD_SETTINGS = 'editRecord'
protected

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

◆ TAB_TRANSLATION

const ilAdvancedMDSettingsGUI::TAB_TRANSLATION = 'translations'
protected

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


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