install.ajax.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Responses to AJAX calls for install.
  5. */
  6. //require_once '../global.inc.php';
  7. $action = $_GET['a'];
  8. switch ($action) {
  9. case 'send_contact_information':
  10. if (!empty($_POST)) {
  11. // get params from contact form
  12. $person_name = $_POST['person_name'];
  13. $person_email = $_POST['person_email'];
  14. $person_role = $_POST['person_role'];
  15. $financial_decision = $_POST['financial_decision'];
  16. $contact_language = $_POST['language'];
  17. $company_name = $_POST['company_name'];
  18. $company_activity = $_POST['company_activity'];
  19. $company_country = $_POST['company_country'];
  20. $company_city = $_POST['company_city'];
  21. // validating required fields
  22. $a_required_fields = [$person_name, $person_role, $company_name, $company_activity, $company_country];
  23. $required_field_error = false;
  24. foreach ($a_required_fields as $required_file) {
  25. if (trim($required_file) === '') {
  26. $required_field_error = true;
  27. break;
  28. }
  29. }
  30. if ($required_field_error) {
  31. echo 'required_field_error';
  32. } else {
  33. // save contact information with web service
  34. // create a client
  35. $client = new SoapClient('https://version.chamilo.org/contact.php?wsdl');
  36. // call method ws_add_contact_information
  37. $contact_params = [
  38. 'person_name' => $person_name,
  39. 'person_email' => $person_email,
  40. 'person_role' => $person_role,
  41. 'financial_decision' => $financial_decision,
  42. 'contact_language' => $contact_language,
  43. 'company_name' => $company_name,
  44. 'company_activity' => $company_activity,
  45. 'company_country' => $company_country,
  46. 'company_city' => $company_city,
  47. ];
  48. $result = $client->__soapCall(
  49. 'ws_add_contact_information',
  50. ['contact_params' => $contact_params]
  51. );
  52. echo $result;
  53. }
  54. }
  55. break;
  56. default:
  57. echo '';
  58. }
  59. exit;