fill_users.php 1.2 KB

12345678910111213141516171819202122232425262728293031
  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_once '../../main/inc/global.inc.php';
  11. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  12. /**
  13. * Loads the data and injects it into the Chamilo database, using the Chamilo
  14. * internal functions.
  15. * @return array List of user IDs for the users that have just been inserted
  16. */
  17. function fill_users() {
  18. $eol = PHP_EOL;
  19. $users = array(); //declare only to avoid parsing notice
  20. require_once 'data_users.php'; //fill the $users array
  21. $output = array();
  22. $output[] = array('title'=>'Users Filling Report:');
  23. $i = 1;
  24. foreach ($users as $i => $user) {
  25. //first check that the first item doesn't exist already
  26. $output[$i]['line-init'] = $user['firstname'];
  27. $output[$i]['line-info'] = ($res = UserManager::create_user($user['firstname'],$user['lastname'],$user['status'],$user['email'],$user['username'],$user['pass'],null,null,null,null,$user['auth_source'],null,$user['active'])?$res:get_lang('NotInserted'));
  28. $i++;
  29. }
  30. return $output;
  31. }