You are here

function userpoints_admin_txn_validate in User Points 7

Same name and namespace in other branches
  1. 7.2 userpoints.admin.inc \userpoints_admin_txn_validate()

Validate function for userpoints transaction form.

File

./userpoints.admin.inc, line 290
Admin menu callbacks for userpoints.module.

Code

function userpoints_admin_txn_validate($form, &$form_state) {
  $txn_user = user_load_by_name($form_state['values']['txn_user']);
  if (!is_object($txn_user)) {
    form_set_error('txn_user', t('Specified user does not exist.'));
  }
  else {
    form_set_value($form['txn_user'], $txn_user, $form_state);
  }
  if ((int) $form_state['values']['points'] == 0) {
    form_set_error('points', t('Amount of !points must be a positive or negative number.', userpoints_translation()));
  }
  if (!strtotime($form_state['values']['time_stamp'])) {
    form_set_error('time_stamp', t('The provided timestamp is not a valid date.'));
  }
}