engine/lib/access.php File Reference

(r6838/r6794)

Go to the source code of this file.

Classes

class  ElggAccess
 Temporary class used to determing if access is being ignored. More...

Packages

package  Elgg
 

Elgg CSS file.


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)
 Gets an array of access restrictions the given user is allowed to see on this site.
 get_default_access (ElggUser $user=null)
 Gets the default access permission for new content.
 access_show_hidden_entities ($show_hidden)
 This will be replaced.
 access_get_show_hidden_status ()
 This will be replaced.
 get_annotation_sql ($annotation_name, $entity_guid, $owner_guid, $exists)
 Add annotation restriction.
 get_access_sql_suffix ($table_prefix= '', $owner=null)
 Add access restriction sql code to a given query.
 has_access_to_entity ($entity, $user=null)
 Determines whether the given user has access to the given entity.
 get_write_access_array ($user_id=0, $site_id=0, $flush=false)
 Returns an array of access permissions that the specified user is allowed to save objects with.
 create_access_collection ($name, $owner_guid=0, $site_guid=0)
 Creates a new access control collection owned by the specified user.
 update_access_collection ($collection_id, $members)
 Updates the membership in an access collection.
 delete_access_collection ($collection_id)
 Deletes a specified access collection.
 get_access_collection ($collection_id)
 Get a specified access collection.
 add_user_to_access_collection ($user_guid, $collection_id)
 Adds a user to the specified user 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)
 Get all of a users collections.
 get_members_of_access_collection ($collection, $idonly=FALSE)
 Get all of members of a friend collection.
 elgg_view_access_collections ($owner_guid)
 Displays a user's access collections, using the friends/collections view.
 get_entities_from_access_id ($collection_id, $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $offset=0, $order_by="", $site_guid=0, $count=false)
 Get entities with the specified access collection id.
 elgg_get_entities_from_access_id (array $options=array())
 Retrieve entities for a given access collection.
 list_entities_from_access_id ($collection_id, $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $fullview=true, $viewtypetoggle=true, $pagination=true)
 Lists entities from an access collection.
 get_readable_access_level ($entity_accessid)
 Return a humanreadable version of an entity's access level.
 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=null)
 Decides if the access system is being ignored.
 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 ($hook, $type, $returnval, $params)
 Override permissions system.

Variables

 $ENTITY_SHOW_HIDDEN_OVERRIDE = false
 Override the default behaviour and allow results to show hidden entities as well.
global $init_finished = false

Function Documentation

access_get_show_hidden_status (  ) 

This will be replaced.

Do not use in plugins!

Definition at line 208 of file access.php.

References $ENTITY_SHOW_HIDDEN_OVERRIDE.

Referenced by defaultwidgets_reset_access(), enable_entity(), and uservalidationbyemail_page_handler().

access_init (  ) 

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

Definition at line 864 of file access.php.

access_show_hidden_entities ( show_hidden  ) 

This will be replaced.

Do not use in plugins!

Parameters:
bool $show

Definition at line 200 of file access.php.

References $ENTITY_SHOW_HIDDEN_OVERRIDE.

Referenced by defaultwidgets_reset_access(), enable_entity(), and uservalidationbyemail_page_handler().

add_user_to_access_collection ( user_guid,
collection_id 
)

Adds a user to the specified user collection.

Parameters:
int $user_guid The GUID of the user to add
int $collection_id The ID of the collection to add them to
Returns:
true|false Depending on success

Definition at line 532 of file access.php.

References $collection, $collection_id, $CONFIG, $e, $params, $user, $user_guid, get_access_collection(), get_user(), get_write_access_array(), insert_data(), and trigger_plugin_hook().

Referenced by groups_user_join_event_listener(), and update_access_collection().

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

Creates a new access control collection owned by the specified user.

Parameters:
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).
Returns:
int|false Depending on success (the collection ID if successful).

Definition at line 405 of file access.php.

References $CONFIG, $id, $name, $owner_guid, $params, get_loggedin_userid(), insert_data(), sanitise_string(), and trigger_plugin_hook().

