Elgg
Version 2.3
|
Public Member Functions | |
__construct (Conf $config, Database $db, EntityTable $entities, ElggStaticVariableCache $cache, PluginHooksService $hooks, ElggSession $session, Translator $translator) | |
Constructor. More... | |
getAccessList ($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... | |
getAccessArray ($user_guid=0, $site_guid=0, $flush=false) | |
Returns an array of access IDs a user is permitted to see. More... | |
getWhereSql (array $options=array()) | |
Returns the SQL where clause for enforcing read access to data. More... | |
hasAccessToEntity ($entity, $user=null) | |
Can a user access an entity. More... | |
getWriteAccessArray ($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... | |
canEdit ($collection_id, $user_guid=null) | |
Can the user change this access collection? More... | |
create ($name, $owner_guid=0, $site_guid=0) | |
Creates a new access collection. More... | |
update ($collection_id, $members) | |
Updates the membership in an access collection. More... | |
delete ($collection_id) | |
Deletes a specified access collection and its membership. More... | |
get ($collection_id) | |
Get a specified access collection. More... | |
addUser ($user_guid, $collection_id) | |
Adds a user to an access collection. More... | |
removeUser ($user_guid, $collection_id) | |
Removes a user from an access collection. More... | |
getEntityCollections ($owner_guid, $site_guid=0) | |
Returns an array of database row objects of the access collections owned by $owner_guid. More... | |
getMembers ($collection_id, $guids_only=false) | |
Get all of members of an access collection. More... | |
getCollectionsByMember ($member_guid, $site_guid=0) | |
Return an array of database row objects of the access collections $entity_guid is a member of. More... | |
getReadableAccessLevel ($entity_access_id) | |
Return the name of an ACCESS_* constant or an access collection, but only if the logged in user owns the access collection or is an admin. More... | |
Protected Attributes | |
$config | |
$db | |
$access_cache | |
$hooks | |
$session | |
$entities | |
$translator | |
$site_guid | |
Definition at line 24 of file AccessCollections.php.
Elgg\Database\AccessCollections::__construct | ( | Conf | $config, |
Database | $db, | ||
EntityTable | $entities, | ||
ElggStaticVariableCache | $cache, | ||
PluginHooksService | $hooks, | ||
ElggSession | $session, | ||
Translator | $translator | ||
) |
Constructor.
Config | $config | Config |
Database | $db | Database |
EntityTable | $entities | Entity table |
ElggStaticVariableCache | $cache | Access cache |
PluginHooksService | $hooks | Hooks |
ElggSession | $session | Session |
Translator | $translator | Translator |
Definition at line 77 of file AccessCollections.php.
Elgg\Database\AccessCollections::addUser | ( | $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 703 of file AccessCollections.php.
Elgg\Database\AccessCollections::canEdit | ( | $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 519 of file AccessCollections.php.
Elgg\Database\AccessCollections::create | ( | $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 559 of file AccessCollections.php.
Elgg\Database\AccessCollections::delete | ( | $collection_id | ) |
Deletes a specified access collection and its membership.
int | $collection_id | The collection ID |
Definition at line 645 of file AccessCollections.php.
Elgg\Database\AccessCollections::get | ( | $collection_id | ) |
Get a specified access collection.
int | $collection_id | The collection ID |
Definition at line 680 of file AccessCollections.php.
Elgg\Database\AccessCollections::getAccessArray | ( | $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.
Definition at line 169 of file AccessCollections.php.
Elgg\Database\AccessCollections::getAccessList | ( | $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 110 of file AccessCollections.php.
Elgg\Database\AccessCollections::getCollectionsByMember | ( | $member_guid, | |
$site_guid = 0 |
|||
) |
Return an array of database row objects of the access collections $entity_guid is a member of.
int | $member_guid | The entity guid |
int | $site_guid | The GUID of the site (default: current site). |
Definition at line 848 of file AccessCollections.php.
Elgg\Database\AccessCollections::getEntityCollections | ( | $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 784 of file AccessCollections.php.
Elgg\Database\AccessCollections::getMembers | ( | $collection_id, | |
$guids_only = false |
|||
) |
Get all of members of an access collection.
int | $collection_id | The collection's ID |
bool | $guids_only | If set to true, will only return the members' GUIDs (default: false) |
Definition at line 813 of file AccessCollections.php.
Elgg\Database\AccessCollections::getReadableAccessLevel | ( | $entity_access_id | ) |
Return the name of an ACCESS_* constant or an access collection, but only if the logged in user owns the access collection or is an admin.
Ownership 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', 'Private'; 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 887 of file AccessCollections.php.
Elgg\Database\AccessCollections::getWhereSql | ( | 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 if null. Passing 0 will build a query for a logged out user (even if there is a 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 292 of file AccessCollections.php.
Elgg\Database\AccessCollections::getWriteAccessArray | ( | $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 453 of file AccessCollections.php.
Elgg\Database\AccessCollections::hasAccessToEntity | ( | $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 395 of file AccessCollections.php.
Elgg\Database\AccessCollections::removeUser | ( | $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 746 of file AccessCollections.php.
Elgg\Database\AccessCollections::update | ( | $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 611 of file AccessCollections.php.
|
protected |
Definition at line 39 of file AccessCollections.php.
|
protected |
Definition at line 29 of file AccessCollections.php.
|
protected |
Definition at line 34 of file AccessCollections.php.
|
protected |
Definition at line 54 of file AccessCollections.php.
|
protected |
Definition at line 44 of file AccessCollections.php.
|
protected |
Definition at line 49 of file AccessCollections.php.
|
protected |
Definition at line 64 of file AccessCollections.php.
|
protected |
Definition at line 59 of file AccessCollections.php.