function document_get_vocid in Document 7
Same name and namespace in other branches
- 6 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_query("SELECT vid FROM {taxonomy_vocabulary} WHERE module='document'")
->fetchField();
if ($vocid) {
// We found a vocabulary, so make sure it is associated with our content.
$vocabulary = taxonomy_vocabulary_load($vocid);
$vocabulary->nodes = array(
'document' => 1,
);
$status = taxonomy_vocabulary_save($vocabulary);
}
else {
// Didn't find one, so create vocabulary from scratch.
$vocabulary = new stdClass();
$vocabulary->name = 'Document types';
$vocabulary->machine_name = 'document_types';
$vocabulary->multiple = 0;
$vocabulary->required = 1;
$vocabulary->hierarchy = 2;
$vocabulary->relations = 0;
$vocabulary->module = 'document';
$vocabulary->nodes = array(
'document' => 1,
);
$status = taxonomy_vocabulary_save($vocabulary);
$vocid = $vocabulary->vid;
}
variable_set('document_vocabulary', $vocid);
}
return $vocid;
}