@@ -15,112 +15,112 @@ |
||
15 | 15 | class Basic implements EmailValidatorInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param string $email_address |
|
20 | - * @return bool |
|
21 | - * @throws EmailValidationException |
|
22 | - */ |
|
23 | - public function validate($email_address) |
|
24 | - { |
|
25 | - if (! preg_match('/^.+\@\S+$/', $email_address)) { |
|
26 | - // email not in correct {string}@{string} format |
|
27 | - throw new EmailValidationException( |
|
28 | - esc_html__('Email does not have the required @ sign.', 'event_espresso') |
|
29 | - ); |
|
30 | - } |
|
31 | - $atIndex = $this->getAtIndex($email_address); |
|
32 | - $local = $this->getLocalPartOfEmail($email_address, $atIndex); |
|
33 | - $localLen = strlen($local); |
|
34 | - if ($localLen < 1) { |
|
35 | - // no local part |
|
36 | - throw new EmailValidationException( |
|
37 | - esc_html__('Email local-part (before the @) is required.', 'event_espresso') |
|
38 | - ); |
|
39 | - } |
|
40 | - if ($localLen > 64) { |
|
41 | - // local part length exceeded |
|
42 | - throw new EmailValidationException( |
|
43 | - esc_html__('Email local-part (before the @) is too long.', 'event_espresso') |
|
44 | - ); |
|
45 | - } |
|
46 | - if ($local[0] === '.') { |
|
47 | - // local part starts with '.' |
|
48 | - throw new EmailValidationException( |
|
49 | - esc_html__('Email local-part (before the @) must not begin with a period.', 'event_espresso') |
|
50 | - ); |
|
51 | - } |
|
52 | - if ($local[ $localLen - 1 ] === '.') { |
|
53 | - // local part starts or ends with '.' |
|
54 | - throw new EmailValidationException( |
|
55 | - esc_html__('Email local-part (before the @) must not end with a period.', 'event_espresso') |
|
56 | - ); |
|
57 | - } |
|
58 | - if (preg_match('/\\.\\./', $local)) { |
|
59 | - // local part has two consecutive dots |
|
60 | - throw new EmailValidationException( |
|
61 | - esc_html__( |
|
62 | - 'Email local-part (before the @) must not have two consecutive periods.', |
|
63 | - 'event_espresso' |
|
64 | - ) |
|
65 | - ); |
|
66 | - } |
|
67 | - $domain = $this->getDomainPartOfEmail($email_address, $atIndex); |
|
68 | - $domainLen = strlen($domain); |
|
69 | - if ($domainLen < 1) { |
|
70 | - throw new EmailValidationException( |
|
71 | - esc_html__('Email domain (after the @) is required.', 'event_espresso') |
|
72 | - ); |
|
73 | - } |
|
74 | - if ($domainLen > 255) { |
|
75 | - // domain part length exceeded |
|
76 | - throw new EmailValidationException( |
|
77 | - esc_html__('Email domain (after the @) is too long.', 'event_espresso') |
|
78 | - ); |
|
79 | - } |
|
80 | - if (preg_match('/\\.\\./', $domain)) { |
|
81 | - // domain part has two consecutive dots |
|
82 | - throw new EmailValidationException( |
|
83 | - esc_html__('Email domain (after the @) must not have two consecutive periods.', 'event_espresso') |
|
84 | - ); |
|
85 | - } |
|
86 | - return true; |
|
87 | - } |
|
18 | + /** |
|
19 | + * @param string $email_address |
|
20 | + * @return bool |
|
21 | + * @throws EmailValidationException |
|
22 | + */ |
|
23 | + public function validate($email_address) |
|
24 | + { |
|
25 | + if (! preg_match('/^.+\@\S+$/', $email_address)) { |
|
26 | + // email not in correct {string}@{string} format |
|
27 | + throw new EmailValidationException( |
|
28 | + esc_html__('Email does not have the required @ sign.', 'event_espresso') |
|
29 | + ); |
|
30 | + } |
|
31 | + $atIndex = $this->getAtIndex($email_address); |
|
32 | + $local = $this->getLocalPartOfEmail($email_address, $atIndex); |
|
33 | + $localLen = strlen($local); |
|
34 | + if ($localLen < 1) { |
|
35 | + // no local part |
|
36 | + throw new EmailValidationException( |
|
37 | + esc_html__('Email local-part (before the @) is required.', 'event_espresso') |
|
38 | + ); |
|
39 | + } |
|
40 | + if ($localLen > 64) { |
|
41 | + // local part length exceeded |
|
42 | + throw new EmailValidationException( |
|
43 | + esc_html__('Email local-part (before the @) is too long.', 'event_espresso') |
|
44 | + ); |
|
45 | + } |
|
46 | + if ($local[0] === '.') { |
|
47 | + // local part starts with '.' |
|
48 | + throw new EmailValidationException( |
|
49 | + esc_html__('Email local-part (before the @) must not begin with a period.', 'event_espresso') |
|
50 | + ); |
|
51 | + } |
|
52 | + if ($local[ $localLen - 1 ] === '.') { |
|
53 | + // local part starts or ends with '.' |
|
54 | + throw new EmailValidationException( |
|
55 | + esc_html__('Email local-part (before the @) must not end with a period.', 'event_espresso') |
|
56 | + ); |
|
57 | + } |
|
58 | + if (preg_match('/\\.\\./', $local)) { |
|
59 | + // local part has two consecutive dots |
|
60 | + throw new EmailValidationException( |
|
61 | + esc_html__( |
|
62 | + 'Email local-part (before the @) must not have two consecutive periods.', |
|
63 | + 'event_espresso' |
|
64 | + ) |
|
65 | + ); |
|
66 | + } |
|
67 | + $domain = $this->getDomainPartOfEmail($email_address, $atIndex); |
|
68 | + $domainLen = strlen($domain); |
|
69 | + if ($domainLen < 1) { |
|
70 | + throw new EmailValidationException( |
|
71 | + esc_html__('Email domain (after the @) is required.', 'event_espresso') |
|
72 | + ); |
|
73 | + } |
|
74 | + if ($domainLen > 255) { |
|
75 | + // domain part length exceeded |
|
76 | + throw new EmailValidationException( |
|
77 | + esc_html__('Email domain (after the @) is too long.', 'event_espresso') |
|
78 | + ); |
|
79 | + } |
|
80 | + if (preg_match('/\\.\\./', $domain)) { |
|
81 | + // domain part has two consecutive dots |
|
82 | + throw new EmailValidationException( |
|
83 | + esc_html__('Email domain (after the @) must not have two consecutive periods.', 'event_espresso') |
|
84 | + ); |
|
85 | + } |
|
86 | + return true; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * returns the location of the @ symbol |
|
92 | - * |
|
93 | - * @param string $email_address |
|
94 | - * @return bool|string |
|
95 | - */ |
|
96 | - protected function getAtIndex($email_address) |
|
97 | - { |
|
98 | - return strrpos($email_address, '@'); |
|
99 | - } |
|
90 | + /** |
|
91 | + * returns the location of the @ symbol |
|
92 | + * |
|
93 | + * @param string $email_address |
|
94 | + * @return bool|string |
|
95 | + */ |
|
96 | + protected function getAtIndex($email_address) |
|
97 | + { |
|
98 | + return strrpos($email_address, '@'); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * Gets the local part of the email |
|
104 | - * |
|
105 | - * @param string $email_address |
|
106 | - * @param bool|int $atIndex |
|
107 | - * @return bool|string |
|
108 | - */ |
|
109 | - protected function getLocalPartOfEmail($email_address, $atIndex) |
|
110 | - { |
|
111 | - return substr($email_address, 0, $atIndex); |
|
112 | - } |
|
102 | + /** |
|
103 | + * Gets the local part of the email |
|
104 | + * |
|
105 | + * @param string $email_address |
|
106 | + * @param bool|int $atIndex |
|
107 | + * @return bool|string |
|
108 | + */ |
|
109 | + protected function getLocalPartOfEmail($email_address, $atIndex) |
|
110 | + { |
|
111 | + return substr($email_address, 0, $atIndex); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | - /** |
|
116 | - * Gets the domain part of the email |
|
117 | - * |
|
118 | - * @param string $email_address |
|
119 | - * @param bool|int $atIndex |
|
120 | - * @return bool|string |
|
121 | - */ |
|
122 | - protected function getDomainPartOfEmail($email_address, $atIndex) |
|
123 | - { |
|
124 | - return substr($email_address, $atIndex + 1); |
|
125 | - } |
|
115 | + /** |
|
116 | + * Gets the domain part of the email |
|
117 | + * |
|
118 | + * @param string $email_address |
|
119 | + * @param bool|int $atIndex |
|
120 | + * @return bool|string |
|
121 | + */ |
|
122 | + protected function getDomainPartOfEmail($email_address, $atIndex) |
|
123 | + { |
|
124 | + return substr($email_address, $atIndex + 1); |
|
125 | + } |
|
126 | 126 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function validate($email_address) |
24 | 24 | { |
25 | - if (! preg_match('/^.+\@\S+$/', $email_address)) { |
|
25 | + if ( ! preg_match('/^.+\@\S+$/', $email_address)) { |
|
26 | 26 | // email not in correct {string}@{string} format |
27 | 27 | throw new EmailValidationException( |
28 | 28 | esc_html__('Email does not have the required @ sign.', 'event_espresso') |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | esc_html__('Email local-part (before the @) must not begin with a period.', 'event_espresso') |
50 | 50 | ); |
51 | 51 | } |
52 | - if ($local[ $localLen - 1 ] === '.') { |
|
52 | + if ($local[$localLen - 1] === '.') { |
|
53 | 53 | // local part starts or ends with '.' |
54 | 54 | throw new EmailValidationException( |
55 | 55 | esc_html__('Email local-part (before the @) must not end with a period.', 'event_espresso') |
@@ -70,14 +70,14 @@ |
||
70 | 70 | 'REG_code' => $reg_code, |
71 | 71 | ) |
72 | 72 | ); |
73 | - if (! $registration instanceof EE_Registration) { |
|
73 | + if ( ! $registration instanceof EE_Registration) { |
|
74 | 74 | throw new UnexpectedEntityException($registration, 'EE_Registration'); |
75 | 75 | } |
76 | 76 | // save registration so that we have an ID |
77 | 77 | $registration->save(); |
78 | 78 | // track reservation on reg but don't adjust ticket and datetime reserved counts |
79 | 79 | // because that is done as soon as the tickets are added/removed from the cart |
80 | - $registration->reserve_ticket(false, 'CreateRegistrationService:' . __LINE__); |
|
80 | + $registration->reserve_ticket(false, 'CreateRegistrationService:'.__LINE__); |
|
81 | 81 | $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
82 | 82 | $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
83 | 83 | $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
@@ -29,102 +29,102 @@ |
||
29 | 29 | { |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param EE_Event $event |
|
34 | - * @param EE_Transaction $transaction |
|
35 | - * @param EE_Ticket $ticket |
|
36 | - * @param EE_Line_Item $ticket_line_item |
|
37 | - * @param $reg_count |
|
38 | - * @param $reg_group_size |
|
39 | - * @param string $reg_status |
|
40 | - * @return EE_Registration |
|
41 | - * @throws OutOfRangeException |
|
42 | - * @throws EE_Error |
|
43 | - * @throws UnexpectedEntityException |
|
44 | - */ |
|
45 | - public function create( |
|
46 | - EE_Event $event, |
|
47 | - EE_Transaction $transaction, |
|
48 | - EE_Ticket $ticket, |
|
49 | - EE_Line_Item $ticket_line_item, |
|
50 | - $reg_count, |
|
51 | - $reg_group_size, |
|
52 | - $reg_status = EEM_Registration::status_id_incomplete |
|
53 | - ) { |
|
54 | - $registrations = $transaction->registrations(); |
|
55 | - $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
56 | - $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
57 | - $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
58 | - // generate new EE_Registration |
|
59 | - $registration = EE_Registration::new_instance( |
|
60 | - array( |
|
61 | - 'EVT_ID' => $event->ID(), |
|
62 | - 'TXN_ID' => $transaction->ID(), |
|
63 | - 'TKT_ID' => $ticket->ID(), |
|
64 | - 'STS_ID' => $reg_status, |
|
65 | - 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
66 | - 'REG_session' => EE_Registry::instance()->SSN->id(), |
|
67 | - 'REG_count' => $reg_count, |
|
68 | - 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegGroupSize($registrations), |
|
69 | - 'REG_url_link' => $reg_url_link, |
|
70 | - 'REG_code' => $reg_code, |
|
71 | - ) |
|
72 | - ); |
|
73 | - if (! $registration instanceof EE_Registration) { |
|
74 | - throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
75 | - } |
|
76 | - // save registration so that we have an ID |
|
77 | - $registration->save(); |
|
78 | - // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
79 | - // because that is done as soon as the tickets are added/removed from the cart |
|
80 | - $registration->reserve_ticket(false, 'CreateRegistrationService:' . __LINE__); |
|
81 | - $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
82 | - $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
83 | - $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
84 | - $registration->save(); |
|
85 | - return $registration; |
|
86 | - } |
|
32 | + /** |
|
33 | + * @param EE_Event $event |
|
34 | + * @param EE_Transaction $transaction |
|
35 | + * @param EE_Ticket $ticket |
|
36 | + * @param EE_Line_Item $ticket_line_item |
|
37 | + * @param $reg_count |
|
38 | + * @param $reg_group_size |
|
39 | + * @param string $reg_status |
|
40 | + * @return EE_Registration |
|
41 | + * @throws OutOfRangeException |
|
42 | + * @throws EE_Error |
|
43 | + * @throws UnexpectedEntityException |
|
44 | + */ |
|
45 | + public function create( |
|
46 | + EE_Event $event, |
|
47 | + EE_Transaction $transaction, |
|
48 | + EE_Ticket $ticket, |
|
49 | + EE_Line_Item $ticket_line_item, |
|
50 | + $reg_count, |
|
51 | + $reg_group_size, |
|
52 | + $reg_status = EEM_Registration::status_id_incomplete |
|
53 | + ) { |
|
54 | + $registrations = $transaction->registrations(); |
|
55 | + $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
56 | + $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
57 | + $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
58 | + // generate new EE_Registration |
|
59 | + $registration = EE_Registration::new_instance( |
|
60 | + array( |
|
61 | + 'EVT_ID' => $event->ID(), |
|
62 | + 'TXN_ID' => $transaction->ID(), |
|
63 | + 'TKT_ID' => $ticket->ID(), |
|
64 | + 'STS_ID' => $reg_status, |
|
65 | + 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
66 | + 'REG_session' => EE_Registry::instance()->SSN->id(), |
|
67 | + 'REG_count' => $reg_count, |
|
68 | + 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegGroupSize($registrations), |
|
69 | + 'REG_url_link' => $reg_url_link, |
|
70 | + 'REG_code' => $reg_code, |
|
71 | + ) |
|
72 | + ); |
|
73 | + if (! $registration instanceof EE_Registration) { |
|
74 | + throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
75 | + } |
|
76 | + // save registration so that we have an ID |
|
77 | + $registration->save(); |
|
78 | + // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
79 | + // because that is done as soon as the tickets are added/removed from the cart |
|
80 | + $registration->reserve_ticket(false, 'CreateRegistrationService:' . __LINE__); |
|
81 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
82 | + $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
83 | + $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
84 | + $registration->save(); |
|
85 | + return $registration; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @param EE_Transaction $transaction |
|
91 | - * @param EE_Ticket $ticket |
|
92 | - * @param EE_Line_Item $ticket_line_item |
|
93 | - * @return float |
|
94 | - * @throws EE_Error |
|
95 | - * @throws OutOfRangeException |
|
96 | - */ |
|
97 | - protected function resolveFinalPrice( |
|
98 | - EE_Transaction $transaction, |
|
99 | - EE_Ticket $ticket, |
|
100 | - EE_Line_Item $ticket_line_item |
|
101 | - ) { |
|
102 | - $final_price = EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
103 | - $transaction->total_line_item(), |
|
104 | - $ticket_line_item |
|
105 | - ); |
|
106 | - $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
107 | - return (float) $final_price; |
|
108 | - } |
|
89 | + /** |
|
90 | + * @param EE_Transaction $transaction |
|
91 | + * @param EE_Ticket $ticket |
|
92 | + * @param EE_Line_Item $ticket_line_item |
|
93 | + * @return float |
|
94 | + * @throws EE_Error |
|
95 | + * @throws OutOfRangeException |
|
96 | + */ |
|
97 | + protected function resolveFinalPrice( |
|
98 | + EE_Transaction $transaction, |
|
99 | + EE_Ticket $ticket, |
|
100 | + EE_Line_Item $ticket_line_item |
|
101 | + ) { |
|
102 | + $final_price = EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
103 | + $transaction->total_line_item(), |
|
104 | + $ticket_line_item |
|
105 | + ); |
|
106 | + $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
107 | + return (float) $final_price; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * @param EE_Registration[] $registrations |
|
113 | - * @param boolean $update_existing_registrations |
|
114 | - * @return int |
|
115 | - * @throws EE_Error |
|
116 | - */ |
|
117 | - protected function incrementRegGroupSize(array $registrations, $update_existing_registrations = true) |
|
118 | - { |
|
119 | - $new_reg_group_size = count($registrations) + 1; |
|
120 | - if ($update_existing_registrations) { |
|
121 | - foreach ($registrations as $registration) { |
|
122 | - if ($registration instanceof EE_Registration) { |
|
123 | - $registration->set_group_size($new_reg_group_size); |
|
124 | - $registration->save(); |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
128 | - return $new_reg_group_size; |
|
129 | - } |
|
111 | + /** |
|
112 | + * @param EE_Registration[] $registrations |
|
113 | + * @param boolean $update_existing_registrations |
|
114 | + * @return int |
|
115 | + * @throws EE_Error |
|
116 | + */ |
|
117 | + protected function incrementRegGroupSize(array $registrations, $update_existing_registrations = true) |
|
118 | + { |
|
119 | + $new_reg_group_size = count($registrations) + 1; |
|
120 | + if ($update_existing_registrations) { |
|
121 | + foreach ($registrations as $registration) { |
|
122 | + if ($registration instanceof EE_Registration) { |
|
123 | + $registration->set_group_size($new_reg_group_size); |
|
124 | + $registration->save(); |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | + return $new_reg_group_size; |
|
129 | + } |
|
130 | 130 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $reindexed_answers = array(); |
84 | 84 | foreach ($answers as $answer) { |
85 | 85 | if ($answer instanceof EE_Answer) { |
86 | - $reindexed_answers[ $answer->question_ID() ] = $answer->value(); |
|
86 | + $reindexed_answers[$answer->question_ID()] = $answer->value(); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | return $reindexed_answers; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | EE_Registration $registration, |
104 | 104 | $previous_answers |
105 | 105 | ) { |
106 | - $old_answer_value = isset($previous_answers[ $question->ID() ]) |
|
107 | - ? $previous_answers[ $question->ID() ] |
|
106 | + $old_answer_value = isset($previous_answers[$question->ID()]) |
|
107 | + ? $previous_answers[$question->ID()] |
|
108 | 108 | : ''; |
109 | 109 | $new_answer = EE_Answer::new_instance( |
110 | 110 | array( |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'ANS_value' => $old_answer_value, |
114 | 114 | ) |
115 | 115 | ); |
116 | - if (! $new_answer instanceof EE_Answer) { |
|
116 | + if ( ! $new_answer instanceof EE_Answer) { |
|
117 | 117 | throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
118 | 118 | } |
119 | 119 | $new_answer->save(); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'RPY_amount' => $payment_amount, |
151 | 151 | ) |
152 | 152 | ); |
153 | - if (! $new_registration_payment instanceof EE_Registration_Payment) { |
|
153 | + if ( ! $new_registration_payment instanceof EE_Registration_Payment) { |
|
154 | 154 | throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
155 | 155 | } |
156 | 156 | $new_registration_payment->save(); |
@@ -27,152 +27,152 @@ |
||
27 | 27 | { |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @param EE_Registration $target_registration |
|
32 | - * @param EE_Registration $registration_to_copy |
|
33 | - * @return bool |
|
34 | - * @throws UnexpectedEntityException |
|
35 | - * @throws EntityNotFoundException |
|
36 | - * @throws RuntimeException |
|
37 | - * @throws EE_Error |
|
38 | - */ |
|
39 | - public function copyRegistrationDetails( |
|
40 | - EE_Registration $target_registration, |
|
41 | - EE_Registration $registration_to_copy |
|
42 | - ) { |
|
43 | - // copy attendee |
|
44 | - $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
|
45 | - $target_registration->updateStatusBasedOnTotalPaid(false); |
|
46 | - $target_registration->save(); |
|
47 | - // get answers to previous reg questions |
|
48 | - $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
|
49 | - // get questions to new event reg form |
|
50 | - $new_event = $target_registration->event(); |
|
51 | - $field_name = 'Event_Question_Group.' |
|
52 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
53 | - $registration_to_copy->is_primary_registrant() |
|
54 | - ); |
|
55 | - $question_groups = $new_event->question_groups([ |
|
56 | - [ |
|
57 | - 'Event.EVT_ID' => $new_event->ID(), |
|
58 | - $field_name => true, |
|
59 | - ], |
|
60 | - 'order_by' => ['QSG_order' => 'ASC'], |
|
61 | - ]); |
|
62 | - foreach ($question_groups as $question_group) { |
|
63 | - if ($question_group instanceof \EE_Question_Group) { |
|
64 | - foreach ($question_group->questions() as $question) { |
|
65 | - if ($question instanceof EE_Question) { |
|
66 | - $this->generateNewAnswer( |
|
67 | - $question, |
|
68 | - $target_registration, |
|
69 | - $answers |
|
70 | - ); |
|
71 | - } |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
75 | - return true; |
|
76 | - } |
|
30 | + /** |
|
31 | + * @param EE_Registration $target_registration |
|
32 | + * @param EE_Registration $registration_to_copy |
|
33 | + * @return bool |
|
34 | + * @throws UnexpectedEntityException |
|
35 | + * @throws EntityNotFoundException |
|
36 | + * @throws RuntimeException |
|
37 | + * @throws EE_Error |
|
38 | + */ |
|
39 | + public function copyRegistrationDetails( |
|
40 | + EE_Registration $target_registration, |
|
41 | + EE_Registration $registration_to_copy |
|
42 | + ) { |
|
43 | + // copy attendee |
|
44 | + $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
|
45 | + $target_registration->updateStatusBasedOnTotalPaid(false); |
|
46 | + $target_registration->save(); |
|
47 | + // get answers to previous reg questions |
|
48 | + $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
|
49 | + // get questions to new event reg form |
|
50 | + $new_event = $target_registration->event(); |
|
51 | + $field_name = 'Event_Question_Group.' |
|
52 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
53 | + $registration_to_copy->is_primary_registrant() |
|
54 | + ); |
|
55 | + $question_groups = $new_event->question_groups([ |
|
56 | + [ |
|
57 | + 'Event.EVT_ID' => $new_event->ID(), |
|
58 | + $field_name => true, |
|
59 | + ], |
|
60 | + 'order_by' => ['QSG_order' => 'ASC'], |
|
61 | + ]); |
|
62 | + foreach ($question_groups as $question_group) { |
|
63 | + if ($question_group instanceof \EE_Question_Group) { |
|
64 | + foreach ($question_group->questions() as $question) { |
|
65 | + if ($question instanceof EE_Question) { |
|
66 | + $this->generateNewAnswer( |
|
67 | + $question, |
|
68 | + $target_registration, |
|
69 | + $answers |
|
70 | + ); |
|
71 | + } |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | + return true; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @param EE_Answer[] $answers |
|
81 | - * @return array |
|
82 | - * @throws EE_Error |
|
83 | - */ |
|
84 | - protected function reindexAnswersByQuestionId(array $answers) |
|
85 | - { |
|
86 | - $reindexed_answers = array(); |
|
87 | - foreach ($answers as $answer) { |
|
88 | - if ($answer instanceof EE_Answer) { |
|
89 | - $reindexed_answers[ $answer->question_ID() ] = $answer->value(); |
|
90 | - } |
|
91 | - } |
|
92 | - return $reindexed_answers; |
|
93 | - } |
|
79 | + /** |
|
80 | + * @param EE_Answer[] $answers |
|
81 | + * @return array |
|
82 | + * @throws EE_Error |
|
83 | + */ |
|
84 | + protected function reindexAnswersByQuestionId(array $answers) |
|
85 | + { |
|
86 | + $reindexed_answers = array(); |
|
87 | + foreach ($answers as $answer) { |
|
88 | + if ($answer instanceof EE_Answer) { |
|
89 | + $reindexed_answers[ $answer->question_ID() ] = $answer->value(); |
|
90 | + } |
|
91 | + } |
|
92 | + return $reindexed_answers; |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * @param EE_Question $question |
|
98 | - * @param EE_Registration $registration |
|
99 | - * @param $previous_answers |
|
100 | - * @return EE_Answer |
|
101 | - * @throws UnexpectedEntityException |
|
102 | - * @throws EE_Error |
|
103 | - */ |
|
104 | - protected function generateNewAnswer( |
|
105 | - EE_Question $question, |
|
106 | - EE_Registration $registration, |
|
107 | - $previous_answers |
|
108 | - ) { |
|
109 | - $old_answer_value = isset($previous_answers[ $question->ID() ]) |
|
110 | - ? $previous_answers[ $question->ID() ] |
|
111 | - : ''; |
|
112 | - $new_answer = EE_Answer::new_instance( |
|
113 | - array( |
|
114 | - 'QST_ID' => $question->ID(), |
|
115 | - 'REG_ID' => $registration->ID(), |
|
116 | - 'ANS_value' => $old_answer_value, |
|
117 | - ) |
|
118 | - ); |
|
119 | - if (! $new_answer instanceof EE_Answer) { |
|
120 | - throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
|
121 | - } |
|
122 | - $new_answer->save(); |
|
123 | - return $new_answer; |
|
124 | - } |
|
96 | + /** |
|
97 | + * @param EE_Question $question |
|
98 | + * @param EE_Registration $registration |
|
99 | + * @param $previous_answers |
|
100 | + * @return EE_Answer |
|
101 | + * @throws UnexpectedEntityException |
|
102 | + * @throws EE_Error |
|
103 | + */ |
|
104 | + protected function generateNewAnswer( |
|
105 | + EE_Question $question, |
|
106 | + EE_Registration $registration, |
|
107 | + $previous_answers |
|
108 | + ) { |
|
109 | + $old_answer_value = isset($previous_answers[ $question->ID() ]) |
|
110 | + ? $previous_answers[ $question->ID() ] |
|
111 | + : ''; |
|
112 | + $new_answer = EE_Answer::new_instance( |
|
113 | + array( |
|
114 | + 'QST_ID' => $question->ID(), |
|
115 | + 'REG_ID' => $registration->ID(), |
|
116 | + 'ANS_value' => $old_answer_value, |
|
117 | + ) |
|
118 | + ); |
|
119 | + if (! $new_answer instanceof EE_Answer) { |
|
120 | + throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
|
121 | + } |
|
122 | + $new_answer->save(); |
|
123 | + return $new_answer; |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | - /** |
|
128 | - * @param EE_Registration $target_registration |
|
129 | - * @param EE_Registration $registration_to_copy |
|
130 | - * @return bool |
|
131 | - * @throws RuntimeException |
|
132 | - * @throws UnexpectedEntityException |
|
133 | - * @throws EE_Error |
|
134 | - */ |
|
135 | - public function copyPaymentDetails( |
|
136 | - EE_Registration $target_registration, |
|
137 | - EE_Registration $registration_to_copy |
|
138 | - ) { |
|
139 | - $save = false; |
|
140 | - $previous_registration_payments = $registration_to_copy->registration_payments(); |
|
141 | - $new_registration_payment_total = 0; |
|
142 | - $registration_to_copy_total = $registration_to_copy->paid(); |
|
143 | - foreach ($previous_registration_payments as $previous_registration_payment) { |
|
144 | - if ( |
|
145 | - $previous_registration_payment instanceof EE_Registration_Payment |
|
146 | - && $previous_registration_payment->payment() instanceof EE_Payment |
|
147 | - && $previous_registration_payment->payment()->is_approved() |
|
148 | - ) { |
|
149 | - $payment_amount = $previous_registration_payment->amount(); |
|
150 | - $new_registration_payment = EE_Registration_Payment::new_instance( |
|
151 | - array( |
|
152 | - 'REG_ID' => $target_registration->ID(), |
|
153 | - 'PAY_ID' => $previous_registration_payment->payment()->ID(), |
|
154 | - 'RPY_amount' => $payment_amount, |
|
155 | - ) |
|
156 | - ); |
|
157 | - if (! $new_registration_payment instanceof EE_Registration_Payment) { |
|
158 | - throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
|
159 | - } |
|
160 | - $new_registration_payment->save(); |
|
161 | - // if new reg payment is good, then set old reg payment amount to zero |
|
162 | - $previous_registration_payment->set_amount(0); |
|
163 | - $previous_registration_payment->save(); |
|
164 | - // now increment/decrement payment amounts |
|
165 | - $new_registration_payment_total += $payment_amount; |
|
166 | - $registration_to_copy_total -= $payment_amount; |
|
167 | - $save = true; |
|
168 | - } |
|
169 | - } |
|
170 | - if ($save) { |
|
171 | - $target_registration->set_paid($new_registration_payment_total); |
|
172 | - $target_registration->save(); |
|
173 | - $registration_to_copy->set_paid($registration_to_copy_total); |
|
174 | - $registration_to_copy->save(); |
|
175 | - } |
|
176 | - return true; |
|
177 | - } |
|
127 | + /** |
|
128 | + * @param EE_Registration $target_registration |
|
129 | + * @param EE_Registration $registration_to_copy |
|
130 | + * @return bool |
|
131 | + * @throws RuntimeException |
|
132 | + * @throws UnexpectedEntityException |
|
133 | + * @throws EE_Error |
|
134 | + */ |
|
135 | + public function copyPaymentDetails( |
|
136 | + EE_Registration $target_registration, |
|
137 | + EE_Registration $registration_to_copy |
|
138 | + ) { |
|
139 | + $save = false; |
|
140 | + $previous_registration_payments = $registration_to_copy->registration_payments(); |
|
141 | + $new_registration_payment_total = 0; |
|
142 | + $registration_to_copy_total = $registration_to_copy->paid(); |
|
143 | + foreach ($previous_registration_payments as $previous_registration_payment) { |
|
144 | + if ( |
|
145 | + $previous_registration_payment instanceof EE_Registration_Payment |
|
146 | + && $previous_registration_payment->payment() instanceof EE_Payment |
|
147 | + && $previous_registration_payment->payment()->is_approved() |
|
148 | + ) { |
|
149 | + $payment_amount = $previous_registration_payment->amount(); |
|
150 | + $new_registration_payment = EE_Registration_Payment::new_instance( |
|
151 | + array( |
|
152 | + 'REG_ID' => $target_registration->ID(), |
|
153 | + 'PAY_ID' => $previous_registration_payment->payment()->ID(), |
|
154 | + 'RPY_amount' => $payment_amount, |
|
155 | + ) |
|
156 | + ); |
|
157 | + if (! $new_registration_payment instanceof EE_Registration_Payment) { |
|
158 | + throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
|
159 | + } |
|
160 | + $new_registration_payment->save(); |
|
161 | + // if new reg payment is good, then set old reg payment amount to zero |
|
162 | + $previous_registration_payment->set_amount(0); |
|
163 | + $previous_registration_payment->save(); |
|
164 | + // now increment/decrement payment amounts |
|
165 | + $new_registration_payment_total += $payment_amount; |
|
166 | + $registration_to_copy_total -= $payment_amount; |
|
167 | + $save = true; |
|
168 | + } |
|
169 | + } |
|
170 | + if ($save) { |
|
171 | + $target_registration->set_paid($new_registration_payment_total); |
|
172 | + $target_registration->save(); |
|
173 | + $registration_to_copy->set_paid($registration_to_copy_total); |
|
174 | + $registration_to_copy->save(); |
|
175 | + } |
|
176 | + return true; |
|
177 | + } |
|
178 | 178 | } |
@@ -27,84 +27,84 @@ |
||
27 | 27 | { |
28 | 28 | |
29 | 29 | |
30 | - protected $attendee; |
|
30 | + protected $attendee; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * AttendeeContactDetailsMetaboxFormHandler constructor. |
|
35 | - * |
|
36 | - * @param EE_Attendee $attendee |
|
37 | - * @param EE_Registry $registry |
|
38 | - * @throws DomainException |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - * @throws InvalidArgumentException |
|
41 | - */ |
|
42 | - public function __construct(EE_Attendee $attendee, EE_Registry $registry) |
|
43 | - { |
|
44 | - $this->attendee = $attendee; |
|
45 | - $label = esc_html__('Contact Details', 'event_espresso'); |
|
46 | - parent::__construct( |
|
47 | - $label, |
|
48 | - $label, |
|
49 | - 'attendee_contact_details', |
|
50 | - '', |
|
51 | - FormHandler::DO_NOT_SETUP_FORM, |
|
52 | - $registry |
|
53 | - ); |
|
54 | - } |
|
33 | + /** |
|
34 | + * AttendeeContactDetailsMetaboxFormHandler constructor. |
|
35 | + * |
|
36 | + * @param EE_Attendee $attendee |
|
37 | + * @param EE_Registry $registry |
|
38 | + * @throws DomainException |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + * @throws InvalidArgumentException |
|
41 | + */ |
|
42 | + public function __construct(EE_Attendee $attendee, EE_Registry $registry) |
|
43 | + { |
|
44 | + $this->attendee = $attendee; |
|
45 | + $label = esc_html__('Contact Details', 'event_espresso'); |
|
46 | + parent::__construct( |
|
47 | + $label, |
|
48 | + $label, |
|
49 | + 'attendee_contact_details', |
|
50 | + '', |
|
51 | + FormHandler::DO_NOT_SETUP_FORM, |
|
52 | + $registry |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * creates and returns the actual form |
|
58 | - * |
|
59 | - * @return EE_Form_Section_Proper |
|
60 | - * @throws EE_Error |
|
61 | - */ |
|
62 | - public function generate() |
|
63 | - { |
|
64 | - return new EE_Form_Section_Proper( |
|
65 | - array( |
|
66 | - 'name' => 'attendee_contact_details', |
|
67 | - 'html_id' => 'attendee-contact-details', |
|
68 | - 'html_class' => 'form-table', |
|
69 | - 'layout_strategy' => new EE_Admin_One_Column_Layout(), |
|
70 | - 'subsections' => array( |
|
71 | - 'ATT_email' => new EE_Email_Input( |
|
72 | - array( |
|
73 | - 'default' => $this->attendee->email(), |
|
74 | - 'html_label_text' => esc_html__('Email Address', 'event_espresso'), |
|
75 | - 'required' => true, |
|
76 | - ) |
|
77 | - ), |
|
78 | - 'ATT_phone' => new EE_Text_Input( |
|
79 | - array( |
|
80 | - 'default' => $this->attendee->phone(), |
|
81 | - 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
82 | - ) |
|
83 | - ), |
|
84 | - ), |
|
85 | - ) |
|
86 | - ); |
|
87 | - } |
|
56 | + /** |
|
57 | + * creates and returns the actual form |
|
58 | + * |
|
59 | + * @return EE_Form_Section_Proper |
|
60 | + * @throws EE_Error |
|
61 | + */ |
|
62 | + public function generate() |
|
63 | + { |
|
64 | + return new EE_Form_Section_Proper( |
|
65 | + array( |
|
66 | + 'name' => 'attendee_contact_details', |
|
67 | + 'html_id' => 'attendee-contact-details', |
|
68 | + 'html_class' => 'form-table', |
|
69 | + 'layout_strategy' => new EE_Admin_One_Column_Layout(), |
|
70 | + 'subsections' => array( |
|
71 | + 'ATT_email' => new EE_Email_Input( |
|
72 | + array( |
|
73 | + 'default' => $this->attendee->email(), |
|
74 | + 'html_label_text' => esc_html__('Email Address', 'event_espresso'), |
|
75 | + 'required' => true, |
|
76 | + ) |
|
77 | + ), |
|
78 | + 'ATT_phone' => new EE_Text_Input( |
|
79 | + array( |
|
80 | + 'default' => $this->attendee->phone(), |
|
81 | + 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
82 | + ) |
|
83 | + ), |
|
84 | + ), |
|
85 | + ) |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * Process form data. |
|
92 | - * |
|
93 | - * @param array $form_data |
|
94 | - * @return bool |
|
95 | - * @throws EE_Error |
|
96 | - * @throws InvalidFormSubmissionException |
|
97 | - * @throws LogicException |
|
98 | - */ |
|
99 | - public function process($form_data = array()) |
|
100 | - { |
|
101 | - $valid_data = (array) parent::process($form_data); |
|
102 | - if (empty($valid_data)) { |
|
103 | - return false; |
|
104 | - } |
|
105 | - $this->attendee->set_email($valid_data['ATT_email']); |
|
106 | - $this->attendee->set_phone($valid_data['ATT_phone']); |
|
107 | - $updated = $this->attendee->save(); |
|
108 | - return $updated !== false; |
|
109 | - } |
|
90 | + /** |
|
91 | + * Process form data. |
|
92 | + * |
|
93 | + * @param array $form_data |
|
94 | + * @return bool |
|
95 | + * @throws EE_Error |
|
96 | + * @throws InvalidFormSubmissionException |
|
97 | + * @throws LogicException |
|
98 | + */ |
|
99 | + public function process($form_data = array()) |
|
100 | + { |
|
101 | + $valid_data = (array) parent::process($form_data); |
|
102 | + if (empty($valid_data)) { |
|
103 | + return false; |
|
104 | + } |
|
105 | + $this->attendee->set_email($valid_data['ATT_email']); |
|
106 | + $this->attendee->set_phone($valid_data['ATT_phone']); |
|
107 | + $updated = $this->attendee->save(); |
|
108 | + return $updated !== false; |
|
109 | + } |
|
110 | 110 | } |
@@ -15,56 +15,56 @@ |
||
15 | 15 | class EmailAddress |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var string $email_address |
|
20 | - */ |
|
21 | - private $email_address; |
|
18 | + /** |
|
19 | + * @var string $email_address |
|
20 | + */ |
|
21 | + private $email_address; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * EmailAddress constructor. |
|
26 | - * |
|
27 | - * @param string $email_address |
|
28 | - * @param EmailValidatorInterface $validator |
|
29 | - * @throws EmailValidationException |
|
30 | - */ |
|
31 | - public function __construct($email_address, EmailValidatorInterface $validator) |
|
32 | - { |
|
33 | - $validator->validate($email_address); |
|
34 | - $this->email_address = $email_address; |
|
35 | - } |
|
24 | + /** |
|
25 | + * EmailAddress constructor. |
|
26 | + * |
|
27 | + * @param string $email_address |
|
28 | + * @param EmailValidatorInterface $validator |
|
29 | + * @throws EmailValidationException |
|
30 | + */ |
|
31 | + public function __construct($email_address, EmailValidatorInterface $validator) |
|
32 | + { |
|
33 | + $validator->validate($email_address); |
|
34 | + $this->email_address = $email_address; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * returns the string value for this EmailAddress |
|
40 | - * |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function get() |
|
44 | - { |
|
45 | - return $this->email_address; |
|
46 | - } |
|
38 | + /** |
|
39 | + * returns the string value for this EmailAddress |
|
40 | + * |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function get() |
|
44 | + { |
|
45 | + return $this->email_address; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * compare another EmailAddress to this one to determine if they are the same |
|
51 | - * |
|
52 | - * @param EmailAddress $address |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - public function equals(EmailAddress $address) |
|
56 | - { |
|
57 | - return strtolower((string) $this) === strtolower((string) $address); |
|
58 | - } |
|
49 | + /** |
|
50 | + * compare another EmailAddress to this one to determine if they are the same |
|
51 | + * |
|
52 | + * @param EmailAddress $address |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + public function equals(EmailAddress $address) |
|
56 | + { |
|
57 | + return strtolower((string) $this) === strtolower((string) $address); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * allows an EmailAddress object to be used as a string |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function __toString() |
|
67 | - { |
|
68 | - return $this->email_address; |
|
69 | - } |
|
61 | + /** |
|
62 | + * allows an EmailAddress object to be used as a string |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function __toString() |
|
67 | + { |
|
68 | + return $this->email_address; |
|
69 | + } |
|
70 | 70 | } |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class AssetRegistrationException extends RuntimeException |
18 | 18 | { |
19 | - /** |
|
20 | - * @param $script_handle |
|
21 | - * @param string $message |
|
22 | - * @param int $code |
|
23 | - * @param Exception|null $previous |
|
24 | - */ |
|
25 | - public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | - { |
|
27 | - if (empty($message)) { |
|
28 | - $message = sprintf( |
|
29 | - esc_html_x( |
|
30 | - 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | - 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - $script_handle |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
19 | + /** |
|
20 | + * @param $script_handle |
|
21 | + * @param string $message |
|
22 | + * @param int $code |
|
23 | + * @param Exception|null $previous |
|
24 | + */ |
|
25 | + public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | + { |
|
27 | + if (empty($message)) { |
|
28 | + $message = sprintf( |
|
29 | + esc_html_x( |
|
30 | + 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | + 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + $script_handle |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -16,20 +16,20 @@ |
||
16 | 16 | interface PrivacyPolicyInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Returns the translated name to display in this privacy policy's section's title |
|
21 | - * |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function getName(); |
|
19 | + /** |
|
20 | + * Returns the translated name to display in this privacy policy's section's title |
|
21 | + * |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function getName(); |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Returns the suggested privacy policy content for this plugin. May contain HTML |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getContent(); |
|
27 | + /** |
|
28 | + * Returns the suggested privacy policy content for this plugin. May contain HTML |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getContent(); |
|
33 | 33 | } |
34 | 34 | // End of file PrivacyPolicyInterface.php |
35 | 35 | // Location: EventEspresso\core\domain\services\admin/PrivacyPolicyInterface.php |
@@ -15,106 +15,106 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportTransaction implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Transaction $transaction_model |
|
20 | - */ |
|
21 | - protected $transaction_model; |
|
18 | + /** |
|
19 | + * @var EEM_Transaction $transaction_model |
|
20 | + */ |
|
21 | + protected $transaction_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportTransaction constructor. |
|
25 | - * |
|
26 | - * @param $transaction_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Transaction $transaction_model) |
|
29 | - { |
|
30 | - $this->transaction_model = $transaction_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportTransaction constructor. |
|
25 | + * |
|
26 | + * @param $transaction_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Transaction $transaction_model) |
|
29 | + { |
|
30 | + $this->transaction_model = $transaction_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $page_size = 10; |
|
58 | - $transactions = $this->transaction_model->get_all( |
|
59 | - array( |
|
60 | - array( |
|
61 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | - ), |
|
63 | - 'limit' => array( |
|
64 | - ($page - 1) * $page_size, |
|
65 | - $page_size, |
|
66 | - ), |
|
67 | - ) |
|
68 | - ); |
|
69 | - $export_fields = array_intersect_key( |
|
70 | - EEM_Transaction::instance()->field_settings(), |
|
71 | - array_flip( |
|
72 | - array( |
|
73 | - 'TXN_timestamp', |
|
74 | - 'TXN_total', |
|
75 | - 'TXN_paid', |
|
76 | - 'TXN_session_data', |
|
77 | - ) |
|
78 | - ) |
|
79 | - ); |
|
80 | - $export_items = array(); |
|
81 | - $found_something = false; |
|
82 | - foreach ($transactions as $transaction) { |
|
83 | - $found_something = true; |
|
84 | - $data = array(); |
|
85 | - foreach ($export_fields as $field_name => $field_obj) { |
|
86 | - if ($field_name === 'TXN_session_data') { |
|
87 | - $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | - } else { |
|
89 | - $value = $transaction->get_pretty($field_name); |
|
90 | - } |
|
91 | - $data[] = array( |
|
92 | - 'name' => $field_obj->get_nicename(), |
|
93 | - 'value' => $value, |
|
94 | - ); |
|
95 | - } |
|
96 | - $export_items[] = array( |
|
97 | - 'group_id' => 'transactions', |
|
98 | - 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | - 'item_id' => $transaction->ID(), |
|
100 | - 'data' => $data, |
|
101 | - ); |
|
102 | - } |
|
103 | - return array( |
|
104 | - 'data' => $export_items, |
|
105 | - 'done' => ! $found_something, |
|
106 | - ); |
|
107 | - } |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $page_size = 10; |
|
58 | + $transactions = $this->transaction_model->get_all( |
|
59 | + array( |
|
60 | + array( |
|
61 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | + ), |
|
63 | + 'limit' => array( |
|
64 | + ($page - 1) * $page_size, |
|
65 | + $page_size, |
|
66 | + ), |
|
67 | + ) |
|
68 | + ); |
|
69 | + $export_fields = array_intersect_key( |
|
70 | + EEM_Transaction::instance()->field_settings(), |
|
71 | + array_flip( |
|
72 | + array( |
|
73 | + 'TXN_timestamp', |
|
74 | + 'TXN_total', |
|
75 | + 'TXN_paid', |
|
76 | + 'TXN_session_data', |
|
77 | + ) |
|
78 | + ) |
|
79 | + ); |
|
80 | + $export_items = array(); |
|
81 | + $found_something = false; |
|
82 | + foreach ($transactions as $transaction) { |
|
83 | + $found_something = true; |
|
84 | + $data = array(); |
|
85 | + foreach ($export_fields as $field_name => $field_obj) { |
|
86 | + if ($field_name === 'TXN_session_data') { |
|
87 | + $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | + } else { |
|
89 | + $value = $transaction->get_pretty($field_name); |
|
90 | + } |
|
91 | + $data[] = array( |
|
92 | + 'name' => $field_obj->get_nicename(), |
|
93 | + 'value' => $value, |
|
94 | + ); |
|
95 | + } |
|
96 | + $export_items[] = array( |
|
97 | + 'group_id' => 'transactions', |
|
98 | + 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | + 'item_id' => $transaction->ID(), |
|
100 | + 'data' => $data, |
|
101 | + ); |
|
102 | + } |
|
103 | + return array( |
|
104 | + 'data' => $export_items, |
|
105 | + 'done' => ! $found_something, |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Gets the Translated name of this exporter |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function name() |
|
115 | - { |
|
116 | - return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | - } |
|
109 | + /** |
|
110 | + * Gets the Translated name of this exporter |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function name() |
|
115 | + { |
|
116 | + return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | // End of file ExportTransaction.php |
120 | 120 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportTransaction.php |
@@ -16,112 +16,112 @@ |
||
16 | 16 | */ |
17 | 17 | class ExportCheckins implements PersonalDataExporterInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EEM_Checkin |
|
21 | - */ |
|
22 | - protected $checkin_model; |
|
19 | + /** |
|
20 | + * @var EEM_Checkin |
|
21 | + */ |
|
22 | + protected $checkin_model; |
|
23 | 23 | |
24 | - /** |
|
25 | - * ExportCheckins constructor. |
|
26 | - * |
|
27 | - * @param EEM_Checkin $checkin_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Checkin $checkin_model) |
|
30 | - { |
|
31 | - $this->checkin_model = $checkin_model; |
|
32 | - } |
|
24 | + /** |
|
25 | + * ExportCheckins constructor. |
|
26 | + * |
|
27 | + * @param EEM_Checkin $checkin_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Checkin $checkin_model) |
|
30 | + { |
|
31 | + $this->checkin_model = $checkin_model; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Returns data for export. |
|
37 | - * |
|
38 | - * @param string $email_address , |
|
39 | - * @param int $page starts at 1, not 0 |
|
40 | - * @return array { |
|
41 | - * @type array $data { |
|
42 | - * @type array { |
|
43 | - * @type string $group_id (not translated, same for all exports) |
|
44 | - * @type string $group_label (translated string) |
|
45 | - * @type string|int $item_id |
|
46 | - * @type array $data { |
|
47 | - * @type array { |
|
48 | - * @type string $name what's shown in the left-column of the export row |
|
49 | - * @type string $value what's showin the right-column of the export row |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - * } |
|
55 | - */ |
|
56 | - public function export($email_address, $page = 1) |
|
57 | - { |
|
58 | - $page_size = 10; |
|
59 | - $checkins = $this->checkin_model->get_all( |
|
60 | - array( |
|
61 | - array( |
|
62 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
63 | - ), |
|
64 | - 'limit' => array( |
|
65 | - ($page - 1) * $page_size, |
|
66 | - $page_size, |
|
67 | - ), |
|
68 | - 'force_join' => array('Registration.Event'), |
|
69 | - ) |
|
70 | - ); |
|
35 | + /** |
|
36 | + * Returns data for export. |
|
37 | + * |
|
38 | + * @param string $email_address , |
|
39 | + * @param int $page starts at 1, not 0 |
|
40 | + * @return array { |
|
41 | + * @type array $data { |
|
42 | + * @type array { |
|
43 | + * @type string $group_id (not translated, same for all exports) |
|
44 | + * @type string $group_label (translated string) |
|
45 | + * @type string|int $item_id |
|
46 | + * @type array $data { |
|
47 | + * @type array { |
|
48 | + * @type string $name what's shown in the left-column of the export row |
|
49 | + * @type string $value what's showin the right-column of the export row |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + * } |
|
55 | + */ |
|
56 | + public function export($email_address, $page = 1) |
|
57 | + { |
|
58 | + $page_size = 10; |
|
59 | + $checkins = $this->checkin_model->get_all( |
|
60 | + array( |
|
61 | + array( |
|
62 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
63 | + ), |
|
64 | + 'limit' => array( |
|
65 | + ($page - 1) * $page_size, |
|
66 | + $page_size, |
|
67 | + ), |
|
68 | + 'force_join' => array('Registration.Event'), |
|
69 | + ) |
|
70 | + ); |
|
71 | 71 | |
72 | - if (empty($checkins)) { |
|
73 | - return array( |
|
74 | - 'data' => array(), |
|
75 | - 'done' => true, |
|
76 | - ); |
|
77 | - } |
|
72 | + if (empty($checkins)) { |
|
73 | + return array( |
|
74 | + 'data' => array(), |
|
75 | + 'done' => true, |
|
76 | + ); |
|
77 | + } |
|
78 | 78 | |
79 | - $export_items = array(); |
|
80 | - foreach ($checkins as $checkin) { |
|
81 | - $reg = $checkin->get_first_related('Registration'); |
|
82 | - if ($reg instanceof EE_Registration) { |
|
83 | - $event_name = $reg->event_name(); |
|
84 | - } else { |
|
85 | - $event_name = esc_html__('Unknown', 'event_espresso'); |
|
86 | - } |
|
87 | - $export_items[] = |
|
88 | - array( |
|
89 | - 'group_id' => 'check-ins', |
|
90 | - 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
91 | - 'item_id' => $checkin->ID(), |
|
92 | - 'data' => array( |
|
93 | - array( |
|
94 | - 'name' => esc_html__('Time', 'event_espresso'), |
|
95 | - 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
96 | - ), |
|
97 | - array( |
|
98 | - 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
99 | - 'value' => $checkin->get('CHK_in') |
|
100 | - ? esc_html__('In', 'event_espresso') |
|
101 | - : esc_html__('Out', 'event_espresso'), |
|
102 | - ), |
|
103 | - array( |
|
104 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
105 | - 'value' => $event_name, |
|
106 | - ), |
|
107 | - ), |
|
108 | - ); |
|
109 | - } |
|
110 | - return array( |
|
111 | - 'data' => $export_items, |
|
112 | - 'done' => true, |
|
113 | - ); |
|
114 | - } |
|
79 | + $export_items = array(); |
|
80 | + foreach ($checkins as $checkin) { |
|
81 | + $reg = $checkin->get_first_related('Registration'); |
|
82 | + if ($reg instanceof EE_Registration) { |
|
83 | + $event_name = $reg->event_name(); |
|
84 | + } else { |
|
85 | + $event_name = esc_html__('Unknown', 'event_espresso'); |
|
86 | + } |
|
87 | + $export_items[] = |
|
88 | + array( |
|
89 | + 'group_id' => 'check-ins', |
|
90 | + 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
91 | + 'item_id' => $checkin->ID(), |
|
92 | + 'data' => array( |
|
93 | + array( |
|
94 | + 'name' => esc_html__('Time', 'event_espresso'), |
|
95 | + 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
96 | + ), |
|
97 | + array( |
|
98 | + 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
99 | + 'value' => $checkin->get('CHK_in') |
|
100 | + ? esc_html__('In', 'event_espresso') |
|
101 | + : esc_html__('Out', 'event_espresso'), |
|
102 | + ), |
|
103 | + array( |
|
104 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
105 | + 'value' => $event_name, |
|
106 | + ), |
|
107 | + ), |
|
108 | + ); |
|
109 | + } |
|
110 | + return array( |
|
111 | + 'data' => $export_items, |
|
112 | + 'done' => true, |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Gets the Translated name of this exporter |
|
118 | - * |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function name() |
|
122 | - { |
|
123 | - return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
124 | - } |
|
116 | + /** |
|
117 | + * Gets the Translated name of this exporter |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function name() |
|
122 | + { |
|
123 | + return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | // End of file ExportCheckins.php |
127 | 127 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportCheckins.php |