You are here

function file_entity_list_permissions in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.module \file_entity_list_permissions()

Helper function to generate standard file permission list for a given type.

Parameters

$type: The machine-readable name of the file type.

Return value

array An array of permission names and descriptions.

Related topics

1 call to file_entity_list_permissions()
file_entity_permission in ./file_entity.module
Implement hook_permission().

File

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

Code

function file_entity_list_permissions($type) {
  $info = file_type_load($type);

  // Build standard list of file permissions for this type.
  $permissions = array(
    "edit own {$type} files" => array(
      'title' => t('%type_name: Edit own files', array(
        '%type_name' => $info->label,
      )),
    ),
    "edit any {$type} files" => array(
      'title' => t('%type_name: Edit any files', array(
        '%type_name' => $info->label,
      )),
    ),
    "delete own {$type} files" => array(
      'title' => t('%type_name: Delete own files', array(
        '%type_name' => $info->label,
      )),
    ),
    "delete any {$type} files" => array(
      'title' => t('%type_name: Delete any files', array(
        '%type_name' => $info->label,
      )),
    ),
    "download own {$type} files" => array(
      'title' => t('%type_name: Download own files', array(
        '%type_name' => $info->label,
      )),
    ),
    "download any {$type} files" => array(
      'title' => t('%type_name: Download any files', array(
        '%type_name' => $info->label,
      )),
    ),
  );
  return $permissions;
}