ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 __construct($a_id = 0,$a_call_by_reference = true)
49  {
50  $this->type = "trac";
51  parent::__construct($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 = sprintf('DELETE FROM read_event WHERE usr_id = %s ',
270  $ilDB->quote($a_usr_id,'integer'));
271  $aff = $ilDB->manipulate($query);
272 
273  $query = sprintf('DELETE FROM write_event WHERE usr_id = %s ',
274  $ilDB->quote($a_usr_id,'integer'));
275  $aff = $ilDB->manipulate($query);
276 
277  $query = "DELETE FROM ut_lp_marks WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
278  $res = $ilDB->manipulate($query);
279 
280  $ilDB->manipulate("DELETE FROM ut_online WHERE usr_id = ".
281  $ilDB->quote($a_usr_id, "integer"));
282 
283  return true;
284  }
285 
287  {
288  global $rbacsystem;
289 
290  $obj_id = array_pop(array_keys(ilObject::_getObjectsByType("trac")));
291  $ref_id = array_pop(ilObject::_getAllReferences($obj_id));
292 
293  return $rbacsystem->checkAccess("lp_other_users", $ref_id);
294  }
295 
296  function setLearningProgressLearner($a_value)
297  {
298  $this->lp_learner = (bool)$a_value;
299  }
300 
302  {
303  return (bool)$this->lp_learner;
304  }
305 
306  static function _hasLearningProgressLearner()
307  {
308  global $ilSetting;
309 
310  return (bool)$ilSetting->get("lp_learner", 1);
311  }
312 
313  function setLearningProgressListGUI($a_value)
314  {
315  $this->lp_list_gui = (bool)$a_value;
316  }
317 
319  {
320  return (bool)$this->lp_list_gui;
321  }
322 
323  static function _hasLearningProgressListGUI()
324  {
325  global $ilSetting;
326 
327  return (bool)$ilSetting->get("lp_list_gui", 0);
328  }
329 
330 } // END class.ilObjUserTracking
331 ?>
static _deleteUser($a_usr_id)
static _enabledObjectStatistics()
check wether object statistics is enabled or not
Class ilObject Basic functions for all objects.
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
enableObjectStatistics($newValue)
Sets the object statistics property.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
enableUserRelatedData($a_enable)
enable tracking of user related data
enabledSessionStatistics()
Gets the session statistic property.
static _getAllReferences($a_id)
get all reference ids of object
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _enabledLearningProgress()
check wether learing progress is enabled or not
enabledChangeEventTracking()
Gets the changeEventTrackingEnabled property.
$is_change_event_tracking_enabled
This variable holds the enabled state of the change event tracking.
enableSessionStatistics($newValue)
Sets the session statistics property.
global $ilSetting
Definition: privfeed.php:17
static _isActive()
Returns true, if change event tracking is active.
enabledObjectStatistics()
Gets the object statistic property.
global $ilDB
static _enabledSessionStatistics()
check wether session statistics is enabled or not
enableChangeEventTracking($newValue)
Sets the changeEventTrackingEnabled property.