ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilOrgUnitPositionFormGUI.php
Go to the documentation of this file.
1<?php
2
4
11{
12 const F_AUTHORITIES = "authorities";
16 protected $object;
17 const F_TITLE = 'title';
18 const F_DESCRIPTION = 'description';
19
20
21 protected function initFormElements()
22 {
23 $te = new ilTextInputGUI($this->txt(self::F_TITLE), self::F_TITLE);
24 $te->setRequired(true);
25 $this->addItem($te);
26
27 $te = new ilTextAreaInputGUI($this->txt(self::F_DESCRIPTION), self::F_DESCRIPTION);
28 $this->addItem($te);
29
30 $m = new ilOrgUnitGenericMultiInputGUI($this->txt(self::F_AUTHORITIES), self::F_AUTHORITIES);
31 $m->setShowLabel(true);
32 $m->setRenderOneForEmptyValue(false);
33 $m->setMulti(true);
34
35 $id = new ilHiddenInputGUI('id');
36 $m->addInput($id);
37
38 $over = new ilSelectInputGUI($this->txt('over'), 'over');
39 $over_options = array();
40 $over_options[ilOrgUnitAuthority::OVER_EVERYONE] = $this->txt('over_'
42 $over_options = $over_options + ilOrgUnitPosition::getArray('id', 'title');
43 $over->setOptions($over_options);
44 $m->addInput($over);
45
46 $available_scopes = array();
47 foreach (ilOrgUnitAuthority::getScopes() as $scope) {
48 $txt = $this->txt('scope_' . $scope);
49 $available_scopes[$scope] = $txt;
50 }
51
52 $scopes = new ilSelectInputGUI($this->txt('scope'), 'scope');
53 $scopes->setOptions($available_scopes);
54 $m->addInput($scopes);
55
56 $this->addItem($m);
57 }
58
59
60 public function fillForm()
61 {
62 $array = array(
63 self::F_TITLE => $this->object->getTitle(),
64 self::F_DESCRIPTION => $this->object->getDescription(),
65 self::F_AUTHORITIES => $this->object->getAuthoritiesAsArray(),
66 );
67
68 $this->setValuesByArray($array);
69 }
70
71
77 public function fillObject()
78 {
79 if (!$this->checkInput()) {
80 return false;
81 }
82
83 $this->object->setTitle($this->getInput(self::F_TITLE));
84 $this->object->setDescription($this->getInput(self::F_DESCRIPTION));
85
86 $authorities = (array) $this->getInput(self::F_AUTHORITIES);
87 $ilOrgUnitAuthorities = array();
88 foreach ($authorities as $authority) {
92 $id = $authority["id"];
93 $ilOrgUnitAuthority = ilOrgUnitAuthority::findOrGetInstance($id);
94 $ilOrgUnitAuthority->setPositionId($this->object->getId());
95 $ilOrgUnitAuthority->setScope($authority["scope"]);
96 $ilOrgUnitAuthority->setOver($authority["over"]);
97 $ilOrgUnitAuthorities[] = $ilOrgUnitAuthority;
98 }
99
100 $this->object->setAuthorities($ilOrgUnitAuthorities);
101
102 return true;
103 }
104}
static findOrGetInstance($primary_key, array $add_constructor_args=array())
static getArray($key=null, $values=null)
An exception for terminatinating execution or to throw for unit testing.
This class represents a hidden form property in a property form.
Class ilOrgUnitPositionFormGUI.
addItem($a_item)
Add Item (Property, SectionHeader).
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
checkInput()
Check Post Input.
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.
$authority
$txt
Definition: error.php:11