engine/lib/access.php File Reference

Go to the source code of this file.

Namespaces

namespace  Elgg::Core
 

Activate a plugin or plugins.


Functions

 get_access_list ($user_id=0, $site_id=0, $flush=false)
 Return a string of access_ids for $user_id appropriate for inserting into an SQL IN clause.
 get_access_array ($user_id=0, $site_id=0, $flush=false)
 Returns an array of access IDs a user is permitted to see.
 get_default_access (ElggUser $user=null)
 Gets the default access permission.
 access_show_hidden_entities ($show_hidden)
 Show or hide disabled entities.
 access_get_show_hidden_status ()
 Return current status of showing disabled entities.
 get_access_sql_suffix ($table_prefix= '', $owner=null)
 Returns the SQL where clause for a table with a access_id and enabled columns.
 get_access_restriction_sql ($annotation_name, $entity_guid, $owner_guid, $exists)
 Get the where clause for an access restriction based on annotations.
 has_access_to_entity ($entity, $user=null)
 Can a user access an entity.
 get_write_access_array ($user_id=0, $site_id=0, $flush=false)
 Returns an array of access permissions that the user is allowed to save content with.
 can_edit_access_collection ($collection_id, $user_guid=null)
 Can the user change this access collection?
 create_access_collection ($name, $owner_guid=0, $site_guid=0)
 Creates a new access collection.
 update_access_collection ($collection_id, $members)
 Updates the membership in an access collection.
 delete_access_collection ($collection_id)
 Deletes a specified access collection and its membership.
 get_access_collection ($collection_id)
 Get a specified access collection.
 add_user_to_access_collection ($user_guid, $collection_id)
 Adds a user to an access collection.
 remove_user_from_access_collection ($user_guid, $collection_id)
 Removes a user from an access collection.
 get_user_access_collections ($owner_guid, $site_guid=0)
 Returns an array of database row objects of the access collections owned by $owner_guid.
 get_members_of_access_collection ($collection, $idonly=FALSE)
 Get all of members of an access collection.
 elgg_get_entities_from_access_id (array $options=array())
 Return entities based upon access id.
 elgg_list_entities_from_access_id (array $options=array())
 Lists entities from an access collection.
 get_readable_access_level ($entity_access_id)
 Return the name of an ACCESS_* constant or a access collection, but only if the user has write access on that ACL.
 elgg_set_ignore_access ($ignore=true)
 Set if entity access system should be ignored.
 elgg_get_ignore_access ()
 Get current ignore access setting.
 elgg_check_access_overrides ($user_guid=0)
 Decides if the access system should be ignored for a user.
 elgg_get_access_object ()
 Returns the ElggAccess object.
 access_init ()
 A quick and dirty way to make sure the access permissions have been correctly set up.
 elgg_override_permissions ($hook, $type, $value, $params)
 Overrides the access system if appropriate.
 access_test ($hook, $type, $value, $params)
 Runs unit tests for the entities object.

Variables

 $ENTITY_SHOW_HIDDEN_OVERRIDE = false
 Allow disabled entities and metadata to be returned by getter functions.
 $init_finished = false
 A flag to set if Elgg's access initialization is finished.

Function Documentation

access_get_show_hidden_status (  ) 

Return current status of showing disabled entities.

Returns:
bool private

Definition at line 209 of file access.php.

access_init (  ) 

A quick and dirty way to make sure the access permissions have been correctly set up.

init system

Returns:
void

Definition at line 961 of file access.php.

access_show_hidden_entities ( show_hidden  ) 

Show or hide disabled entities.

Parameters:
bool $show_hidden Show disabled entities.
Returns:
void private

Definition at line 198 of file access.php.

access_test ( hook,
type,
value,
params 
)

Runs unit tests for the entities object.

private

Definition at line 1011 of file access.php.

add_user_to_access_collection ( user_guid,
collection_id 
)

Adds a user to an access collection.

Triggers the 'access:collections:add_user', 'collection' plugin hook.

Parameters:
int $user_guid The GUID of the user to add
int $collection_id The ID of the collection to add them to
Returns:
bool
See also:
update_access_collection()
remove_user_from_access_collection() http://docs.elgg.org/Access/Collections

Definition at line 651 of file access.php.

can_edit_access_collection ( collection_id,
user_guid = null 
)

Can the user change this access collection?

