You are here

function paranoia_permissions_validate in Paranoia 7

Form validation prevents granting permissions to untrusted roles.

See also

paranoia_form_user_admin_permissions_alter()

1 string reference to 'paranoia_permissions_validate'
paranoia_form_user_admin_permissions_alter in ./paranoia.module
Implements hook_form_FORM_ID_alter().

File

./paranoia.module, line 162
Paranoia module file. Provides various extra security features.

Code

function paranoia_permissions_validate($form, &$form_state) {
  $permissions = module_invoke_all('permission');
  foreach ($permissions as $machine_name => $attributes) {
    if (!empty($attributes['restrict access'])) {
      if (!empty($form_state['values'][1][$machine_name])) {
        form_set_error('1][' . $machine_name, t('The permission %name can affect site security and should not be granted to anonymous users.', array(
          '%name' => $attributes['title'],
        )));
      }
      if (!empty($form_state['values'][2][$machine_name])) {
        form_set_error('2][' . $machine_name, t('The permission %name can affect site security and should not be granted to authenticated users.', array(
          '%name' => $attributes['title'],
        )));
      }
    }
  }
}