'fieldset',
'#title' => t('!Points Cap', userpoints_translation()),
'#description' => t('Maximum number of !points allowed for each user.', userpoints_translation()),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form[$group][USERPOINTS_CAP_MAXIMUM] = array(
'#type' => 'textfield',
'#title' => t('Maximum !Points per User', userpoints_translation()),
'#default_value' => t(variable_get(USERPOINTS_CAP_MAXIMUM, USERPOINTS_CAP_MAXIMUM_DEFAULT), userpoints_translation()),
);
$form[$group][USERPOINTS_CAP_MESSAGE] = array(
'#type' => 'textarea',
'#title' => t('Maximum !Points Exceeded Message', userpoints_translation()),
'#default_value' => t(variable_get(USERPOINTS_CAP_MESSAGE, USERPOINTS_CAP_MESSAGE_DEFAULT), userpoints_translation()),
'#description' => t('The message a user will see if they exceed the cap. Insert '.'!'.'Points to use the branded name of your points.', userpoints_translation()),
);
return $form;
break;
case 'points before':
$current_points = userpoints_get_current_points($uid, 'all');
$new_points = $params['points'];
$max_points = variable_get(USERPOINTS_CAP_MAXIMUM, USERPOINTS_CAP_MAXIMUM_DEFAULT);
if ($current_points + $new_points > $max_points) {
drupal_set_message(variable_get(USERPOINTS_CAP_MESSAGE, USERPOINTS_CAP_MESSAGE_DEFAULT));
return FALSE; // DO NOT add points
} else {
return TRUE; // OK to add points
}
break;
}
}