ILIAS  release_8 Revision v8.24
class.ilOrgUnitGlobalSettingsGUI.php
Go to the documentation of this file.
1<?php
19/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
20
27{
28 protected ilCtrl $ctrl;
29 protected ilLanguage $lng;
31
32 public function __construct()
33 {
34 global $DIC;
35 $main_tpl = $DIC->ui()->mainTemplate();
36
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 $this->lng->loadLanguageModule('orgu');
40 $this->tpl = $DIC->ui()->mainTemplate();
41
42 if (!ilObjOrgUnitAccess::_checkAccessSettings((int) $_GET['ref_id'])) {
43 $main_tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
44 $this->ctrl->redirectByClass(ilObjOrgUnitGUI::class);
45 }
46 }
47
48 public function executeCommand(): void
49 {
50 $cmd = $this->ctrl->getCmd('settings');
51 $next_class = $this->ctrl->getNextClass($this);
52
53 switch ($next_class) {
54 default:
55 $this->$cmd();
56 break;
57 }
58 }
59
60 private function settings(ilPropertyFormGUI $form = null): void
61 {
62 if (!$form instanceof ilPropertyFormGUI) {
63 $form = $this->initSettingsForm();
64 }
65 $this->tpl->setContent($form->getHTML());
66 }
67
69 {
70 global $DIC;
71
72 $form = new ilPropertyFormGUI();
73 $form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
74
75 // My Staff
76 $section = new ilFormSectionHeaderGUI();
77 $section->setTitle($this->lng->txt('orgu_enable_my_staff'));
78 $form->addItem($section);
79
80 $item = new ilCheckboxInputGUI($this->lng->txt("orgu_enable_my_staff"), "enable_my_staff");
81 $item->setInfo($this->lng->txt("orgu_enable_my_staff_info"));
82 $item->setValue("1");
83 $item->setChecked(($DIC->settings()->get("enable_my_staff") ? true : false));
84 $form->addItem($item);
85
86 // Positions in Modules
87 $section = new ilFormSectionHeaderGUI();
88 $section->setTitle($this->lng->txt('orgu_global_set_positions'));
89 $form->addItem($section);
90
91 $objDefinition = $DIC['objDefinition'];
92 $available_types = $objDefinition->getOrgUnitPermissionTypes();
93 foreach ($available_types as $object_type) {
94 $setting = new ilOrgUnitObjectTypePositionSetting($object_type);
95 $is_multi = false;
96
97 if ($objDefinition->isPlugin($object_type)) {
98 $label = ilObjectPlugin::lookupTxtById($object_type, 'objs_' . $object_type);
99 } else {
100 $is_multi = !$objDefinition->isSystemObject($object_type) && $object_type != ilOrgUnitOperationContext::CONTEXT_ETAL;
101 $lang_prefix = $is_multi ? 'objs_' : 'obj_';
102 $label = $this->lng->txt($lang_prefix . $object_type);
103 }
104
106 $this->lng->txt('orgu_global_set_positions_type_active') . ' ' . $label,
107 $object_type . '_active'
108 );
109 $type->setValue(1);
110 $type->setChecked($setting->isActive());
111 if ($is_multi) {
113 $this->lng->txt('orgu_global_set_type_changeable'),
114 $object_type . '_changeable'
115 );
116 $scope->setValue((int) $setting->isChangeableForObject());
117
118 $scope_object = new ilRadioOption(
119 $this->lng->txt('orgu_global_set_type_changeable_object'),
120 1
121 );
122 $default = new ilCheckboxInputGUI(
123 $this->lng->txt('orgu_global_set_type_default'),
124 $object_type . '_default'
125 );
126 $default->setInfo($this->lng->txt('orgu_global_set_type_default_info'));
128 $default->setChecked($setting->getActivationDefault());
129
130 $scope_object->addSubItem($default);
131 $scope->addOption($scope_object);
132
133 $scope_global = new ilRadioOption(
134 $this->lng->txt('orgu_global_set_type_changeable_no'),
135 0
136 );
137 $scope->addOption($scope_global);
138
139 $type->addSubItem($scope);
140 }
141 $form->addItem($type);
142 }
143 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
144
145 return $form;
146 }
147
148 private function saveSettings(): void
149 {
150 global $DIC;
151 $objDefinition = $DIC['objDefinition'];
152 $form = $this->initSettingsForm();
153 if ($form->checkInput()) {
154 // Orgu Permissions / Positions in Modules
155 $available_types = $objDefinition->getOrgUnitPermissionTypes();
156 foreach ($available_types as $object_type) {
157 $obj_setting = new ilOrgUnitObjectTypePositionSetting($object_type);
158 $obj_setting->setActive((bool) $form->getInput($object_type . '_active'));
159 $obj_setting->setActivationDefault((int) $form->getInput($object_type . '_default'));
160 $obj_setting->setChangeableForObject((bool) $form->getInput($object_type
161 . '_changeable'));
162 $obj_setting->update();
163 }
164
165 // MyStaff
166 $DIC->settings()->set("enable_my_staff", (int) $form->getInput('enable_my_staff'));
167
168 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
169 $this->ctrl->redirect($this, 'settings');
170 } else {
171 $form->setValuesByPost();
172 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), false);
173 $this->settings($form);
174 }
175 }
176}
This class represents a checkbox property in a property form.
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
static _checkAccessSettings(int $ref_id)
static lookupTxtById(string $plugin_id, string $lang_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
settings(ilPropertyFormGUI $form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$scope
Definition: ltiregstart.php:53
$type
$_GET['client_id']
Definition: saml1-acs.php:21