hook_node_grants
developer/hooks/core.php, строка 1174
- Версии
- 5 – 6
hook_node_grants($account, $op)
Информирует систему управления доступом к нодам о правах, которые пользователь имеет.
Этот хук нужен модулям для указания прав доступа к материалам. В дополнение к управлению доступом к материалам модуль должен сообщить системе доступа "grant IDs" (gid) текущего пользователя. Во многих случаях "grant IDs" равнозначны идентификаторам ролей (rid), но могут быть и чем-то ещё в зависимости от модуля.
For example, modules can maintain their own lists of users, where each list has an ID. In that case, the module could return a list of all IDs of all lists that the current user is a member of.
A node access module may implement as many realms as necessary to properly define the access privileges for the nodes.
For a detailed example, see node_access_example.module.
Параметры
$account
Объект пользователя, чьи права были запрошены.
$op
Операция над нодой, которая будет совершена, например 'view', 'update' или 'delete'.
Возвращаемое значение
An array whose keys are 'realms' of grants such as 'user' or 'role', and
whose values are linear lists of grant IDs.
Связанные темы
Код
<?php
function hook_node_grants($account, $op) {
if (user_access('access private content', $account)) {
$grants['example'] = array(1);
}
$grants['example_owner'] = array($user->uid);
return $grants;
}
?>Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии 