function brightcove_field_browse_access in Brightcove Video Connect 7.4
Same name and namespace in other branches
- 7.7 brightcove.module \brightcove_field_browse_access()
- 7.2 brightcove_field/brightcove_field.module \brightcove_field_browse_access()
- 7.3 brightcove_field/brightcove_field.module \brightcove_field_browse_access()
- 7.5 brightcove_field/brightcove_field.module \brightcove_field_browse_access()
- 7.6 brightcove.module \brightcove_field_browse_access()
Access callback for brightcove browser.
File
- brightcove_field/
brightcove_field.module, line 220 - Brightcove field module provides a Content Construction Kit module to developers, allowing them to browse videos in their Brightcove Studio and upload them.
Code
function brightcove_field_browse_access($entity_type, $field_name, $entity_id_or_bundle = NULL) {
$field = field_info_field($field_name);
if ($entity_id_or_bundle) {
if (is_numeric($entity_id_or_bundle)) {
// entity id is given
$entity = entity_load($entity_type, array(
$entity_id_or_bundle,
));
if (count($entity)) {
$entity = array_shift($entity);
return entity_access('update', $entity_type, $entity) && field_access('edit', $field, $entity_type);
}
}
else {
// bundle is given
$info = entity_get_info($entity_type);
if (!empty($info['bundles'][$entity_id_or_bundle]) && !empty($info['entity keys']['bundle'])) {
$key = $info['entity keys']['bundle'];
$entity = entity_create($entity_type, array(
$key => $entity_id_or_bundle,
));
return entity_access('create', $entity_type, $entity) && field_access('edit', $field, $entity_type);
}
}
}
return entity_access('create', $entity_type) && field_access('edit', $field, $entity_type);
}