profile_view_field

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/profile/profile.module, строка 548

Версии
5 – 6
profile_view_field($user, $field)

Код

<?php
function profile_view_field($user, $field) {
  // Only allow browsing of private fields for admins, if browsing is enabled,
  // and if a user has permission to view profiles. Note that this check is
  // necessary because a user may always see their own profile.
  $browse = user_access('access user profiles')
         && (user_access('administer users') || $field->visibility != PROFILE_PRIVATE)
         && !empty($field->page);

  if ($value = $user->{$field->name}) {
    switch ($field->type) {
      case 'textarea':
        return check_markup($value);
      case 'textfield':
      case 'selection':
        return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
      case 'checkbox':
        return $browse ? l($field->title, 'profile/'. $field->name) : check_plain($field->title);
      case 'url':
        return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
      case 'date':
        $format = substr(variable_get('date_format_short', 'm/d/Y - H:i'), 0, 5);
        // Note: Avoid PHP's date() because it does not handle dates before
        // 1970 on Windows. This would make the date field useless for e.g.
        // birthdays.
        $replace = array('d' => sprintf('%02d', $value['day']),
                         'j' => $value['day'],
                         'm' => sprintf('%02d', $value['month']),
                         'M' => map_month($value['month']),
                         'Y' => $value['year'],
                         'H:i' => NULL,
                         'g:ia' => NULL);
        return strtr($format, $replace);
      case 'list':
        $values = split("[,\n\r]", $value);
        $fields = array();
        foreach ($values as $value) {
          if ($value = trim($value)) {
            $fields[] = $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
          }
        }
        return implode(', ', $fields);
    }
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему