Elgg  Version 6.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 (protected Config $config, protected Database $db, protected EntityTable $entities, protected UserCapabilities $capabilities, protected AccessCache $access_cache, protected EventsService $events, protected SessionManagerService $session_manager, protected 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

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 ( protected Config  $config,
protected Database  $db,
protected EntityTable  $entities,
protected UserCapabilities  $capabilities,
protected AccessCache  $access_cache,
protected EventsService  $events,
protected SessionManagerService  $session_manager,
protected Translator  $translator 
)

Constructor.

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

Definition at line 51 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 504 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 325 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 364 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 426 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 470 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 95 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 640 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 282 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 589 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 623 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 668 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 224 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 169 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 486 of file AccessCollections.php.

Elgg\Database\AccessCollections::markInitComplete ( )

Mark the access system as initialized.

Returns
void

Definition at line 67 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 560 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 459 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 397 of file AccessCollections.php.

Member Data Documentation

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

Definition at line 37 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: