Projet

Général

Profil

Paste
Télécharger (972 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panelizer / plugins / panels_storage / panelizer_entity.inc @ 136a805a

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides a panels_storage plugin for Panelizer entity overrides.
6
 */
7

    
8
// Plugin definition
9
$plugin = array(
10
  'access callback' => 'panelizer_entity_panels_storage_access',
11
);
12

    
13
/**
14
 * Access callback for panels storage.
15
 */
16
function panelizer_entity_panels_storage_access($storage_type, $storage_id, $op, $account) {
17
  list ($entity_type, $entity_id, $view_mode) = explode(':', $storage_id);
18

    
19
  $entities = entity_load($entity_type, array($entity_id));
20
  $entity = reset($entities);
21
  if (!$entity) {
22
    return FALSE;
23
  }
24

    
25
  $handler = panelizer_entity_plugin_get_handler($entity_type);
26
  if (!$handler) {
27
    return FALSE;
28
  }
29

    
30
  if ($op == 'read') {
31
    return $handler->entity_access('view', $entity);
32
  }
33

    
34
  // The 'layout' operation has a special permission.
35
  if ($op == 'change layout') {
36
    return $handler->access_admin($entity, 'layout', $view_mode);
37
  }
38
  else {
39
    return $handler->access_admin($entity, 'content', $view_mode);
40
  }
41
}