function document_get_vocid in Document 6
Same name and namespace in other branches
- 7 document.inc \document_get_vocid()
- 8.x document.inc \document_get_vocid()
4 calls to document_get_vocid()
File
- ./
document.inc, line 42
Code
function document_get_vocid() {
$vocid = variable_get('document_vocabulary', '');
if (empty($vocid)) {
// Check to see if document vocabulary exists
$vocid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='document'"));
if ($vocid) {
// We found a vocabulary, so make sure it is associated with our content.
$vocabulary = (array) taxonomy_vocabulary_load($vocid);
$vocabulary['nodes'] = array(
'document' => 1,
);
$status = taxonomy_save_vocabulary($vocabulary);
}
else {
// Didn't find one, so create vocabulary from scratch.
$vocabulary = array(
'name' => 'Document types',
'multiple' => 0,
'required' => 1,
'hierarchy' => 2,
'relations' => 0,
'module' => 'document',
'nodes' => array(
'document' => 1,
),
);
$status = taxonomy_save_vocabulary($vocabulary);
$vocid = $vocabulary['vid'];
}
variable_set('document_vocabulary', $vocid);
}
return $vocid;
}