Hi,
First thanks for this module, it's a really cool functionnality !
I just need it to be compatible with the Vocabulary Permissions Per Role (vppr) module :
I assigned some roles to administer some vocabularies ( I don't want to allow them to rule all ), but as they don't have the "administer taxonomy" permission, they can't publish or unpublish terms.
I tried to alter the module to change permissions :
In termstatus_form_taxonomy_form_term_alter() and termstatus_form_taxonomy_form_vocabulary_alter(), I replaced user_access('administer taxonomy') by the vppr permissions user_access('administer '.$vocabulary->machine_name.' vocabulary terms').
It works for manual edit : I mean that if I edit the taxonomy term, I can see the status checkbox, check it, and the new status is saved.
But my problem is that in my view, the VBO actions "publish" ans "unpublish" don't care about these new permissions : It only uses "administer taxonomy" permission.
I've seen that there's an access permission defined in termstatus_entity_property_info_alter(&$entity_info) function, but if it's the right value to change to make VBO work as designed, I will need to replace 'access permission' => 'administer taxonomy', by several access permissions, as my users can administer several vocabularies ; or by the current vocabulary at least, depending on when the funciton is loaded, and what is passed through the $entity_info argument. But I don't how it works at all, and I can't print $entity_info anywhere. It never shows up. Maybe because VBO it using ajax ?
So, I'm stuck here.
Thanks for your help.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | custom.module.txt | 2.1 KB | seren10pity13 |
Comments
Comment #1
znerol commentedOk, thanks for the report. Concerning the VBO stuff, I think this is an issue with the entity module. Let me explain:
First, our implementation of
hook_entity_property_info_alterseems to be wrong. As per the hook_entity_property_info documentation only the keys access callback and setter permission are used to determine if a user has edit-access to a taxonomy term or taxonomy vocabulary. In my implementation there is access permission which I suppose will simply be ignored by entity API / VBO. Because the implementation for taxonomy terms shipping with the entity API does not have any access-keys, I'm pretty sure that term status does not need to enforce access-checks to the status-property neither.Second, the entity API adds access-checks for core entities in _entity_info_add_metadata which is called from its implementation of the core hook hook_entity_info_alter. The access callback for taxonomy terms is forced to entity_metadata_taxonomy_access. In a little experiment I was able to make vppr work together with VBO by injecting the following additional access-check:
So probably you want to check with the maintainers of vppr or entity API on how this check could be injected without having to patch entity API.
HTH
Comment #2
seren10pity13 commentedThanks for your quick answer, the code you proposed worked like a charm !
To avoid patching Entity.module, I tried to use a Custom module with a hook_entity_info_alter(), to replace Entity's access callback function for taxonomies by another one :
I think that it should work, but according to my tests, it seems that my
custom_entity_info_alter()function is executing beforeentity_entity_info_alter(), even if my custom module has a weight of 4 in the system table, when entity's weight is 0...Stuck again.
I'm gonna move this issue to vppr issue queue because, as it set new access permissions for taxonomies, I think it's up to them to make it compatible with Entity and VBO that are widely used.
Thank you very much for your investigations on this. It helped me a lot.
Seren10pity
Comment #3
znerol commentedEntity API alters the execution order of
hook_entity_info_alterby implementing hook_module_implements_alter. Therefore you need to do the same and ensure that your alter-hook runs after the one of Entity API...Comment #4
seren10pity13 commentedYes ! You led me in the right direction, and I managed to make it work. I removed the modifications in Entity, and used only the custom module, with the hooks you suggested to me.
Thank you very much.
Comment #5
seren10pity13 commented