You are here

function entity_print_permission in Entity Print 7

Implements hook_permission().

File

./entity_print.module, line 269
Print any entity.

Code

function entity_print_permission() {

  // Administer entity print.
  $permissions['administer entity print'] = array(
    'title' => t('Administer Entity Print'),
    'description' => t('Allow users to administer the Entity Print settings.'),
    // We make this restricted because you can set the path to the wkhtmltopdf
    // binary from the settings page. It isn't vulnerable to injection but
    // it's probably not a setting you want everyone configuring anyway.
    'restrict access' => TRUE,
  );

  // Bypass access.
  $permissions['bypass entity print access'] = array(
    'title' => t('Bypass entity print access'),
    'description' => t('Allow a user to bypass the entity print access rights.'),
  );

  // Create a permission for every entity type and bundle.
  $entities = entity_get_info();
  foreach ($entities as $entity_key => $entity_info) {
    $permissions['entity print access type ' . $entity_key] = array(
      'title' => t('%entity_label: Use entity print for all bundles', array(
        '%entity_label' => $entity_info['label'],
      )),
      'description' => t('Allow a user to use entity print to view the generated PDF for all %entity_label bundles.', array(
        '%entity_label' => $entity_info['label'],
      )),
    );
    foreach ($entity_info['bundles'] as $bundle_key => $entity_bundle) {
      $permissions['entity print access bundle ' . $bundle_key] = array(
        'title' => t('%entity_label (%entity_bundle_label): Use entity print', array(
          '%entity_label' => $entity_info['label'],
          '%entity_bundle_label' => $entity_bundle['label'],
        )),
        'description' => t('Allow a user to use entity print to view the generated PDF for entity type %entity_label and bundle %entity_bundle_label', array(
          '%entity_label' => $entity_info['label'],
          '%entity_bundle_label' => $entity_bundle['label'],
        )),
      );
    }
  }
  return $permissions;
}