ILIAS  release_4-3 Revision
 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 {
26 
27  // BEGIN ChangeEvent
32  // BEGIN ChangeEvent
33 
37 
38  const DEFAULT_TIME_SPAN = 300;
39 
46  function ilObjUserTracking($a_id = 0,$a_call_by_reference = true)
47  {
48  $this->type = "trac";
49  $this->ilObject($a_id,$a_call_by_reference);
50 
51  $this->__readSettings();
52  }
53 
54  function enableLearningProgress($a_enable)
55  {
56  $this->learning_progress = (bool)$a_enable;
57  }
58 
60  {
62  }
63 
67  static function _enabledLearningProgress()
68  {
69  global $ilSetting;
70 
71  return (bool)$ilSetting->get("enable_tracking", 0);
72  }
73 
77  function enableUserRelatedData($a_enable)
78  {
79  $this->tracking_user_related = (bool)$a_enable;
80  }
81 
83  {
84  return (bool)$this->tracking_user_related;
85  }
86 
90  static function _enabledUserRelatedData()
91  {
92  global $ilSetting;
93 
94  return (bool)$ilSetting->get('save_user_related_data');
95  }
96 
100  static function _enabledObjectStatistics()
101  {
102  global $ilSetting;
103 
104  return (bool)$ilSetting->get('object_statistics', 0);
105  }
106 
113  public function enableObjectStatistics($newValue)
114  {
115  $this->object_statistics_enabled = (bool)$newValue;
116  }
122  public function enabledObjectStatistics()
123  {
125  }
126 
133  public function enableSessionStatistics($newValue)
134  {
135  $this->session_statistics_enabled = (bool)$newValue;
136  }
142  public function enabledSessionStatistics()
143  {
145  }
146 
150  static function _enabledSessionStatistics()
151  {
152  global $ilSetting;
153 
154  return (bool)$ilSetting->get('session_statistics', 1);
155  }
156 
157  function setValidTimeSpan($a_time_span)
158  {
159  $this->valid_time = (int)$a_time_span;
160  }
161 
162  function getValidTimeSpan()
163  {
164  return (int)$this->valid_time;
165  }
166 
167  static function _getValidTimeSpan()
168  {
169  global $ilSetting;
170 
171  return (int)$ilSetting->get("tracking_time_span", self::DEFAULT_TIME_SPAN);
172  }
173 
174  // BEGIN ChangeEvent
181  public function enableChangeEventTracking($newValue)
182  {
183  $this->is_change_event_tracking_enabled = (bool)$newValue;
184  }
190  public function enabledChangeEventTracking()
191  {
193  }
194  // END ChangeEvent
195 
196  function setExtendedData($a_value)
197  {
198  $this->extended_data = $a_value;
199  }
200 
201  function hasExtendedData($a_code)
202  {
203  return $this->extended_data & $a_code;
204  }
205 
206  function updateSettings()
207  {
208  global $ilSetting;
209 
210  $ilSetting->set("enable_tracking", (int)$this->enabledLearningProgress());
211  $ilSetting->set("save_user_related_data", (int)$this->enabledUserRelatedData());
212  $ilSetting->set("tracking_time_span",$this->getValidTimeSpan());
213  $ilSetting->set("lp_extended_data", $this->extended_data);
214  $ilSetting->set("object_statistics", (int)$this->enabledObjectStatistics());
215  // $ilSetting->set("lp_desktop", (int)$this->hasLearningProgressDesktop());
216  $ilSetting->set("lp_learner", (int)$this->hasLearningProgressLearner());
217  $ilSetting->set("session_statistics", (int)$this->enabledSessionStatistics());
218 
219  // BEGIN ChangeEvent
220  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
222  {
223  if ($this->enabledChangeEventTracking())
224  {
226  }
227  else
228  {
230  }
231  }
232  // END ChangeEvent
233 
234  return true;
235  }
236 
237  protected function __readSettings()
238  {
239  global $ilSetting;
240 
241  $this->enableLearningProgress($ilSetting->get("enable_tracking",0));
242  $this->enableUserRelatedData($ilSetting->get("save_user_related_data",0));
243  $this->enableObjectStatistics($ilSetting->get("object_statistics",0));
244  $this->setValidTimeSpan($ilSetting->get("tracking_time_span", self::DEFAULT_TIME_SPAN));
245  // $this->setLearningProgressDesktop($ilSetting->get("lp_desktop", 1));
246  $this->setLearningProgressLearner($ilSetting->get("lp_learner", 1));
247  $this->enableSessionStatistics($ilSetting->get("session_statistics", 1));
248 
249  // BEGIN ChangeEvent
250  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
252  // END ChangeEvent
253 
254  $this->setExtendedData($ilSetting->get("lp_extended_data"),0);
255 
256  return true;
257  }
258 
259  static function _deleteUser($a_usr_id)
260  {
261  global $ilDB;
262 
263  $query = "DELETE FROM ut_access WHERE user_id = ".$ilDB->quote($a_usr_id, "integer")."";
264  $ilDB->manipulate($query);
265 
266  $query = sprintf('DELETE FROM read_event WHERE usr_id = %s ',
267  $ilDB->quote($a_usr_id,'integer'));
268  $aff = $ilDB->manipulate($query);
269 
270  $query = sprintf('DELETE FROM write_event WHERE usr_id = %s ',
271  $ilDB->quote($a_usr_id,'integer'));
272  $aff = $ilDB->manipulate($query);
273 
274  $query = "DELETE FROM ut_lp_marks WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
275  $res = $ilDB->manipulate($query);
276 
277  $ilDB->manipulate("DELETE FROM ut_online WHERE usr_id = ".
278  $ilDB->quote($a_usr_id, "integer"));
279 
280  return true;
281  }
282 
283  /*
284  function setLearningProgressDesktop($a_value)
285  {
286  $this->lp_desktop = (bool)$a_value;
287  }
288 
289  function hasLearningProgressDesktop()
290  {
291  return (bool)$this->lp_desktop;
292  }
293 
294  static function _hasLearningProgressDesktop()
295  {
296  global $ilias;
297 
298  return (bool)$ilias->getSetting("lp_desktop");
299  }
300  */
301 
303  {
304  global $rbacsystem;
305 
306  $obj_id = array_pop(array_keys(ilObject::_getObjectsByType("trac")));
307  $ref_id = array_pop(ilObject::_getAllReferences($obj_id));
308 
309  return $rbacsystem->checkAccess("lp_other_users", $ref_id);
310  }
311 
312  function setLearningProgressLearner($a_value)
313  {
314  $this->lp_learner = (bool)$a_value;
315  }
316 
318  {
319  return (bool)$this->lp_learner;
320  }
321 
322  static function _hasLearningProgressLearner()
323  {
324  global $ilias;
325 
326  return (bool)$ilias->getSetting("lp_learner", 1);
327  }
328 
329 } // END class.ilObjUserTracking
330 ?>