You are here

function classified_install in Classified Ads 6.3

Same name and namespace in other branches
  1. 7.3 classified.install \classified_install()

Implements hook_install().

File

./classified.install, line 31
Install file for the Classified Ads module.

Code

function classified_install() {
  $t = get_t();
  drupal_install_schema('classified');
  drupal_load('module', 'classified');

  // Define default values
  foreach (_classified_get_vars() as $name => $default) {
    variable_set($name, $default);
  }

  // Create module vocabulary
  $vocabulary = array(
    'module' => 'classified',
    'name' => $t('Classified Ads categories'),
    'description' => $t('This vocabulary is the one used by the Classified Ads module to classify ads. Do not remove it: it is managed by the Classified Ads module, not by the taxonomy module.'),
    'help' => $t('This term will appear on Classified Ads pages'),
    'multiple' => 0,
    'required' => 1,
    'hierarchy' => 1,
    'relations' => 0,
    'weight' => -10,
    'nodes' => array(
      'classified' => 1,
    ),
  );
  taxonomy_save_vocabulary($vocabulary);
  $vid = $vocabulary['vid'];
  variable_set('classified-vid', $vid);
  drupal_set_message($t('New vocabulary @vid created for Classified Ads', array(
    '@vid' => $vid,
  )));

  // Create terms in module vocabulary
  $terms = array(
    $t('For sale'),
    $t('Wanted'),
  );
  foreach ($terms as $name) {
    $term = array(
      'name' => $name,
      'vid' => $vid,
    );
    taxonomy_save_term($term);
  }
  drupal_set_message($t('@count default ad classifications inserted', array(
    '@count' => count($terms),
  )));
}