node_access_example_node_access_records
developer/examples/node_access_example.module, строка 72
- Версии
- 5 – 6
node_access_example_node_access_records($node)
Реализация hook_node_access_records()
.
Все модули доступа к нодам должны реализовать этот хук. Если модуль хочет ограничить доступ к нодам, то он должен вернуть список значений доступа для каждого идентификатора разрешения. Поскольку этот пример модуля предлагает только один идентификатор разрешения, мы должны вернуть только одну запись.
Код
<?php
function node_access_example_node_access_records($node) {
// We only care about the node if it's been marked private. If not, it is
// treated just like any other node and we completely ignore it.
if ($node->private) {
$grants = array();
$grants[] = array(
'realm' => 'example',
'gid' => TRUE,
'grant_view' => TRUE,
'grant_update' => FALSE,
'grant_delete' => FALSE,
'priority' => 0,
);
// For the example_author array, the GID is equivalent to a UID, which
// means there are many many groups of just 1 user.
$grants[] = array(
'realm' => 'example_author',
'gid' => $node->uid,
'grant_view' => TRUE,
'grant_update' => TRUE,
'grant_delete' => TRUE,
'priority' => 0,
);
return $grants;
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии