ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjOrgUnitSettingsFormGUI.php
Go to the documentation of this file.
1<?php
2require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
3
10
14 protected $obj_orgu;
15
19 protected $tpl;
20
24 protected $lng;
25
29 protected $ctrl;
30
34 protected $user;
35
39 protected $parent_gui;
40
41
43 global $DIC;
44 $tpl = $DIC['tpl'];
45 $ilCtrl = $DIC['ilCtrl'];
46 $lng = $DIC['lng'];
47 $ilUser = $DIC['ilUser'];
48 $this->parent_gui = $parent_gui;
49 $this->obj_orgu = $obj_orgu;
50 $this->tpl = $tpl;
51 $this->ctrl = $ilCtrl;
52 $this->lng = $lng;
53 $this->user = $ilUser;
54 $this->initForm();
55 }
56
57
63 public function saveObject() {
64 if (!$this->fillObject()) {
65 return false;
66 }
67 $this->obj_orgu->update();
68 $this->updateTranslation();
69 return true;
70 }
71
75 protected function initForm() {
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
119 protected function fillObject() {
120 $this->setValuesByPost();
121 if (!$this->checkInput()) {
122 return false;
123 }
124 $this->obj_orgu->setOrgUnitTypeId($this->getInput('orgu_type'));
125 $this->obj_orgu->setImportId($this->getInput('ext_id'));
126 $this->obj_orgu->setTitle($this->getInput('title'));
127 $this->obj_orgu->setDescription($this->getInput('description'));
128 return true;
129 }
130
134 protected function updateTranslation() {
135 $translations = $this->obj_orgu->getTranslations();
136 $lang_code_default = '';
137 $lang_codes = array();
138 foreach ($translations['Fobject'] as $translation) {
139 if ($translation['lang_default']) {
140 $lang_code_default = $translation['lang'];
141 }
142 $lang_codes[] = $translation['lang'];
143 }
144 $lang_code = (in_array($this->user->getLanguage(), $lang_codes)) ? $this->user->getLanguage() : $lang_code_default;
145 $this->obj_orgu->updateTranslation($this->getInput('title'), $this->getInput('description'), $lang_code, 0);
146 }
147
148}
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
if(!is_array($argv)) $options
global $DIC
$ilUser
Definition: imgupload.php:18