Same name and namespace in other branches
- 4.7.x modules/profile.module \profile_form_profile()
- 5.x modules/profile/profile.module \profile_form_profile()
- 6.x modules/profile/profile.module \profile_form_profile()
File
- modules/
profile.module, line 253 - Support for configurable user profiles.
Code
function profile_form_profile($edit, $user, $category) {
if ($_GET['q'] == 'user/register' ? 1 : 0) {
$result = db_query('SELECT * FROM {profile_fields} WHERE register = 1 ORDER BY category, weight');
}
else {
$result = db_query("SELECT * FROM {profile_fields} WHERE LOWER(category) = LOWER('%s') ORDER BY weight", $category);
// We use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues.
}
$fields = array();
while ($field = db_fetch_object($result)) {
$category = $field->category;
switch ($field->type) {
case 'textfield':
case 'url':
$fields[$category] .= form_textfield(check_plain($field->title), $field->name, $edit[$field->name], 70, 255, _profile_form_explanation($field), NULL, $field->required);
break;
case 'textarea':
$fields[$category] .= form_textarea(check_plain($field->title), $field->name, $edit[$field->name], 70, 5, _profile_form_explanation($field), NULL, $field->required);
break;
case 'list':
$fields[$category] .= form_textarea(check_plain($field->title), $field->name, $edit[$field->name], 70, 5, _profile_form_explanation($field), NULL, $field->required);
break;
case 'checkbox':
$fields[$category] .= form_checkbox(check_plain($field->title), $field->name, 1, $edit[$field->name], _profile_form_explanation($field), NULL, $field->required);
break;
case 'selection':
$options = array(
'--',
);
$lines = split("[,\n\r]", $field->options);
foreach ($lines as $line) {
if ($line = trim($line)) {
$options[$line] = $line;
}
}
$fields[$category] .= form_select(check_plain($field->title), $field->name, $edit[$field->name], $options, _profile_form_explanation($field), 0, 0, $field->required);
break;
case 'date':
$fields[$category] .= _profile_date_field($field, $edit);
break;
}
}
if ($fields) {
foreach ($fields as $category => $data) {
$output[] = array(
'title' => $category,
'data' => $data,
);
}
return $output;
}
}