ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilOrgUnitTypeGUI Class Reference

Class ilOrgUnitTypeGUI. More...

+ Inheritance diagram for ilOrgUnitTypeGUI:
+ Collaboration diagram for ilOrgUnitTypeGUI:

Public Member Functions

 __construct (private ilObjOrgUnitGUI $parent_gui)
 
 executeCommand ()
 

Protected Member Functions

 getIconForm (string $section_title=null, string $current_identifier=null)
 
 getAvailableAMDRecords ()
 
 getCurrentOrgUnitType ()
 
 getAmdForm (string $action, array $available_records, ilOrgUnitType $type)
 
 create ()
 Create (save) type. More...
 

Protected Attributes

ilLanguage $lng
 
ILIAS UI Component Link Factory $link_factory
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
Refinery $refinery
 
ServerRequestInterface $request
 

Private Member Functions

 checkAccess ()
 
 setSubTabsEdit (string $active_tab_id)
 
 editCustomIcons ()
 
 updateCustomIcons ()
 
 editAMD ()
 
 updateAMD ()
 
 listTypes ()
 Display all types in a table with actions to edit/delete. More...
 
 add ()
 Display form to create a new OrgUnit type. More...
 
 edit ()
 Display form to edit an existing OrgUnit type. More...
 
 update ()
 Update (save) type. More...
 
 delete ()
 Delete a type. More...
 

Private Attributes

ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilTabsGUI $tabs
 
ilAccessHandler $access
 
ilToolbarGUI $toolbar
 
ilSetting $settings
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitTypeGUI::__construct ( private ilObjOrgUnitGUI  $parent_gui)
Parameters
ilObjOrgUnitGUI$parent_gui

Definition at line 51 of file class.ilOrgUnitTypeGUI.php.

