You are here

function _enable_biblio_keyword_vocabulary in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6 biblio.install \_enable_biblio_keyword_vocabulary()
  2. 7 biblio.install \_enable_biblio_keyword_vocabulary()
2 calls to _enable_biblio_keyword_vocabulary()
biblio_install in ./biblio.install
Implements hook_install().
_add_biblio_keywords in ./biblio.install
Copies keywords from the biblio_keyword column of the biblio table to a taxonomy vocabulary

File

./biblio.install, line 178

Code

function _enable_biblio_keyword_vocabulary() {
  if ($vocabulary = taxonomy_vocabulary_load(variable_get('biblio_keyword_vocabulary', 0))) {

    // Existing install. Add back forum node type, if the biblio
    // vocabulary still exists. Keep all other node types intact there.
    $vocabulary = (array) $vocabulary;
    $vocabulary['nodes']['biblio'] = 1;
    taxonomy_save_vocabulary($vocabulary);
  }
  else {

    // Create the biblio vocabulary if it does not exist.
    $vocabulary = new stdClass();
    $vocabulary->name = 'Biblio Keywords';
    $vocabulary->machine_name = 'biblio_keywords';
    $vocabulary->description = t('This is a free tag vocabulary which contains the keywords from all nodes created by the biblio module');
    $vocabulary->help = t('Enter a comma separated list of words. Phrases containing commas should be enclosed in double quotes');
    $vocabulary->nodes = array(
      'biblio' => 1,
    );
    $vocabulary->hierarchy = 0;
    $vocabulary->relations = 1;
    $vocabulary->tags = 1;
    $vocabulary->multiple = 0;
    $vocabulary->required = 0;
    $vocabulary->weight = 0;
    $vocabulary->module = 'biblio';
    taxonomy_vocabulary_save($vocabulary);
    variable_set('biblio_keyword_vocabulary', $vocabulary->vid);
  }
  return $vocabulary->vid;
}