You are here

function pay::permissions_settings in Pay 6

Same name and namespace in other branches
  1. 7 includes/handlers/pay.inc \pay::permissions_settings()
1 call to pay::permissions_settings()
pay_method::settings_form in includes/handlers/pay_method.inc

File

includes/handlers/pay.inc, line 294
The base class for the Payment API.

Class

pay
@file The base class for the Payment API.

Code

function permissions_settings($activity = 'view', $title = NULL) {
  $perm = $this->permissions[$activity];
  if (!$title) {
    $title = t('Permissions');
  }
  $element = array(
    '#type' => 'checkboxes',
    '#title' => $title ? $title : t('Permissions'),
    '#parents' => array(
      $this
        ->handler(),
      'permissions',
      $activity,
    ),
    '#required' => TRUE,
    '#tree' => TRUE,
  );
  $element['all'] = array(
    '#type' => 'checkbox',
    '#title' => t('Everyone'),
    '#default_value' => $perm['all'],
  );

  // The owner of this pay item.
  $element['owner'] = array(
    '#type' => 'checkbox',
    '#title' => t('Owner'),
    '#default_value' => $perm['owner'],
  );
  $permissions = array(
    'administer pay',
    'administer payments for any form',
    'make payments on any form',
  );
  foreach (pay_handlers('pay_form') as $name => $info) {
    $permissions[] = 'administer payments for ' . $name . ' forms';
    $permissions[] = 'make payments on ' . $name . ' forms';
  }
  foreach ($permissions as $name) {
    $element['permission:' . $name] = array(
      '#type' => 'checkbox',
      '#title' => t('Users of any role with the %perm permission', array(
        '%perm' => $name,
      )),
      '#default_value' => $perm['permission:' . $name],
    );
  }
  foreach (user_roles() as $rid => $role) {
    $element['role:' . $rid] = array(
      '#type' => 'checkbox',
      '#title' => t('Members of the %role role', array(
        '%role' => $role,
      )),
      '#default_value' => $perm['role:' . $rid],
    );
  }
  return $element;
}