You are here

function farm_plan_permission in farmOS 7

Implements hook_permission().

File

modules/farm/farm_plan/farm_plan.module, line 18
Farm plan - A farm plan entity type.

Code

function farm_plan_permission() {
  $perms = array(
    'administer farm_plan module' => array(
      'title' => t('Administer farm plan module'),
      'description' => t('Gives full access to everything in the farm plan module.'),
      'restrict access' => TRUE,
    ),
    'administer farm_plan types' => array(
      'title' => t('Administer farm plan types'),
      'restrict access' => TRUE,
    ),
    'view farm plans' => array(
      'title' => t('View farm plans'),
      'description' => t('Allows users to view the full list of farm plans.'),
    ),
  );

  // Add permissions for each farm_plan type.
  foreach (farm_plan_types() as $farm_plan_type) {
    $type = $farm_plan_type->type;
    $ops = array(
      'view',
      'edit',
      'delete',
    );
    $scopes = array(
      'any',
      'own',
    );
    $perms += array(
      "create {$type} farm plans" => array(
        'title' => t('Create new %type_name farm plans', array(
          '%type_name' => $farm_plan_type->label,
        )),
      ),
    );
    foreach ($ops as $op) {
      foreach ($scopes as $scope) {
        $perms += array(
          "{$op} {$scope} {$type} farm plans" => array(
            'title' => drupal_ucfirst($op) . ' ' . $scope . ' ' . t('%type_name farm plans', array(
              '%type_name' => $farm_plan_type->label,
            )),
          ),
        );
      }
    }
  }
  return $perms;
}