Guest User

Untitled

a guest
May 21st, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. /**
  2. * Form builder for execute rights form.
  3. */
  4. function gdpr_execute_rights_form($form, $form_state, $org, $lang, $token) {
  5. $form = array();
  6. // Check Gigya to make sure this is the valid user.
  7. // First, generate random string to use as new password.
  8. $new_password = '';
  9. for($i = 0; $i < 20; $i++) {
  10. $new_password .= mt_rand(0, 9);
  11. }
  12.  
  13. $params = array(
  14. 'passwordResetToken' => $token,
  15. 'newPassword' => $new_password
  16. );
  17.  
  18. $validate = [];
  19. // Use token to validate that email had been verified. However, we only want to do it the first time
  20. // the form is displayed, not when it is rebuilt after being submitted.
  21. $validate_gigya = count($form_state['input']) > 0 && $form_state['input']['op'] == 'Submit' ? FALSE : TRUE;
  22. if ($validate_gigya) {
  23. $validate = gdpr_send_gigya_request($org, $params, 'resetPassword');
  24. }
  25. // We only want to actually display the form fields if the user has been validated against Gigya.
  26. $display_fields = isset($validate['status']) && $validate['status'] == TRUE ? TRUE : FALSE;
  27. // Address has been validated, so build the form.
  28. $form['details'] = array(
  29. '#type' => $display_fields ? 'markup' : 'hidden',
  30. '#markup' => '<p>Your identity has been confirmed and we can continue with the data privacy rights request process. Please select one of the options below to tell us what you want to do with your personal data. If you’d like to make more than one change please initiate an additional rights request by clicking on this link.</p>'
  31. );
  32.  
  33. $form['data_options'] = array(
  34. '#type' => $display_fields ? 'select' : 'hidden',
  35. '#title' => t('Data Options'),
  36. '#options' => array(
  37. 'update' => 'Update your information. Please include details of the information you'd like updated in the fields below.',
  38. 'restrict' => 'Restrict processing of your personal information. Please provide details below.',
  39. 'access' => 'Access the personal information stored on you by this company. You will be sent a file via email.',
  40. 'consent' => 'Consent to receive marketing materials from (brand specific).',
  41. 'revoke_marketing' => 'Revoke consent to be sent marketing materials (brand specific).',
  42. 'revoke_all' => 'Revoke consent to receive marketing materials from all Fluke brands.',
  43. 'forget' => 'Forget me.'
  44. ),
  45. '#default_value' => 'update'
  46. );
  47.  
  48. $form['given_name'] = array(
  49. '#type' => $display_fields ? 'textfield' : 'hidden',
  50. '#title' => t('Given Name'),
  51. '#description' => t('Enter your given (first) name'),
  52. '#required' => TRUE,
  53. );
  54.  
  55. $form['family_name'] = array(
  56. '#type' => $display_fields ? 'textfield' : 'hidden',
  57. '#title' => t('Family Name'),
  58. '#description' => t('Enter your family (last) name'),
  59. '#required' => TRUE,
  60. );
  61.  
  62. $form['email'] = array(
  63. '#type' => $display_fields ? 'textfield' : 'hidden',
  64. '#title' => t('Email Address'),
  65. '#description' => t('This is the address used to identify you in our system.'),
  66. '#disabled' => TRUE,
  67. '#default_value' => isset($validate['email']) ? $validate['email'] : ''
  68. );
  69.  
  70. $form['submit'] = array(
  71. '#type' => $display_fields ? 'submit' : 'hidden',
  72. '#value' => t('Submit')
  73. );
  74.  
  75. $form['error'] = array(
  76. '#type' => $display_fields ? 'hidden' : 'markup',
  77. '#markup' => '<p>Sorry, your email address could not be validated.</p>'
  78. );
  79.  
  80. return $form;
  81. }
Add Comment
Please, Sign In to add comment