You are here

function admin_update_6202 in Admin 6.2

Update 6202: Update the format of the admin_toolbar variable.

File

./admin.install, line 107

Code

function admin_update_6202() {
  $ret = array();
  $settings = variable_get('admin_toolbar', array());
  if (isset($settings['blocks'])) {
    $needs_update = FALSE;

    // First pass, determine if we need to update these.
    foreach ($settings['blocks'] as $bid => $status) {
      if (!is_numeric($status)) {
        $needs_update = TRUE;
        break;
      }
    }
    if ($needs_update) {
      module_load_include('module', 'admin', 'admin');
      $defaults = admin_get_default_blocks(TRUE);

      // Second pass, do the update!
      foreach ($settings['blocks'] as $bid => $status) {
        if ($status) {
          $settings['blocks'][$bid] = isset($defaults[$bid]) ? $defaults[$bid] : BLOCK_NO_CACHE;
        }
        else {
          unset($settings['blocks'][$bid]);
        }
      }
      variable_set('admin_toolbar', $settings);
      $ret[] = array(
        'success' => TRUE,
        'query' => 'Updated admin settings.',
      );
    }
  }
  return $ret;
}