Same name and namespace in other branches
  1. 4.6.x modules/profile.module \profile_view_profile()
  2. 5.x modules/profile/profile.module \profile_view_profile()
  3. 6.x modules/profile/profile.module \profile_view_profile()

File

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

Code

function profile_view_profile($user) {
  profile_load_profile($user);

  // Show private fields to administrators and people viewing their own account.
  if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) {
    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', PROFILE_HIDDEN);
  }
  else {
    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN);
  }
  while ($field = db_fetch_object($result)) {
    if ($value = profile_view_field($user, $field)) {
      $description = $field->visibility == PROFILE_PRIVATE ? t('The content of this field is private and only visible to yourself.') : '';
      $title = $field->type != 'checkbox' ? check_plain($field->title) : NULL;
      $item = array(
        'title' => $title,
        'value' => $value,
        'class' => $field->name,
      );
      $fields[$field->category][] = $item;
    }
  }
  return $fields;
}