You are here

function block_access_config_presubmit in Block Access 6

Same name and namespace in other branches
  1. 6.2 block_access.module \block_access_config_presubmit()
1 string reference to 'block_access_config_presubmit'
block_access_form_alter in ./block_access.module

File

./block_access.module, line 415

Code

function block_access_config_presubmit($form, &$form_state) {
  $module = $form_state['values']['module'];
  $delta = $form_state['values']['delta'];

  // restore existing values if they were removed from the form
  $edit = db_fetch_array(db_query("\n    SELECT pages, visibility, custom, title\n    FROM   {blocks}\n    WHERE  module = '%s'\n    AND delta = '%s'", $module, $delta));
  if (!isset($form_state['values']['pages'])) {
    $form_state['values']['pages'] = $edit['pages'];
  }
  if (!isset($form_state['values']['visibility'])) {
    $form_state['values']['visibility'] = $edit['visibility'];
  }
  if (!isset($form_state['values']['custom'])) {
    $form_state['values']['custom'] = $edit['custom'];
  }
  if (!isset($form_state['values']['title'])) {
    $form_state['values']['title'] = $edit['title'];
  }
  if (!isset($form_state['values']['roles'])) {
    $form_state['values']['roles'] = array();
    $result = db_query("\n      SELECT rid\n      FROM   {blocks_roles}\n      WHERE  module = '%s'\n      AND    delta = '%s'", $module, $delta);
    while ($role = db_fetch_object($result)) {
      $form_state['values']['roles'][] = $role->rid;
    }
  }

  // i18n deletes its config if the fields aren't in the form, so replace them here
  if (function_exists('i18nblocks_load')) {
    $i18n = i18nblocks_load($module, $delta);
    $form_state['values']['language'] = $i18n->language;
    $form_state['values']['ibid'] = $i18n->ibid;
  }
}