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