You are here

function ed_classified_init_taxonomy in Classified Ads 5

1 call to ed_classified_init_taxonomy()
ed_classified_install in ./ed_classified.install

File

./ed_classified.install, line 40

Code

function ed_classified_init_taxonomy() {
  drupal_set_message(t('Creating classified ads taxonomy terms'));
  $vid = variable_get('ed_classified_vocabulary', '');
  if (empty($vid)) {
    $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='%s'", ED_CLASSIFIED_MODULE_NAME));
    if (!$vid) {
      $vocabulary = array(
        'name' => 'Classified Ad Category',
        'description' => t('Vocabulary required by Classified Ads (ed_classified) module.  <strong>Warning:  You should not delete this vocabulary unless you intend to uninstall (or have already uninstalled) the Classified Ads module.</strong>'),
        'multiple' => '0',
        'required' => '1',
        'hierarchy' => '1',
        'relations' => '0',
        'module' => ED_CLASSIFIED_MODULE_NAME,
        'nodes' => array(
          ED_CLASSIFIED_MODULE_NAME => 1,
        ),
      );
      taxonomy_save_vocabulary($vocabulary);
      $vid = $vocabulary['vid'];
    }
    variable_set('ed_classified_vocabulary', $vid);
  }
  $msg = t('Install: Classified Ad vocabulary !vid created.', array(
    '!vid' => $vid,
  ));
  drupal_set_message($msg);
  watchdog('Classified Ads', $msg);
}