You are here

genpass.module in Generate Password 5

Same filename and directory in other branches
  1. 8 genpass.module
  2. 6 genpass.module
  3. 7.2 genpass.module
  4. 7 genpass.module

File

genpass.module
View source
<?php

/**
 * Remove the require on the password, on user creation.
 */
function genpass_form_alter($form_id, &$form) {
  if ($form_id == 'user_register') {
    if ($form['pass']) {
      $form['pass']['#required'] = FALSE;
      $form['#validate']["genpass_register_validate"] = array();
    }
    else {
      if ($form['account']['pass']) {
        $form['account']['pass']['#required'] = FALSE;
        $form['#validate']["genpass_register_validate2"] = array();
      }
    }
  }
}
function genpass_register_validate($form_id, $form_values, $form) {

  //  drupal_set_message("genpass_register_validate: " . print_r($form_values, true));
  if ($form_values['pass'] == '') {
    $pass = user_password();
    form_set_value($form['pass'], $pass);
    drupal_set_message("Generated password");
  }
}
function genpass_register_validate2($form_id, $form_values, $form) {

  //  drupal_set_message("genpass_register_validate: " . print_r($form_values, true));
  if ($form_values['account']['pass'] == '') {
    $pass = user_password();
    form_set_value($form['account']['pass'], $pass);
    drupal_set_message("Generated password.");
  }
}

//
//

//function genpass_register_submit($form_id, &$form_values) {

//  drupal_set_message("genpass_register_submit");
//  $form_values['pass'] = 'foobar';

//}

/**
 * Implementation of hook_user().
 */

//function genpass_user($type, &$edit, &$user, $category = NULL) {

//  // Only generate a password on account creation.
//  if ($type == 'validate' && $category == 'account' && !$user->pass) {
//    if ($edit['pass'] == '') {
//      $edit['pass'] = user_password();
//      drupal_set_message( "Generating password = " . $edit['pass']);

////      drupal_set_message("Generated password.");

//    }
//  }

//}

//

//function genpass_requirements($phase) {

//  $weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'user'"));
//  db_query("UPDATE {system} SET weight = %d WHERE name = 'genpass'", $weight-1);
//  drupal_set_message("moving module to " . ($weight -1));

//}

Functions

Namesort descending Description
genpass_form_alter Remove the require on the password, on user creation.
genpass_register_validate
genpass_register_validate2