You are here

function blocktheme_save in Block Theme 7

Same name and namespace in other branches
  1. 8 blocktheme.module \blocktheme_save()
  2. 5 blocktheme.module \blocktheme_save()
  3. 6 blocktheme.module \blocktheme_save()

Save a new block after the block form has been submitted.

1 string reference to 'blocktheme_save'
blocktheme_form_block_add_block_form_alter in ./blocktheme.module
Form for adding a new block.

File

./blocktheme.module, line 220
Provides a configuration option to select custom themes for blocks

Code

function blocktheme_save($form_id, &$form_state) {

  // First, get the new delta value
  $result = db_query_range("SELECT delta FROM {block} ORDER BY bid DESC", 0, 1);
  if ($record = $result
    ->fetchObject()) {
    $delta = $record->delta;
    $var_name = $form_state['values']['module'] . '-' . $delta;
    $blocktheme = blocktheme_get();
    $blocktheme_vars = blocktheme_get_vars();
    if ($form_state['values']['blocktheme']) {
      $blocktheme[$var_name] = $form_state['values']['blocktheme'];
    }
    if ($form_state['values']['blocktheme_vars']) {
      $blocktheme_vars[$var_name] = blocktheme_format_vars($form_state['values']['blocktheme_vars']);
    }
    blocktheme_set($blocktheme, $blocktheme_vars);
    drupal_theme_rebuild();
  }
}