You are here

function block_access_check_submit in Block Access 6.2

Same name and namespace in other branches
  1. 6 block_access.module \block_access_check_submit()
  2. 7 block_access.module \block_access_check_submit()
1 call to block_access_check_submit()
block_access_admin_display_submit in ./block_access.module

File

./block_access.module, line 386

Code

function block_access_check_submit($form, $key, $block) {
  $valid = TRUE;
  $name = array(
    check_plain($block['info']),
  );

  // If the user is trying to disable the block but can't, report it
  if ($block['region'] == BLOCK_REGION_NONE && $form[$key]['region']['#value'] != BLOCK_REGION_NONE && !block_access_can_delete($block['module']['#value'], $block['delta']['#value'])) {
    drupal_set_message(t('You cannot disable @block.', $name));
    $valid = FALSE;
  }
  elseif ($block['region'] != BLOCK_REGION_NONE && $form[$key]['region']['#value'] == BLOCK_REGION_NONE && !block_access_can_enable($block['module']['#value'], $block['delta']['#value'])) {
    drupal_set_message(t('You cannot enable @block.', $name));
    $valid = FALSE;
  }
  elseif ($block['region'] != BLOCK_REGION_NONE && $form[$key]['region']['#value'] != BLOCK_REGION_NONE && $block['region'] != $form[$key]['region']['#value'] && !block_access_can_move($block['module']['#value'], $block['delta']['#value'])) {
    drupal_set_message(t('You cannot move @block.', $name));
    $valid = FALSE;
  }
  return $valid;
}