fill_users.php 1.2 KB

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