diff --git a/plugins/access/entity_field_value.inc b/plugins/access/entity_field_value.inc index 1fb1fe8..7ccbd81 100644 --- a/plugins/access/entity_field_value.inc +++ b/plugins/access/entity_field_value.inc @@ -137,6 +137,11 @@ function ctools_entity_field_value_ctools_access_settings_submit($form, &$form_s * Check for access. */ function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin) { + // Ensure that we actually have context to check. + if (empty($context->data)) { + return FALSE; + } + list($parent, $entity_type, $bundle_type, $field_name) = explode(':', $plugin['name']); if ($field_items = field_get_items($entity_type, $context->data, $field_name)) { @@ -177,49 +182,29 @@ function _ctools_entity_field_value_ctools_access_get_conf_field_values($values, /** * Provide a summary description based upon the checked entity_bundle. + * + * @todo Figure out how to display the nice field values using a list. */ function ctools_entity_field_value_ctools_access_summary($conf, $context, $plugin) { list($parent, $entity_type, $bundle_type, $field_name) = explode(':', $plugin['name']); - $instances = field_info_instances($entity_type, $bundle_type); - $instance = $instances[$field_name]; - $field = field_info_field_by_id($instance['field_id']); - $entity_info = entity_get_info($entity_type); - $entity = (object)array( - $entity_info['entity keys']['bundle'] => $bundle_type, - ); + //$instance = field_info_instance($entity_type, $bundle_type, $field_name); + $field = field_info_field($field_name); + + // Create a stub entity with the desired field values. + $entity = entity_create_stub_entity($entity_type, array(NULL, NULL, $bundle_type)); + $entity->{$field_name} = $conf[$field_name]; + $string = ''; $keys = array(); $values = array(); + foreach ($field['columns'] as $column => $attributes) { - $conf_key = _field_sql_storage_columnname($field_name, $column); - if (count($field['columns']) > 1) { - // Add some sort of handling for compound fields - } - else { - if (isset($conf[$conf_key])) { - $entity->{$field_name}[LANGUAGE_NONE][] = array($column => $conf[$conf_key]); - } - } $string .= " @{$column} equals @{$column}_value"; $keys['@' . $column] = $column; - $values["@{$column}_value"] = $conf[$conf_key]; - } - $view_mode = 'full'; - $null = NULL; - $options = array('language' => LANGUAGE_NONE); - ctools_include('fields'); - $display = field_get_display($instance, $view_mode, $entity); - $display['type'] = 'list_default'; - $function = $display['module'] . '_field_formatter_view'; - $items = isset($entity->{$field_name}[LANGUAGE_NONE]) ? $entity->{$field_name}[LANGUAGE_NONE] : array(); - if (function_exists($function)) { - $elements = $function($entity_type, $entity, $field, $instance, LANGUAGE_NONE, $items, $display); - } - $value_keys = array_keys($values); - foreach ($value_keys as $key => $value) { - $values[$value] = $elements[$key]['#markup']; + // Display the field values raw separated by commas. + $values["@{$column}_value"] = implode(', ', $conf[$field_name . '_' . $column]); } + $values = array_merge($keys, $values); return t($string, $values); } -