diff --git a/components/ILIAS/Exercise/Settings/class.SettingsGUI.php b/components/ILIAS/Exercise/Settings/class.SettingsGUI.php index 39d6d25f5a9f..3023f4bc03c0 100644 --- a/components/ILIAS/Exercise/Settings/class.SettingsGUI.php +++ b/components/ILIAS/Exercise/Settings/class.SettingsGUI.php @@ -187,7 +187,8 @@ protected function getEditForm(): FormAdapterGUI $form = $form->addAdditionalFeatures( $this->obj_id, [ - \ilObjectServiceSettingsGUI::CUSTOM_METADATA + \ilObjectServiceSettingsGUI::CUSTOM_METADATA, + \ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS, ] ); @@ -241,7 +242,10 @@ protected function save(): void ); $form->saveAdditionalFeatures( $this->obj_id, - [\ilObjectServiceSettingsGUI::CUSTOM_METADATA] + [ + \ilObjectServiceSettingsGUI::CUSTOM_METADATA, + \ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS, + ] ); $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true); diff --git a/components/ILIAS/Repository/Service/Form/class.FormAdapterGUI.php b/components/ILIAS/Repository/Service/Form/class.FormAdapterGUI.php index 872b23019d71..b6ef907d9603 100755 --- a/components/ILIAS/Repository/Service/Form/class.FormAdapterGUI.php +++ b/components/ILIAS/Repository/Service/Form/class.FormAdapterGUI.php @@ -194,13 +194,17 @@ public function checkbox( string $key, string $title, string $description = "", - ?bool $value = null + ?bool $value = null, + ?bool $disabled = null ): self { $this->values[$key] = $value; $field = $this->ui->factory()->input()->field()->checkbox($title, $description); if (!is_null($value)) { $field = $field->withValue($value); } + if (!is_null($disabled)) { + $field = $field->withDisabled($disabled); + } $this->addField($key, $field); return $this; } diff --git a/components/ILIAS/Repository/Service/Form/trait.StdObjProperties.php b/components/ILIAS/Repository/Service/Form/trait.StdObjProperties.php index c6cff1fabb6a..d37fd60c969b 100755 --- a/components/ILIAS/Repository/Service/Form/trait.StdObjProperties.php +++ b/components/ILIAS/Repository/Service/Form/trait.StdObjProperties.php @@ -225,6 +225,20 @@ public function addAdditionalFeatures( ); } + if (\in_array(\ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS, $services, true)) { + $position_settings = \ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType( + \ilObject::_lookupType($obj_id) + ); + if ($position_settings->isActive()) { + $form = $this->checkbox( + \ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS, + $lng->txt('obj_orgunit_positions'), + $lng->txt('obj_orgunit_positions_info'), + \ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($obj_id), + !$position_settings->isChangeableForObject() + ); + } + } return $form; } @@ -243,6 +257,17 @@ public function saveAdditionalFeatures( if (in_array($key, $services)) { \ilContainer::_writeContainerSetting($obj_id, $key, (string) $this->getData($key)); } + // extended user access + if (\in_array(\ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS, $services, true)) { + $position_settings = \ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType( + \ilObject::_lookupType($obj_id) + ); + if ($position_settings->isActive() && $position_settings->isChangeableForObject()) { + $orgu_object_settings = new \ilOrgUnitObjectPositionSetting($obj_id); + $orgu_object_settings->setActive($this->getData(\ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS)); + $orgu_object_settings->update(); + } + } } public function addDidacticTemplates(