Use the plugin hook of 'access:collections:write', 'user' to change this.

See also:
get_write_access_array() for details on the hook.

Respects access control disabling for admin users and {

See also:
elgg_set_ignore_access()}
get_write_access_array()
Parameters:
int $collection_id The collection id
mixed $user_guid The user GUID to check for. Defaults to logged in user.
Returns:
bool

Definition at line 459 of file access.php.

create_access_collection ( name,
owner_guid = 0,
site_guid = 0 
)

Creates a new access collection.

Access colletions allow plugins and users to create granular access for entities.

Triggers plugin hook 'access:collections:addcollection', 'collection'

Definition at line 502 of file access.php.

delete_access_collection ( collection_id  ) 

Deletes a specified access collection and its membership.

Parameters:
int $collection_id The collection ID
Returns:
bool create_access_collection() update_access_collection()

Definition at line 594 of file access.php.

elgg_check_access_overrides ( 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_guid The user to check against.
Returns:
bool
Since:
1.7.0

Definition at line 914 of file access.php.

elgg_get_access_object (  ) 

Returns the ElggAccess object.

//

Returns:
ElggAccess
Since:
1.7.0 private

Definition at line 934 of file access.php.

elgg_get_entities_from_access_id ( array $  options = array()  ) 

Return entities based upon access id.

Parameters:
array $options Any options accepted by elgg_get_entities() and access_id => int The access ID of the entity.
See also:
elgg_get_entities()
Returns:
mixed If count, int. If not count, array. false on errors.
Since:
1.7.0

Definition at line 799 of file access.php.

elgg_get_ignore_access (  ) 

Get current ignore access setting.

Returns:
bool
Since:
1.7.0
See also:
http://docs.elgg.org/Access/IgnoreAccess
elgg_set_ignore_access()

Definition at line 896 of file access.php.

elgg_list_entities_from_access_id ( array $  options = array()  ) 

Lists entities from an access collection.

Parameters:
array $options See elgg_list_entities() and elgg_get_entities_from_access_id()
See also:
elgg_list_entities()
elgg_get_entities_from_access_id()
Returns:
string

Definition at line 831 of file access.php.

elgg_override_permissions ( hook,
type,
value,
params 
)

Overrides the access system if appropriate.

Allows admin users and calls after elgg_set_ignore_access to bypass the access system.

Registered for the 'permissions_check', 'all' and the 'container_permissions_check', 'all' plugin hooks.

Returns true to override the access system or null if no change is needed.

Returns:
true|null private

Definition at line 980 of file access.php.

elgg_set_ignore_access ( ignore = true  ) 

Set if entity access system should be ignored.

The access system will not return entities in any getter functions if the user doesn't have access.

Definition at line 883 of file access.php.

get_access_array ( user_id = 0,
site_id = 0,
flush = false 
)

Returns an array of access IDs a user is permitted to see.

Can be overridden with the 'access:collections:read', 'user' plugin hook.

This returns a list of all the collection ids a user owns or belongs to plus public and logged in access levels. If the user is an admin, it includes the private access level.

Definition at line 79 of file access.php.

get_access_collection ( collection_id  ) 

Get a specified access collection.

Note:
This doesn't return the members of an access collection, just the database row of the actual collection.
See also:
get_members_of_access_collection()
Parameters:
int $collection_id The collection ID
Returns:
object|false

Definition at line 628 of file access.php.

get_access_list ( user_id = 0,
site_id = 0,
flush = false 
)
get_access_restriction_sql ( annotation_name,
entity_guid,
owner_guid,
exists 
)

Get the where clause for an access restriction based on annotations.

Returns an SQL fragment that is true (or optionally false) if the given user has added an annotation with the given name to the given entity.

Warning:
this is a private function for an untested capability and will likely be removed from a future version of Elgg.
Parameters:
string $annotation_name Name of the annotation
string $entity_guid SQL GUID of entity the annotation is attached to.
string $owner_guid SQL string that evaluates to the GUID of the annotation owner
boolean $exists If true, returns BOOL if the annotation exists
Returns:
string An SQL fragment suitable for inserting into a WHERE clause private

Definition at line 312 of file access.php.

get_access_sql_suffix ( table_prefix = '',
owner = null 
)

Returns the SQL where clause for a table with a access_id and enabled columns.

This handles returning where clauses for ACCESS_FRIENDS and the currently unused block and filter lists in addition to using get_access_list() for access collections and the standard access levels.

Parameters:
string $table_prefix Optional table. prefix for the access code.
int $owner The guid to check access for. Defaults to logged in user.
Returns:
string The SQL for a where clause private

Definition at line 227 of file access.php.

get_default_access ( ElggUser user = null  ) 

Gets the default access permission.

This returns the default access level for the site or optionally for the user.

Parameters:
ElggUser $user Get the user's default access. Defaults to logged in user.
Returns:
int default access id (see ACCESS defines in elgglib.php) http://docs.elgg.org/Access

Definition at line 164 of file access.php.

get_members_of_access_collection ( collection,
idonly = FALSE 
)

Get all of members of an access collection.

Parameters:
int $collection The collection's ID
bool $idonly If set to true, will only return the members' GUIDs (default: false)
Returns:
array ElggUser guids or entities if successful, false if not
See also:
add_user_to_access_collection()
http://docs.elgg.org/Access/Collections

Definition at line 764 of file access.php.

get_readable_access_level ( entity_access_id  ) 

Return the name of an ACCESS_* constant or a access collection, but only if the user has write access on that ACL.

Warning:
This function probably doesn't work how it's meant to.
Parameters:
int $entity_access_id The entity's access id
Returns:
string 'Public', 'Private', etc.
Since:
1.7.0

Definition at line 848 of file access.php.

get_user_access_collections ( owner_guid,
site_guid = 0 
)

Returns an array of database row objects of the access collections owned by $owner_guid.

Parameters:
int $owner_guid The entity guid
int $site_guid The GUID of the site (default: current site).
Returns:
array|false
See also:
add_access_collection()
get_members_of_access_collection() http://docs.elgg.org/Access/Collections

Definition at line 736 of file access.php.

get_write_access_array ( user_id = 0,
site_id = 0,
flush = false 
)

Returns an array of access permissions that the user is allowed to save content with.

Permissions returned are of the form (id => 'name').

Example return value in English: array( 0 => 'Private', -2 => 'Friends', 1 => 'Logged in users', 2 => 'Public', 34 => 'My favorite friends', );

Plugin hook of 'access:collections:write', 'user'

Warning:
this only returns access collections that the user owns plus the standard access levels. It does not return access collections that the user belongs to such as the access collection for a group.
Parameters:
int $user_id The user's GUID.
int $site_id The current site.
bool $flush If this is set to true, this will ignore a cached access array
Returns:
array List of access permissions http://docs.elgg.org/Access

Definition at line 396 of file access.php.

has_access_to_entity ( entity,
user = null 
)

Can a user access an entity.

Warning:
If a logged in user doesn't have access to an entity, the core engine will not load that entity.

This is mostly useful for checking if a user other than the logged in user has access to an entity that is currently loaded.

Parameters:
ElggEntity $entity The entity to check access for.
ElggUser $user Optionally user to check access for. Defaults to logged in user (which is a useless default).
Returns:
bool http://docs.elgg.org/Access

Definition at line 351 of file access.php.

remove_user_from_access_collection ( user_guid,
collection_id 
)

Removes a user from an access collection.

Triggers the 'access:collections:remove_user', 'collection' plugin hook.

Parameters:
int $user_guid The user GUID
int $collection_id The access collection ID
Returns:
bool
See also:
update_access_collection()
remove_user_from_access_collection() http://docs.elgg.org/Access/Collections

Definition at line 696 of file access.php.

update_access_collection ( collection_id,
members 
)

Updates the membership in an access collection.

Warning:
Expects a full list of all members that should be part of the access collection
Note:
This will run all hooks associated with adding or removing members to access collections.
Parameters:
int $collection_id The ID of the collection.
array $members Array of member GUIDs
Returns:
bool add_user_to_access_collection() remove_user_from_access_collection()

Definition at line 555 of file access.php.


Variable Documentation

$ENTITY_SHOW_HIDDEN_OVERRIDE = false

Allow disabled entities and metadata to be returned by getter functions.

Definition at line 189 of file access.php.

$init_finished = false

A flag to set if Elgg's access initialization is finished.

bool $init_finished private

Definition at line 951 of file access.php.

 All Classes Namespaces Files Functions Variables Enumerations
Generated on Fri Jan 27 00:00:27 2012 for Elgg by  doxygen 1.6.3