Drupal API

hook_node_grants

  • Drupal 5
  • Drupal 6
Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

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.

Связанные темы

▸ 6 функции вызывают hook_node_grants()

▾ 6 функции вызывают hook_node_grants()

block_list in modules/block/block.module
Возвращает все блоки в заданном регионе для текущего пользователя.
module_disable in includes/module.inc
Отключает заданный набор модулей.
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...
system_performance_settings in modules/system/system.admin.inc
Form builder; Configure site performance settings. See alsosystem_settings_form()

Код

<?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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему

Что такое OpenID?
  • Регистрация
  • Забыли пароль?

Документация

  • Drupal 6
  • Константы
  • Файлы
  • Функции
  • Глобальные переменные
  • Разделы