You are here

function view_mode_page_permission in View Mode Page 7.2

Same name and namespace in other branches
  1. 8.2 view_mode_page.module \view_mode_page_permission()

Implements hook_permission().

File

./view_mode_page.module, line 852
View Mode Page module allows users to add a page for a specific view mode.

Code

function view_mode_page_permission() {
  $permissions = array(
    VIEW_MODE_PAGE_ADMINISTER => array(
      'title' => t('Administer View Mode Page'),
      'description' => t('Allow user to update view mode page patterns on content types'),
    ),
  );
  $entities = view_mode_page_get_entity_types();
  foreach ($entities as $entity_type) {
    $permissions["manage VMP patterns for entity {$entity_type}"] = array(
      'title' => t('Manage patterns for %type', array(
        '%type' => $entity_type,
      )),
      'description' => t('Allow user to update view mode page patterns for the entity %type', array(
        '%type' => $entity_type,
      )),
    );
  }
  $view_modes = view_mode_page_get_entity_view_modes();
  foreach ($view_modes as $entity_type => $entity_view_modes) {
    foreach ($entity_view_modes as $view_mode) {
      $info = array(
        '%entity_type' => $entity_type,
        '%type' => $view_mode,
      );
      $permissions["manage VMP patterns for view mode {$entity_type}:{$view_mode}"] = array(
        'title' => t('Manage patterns for the view mode %entity_type:%type', $info),
        'description' => t('Allow user to update view mode page patterns for the view mode %type', $info),
      );
    }
  }
  return $permissions;
}