function ctools_entity_field_value_ctools_access_check
Check for access.
1 string reference to 'ctools_entity_field_value_ctools_access_check'
- entity_field_value.inc in plugins/
access/ entity_field_value.inc
File
-
plugins/
access/ entity_field_value.inc, line 205
Code
function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin) {
if (!is_object($context) || empty($context->data)) {
// If the context doesn't exist -- for example, a newly added entity
// reference is used as a pane visibility criteria -- we deny access.
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)) {
$langcode = field_language($entity_type, $context->data, $field_name);
// Get field storage columns.
$instance = field_info_instance($entity_type, $field_name, $bundle_type);
$field = field_info_field_by_id($instance['field_id']);
$columns = array();
foreach ($field['columns'] as $column => $attributes) {
$columns[$column] = _field_sql_storage_columnname($field_name, $column);
}
if (isset($conf[$field_name])) {
// We have settings for this field.
$conf_value_array = _ctools_entity_field_value_ctools_access_get_conf_field_values($conf[$field_name], $langcode);
if (empty($conf_value_array)) {
return FALSE;
}
// Check field value.
foreach ($field_items as $field_value) {
// Iterate through config values.
foreach ($conf_value_array as $conf_value) {
$match = FALSE;
foreach ($field_value as $field_column => $value) {
// Check access only for stored in config column values.
if (isset($conf_value[$field_column])) {
if ($value == $conf_value[$field_column]) {
$match = TRUE;
}
else {
$match = FALSE;
break;
}
}
}
if ($match) {
return TRUE;
}
}
}
return FALSE;
}
}
return FALSE;
}