dashboard_update

Versions
7
dashboard_update()

Set the new weight of each region according to the drag-and-drop order.

Code

modules/dashboard/dashboard.module, line 320

<?php
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 = '';
      }
      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;
        if (empty($region_name)) {
          $block->status = 0;
        }
        else {
          $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_exit();
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.