ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPortfolioAccessHandler Class Reference

Access handler for portfolio. More...

+ Collaboration diagram for ilPortfolioAccessHandler:

Public Member Functions

 __construct ()
 checkAccess ($a_permission, $a_cmd, $a_node_id, $a_type="")
 check access for an object
 checkAccessOfUser ($a_user_id, $a_permission, $a_cmd, $a_node_id, $a_type="")
 check access for an object
 setPermissions ($a_parent_node_id, $a_node_id)
 Set permissions after creating node/object.
 addPermission ($a_node_id, $a_object_id, $a_extended_data=null)
 Add permission to node for object.
 removePermission ($a_node_id, $a_object_id=null)
 Remove permission[s] (for object) to node.
 getPermissions ($a_node_id)
 Get all permissions to node.
 hasRegisteredPermission ($a_node_id)
 hasGlobalPermission ($a_node_id)
 hasGlobalPasswordPermission ($a_node_id)
 getObjectsIShare ()
 getSharedOwners ()
 getSharedObjects ($a_owner_id)

Static Public Member Functions

static getPossibleSharedTargets ()
static getSharedNodePassword ($a_node_id)
static keepSharedSessionPassword ($a_node_id, $a_password)
static getSharedSessionPassword ($a_node_id)

Protected Member Functions

 syncProfile ($a_node_id)

Detailed Description

Access handler for portfolio.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilPersonalDesktopGUI.php 26976 2010-12-16 13:24:38Z akill

Definition at line 18 of file class.ilPortfolioAccessHandler.php.

Constructor & Destructor Documentation

ilPortfolioAccessHandler::__construct ( )

Definition at line 20 of file class.ilPortfolioAccessHandler.php.

References $lng.

{
global $lng;
$lng->loadLanguageModule("wsp");
}

Member Function Documentation

ilPortfolioAccessHandler::addPermission (   $a_node_id,
  $a_object_id,
  $a_extended_data = null 
)

Add permission to node for object.

Parameters
int$a_node_id
int$a_object_id
string$a_extended_data

Definition at line 171 of file class.ilPortfolioAccessHandler.php.

References $ilUser, and syncProfile().

{
global $ilDB, $ilUser;
// current owner must not be added
if($a_object_id == $ilUser->getId())
{
return;
}
$ilDB->manipulate("INSERT INTO usr_portf_acl (node_id, object_id, extended_data)".
" VALUES (".$ilDB->quote($a_node_id, "integer").", ".
$ilDB->quote($a_object_id, "integer").",".
$ilDB->quote($a_extended_data, "text").")");
// portfolio as profile
$this->syncProfile($a_node_id);
}

+ Here is the call graph for this function:

ilPortfolioAccessHandler::checkAccess (   $a_permission,
  $a_cmd,
  $a_node_id,
  $a_type = "" 
)

check access for an object

Parameters
string$a_permission
string$a_cmd
int$a_node_id
string$a_type(optional)
Returns
bool

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

References $ilUser, and checkAccessOfUser().

{
global $ilUser;
return $this->checkAccessOfUser($ilUser->getId(),$a_permission, $a_cmd, $a_node_id, $a_type);
}

+ Here is the call graph for this function:

ilPortfolioAccessHandler::checkAccessOfUser (   $a_user_id,
  $a_permission,
  $a_cmd,
  $a_node_id,
  $a_type = "" 
)

check access for an object

Parameters
integer$a_user_id
string$a_permission
string$a_cmd
int$a_node_id
string$a_type(optional)
Returns
bool

Definition at line 52 of file class.ilPortfolioAccessHandler.php.

