function realname_admin_settings in Real Name 5
Same name and namespace in other branches
- 6 realname.admin.inc \realname_admin_settings()
Displays the admin settings form.
1 string reference to 'realname_admin_settings'
- realname_menu in ./
realname.module - Implementation of hook_menu().
File
- ./
realname.module, line 467 - The RealName module allows the admin to choose fields from the user profile that will be used to add a "realname" element (method) to a user object. Hook_user is used to automatically add this to any user object that is loaded.
Code
function realname_admin_settings() {
$form = $fields = $links = array();
$current = variable_get('realname_fields', array());
$result = db_query("SELECT * FROM {profile_fields}");
while ($field = db_fetch_array($result)) {
switch ($field['type']) {
case 'textfield':
$name = $field['name'];
$selected = array_key_exists($name, $current);
$fields[$name] = array(
'title' => $field['title'],
'weight' => $selected ? $current[$name] : 0,
'selected' => $selected,
);
break;
case 'url':
$links[$field['name']] = $field['title'];
break;
default:
break;
}
}
uasort($fields, '_realname_sort');
$form['start_table'] = array(
'#type' => 'markup',
'#value' => '<table><tr><th>Select</th><th>Field name</th><th>Weight</th></tr>',
);
$i = 0;
foreach ($fields as $f_name => $values) {
$form['field_select_' . $i] = array(
'#type' => 'checkbox',
'#default_value' => $values['selected'],
'#prefix' => '<tr><td align="center">',
'#suffix' => '</td>',
);
$form['field_name_' . $i] = array(
'#type' => 'hidden',
'#value' => $f_name,
);
$form['field_title_' . $i] = array(
'#type' => 'item',
'#value' => $values['title'],
'#prefix' => '<td>',
'#suffix' => '</td>',
);
$form['field_weight_' . $i] = array(
'#type' => 'weight',
'#delta' => 10,
'#default_value' => $values['weight'],
'#prefix' => '<td>',
'#suffix' => '</td></tr>',
);
++$i;
}
$form['end_table'] = array(
'#type' => 'markup',
'#value' => '</table>',
);
$form['realname_pattern'] = array(
'#type' => 'textfield',
'#field_prefix' => '<strong>' . t('Name Pattern') . '</strong> ',
'#description' => t('The determines how the fields will be used to create the "Real name." Use "%1" to refer to the first field, "%2" to refer to the second, etc..'),
'#size' => 30,
'#default_value' => variable_get('realname_pattern', '%1'),
);
$form['realname_theme'] = array(
'#type' => 'checkbox',
'#title' => '<strong>' . t('Override username theme') . '</strong>',
'#description' => t('If this option is selected, the standard username theme function will be overriden to use the "Real name."'),
'#default_value' => variable_get('realname_theme', TRUE),
);
$form['realname_max_username'] = array(
'#type' => 'textfield',
'#field_prefix' => '<strong>' . t('Maximum allowed username length') . '</strong> ',
'#description' => t('Long usernames may "break" some tables or other displays; this setting limits the maximum length. Note that the core recommendation is 20.'),
'#size' => 6,
'#default_value' => variable_get('realname_max_username', 20),
);
$form['realname_nodeapi'] = array(
'#type' => 'checkbox',
'#title' => '<strong>' . t('Show realname in nodes') . '</strong>',
'#description' => t('If this option is selected, the "Real name" will be used on node displays.'),
'#default_value' => variable_get('realname_nodeapi', FALSE),
);
$form['realname_notver'] = array(
'#type' => 'checkbox',
'#title' => '<strong>' . t('Show "Not verified" for anonymous users') . '</strong>',
'#description' => t('Drupal core adds "Not verified" for anonymous users, this option allows that to be turned off.'),
'#default_value' => variable_get('realname_notver', TRUE),
);
// If there were any URL fields, give a home page option.
if ($links) {
$links[''] = t('');
asort($links);
$form['realname_homepage'] = array(
'#type' => 'select',
'#options' => $links,
'#title' => t('Link to homepage'),
'#description' => t('There were URL fields in the profile. If one of these is a personal homepage link, you may choose to link to it rather than the user profile. Choose which field to use.'),
'#default_value' => variable_get('realname_homepage', NULL),
);
$form['realname_nofollow'] = array(
'#type' => 'checkbox',
'#title' => t('Spam link deterrent'),
'#description' => t('If enabled, Drupal will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links. Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.'),
'#default_value' => variable_get('realname_nofollow', FALSE),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}