Elgg
Version 1.11
|
Go to the source code of this file.
Namespaces | |
Elgg\Core | |
Activate a plugin or plugins. | |
Functions | |
elgg_set_ignore_access ($ignore=true) | |
Set if Elgg's access system should be ignored. More... | |
elgg_get_ignore_access () | |
Get current ignore access setting. More... | |
get_access_list ($user_guid=0, $site_guid=0, $flush=false) | |
Return a string of access_ids for $user_guid appropriate for inserting into an SQL IN clause. More... | |
get_access_array ($user_guid=0, $site_guid=0, $flush=false) | |
Returns an array of access IDs a user is permitted to see. More... | |
get_default_access (ElggUser $user=null, array $input_params=array()) | |
Gets the default access permission. More... | |
access_show_hidden_entities ($show_hidden) | |
Show or hide disabled entities. More... | |
access_get_show_hidden_status () | |
Return current status of showing disabled entities. More... | |
_elgg_get_access_where_sql (array $options=array()) | |
Returns the SQL where clause for enforcing read access to data. More... | |
has_access_to_entity ($entity, $user=null) | |
Can a user access an entity. More... | |
get_write_access_array ($user_guid=0, $site_guid=0, $flush=false, array $input_params=array()) | |
Returns an array of access permissions that the user is allowed to save content with. More... | |
can_edit_access_collection ($collection_id, $user_guid=null) | |
Can the user change this access collection? More... | |
create_access_collection ($name, $owner_guid=0, $site_guid=0) | |
Creates a new access collection. More... | |
update_access_collection ($collection_id, $members) | |
Updates the membership in an access collection. More... | |
delete_access_collection ($collection_id) | |
Deletes a specified access collection and its membership. More... | |
get_access_collection ($collection_id) | |
Get a specified access collection. More... | |
add_user_to_access_collection ($user_guid, $collection_id) | |
Adds a user to an access collection. More... | |
remove_user_from_access_collection ($user_guid, $collection_id) | |
Removes a user from an access collection. More... | |
get_user_access_collections ($owner_guid, $site_guid=0) | |
Returns an array of database row objects of the access collections owned by $owner_guid. More... | |
get_members_of_access_collection ($collection, $idonly=false) | |
Get all of members of an access collection. More... | |
elgg_get_entities_from_access_id (array $options=array()) | |
Return entities based upon access id. More... | |
elgg_list_entities_from_access_id (array $options=array()) | |
Lists entities from an access collection. More... | |
get_readable_access_level ($entity_access_id) | |
Return the name of an ACCESS_* constant or an access collection, but only if the logged in user has write access to it. More... | |
elgg_check_access_overrides ($user_guid=0) | |
Decides if the access system should be ignored for a user. More... | |
access_init () | |
A quick and dirty way to make sure the access permissions have been correctly set up. More... | |
elgg_override_permissions ($hook, $type, $value, $params) | |
Overrides the access system if appropriate. More... | |
access_test ($hook, $type, $value, $params) | |
Runs unit tests for the access library. More... | |
Variables | |
$ENTITY_SHOW_HIDDEN_OVERRIDE = false | |
Allow disabled entities and metadata to be returned by getter functions. More... | |
$init_finished = false | |
A flag to set if Elgg's access initialization is finished. More... | |
return | function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
The function used to get results. More... | |
_elgg_get_access_where_sql | ( | array | $options = array() | ) |
Returns the SQL where clause for enforcing read access to data.
Note that if this code is executed in privileged mode it will return (1=1).
Otherwise it returns a where clause to retrieve the data that a user has permission to read.
Plugin authors can hook into the 'get_sql', 'access' plugin hook to modify, remove, or add to the where clauses. The plugin hook will pass an array with the current ors and ands to the function in the form: array( 'ors' => array(), 'ands' => array() )
The results will be combined into an SQL where clause in the form: ((or1 OR or2 OR orN) AND (and1 AND and2 AND andN))
array | $options | Array in format: table_alias => STR Optional table alias. This is based on the select and join clauses. Default is 'e'. |
user_guid => INT Optional GUID for the user that we are retrieving data for. Defaults to the logged in user.
use_enabled_clause => BOOL Optional. Should we append the enabled clause? The default is set by access_show_hidden_entities().
access_column => STR Optional access column name. Default is 'access_id'.
owner_guid_column => STR Optional owner_guid column. Default is 'owner_guid'.
guid_column => STR Optional guid_column. Default is 'guid'.
Definition at line 216 of file access.php.
access_get_show_hidden_status | ( | ) |
Return current status of showing disabled entities.
Definition at line 172 of file access.php.
access_init | ( | ) |
A quick and dirty way to make sure the access permissions have been correctly set up.
init system
Definition at line 533 of file access.php.
access_show_hidden_entities | ( | $show_hidden | ) |
Show or hide disabled entities.
bool | $show_hidden | Show disabled entities. |
Definition at line 159 of file access.php.
access_test | ( | $hook, | |
$type, | |||
$value, | |||
$params | |||
) |
Runs unit tests for the access library.
string | $hook | |
string | $type | |
array | $value | |
array | $params |
private
Definition at line 596 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.
int | $user_guid | The GUID of the user to add |
int | $collection_id | The ID of the collection to add them to |
Definition at line 375 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.
Respects access control disabling for admin users and elgg_set_ignore_access()
int | $collection_id | The collection id |
mixed | $user_guid | The user GUID to check for. Defaults to logged in user. |
Definition at line 287 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'
string | $name | The name of the collection. |
int | $owner_guid | The GUID of the owner (default: currently logged in user). |
int | $site_guid | The GUID of the site (default: current site). |
Definition at line 310 of file access.php.
delete_access_collection | ( | $collection_id | ) |
Deletes a specified access collection and its membership.
int | $collection_id | The collection ID |
Definition at line 343 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.
int | $user_guid | The user to check against. |
Definition at line 505 of file access.php.
elgg_get_entities_from_access_id | ( | array | $options = array() | ) |
Return entities based upon access id.
TODO(ewinslow): Move this logic into elgg_get_entities
array | $options | Any options accepted by elgg_get_entities() and access_id => int The access ID of the entity. |
Definition at line 434 of file access.php.
elgg_get_ignore_access | ( | ) |
Get current ignore access setting.
Definition at line 54 of file access.php.
elgg_list_entities_from_access_id | ( | array | $options = array() | ) |
Lists entities from an access collection.
array | $options | See elgg_list_entities() and elgg_get_entities_from_access_id() |
Definition at line 466 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.
Definition at line 558 of file access.php.
elgg_set_ignore_access | ( | $ignore = true | ) |
Set if Elgg's access system should be ignored.
The access system will not return entities in any getter functions if the user doesn't have access. This removes this restriction.
When the access system is being ignored, all checks for create, retrieve, update, and delete should pass. This affects all the canEdit() and related methods.
Use this to access entities in automated scripts when no user is logged in.
bool | $ignore | If true, disables all access checks. |
Definition at line 43 of file access.php.
get_access_array | ( | $user_guid = 0 , |
|
$site_guid = 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.
int | $user_guid | User ID; defaults to currently logged in user |
int | $site_guid | Site ID; defaults to current site |
bool | $flush | If set to true, will refresh the access ids from the database rather than using this function's cache. |
Definition at line 102 of file access.php.
get_access_collection | ( | $collection_id | ) |
Get a specified access collection.
int | $collection_id | The collection ID |
Definition at line 359 of file access.php.
get_access_list | ( | $user_guid = 0 , |
|
$site_guid = 0 , |
|||
$flush = false |
|||
) |
Return a string of access_ids for $user_guid appropriate for inserting into an SQL IN clause.
get_access_array
int | $user_guid | User ID; defaults to currently logged in user |
int | $site_guid | Site ID; defaults to current site |
bool | $flush | If set to true, will refresh the access list from the database rather than using this function's cache. |
Definition at line 73 of file access.php.
get_default_access | ( | ElggUser | $user = null , |
array | $input_params = array() |
||
) |
Gets the default access permission.
This returns the default access level for the site or optionally of the user. If want you to change the default access based on group of other information, use the 'default', 'access' plugin hook.
ElggUser | $user | The user for whom we're getting default access. Defaults to logged in user. |
array | $input_params | Parameters passed into an input/access view |
Definition at line 118 of file access.php.
get_members_of_access_collection | ( | $collection, | |
$idonly = false |
|||
) |
Get all of members of an access collection.
int | $collection | The collection's ID |
bool | $idonly | If set to true, will only return the members' GUIDs (default: false) |
Definition at line 418 of file access.php.
get_readable_access_level | ( | $entity_access_id | ) |
Return the name of an ACCESS_* constant or an access collection, but only if the logged in user has write access to it.
Write access requirement prevents us from exposing names of access collections that current user has been added to by other members and may contain sensitive classification of the current user (e.g. close friends vs acquaintances).
Returns a string in the language of the user for global access levels, e.g.'Public, 'Friends', 'Logged in', 'Public'; or a name of the owned access collection, e.g. 'My work colleagues'; or a name of the group or other access collection, e.g. 'Group: Elgg technical support'; or 'Limited' if the user access is restricted to read-only, e.g. a friends collection the user was added to
int | $entity_access_id | The entity's access id |
Definition at line 486 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.
int | $owner_guid | The entity guid |
int | $site_guid | The GUID of the site (default: current site). |
Definition at line 405 of file access.php.
get_write_access_array | ( | $user_guid = 0 , |
|
$site_guid = 0 , |
|||
$flush = false , |
|||
array | $input_params = array() |
||
) |
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'
int | $user_guid | The user's GUID. |
int | $site_guid | The current site. |
bool | $flush | If this is set to true, this will ignore a cached access array |
array | $input_params | Some parameters passed into an input/access view |
Definition at line 269 of file access.php.
has_access_to_entity | ( | $entity, | |
$user = null |
|||
) |
Can a user access an 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.
\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). |
Definition at line 239 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.
int | $user_guid | The user GUID |
int | $collection_id | The access collection ID |
Definition at line 391 of file access.php.
update_access_collection | ( | $collection_id, | |
$members | |||
) |
Updates the membership in an access collection.
int | $collection_id | The ID of the collection. |
array | $members | Array of member GUIDs |
Definition at line 330 of file access.php.
$ENTITY_SHOW_HIDDEN_OVERRIDE = false |
Allow disabled entities and metadata to be returned by getter functions.
Definition at line 150 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 523 of file access.php.
The function used to get results.
A callback function to pass results through.
Definition at line 603 of file access.php.