You are here

function dfp_install in Doubleclick for Publishers (DFP) 7

Same name and namespace in other branches
  1. 7.2 dfp.install \dfp_install()

Implements hook_install().

File

./dfp.install, line 119
Installation file for DFP module.

Code

function dfp_install() {

  // Migrate data from the DART module if possible.
  dfp_update_7000();
  $vocabulary_machinename = 'dfp_ad_categories';

  // If it doesn't already exist, create a vocabulary so that terms can be
  // targeted in groups.
  $existing_vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_machinename);
  if (!$existing_vocabulary) {
    taxonomy_vocabulary_save((object) array(
      'name' => 'DFP Ad Categories',
      'machine_name' => $vocabulary_machinename,
    ));
  }

  // Create a new term_reference field for the new vocabulary.
  if (field_read_field('field_dfp_ad_categories') === FALSE) {
    $field = array(
      'field_name' => 'field_dfp_ad_categories',
      'type' => 'taxonomy_term_reference',
      'settings' => array(
        'allowed_values' => array(
          array(
            'vocabulary' => $vocabulary_machinename,
            'parent' => 0,
          ),
        ),
      ),
    );
    field_create_field($field);
  }
}