17 define(
'UT_INACTIVE_BOTH',0);
18 define(
'UT_ACTIVE_BOTH',1);
19 define(
'UT_ACTIVE_UT',2);
20 define(
'UT_ACTIVE_LP',3);
22 include_once
"classes/class.ilObject.php";
50 $this->
ilObject($a_id,$a_call_by_reference);
52 define(
"DEFAULT_TIME_SPAN",60*5);
60 $this->status = $a_status;
75 $this->tracking_enabled = (bool) $a_enable;
92 $status = $ilias->getSetting(
"enable_tracking");
109 $status = $ilias->getSetting(
"enable_tracking");
119 $this->tracking_user_related = (bool) $a_enable;
124 return $this->tracking_user_related ?
true :
false;
134 return (
boolean) $ilSetting->get(
'save_user_related_data');
143 return (
boolean) $ilSetting->get(
'object_statistics');
148 $this->valid_time = (int) $a_time_span;
155 return (
int) $this->valid_time;
162 return (
int) $ilias->getSetting(
"tracking_time_span",DEFAULT_TIME_SPAN);
174 $this->is_change_event_tracking_enabled = $newValue;
195 $this->object_statistics_enabled = (bool)$newValue;
204 return $this->object_statistics_enabled;
214 $ilias->setSetting(
"lp_extended_data", $this->extended_data);
215 $ilias->setSetting(
"object_statistics", $this->object_statistics_enabled);
218 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
221 if ($this->is_change_event_tracking_enabled)
253 $q =
"SELECT count(*) AS cnt FROM ut_access";
254 $cnt_set = $ilDB->query($q);
258 return $cnt_rec[
"cnt"];
268 $q =
"SELECT count(*) as cnt, count(distinct user_id) as user_cnt, ut_month FROM ut_access".
269 " GROUP BY ut_month ORDER BY ut_month DESC";
270 $min_set = $ilDB->query($q);
274 $months[] = array(
"month" => $min_rec[
"ut_month"],
275 "cnt" => $min_rec[
"cnt"],
"user_cnt" => $min_rec[
"user_cnt"]);
287 $q =
"SELECT count(*) as cnt, count(ut_month) as d FROM ut_access WHERE acc_time <= ".
288 $ilDB->quote($this->
increaseMonth($a_month).
"-01",
"timestamp");
290 $cnt_set = $ilDB->query($q);
294 return $cnt_rec[
"cnt"];
304 $q =
"SELECT count(*) as cnt, user_id FROM ut_access "
305 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
308 .
" GROUP BY user_id";
310 $cnt_set = $ilDB->query($q);
317 if ($cnt_rec[
"user_id"] != 0)
319 $acc[] = array(
"user_id" => $cnt_rec[
"user_id"],
320 "name" => $name[
"lastname"].
", ".$name[
"firstname"],
321 "cnt" => $cnt_rec[
"cnt"]);
333 $q =
"SELECT count(acc_obj_id) AS cnt, acc_obj_id FROM ut_access "
334 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
336 .
" GROUP BY acc_obj_id";
337 $cnt_set = $ilDB->query($q);
343 if ($cnt_rec[
"cnt"] !=
"")
346 $acc[] = array(
"id" => $cnt_rec[
"acc_obj_id"],
348 "author" => $this->
getOwnerName($cnt_rec[
"acc_obj_id"]),
349 "duration" => $this->
getDuration($cnt_rec[
"acc_obj_id"]),
350 "cnt" => $cnt_rec[
"cnt"]);
360 $query = sprintf(
'SELECT AVG(spent_seconds) FROM read_event '.
361 'WHERE obj_id = %s '.
363 $ilDB->quote($a_obj_id,
'integer'));
365 $data = $ilDB->fetchAssoc($res);
366 return $data[
"spent_seconds"];
376 $q =
"SELECT id, user_id,client_ip,acc_obj_id,language ,acc_time FROM ut_access "
377 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
382 $cnt_set = $ilDB->query($q);
388 if ($cnt_rec[
"user_id"] != 0)
390 $acc[] = array(
"user_id" => $cnt_rec[
"user_id"],
391 "name" => $name[
"lastname"].
", ".$name[
"firstname"],
392 "client_ip" => $cnt_rec[
"client_ip"],
394 "language" => $cnt_rec[
"language"],
395 "acc_time" => $cnt_rec[
"acc_time"]
409 $q =
"DELETE FROM ut_access WHERE acc_time < ".
410 $ilDB->quote($this->
increaseMonth($a_month).
"-01",
"timestamp");
412 $ilDB->manipulate($q);
423 $year = (int) substr($a_month, 0, 4);
424 $month = (int) substr($a_month, 5);
431 return $year.
"-".str_pad($month, 2,
"0", STR_PAD_LEFT);
441 $q =
"SELECT DISTINCT A.obj_id,A.type,A.title FROM object_data A,object_data B WHERE A.type = ".
442 $ilDB->quote($a_type ,
'text').
" AND A.obj_id = B.owner AND B.type=".$ilDB->quote(
$type ,
'text').
" ".
445 $author = $ilDB->query($q);
449 $all[] = array(
"title" => $aauthor[
"title"],
450 "obj_id" =>$aauthor[
"obj_id"]);
462 $q =
"SELECT title,obj_id FROM object_data WHERE owner = ".$ilDB->quote(
$id ,
'integer').
" and type=".$ilDB->quote(
$type ,
'text');
464 $lms = $ilDB->query($q);
468 $all[] = array(
"title" => $alms[
"title"],
469 "obj_id" =>$alms[
"obj_id"]);
481 $q =
"SELECT obj_id FROM object_data WHERE type = ".$ilDB->quote(
$type ,
'text').
" and title=".$ilDB->quote(
$title ,
'text');
482 $id = $ilDB->query($q);
484 return $obj_id[
"obj_id"];
492 $q =
"select obj_id from object_data "
493 .
" where type = 'tst' and "
494 .
" owner = ".
$ilDB->quote(
$id ,
'integer');
495 $res = $this->ilias->db->query($q);
496 for ($i=0;$i<
$res->numRows();$i++)
508 $q =
"SELECT count(*) from ut_access "
511 $res = $this->ilias->db->query($q);
523 $q =
" select A.login from usr_data A, object_data B where A.usr_id=B.owner and B.obj_id = ".$ilDB->quote(
$id ,
'integer');
524 $res = $this->ilias->db->query($q);
534 #$this->enableTracking($ilias->getSetting("enable_tracking",0));
537 $this->
setValidTimeSpan($ilias->getSetting(
"tracking_time_span",DEFAULT_TIME_SPAN));#
540 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
554 $query =
"DELETE FROM ut_access WHERE user_id = ".$ilDB->quote($a_usr_id,
"integer").
"";
555 $ilDB->manipulate(
$query);
557 $query = sprintf(
'DELETE FROM read_event WHERE usr_id = %s ',
558 $ilDB->quote($a_usr_id,
'integer'));
559 $aff = $ilDB->manipulate(
$query);
561 $query = sprintf(
'DELETE FROM write_event WHERE usr_id = %s ',
562 $ilDB->quote($a_usr_id,
'integer'));
563 $aff = $ilDB->manipulate(
$query);
565 $query =
"DELETE FROM ut_lp_marks WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ";
568 $ilDB->manipulate(
"DELETE FROM ut_online WHERE usr_id = ".
569 $ilDB->quote($a_usr_id,
"integer"));
576 $this->extended_data = $a_value;
581 return $this->extended_data & $a_code;