function homebox_admin_display_form_submit in Homebox 7.3
Same name and namespace in other branches
- 6.3 homebox.admin.inc \homebox_admin_display_form_submit()
- 6 homebox.admin.inc \homebox_admin_display_form_submit()
- 6.2 homebox.admin.inc \homebox_admin_display_form_submit()
- 7.2 homebox.admin.inc \homebox_admin_display_form_submit()
Process main home blocks administration form submission.
File
- ./
homebox.admin.inc, line 537 - 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'],
);
}
}
if ($form_state['values']['enable_block']) {
$blocks = $form_state['build_info']['args'][0];
$key = $form_state['values']['enable_block'];
foreach ($blocks as $block) {
if ($key == $block['module'] . '_' . $block['delta']) {
break;
}
}
$page->settings['blocks'][$key] = array(
'module' => $block['module'],
'delta' => $block['delta'],
// Always move the enabled block to the first column.
'region' => 1,
'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'],
)));
}