function media_browser_plus_media_access in Media Browser Plus 7
Same name and namespace in other branches
- 7.2 media_browser_plus.module \media_browser_plus_media_access()
Checks access to a given media entity.
Parameters
$media_entity:
1 call to media_browser_plus_media_access()
- media_browser_plus_file_download_access in ./
media_browser_plus.module - Checks if the user has the permission to download a file.
File
- ./
media_browser_plus.module, line 1008 - Adds fields to the media browser forms for better UX
Code
function media_browser_plus_media_access($media_entity) {
if (media_browser_plus_access('administer media')) {
return TRUE;
}
// Start with ACCESS_ALLOW - by default media items are fully accessible.
$access = MEDIA_ENTITY_ACCESS_ALLOW;
// Collect all modules implementing hook_media_entity_access.
foreach (module_implements('media_entity_access') as $module) {
// and invoke the hook
$return = module_invoke($module, 'media_entity_access', $media_entity);
// If no ALLOW or DENY was returned we assume IGNORE and check the next.
if ($return != MEDIA_ENTITY_ACCESS_ALLOW && $return != MEDIA_ENTITY_ACCESS_DENY) {
continue;
}
// If we have a DENY we can return a complete false here.
if ($return === MEDIA_ENTITY_ACCESS_DENY) {
return FALSE;
}
// Otherwise it is an ALLOW and we save it.
$access = MEDIA_ENTITY_ACCESS_ALLOW;
}
// Check if we had one allow.
return $access === MEDIA_ENTITY_ACCESS_ALLOW;
}