ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjOrgUnitSettingsFormGUI.php
Go to the documentation of this file.
1<?php
2
24{
27
29 {
30 global $DIC;
31
33 $tpl = $DIC['tpl'];
34 $ilCtrl = $DIC['ilCtrl'];
35 $lng = $DIC['lng'];
36 $ilUser = $DIC['ilUser'];
37 $this->parent_gui = $parent_gui;
38 $this->obj_orgu = $obj_orgu;
39
40 //$this->tpl = $tpl;
41 $this->ctrl = $ilCtrl;
42 $this->lng = $lng;
43 $this->user = $ilUser;
44 $this->initForm();
45 }
46
51 public function saveObject()
52 {
53 if (!$this->fillObject()) {
54 return false;
55 }
56 $this->obj_orgu->update();
57 $this->updateTranslation();
58
59 return true;
60 }
61
65 private function initForm(): void
66 {
67 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
68 $this->setTitle($this->lng->txt('orgu_settings'));
69
70 $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
71 $item->setRequired(true);
72 $item->setValue($this->obj_orgu->getTitle());
73 $this->addItem($item);
74
75 $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
76 $item->setValue($this->obj_orgu->getDescription());
77 $this->addItem($item);
78
79 $item = new ilFormSectionHeaderGUI();
80 $item->setTitle($this->lng->txt('orgu_type'));
81 $this->addItem($item);
83 $options = array(0 => '');
85 foreach ($types as $type) {
86 $options[$type->getId()] = $type->getTitle();
87 }
88 asort($options);
89 $item = new ilSelectInputGUI($this->lng->txt('orgu_type'), 'orgu_type');
90 $item->setOptions($options);
91 $item->setValue($this->obj_orgu->getOrgUnitTypeId());
92 $this->addItem($item);
93
94 $item = new ilFormSectionHeaderGUI();
95 $item->setTitle($this->lng->txt('ext_id'));
96 $this->addItem($item);
97
98 $item = new ilTextInputGUI($this->lng->txt('ext_id'), 'ext_id');
99 $item->setValue($this->obj_orgu->getImportId());
100 $this->addItem($item);
101
102 $this->addCommandButton('updateSettings', $this->lng->txt('save'));
103 }
104
109 private function fillObject(): bool
110 {
111 $this->setValuesByPost();
112 if (!$this->checkInput()) {
113 return false;
114 }
115 $this->obj_orgu->setOrgUnitTypeId($this->getInput('orgu_type'));
116 $this->obj_orgu->setImportId($this->getInput('ext_id'));
117 $this->obj_orgu->setTitle($this->getInput('title'));
118 $this->obj_orgu->setDescription($this->getInput('description'));
119
120 return true;
121 }
122
126 private function updateTranslation(): void
127 {
128 $translations = $this->obj_orgu->getTranslations();
129 $lang_code_default = '';
130 $lang_codes = array();
131 foreach ($translations as $translation) {
132 if ($translation['default']) {
133 $lang_code_default = $translation['lang'];
134 }
135 $lang_codes[] = $translation['lang'];
136 }
137 $lang_code = (in_array($this->user->getLanguage(), $lang_codes, true)) ? $this->user->getLanguage() : $lang_code_default;
138 $this->obj_orgu->updateTranslation($this->getInput('title'), $this->getInput('description'), $lang_code, 0);
139 }
140}
setFormAction(string $a_formaction)
This class represents a section header in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillObject()
Check validity of form and pass values from form to object.
__construct(ilObjectGUI $parent_gui, ilObjOrgUnit $obj_orgu)
updateTranslation()
Update title and description for the default language of translation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectGUI Basic methods of all Output classes.
static getAllTypes()
Get array of all instances of ilOrgUnitType objects.
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26