function rh_bean_entity_view in Rabbit Hole 7.2
Implements hook_entity_view().
File
- modules/
rh_bean/ rh_bean.module, line 101 - Main module file for Rabbit Hole beans module.
Code
function rh_bean_entity_view($bean, $entity_type, $view_mode, $langcode) {
if ($entity_type == 'bean') {
if ($view_mode != 'default') {
// The bean isn't viewed using the default view mode, exit early.
return;
}
// Determine whether or not the bean is being viewed at it's own page. The
// logic for this has been taken from node_is_page().
$page_bean = menu_get_object('bean_delta');
$bean_is_page = !empty($page_bean) ? $page_bean->delta == $bean->delta : FALSE;
// Execute Rabbit Hole, if the bean is being viewed at its own page, and the
// current user isn't able to override Rabbit Hole.
if ($bean_is_page && !user_access('bypass rh_bean')) {
rabbit_hole_execute('bean', $bean);
}
}
}