function userpoints_get_vid in User Points 6
Same name and namespace in other branches
- 5.3 userpoints.module \userpoints_get_vid()
- 7.2 userpoints.module \userpoints_get_vid()
- 7 userpoints.module \userpoints_get_vid()
3 calls to userpoints_get_vid()
- UserpointsTestCase::testGetDefaultTid in tests/
userpoints_api.test - userpoints_action_grant_points_form in ./
userpoints_rules.rules.inc - Rules action form configuration - allow number of points to be set.
- userpoints_get_categories in ./
userpoints.module
File
- ./
userpoints.module, line 1803
Code
function userpoints_get_vid() {
if (!module_exists('taxonomy')) {
return FALSE;
}
//code lovingly inspired by the image.module w/ code by drewish
$vid = variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '');
if (empty($vid) || !taxonomy_vocabulary_load($vid)) {
$sql = "SELECT vid FROM {vocabulary} WHERE module='userpoints'";
$vid = db_result(db_query($sql));
if (!$vid) {
drupal_set_message(t("Created Userpoints vocabulary"));
//No vocabulary exists, we'll create one
$vocab = array(
'name' => t(USERPOINTS_CATEGORY_NAME),
'description' => t('Automatically created by the userpoints module'),
'multiple' => '0',
'required' => '0',
'hierarchy' => '1',
'relations' => '0',
'module' => 'userpoints',
);
taxonomy_save_vocabulary($vocab);
$vid = $vocab['vid'];
}
variable_set(USERPOINTS_CATEGORY_DEFAULT_VID, $vid);
}
if (!is_numeric($vid)) {
watchdog('userpoints', 'userpoints module was unable to select or create a vocabulary. !Points will be uncategorized', array(), WATCHDOG_ERROR);
}
return $vid;
}