Guest User

Untitled

a guest
Nov 22nd, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.78 KB | None | 0 0
  1. function sonesta_travelpass_quick_sign_up_form_submit(&$form, &$form_state) {
  2.   $values = $form_state['values'];
  3.   $username = 'Hotel Staff';
  4.   $password = 'Tr@ve1P@55!';
  5.   $guestDetails = new GuestDetails($username, $password);
  6.   $last_name = $values['last_name'];
  7.   $first_name = $values['first_name'];
  8.   $group_wrapper = entity_metadata_wrapper('group', $values['hotel']);
  9.   $synxis_id = sonesta_travelpass_get_wrapper_property($group_wrapper, 'field_property_synxis_id');
  10.   $source = htmlentities(sonesta_travelpass_get_wrapper_property($group_wrapper, 'title', 'GUEST'));
  11.   $guestDetails->addGuest(0, $last_name, NULL, $first_name, NULL, NULL, NULL, 'Member', truncate_utf8($source, 50), 'inserted');
  12.   $associateName = implode(' ', [$values['employee_first_name'], $values['employee_last_name']]);
  13.   $guestDetails->addGuestIssuedId(0, 'inserted');
  14.   $email = $values['email'];
  15.   $guestDetails->addCommunication(0, 'Email', $email, 'inserted');
  16.   $guestDetails->addGuestContactLog(0, $synxis_id, $associateName, 'inserted');
  17.   $results = sonesta_guestware_api_update_guest_details($guestDetails);
  18.   if (preg_match('%GuestID>(\d+)</GuestID%si', $results, $matches)) {
  19.     drupal_set_message(t('Travel Pass Enrollment Complete'));
  20.     drupal_set_message(t('Guest Membership ID #: @id', ['@id' => $matches[1]]));
  21.     $guest_name = implode(' ', [$first_name, $last_name]);
  22.     drupal_set_message(t('Member Name: @name', ['@name' => $guest_name]));
  23.     drupal_set_message(t('Member Email: @email', ['@email' => $email]));
  24.     drupal_set_message(t('Remind the guest that they will receive an email requesting that they sign in to their member profile on Sonesta.com and update their member preferences'), 'warning');
  25.  
  26.     $login = new GuestLogin($username, $password, TRUE);
  27.     $tmp_password = user_password(8);
  28.     $login->addGuest($matches[1], $email, $tmp_password);
  29.     $results2 = sonesta_guestware_api_update_guest_login($login);
  30.     if (preg_match('%GuestID>(\d+)</GuestID%i', $results2, $matches)) {
  31.       sonesta_exact_target_triggered_send(variable_get(SONESTA_ET_WELCOME), $email, [
  32.         [
  33.           'Name' => 'Username',
  34.           'Value' => $guest_name,
  35.         ],
  36.         [
  37.           'Name' => 'resetUrl',
  38.           'Value' => sonesta_travelpass_reset_url($matches[1], $tmp_password),
  39.         ],
  40.         [
  41.           'Name' => 'FirstName',
  42.           'Value' => $first_name,
  43.         ],
  44.         [
  45.           'Name' => 'LastName',
  46.           'Value' => $last_name,
  47.         ],
  48.       ], $matches[1]);
  49.       drupal_goto('travel-pass/login');
  50.     }
  51.     else {
  52.       drupal_set_message(t('Unable to register. Please see your system administrator.'), 'error');
  53.     }
  54.   }
  55.   else {
  56.     drupal_set_message(t('Unable to register. Please see your system administrator.'), 'error');
  57.   }
  58. }
Add Comment
Please, Sign In to add comment