﻿### Eclipse Workspace Patch 1.0
#P realname-6
Index: contrib/realname_generate.test
===================================================================
RCS file: contrib/realname_generate.test
diff -N contrib/realname_generate.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/realname_generate.test	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,189 @@
+<?php
+// $Id: realname_generate.test,v .1$
+
+/*
+ * @TODO Finish and fix these tests. They will not work yet.
+ * Simple test for the realname_generate module. 
+ */
+class RealNameGenerateTestCase extends DrupalWebTestCase {
+  /**
+   * Implementation of getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      'name' => t('RealName username generation.'),
+      'description' => t('Test the realname generate registration module.'),
+      'group' => t('RealName'),
+    );
+  }
+
+  /**
+   * Implementation of setUp().
+   */
+  function setUp() {
+    parent::setUp('profile');
+    parent::setUp('content_profile');
+    parent::setUp('realname');
+    parent::setUp('realname_generate');
+
+    $privileged_user = $this->drupalCreateUser(array('change own username', 'administer users'));
+    $this->drupalLogin($privileged_user);
+    
+    // Configure to allow set password.
+    variable_set('user_email_verification', FALSE);
+    
+    // Enable realname generation
+    variable_set('realname_generate_username', TRUE);
+
+    // Create Profile fields
+    
+    // Create Content profile node type
+    
+    // Create Content profile fields
+
+  }
+
+  /**
+   * Test content_profile registration for anonymous users.
+   */
+  function testContenProfileAnonRegistration() {
+    // Enable content profile fields on registration
+    
+  
+  
+    // Set some realname content profile fields
+    variable_set('realname_fields', array('field_fname'=> -10, 'field_lname'=> -5));
+    
+   // Set realname to use the content profile module.
+   variable_set('realname_profile_module', 'content_profile'); 
+
+    // Try to register an anon user with content profile fields.
+    $email = $this->randomName();
+    $fname = $this->randomName();
+    $lname = $this->randomName();
+    $pass = $this->randomName(10);
+    $register = array(
+      'mail' => $email .'@example.com',
+      'pass[pass1]' => $pass,
+      'pass[pass2]' => $pass,
+      'field_fname' => $fname,
+      'field_lname' => $lname,
+    );  
+
+    
+    
+    $this->drupalPost('/user/register', $register, t('Create new account'));
+
+    $login = array(
+      'name' => $fname . '.' . $lname,
+      'pass' => $pass,
+    );
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertRaw('<h2>'. $name .'</h2>', t('User properly created, logged in.'));
+  }
+
+  /**
+   * Test content_profile registration for admin users.
+   */
+  function testContenProfileAdminRegistration() {
+    // Set some realname content profile fields
+    variable_set('realname_fields', array('field_fname'=> -10, 'field_lname'=> -5));
+    
+    // Set realname to use the content profile module.
+    variable_set('realname_profile_module', 'content_profile');  
+
+    // Try to register an admin user with content profile fields.
+    $email = $this->randomName();
+    $fname = $this->randomName();
+    $lname = $this->randomName();
+    $pass = $this->randomName(10);
+    $register = array(
+      'mail' => $email .'@example.com',
+      'pass[pass1]' => $pass,
+      'pass[pass2]' => $pass,
+      'field_fname' => $fname,
+      'field_lname' => $lname,
+    );    
+    
+    $this->drupalPost('admin/user/user/create', $register, t('Create new account'));
+
+    $login = array(
+      'name' => $fname . '.' . $lname,
+      'pass' => $pass,
+    );
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertRaw('<h2>'. $name .'</h2>', t('User properly created, logged in.'));
+  }
+  
+  /**
+   * Test profile registration for anonymous users.
+   */
+  function testProfileAnonRegistration() {
+    // Set some realname profile fields
+    variable_set('realname_fields', array('profile_fname'=> 0, 'profile_lname'=>0));  
+    
+    // Set realname to use the profile module.
+    variable_set('realname_profile_module', 'profile');
+
+    // Try to register an anon user with profile fields.
+    $email = $this->randomName();
+    $fname = $this->randomName();
+    $lname = $this->randomName();
+    $pass  = $this->randomName(10);
+    $register = array(
+      'mail' => $email .'@example.com',
+      'pass[pass1]'   => $pass,
+      'pass[pass2]'   => $pass,
+      'profile_fname' => $fname,
+      'profile_lname' => $lname,
+    );
+
+    
+    
+    $this->drupalPost('/user/register', $register, t('Create new account'));
+
+    $login = array(
+      'name' => $fname . '.' . $lname,
+      'pass' => $pass,
+    );
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertRaw('<h2>'. $name .'</h2>', t('User properly created, logged in.'));
+  }
+  
+    /**
+   * Test profile registration for admin users.
+   */
+  function testProfileAdminRegistration() {
+    // Set some realname profile fields
+    variable_set('realname_fields', array('profile_fname'=> 0, 'profile_lname'=>0));   
+    
+    // Set realname to use the profile module.
+    variable_set('realname_profile_module', 'profile');
+	
+    
+    // Try to register an admin user with profile fields.
+    $email = $this->randomName();
+    $fname = $this->randomName();
+    $lname = $this->randomName();
+    $pass  = $this->randomName(10);
+    $register = array(
+      'mail' => $email .'@example.com',
+      'pass[pass1]'   => $pass,
+      'pass[pass2]'   => $pass,
+      'profile_fname' => $fname,
+      'profile_lname' => $lname,
+    );
+
+    
+    
+    $this->drupalPost('admin/user/user/create', $register, t('Create new account'));
+
+    $login = array(
+      'name' => $fname . '.' . $lname,
+      'pass' => $pass,
+    );
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertRaw('<h2>'. $name .'</h2>', t('User properly created, logged in.'));
+  }
+  
+}
Index: contrib/realname_generate.install
===================================================================
RCS file: contrib/realname_generate.install
diff -N contrib/realname_generate.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/realname_generate.install	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,25 @@
+<?php
+// $Id: realname_generate.install,v .4
+
+/**
+ * @file
+ *   Uninstall realname_generate module.
+ *
+ */
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function realname_generate_uninstall() {
+  variable_del('realname_generate_username');
+  variable_del('realname_generate_pattern');
+  variable_del('realname_generate_separator');
+  variable_del('realname_generate_replace_spaces');
+  variable_del('realname_generate_update_names');
+}
+
+function realname_generate_update_1() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {system} SET weight = 0 WHERE name = 'realname_generate'");
+  return $ret;
+}
Index: contrib/realname_generate.module
===================================================================
RCS file: contrib/realname_generate.module
diff -N contrib/realname_generate.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/realname_generate.module	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,390 @@
+<?php
+// $Id: realname_generate.module $
+
+/**
+ * @file
+ * Generates a username from fields on the registration page.
+ */
+
+define(REALNAME_MODULE, variable_get('realname_profile_module', ''));
+
+/**
+ * Implementation of hook_menu_alter().
+ * Remember to clear the menu cache after adding/editing this function.
+ */
+function realname_generate_menu_alter(&$items) {
+  $items['admin/user/realname/generate/setup'] = array(
+    'title' => 'Username generation',
+    'access arguments' => array('administer users'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('realname_generate_admin'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+  );
+  return $items;
+}
+
+/**
+ * Callback for the local task item.
+ */
+function realname_generate_admin() {
+  $form = array();
+  if (count($realname_fields = variable_get('realname_fields', array()))) {
+    drupal_add_js(drupal_get_path('module', 'realname_generate') .'/realname_generate.js');
+    //Username settings.
+    $form['realname_generate_username'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => '<strong>'. t('Generate username from RealName') .'</strong>',
+      '#description'   => t('If this option is selected, the RealName will be used to automatically generate a username.'),
+      '#default_value' => variable_get('realname_generate_username', FALSE),
+      '#weight'        => -10,
+    );
+    $form['realname_generate_options'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Settings'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+    );
+    $form['realname_generate_options']['realname_generate_pattern'] = array(
+      '#type'          => 'radios',
+      '#title'         => t('Username Pattern'),
+      '#options'       => array(0 => 'RealName pattern', 1 => 'Simple Separator'),
+      '#description'   => t('NOT YET IMPLEMENTED: Whether or not to use the RealName pattern, or a simple separator between fields. A RealName pattern might contain spaces or other characters that you might not want as a part of a username.'),
+      '#default_value' => variable_get('realname_generate_pattern', 1),
+      '#disabled'      => TRUE,
+    );
+    $form['realname_generate_options']['realname_generate_separator'] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Username Separator'),
+      '#size'          => 1,
+      '#description'   => t('Enter a character to put between the RealName fields in the username.'),
+      '#default_value' => variable_get('realname_generate_separator', '.'),
+    );
+    $form['realname_generate_options']['realname_generate_replace_spaces'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Replace whitespace characters'),
+      '#description'   => t('If this option is selected, all whitespace characters will be replaced by the separator.'),
+      '#default_value' => variable_get('realname_generate_replace_spaces', TRUE),
+      '#prefix'        => t('<strong>Other settings</strong>'),
+    );
+    $form['realname_generate_options']['realname_generate_update_names'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Update username when RealName is updated.'),
+      '#description'   => t('If this option is selected, the username will be regenerated when the RealName is updated.'),
+      '#default_value' => variable_get('realname_generate_update_names', TRUE),
+    );
+    $form['submit'] = array(
+      '#type' => 'submit',
+      '#value' => t('Save'),
+    );
+    return $form;
+  }
+  else {
+    //Need to select fields
+    $module = variable_get('realname_profile_module', NULL);
+    if (!$module) {
+      drupal_goto('admin/user/realname/module');
+    }
+    else {
+      drupal_goto('admin/user/realname/fields');
+    }
+  }
+}
+
+/**
+ * Sumbit handler for the settings.
+ */
+function realname_generate_admin_submit($form, &$form_state) {
+  // Save all the settings,.
+  variable_set('realname_generate_username', $form_state['values']['realname_generate_username']);
+  variable_set('realname_generate_pattern', $form_state['values']['realname_generate_pattern']);
+  variable_set('realname_generate_separator', $form_state['values']['realname_generate_separator']);
+  variable_set('realname_generate_replace_spaces', $form_state['values']['realname_generate_replace_spaces']);
+  variable_set('realname_generate_update_names', $form_state['values']['realname_generate_update_names']);
+  drupal_set_message(t('Configuration has been updated.'), 'status');
+}
+
+/**
+ * Implementation of hook_user().
+ * Borrowed from the auto_username module and email_registration (hat tips to Crell and Chris Herberte)
+ */
+function realname_generate_user($op, &$edit, &$account, $category = NULL) {
+  if (variable_get('realname_generate_username', FALSE)!== 0) {
+    static $new_name;
+    switch ($op) {
+      case 'validate':
+        $names = module_invoke_all('realname_generate', $edit, $account);
+        // Remove any empty entries
+        $names = array_filter($names);
+        if (empty($names)) {
+          // Generate the new username.
+          $new_name = realname_generate_make_name($account->uid, $edit);
+          // Validate the generated username.
+          if ($error = user_validate_name($new_name) && !is_numeric(arg(1))) {
+            form_set_error('name', $error);
+          }
+        }
+        else {
+          // One would expect a single implementation of the hook, but if there
+          // are multiples out there use the last one
+          $new_name = array_pop($names);
+        }
+        $_SESSION['realname_generate']['new_name'] = $new_name;
+        break;
+      case 'insert':
+        if (realname_generate_update_name($account->uid, $new_name)) {
+          $edit['name'] = $new_name;
+        }
+        // if email verification is off and a new user is the one creating account, log the new user in with correct name
+        global $user;
+        if (!variable_get('user_email_verification', 1) && $user->uid == 0) {
+          $user = $account;
+          $user->name = $new_name;
+        }
+        $account->name = $new_name;
+        break;
+      case 'update':
+        // Clear out changes to the user form so that the data column doesn't get full of cruft
+        $edit['realname_generate_username'] = NULL;
+        $edit['realname_generate_name'] = NULL;
+        break;
+      case 'after_update':
+        // If a user has updated their realname, we want to update their username.
+        // This will only work if using the profile module
+        if (arg(3) && REALNAME_MODULE === 'profile' &&
+            variable_get('realname_generate_update_names', FALSE) !== FALSE) {
+          realname_generate_update_name($account->uid, $new_name);
+        }
+        _realname_generate_destroy_session();
+        break;
+    }
+  }
+}
+
+/**
+ * Implementation of hook_nodeapi().
+ * If using the content_profile module, you can update username automatically when a profile field is updated.
+ * @TODO figure out what to do if an there is a validation error when re-generating a username.
+ */
+function realname_generate_nodeapi(&$node, $op) {
+  if ($op === 'update' && REALNAME_MODULE === 'content_profile' &&
+      variable_get('realname_generate_username', NULL) &&
+      $node->type === variable_get('realname_profile_type', NULL) &&
+      variable_get('realname_generate_update_names', NULL) &&
+      $new_name = realname_generate_make_name($node->uid, $node)) {
+    // Validate the generated username.
+    if ($error = user_validate_name($new_name)) {
+      // There was a validation problem with the new username, so it was not updated
+      $author = user_load($node->uid);
+      watchdog('realname_generate', 'There was an error re-generating a new username for %author' , array('%author' => $author->name ), WATCHDOG_ERROR);
+    }
+    realname_generate_update_name($node->uid, $new_name);
+  }
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function realname_generate_form_alter(&$form, &$form_state, $form_id) {
+  if (variable_get('realname_generate_username', FALSE) !== 0) {
+    switch ($form_id) {
+      case 'user_register':
+      case 'user_profile_form':
+        $username = array();
+        $admin_generate = array();
+        $username['#required'] = FALSE;
+
+        $_SESSION['realname_generate']['temp_name'] = user_password(10);
+
+        // If we use element_validate instead of a full form validation, the user profile's path alias is not generated.
+        // And hook_user op validate has not run before we get to our custom validation, thus the session is not filled with the
+        // generated username.
+
+        // Validation attempts...
+        //$username['#element_validate'][] = 'realname_generate_user_name_validate';
+        // Unset the normal validation, and redo it in our own custom validation callback.
+        //unset($form['#validate'][array_search('user_register_validate', $form['#validate'])]);
+        //$form['#validate'][] = 'realname_generate_user_form_validate';
+        //
+        // If the user is allowed to edit usernames
+        if (user_access('change own username') && is_numeric(arg(1)) && arg(3) != 'create') {
+          // Add javascript to toggle the enable/disable the username field.
+          drupal_add_js(drupal_get_path('module', 'realname_generate') .'/realname_generate.js');
+          $output = t('If you check this, a username will be generated automatically. If you wish to edit the username, uncheck this option.');
+          // An adminisration can change the realname defaults
+          if (user_access('administer users')) {
+            $output .= ' '. t('To control the format of the generated username, see the <a href="@realname_generate">RealName generate settings</a>.',
+              array('@realname_generate' => url('admin/user/realname/generate')));
+          }
+          $admin_generate['realname_generate_username'] = array(
+            '#type' => 'checkbox',
+            '#title' => t('Automatically generate a username.'),
+            '#default_value' => TRUE,
+            '#description' => $output,
+            '#weight' => -2,
+          );
+          // Get the generated name
+          $new_name = realname_generate_make_name(arg(1), $form_state);
+          $_SESSION['realname_generate']['new_name'] = $new_name;
+
+          $admin_generate['realname_generate_name'] = array(
+            '#weight' => -1,
+            '#type' => 'hidden',
+            '#prefix' => '<div id="generated-realname"><small>'. t('Your generated username will be:') .' <span>',
+            '#value'  => check_plain($new_name),
+            '#suffix' => check_plain($new_name) .'</span></small></div>',
+          );
+          // Add validation only to the name element. This is where we will add their realname as the username.
+          $username['#element_validate'][] = 'realname_generate_user_name_validate';
+        }
+        elseif (arg(0) == 'admin' && arg(2)== 'user' && arg(3) == 'create') {
+          $output = t('The username will be generated automatically.');
+          $output .= ' '. t('To control the format of the generated username, or disable automatic generation, see the <a href="@realname_generate">RealName Generate settings</a>.',
+              array('@realname_generate' => url('admin/user/realname/generate')));
+          $admin_generate['realname_generate_info'] = array(
+            '#value' => $output,
+            '#type'  => 'markup',
+            '#weight' => -1,
+          );
+          //drupal_set_message($output);
+          $username['#type']  = 'hidden';
+          $username['#value'] = $_SESSION['realname_generate']['temp_name'];
+        }
+        else {
+          // Hide the username field
+          $username['#type']  = 'hidden';
+          // If we use element_validate instead of a full form validation, the user profile's path alias is not generated.
+          // And hook_user op vallidate has not run before we get to our custom validation, thus the session is not filled with the
+          // generated username.
+          $form['#validate'][] = 'realname_generate_user_form_validate';
+
+          //Finally, set the username value to some temporary random string so that we can get past other validation.
+          $username['#value'] = $_SESSION['realname_generate']['temp_name'];
+        }
+        if (!arg(3) || arg(3) === 'create') {
+          // Does the form have $form['account']?
+          $account = isset($form['account']) && is_array($form['account']) ? TRUE: FALSE;
+          if ($account) {
+            $form['account']['name'] = array_merge($form['account']['name'], $username);
+            if (count($admin_generate)) {
+              $form['account'] = array_merge($form['account'], $admin_generate);
+            }
+          }
+          else {
+            $form['name'] = array_merge($form['name'], $username);
+            if (count($admin_generate)) {
+              $form = array_merge($form, $admin_generate);
+            }
+          }
+        }
+        break;
+    }
+    return $form;
+  }
+}
+
+/**
+ * Validation function is used to set the username to the realname fields entered on the previous screen.
+ *
+ */
+function realname_generate_user_form_validate($form, &$form_state) {
+  _realname_generate_user_validate($form, $form_state);
+}
+
+/**
+ * Element validation callback function that is used to set the username to the realname.
+ *
+ */
+function realname_generate_user_name_validate($element, &$form_state) {
+  _realname_generate_user_validate($element, $form_state);
+}
+
+/**
+ * Basic validation function is used by #validate and #element_validate.
+ *
+ */
+function _realname_generate_user_validate($form, &$form_state) {
+  if ($form_state['values']['realname_generate_username'] &&
+      empty($_SESSION['realname_generate']['new_name'])) {
+    $form_state['values']['name'] = $form_state['values']['realname_generate_name'];
+  }
+  if (($form_state['values']['realname_generate_username'] ||
+      $form_state['values']['name'] === $_SESSION['realname_generate']['temp_name']) &&
+      !empty($_SESSION['realname_generate']['new_name'])) {
+    $form_state['values']['name'] = $_SESSION['realname_generate']['new_name'];
+  }
+}
+
+/**
+ * A helper function to generate the username from the realname fields.
+ *
+ */
+function realname_generate_make_name($uid, &$edit) {
+  $new_name = '';
+  // Find the fields on to generate the username from.
+  $fields = variable_get('realname_fields', array());
+  $separator = variable_get('realname_generate_separator', '.');
+
+  // Which pattern are we using to generate the realname? NOT YET ENABLED
+  //$pattern = variable_get('realname_generate_pattern', 1);
+
+  // @TODO
+  // Turn this into hooks with a module_invoke_all, and write default hooks for content_profile and profile
+
+  if (arg(0) == 'user' && is_numeric(arg(1)) &&  arg(2) == 'edit' && !arg(3)) {
+    if (!($edit['submitted'])) {
+      $edit['_account'] = user_load($uid);
+    }
+    $new_name = $edit['_account']->realname;
+  }
+  else {
+    if (REALNAME_MODULE === 'profile') {
+      foreach ($fields as $key => $values) {
+        $new_name .= $edit[$key] . $separator;
+      }
+    }
+    elseif (REALNAME_MODULE === 'content_profile') {
+      $temp =  is_object($edit) ? get_object_vars($edit) : $edit;
+      foreach ($fields as $key => $values) {
+        if ($temp[$key] && isset($temp[$key][0]['value'])) {
+          $new_name .= $temp[$key][0]['value'] . $separator;
+        }
+      }
+    }
+    // Remove the separator from the ending of the generated username.
+    $new_name =  drupal_substr($new_name, 0, -abs(drupal_strlen($separator)));
+  }
+  if ($new_name) {
+    // Replace any space characters with the separator
+    if (variable_get('realname_generate_replace_spaces', FALSE)!== 0) {
+      $new_name = preg_replace('/\s+/', $separator,  $new_name);
+    }
+
+    // Add a serial to the name for uniqueness.
+    $counter = 1;
+    $base_name = $new_name;
+    $sql = "SELECT COUNT(uid) FROM {users} WHERE uid <> %d AND LOWER(name) = LOWER('%s')";
+    while ($result = db_result(db_query($sql, $uid, $new_name)) > 0) {
+      $new_name = $base_name . $separator . $counter++;
+    }
+    return trim($new_name);
+  }
+}
+
+/**
+ * A helper function to update the realname in to the database.
+ *
+ */
+function realname_generate_update_name($uid, $new_name) {
+  if (db_query("UPDATE {users} SET name='%s' WHERE uid=%d", array($new_name, $uid))) {
+    return TRUE;
+  }
+}
+
+/**
+ * A helper function to update the realname in to the database.
+ *
+ */
+function _realname_generate_destroy_session() {
+  unset($_SESSION['realname_generate']);
+}
Index: contrib/realname_generate.js
===================================================================
RCS file: contrib/realname_generate.js
diff -N contrib/realname_generate.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/realname_generate.js	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,47 @@
+// $Id: realname_generate.js .1 
+
+// Username field manipulation, borrowed from pathautho...
+// Using readonly instead of disabled because of http://drupal.org/node/227966
+Drupal.behaviors.realname_generate_edit = function() {
+  if ($("#edit-realname-generate-username").size() && $("#edit-realname-generate-username").attr("checked")) {
+    // Disable input and hide its description.
+    $("#edit-name").attr("readonly","readonly");
+    $("#edit-name").css({'background-color' : '#F0F0F0'})
+    $("#edit-name-wrapper > div.description").hide(0);
+  }
+  $("#edit-realname-generate-username").bind("click", function() {
+    if ($("#edit-realname-generate-username").attr("checked")) {
+      // Auto-generate checked; disable input.
+      $("#edit-name").attr("readonly","readonly");
+      $("#edit-name").css({'background-color' : '#F0F0F0'})
+      $("#edit-name-wrapper > div[class=description]").slideUp('fast');
+    }
+    else {
+      // Auto-alias unchecked; enable input.
+      $("#edit-name").removeAttr("readonly");
+      $("#edit-name").css({'background-color' : '#FFF'})
+      $("#edit-name")[0].focus();
+      $("#edit-name-wrapper > div[class=description]").slideDown('fast');
+    }
+  });
+}
+
+Drupal.behaviors.realname_generate_pattern = function() {
+  if ($("#edit-realname-generate-pattern-0").attr("checked")) {
+    // Disable input and hide its description.
+    $("#edit-realname-generate-separator").attr("disabled","disabled");
+    $("edit-realname-generate-separator-wrapper").hide(0);
+  }
+  $("input[name='realname_generate_pattern']").bind("click", function() {
+    if ($("#edit-realname-generate-pattern-0").attr("checked")) {
+      // RealName pattern selected; disable input.
+      $("#edit-realname-generate-separator").attr("disabled","disabled");
+      $("#edit-realname-generate-separator-wrapper").slideUp('fast');
+    }
+    else {
+      // Simple separtator selected
+      $("#edit-realname-generate-separator").removeAttr("disabled");
+      $("#edit-realname-generate-separator-wrapper").slideDown('fast');
+    }
+  });
+}
Index: contrib/realname_generate.info
===================================================================
RCS file: contrib/realname_generate.info
diff -N contrib/realname_generate.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/realname_generate.info	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+; $Id: generate_username.info,v .3
+name = "RealName Generatate"
+description = "Username Generation based on RealName."
+core = 6.x
+dependencies[] = realname
