ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
20
21 public $tpl;
22 public $lng;
23 public $ctrl;
24 protected $tabs_gui;
25 protected $form;
26 protected $settings;
27
28
29 protected $log;
30
31
32
38 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
39 {
40 global $lng,$tpl,$ilCtrl,$ilTabs;
41
42 $this->type = 'logs';
43 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
44
45 $this->lng = $lng;
46
47 $this->tpl = $tpl;
48 $this->lng = $lng;
49 $this->ctrl = $ilCtrl;
50 $this->tabs_gui = $ilTabs;
51
52 $this->initSettings();
53 $this->lng->loadLanguageModule('logging');
54 $this->lng->loadLanguageModule('log');
55
56 include_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
57 $this->log = ilLoggerFactory::getLogger('log');
58
59 }
60
65 public function getLogger()
66 {
67 return $this->log;
68 }
69
76 public function executeCommand()
77 {
78 $next_class = $this->ctrl->getNextClass($this);
79 $cmd = $this->ctrl->getCmd();
80 $this->prepareOutput();
81
82 switch($next_class)
83 {
84 case 'ilpermissiongui':
85 $this->tabs_gui->setTabActive('perm_settings');
86 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
87 $perm_gui =& new ilPermissionGUI($this);
88 $ret =& $this->ctrl->forwardCommand($perm_gui);
89 break;
90
91 default:
92 if($cmd == "" || $cmd == "view")
93 {
94 $cmd = "settings";
95 }
96 $this->$cmd();
97
98 break;
99 }
100 return true;
101 }
102
103
110 public function getAdminTabs()
111 {
112 global $rbacsystem, $ilAccess;
113
114 if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
115 {
116 $this->tabs_gui->addTarget(
117 static::SECTION_SETTINGS,
118 $this->ctrl->getLinkTargetByClass('ilobjloggingsettingsgui', "settings")
119 );
120 }
121 if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
122 {
123 $this->tabs_gui->addTarget(
124 "perm_settings",
125 $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm")
126 );
127 }
128 }
129
130 public function setSubTabs($a_section)
131 {
132 $this->tabs_gui->addSubTab(
133 static::SUB_SECTION_MAIN,
134 $this->lng->txt(static::SUB_SECTION_MAIN),
135 $this->ctrl->getLinkTarget($this,'settings')
136 );
137 $this->tabs_gui->addSubTab(
138 static::SUB_SECTION_COMPONENTS,
139 $this->lng->txt(static::SUB_SECTION_COMPONENTS),
140 $this->ctrl->getLinkTarget($this,'components')
141 );
142
143 $this->tabs_gui->activateSubTab($a_section);
144 }
145
146 protected function initSettings()
147 {
148 include_once("Services/Logging/classes/class.ilLoggingDBSettings.php");
150 }
151
156 public function getSettings()
157 {
158 return $this->settings;
159 }
160
165 public function settings(ilPropertyFormGUI $form = null)
166 {
167 global $ilAccess,$ilErr;
168
169 if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
170 {
171 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
172 }
173
174 $this->tabs_gui->setTabActive(static::SECTION_SETTINGS);
175 $this->setSubTabs(static::SUB_SECTION_MAIN);
176
177 if(!$form instanceof ilPropertyFormGUI)
178 {
179 $form = $this->initFormSettings();
180 }
181 $this->tpl->setContent($form->getHTML());
182
183 $this->getLogger()->debug('Currrent level is '.$this->getSettings()->getLevel());
184
185 return TRUE;
186 }
187
192 public function updateSettings()
193 {
194 include_once 'Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
195
196 global $rbacsystem;
197
198 if(!$rbacsystem->checkAccess('write',$this->object->getRefId()))
199 {
200 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
201 }
202
203
204 $form = $this->initFormSettings();
205 if($form->checkInput())
206 {
207 $this->getSettings()->setLevel($form->getInput('level'));
208 $this->getSettings()->enableCaching($form->getInput('cache'));
209 $this->getSettings()->setCacheLevel($form->getInput('cache_level'));
210 $this->getSettings()->enableMemoryUsage($form->getInput('memory'));
211 $this->getSettings()->enableBrowserLog($form->getInput('browser'));
212 $this->getSettings()->setBrowserUsers($form->getInput('browser_users'));
213
214 $this->getLogger()->info(print_r($form->getInput('browser_users'),TRUE));
215
216 $this->getSettings()->update();
217
218 ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
219 $this->ctrl->redirect($this,'settings');
220 return TRUE;
221 }
222
223 ilUtil::sendFailure($this->lng->txt('err_check_input'));
224 $form->setValuesByPost();
225 $this->settings($form);
226
227 return TRUE;
228 }
229
234 protected function initFormSettings()
235 {
236 global $lng,$ilDB, $ilAccess;
237
238 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
239 include_once './Services/Search/classes/class.ilSearchSettings.php';
240
241 $form = new ilPropertyFormGUI();
242 $form->setTitle($this->lng->txt('logs_settings'));
243 $form->setFormAction($this->ctrl->getFormAction($this));
244
245 if($ilAccess->checkAccess('write','',$this->object->getRefId()))
246 {
247 $form->addCommandButton('updateSettings', $this->lng->txt('save'));
248 }
249
250 $level = new ilSelectInputGUI($this->lng->txt('log_log_level'),'level');
251 $level->setOptions(ilLogLevel::getLevelOptions());
252 $level->setValue($this->getSettings()->getLevel());
253 $form->addItem($level);
254
255 $cache = new ilCheckboxInputGUI($this->lng->txt('log_cache_'), 'cache');
256 $cache->setInfo($this->lng->txt('log_cache_info'));
257 $cache->setValue(1);
258 $cache->setChecked($this->getSettings()->isCacheEnabled());
259 $form->addItem($cache);
260
261 $cache_level = new ilSelectInputGUI($this->lng->txt('log_cache_level'), 'cache_level');
262 $cache_level->setOptions(ilLogLevel::getLevelOptions());
263 $cache_level->setValue($this->getSettings()->getCacheLevel());
264 $cache->addSubItem($cache_level);
265
266 $memory = new ilCheckboxInputGUI($this->lng->txt('log_memory'),'memory');
267 $memory->setValue(1);
268 $memory->setChecked($this->getSettings()->isMemoryUsageEnabled());
269 $form->addItem($memory);
270
271 // Browser handler
272 $browser = new ilCheckboxInputGUI($this->lng->txt('log_browser'),'browser');
273 $browser->setValue(1);
274 $browser->setChecked($this->getSettings()->isBrowserLogEnabled());
275 $form->addItem($browser);
276
277 // users
278 $users = new ilTextInputGUI($this->lng->txt('log_browser_users'), 'browser_users');
279 $users->setValue(current($this->getSettings()->getBrowserLogUsers()));
280 $users->setMulti(TRUE);
281 $users->setMultiValues($this->getSettings()->getBrowserLogUsers());
282
283 $this->getLogger()->debug(print_r($this->getSettings()->getBrowserLogUsers(),TRUE));
284
285 $browser->addSubItem($users);
286
287
288 return $form;
289 }
290
291
295 protected function components()
296 {
297 $this->tabs_gui->activateTab(static::SECTION_SETTINGS);
298 $this->setSubTabs(static::SUB_SECTION_COMPONENTS);
299
300 include_once './Services/Logging/classes/class.ilLogComponentTableGUI.php';
301 $table = new ilLogComponentTableGUI($this, 'components');
302 $table->init();
303 $table->parse();
304
305 $GLOBALS['tpl']->setContent($table->getHTML());
306
307 }
308
312 protected function saveComponentLevels()
313 {
315
316 foreach($_POST['level'] as $component_id => $value)
317 {
318 ilLoggerFactory::getLogger('log')->debug($component_id);
319 ilLoggerFactory::getLogger('log')->debug($value);
320 include_once './Services/Logging/classes/class.ilLogComponentLevel.php';
321 $level = new ilLogComponentLevel($component_id);
322 $level->setLevel($value);
323 $level->update();
324 }
325
326 ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
327 $this->ctrl->redirect($this, 'components');
328 }
329
330 protected function resetComponentLevels()
331 {
332 foreach(ilLogComponentLevels::getInstance()->getLogComponents() as $component)
333 {
334 $component->setLevel(null);
335 $component->update();
336 }
337 ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
338 $this->ctrl->redirect($this, 'components');
339
340 }
341
342}
343?>
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.
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()
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.
$_POST['username']
Definition: cron.php:12
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$cmd
Definition: sahs_server.php:35
global $ilDB