WYSIJA_view_front_confirm

The MailPoet Newsletters WYSIJA view front confirm class.

Defined (1)

The class is defined in the following location(s).

/views/front/confirm.php  
  1. class WYSIJA_view_front_confirm extends WYSIJA_view_front { 
  2.  
  3. function __construct() { 
  4. $this->model = WYSIJA::get( 'user', 'model' ); 
  5.  
  6. add_action( 'wp_head', array( $this, 'add_noindex' ) ); 
  7.  
  8. public function add_noindex() { 
  9. $wysija_page_flag = (bool) absint( isset( $_GET['wysija-page'] ) ? $_GET['wysija-page'] : 0 ); 
  10. if ( ! is_admin() && $wysija_page_flag ) { 
  11. echo '<meta name="robots" content="noindex, nofollow">'; 
  12.  
  13. /** 
  14. * In that view we put all the content in a string because if we don't we won't be able to return it in the right place of the page 
  15. * ob_start can't be used because of the other plugins possible conflicts 
  16. * @param type $data 
  17. * @return string 
  18. */ 
  19. function subscriptions( $data ) { 
  20. wp_enqueue_script( 'wysija-validator-lang' ); 
  21. wp_enqueue_script( 'wysija-validator' ); 
  22. wp_enqueue_script( 'wysija-front-subscribers' ); 
  23. wp_enqueue_style( 'validate-engine-css' ); 
  24.  
  25. $content = $this->messages(); 
  26. $formObj = WYSIJA::get( 'forms', 'helper' ); 
  27.  
  28. $content .= '<form id="wysija-subscriptions" method="post" action="#wysija-subscriptions" class="form-valid">'; 
  29.  
  30. $content .= 
  31. '<table class="form-table">' . 
  32. '<tbody>'; 
  33. //user details */ 
  34.  
  35. //do not show the email input if the subscriber is a wordPress user 
  36. $configm = WYSIJA::get( 'config', 'model' ); 
  37. $synchwp = $configm->getValue( 'importwp_list_id' ); 
  38. $iswpsynched = false; 
  39. foreach ( $data['user']['lists'] as $listdt ) { 
  40. if ( $listdt['list_id'] == $synchwp ) { 
  41. $iswpsynched = true; 
  42. if ( ! $iswpsynched ) { 
  43. $content .= 
  44. '<tr>' . 
  45. '<th scope="row">' . 
  46. '<label for="email">' . esc_attr__( 'Email', WYSIJA ) . '</label>' . 
  47. '</th>' . 
  48. '<td>' . 
  49. '<input type="text" size="40" class="validate[required, custom[email]]" id="email" value="' . esc_attr( $data['user']['details']['email'] ) . '" name="wysija[user][email]" />' . 
  50. '</td>' . 
  51. '</tr>'; 
  52.  
  53. $content.='<tr> 
  54. <th scope="row"> 
  55. <label for="fname">'.__('First name', WYSIJA).'</label> 
  56. </th> 
  57. <td> 
  58. <input type="text" size="40" id="fname" value="'.esc_attr($data['user']['details']['firstname']).'" name="wysija[user][firstname]" /> 
  59. </td> 
  60. </tr>'; 
  61.  
  62. $content.='<tr> 
  63. <th scope="row"> 
  64. <label for="lname">'.__('Last name', WYSIJA).'</label> 
  65. </th> 
  66. <td> 
  67. <input type="text" size="40" id="lname" value="'.esc_attr($data['user']['details']['lastname']).'" name="wysija[user][lastname]" /> 
  68. </td> 
  69. </tr>'; 
  70.  
  71. $content.='<tr> 
  72. <th scope="row"> 
  73. <label for="status">'.__('Status', WYSIJA).'</label> 
  74. </th> 
  75. <td> 
  76. '.$formObj->radios( 
  77. array('id'=>'status', 'name'=>'wysija[user][status]'),  
  78. array('-1'=>' '.__('Unsubscribed', WYSIJA).' ', '1'=>' '.__('Subscribed', WYSIJA).' '),  
  79. $data['user']['details']['status'],  
  80. ' class="validate[required]" ').' 
  81. </td> 
  82. </tr>'; 
  83.  
  84. /** 
  85. Custom Fields. 
  86. */ 
  87. $content .= WJ_FieldRender::render_all( 
  88. $data['user']['details']['user_id'] 
  89. ); 
  90.  
  91. //list subscriptions */ 
  92. if ( $data['list'] ) { 
  93. $content .= 
  94. '<tr></tr><tr> 
  95. <th scope="row" colspan="2">'; 
  96.  
  97. $content .= '<h3>' . esc_attr__( 'Your lists', WYSIJA ) . '</h3>'; 
  98. $field = 'lists-'; 
  99.  
  100. $content .= '</th>'; 
  101.  
  102. $fieldHTML = ''; 
  103. $field = 'list'; 
  104. $valuefield = array(); 
  105. foreach ( $data['user']['lists'] as $list ) { 
  106. $valuefield[ $list['list_id'] ] = $list; 
  107.  
  108. $fieldHTML = ''; 
  109. $field = 'list'; 
  110. $valuefield = array(); 
  111. if ( $data['user'] ) { 
  112. foreach ( $data['user']['lists'] as $list ) { 
  113. $valuefield[ $list['list_id'] ] = $list; 
  114.  
  115. $formObj=WYSIJA::get('forms', 'helper'); 
  116. foreach($data['list'] as $list) { 
  117. $checked=false; 
  118. $extratext=$extraCheckbox=$hiddenField=''; 
  119.  
  120. if(isset($valuefield[$list['list_id']])) { 
  121. //if the subscriber has this list and is not unsubed then we check the checkbox 
  122. if($valuefield[$list['list_id']]['unsub_date']<=0) { 
  123. $checked=true; 
  124. }else{ 
  125. //we keep a reference of the list to which we are unsubscribed 
  126. $hiddenField=$formObj->hidden(array('id'=>$field.$list['list_id'], 'name'=>"wysija[user_list][unsub_list][]", 'class'=>'checkboxx'), $list['list_id']); 
  127. $hiddenField.=' / <span class="wysija-unsubscribed-on">'.sprintf(__('Unsubscribed on %1$s', WYSIJA), date_i18n(get_option('date_format'), $valuefield[$list['list_id']]['unsub_date'])).'</span>'; 
  128. $labelHTML= '<label for="'.$field.$list['list_id'].'">'.$list['name'].'</label>'; 
  129. $fieldHTML=$formObj->checkbox( array('id'=>$field.$list['list_id'], 'name'=>"wysija[user_list][list_id][]", 'class'=>'checkboxx'), $list['list_id'], $checked, $extraCheckbox).$labelHTML; 
  130. $fieldHTML.=$hiddenField; 
  131. $content.= '<tr><td colspan="2">'. $fieldHTML.'</td></tr>'; 
  132.  
  133.  
  134. $content.='</tbody></table>'; 
  135. $content.='<p class="submit"> 
  136. '.$this->secure(array('controller'=>"confirm", 'action'=>"save", 'id'=> $data['user']['details']['user_id']), false, false).' 
  137. <input type="hidden" name="wysija[user][user_id]" id="user_id" value="'.esc_attr($data['user']['details']['user_id']).'" /> 
  138. <input type="hidden" name="id" id="user_id2" value="'.esc_attr($data['user']['details']['user_id']).'" /> 
  139. <input type="hidden" value="save" name="action" /> 
  140. <input type="submit" value="'.esc_attr(__('Save', WYSIJA)).'" class="button-primary wysija"> 
  141. </p>'; 
  142. $content.='</form>'; 
  143. return $content;