16、Drupal开发:节点访问与主题系统搭建指南

Drupal开发:节点访问与主题系统搭建指南

1. 节点访问记录函数实现

在Drupal开发中,有一个用于实现 hook_node_access_records() 的函数 forum_access_node_access_records ,它的作用是返回传入节点对象的授权记录列表。以下是该函数的代码:

/**
* Implementation of hook_node_access_records().
*
* Returns a list of grant records for the passed in node object.
*/
function forum_access_node_access_records($node) {
...
if ($node->type == 'forum') {
$result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $node->tid);
while ($grant = db_fetch_object($result)) {
$grants[] = array(
'realm' => 'forum_access',
'gid' => $grant->rid,
'grant_view'   => $grant->grant_view, 
'grant_update' => $grant->grant_update, 
'grant_delete' => $grant->grant_delete
)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值