fill_many_users.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php //$id$
  2. /**
  3. * This script contains a data filling procedure for users
  4. * @author Yannick Warnier <yannick.warnier@beeznest.com>
  5. *
  6. */
  7. /**
  8. * Initialisation section
  9. */
  10. require '../../main/inc/global.inc.php';
  11. /**
  12. * Executing
  13. */
  14. fill_many_users(100000);
  15. /**
  16. * Loads the data and injects it into the Chamilo database, using the Chamilo
  17. * internal functions.
  18. * @return array List of user IDs for the users that have just been inserted
  19. */
  20. function fill_many_users($num) {
  21. $eol = PHP_EOL;
  22. $users = array(); //declare only to avoid parsing notice
  23. require_once 'data_users.php'; //fill the $users array
  24. $i = 1;
  25. while ($i < $num) {
  26. $output = array();
  27. $output[] = array('title'=>'Users Filling Report:');
  28. foreach ($users as $j => $user) {
  29. //first check that the first item doesn't exist already
  30. $output[$i]['line-init'] = $user['firstname'];
  31. $res = UserManager::create_user($user['firstname'],$user['lastname'],$user['status'],$user['email'],$user['username'].$i,$user['pass'],null,null,null,null,$user['auth_source'],null,$user['active']);
  32. $output[$i]['line-info'] = ($res ? get_lang('Inserted') : get_lang('NotInserted')).' '.$user['username'].$i;
  33. $i++;
  34. }
  35. print_r($output);
  36. }
  37. //return $output;
  38. }