ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
ilAdvancedMDSettingsGUI Class Reference
+ Collaboration diagram for ilAdvancedMDSettingsGUI:

Public Member Functions

 __construct (int $a_context, int $a_ref_id, ?string $a_obj_type=null, $a_sub_type=null)
 Constructor public. More...
 
 executeCommand ()
 
 showRecords ()
 
 updateSubstitutions ()
 Update substitution public. More...
 
 exportRecords ()
 Export records public. More...
 
 downloadFile ()
 Download XML file public. More...
 
 confirmDeleteFiles ()
 confirm delete files public More...
 
 deleteFiles ()
 Delete files public. More...
 
 confirmDeleteRecords ()
 Confirm delete public. More...
 
 deleteRecords ()
 Permanently delete records public. More...
 
 updateRecords ()
 Save records (assigned object typed) public. More...
 
 confirmDeleteFields ()
 
 deleteFields ()
 
 editRecord (ilPropertyFormGUI $form=null)
 
 updateFields ()
 Update fields public. More...
 
 updateRecord ()
 Update record public. More...
 
 createRecord (ilPropertyFormGUI $form=null)
 Show public. More...
 
 importRecord ()
 
 saveRecord ()
 Save record public. More...
 
 editField (ilPropertyFormGUI $a_form=null)
 Edit field public. More...
 
 updateField ()
 Update field public. More...
 
 createField (ilPropertyFormGUI $a_form=null)
 Show field type selection public. More...
 
 saveField ()
 
 editComplexOption (ilPropertyFormGUI $a_form=null)
 
 updateComplexOption ()
 

Data Fields

const CONTEXT_ADMINISTRATION = 1
 
const CONTEXT_OBJECT = 2
 

Protected Member Functions

 getRecordIdFromQuery ()
 
 getRecordIdsFromPost ()
 
 getFieldIdFromQuery ()
 
 getFieldIdsFromPost ()
 
 getFileIdsFromPost ()
 
 getFieldTypeFromQuery ()
 
 getFieldTypeFromPost ()
 
 getOidFromQuery ()
 
 getPositionsFromPost ()
 
 getPermissions ()
 
 initContextParameters (int $context, int $ref_id, ?string $obj_type, $sub_type)
 
 showPresentation ()
 
 showFiles ()
 Show export files. More...
 
 editFields ()
 
 importRecords ()
 
 setRecordSubTabs (int $level=1, bool $show_settings=false)
 Set subtabs for record editing/creation. More...
 
 initImportForm ()
 
 initFieldForm (ilAdvancedMDFieldDefinition $a_definition)
 
 initForm ($a_mode)
 
 getSubstitutionFieldPermissions (string $a_obj_type, int $a_field_id)
 
 initFormSubstitutions ()
 init form table 'substitutions' protected More...
 
 loadRecordFormData (ilPropertyFormGUI $form)
 
 initRecordObject ()
 
 setSubTabs (int $context)
 Set sub tabs protected. More...
 
 getParsedRecordObjects ()
 
 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'
 
ilPropertyFormGUI $import_form = null
 
ilPropertyFormGUI $form = null
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
RequestInterface $request
 
GlobalHttpState $http
 
RefineryFactory $refinery
 
ilDBInterface $db
 
ilTabsGUI $tabs_gui
 
UIFactory $ui_factory
 
Renderer $ui_renderer
 
ilToolbarGUI $toolbar
 
ilLogger $logger
 
ilAdvancedMDPermissionHelper $permissions
 
ilAdvancedMDRecord $record = null
 
int $ref_id
 
int $obj_id
 
string $obj_type = null
 
 $sub_type = null
 

Private Attributes

 $context = null
 
string $active_language = ''
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDSettingsGUI::__construct ( int  $a_context,
int  $a_ref_id,
?string  $a_obj_type = null,
  $a_sub_type = null 
)

Constructor public.

PhpUndefinedMethodInspection

PhpFieldAssignmentTypeMismatchInspection

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

