function realname_admin_fields in Real Name 6
1 string reference to 'realname_admin_fields'
- realname_menu in ./
realname.module - Implements hook_menu().
File
- ./
realname.admin.inc, line 298 - 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_fields() {
$form = array();
$module = variable_get('realname_profile_module', NULL);
// Do we have a module set yet?
if (!$module) {
drupal_goto('admin/user/realname/module');
}
$module_info = $module ? realname_supported_modules($module) : NULL;
if (isset($module_info['fields']) && !$module_info['fields']) {
$form['heading'] = array(
'#type' => 'item',
'#value' => t("You are using the %module module to provide data and it doesn't utilize fields.", array(
'%module' => $module,
)),
);
return $form;
}
if (isset($module_info['file'])) {
$path = !empty($module_info['path']) ? $module_info['path'] : drupal_get_path('module', $module);
require_once $path . '/' . $module_info['file'];
}
$current = variable_get('realname_fields', array());
$type = !isset($module_info['type']) || !$module_info['type'] ? variable_get('realname_profile_type', NULL) : NULL;
$profile_fields = (array) module_invoke($module, 'realname_get_fields', $current, $type);
$what = t('You are using the %module module to provide fields.', array(
'%module' => $module,
));
if ($type) {
$what .= t('The %type type is the source of data.', array(
'%type' => $type,
));
}
$form['heading'] = array(
'#type' => 'item',
'#value' => $what,
);
$fields = $profile_fields['fields'];
uasort($fields, '_realname_sort');
$links = $profile_fields['links'];
asort($links);
$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('This 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'),
);
// If there were any URL fields, give a home page option.
$form['homepage'] = array(
'#type' => 'fieldset',
'#title' => t('Homepage options'),
'#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.'),
'#collapsible' => TRUE,
'#collapsed' => count($links) == 0,
'#access' => !empty($links),
);
$form['homepage']['realname_homepage'] = array(
'#type' => 'select',
'#options' => array(
'' => t('- None -'),
) + $links,
'#title' => t('Link to homepage'),
'#description' => t('Select a personal homepage link, if appropriate.'),
'#default_value' => variable_get('realname_homepage', ''),
);
$form['homepage']['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;
}