ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjOrgUnitSettingsFormGUI.php
Go to the documentation of this file.
1<?php
2
9{
10
14 protected $obj_orgu;
18 protected $tpl;
22 protected $lng;
26 protected $ctrl;
30 protected $user;
34 protected $parent_gui;
35
36
38 {
39 global $DIC;
40 $tpl = $DIC['tpl'];
41 $ilCtrl = $DIC['ilCtrl'];
42 $lng = $DIC['lng'];
43 $ilUser = $DIC['ilUser'];
44 $this->parent_gui = $parent_gui;
45 $this->obj_orgu = $obj_orgu;
46 $this->tpl = $tpl;
47 $this->ctrl = $ilCtrl;
48 $this->lng = $lng;
49 $this->user = $ilUser;
50 $this->initForm();
51 }
52
53
59 public function saveObject()
60 {
61 if (!$this->fillObject()) {
62 return false;
63 }
64 $this->obj_orgu->update();
65 $this->updateTranslation();
66
67 return true;
68 }
69
70
74 protected function initForm()
75 {
76 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
77 $this->setTitle($this->lng->txt('orgu_settings'));
78
79 $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
80 $item->setRequired(true);
81 $item->setValue($this->obj_orgu->getTitle());
82 $this->addItem($item);
83
84 $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
85 $item->setValue($this->obj_orgu->getDescription());
86 $this->addItem($item);
87
88 $item = new ilFormSectionHeaderGUI();
89 $item->setTitle($this->lng->txt('orgu_type'));
90 $this->addItem($item);
92 $options = array(0 => '');
94 foreach ($types as $type) {
95 $options[$type->getId()] = $type->getTitle();
96 }
97 asort($options);
98 $item = new ilSelectInputGUI($this->lng->txt('orgu_type'), 'orgu_type');
99 $item->setOptions($options);
100 $item->setValue($this->obj_orgu->getOrgUnitTypeId());
101 $this->addItem($item);
102
103 $item = new ilFormSectionHeaderGUI();
104 $item->setTitle($this->lng->txt('ext_id'));
105 $this->addItem($item);
106
107 $item = new ilTextInputGUI($this->lng->txt('ext_id'), 'ext_id');
108 $item->setValue($this->obj_orgu->getImportId());
109 $this->addItem($item);
110
111 $this->addCommandButton('updateSettings', $this->lng->txt('save'));
112 }
113
114
120 protected function fillObject()
121 {
122 $this->setValuesByPost();
123 if (!$this->checkInput()) {
124 return false;
125 }
126 $this->obj_orgu->setOrgUnitTypeId($this->getInput('orgu_type'));
127 $this->obj_orgu->setImportId($this->getInput('ext_id'));
128 $this->obj_orgu->setTitle($this->getInput('title'));
129 $this->obj_orgu->setDescription($this->getInput('description'));
130
131 return true;
132 }
133
134
138 protected function updateTranslation()
139 {
140 $translations = $this->obj_orgu->getTranslations();
141 $lang_code_default = '';
142 $lang_codes = array();
143 foreach ($translations as $translation) {
144 if ($translation['lang_default']) {
145 $lang_code_default = $translation['lang'];
146 }
147 $lang_codes[] = $translation['lang'];
148 }
149 $lang_code = (in_array($this->user->getLanguage(), $lang_codes)) ? $this->user->getLanguage() : $lang_code_default;
150 $this->obj_orgu->updateTranslation($this->getInput('title'), $this->getInput('description'), $lang_code, 0);
151 }
152}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
setFormAction($a_formaction)
Set FormAction.
This class represents a section header in a property form.
Class ilObjOrgUnitSettingsFormGUI.
__construct($parent_gui, ilObjOrgUnit $obj_orgu)
fillObject()
Check validity of form and pass values from form to object.
updateTranslation()
Update title and description for the default language of translation.
Class ilObjOrgUnit.
static getAllTypes()
Get array of all instances of ilOrgUnitType objects.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
checkInput()
Check Post Input.
setValuesByPost()
Set form values from POST values.
setTitle($a_title)
Set Title.
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.
global $ilCtrl
Definition: ilias.php:18
$type
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46