updateUser.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. //Script loaded by local.inc.php providing update user information of type external_logininfo.
  3. /*
  4. This script must not exit.
  5. */
  6. use ChamiloSession as Session;
  7. require_once __DIR__.'/functions.inc.php';
  8. //MAIN CODE
  9. //$uData variable is set in local.inc.php
  10. $user = api_get_user_info($uData['user_id']);
  11. $new_user = external_get_user_info($login);
  12. $user['firstname'] = $new_user['firstname'];
  13. $user['lastname'] = $new_user['lastname'];
  14. $user['status'] = $new_user['status'];
  15. $user['admin'] = $new_user['admin'];
  16. $user['email'] = $new_user['email'];
  17. $user['username'] = $new_user['username'];
  18. $user['profile_link'] = $new_user['profile_link'];
  19. $user['worldwide_bu'] = $new_user['worldwide_bu'];
  20. $user['manager'] = $new_user['manager'];
  21. $user['country_bu'] = $new_user['country_bu'];
  22. $user['extra'] = $new_user['extra'];
  23. if ($new_user !== false) { //User can login
  24. external_update_user($user);
  25. $loginFailed = false;
  26. $_user['user_id'] = $user['user_id'];
  27. $_user['uidReset'] = true;
  28. $uidReset = true;
  29. Session::write('_user', $_user);
  30. } else {
  31. //User cannot login
  32. $loginFailed = true;
  33. Session::erase('_uid');
  34. header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=user_password_incorrect');
  35. exit;
  36. }