Elgg  Version 4.3
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,\ElggCache $cache, PluginHooksService $hooks,\ElggSession $session, 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 ($user_guid=0, $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 (string $name, int $owner_guid=0, string $subtype=null)
 Creates a new access collection. More...
 
 rename (int $collection_id, string $name)
 Renames an access collection. More...
 
 update ($collection_id, array $new_members=[])
 Updates the membership in an access collection. More...
 
 delete (int $collection_id)
 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 ($user_guid, $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
 
 $db
 
 $access_cache
 
 $hooks
 
 $session
 
 $entities
 
 $capabilities
 
 $translator
 
 $init_complete = false
 

Detailed Description

Access collections database service.

Definition at line 21 of file AccessCollections.php.

Constructor & Destructor Documentation

Elgg\Database\AccessCollections::__construct ( Config  $config,
Database  $db,
EntityTable  $entities,
UserCapabilities  $capabilities,
\ElggCache  $cache,
PluginHooksService  $hooks,
\ElggSession  $session,
Translator  $translator 
)

Constructor.

Parameters
Config$configConfig
Database$dbDatabase
EntityTable$entitiesEntity table
UserCapabilities$capabilitiesUser capabilities
\ElggCache$cacheAccess cache
PluginHooksService$hooksHooks
\ElggSession$sessionSession
Translator$translatorTranslator

Definition at line 92 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' plugin hook.

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

Definition at line 636 of file AccessCollections.php.

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

Can the user change this access collection?

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

See also
elgg_get_write_access_array() for details on the hook.

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

Elgg\Database\AccessCollections::create ( string  $name,
int  $owner_guid = 0,
string  $subtype = null 
)

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

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

Deletes a collection and its membership information.

Parameters
int$collection_idID of the collection
Returns
bool

Definition at line 560 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 603 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' plugin hook.

Warning
A callback for that plugin hook 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 144 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 771 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 338 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 720 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 754 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 799 of file AccessCollections.php.

Elgg\Database\AccessCollections::getWriteAccessArray (   $user_guid = 0,
  $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', );

Plugin hook of 'access:collections:write', 'user'

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

Elgg\Database\AccessCollections::hasUser (   $user_guid,
  $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 618 of file AccessCollections.php.

Elgg\Database\AccessCollections::markInitComplete ( )

Mark the access system as initialized.

Returns
void

Definition at line 116 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' plugin hook.

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

Definition at line 692 of file AccessCollections.php.

Elgg\Database\AccessCollections::rename ( int  $collection_id,
string  $name 
)

Renames an access collection.

Parameters
int$collection_idID of the collection
string$nameThe name of the collection
Returns
bool

Definition at line 477 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 592 of file AccessCollections.php.

Elgg\Database\AccessCollections::update (   $collection_id,
array  $new_members = [] 
)

Updates the membership in an access collection.

Warning
Expects a full list of all members that should be part of the access collection
Note
This will run all hooks associated with adding or removing members to access collections.
Parameters
int$collection_idID of the collection.
array$new_membersArray of member entities or GUIDs
Returns
bool

Definition at line 505 of file AccessCollections.php.

Member Data Documentation

Elgg\Database\AccessCollections::$access_cache
protected

Definition at line 48 of file AccessCollections.php.

Elgg\Database\AccessCollections::$capabilities
protected

Definition at line 68 of file AccessCollections.php.

Elgg\Database\AccessCollections::$config
protected

Definition at line 38 of file AccessCollections.php.

Elgg\Database\AccessCollections::$db
protected

Definition at line 43 of file AccessCollections.php.

Elgg\Database\AccessCollections::$entities
protected

Definition at line 63 of file AccessCollections.php.

Elgg\Database\AccessCollections::$hooks
protected

Definition at line 53 of file AccessCollections.php.

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

Definition at line 78 of file AccessCollections.php.

Elgg\Database\AccessCollections::$session
protected

Definition at line 58 of file AccessCollections.php.

Elgg\Database\AccessCollections::$translator
protected

Definition at line 73 of file AccessCollections.php.

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

Definition at line 33 of file AccessCollections.php.

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

Definition at line 28 of file AccessCollections.php.


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