You are here

function homebox_admin_display_form_submit in Homebox 6.3

Same name and namespace in other branches
  1. 6 homebox.admin.inc \homebox_admin_display_form_submit()
  2. 6.2 homebox.admin.inc \homebox_admin_display_form_submit()
  3. 7.3 homebox.admin.inc \homebox_admin_display_form_submit()
  4. 7.2 homebox.admin.inc \homebox_admin_display_form_submit()

Process main home blocks administration form submission.

File

./homebox.admin.inc, line 518
Homebox admin file, takes care admin interface for homebox

Code

function homebox_admin_display_form_submit($form, &$form_state) {

  // Page
  $page = homebox_get_page($form_state['values']['name']);

  // We can safely remove old records
  $page->settings['blocks'] = array();
  foreach ($form_state['values'] as $key => $block) {

    // Check to see if this is a block
    // We check $block['region'] == 0, since we don't want to store block that are not enabled
    if (is_array($block) && is_numeric($block['bid']) && $block['bid'] != 0 && is_numeric($block['region']) && (int) $block['region'] > 0) {
      $page->settings['blocks'][$key] = array(
        'module' => $block['module'],
        'delta' => $block['delta'],
        'region' => (int) $block['region'],
        'movable' => (int) $block['movable'],
        'status' => (int) $block['status'],
        'open' => (int) $block['open'],
        'closable' => (int) $block['closable'],
        'title' => $block['title'],
        'weight' => (int) $block['weight'],
      );
    }
  }

  // Save the page
  homebox_save_page($page);

  /*
   * There is no reason to remove the blocks from user settings that
   * were removed here. Blocks that aren't in the page will be stripped
   * from the user settings upon rendering. Once the user saves, the
   * settings will be updated.
   */
  menu_rebuild();
  drupal_set_message(t('Layout settings have been updated for @page_title.', array(
    '@page_title' => $page->settings['title'],
  )));
  $form_state['redirect'] = 'admin/build/homebox';
}