开发者

Drupal 6 administer nodes permission is ignoring content type permissions

I'm needing to set different 'create content' permissions for different user roles. This only appears to work when a particular role has not been given the "administer node" permission. However, without this permission the role does not have permission to control whether or not the node is published (which I require) or to view the content management table (Home › Administer › Content management).

For example, I want a user role to be able to create new news items and to be able to publish/unpublish them, but开发者_如何学Python not create new pages (but be able to edit existing pages).

Does anyone know a way around this? Or which permissions should be set?


Administer Nodes permission gives more access than necessary, and some modules use it as a crutch permission since it exists.

You might want to switch off this permission and implement Override Node Options module which will let users publish unpublish content. These can work in conjunction with the create/edit/delete permissions at the content type level.


See the patch provided here http://drupal.org/node/214190 It looks like Drupal 7 may allow for this separation of permissions between publishing and full-blown administering, but for now you'll have to use the patch.


I didn't want to install another module so I put this code in hook_init() in one of our custom modules. Enforces the node/add page, by giving an access denied if the users do not have the "create * content" permission.

  $arg = arg();
  // Quick hack to enforce node creation permissions.
  if (   $arg[0] == 'node'
      && !empty($arg[1])
      && $arg[1] == 'add'
      && !empty($arg[2])
        ) {
    $arg[2] = str_replace('-', '_', $arg[2]);
    if (!user_access('create ' . $arg[2] . ' content')) {
      drupal_access_denied();
    }
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