Public Member Functions | Data Fields

ilUserTracking Class Reference

Public Member Functions

 ilUserTracking ()
 _getLastAccess ()
 get last access data of current user
 _trackAccess ($a_obj_id, $a_obj_type, $a_sub_id=0, $a_sub_type="", $a_action_type="read")
 track access to an object by current user
 TestTitle ($user_id)
 numDay ($from, $to)
 numHour ($from, $to)
 addHour ($time)
 addDay ($time)
 getSubId ($id)
 getSubTest ($id)
 getTestId ($id)
 countResults ($condition)
 searchResults ($condition)
 searchTestResults ($condition)
 searchUserId ($condition)
 searchTestId ($condition)
 getPerTestId ($test)
 countNum ($from, $from1, $condition)
 selectTime ($from, $to, $condition)
 getTest ($id)
 _tables ()
 _locator ()

Data Fields

 $objId
 $userId
 $actionType
 $phpScript
 $clientIp
 $accObjType
 $accObjId
 $accSubType
 $accSubId
 $lanugage
 $browser
 $sessionId
 $acc_time

Detailed Description

Definition at line 35 of file class.ilUserTracking.php.


Member Function Documentation

ilUserTracking::_getLastAccess (  ) 

get last access data of current user

Definition at line 64 of file class.ilUserTracking.php.

References $q, and $res.

Referenced by _trackAccess().

        {
                global $ilUser, $ilDB;

                $q = "SELECT * from ut_access "
                ." WHERE "
                ." user_id = ".$ilDB->quote($ilUser->getId())
                ." order by acc_time desc limit 1 ";
                $res = $ilDB->query($q);
                return $res->fetchRow(DB_FETCHMODE_ASSOC);
        }

Here is the caller graph for this function:

ilUserTracking::_locator (  ) 

Definition at line 419 of file class.ilUserTracking.php.

        {
                $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
                $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
                $this->tpl->setCurrentBlock("locator_item");
                $this->tpl->setVariable("ITEM", $this->lng->txt("usertracking"));
                $this->tpl->setVariable("LINK_ITEM", "tracking.php");
                $this->tpl->parseCurrentBlock();
        }

ilUserTracking::_tables (  ) 

Definition at line 389 of file class.ilUserTracking.php.

        {
                $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("personal_desktop"));
                $this->tpl->addBlockFile("TABS","tabs","tpl.tabs.html");
                $this->tpl->setCurrentBlock("tab");
                $this->tpl->setVariable("TAB_TYPE","tabinactive");
                $this->tpl->setVariable("TAB_LINK","user_personaldesktop.php");
                $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("overview"));
                $this->tpl->parseCurrentBlock();
                $this->tpl->setCurrentBlock("tab");
                $this->tpl->setVariable("TAB_TYPE","tabinactive");
                $this->tpl->setVariable("TAB_LINK","user_profile.php");
                $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("personal_profile"));
                $this->tpl->parseCurrentBlock();
                $this->tpl->setCurrentBlock("tab");
                $this->tpl->setVariable("TAB_TYPE","tabinactive");
                $this->tpl->setVariable("TAB_LINK","dataplaner.php");
                $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("calendar"));
                $this->tpl->parseCurrentBlock();
                $this->tpl->setCurrentBlock("tab");
                $this->tpl->setVariable("TAB_TYPE","tabinactive");
                $this->tpl->setVariable("TAB_LINK","usr_bookmarks.php");
                $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("bookmarks"));
                $this->tpl->parseCurrentBlock();
                $this->tpl->setCurrentBlock("tab");
                $this->tpl->setVariable("TAB_TYPE","tabinactive");
                $this->tpl->setVariable("TAB_LINK","tracking.php");
                $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("usertracking"));
                $this->tpl->parseCurrentBlock();
        }

ilUserTracking::_trackAccess ( a_obj_id,
a_obj_type,
a_sub_id = 0,
a_sub_type = "",
a_action_type = "read" 
)

track access to an object by current user

Parameters:
int $a_obj_id object id
string $a_obj_type object type (e.g. "lm")
int $a_sub_id subobject id
string $a_sub_type subobject type (e.g. "pg")
string $a_action_type "read", "write", ...

Definition at line 85 of file class.ilUserTracking.php.