References $DIC, $ref_id, ILIAS\Repository\ctrl(), ilClaimingPermissionHelper\getInstance(), ILIAS\FileDelivery\http(), initContextParameters(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

79  {
80  global $DIC;
81 
82  $this->ctrl = $DIC->ctrl();
83  $this->lng = $DIC->language();
84  $this->lng->loadLanguageModule('meta');
85  $this->tpl = $DIC->ui()->mainTemplate();
86  $this->tabs_gui = $DIC->tabs();
87 
88  $this->refinery = $DIC->refinery();
89  $this->toolbar = $DIC->toolbar();
90  $this->ui_factory = $DIC->ui()->factory();
91  $this->ui_renderer = $DIC->ui()->renderer();
92  $this->request = $DIC->http()->request();
93  $this->http = $DIC->http();
94  $this->db = $DIC->database();
95 
97  $this->logger = $DIC->logger()->amet();
98 
99  $this->context = $a_context;
100  $this->initContextParameters(
101  $this->context,
102  $a_ref_id,
103  $a_obj_type,
104  $a_sub_type
105  );
106 
108  $this->permissions = ilAdvancedMDPermissionHelper::getInstance($DIC->user()->getId(), $this->ref_id);
109  }
initContextParameters(int $context, int $ref_id, ?string $obj_type, $sub_type)
static http()
Fetches the global http state from ILIAS.
$DIC
Definition: xapitoken.php:62
static getInstance(int $a_user_id, int $a_ref_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteFields()

ilAdvancedMDSettingsGUI::confirmDeleteFields ( )

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

References ILIAS\Repository\ctrl(), editFields(), getFieldIdsFromPost(), ilAdvancedMDFieldDefinition\getInstance(), initRecordObject(), ILIAS\Repository\lng(), and setRecordSubTabs().

820  : void
821  {
822  $field_ids = $this->getFieldIdsFromPost();
823  if (!count($field_ids)) {
824  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
825  $this->editFields();
826  return;
827  }
828 
829  $this->initRecordObject();
830  $this->setRecordSubTabs(2);
831 
832  $c_gui = new ilConfirmationGUI();
833 
834  // set confirm/cancel commands
835  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFields"));
836  $c_gui->setHeaderText($this->lng->txt("md_adv_delete_fields_sure"));
837  $c_gui->setCancel($this->lng->txt("cancel"), "editFields");
838  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFields");
839 
840  // add items to delete
841  foreach ($field_ids as $field_id) {
842  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
843  $c_gui->addItem("field_id[]", (string) $field_id, $field->getTitle() ?: 'No Title');
844  }
845  $this->tpl->setContent($c_gui->getHTML());
846  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
+ Here is the call graph for this function:

◆ confirmDeleteFiles()

ilAdvancedMDSettingsGUI::confirmDeleteFiles ( )

confirm delete files public

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

References ILIAS\Repository\ctrl(), getFileIdsFromPost(), ILIAS\Repository\lng(), and showFiles().

560  : void
561  {
562  $file_ids = $this->getFileIdsFromPost();
563  if (count($file_ids) !== 1) {
564  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
565  $this->showFiles();
566  return;
567  }
568 
569  $c_gui = new ilConfirmationGUI();
570  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
571  $c_gui->setHeaderText($this->lng->txt("md_adv_delete_files_sure"));
572  $c_gui->setCancel($this->lng->txt("cancel"), "showFiles");
573  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
574 
575  $files = new ilAdvancedMDRecordExportFiles(
576  $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
577  );
578  $file_data = $files->readFilesInfo();
579 
580  // add items to delete
581  foreach ($file_ids as $file_id) {
582  $info = $file_data[$file_id];
583  $c_gui->addItem(
584  "file_id[]",
585  (string) $file_id,
586  is_array($info['name'] ?? false) ? implode(',', $info['name']) : 'No Records'
587  );
588  }
589  $this->tpl->setContent($c_gui->getHTML());
590  }
+ Here is the call graph for this function:

◆ confirmDeleteRecords()

ilAdvancedMDSettingsGUI::confirmDeleteRecords ( )

Confirm delete public.

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

References ilAdvancedMDRecord\_getInstanceByRecordId(), ILIAS\Repository\ctrl(), getRecordIdsFromPost(), ilAdvancedMDRecord\getTitle(), initRecordObject(), ILIAS\Repository\lng(), setRecordSubTabs(), and showRecords().

625  : void
626  {
627  $this->initRecordObject();
628  $this->setRecordSubTabs();
629 
630  $record_ids = $this->getRecordIdsFromPost();
631  if (!count($record_ids)) {
632  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
633  $this->showRecords();
634  return;
635  }
636 
637  $c_gui = new ilConfirmationGUI();
638 
639  // set confirm/cancel commands
640  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteRecords"));
641  $c_gui->setHeaderText($this->lng->txt("md_adv_delete_record_sure"));
642  $c_gui->setCancel($this->lng->txt("cancel"), "showRecords");
643  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteRecords");
644 
645  // add items to delete
646  foreach ($record_ids as $record_id) {
648  $c_gui->addItem("record_id[]", (string) $record_id, $record->getTitle() ?: 'No Title');
649  }
650  $this->tpl->setContent($c_gui->getHTML());
651  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:

◆ createField()

ilAdvancedMDSettingsGUI::createField ( ilPropertyFormGUI  $a_form = null)

Show field type selection public.

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

References ILIAS\Repository\ctrl(), editFields(), getFieldTypeFromPost(), getFieldTypeFromQuery(), ilAdvancedMDFieldDefinition\getInstance(), getRecordIdFromQuery(), initFieldForm(), initRecordObject(), and setRecordSubTabs().

Referenced by saveField().

1338  : void
1339  {
1340  $record_id = $this->getRecordIdFromQuery();
1341  $field_type = $this->getFieldTypeFromPost();
1342  if (!$field_type) {
1343  $field_type = $this->getFieldTypeFromQuery();
1344  }
1345 
1346  $this->initRecordObject();
1347  $this->ctrl->setParameter($this, 'ftype', $field_type);
1348  $this->setRecordSubTabs(2);
1349  if (!$record_id || !$field_type) {
1350  $this->editFields();
1351  return;
1352  }
1353 
1354  if (!$a_form) {
1355  $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $field_type);
1356  $field_definition->setRecordId($record_id);
1357  $a_form = $this->initFieldForm($field_definition);
1358  }
1359  $this->tpl->setContent($a_form->getHTML());
1360  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createRecord()

ilAdvancedMDSettingsGUI::createRecord ( ilPropertyFormGUI  $form = null)

Show public.

Parameters

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

References ILIAS\Repository\form(), initForm(), initRecordObject(), and setRecordSubTabs().

Referenced by importRecord(), and saveRecord().

1081  : void
1082  {
1083  $this->initRecordObject();
1084  $this->setRecordSubTabs();
1085  if (!$form instanceof ilPropertyFormGUI) {
1086  $this->initForm('create');
1087  }
1088  $this->tpl->setContent($this->form->getHTML());
1089  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFields()

ilAdvancedMDSettingsGUI::deleteFields ( )

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

References ilAdvancedMDPermissionHelper\ACTION_FIELD_DELETE, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ILIAS\Repository\ctrl(), editFields(), getFieldIdsFromPost(), ilAdvancedMDFieldDefinition\getInstance(), getPermissions(), and ILIAS\Repository\lng().

848  : void
849  {
850  $this->ctrl->saveParameter($this, 'record_id');
851 
852  $field_ids = $this->getFieldIdsFromPost();
853  if (!count($field_ids)) {
854  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
855  $this->editFields();
856  return;
857  }
858 
859  // all fields have to be deletable
860  $fail = array();
861  foreach ($field_ids as $field_id) {
862  if (!$this->getPermissions()->hasPermission(
864  (string) $field_id,
866  )) {
867  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
868  $fail[] = $field->getTitle();
869  }
870  }
871  if ($fail) {
872  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
873  $this->ctrl->redirect($this, "editFields");
874  }
875 
876  foreach ($field_ids as $field_id) {
877  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
878  $field->delete();
879  }
880  $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_fields'), true);
881  $this->ctrl->redirect($this, "editFields");
882  }
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
+ Here is the call graph for this function:

◆ deleteFiles()

ilAdvancedMDSettingsGUI::deleteFiles ( )

Delete files public.

Parameters

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

References $GLOBALS, ILIAS\Repository\access(), getFileIdsFromPost(), ILIAS\Repository\lng(), and showFiles().

597  : void
598  {
599  $file_ids = $this->getFileIdsFromPost();
600  if (count($file_ids) === 0) {
601  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
602  $this->showFiles();
603  return;
604  }
605 
606  if (!$GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
607  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
608  $GLOBALS['DIC']->ctrl()->redirect($this, 'showFiles');
609  }
610 
611  $files = new ilAdvancedMDRecordExportFiles(
612  $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
613  );
614  foreach ($file_ids as $file_id) {
615  $files->deleteByFileId((int) $file_id);
616  }
617  $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_files'));
618  $this->showFiles();
619  }
$GLOBALS["DIC"]
Definition: wac.php:31
+ Here is the call graph for this function:

◆ deleteRecords()

ilAdvancedMDSettingsGUI::deleteRecords ( )

Permanently delete records public.

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

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_DELETE, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ilAdvancedMDRecord\delete(), ilAdvancedMDRecord\getParentObject(), getPermissions(), getRecordIdsFromPost(), ilAdvancedMDRecord\getTitle(), ILIAS\Repository\lng(), and showRecords().

657  : void
658  {
659  $record_ids = $this->getRecordIdsFromPost();
660  if (!count($record_ids)) {
661  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
662  $this->showRecords();
663  return;
664  }
665 
666  // all records have to be deletable
667  $fail = array();
668  foreach ($record_ids as $record_id) {
669  // must not delete global records in local context
670  if ($this->context == self::CONTEXT_OBJECT) {
672  if (!$record->getParentObject()) {
673  $fail[] = $record->getTitle();
674  }
675  }
676 
677  if (!$this->getPermissions()->hasPermission(
679  (string) $record_id,
681  )) {
683  $fail[] = $record->getTitle();
684  }
685  }
686  if ($fail) {
687  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
688  $this->ctrl->redirect($this, "showRecords");
689  }
690 
691  foreach ($record_ids as $record_id) {
693  $record->delete();
694  }
695  $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_records'), true);
696  $this->ctrl->redirect($this, "showRecords");
697  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:

◆ downloadFile()

ilAdvancedMDSettingsGUI::downloadFile ( )

Download XML file public.

Parameters

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

References ilFileDelivery\deliverFileLegacy(), getFileIdsFromPost(), ILIAS\Repository\lng(), and showFiles().

541  : void
542  {
543  $file_ids = $this->getFileIdsFromPost();
544  if (count($file_ids) !== 1) {
545  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('md_adv_select_one_file'));
546  $this->showFiles();
547  return;
548  }
549  $files = new ilAdvancedMDRecordExportFiles(
550  $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
551  );
552  $abs_path = $files->getAbsolutePathByFileId($file_ids[0]);
553  ilFileDelivery::deliverFileLegacy($abs_path, 'ilias_meta_data_record.xml', 'application/xml');
554  }
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
+ Here is the call graph for this function:

◆ editComplexOption()

ilAdvancedMDSettingsGUI::editComplexOption ( ilPropertyFormGUI  $a_form = null)

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

References ILIAS\Repository\ctrl(), getFieldIdFromQuery(), ilAdvancedMDFieldDefinition\getInstance(), initComplexOptionForm(), and ILIAS\Repository\lng().

2245  : void
2246  {
2247  $field_id = $this->getFieldIdFromQuery();
2248  if (!$field_id) {
2249  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_select_one'));
2250  $this->ctrl->redirect($this, 'showRecords');
2251  }
2252 
2253  $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
2254  if (!$field_definition->hasComplexOptions()) {
2255  $this->ctrl->redirect($this, "editField");
2256  }
2257 
2258  if (!$a_form) {
2259  $a_form = $this->initComplexOptionForm($field_definition);
2260  }
2261 
2262  $this->tpl->setContent($a_form->getHTML());
2263  }
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
+ Here is the call graph for this function:

◆ editField()

ilAdvancedMDSettingsGUI::editField ( ilPropertyFormGUI  $a_form = null)

Edit field public.

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

References ILIAS\Repository\ctrl(), editFields(), getFieldIdFromQuery(), ilAdvancedMDFieldDefinition\getInstance(), getRecordIdFromQuery(), initFieldForm(), initLanguage(), initRecordObject(), setRecordSubTabs(), and showLanguageSwitch().

Referenced by updateField().

1259  : void
1260  {
1261  $record_id = $this->getRecordIdFromQuery();
1262  $field_id = $this->getFieldIdFromQuery();
1263  if (!$record_id || !$field_id) {
1264  $this->editFields();
1265  return;
1266  }
1267  $this->ctrl->saveParameter($this, 'field_id');
1268  $this->ctrl->saveParameter($this, 'record_id');
1269  $this->initRecordObject();
1270  $this->setRecordSubTabs(2);
1271 
1272  $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1273 
1274  if (!$a_form instanceof ilPropertyFormGUI) {
1275  $this->initLanguage($this->record->getRecordId());
1276  $this->showLanguageSwitch($this->record->getRecordId(), 'editField');
1277  $a_form = $this->initFieldForm($field_definition);
1278  }
1279  $table = null;
1280  if ($field_definition->hasComplexOptions()) {
1281  $table = $field_definition->getComplexOptionsOverview($this, "editField");
1282  }
1283  $this->tpl->setContent($a_form->getHTML() . $table);
1284  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
showLanguageSwitch(int $record_id, string $target)
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editFields()

ilAdvancedMDSettingsGUI::editFields ( )
protected

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

References $active_language, $DIC, ilAdvancedMDPermissionHelper\ACTION_RECORD_CREATE_FIELD, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), getRecordIdFromQuery(), ilAdvancedMDFieldDefinition\getValidTypes(), initLanguage(), initRecordObject(), ILIAS\Repository\lng(), setRecordSubTabs(), ilTable2GUI\setTitle(), showLanguageSwitch(), and ILIAS\Repository\toolbar().

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

902  : void
903  {
904  global $DIC;
905 
906  $record_id = $this->getRecordIdFromQuery();
907  if (!$record_id) {
908  $this->ctrl->redirect($this, 'showRecords');
909  }
910  $this->ctrl->saveParameter($this, 'record_id');
911  $this->initRecordObject();
912  $this->setRecordSubTabs();
913  $this->initLanguage($record_id);
914  $this->showLanguageSwitch($record_id, 'editFields');
915 
916  $perm = $this->getPermissions()->hasPermissions(
918  (string) $this->record->getRecordId(),
919  array(
921  ,
923  )
924  );
925 
926  $filter_warn = [];
928  // type selection
929  $field_buttons = [];
930  foreach (ilAdvancedMDFieldDefinition::getValidTypes() as $type) {
931  $field = ilAdvancedMDFieldDefinition::getInstance(null, $type);
932 
933  $this->ctrl->setParameter($this, 'ftype', $type);
934  $create_link = $this->ctrl->getLinkTarget($this, 'createField');
935  $this->ctrl->clearParameterByClass(strtolower(self::class), 'ftype');
936 
937  $field_buttons[] = $this->ui_factory->button()->shy(
938  $this->lng->txt($field->getTypeTitle()),
939  $create_link
940  );
941 
942  if (!$field->isFilterSupported()) {
943  $filter_warn[] = $this->lng->txt($field->getTypeTitle());
944  }
945  }
946 
947  if (count($this->toolbar->getItems())) {
948  $this->toolbar->addSeparator();
949  }
950 
951  $dropdown = $this->ui_factory->dropdown()
952  ->standard($field_buttons)
953  ->withLabel($this->lng->txt('meta_advmd_add_field'));
954  $this->toolbar->addComponent($dropdown);
955  }
956 
957  // #17092
958  if (sizeof($filter_warn)) {
959  $this->tpl->setOnScreenMessage('info', sprintf($this->lng->txt("md_adv_field_filter_warning"), implode(", ", $filter_warn)));
960  }
961 
962  // show field table
964  $this->record->getRecordId(),
965  false,
967  );
968 
969  $table_gui = new ilAdvancedMDFieldTableGUI(
970  $this,
971  'editFields',
972  $this->getPermissions(),
974  $this->record->getDefaultLanguage()
975  );
976  $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
977  $table_gui->parseDefinitions($fields);
978  if (sizeof($fields)) {
979  $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
980  }
981  $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
982  $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
983  $table_gui->setSelectAllCheckbox("field_id");
984 
985  $this->tpl->setContent($table_gui->getHTML());
986  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
showLanguageSwitch(int $record_id, string $target)
$DIC
Definition: xapitoken.php:62
static getValidTypes()
Get all valid types.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editRecord()

ilAdvancedMDSettingsGUI::editRecord ( ilPropertyFormGUI  $form = null)

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

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), getRecordIdFromQuery(), initForm(), initLanguage(), initRecordObject(), setRecordSubTabs(), and showLanguageSwitch().

Referenced by updateRecord().

884  : void
885  {
886  $record_id = $this->getRecordIdFromQuery();
887  if (!$record_id) {
888  $this->ctrl->redirect($this, 'showRecords');
889  }
890  $this->initRecordObject();
891  $this->setRecordSubTabs(1, true);
892  $this->tabs_gui->activateTab(self::TAB_RECORD_SETTINGS);
893 
894  if (!$form instanceof ilPropertyFormGUI) {
895  $this->initLanguage($record_id);
896  $this->showLanguageSwitch($record_id, 'editRecord');
897  $this->initForm('edit');
898  }
899  $this->tpl->setContent($this->form->getHTML());
900  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
showLanguageSwitch(int $record_id, string $target)
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilAdvancedMDSettingsGUI::executeCommand ( )

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

References $GLOBALS, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), initForm(), initRecordObject(), and setRecordSubTabs().

260  : void
261  {
262  $next_class = $this->ctrl->getNextClass($this);
263  $cmd = $this->ctrl->getCmd();
264  switch ($next_class) {
265  case strtolower(ilAdvancedMDRecordTranslationGUI::class):
266  $record = $this->initRecordObject();
267  $this->setRecordSubTabs(1, true);
268  $int_gui = new \ilAdvancedMDRecordTranslationGUI($record);
269  $this->ctrl->forwardCommand($int_gui);
270  break;
271 
272  case "ilpropertyformgui":
273  $this->initRecordObject();
274  $this->initForm(
275  $this->record->getRecordId() > 0 ? 'edit' : 'create'
276  );
277  $GLOBALS['DIC']->ctrl()->forwardCommand($this->form);
278  break;
279 
280  default:
281  if (!$cmd) {
282  $cmd = 'showRecords';
283  }
284  $this->$cmd();
285  }
286  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
$GLOBALS["DIC"]
Definition: wac.php:31
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ exportRecords()

ilAdvancedMDSettingsGUI::exportRecords ( )

Export records public.

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

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EXPORT, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), getPermissions(), getRecordIdsFromPost(), ilAdvancedMDRecord\getTitle(), ILIAS\Repository\lng(), showFiles(), and showRecords().

472  : void
473  {
474  $record_ids = $this->getRecordIdsFromPost();
475  if (!count($record_ids)) {
476  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
477  $this->showRecords();
478  return;
479  }
480 
481  // all records have to be exportable
482  $fail = array();
483  foreach ($record_ids as $record_id) {
484  if (!$this->getPermissions()->hasPermission(
486  (string) $record_id,
488  )) {
490  $fail[] = $record->getTitle();
491  }
492  }
493  if ($fail) {
494  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_copy') . " " . implode(", ", $fail), true);
495  $this->ctrl->redirect($this, "showRecords");
496  }
497 
498  $xml_writer = new ilAdvancedMDRecordXMLWriter((array) $record_ids);
499  $xml_writer->write();
500 
501  $export_files = new ilAdvancedMDRecordExportFiles(
502  $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
503  );
504  $export_files->create($xml_writer->xmlDumpMem());
505 
506  $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_records_exported'));
507  $this->showFiles();
508  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:

◆ getFieldIdFromQuery()

ilAdvancedMDSettingsGUI::getFieldIdFromQuery ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by editComplexOption(), editField(), updateComplexOption(), and updateField().

137  : ?int
138  {
139  if ($this->http->wrapper()->query()->has('field_id')) {
140  return $this->http->wrapper()->query()->retrieve(
141  'field_id',
142  $this->refinery->kindlyTo()->int()
143  );
144  }
145  return null;
146  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFieldIdsFromPost()

ilAdvancedMDSettingsGUI::getFieldIdsFromPost ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by confirmDeleteFields(), and deleteFields().

148  : SplFixedArray
149  {
150  if ($this->http->wrapper()->post()->has('field_id')) {
151  return SplFixedArray::fromArray(
152  $this->http->wrapper()->post()->retrieve(
153  'field_id',
154  $this->refinery->kindlyTo()->listOf(
155  $this->refinery->kindlyTo()->int()
156  )
157  )
158  );
159  }
160  return new SplFixedArray(0);
161  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFieldTypeFromPost()

ilAdvancedMDSettingsGUI::getFieldTypeFromPost ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by createField().

189  : ?int
190  {
191  if ($this->http->wrapper()->post()->has('ftype')) {
192  return $this->http->wrapper()->post()->retrieve(
193  'ftype',
194  $this->refinery->kindlyTo()->int()
195  );
196  }
197  return null;
198  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFieldTypeFromQuery()

ilAdvancedMDSettingsGUI::getFieldTypeFromQuery ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by createField(), and saveField().

178  : ?int
179  {
180  if ($this->http->wrapper()->query()->has('ftype')) {
181  return $this->http->wrapper()->query()->retrieve(
182  'ftype',
183  $this->refinery->kindlyTo()->int()
184  );
185  }
186  return null;
187  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileIdsFromPost()

ilAdvancedMDSettingsGUI::getFileIdsFromPost ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

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

163  : SplFixedArray
164  {
165  if ($this->http->wrapper()->post()->has('file_id')) {
166  return SplFixedArray::fromArray(
167  $this->http->wrapper()->post()->retrieve(
168  'file_id',
169  $this->refinery->kindlyTo()->dictOf(
170  $this->refinery->kindlyTo()->int()
171  )
172  )
173  );
174  }
175  return new SplFixedArray(0);
176  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOidFromQuery()

ilAdvancedMDSettingsGUI::getOidFromQuery ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by initComplexOptionForm(), and updateComplexOption().

200  : ?string
201  {
202  if ($this->http->wrapper()->query()->has('oid')) {
203  return $this->http->wrapper()->query()->retrieve(
204  'oid',
205  $this->refinery->kindlyTo()->string()
206  );
207  }
208  return null;
209  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParsedRecordObjects()

ilAdvancedMDSettingsGUI::getParsedRecordObjects ( )
protected
Todo:
get rid of this (used in ilAdvancedMDRecordTableGUI) and the parsing there.

Also get rid of the usage in ilAvancedMDSettingsGUI::updateRecords

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

References ILIAS\LTI\ToolProvider\$key, $obj_type, $res, $sub_type, ilAdvancedMDRecord\_getRecords(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), 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().

2115  : array
2116  {
2117  $res = [];
2118 
2119  $sub_type = (!is_array($this->sub_type))
2120  ? [$this->sub_type]
2121  : $this->sub_type;
2122 
2123  if ($this->context === self::CONTEXT_OBJECT) {
2124  // get all records selected for subtype
2125  foreach ($sub_type as $st) {
2126  $selected[$st] = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $st);
2127  }
2128  }
2129 
2130  $records = ilAdvancedMDRecord::_getRecords();
2131  $orderings = new ilAdvancedMDRecordObjectOrderings();
2132  $records = $orderings->sortRecords($records, $this->obj_id);
2133 
2134  $position = 0;
2135 
2136  // get all records usuable in current context
2137  foreach ($records as $record) {
2138  $parent_id = $record->getParentObject();
2139 
2140  if ($this->context == self::CONTEXT_ADMINISTRATION) {
2141  if ($parent_id) {
2142  continue;
2143  }
2144  } else {
2145  // does not match current object
2146  if ($parent_id && $parent_id != $this->obj_id) {
2147  continue;
2148  }
2149 
2150  // inactive records only in administration
2151  if (!$parent_id && !$record->isActive()) {
2152  continue;
2153  }
2154  // scope needs to match in object context
2155  if (
2157  $this->ref_id,
2158  $record->getScopes()
2159  )
2160  ) {
2161  continue;
2162  }
2163  }
2164 
2165  $tmp_arr = [];
2166  $tmp_arr['readonly'] = null;
2167  $tmp_arr['local'] = null;
2168  $tmp_arr['optional'] = null;
2169  $tmp_arr['id'] = $record->getRecordId();
2170  $tmp_arr['active'] = $record->isActive();
2171  $tmp_arr['title'] = $record->getTitle();
2172  $tmp_arr['description'] = $record->getDescription();
2173  $tmp_arr['fields'] = [];
2174  /*
2175  * This is a workaround to fix sorting by scope, see #21963
2176  */
2177  $tmp_arr['first_scope'] = ilObject::_lookupTitle(
2178  ilObject::_lookupObjId($record->getScopeRefIds()[0] ?? 0)
2179  );
2180  $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
2181  foreach ($record->getAssignedObjectTypes() as $idx => $item) {
2182  $tmp_arr['obj_types'][$idx]['context'] = null;
2183  }
2184  $position += 10;
2185  $tmp_arr['position'] = $position;
2186 
2187  $tmp_arr['perm'] = $this->permissions->hasPermissions(
2189  (string) $record->getRecordId(),
2190  array(
2192  ,
2194  ,
2196  ,
2199  )
2200  )
2201  );
2202 
2203  if ($this->obj_type) {
2204  $tmp_arr["readonly"] = !(bool) $parent_id;
2205  $tmp_arr["local"] = $parent_id;
2206 
2207  // local records are never optional (or unassigned)
2208  $assigned = (bool) $parent_id;
2209  $optional = false;
2210  foreach ($tmp_arr['obj_types'] as $idx => $item) {
2211  if ($item["obj_type"] == $this->obj_type &&
2212  in_array($item["sub_type"], $sub_type)) {
2213  $assigned = true;
2214  $optional = $item["optional"];
2215  $tmp_arr['obj_types'][$idx]['context'] = true;
2216  } else {
2217  unset($tmp_arr['obj_types'][$idx]);
2218  }
2219  }
2220  $tmp_arr['optional'] = $optional;
2221  if ($optional) {
2222  // in object context "active" means selected record
2223  // $tmp_arr['active'] = (is_array($selected[$item["sub_type"]]) && in_array($record->getRecordId(), $selected[$item["sub_type"]]));
2224  $tmp_arr['local_selected'] = [];
2225  foreach ($selected as $key => $records) {
2226  if (in_array($record->getRecordId(), $records)) {
2227  $tmp_arr['local_selected'][$this->obj_type][] = $key;
2228  }
2229  }
2230  }
2231  }
2232 
2233  if ($assigned ?? true) {
2234  $res[] = $tmp_arr;
2235  }
2236  }
2237  return $res;
2238  }
$res
Definition: ltiservices.php:67
static _getRecords()
Get records public.
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
static _lookupObjId(int $ref_id)
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
static _lookupTitle(int $obj_id)
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPermissions()

ilAdvancedMDSettingsGUI::getPermissions ( )
protected

◆ getPositionsFromPost()

ilAdvancedMDSettingsGUI::getPositionsFromPost ( )
protected
Returns
array<string, float>

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by updateFields(), and updateRecords().

214  : array
215  {
216  if ($this->http->wrapper()->post()->has('position')) {
217  return $this->http->wrapper()->post()->retrieve(
218  'position',
219  $this->refinery->kindlyTo()->dictOf(
220  $this->refinery->byTrying([
221  $this->refinery->kindlyTo()->float(),
222  $this->refinery->always(0)
223  ])
224  )
225  );
226  }
227  return [];
228  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecordIdFromQuery()

ilAdvancedMDSettingsGUI::getRecordIdFromQuery ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

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

111  : ?int
112  {
113  if ($this->http->wrapper()->query()->has('record_id')) {
114  return $this->http->wrapper()->query()->retrieve(
115  'record_id',
116  $this->refinery->kindlyTo()->int()
117  );
118  }
119  return null;
120  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecordIdsFromPost()

ilAdvancedMDSettingsGUI::getRecordIdsFromPost ( )
protected

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

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

122  : SplFixedArray
123  {
124  if ($this->http->wrapper()->post()->has('record_id')) {
125  return SplFixedArray::fromArray(
126  $this->http->wrapper()->post()->retrieve(
127  'record_id',
128  $this->refinery->kindlyTo()->listOf(
129  $this->refinery->kindlyTo()->int()
130  )
131  )
132  );
133  }
134  return new SplFixedArray(0);
135  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubstitutionFieldPermissions()

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

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

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_FILE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FILE_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_ORG_UNIT_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_ORG_UNIT_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_PRG_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_PRG_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_FILE, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_GROUP, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_IASS, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_ORG_UNIT, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_PRG, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_SESSION, getPermissions(), ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_BOLD, and ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_NEWLINE.

Referenced by initFormSubstitutions(), and updateSubstitutions().

1622  : array
1623  {
1624  if ($a_obj_type == "crs") {
1625  $perm = $this->getPermissions()->hasPermissions(
1627  (string) $a_field_id,
1628  array(
1630  ,
1633  )
1634  ,
1637  )
1638  )
1639  );
1640  return array(
1642  ,
1644  ,
1646  );
1647  } elseif ($a_obj_type == "cat") {
1648  $perm = $this->getPermissions()->hasPermissions(
1650  (string) $a_field_id,
1651  array(
1653  ,
1656  )
1657  ,
1660  )
1661  )
1662  );
1663  return array(
1665  ,
1667  ,
1669  );
1670  } elseif ($a_obj_type == "sess") {
1671  $perm = $this->getPermissions()->hasPermissions(
1673  (string) $a_field_id,
1674  array(
1676  ,
1679  )
1680  ,
1683  )
1684  )
1685  );
1686  return array(
1688  ,
1690  ,
1692  );
1693  } elseif ($a_obj_type == "grp") {
1694  $perm = $this->getPermissions()->hasPermissions(
1696  (string) $a_field_id,
1697  array(
1699  ,
1702  )
1703  ,
1706  )
1707  )
1708  );
1709  return array(
1711  ,
1713  ,
1715  );
1716  } elseif ($a_obj_type == "iass") {
1717  $perm = $this->getPermissions()->hasPermissions(
1719  (string) $a_field_id,
1720  array(
1722  ,
1725  )
1726  ,
1729  )
1730  )
1731  );
1732  return array(
1734  ,
1736  ,
1738  );
1739  } elseif ($a_obj_type == "exc") {
1740  $perm = $this->getPermissions()->hasPermissions(
1742  (string) $a_field_id,
1743  array(
1745  ,
1748  )
1749  ,
1752  )
1753  )
1754  );
1755  return array(
1757  ,
1759  ,
1761  );
1762  } elseif ($a_obj_type == "file") {
1763  $perm = $this->getPermissions()->hasPermissions(
1765  (string) $a_field_id,
1766  array(
1768  ,
1771  )
1772  ,
1775  )
1776  )
1777  );
1778  return array(
1780  ,
1782  ,
1784  );
1785  } elseif ($a_obj_type == "prg") {
1786  $perm = $this->getPermissions()->hasPermissions(
1788  (string) $a_field_id,
1789  [
1791  [
1794  ],
1795  [
1798  ]
1799  ]
1800  );
1801  return array(
1803  ,
1805  ,
1807  );
1808  } elseif ($a_obj_type == "orgu") {
1809  $perm = $this->getPermissions()->hasPermissions(
1811  (string) $a_field_id,
1812  [
1814  ,
1815  [
1818  ]
1819  ,
1820  [
1823  ]
1824  ]
1825  );
1826  return [
1828  ,
1830  ,
1832  ];
1833  }
1834  return [];
1835  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importRecord()

