ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $ilErr = null;
23  var $lng = null;
24  var $ctrl = null;
25 
26  function ilObjUserTrackingGUI($a_data,$a_id,$a_call_by_reference)
27  {
28  global $tpl,$ilErr,$lng,$ilCtrl;
29 
30  $this->type = "trac";
31  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
32 
33  $this->tpl =& $tpl;
34  $this->ilErr =& $ilErr;
35  $this->lng =& $lng;
36  $this->lng->loadLanguageModule('trac');
37 
38  $this->ctrl =& $ilCtrl;
39  }
40 
41  function &executeCommand()
42  {
43  $next_class = $this->ctrl->getNextClass();
44  $this->ctrl->setReturn($this, "show");
45  $this->prepareOutput();
46 
47  switch($next_class)
48  {
49  case 'ilpermissiongui':
50  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
51  $perm_gui =& new ilPermissionGUI($this);
52  $ret =& $this->ctrl->forwardCommand($perm_gui);
53  break;
54 
55  case 'illearningprogressgui':
56  $this->tabs_gui->setTabActive('learning_progress');
57  include_once("./Services/Tracking/classes/class.ilLearningProgressGUI.php");
59  $ret =& $this->ctrl->forwardCommand($lp_gui);
60  break;
61 
62  case 'illpobjectstatisticsgui':
63  $this->tabs_gui->setTabActive('statistics');
64  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsGUI.php");
66  $ret =& $this->ctrl->forwardCommand($os_gui);
67  break;
68 
69  case 'ilsessionstatisticsgui':
70  $this->tabs_gui->setTabActive('session_statistics');
71  include_once("./Services/Authentication/classes/class.ilSessionStatisticsGUI.php");
72  $sess_gui =& new ilSessionStatisticsGUI();
73  $ret =& $this->ctrl->forwardCommand($sess_gui);
74  break;
75 
76  default:
77  $cmd = $this->ctrl->getCmd();
78  if ($cmd == "view" || $cmd == "")
79  {
80  $cmd = "settings";
81  }
82  $cmd .= "Object";
83  $this->$cmd();
84  break;
85  }
86 
87  return true;
88  }
89 
90  function getAdminTabs(&$tabs_gui)
91  {
92  $this->getTabs($tabs_gui);
93  }
94 
95  function getTabs(&$tabs_gui)
96  {
97  global $rbacsystem;
98 
99  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
100 
101  $tabs_gui->addTarget("settings",
102  $this->ctrl->getLinkTarget($this, "settings"),
103  "settings",
104  get_class($this));
105 
106  if ($rbacsystem->checkAccess("read",$this->object->getRefId()))
107  {
109  {
110  $tabs_gui->addTarget("statistics",
111  $this->ctrl->getLinkTargetByClass("illpobjectstatisticsgui",
112  "access"),
113  "",
114  "illpobjectstatisticsgui");
115  }
116 
118  {
119  $tabs_gui->addTarget("learning_progress",
120  $this->ctrl->getLinkTargetByClass("illearningprogressgui",
121  "show"),
122  "",
123  "illearningprogressgui");
124  }
125 
126  // session statistics
128  {
129  $tabs_gui->addTarget("session_statistics",
130  $this->ctrl->getLinkTargetByClass("ilsessionstatisticsgui",
131  ""),
132  "",
133  "ilsessionstatisticsgui");
134  }
135  }
136 
137  if ($rbacsystem->checkAccess("edit_permission",$this->object->getRefId()))
138  {
139  $tabs_gui->addTarget("perm_settings",
140  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
141  array("perm","info","owner"),
142  'ilpermissiongui');
143  }
144  }
145 
146 
150  function settingsObject($a_form = null)
151  {
152  global $rbacsystem;
153 
154  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
155  {
156  $ilErr->raiseError($this->lng->txt("msg_no_perm_read_track"),$ilErr->WARNING);
157  }
158 
159  $this->tabs_gui->setTabActive('settings');
160 
161  if(!$a_form)
162  {
163  $a_form = $this->initSettingsForm();
164  }
165 
166  $this->tpl->setContent($a_form->getHTML());
167  }
168 
169  protected function initSettingsForm()
170  {
171  global $rbacsystem;
172 
173  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
174  $form = new ilPropertyFormGUI();
175  $form->setFormAction($this->ctrl->getFormAction($this));
176  $form->setTitle($this->lng->txt('tracking_settings'));
177 
178  $activate = new ilCheckboxGroupInputGUI($this->lng->txt('activate_tracking'));
179  $form->addItem($activate);
180 
181  // learning progress
182  $lp = new ilCheckboxInputGUI($this->lng->txt('trac_learning_progress'), 'learning_progress_tracking');
183  if($this->object->enabledLearningProgress())
184  {
185  $lp->setChecked(true);
186  }
187  $activate->addSubItem($lp);
188 
189 
190  // lp settings
191 
192  /*
193  $desktop = new ilCheckboxInputGUI($this->lng->txt('trac_lp_on_personal_desktop'), 'lp_desktop');
194  $desktop->setInfo($this->lng->txt('trac_lp_on_personal_desktop_info'));
195  $desktop->setChecked($this->object->hasLearningProgressDesktop());
196  $lp->addSubItem($desktop);
197  */
198 
199  $learner = new ilCheckboxInputGUI($this->lng->txt('trac_lp_learner_access'), 'lp_learner');
200  $learner->setInfo($this->lng->txt('trac_lp_learner_access_info'));
201  $learner->setChecked($this->object->hasLearningProgressLearner());
202  $lp->addSubItem($learner);
203 
204 
205  // extended data
206 
207  $extdata = new ilCheckboxGroupInputGUI($this->lng->txt('trac_learning_progress_settings_info'), 'lp_extdata');
208  $extdata->addOption(new ilCheckboxOption($this->lng->txt('trac_first_and_last_access'), 'lp_access'));
209  $extdata->addOption(new ilCheckboxOption($this->lng->txt('trac_read_count'), 'lp_count'));
210  $extdata->addOption(new ilCheckboxOption($this->lng->txt('trac_spent_seconds'), 'lp_spent'));
211  $lp->addSubItem($extdata);
212 
213  $ext_value = array();
214  if($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
215  {
216  $ext_value[] = 'lp_access';
217  }
218  if($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT))
219  {
220  $ext_value[] = 'lp_count';
221  }
222  if($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS))
223  {
224  $ext_value[] = 'lp_spent';
225  }
226  $extdata->setValue($ext_value);
227 
228  $listgui = new ilCheckboxInputGUI($this->lng->txt('trac_lp_list_gui'), 'lp_list');
229  $listgui->setInfo($this->lng->txt('trac_lp_list_gui_info'));
230  $listgui->setChecked($this->object->hasLearningProgressListGUI());
231  $lp->addSubItem($listgui);
232 
233  /* => REPOSITORY
234  // change event
235  $event = new ilCheckboxInputGUI($this->lng->txt('trac_repository_changes'), 'change_event_tracking');
236  if($this->object->enabledChangeEventTracking())
237  {
238  $event->setChecked(true);
239  }
240  $activate->addSubItem($event);
241  */
242 
243  // object statistics
244  $objstat = new ilCheckboxInputGUI($this->lng->txt('trac_object_statistics'), 'object_statistics');
245  if($this->object->enabledObjectStatistics())
246  {
247  $objstat->setChecked(true);
248  }
249  $activate->addSubItem($objstat);
250 
251  // session statistics
252  $sessstat = new ilCheckboxInputGUI($this->lng->txt('session_statistics'), 'session_statistics');
253  if($this->object->enabledSessionStatistics())
254  {
255  $sessstat->setChecked(true);
256  }
257  $activate->addSubItem($sessstat);
258 
259  // Anonymized
260  $user = new ilCheckboxInputGUI($this->lng->txt('trac_anonymized'), 'user_related');
261  $user->setInfo($this->lng->txt('trac_anonymized_info'));
262  $user->setChecked(!$this->object->enabledUserRelatedData());
263  $form->addItem($user);
264 
265  // Max time gap
266  $valid = new ilNumberInputGUI($this->lng->txt('trac_valid_request'), 'valid_request');
267  $valid->setMaxLength(4);
268  $valid->setSize(4);
269  $valid->setSuffix($this->lng->txt('seconds'));
270  $valid->setInfo($this->lng->txt('info_valid_request'));
271  $valid->setValue($this->object->getValidTimeSpan());
272  $valid->setMinValue(1);
273  $valid->setMaxValue(9999);
274  $valid->setRequired(true);
275  $form->addItem($valid);
276 
277  include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
280  $form,
281  $this
282  );
283 
284  // #12259
285  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
286  {
287  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
288  }
289  else
290  {
291  $lp->setDisabled(true);
292  $learner->setDisabled(true);
293  $extdata->setDisabled(true);
294  $listgui->setDisabled(true);
295  $objstat->setDisabled(true);
296  $user->setDisabled(true);
297  $valid->setDisabled(true);
298  }
299 
300  return $form;
301  }
302 
307  {
308  global $rbacsystem;
309 
310  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
311  {
312  return;
313  }
314 
315  $form = $this->initSettingsForm();
316  if($form->checkInput())
317  {
318  $lp_active = $form->getInput('learning_progress_tracking');
319 
320  $this->object->enableLearningProgress($lp_active);
321 
322  if($lp_active)
323  {
324  $ext_data = (array)$form->getInput("lp_extdata");
325  $code = 0;
326  if(in_array('lp_access', $ext_data))
327  {
329  }
330  if(in_array('lp_count', $ext_data))
331  {
333  }
334  if(in_array('lp_spent', $ext_data))
335  {
337  }
338  $this->object->setExtendedData($code);
339  }
340 
341  $this->object->enableChangeEventTracking($form->getInput('change_event_tracking'));
342  $this->object->enableObjectStatistics($form->getInput('object_statistics'));
343  $this->object->enableUserRelatedData(!$form->getInput('user_related'));
344  $this->object->setValidTimeSpan($form->getInput('valid_request'));
345  // $this->object->setLearningProgressDesktop($form->getInput('lp_desktop'));
346  $this->object->setLearningProgressLearner($form->getInput('lp_learner'));
347  $this->object->enableSessionStatistics($form->getInput('session_statistics'));
348  $this->object->setLearningProgressListGUI($form->getInput('lp_list'));
349  $this->object->updateSettings();
350 
351  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
352  $this->ctrl->redirect($this, "settings");
353  }
354 
355  $form->setValuesByPost();
356  $this->settingsObject($form);
357  return false;
358  }
359 }
360 
361 ?>