References $q, $user_id, ilObjSysUserTracking::_enabledTracking(), ilObjSysUserTracking::_enabledUserRelatedData(), and _getLastAccess().

        {
                global $ilUser, $ilDB;

                include_once("classes/class.ilObjSysUserTracking.php");
                if (!ilObjSysUserTracking::_enabledTracking())
                {
                        return false;
                }

                if (ilObjSysUserTracking::_enabledUserRelatedData())
                {
                        $user_id = $ilUser->getId();
                }
                else
                {
                        $user_id = 0;
                }

                $client_ip = getenv("REMOTE_ADDR");
                $script = substr($_SERVER["SCRIPT_FILENAME"], strlen(IL_ABSOLUTE_PATH) - 1,
                        strlen($_SERVER["SCRIPT_FILENAME"]) - strlen(IL_ABSOLUTE_PATH) + 1);
                $language = $ilUser->getLanguage();
                $session_id = session_id();

                $last_access = ilUserTracking::_getLastAccess();
                if(($session_id == $last_access["session_id"]) &&
                        ($a_obj_id == $last_access["acc_obj_id"]) &&
                        ($a_obj_type == $last_access["acc_obj_type"]) &&
                        ($a_sub_id == $last_access["acc_sub_id"]) &&
                        ($a_sub_type == $last_access["acc_sub_type"])
                        )
                {
                        return true;
                }
                else
                {
                        $q = "INSERT INTO ut_access ("
                                ."user_id, action_type, php_script, client_ip,"
                                ."acc_obj_type, acc_obj_id, acc_sub_type, acc_sub_id,"
                                ."language, browser, session_id, acc_time"
                                .") VALUES ("
                                .$ilDB->quote($user_id).","
                                .$ilDB->quote($a_action_type).","
                                .$ilDB->quote($script).","
                                .$ilDB->quote($client_ip).","
                                .$ilDB->quote($a_obj_type).","
                                .$ilDB->quote($a_obj_id).","
                                .$ilDB->quote($a_sub_type).","
                                .$ilDB->quote($a_sub_id).","
                                .$ilDB->quote($language).","
                                .$ilDB->quote($_SERVER["HTTP_USER_AGENT"]).","
                                .$ilDB->quote($session_id).", now()"
                                .")";
                   $ilDB->query($q);
                }
        }

Here is the call graph for this function:

ilUserTracking::addDay ( time  ) 

Definition at line 212 of file class.ilUserTracking.php.

        {
                $time = strtotime($time);
                $day = date("d",$time);
                $month = date("m",$time);
                $year = date("y",$time);
                $min = date("i",$time);
                $hour = date("h",$time);
                $sec = date("s",$time);
                $day = $day + 1;
                $ret = date ("Y-m-d", mktime($hour,$min,$sec,$month,$day,$year));
                return $ret;
        }

ilUserTracking::addHour ( time  ) 

Definition at line 199 of file class.ilUserTracking.php.

        {
                $time = strtotime($time);
                $day = date("d",$time);
                $month = date("m",$time);
                $year = date("Y",$time);
                $hour = date("H",$time);
                $min = date("i",$time);
                $sec = date("s",$time);
                $hour = $hour+1;
                $ret = date("H:i:s", mktime($hour,$min,$sec,$month,$day,$year));
                return $ret;
        }

ilUserTracking::countNum ( from,
from1,
condition 
)

Definition at line 327 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "SELECT count(*) from ut_access "
                        ." WHERE (acc_time > '".$from
                        ."' AND acc_time <='".$from1."')"
                        ." AND ".$condition;
                        //echo $condition;echo "<br>";
//echo $q;
                $res = $this->ilias->db->query($q);
                $result = $res->fetchRow();
                return $result[0];
        }

ilUserTracking::countResults ( condition  ) 

Definition at line 262 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "SELECT count(*) from ut_access "
                ." WHERE "
                .$condition;
                $res = $this->ilias->db->query($q);
                $result = $res->fetchRow();
                return $result[0];
        }

ilUserTracking::getPerTestId ( test  ) 

Definition at line 320 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "select obj_id from object_data where type = 'tst' and title = '".$test."'";
                $res = $this->ilias->db->query($q);
                $result = $res->fetchRow();
                return $result[0];
        }

ilUserTracking::getSubId ( id  ) 

Definition at line 226 of file class.ilUserTracking.php.