Referenced by groups_create_event_listener().

delete_access_collection ( collection_id  ) 

Deletes a specified access collection.

Parameters:
int $collection_id The collection ID
Returns:
true|false Depending on success

Definition at line 489 of file access.php.

References $collection_id, $CONFIG, $params, delete_data(), get_write_access_array(), and trigger_plugin_hook().

Referenced by groups_delete_event_listener().

elgg_check_access_overrides ( user_guid = null  ) 

Decides if the access system is being ignored.

Returns:
bool
Since:
1.7.0

Definition at line 831 of file access.php.

References $user_guid, elgg_get_ignore_access(), and elgg_is_admin_user().

Referenced by elgg_override_permissions_hook(), get_access_array(), and get_access_sql_suffix().

elgg_get_access_object (  ) 

Returns the ElggAccess object.

Returns:
ElggAccess
Since:
1.7.0

Definition at line 847 of file access.php.

Referenced by elgg_get_ignore_access(), and elgg_set_ignore_access().

elgg_get_entities_from_access_id ( array $  options = array()  ) 

Retrieve entities for a given access collection.

Parameters:
int $collection_id
array $options
See also:
elgg_get_entities()
Returns:
array
Since:
1.7.0

Definition at line 739 of file access.php.

References $options, and elgg_get_entities().

Referenced by get_entities_from_access_id().

elgg_get_ignore_access (  ) 

Get current ignore access setting.

Returns:
bool
Since:
1.7.0

Definition at line 821 of file access.php.

References elgg_get_access_object().

Referenced by elgg_check_access_overrides().

elgg_override_permissions_hook ( hook,
type,
returnval,
params 
)

Override permissions system.

Returns:
true|null
Since:
1.7.0

Definition at line 875 of file access.php.

References $user_guid, elgg_check_access_overrides(), elgg_is_admin_user(), and get_loggedin_userid().

elgg_set_ignore_access ( ignore = true  ) 

Set if entity access system should be ignored.

Returns:
bool Previous ignore_access setting.
Since:
1.7.0

Definition at line 810 of file access.php.

References elgg_get_access_object().

Referenced by ElggCoreRegressionBugsTest.__construct(), ElggCoreEntityGetterFunctionsTest.__construct(), ElggCoreRegressionBugsTest.__destruct(), groups_get_invited_groups(), and ElggCoreObjectTest.xtestElggObjectAccessOverrides().

elgg_view_access_collections ( owner_guid  ) 

Displays a user's access collections, using the friends/collections view.

Parameters:
int $owner_guid The GUID of the owning user
Returns:
string A formatted rendition of the collections

Definition at line 658 of file access.php.

References $collection, $owner_guid, elgg_view(), get_members_of_access_collection(), get_user_access_collections(), and get_user_friends().

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

Gets an array of access restrictions the given user is allowed to see on this site.

Parameters:
int $user_id User ID; defaults to currently logged in user
int $site_id Site ID; defaults to current site
boolean $flush If set to true, will refresh the access list from the database
Returns:
array An array of access collections suitable for injection in an SQL call

Definition at line 91 of file access.php.

References $collection, $CONFIG, $init_finished, $query, $user_id, elgg_check_access_overrides(), get_data(), get_loggedin_userid(), isloggedin(), and trigger_plugin_hook().

Referenced by get_access_list(), and pages_write_permission_check().

get_access_collection ( collection_id  ) 

Get a specified access collection.

Parameters:
int $collection_id The collection ID
Returns:
array|false Depending on success

Definition at line 516 of file access.php.

References $collection_id, $CONFIG, $get_collection, and get_data_row().

Referenced by add_user_to_access_collection(), notifications_update_collection_notify(), and remove_user_from_access_collection().

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

Parameters:
int $user_id User ID; defaults to currently logged in user
int $site_id Site ID; defaults to current site
boolean $flush If set to true, will refresh the access list from the database
Returns:
string A list of access collections suitable for injection in an SQL call

Definition at line 56 of file access.php.

