I am using workflow_access features to manage permissions on workflow states. I give delete permissions on one of my states to the author of the content.
My problem is that I only see the delete button when the node I would like to delete is published.
I checked Drupal behaviour on such case and saw that node_access('delete', $my_node) returns false. I guess it is due to the following test:
if ($op != 'create' && $node->nid && $node->status) { at line 2040 of node.module.
I do not understand why status is checked there but the result is that the call to node_access returns false in this case.
I am wondering if workflow_access module should alter the node form to add delete button when needed.
NB: I work on Drupal 6.16 on a LAMP platform. I also use revisioning, module_grants and node_tools.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | node_tools-missing-delete-button.patch | 944 bytes | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedCore Node module's node_form function is calling node_access('delete', $node) directly to determine whether to display delete button. node_access returns FALSE for a couple of reasons:
1. node_access first calls node_content_access which returns NULL because with Workflow we are intentionally not permitting user_access 'delete any ...' or 'delete own ...' permissions (allowing these permissions would override Workflow access permissions which would mess up the user role access at different stages in a node's workflow).
2. node_access will not check access grants for nodes where status = 0 i.e. unpublished nodes.
node_access ideally should be replaced by module_grants_node_access function which acts precisely to combat issue number 2 above. However, since it is called directly the only way to do this I'm guessing would be to hack core. In addition, node_form does not make use of '#access' variable for the delete button, rather the entire delete button array is excluded if node_access returns false.
So the solution I used was to basically re-add the delete button if module_grants_node_access returns true for the node delete operation, for the current user:
I originally added this to module_grants form alter, because I needed it to happen before module_grants made its adjustments to the delete button text (and I didn't want to create a new module just for one form_alter). In module_grants 6.x-3.5 form_alter has been moved to node_tools module.
Since it is the workflow module that dictates that we are not using the 'delete own' or 'delete any' permissions then perhaps it would make sense to add it to workflow module. However, presumably any access modules that provide alternative 'delete' access/grants are going to run into this "missing delete button" problem, so I'm thinking it is still a good candidate for module_grants/node_tools form_alter instead.
Patch that I'm using for node_tools 6.x-3.5 attached, apply to module_grants folder.
Comment #2
Anonymous (not verified) commentedSee also, http://drupal.org/node/592164 where alternative solution is provided, i.e. to hack core and add module_grants_node_access function call to core node_access function.
Comment #3
Bastlynn commentedSince this request is over a year old, I'm going to assume a solution was found or you've moved on. If not, please get updated to the latest versions of all modules and make a request for it against Drupal 7 and I'll be glad to take a look at it.