Public Member Functions

ilObjSysUserTracking Class Reference

Class ilObjSysUserTracking. More...

Inheritance diagram for ilObjSysUserTracking:
Collaboration diagram for ilObjSysUserTracking:

Public Member Functions

 ilObjSysUserTracking ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 update ()
 update object data
 delete ()
 delete object and all related data
 initDefaultRoles ()
 init default roles settings
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts.
 getRecordsTotal ()
 get total number of tracking records
 getMonthTotalOverview ()
 get total number of accesses per month
 getTotalOlderThanMonth ($a_month)
 get total number of records older than given month (YYYY-MM)
 getAccessTotalPerUser ($a_condition)
 get total number of records older than given month (YYYY-MM)
 getAccessTotalPerObj ($a_condition)
 get total number of records older than given month (YYYY-MM)
 getAccessPerUserDetail ($a_condition)
 get per user of records older than given month (YYYY-MM)
 deleteTrackingDataBeforeMonth ($a_month)
 delete tracking data of month (YYYY-MM) and before
 enableTracking ($a_enable)
 enable user tracking
 _enabledTracking ()
 check wether user tracking is enabled or not
 enableUserRelatedData ($a_enable)
 enable tracking of user related data
 _enabledUserRelatedData ()
 check wether user related tracking is enabled or not
 allAuthor ($a_type, $type)
 get all author
 authorLms ($id, $type)
 get author's all lm or tst
 getObjId ($title, $type)
 get obj_id of some object
 getTestId ($id)
 get Test_id of some test
 countResults ($condition)
 Return the counts of search results.
 getOwnerName ($id)
 Return the owner name of the object.

Detailed Description

Class ilObjSysUserTracking.

Author:
Arlon Yin <arlon_yin@hotmail.com>
Alex Killing <alex.killing@gmx.de>
Version:
Id:
class.ilObjSysUserTracking.php 13414 2007-03-08 12:41:48Z smeyer

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


Member Function Documentation

ilObjSysUserTracking::_enabledTracking (  ) 

check wether user tracking is enabled or not

Definition at line 346 of file class.ilObjSysUserTracking.php.

References ilObject::$ilias.

Referenced by ilUserTracking::_trackAccess().

        {
                global $ilias;

                return (boolean) $ilias->getSetting("enable_tracking");
        }

Here is the caller graph for this function:

ilObjSysUserTracking::_enabledUserRelatedData (  ) 

check wether user related tracking is enabled or not

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

References ilObject::$ilias.

Referenced by ilUserTracking::_trackAccess().

        {
                global $ilias;

                return (boolean) $ilias->getSetting("save_user_related_data");
        }

Here is the caller graph for this function:

ilObjSysUserTracking::allAuthor ( a_type,
type 
)

get all author

Definition at line 383 of file class.ilObjSysUserTracking.php.

References ilObject::$type.

        {
                global $ilDB;

                $q = "SELECT distinct A.obj_id,A.type,A.title FROM object_data as A,object_data as B WHERE A.type = ".$ilDB->quote($a_type)." AND A.obj_id = B.owner AND B.type=".$ilDB->quote($type);
                //echo $q;
                $author = $ilDB->query($q);
                $all = array();
                while ($aauthor = $author->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $all[] = array("title" => $aauthor["title"],
                                        "obj_id" =>$aauthor["obj_id"]);
                }
                return $all;
        }

ilObjSysUserTracking::authorLms ( id,
type 
)

get author's all lm or tst

Definition at line 402 of file class.ilObjSysUserTracking.php.

References ilObject::$id, and ilObject::$type.

        {
                global $ilDB;

                $q = "SELECT title,obj_id FROM object_data WHERE owner = ".$ilDB->quote($id)." and type=".$ilDB->quote($type);
                //echo $q."<br>";
                $lms = $ilDB->query($q);
                $all = array();
                while ($alms = $lms->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $all[] = array("title" => $alms["title"],
                                        "obj_id" =>$alms["obj_id"]);
                }
                return $all;
                
        }

ilObjSysUserTracking::countResults ( condition  ) 

Return the counts of search results.

Definition at line 452 of file class.ilObjSysUserTracking.php.

References $res.

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

ilObjSysUserTracking::delete (  ) 

delete object and all related data

public

Returns:
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 76 of file class.ilObjSysUserTracking.php.

        {
                // always call parent delete function first!!
                if (!parent::delete())
                {
                        return false;
                }

                //put here your module specific stuff

                return true;
        }

ilObjSysUserTracking::deleteTrackingDataBeforeMonth ( a_month  ) 

delete tracking data of month (YYYY-MM) and before

