ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 {
20  public $valid_time;
25  public $lp_learner;
27  public $lp_list_gui;
28 
29  // BEGIN ChangeEvent
34  // BEGIN ChangeEvent
35 
39 
40  const DEFAULT_TIME_SPAN = 300;
41 
48  public 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  public function enableLearningProgress($a_enable)
57  {
58  $this->learning_progress = (bool) $a_enable;
59  }
60 
61  public function enabledLearningProgress()
62  {
64  }
65 
69  public static function _enabledLearningProgress()
70  {
71  global $DIC;
72 
73  $ilSetting = $DIC['ilSetting'];
74 
75  return (bool) $ilSetting->get("enable_tracking", 0);
76  }
77 
81  public function enableUserRelatedData($a_enable)
82  {
83  $this->tracking_user_related = (bool) $a_enable;
84  }
85 
86  public function enabledUserRelatedData()
87  {
88  return (bool) $this->tracking_user_related;
89  }
90 
94  public static function _enabledUserRelatedData()
95  {
96  global $DIC;
97 
98  $ilSetting = $DIC['ilSetting'];
99 
100  return (bool) $ilSetting->get('save_user_related_data');
101  }
102 
106  public static function _enabledObjectStatistics()
107  {
108  global $DIC;
109 
110  $ilSetting = $DIC['ilSetting'];
111 
112  return (bool) $ilSetting->get('object_statistics', 0);
113  }
114 
121  public function enableObjectStatistics($newValue)
122  {
123  $this->object_statistics_enabled = (bool) $newValue;
124  }
130  public function enabledObjectStatistics()
131  {
132  return (bool) $this->object_statistics_enabled;
133  }
134 
141  public function enableSessionStatistics($newValue)
142  {
143  $this->session_statistics_enabled = (bool) $newValue;
144  }
150  public function enabledSessionStatistics()
151  {
152  return (bool) $this->session_statistics_enabled;
153  }
154 
158  public static function _enabledSessionStatistics()
159  {
160  global $DIC;
161 
162  $ilSetting = $DIC['ilSetting'];
163 
164  return (bool) $ilSetting->get('session_statistics', 1);
165  }
166 
167  public function setValidTimeSpan($a_time_span)
168  {
169  $this->valid_time = (int) $a_time_span;
170  }
171 
172  public function getValidTimeSpan()
173  {
174  return (int) $this->valid_time;
175  }
176 
177  public static function _getValidTimeSpan()
178  {
179  global $DIC;
180 
181  $ilSetting = $DIC['ilSetting'];
182 
183  return (int) $ilSetting->get("tracking_time_span", self::DEFAULT_TIME_SPAN);
184  }
185 
186  // BEGIN ChangeEvent
193  public function enableChangeEventTracking($newValue)
194  {
195  $this->is_change_event_tracking_enabled = (bool) $newValue;
196  }
202  public function enabledChangeEventTracking()
203  {
205  }
206  // END ChangeEvent
207 
208  public function setExtendedData($a_value)
209  {
210  $this->extended_data = $a_value;
211  }
212 
213  public function hasExtendedData($a_code)
214  {
215  return (int) $this->extended_data & (int) $a_code;
216  }
217 
218  public function updateSettings()
219  {
220  global $DIC;
221 
222  $ilSetting = $DIC['ilSetting'];
223 
224  $ilSetting->set("enable_tracking", (int) $this->enabledLearningProgress());
225  $ilSetting->set("save_user_related_data", (int) $this->enabledUserRelatedData());
226  $ilSetting->set("tracking_time_span", $this->getValidTimeSpan());
227  $ilSetting->set("lp_extended_data", $this->extended_data);
228  $ilSetting->set("object_statistics", (int) $this->enabledObjectStatistics());
229  // $ilSetting->set("lp_desktop", (int)$this->hasLearningProgressDesktop());
230  $ilSetting->set("lp_learner", (int) $this->hasLearningProgressLearner());
231  $ilSetting->set("session_statistics", (int) $this->enabledSessionStatistics());
232  $ilSetting->set("lp_list_gui", (int) $this->hasLearningProgressListGUI());
233 
234  /* => REPOSITORY
235  // BEGIN ChangeEvent
236  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
237  if ($this->enabledChangeEventTracking() != ilChangeEvent::_isActive())
238  {
239  if ($this->enabledChangeEventTracking())
240  {
241  ilChangeEvent::_activate();
242  }
243  else
244  {
245  ilChangeEvent::_deactivate();
246  }
247  }
248  // END ChangeEvent
249  */
250 
251  return true;
252  }
253 
254  protected function __readSettings()
255  {
256  global $DIC;
257 
258  $ilSetting = $DIC['ilSetting'];
259 
260  $this->enableLearningProgress($ilSetting->get("enable_tracking", 0));
261  $this->enableUserRelatedData($ilSetting->get("save_user_related_data", 0));
262  $this->enableObjectStatistics($ilSetting->get("object_statistics", 0));
263  $this->setValidTimeSpan($ilSetting->get("tracking_time_span", self::DEFAULT_TIME_SPAN));
264  // $this->setLearningProgressDesktop($ilSetting->get("lp_desktop", 1));
265  $this->setLearningProgressLearner($ilSetting->get("lp_learner", 1));
266  $this->enableSessionStatistics($ilSetting->get("session_statistics", 1));
267  $this->setLearningProgressListGUI($ilSetting->get("lp_list_gui", 0));
268 
269  // BEGIN ChangeEvent
270  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
272  // END ChangeEvent
273 
274  $this->setExtendedData($ilSetting->get("lp_extended_data"), 0);
275 
276  return true;
277  }
278 
279  public static function _deleteUser($a_usr_id)
280  {
281  global $DIC;
282 
283  $ilDB = $DIC['ilDB'];
284 
285  $query = sprintf(
286  'DELETE FROM read_event WHERE usr_id = %s ',
287  $ilDB->quote($a_usr_id, 'integer')
288  );
289  $aff = $ilDB->manipulate($query);
290 
291  $query = sprintf(
292  'DELETE FROM write_event WHERE usr_id = %s ',
293  $ilDB->quote($a_usr_id, 'integer')
294  );
295  $aff = $ilDB->manipulate($query);
296 
297  $query = "DELETE FROM ut_lp_marks WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
298  $res = $ilDB->manipulate($query);
299 
300  $ilDB->manipulate("DELETE FROM ut_online WHERE usr_id = " .
301  $ilDB->quote($a_usr_id, "integer"));
302 
303  return true;
304  }
305 
306  public static function _hasLearningProgressOtherUsers()
307  {
308  global $DIC;
309 
310  $rbacsystem = $DIC['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  public function setLearningProgressLearner($a_value)
319  {
320  $this->lp_learner = (bool) $a_value;
321  }
322 
323  public function hasLearningProgressLearner()
324  {
325  return (bool) $this->lp_learner;
326  }
327 
328  public static function _hasLearningProgressLearner()
329  {
330  global $DIC;
331 
332  $ilSetting = $DIC['ilSetting'];
333 
334  return (bool) $ilSetting->get("lp_learner", 1);
335  }
336 
337  public function setLearningProgressListGUI($a_value)
338  {
339  $this->lp_list_gui = (bool) $a_value;
340  }
341 
342  public function hasLearningProgressListGUI()
343  {
344  return (bool) $this->lp_list_gui;
345  }
346 
347  public static function _hasLearningProgressListGUI()
348  {
349  global $DIC;
350 
351  $ilSetting = $DIC['ilSetting'];
352 
353  return (bool) $ilSetting->get("lp_list_gui", 0);
354  }
355 } // END class.ilObjUserTracking
static _deleteUser($a_usr_id)
static _enabledObjectStatistics()
check wether object statistics is enabled or not
global $DIC
Definition: saml.php:7
__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.
foreach($_POST as $key=> $value) $res
$is_change_event_tracking_enabled
This variable holds the enabled state of the change event tracking.
$query
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.