ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjLoggingSettingsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Object/classes/class.ilObjectGUI.php';
5
15{
16 const SECTION_SETTINGS = 'settings';
17 const SUB_SECTION_MAIN = 'log_general_settings';
18 const SUB_SECTION_COMPONENTS = 'log_components';
19 const SUB_SECTION_ERROR = 'log_error_settings';
20
21
22 public $tpl;
23 public $lng;
24 public $ctrl;
25 protected $tabs_gui;
26 protected $form;
27 protected $settings;
28
29
30 protected $log;
31
32
33
39 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
40 {
41 global $lng,$tpl,$ilCtrl,$ilTabs;
42
43 $this->type = 'logs';
44 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
45
46 $this->lng = $lng;
47
48 $this->tpl = $tpl;
49 $this->lng = $lng;
50 $this->ctrl = $ilCtrl;
51 $this->tabs_gui = $ilTabs;
52
53 $this->initSettings();
54 $this->initErrorSettings();
55 $this->lng->loadLanguageModule('logging');
56 $this->lng->loadLanguageModule('log');
57
58 include_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
59 $this->log = ilLoggerFactory::getLogger('log');
60
61 }
62
67 public function getLogger()
68 {
69 return $this->log;
70 }
71
78 public function executeCommand()
79 {
80 $next_class = $this->ctrl->getNextClass($this);
81 $cmd = $this->ctrl->getCmd();
82 $this->prepareOutput();
83
84 switch($next_class)
85 {
86 case 'ilpermissiongui':
87 $this->tabs_gui->setTabActive('perm_settings');
88 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
89 $perm_gui = new ilPermissionGUI($this);
90 $ret =& $this->ctrl->forwardCommand($perm_gui);
91 break;
92
93 default:
94 if($cmd == "" || $cmd == "view")
95 {
96 $cmd = "settings";
97 }
98 $this->$cmd();
99
100 break;
101 }
102 return true;
103 }
104
105
112 public function getAdminTabs()
113 {
114 global $rbacsystem, $ilAccess;
115
116 if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
117 {
118 $this->tabs_gui->addTarget(
119 static::SECTION_SETTINGS,
120 $this->ctrl->getLinkTargetByClass('ilobjloggingsettingsgui', "settings")
121 );
122 }
123 if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
124 {
125 $this->tabs_gui->addTarget(
126 "perm_settings",
127 $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm")
128 );
129 }
130 }
131
132 public function setSubTabs($a_section)
133 {
134 $this->tabs_gui->addSubTab(
135 static::SUB_SECTION_MAIN,
136 $this->lng->txt(static::SUB_SECTION_MAIN),
137 $this->ctrl->getLinkTarget($this,'settings')
138 );
139 $this->tabs_gui->addSubTab(
140 static::SUB_SECTION_ERROR,
141 $this->lng->txt(static::SUB_SECTION_ERROR),
142 $this->ctrl->getLinkTarget($this,'errorSettings')
143 );
144 $this->tabs_gui->addSubTab(
145 static::SUB_SECTION_COMPONENTS,
146 $this->lng->txt(static::SUB_SECTION_COMPONENTS),
147 $this->ctrl->getLinkTarget($this,'components')
148 );
149
150 $this->tabs_gui->activateSubTab($a_section);
151 }
152
153 protected function initSettings()
154 {
155 include_once("Services/Logging/classes/class.ilLoggingDBSettings.php");
157 }
158
163 public function getSettings()
164 {
165 return $this->settings;
166 }
167
172 public function settings(ilPropertyFormGUI $form = null)
173 {
174 global $ilAccess,$ilErr;
175
176 if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
177 {
178 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
179 }
180
181 $this->tabs_gui->setTabActive(static::SECTION_SETTINGS);
182 $this->setSubTabs(static::SUB_SECTION_MAIN);
183
184 if(!$form instanceof ilPropertyFormGUI)
185 {
186 $form = $this->initFormSettings();
187 }
188 $this->tpl->setContent($form->getHTML());
189
190 $this->getLogger()->debug('Currrent level is '.$this->getSettings()->getLevel());
191
192 return TRUE;
193 }
194
199 public function updateSettings()
200 {
201 include_once 'Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
202
203 global $rbacsystem;
204
205 if(!$rbacsystem->checkAccess('write',$this->object->getRefId()))
206 {
207 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
208 }
209
210
211 $form = $this->initFormSettings();
212 if($form->checkInput())
213 {
214 $this->getSettings()->setLevel($form->getInput('level'));
215 $this->getSettings()->enableCaching($form->getInput('cache'));
216 $this->getSettings()->setCacheLevel($form->getInput('cache_level'));
217 $this->getSettings()->enableMemoryUsage($form->getInput('memory'));
218 $this->getSettings()->enableBrowserLog($form->getInput('browser'));
219 $this->getSettings()->setBrowserUsers($form->getInput('browser_users'));
220
221 $this->getLogger()->info(print_r($form->getInput('browser_users'),TRUE));
222
223 $this->getSettings()->update();
224
225 ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
226 $this->ctrl->redirect($this,'settings');
227 return TRUE;
228 }
229
230 ilUtil::sendFailure($this->lng->txt('err_check_input'));
231 $form->setValuesByPost();
232 $this->settings($form);
233
234 return TRUE;
235 }
236
241 protected function initFormSettings()
242 {
243 global $lng,$ilDB, $ilAccess;
244
245 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
246 include_once './Services/Search/classes/class.ilSearchSettings.php';
247
248 $form = new ilPropertyFormGUI();
249 $form->setTitle($this->lng->txt('logs_settings'));
250 $form->setFormAction($this->ctrl->getFormAction($this));
251
252 if($ilAccess->checkAccess('write','',$this->object->getRefId()))
253 {
254 $form->addCommandButton('updateSettings', $this->lng->txt('save'));
255 }
256
257 $level = new ilSelectInputGUI($this->lng->txt('log_log_level'),'level');
258 $level->setOptions(ilLogLevel::getLevelOptions());
259 $level->setValue($this->getSettings()->getLevel());
260 $form->addItem($level);
261
262 $cache = new ilCheckboxInputGUI($this->lng->txt('log_cache_'), 'cache');
263 $cache->setInfo($this->lng->txt('log_cache_info'));
264 $cache->setValue(1);
265 $cache->setChecked($this->getSettings()->isCacheEnabled());
266 $form->addItem($cache);
267
268 $cache_level = new ilSelectInputGUI($this->lng->txt('log_cache_level'), 'cache_level');
269 $cache_level->setOptions(ilLogLevel::getLevelOptions());
270 $cache_level->setValue($this->getSettings()->getCacheLevel());
271 $cache->addSubItem($cache_level);
272
273 $memory = new ilCheckboxInputGUI($this->lng->txt('log_memory'),'memory');
274 $memory->setValue(1);
275 $memory->setChecked($this->getSettings()->isMemoryUsageEnabled());
276 $form->addItem($memory);
277
278 // Browser handler
279 $browser = new ilCheckboxInputGUI($this->lng->txt('log_browser'),'browser');
280 $browser->setValue(1);
281 $browser->setChecked($this->getSettings()->isBrowserLogEnabled());
282 $form->addItem($browser);
283
284 // users
285 $users = new ilTextInputGUI($this->lng->txt('log_browser_users'), 'browser_users');
286 $users->setValue(current($this->getSettings()->getBrowserLogUsers()));
287 $users->setMulti(TRUE);
288 $users->setMultiValues($this->getSettings()->getBrowserLogUsers());
289
290 $this->getLogger()->debug(print_r($this->getSettings()->getBrowserLogUsers(),TRUE));
291
292 $browser->addSubItem($users);
293
294
295 return $form;
296 }
297
298
302 protected function components()
303 {
304 $this->tabs_gui->activateTab(static::SECTION_SETTINGS);
305 $this->setSubTabs(static::SUB_SECTION_COMPONENTS);
306
307 include_once './Services/Logging/classes/class.ilLogComponentTableGUI.php';
308 $table = new ilLogComponentTableGUI($this, 'components');
309 $table->init();
310 $table->parse();
311
312 $GLOBALS['tpl']->setContent($table->getHTML());
313
314 }
315
319 protected function saveComponentLevels()
320 {
322
323 foreach($_POST['level'] as $component_id => $value)
324 {
325 ilLoggerFactory::getLogger('log')->debug($component_id);
326 ilLoggerFactory::getLogger('log')->debug($value);
327 include_once './Services/Logging/classes/class.ilLogComponentLevel.php';
328 $level = new ilLogComponentLevel($component_id);
329 $level->setLevel($value);
330 $level->update();
331 }
332
333 ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
334 $this->ctrl->redirect($this, 'components');
335 }
336
337 protected function resetComponentLevels()
338 {
339 foreach(ilLogComponentLevels::getInstance()->getLogComponents() as $component)
340 {
341 $component->setLevel(null);
342 $component->update();
343 }
344 ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
345 $this->ctrl->redirect($this, 'components');
346
347 }
348
349 protected function errorSettings() {
350 global $ilAccess,$ilErr;
351
352 if(!$ilAccess->checkAccess('read','',$this->object->getRefId())) {
353 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
354 }
355
356 $this->tabs_gui->setTabActive(static::SECTION_SETTINGS);
357 $this->setSubTabs(static::SUB_SECTION_ERROR);
358
359 if(!$form instanceof ilPropertyFormGUI) {
360 $form = $this->initFormErrorSettings();
361 }
362 $this->tpl->setContent($form->getHTML());
363
364 $this->getLogger()->debug('Currrent level is '.$this->getSettings()->getLevel());
365 }
366
367 protected function updateErrorSettings() {
368 global $rbacsystem;
369
370 if(!$rbacsystem->checkAccess('write',$this->object->getRefId())) {
371 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
372 }
373
374 $form = $this->initFormErrorSettings();
375 if($form->checkInput()) {
376 $this->getErrorSettings()->setMail($form->getInput('error_mail'));
377 $this->getErrorSettings()->update();
378
379 ilUtil::sendSuccess($this->lng->txt('error_settings_saved'),TRUE);
380 $this->ctrl->redirect($this,'errorSettings');
381 }
382
383 ilUtil::sendFailure($this->lng->txt('err_check_input'));
384 $form->setValuesByPost();
385 $this->errorSettings($form);
386 }
387
388 protected function initFormErrorSettings() {
389 global $lng,$ilDB, $ilAccess;
390
391 require_once './Services/Form/classes/class.ilPropertyFormGUI.php';
392 require_once './Services/Search/classes/class.ilSearchSettings.php';
393
394 $form = new ilPropertyFormGUI();
395 $form->setTitle($this->lng->txt('logs_settings'));
396 $form->setFormAction($this->ctrl->getFormAction($this));
397
398 if($ilAccess->checkAccess('write','',$this->object->getRefId())) {
399 $form->addCommandButton('updateErrorSettings', $this->lng->txt('save'));
400 }
401
402 $folder = new ilNonEditableValueGUI($this->lng->txt('log_error_folder'), 'error_folder');
403 $folder->setValue($this->getErrorSettings()->folder());
404 $form->addItem($folder);
405
406 $mail = new ilTextInputGUI($this->lng->txt('log_error_mail'), 'error_mail');
407 $mail->setValue($this->getErrorSettings()->mail());
408 $form->addItem($mail);
409
410 return $form;
411 }
412
413 protected function initErrorSettings() {
414 require_once("Services/Logging/classes/error/class.ilLoggingErrorSettings.php");
415 $this->error_settings = ilLoggingErrorSettings::getInstance();
416 }
417
418 protected function getErrorSettings() {
419 return $this->error_settings;
420 }
421}
422?>
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
individual log levels for components
Component logger with individual log levels by component id.
static getLevelOptions()
Get log level options.
static getLogger($a_component_id)
Get component logger.
static getInstance()
Get instance.
This class represents a non editable value in a property form.
settings(ilPropertyFormGUI $form=null)
Show settings @access public.
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
updateSettings()
Save settings @access public.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
mail($to, $subject, $message, $additional_headers=null, $additional_parameters=null)
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
global $ilDB