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";
45 $this->
ilObject($a_id,$a_call_by_reference);
47 define(
"DEFAULT_TIME_SPAN",60*5);
55 $this->status = $a_status;
70 $this->tracking_enabled = (bool) $a_enable;
87 $status = $ilias->getSetting(
"enable_tracking");
104 $status = $ilias->getSetting(
"enable_tracking");
114 $this->tracking_user_related = (bool) $a_enable;
119 return $this->tracking_user_related ?
true :
false;
129 return (
boolean) $ilSetting->get(
'save_user_related_data');
134 $this->valid_time = (int) $a_time_span;
141 return (
int) $this->valid_time;
148 return (
int) $ilias->getSetting(
"tracking_time_span",DEFAULT_TIME_SPAN);
160 $this->is_change_event_tracking_enabled = $newValue;
182 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
185 if ($this->is_change_event_tracking_enabled)
218 $q =
"SELECT count(*) AS cnt FROM ut_access";
219 $cnt_set = $ilDB->query(
$q);
223 return $cnt_rec[
"cnt"];
233 $q =
"SELECT count(*) as cnt, count(distinct user_id) as user_cnt, ut_month FROM ut_access".
234 " GROUP BY ut_month ORDER BY ut_month DESC";
235 $min_set = $ilDB->query(
$q);
239 $months[] = array(
"month" => $min_rec[
"ut_month"],
240 "cnt" => $min_rec[
"cnt"],
"user_cnt" => $min_rec[
"user_cnt"]);
252 $q =
"SELECT count(*) as cnt, count(ut_month) as d FROM ut_access WHERE acc_time <= ".
253 $ilDB->quote($this->
increaseMonth($a_month).
"-01",
"timestamp");
255 $cnt_set = $ilDB->query(
$q);
259 return $cnt_rec[
"cnt"];
269 $q =
"SELECT count(*) as cnt, user_id FROM ut_access "
270 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
273 .
" GROUP BY user_id";
275 $cnt_set = $ilDB->query(
$q);
282 if ($cnt_rec[
"user_id"] != 0)
284 $acc[] = array(
"user_id" => $cnt_rec[
"user_id"],
285 "name" =>
$name[
"lastname"].
", ".
$name[
"firstname"],
286 "cnt" => $cnt_rec[
"cnt"]);
298 $q =
"SELECT count(acc_obj_id) AS cnt, acc_obj_id FROM ut_access "
299 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
301 .
" GROUP BY acc_obj_id";
302 $cnt_set = $ilDB->query(
$q);
308 if ($cnt_rec[
"cnt"] !=
"")
311 $acc[] = array(
"id" => $cnt_rec[
"acc_obj_id"],
313 "author" => $this->
getOwnerName($cnt_rec[
"acc_obj_id"]),
314 "duration" => $this->
getDuration($cnt_rec[
"acc_obj_id"]),
315 "cnt" => $cnt_rec[
"cnt"]);
325 $query = sprintf(
'SELECT AVG(spent_seconds) FROM read_event '.
326 'WHERE obj_id = %s '.
328 $ilDB->quote($a_obj_id,
'integer'));
330 $data = $ilDB->fetchAssoc($res);
331 return $data[
"spent_seconds"];
341 $q =
"SELECT id, user_id,client_ip,acc_obj_id,language ,acc_time FROM ut_access "
342 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
347 $cnt_set = $ilDB->query(
$q);
353 if ($cnt_rec[
"user_id"] != 0)
355 $acc[] = array(
"user_id" => $cnt_rec[
"user_id"],
356 "name" =>
$name[
"lastname"].
", ".
$name[
"firstname"],
357 "client_ip" => $cnt_rec[
"client_ip"],
359 "language" => $cnt_rec[
"language"],
360 "acc_time" => $cnt_rec[
"acc_time"]
374 $q =
"DELETE FROM ut_access WHERE acc_time < ".
375 $ilDB->quote($this->
increaseMonth($a_month).
"-01",
"timestamp");
377 $ilDB->manipulate(
$q);
388 $year = (int) substr($a_month, 0, 4);
389 $month = (int) substr($a_month, 5);
396 return $year.
"-".str_pad($month, 2,
"0", STR_PAD_LEFT);
406 $q =
"SELECT DISTINCT A.obj_id,A.type,A.title FROM object_data A,object_data B WHERE A.type = ".
407 $ilDB->quote($a_type ,
'text').
" AND A.obj_id = B.owner AND B.type=".$ilDB->quote(
$type ,
'text').
" ".
410 $author = $ilDB->query(
$q);
414 $all[] = array(
"title" => $aauthor[
"title"],
415 "obj_id" =>$aauthor[
"obj_id"]);
427 $q =
"SELECT title,obj_id FROM object_data WHERE owner = ".$ilDB->quote(
$id ,
'integer').
" and type=".$ilDB->quote(
$type ,
'text');
429 $lms = $ilDB->query(
$q);
433 $all[] = array(
"title" => $alms[
"title"],
434 "obj_id" =>$alms[
"obj_id"]);
446 $q =
"SELECT obj_id FROM object_data WHERE type = ".$ilDB->quote(
$type ,
'text').
" and title=".$ilDB->quote(
$title ,
'text');
447 $id = $ilDB->query(
$q);
449 return $obj_id[
"obj_id"];
457 $q =
"select obj_id from object_data "
458 .
" where type = 'tst' and "
459 .
" owner = ".
$ilDB->quote(
$id ,
'integer');
460 $res = $this->ilias->db->query(
$q);
461 for ($i=0;$i<
$res->numRows();$i++)
473 $q =
"SELECT count(*) from ut_access "
476 $res = $this->ilias->db->query(
$q);
488 $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');
489 $res = $this->ilias->db->query(
$q);
499 #$this->enableTracking($ilias->getSetting("enable_tracking",0));
502 $this->
setValidTimeSpan($ilias->getSetting(
"tracking_time_span",DEFAULT_TIME_SPAN));
505 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
516 $query =
"DELETE FROM ut_access WHERE user_id = ".$ilDB->quote($a_usr_id,
"integer").
"";
517 $ilDB->manipulate(
$query);
519 $query = sprintf(
'DELETE FROM read_event WHERE usr_id = %s ',
520 $ilDB->quote($a_usr_id,
'integer'));
521 $aff = $ilDB->manipulate(
$query);
523 $query = sprintf(
'DELETE FROM write_event WHERE usr_id = %s ',
524 $ilDB->quote($a_usr_id,
'integer'));
525 $aff = $ilDB->manipulate(
$query);
527 $query =
"DELETE FROM ut_lp_filter WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
530 $query =
"DELETE FROM ut_lp_marks WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ";
533 $ilDB->manipulate(
"DELETE FROM ut_online WHERE usr_id = ".
534 $ilDB->quote($a_usr_id,
"integer"));