You are here

function homebox_update_6003 in Homebox 6.3

Same name and namespace in other branches
  1. 6 homebox.install \homebox_update_6003()
  2. 6.2 homebox.install \homebox_update_6003()

Make sure all user blocks have a module and delta.

File

./homebox.install, line 130
The install file for Homebox allows the module to install (and uninstall) itself. This is required as this module uses its own table.

Code

function homebox_update_6003() {
  $return = array();
  $result = db_query("SELECT uid, name, settings FROM {homebox_users}");
  while ($row = db_fetch_object($result)) {
    $row->settings = unserialize($row->settings);
    if ($page = homebox_get_page($row->name)) {
      foreach ($row->settings as $key => $block) {
        if ((!isset($block['module']) || !isset($block['delta'])) && isset($page->settings['blocks'][$key])) {
          $row->settings[$key]['module'] = $page->settings['blocks'][$key]['module'];
          $row->settings[$key]['delta'] = $page->settings['blocks'][$key]['delta'];
        }
      }
      drupal_write_record('homebox_users', $row, array(
        'uid',
        'name',
      ));
    }
  }
  return $return;
}