You are here

function blocktheme_save in Block Theme 6

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

Save a new block after form was 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 205
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("SELECT delta FROM {blocks} WHERE bid = '%s'", db_last_insert_id('boxes', 'bid'));
  if ($delta_result = db_fetch_object($result)) {
    $delta = $delta_result->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);
  }
}