Elgg  Version 5.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Database\AccessCollections Class Reference

Access collections database service. More...

Public Member Functions

 __construct (Config $config, Database $db, EntityTable $entities, UserCapabilities $capabilities, BaseCache $cache, EventsService $events, SessionManagerService $session_manager, Translator $translator)
 Constructor. More...
 
 markInitComplete ()
 Mark the access system as initialized. More...
 
 getAccessArray (int $user_guid=0, bool $flush=false)
 Returns an array of access IDs a user is permitted to see. More...
 
 hasAccessToEntity (\ElggEntity $entity, int $user_guid=0)
 Can a user access an entity. More...
 
 getWriteAccessArray (int $user_guid=0, bool $flush=false, array $input_params=[])
 Returns an array of access permissions that the user is allowed to save content with. More...
 
 canEdit (int $collection_id, int $user_guid=null)
 Can the user change this access collection? More...
 
 create (\ElggAccessCollection $acl)
 Creates a new access collection. More...
 
 update (\ElggAccessCollection $acl)
 Update an existing access collection. More...
 
 delete (\ElggAccessCollection $acl)
 Deletes a collection and its membership information. More...
 
 rowToElggAccessCollection (\stdClass $row)
 Transforms a database row to an instance of ElggAccessCollection. More...
 
 get (int $collection_id)
 Get a specified access collection. More...
 
 hasUser (int $user_guid, int $collection_id)
 Check if user is already in the collection. More...
 
 addUser (int $user_guid, int $collection_id)
 Adds a user to an access collection. More...
 
 removeUser (int $user_guid, int $collection_id)
 Removes a user from an access collection. More...
 
 getEntityCollections (array $options=[])
 Returns access collections. More...
 
 getMembers (int $collection_id, array $options=[])
 Get members of an access collection. More...
 
 getCollectionsByMember (int $member_guid)
 Return an array of collections that the entity is member of. More...
 
 getReadableAccessLevel (int $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...
 

Public Attributes

const TABLE_NAME = 'access_collections'
 
const MEMBERSHIP_TABLE_NAME = 'access_collection_membership'
 

Protected Member Functions

 getCollectionsForWriteAccess (int $owner_guid)
 Returns an array of access collections to be used in the write access array. More...
 

Protected Attributes

Config $config
 
Database $db
 
BaseCache $access_cache
 
EventsService $events
 
SessionManagerService $session_manager
 
EntityTable $entities
 
UserCapabilities $capabilities
 
Translator $translator
 
bool $init_complete = false
 

Detailed Description

Access collections database service.

Definition at line 23 of file AccessCollections.php.

Constructor & Destructor Documentation

Elgg\Database\AccessCollections::__construct ( Config  $config,
Database  $db,
EntityTable  $entities,
UserCapabilities  $capabilities,
BaseCache  $cache,
EventsService  $events,
SessionManagerService  $session_manager,
Translator  $translator 
)

Constructor.

Parameters
Config$configConfig
Database$dbDatabase
EntityTable$entitiesEntity table
UserCapabilities$capabilitiesUser capabilities
BaseCache$cacheAccess cache
EventsService$eventsEvents
SessionManagerService$session_managerSession
Translator$translatorTranslator

Definition at line 67 of file AccessCollections.php.

Member Function Documentation

Elgg\Database\AccessCollections::addUser ( int  $user_guid,
int  $collection_id 
)

Adds a user to an access collection.

Triggers the 'access:collections:add_user', 'collection' event.

Parameters
int$user_guidGUID of the user to add
int$collection_idID of the collection to add them to
Returns
bool

Definition at line 530 of file AccessCollections.php.

Elgg\Database\AccessCollections::canEdit ( int  $collection_id,
int  $user_guid = null 
)

Can the user change this access collection?

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

See also
elgg_get_write_access_array() for details on the event.

Respects access control disabling for admin users and elgg_call()

Parameters
int$collection_idThe collection id
int$user_guidThe user GUID to check for. Defaults to logged in user.
Returns
bool

Definition at line 351 of file AccessCollections.php.

Elgg\Database\AccessCollections::create ( \ElggAccessCollection  $acl)

Creates a new access collection.

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

Triggers event sequence 'create', 'access_collection'

Definition at line 390 of file AccessCollections.php.

Elgg\Database\AccessCollections::delete ( \ElggAccessCollection  $acl)

Deletes a collection and its membership information.

Parameters
\ElggAccessCollection$aclthe access collection to update
Returns
bool

Definition at line 452 of file AccessCollections.php.

Elgg\Database\AccessCollections::get ( int  $collection_id)

Get a specified access collection.

Parameters
int$collection_idThe collection ID
Returns
|null

Definition at line 496 of file AccessCollections.php.

Elgg\Database\AccessCollections::getAccessArray ( int  $user_guid = 0,
bool  $flush = false 
)

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

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

Warning
A callback for that event needs to either not retrieve data from the database that would use the access system (triggering the plugin again) or ignore the second call. Otherwise, an infinite loop will be created.

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 119 of file AccessCollections.php.

Elgg\Database\AccessCollections::getCollectionsByMember ( int  $member_guid)

Return an array of collections that the entity is member of.

Parameters
int$member_guidGUID of th member
Returns
[]

Definition at line 666 of file AccessCollections.php.

Elgg\Database\AccessCollections::getCollectionsForWriteAccess ( int  $owner_guid)
protected

Returns an array of access collections to be used in the write access array.

Parameters
int$owner_guidowner of the collections
Returns
array
Since
3.2

Definition at line 308 of file AccessCollections.php.

Elgg\Database\AccessCollections::getEntityCollections ( array  $options = [])

Returns access collections.

Parameters
array$optionsOptions to get access collections by Supported are 'owner_guid', 'subtype'
Returns
[]

Definition at line 615 of file AccessCollections.php.

Elgg\Database\AccessCollections::getMembers ( int  $collection_id,
array  $options = [] 
)

Get members of an access collection.

Parameters
int$collection_idThe collection's ID
array$optionsEge* options
Returns
[]|int|mixed

Definition at line 649 of file AccessCollections.php.

Elgg\Database\AccessCollections::getReadableAccessLevel ( int  $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

Parameters
int$entity_access_idThe entity's access id
Returns
string
Since
1.11

Definition at line 694 of file AccessCollections.php.

Elgg\Database\AccessCollections::getWriteAccessArray ( int  $user_guid = 0,
bool  $flush = false,
array  $input_params = [] 
)

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', );

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_guidThe user's GUID.
bool$flushIf this is set to true, this will ignore a cached access array
array$input_paramsSome parameters passed into an input/access view
Returns
array List of access permissions

Definition at line 249 of file AccessCollections.php.

Elgg\Database\AccessCollections::hasAccessToEntity ( \ElggEntity  $entity,
int  $user_guid = 0 
)

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$entityThe entity to check access for
int$user_guidOptionally user_guid to check access for. Defaults to logged in user
Returns
bool

Definition at line 194 of file AccessCollections.php.

Elgg\Database\AccessCollections::hasUser ( int  $user_guid,
int  $collection_id 
)

Check if user is already in the collection.

Parameters
int$user_guidGUID of the user
int$collection_idID of the collection
Returns
bool

Definition at line 512 of file AccessCollections.php.

Elgg\Database\AccessCollections::markInitComplete ( )

Mark the access system as initialized.

Returns
void

Definition at line 91 of file AccessCollections.php.

Elgg\Database\AccessCollections::removeUser ( int  $user_guid,
int  $collection_id 
)

Removes a user from an access collection.

Triggers the 'access:collections:remove_user', 'collection' event.

Parameters
int$user_guidGUID of the user
int$collection_idID of the collection
Returns
bool

Definition at line 586 of file AccessCollections.php.

Elgg\Database\AccessCollections::rowToElggAccessCollection ( \stdClass  $row)

Transforms a database row to an instance of ElggAccessCollection.

Parameters
\stdClass$rowDatabase row
Returns

Definition at line 485 of file AccessCollections.php.

Elgg\Database\AccessCollections::update ( \ElggAccessCollection  $acl)

Update an existing access collection.

Parameters
\ElggAccessCollection$aclthe access collection to update
Returns
bool

Definition at line 423 of file AccessCollections.php.

Member Data Documentation

BaseCache Elgg\Database\AccessCollections::$access_cache
protected

Definition at line 41 of file AccessCollections.php.

UserCapabilities Elgg\Database\AccessCollections::$capabilities
protected

Definition at line 49 of file AccessCollections.php.

Config Elgg\Database\AccessCollections::$config
protected

Definition at line 37 of file AccessCollections.php.

Database Elgg\Database\AccessCollections::$db
protected

Definition at line 39 of file AccessCollections.php.

EntityTable Elgg\Database\AccessCollections::$entities
protected

Definition at line 47 of file AccessCollections.php.

EventsService Elgg\Database\AccessCollections::$events
protected

Definition at line 43 of file AccessCollections.php.

bool Elgg\Database\AccessCollections::$init_complete = false
protected

Definition at line 53 of file AccessCollections.php.

SessionManagerService Elgg\Database\AccessCollections::$session_manager
protected

Definition at line 45 of file AccessCollections.php.

Translator Elgg\Database\AccessCollections::$translator
protected

Definition at line 51 of file AccessCollections.php.

const Elgg\Database\AccessCollections::MEMBERSHIP_TABLE_NAME = 'access_collection_membership'

Definition at line 35 of file AccessCollections.php.

const Elgg\Database\AccessCollections::TABLE_NAME = 'access_collections'

Definition at line 30 of file AccessCollections.php.


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