ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
16include_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 {
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
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
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 }
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
286 /*
287 function setLearningProgressDesktop($a_value)
288 {
289 $this->lp_desktop = (bool)$a_value;
290 }
291
292 function hasLearningProgressDesktop()
293 {
294 return (bool)$this->lp_desktop;
295 }
296
297 static function _hasLearningProgressDesktop()
298 {
299 global $ilias;
300
301 return (bool)$ilias->getSetting("lp_desktop");
302 }
303 */
304
306 {
307 global $rbacsystem;
308
309 $obj_id = array_pop(array_keys(ilObject::_getObjectsByType("trac")));
310 $ref_id = array_pop(ilObject::_getAllReferences($obj_id));
311
312 return $rbacsystem->checkAccess("lp_other_users", $ref_id);
313 }
314
315 function setLearningProgressLearner($a_value)
316 {
317 $this->lp_learner = (bool)$a_value;
318 }
319
321 {
322 return (bool)$this->lp_learner;
323 }
324
326 {
327 global $ilias;
328
329 return (bool)$ilias->getSetting("lp_learner", 1);
330 }
331
332 function setLearningProgressListGUI($a_value)
333 {
334 $this->lp_list_gui = (bool)$a_value;
335 }
336
338 {
339 return (bool)$this->lp_list_gui;
340 }
341
343 {
344 global $ilias;
345
346 return (bool)$ilias->getSetting("lp_list_gui", 0);
347 }
348
349} // END class.ilObjUserTracking
350?>
static _isActive()
Returns true, if change event tracking is active.
enableSessionStatistics($newValue)
Sets the session statistics property.
enableObjectStatistics($newValue)
Sets the object statistics property.
enabledObjectStatistics()
Gets the object statistic property.
ilObjUserTracking($a_id=0, $a_call_by_reference=true)
Constructor @access public.
enableChangeEventTracking($newValue)
Sets the changeEventTrackingEnabled property.
enabledSessionStatistics()
Gets the session statistic property.
enableUserRelatedData($a_enable)
enable tracking of user related data
static _enabledObjectStatistics()
check wether object statistics is enabled or not
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _deleteUser($a_usr_id)
static _enabledSessionStatistics()
check wether session statistics is enabled or not
$is_change_event_tracking_enabled
This variable holds the enabled state of the change event tracking.
enabledChangeEventTracking()
Gets the changeEventTrackingEnabled property.
Class ilObject Basic functions for all objects.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
static _getAllReferences($a_id)
get all reference ids of object
global $ilSetting
Definition: privfeed.php:40
global $ilDB