You are here

function _ed_classified_get_vid in Classified Ads 5

Same name and namespace in other branches
  1. 5.2 ed_classified_utils.inc \_ed_classified_get_vid()
  2. 6.2 ed_classified_utils.inc \_ed_classified_get_vid()
  3. 7.2 ed_classified_utils.inc \_ed_classified_get_vid()

Returns (and possibly creates) a new vocabulary for classified Lifted from image.module. TODO: Create some built-in terms for the created taxonomy: Miscellaneous, Cars, Pets, etc. (look at craigslist for inspiration)

6 calls to _ed_classified_get_vid()
ed_classified_admin_settings in ./ed_classified_settings.inc
Implementation of hook_settings(). TODO - this is hardcoded to the Classified Ads vid - needs to be able to handle any taxonomy assigned
ed_classified_page in ./ed_classified.module
Display a page of classified ads, as appropriate. Lifted from image_gallery module. Shameless.
ed_classified_view in ./ed_classified.module
Implementation of hook_view().
_ed_classified_check_settings in ./ed_classified_utils.inc
do the sanity-check dance.
_ed_classified_get_primary_category in ./ed_classified_utils.inc
Helper function to determine the single ad category name to which this node belongs.

... See full list

File

./ed_classified_utils.inc, line 333
Simple text-based classified ads module. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com/drupal/modules/classified.module Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights…

Code

function _ed_classified_get_vid() {
  $vid = _ed_classified_variable_get('vocabulary', '');
  if (empty($vid)) {

    // Check to see if classified ads vocabulary exists
    $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='%s'", EDI_CLASSIFIED_MODULE_NAME));
    if (!$vid) {
      _edi_wd("Classified Ads vocabulary not found - creating taxonomy.");
      $vocabulary = array(
        'name' => _ed_classified_displayname() . t(' 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' => EDI_CLASSIFIED_MODULE_NAME,
        'nodes' => array(
          EDI_CLASSIFIED_MODULE_NAME => 1,
        ),
      );
      taxonomy_save_vocabulary($vocabulary);
      $vid = $vocabulary['vid'];
      $msg = "Classified Ads taxonomy" . $vocabulary->name . " (id={$vid}) created.";
      _edi_wd($msg);
      drupal_set_message($msg);

      // TODO: create standard terms and subterms specified in external file (or, at a minimum, create a few standard categories)
      // taxonomy_save_term(...);
    }
    _ed_classified_variable_set('vocabulary', $vid);
  }
  return $vid;
}