ilAdvancedMDSettingsGUI::importRecord ( )

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

References createRecord(), ILIAS\Repository\ctrl(), importRecords(), initImportForm(), ILIAS\Repository\lng(), ilAdvancedMDRecordParser\MODE_INSERT, ilAdvancedMDRecordParser\MODE_INSERT_VALIDATION, and ilAdvancedMDRecordParser\setContext().

1170  : void
1171  {
1172  $this->initImportForm();
1173  if (!$this->import_form->checkInput()) {
1174  $this->import_form->setValuesByPost();
1175  $this->importRecords();
1176  return;
1177  }
1178 
1179  $import_files = new ilAdvancedMDRecordImportFiles();
1180  if (!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name'])) {
1181  $this->createRecord();
1182  return;
1183  }
1184 
1185  try {
1186  $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
1187 
1188  // local import?
1189  if ($this->context === self::CONTEXT_OBJECT) {
1190  $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
1191  }
1192 
1193  // Validate
1195  $parser->startParsing();
1196 
1197  // Insert
1198  $parser->setMode(ilAdvancedMDRecordParser::MODE_INSERT);
1199  $parser->startParsing();
1200  $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_added_new_record'), true);
1201  $this->ctrl->redirect($this, "showRecords");
1202  } catch (ilSaxParserException $exc) {
1203  $this->tpl->setOnScreenMessage('failure', $exc->getMessage(), true);
1204  $this->ctrl->redirect($this, "importRecords");
1205  }
1206 
1207  // Finally delete import file
1208  $import_files->deleteFileByCreationDate($create_time);
1209  }
createRecord(ilPropertyFormGUI $form=null)
Show public.
setContext(int $a_obj_id, string $a_obj_type, ?string $a_sub_type=null)
SaxParserException thrown by ilSaxParser if property throwException is set.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ importRecords()

