国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

[Drupal教程] Drupal的组成部分 7.节点存取系统

[复制链接]
发表于 11-29-2011 07:36 | 显示全部楼层 |阅读模式

The node access system determines who can do what to which nodes.

In determining access rights for a node, node_access() first checks whether the user has the "administer nodes" permission. Such users have unrestricted access to all nodes. Then the node module's hook_access() is called, and a TRUE or FALSE return value will grant or deny access. This allows, for example, the blog module to always grant access to the blog author, and for the book module to always deny editing access to PHP pages.

If node module does not intervene (returns NULL), then the node_access table is used to determine access. All node access modules are queried using hook_node_grants() to assemble a list of "grant IDs" for the user. This list is compared against the table. If any row contains the node ID in question (or 0, which stands for "all nodes"), one of the grant IDs returned, and a value of TRUE for the operation in question, then access is granted. Note that this table is a list of grants; any matching row is sufficient to grant access to the node.

In node listings, the process above is followed except that hook_access() is not called on each node for performance reasons and for proper functioning of the pager system. When adding a node listing to your module, be sure to use db_rewrite_sql() to add the appropriate clauses to your query for access checks.

To see how to write a node access module of your own, seenode_access_example.module.

函数

名称sort icon位置描述
hook_accessmodules/node/node.api.phpDefine access restrictions.
hook_node_access_recordsmodules/node/node.api.phpSet permissions for a node to be written to the database.
hook_node_grantsmodules/node/node.api.phpInform the node access system what permissions the user has.
node_accessmodules/node/node.moduleDetermine whether the current user may perform the given operation on the specified node.
node_access_acquire_grantsmodules/node/node.moduleThis function will call module invoke to get a list of grants and then write them to the database. It is called at node save, and should be called by modules whenever something other than a node_save causes the permissions on a node to change.
node_access_grantsmodules/node/node.moduleFetch an array of permission IDs granted to the given user ID.
node_access_needs_rebuildmodules/node/node.moduleFlag / unflag the node access grants for rebuilding, or read the current value of the flag.
node_access_rebuildmodules/node/node.moduleRebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
node_access_view_all_nodesmodules/node/node.moduleDetermine whether the user has a global viewing grant for all nodes.
node_access_write_grantsmodules/node/node.moduleThis 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_db_rewrite_sqlmodules/node/node.moduleImplementation ofhook_db_rewrite_sql().
node_query_node_access_altermodules/node/node.moduleImplementation ofhook_query_TAG_alter().
_node_access_join_sqlmodules/node/node.moduleGenerate an SQL join clause for use in fetching a node listing.
_node_access_rebuild_batch_finishedmodules/node/node.modulePost-processing for node_access_rebuild_batch.
_node_access_rebuild_batch_operationmodules/node/node.moduleBatch operation for node_access_rebuild_batch.
_node_access_where_sqlmodules/node/node.moduleGenerate an SQL where clause for use in fetching a node listing.

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 5-2-2025 12:39 , Processed in 0.388727 second(s), 103 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表