继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

Drupal 权限设置,hook_perm()定义权限变量,hook_access控制权限的应用。

其实drupal的权限设置,是很巧妙的。而且drupal权限设置,在写特定的模块的时候。可以很方便控制自己写的模块权限, 主要适用hook_prem 访问权限位,来定义变量。 然后在后台就可以看到了,按照/admin/user/permissions 这个路径来查看。 现在如果设置权限,没有效果,还必须用hook_access,来设定。 uid == $node->uid; switch ($op) { case 'create': return user_access('create product', $account); case 'update': return user_access('edit own product', $account) && $is_author || user_access('edit any product', $account); case 'delete': return user_access('delete own product', $account) && $is_author || user_access('delete any product', $account); case 'view': Return user_access('view product',$account); break; } } ?> 这里只要对node 操作查看,修改,删除,创建权限来设定。按照我理解,如果对其他内容设置权限,比起区块,可以用user_access来控制判断

评论

Drupal 权限设置

Drupal 权限设置

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.