References $CONFIG, $init_finished, $SESSION, $user_id, and get_access_array().

Referenced by get_access_sql_suffix(), and pages_container_permission_check().

get_access_sql_suffix ( table_prefix = '',
owner = null 
)

Add access restriction sql code to a given query.

Note that if this code is executed in privileged mode it will return blank.

Todo:
DELETE once Query classes are fully integrated
Parameters:
string $table_prefix Optional table. prefix for the access code.
int $owner

Definition at line 254 of file access.php.

References $access, $CONFIG, $ENTITY_SHOW_HIDDEN_OVERRIDE, $owner, elgg_check_access_overrides(), get_access_list(), get_annotation_sql(), get_loggedin_userid(), and sanitise_string().

Referenced by __get_annotations_calculate_x(), __get_entities_from_annotations_calculate_x(), delete_annotation(), elgg_get_entities(), elgg_get_entity_metadata_where_sql(), elgg_get_tags(), find_active_users(), find_metadata(), get_activity_stream_data(), get_annotation(), get_annotations(), get_entities_by_relationship_count(), get_entities_from_metadata_groups(), get_entities_from_metadata_groups_multi(), get_entities_from_private_setting(), get_entities_from_private_setting_multi(), get_entities_in_area(), get_entity_as_row(), get_entity_dates(), get_metadata(), get_metadata_byname(), get_metadata_for_entity(), get_notable_entities(), get_notable_entities_from_metadata(), get_noteable_entities_from_relationship(), get_number_users(), get_objects_in_group(), get_river_items(), get_user_by_code(), get_user_by_email(), get_user_by_username(), has_access_to_entity(), input_livesearch_page_handler(), search_comments_hook(), search_for_group(), search_for_object(), search_for_site(), search_for_user(), search_tags_hook(), update_annotation(), and update_metadata().

get_annotation_sql ( annotation_name,
entity_guid,
owner_guid,
exists 
)

Add annotation restriction.

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.

Todo:
This is fairly generic so perhaps it could be moved to annotations.php
Parameters:
string $annotation_name name of the annotation
string $entity_guid SQL string that evaluates to the GUID of the entity the annotation should be attached to
string $owner_guid SQL string that evaluates to the GUID of the owner of the annotation *
boolean $exists If set to true, will return true if the annotation exists, otherwise returns false
Returns:
string An SQL fragment suitable for inserting into a WHERE clause

Definition at line 227 of file access.php.

References $CONFIG, $entity_guid, and $owner_guid.

Referenced by get_access_sql_suffix().

get_default_access ( ElggUser user = null  ) 

Gets the default access permission for new content.

Returns:
int default access id (see ACCESS defines in elgglib.php)

Definition at line 169 of file access.php.

References $CONFIG, $user, and get_loggedin_user().

Referenced by add_widget(), defaultwidgets_reset_access(), and thewire_incoming_sms().

get_entities_from_access_id ( collection_id,
entity_type = "",
entity_subtype = "",
owner_guid = 0,
limit = 10,
offset = 0,
order_by = "",
site_guid = 0,
count = false 
)

Get entities with the specified access collection id.

Deprecated:
1.7. Use elgg_get_entities_from_access_id()
Parameters:
$collection_id 
$entity_type 
$entity_subtype 
$owner_guid 
$limit 
$offset 
$order_by 
$site_guid 
$count 
Returns:
unknown_type

Definition at line 685 of file access.php.

References $collection_id, $count, $entity_subtype, $entity_type, $guid, $limit, $offset, $options, $owner_guid, elgg_deprecated_notice(), elgg_get_entities_from_access_id(), and sanitise_string().

Referenced by list_entities_from_access_id().

get_members_of_access_collection ( collection,
idonly = FALSE 
)

Get all of members of a friend collection.

Parameters:
int $collection The collection's ID
true|false $idonly If set to true, will only return the members' IDs (default: false)
Returns:
ElggUser entities if successful, false if not

Definition at line 631 of file access.php.

References $collection, $collection_members, $CONFIG, $query, and get_data().

