function media_browser_plus_media_access in Media Browser Plus 7.2
Same name and namespace in other branches
- 7 media_browser_plus.module \media_browser_plus_media_access()
Checks access to a given media entity.
@todo: this function may be obsolete in 2.x
Parameters
object $media_entity:
File
- ./
media_browser_plus.module, line 876 - 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 files')) {
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;
}