ILIAS  trunk Revision v12.0_alpha-33-ge186251a14d
ContactInformationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Administration;
22
23use ilCtrl;
25use ilLanguage;
32
39{
40 public function __construct(
41 private ilCtrl $ctrl,
42 private ilGlobalTemplateInterface $tpl,
43 private ilLanguage $lng,
44 private Setting $settings,
45 private bool $has_write_access,
46 ) {
47 }
48
49 public function executeCommand()
50 {
51 $cmd = $this->ctrl->getCmd("view");
52 switch ($cmd) {
53 case 'view':
54 $this->view();
55 break;
56
57 case 'update':
58 if ($this->has_write_access) {
59 $this->$cmd();
60 }
61 break;
62 }
63 }
64
65 public function view(): void
66 {
67 $this->tpl->setContent($this->buildForm()->getHTML());
68 }
69
70 public function update(): void
71 {
72 $form = $this->buildForm();
73 if ($form->checkInput()) {
74 $fs = array("admin_firstname", "admin_lastname", "admin_title", "admin_position",
75 "admin_institution", "admin_street", "admin_zipcode", "admin_city",
76 "admin_country", "admin_phone", "admin_email");
77 foreach ($fs as $f) {
78 $this->settings->set($f, $form->getInput($f));
79 }
80
81 // System support contacts
82 ilSystemSupportContacts::setList($form->getInput("adm_support_contacts"));
83
84 // Accessibility support contacts
85 ilAccessibilitySupportContacts::setList($form->getInput("accessibility_support_contacts"));
86
87 $this->tpl->setOnScreenMessage(GlobalTemplate::MESSAGE_TYPE_SUCCESS, $this->lng->txt("msg_obj_modified"), true);
88 $this->ctrl->redirect($this);
89 } else {
90 $form->setValuesByPost();
91 $this->tpl->setContent($form->getHtml());
92 }
93 }
94
95 public function buildForm(): ilPropertyFormGUI
96 {
97 $form = new ilPropertyFormGUI();
98
99 // first name
100 $ti = new ilTextInputGUI($this->lng->txt("firstname"), "admin_firstname");
101 $ti->setMaxLength(64);
102 $ti->setSize(40);
103 $ti->setRequired(true);
104 $ti->setValue($this->settings->get("admin_firstname"));
105 $form->addItem($ti);
106
107 // last name
108 $ti = new ilTextInputGUI($this->lng->txt("lastname"), "admin_lastname");
109 $ti->setMaxLength(64);
110 $ti->setSize(40);
111 $ti->setRequired(true);
112 $ti->setValue($this->settings->get("admin_lastname"));
113 $form->addItem($ti);
114
115 // title
116 $ti = new ilTextInputGUI($this->lng->txt("title"), "admin_title");
117 $ti->setMaxLength(64);
118 $ti->setSize(40);
119 $ti->setValue($this->settings->get("admin_title"));
120 $form->addItem($ti);
121
122 // position
123 $ti = new ilTextInputGUI($this->lng->txt("position"), "admin_position");
124 $ti->setMaxLength(64);
125 $ti->setSize(40);
126 $ti->setValue($this->settings->get("admin_position"));
127 $form->addItem($ti);
128
129 // institution
130 $ti = new ilTextInputGUI($this->lng->txt("institution"), "admin_institution");
131 $ti->setMaxLength(200);
132 $ti->setSize(40);
133 $ti->setValue($this->settings->get("admin_institution"));
134 $form->addItem($ti);
135
136 // street
137 $ti = new ilTextInputGUI($this->lng->txt("street"), "admin_street");
138 $ti->setMaxLength(64);
139 $ti->setSize(40);
140 //$ti->setRequired(true);
141 $ti->setValue($this->settings->get("admin_street"));
142 $form->addItem($ti);
143
144 // zip code
145 $ti = new ilTextInputGUI($this->lng->txt("zipcode"), "admin_zipcode");
146 $ti->setMaxLength(10);
147 $ti->setSize(5);
148 //$ti->setRequired(true);
149 $ti->setValue($this->settings->get("admin_zipcode"));
150 $form->addItem($ti);
151
152 // city
153 $ti = new ilTextInputGUI($this->lng->txt("city"), "admin_city");
154 $ti->setMaxLength(64);
155 $ti->setSize(40);
156 //$ti->setRequired(true);
157 $ti->setValue($this->settings->get("admin_city"));
158 $form->addItem($ti);
159
160 // country
161 $ti = new ilTextInputGUI($this->lng->txt("country"), "admin_country");
162 $ti->setMaxLength(64);
163 $ti->setSize(40);
164 //$ti->setRequired(true);
165 $ti->setValue($this->settings->get("admin_country"));
166 $form->addItem($ti);
167
168 // phone
169 $ti = new ilTextInputGUI($this->lng->txt("phone"), "admin_phone");
170 $ti->setMaxLength(64);
171 $ti->setSize(40);
172 //$ti->setRequired(true);
173 $ti->setValue($this->settings->get("admin_phone"));
174 $form->addItem($ti);
175
176 // email
177 $ti = new ilEMailInputGUI($this->lng->txt("email"), "admin_email");
178 $ti->setMaxLength(64);
179 $ti->setSize(40);
180 $ti->setRequired(true);
181 $ti->allowRFC822(true);
182 $ti->setValue($this->settings->get("admin_email"));
183 $form->addItem($ti);
184
185 // System support contacts
186 $ti = new ilTextInputGUI($this->lng->txt("adm_support_contacts"), "adm_support_contacts");
187 $ti->setMaxLength(500);
188 $ti->setValue(ilSystemSupportContacts::getList());
189 //$ti->setSize();
190 $ti->setInfo($this->lng->txt("adm_support_contacts_info"));
191 $form->addItem($ti);
192
193 // Accessibility support contacts
194 $ti = new ilTextInputGUI($this->lng->txt("adm_accessibility_contacts"), "accessibility_support_contacts");
195 $ti->setMaxLength(500);
197 //$ti->setSize();
198 $ti->setInfo($this->lng->txt("adm_accessibility_contacts_info"));
199 $form->addItem($ti);
200
201 if ($this->has_write_access) {
202 $form->addCommandButton("update", $this->lng->txt("save"));
203 }
204
205 $form->setTitle($this->lng->txt("contact_data"));
206 $form->setFormAction($this->ctrl->getFormAction($this));
207
208 return $form;
209 }
210}
GUI to change the header title of the installation.
__construct(private ilCtrl $ctrl, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private Setting $settings, private bool $has_write_access,)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
This class represents a email property in a property form.
language handling
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
global $lng
Definition: privfeed.php:31