user.inc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * User module integration.
  5. */
  6. /**
  7. * Implements hook_custom_formatters_devel_generate_info() on behalf of
  8. * user.module.
  9. */
  10. function user_custom_formatters_devel_generate_info() {
  11. return array(
  12. 'user' => array(
  13. 'process callback' => 'custom_formatters_user_devel_generate_process',
  14. ),
  15. );
  16. }
  17. /**
  18. * Process callback for User Devel Generate integration.
  19. */
  20. function custom_formatters_user_devel_generate_process($form_state) {
  21. module_load_include('inc', 'devel_generate', 'devel_generate');
  22. $url = parse_url($GLOBALS['base_url']);
  23. $object = new stdClass();
  24. $object->uid = mt_rand(3, 100);
  25. $object->name = devel_generate_word(mt_rand(6, 12));
  26. $object->pass = user_password();
  27. $object->mail = "{$object->name}@{$url['host']}";
  28. $object->status = 1;
  29. $object->created = 1;
  30. $object->roles = drupal_map_assoc(array(DRUPAL_AUTHENTICATED_RID));
  31. $object->language = LANGUAGE_NONE;
  32. // Populate all core fields on behalf of field.module
  33. module_load_include('inc', 'devel_generate', 'devel_generate.fields');
  34. devel_generate_fields($object, 'user', 'user');
  35. return $object;
  36. }