function commerce_file_is_licensable in Commerce File 7.2
Checks whether the given file is licensable.
A file is licensable if it's referenced from at least one product's commerce_file field.
Parameters
$file: The file entity.
Return value
TRUE if the file is licensable, FALSE otherwise.
3 calls to commerce_file_is_licensable()
- commerce_file_access in ./
commerce_file.module - Determines if a user may perform the given operation on the licensed file.
- commerce_file_file_download in ./
commerce_file.module - Implements hook_file_download().
- commerce_file_file_download_headers_alter in ./
commerce_file.module - Implements hook_file_download_headers_alter().
File
- ./
commerce_file.module, line 288 - Extends Commerce License with the ability to sell access to files.
Code
function commerce_file_is_licensable($file) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_product')
->fieldCondition('commerce_file', 'fid', $file->fid)
->count();
$result = $query
->execute();
return $result > 0;
}