3
3
namespace RRZE \RSVP \Shortcodes ;
4
4
5
5
use RRZE \RSVP \{Email , Functions , Template , TransientData };
6
+ use RRZE \RSVP \Auth \{IdM , LDAP };
6
7
7
8
use function RRZE \RSVP \Config \defaultOptions ;
8
9
use function RRZE \RSVP \Config \getShortcodeSettings ;
@@ -48,7 +49,7 @@ public function __construct($settings)
48
49
public function shortcodeBooking ($ atts , $ content = '' , $ tag = '' )
49
50
{
50
51
global $ post ;
51
- $ postID = $ post ->ID ;
52
+ $ postID = $ post ->ID ;
52
53
53
54
if (isset ($ _GET ['transient-data ' ]) && isset ($ _GET ['transient-data-nonce ' ]) && wp_verify_nonce ($ _GET ['transient-data-nonce ' ], 'transient-data- ' . $ _GET ['transient-data ' ])) {
54
55
$ transient = $ _GET ['transient-data ' ];
@@ -63,14 +64,14 @@ public function shortcodeBooking($atts, $content = '', $tag = '')
63
64
wp_redirect ($ redirectUrl );
64
65
exit ;
65
66
}
66
- }
67
-
67
+ }
68
+
68
69
wp_enqueue_style ('rrze-rsvp-shortcode ' );
69
70
70
71
if ($ output = $ this ->ssoAuthenticationError ()) {
71
72
return $ output ;
72
73
}
73
- // if ($output = $this-> ldapAuthenticationError()) {
74
+ // if ($output = $ldapAuthenticationError()) {
74
75
// return $output;
75
76
// }
76
77
if ($ output = $ this ->postDataError ()) {
@@ -107,10 +108,12 @@ public function shortcodeBooking($atts, $content = '', $tag = '')
107
108
wp_enqueue_script ('rrze-rsvp-shortcode ' );
108
109
109
110
// Perhaps the user needs authentication?
111
+ $ idm = new IdM ;
112
+ $ ldap = new LDAP ;
110
113
$ ssoRequired = Functions::getBoolValueFromAtt (get_post_meta ($ input_room , 'rrze-rsvp-room-sso-required ' , true ));
111
114
$ ldapRequired = Functions::getBoolValueFromAtt (get_post_meta ($ input_room , 'rrze-rsvp-room-ldap-required ' , true ));
112
115
$ ldapRequired = $ ldapRequired && $ this ->settings ->getOption ('ldap ' , 'server ' ) ? true : false ;
113
- if (($ ssoRequired && !$ this -> idm ->isAuthenticated ()) || ($ ldapRequired && !$ this -> ldap ->isAuthenticated ())) {
116
+ if (($ ssoRequired && !$ idm ->isAuthenticated ()) || ($ ldapRequired && !$ ldap ->isAuthenticated ())) {
114
117
if ($ output = $ this ->authForm ($ ssoRequired , $ ldapRequired )) {
115
118
return $ output ;
116
119
}
@@ -273,8 +276,8 @@ public function shortcodeBooking($atts, $content = '', $tag = '')
273
276
$ output .= '<fieldset> ' ;
274
277
$ output .= '<legend> ' . __ ('Your data ' , 'rrze-rsvp ' ) . ' <span class="notice-required">( ' . __ ('Required ' , 'rrze-rsvp ' ) . ')</span></legend> ' ;
275
278
276
- if ($ this -> idm ->isAuthenticated ()) {
277
- $ data = $ this -> idm ->getCustomerData ();
279
+ if ($ idm ->isAuthenticated ()) {
280
+ $ data = $ idm ->getCustomerData ();
278
281
$ output .= '<input type="hidden" value=" ' . $ data ['customer_lastname ' ] . '" id="rsvp_lastname" name="rsvp_lastname"> ' ;
279
282
$ output .= '<input type="hidden" value=" ' . $ data ['customer_firstname ' ] . '" id="rsvp_firstname" name="rsvp_firstname"> ' ;
280
283
$ output .= '<input type="hidden" value=" ' . $ data ['customer_email ' ] . '" id="rsvp_email" name="rsvp_email"> ' ;
@@ -286,16 +289,16 @@ public function shortcodeBooking($atts, $content = '', $tag = '')
286
289
. '</div> ' ;
287
290
}
288
291
289
- if ($ this -> ldap ->isAuthenticated ()) {
290
- $ data = $ this -> ldap ->getCustomerData ();
292
+ if ($ ldap ->isAuthenticated ()) {
293
+ $ data = $ ldap ->getCustomerData ();
291
294
$ output .= '<input type="hidden" value=" ' . $ data ['customer_email ' ] . '" id="rsvp_email" name="rsvp_email"> ' ;
292
295
293
296
$ output .= '<div class="form-group"> '
294
297
. '<p> ' . __ ('Email ' , 'rrze-rsvp ' ) . ': <strong> ' . $ data ['customer_email ' ] . '</strong></p> '
295
298
. '</div> ' ;
296
299
}
297
300
298
- if (!$ this -> idm ->isAuthenticated ()) {
301
+ if (!$ idm ->isAuthenticated ()) {
299
302
$ error = isset ($ fieldErrors ['rsvp_lastname ' ]) ? ' error ' : '' ;
300
303
$ value = isset ($ fieldErrors ['rsvp_lastname ' ]['value ' ]) ? $ fieldErrors ['rsvp_lastname ' ]['value ' ] : '' ;
301
304
$ message = isset ($ fieldErrors ['rsvp_lastname ' ]['message ' ]) ? $ fieldErrors ['rsvp_lastname ' ]['message ' ] : '' ;
@@ -315,7 +318,7 @@ public function shortcodeBooking($atts, $content = '', $tag = '')
315
318
. '</div> ' ;
316
319
}
317
320
318
- if (!$ this -> idm ->isAuthenticated () && !$ this -> ldap ->isAuthenticated ()) {
321
+ if (!$ idm ->isAuthenticated () && !$ ldap ->isAuthenticated ()) {
319
322
$ error = isset ($ fieldErrors ['rsvp_email ' ]) ? ' error ' : '' ;
320
323
$ value = isset ($ fieldErrors ['rsvp_email ' ]['value ' ]) ? $ fieldErrors ['rsvp_email ' ]['value ' ] : '' ;
321
324
$ message = isset ($ fieldErrors ['rsvp_email ' ]['message ' ]) ? $ fieldErrors ['rsvp_email ' ]['message ' ] : '' ;
@@ -530,15 +533,18 @@ protected function bookedNotice()
530
533
return '' ;
531
534
}
532
535
536
+ $ idm = new IdM ;
537
+ $ ldap = new LDAP ;
538
+
533
539
$ queryStr = Functions::getQueryStr ([], ['require-auth ' ]);
534
540
$ returnTo = trailingslashit (get_permalink ()) . ($ queryStr ? '? ' . $ queryStr : '' );
535
541
536
- if ($ this -> idm ->isAuthenticated ()) {
537
- $ this -> idm ->logout ($ returnTo );
542
+ if ($ idm ->isAuthenticated ()) {
543
+ $ idm ->logout ($ returnTo );
538
544
}
539
545
540
- if ($ this -> ldap ->isAuthenticated ()) {
541
- $ this -> ldap ->logout ($ returnTo );
546
+ if ($ ldap ->isAuthenticated ()) {
547
+ $ ldap ->logout ($ returnTo );
542
548
}
543
549
544
550
$ bookingId = absint ($ _GET ['id ' ]);
@@ -608,6 +614,9 @@ public function bookingSubmitted()
608
614
return ;
609
615
}
610
616
617
+ $ idm = new IdM ;
618
+ $ ldap = new LDAP ;
619
+
611
620
array_walk_recursive (
612
621
$ _POST ,
613
622
function (&$ value ) {
@@ -665,9 +674,9 @@ function (&$value) {
665
674
$ booking_end = array_key_exists ($ booking_start , $ schedule [$ weekday ]) ? $ schedule [$ weekday ][$ booking_start ] : $ booking_start ;
666
675
$ booking_timestamp_end = strtotime ($ booking_date . ' ' . $ booking_end );
667
676
668
- if ($ this -> idm ->isAuthenticated ()) {
669
- if ($ this -> idm ->isAuthenticated ()) {
670
- $ sso_data = $ this -> idm ->getCustomerData ();
677
+ if ($ idm ->isAuthenticated ()) {
678
+ if ($ idm ->isAuthenticated ()) {
679
+ $ sso_data = $ idm ->getCustomerData ();
671
680
$ booking_lastname = $ sso_data ['customer_lastname ' ];
672
681
$ booking_firstname = $ sso_data ['customer_firstname ' ];
673
682
$ booking_email = $ sso_data ['customer_email ' ];
@@ -682,9 +691,9 @@ function (&$value) {
682
691
wp_redirect ($ redirectUrl );
683
692
exit ;
684
693
}
685
- } elseif ($ this -> ldap ->isAuthenticated ()) {
686
- if ($ this -> ldap ->isAuthenticated ()) {
687
- $ ldap_data = $ this -> ldap ->getCustomerData ();
694
+ } elseif ($ ldap ->isAuthenticated ()) {
695
+ if ($ ldap ->isAuthenticated ()) {
696
+ $ ldap_data = $ ldap ->getCustomerData ();
688
697
$ booking_email = $ ldap_data ['customer_email ' ];
689
698
} else {
690
699
$ redirectUrl = add_query_arg (
0 commit comments