ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAdministrationSettingsFormHandler.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 protected static $OBJ_MAP;
13
14 const FORM_PRIVACY = 1;
15 const FORM_SECURITY = 2;
16 //Not used aymore: const FORM_FILES_QUOTA = 3;
17 const FORM_LP = 4;
18 const FORM_MAIL = 5;
19 const FORM_COURSE = 6;
20 const FORM_GROUP = 7;
21 const FORM_REPOSITORY = 8;
22 const FORM_LDAP = 9;
23 const FORM_FORUM = 10;
25 const FORM_WSP = 12;
26 const FORM_TAGGING = 13;
27 const FORM_CERTIFICATE = 14;
29 const FORM_TOS = 16;
30
31
32 const SETTINGS_USER = "usrf";
33 const SETTINGS_GENERAL = "adm";
34 const SETTINGS_FILE = "facs";
35 const SETTINGS_ROLE = "rolf";
36 const SETTINGS_FORUM = "frma";
37 const SETTINGS_LRES = "lrss";
38 const SETTINGS_REPOSITORY = "reps";
39 const SETTINGS_PR = "prss";
40 const SETTINGS_COURSE = "crss";
41 const SETTINGS_GROUP = "grps";
43 const SETTINGS_CALENDAR = "cals";
44 const SETTINGS_AUTH = "auth";
45 const SETTINGS_WIKI = "wiks";
46 const SETTINGS_PORTFOLIO = "prfa";
49 const SETTINGS_COMMENTS = "coms";
50
51 const VALUE_BOOL = "bool";
52
53 protected static function initObjectMap()
54 {
55 global $DIC;
56
57 $tree = $DIC->repositoryTree();
58
59 $map = array("adm" => SYSTEM_FOLDER_ID);
60 foreach ($tree->getChilds(SYSTEM_FOLDER_ID) as $obj) {
61 $map[$obj["type"]] = $obj["ref_id"];
62 }
63
64 self::$OBJ_MAP = $map;
65 }
66
67 protected static function getRefId($a_obj_type)
68 {
69 if (!is_array(self::$OBJ_MAP)) {
71 }
72 return self::$OBJ_MAP[$a_obj_type];
73 }
74
75 public static function getSettingsGUIInstance($a_settings_obj_type)
76 {
77 global $DIC;
78
79 $objDefinition = $DIC["objDefinition"];
80 $ilCtrl = $DIC->ctrl();
81
82 $ref_id = self::getRefId($a_settings_obj_type);
83 $obj_type = ilObject::_lookupType($ref_id, true);
84
85 $class_name = $objDefinition->getClassName($obj_type);
86 $class_name = "ilObj" . $class_name . "GUI";
87 $class_path = $ilCtrl->lookupClassPath($class_name);
88 if (is_subclass_of($class_name, "ilObject2GUI")) {
89 $gui_obj = new $class_name($ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
90 } else {
91 $gui_obj = new $class_name("", $ref_id, true, false);
92 }
93
94 $gui_obj->setCreationMode(true);
95
96 return $gui_obj;
97 }
98
99 public static function addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
100 {
101 switch ($a_form_id) {
103 $types = array(self::SETTINGS_USER, self::SETTINGS_FILE, self::SETTINGS_ROLE);
104 break;
105
107 $types = array(self::SETTINGS_ROLE, self::SETTINGS_FORUM, self::SETTINGS_LRES, self::SETTINGS_COMMENTS);
108 break;
109
110 case self::FORM_LP:
111 $types = array(self::SETTINGS_REPOSITORY);
112 break;
113
115 $types = array(self::SETTINGS_FORUM, self::SETTINGS_AUTH, self::SETTINGS_WIKI);
116 break;
117
118 case self::FORM_MAIL:
119 $types = array(self::SETTINGS_COURSE, self::SETTINGS_GROUP, self::SETTINGS_LEARNINGSEQUENCE);
120 break;
121
123 $types = array(self::SETTINGS_PRIVACY_SECURITY, self::SETTINGS_CALENDAR, self::SETTINGS_GENERAL);
124 break;
125
126 case self::FORM_GROUP:
127 $types = array(self::SETTINGS_PRIVACY_SECURITY, self::SETTINGS_CALENDAR, self::SETTINGS_GENERAL, self::SETTINGS_COURSE);
128 break;
129
130 case self::FORM_WSP:
131 $types = array(self::SETTINGS_PORTFOLIO);
132 break;
133
135 $types = array(self::SETTINGS_REPOSITORY);
136 break;
137
139 $types = array(self::SETTINGS_LP_COMPLETION_STATUS);
140 break;
141
142 case self::FORM_TOS:
143 $types = [self::SETTINGS_USER];
144 break;
145
146 default:
147 $types = null;
148 break;
149 }
150
151 if (is_array($types)) {
152 foreach ($types as $type) {
154 if ($gui && method_exists($gui, "addToExternalSettingsForm")) {
155 $data = $gui->addToExternalSettingsForm($a_form_id);
156 if (is_array($data)) {
157 self::parseFieldDefinition($type, $a_form, $gui, $data);
158 }
159 }
160 }
161 }
162
163 // cron jobs - special handling
164
165 include_once "Modules/SystemFolder/classes/class.ilObjSystemFolderGUI.php";
166 $parent_gui = new ilObjSystemFolderGUI(null, SYSTEM_FOLDER_ID, true);
167 $parent_gui->setCreationMode(true);
168
169 include_once "Services/Cron/classes/class.ilCronManagerGUI.php";
170 $gui = new ilCronManagerGUI();
171 $data = $gui->addToExternalSettingsForm($a_form_id);
172 if (is_array($data) && sizeof($data)) {
173 self::parseFieldDefinition("cron", $a_form, $parent_gui, $data);
174 }
175 }
176
177 protected static function parseFieldValue($a_field_type, & $a_field_value)
178 {
179 global $DIC;
180
181 $lng = $DIC->language();
182
183 switch ($a_field_type) {
184 case self::VALUE_BOOL:
185 $a_field_value = (bool) $a_field_value ?
186 $lng->txt("enabled") :
187 $lng->txt("disabled");
188 return $a_field_value;
189 }
190
191 if (!is_numeric($a_field_value) &&
192 $a_field_value !== null && !trim($a_field_value)) {
193 $a_field_value = "-";
194 }
195
196 if (is_numeric($a_field_value) || $a_field_value !== "") {
197 return true;
198 }
199 return false;
200 }
201
202 protected static function parseFieldDefinition($a_type, ilPropertyFormGUI $a_form, ilObjectGUI $a_gui, $a_data)
203 {
204 global $DIC;
205
206 $lng = $DIC->language();
207 $rbacsystem = $DIC->rbac()->system();
208 $ilCtrl = $DIC->ctrl();
209 $ilAccess = $DIC->access();
210
211 if (!is_array($a_data)) {
212 return;
213 }
214
215 // write permission for current gui?
216 $has_write = $ilAccess->checkAccess("write", "", (int) $_REQUEST["ref_id"]);
217
218 foreach ($a_data as $area_caption => $fields) {
219 if (is_numeric($area_caption) || !trim($area_caption)) {
220 $area_caption = "obj_" . $a_type;
221 }
222
223 if (is_array($fields) && sizeof($fields) == 2) {
224 $cmd = $fields[0];
225 $fields = $fields[1];
226 if (is_array($fields)) {
227 $ftpl = new ilTemplate("tpl.external_settings.html", true, true, "Services/Administration");
228
229
230 $stack = array();
231 foreach ($fields as $field_caption_id => $field_value) {
232 $field_type = $subitems = null;
233 if (is_array($field_value)) {
234 $field_type = $field_value[1];
235 $subitems = $field_value[2];
236 $field_value = $field_value[0];
237 }
238
239 if (self::parseFieldValue($field_type, $field_value)) {
240 $ftpl->setCurrentBlock("value_bl");
241 $ftpl->setVariable("VALUE", $field_value);
242 $ftpl->parseCurrentBlock();
243 }
244
245 if (is_array($subitems)) {
246 $ftpl->setCurrentBlock("subitem_bl");
247 foreach ($subitems as $sub_caption_id => $sub_value) {
248 $sub_type = null;
249 if (is_array($sub_value)) {
250 $sub_type = $sub_value[1];
251 $sub_value = $sub_value[0];
252 }
253 self::parseFieldValue($sub_type, $sub_value);
254
255 $ftpl->setVariable("SUBKEY", $lng->txt($sub_caption_id));
256 $ftpl->setVariable("SUBVALUE", $sub_value);
257 $ftpl->parseCurrentBlock();
258 }
259 }
260
261 $ftpl->setCurrentBlock("row_bl");
262 $ftpl->setVariable("KEY", $lng->txt($field_caption_id));
263 $ftpl->parseCurrentBlock();
264 }
265
266 if ($has_write &&
267 $rbacsystem->checkAccess("visible,read", $a_gui->object->getRefId())) {
268 if (!$cmd) {
269 $cmd = "view";
270 }
271 $ilCtrl->setParameter($a_gui, "ref_id", $a_gui->object->getRefId());
272
273 $ftpl->setCurrentBlock("edit_bl");
274 $ftpl->setVariable("URL_EDIT", $ilCtrl->getLinkTargetByClass(array("ilAdministrationGUI", get_class($a_gui)), $cmd));
275 $ftpl->setVariable("TXT_EDIT", $lng->txt("adm_external_setting_edit"));
276 $ftpl->parseCurrentBlock();
277 }
278
279 $ext = new ilCustomInputGUI($lng->txt($area_caption));
280 $ext->setHtml($ftpl->get());
281 $a_form->addItem($ext);
282 }
283 }
284 }
285 }
286}
An exception for terminatinating execution or to throw for unit testing.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
static parseFieldDefinition($a_type, ilPropertyFormGUI $a_form, ilObjectGUI $a_gui, $a_data)
static parseFieldValue($a_field_type, & $a_field_value)
Class ilCronManagerGUI.
This class represents a custom property in a property form.
Class ilObjSystemFolderGUI.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
special template class to simplify handling of ITX/PEAR
const SYSTEM_FOLDER_ID
Definition: constants.php:33
global $DIC
Definition: goto.php:24
$type
$lng
$data
Definition: storeScorm.php:23