ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 46 of file class.ilOrgUnitGlobalSettingsGUI.php.

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

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

Member Function Documentation

◆ edit()

ilOrgUnitGlobalSettingsGUI::edit ( )
private

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

References getSettingsForm().

Referenced by executeCommand().

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

◆ executeCommand()

ilOrgUnitGlobalSettingsGUI::executeCommand ( )

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

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

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

◆ getSettingsForm()

ilOrgUnitGlobalSettingsGUI::getSettingsForm ( )
protected

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

References ilOrgUnitOperationContext\CONTEXT_ETAL, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilObjectPlugin\lookupTxtById(), null, 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().

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

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

Referenced by executeCommand().

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

◆ $lng

ilLanguage ilOrgUnitGlobalSettingsGUI::$lng
protected

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

◆ $object_definition

ilObjectDefinition ilOrgUnitGlobalSettingsGUI::$object_definition
protected

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

◆ $refinery

Refinery ilOrgUnitGlobalSettingsGUI::$refinery
protected

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

◆ $request

ServerRequestInterface ilOrgUnitGlobalSettingsGUI::$request
protected

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

◆ $settings

ilSetting ilOrgUnitGlobalSettingsGUI::$settings
protected

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

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitGlobalSettingsGUI::$tpl
protected

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

◆ $ui_factory

UIFactory ilOrgUnitGlobalSettingsGUI::$ui_factory
protected

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

◆ $ui_renderer

UIRenderer ilOrgUnitGlobalSettingsGUI::$ui_renderer
protected

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

◆ CMD_EDIT

const ilOrgUnitGlobalSettingsGUI::CMD_EDIT = 'edit'
protected

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

◆ CMD_SAVE

const ilOrgUnitGlobalSettingsGUI::CMD_SAVE = 'save'
protected

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


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