有效的访问参数 [英] Valid access arguments

查看:156
本文介绍了有效的访问参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看有效的访问参数?我看着menu_router,但我相信只给了一些。

How can I look up the valid access arguments? I looked in menu_router, but I believe that only gives some of them.

$items['admin/page'] = array(
   'access arguments' => array('access administration pages'),
  );


推荐答案

其实,你对访问的价值感兴趣访问回调是user_access(默认值)的参数;因为模块可以使用不同的访问回调,访问参数的值在理论上可以是无限的。

Actually, you are interested to the values of the access arguments where the access callback is "user_access" (the default value); as a module can use a different access callback, the values for the access arguments can theoretically be infinite.

调用的所有实现的替代方法hook_permission()是使用与以下代码相似的代码:

The alternative to invoking all the implementations of hook_permission() is to use code similar to the following one:

$permissions = array();
db_query("SELECT permission FROM {role_permission}");

foreach ($result as $row) {
  $permissions[$row->permission] = TRUE;
}

array_keys($ permissions)然后会给你所有权限的列表。

array_keys($permissions) will then give you the list of all the permissions.

我从 user_role_permissions();不同之处在于该函数对与作为参数传递的角色相关联的权限感兴趣。

I took the query from user_role_permissions(); the difference is that the function is interested in the permissions associated to the role passed as argument.

这篇关于有效的访问参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