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)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

westbywest’s picture

The 2nd symptom described above was resolved by adding field_access awareness to field_collections_table:
http://drupal.org/node/1284042

RobLoach’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Try update?

adellefrank’s picture

I, 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:

adellefrank’s picture

Status: Postponed (maintainer needs more info) » Needs work

I'm hoping I can move this back into the "needs work" category, since I provided lots more info in comment #3.

DrupalDan’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
Category: feature » bug
Status: Needs work » Active

I 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!

mariacha1’s picture

Title: field_collection integration? » field_collection integration -- add hook for defining entity's owner
Issue summary: View changes
Status: Active » Needs review
FileSize
1.38 KB

It 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:

  // Try to get the uid of the entity owner from the entity itself. If it's not
  // set (for example, if the entity type does not store a uid or does not have
  // a concept of "ownership"), we need to assume that the provided user
  // account does not own it.

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.

Status: Needs review » Needs work

The last submitted patch, 6: field_permissions-add_userid_hook-1284016-6.patch, failed testing.

mariacha1’s picture

Status: Needs work » Needs review
FileSize
1.43 KB
673 bytes

Sorry, broke tests. New attempt (with diff between it and #6).

Renee S’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

I've been using this solution (in combination with Field Collection) for quite awhile now on a few sites. No problems so far.

sdudnik’s picture

Renee S, do you using dev versions of both modules?

ron_s’s picture

@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.

webservant316’s picture

Yeah 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.

  • mariacha1 committed 665ccfd on 7.x-1.x
    Issue #1284016 by mariacha1, adellefrank: field_collection integration...
mariacha1’s picture

Status: Reviewed & tested by the community » Fixed

Now it is I who am the maintainer! Thanks me from the past! And everyone else. :)

mariacha1’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Fixed » Patch (to be ported)

Actually, setting this to Patched (to be ported) so the D8 peeps can review it for relevance.

mariacha1’s picture

Status: Patch (to be ported) » Needs work

Going to see if I can't get this solved in a way that doesn't rely on https://www.drupal.org/node/1954124.

mariacha1’s picture

Assigned: Unassigned » mariacha1

  • mariacha1 committed 7823ec0 on 7.x-1.x
    Issue #1284016 by mariacha1: field_collection integration -- implement...
mariacha1’s picture

Status: Needs work » Patch (to be ported)

Pulled 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.

mariacha1’s picture

Assigned: mariacha1 » Unassigned
pifagor’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jhedstrom’s picture

Status: Closed (fixed) » Patch (to be ported)

This feature may still have merit in 8.x. Moving back to previous status.