developer/hooks/core.php, строка 811
- 5 – 6
hook_node_grants($account, $op)
Inform the node access system what permissions the user has.
This hook is for implementation by node access modules. In addition to
managing access rights for nodes, the node access module must tell
the node access system what 'grant IDs'
the current user has. In many
cases, the grant IDs will simply be role IDs, but grant IDs can be
arbitrary based upon the module.
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.
Параметры
$user
The user object whose grants are requested.
$op
The node operation to be performed, such as 'view'
, 'update'
, or 'delete'
.
Возвращаемое значение
An array whose keys are 'realms'
of grants such as 'user'
or 'role'
, and
whose values are linear lists of grant IDs.
Inform the node access system what permissions the user has.
This hook is for implementation by node access modules. In addition to
managing access rights for nodes, the node access module must tell
the node access system what 'grant IDs' the current user has. In many
cases, the grant IDs will simply be role IDs, but grant IDs can be
arbitrary based upon the module.
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.
Parameters
$user
The user object whose grants are requested.
$op
The node operation to be performed, such as "view", "update", or "delete".
Return value
An array whose keys are "realms" of grants such as "user" or "role", and
whose values are linear lists of grant IDs.
Связанные темы
- Система доступа к нодам
- Система доступа к нодам определяет кто и что может сделать с определёнными нодами.
- Хуки
- Позволяет модулям взаимодействовать с ядром Drupal.
- node_access_grants in modules/node/node.module
- Fetch an array of permission IDs granted to the given user ID.
- node_access_rebuild in modules/node/node.module
- Rebuild the node access database. This is occasionally needed by modules
that make system-wide changes to access levels.
- node_access_write_grants in modules/node/node.module
- This function will write a list of grants to the database, deleting
any pre-existing grants. If a realm is provided, it will only
delete grants from that realm, but it will always delete a grant
from the 'all' realm. Modules which utilize...
- node_configure in modules/node/node.module
- Menu callback; presents general node configuration options.
Код
<?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;
}
?>
Войдите или
зарегистрируйтесь, чтобы получить возможность отправлять комментарии