Here is what I'm using:
Drupal 7.7
field_collections v7.x-1.x-dev (downloaded last week)
field_permissions v7.x-1.0-alpha1
My symptoms:
- Fields in the collection which are restricted from edit are correctly hidden on a node form to users who don't have those fields' edit permissions
- Fields in the collection which are restricted from view are incorrectly displayed in the rendered node
- Submitting the node edit form, although restricted fields in the collection are not displayed, triggers these undefined index warnings for each restricted field:
Notice: Undefined index: #title in theme_field_collection_table_multiple_value_fields() (line 85 of /blah/blah/blah/sites/all/modules/field_collection_table/theme/theme.inc)
Here are relevant lines I've found in the field_permissions in my own search where this integration may be added:
field_permissions.module
line 115: function field_permissions_field_access($op, $field, $obj_type, $object, $account)
admin/includes/field_access.inc
line 11: function _field_permissions_field_view_access($field_name, $field_permissions, $obj_type, $object, $account)
line 63: function _field_permissions_field_edit_access($field_name, $field_permissions, $obj_type, $object, $account)
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff.txt | 673 bytes | mariacha1 |
#8 | field_permissions-add_userid_hook-1284016-8.patch | 1.43 KB | mariacha1 |
#6 | field_permissions-add_userid_hook-1284016-6.patch | 1.38 KB | mariacha1 |
#3 | permissionsByRole.png | 157 KB | adellefrank |
#3 | authenticated_view_of_mytype.png | 8.95 KB | adellefrank |
Comments
Comment #1
westbywest CreditAttribution: westbywest commentedThe 2nd symptom described above was resolved by adding field_access awareness to field_collections_table:
http://drupal.org/node/1284042
Comment #2
RobLoachTry update?
Comment #3
adellefrank CreditAttribution: adellefrank commentedI, too, have found that permissions for VIEWING OWN/EDITING OWN field is not working when that field is a subfield of a field collection.
To reproduce this problem, give View Own/Edit Own permissions to the authenticated user for a field collection "mycollection" and its subfield "subfield1" in a content type's "mytype". I've attached a feature with the setup I described above for testing. This feature uses:
Comment #4
adellefrank CreditAttribution: adellefrank commentedI'm hoping I can move this back into the "needs work" category, since I provided lots more info in comment #3.
Comment #5
DrupalDan CreditAttribution: DrupalDan commentedI got a similiar problem. I use the module to restrict access to files that users uploaded. I gave the role author the field permissions to create and view own value for such a field of the collection as "Manuscript", but NOT edit own field for that field. But the author can still edit it like removing it or uploading a new one.
Can anyone please tell me how to fix this? Thanks!
Comment #6
mariacha1 CreditAttribution: mariacha1 commentedIt looks like the major issue here is with function _field_permissions_entity_is_owned_by_account(). It's looking for each entity to have a uid property. Here's the code within the function:
However, with field collections, there IS no defined uid per entity.
What do you think of adding a hook to allow other modules to modify the assigned userid?
hook_field_permissions_userid_ENTITY_TYPE_alter(&$uid, $entity)
Adding this hook could be the first step to getting field collections to work with field permissions.
Patch attached.
Comment #8
mariacha1 CreditAttribution: mariacha1 commentedSorry, broke tests. New attempt (with diff between it and #6).
Comment #9
Renee S CreditAttribution: Renee S commentedI've been using this solution (in combination with Field Collection) for quite awhile now on a few sites. No problems so far.
Comment #10
sdudnik CreditAttribution: sdudnik commentedRenee S, do you using dev versions of both modules?
Comment #11
ron_s CreditAttribution: ron_s commented@sdudnik, I've been using the main releases with these patches, and have had no issues. More specifically, the module versions I'm using are Field Permissions 7.x-1.0 and Field Collection 7.x-1.0-beta11.
However, @Renee S is absolutely correct in setting the version to 7.x-1.x-dev. New patches should be applied to the -dev branch, not a release of a module.
Comment #12
webservant316 CreditAttribution: webservant316 commentedYeah just hit this snafu today.
Fortunately, the patches fix it.
#8 above
+
https://www.drupal.org/node/1954124#comment-10626332
Hopefully the field_collections and field_permissions maintainers are on board with the patches.
Comment #14
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedNow it is I who am the maintainer! Thanks me from the past! And everyone else. :)
Comment #15
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedActually, setting this to Patched (to be ported) so the D8 peeps can review it for relevance.
Comment #16
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedGoing to see if I can't get this solved in a way that doesn't rely on https://www.drupal.org/node/1954124.
Comment #17
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedComment #19
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedPulled this patch into the field permissions module instead:
https://www.drupal.org/node/1954124
So this is going back to the d8 branch for evaluation.
Comment #21
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedComment #22
pifagorComment #24
jhedstromThis feature may still have merit in 8.x. Moving back to previous status.