ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilOrgUnitGlobalSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
15
19 protected $ctrl;
23 protected $lng;
27 protected $tpl;
28
29
35 public function __construct()
36 {
37 global $DIC;
38
39 $this->ctrl = $DIC->ctrl();
40 $this->lng = $DIC->language();
41 $this->lng->loadLanguageModule('orgu');
42 $this->tpl = $DIC->ui()->mainTemplate();
43
44 if (!ilObjOrgUnitAccess::_checkAccessSettings((int) $_GET['ref_id'])) {
45 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
46 $this->ctrl->redirectByClass(ilObjOrgUnitGUI::class);
47 }
48 }
49
50
54 public function executeCommand()
55 {
56 $cmd = $this->ctrl->getCmd('settings');
57 $next_class = $this->ctrl->getNextClass($this);
58
59 switch ($next_class) {
60 default:
61 $this->$cmd();
62 break;
63 }
64 }
65
66
72 protected function settings(ilPropertyFormGUI $form = null)
73 {
74 if (!$form instanceof ilPropertyFormGUI) {
75 $form = $this->initSettingsForm();
76 }
77 $this->tpl->setContent($form->getHTML());
78 }
79
80
84 protected function initSettingsForm()
85 {
86 global $DIC;
87
88 $form = new ilPropertyFormGUI();
89 $form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
90
91 // My Staff
93 $section->setTitle($this->lng->txt('orgu_enable_my_staff'));
94 $form->addItem($section);
95
96 $item = new ilCheckboxInputGUI($this->lng->txt("orgu_enable_my_staff"), "enable_my_staff");
97 $item->setInfo($this->lng->txt("orgu_enable_my_staff_info"));
98 $item->setValue("1");
99 $item->setChecked(($DIC->settings()->get("enable_my_staff") ? true : false));
100 $form->addItem($item);
101
102 // Positions in Modules
104 $section->setTitle($this->lng->txt('orgu_global_set_positions'));
105 $form->addItem($section);
106
107 $objDefinition = $DIC['objDefinition'];
108 $available_types = $objDefinition->getOrgUnitPermissionTypes();
109 foreach ($available_types as $object_type) {
110 $setting = new ilOrgUnitObjectTypePositionSetting($object_type);
111 $is_multi = false;
112
113 if ($objDefinition->isPlugin($object_type)) {
114 $label = ilObjectPlugin::lookupTxtById($object_type, 'objs_' . $object_type);
115 } else {
116 $is_multi = !$objDefinition->isSystemObject($object_type);
117 $lang_prefix = $is_multi ? 'objs_' : 'obj_';
118 $label = $this->lng->txt($lang_prefix . $object_type);
119 }
120
122 $this->lng->txt('orgu_global_set_positions_type_active') . ' ' . $label,
123 $object_type . '_active'
124 );
125 $type->setValue(1);
126 $type->setChecked($setting->isActive());
127 if ($is_multi) {
128 $scope = new ilRadioGroupInputGUI($this->lng->txt('orgu_global_set_type_changeable'), $object_type . '_changeable');
129 $scope->setValue((int) $setting->isChangeableForObject());
130
131 $scope_object = new ilRadioOption(
132 $this->lng->txt('orgu_global_set_type_changeable_object'),
133 1
134 );
135 $default = new ilCheckboxInputGUI($this->lng->txt('orgu_global_set_type_default'), $object_type . '_default');
136 $default->setInfo($this->lng->txt('orgu_global_set_type_default_info'));
138 $default->setChecked($setting->getActivationDefault());
139
140 $scope_object->addSubItem($default);
141 $scope->addOption($scope_object);
142
143 $scope_global = new ilRadioOption(
144 $this->lng->txt('orgu_global_set_type_changeable_no'),
145 0
146 );
147 $scope->addOption($scope_global);
148
149 $type->addSubItem($scope);
150 }
151 $form->addItem($type);
152 }
153 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
154
155 return $form;
156 }
157
158
159 protected function saveSettings()
160 {
164 global $DIC;
165 $objDefinition = $DIC['objDefinition'];
166 $form = $this->initSettingsForm();
167 if ($form->checkInput()) {
168 // Orgu Permissions / Positions in Modules
169 $available_types = $objDefinition->getOrgUnitPermissionTypes();
170 foreach ($available_types as $object_type) {
171 $obj_setting = new ilOrgUnitObjectTypePositionSetting($object_type);
172 $obj_setting->setActive((bool) $form->getInput($object_type . '_active'));
173 $obj_setting->setActivationDefault((int) $form->getInput($object_type . '_default'));
174 $obj_setting->setChangeableForObject((bool) $form->getInput($object_type
175 . '_changeable'));
176 $obj_setting->update();
177 }
178
179 // MyStaff
180 $DIC->settings()->set("enable_my_staff", (int) ($_POST["enable_my_staff"] ? 1 : 0));
181
182 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
183 $this->ctrl->redirect($this, 'settings');
184 } else {
185 $form->setValuesByPost();
186 ilUtil::sendFailure($this->lng->txt('err_check_input'), false);
187 $this->settings($form);
188 }
189 }
190}
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
static _checkAccessSettings(int $ref_id)
static lookupTxtById($plugin_id, $lang_var)
settings(ilPropertyFormGUI $form=null)
Show settings.
Object settings regarding position permissions.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
$type