You are here

function biblio_update_6015 in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 biblio.install \biblio_update_6015()

File

./biblio.install, line 1672
Install file for biblio module

Code

function biblio_update_6015() {
  require_once drupal_get_path('module', 'biblio') . '/biblio.keywords.inc';
  $result = array();
  if ($vid = variable_get('biblio_freetagging_vocab', 0)) {
    variable_set('biblio_keyword_vocabulary', $vid);
  }
  variable_del('biblio_freetagging_vocab');
  $result[] = update_sql("ALTER TABLE {biblio_keyword_data} MODIFY COLUMN kid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT");
  $db_result = db_query('SELECT t.nid, t.vid, td.name as biblio_keywords FROM {term_node} t left join {term_data} td on t.tid=td.tid where td.vid=%d', variable_get('biblio_keyword_vocabulary', -1));
  $count = 0;
  while ($node = db_fetch_object($db_result)) {
    biblio_insert_keywords($node, TRUE);
    $count++;
  }
  $result[] = array(
    'success' => TRUE,
    'query' => "Copied {$count} keywords to the new database stucture from taxonomy",
  );
  $count = 0;
  $db_result = db_query('SELECT nid,vid,biblio_keywords FROM {biblio} where biblio_keywords != "" ');
  while ($node = db_fetch_object($db_result)) {
    biblio_insert_keywords($node, TRUE);
    $count++;
  }
  $result[] = array(
    'success' => TRUE,
    'query' => "Moved " . $count . " keywords to the new database stucture",
  );
  db_drop_field($result, 'biblio', 'biblio_keywords');
  return $result;
}