You are here

function block_access_form_alter in Block Access 6.2

Same name and namespace in other branches
  1. 6 block_access.module \block_access_form_alter()
  2. 7 block_access.module \block_access_form_alter()

File

./block_access.module, line 310

Code

function block_access_form_alter(&$form, &$form_state, $form_id) {

  // Only alter the form we're interested in
  if ($form_id == BLOCK_ACCESS_FORM_ADMIN) {

    // loop over all values, ignoring those that are not block arrays
    foreach ($form as $key => $block) {

      // it's a block array if it has the info attribute (assumption)
      if (is_array($block) && isset($block['info'])) {
        block_access_check_perms($form, $key, $block);
      }
    }

    // override the submit button to run perm validation before block.admin
    $form['#submit'][] = 'block_access_admin_display_submit';
  }
  elseif ($form_id == BLOCK_ACCESS_FORM_CONFIG || $form_id == BLOCK_ACCESS_FORM_ADD) {
    $role_options = user_roles();
    $module = $form['module']['#value'];
    $delta = $form['delta']['#value'];

    // Add fieldset for each permission
    block_access_fieldset($form, $role_options, 'view', $module, $delta);
    block_access_fieldset($form, $role_options, 'move', $module, $delta);
    block_access_fieldset($form, $role_options, 'enable', $module, $delta);
    block_access_fieldset($form, $role_options, 'disable', $module, $delta);
    block_access_fieldset($form, $role_options, 'config', $module, $delta);
    block_access_fieldset($form, $role_options, 'delete', $module, $delta);
    block_access_fieldset($form, $role_options, 'config_lang', $module, $delta);
    block_access_fieldset($form, $role_options, 'config_spec', $module, $delta);
    block_access_fieldset($form, $role_options, 'config_user', $module, $delta);
    block_access_fieldset($form, $role_options, 'config_role', $module, $delta);
    block_access_fieldset($form, $role_options, 'config_page', $module, $delta);
    array_unshift($form['#submit'], 'block_access_config_presubmit');
    $form['#submit'][] = 'block_access_config_submit';
    $form['submit']['#weight'] = 99;
    block_access_check_config_form($form);
  }
}