References $DIC, ILIAS\Repository\access(), checkAccess(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\settings(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

53  {
54  global $DIC;
55 
56  $this->tpl = $DIC->ui()->mainTemplate();
57  $this->ctrl = $DIC->ctrl();
58  $this->access = $DIC->access();
59  $this->toolbar = $DIC->toolbar();
60  $this->tabs = $DIC->tabs();
61  $this->lng = $DIC->language();
62  $this->settings = $DIC->settings();
63  $this->lng->loadLanguageModule('orgu');
64  $this->ctrl->saveParameter($this, 'type_id');
65  $this->lng->loadLanguageModule('meta');
66  $this->checkAccess();
67  $this->link_factory = $DIC['ui.factory']->link();
68  $this->ui_factory = $DIC['ui.factory'];
69  $this->ui_renderer = $DIC['ui.renderer'];
70  $this->refinery = $DIC['refinery'];
71  $this->request = $DIC->http()->request();
72  $this->lng->loadLanguageModule('meta');
73  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilOrgUnitTypeGUI::add ( )
private

Display form to create a new OrgUnit type.

Definition at line 344 of file class.ilOrgUnitTypeGUI.php.

Referenced by executeCommand().

344  : void
345  {
346  $form = new ilOrgUnitTypeFormGUI($this, new ilOrgUnitType());
347  $this->tpl->setContent($form->getHTML());
348  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ checkAccess()

ilOrgUnitTypeGUI::checkAccess ( )
private

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

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by __construct().

130  : void
131  {
132  if (!$this->access->checkAccess("write", "", $this->parent_gui->object->getRefId())) {
133  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
134  $this->ctrl->redirect($this->parent_gui);
135  }
136  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilOrgUnitTypeGUI::create ( )
protected

Create (save) type.

Definition at line 363 of file class.ilOrgUnitTypeGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by executeCommand().

363  : void
364  {
365  $form = new ilOrgUnitTypeFormGUI($this, new ilOrgUnitType());
366  if ($form->saveObject()) {
367  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_created'), true);
368  $this->ctrl->redirect($this);
369  } else {
370  $this->tpl->setContent($form->getHTML());
371  }
372  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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:

◆ delete()

ilOrgUnitTypeGUI::delete ( )
private

Delete a type.

Definition at line 391 of file class.ilOrgUnitTypeGUI.php.

References $_GET, Vendor\Package\$e, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

391  : void
392  {
393  $type = new ilOrgUnitType((int) $_GET['type_id']);
394  try {
395  $type->delete();
396  $this->tpl->setOnScreenMessage('success', $this->lng->txt('orgu_type_msg_deleted'), true);
397  $this->ctrl->redirect($this);
398  } catch (ilException $e) {
399  $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
400  $this->ctrl->redirect($this);
401  }
402  }
$_GET["client_id"]
Definition: webdav.php:30
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:

◆ edit()

ilOrgUnitTypeGUI::edit ( )
private

Display form to edit an existing OrgUnit type.

Definition at line 353 of file class.ilOrgUnitTypeGUI.php.

References $_GET.

Referenced by executeCommand().

353  : void
354  {
355  $type = new ilOrgUnitType((int) $_GET['type_id']);
356  $form = new ilOrgUnitTypeFormGUI($this, $type);
357  $this->tpl->setContent($form->getHTML());
358  }
$_GET["client_id"]
Definition: webdav.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ editAMD()

ilOrgUnitTypeGUI::editAMD ( )
private

Definition at line 295 of file class.ilOrgUnitTypeGUI.php.

References ILIAS\Repository\ctrl(), getAmdForm(), getAvailableAMDRecords(), and getCurrentOrgUnitType().

Referenced by executeCommand().

295  : void
296  {
297  $form = $this->getAmdForm(
298  $this->ctrl->getFormAction($this, 'updateAMD'),
299  $this->getAvailableAMDRecords(),
300  $this->getCurrentOrgUnitType()
301  );
302  $this->tpl->setContent(
303  $this->ui_renderer->render($form)
304  );
305  }
getAmdForm(string $action, array $available_records, ilOrgUnitType $type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editCustomIcons()

ilOrgUnitTypeGUI::editCustomIcons ( )
private

Definition at line 195 of file class.ilOrgUnitTypeGUI.php.

References $_GET, and getIconForm().

Referenced by executeCommand().

195  : void
196  {
197  $type = new ilOrgUnitType((int) $_GET['type_id']);
198  $form = $this->getIconForm(
199  $type->getTitle() . ': ',
200  $type->getIconIdentifier()
201  );
202  $this->tpl->setContent($this->ui_renderer->render($form));
203  }
$_GET["client_id"]
Definition: webdav.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getIconForm(string $section_title=null, string $current_identifier=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilOrgUnitTypeGUI::executeCommand ( )

Definition at line 75 of file class.ilOrgUnitTypeGUI.php.

References add(), create(), ILIAS\Repository\ctrl(), edit(), editAMD(), editCustomIcons(), listTypes(), setSubTabsEdit(), update(), updateAMD(), and updateCustomIcons().

75  : void
76  {
77  $cmd = $this->ctrl->getCmd();
78  $next_class = $this->ctrl->getNextClass($this);
79  switch ($next_class) {
80  case strtolower(ilOrgUnitTypeUploadHandlerGUI::class):
81  $this->ctrl->forwardCommand(
83  );
84  break;
85 
86  case '':
87  switch ($cmd) {
88  case '':
89  case 'listTypes':
90  $this->listTypes();
91  break;
92  case 'add':
93  $this->add();
94  break;
95  case 'edit':
96  $this->setSubTabsEdit('general');
97  $this->edit();
98  break;
99  case 'editCustomIcons':
100  $this->setSubTabsEdit('custom_icons');
101  $this->editCustomIcons();
102  break;
103  case 'editAMD':
104  $this->setSubTabsEdit('amd');
105  $this->editAMD();
106  break;
107  case 'updateAMD':
108  $this->setSubTabsEdit('amd');
109  $this->updateAMD();
110  break;
111  case 'updateCustomIcons':
112  $this->setSubTabsEdit('custom_icons');
113  $this->updateCustomIcons();
114  break;
115  case 'create':
116  $this->create();
117  break;
118  case 'update':
119  $this->setSubTabsEdit('general');
120  $this->update();
121  break;
122  case 'delete':
123  $this->delete();
124  break;
125  }
126  break;
127  }
128  }
update()
Update (save) type.
edit()
Display form to edit an existing OrgUnit type.
create()
Create (save) type.
setSubTabsEdit(string $active_tab_id)
listTypes()
Display all types in a table with actions to edit/delete.
ilOrgUnitTypeUploadHandlerGUI: ilOrgUnitTypeGUI
add()
Display form to create a new OrgUnit type.
+ Here is the call graph for this function:

◆ getAmdForm()

ilOrgUnitTypeGUI::getAmdForm ( string  $action,
array  $available_records,
ilOrgUnitType  $type 
)
protected

Definition at line 248 of file class.ilOrgUnitTypeGUI.php.

References ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by editAMD(), mock_ilOrgUnitTypeGUI\mockGetAmdForm(), and updateAMD().

252  : StandardForm {
253  $options = [];
254  foreach ($available_records as $record) {
255  $options[$record->getRecordId()] = $record->getTitle();
256  }
257  $selected_ids = $type->getAssignedAdvancedMDRecordIds();
258 
259  $trafo = $this->refinery->custom()->transformation(
260  fn($v) => is_array($v) ? array_shift($v) : []
261  );
262 
263  $field = $this->ui_factory->input()->field()->multiselect(
264  $this->lng->txt('orgu_type_available_amd_sets'),
265  $options
266  )
267  ->withValue($selected_ids);
268 
269  $section = $this->ui_factory->input()->field()->section(
270  [$field],
271  $this->lng->txt('orgu_type_assign_amd_sets')
272  )
274 
275  $store = $this->refinery->custom()->transformation(
276  function (?array $record_ids) use ($type, $selected_ids) {
277  $record_ids = $record_ids ?? [];
278  $record_ids_removed = array_diff($selected_ids, $record_ids);
279  $record_ids_added = array_diff($record_ids, $selected_ids);
280  foreach ($record_ids_added as $record_id) {
281  $type->assignAdvancedMDRecord((int)$record_id);
282  }
283  foreach ($record_ids_removed as $record_id) {
284  $type->deassignAdvancedMdRecord((int)$record_id);
285  }
286  return true;
287  }
288  );
289 
290  return $this->ui_factory->input()->container()->form()->standard($action, [$section])
291  ->withAdditionalTransformation($trafo)
292  ->withAdditionalTransformation($store);
293  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableAMDRecords()

ilOrgUnitTypeGUI::getAvailableAMDRecords ( )
protected
Returns
ilAdvancedMDRecord[]

Definition at line 234 of file class.ilOrgUnitTypeGUI.php.

References ilOrgUnitType\getAvailableAdvancedMDRecords().

Referenced by editAMD(), and updateAMD().

234  : array
235  {
237  }
static getAvailableAdvancedMDRecords()
Get all available AdvancedMDRecord objects for OrgUnits/Types.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentOrgUnitType()

ilOrgUnitTypeGUI::getCurrentOrgUnitType ( )
protected
Returns
ilOrgUnitType

Definition at line 242 of file class.ilOrgUnitTypeGUI.php.

References $_GET.

Referenced by editAMD(), and updateAMD().

242  : ilOrgUnitType
243  {
244  return new ilOrgUnitType((int) $_GET['type_id']);
245  }
$_GET["client_id"]
Definition: webdav.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getIconForm()

ilOrgUnitTypeGUI::getIconForm ( string  $section_title = null,
string  $current_identifier = null 
)
protected

Definition at line 156 of file class.ilOrgUnitTypeGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by editCustomIcons(), and updateCustomIcons().

159  : StandardForm {
160  $handler_gui = new ilOrgUnitTypeUploadHandlerGUI();
161 
162  $input = $this->ui_factory->input()->field()->file(
163  $handler_gui,
164  $this->lng->txt('icon'),
165  $this->lng->txt('file_allowed_suffixes') . ' .svg'
166  );
167 
168  if($current_identifier) {
169  $input = $input->withValue([$current_identifier]);
170  }
171 
172  $section = $this->ui_factory->input()->field()->section(
173  ['iconfile' => $input],
174  $section_title . $this->lng->txt('orgu_type_custom_icon'),
175  $this->lng->txt('orgu_type_custom_icon_info')
176  );
177 
178  $form_action = $this->ctrl->getFormAction($this, 'updateCustomIcons');
179  $form = $this->ui_factory->input()->container()->form()->standard(
180  $form_action,
181  [$section]
182  );
183 
184  $form = $form->withAdditionalTransformation(
185  $this->refinery->custom()->transformation(
186  function ($values) {
187  return array_shift($values)['iconfile'];
188  }
189  )
190  );
191  return $form;
192  }
ilOrgUnitTypeUploadHandlerGUI: ilOrgUnitTypeGUI
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listTypes()

ilOrgUnitTypeGUI::listTypes ( )
private

Display all types in a table with actions to edit/delete.

Definition at line 328 of file class.ilOrgUnitTypeGUI.php.

References $url, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by executeCommand().

328  : void
329  {
330  $url = $this->ctrl->getLinkTarget($this, 'add');
331  $link = $this->link_factory->standard(
332  $this->lng->txt('orgu_type_add'),
333  $url
334  );
335  $this->toolbar->addComponent($link);
336 
337  $table = new ilOrgUnitTypeTableGUI($this, 'listTypes');
338  $this->tpl->setContent($table->getHTML());
339  }
$url
Definition: ltiregstart.php:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSubTabsEdit()

ilOrgUnitTypeGUI::setSubTabsEdit ( string  $active_tab_id)
private

Definition at line 138 of file class.ilOrgUnitTypeGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

138  : void
139  {
140  $this->tabs->addSubTab('general', $this->lng->txt('meta_general'), $this->ctrl->getLinkTarget($this, 'edit'));
141  if ($this->settings->get('custom_icons')) {
142  $this->tabs->addSubTab(
143  'custom_icons',
144  $this->lng->txt('icon_settings'),
145  $this->ctrl->getLinkTarget($this, 'editCustomIcons')
146  );
147  }
148  if (count(ilOrgUnitType::getAvailableAdvancedMDRecordIds())) {
149  $this->tabs->addSubTab('amd', $this->lng->txt('md_advanced'), $this->ctrl->getLinkTarget($this, 'editAMD'));
150  }
151  $this->tabs->setSubTabActive($active_tab_id);
152  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilOrgUnitTypeGUI::update ( )
private

Update (save) type.

Definition at line 377 of file class.ilOrgUnitTypeGUI.php.

References $_GET, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by executeCommand().

377  : void
378  {
379  $form = new ilOrgUnitTypeFormGUI($this, new ilOrgUnitType((int) $_GET['type_id']));
380  if ($form->saveObject()) {
381  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
382  $this->ctrl->redirect($this);
383  } else {
384  $this->tpl->setContent($form->getHTML());
385  }
386  }
$_GET["client_id"]
Definition: webdav.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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:

◆ updateAMD()

ilOrgUnitTypeGUI::updateAMD ( )
private

Definition at line 307 of file class.ilOrgUnitTypeGUI.php.

References ILIAS\Repository\ctrl(), getAmdForm(), getAvailableAMDRecords(), getCurrentOrgUnitType(), and ILIAS\Repository\lng().

Referenced by executeCommand().

307  : void
308  {
309  $form = $this->getAmdForm(
310  $this->ctrl->getFormAction($this, 'updateAMD'),
311  $this->getAvailableAMDRecords(),
312  $this->getCurrentOrgUnitType()
313  )
314  ->withRequest($this->request);
315 
316  if($form->getData()) {
317  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
318  $this->ctrl->redirect($this);
319  } else {
320  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error'), true);
321  $this->tpl->setContent($this->ui_renderer->render($form));
322  }
323  }
getAmdForm(string $action, array $available_records, ilOrgUnitType $type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCustomIcons()

ilOrgUnitTypeGUI::updateCustomIcons ( )
private

Definition at line 205 of file class.ilOrgUnitTypeGUI.php.

References $_GET, $data, ILIAS\Repository\ctrl(), getIconForm(), and ILIAS\Repository\lng().

Referenced by executeCommand().

205  : void
206  {
207  $type = new ilOrgUnitType((int) $_GET['type_id']);
208  $form = $this->getIconForm(
209  $type->getTitle() . ': ',
210  $type->getIconIdentifier()
211  )
212  ->withRequest($this->request);
213 
214  $data = $form->getData();
215 
216  if(! is_null($data)) {
217  $new_icon_id = current($data) ? current($data) : '';
218  $identifier = $type->getIconIdentifier();
219  if($identifier && $new_icon_id == '') {
220  $type->removeIconFromIrss($identifier);
221  }
222  $type = $type->withIconIdentifier($new_icon_id);
223  $type->save();
224  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
225  $this->ctrl->redirect($this);
226  } else {
227  $this->tpl->setContent($this->ui_renderer->render($form));
228  }
229  }
$_GET["client_id"]
Definition: webdav.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getIconForm(string $section_title=null, string $current_identifier=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilOrgUnitTypeGUI::$access
private

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

◆ $ctrl

ilCtrl ilOrgUnitTypeGUI::$ctrl
private

Definition at line 35 of file class.ilOrgUnitTypeGUI.php.

◆ $link_factory

ILIAS UI Component Link Factory ilOrgUnitTypeGUI::$link_factory
protected

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

◆ $lng

ilLanguage ilOrgUnitTypeGUI::$lng
protected

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

Referenced by mock_ilOrgUnitTypeGUI\__construct().

◆ $refinery

Refinery ilOrgUnitTypeGUI::$refinery
protected

◆ $request

ServerRequestInterface ilOrgUnitTypeGUI::$request
protected

Definition at line 46 of file class.ilOrgUnitTypeGUI.php.

◆ $settings

ilSetting ilOrgUnitTypeGUI::$settings
private

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

◆ $tabs

ilTabsGUI ilOrgUnitTypeGUI::$tabs
private

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

◆ $toolbar

ilToolbarGUI ilOrgUnitTypeGUI::$toolbar
private

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

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitTypeGUI::$tpl
private

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

◆ $ui_factory

UIFactory ilOrgUnitTypeGUI::$ui_factory
protected

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

◆ $ui_renderer

UIRenderer ilOrgUnitTypeGUI::$ui_renderer
protected

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


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