References $id, $q, $res, and $result.

        {
                $q = "SELECT obj_id from object_data "
                ." WHERE type = 'lm' and "
                ." owner = ".$id;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::getSubTest ( id  ) 

Definition at line 238 of file class.ilUserTracking.php.

References $id, $q, $res, and $result.

        {
                $q = "SELECT obj_id from object_data "
                ." WHERE type = 'tst' and "
                ." owner = ".$id;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::getTest ( id  ) 

Definition at line 373 of file class.ilUserTracking.php.

References $id, $q, $res, and $result.

        {
                $q = "SELECT title from object_data "
                ." WHERE "
                ." type = 'tst' "
                ." and "
                ." owner = ".$id;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::getTestId ( id  ) 

Definition at line 250 of file class.ilUserTracking.php.

References $id, $q, $res, and $result.

        {
                $q = "select obj_id from object_data "
                ." where type = 'tst' and "
                ." owner = ".$id;
                $res = $this->ilias->db->query($q);
                for ($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::ilUserTracking (  ) 

Definition at line 51 of file class.ilUserTracking.php.

References $ilias, $lng, and $tpl.

        {
                global $ilias,$tpl,$lng;

                $this->ilias    =& $ilias;
                $this->tpl              =& $tpl;
                $this->lng              =& $lng;

        }

ilUserTracking::numDay ( from,
to 
)

Definition at line 170 of file class.ilUserTracking.php.

        {
                $from = strtotime($from);
                $to = strtotime($to);
                $dayf = date ("d",$from);
                $dayt = date ("d",$to);
                $yearf = date ("Y",$from); 
                $yeart = date ("Y",$to); 
                $montht = date ("m",$to); 
                $monthf = date ("m",$from); 
                $ret = ( mktime(0,0,0,$montht,$dayt,$yeart) - mktime(0,0,0,$monthf,$dayf,$yearf))/(3600*24); 
                return $ret; 
        }

ilUserTracking::numHour ( from,
to 
)

Definition at line 183 of file class.ilUserTracking.php.

        {
                $from = strtotime($from);
                $to = strtotime($to);
                $dayf = date ("d",$from); 
                $dayt = date ("d",$to);
                $yearf = date ("Y",$from); 
                $yeart = date ("Y",$to); 
                $montht = date ("m",$to); 
                $monthf = date ("m",$from); 
                $hourt = date ("h",$to);
                $hourf = date ("h",$from);
                $ret = (mktime($hourt,0,0,$montht,$dayt,$yeart)-mktime($hourf,0,0,$monthf,$dayf,$yearf))/3600; 
                $ret = strftime($ret);
                return $ret; 
        }

ilUserTracking::searchResults ( condition  ) 

Definition at line 271 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "SELECT a.login,b.acc_obj_type,b.language,b.client_ip,b.acc_time "
                        ." FROM usr_data as a,ut_access as b "
                        ." WHERE a.usr_id=b.user_id "
                        ." AND ".$condition;
//echo $q;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::searchTestId ( condition  ) 

Definition at line 310 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "select user_fi from tst_active where ".$condition;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::searchTestResults ( condition  ) 

Definition at line 285 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "SELECT a.login,b.acc_obj_type,b.client_ip,b.acc_time "
                        ." FROM usr_data as a,ut_access as b "
                        ." WHERE a.usr_id=b.user_id "
                        ." AND ".$condition;
//echo $q;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::searchUserId ( condition  ) 

Definition at line 299 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "SELECT user_id from ut_access where ".$condition;
//echo $q;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::selectTime ( from,
to,
condition 
)

Definition at line 339 of file class.ilUserTracking.php.

References $q, $res, and $result.

        {
                $q = "SELECT acc_time from ut_access "
                        ." WHERE (acc_time >= '".$from
                        ."' AND acc_time <='".$to."')"
                        ." AND ".$condition;
//echo $q;
//echo "<br>";
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }

ilUserTracking::TestTitle ( user_id  ) 

Definition at line 142 of file class.ilUserTracking.php.

References $q, $res, $result, and $user_id.

        {
                $q = " SELECT title from object_data "
                        ." WHERE type = 'tst'"
                        ." AND owner = ".$user_id;
                $res = $this->ilias->db->query($q);
                for($i=0;$i<$res->numRows();$i++)
                {
                        $result[$i]=$res->fetchRow();
                }
                return $result;
        }


Field Documentation

ilUserTracking::$acc_time

Definition at line 49 of file class.ilUserTracking.php.

ilUserTracking::$accObjId

Definition at line 43 of file class.ilUserTracking.php.

ilUserTracking::$accObjType

Definition at line 42 of file class.ilUserTracking.php.

ilUserTracking::$accSubId

Definition at line 45 of file class.ilUserTracking.php.

ilUserTracking::$accSubType

Definition at line 44 of file class.ilUserTracking.php.

ilUserTracking::$actionType

Definition at line 39 of file class.ilUserTracking.php.

ilUserTracking::$browser

Definition at line 47 of file class.ilUserTracking.php.

ilUserTracking::$clientIp

Definition at line 41 of file class.ilUserTracking.php.

ilUserTracking::$lanugage

Definition at line 46 of file class.ilUserTracking.php.

ilUserTracking::$objId

Definition at line 37 of file class.ilUserTracking.php.

ilUserTracking::$phpScript

Definition at line 40 of file class.ilUserTracking.php.

ilUserTracking::$sessionId

Definition at line 48 of file class.ilUserTracking.php.

ilUserTracking::$userId

Definition at line 38 of file class.ilUserTracking.php.


The documentation for this class was generated from the following file: