ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilOrgUnitGlobalSettingsGUI Class Reference

Global orgunit settings GUI. More...

+ Collaboration diagram for ilOrgUnitGlobalSettingsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Protected Member Functions

 getSettingsForm ()
 

Protected Attributes

const CMD_EDIT = 'edit'
 
const CMD_SAVE = 'save'
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilSetting $settings
 
ilObjectDefinition $object_definition
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
Refinery $refinery
 
ServerRequestInterface $request
 

Private Member Functions

 edit ()
 
 save ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitGlobalSettingsGUI::__construct ( )

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

References $DIC, $ref_id, ilObjOrgUnitAccess\_checkAccessSettings(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

48  {
49  global $DIC;
50  $main_tpl = $DIC->ui()->mainTemplate();
51 
52  $this->ctrl = $DIC->ctrl();
53  $this->lng = $DIC->language();
54  $this->lng->loadLanguageModule('orgu');
55  $this->tpl = $DIC->ui()->mainTemplate();
56  $this->request = $DIC->http()->request();
57  $to_int = $DIC['refinery']->kindlyTo()->int();
58  $ref_id = $DIC['http']->wrapper()->query()->retrieve('ref_id', $to_int);
59 
61  $main_tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
62  $this->ctrl->redirectByClass(ilObjOrgUnitGUI::class);
63  }
64 
65  $this->settings = $DIC->settings();
66  $this->object_definition = $DIC["objDefinition"];
67  $this->ui_factory = $DIC['ui.factory'];
68  $this->ui_renderer = $DIC['ui.renderer'];
69  $this->refinery = $DIC['refinery'];
70  }
static _checkAccessSettings(int $ref_id)
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ edit()

ilOrgUnitGlobalSettingsGUI::edit ( )
private

Definition at line 90 of file class.ilOrgUnitGlobalSettingsGUI.php.

References getSettingsForm().

Referenced by executeCommand().

