function taxonomy_defaults_update_6102 in Taxonomy Defaults 6.2
Same name and namespace in other branches
- 6 taxonomy_defaults.install \taxonomy_defaults_update_6102()
- 7 taxonomy_defaults.install \taxonomy_defaults_update_6102()
Update taxonomy defaults settings.
Delete orphaned settings due to deleted vocabularies & content types, as well as deprecated settings, and initialize the new "visible" setting
File
- ./
taxonomy_defaults.install, line 98 - Install, update and uninstall functions for the taxonomy_defaults module.
Code
function taxonomy_defaults_update_6102() {
$ret = array();
$valid_settings = array();
//loop through every combo of content types and vocabularies
foreach (node_get_types() as $type => $name) {
foreach (taxonomy_get_vocabularies() as $vid => $vocab) {
// only store settings for vocabs previously marked active for this content type
if (variable_get("taxdef_{$type}_{$vid}_active", FALSE)) {
$valid_settings["taxdef_{$type}_{$vid}"] = variable_get("taxdef_{$type}_{$vid}", array());
if (!array_key_exists($vid, taxonomy_get_vocabularies($type))) {
// this appears to be a "hidden" vocabulary, so turn off visibility
$valid_settings["taxdef_{$type}_{$vid}_visible"] = FALSE;
}
else {
// otherwise, leave visibility on
$valid_settings["taxdef_{$type}_{$vid}_visible"] = TRUE;
}
}
}
}
// delete ALL taxonomy default settings
db_query("DELETE FROM {variable} WHERE name LIKE 'taxdef_%'");
foreach ($valid_settings as $setting => $value) {
variable_set($setting, $value);
}
return $ret;
}