function taxonomy_dupecheck_is_dupe_vocabulary in Taxonomy dupecheck 7
Same name and namespace in other branches
- 6 taxonomy_dupecheck.module \taxonomy_dupecheck_is_dupe_vocabulary()
Checks whether a vocabulary is a duplicate, based on the module preferences.
Parameters
$vocab: Name of the new vocabulary to check
int $vid: ID of the vocabulary the new term belongs to (used when updating an existing vocabulary)
Return value
TRUE if the vocabulary is a duplicate, FALSE if not
1 call to taxonomy_dupecheck_is_dupe_vocabulary()
- taxonomy_dupecheck_vocabulary_validate in ./
taxonomy_dupecheck.module - Implements _form_validate() for taxonomy_form_vocabulary().
File
- ./
taxonomy_dupecheck.module, line 222 - Module file for the Taxonomy dupecheck module.
Code
function taxonomy_dupecheck_is_dupe_vocabulary($vocab, $vid = 0) {
// Clean up the vocabulary to check
$vocab = trim($vocab);
// Get all vocabularies
$vocabs = taxonomy_get_vocabularies();
// Look for a vocabulary with the same name based on case-sensitivity preferences
$case_sensitive = variable_get('taxonomy_dupecheck_case_sensitive');
foreach ($vocabs as $found_vocab) {
// Skip the check if the current found vocabulary is the same one we're comparing.
// This will happen on updates to an existing vocabulary.
if ($vid == $found_vocab->vid) {
continue;
}
// Clean up the stored vocabulary. This helps for systems that
// don't trim their vocabulary names before entry.
$found_vocab_name = trim($found_vocab->name);
if ($case_sensitive && !strcmp($found_vocab_name, $vocab) || !$case_sensitive && !strcasecmp($found_vocab_name, $vocab)) {
return TRUE;
}
}
return FALSE;
}