Definition at line 316 of file class.ilObjSysUserTracking.php.

        {
                global $ilDB;

                $q = "DELETE FROM ut_access WHERE acc_time < ".
                        "date_add(".$ilDB->quote("$a_month-01").", INTERVAL 1 MONTH)";

                $ilDB->query($q);
        }

ilObjSysUserTracking::enableTracking ( a_enable  ) 

enable user tracking

Definition at line 329 of file class.ilObjSysUserTracking.php.

References ilObject::$ilias.

        {
                global $ilias;

                if ($a_enable)
                {
                        $ilias->setSetting("enable_tracking", 1);
                }
                else
                {
                        $ilias->setSetting("enable_tracking", 0);
                }
        }

ilObjSysUserTracking::enableUserRelatedData ( a_enable  ) 

enable tracking of user related data

Definition at line 356 of file class.ilObjSysUserTracking.php.

References ilObject::$ilias.

        {
                global $ilias;

                if ($a_enable)
                {
                        $ilias->setSetting("save_user_related_data", 1);
                }
                else
                {
                        $ilias->setSetting("save_user_related_data", 0);
                }
        }

ilObjSysUserTracking::getAccessPerUserDetail ( a_condition  ) 

get per user of records older than given month (YYYY-MM)

Definition at line 287 of file class.ilObjSysUserTracking.php.

References ilObjUser::_lookupName(), and ilObject::_lookupTitle().

        {
                global $ilDB;

                $q ="SELECT user_id,client_ip,acc_obj_id,language ,acc_time ".
                        "FROM ut_access WHERE ".$a_condition;
                $cnt_set = $ilDB->query($q);
                $acc = array();
                while($cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $name = ilObjUser::_lookupName($cnt_rec["user_id"]);

                        if ($cnt_rec["user_id"] != 0)
                        {
                                $acc[] = array("user_id" => $cnt_rec["user_id"],
                                        "name" => $name["lastname"].", ".$name["firstname"],
                                        "client_ip" => $cnt_rec["client_ip"],
                                        "acc_obj_id" => ilObject::_lookupTitle($cnt_rec["acc_obj_id"]),
                                        "language" => $cnt_rec["language"],
                                        "acc_time" => $cnt_rec["acc_time"]
                                        );
                        }
                }

                return $acc;
        }

Here is the call graph for this function:

ilObjSysUserTracking::getAccessTotalPerObj ( a_condition  ) 

get total number of records older than given month (YYYY-MM)

Definition at line 263 of file class.ilObjSysUserTracking.php.

References ilObject::_lookupTitle(), and ilObject::getOwnerName().

        {
                global $ilDB;
                $q = "SELECT count(*) as cnt,acc_obj_id from ut_access where ".$a_condition.
                        " GROUP BY acc_obj_id";
                $cnt_set = $ilDB->query($q);
                //echo "q:".$q;

                $acc = array();
                while ($cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        if ($cnt_rec["cnt"] != "")
                        {
                                
                                $acc[] = array("title" => ilObject::_lookupTitle($cnt_rec["acc_obj_id"]),
                                        "author" => $this->getOwnerName($cnt_rec["acc_obj_id"]),
                                        "cnt" => $cnt_rec["cnt"]);
                        }
                }
                return $acc;
        }

Here is the call graph for this function:

ilObjSysUserTracking::getAccessTotalPerUser ( a_condition  ) 

get total number of records older than given month (YYYY-MM)

Definition at line 236 of file class.ilObjSysUserTracking.php.

References ilObjUser::_lookupName().

        {
                global $ilDB;

                $q = "SELECT count(*) AS cnt, user_id ".
                        "FROM ut_access WHERE ".$a_condition.
                        " GROUP BY user_id";
                $cnt_set = $ilDB->query($q);

                $acc = array();
                while ($cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $name = ilObjUser::_lookupName($cnt_rec["user_id"]);

                        if ($cnt_rec["user_id"] != 0)
                        {
                                $acc[] = array("user_id" => $cnt_rec["user_id"],
                                        "name" => $name["lastname"].", ".$name["firstname"],
                                        "cnt" => $cnt_rec["cnt"]);
                        }
                }
                return $acc;
        }

Here is the call graph for this function:

ilObjSysUserTracking::getMonthTotalOverview (  ) 

get total number of accesses per month

Definition at line 200 of file class.ilObjSysUserTracking.php.

        {
                global $ilDB;

                $q = "SELECT count(*) as cnt, count(distinct user_id) as user_cnt, date_format(acc_time,'%Y-%m') AS month FROM ut_access".
                        " GROUP BY month ORDER BY month DESC";
                $min_set = $ilDB->query($q);
                $months = array();
                while ($min_rec = $min_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $months[] = array("month" => $min_rec["month"],
                                "cnt" => $min_rec["cnt"], "user_cnt" => $min_rec["user_cnt"]);
                }
                return $months;
        }

