You are here

function biblio_update_6027 in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6.2 biblio.install \biblio_update_6027()
  2. 6 biblio.install \biblio_update_6027()
  3. 7 biblio.install \biblio_update_6027()

File

./biblio.install, line 1538

Code

function biblio_update_6027() {

  // renunmber the author rank such that it is zero based accross all categories
  // this only needs to be done for entries that actually have auth_categories other than 1
  require_once drupal_get_path('module', 'biblio') . '/biblio.contributors.inc';
  $result = array();
  $count = 0;
  $db_result = db_query("SELECT DISTINCT(vid),nid FROM {biblio_contributor} WHERE auth_category IN (2,3,4,5) ");
  $db_count_result = db_query("SELECT COUNT(DISTINCT(vid)) FROM {biblio_contributor} WHERE auth_category IN (2,3,4,5) ");
  $count_success = db_result($db_count_result);
  while ($node = db_fetch_object($db_result)) {
    $contributors = biblio_load_contributors($node->vid);
    _save_contributors($contributors, $node->nid, $node->vid, $update = FALSE);
    $count++;
  }
  $mesg = "Reordered the authors on {$count}/{$count_success} nodes";
  $result[] = array(
    'success' => $count_success == $count,
    'query' => $mesg,
  );
  return $result;
}