References $ilSetting, $ilUser, ilGroupParticipants\_getInstanceByObjId(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupType(), getPermissions(), ilWorkspaceAccessGUI\PERMISSION_ALL, ilWorkspaceAccessGUI\PERMISSION_ALL_PASSWORD, and ilWorkspaceAccessGUI\PERMISSION_REGISTERED.

Referenced by checkAccess().

{
global $rbacreview, $ilUser, $ilSetting;
// #12059
if (!$ilSetting->get('user_portfolios'))
{
return false;
}
// :TODO: create permission for parent node with type ?!
$pf = new ilObjPortfolio($a_node_id, false);
if(!$pf->getId())
{
return false;
}
// portfolio owner has all rights
if($pf->getOwner() == $a_user_id)
{
return true;
}
// other users can only read
if($a_permission == "read" || $a_permission == "visible")
{
// get all objects with explicit permission
$objects = $this->getPermissions($a_node_id);
if($objects)
{
include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php";
// check if given user is member of object or has role
foreach($objects as $obj_id)
{
switch($obj_id)
{
return true;
// check against input kept in session
if(self::getSharedNodePassword($a_node_id) == self::getSharedSessionPassword($a_node_id) ||
$a_permission == "visible")
{
return true;
}
break;
if($ilUser->getId() != ANONYMOUS_USER_ID)
{
return true;
}
break;
default:
switch(ilObject::_lookupType($obj_id))
{
case "grp":
// member of group?
if(ilGroupParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id))
{
return true;
}
break;
case "crs":
// member of course?
if(ilCourseParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id))
{
return true;
}
break;
case "role":
// has role?
if($rbacreview->isAssigned($a_user_id, $obj_id))
{
return true;
}
break;
case "usr":
// direct assignment
if($a_user_id == $obj_id)
{
return true;
}
break;
}
break;
}
}
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPortfolioAccessHandler::getObjectsIShare ( )

Definition at line 264 of file class.ilPortfolioAccessHandler.php.

References $ilUser, $res, and $row.

{
global $ilDB, $ilUser;
$res = array();
$set = $ilDB->query("SELECT obj.obj_id".
" FROM object_data obj".
" JOIN usr_portf_acl acl ON (acl.node_id = obj.obj_id)".
" WHERE obj.owner = ".$ilDB->quote($ilUser->getId(), "integer"));
while ($row = $ilDB->fetchAssoc($set))
{
$res[] = $row["obj_id"];
}
return $res;
}
ilPortfolioAccessHandler::getPermissions (   $a_node_id)

Get all permissions to node.

Parameters
int$a_node_id
Returns
array

Definition at line 220 of file class.ilPortfolioAccessHandler.php.

References $res, and $row.

Referenced by checkAccessOfUser(), and ilSharedResourceGUI\hasAccess().

{
global $ilDB;
$set = $ilDB->query("SELECT object_id FROM usr_portf_acl".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer"));
$res = array();
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row["object_id"];
}
return $res;
}

+ Here is the caller graph for this function:

static ilPortfolioAccessHandler::getPossibleSharedTargets ( )
static

Definition at line 281 of file class.ilPortfolioAccessHandler.php.

References $ilUser, ilParticipants\_getMembershipByType(), ilWorkspaceAccessGUI\PERMISSION_ALL, ilWorkspaceAccessGUI\PERMISSION_ALL_PASSWORD, and ilWorkspaceAccessGUI\PERMISSION_REGISTERED.

Referenced by getSharedObjects(), and getSharedOwners().

{
global $ilUser;
include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php";
include_once "Services/Membership/classes/class.ilParticipants.php";
$grp_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "grp");
$crs_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "crs");
$obj_ids = array_merge($grp_ids, $crs_ids);
$obj_ids[] = $ilUser->getId();
return $obj_ids;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPortfolioAccessHandler::getSharedNodePassword (   $a_node_id)
static

Definition at line 345 of file class.ilPortfolioAccessHandler.php.

References $res, and ilWorkspaceAccessGUI\PERMISSION_ALL_PASSWORD.

Referenced by ilSharedResourceGUI\checkPassword().

{
global $ilDB;
include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php";
$set = $ilDB->query("SELECT extended_data FROM usr_portf_acl".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer").
" AND object_id = ".$ilDB->quote(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, "integer"));
$res = $ilDB->fetchAssoc($set);
if($res)
{
return $res["extended_data"];
}
}

+ Here is the caller graph for this function:

ilPortfolioAccessHandler::getSharedObjects (   $a_owner_id)

Definition at line 325 of file class.ilPortfolioAccessHandler.php.

References $res, $row, and getPossibleSharedTargets().

{
global $ilDB;
$obj_ids = $this->getPossibleSharedTargets();
$res = array();
$set = $ilDB->query("SELECT obj.obj_id".
" FROM object_data obj".
" JOIN usr_portf_acl acl ON (acl.node_id = obj.obj_id)".
" WHERE ".$ilDB->in("acl.object_id", $obj_ids, "", "integer").
" AND obj.owner = ".$ilDB->quote($a_owner_id, "integer"));
while ($row = $ilDB->fetchAssoc($set))
{
$res[$row["obj_id"]] = $row["obj_id"];
}
return $res;
}

+ Here is the call graph for this function:

ilPortfolioAccessHandler::getSharedOwners ( )

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

References $ilUser, $row, and getPossibleSharedTargets().

{
global $ilUser, $ilDB;
$obj_ids = $this->getPossibleSharedTargets();
$user_ids = array();
$set = $ilDB->query("SELECT DISTINCT(obj.owner), u.lastname, u.firstname, u.title".
" FROM object_data obj".
" JOIN usr_portf_acl acl ON (acl.node_id = obj.obj_id)".
" JOIN usr_data u on (u.usr_id = obj.owner)".
" WHERE ".$ilDB->in("acl.object_id", $obj_ids, "", "integer").
" AND obj.owner <> ".$ilDB->quote($ilUser->getId(), "integer").
" ORDER BY u.lastname, u.firstname, u.title");
while ($row = $ilDB->fetchAssoc($set))
{
$user_ids[$row["owner"]] = $row["lastname"].", ".$row["firstname"];
if($row["title"])
{
$user_ids[$row["owner"]] .= ", ".$row["title"];
}
}
return $user_ids;
}

+ Here is the call graph for this function:

static ilPortfolioAccessHandler::getSharedSessionPassword (   $a_node_id)
static

Definition at line 366 of file class.ilPortfolioAccessHandler.php.

References $_SESSION.

{
return $_SESSION["ilshpw_".$a_node_id];
}
ilPortfolioAccessHandler::hasGlobalPasswordPermission (   $a_node_id)

Definition at line 254 of file class.ilPortfolioAccessHandler.php.

References ilWorkspaceAccessGUI\PERMISSION_ALL_PASSWORD.

{
global $ilDB;
$set = $ilDB->query("SELECT object_id FROM usr_portf_acl".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer").
" AND object_id = ".$ilDB->quote(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, "integer"));
return (bool)$ilDB->numRows($set);
}
ilPortfolioAccessHandler::hasGlobalPermission (   $a_node_id)

Definition at line 244 of file class.ilPortfolioAccessHandler.php.

References ilWorkspaceAccessGUI\PERMISSION_ALL.

Referenced by syncProfile().

{
global $ilDB;
$set = $ilDB->query("SELECT object_id FROM usr_portf_acl".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer").
" AND object_id = ".$ilDB->quote(ilWorkspaceAccessGUI::PERMISSION_ALL, "integer"));
return (bool)$ilDB->numRows($set);
}

+ Here is the caller graph for this function:

ilPortfolioAccessHandler::hasRegisteredPermission (   $a_node_id)

Definition at line 234 of file class.ilPortfolioAccessHandler.php.

References ilWorkspaceAccessGUI\PERMISSION_REGISTERED.

Referenced by syncProfile().

{
global $ilDB;
$set = $ilDB->query("SELECT object_id FROM usr_portf_acl".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer").
" AND object_id = ".$ilDB->quote(ilWorkspaceAccessGUI::PERMISSION_REGISTERED, "integer"));
return (bool)$ilDB->numRows($set);
}

+ Here is the caller graph for this function:

static ilPortfolioAccessHandler::keepSharedSessionPassword (   $a_node_id,
  $a_password 
)
static

Definition at line 361 of file class.ilPortfolioAccessHandler.php.

References $_SESSION.

Referenced by ilSharedResourceGUI\checkPassword().

{
$_SESSION["ilshpw_".$a_node_id] = $a_password;
}

+ Here is the caller graph for this function:

ilPortfolioAccessHandler::removePermission (   $a_node_id,
  $a_object_id = null 
)

Remove permission[s] (for object) to node.

Parameters
int$a_node_id
int$a_object_id

Definition at line 196 of file class.ilPortfolioAccessHandler.php.

References $query, and syncProfile().

{
global $ilDB;
$query = "DELETE FROM usr_portf_acl".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer");
if($a_object_id)
{
$query .= " AND object_id = ".$ilDB->quote($a_object_id, "integer");
}
$ilDB->manipulate($query);
// portfolio as profile
$this->syncProfile($a_node_id);
}

+ Here is the call graph for this function:

ilPortfolioAccessHandler::setPermissions (   $a_parent_node_id,
  $a_node_id 
)

Set permissions after creating node/object.

Parameters
int$a_parent_node_id
int$a_node_id

Definition at line 159 of file class.ilPortfolioAccessHandler.php.

{
// nothing to do as owner has irrefutable rights to any portfolio object
}
ilPortfolioAccessHandler::syncProfile (   $a_node_id)
protected

Definition at line 371 of file class.ilPortfolioAccessHandler.php.

References $ilUser, ilObjPortfolio\getDefaultPortfolio(), hasGlobalPermission(), hasRegisteredPermission(), and ilObjPortfolio\setUserDefault().

Referenced by addPermission(), and removePermission().

{
global $ilUser;
// #12845
include_once "Services/Portfolio/classes/class.ilObjPortfolio.php";
if(ilObjPortfolio::getDefaultPortfolio($ilUser->getId()) == $a_node_id)
{
$has_registered = $this->hasRegisteredPermission($a_node_id);
$has_global = $this->hasGlobalPermission($a_node_id);
// not published anymore - remove portfolio as profile
if(!$has_registered && !$has_global)
{
$ilUser->setPref("public_profile", "n");
$ilUser->writePrefs();
ilObjPortfolio::setUserDefault($ilUser->getId());
}
// adapt profile setting
else
{
$new_pref = "y";
if($has_global)
{
$new_pref = "g";
}
if($ilUser->getPref("public_profile") != $new_pref)
{
$ilUser->setPref("public_profile", $new_pref);
$ilUser->writePrefs();
}
}
}
}

+ 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: