function dashboard_update in Drupal 7
Sets the new weight of each region according to the drag-and-drop order.
1 string reference to 'dashboard_update'
- dashboard_menu in modules/
dashboard/ dashboard.module - Implements hook_menu().
File
- modules/
dashboard/ dashboard.module, line 543 - Provides a dashboard page in the administrative interface.
Code
function dashboard_update() {
drupal_theme_initialize();
global $theme_key;
// Check the form token to make sure we have a valid request.
if (!empty($_REQUEST['form_token']) && drupal_valid_token($_REQUEST['form_token'], 'dashboard-update')) {
parse_str($_REQUEST['regions'], $regions);
foreach ($regions as $region_name => $blocks) {
if ($region_name == 'disabled_blocks') {
$region_name = 'dashboard_inactive';
}
foreach ($blocks as $weight => $block_string) {
// Parse the query string to determine the block's module and delta.
preg_match('/block-([^-]+)-(.+)/', $block_string, $matches);
$block = new stdClass();
$block->module = $matches[1];
$block->delta = $matches[2];
$block->region = $region_name;
$block->weight = $weight;
$block->status = 1;
db_merge('block')
->key(array(
'module' => $block->module,
'delta' => $block->delta,
'theme' => $theme_key,
))
->fields(array(
'status' => $block->status,
'weight' => $block->weight,
'region' => $block->region,
'pages' => '',
))
->execute();
}
}
drupal_set_message(t('The configuration options have been saved.'), 'status', FALSE);
}
drupal_exit();
}