ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilClaimingPermissionHelper Class Reference

Claiming permission helper base class. More...

+ Inheritance diagram for ilClaimingPermissionHelper:
+ Collaboration diagram for ilClaimingPermissionHelper:

Public Member Functions

 reset ()
 Reset (internal caches)
 hasPermission ($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
 Check permission.
 hasPermissions ($a_context_type, $a_context_id, array $a_action_ids)
 Check permissions.

Static Public Member Functions

static getInstance ($a_user_id=null, $a_ref_id=null)
 Factory.

Protected Member Functions

 __construct ($a_user_id, $a_ref_id)
 Constructor.
 setUserId ($a_value)
 Set user id.
 getUserId ()
 Get user id.
 setRefId ($a_value)
 Set ref id.
 getRefId ()
 Get ref id.
 readContextIds ($a_context_type)
 Get all context ids for context type (from DB, is cached)
 buildPermissionMap ()
 Build map of context and actions.
 isValidContextAndAction ($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
 Check if given combination of context and action is valid.
 getValidContextIds ($a_context_type)
 Get context ids for context type (uses cache)
 checkPermission ($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
 Check permission (helper: rbac, plugins)
 checkRBAC ()
 Check permission against RBAC.
 getActivePlugins ()
 Get active plugins (for current slot)
 checkPlugins ($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
 Check permission against plugins.

Protected Attributes

 $user_id
 $ref_id
 $map
 $context_ids
 $plugins

Static Protected Attributes

static $instances

Detailed Description

Claiming permission helper base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilClaimingPermissionHelper.php.

Constructor & Destructor Documentation

ilClaimingPermissionHelper::__construct (   $a_user_id,
  $a_ref_id 
)
protected

Constructor.

Parameters
int$a_user_id
int$a_ref_id
Returns
self

Definition at line 32 of file class.ilClaimingPermissionHelper.php.

References buildPermissionMap(), reset(), setRefId(), and setUserId().

{
$this->setUserId($a_user_id);
$this->setRefId($a_ref_id);
$this->map = $this->buildPermissionMap();
$this->reset();
}

+ Here is the call graph for this function:

Member Function Documentation

ilClaimingPermissionHelper::buildPermissionMap ( )
abstractprotected

Build map of context and actions.

Returns
array

Reimplemented in ilAdvancedMDPermissionHelper, and ilUDFPermissionHelper.

Referenced by __construct().

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::checkPermission (   $a_context_type,
  $a_context_id,
  $a_action_id,
  $a_action_sub_id = null 
)
protected

Check permission (helper: rbac, plugins)

Parameters
int$a_context_type
int$a_context_id
int$a_action_id
int$a_action_sub_id
Returns
bool

Definition at line 259 of file class.ilClaimingPermissionHelper.php.

References checkPlugins(), and checkRBAC().

Referenced by hasPermission().

{
return ($this->checkRBAC() &&
$this->checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::checkPlugins (   $a_context_type,
  $a_context_id,
  $a_action_id,
  $a_action_sub_id = null 
)
protected

Check permission against plugins.

Parameters
int$a_context_type
int$a_context_id
int$a_action_id
int$a_action_sub_id
Returns
boolean

Definition at line 294 of file class.ilClaimingPermissionHelper.php.

References $valid, and getActivePlugins().

Referenced by checkPermission().

{
$valid = true;
if(!is_array($this->plugins))
{
$this->plugins = (array)$this->getActivePlugins();
}
foreach($this->plugins as $plugin)
{
if(!$plugin->checkPermission($this->getUserId(), $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id))
{
$valid = false;
break;
}
}
return $valid;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::checkRBAC ( )
protected

Check permission against RBAC.

Returns
bool

Definition at line 270 of file class.ilClaimingPermissionHelper.php.

References getRefId(), and getUserId().

Referenced by checkPermission().

{
global $ilAccess;
// we are currently only supporting write operations
return $ilAccess->checkAccessOfUser($this->getUserId(), "write", "", $this->getRefId());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::getActivePlugins ( )
abstractprotected

Get active plugins (for current slot)

Returns
array ilPlugin

Reimplemented in ilAdvancedMDPermissionHelper, and ilUDFPermissionHelper.

Referenced by checkPlugins().

+ Here is the caller graph for this function:

static ilClaimingPermissionHelper::getInstance (   $a_user_id = null,
  $a_ref_id = null 
)
static

Factory.

Parameters
int$a_user_id
int$a_ref_id
Returns
self

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

References $_REQUEST, and $ilUser.

Referenced by ilCustomUserFieldsGUI\__construct(), and ilAdvancedMDSettingsGUI\__construct().

{
global $ilUser;
if(!$a_user_id)
{
$a_user_id = $ilUser->getId();
}
if(!$a_ref_id)
{
$a_ref_id = (int)$_REQUEST["ref_id"];
}
if(!isset(self::$instances[$a_user_id][$a_ref_id]))
{
self::$instances[$a_user_id][$a_ref_id] = new static($a_user_id, $a_ref_id);
}
return self::$instances[$a_user_id][$a_ref_id];
}

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::getRefId ( )
protected

Get ref id.

Returns
int

Definition at line 112 of file class.ilClaimingPermissionHelper.php.

References $ref_id.

Referenced by checkRBAC().

{
return $this->ref_id;
}

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::getUserId ( )
protected

Get user id.

Returns
int

Definition at line 92 of file class.ilClaimingPermissionHelper.php.

References $user_id.

Referenced by checkRBAC().

{
}

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::getValidContextIds (   $a_context_type)
protected

Get context ids for context type (uses cache)

See Also
self::readContextIds()
Parameters
int$a_context_type
Returns
array

Definition at line 193 of file class.ilClaimingPermissionHelper.php.

References readContextIds().

Referenced by isValidContextAndAction().

{
if(!array_key_exists($a_context_type, $this->context_ids))
{
$this->context_ids[$a_context_type] = $this->readContextIds($a_context_type);
}
return (array)$this->context_ids[$a_context_type];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::hasPermission (   $a_context_type,
  $a_context_id,
  $a_action_id,
  $a_action_sub_id = null 
)

Check permission.

Parameters
int$a_context_type
int$a_context_id
int$a_action_id
int$a_action_sub_id
Returns
bool

Definition at line 211 of file class.ilClaimingPermissionHelper.php.

References checkPermission(), and isValidContextAndAction().

Referenced by hasPermissions(), and ilAdvancedMDFieldDefinition\importDefinitionFormPostValues().

{
if($this->isValidContextAndAction($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id))
{
return $this->checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id);
}
// :TODO: exception?
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::hasPermissions (   $a_context_type,
  $a_context_id,
array  $a_action_ids 
)

Check permissions.

Parameters
int$a_context_type
int$a_context_id
array$a_action_ids
Returns
bool

Definition at line 228 of file class.ilClaimingPermissionHelper.php.

References $res, and hasPermission().

Referenced by ilAdvancedMDFieldDefinition\addToFieldDefinitionForm().

{
$res = array();
foreach($a_action_ids as $action_id)
{
if(is_array($action_id))
{
$action_sub_id = $action_id[1];
$action_id = $action_id[0];
$res[$action_id][$action_sub_id] = $this->hasPermission($a_context_type, $a_context_id, $action_id, $action_sub_id);
}
else
{
$res[$action_id] = $this->hasPermission($a_context_type, $a_context_id, $action_id);
}
}
return $res;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::isValidContextAndAction (   $a_context_type,
  $a_context_id,
  $a_action_id,
  $a_action_sub_id = null 
)
protected

Check if given combination of context and action is valid.

Parameters
int$a_context_type
mixed$a_context_id
int$a_action_id
int$a_action_sub_id
Returns
boolean

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

References $valid, and getValidContextIds().

Referenced by hasPermission().

{
$valid = false;
if(array_key_exists($a_context_type, $this->map))
{
if(!$a_action_sub_id)
{
if(in_array($a_action_id, $this->map[$a_context_type]["actions"]))
{
$valid = true;
}
}
else
{
if(array_key_exists($a_action_id, $this->map[$a_context_type]["subactions"]) &&
in_array($a_action_sub_id, $this->map[$a_context_type]["subactions"][$a_action_id]))
{
$valid = true;
}
}
}
if($valid &&
$a_context_id &&
!in_array($a_context_id, $this->getValidContextIds($a_context_type)))
{
$valid = false;
}
if(DEVMODE && !$valid)
{
trigger_error("INVALID permission context - ".$a_context_type.":".$a_context_id.":".$a_action_id.":".$a_action_sub_id, E_USER_WARNING);
}
return $valid;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::readContextIds (   $a_context_type)
abstractprotected

Get all context ids for context type (from DB, is cached)

See Also
self::getValidContextIds()
Parameters
int$a_context_type
Returns
array

Reimplemented in ilAdvancedMDPermissionHelper, and ilUDFPermissionHelper.

Referenced by getValidContextIds().

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::reset ( )

Reset (internal caches)

Definition at line 69 of file class.ilClaimingPermissionHelper.php.

Referenced by __construct().

{
$this->context_ids = array();
}

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::setRefId (   $a_value)
protected

Set ref id.

Parameters
int$a_value

Definition at line 102 of file class.ilClaimingPermissionHelper.php.

Referenced by __construct().

{
$this->ref_id = (int)$a_value;
}

+ Here is the caller graph for this function:

ilClaimingPermissionHelper::setUserId (   $a_value)
protected

Set user id.

Parameters
int$a_value

Definition at line 82 of file class.ilClaimingPermissionHelper.php.

Referenced by __construct().

{
$this->user_id = (int)$a_value;
}

+ Here is the caller graph for this function:

Field Documentation

ilClaimingPermissionHelper::$context_ids
protected

Definition at line 17 of file class.ilClaimingPermissionHelper.php.

ilClaimingPermissionHelper::$instances
staticprotected

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

ilClaimingPermissionHelper::$map
protected

Definition at line 16 of file class.ilClaimingPermissionHelper.php.

ilClaimingPermissionHelper::$plugins
protected

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

ilClaimingPermissionHelper::$ref_id
protected

Definition at line 15 of file class.ilClaimingPermissionHelper.php.

Referenced by getRefId().

ilClaimingPermissionHelper::$user_id
protected

Definition at line 14 of file class.ilClaimingPermissionHelper.php.

Referenced by getUserId().


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