1.20.x file.module file_permission()

Implements hook_permission().

File

modules/file/file.module, line 135
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_permission() {
  $permissions = array(
    'access file overview' => array(
      'title' => t('Access the manage files overview'),
      'description' => t('The <a href="@url">manage files overview page</a> shows all files uploaded to the site.', array('@url' => url('admin/content/files'))),
    ),
    '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,
    ),
    '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'),
    ),
    'manage files' => array(
      'title' => t('Manage or replace any file'),
      'description' => t('Allow managing of files from the files overview page.'),
      'restrict access' => TRUE,
    ),
    'delete files' => array(
      'title' => t('Delete any file'),
      'description' => t('Allow deleting files directly from the manage files overview page.'),
      'restrict access' => TRUE,
    ),
  );

  // Add description for the 'View file details' and 'View own private file
  // details' permissions to show which stream wrappers they apply to.
  $wrappers = file_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_permissions_get_configured_types() as $type) {
    $permissions += file_list_permissions($type);
  }

  return $permissions;
}