function wsfields_field_access in Web Service Data 7
Implements hook_field_access().
File
- modules/
wsfields/ wsfields.module, line 50 - Defines core functionality for web service powered fields
Code
function wsfields_field_access($op, $field, $entity_type, $entity, $account) {
if ($field['storage']['module'] == 'wsfields_storage') {
$wsconfig = wsconfig_load_by_name($field['storage']['settings']['wsconfig_name']);
if (!$wsconfig) {
return FALSE;
}
$supported_ops = $wsconfig
->getOperations();
switch ($op) {
case 'view':
if (!in_array('read', $supported_ops)) {
return FALSE;
}
break;
case 'edit':
if (!in_array('update', $supported_ops) or !in_array('create', $supported_ops)) {
return FALSE;
}
break;
default:
}
}
return TRUE;
}