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');
139 $this->valid_time = (int) $a_time_span;
146 return (
int) $this->valid_time;
153 return (
int) $ilias->getSetting(
"tracking_time_span",DEFAULT_TIME_SPAN);
165 $this->is_change_event_tracking_enabled = $newValue;
185 $ilias->setSetting(
"lp_extended_data", $this->extended_data);
188 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
191 if ($this->is_change_event_tracking_enabled)
224 $q =
"SELECT count(*) AS cnt FROM ut_access";
225 $cnt_set = $ilDB->query($q);
229 return $cnt_rec[
"cnt"];
239 $q =
"SELECT count(*) as cnt, count(distinct user_id) as user_cnt, ut_month FROM ut_access".
240 " GROUP BY ut_month ORDER BY ut_month DESC";
241 $min_set = $ilDB->query($q);
245 $months[] = array(
"month" => $min_rec[
"ut_month"],
246 "cnt" => $min_rec[
"cnt"],
"user_cnt" => $min_rec[
"user_cnt"]);
258 $q =
"SELECT count(*) as cnt, count(ut_month) as d FROM ut_access WHERE acc_time <= ".
259 $ilDB->quote($this->
increaseMonth($a_month).
"-01",
"timestamp");
261 $cnt_set = $ilDB->query($q);
265 return $cnt_rec[
"cnt"];
275 $q =
"SELECT count(*) as cnt, user_id FROM ut_access "
276 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
279 .
" GROUP BY user_id";
281 $cnt_set = $ilDB->query($q);
288 if ($cnt_rec[
"user_id"] != 0)
290 $acc[] = array(
"user_id" => $cnt_rec[
"user_id"],
291 "name" =>
$name[
"lastname"].
", ".
$name[
"firstname"],
292 "cnt" => $cnt_rec[
"cnt"]);
304 $q =
"SELECT count(acc_obj_id) AS cnt, acc_obj_id FROM ut_access "
305 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
307 .
" GROUP BY acc_obj_id";
308 $cnt_set = $ilDB->query($q);
314 if ($cnt_rec[
"cnt"] !=
"")
317 $acc[] = array(
"id" => $cnt_rec[
"acc_obj_id"],
319 "author" => $this->
getOwnerName($cnt_rec[
"acc_obj_id"]),
320 "duration" => $this->
getDuration($cnt_rec[
"acc_obj_id"]),
321 "cnt" => $cnt_rec[
"cnt"]);
331 $query = sprintf(
'SELECT AVG(spent_seconds) FROM read_event '.
332 'WHERE obj_id = %s '.
334 $ilDB->quote($a_obj_id,
'integer'));
336 $data = $ilDB->fetchAssoc($res);
337 return $data[
"spent_seconds"];
347 $q =
"SELECT id, user_id,client_ip,acc_obj_id,language ,acc_time FROM ut_access "
348 .($a_searchTermsCondition !=
"" ? $a_searchTermsCondition :
" WHERE ")
353 $cnt_set = $ilDB->query($q);
359 if ($cnt_rec[
"user_id"] != 0)
361 $acc[] = array(
"user_id" => $cnt_rec[
"user_id"],
362 "name" =>
$name[
"lastname"].
", ".
$name[
"firstname"],
363 "client_ip" => $cnt_rec[
"client_ip"],
365 "language" => $cnt_rec[
"language"],
366 "acc_time" => $cnt_rec[
"acc_time"]
380 $q =
"DELETE FROM ut_access WHERE acc_time < ".
381 $ilDB->quote($this->
increaseMonth($a_month).
"-01",
"timestamp");
383 $ilDB->manipulate($q);
394 $year = (int) substr($a_month, 0, 4);
395 $month = (int) substr($a_month, 5);
402 return $year.
"-".str_pad($month, 2,
"0", STR_PAD_LEFT);
412 $q =
"SELECT DISTINCT A.obj_id,A.type,A.title FROM object_data A,object_data B WHERE A.type = ".
413 $ilDB->quote($a_type ,
'text').
" AND A.obj_id = B.owner AND B.type=".$ilDB->quote(
$type ,
'text').
" ".
416 $author = $ilDB->query($q);
420 $all[] = array(
"title" => $aauthor[
"title"],
421 "obj_id" =>$aauthor[
"obj_id"]);
433 $q =
"SELECT title,obj_id FROM object_data WHERE owner = ".$ilDB->quote(
$id ,
'integer').
" and type=".$ilDB->quote(
$type ,
'text');
435 $lms = $ilDB->query($q);
439 $all[] = array(
"title" => $alms[
"title"],
440 "obj_id" =>$alms[
"obj_id"]);
452 $q =
"SELECT obj_id FROM object_data WHERE type = ".$ilDB->quote(
$type ,
'text').
" and title=".$ilDB->quote(
$title ,
'text');
453 $id = $ilDB->query($q);
455 return $obj_id[
"obj_id"];
463 $q =
"select obj_id from object_data "
464 .
" where type = 'tst' and "
465 .
" owner = ".
$ilDB->quote(
$id ,
'integer');
466 $res = $this->ilias->db->query($q);
467 for ($i=0;$i<
$res->numRows();$i++)
469 $result[$i]=
$res->fetchRow();
479 $q =
"SELECT count(*) from ut_access "
482 $res = $this->ilias->db->query($q);
483 $result =
$res->fetchRow();
494 $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');
495 $res = $this->ilias->db->query($q);
496 $result =
$res->fetchRow();
505 #$this->enableTracking($ilias->getSetting("enable_tracking",0));
508 $this->
setValidTimeSpan($ilias->getSetting(
"tracking_time_span",DEFAULT_TIME_SPAN));#
511 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
524 $query =
"DELETE FROM ut_access WHERE user_id = ".$ilDB->quote($a_usr_id,
"integer").
"";
525 $ilDB->manipulate(
$query);
527 $query = sprintf(
'DELETE FROM read_event WHERE usr_id = %s ',
528 $ilDB->quote($a_usr_id,
'integer'));
529 $aff = $ilDB->manipulate(
$query);
531 $query = sprintf(
'DELETE FROM write_event WHERE usr_id = %s ',
532 $ilDB->quote($a_usr_id,
'integer'));
533 $aff = $ilDB->manipulate(
$query);
535 $query =
"DELETE FROM ut_lp_marks WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ";
538 $ilDB->manipulate(
"DELETE FROM ut_online WHERE usr_id = ".
539 $ilDB->quote($a_usr_id,
"integer"));
546 $this->extended_data = $a_value;
551 return $this->extended_data & $a_code;