ILIAS  release_4-3 Revision
 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/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,
103  "settings"),
104  "settings",
105  get_class($this));
106 
107  if ($rbacsystem->checkAccess("read",$this->object->getRefId()))
108  {
110  {
111  $tabs_gui->addTarget("statistics",
112  $this->ctrl->getLinkTargetByClass("illpobjectstatisticsgui",
113  "access"),
114  "",
115  "illpobjectstatisticsgui");
116  }
117 
119  {
120  $tabs_gui->addTarget("learning_progress",
121  $this->ctrl->getLinkTargetByClass("illearningprogressgui",
122  "show"),
123  "",
124  "illearningprogressgui");
125  }
126 
127  // session statistics
129  {
130  $tabs_gui->addTarget("session_statistics",
131  $this->ctrl->getLinkTargetByClass("ilsessionstatisticsgui",
132  ""),
133  "",
134  "ilsessionstatisticsgui");
135  }
136  }
137 
138  if ($rbacsystem->checkAccess("edit_permission",$this->object->getRefId()))
139  {
140  $tabs_gui->addTarget("perm_settings",
141  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
142  array("perm","info","owner"),
143  'ilpermissiongui');
144  }
145  }
146 
147 
151  function settingsObject($a_form = null)
152  {
153  global $rbacsystem;
154 
155  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
156  {
157  $ilErr->raiseError($this->lng->txt("msg_no_perm_read_track"),$ilErr->WARNING);
158  }
159 
160  $this->tabs_gui->setTabActive('settings');
161 
162  if(!$a_form)
163  {
164  $a_form = $this->initSettingsForm();
165  }
166 
167  $this->tpl->setContent($a_form->getHTML());
168  }
169 
170  protected function initSettingsForm()
171  {
172  global $rbacsystem;
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  // change event
230  $event = new ilCheckboxInputGUI($this->lng->txt('trac_repository_changes'), 'change_event_tracking');
231  if($this->object->enabledChangeEventTracking())
232  {
233  $event->setChecked(true);
234  }
235  $activate->addSubItem($event);
236 
237  // object statistics
238  $objstat = new ilCheckboxInputGUI($this->lng->txt('trac_object_statistics'), 'object_statistics');
239  if($this->object->enabledObjectStatistics())
240  {
241  $objstat->setChecked(true);
242  }
243  $activate->addSubItem($objstat);
244 
245  // session statistics
246  $sessstat = new ilCheckboxInputGUI($this->lng->txt('session_statistics'), 'session_statistics');
247  if($this->object->enabledSessionStatistics())
248  {
249  $sessstat->setChecked(true);
250  }
251  $activate->addSubItem($sessstat);
252 
253 
254  // Anonymized
255  $user = new ilCheckboxInputGUI($this->lng->txt('trac_anonymized'), 'user_related');
256  $user->setInfo($this->lng->txt('trac_anonymized_info'));
257  $user->setChecked(!$this->object->enabledUserRelatedData());
258  $form->addItem($user);
259 
260  // Max time gap
261  $valid = new ilNumberInputGUI($this->lng->txt('trac_valid_request'), 'valid_request');
262  $valid->setMaxLength(4);
263  $valid->setSize(4);
264  $valid->setSuffix($this->lng->txt('seconds'));
265  $valid->setInfo($this->lng->txt('info_valid_request'));
266  $valid->setValue($this->object->getValidTimeSpan());
267  $valid->setMinValue(1);
268  $valid->setMaxValue(9999);
269  $valid->setRequired(true);
270  $form->addItem($valid);
271 
272  // #12259
273  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
274  {
275  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
276  }
277  else
278  {
279  $lp->setDisabled(true);
280  $learner->setDisabled(true);
281  $extdata->setDisabled(true);
282  $event->setDisabled(true);
283  $objstat->setDisabled(true);
284  $user->setDisabled(true);
285  $valid->setDisabled(true);
286  }
287 
288  return $form;
289  }
290 
295  {
296  $form = $this->initSettingsForm();
297  if($form->checkInput())
298  {
299  $lp_active = $form->getInput('learning_progress_tracking');
300 
301  $this->object->enableLearningProgress($lp_active);
302 
303  if($lp_active)
304  {
305  $ext_data = (array)$form->getInput("lp_extdata");
306  $code = 0;
307  if(in_array('lp_access', $ext_data))
308  {
310  }
311  if(in_array('lp_count', $ext_data))
312  {
314  }
315  if(in_array('lp_spent', $ext_data))
316  {
318  }
319  $this->object->setExtendedData($code);
320  }
321 
322  $this->object->enableChangeEventTracking($form->getInput('change_event_tracking'));
323  $this->object->enableObjectStatistics($form->getInput('object_statistics'));
324  $this->object->enableUserRelatedData(!$form->getInput('user_related'));
325  $this->object->setValidTimeSpan($form->getInput('valid_request'));
326  // $this->object->setLearningProgressDesktop($form->getInput('lp_desktop'));
327  $this->object->setLearningProgressLearner($form->getInput('lp_learner'));
328  $this->object->enableSessionStatistics($form->getInput('session_statistics'));
329 
330  $this->object->updateSettings();
331 
332  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
333  $this->ctrl->redirect($this, "settings");
334  }
335 
336  $form->setValuesByPost();
337  $this->settingsObject($form);
338  return false;
339  }
340 }
341 
342 ?>