Elgg  Version 3.0
Public Member Functions | List of all members
Elgg\UserCapabilities Class Reference

WARNING: API IN FLUX. More...

Public Member Functions

 __construct (PluginHooksService $hooks, EntityTable $entities, ElggSession $session)
 Constructor. More...
 
 canBypassPermissionsCheck ($user_guid=0)
 Decides if the access system should be ignored for a user. More...
 
 canEdit (ElggEntity $entity, $user_guid=0)
 Can a user edit this entity? More...
 
 canDelete (ElggEntity $entity, $user_guid=0)
 Can a user delete this entity? More...
 
 canDeleteRiverItem (ElggRiverItem $item, $user_guid=0)
 Can a user delete this river item? More...
 
 canEditMetadata (ElggEntity $entity, $user_guid=0, ElggMetadata $metadata=null)
 Can a user edit metadata on this entity? More...
 
 canEditAnnotation (ElggEntity $entity, $user_guid=0, ElggAnnotation $annotation=null)
 Determines whether or not the user can edit this annotation. More...
 
 canWriteToContainer (ElggEntity $entity, $user_guid=0, $type= 'all', $subtype= 'all')
 Can a user add an entity to this container. More...
 
 canComment (ElggEntity $entity, $user_guid=0, $default=null)
 Can a user comment on an entity? More...
 
 canAnnotate (ElggEntity $entity, $user_guid=0, $annotation_name= '')
 Can a user annotate an entity? More...
 
 canDownload (ElggFile $entity, $user_guid=0, $default=true)
 Can a user download a file? More...
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

Use the elgg_* versions instead.

Definition at line 23 of file UserCapabilities.php.

Constructor & Destructor Documentation

Elgg\UserCapabilities::__construct ( PluginHooksService  $hooks,
EntityTable  $entities,
ElggSession  $session 
)

Constructor.

Parameters
PluginHooksService$hooksPlugin hooks service
EntityTable$entitiesEntity table
ElggSession$sessionSession

Definition at line 47 of file UserCapabilities.php.

Member Function Documentation

Elgg\UserCapabilities::canAnnotate ( ElggEntity  $entity,
  $user_guid = 0,
  $annotation_name = '' 
)

Can a user annotate an entity?

Can be overridden by registering for the plugin hook [permissions_check:annotate:<name>, <entity type>="">] or [permissions_check:annotate, <entity type>="">]. The hooks are called in that order.

If you want logged out users to annotate an object, do not call canAnnotate(). It's easier than using the plugin hook.

Parameters
ElggEntity$entityObjet entity
int$user_guidUser guid (default is logged in user)
string$annotation_nameThe name of the annotation (default is unspecified)
Returns
bool

Definition at line 409 of file UserCapabilities.php.

Elgg\UserCapabilities::canBypassPermissionsCheck (   $user_guid = 0)

Decides if the access system should be ignored for a user.

Returns true (meaning ignore access) if either of these 2 conditions are true: 1) an admin user guid is passed to this function. 2) elgg_get_ignore_access() returns true.

See also
elgg_set_ignore_access()
Parameters
int$user_guidThe user to check against.
Returns
bool

Definition at line 66 of file UserCapabilities.php.

Elgg\UserCapabilities::canComment ( ElggEntity  $entity,
  $user_guid = 0,
  $default = null 
)

Can a user comment on an entity?

Can be overridden by registering for the permissions_check:comment, <entity type>=""> plugin hook.

Parameters
ElggEntity$entityObject entity
int$user_guidUser guid (default is logged in user)
bool$defaultDefault permission
Returns
bool|null

Definition at line 374 of file UserCapabilities.php.

Elgg\UserCapabilities::canDelete ( ElggEntity  $entity,
  $user_guid = 0 
)

Can a user delete this entity?

Can be overridden by registering for the permissions_check:delete plugin hook.

Parameters
ElggEntity$entityObject entity
int$user_guidThe user GUID, optionally (default: logged in user)
Returns
bool Whether this entity is deletable by the given user.
Since
1.11
See also
elgg_set_ignore_access()

Definition at line 151 of file UserCapabilities.php.

Elgg\UserCapabilities::canDeleteRiverItem ( ElggRiverItem  $item,
  $user_guid = 0 
)

Can a user delete this river item?

Can be overridden by registering for the "permissions_check:delete", "river" plugin hook.

Parameters
ElggRiverItem$itemRiver item
int$user_guidThe user GUID, optionally (default: logged in user)
Returns
bool Whether this river item should be considered deletable by the given user.
Since
2.3
See also
elgg_set_ignore_access()

Definition at line 183 of file UserCapabilities.php.

Elgg\UserCapabilities::canDownload ( ElggFile  $entity,
  $user_guid = 0,
  $default = true 
)

Can a user download a file?

Can be overridden by registering for the permissions_check:download,file plugin hook.

Parameters
ElggFile$entityFile entity
int$user_guidUser guid (default is logged in user)
bool$defaultDefault permission
Returns
bool

Definition at line 453 of file UserCapabilities.php.

Elgg\UserCapabilities::canEdit ( ElggEntity  $entity,
  $user_guid = 0 
)

Can a user edit this entity?

Can be overridden by registering for the permissions_check plugin hook.

Parameters
ElggEntity$entityObject entity
int$user_guidThe user GUID, optionally (default: logged in user)
Returns
bool Whether this entity is editable by the given user.
See also
elgg_set_ignore_access()

Definition at line 93 of file UserCapabilities.php.

Elgg\UserCapabilities::canEditAnnotation ( ElggEntity  $entity,
  $user_guid = 0,
ElggAnnotation  $annotation = null 
)

Determines whether or not the user can edit this annotation.

Parameters
Elggentity$entityObject entity
int$user_guidThe GUID of the user (defaults to currently logged in user)
ElggAnnotation$annotationAnnotation
Returns
bool
See also
elgg_set_ignore_access()

Definition at line 264 of file UserCapabilities.php.

Elgg\UserCapabilities::canEditMetadata ( ElggEntity  $entity,
  $user_guid = 0,
ElggMetadata  $metadata = null 
)

Can a user edit metadata on this entity?

If no specific metadata is passed, it returns whether the user can edit any metadata on the entity.

Since 3.0, metadata is not owned and can in principle be updated by any user, who has access to the entity. You can still use the hook to prevent the metadata from being written to the database, however it may propagate in ElggEntity properties. Use ElggEntity::canEdit() before setting metadata, if you want to ensure that only owners/admins can update metadata.

Parameters
ElggEntity$entityObject entity
int$user_guidThe user GUID, optionally (default: logged in user)
ElggMetadata$metadataThe piece of metadata to specifically check or null for any metadata
Returns
bool
See also
elgg_set_ignore_access()

Definition at line 221 of file UserCapabilities.php.

Elgg\UserCapabilities::canWriteToContainer ( ElggEntity  $entity,
  $user_guid = 0,
  $type = 'all',
  $subtype = 'all' 
)

Can a user add an entity to this container.

Parameters
ElggEntity$entityContainer entity
int$user_guidThe GUID of the user creating the entity (0 for logged in user).
string$typeThe type of entity we're looking to write
string$subtypeThe subtype of the entity we're looking to write
Returns
bool
See also
elgg_set_ignore_access()

Definition at line 314 of file UserCapabilities.php.


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