function deploy_uuid_taxonomy in Deploy - Content Staging 6
Implementation of hook_taxonomy().
$op What is being done to $array. Possible values:
- "delete"
- "insert"
- "update"
$type What manner of item $array is. Possible values:
- "term"
- "vocabulary"
$array The item on which $op is being performed. Possible values:
- for vocabularies, 'insert' and 'update' ops: $form_values from taxonomy_form_vocabulary_submit()
- for vocabularies, 'delete' op: $vocabulary from taxonomy_get_vocabulary() cast to an array
- for terms, 'insert' and 'update' ops: $form_values from taxonomy_form_term_submit()
- for terms, 'delete' op: $term from taxonomy_get_term() cast to an array
File
- modules/
deploy_uuid/ deploy_uuid.module, line 134 - Deployment UUID management
Code
function deploy_uuid_taxonomy($op, $type, $array = NULL) {
switch ($op) {
case 'insert':
// The only case in which we would have a term or vocabulary come through insert with a uuid
// already in place is the case where it's being deployed from a remote source. In this case,
// keep the existing uuid. Otherwise, create a new one.
if ($type == 'term') {
if (isset($array['uuid'])) {
db_query("INSERT INTO {term_data_uuid} (tid, uuid) VALUES (%d, '%s')", $array['tid'], $array['uuid']);
}
else {
db_query("INSERT INTO {term_data_uuid} (tid, uuid) VALUES (%d, '%s')", $array['tid'], deploy_uuid_create_uuid());
}
}
else {
if (isset($array['uuid'])) {
db_query("INSERT INTO {vocabulary_uuid} (vid, uuid) VALUES (%d, '%s')", $array['vid'], $array['uuid']);
}
else {
db_query("INSERT INTO {vocabulary_uuid} (vid, uuid) VALUES (%d, '%s')", $array['vid'], deploy_uuid_create_uuid());
}
}
break;
// When a term or vocabulary is deleted, clean out its associated UUID.
case 'delete':
if ($type == 'term') {
db_query("DELETE FROM {term_data_uuid} WHERE tid = %d", $array['tid']);
}
else {
db_query("DELETE FROM {vocabulary_uuid} WHERE vid = %d", $array['vid']);
}
break;
}
}