ilAdvancedMDSettingsGUI::importRecords ( )
protected

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

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

Referenced by importRecord().

1091  : void
1092  {
1093  $this->initRecordObject();
1094  $this->setRecordSubTabs();
1095 
1096  // Import Table
1097  $this->initImportForm();
1098  $this->tpl->setContent($this->import_form->getHTML());
1099  }
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
+ 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 2265 of file class.ilAdvancedMDSettingsGUI.php.

References $form, ilPropertyFormGUI\addCommandButton(), ILIAS\Repository\ctrl(), getOidFromQuery(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), and ilPropertyFormGUI\setTitle().

Referenced by editComplexOption(), and updateComplexOption().

2266  {
2267  $this->ctrl->saveParameter($this, "record_id");
2268  $this->ctrl->saveParameter($this, "field_id");
2269  $this->ctrl->saveParameter($this, "oid");
2270 
2271  $form = new ilPropertyFormGUI();
2272  $form->setTitle($this->lng->txt("md_adv_edit_complex_option"));
2273  $form->setFormAction($this->ctrl->getFormAction($this, "updateComplexOption"));
2274 
2275  $oid = $this->getOidFromQuery();
2276  $a_def->initOptionForm($form, $oid);
2277 
2278  $form->addCommandButton("updateComplexOption", $this->lng->txt("save"));
2279  $form->addCommandButton("editField", $this->lng->txt("cancel"));
2280 
2281  return $form;
2282  }
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initContextParameters()

ilAdvancedMDSettingsGUI::initContextParameters ( int  $context,
int  $ref_id,
?string  $obj_type,
  $sub_type 
)
protected
Parameters
string|string[]|null$sub_type

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

References $obj_type, $ref_id, $sub_type, and ilObject\_lookupObjId().

Referenced by __construct().

