You are here

function secure_permissions_form_submit in Secure Permissions 6

Same name and namespace in other branches
  1. 7.2 secure_permissions.module \secure_permissions_form_submit()
  2. 7 secure_permissions.module \secure_permissions_form_submit()

We cannot rebuild the menu baed on a setting during form submit, at least, not without special handling.

So set a session value to indicate we must rebuild the menus.

Also rebuilds permissions, if necessary.

1 string reference to 'secure_permissions_form_submit'
secure_permissions_form in ./secure_permissions.module
Configuration form for the module.

File

./secure_permissions.module, line 506
Secure Permissions module file.

Code

function secure_permissions_form_submit($form, &$form_state) {
  global $conf;
  $modules = module_implements('secure_permissions');
  $_SESSION['secure_permissions_rebuild'] = TRUE;
  if ($form_state['values']['secure_permissions_active'] && count($modules) > 1) {

    // We must do this to pass the value to the calling function during submit.
    $conf['secure_permissions_active'] = TRUE;
    $conf['secure_permissions_administrative_role'] = $form_state['values']['secure_permissions_administrative_role'];
    $conf['secure_permissions_role_name'] = $form_state['values']['secure_permissions_role_name'];
    $conf['secure_permissions_use_default'] = $form_state['values']['secure_permissions_use_default'];
    secure_permissions_rebuild();
  }
  else {
    drupal_set_message(t('Permissions cannot be rebuilt from code at this time.'));
  }
}