function i18nprofile_view_profile in Internationalization 5.3
Same name and namespace in other branches
- 5 i18nprofile/i18nprofile.module \i18nprofile_view_profile()
- 5.2 i18nprofile/i18nprofile.module \i18nprofile_view_profile()
Show user profile with translated fields and categories
From profile_view_profile, rewritten for translations
File
- i18nprofile/
i18nprofile.module, line 104
Code
function i18nprofile_view_profile($user) {
$language = i18n_get_lang();
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 p.*, t.title AS translation_title, t.options AS translation_options FROM {profile_fields} p LEFT JOIN {i18n_profile_fields} t ON p.fid = t.fid AND t.language = '%s' WHERE p.visibility != %d ORDER BY p.category, p.weight", $language, PROFILE_HIDDEN);
}
else {
$result = db_query("SELECT p.*, t.title AS translation_title, t.options AS translation_options FROM {profile_fields} p LEFT JOIN {i18n_profile_fields} t ON p.fid = t.fid AND t.language = '%s' WHERE visibility != %d AND visibility != %d ORDER BY category, weight", $language, PROFILE_PRIVATE, PROFILE_HIDDEN);
}
$translation = i18nprofile_categories(TRUE);
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->translation_title ? $field->translation_title : $field->title;
$title = $field->type != 'checkbox' ? check_plain($title) : NULL;
if ($field->type == 'selection' && ($options = unserialize($field->translation_options))) {
$value = isset($options[$value]) ? $options[$value] : $value;
}
$item = array(
'title' => $title,
'value' => $value,
'class' => $field->name,
'weight' => $field->weight,
);
if ($category = $translation[check_plain($field->category)]) {
$fields[$category][] = $item;
}
else {
$fields[$field->category][] = $item;
}
}
}
return $fields;
}