ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjUserTracking.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 include_once "./Services/Object/classes/class.ilObject.php";
17 
19 {
28 
29  // BEGIN ChangeEvent
34  // BEGIN ChangeEvent
35 
39 
40  const DEFAULT_TIME_SPAN = 300;
41 
48  function ilObjUserTracking($a_id = 0,$a_call_by_reference = true)
49  {
50  $this->type = "trac";
51  $this->ilObject($a_id,$a_call_by_reference);
52 
53  $this->__readSettings();
54  }
55 
56  function enableLearningProgress($a_enable)
57  {
58  $this->learning_progress = (bool)$a_enable;
59  }
60 
62  {
64  }
65 
69  static function _enabledLearningProgress()
70  {
71  global $ilSetting;
72 
73  return (bool)$ilSetting->get("enable_tracking", 0);
74  }
75 
79  function enableUserRelatedData($a_enable)
80  {
81  $this->tracking_user_related = (bool)$a_enable;
82  }
83 
85  {
86  return (bool)$this->tracking_user_related;
87  }
88 
92  static function _enabledUserRelatedData()
93  {
94  global $ilSetting;
95 
96  return (bool)$ilSetting->get('save_user_related_data');
97  }
98 
102  static function _enabledObjectStatistics()
103  {
104  global $ilSetting;
105 
106  return (bool)$ilSetting->get('object_statistics', 0);
107  }
108 
115  public function enableObjectStatistics($newValue)
116  {
117  $this->object_statistics_enabled = (bool)$newValue;
118  }
124  public function enabledObjectStatistics()
125  {
127  }
128 
135  public function enableSessionStatistics($newValue)
136  {
137  $this->session_statistics_enabled = (bool)$newValue;
138  }
144  public function enabledSessionStatistics()
145  {
147  }
148 
152  static function _enabledSessionStatistics()
153  {
154  global $ilSetting;
155 
156  return (bool)$ilSetting->get('session_statistics', 1);
157  }
158 
159  function setValidTimeSpan($a_time_span)
160  {
161  $this->valid_time = (int)$a_time_span;
162  }
163 
164  function getValidTimeSpan()
165  {
166  return (int)$this->valid_time;
167  }
168 
169  static function _getValidTimeSpan()
170  {
171  global $ilSetting;
172 
173  return (int)$ilSetting->get("tracking_time_span", self::DEFAULT_TIME_SPAN);
174  }
175 
176  // BEGIN ChangeEvent
183  public function enableChangeEventTracking($newValue)
184  {
185  $this->is_change_event_tracking_enabled = (bool)$newValue;
186  }
192  public function enabledChangeEventTracking()
193  {
195  }
196  // END ChangeEvent
197 
198  function setExtendedData($a_value)
199  {
200  $this->extended_data = $a_value;
201  }
202 
203  function hasExtendedData($a_code)
204  {
205  return $this->extended_data & $a_code;
206  }
207 
208  function updateSettings()
209  {
210  global $ilSetting;
211 
212  $ilSetting->set("enable_tracking", (int)$this->enabledLearningProgress());
213  $ilSetting->set("save_user_related_data", (int)$this->enabledUserRelatedData());
214  $ilSetting->set("tracking_time_span",$this->getValidTimeSpan());
215  $ilSetting->set("lp_extended_data", $this->extended_data);
216  $ilSetting->set("object_statistics", (int)$this->enabledObjectStatistics());
217  // $ilSetting->set("lp_desktop", (int)$this->hasLearningProgressDesktop());
218  $ilSetting->set("lp_learner", (int)$this->hasLearningProgressLearner());
219  $ilSetting->set("session_statistics", (int)$this->enabledSessionStatistics());
220  $ilSetting->set("lp_list_gui", (int)$this->hasLearningProgressListGUI());
221 
222  /* => REPOSITORY
223  // BEGIN ChangeEvent
224  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
225  if ($this->enabledChangeEventTracking() != ilChangeEvent::_isActive())
226  {
227  if ($this->enabledChangeEventTracking())
228  {
229  ilChangeEvent::_activate();
230  }
231  else
232  {
233  ilChangeEvent::_deactivate();
234  }
235  }
236  // END ChangeEvent
237  */
238 
239  return true;
240  }
241 
242  protected function __readSettings()
243  {
244  global $ilSetting;
245 
246  $this->enableLearningProgress($ilSetting->get("enable_tracking",0));
247  $this->enableUserRelatedData($ilSetting->get("save_user_related_data",0));
248  $this->enableObjectStatistics($ilSetting->get("object_statistics",0));
249  $this->setValidTimeSpan($ilSetting->get("tracking_time_span", self::DEFAULT_TIME_SPAN));
250  // $this->setLearningProgressDesktop($ilSetting->get("lp_desktop", 1));
251  $this->setLearningProgressLearner($ilSetting->get("lp_learner", 1));
252  $this->enableSessionStatistics($ilSetting->get("session_statistics", 1));
253  $this->setLearningProgressListGUI($ilSetting->get("lp_list_gui", 0));
254 
255  // BEGIN ChangeEvent
256  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
258  // END ChangeEvent
259 
260  $this->setExtendedData($ilSetting->get("lp_extended_data"),0);
261 
262  return true;
263  }
264 
265  static function _deleteUser($a_usr_id)
266  {
267  global $ilDB;
268 
269  $query = "DELETE FROM ut_access WHERE user_id = ".$ilDB->quote($a_usr_id, "integer")."";
270  $ilDB->manipulate($query);
271 
272  $query = sprintf('DELETE FROM read_event WHERE usr_id = %s ',
273  $ilDB->quote($a_usr_id,'integer'));
274  $aff = $ilDB->manipulate($query);
275 
276  $query = sprintf('DELETE FROM write_event WHERE usr_id = %s ',
277  $ilDB->quote($a_usr_id,'integer'));
278  $aff = $ilDB->manipulate($query);
279 
280  $query = "DELETE FROM ut_lp_marks WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
281  $res = $ilDB->manipulate($query);
282 
283  $ilDB->manipulate("DELETE FROM ut_online WHERE usr_id = ".
284  $ilDB->quote($a_usr_id, "integer"));
285 
286  return true;
287  }
288 
289  /*
290  function setLearningProgressDesktop($a_value)
291  {
292  $this->lp_desktop = (bool)$a_value;
293  }
294 
295  function hasLearningProgressDesktop()
296  {
297  return (bool)$this->lp_desktop;
298  }
299 
300  static function _hasLearningProgressDesktop()
301  {
302  global $ilias;
303 
304  return (bool)$ilias->getSetting("lp_desktop");
305  }
306  */
307 
309  {
310  global $rbacsystem;
311 
312  $obj_id = array_pop(array_keys(ilObject::_getObjectsByType("trac")));
313  $ref_id = array_pop(ilObject::_getAllReferences($obj_id));
314 
315  return $rbacsystem->checkAccess("lp_other_users", $ref_id);
316  }
317 
318  function setLearningProgressLearner($a_value)
319  {
320  $this->lp_learner = (bool)$a_value;
321  }
322 
324  {
325  return (bool)$this->lp_learner;
326  }
327 
328  static function _hasLearningProgressLearner()
329  {
330  global $ilias;
331 
332  return (bool)$ilias->getSetting("lp_learner", 1);
333  }
334 
335  function setLearningProgressListGUI($a_value)
336  {
337  $this->lp_list_gui = (bool)$a_value;
338  }
339 
341  {
342  return (bool)$this->lp_list_gui;
343  }
344 
345  static function _hasLearningProgressListGUI()
346  {
347  global $ilias;
348 
349  return (bool)$ilias->getSetting("lp_list_gui", 0);
350  }
351 
352 } // END class.ilObjUserTracking
353 ?>