Elgg
Version 4.3
|
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 | |
Access collections database service.
Definition at line 21 of file AccessCollections.php.
Elgg\Database\AccessCollections::__construct | ( | Config | $config, |
Database | $db, | ||
EntityTable | $entities, | ||
UserCapabilities | $capabilities, | ||
\ElggCache | $cache, | ||
PluginHooksService | $hooks, | ||
\ElggSession | $session, | ||
Translator | $translator | ||
) |
Constructor.
Config | $config | Config |
Database | $db | Database |
EntityTable | $entities | Entity table |
UserCapabilities | $capabilities | User capabilities |
\ElggCache | $cache | Access cache |
PluginHooksService | $hooks | Hooks |
\ElggSession | $session | Session |
Translator | $translator | Translator |
Definition at line 92 of file AccessCollections.php.
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.
int | $user_guid | GUID of the user to add |
int | $collection_id | ID of the collection to add them to |
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.
Respects access control disabling for admin users and elgg_call()
int | $collection_id | The collection id |
int | $user_guid | The user GUID to check for. Defaults to logged in user. |
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.
int | $collection_id | ID of the collection |
Definition at line 560 of file AccessCollections.php.
Elgg\Database\AccessCollections::get | ( | int | $collection_id | ) |
Get a specified access collection.
int | $collection_id | The collection ID |
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.
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.
int | $member_guid | GUID of th member |
Definition at line 771 of file AccessCollections.php.
|
protected |
Returns an array of access collections to be used in the write access array.
int | $owner_guid | owner of the collections |
Definition at line 338 of file AccessCollections.php.
Elgg\Database\AccessCollections::getEntityCollections | ( | array | $options = [] | ) |
Returns access collections.
array | $options | Options to get access collections by Supported are 'owner_guid', 'subtype' |
Definition at line 720 of file AccessCollections.php.
Elgg\Database\AccessCollections::getMembers | ( | int | $collection_id, |
array | $options = [] |
||
) |
Get members of an access collection.
int | $collection_id | The collection's ID |
array | $options | Ege* options |
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
int | $entity_access_id | The entity's access id |
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'
int | $user_guid | The user's GUID. |
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 276 of file AccessCollections.php.
Elgg\Database\AccessCollections::hasAccessToEntity | ( | \ElggEntity | $entity, |
int | $user_guid = 0 |
||
) |
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 |
int | $user_guid | Optionally user_guid to check access for. Defaults to logged in user |
Definition at line 219 of file AccessCollections.php.
Elgg\Database\AccessCollections::hasUser | ( | $user_guid, | |
$collection_id | |||
) |
Check if user is already in the collection.
int | $user_guid | GUID of the user |
int | $collection_id | ID of the collection |
Definition at line 618 of file AccessCollections.php.
Elgg\Database\AccessCollections::markInitComplete | ( | ) |
Mark the access system as initialized.
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.
int | $user_guid | GUID of the user |
int | $collection_id | ID of the collection |
Definition at line 692 of file AccessCollections.php.
Elgg\Database\AccessCollections::rename | ( | int | $collection_id, |
string | $name | ||
) |
Renames an access collection.
int | $collection_id | ID of the collection |
string | $name | The name of the collection |
Definition at line 477 of file AccessCollections.php.
Elgg\Database\AccessCollections::rowToElggAccessCollection | ( | \stdClass | $row | ) |
Transforms a database row to an instance of ElggAccessCollection.
\stdClass | $row | Database row |
Definition at line 592 of file AccessCollections.php.
Elgg\Database\AccessCollections::update | ( | $collection_id, | |
array | $new_members = [] |
||
) |
Updates the membership in an access collection.
int | $collection_id | ID of the collection. |
array | $new_members | Array of member entities or GUIDs |
Definition at line 505 of file AccessCollections.php.
|
protected |
Definition at line 48 of file AccessCollections.php.
|
protected |
Definition at line 68 of file AccessCollections.php.
|
protected |
Definition at line 38 of file AccessCollections.php.
|
protected |
Definition at line 43 of file AccessCollections.php.
|
protected |
Definition at line 63 of file AccessCollections.php.
|
protected |
Definition at line 53 of file AccessCollections.php.
|
protected |
Definition at line 78 of file AccessCollections.php.
|
protected |
Definition at line 58 of file AccessCollections.php.
|
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.