You are here

function _ad_get_vid in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 ad.module \_ad_get_vid()
  2. 5 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.

11 calls to _ad_get_vid()
ad_admin_groups_list in ./ad.admin.inc
ad_admin_group_form in ./ad.admin.inc
Returns a form for adding an ad group.
ad_channel_admin_channel in channel/ad_channel.module
Administrative page for creating or editing channels.
ad_channel_admin_channel_submit in channel/ad_channel.module
Save the channel.
ad_filters in ./ad.admin.inc
List ad administration filters that can be applied.

... See full list

File

./ad.module, line 1418

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' => t('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;
}