ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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;
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
28 const SETTINGS_USER = "usrf";
29 const SETTINGS_GENERAL = "adm";
30 const SETTINGS_FILE = "facs";
31 const SETTINGS_ROLE = "rolf";
32 const SETTINGS_FORUM = "frma";
33 const SETTINGS_LRES = "lrss";
34 const SETTINGS_REPOSITORY = "reps";
35 const SETTINGS_PD = "pdts";
36 const SETTINGS_COURSE = "crss";
37 const SETTINGS_GROUP = "grps";
39 const SETTINGS_CALENDAR = "cals";
40 const SETTINGS_AUTH = "auth";
41 const SETTINGS_WIKI = "wiks";
42 const SETTINGS_PORTFOLIO = "prfa";
43
44 const VALUE_BOOL = "bool";
45
46 protected static function initObjectMap()
47 {
48 global $tree;
49
50 $map = array("adm" => SYSTEM_FOLDER_ID);
51 foreach($tree->getChilds(SYSTEM_FOLDER_ID) as $obj)
52 {
53 $map[$obj["type"]] = $obj["ref_id"];
54 }
55
56 self::$OBJ_MAP = $map;
57 }
58
59 protected static function getRefId($a_obj_type)
60 {
61 if(!is_array(self::$OBJ_MAP))
62 {
64 }
65 return self::$OBJ_MAP[$a_obj_type];
66 }
67
68 public static function getSettingsGUIInstance($a_settings_obj_type)
69 {
70 global $objDefinition, $ilCtrl;
71
72 $ref_id = self::getRefId($a_settings_obj_type);
73 $obj_type = ilObject::_lookupType($ref_id, true);
74
75 $class_name = $objDefinition->getClassName($obj_type);
76 $class_name = "ilObj".$class_name."GUI";
77
78 $class_path = $ilCtrl->lookupClassPath($class_name);
79 include_once($class_path);
80
81 if(is_subclass_of($class_name, "ilObject2GUI"))
82 {
83 $gui_obj = new $class_name($ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
84 }
85 else
86 {
87 $gui_obj = new $class_name("", $ref_id, true, false);
88 }
89
90 $gui_obj->setCreationMode(true);
91
92 return $gui_obj;
93 }
94
95 public static function addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
96 {
97 switch($a_form_id)
98 {
100 $types = array(self::SETTINGS_GENERAL, self::SETTINGS_USER, self::SETTINGS_FILE, self::SETTINGS_ROLE);
101 break;
102
104 $types = array(self::SETTINGS_ROLE, self::SETTINGS_FORUM, self::SETTINGS_LRES);
105 break;
106
108 $types = array(self::SETTINGS_PD);
109 break;
110
111 case self::FORM_LP:
112 $types = array(self::SETTINGS_REPOSITORY);
113 break;
114
116 $types = array(self::SETTINGS_FORUM, self::SETTINGS_AUTH, self::SETTINGS_WIKI);
117 break;
118
119 case self::FORM_MAIL:
120 $types = array(self::SETTINGS_COURSE, self::SETTINGS_GROUP);
121 break;
122
124 case self::FORM_GROUP:
125 $types = array(self::SETTINGS_PRIVACY_SECURITY, self::SETTINGS_CALENDAR, self::SETTINGS_GENERAL);
126 break;
127
128 case self::FORM_WSP:
129 $types = array(self::SETTINGS_PORTFOLIO);
130 break;
131
133 $types = array(self::SETTINGS_REPOSITORY);
134 break;
135
136 default:
137 $types = null;
138 break;
139 }
140
141 if(is_array($types))
142 {
143 foreach($types as $type)
144 {
145 $gui = self::getSettingsGUIInstance($type);
146 if($gui && method_exists($gui, "addToExternalSettingsForm"))
147 {
148 $data = $gui->addToExternalSettingsForm($a_form_id);
149 if(is_array($data))
150 {
151 self::parseFieldDefinition($type, $a_form, $gui, $data);
152 }
153 }
154 }
155 }
156
157 // cron jobs - special handling
158
159 include_once "Modules/SystemFolder/classes/class.ilObjSystemFolderGUI.php";
160 $parent_gui = new ilObjSystemFolderGUI(null, SYSTEM_FOLDER_ID, true);
161 $parent_gui->setCreationMode(true);
162
163 include_once "Services/Cron/classes/class.ilCronManagerGUI.php";
164 $gui = new ilCronManagerGUI();
165 $data = $gui->addToExternalSettingsForm($a_form_id);
166 if(sizeof($data))
167 {
168 self::parseFieldDefinition("cron", $a_form, $parent_gui, $data);
169 }
170 }
171
172 protected static function parseFieldValue($a_field_type, &$a_field_value)
173 {
174 global $lng;
175
176 switch($a_field_type)
177 {
178 case self::VALUE_BOOL:
179 $a_field_value = (bool)$a_field_value ?
180 $lng->txt("enabled") :
181 $lng->txt("disabled");
182 return $a_field_value;
183 }
184
185 if(!is_numeric($a_field_value) &&
186 $a_field_value !== null && !trim($a_field_value))
187 {
188 $a_field_value = "-";
189 }
190
191 if(is_numeric($a_field_value) || $a_field_value !== "")
192 {
193 return true;
194 }
195 return false;
196 }
197
198 protected static function parseFieldDefinition($a_type, ilPropertyFormGUI $a_form, ilObjectGUI $a_gui, $a_data)
199 {
200 global $lng, $rbacsystem, $ilCtrl;
201
202 if(!is_array($a_data))
203 {
204 return;
205 }
206
207 foreach($a_data as $area_caption => $fields)
208 {
209 if(is_numeric($area_caption) || !trim($area_caption))
210 {
211 $area_caption = "obj_".$a_type;
212 }
213
214 if(is_array($fields) && sizeof($fields) == 2)
215 {
216 $cmd = $fields[0];
217 $fields = $fields[1];
218 if(is_array($fields))
219 {
220 $ftpl = new ilTemplate("tpl.external_settings.html", true, true, "Services/Administration");
221
222
223 $stack = array();
224 foreach($fields as $field_caption_id => $field_value)
225 {
226 $field_type = $subitems = null;
227 if(is_array($field_value))
228 {
229 $field_type = $field_value[1];
230 $subitems = $field_value[2];
231 $field_value = $field_value[0];
232 }
233
234 if(self::parseFieldValue($field_type, $field_value))
235 {
236 $ftpl->setCurrentBlock("value_bl");
237 $ftpl->setVariable("VALUE", $field_value);
238 $ftpl->parseCurrentBlock();
239 }
240
241 if(is_array($subitems))
242 {
243 $ftpl->setCurrentBlock("subitem_bl");
244 foreach($subitems as $sub_caption_id => $sub_value)
245 {
246 $sub_type = null;
247 if(is_array($sub_value))
248 {
249 $sub_type = $sub_value[1];
250 $sub_value = $sub_value[0];
251 }
252 self::parseFieldValue($sub_type, $sub_value);
253
254 $ftpl->setVariable("SUBKEY", $lng->txt($sub_caption_id));
255 $ftpl->setVariable("SUBVALUE", $sub_value);
256 $ftpl->parseCurrentBlock();
257 }
258 }
259
260 $ftpl->setCurrentBlock("row_bl");
261 $ftpl->setVariable("KEY", $lng->txt($field_caption_id));
262 $ftpl->parseCurrentBlock();
263 }
264
265 if ($rbacsystem->checkAccess("visible,read", $a_gui->object->getRefId()))
266 {
267 if(!$cmd)
268 {
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}
287
288?>
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
static parseFieldDefinition($a_type, ilPropertyFormGUI $a_form, ilObjectGUI $a_gui, $a_data)
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
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39