PHP Класс Elgg\Database\AccessCollections

С версии: 1.10.0
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$access_cache
$config Elgg\Config
$db Elgg\Database
$entities EntityTable
$hooks Elgg\PluginHooksService
$session ElggSessio\ElggSession
$translator Elgg\I18n\Translator

Открытые методы

Метод Описание
__construct ( Config $config, Database $db, EntityTable $entities, ElggStaticVariableCach\ElggStaticVariableCache $cache, PluginHooksService $hooks, ElggSessio\ElggSession $session, Translator $translator ) Constructor
addUser ( integer $user_guid, integer $collection_id ) : boolean Adds a user to an access collection.
canEdit ( integer $collection_id, mixed $user_guid = null ) : boolean Can the user change this access collection?
create ( string $name, integer $owner_guid ) : integer | false Creates a new access collection.
delete ( integer $collection_id ) : boolean Deletes a specified access collection and its membership.
get ( integer $collection_id ) : object | false Get a specified access collection
getAccessArray ( integer $user_guid, boolean $flush = false ) : array Returns an array of access IDs a user is permitted to see.
getAccessList ( integer $user_guid, boolean $flush = false ) : string Return a string of access_ids for $user_guid appropriate for inserting into an SQL IN clause.
getCollectionsByMember ( integer $member_guid ) : array | false Return an array of database row objects of the access collections $entity_guid is a member of.
getEntityCollections ( integer $owner_guid ) : array | false Returns an array of database row objects of the access collections owned by $owner_guid.
getMembers ( integer $collection_id, boolean $guids_only = false ) : ElggUse\ElggUser[] | int[] | false Get all of members of an access collection
getReadableAccessLevel ( integer $entity_access_id ) : string 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.
getWhereSql ( array $options = [] ) : string Returns the SQL where clause for enforcing read access to data.
getWriteAccessArray ( integer $user_guid, boolean $flush = false, array $input_params = [] ) : array Returns an array of access permissions that the user is allowed to save content with.
hasAccessToEntity ( ElggEntit\ElggEntity $entity, ElggUse\ElggUser $user = null ) : boolean Can a user access an entity.
removeUser ( integer $user_guid, integer $collection_id ) : boolean Removes a user from an access collection.
update ( integer $collection_id, array $members ) : boolean Updates the membership in an access collection.

Описание методов

__construct() публичный Метод

Constructor
public __construct ( Config $config, Database $db, EntityTable $entities, ElggStaticVariableCach\ElggStaticVariableCache $cache, PluginHooksService $hooks, ElggSessio\ElggSession $session, Translator $translator )
$config Elgg\Config Config
$db Elgg\Database Database
$entities EntityTable Entity table
$cache ElggStaticVariableCach\ElggStaticVariableCache Access cache
$hooks Elgg\PluginHooksService Hooks
$session ElggSessio\ElggSession Session
$translator Elgg\I18n\Translator Translator

addUser() публичный Метод

Triggers the 'access:collections:add_user', 'collection' plugin hook.
public addUser ( integer $user_guid, integer $collection_id ) : boolean
$user_guid integer The GUID of the user to add
$collection_id integer The ID of the collection to add them to
Результат boolean

canEdit() публичный Метод

Use the plugin hook of 'access:collections:write', 'user' to change this.
См. также: get_write_access_array() for details on the hook. Respects access control disabling for admin users and {@link elgg_set_ignore_access()}
См. также: get_write_access_array()
public canEdit ( integer $collection_id, mixed $user_guid = null ) : boolean
$collection_id integer The collection id
$user_guid mixed The user GUID to check for. Defaults to logged in user.
Результат boolean

create() публичный Метод

Access colletions allow plugins and users to create granular access for entities. Triggers plugin hook 'access:collections:addcollection', 'collection'
public create ( string $name, integer $owner_guid ) : integer | false
$name string The name of the collection.
$owner_guid integer The GUID of the owner (default: currently logged in user).
Результат integer | false The collection ID if successful and false on failure.

delete() публичный Метод

Deletes a specified access collection and its membership.
public delete ( integer $collection_id ) : boolean
$collection_id integer The collection ID
Результат boolean

get() публичный Метод

Get a specified access collection
См. также: get_members_of_access_collection()
public get ( integer $collection_id ) : object | false
$collection_id integer The collection ID
Результат object | false

getAccessArray() публичный Метод

Can be overridden with the 'access:collections:read', 'user' plugin hook.
См. также: get_write_access_array() for the access levels that a user can write to.
public getAccessArray ( integer $user_guid, boolean $flush = false ) : array
$user_guid integer User ID; defaults to currently logged in user
$flush boolean If set to true, will refresh the access ids from the database rather than using this function's cache.
Результат array An array of access collections ids

getAccessList() публичный Метод

Return a string of access_ids for $user_guid appropriate for inserting into an SQL IN clause.
См. также: get_access_array()
public getAccessList ( integer $user_guid, boolean $flush = false ) : string
$user_guid integer User ID; defaults to currently logged in user
$flush boolean If set to true, will refresh the access list from the database rather than using this function's cache.
Результат string A list of access collections suitable for using in an SQL call

getCollectionsByMember() публичный Метод

Return an array of database row objects of the access collections $entity_guid is a member of.
public getCollectionsByMember ( integer $member_guid ) : array | false
$member_guid integer The entity guid
Результат array | false

getEntityCollections() публичный Метод

Returns an array of database row objects of the access collections owned by $owner_guid.
public getEntityCollections ( integer $owner_guid ) : array | false
$owner_guid integer The entity guid
Результат array | false

getMembers() публичный Метод

Get all of members of an access collection
public getMembers ( integer $collection_id, boolean $guids_only = false ) : ElggUse\ElggUser[] | int[] | false
$collection_id integer The collection's ID
$guids_only boolean If set to true, will only return the members' GUIDs (default: false)
Результат ElggUse\ElggUser[] | int[] | false guids or entities if successful, false if not

getReadableAccessLevel() публичный Метод

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
С версии: 1.11
public getReadableAccessLevel ( integer $entity_access_id ) : string
$entity_access_id integer The entity's access id
Результат string

getWhereSql() публичный Метод

Note that if this code is executed in privileged mode it will return (1=1). Otherwise it returns a where clause to retrieve the data that a user has permission to read. Plugin authors can hook into the 'get_sql', 'access' plugin hook to modify, remove, or add to the where clauses. The plugin hook will pass an array with the current ors and ands to the function in the form: array( 'ors' => array(), 'ands' => array() ) The results will be combined into an SQL where clause in the form: ((or1 OR or2 OR orN) AND (and1 AND and2 AND andN))
public getWhereSql ( array $options = [] ) : string
$options array Array in format: table_alias => STR Optional table alias. This is based on the select and join clauses. Default is 'e'. user_guid => INT Optional GUID for the user that we are retrieving data for. Defaults to the logged in user if null. Passing 0 will build a query for a logged out user (even if there is a logged in user) use_enabled_clause => BOOL Optional. Should we append the enabled clause? The default is set by access_show_hidden_entities(). access_column => STR Optional access column name. Default is 'access_id'. owner_guid_column => STR Optional owner_guid column. Default is 'owner_guid'. guid_column => STR Optional guid_column. Default is 'guid'.
Результат string

getWriteAccessArray() публичный Метод

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'
public getWriteAccessArray ( integer $user_guid, boolean $flush = false, array $input_params = [] ) : array
$user_guid integer The user's GUID.
$flush boolean If this is set to true, this will ignore a cached access array
$input_params array Some parameters passed into an input/access view
Результат array List of access permissions

hasAccessToEntity() публичный Метод

Can a user access an entity.
public hasAccessToEntity ( ElggEntit\ElggEntity $entity, ElggUse\ElggUser $user = null ) : boolean
$entity ElggEntit\ElggEntity The entity to check access for.
$user ElggUse\ElggUser Optionally user to check access for. Defaults to logged in user (which is a useless default).
Результат boolean

removeUser() публичный Метод

Triggers the 'access:collections:remove_user', 'collection' plugin hook.
public removeUser ( integer $user_guid, integer $collection_id ) : boolean
$user_guid integer The user GUID
$collection_id integer The access collection ID
Результат boolean

update() публичный Метод

Updates the membership in an access collection.
public update ( integer $collection_id, array $members ) : boolean
$collection_id integer The ID of the collection.
$members array Array of member GUIDs
Результат boolean

Описание свойств

$access_cache защищенное свойство

protected $access_cache

$config защищенное свойство

protected Config,Elgg $config
Результат Elgg\Config

$db защищенное свойство

protected Database,Elgg $db
Результат Elgg\Database

$entities защищенное свойство

protected EntityTable,Elgg\Database $entities
Результат EntityTable

$hooks защищенное свойство

protected PluginHooksService,Elgg $hooks
Результат Elgg\PluginHooksService

$session защищенное свойство

protected ElggSession,ElggSessio $session
Результат ElggSessio\ElggSession

$translator защищенное свойство

protected Translator,Elgg\I18n $translator
Результат Elgg\I18n\Translator