Public Member Functions

ilObjContentObjectAccess Class Reference
[Modules/IliasLearningModule]

Class ilObjContentObjectAccess. More...

Inheritance diagram for ilObjContentObjectAccess:
Collaboration diagram for ilObjContentObjectAccess:

Public Member Functions

 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)
 _lookupOnline ($a_id)
 check wether learning module is online
 _getLastAccessedPage ($a_ref_id, $a_user_id="")
 get last accessed page
 _checkGoto ($a_target)
 check whether goto script will succeed

Detailed Description

Class ilObjContentObjectAccess.

Author:
Alex Killing <alex.killing@gmx.de>
Version:
Id:
class.ilObjContentObjectAccess.php 12007 2006-09-06 10:14:00Z smeyer

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


Member Function Documentation

ilObjContentObjectAccess::_checkAccess ( a_cmd,
a_permission,
a_ref_id,
a_obj_id,
a_user_id = "" 
)

checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)

Parameters:
string $a_cmd command (not permission!)
string $a_permission permission
int $a_ref_id reference id
int $a_obj_id object id
int $a_user_id user id (if not provided, current user is taken)
Returns:
boolean true, if everything is ok

Reimplemented from ilObjectAccess.

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

References $lng, $rbacsystem, _getLastAccessedPage(), and _lookupOnline().

        {
                global $ilUser, $lng, $rbacsystem, $ilAccess;

                if ($a_user_id == "")
                {
                        $a_user_id = $ilUser->getId();
                }

                switch ($a_cmd)
                {
                        case "view":

                                if(!ilObjContentObjectAccess::_lookupOnline($a_obj_id)
                                        && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                                        return false;
                                }
                                break;
                                
                        case "continue":
                        
                                // no continue command for anonymous user
                                if ($ilUser->getId() == ANONYMOUS_USER_ID)
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("lm_no_continue_for_anonym"));
                                        return false;
                                }
                        
                                if(!ilObjContentObjectAccess::_lookupOnline($a_obj_id)
                                        && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                                        return false;
                                }

                                if (ilObjContentObjectAccess::_getLastAccessedPage($a_ref_id,$a_user_id) <= 0)
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("not_accessed_yet"));
                                        return false;
                                }
                                break;
                                
                        // for permission query feature
                        case "info":
                                if(!ilObjContentObjectAccess::_lookupOnline($a_obj_id))
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                                }
                                else
                                {
                                        $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
                                }
                                break;

                }

                switch ($a_permission)
                {
                        case "read":
                        case "visible":
                                if (!ilObjContentObjectAccess::_lookupOnline($a_obj_id) &&
                                        (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                                        return false;
                                }
                                break;
                }


                return true;
        }

Here is the call graph for this function:

ilObjContentObjectAccess::_checkGoto ( a_target  ) 

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 182 of file class.ilObjContentObjectAccess.php.

References $lm_id, $ref_id, ilObject::_getAllReferences(), and ilLMObject::_lookupContObjID().

        {
                global $ilAccess;
                
                $t_arr = explode("_", $a_target);

                if (($t_arr[0] != "lm" &&  $t_arr[0] != "dbk" &&  $t_arr[0] != "st"
                        &&  $t_arr[0] != "pg")
                        || ((int) $t_arr[1]) <= 0)
                {
                        return false;
                }

                if ($t_arr[0] == "lm" || $t_arr[0] == "dbk")
                {
                        if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
                                $ilAccess->checkAccess("visible", "", $t_arr[1]))
                        {
                                return true;
                        }
                }
                else
                {
                        if ($t_arr[2] > 0)
                        {
                                $ref_ids = array($t_arr[2]);
                        }
                        else
                        {
                                // determine learning object
                                include_once("content/classes/class.ilLMObject.php");
                                $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
                                $ref_ids = ilObject::_getAllReferences($lm_id);
                        }
                        // check read permissions
                        foreach ($ref_ids as $ref_id)
                        {
                                // Permission check
                                if ($ilAccess->checkAccess("read", "", $ref_id))
                                {
                                        return true;
                                }
                        }

                }
                return false;
        }

Here is the call graph for this function:

ilObjContentObjectAccess::_getLastAccessedPage ( a_ref_id,
a_user_id = "" 
)

get last accessed page

Parameters:
int $a_obj_id content object id
int $a_user_id user object id

Definition at line 148 of file class.ilObjContentObjectAccess.php.

References $lm_id, $mtree, $q, and _lookupObjId().

Referenced by _checkAccess(), ilObjLearningModuleListGUI::initItem(), and ilObjDlBookListGUI::initItem().

        {
                global $ilDB, $ilUser;
                
                if ($a_user_id == "")
                {
                        $a_user_id = $ilUser->getId();
                }

                $q = "SELECT * FROM lo_access WHERE ".
                        "usr_id = ".$ilDB->quote($a_user_id)." AND ".
                        "lm_id = ".$ilDB->quote($a_ref_id);
                        
                $lm_id = ilObject::_lookupObjId($a_ref_id);

                $acc_set = $ilDB->query($q);

                if ($acc_rec = $acc_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $mtree = new ilTree($lm_id);
                        $mtree->setTableNames('lm_tree','lm_data');
                        $mtree->setTreeTablePK("lm_id");
                        if ($mtree->isInTree($acc_rec["obj_id"]))
                        {
                                return $acc_rec["obj_id"];
                        }
                }
                
                return 0;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjContentObjectAccess::_lookupOnline ( a_id  ) 

check wether learning module is online

Definition at line 131 of file class.ilObjContentObjectAccess.php.

References $q, and ilUtil::yn2tf().

Referenced by _checkAccess(), ilObjLearningModuleListGUI::getProperties(), and ilObjDlBookListGUI::getProperties().

        {
                global $ilDB;

                $q = "SELECT * FROM content_object WHERE id = '".$a_id."'";
                $lm_set = $ilDB->query($q);
                $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);

                return ilUtil::yn2tf($lm_rec["online"]);
        }

Here is the call graph for this function:

Here is the caller graph for this function:


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