90  : void
91  {
92  $form = $this->getSettingsForm();
93  $this->tpl->setContent(
94  $this->ui_renderer->render($form)
95  );
96  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilOrgUnitGlobalSettingsGUI::executeCommand ( )

Definition at line 72 of file class.ilOrgUnitGlobalSettingsGUI.php.

References ILIAS\Repository\ctrl(), edit(), and save().

72  : void
73  {
74  $cmd = $this->ctrl->getCmd(self::CMD_EDIT);
75  $next_class = $this->ctrl->getNextClass($this);
76 
77  switch ($next_class) {
78  default:
79  switch ($cmd) {
80  case self::CMD_SAVE:
81  $this->save();
82  break;
83  case self::CMD_EDIT:
84  default:
85  $this->edit();
86  }
87  }
88  }
+ Here is the call graph for this function:

◆ getSettingsForm()

ilOrgUnitGlobalSettingsGUI::getSettingsForm ( )
protected

Definition at line 131 of file class.ilOrgUnitGlobalSettingsGUI.php.

References ilOrgUnitOperationContext\CONTEXT_ETAL, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilObjectPlugin\lookupTxtById(), ILIAS\Repository\refinery(), ILIAS\Repository\settings(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by edit(), and save().

131  : StandardForm
132  {
133  $sections = [];
134  $sections[] = $this->ui_factory->input()->field()->section(
135  [
136  $this->ui_factory->input()->field()->checkbox(
137  $this->lng->txt("orgu_enable_my_staff"),
138  $this->lng->txt("orgu_enable_my_staff_info")
139  )
140  ->withValue($this->settings->get("enable_my_staff") ? true : false)
141  ],
142  $this->lng->txt("orgu_enable_my_staff")
143  );
144 
145  $groups = [];
146  $values = [];
147  $available_types = $this->object_definition->getOrgUnitPermissionTypes();
148  foreach ($available_types as $object_type) {
149 
150  $setting = new ilOrgUnitObjectTypePositionSetting($object_type);
151  $is_multi = false;
152 
153  if ($this->object_definition->isPlugin($object_type)) {
154  $label = ilObjectPlugin::lookupTxtById($object_type, 'objs_' . $object_type);
155  } else {
156  $is_multi = !$this->object_definition->isSystemObject($object_type)
157  && $object_type != ilOrgUnitOperationContext::CONTEXT_ETAL;
158  $lang_prefix = $is_multi ? 'objs_' : 'obj_';
159  $label = $this->lng->txt($lang_prefix . $object_type);
160  }
161 
162  $changeable = [];
163  if ($is_multi) {
164  $changeable[] = $this->ui_factory->input()->field()->switchableGroup(
165  [
166  $this->ui_factory->input()->field()->group(
167  [
168  $this->ui_factory->input()->field()->checkbox(
169  $this->lng->txt('orgu_global_set_type_default'),
170  $this->lng->txt('orgu_global_set_type_default_info'),
171  )
172  ->withValue((bool) $setting->getActivationDefault())
173  ],
174  $this->lng->txt('orgu_global_set_type_changeable_object'),
175  )
176  ,
177  $this->ui_factory->input()->field()->group(
178  [
179 
180  ],
181  $this->lng->txt('orgu_global_set_type_changeable_no'),
182  )
183  ],
184  $this->lng->txt('orgu_global_set_type_changeable')
185  )
186  ->withValue(
187  $setting->isChangeableForObject() ? 0 : 1
188  )
190  $this->refinery->custom()->transformation(
191  function ($v) {
192  $active = true;
193  $changeable = !(bool) array_shift($v);
194  $default = false;
195  if ($changeable) {
196  $default = (bool) current(array_shift($v));
197  }
198  return [$active, $changeable, $default];
199  }
200  )
201  );
202  } else {
203  $changeable[] = $this->ui_factory->input()->field()->hidden()->withValue('true')
204  ->withAdditionalTransformation(
205  $this->refinery->custom()->transformation(
206  fn($v) => [true, false, false]
207  )
208  );
209  }
210 
211  $groups[$object_type] = $this->ui_factory->input()->field()->optionalGroup(
212  $changeable,
213  $this->lng->txt('orgu_global_set_positions_type_active') . ' ' . $label
214  );
215 
216  if (!$setting->isActive()) {
217  $groups[$object_type] = $groups[$object_type]->withValue(null);
218  }
219  }
220 
221  $sections[] = $this->ui_factory->input()->field()->section(
222  $groups,
223  $this->lng->txt("orgu_global_set_positions")
224  );
225 
226  $form_action = $this->ctrl->getFormAction($this, self::CMD_SAVE);
227  return $this->ui_factory->input()->container()->form()->standard(
228  $form_action,
229  $sections
230  );
231  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilOrgUnitGlobalSettingsGUI::save ( )
private

Definition at line 98 of file class.ilOrgUnitGlobalSettingsGUI.php.

References $data, ILIAS\Repository\ctrl(), getSettingsForm(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

Referenced by executeCommand().

98  : void
99  {
100  $form = $this->getSettingsForm()->withRequest($this->request);
101  $data = $form->getData();
102 
103  if (!$data) {
104  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), false);
105  $this->tpl->setContent($this->ui_renderer->render($form));
106  }
107  $enable_my_staff = current(array_shift($data));
108  $obj_settings = array_shift($data);
109 
110  $this->settings->set("enable_my_staff", $enable_my_staff);
111 
112  $available_types = $this->object_definition->getOrgUnitPermissionTypes();
113  foreach ($available_types as $object_type) {
114 
115  $active = false;
116  $changeable = false;
117  $default = false;
118  if (!is_null($obj_settings[$object_type])) {
119  list($active, $changeable, $default) = array_shift($obj_settings[$object_type]);
120  }
121  $obj_setting = new ilOrgUnitObjectTypePositionSetting($object_type);
122  $obj_setting->setActive($active);
123  $obj_setting->setChangeableForObject($changeable);
124  $obj_setting->setActivationDefault((int) $default);
125  $obj_setting->update();
126  }
127  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
128  $this->ctrl->redirect($this, self::CMD_EDIT);
129  }
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:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilOrgUnitGlobalSettingsGUI::$ctrl
protected

Definition at line 36 of file class.ilOrgUnitGlobalSettingsGUI.php.

◆ $lng

ilLanguage ilOrgUnitGlobalSettingsGUI::$lng
protected

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

◆ $object_definition

ilObjectDefinition ilOrgUnitGlobalSettingsGUI::$object_definition
protected

Definition at line 41 of file class.ilOrgUnitGlobalSettingsGUI.php.

◆ $refinery

Refinery ilOrgUnitGlobalSettingsGUI::$refinery
protected

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

◆ $request

ServerRequestInterface ilOrgUnitGlobalSettingsGUI::$request
protected

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

◆ $settings

ilSetting ilOrgUnitGlobalSettingsGUI::$settings
protected

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

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitGlobalSettingsGUI::$tpl
protected

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

◆ $ui_factory

UIFactory ilOrgUnitGlobalSettingsGUI::$ui_factory
protected

Definition at line 42 of file class.ilOrgUnitGlobalSettingsGUI.php.

◆ $ui_renderer

UIRenderer ilOrgUnitGlobalSettingsGUI::$ui_renderer
protected

Definition at line 43 of file class.ilOrgUnitGlobalSettingsGUI.php.

◆ CMD_EDIT

const ilOrgUnitGlobalSettingsGUI::CMD_EDIT = 'edit'
protected

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

◆ CMD_SAVE

const ilOrgUnitGlobalSettingsGUI::CMD_SAVE = 'save'
protected

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


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