You are here

function file_entity_permission in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.module \file_entity_permission()
  2. 7 file_entity.module \file_entity_permission()

Implement hook_permission().

File

./file_entity.module, line 432
Extends Drupal file entities to be fieldable and viewable.

Code

function file_entity_permission() {
  $permissions = array(
    'bypass file access' => array(
      'title' => t('Bypass file access control'),
      'description' => t('View, edit and delete all files regardless of permission restrictions.'),
      'restrict access' => TRUE,
    ),
    'administer file types' => array(
      'title' => t('Administer file types'),
      'restrict access' => TRUE,
    ),
    'administer files' => array(
      'title' => t('Administer files'),
      'restrict access' => TRUE,
    ),
    'create files' => array(
      'title' => t('Add and upload new files'),
    ),
    'view own private files' => array(
      'title' => t('View own private files'),
    ),
    'view own files' => array(
      'title' => t('View own files'),
    ),
    'view private files' => array(
      'title' => t('View private files'),
      'restrict access' => TRUE,
    ),
    'view files' => array(
      'title' => t('View files'),
    ),
  );

  // Add description for the 'View file details' and 'View own private file
  // details' permissions to show which stream wrappers they apply to.
  $wrappers = file_entity_get_public_and_private_stream_wrapper_names();
  $wrappers += array(
    'public' => array(
      t('None'),
    ),
    'private' => array(
      t('None'),
    ),
  );
  $permissions['view files']['description'] = t('Includes the following stream wrappers: %wrappers.', array(
    '%wrappers' => implode(', ', $wrappers['public']),
  ));
  $permissions['view own private files']['description'] = t('Includes the following stream wrappers: %wrappers.', array(
    '%wrappers' => implode(', ', $wrappers['private']),
  ));

  // Generate standard file permissions for all applicable file types.
  foreach (file_entity_permissions_get_configured_types() as $type) {
    $permissions += file_entity_list_permissions($type);
  }
  return $permissions;
}