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

WARNING: API IN FLUX. 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...
 
 getAccessList ($user_guid=0, $flush=false)
 Returns a string of access_ids for $user_guid appropriate for inserting into an SQL IN clause. More...
 
 getAccessArray ($user_guid=0, $flush=false)
 Returns an array of access IDs a user is permitted to see. More...
 
 hasAccessToEntity ($entity, $user=null)
 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 ($collection_id, $user_guid=null)
 Can the user change this access collection? More...
 
 create ($name, $owner_guid=0, $subtype=null)
 Creates a new access collection. More...
 
 rename ($collection_id, $name)
 Renames an access collection. More...
 
 update ($collection_id, array $new_members=[])
 Updates the membership in an access collection. More...
 
 delete ($collection_id)
 Deletes a collection and its membership information. More...
 
 rowToElggAccessCollection (\stdClass $row)
 Transforms a database row to an instance of ElggAccessCollection. More...
 
 get ($collection_id)
 Get a specified access collection. More...
 
 hasUser ($user_guid, $collection_id)
 Check if user is already in the 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 ($options=[])
 Returns access collections. More...
 
 getMembers ($collection_id, array $options=[])
 Get members of an access collection. More...
 
 getCollectionsByMember ($member_guid)
 Return an array of collections that the entity is 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
 ElggCache More...
 
 $hooks
 
 $session
 
 $entities
 
 $capabilities
 
 $translator
 
 $table
 
 $membership_table
 
 $init_complete = false
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

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

Member Function Documentation

Elgg\Database\AccessCollections::addUser (   $user_guid,
  $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 671 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.

See also
get_write_access_array() for details on the hook.

Respects access control disabling for admin users and elgg_set_ignore_access()

See also
get_write_access_array()
Parameters
int$collection_idThe collection id
mixed$user_guidThe user GUID to check for. Defaults to logged in user.
Returns
bool

Definition at line 386 of file AccessCollections.php.

Elgg\Database\AccessCollections::create (   $name,
  $owner_guid = 0,
  $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 424 of file AccessCollections.php.

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

Deletes a collection and its membership information.

Parameters
int$collection_idID of the collection
Returns
bool

Definition at line 573 of file AccessCollections.php.

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

Get a specified access collection.

Note
This doesn't return the members of an access collection, just the database row of the actual collection.
See also
get_members_of_access_collection()
Parameters
int$collection_idThe collection ID
Returns
|false

Definition at line 627 of file AccessCollections.php.

Elgg\Database\AccessCollections::getAccessArray (   $user_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.

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

Elgg\Database\AccessCollections::getAccessList (   $user_guid = 0,
  $flush = false 
)

Returns a string of access_ids for $user_guid appropriate for inserting into an SQL IN clause.

See also
get_access_array()
Parameters
int$user_guidUser ID; defaults to currently logged in user
bool$flushIf set to true, will refresh the access list from the database rather than using this function's cache.
Returns
string A concatenated string of access collections suitable for using in an SQL IN clause

Definition at line 136 of file AccessCollections.php.

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

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

Parameters
int$member_guidGUID of th member
Returns
[]|false

Definition at line 801 of file AccessCollections.php.

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

Returns access collections.

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

Definition at line 752 of file AccessCollections.php.

Elgg\Database\AccessCollections::getMembers (   $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 785 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

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

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

Elgg\Database\AccessCollections::hasAccessToEntity (   $entity,
  $user = null 
)

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.
ElggUser$userOptionally user to check access for. Defaults to logged in user (which is a useless default).
Returns
bool

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

Elgg\Database\AccessCollections::markInitComplete ( )

Mark the access system as initialized.

Returns
void

Definition at line 121 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.

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

Definition at line 720 of file AccessCollections.php.

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

Renames an access collection.

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

Definition at line 484 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 612 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 519 of file AccessCollections.php.

Member Data Documentation

Elgg\Database\AccessCollections::$access_cache
protected

ElggCache

Definition at line 40 of file AccessCollections.php.

Elgg\Database\AccessCollections::$capabilities
protected

Definition at line 60 of file AccessCollections.php.

Elgg\Database\AccessCollections::$config
protected

Definition at line 30 of file AccessCollections.php.

Elgg\Database\AccessCollections::$db
protected

Definition at line 35 of file AccessCollections.php.

Elgg\Database\AccessCollections::$entities
protected

Definition at line 55 of file AccessCollections.php.

Elgg\Database\AccessCollections::$hooks
protected

Definition at line 45 of file AccessCollections.php.

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

Definition at line 80 of file AccessCollections.php.

Elgg\Database\AccessCollections::$membership_table
protected

Definition at line 75 of file AccessCollections.php.

Elgg\Database\AccessCollections::$session
protected

Definition at line 50 of file AccessCollections.php.

Elgg\Database\AccessCollections::$table
protected

Definition at line 70 of file AccessCollections.php.

Elgg\Database\AccessCollections::$translator
protected

Definition at line 65 of file AccessCollections.php.


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