You are here

function _radioactivity_upgrade_view in Radioactivity 5

1 call to _radioactivity_upgrade_view()
radioactivity_update_2 in ./radioactivity.install

File

./radioactivity.install, line 130

Code

function _radioactivity_upgrade_view($view) {
  $upgraded = FALSE;

  // upgrade sorts when necessary
  foreach (array_keys($view->sort) as $sortkey) {
    if ($dpid = _radioactivity_upgrade_view_get_legacy_dpid_from_field($view->sort[$sortkey]['id'])) {
      $view->sort[$sortkey]['field'] = 'radioactivity_node_' . $dpid . '_s.energy';
      $view->sort[$sortkey]['options'] = 'radioactive';
      $upgraded = TRUE;
    }
  }

  // upgrade tablefields when necessary
  foreach (array_keys($view->field) as $fieldkey) {
    if ($dpid = _radioactivity_upgrade_view_get_legacy_dpid_from_tablename($view->field[$fieldkey]['tablename'])) {
      $view->field[$fieldkey]['tablename'] = 'radioactivity_node_' . $dpid . '_f';
      $upgraded = TRUE;
    }
  }

  // upgrade filters when necessary
  foreach (array_keys($view->filter) as $filterkey) {
    if ($dpid = _radioactivity_upgrade_view_get_legacy_dpid_from_field($view->filter[$filterkey]['field'])) {
      $view->filter[$filterkey]['field'] = 'radioactivity_node_' . $dpid . '_c.energy';
      $upgraded = TRUE;
    }
  }
  if ($upgraded) {
    return $view;
  }
  else {
    return FALSE;
  }
}