You are here

function _ad_get_vid in Advertisement 5

Same name and namespace in other branches
  1. 5.2 ad.module \_ad_get_vid()
  2. 6.3 ad.module \_ad_get_vid()
  3. 6 ad.module \_ad_get_vid()
  4. 6.2 ad.module \_ad_get_vid()
  5. 7 ad.module \_ad_get_vid()

Creates a vocabulary for use by ad groups if not already created.

9 calls to _ad_get_vid()
ad_admin_groups_list in ./ad.module
ad_admin_group_form in ./ad.module
Returns a form for adding an ad group.
ad_filters in ./ad.module
List ad administration filters that can be applied.
ad_form_alter in ./ad.module
Drupal _form_alter() hook.
ad_groups_list in ./ad.module
Return an array of all groups, or a specific group.

... See full list

File

./ad.module, line 2710
An advertising system for Drupal powered websites.

Code

function _ad_get_vid() {
  $vid = variable_get('ad_group_vid', '');
  if (empty($vid)) {

    // No vid stored in the variables table, check if one even exists.
    $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = '%s'", 'ad'));
    if (!$vid) {

      // No vid, so we create one.
      $edit = array(
        'name' => 'Ad groups',
        'multiple' => 1,
        'required' => 0,
        'hierarchy' => 0,
        'relations' => 0,
        'module' => 'ad',
        'nodes' => array(
          'ad' => 1,
        ),
      );
      taxonomy_save_vocabulary($edit);
      $vid = $edit['vid'];
    }

    // Save the vid for next time.
    variable_set('ad_group_vid', $vid);
  }
  return $vid;
}