ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $tpl, $ilCtrl, $lng, $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 if (!$this->fillObject()) {
61 return false;
62 }
63 $this->obj_orgu->update();
64 $this->updateTranslation();
65 return true;
66 }
67
71 protected function initForm() {
72 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
73 $this->setTitle($this->lng->txt('orgu_settings'));
74
75 $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
76 $item->setRequired(true);
77 $item->setValue($this->obj_orgu->getTitle());
78 $this->addItem($item);
79
80 $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
81 $item->setValue($this->obj_orgu->getDescription());
82 $this->addItem($item);
83
84 $item = new ilFormSectionHeaderGUI();
85 $item->setTitle($this->lng->txt('orgu_type'));
86 $this->addItem($item);
88 $options = array(0 => '');
90 foreach ($types as $type) {
91 $options[$type->getId()] = $type->getTitle();
92 }
93 asort($options);
94 $item = new ilSelectInputGUI($this->lng->txt('orgu_type'), 'orgu_type');
95 $item->setOptions($options);
96 $item->setValue($this->obj_orgu->getOrgUnitTypeId());
97 $this->addItem($item);
98
99 $item = new ilFormSectionHeaderGUI();
100 $item->setTitle($this->lng->txt('ext_id'));
101 $this->addItem($item);
102
103 $item = new ilTextInputGUI($this->lng->txt('ext_id'), 'ext_id');
104 $item->setValue($this->obj_orgu->getImportId());
105 $this->addItem($item);
106
107 $this->addCommandButton('updateSettings', $this->lng->txt('save'));
108 }
109
115 protected function fillObject() {
116 $this->setValuesByPost();
117 if (!$this->checkInput()) {
118 return false;
119 }
120 $this->obj_orgu->setOrgUnitTypeId($this->getInput('orgu_type'));
121 $this->obj_orgu->setImportId($this->getInput('ext_id'));
122 $this->obj_orgu->setTitle($this->getInput('title'));
123 $this->obj_orgu->setDescription($this->getInput('description'));
124 return true;
125 }
126
130 protected function updateTranslation() {
131 $translations = $this->obj_orgu->getTranslations();
132 $lang_code_default = '';
133 $lang_codes = array();
134 foreach ($translations['Fobject'] as $translation) {
135 if ($translation['lang_default']) {
136 $lang_code_default = $translation['lang'];
137 }
138 $lang_codes[] = $translation['lang'];
139 }
140 $lang_code = (in_array($this->user->getLanguage(), $lang_codes)) ? $this->user->getLanguage() : $lang_code_default;
141 $this->obj_orgu->updateTranslation($this->getInput('title'), $this->getInput('description'), $lang_code, 0);
142 }
143
144}
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).
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.
addCommandButton($a_cmd, $a_text)
Add Command button.
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 $ilUser
Definition: imgupload.php:15