You are here

function user_relationships_type_edit_validate in User Relationships 5

Same name and namespace in other branches
  1. 5.2 user_relationships_actions.inc \user_relationships_type_edit_validate()

Validate the submitted relationship type

File

./user_relationships_actions.inc, line 11

Code

function user_relationships_type_edit_validate($form_id, &$form_values) {
  if ($form_values['relationship_type']->rtid && db_result(db_query("SELECT name FROM {user_relationship_types} WHERE LOWER(`name`) = LOWER('%s') AND rtid != %d", $form_values['name'], $form_values['relationship_type']->rtid)) || !$form_values['relationship_type']->rtid && db_result(db_query("SELECT name FROM {user_relationship_types} WHERE LOWER(`name`) = LOWER('%s')", $form_values['name']))) {
    form_set_error('name', t('%name has already been used.', array(
      '%name' => $form_values['name'],
    )));
  }
  $expire = $form_values['expires_val'];
  if (!is_numeric($expire) || (int) $expire < 0) {
    form_set_error('expires_val', t('Expiration period must be an integer greater than or equal to 0.'));
  }
}