I'm using TAC to control edit permissions by taxonomy term for a single content type. The issue I'm trying to solve is that currently any content moderator with the Revisioning module permission "Publish revisions of any [content-type] content" is capable of publishing pending revisions of nodes that they do not have edit permissions on (since this is restricted by TAC). I'd like the "Publish" menu tab to be hidden whenever the user does not have edit permission on the node. I'm looking for advice on the best approach for this. Currently, on line 322 of revisioning_theme.inc I notice this menu link is run through the theme function, and I'm considering overriding this somehow in a custom theme function. Is this a good approach?
Comments
Comment #1
shaundychkoRules came to the rescue on this one. The "Publish" link is still shown to moderators who do not have edit permissions on nodes with the particular taxonomy term, but the publish link will redirect to the node view without publishing the revision. The rule tests whether the acting user has edit permission on the node, and it requires that the PHP Filter module is enabled.
Comment #2
rdeboerHi Shaun,
Without delving into it too deep, I believe this might work.
Another approach may also work, if in your use-case you are able to align (groups of) taxonomy terms with content types and roles. Because in 6.x-3.13 publication permissions are optionally per content type, you could have, say, a Sports publisher who can only publish content of type Sport, which potentially terms of, say, Basketball, Football, Swimming, etc...
BTW did you try this tutorial: http://drupal.org/node/408018 ? Did that give you any inspiration?
Rik
Comment #3
shaundychkoThank you Rik for such a quick reply. I'd like to keep the number of content types to a minimum and use taxonomy to segment the moderators by term since this will give greater flexibility down the road. The client, if they wish, can just add another taxonomy term, associate it with a new moderator role, and apply it to a group of nodes. Yes, I tried that tutorial, and it was great. The one limitation however is that it suggests removing view permissions on nodes the moderator doesn't publish. This is not ideal since I'd have some explaining to do when parts of the site disappear for moderators logging in who believe they have "special permissions". The tutorial acknowledges this and suggests using http://drupal.org/project/taxonomy_access (TAC) instead of TACLite. This is what I've done, but the new issue that pops up is that moderators who do not have edit permission on a node (as a result of TAC limiting their edit permission), can nevertheless publish a pending revision since this permission is, as you say, on a content type basis.
Do you think that in most use cases a node publisher will also have edit permission on that node? If so, perhaps a node_access("update", $node, $user) belongs in the module somewhere before enabling the "Publish" revision menu tab?
One reason I went with Rules, by the way, is a limitation on the theme override approach: if a moderator for one taxonomy group (Basketball) really wants to publish a pending revision from a different term (Baseball), they can manually construct the publish URL .../node/[nid]/revisions/[vid]/publish even if the Publish link isn't displayed. Perhaps this could also be taken into account? I know this is getting picky, but this is a node access module afterall...
Thank you so much for the great tutorials you have for this module (and for the module itself!).
Comment #4
rdeboerThanks Shaun for reporting back on all the experimentation you've done. Some great insights and solutions for all to enjoy, so I might refer to this thread from the Revisioning project page.
Quoted from #3:
Do you think that in most use cases a node publisher will also have edit permission on that node? If so, perhaps a node_access("update", $node, $user) belongs in the module somewhere before enabling the "Publish" revision menu tab?
Yes I'd say this is often the case in real-life scenario's. I'd say that those that are allowed to publish a node, e.g. the moderators, are usually allowed to make some minor modifications, before publishing that content. And yes, maybe the code should enforce this. With core's
{node_access}lacking a "grant_publish" column, Revisioning should perhaps tie the publish grant in with "grant_update" (one could indeed argue that a publication is a form of "update").This would then also solve the issue of the moderator maliciously constructing by hand the URL to publish content of a term he does not have access to, right?
Food for thought...
Rik
Comment #5
shaundychkoYep, you understand this perfectly Rik, and I agree with what you're saying. I'd also point out that Revisioning already ties the edit permission together with the publish permission as it relates to the "pending revisions" block. This block will alert the moderator about pending revisions only if they also have edit permissions to the node (which is a relief since I'd have a much harder time solving that one). So, since this logic (ie publishers also must have edit permission) is already part of one aspect of the Revisioning module, is seems reasonable to apply that to the "Publish" menu tab as well.
Comment #6
rdeboerI made it a configurable option on the master branch (i.e 7.x).
Will backport to 6.x branch (i.e 3.14) soon.
Comment #7
shaundychkoHello Rik, I got inspired to learn more about the Drupal API and came up with the following solution for my use case. This module provides a permission on the regular user permissions page to publish content for each term ID. I wanted to make sure publishers also have node edit permission, and segment the publisher permission by taxonomy term instead of by content type.
Known limitations:
1) I didn't want to monkey too much with the revisioning module (thanks for such great commenting in your code, by the way!) so instead of overriding the menu access callback of revisioning's publish link, this module creates it's own publish link. If a user has both permission to publish the content type from the revisioning permission, and permission to publish content with the term ID, they will see two publish links.
2) I used term ID reluctantly since it isn't user friendly. Nevertheless I went this way since tid is guaranteed to be unique.
3) When a term is deleted, I suppose this module should delete all permissions to publish with that ID. I don't think this is a real issue since it's guaranteed that all future terms will have a different tid since the tid autoincrements, but having obsolete publish permissions left over after term deletion isn't very clean.
This module also adds a comment in the revision log stating which username published the node, and when.
The vocabularies that are enabled for providing access to the publish link is set using a checkbox on the vocabulary edit form.
Do you think this module is worth adding to Revisioning, or whether others might find it useful as a separate module? If so, I don't mind cleaning up any loose ends.
Comment #8
shaundychkoComment #9
shaundychkoJust for fun I created a sandbox project here: http://drupal.org/sandbox/ShaunDychko/1260258
Comment #10
rdeboerWell it's all at http://drupal.org/sandbox/ShaunDychko/1260258
Closing this issue.