ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjOrgUnitSettingsFormGUI.php
Go to the documentation of this file.
1 <?php
2 
9 {
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  {
44  global $DIC;
45  $tpl = $DIC['tpl'];
46  $ilCtrl = $DIC['ilCtrl'];
47  $lng = $DIC['lng'];
48  $ilUser = $DIC['ilUser'];
49  $this->parent_gui = $parent_gui;
50  $this->obj_orgu = $obj_orgu;
51  $this->tpl = $tpl;
52  $this->ctrl = $ilCtrl;
53  $this->lng = $lng;
54  $this->user = $ilUser;
55  $this->initForm();
56  }
57 
58 
64  public function saveObject()
65  {
66  if (!$this->fillObject()) {
67  return false;
68  }
69  $this->obj_orgu->update();
70  $this->updateTranslation();
71  return true;
72  }
73 
77  protected function initForm()
78  {
79  $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
80  $this->setTitle($this->lng->txt('orgu_settings'));
81 
82  $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
83  $item->setRequired(true);
84  $item->setValue($this->obj_orgu->getTitle());
85  $this->addItem($item);
86 
87  $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
88  $item->setValue($this->obj_orgu->getDescription());
89  $this->addItem($item);
90 
91  $item = new ilFormSectionHeaderGUI();
92  $item->setTitle($this->lng->txt('orgu_type'));
93  $this->addItem($item);
94  $types = ilOrgUnitType::getAllTypes();
95  $options = array(0 => '');
97  foreach ($types as $type) {
98  $options[$type->getId()] = $type->getTitle();
99  }
100  asort($options);
101  $item = new ilSelectInputGUI($this->lng->txt('orgu_type'), 'orgu_type');
102  $item->setOptions($options);
103  $item->setValue($this->obj_orgu->getOrgUnitTypeId());
104  $this->addItem($item);
105 
106  $item = new ilFormSectionHeaderGUI();
107  $item->setTitle($this->lng->txt('ext_id'));
108  $this->addItem($item);
109 
110  $item = new ilTextInputGUI($this->lng->txt('ext_id'), 'ext_id');
111  $item->setValue($this->obj_orgu->getImportId());
112  $this->addItem($item);
113 
114  $this->addCommandButton('updateSettings', $this->lng->txt('save'));
115  }
116 
122  protected function fillObject()
123  {
124  $this->setValuesByPost();
125  if (!$this->checkInput()) {
126  return false;
127  }
128  $this->obj_orgu->setOrgUnitTypeId($this->getInput('orgu_type'));
129  $this->obj_orgu->setImportId($this->getInput('ext_id'));
130  $this->obj_orgu->setTitle($this->getInput('title'));
131  $this->obj_orgu->setDescription($this->getInput('description'));
132  return true;
133  }
134 
138  protected function updateTranslation()
139  {
140  $translations = $this->obj_orgu->getTranslations();
141  $lang_code_default = '';
142  $lang_codes = array();
143  foreach ($translations['Fobject'] 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 }
fillObject()
Check validity of form and pass values from form to object.
This class represents a selection list property in a property form.
This class represents a property form user interface.
$type
global $DIC
Definition: saml.php:7
This class represents a section header in a property form.
setValue($a_value)
Set Value.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
updateTranslation()
Update title and description for the default language of translation.
static getAllTypes()
Get array of all instances of ilOrgUnitType objects.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title)
Set Title.
Class ilObjOrgUnit.
This class represents a text property in a property form.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
checkInput()
Check Post Input.
$ilUser
Definition: imgupload.php:18
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
setOptions($a_options)
Set Options.
setValuesByPost()
Set form values from POST values.
__construct($parent_gui, ilObjOrgUnit $obj_orgu)
This class represents a text area property in a property form.
Class ilObjOrgUnitSettingsFormGUI.
setValue($a_value)
Set Value.
setRequired($a_required)
Set Required.