ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjUserTrackingGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Object/classes/class.ilObjectGUI.php";
5
20{
21
25 public $tpl = null;
29 public $lng = null;
33 public $ctrl = null;
37 protected $dic;
41 protected $rbacsystem;
42
43 public function __construct($a_data, $a_id, $a_call_by_reference)
44 {
45 global $DIC;
46
47 $this->type = "trac";
48 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
49
50 $this->dic = $DIC;
51 $this->tpl = $this->dic['tpl'];
52 $this->lng = $this->dic->language();
53 $this->lng->loadLanguageModule('trac');
54 $this->rbacsystem = $this->dic->rbac()->system();
55
56 $this->ctrl = $this->dic->ctrl();
57 }
58
59 public function executeCommand()
60 {
61 $next_class = $this->ctrl->getNextClass();
62 $this->ctrl->setReturn($this, "show");
63 $this->prepareOutput();
64
65 switch ($next_class) {
66 case 'ilpermissiongui':
67 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
68 $perm_gui = new ilPermissionGUI($this);
69 $ret = &$this->ctrl->forwardCommand($perm_gui);
70 break;
71
72 case 'illearningprogressgui':
73 $this->tabs_gui->setTabActive('learning_progress');
74 include_once("./Services/Tracking/classes/class.ilLearningProgressGUI.php");
76 $ret = &$this->ctrl->forwardCommand($lp_gui);
77 break;
78
79 case 'illpobjectstatisticsgui':
80 $this->tabs_gui->setTabActive('statistics');
81 include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsGUI.php");
83 $ret = &$this->ctrl->forwardCommand($os_gui);
84 break;
85
86 case 'ilsessionstatisticsgui':
87 $this->tabs_gui->setTabActive('session_statistics');
88 include_once("./Services/Authentication/classes/class.ilSessionStatisticsGUI.php");
89 $sess_gui = new ilSessionStatisticsGUI();
90 $ret = &$this->ctrl->forwardCommand($sess_gui);
91 break;
92
93 default:
94 $cmd = $this->ctrl->getCmd();
95 if ($cmd == "view" || $cmd == "") {
96 $cmd = "settings";
97 }
98 $cmd .= "Object";
99 $this->$cmd();
100 break;
101 }
102
103 return true;
104 }
105
106 public function getAdminTabs()
107 {
108 $this->getTabs();
109 }
110
111 public function getTabs()
112 {
113 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
114
115 $this->tabs_gui->addTarget(
116 "settings",
117 $this->ctrl->getLinkTarget($this, "settings"),
118 "settings",
119 get_class($this)
120 );
121
122 if ($this->rbacsystem->checkAccess("visible,read", $this->ref_id)) {
124 $this->tabs_gui->addTarget(
125 "statistics",
126 $this->ctrl->getLinkTargetByClass(
127 "illpobjectstatisticsgui",
128 "access"
129 ),
130 "",
131 "illpobjectstatisticsgui"
132 );
133 }
134
136 $this->tabs_gui->addTarget(
137 "learning_progress",
138 $this->ctrl->getLinkTargetByClass(
139 "illearningprogressgui",
140 "show"
141 ),
142 "",
143 "illearningprogressgui"
144 );
145 }
146
147 // session statistics
149 $this->tabs_gui->addTarget(
150 "session_statistics",
151 $this->ctrl->getLinkTargetByClass(
152 "ilsessionstatisticsgui",
153 ""
154 ),
155 "",
156 "ilsessionstatisticsgui"
157 );
158 }
159 }
160
161 if ($this->checkPermissionBool("edit_permission")) {
162 $this->tabs_gui->addTarget(
163 "perm_settings",
164 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
165 array("perm","info","owner"),
166 'ilpermissiongui'
167 );
168 }
169 }
170
171
175 public function settingsObject($a_form = null)
176 {
177 global $ilErr;
178
179 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
180 $ilErr->raiseError($this->lng->txt("no_permission"), $ilErr->WARNING);
181 }
182
183 $this->tabs_gui->addSubTab(
184 'lp_settings',
185 $this->lng->txt('settings'),
186 $this->ctrl->getLinkTarget($this, 'settings')
187 );
188
190 $this->tabs_gui->addSubTab(
191 'lpdef',
192 $this->lng->txt('trac_defaults'),
193 $this->ctrl->getLinkTarget($this, 'editLPDefaults')
194 );
195 }
196
197 $this->tabs_gui->setTabActive('settings');
198 $this->tabs_gui->setSubTabActive('lp_settings');
199
200 if (!$a_form) {
201 $a_form = $this->initSettingsForm();
202 }
203
204 $this->tpl->setContent($a_form->getHTML());
205 }
206
207 protected function initSettingsForm()
208 {
209 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
210 $form = new ilPropertyFormGUI();
211 $form->setFormAction($this->ctrl->getFormAction($this));
212 $form->setTitle($this->lng->txt('tracking_settings'));
213
214 $activate = new ilCheckboxGroupInputGUI($this->lng->txt('activate_tracking'));
215 $form->addItem($activate);
216
217 // learning progress
218 $lp = new ilCheckboxInputGUI($this->lng->txt('trac_learning_progress'), 'learning_progress_tracking');
219 if ($this->object->enabledLearningProgress()) {
220 $lp->setChecked(true);
221 }
222 $activate->addSubItem($lp);
223
224
225 // lp settings
226
227 $learner = new ilCheckboxInputGUI($this->lng->txt('trac_lp_learner_access'), 'lp_learner');
228 $learner->setInfo($this->lng->txt('trac_lp_learner_access_info'));
229 $learner->setChecked($this->object->hasLearningProgressLearner());
230 $lp->addSubItem($learner);
231
232
233 // extended data
234
235 $extdata = new ilCheckboxGroupInputGUI($this->lng->txt('trac_learning_progress_settings_info'), 'lp_extdata');
236 $extdata->addOption(new ilCheckboxOption($this->lng->txt('trac_first_and_last_access'), 'lp_access'));
237 $extdata->addOption(new ilCheckboxOption($this->lng->txt('trac_read_count'), 'lp_count'));
238 $extdata->addOption(new ilCheckboxOption($this->lng->txt('trac_spent_seconds'), 'lp_spent'));
239 $lp->addSubItem($extdata);
240
241 $ext_value = array();
242 if ($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
243 $ext_value[] = 'lp_access';
244 }
245 if ($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
246 $ext_value[] = 'lp_count';
247 }
248 if ($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
249 $ext_value[] = 'lp_spent';
250 }
251 $extdata->setValue($ext_value);
252
253 $listgui = new ilCheckboxInputGUI($this->lng->txt('trac_lp_list_gui'), 'lp_list');
254 $listgui->setInfo($this->lng->txt('trac_lp_list_gui_info'));
255 $listgui->setChecked($this->object->hasLearningProgressListGUI());
256 $lp->addSubItem($listgui);
257
258 /* => REPOSITORY
259 // change event
260 $event = new ilCheckboxInputGUI($this->lng->txt('trac_repository_changes'), 'change_event_tracking');
261 if($this->object->enabledChangeEventTracking())
262 {
263 $event->setChecked(true);
264 }
265 $activate->addSubItem($event);
266 */
267
268 // object statistics
269 $objstat = new ilCheckboxInputGUI($this->lng->txt('trac_object_statistics'), 'object_statistics');
270 if ($this->object->enabledObjectStatistics()) {
271 $objstat->setChecked(true);
272 }
273 $activate->addSubItem($objstat);
274
275 // session statistics
276 $sessstat = new ilCheckboxInputGUI($this->lng->txt('session_statistics'), 'session_statistics');
277 if ($this->object->enabledSessionStatistics()) {
278 $sessstat->setChecked(true);
279 }
280 $activate->addSubItem($sessstat);
281
282 // Anonymized
283 $user = new ilCheckboxInputGUI($this->lng->txt('trac_anonymized'), 'user_related');
284 $user->setInfo($this->lng->txt('trac_anonymized_info'));
285 $user->setChecked(!$this->object->enabledUserRelatedData());
286 $form->addItem($user);
287
288 // Max time gap
289 $valid = new ilNumberInputGUI($this->lng->txt('trac_valid_request'), 'valid_request');
290 $valid->setMaxLength(4);
291 $valid->setSize(4);
292 $valid->setSuffix($this->lng->txt('seconds'));
293 $valid->setInfo($this->lng->txt('info_valid_request'));
294 $valid->setValue($this->object->getValidTimeSpan());
295 $valid->setMinValue(1);
296 $valid->setMaxValue(9999);
297 $valid->setRequired(true);
298 $form->addItem($valid);
299
300 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
303 $form,
304 $this
305 );
306
307 // #12259
308 if ($this->checkPermissionBool("write")) {
309 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
310 } else {
311 $lp->setDisabled(true);
312 $learner->setDisabled(true);
313 $extdata->setDisabled(true);
314 $listgui->setDisabled(true);
315 $objstat->setDisabled(true);
316 $user->setDisabled(true);
317 $valid->setDisabled(true);
318 }
319
320 return $form;
321 }
322
326 public function saveSettingsObject()
327 {
328 $this->checkPermission('write');
329
330 $form = $this->initSettingsForm();
331 if ($form->checkInput()) {
332 $lp_active = $form->getInput('learning_progress_tracking');
333
334 $this->object->enableLearningProgress($lp_active);
335
336 if ($lp_active) {
337 $ext_data = (array) $form->getInput("lp_extdata");
338 $code = 0;
339 if (in_array('lp_access', $ext_data)) {
341 }
342 if (in_array('lp_count', $ext_data)) {
344 }
345 if (in_array('lp_spent', $ext_data)) {
347 }
348 $this->object->setExtendedData($code);
349 }
350
351 $this->object->enableChangeEventTracking($form->getInput('change_event_tracking'));
352 $this->object->enableObjectStatistics($form->getInput('object_statistics'));
353 $this->object->enableUserRelatedData(!$form->getInput('user_related'));
354 $this->object->setValidTimeSpan($form->getInput('valid_request'));
355 // $this->object->setLearningProgressDesktop($form->getInput('lp_desktop'));
356 $this->object->setLearningProgressLearner($form->getInput('lp_learner'));
357 $this->object->enableSessionStatistics($form->getInput('session_statistics'));
358 $this->object->setLearningProgressListGUI($form->getInput('lp_list'));
359 $this->object->updateSettings();
360
361 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
362 $this->ctrl->redirect($this, "settings");
363 }
364
365 $form->setValuesByPost();
366 $this->settingsObject($form);
367 return false;
368 }
369
370
371 //
372 // LP DEFAULTS
373 //
374
375 protected function editLPDefaultsObject($a_form = null)
376 {
377 $this->checkPermission('read');
378
379 $this->tabs_gui->addSubTab(
380 'lp_settings',
381 $this->lng->txt('settings'),
382 $this->ctrl->getLinkTarget($this, 'settings')
383 );
384
385 $this->tabs_gui->addSubTab(
386 'lpdef',
387 $this->lng->txt('trac_defaults'),
388 $this->ctrl->getLinkTarget($this, 'editLPDefaults')
389 );
390
391 $this->tabs_gui->setTabActive('settings');
392 $this->tabs_gui->setSubTabActive('lpdef');
393
394 if (!$a_form) {
395 $a_form = $this->initLPDefaultsForm();
396 }
397
398 $this->tpl->setContent($a_form->getHTML());
399 }
400
401 protected function initLPDefaultsForm()
402 {
403 global $DIC;
404
405 $objDefinition = $DIC['objDefinition'];
406
407 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
408 $form = new ilPropertyFormGUI();
409 $form->setFormAction($this->ctrl->getFormAction($this));
410 $form->setTitle($this->lng->txt('trac_defaults'));
411 $form->setDescription($this->lng->txt('trac_defaults_info'));
412
413 include_once "Services/Object/classes/class.ilObjectLP.php";
414 include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
415
416 $types = array();
417 foreach ($objDefinition->getAllRepositoryTypes() as $type) {
419 $types[$type] = array(
420 "type" => $type,
421 "caption" => $this->lng->txt("obj_" . $type)
422 );
423 }
424 }
425 $types = ilUtil::sortArray($types, "caption", "asc");
426 foreach ($types as $item) {
427 $class = ilObjectLP::getTypeClass($item["type"]);
428 $modes = $class::getDefaultModes(ilObjUserTracking::_enabledLearningProgress());
429 if (sizeof($modes) > 1) {
430 $def_type = new ilSelectInputGUI($item["caption"], "def_" . $item["type"]);
431 $form->addItem($def_type);
432
433 $def_type->setRequired(true);
434 $def_type->setValue(ilObjectLP::getTypeDefault($item["type"]));
435
436 $options = array();
437 foreach ($modes as $mode) {
438 $caption = ($mode == ilLPObjSettings::LP_MODE_DEACTIVATED)
439 ? $this->lng->txt("trac_defaults_inactive")
441 $options[$mode] = $caption;
442 }
443 $def_type->setOptions($options);
444 }
445 }
446
447 if ($this->checkPermissionBool("write")) {
448 $form->addCommandButton('saveLPDefaults', $this->lng->txt('save'));
449 } else {
450 foreach ($types as $item) {
451 $form->getItemByPostVar("def_" . $item["type"])->setDisabled(true);
452 }
453 }
454
455 return $form;
456 }
457
458 protected function saveLPDefaultsObject()
459 {
460 global $DIC;
461
462 $objDefinition = $DIC['objDefinition'];
463
464 $this->checkPermission('write');
465
466 $form = $this->initLPDefaultsForm();
467 if ($form->checkInput()) {
468 include_once "Services/Object/classes/class.ilObjectLP.php";
469 include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
470
471 $res = array();
472 foreach ($objDefinition->getAllRepositoryTypes() as $type) {
474 $mode = $form->getInput("def_" . $type);
475 $res[$type] = $mode
476 ? $mode
478 }
479 }
480
482
483 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
484 $this->ctrl->redirect($this, "editLPDefaults");
485 }
486
487 $form->setValuesByPost();
488 $this->editLPDefaultsObject($form);
489 return false;
490 }
491
496 public function addToExternalSettingsForm($a_form_id)
497 {
498 switch ($a_form_id) {
500 $fields = array();
501
502 return array('obj_trac' => array('editLPDefaults', $fields));
503 }
504 }
505}
An exception for terminatinating execution or to throw for unit testing.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
static _mode2Text($a_mode)
Class ilObjUserTrackingGUI.
This class represents a number property in a property form.
saveSettingsObject()
save user tracking settings
settingsObject($a_form=null)
display tracking settings form
__construct($a_data, $a_id, $a_call_by_reference)
getTabs()
get tabs abstract method.
getAdminTabs()
administration tabs show only permissions and trash folder
static _enabledObjectStatistics()
check wether object statistics is enabled or not
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledSessionStatistics()
check wether session statistics is enabled or not
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
static saveTypeDefaults(array $a_data)
static isSupportedObjectType($type)
static getTypeClass($a_type)
static getTypeDefault($a_type)
Get current type default.
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.
Class ilSessionStatisticsGUI.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$valid
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$type
foreach($_POST as $key=> $value) $res