246  : void {
247  if ($context === self::CONTEXT_ADMINISTRATION) {
248  $this->ref_id = $ref_id;
249  $this->obj_id = null;
250  $this->obj_type = null;
251  $this->sub_type = null;
252  } else {
253  $this->ref_id = $ref_id;
254  $this->obj_id = ilObject::_lookupObjId($ref_id);
255  $this->obj_type = $obj_type;
256  $this->sub_type = $sub_type;
257  }
258  }
static _lookupObjId(int $ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFieldForm()

ilAdvancedMDSettingsGUI::initFieldForm ( ilAdvancedMDFieldDefinition  $a_definition)
protected

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

References $active_language, $form, ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ilAdvancedMDFieldDefinition\addToFieldDefinitionForm(), ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getDescription(), ilAdvancedMDFieldDefinition\getFieldId(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getPermissions(), ilAdvancedMDFieldDefinition\getTypeTitle(), ILIAS\Repository\lng(), ilPropertyFormGUI\setDescription(), ilFormGUI\setFormAction(), and ilPropertyFormGUI\setTitle().

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

1400  {
1401  $is_creation_mode = $a_definition->getFieldId() ? false : true;
1402 
1403  $form = new ilPropertyFormGUI();
1404  $form->setFormAction($this->ctrl->getFormAction($this));
1405 
1406  $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1407  if ($is_creation_mode) {
1408  $form->setDescription($a_definition->getDescription());
1409  } else {
1410  $form->setDescription($translations->getFormTranslationInfo(
1411  $a_definition->getFieldId(),
1413  ));
1414  }
1415  $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1416  $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1417  $form->addItem($type);
1418  $a_definition->addToFieldDefinitionForm($form, $this->getPermissions(), $this->active_language);
1419 
1420  if ($is_creation_mode) {
1421  $form->setTitle($this->lng->txt('md_adv_create_field'));
1422  $form->addCommandButton('saveField', $this->lng->txt('create'));
1423  } else {
1424  $form->setTitle($this->lng->txt('md_adv_edit_field'));
1425  $form->addCommandButton('updateField', $this->lng->txt('save'));
1426  }
1427 
1428  $form->addCommandButton('editFields', $this->lng->txt('cancel'));
1429 
1430  return $form;
1431  }
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
Add input elements to definition form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilAdvancedMDSettingsGUI::initForm (   $a_mode)
protected

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

References $check, $form, $GLOBALS, $scope, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), getPermissions(), ILIAS\Repository\lng(), ROOT_FOLDER_ID, ilExplorerSelectInputGUI\setValue(), ilTextAreaInputGUI\setValue(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

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

1434  {
1435  if ($this->form instanceof ilPropertyFormGUI) {
1436  return $this->form;
1437  }
1438  $perm = $this->getPermissions()->hasPermissions(
1440  (string) $this->record->getRecordId(),
1441  array(
1444  )
1445  ,
1448  )
1449  ,
1452  )
1453  ,
1455  )
1456  );
1457 
1458  $this->form = new ilPropertyFormGUI();
1459 
1460  $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1461  $this->form->setDescription($translations->getFormTranslationInfo($this->active_language));
1462  $this->form->setFormAction($this->ctrl->getFormAction($this));
1463 
1464  // title
1465  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
1466  $title->setValue($this->record->getTitle());
1467  $title->setSize(20);
1468  $title->setMaxLength(70);
1469  $title->setRequired(true);
1470 
1472  $title->setDisabled(true);
1473  }
1474  $this->form->addItem($title);
1475  $translations->modifyTranslationInfoForTitle($this->form, $title, $this->active_language);
1476 
1477  // desc
1478  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
1479  $desc->setValue($this->record->getDescription());
1480  $desc->setRows(3);
1481 
1483  $desc->setDisabled(true);
1484  }
1485  $this->form->addItem($desc);
1486  $translations->modifyTranslationInfoForDescription($this->form, $desc, $this->active_language);
1487 
1488  // active
1489  $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'), 'active');
1490  $check->setChecked($this->record->isActive());
1491  $check->setValue("1");
1492  $this->form->addItem($check);
1493 
1495  $check->setDisabled(true);
1496  }
1497 
1498  if (!$this->obj_type) {
1499  // scope
1500  $scope = new ilCheckboxInputGUI($this->lng->txt('md_adv_scope'), 'scope');
1501  $scope->setInfo($this->lng->txt('md_adv_scope_info'));
1502  $scope->setChecked($this->record->enabledScope());
1503  $scope->setValue("1");
1504  $this->form->addItem($scope);
1505  $subitems = new ilRepositorySelector2InputGUI(
1506  $this->lng->txt('md_adv_scope_objects'),
1507  "scope_containers",
1508  true,
1509  $this->form
1510  );
1511  $subitems->setValue($this->record->getScopeRefIds());
1512  $exp = $subitems->getExplorerGUI();
1513 
1514  $definition = $GLOBALS['DIC']['objDefinition'];
1515  $white_list = [];
1516  foreach ($definition->getAllRepositoryTypes() as $type) {
1517  if ($definition->isContainer($type)) {
1518  $white_list[] = $type;
1519  }
1520  }
1521 
1522  $exp->setTypeWhiteList($white_list);
1523  $exp->setSkipRootNode(false);
1524  $exp->setRootId(ROOT_FOLDER_ID);
1525  $scope->addSubItem($subitems);
1526  }
1527 
1528  if (!$this->obj_type) {
1529  $section = new ilFormSectionHeaderGUI();
1530  $section->setTitle($this->lng->txt('md_obj_types'));
1531  $this->form->addItem($section);
1532 
1533  // see ilAdvancedMDRecordTableGUI::fillRow()
1534  $options = array(
1535  0 => $this->lng->txt("meta_obj_type_inactive"),
1536  1 => $this->lng->txt("meta_obj_type_mandatory"),
1537  2 => $this->lng->txt("meta_obj_type_optional")
1538  );
1539 
1540  foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type) {
1541  $t = $type["obj_type"] . ":" . $type["sub_type"];
1542  $this->lng->loadLanguageModule($type["obj_type"]);
1543 
1544  /*
1545  * BT 35914: workaround for hiding portfolio pages in portfolios,
1546  * since they only get data from portfolio templates
1547  */
1548  $hidden = false;
1549  if ($type["obj_type"] == "prtf" && $type["sub_type"] == "pfpg") {
1550  $hidden = true;
1551  }
1552  // EmployeeTalks get their md from templates
1553  if ($type["obj_type"] == "tals" && $type["sub_type"] == "etal") {
1554  $hidden = true;
1555  }
1556 
1557 
1558  $type_options = $options;
1559  switch ($type["obj_type"]) {
1560  case "orgu":
1561  // currently only optional records for org unit (types)
1562  unset($type_options[1]);
1563  break;
1564  case "talt":
1565  // currently only optional records for talk templates (types)
1566  unset($type_options[1]);
1567  break;
1568  case "rcrs":
1569  // optional makes no sense for ecs-courses
1570  unset($type_options[2]);
1571  break;
1572  }
1573 
1574  $value = 0;
1575  if ($a_mode == "edit") {
1576  foreach ($this->record->getAssignedObjectTypes() as $item) {
1577  if ($item["obj_type"] == $type["obj_type"] &&
1578  $item["sub_type"] == $type["sub_type"]) {
1579  $value = $item["optional"]
1580  ? 2
1581  : 1;
1582  }
1583  }
1584  }
1585 
1586  $sel_name = 'obj_types__' . $t;
1587 
1588  if ($hidden) {
1589  $hidden = new ilHiddenInputGUI($sel_name);
1590  $hidden->setValue((string) $value);
1591  $this->form->addItem($hidden);
1592  continue;
1593  }
1594 
1595  $check = new ilSelectInputGUI($type['text'], $sel_name);
1596  //$check = new ilSelectInputGUI($type["text"], 'obj_types[' . $t . ']');
1597  $check->setOptions($type_options);
1598  $check->setValue($value);
1599  $this->form->addItem($check);
1600 
1602  $check->setDisabled(true);
1603  }
1604  }
1605  }
1606 
1607  switch ($a_mode) {
1608  case 'create':
1609  $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1610  $this->form->addCommandButton('saveRecord', $this->lng->txt('add'));
1611  $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1612  break;
1613 
1614  case 'edit':
1615  $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1616  $this->form->addCommandButton('updateRecord', $this->lng->txt('save'));
1617  $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1618  }
1619  return $this->form;
1620  }
$scope
Definition: ltiregstart.php:50
This class represents a selection list property in a property form.
const ROOT_FOLDER_ID
Definition: constants.php:32
static _getAssignableObjectTypes(bool $a_include_text=false)
Get assignable object type public.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$GLOBALS["DIC"]
Definition: wac.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
form( $class_path, string $cmd, string $submit_caption="")
This class represents a text area property in a property form.
$check
Definition: buildRTE.php:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormSubstitutions()

ilAdvancedMDSettingsGUI::initFormSubstitutions ( )
protected

init form table 'substitutions' protected

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

References $check, $DIC, $form, $obj_type, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDRecord\_lookupTitle(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDFieldDefinition\getInstancesByObjType(), getPermissions(), getSubstitutionFieldPermissions(), and ILIAS\Repository\lng().

Referenced by showPresentation(), and updateSubstitutions().

1842  {
1843  global $DIC;
1844 
1845  $ilAccess = $DIC['ilAccess'];
1846 
1847  if (!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType()) {
1848  return null;
1849  }
1850 
1851  $this->form = new ilPropertyFormGUI();
1852  $this->form->setFormAction($this->ctrl->getFormAction($this));
1853  #$this->form->setTableWidth('100%');
1854 
1855  // substitution
1856  foreach ($visible_records as $obj_type => $records) {
1857  $perm = null;
1858 
1859  if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
1860  $perm = $this->getPermissions()->hasPermissions(
1862  (string) $obj_type,
1863  array(
1865  ,
1867  ,
1869  )
1870  );
1871  }
1872 
1874 
1875  // Show section
1876  $section = new ilFormSectionHeaderGUI();
1877  $section->setTitle($this->lng->txt('objs_' . $obj_type));
1878  $this->form->addItem($section);
1879 
1880  $check = new ilCheckboxInputGUI($this->lng->txt('description'), 'enabled_desc_' . $obj_type);
1881  $check->setValue("1");
1882  $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1883  $check->setChecked($sub->isDescriptionEnabled());
1884  $this->form->addItem($check);
1885 
1887  $check->setDisabled(true);
1888  }
1889 
1890  $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'), 'enabled_field_names_' . $obj_type);
1891  $check->setValue("1");
1892  $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1893  $check->setChecked($sub->enabledFieldNames());
1894  $this->form->addItem($check);
1895 
1897  $check->setDisabled(true);
1898  }
1899 
1900  $perm_pos = null;
1901  if ($perm) {
1903  }
1904 
1905  $definitions = ilAdvancedMDFieldDefinition::getInstancesByObjType($obj_type);
1906  $definitions = $sub->sortDefinitions($definitions);
1907 
1908  $counter = 1;
1909  foreach ($definitions as $def) {
1910  $definition_id = $def->getFieldId();
1911 
1912  $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id);
1913 
1914  $title = ilAdvancedMDRecord::_lookupTitle((int) $def->getRecordId());
1915  $title = $def->getTitle() . ' (' . $title . ')';
1916 
1917  $check = new ilCheckboxInputGUI($title, 'show_' . $obj_type . '_' . $definition_id);
1918  $check->setValue("1");
1919  $check->setOptionTitle($this->lng->txt('md_adv_show'));
1920  $check->setChecked($sub->isSubstituted($definition_id));
1921 
1922  if ($perm && !$perm["show"]) {
1923  $check->setDisabled(true);
1924  }
1925 
1926  $pos = new ilNumberInputGUI(
1927  $this->lng->txt('position'),
1928  'position_' . $obj_type . '_' . $definition_id
1929  );
1930  $pos->setSize(3);
1931  $pos->setMaxLength(4);
1932  $pos->allowDecimals(true);
1933  $pos->setValue(sprintf('%.1f', $counter++));
1934  $check->addSubItem($pos);
1935 
1936  if ($perm && !$perm_pos) {
1937  $pos->setDisabled(true);
1938  }
1939 
1940  $bold = new ilCheckboxInputGUI(
1941  $this->lng->txt('bold'),
1942  'bold_' . $obj_type . '_' . $definition_id
1943  );
1944  $bold->setValue("1");
1945  $bold->setChecked($sub->isBold($definition_id));
1946  $check->addSubItem($bold);
1947 
1948  if ($perm && !$perm["bold"]) {
1949  $bold->setDisabled(true);
1950  }
1951 
1952  $bold = new ilCheckboxInputGUI(
1953  $this->lng->txt('newline'),
1954  'newline_' . $obj_type . '_' . $definition_id
1955  );
1956  $bold->setValue("1");
1957  $bold->setChecked($sub->hasNewline($definition_id));
1958  $check->addSubItem($bold);
1959 
1960  if ($perm && !$perm["newline"]) {
1961  $bold->setDisabled(true);
1962  }
1963 
1964  $this->form->addItem($check);
1965  }
1966  }
1967  $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1968 
1969  if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1970  $this->form->addCommandButton('updateSubstitutions', $this->lng->txt('save'));
1971  }
1972  return $this->form;
1973  }
getSubstitutionFieldPermissions(string $a_obj_type, int $a_field_id)
static getInstancesByObjType($a_obj_type, $a_active_only=true)
$DIC
Definition: xapitoken.php:62
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types!
form( $class_path, string $cmd, string $submit_caption="")
static _lookupTitle(int $a_record_id)
$check
Definition: buildRTE.php:81
static _getInstanceByObjectType(string $a_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initImportForm()

ilAdvancedMDSettingsGUI::initImportForm ( )
protected

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

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilFileInputGUI\setSuffixes().

Referenced by importRecord(), and importRecords().

1149  : void
1150  {
1151  if (is_object($this->import_form)) {
1152  return;
1153  }
1154 
1155  $this->import_form = new ilPropertyFormGUI();
1156  $this->import_form->setMultipart(true);
1157  $this->import_form->setFormAction($this->ctrl->getFormAction($this));
1158 
1159  // add file property
1160  $file = new ilFileInputGUI($this->lng->txt('file'), 'file');
1161  $file->setSuffixes(array('xml'));
1162  $file->setRequired(true);
1163  $this->import_form->addItem($file);
1164 
1165  $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
1166  $this->import_form->addCommandButton('importRecord', $this->lng->txt('import'));
1167  $this->import_form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1168  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSuffixes(array $a_suffixes)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initLanguage()

ilAdvancedMDSettingsGUI::initLanguage ( int  $record_id)
protected

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

References ilAdvancedMDRecordTranslations\getInstanceByRecordId().

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

2302  : void
2303  {
2304  $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($record_id);
2305  // read active language
2306  $default = '';
2307  foreach ($translations->getTranslations() as $translation) {
2308  if ($translation->getLangKey() == $translations->getDefaultLanguage()) {
2309  $default = $translation->getLangKey();
2310  }
2311  }
2312  $active = $this->request->getQueryParams()['mdlang'] ?? $default;
2313  $this->active_language = $active;
2314  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initRecordObject()

ilAdvancedMDSettingsGUI::initRecordObject ( )
protected
Todo:
get rid of $this->obj_id switch

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

References $record, ilAdvancedMDRecord\_getInstanceByRecordId(), ILIAS\Repository\ctrl(), and getRecordIdFromQuery().

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

2062  {
2063  if (!$this->record instanceof ilAdvancedMDRecord) {
2064  $record_id = $this->getRecordIdFromQuery();
2065  $this->record = ilAdvancedMDRecord::_getInstanceByRecordId((int) $record_id);
2066  $this->ctrl->saveParameter($this, 'record_id');
2067 
2068  // bind to parent object (aka local adv md)
2069  if (!$record_id && $this->obj_id) {
2070  $this->record->setParentObject($this->obj_id);
2071  }
2072  }
2073  return $this->record;
2074  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadRecordFormData()

ilAdvancedMDSettingsGUI::loadRecordFormData ( ilPropertyFormGUI  $form)
protected

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

References $active_language, $record, $scope, $scopes, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilPropertyFormGUI\getInput(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), getPermissions(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

Referenced by saveRecord(), and updateRecord().

1976  {
1977  $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1978 
1979  $perm = $this->getPermissions()->hasPermissions(
1981  (string) $this->record->getRecordId(),
1982  array(
1985  )
1986  ,
1989  )
1990  ,
1993  )
1994  ,
1996  )
1997  );
1998 
2000  $this->record->setActive((bool) $form->getInput('active'));
2001  }
2003  if (
2004  $translations->getDefaultTranslation() == null ||
2005  $translations->getDefaultTranslation()->getLangKey() == $this->active_language
2006  ) {
2007  $this->record->setTitle((string) $form->getInput('title'));
2008  }
2009  }
2011  if (
2012  $translations->getDefaultTranslation() == null ||
2013  $translations->getDefaultTranslation()->getLangKey() == $this->active_language) {
2014  $this->record->setDescription($form->getInput('desc'));
2015  }
2016  }
2017 
2018  if (!$this->obj_type) {
2020  $obj_types = [];
2021  foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type) {
2022  $t = $type["obj_type"] . ":" . $type["sub_type"];
2023  $value = $form->getInput('obj_types__' . $t);
2024  if (!$value) {
2025  continue;
2026  }
2027  $obj_types[] = [
2028  'obj_type' => $type['obj_type'],
2029  'sub_type' => $type['sub_type'],
2030  'optional' => ($value > 1)
2031  ];
2032  }
2033  $this->record->setAssignedObjectTypes($obj_types);
2034  }
2035  }
2036 
2037  $scopes = $form->getInput('scope');
2038  $scopes_selection = $form->getInput('scope_containers_sel');
2039  if ($scopes && is_array($scopes_selection)) {
2040  $this->record->enableScope(true);
2041  $this->record->setScopes(
2042  array_map(
2043  function (string $scope_ref_id) {
2045  $scope->setRefId((int) $scope_ref_id);
2046  return $scope;
2047  },
2048  $scopes_selection
2049  )
2050  );
2051  } else {
2052  $this->record->enableScope(false);
2053  $this->record->setScopes([]);
2054  }
2055  return $this->record;
2056  }
Scope restrictions for advanced md records.
$scope
Definition: ltiregstart.php:50
$scopes
Definition: ltitoken.php:97
static _getAssignableObjectTypes(bool $a_include_text=false)
Get assignable object type public.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveField()

