function pay::permissions_settings in Pay 7
Same name and namespace in other branches
- 6 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 327 - 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,
);
$all = !empty($perm['all']) ? $perm['all'] : 0;
$element['all'] = array(
'#type' => 'checkbox',
'#title' => t('Everyone'),
'#default_value' => $all,
);
$options['all'] = 'all';
// The owner of this pay item.
$owner = !empty($perm['owner']) ? $perm['owner'] : 0;
$element['owner'] = array(
'#type' => 'checkbox',
'#title' => t('Owner'),
'#default_value' => $owner,
);
$options['owner'] = '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) {
$default = !empty($perm['permission:' . $name]) ? $perm['permission:' . $name] : 0;
$element['permission:' . $name] = array(
'#type' => 'checkbox',
'#title' => t('Users of any role with the %perm permission', array(
'%perm' => $name,
)),
'#default_value' => $default,
);
$options['permission:' . $name] = 'permission:' . $name;
}
foreach (user_roles() as $rid => $role) {
$default = !empty($perm['role:' . $rid]) ? $perm['role:' . $rid] : 0;
$element['role:' . $rid] = array(
'#type' => 'checkbox',
'#title' => t('Members of the %role role', array(
'%role' => $role,
)),
'#default_value' => $default,
);
$options['role:' . $rid] = 'role:' . $rid;
}
$element['#options'] = $options;
return $element;
}