Referenced by elgg_view_access_collections(), groups_read_acl_plugin_hook(), and update_access_collection().

get_readable_access_level ( entity_accessid  ) 

Return a humanreadable version of an entity's access level.

Parameters:
$entity_accessid (int) The entity's access id
Returns:
string e.g. Public, Private etc
Since:
1.7.0

Definition at line 790 of file access.php.

References $access, $options, and get_write_access_array().

get_user_access_collections ( owner_guid,
site_guid = 0 
)

Get all of a users collections.

Parameters:
int $owner_guid The user ID
int $site_guid The GUID of the site (default: current site).
Returns:
true|false Depending on success

Definition at line 606 of file access.php.

References $CONFIG, $owner_guid, $query, and get_data().

Referenced by elgg_view_access_collections(), and user_remove_friend().

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

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

Permissions are of the form ('id' => 'Description')

Parameters:
int $user_id The user's GUID.
int $site_id The current site.
true|false $flush If this is set to true, this will shun any cached version
Returns:
array List of access permissions

Definition at line 354 of file access.php.

References $collection, $CONFIG, $query, $user_id, elgg_echo(), get_data(), get_loggedin_userid(), and trigger_plugin_hook().

Referenced by add_user_to_access_collection(), delete_access_collection(), get_readable_access_level(), remove_user_from_access_collection(), and update_access_collection().

has_access_to_entity ( entity,
user = null 
)

Determines whether the given user has access to the given entity.

Parameters:
ElggEntity $entity The entity to check access for.
ElggUser $user Optionally the user to check access for.
Returns:
boolean True if the user can access the entity

Definition at line 326 of file access.php.

References $CONFIG, $entity, $query, $user, get_access_sql_suffix(), and get_data().

Referenced by object_notifications().

list_entities_from_access_id ( collection_id,
entity_type = "",
entity_subtype = "",
owner_guid = 0,
limit = 10,
fullview = true,
viewtypetoggle = true,
pagination = true 
)

Lists entities from an access collection.

Parameters:
$collection_id 
$entity_type 
$entity_subtype 
$owner_guid 
$limit 
$fullview 
$viewtypetoggle 
$pagination 
Returns:
str

Definition at line 774 of file access.php.

References $collection_id, $count, $entities, $entity_subtype, $entity_type, $fullview, $limit, $offset, $owner_guid, $pagination, elgg_view_entity_list(), get_entities_from_access_id(), and get_input().

remove_user_from_access_collection ( user_guid,
collection_id 
)

Removes a user from an access collection.

Parameters:
int $user_guid The user GUID
int $collection_id The access collection ID
Returns:
true|false Depending on success

Definition at line 572 of file access.php.

References $collection, $collection_id, $CONFIG, $params, $user, $user_guid, delete_data(), get_access_collection(), get_user(), get_write_access_array(), and trigger_plugin_hook().

Referenced by groups_user_leave_event_listener(), update_access_collection(), and user_remove_friend().

update_access_collection ( collection_id,
members 
)

Updates the membership in an access collection.

Parameters:
int $collection_id The ID of the collection.
array $members Array of member GUIDs
Returns:
true|false Depending on success

Definition at line 447 of file access.php.

References $collection_id, $CONFIG, $guid, $members, $params, add_user_to_access_collection(), get_members_of_access_collection(), get_write_access_array(), and remove_user_from_access_collection().


Variable Documentation

$ENTITY_SHOW_HIDDEN_OVERRIDE = false

Override the default behaviour and allow results to show hidden entities as well.

THIS IS A HACK.

Todo:
Replace this with query object!

Definition at line 193 of file access.php.

Referenced by access_get_show_hidden_status(), access_show_hidden_entities(), and get_access_sql_suffix().

$init_finished = false

Definition at line 857 of file access.php.

Referenced by get_access_array(), and get_access_list().

 All Classes Namespaces Files Functions Variables Enumerations
Generated on Thu Sep 2 00:13:01 2010 for Elgg by  doxygen 1.6.3