The way ipaper_access function was implemented, it does not play well with other node access modules. I particularly had a problem making the module work with workflow due to conflicts between the ipaper_access function and workflow_access.
I fixed it substituting the module's original ipaper_access function with the one described bellow:
/**
* Implementation of hook_access().
*/
function ipaper_access($op, $node) {
global $user;
if ($op == 'create') {
// Only users with permission to do so may create this node type.
return user_access('create ipaper');
}
// Users who create a node may edit or delete it later, assuming they have the
// necessary permissions.
if ($op == 'update') {
if ( user_access('edit own ipapers') && ($user->uid == $node->uid)) {
return true;
}
else if (user_access('edit ipapers')) {
return true;
}
}
if ($op == 'delete') {
if ( user_access('delete own ipapers') && ($user->uid == $node->uid)) {
return true;
}
else if (user_access('delete ipapers')) {
return true;
}
}
if ($op == 'view') {
if (user_access('view ipapers')) {
return true;
}
}
}
Before I had to give users at least "edit own ipapers" and "view ipapers" permissions and could not restrict view or edit access acording to workflow states. With the change described above I made iPaper behave correctly with workflow_access. Now I can give users only "create ipaper" permission and control further access through workflow_access.
I believe similar conflicts exists between ipaper and other content access modules and that the above implementation should make ipaper behave better with such modules.
Comments
Comment #1
rares commentedFrom what I can see the changes have to do with using
if (user_access () ) return TRUE;rather thanreturn user_access();. Why do you think the result is different if you use this syntax?I would imagine that your problem using ipaper and workflow comes from the module weights. http://drupal.org/node/110238. the ipaper module has weight 1 while workflow has 0 (from what I can tell), which means ipaper_access() is run after workflow_access(). A module like workflow should probably have a higher weight, since it plans to override the hooks of core and contributed modules. ipaper has weight 1 because ipaper_nodeapi must run after upload_nodeapi (#273144: Quickswitch functionality - comment 10).
Comment #2
rarps commentedI am not a developer, so forgive me if I say something dumb here.
I based the ipaper_access function I used in the "_access" functions of other modules I tried that worked correctly with workflow_access. If I remember correctly Biblio module was my main example. In fact I looked at a couple of other modules and found out that the "style" of their respective "_access" functions where closer to the one I proposed.
The way I did allowed me to use iPaper with workflow_access with no problems. No changes to module weights where necessary.
One basic difference I noted was that in the way I implemented the function it does not return false in any situation allowing other modules to further restrict access to edit or delete operations (depending, for example, of workflow state).
Anyway, I want to thank you for the great module you developed. It solved a big issue regarding scientific article submission for a Biology related Portal I am implementing in Brazil.
I also take the opportunity to mention that the iPaper module worked correctly with the upload_path module, allowing custom directory configuration and unique filenames for the documents submitted for reviewal and publication. That required no changes to the iPaper module, just regular use of upload_path module.
It would be great if iPaper worked with the filefield or the asset modules, but with upload_path it was enough for our needs.
Comment #3
rares commentedI think the issue with the workflow module might be that the weight of that module is not higher that that of ipaper. you can fix this by changing the weight column for workflow_access in the system table by something higher than 3.