function blocks_manage_blocks_form_submit

4.x blocks.module blocks_manage_blocks_form_submit($form, $form_state)
5.x blocks.module blocks_manage_blocks_form_submit($form, $form_state)

Submit handler for the manage blocks form.

File

modules/blocks/blocks.module, line 362

Code

function blocks_manage_blocks_form_submit($form, $form_state) {

  $selected_module = $form_state ["values"]["module"];
  $selected_section = $form_state ["values"]["section"];

  // begin by deleteing what is all ready there, if anything, for this section.
  db_query("DELETE FROM blocks WHERE section = '?' ", $selected_section);

  foreach ($form_state ["values"] as $key => $value) {

    if (strstr($key, "block_region~~")) {
      $temp = explode("~~", $key);
      $module = $temp [1];
      $delta = $temp [2];

      // Okay, let's see where it was placed, and update our blocks table.
      $region = $form_state ["values"]["block_region~~$module~~$delta"];
      $weight = $form_state ["values"]["block_weight~~$module~~$delta"];

      if ($region != "") {
        db_query("INSERT INTO blocks (section, region, module, delta, weight)
                  VALUES ('?', '?', '?', '?', '?')
                  ", $selected_section, $region, $module, $delta, $weight);
      }


    }
  }

  fp_add_message(t("Blocks have been updated successfully."));

}