How to control node/content access in drupal 6.X?
I had a site created in drupal 6. All its contents are placed as Page Nodes. I created a user with editor role and given following permis开发者_开发技巧sions
access content administer content types adminsiter node edit any page content edit own page content
I want this user to only edit the content pages already created by another user do not want to remove/delete content/node from the site.
How can I do this. I tried
nodeaccess-6.x-1.3.zip node_privacy_byrole-6.x-1.6.zip
also tried content_access-6.x-1.2.zip(but not find any settings for this module ?). Please help me to solve this issue.
thanks in advance.
Step1.
ok i don't know if there is a modules that support adding permissions on node delete or not but try the following.....
first we need to create a module (don't worry ist easy) that generate a new permission which you can give to any users role lets call this permission "node delete permission"
1- go to /sites/all/modules
2- create a new folder with name "node_delete_permission" and create files inside this folder with the following names "node_delete_permission.info" && "node_delete_permission.module"
3- open node_delete_permission.info and add the following inside it :
name = node delete permission description = node delete permission core = 6.x
4- now open node_delete_permission.module and add the following code inside it
<?php /** * Implementation of hook_perm() */ function node_delete_permission_perm() { return array("node delete permission") ; } /** * Implementation of hook_form_alter */ function node_delete_permission_form_alter($form, $form_state, $form_id) { if($form_id == 'node_admin_content') { if (!user_access('node delete permission')) { unset($form['admin']['options']['operation']['#options']['delete']); } } }
5- now enable your new module from (admin/build/modules) and go to (/admin/user/permissions) .. make sure that you have a new permission generated called "node delete permission"
if its ok...lets go to the next step
6- go to you theme "page.tpl.php" and add the following code at the top of the this file
<?php $arg1 = arg(1) ; $node_path = url( 'node/'.$arg1 , array('absolute' => TRUE)) ; if(arg(0) == 'node' && arg(2) == 'delete' && !user_access('node delete permission')){ drupal_set_message('<div class="message error" > You don\'t have the permission to delete node </div>') ; header("Location: {$node_path}") ; } ?>
now you can give this permission to any user role you want from (/admin/user/permissions)
NOTE:
1- its not 100% the drupal way but i think its useful in ur case
2- i didn't test this code so you may found a syntax error or something...you can get back to me if you found this
3- i hav a bad english i know and im sorry for this
Enabling the content permissions module that ships with CCK , should give you control over which field in the Page content type can be viewed , created, edited or deleted
精彩评论