ilObjSysUserTracking::getObjId ( title,
type 
)

get obj_id of some object

Definition at line 422 of file class.ilObjSysUserTracking.php.

References ilObject::$id, ilObject::$title, and ilObject::$type.

        {
                global $ilDB;
                $q ="SELECT obj_id FROM object_data WHERE type = ".$ilDB->quote($type)." and title=".$ilDB->quote($title);
                $id = $ilDB->query($q);
                $obj_id = $id->fetchRow(DB_FETCHMODE_ASSOC);
                return $obj_id["obj_id"];
        }

ilObjSysUserTracking::getOwnerName ( id  ) 

Return the owner name of the object.

Definition at line 465 of file class.ilObjSysUserTracking.php.

References ilObject::$id, and $res.

        {
                $q =" select A.login from usr_data as A, object_data as B where A.usr_id=B.owner and B.obj_id = ".
                        $ilDB->quote($id);
                $res = $this->ilias->db->query($q);
                $result = $res->fetchRow();
                return $result[0];
        }

ilObjSysUserTracking::getRecordsTotal (  ) 

get total number of tracking records

Definition at line 185 of file class.ilObjSysUserTracking.php.

        {
                global $ilDB;

                $q = "SELECT count(*) AS cnt FROM ut_access";
                $cnt_set = $ilDB->query($q);

                $cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);

                return $cnt_rec["cnt"];
        }

ilObjSysUserTracking::getTestId ( id  ) 

get Test_id of some test

Definition at line 434 of file class.ilObjSysUserTracking.php.

References ilObject::$id, and $res.

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

ilObjSysUserTracking::getTotalOlderThanMonth ( a_month  ) 

get total number of records older than given month (YYYY-MM)

Definition at line 219 of file class.ilObjSysUserTracking.php.

        {
                global $ilDB;

                $q = "SELECT count(*) as cnt, date_add(".$ilDB->quote("$a_month-01").", INTERVAL 1 MONTH) as d FROM ut_access WHERE acc_time < ".
                        "date_add(".$ilDB->quote("$a_month-01").", INTERVAL 1 MONTH)";

                $cnt_set = $ilDB->query($q);
                $cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);
//echo "cnt:".$cnt_rec["cnt"].":date:".$cnt_rec["d"].":";

                return $cnt_rec["cnt"];
        }

ilObjSysUserTracking::ilObjSysUserTracking ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

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

References ilObject::ilObject().

        {
                $this->type = "trac";
                $this->ilObject($a_id,$a_call_by_reference);
        }

Here is the call graph for this function:

ilObjSysUserTracking::initDefaultRoles (  ) 

init default roles settings

If your module does not require any default roles, delete this method (For an example how this method is used, look at ilObjForum)

public

Returns:
array object IDs of created local roles.

Reimplemented from ilObject.

Definition at line 98 of file class.ilObjSysUserTracking.php.

        {
                global $rbacadmin;

                // create a local role folder
                //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());

                // create moderator role and assign role to rolefolder...
                //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
                //$roles[] = $roleObj->getId();

                //unset($rfoldObj);
                //unset($roleObj);

                return $roles ? $roles : array();
        }

ilObjSysUserTracking::notify ( a_event,
a_ref_id,
a_parent_non_rbac_id,
a_node_id,
a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

If you are not required to handle any events related to your module, just delete this method. (For an example how this method is used, look at ilObjGroup)

public

Parameters:
string event
integer reference id of object where the event occured
array passes optional parameters if required
Returns:
boolean

Reimplemented from ilObject.

Definition at line 128 of file class.ilObjSysUserTracking.php.

References $_GET, and ilObject::getType().

        {
                global $tree;

                switch ($a_event)
                {
                        case "link":

                                //var_dump("<pre>",$a_params,"</pre>");
                                //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
                                //exit;
                                break;

                        case "cut":

                                //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
                                //exit;
                                break;

                        case "copy":

                                //var_dump("<pre>",$a_params,"</pre>");
                                //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
                                //exit;
                                break;

                        case "paste":

                                //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
                                //exit;
                                break;

                        case "new":

                                //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
                                //exit;
                                break;
                }

                // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
                if ($a_node_id==$_GET["ref_id"])
                {
                        $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
                        $parent_type = $parent_obj->getType();
                        if($parent_type == $this->getType())
                        {
                                $a_node_id = (int) $tree->getParentId($a_node_id);
                        }
                }

                parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
        }

Here is the call graph for this function:

ilObjSysUserTracking::update (  ) 

update object data

public

Returns:
boolean

Reimplemented from ilObject.

Definition at line 57 of file class.ilObjSysUserTracking.php.

        {
                if (!parent::update())
                {
                        return false;
                }

                // put here object specific stuff

                return true;
        }


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