ilAdvancedMDSettingsGUI::saveField ( )

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

References $active_language, $form, ilPropertyFormGUI\checkInput(), createField(), ILIAS\Repository\ctrl(), editFields(), getFieldTypeFromQuery(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getPermissions(), getRecordIdFromQuery(), initFieldForm(), initLanguage(), initRecordObject(), ILIAS\Repository\lng(), and ilPropertyFormGUI\setValuesByPost().

1362  : void
1363  {
1364  $record_id = $this->getRecordIdFromQuery();
1365  $ftype = $this->getFieldTypeFromQuery();
1366 
1367  if (!$record_id || !$ftype) {
1368  $this->editFields();
1369  return;
1370  }
1371 
1372  $this->initRecordObject();
1373  $this->initLanguage($record_id);
1374  $this->ctrl->saveParameter($this, 'ftype');
1375 
1376  $field_definition = ilAdvancedMDFieldDefinition::getInstance(
1377  null,
1378  $ftype
1379  );
1380  $field_definition->setRecordId($record_id);
1381  $form = $this->initFieldForm($field_definition);
1382 
1383  if ($form->checkInput()) {
1384  $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1385  $field_definition->save();
1386 
1387  $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($record_id);
1388  $translations->read();
1389  $translations->updateFromForm($field_definition->getFieldId(), $this->active_language, $form);
1390 
1391  $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_settings'), true);
1392  $this->ctrl->redirect($this, "editFields");
1393  }
1394 
1396  $this->createField($form);
1397  }
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
createField(ilPropertyFormGUI $a_form=null)
Show field type selection public.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
+ Here is the call graph for this function:

◆ saveRecord()

ilAdvancedMDSettingsGUI::saveRecord ( )

Save record public.

Parameters

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

References $obj_type, $sub_type, createRecord(), ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDRecord\getDefaultLanguage(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ilAdvancedMDRecord\getRecordId(), initForm(), initRecordObject(), ILIAS\Repository\lng(), loadRecordFormData(), ilAdvancedMDRecord\save(), and ilAdvancedMDRecord\setDefaultLanguage().

1216  : void
1217  {
1218  $this->initRecordObject();
1219  $form = $this->initForm('create');
1220  if (!$this->form->checkInput()) {
1221  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
1222  $this->createRecord($this->form);
1223  return;
1224  }
1225 
1226  $record = $this->loadRecordFormData($form);
1227  if ($this->obj_type) {
1228  $sub_types = (!is_array($this->sub_type))
1229  ? [$this->sub_type]
1230  : $this->sub_type;
1231  $assigned_object_types = array_map(function ($sub_type) {
1232  return [
1233  "obj_type" => $this->obj_type,
1234  "sub_type" => $sub_type,
1235  "optional" => false
1236  ];
1237  }, $sub_types);
1238  $this->record->setAssignedObjectTypes($assigned_object_types);
1239  }
1240 
1241  $record->setDefaultLanguage($this->lng->getDefaultLanguage());
1242  $record->save();
1243 
1245  $translations->addTranslationEntry($record->getDefaultLanguage(), true);
1246  $translations->updateTranslations(
1248  $this->form->getInput('title'),
1249  $this->form->getInput('desc')
1250  );
1251  $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_added_new_record'), true);
1252  $this->ctrl->redirect($this, 'showRecords');
1253  }
createRecord(ilPropertyFormGUI $form=null)
Show public.
loadRecordFormData(ilPropertyFormGUI $form)
setDefaultLanguage(string $language_code)
form( $class_path, string $cmd, string $submit_caption="")
+ 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 1104 of file class.ilAdvancedMDSettingsGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

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

1104  : void
1105  {
1106  $this->tabs_gui->clearTargets();
1107  $this->tabs_gui->clearSubTabs();
1108 
1109  if ($level == 1) {
1110  $this->tabs_gui->setBackTarget(
1111  $this->lng->txt('md_adv_record_list'),
1112  $this->ctrl->getLinkTarget($this, 'showRecords')
1113  );
1114 
1115  if ($show_settings) {
1116  $this->tabs_gui->addTab(
1117  self::TAB_RECORD_SETTINGS,
1118  $this->lng->txt('settings'),
1119  $this->ctrl->getLinkTarget($this, self::TAB_RECORD_SETTINGS)
1120  );
1121  $this->ctrl->setParameterByClass(
1122  strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1123  'record_id',
1124  $this->record->getRecordId()
1125  );
1126  $this->lng->loadLanguageModule('obj');
1127  $this->tabs_gui->addTab(
1128  self::TAB_TRANSLATION,
1129  $this->lng->txt('obj_multilinguality'),
1130  $this->ctrl->getLinkTargetByClass(
1131  strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1132  ''
1133  )
1134  );
1135  }
1136  }
1137  if ($level == 2) {
1138  $this->tabs_gui->setBack2Target(
1139  $this->lng->txt('md_adv_record_list'),
1140  $this->ctrl->getLinkTarget($this, 'showRecords')
1141  );
1142  $this->tabs_gui->setBackTarget(
1143  $this->lng->txt('md_adv_field_list'),
1144  $this->ctrl->getLinkTarget($this, 'editFields')
1145  );
1146  }
1147  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSubTabs()

ilAdvancedMDSettingsGUI::setSubTabs ( int  $context)
protected

Set sub tabs protected.

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

References ilAdvancedMDRecord\_getAllRecordsByObjectType(), and ILIAS\Repository\ctrl().

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

2080  : void
2081  {
2082  if ($context == self::CONTEXT_OBJECT) {
2083  return;
2084  }
2085 
2086  $this->tabs_gui->clearSubTabs();
2087 
2088  $this->tabs_gui->addSubTabTarget(
2089  "md_adv_record_list",
2090  $this->ctrl->getLinkTarget($this, "showRecords"),
2091  '',
2092  '',
2093  '',
2094  true
2095  );
2096 
2098  $this->tabs_gui->addSubTabTarget(
2099  "md_adv_presentation",
2100  $this->ctrl->getLinkTarget($this, "showPresentation")
2101  );
2102  }
2103 
2104  $this->tabs_gui->addSubTabTarget(
2105  "md_adv_file_list",
2106  $this->ctrl->getLinkTarget($this, "showFiles"),
2107  "showFiles"
2108  );
2109  }
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types!
+ 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 513 of file class.ilAdvancedMDSettingsGUI.php.

References $GLOBALS, ILIAS\Repository\access(), ILIAS\Repository\lng(), and setSubTabs().

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

513  : void
514  {
515  $this->setSubTabs($this->context);
516  $this->tabs_gui->setSubTabActive('md_adv_file_list');
517 
518  $files = new ilAdvancedMDRecordExportFiles(
519  $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
520  );
521  $file_data = $files->readFilesInfo();
522 
523  $table_gui = new ilAdvancedMDRecordExportFilesTableGUI($this, "showFiles");
524  $table_gui->setTitle($this->lng->txt("md_record_export_table"));
525  $table_gui->parseFiles($file_data);
526  $table_gui->addMultiCommand("downloadFile", $this->lng->txt('download'));
527 
528  if ($GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
529  $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
530  }
531  $table_gui->setSelectAllCheckbox("file_id");
532 
533  $this->tpl->setContent($table_gui->getHTML());
534  }
setSubTabs(int $context)
Set sub tabs protected.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$GLOBALS["DIC"]
Definition: wac.php:31
+ 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

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

References ILIAS\Repository\ctrl(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

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

2316  : void
2317  {
2318  $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($record_id);
2319 
2320  if (count($translations->getTranslations()) <= 1) {
2321  return;
2322  }
2323  $actions = [];
2324  foreach ($translations->getTranslations() as $translation) {
2325  $this->ctrl->setParameter($this, 'mdlang', $translation->getLangKey());
2326  $actions[$translation->getLangKey()] = $this->ctrl->getLinkTarget(
2327  $this,
2328  $target
2329  );
2330  }
2331  $this->ctrl->setParameter($this, 'mdlang', $this->active_language);
2332  $view_control = $this->ui_factory->viewControl()->mode(
2333  $actions,
2334  $this->lng->txt('meta_aria_language_selection')
2335  )->withActive($this->active_language);
2336  $this->toolbar->addComponent($view_control);
2337  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showPresentation()

ilAdvancedMDSettingsGUI::showPresentation ( )
protected

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

References ILIAS\Repository\form(), initFormSubstitutions(), setSubTabs(), and showRecords().

351  : void
352  {
353  $this->setSubTabs($this->context);
354  $form = $this->initFormSubstitutions();
355  if ($form instanceof ilPropertyFormGUI) {
356  $this->tabs_gui->setSubTabActive('md_adv_presentation');
357  $this->tpl->setContent($this->form->getHTML());
358  return;
359  }
360  $this->showRecords();
361  }
setSubTabs(int $context)
Set sub tabs protected.
form( $class_path, string $cmd, string $submit_caption="")
initFormSubstitutions()
init form table &#39;substitutions&#39; protected
+ Here is the call graph for this function:

◆ showRecords()

ilAdvancedMDSettingsGUI::showRecords ( )

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

References $DIC, ilObject\_lookupType(), ilAdvancedMDPermissionHelper\ACTION_MD_CREATE_RECORD, ilAdvancedMDPermissionHelper\ACTION_MD_IMPORT_RECORDS, ilAdvancedMDPermissionHelper\CONTEXT_MD, ILIAS\Repository\ctrl(), getParsedRecordObjects(), getPermissions(), ILIAS\Repository\lng(), and setSubTabs().

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

288  : void
289  {
290  global $DIC;
291 
292  $ilToolbar = $DIC['ilToolbar'];
293  $ilAccess = $DIC['ilAccess'];
294 
295  $this->setSubTabs($this->context);
296 
297  $perm = $this->getPermissions()->hasPermissions(
299  (string) $this->ref_id,
300  array(
303  )
304  );
305 
307  $button = $this->ui_factory->button()->standard(
308  $this->lng->txt('add'),
309  $this->ctrl->getLinkTargetByClass(strtolower(self::class), "createRecord")
310  );
311  $ilToolbar->addComponent($button);
312 
314  $ilToolbar->addSeparator();
315  }
316  }
317 
318  if ($perm[ilAdvancedMDPermissionHelper::ACTION_MD_IMPORT_RECORDS]) {
319  $button = $this->ui_factory->button()->standard(
320  $this->lng->txt('import'),
321  $this->ctrl->getLinkTargetByClass(strtolower(self::class), "importRecords")
322  );
323  $ilToolbar->addComponent($button);
324  }
325 
326  $obj_type_context = ($this->obj_id > 0)
327  ? ilObject::_lookupType($this->obj_id)
328  : "";
329  $table_gui = new ilAdvancedMDRecordTableGUI(
330  $this,
331  "showRecords",
332  $this->getPermissions(),
333  $obj_type_context
334  );
335  $table_gui->setTitle($this->lng->txt("md_record_list_table"));
336  $table_gui->setData($this->getParsedRecordObjects());
337 
338  // permissions?
339  //$table_gui->addCommandButton('createRecord',$this->lng->txt('add'));
340  $table_gui->addMultiCommand("exportRecords", $this->lng->txt('export'));
341  $table_gui->setSelectAllCheckbox("record_id");
342 
343  if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
344  $table_gui->addMultiCommand("confirmDeleteRecords", $this->lng->txt("delete"));
345  $table_gui->addCommandButton("updateRecords", $this->lng->txt("save"));
346  }
347 
348  $DIC->ui()->mainTemplate()->setContent($table_gui->getHTML());
349  }
setSubTabs(int $context)
Set sub tabs protected.
$DIC
Definition: xapitoken.php:62
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateComplexOption()

ilAdvancedMDSettingsGUI::updateComplexOption ( )

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

References ilPropertyFormGUI\checkInput(), ILIAS\Repository\ctrl(), getFieldIdFromQuery(), ilAdvancedMDFieldDefinition\getInstance(), getOidFromQuery(), initComplexOptionForm(), and ILIAS\Repository\lng().

2284  : void
2285  {
2286  $field_id = $this->getFieldIdFromQuery();
2287  $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
2288  $oid = $this->getOidFromQuery();
2289 
2290  if ($field_definition->hasComplexOptions()) {
2291  $form = $this->initComplexOptionForm($field_definition);
2292  if ($form->checkInput() &&
2293  $field_definition->updateComplexOption($form, $oid)) {
2294  $field_definition->update();
2295  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2296  }
2297  }
2298 
2299  $this->ctrl->redirect($this, "editField");
2300  }
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
+ Here is the call graph for this function:

◆ updateField()

ilAdvancedMDSettingsGUI::updateField ( )

Update field public.

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

References ilPropertyFormGUI\checkInput(), ILIAS\Repository\ctrl(), editField(), editFields(), getFieldIdFromQuery(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getPermissions(), getRecordIdFromQuery(), initFieldForm(), initLanguage(), initRecordObject(), ILIAS\Repository\lng(), ilPropertyFormGUI\setValuesByPost(), and showLanguageSwitch().

1290  : void
1291  {
1292  $record_id = $this->getRecordIdFromQuery();
1293  $field_id = $this->getFieldIdFromQuery();
1294  $this->ctrl->saveParameter($this, 'record_id');
1295  $this->ctrl->saveParameter($this, 'field_id');
1296 
1297  if (!$record_id || !$field_id) {
1298  $this->editFields();
1299  return;
1300  }
1301 
1302  $this->initRecordObject();
1303  $this->initLanguage($record_id);
1304  $this->showLanguageSwitch($record_id, 'editField');
1305 
1306  $confirm = false;
1307  $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1308  $form = $this->initFieldForm($field_definition);
1309  if ($form->checkInput()) {
1310  $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1311  if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1312  $field_definition->update();
1313  $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1314  $translations->updateFromForm($field_id, $this->active_language, $form);
1315 
1316  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1317  $this->ctrl->redirect($this, 'editField');
1318  } else {
1319  $confirm = true;
1320  }
1321  }
1322 
1324 
1325  // fields needs confirmation of updated settings
1326  if ($confirm) {
1327  $this->tpl->setOnScreenMessage('info', $this->lng->txt("md_adv_confirm_definition"));
1328  $field_definition->prepareDefinitionFormConfirmation($form);
1329  }
1330 
1331  $this->editField($form);
1332  }
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
showLanguageSwitch(int $record_id, string $target)
editField(ilPropertyFormGUI $a_form=null)
Edit field public.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
+ Here is the call graph for this function:

◆ updateFields()

ilAdvancedMDSettingsGUI::updateFields ( )

Update fields public.

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

References ilAdvancedMDPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), editFields(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getPermissions(), getPositionsFromPost(), getRecordIdFromQuery(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ilAdvancedMDPermissionHelper\SUBACTION_FIELD_SEARCHABLE.

992  : void
993  {
994  $this->ctrl->saveParameter($this, 'record_id');
995  $positions = $this->getPositionsFromPost();
996  asort($positions, SORT_NUMERIC);
997  $record_id = $this->getRecordIdFromQuery();
998  if (!$record_id) {
999  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
1000  $this->editFields();
1001  return;
1002  }
1003 
1005 
1006  if ($this->getPermissions()->hasPermission(
1008  (string) $record_id,
1010  )) {
1011  $positions_flipped = array_flip(array_keys($positions));
1012  foreach ($fields as $field) {
1013  $field->setPosition((int) $positions_flipped[$field->getFieldId()]);
1014  $field->update();
1015  }
1016  }
1017 
1018  foreach ($fields as $field) {
1019  if ($this->getPermissions()->hasPermission(
1021  (string) $field->getFieldId(),
1024  )) {
1025  $post_searchable = (array) ($this->http->request()->getParsedBody()['searchable'] ?? []);
1026  $field->setSearchable((bool) ($post_searchable[$field->getFieldId()] ?? false));
1027  $field->update();
1028  }
1029  }
1030 
1031  $language = $this->request->getQueryParams()['mdlang'] ?? false;
1032  if ($language) {
1033  $this->ctrl->setParameter($this, 'mdlang', $this->request->getQueryParams()['mdlang']);
1034  }
1035  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1036  $this->ctrl->redirect($this, "editFields");
1037  }
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ updateRecord()

ilAdvancedMDSettingsGUI::updateRecord ( )

Update record public.

Parameters

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

References ILIAS\Repository\ctrl(), editRecord(), ILIAS\Repository\form(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), getRecordIdFromQuery(), initForm(), initLanguage(), initRecordObject(), ILIAS\Repository\lng(), loadRecordFormData(), and showLanguageSwitch().

1044  : void
1045  {
1046  $record_id = $this->getRecordIdFromQuery();
1047  if (!$record_id) {
1048  $this->ctrl->redirect($this, 'showRecords');
1049  }
1050  $this->initRecordObject();
1051  $this->initLanguage($record_id);
1052  $this->showLanguageSwitch($record_id, 'editRecord');
1053 
1054  $form = $this->initForm('edit');
1055  if (!$this->form->checkInput()) {
1056  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
1057  $this->form->setValuesByPost();
1058  $this->editRecord($this->form);
1059  return;
1060  }
1061 
1062  $this->loadRecordFormData($form);
1063  $this->record->update();
1064 
1065  $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1066  $translations->updateTranslations(
1067  $this->active_language,
1068  $this->form->getInput('title'),
1069  $this->form->getInput('desc')
1070  );
1071 
1072  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1073  $this->ctrl->redirect($this, 'editRecord');
1074  }
editRecord(ilPropertyFormGUI $form=null)
loadRecordFormData(ilPropertyFormGUI $form)
showLanguageSwitch(int $record_id, string $target)
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ updateRecords()

ilAdvancedMDSettingsGUI::updateRecords ( )

Save records (assigned object typed) public.

Parameters

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

References $i, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ilAdvancedMDRecord\deleteObjRecSelection(), getParsedRecordObjects(), getPermissions(), getPositionsFromPost(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilAdvancedMDRecord\saveObjRecSelection(), ilUtil\stripSlashes(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

704  : void
705  {
706  // sort positions and renumber
707  $positions = $this->getPositionsFromPost();
708  $records = $this->getParsedRecordObjects();
709 
710  $all_positions = $positions;
711  foreach ($records as $record) {
712  if (!array_key_exists($record['id'], $all_positions)) {
713  $all_positions[$record['id']] = $record['position'];
714  }
715  }
716  asort($all_positions, SORT_NUMERIC);
717 
718  $sorted_positions = [];
719  $i = 1;
720  foreach ($all_positions as $record_id => $pos) {
721  $sorted_positions[(int) $record_id] = $i++;
722  }
723  $selected_global = [];
724 
725  $post_active = (array) ($this->http->request()->getParsedBody()['active'] ?? []);
726  if ($this->obj_id > 0) {
728  }
729  foreach ($records as $item) {
730  // BT 35518: this is kind of a hacky solution to skip items not in the table due to pagination
731  $is_on_page = array_key_exists($item['id'], $positions);
732 
733  $perm = $this->getPermissions()->hasPermissions(
735  (string) $item['id'],
736  [
738  [
741  ]
742  ]
743  );
744 
745  $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
746 
747  if (
749  $is_on_page
750  ) {
751  $obj_types = array();
752  $post_object_types = (array) ($this->http->request()->getParsedBody()['obj_types'] ?? []);
753  if (is_array($post_object_types[$record_obj->getRecordId()] ?? false)) {
754  foreach ($post_object_types[$record_obj->getRecordId()] as $type => $status) {
755  if ($status) {
756  $type = explode(":", $type);
757  $obj_types[] = array(
758  "obj_type" => ilUtil::stripSlashes($type[0]),
759  "sub_type" => ilUtil::stripSlashes($type[1]),
760  "optional" => ((int) $status == 2)
761  );
762  }
763  }
764  }
765 
766  // global records in global administration and local records in local administration
767  if (!$item['readonly']) {
768  // table adv_md_record_objs
769  $record_obj->setAssignedObjectTypes($obj_types);
770  } else { // global records in local administration
771  foreach ($obj_types as $t) {
772  // table adv_md_obj_rec_select
773  ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $t["sub_type"], [$record_obj->getRecordId()], false);
774  }
775  }
776  }
777 
778  if ($this->context == self::CONTEXT_ADMINISTRATION) {
779  if (
781  $is_on_page
782  ) {
783  $record_obj->setActive(isset($post_active[$record_obj->getRecordId()]));
784  }
785 
786  $record_obj->setGlobalPosition((int) $sorted_positions[$record_obj->getRecordId()]);
787  $record_obj->update();
788  } elseif (
790  $is_on_page
791  ) {
792  // global, optional record
793  if ($item['readonly'] &&
794  $item['optional'] &&
795  ($post_active[$item['id']] ?? false)) {
796  $selected_global[] = $item['id'];
797  } elseif ($item['local']) {
798  $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
799  $record_obj->setActive((bool) ($post_active[$item['id']] ?? false));
800  $record_obj->update();
801  }
802  }
803 
804  // save local sorting
805  if ($this->context == self::CONTEXT_OBJECT) {
806  $local_position = new \ilAdvancedMDRecordObjectOrdering(
807  $item['id'],
808  $this->obj_id,
809  $this->db
810  );
811  $local_position->setPosition((int) $sorted_positions[$item['id']]);
812  $local_position->save();
813  }
814  }
815 
816  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
817  $this->ctrl->redirect($this, "showRecords");
818  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
static _getInstanceByRecordId(int $a_record_id)
static http()
Fetches the global http state from ILIAS.
$i
Definition: saml1-acs.php:28
static deleteObjRecSelection(int $a_obj_id)
Delete repository object record selection.
+ Here is the call graph for this function:

◆ updateSubstitutions()

ilAdvancedMDSettingsGUI::updateSubstitutions ( )

Update substitution public.

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

References $DIC, ilAdvancedMDRecord\_getActivatedObjTypes(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilPropertyFormGUI\checkInput(), ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ILIAS\Repository\ctrl(), ilPropertyFormGUI\getInput(), ilAdvancedMDFieldDefinition\getInstancesByObjType(), getPermissions(), getSubstitutionFieldPermissions(), initFormSubstitutions(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ilArrayUtil\sortArray().

367  : void
368  {
369  global $DIC;
370 
371  $ilAccess = $DIC['ilAccess'];
372 
373  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
374  $this->ctrl->redirect($this, "showPresentation");
375  }
376 
377  $form = $this->initFormSubstitutions();
378  if (!$form instanceof ilPropertyFormGUI) {
379  $this->ctrl->redirect($this, 'showPresentation');
380  return;
381  }
382  if (!$form->checkInput()) {
383  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), true);
384  $this->ctrl->redirect($this, "showPresentation");
385  }
386 
388  $perm = null;
389 
390  if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
391  $perm = $this->getPermissions()->hasPermissions(
393  "0",
394  array(
396  ,
398  ,
400  )
401  );
402  }
405  $sub->enableDescription((bool) $form->getInput('enabled_desc_' . $obj_type));
406  }
407 
409  $sub->enableFieldNames((bool) $form->getInput('enabled_field_names_' . $obj_type));
410  }
411 
412  $definitions = ilAdvancedMDFieldDefinition::getInstancesByObjType($obj_type);
413  $definitions = $sub->sortDefinitions($definitions);
414 
415  // gather existing data
416  $counter = 1;
417  $old_sub = array();
418  foreach ($definitions as $def) {
419  $field_id = $def->getFieldId();
420  $old_sub[$field_id] = array(
421  "active" => $sub->isSubstituted($field_id),
422  "pos" => $counter++,
423  "bold" => $sub->isBold($field_id),
424  "newline" => $sub->hasNewline($field_id)
425  );
426  }
427 
428  $sub->resetSubstitutions();
429 
430  $new_sub = [];
431  foreach ($definitions as $def) {
432  $field_id = $def->getFieldId();
433  $old = $old_sub[$field_id];
434 
435  $perm_def = $this->getSubstitutionFieldPermissions($obj_type, $field_id);
436  if ($perm_def["show"] ?? false) {
437  $active = (bool) $form->getInput('show_' . $obj_type . '_' . $field_id);
438  } else {
439  $active = $old["active"] ?? false;
440  }
441  if ($active) {
442  $new_sub[$field_id] = $old;
444  $new_sub[$field_id]['pos'] = (int) $form->getInput('position_' . $obj_type . '_' . $field_id);
445  }
446  if ($perm_def["bold"] ?? false) {
447  $new_sub[$field_id]['bold'] = (bool) $form->getInput('bold_' . $obj_type . '_' . $field_id);
448  }
449  if ($perm_def["newline"] ?? false) {
450  $new_sub[$field_id]['newline'] = (bool) $form->getInput('newline_' . $obj_type . '_' . $field_id);
451  }
452  }
453  }
454 
455  if (sizeof($new_sub)) {
456  $new_sub = ilArrayUtil::sortArray($new_sub, "pos", "asc", true, true);
457  foreach ($new_sub as $field_id => $field) {
458  $sub->appendSubstitution($field_id, (bool) $field["bold"], (bool) $field["newline"]);
459  }
460  }
461  $sub->update();
462  }
463 
464  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
465  $this->ctrl->redirect($this, "showPresentation");
466  }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getSubstitutionFieldPermissions(string $a_obj_type, int $a_field_id)
static getInstancesByObjType($a_obj_type, $a_active_only=true)
$DIC
Definition: xapitoken.php:62
initFormSubstitutions()
init form table &#39;substitutions&#39; protected
static _getActivatedObjTypes()
get activated obj types
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _getInstanceByObjectType(string $a_type)
+ Here is the call graph for this function:

Field Documentation

◆ $active_language

string ilAdvancedMDSettingsGUI::$active_language = ''
private

◆ $context

ilAdvancedMDSettingsGUI::$context = null
private

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

◆ $ctrl

ilCtrl ilAdvancedMDSettingsGUI::$ctrl
protected

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

◆ $db

ilDBInterface ilAdvancedMDSettingsGUI::$db
protected

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

◆ $form

ilPropertyFormGUI ilAdvancedMDSettingsGUI::$form = null
protected

◆ $http

GlobalHttpState ilAdvancedMDSettingsGUI::$http
protected

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

◆ $import_form

ilPropertyFormGUI ilAdvancedMDSettingsGUI::$import_form = null
protected

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

◆ $lng

ilLanguage ilAdvancedMDSettingsGUI::$lng
protected

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

◆ $logger

ilLogger ilAdvancedMDSettingsGUI::$logger
protected

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

◆ $obj_id

int ilAdvancedMDSettingsGUI::$obj_id
protected

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

◆ $obj_type

string ilAdvancedMDSettingsGUI::$obj_type = null
protected

◆ $permissions

ilAdvancedMDPermissionHelper ilAdvancedMDSettingsGUI::$permissions
protected

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

Referenced by getPermissions().

◆ $record

ilAdvancedMDRecord ilAdvancedMDSettingsGUI::$record = null
protected

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

Referenced by initRecordObject(), and loadRecordFormData().

◆ $ref_id

int ilAdvancedMDSettingsGUI::$ref_id
protected

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

Referenced by __construct(), and initContextParameters().

◆ $refinery

RefineryFactory ilAdvancedMDSettingsGUI::$refinery
protected

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

◆ $request

RequestInterface ilAdvancedMDSettingsGUI::$request
protected

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

◆ $sub_type

ilAdvancedMDSettingsGUI::$sub_type = null
protected

◆ $tabs_gui

ilTabsGUI ilAdvancedMDSettingsGUI::$tabs_gui
protected

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

◆ $toolbar

ilToolbarGUI ilAdvancedMDSettingsGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilAdvancedMDSettingsGUI::$tpl
protected

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

◆ $ui_factory

UIFactory ilAdvancedMDSettingsGUI::$ui_factory
protected

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

◆ $ui_renderer

Renderer ilAdvancedMDSettingsGUI::$ui_renderer
protected

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

◆ CONTEXT_ADMINISTRATION

const ilAdvancedMDSettingsGUI::CONTEXT_ADMINISTRATION = 1

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

Referenced by ilObjMDSettingsGUI\executeCommand().

◆ CONTEXT_OBJECT

const ilAdvancedMDSettingsGUI::CONTEXT_OBJECT = 2

◆ TAB_RECORD_SETTINGS

const ilAdvancedMDSettingsGUI::TAB_RECORD_SETTINGS = 'editRecord'
protected

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

◆ TAB_TRANSLATION

const ilAdvancedMDSettingsGUI::TAB_TRANSLATION = 'translations'
protected

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


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