You are here

function secure_permissions_modules_submit in Secure Permissions 6

Rebuild permissions on module page submission.

1 string reference to 'secure_permissions_modules_submit'
secure_permissions_form_system_modules_alter in ./secure_permissions.module
In Drupal 6, we do not have a hook for when modules are enabled or disabled, so we must add a submit to the form.

File

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

Code

function secure_permissions_modules_submit($form, &$form_state) {
  $status = $form_state['values']['status'];
  $modules = $form_state['values']['secure_permissions'];
  $modules_new = module_implements('secure_permissions');

  // If module_implements is greater than the form value, a new module
  // has been activated for secure_permissions.
  $rebuild = TRUE;

  // If only the core module is enabled, do not rebuild.
  if (count($modules_new) == 1) {
    variable_set('secure_permissions_active', 0);
    drupal_set_message(t('Loading permissions from code has been disabled. You may <a href="!url">re-enable it</a>.', array(
      '!url' => url('admin/user/secure_permissions'),
    )));
    return;
  }
  foreach ($modules as $module) {
    if (empty($status[$module])) {
      $rebuild = FALSE;
    }
  }
  if ($rebuild) {
    secure_permissions_rebuild();
  }
}