You are here

function panelizer_entity_panels_storage_access in Panelizer 7.3

Access callback for panels storage.

1 string reference to 'panelizer_entity_panels_storage_access'
panelizer_entity.inc in plugins/panels_storage/panelizer_entity.inc
Provides a panels_storage plugin for Panelizer entity overrides.

File

plugins/panels_storage/panelizer_entity.inc, line 16
Provides a panels_storage plugin for Panelizer entity overrides.

Code

function panelizer_entity_panels_storage_access($storage_type, $storage_id, $op, $account) {
  list($entity_type, $entity_id, $view_mode) = explode(':', $storage_id);
  $entities = entity_load($entity_type, array(
    $entity_id,
  ));
  $entity = reset($entities);
  if (!$entity) {
    return FALSE;
  }
  $handler = panelizer_entity_plugin_get_handler($entity_type);
  if (!$handler) {
    return FALSE;
  }
  if ($op == 'read') {
    return $handler
      ->entity_access('view', $entity);
  }

  // The 'layout' operation has a special permission.
  if ($op == 'change layout') {
    return $handler
      ->access_admin($entity, 'layout', $view_mode);
  }
  else {
    return $handler
      ->access_admin($entity, 'content', $view_mode);
  }
}