You are here

function commerce_file_permission in Commerce File 7

Same name and namespace in other branches
  1. 7.2 commerce_file.module \commerce_file_permission()

Implements hook_permission().

File

./commerce_file.module, line 222
Provides integration of file licenses with Commerce

Code

function commerce_file_permission() {
  $tokens = _commerce_file_translatables_tokenized();
  $perms = array(
    COMMERCE_FILE_ADMIN_PERM => array(
      'title' => t('Administer Commerce File'),
      'description' => t('Allows users to perform any action with the Commerce File module.'),
      'restrict access' => TRUE,
    ),
  );

  // license perms
  $license_entity_name = COMMERCE_FILE_LICENSE_ENTITY_NAME;
  $perms += array(
    "administer {$license_entity_name}" => array(
      'title' => t('Administer !license_label_plural', $tokens),
      'description' => t('Allows users to perform any action on !license_label_plural of any type.', $tokens),
      'restrict access' => TRUE,
    ),
    "access any {$license_entity_name}" => array(
      'title' => t('Access any !license_label_plural', $tokens),
      'description' => t('Allows users to view any !license_label_plural.', $tokens),
      'restrict access' => TRUE,
    ),
    "create {$license_entity_name}" => array(
      'title' => t('Create !license_label_plural', $tokens),
      'restrict access' => TRUE,
    ),
    "edit any {$license_entity_name}" => array(
      'title' => t('Edit or Delete any !license_label_plural', $tokens),
      'restrict access' => TRUE,
    ),
  );

  // log perms
  $log_entity_name = COMMERCE_FILE_LICENSE_LOG_ENTITY_NAME;
  $perms += array(
    "administer {$log_entity_name}" => array(
      'title' => t('Administer !log_label_plural', $tokens),
      'description' => t('Allows users to perform any action on !log_label_plural of any type.', $tokens),
      'restrict access' => TRUE,
    ),
    "access any {$log_entity_name}" => array(
      'title' => t('Access any !log_label_plural', $tokens),
      'description' => t('Allows users to view any !log_label_plural.', $tokens),
      'restrict access' => TRUE,
    ),
    "access own {$log_entity_name}" => array(
      'title' => t('Access own !log_label_plural', $tokens),
      'description' => t('Allows users to view their own !log_label_plural.', $tokens),
      'restrict access' => TRUE,
    ),
    "create {$log_entity_name}" => array(
      'title' => t('Create !log_label_plural', $tokens),
      'restrict access' => TRUE,
    ),
    "edit any {$log_entity_name}" => array(
      'title' => t('Edit or Delete any !log_label_plural', $tokens),
      'restrict access' => TRUE,
    ),
  );

  // File Field perms
  $perms += array(
    'administer ' . COMMERCE_FILE_FIELD_TYPE . ' field type' => array(
      'title' => t('Administer Commerce File field type'),
      'description' => t('Allows users to perform any action for Commerce File field type.'),
      'restrict access' => TRUE,
    ),
  );
  return $perms;
}