'checkbox', '#title' => ''. t('Show realname in nodes') .'', '#description' => t('If this option is selected, the "Real name" will be used on node displays.'), '#default_value' => variable_get('realname_nodeapi', FALSE), ); if (variable_get('realname_profile_module', NULL) == 'content_profile') { $form['realname_use_title'] = array( '#type' => 'checkbox', '#title' => ''. t('Add node title to available fields') .'', '#description' => t('This option allows you to include the profile title in the list of available fields.'), '#default_value' => variable_get('realname_use_title', FALSE), ); } else { $form['realname_use_title'] = array('#type' => 'value', '#value' => FALSE); } if (module_exists('views')) { $form['realname_view'] = array( '#type' => 'checkbox', '#title' => ''. t('Overwrite user fields in view to show realnames') .'', '#description' => t('This option will overwrite the default user name definition in Views in order to show Realnames without the need to modify Views. Remember to rebuild your Views cache if you change this option.'), '#default_value' => variable_get('realname_view', FALSE), ); } $form['realname_myacct'] = array( '#type' => 'textfield', '#title' => ''. t('Title for own account') .'', '#description' => t('This will be shown instead of "My account" on the user\'s own account pages and in the menu. If it is empty, the user\'s RealName will be shown.'), '#default_value' => variable_get('realname_myacct', t('My account')), ); $form['search'] = array( '#type' => 'fieldset', '#title' => t('Search options'), '#description' => t('These settings control how RealName search will work.'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $search_enable = variable_get('realname_search_enable', FALSE); $user_disable = variable_get('realname_user_disable', FALSE); $form['original_search_enable'] = array('#type' => 'value', '#value' => $search_enable); $form['original_user_disable'] = array('#type' => 'value', '#value' => $user_disable); $form['search']['realname_search_enable'] = array( '#type' => 'checkbox', '#title' => ''. t('Enable realname search') .'', '#description' => t('If this option is selected, the "Real name" searching will be allowed. The menus will be rebuilt if this setting changes.'), '#default_value' => $search_enable, ); $form['search']['realname_user_disable'] = array( '#type' => 'checkbox', '#title' => ''. t('Disable user search') .'', '#description' => t('If this option is selected, the standard "Users" search page will be disabled. The menus will be rebuilt if this setting changes.'), '#default_value' => $user_disable, ); $form['search']['realname_search_login'] = array( '#type' => 'checkbox', '#title' => ''. t('Include login name in search') .'', '#description' => t('Should the "Real name" search also index the login name?'), '#default_value' => variable_get('realname_search_login', FALSE), ); $form['theme'] = array( '#type' => 'fieldset', '#title' => t('Theme_username options'), '#description' => t('These settings control how "theme(\'username\', ...)" will work.'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['theme']['realname_theme'] = array( '#type' => 'checkbox', '#title' => ''. t('Override username theme') .'', '#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['theme']['realname_max_username'] = array( '#type' => 'textfield', '#field_prefix' => ''. t('Maximum allowed username length') .' ', '#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['theme']['realname_notver'] = array( '#type' => 'checkbox', '#title' => ''. t('Show "Not verified" for anonymous users') .'', '#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), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save configuration'), ); return $form; } function realname_admin_general_validate($form, &$form_state) { // If realname_search is not enabled, then we won't disable user_search. if (!$form_state['values']['realname_search_enable'] && $form_state['values']['realname_user_disable']) { form_set_error('realname_user_disable', t('User search disable cannot be used if RealName search is not enabled.')); } } function realname_admin_general_submit($form, &$form_state) { variable_set('realname_nodeapi', $form_state['values']['realname_nodeapi']); variable_set('realname_myacct', $form_state['values']['realname_myacct']); variable_set('realname_search_enable', $form_state['values']['realname_search_enable']); variable_set('realname_user_disable', $form_state['values']['realname_user_disable']); variable_set('realname_search_login', $form_state['values']['realname_search_login']); variable_set('realname_theme', $form_state['values']['realname_theme']); variable_set('realname_max_username', $form_state['values']['realname_max_username']); variable_set('realname_notver', $form_state['values']['realname_notver']); variable_set('realname_use_title', $form_state['values']['realname_use_title']); variable_set('realname_view', $form_state['values']['realname_view']); // Did the admin change the search enable or user disable settings? if ($form_state['values']['original_search_enable'] != $form_state['values']['realname_search_enable'] || $form_state['values']['original_user_disable'] != $form_state['values']['realname_user_disable']) { // Yes, so we have to rebuild the menu. menu_rebuild(); drupal_set_message(t('The menu router has been rebuilt.')); watchdog('RealName', 'User module search disabled.'); } drupal_set_message(t('Configuration saved.')); } function realname_admin_bypass() { $form = array(); $current = variable_get('realname_bypass_forms', array(array('name' => 'comment_form', 'fields' => array('name')))); $rows = count($current); $bypass_list = NULL; foreach ($current as $bypass) { $bypass_list .= $bypass['name'] .' '. implode(' ', $bypass['fields']) ."\n"; } $form['warning'] = array( '#type' => 'markup', '#value' => '
', ); $form['bypass_forms'] = array( '#type' => 'textarea', '#title' => t('Bypass these forms'), '#rows' => max(array($rows + 1, 5)), '#default_value' => $bypass_list, '#description' => t('Enter one form per line. Each line should start with the form name. That should be followed by the name of the field to be reset to the username. If the field is a child field, include its full parent path, separated by spaces. For example: mymodule_form fieldset_1 fieldset_2 name'), '#required' => TRUE, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Bypass these forms'), ); return $form; } function realname_admin_bypass_submit($form, &$form_state) { $bypass_list = explode("\n", $form_state['values']['bypass_forms']); $bypass_forms = array(); foreach ($bypass_list as $line) { $line = trim($line); if ($line) { $pieces = explode(' ', $line); $form_info = array('name' => array_shift($pieces)); $form_info['fields'] = $pieces; $bypass_forms[] = $form_info; } } variable_set('realname_bypass_forms', $bypass_forms); // Mark form for realname recalculation. variable_set('realname_recalculate', TRUE); drupal_set_message(t('Information saved for !count forms.', array('!count' => count($bypass_forms))), 'status'); } function realname_admin_module($form_state) { $form = array(); // Get the list of modules we support. include_once(drupal_get_path('module', 'realname') .'/realname_supported.inc'); $supported_modules = realname_supported_modules(); $choices = $show_types = array(); foreach ($supported_modules as $module => $values) { if (module_exists($module)) { $choices[$module] = check_plain($values['name']); $show_types[$module] = $values['types']; } } $form['show_types'] = array('#type' => 'value', '#value' => $show_types); if (isset($form_state['storage']['module_chosen'])) { $module = $form_state['storage']['module_chosen']; $form['module'] = array( '#type' => 'item', '#value' => t('You have chosen the "@module" module to provide data.', array('@module' => $module)), ); // Now show the types, if appropriate. $button_text = t('Use this content type'); $form['type'] = array( '#type' => 'radios', '#title' => t('Content types available to @module', array('@module' => $module)), '#options' => $form_state['storage']['types'], '#default_value' => variable_get('realname_profile_type', NULL), '#required' => TRUE, ); } else { $button_text = t('Use this module'); $form['module'] = array( '#type' => 'radios', '#title' => t('These modules are available for providing data to RealName'), '#options' => $choices, '#default_value' => variable_get('realname_profile_module', NULL), '#required' => TRUE, ); } $form['submit'] = array( '#type' => 'submit', '#value' => $button_text, ); return $form; } function realname_admin_module_submit($form, &$form_state) { if (isset($form_state['storage']['module_chosen'])) { variable_set('realname_profile_type', $form_state['values']['type']); } else { // First time here, so sav ethe chosen module and prepare types. $module = $form_state['values']['module']; variable_set('realname_profile_module', $module); $form_state['storage']['module_chosen'] = $module; $show_types = $form_state['values']['show_types']; if ($show_types[$module]) { include_once(drupal_get_path('module', 'realname') .'/realname_'. $module .'.inc'); // This module uses types, so let's see what types are allowed. $types = call_user_func('realname_'. $module .'_get_types'); if (count($types) > 1) { $form_state['storage']['types'] = $types; return; } else { variable_set('realname_profile_type', key($types)); } } } // Mark form for realname recalculation. variable_set('realname_recalculate', TRUE); // We are done with types, so go pick fields. unset($form_state['storage']); $form_state['redirect'] = 'admin/user/realname/fields'; // Go get the fields now. return; } function realname_admin_fields() { $form = array(); $current = variable_get('realname_fields', array()); $module = variable_get('realname_profile_module', NULL); $type = variable_get('realname_profile_type', NULL); // Do we have a module set yet? if (!$module) { drupal_goto('admin/user/realname/module'); } $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, ); include_once(drupal_get_path('module', 'realname') .'/realname_'. $module .'.inc'); $profile_fields = call_user_func('realname_'. $module .'_get_fields', $current, $type); $fields = $profile_fields['fields']; uasort($fields, '_realname_sort'); $links = $profile_fields['links']; asort($links); $form['start_table'] = array( '#type' => 'markup', '#value' => '| Select | Field name | Weight |
|---|---|---|
| ', '#suffix' => ' | ', ); $form['field_name_'. $i] = array( '#type' => 'hidden', '#value' => $f_name, ); $form['field_title_'. $i] = array( '#type' => 'item', '#value' => $values['title'], '#prefix' => '', '#suffix' => ' | ', ); $form['field_weight_'. $i] = array( '#type' => 'weight', '#delta' => 10, '#default_value' => $values['weight'], '#prefix' => '', '#suffix' => ' |