You are here

function profile_validate_profile in Drupal 4

Same name and namespace in other branches
  1. 5 modules/profile/profile.module \profile_validate_profile()
  2. 6 modules/profile/profile.module \profile_validate_profile()
1 call to profile_validate_profile()
profile_user in modules/profile.module
Implementation of hook_user().

File

modules/profile.module, line 701
Support for configurable user profiles.

Code

function profile_validate_profile($edit, $category) {
  if (arg(0) == 'user' && arg(1) == 'register') {
    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND register = 1 ORDER BY category, weight', PROFILE_HIDDEN);
  }
  elseif (arg(0) == 'admin' && arg(1) == 'user' && arg(2) == 'create') {
    $result = db_query('SELECT * FROM {profile_fields} WHERE register = 1 ORDER BY category, weight');
  }
  elseif (user_access('administer users')) {
    $result = db_query("SELECT * FROM {profile_fields} WHERE LOWER(category) = LOWER('%s') ORDER BY weight", $category);
  }
  else {
    $result = db_query("SELECT * FROM {profile_fields} WHERE visibility != %d AND LOWER(category) = LOWER('%s') ORDER BY weight", PROFILE_HIDDEN, $category);

    // Use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues.
  }
  while ($field = db_fetch_object($result)) {
    if ($edit[$field->name]) {
      if ($field->type == 'url') {
        if (!valid_url($edit[$field->name], true)) {
          form_set_error($field->name, t('The value provided for %field is not a valid URL.', array(
            '%field' => theme('placeholder', $field->title),
          )));
        }
      }
    }
    else {
      if ($field->required && !user_access('administer users')) {
        form_set_error($field->name, t('The field %field is required.', array(
          '%field' => theme('placeholder', $field->title),
        )));
      }
    }
  }
  return $edit;
}