You are here

function biblio_update_6024 in Bibliography Module 6

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

File

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

Code

function biblio_update_6024() {
  $result = array();
  db_add_field($result, 'biblio', 'biblio_refereed', array(
    'type' => 'varchar',
    'length' => '20',
  ));

  /* add the field data for -refereed- on the biblo_fields table
     you need to get the last inserted record from biblio_fields and increment it by one
     so you don't step on customized fields added via the user online interface */
  $sql = 'SELECT fid FROM {biblio_fields} ORDER BY fid DESC LIMIT 1';
  $lastfid = db_result(db_query($sql));
  $newfid = $lastfid + 1;
  $result[] = update_sql("INSERT INTO {biblio_fields} (fid, name, type, size, maxsize) VALUES\n                        ({$newfid}, 'biblio_refereed', 'select', 0, 125)");

  /*use the same fid and insert an entry in the biblio_field_type_data */
  $result[] = update_sql("INSERT INTO {biblio_field_type_data}\n       (ftdid, title, hint) VALUES ({$newfid}, 'Refereed Designation', NULL)");

  /* get a list of unique tids from the biblio_field_type table.  You want to
     insert a tid,fid using the new fid for every available tid */
  $newsql = "SELECT DISTINCT tid FROM {biblio_field_type} ORDER BY tid DESC";
  $tidlist = db_query($newsql);
  while ($db_result = db_fetch_array($tidlist)) {
    $newtid = $db_result['tid'];
    db_query('INSERT INTO {biblio_field_type}
       (tid, fid, ftdid, cust_tdid, common, autocomplete, required, weight, visible)
        VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d)', $newtid, $newfid, $newfid, $newfid, 1, 1, 0, 1, 1);
  }
  return $result;
}