Hi. I found this module very useful, but I think it miss the support of Flag entity fields. I've tried to make editable fields that are attached to Flag's module entity (bookmark flag) via Views, but no luck - no "Click to edit" button. Is it unsupported or am I missing something?

Comments

dwkitchen’s picture

I've come up against this as well and will have a look at it.

bsarchive’s picture

Issue summary: View changes

@dwkitchen, did you get anywhere with this? Is it a permissions check issue perhaps?

bsarchive’s picture

The problem is that Editablefields looks to see if the user has permission to 'update' the entity to which the field is attached. Flaggings don't seem to have standard access permissions (Flag settings are set indepently and are based on a users' ability to flag/unflag a particular entity, rather being able to create or update the flagging entity itself.)

As a botch, I changed in editablefields.module the following:

  if (!entity_access('update', $entity_type, $entity)|| !field_access('edit', $field, $entity_type, $entity)) {
    // Can't edit.
    return editablefields_fallback_formatter($entity_type, $entity, $field, $instance, $langcode, $items, $display);
  }

to this

  if (!entity_access('update', $entity_type, $entity)|| !field_access('edit', $field, $entity_type, $entity)) {
    // Can't edit.
    if ($entity_type=='flagging'){
    	global $user; 
    	if (!($entity->flag_name=='my_flag_name' && $entity->uid==$user->uid)){
	    	return editablefields_fallback_formatter($entity_type, $entity, $field, $instance, $langcode, $items, $display);
    	}
	} else {
    return editablefields_fallback_formatter($entity_type, $entity, $field, $instance, $langcode, $items, $display);
    }
  }

I tried various combinations of using hook_flag_access and hook_entity_access in a module and invoking flag_flag_access within editablefields but all of these operate on the flag, rather than the flagging whereas the field is attached to the flagging.

I've also posted this issue in the flag queue.

IckZ’s picture

are there any updates for this topic?

OFF’s picture

Shank you, bsarchive!

#3 is working for me!

theshanergy’s picture

To accomplish this without hacking editablefields, you can add the following to a custom module:

/**
 * Implements hook_entity_info_alter().
 */
function custom_entity_info_alter(&$entity_info) {
  // Define custom flagging callback.
  $entity_info['flagging']['access callback'] = 'custom_entity_flagging_access';
}

/**
 * Custom flagging access callback.
 */
function custom_entity_flagging_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  // Load flag.
  $flag = flag_get_flag($entity->flag_name);
  // Check access.
  if ($flag->access($entity->entity_id, 'flag')) {
    return TRUE;
  }

  return FALSE;
}

Note that the access check is fairly broad - you may want to customize it to suit your needs.