@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | //If there is no event objecdt by now then get out. |
167 | - if (! $this->_event instanceof EE_Event) { |
|
167 | + if ( ! $this->_event instanceof EE_Event) { |
|
168 | 168 | return ''; |
169 | 169 | } |
170 | 170 | |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | break; |
191 | 191 | |
192 | 192 | case 'image': |
193 | - return '<img src="' . $venue->feature_image_url(array(200, 200,)) |
|
194 | - . '" alt="' . sprintf( |
|
193 | + return '<img src="'.$venue->feature_image_url(array(200, 200,)) |
|
194 | + . '" alt="'.sprintf( |
|
195 | 195 | esc_attr__('%s Feature Image', 'event_espresso'), |
196 | 196 | $venue->get('VNU_name') |
197 | - ) . '" />'; |
|
197 | + ).'" />'; |
|
198 | 198 | break; |
199 | 199 | |
200 | 200 | case 'phone': |
@@ -16,257 +16,257 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Will hold the EE_Event if available |
|
21 | - * |
|
22 | - * @var EE_Event |
|
23 | - */ |
|
24 | - protected $_event; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * Initialize properties |
|
29 | - */ |
|
30 | - protected function _init_props() |
|
31 | - { |
|
32 | - $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
33 | - $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
34 | - $this->_shortcodes = array( |
|
35 | - '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
36 | - '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
37 | - '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
38 | - '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
39 | - '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
40 | - '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
41 | - '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
42 | - '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
43 | - '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
44 | - '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
45 | - '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
46 | - 'This just outputs the venue address in a semantic address format.', |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
50 | - '[GOOGLE_MAP_URL]' => esc_html__( |
|
51 | - 'URL for the google map associated with the venue.', |
|
52 | - 'event_espresso' |
|
53 | - ), |
|
54 | - '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
55 | - '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Parse incoming shortcode |
|
62 | - * @param string $shortcode |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - protected function _parser($shortcode) |
|
66 | - { |
|
67 | - |
|
68 | - switch ($shortcode) { |
|
69 | - case '[VENUE_TITLE]': |
|
70 | - return $this->_venue('title'); |
|
71 | - break; |
|
72 | - |
|
73 | - case '[VENUE_DESCRIPTION]': |
|
74 | - return $this->_venue('description'); |
|
75 | - break; |
|
76 | - |
|
77 | - case '[VENUE_URL]': |
|
78 | - return $this->_venue('url'); |
|
79 | - break; |
|
80 | - |
|
81 | - case '[VENUE_IMAGE]': |
|
82 | - return $this->_venue('image'); |
|
83 | - break; |
|
84 | - |
|
85 | - case '[VENUE_PHONE]': |
|
86 | - return $this->_venue('phone'); |
|
87 | - break; |
|
88 | - |
|
89 | - case '[VENUE_ADDRESS]': |
|
90 | - return $this->_venue('address'); |
|
91 | - break; |
|
92 | - |
|
93 | - case '[VENUE_ADDRESS2]': |
|
94 | - return $this->_venue('address2'); |
|
95 | - break; |
|
96 | - |
|
97 | - case '[VENUE_CITY]': |
|
98 | - return $this->_venue('city'); |
|
99 | - break; |
|
100 | - |
|
101 | - case '[VENUE_COUNTRY]': |
|
102 | - return $this->_venue('country'); |
|
103 | - break; |
|
104 | - |
|
105 | - case '[VENUE_STATE]': |
|
106 | - return $this->_venue('state'); |
|
107 | - break; |
|
108 | - |
|
109 | - case '[VENUE_ZIP]': |
|
110 | - return $this->_venue('zip'); |
|
111 | - break; |
|
112 | - |
|
113 | - case '[VENUE_FORMATTED_ADDRESS]': |
|
114 | - return $this->_venue('formatted_address'); |
|
115 | - break; |
|
116 | - |
|
117 | - case '[GOOGLE_MAP_URL]': |
|
118 | - return $this->_venue('gmap_url'); |
|
119 | - break; |
|
120 | - |
|
121 | - case '[GOOGLE_MAP_LINK]': |
|
122 | - return $this->_venue('gmap_link'); |
|
123 | - break; |
|
124 | - |
|
125 | - case '[GOOGLE_MAP_IMAGE]': |
|
126 | - return $this->_venue('gmap_link_img'); |
|
127 | - break; |
|
128 | - |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * This retrieves the specified venue information |
|
135 | - * |
|
136 | - * @param string $field What Venue field to retrieve |
|
137 | - * @return string What was retrieved! |
|
138 | - * @throws EE_Error |
|
139 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
140 | - */ |
|
141 | - private function _venue($field) |
|
142 | - { |
|
143 | - //we need the EE_Event object to get the venue. |
|
144 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
145 | - |
|
146 | - //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
|
147 | - if (empty($this->_event)) { |
|
148 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
149 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
150 | - |
|
151 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : null; |
|
152 | - |
|
153 | - //if still empty do we have a ticket data item? |
|
154 | - $this->_event = empty($this->_event) |
|
155 | - && $this->_data instanceof EE_Ticket |
|
156 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
157 | - ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
158 | - : $this->_event; |
|
159 | - |
|
160 | - //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee and use that. |
|
161 | - $event = $aee instanceof EE_Messages_Addressee ? reset($aee->events) : array(); |
|
162 | - $this->_event = empty($this->_event) && ! empty($events) ? $event : $this->_event; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - //If there is no event objecdt by now then get out. |
|
167 | - if (! $this->_event instanceof EE_Event) { |
|
168 | - return ''; |
|
169 | - } |
|
170 | - |
|
171 | - /** @var EE_Venue $venue */ |
|
172 | - $venue = $this->_event->get_first_related('Venue'); |
|
173 | - |
|
174 | - if (empty($venue)) { |
|
175 | - return ''; |
|
176 | - } //no venue so get out. |
|
177 | - |
|
178 | - switch ($field) { |
|
179 | - case 'title': |
|
180 | - return $venue->get('VNU_name'); |
|
181 | - break; |
|
182 | - |
|
183 | - case 'description': |
|
184 | - return $venue->get('VNU_desc'); |
|
185 | - break; |
|
186 | - |
|
187 | - case 'url': |
|
188 | - $url = $venue->get('VNU_url'); |
|
189 | - return empty($url) ? $venue->get_permalink() : $url; |
|
190 | - break; |
|
191 | - |
|
192 | - case 'image': |
|
193 | - return '<img src="' . $venue->feature_image_url(array(200, 200,)) |
|
194 | - . '" alt="' . sprintf( |
|
195 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
196 | - $venue->get('VNU_name') |
|
197 | - ) . '" />'; |
|
198 | - break; |
|
199 | - |
|
200 | - case 'phone': |
|
201 | - return $venue->get('VNU_phone'); |
|
202 | - break; |
|
203 | - |
|
204 | - case 'address': |
|
205 | - return $venue->get('VNU_address'); |
|
206 | - break; |
|
207 | - |
|
208 | - case 'address2': |
|
209 | - return $venue->get('VNU_address2'); |
|
210 | - break; |
|
211 | - |
|
212 | - case 'city': |
|
213 | - return $venue->get('VNU_city'); |
|
214 | - break; |
|
215 | - |
|
216 | - case 'state': |
|
217 | - $state = $venue->state_obj(); |
|
218 | - return is_object($state) ? $state->get('STA_name') : ''; |
|
219 | - break; |
|
220 | - |
|
221 | - case 'country': |
|
222 | - $country = $venue->country_obj(); |
|
223 | - return is_object($country) ? $country->get('CNT_name') : ''; |
|
224 | - break; |
|
225 | - |
|
226 | - case 'zip': |
|
227 | - return $venue->get('VNU_zip'); |
|
228 | - break; |
|
229 | - |
|
230 | - case 'formatted_address': |
|
231 | - return EEH_Address::format($venue); |
|
232 | - break; |
|
233 | - |
|
234 | - case 'gmap_link': |
|
235 | - case 'gmap_url': |
|
236 | - case 'gmap_link_img': |
|
237 | - $atts = $this->get_map_attributes($venue, $field); |
|
238 | - return EEH_Maps::google_map_link($atts); |
|
239 | - break; |
|
240 | - } |
|
241 | - return ''; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Generates the attributes for retrieving a google_map artifact. |
|
247 | - * @param EE_Venue $venue |
|
248 | - * @param string $field |
|
249 | - * @return array |
|
250 | - * @throws EE_Error |
|
251 | - */ |
|
252 | - protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
253 | - { |
|
254 | - $state = $venue->state_obj(); |
|
255 | - $country = $venue->country_obj(); |
|
256 | - $atts = array( |
|
257 | - 'id' => $venue->ID(), |
|
258 | - 'address' => $venue->get('VNU_address'), |
|
259 | - 'city' => $venue->get('VNU_city'), |
|
260 | - 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
261 | - 'zip' => $venue->get('VNU_zip'), |
|
262 | - 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
263 | - 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
264 | - 'map_w' => 200, |
|
265 | - 'map_h' => 200, |
|
266 | - ); |
|
267 | - if ($field === 'gmap_url') { |
|
268 | - $atts['type'] = 'url_only'; |
|
269 | - } |
|
270 | - return $atts; |
|
271 | - } |
|
19 | + /** |
|
20 | + * Will hold the EE_Event if available |
|
21 | + * |
|
22 | + * @var EE_Event |
|
23 | + */ |
|
24 | + protected $_event; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * Initialize properties |
|
29 | + */ |
|
30 | + protected function _init_props() |
|
31 | + { |
|
32 | + $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
33 | + $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
34 | + $this->_shortcodes = array( |
|
35 | + '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
36 | + '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
37 | + '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
38 | + '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
39 | + '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
40 | + '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
41 | + '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
42 | + '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
43 | + '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
44 | + '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
45 | + '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
46 | + 'This just outputs the venue address in a semantic address format.', |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
50 | + '[GOOGLE_MAP_URL]' => esc_html__( |
|
51 | + 'URL for the google map associated with the venue.', |
|
52 | + 'event_espresso' |
|
53 | + ), |
|
54 | + '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
55 | + '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Parse incoming shortcode |
|
62 | + * @param string $shortcode |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + protected function _parser($shortcode) |
|
66 | + { |
|
67 | + |
|
68 | + switch ($shortcode) { |
|
69 | + case '[VENUE_TITLE]': |
|
70 | + return $this->_venue('title'); |
|
71 | + break; |
|
72 | + |
|
73 | + case '[VENUE_DESCRIPTION]': |
|
74 | + return $this->_venue('description'); |
|
75 | + break; |
|
76 | + |
|
77 | + case '[VENUE_URL]': |
|
78 | + return $this->_venue('url'); |
|
79 | + break; |
|
80 | + |
|
81 | + case '[VENUE_IMAGE]': |
|
82 | + return $this->_venue('image'); |
|
83 | + break; |
|
84 | + |
|
85 | + case '[VENUE_PHONE]': |
|
86 | + return $this->_venue('phone'); |
|
87 | + break; |
|
88 | + |
|
89 | + case '[VENUE_ADDRESS]': |
|
90 | + return $this->_venue('address'); |
|
91 | + break; |
|
92 | + |
|
93 | + case '[VENUE_ADDRESS2]': |
|
94 | + return $this->_venue('address2'); |
|
95 | + break; |
|
96 | + |
|
97 | + case '[VENUE_CITY]': |
|
98 | + return $this->_venue('city'); |
|
99 | + break; |
|
100 | + |
|
101 | + case '[VENUE_COUNTRY]': |
|
102 | + return $this->_venue('country'); |
|
103 | + break; |
|
104 | + |
|
105 | + case '[VENUE_STATE]': |
|
106 | + return $this->_venue('state'); |
|
107 | + break; |
|
108 | + |
|
109 | + case '[VENUE_ZIP]': |
|
110 | + return $this->_venue('zip'); |
|
111 | + break; |
|
112 | + |
|
113 | + case '[VENUE_FORMATTED_ADDRESS]': |
|
114 | + return $this->_venue('formatted_address'); |
|
115 | + break; |
|
116 | + |
|
117 | + case '[GOOGLE_MAP_URL]': |
|
118 | + return $this->_venue('gmap_url'); |
|
119 | + break; |
|
120 | + |
|
121 | + case '[GOOGLE_MAP_LINK]': |
|
122 | + return $this->_venue('gmap_link'); |
|
123 | + break; |
|
124 | + |
|
125 | + case '[GOOGLE_MAP_IMAGE]': |
|
126 | + return $this->_venue('gmap_link_img'); |
|
127 | + break; |
|
128 | + |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * This retrieves the specified venue information |
|
135 | + * |
|
136 | + * @param string $field What Venue field to retrieve |
|
137 | + * @return string What was retrieved! |
|
138 | + * @throws EE_Error |
|
139 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
140 | + */ |
|
141 | + private function _venue($field) |
|
142 | + { |
|
143 | + //we need the EE_Event object to get the venue. |
|
144 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
145 | + |
|
146 | + //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
|
147 | + if (empty($this->_event)) { |
|
148 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
149 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
150 | + |
|
151 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : null; |
|
152 | + |
|
153 | + //if still empty do we have a ticket data item? |
|
154 | + $this->_event = empty($this->_event) |
|
155 | + && $this->_data instanceof EE_Ticket |
|
156 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
157 | + ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
158 | + : $this->_event; |
|
159 | + |
|
160 | + //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee and use that. |
|
161 | + $event = $aee instanceof EE_Messages_Addressee ? reset($aee->events) : array(); |
|
162 | + $this->_event = empty($this->_event) && ! empty($events) ? $event : $this->_event; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + //If there is no event objecdt by now then get out. |
|
167 | + if (! $this->_event instanceof EE_Event) { |
|
168 | + return ''; |
|
169 | + } |
|
170 | + |
|
171 | + /** @var EE_Venue $venue */ |
|
172 | + $venue = $this->_event->get_first_related('Venue'); |
|
173 | + |
|
174 | + if (empty($venue)) { |
|
175 | + return ''; |
|
176 | + } //no venue so get out. |
|
177 | + |
|
178 | + switch ($field) { |
|
179 | + case 'title': |
|
180 | + return $venue->get('VNU_name'); |
|
181 | + break; |
|
182 | + |
|
183 | + case 'description': |
|
184 | + return $venue->get('VNU_desc'); |
|
185 | + break; |
|
186 | + |
|
187 | + case 'url': |
|
188 | + $url = $venue->get('VNU_url'); |
|
189 | + return empty($url) ? $venue->get_permalink() : $url; |
|
190 | + break; |
|
191 | + |
|
192 | + case 'image': |
|
193 | + return '<img src="' . $venue->feature_image_url(array(200, 200,)) |
|
194 | + . '" alt="' . sprintf( |
|
195 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
196 | + $venue->get('VNU_name') |
|
197 | + ) . '" />'; |
|
198 | + break; |
|
199 | + |
|
200 | + case 'phone': |
|
201 | + return $venue->get('VNU_phone'); |
|
202 | + break; |
|
203 | + |
|
204 | + case 'address': |
|
205 | + return $venue->get('VNU_address'); |
|
206 | + break; |
|
207 | + |
|
208 | + case 'address2': |
|
209 | + return $venue->get('VNU_address2'); |
|
210 | + break; |
|
211 | + |
|
212 | + case 'city': |
|
213 | + return $venue->get('VNU_city'); |
|
214 | + break; |
|
215 | + |
|
216 | + case 'state': |
|
217 | + $state = $venue->state_obj(); |
|
218 | + return is_object($state) ? $state->get('STA_name') : ''; |
|
219 | + break; |
|
220 | + |
|
221 | + case 'country': |
|
222 | + $country = $venue->country_obj(); |
|
223 | + return is_object($country) ? $country->get('CNT_name') : ''; |
|
224 | + break; |
|
225 | + |
|
226 | + case 'zip': |
|
227 | + return $venue->get('VNU_zip'); |
|
228 | + break; |
|
229 | + |
|
230 | + case 'formatted_address': |
|
231 | + return EEH_Address::format($venue); |
|
232 | + break; |
|
233 | + |
|
234 | + case 'gmap_link': |
|
235 | + case 'gmap_url': |
|
236 | + case 'gmap_link_img': |
|
237 | + $atts = $this->get_map_attributes($venue, $field); |
|
238 | + return EEH_Maps::google_map_link($atts); |
|
239 | + break; |
|
240 | + } |
|
241 | + return ''; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Generates the attributes for retrieving a google_map artifact. |
|
247 | + * @param EE_Venue $venue |
|
248 | + * @param string $field |
|
249 | + * @return array |
|
250 | + * @throws EE_Error |
|
251 | + */ |
|
252 | + protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
253 | + { |
|
254 | + $state = $venue->state_obj(); |
|
255 | + $country = $venue->country_obj(); |
|
256 | + $atts = array( |
|
257 | + 'id' => $venue->ID(), |
|
258 | + 'address' => $venue->get('VNU_address'), |
|
259 | + 'city' => $venue->get('VNU_city'), |
|
260 | + 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
261 | + 'zip' => $venue->get('VNU_zip'), |
|
262 | + 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
263 | + 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
264 | + 'map_w' => 200, |
|
265 | + 'map_h' => 200, |
|
266 | + ); |
|
267 | + if ($field === 'gmap_url') { |
|
268 | + $atts['type'] = 'url_only'; |
|
269 | + } |
|
270 | + return $atts; |
|
271 | + } |
|
272 | 272 | } |
@@ -14,176 +14,176 @@ |
||
14 | 14 | class EEH_Maps |
15 | 15 | { |
16 | 16 | |
17 | - // array of map settings |
|
18 | - public static $gmap_vars = array(); |
|
19 | - |
|
20 | - |
|
21 | - /** |
|
22 | - * google_map - creates a Google Map Link |
|
23 | - * |
|
24 | - * @param array $ee_gmaps_opts array of attributes required for the map link generation |
|
25 | - * @return string (link to map!) |
|
26 | - */ |
|
27 | - public static function google_map($ee_gmaps_opts) |
|
28 | - { |
|
29 | - |
|
30 | - $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
31 | - $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
32 | - $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
33 | - $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
34 | - $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
|
35 | - ? $ee_gmaps_opts['ee_map_nav_size'] |
|
36 | - : 'default'; |
|
37 | - $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
|
38 | - ? $ee_gmaps_opts['ee_map_type_control'] |
|
39 | - : 'default'; |
|
40 | - $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
|
41 | - |
|
42 | - if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
43 | - switch ($ee_gmaps_opts['ee_map_align']) { |
|
44 | - case "left": |
|
45 | - $map_align = 'ee-gmap-align-left left'; |
|
46 | - break; |
|
47 | - case "right": |
|
48 | - $map_align = 'ee-gmap-align-right right'; |
|
49 | - break; |
|
50 | - case "center": |
|
51 | - $map_align = 'ee-gmap-align-center center'; |
|
52 | - break; |
|
53 | - case "none": |
|
54 | - default: |
|
55 | - $map_align = 'ee-gmap-align-none'; |
|
56 | - } |
|
57 | - } else { |
|
58 | - $map_align = 'ee-gmap-align-none'; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - // Determine whether user has set a hardoded url to use and |
|
63 | - // if so display a Google static iframe map else run V3 api |
|
64 | - if ($static_url) { |
|
65 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
66 | - $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
67 | - . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
68 | - . ' frameborder="0" scrolling="no">'; |
|
69 | - $html .= '</iframe>'; |
|
70 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
71 | - $html .= '</div>'; |
|
72 | - return $html; |
|
73 | - |
|
74 | - } else { |
|
75 | - EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
76 | - 'map_ID' => $ee_gmaps_opts['map_ID'], |
|
77 | - 'ee_map_zoom' => $ee_map_zoom, |
|
78 | - 'ee_map_nav_display' => $ee_map_nav_display, |
|
79 | - 'ee_map_nav_size' => $ee_map_nav_size, |
|
80 | - 'ee_map_type_control' => $ee_map_type_control, |
|
81 | - 'location' => $ee_gmaps_opts['location'], |
|
82 | - ); |
|
83 | - |
|
84 | - $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
85 | - $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
86 | - . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
87 | - . ' style="' . $style . '"></div>' |
|
88 | - . '</div>'; |
|
89 | - |
|
90 | - wp_enqueue_script('gmap_api'); |
|
91 | - wp_enqueue_script('ee_gmap'); |
|
92 | - add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
93 | - |
|
94 | - return $html; |
|
95 | - } // end auto map or static url map check |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * enqueue_script |
|
101 | - * |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public static function footer_enqueue_script() |
|
105 | - { |
|
106 | - wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * registers scripts for maps |
|
112 | - */ |
|
113 | - public static function espresso_google_map_js() |
|
114 | - { |
|
115 | - $api_url = sprintf( |
|
116 | - "https://maps.googleapis.com/maps/api/js?key=%s", |
|
117 | - apply_filters( |
|
118 | - 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
119 | - EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
120 | - ) |
|
121 | - ); |
|
122 | - wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
|
123 | - wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * creates a Google Map Link |
|
128 | - * |
|
129 | - * @param array $atts array of attributes required for the map link generation |
|
130 | - * @return string (link to map!) |
|
131 | - */ |
|
132 | - public static function google_map_link($atts) |
|
133 | - { |
|
134 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | - extract($atts); |
|
136 | - /** @var string $address */ |
|
137 | - /** @var string $city */ |
|
138 | - /** @var string $state */ |
|
139 | - /** @var string $zip */ |
|
140 | - /** @var string $country */ |
|
141 | - $address = "{$address}"; |
|
142 | - $city = "{$city}"; |
|
143 | - $state = "{$state}"; |
|
144 | - $zip = "{$zip}"; |
|
145 | - $country = "{$country}"; |
|
146 | - $text = isset($text) ? "{$text}" : ""; |
|
147 | - $type = isset($type) ? "{$type}" : ""; |
|
148 | - $map_w = isset($map_w) ? "{$map_w}" : 400; |
|
149 | - $map_h = isset($map_h) ? "{$map_h}" : 400; |
|
150 | - $id = isset($id) ? $id : 'not_set'; |
|
151 | - $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
|
152 | - |
|
153 | - $address_string = ($address != '' ? $address : '') |
|
154 | - . ($city != '' ? ',' . $city : '') |
|
155 | - . ($state != '' ? ',' . $state : '') |
|
156 | - . ($zip != '' ? ',' . $zip : '') |
|
157 | - . ($country != '' ? ',' . $country : ''); |
|
158 | - |
|
159 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
160 | - |
|
161 | - switch ($type) { |
|
162 | - case 'text': |
|
163 | - default: |
|
164 | - $text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; |
|
165 | - break; |
|
166 | - |
|
167 | - case 'url_only': |
|
168 | - case 'url': |
|
169 | - $text = $google_map; |
|
170 | - break; |
|
171 | - |
|
172 | - case 'map': |
|
173 | - $scheme = is_ssl() ? 'https://' : 'http://'; |
|
174 | - |
|
175 | - $api_key = apply_filters( |
|
176 | - 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', |
|
177 | - EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
178 | - ); |
|
179 | - |
|
180 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
181 | - } |
|
182 | - |
|
183 | - return $type === 'url_only' |
|
184 | - ? $text |
|
185 | - : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
186 | - } |
|
17 | + // array of map settings |
|
18 | + public static $gmap_vars = array(); |
|
19 | + |
|
20 | + |
|
21 | + /** |
|
22 | + * google_map - creates a Google Map Link |
|
23 | + * |
|
24 | + * @param array $ee_gmaps_opts array of attributes required for the map link generation |
|
25 | + * @return string (link to map!) |
|
26 | + */ |
|
27 | + public static function google_map($ee_gmaps_opts) |
|
28 | + { |
|
29 | + |
|
30 | + $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
31 | + $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
32 | + $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
33 | + $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
34 | + $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
|
35 | + ? $ee_gmaps_opts['ee_map_nav_size'] |
|
36 | + : 'default'; |
|
37 | + $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
|
38 | + ? $ee_gmaps_opts['ee_map_type_control'] |
|
39 | + : 'default'; |
|
40 | + $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
|
41 | + |
|
42 | + if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
43 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
44 | + case "left": |
|
45 | + $map_align = 'ee-gmap-align-left left'; |
|
46 | + break; |
|
47 | + case "right": |
|
48 | + $map_align = 'ee-gmap-align-right right'; |
|
49 | + break; |
|
50 | + case "center": |
|
51 | + $map_align = 'ee-gmap-align-center center'; |
|
52 | + break; |
|
53 | + case "none": |
|
54 | + default: |
|
55 | + $map_align = 'ee-gmap-align-none'; |
|
56 | + } |
|
57 | + } else { |
|
58 | + $map_align = 'ee-gmap-align-none'; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + // Determine whether user has set a hardoded url to use and |
|
63 | + // if so display a Google static iframe map else run V3 api |
|
64 | + if ($static_url) { |
|
65 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
66 | + $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
67 | + . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
68 | + . ' frameborder="0" scrolling="no">'; |
|
69 | + $html .= '</iframe>'; |
|
70 | + $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
71 | + $html .= '</div>'; |
|
72 | + return $html; |
|
73 | + |
|
74 | + } else { |
|
75 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
76 | + 'map_ID' => $ee_gmaps_opts['map_ID'], |
|
77 | + 'ee_map_zoom' => $ee_map_zoom, |
|
78 | + 'ee_map_nav_display' => $ee_map_nav_display, |
|
79 | + 'ee_map_nav_size' => $ee_map_nav_size, |
|
80 | + 'ee_map_type_control' => $ee_map_type_control, |
|
81 | + 'location' => $ee_gmaps_opts['location'], |
|
82 | + ); |
|
83 | + |
|
84 | + $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
85 | + $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
86 | + . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
87 | + . ' style="' . $style . '"></div>' |
|
88 | + . '</div>'; |
|
89 | + |
|
90 | + wp_enqueue_script('gmap_api'); |
|
91 | + wp_enqueue_script('ee_gmap'); |
|
92 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
93 | + |
|
94 | + return $html; |
|
95 | + } // end auto map or static url map check |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * enqueue_script |
|
101 | + * |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public static function footer_enqueue_script() |
|
105 | + { |
|
106 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * registers scripts for maps |
|
112 | + */ |
|
113 | + public static function espresso_google_map_js() |
|
114 | + { |
|
115 | + $api_url = sprintf( |
|
116 | + "https://maps.googleapis.com/maps/api/js?key=%s", |
|
117 | + apply_filters( |
|
118 | + 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
119 | + EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
120 | + ) |
|
121 | + ); |
|
122 | + wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
|
123 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * creates a Google Map Link |
|
128 | + * |
|
129 | + * @param array $atts array of attributes required for the map link generation |
|
130 | + * @return string (link to map!) |
|
131 | + */ |
|
132 | + public static function google_map_link($atts) |
|
133 | + { |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | + extract($atts); |
|
136 | + /** @var string $address */ |
|
137 | + /** @var string $city */ |
|
138 | + /** @var string $state */ |
|
139 | + /** @var string $zip */ |
|
140 | + /** @var string $country */ |
|
141 | + $address = "{$address}"; |
|
142 | + $city = "{$city}"; |
|
143 | + $state = "{$state}"; |
|
144 | + $zip = "{$zip}"; |
|
145 | + $country = "{$country}"; |
|
146 | + $text = isset($text) ? "{$text}" : ""; |
|
147 | + $type = isset($type) ? "{$type}" : ""; |
|
148 | + $map_w = isset($map_w) ? "{$map_w}" : 400; |
|
149 | + $map_h = isset($map_h) ? "{$map_h}" : 400; |
|
150 | + $id = isset($id) ? $id : 'not_set'; |
|
151 | + $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
|
152 | + |
|
153 | + $address_string = ($address != '' ? $address : '') |
|
154 | + . ($city != '' ? ',' . $city : '') |
|
155 | + . ($state != '' ? ',' . $state : '') |
|
156 | + . ($zip != '' ? ',' . $zip : '') |
|
157 | + . ($country != '' ? ',' . $country : ''); |
|
158 | + |
|
159 | + $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
160 | + |
|
161 | + switch ($type) { |
|
162 | + case 'text': |
|
163 | + default: |
|
164 | + $text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; |
|
165 | + break; |
|
166 | + |
|
167 | + case 'url_only': |
|
168 | + case 'url': |
|
169 | + $text = $google_map; |
|
170 | + break; |
|
171 | + |
|
172 | + case 'map': |
|
173 | + $scheme = is_ssl() ? 'https://' : 'http://'; |
|
174 | + |
|
175 | + $api_key = apply_filters( |
|
176 | + 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', |
|
177 | + EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
178 | + ); |
|
179 | + |
|
180 | + return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
181 | + } |
|
182 | + |
|
183 | + return $type === 'url_only' |
|
184 | + ? $text |
|
185 | + : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
186 | + } |
|
187 | 187 | } |
188 | 188 | // End of file EEH_Maps.helper.php |
189 | 189 | // Location: /helpers/EEH_Maps.helper.php |
190 | 190 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | : 'default'; |
40 | 40 | $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
41 | 41 | |
42 | - if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
42 | + if ( ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
43 | 43 | switch ($ee_gmaps_opts['ee_map_align']) { |
44 | 44 | case "left": |
45 | 45 | $map_align = 'ee-gmap-align-left left'; |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | // Determine whether user has set a hardoded url to use and |
63 | 63 | // if so display a Google static iframe map else run V3 api |
64 | 64 | if ($static_url) { |
65 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
66 | - $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
67 | - . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
65 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
66 | + $html .= '<iframe src="'.$static_url.'&output=embed"' |
|
67 | + . ' style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"' |
|
68 | 68 | . ' frameborder="0" scrolling="no">'; |
69 | 69 | $html .= '</iframe>'; |
70 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
70 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
71 | 71 | $html .= '</div>'; |
72 | 72 | return $html; |
73 | 73 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | 'location' => $ee_gmaps_opts['location'], |
82 | 82 | ); |
83 | 83 | |
84 | - $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
85 | - $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
86 | - . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
87 | - . ' style="' . $style . '"></div>' |
|
84 | + $style = 'width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;'; |
|
85 | + $html = '<div class="ee-gmap-wrapper '.$map_align.'">' |
|
86 | + . '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'"' |
|
87 | + . ' style="'.$style.'"></div>' |
|
88 | 88 | . '</div>'; |
89 | 89 | |
90 | 90 | wp_enqueue_script('gmap_api'); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
123 | - wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
123 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
152 | 152 | |
153 | 153 | $address_string = ($address != '' ? $address : '') |
154 | - . ($city != '' ? ',' . $city : '') |
|
155 | - . ($state != '' ? ',' . $state : '') |
|
156 | - . ($zip != '' ? ',' . $zip : '') |
|
157 | - . ($country != '' ? ',' . $country : ''); |
|
154 | + . ($city != '' ? ','.$city : '') |
|
155 | + . ($state != '' ? ','.$state : '') |
|
156 | + . ($zip != '' ? ','.$zip : '') |
|
157 | + . ($country != '' ? ','.$country : ''); |
|
158 | 158 | |
159 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
159 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
160 | 160 | |
161 | 161 | switch ($type) { |
162 | 162 | case 'text': |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | EE_Registry::instance()->CFG->map_settings->google_map_api_key |
178 | 178 | ); |
179 | 179 | |
180 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
180 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false&key='.$api_key).'" /></a>'; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $type === 'url_only' |
184 | 184 | ? $text |
185 | - : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
185 | + : '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | // End of file EEH_Maps.helper.php |
@@ -44,77 +44,76 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $_image_url; |
46 | 46 | |
47 | - /** |
|
48 | - * gateway URL variable |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $_base_gateway_url = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * EEG_Paypal_Express constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->_currencies_supported = array( |
|
62 | - 'USD', |
|
63 | - 'AUD', |
|
64 | - 'BRL', |
|
65 | - 'CAD', |
|
66 | - 'CZK', |
|
67 | - 'DKK', |
|
68 | - 'EUR', |
|
69 | - 'HKD', |
|
70 | - 'HUF', |
|
71 | - 'ILS', |
|
72 | - 'JPY', |
|
73 | - 'MYR', |
|
74 | - 'MXN', |
|
75 | - 'NOK', |
|
76 | - 'NZD', |
|
77 | - 'PHP', |
|
78 | - 'PLN', |
|
79 | - 'GBP', |
|
80 | - 'RUB', |
|
81 | - 'SGD', |
|
82 | - 'SEK', |
|
83 | - 'CHF', |
|
84 | - 'TWD', |
|
85 | - 'THB', |
|
86 | - 'TRY' |
|
87 | - ); |
|
88 | - parent::__construct(); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
47 | + /** |
|
48 | + * gateway URL variable |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $_base_gateway_url = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * EEG_Paypal_Express constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->_currencies_supported = array( |
|
62 | + 'USD', |
|
63 | + 'AUD', |
|
64 | + 'BRL', |
|
65 | + 'CAD', |
|
66 | + 'CZK', |
|
67 | + 'DKK', |
|
68 | + 'EUR', |
|
69 | + 'HKD', |
|
70 | + 'HUF', |
|
71 | + 'ILS', |
|
72 | + 'JPY', |
|
73 | + 'MYR', |
|
74 | + 'MXN', |
|
75 | + 'NOK', |
|
76 | + 'NZD', |
|
77 | + 'PHP', |
|
78 | + 'PLN', |
|
79 | + 'GBP', |
|
80 | + 'RUB', |
|
81 | + 'SGD', |
|
82 | + 'SEK', |
|
83 | + 'CHF', |
|
84 | + 'TWD', |
|
85 | + 'THB', |
|
86 | + 'TRY' |
|
87 | + ); |
|
88 | + parent::__construct(); |
|
89 | + } |
|
90 | + |
|
95 | 91 | |
92 | + |
|
93 | + /** |
|
94 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
96 | 95 | * |
97 | 96 | *@param array $settings_array |
98 | 97 | */ |
99 | 98 | public function set_settings( $settings_array ) { |
100 | 99 | parent::set_settings($settings_array); |
101 | 100 | // Redirect URL. |
102 | - $this->_base_gateway_url = $this->_debug_mode |
|
103 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
104 | - : 'https://api-3t.paypal.com/nvp'; |
|
101 | + $this->_base_gateway_url = $this->_debug_mode |
|
102 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
103 | + : 'https://api-3t.paypal.com/nvp'; |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | |
108 | 107 | |
109 | - /** |
|
110 | - * @param EEI_Payment $payment |
|
111 | - * @param array $billing_info |
|
112 | - * @param string $return_url |
|
113 | - * @param string $notify_url |
|
114 | - * @param string $cancel_url |
|
115 | - * @return \EE_Payment|\EEI_Payment |
|
116 | - * @throws \EE_Error |
|
117 | - */ |
|
108 | + /** |
|
109 | + * @param EEI_Payment $payment |
|
110 | + * @param array $billing_info |
|
111 | + * @param string $return_url |
|
112 | + * @param string $notify_url |
|
113 | + * @param string $cancel_url |
|
114 | + * @return \EE_Payment|\EEI_Payment |
|
115 | + * @throws \EE_Error |
|
116 | + */ |
|
118 | 117 | public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
119 | 118 | if ( ! $payment instanceof EEI_Payment ) { |
120 | 119 | $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
@@ -202,9 +201,9 @@ discard block |
||
202 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 202 | // Item quantity. |
204 | 203 | $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
205 | - // Digital item is sold. |
|
206 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
207 | - $item_num++; |
|
204 | + // Digital item is sold. |
|
205 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
206 | + $item_num++; |
|
208 | 207 | } |
209 | 208 | } else { |
210 | 209 | // Just one Item. |
@@ -277,7 +276,6 @@ discard block |
||
277 | 276 | |
278 | 277 | |
279 | 278 | /** |
280 | - |
|
281 | 279 | * @param array $update_info { |
282 | 280 | * @type string $gateway_txn_id |
283 | 281 | * @type string status an EEMI_Payment status |
@@ -297,8 +295,8 @@ discard block |
||
297 | 295 | return $payment; |
298 | 296 | } |
299 | 297 | $primary_registrant = $transaction->primary_registration(); |
300 | - $payment_details = $payment->details(); |
|
301 | - // Check if we still have the token. |
|
298 | + $payment_details = $payment->details(); |
|
299 | + // Check if we still have the token. |
|
302 | 300 | if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
303 | 301 | $payment->set_status( $this->_pay_model->failed_status() ); |
304 | 302 | return $payment; |
@@ -407,35 +405,35 @@ discard block |
||
407 | 405 | */ |
408 | 406 | public function _ppExpress_check_response( $request_response ) { |
409 | 407 | if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
410 | - // If we got here then there was an error in this request. |
|
411 | - return array('status' => false, 'args' => $request_response); |
|
412 | - } |
|
413 | - $response_args = array(); |
|
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
415 | - if ( ! isset($response_args['ACK'])) { |
|
416 | - return array('status' => false, 'args' => $request_response); |
|
417 | - } |
|
418 | - if ( |
|
419 | - ( |
|
420 | - isset($response_args['PAYERID']) |
|
421 | - || isset($response_args['TOKEN']) |
|
422 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
423 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
424 | - ) |
|
425 | - && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
426 | - ) { |
|
427 | - // Response status OK, return response parameters for further processing. |
|
428 | - return array('status' => true, 'args' => $response_args); |
|
429 | - } |
|
430 | - $errors = $this->_get_errors($response_args); |
|
431 | - return array('status' => false, 'args' => $errors); |
|
408 | + // If we got here then there was an error in this request. |
|
409 | + return array('status' => false, 'args' => $request_response); |
|
410 | + } |
|
411 | + $response_args = array(); |
|
412 | + parse_str( urldecode($request_response['body']), $response_args ); |
|
413 | + if ( ! isset($response_args['ACK'])) { |
|
414 | + return array('status' => false, 'args' => $request_response); |
|
415 | + } |
|
416 | + if ( |
|
417 | + ( |
|
418 | + isset($response_args['PAYERID']) |
|
419 | + || isset($response_args['TOKEN']) |
|
420 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
421 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
422 | + ) |
|
423 | + && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
424 | + ) { |
|
425 | + // Response status OK, return response parameters for further processing. |
|
426 | + return array('status' => true, 'args' => $response_args); |
|
427 | + } |
|
428 | + $errors = $this->_get_errors($response_args); |
|
429 | + return array('status' => false, 'args' => $errors); |
|
432 | 430 | } |
433 | 431 | |
434 | 432 | |
435 | 433 | /** |
436 | - * Log a "Cleared" request. |
|
437 | - * |
|
438 | - * @param array $request |
|
434 | + * Log a "Cleared" request. |
|
435 | + * |
|
436 | + * @param array $request |
|
439 | 437 | * @param EEI_Payment $payment |
440 | 438 | * @param string $info |
441 | 439 | * @return void |
@@ -458,17 +456,17 @@ discard block |
||
458 | 456 | $n = 0; |
459 | 457 | while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
460 | 458 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
461 | - ? $data_array["L_ERRORCODE{$n}"] |
|
462 | - : ''; |
|
459 | + ? $data_array["L_ERRORCODE{$n}"] |
|
460 | + : ''; |
|
463 | 461 | $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
464 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
465 | - : ''; |
|
462 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
463 | + : ''; |
|
466 | 464 | $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
467 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
468 | - : ''; |
|
465 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
466 | + : ''; |
|
469 | 467 | $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
470 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
471 | - : ''; |
|
468 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
469 | + : ''; |
|
472 | 470 | |
473 | 471 | if ( $n === 0 ) { |
474 | 472 | $errors = array( |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | *@param array $settings_array |
98 | 98 | */ |
99 | - public function set_settings( $settings_array ) { |
|
99 | + public function set_settings($settings_array) { |
|
100 | 100 | parent::set_settings($settings_array); |
101 | 101 | // Redirect URL. |
102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | * @return \EE_Payment|\EEI_Payment |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
119 | + if ( ! $payment instanceof EEI_Payment) { |
|
120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
122 | 122 | return $payment; |
123 | 123 | } |
124 | 124 | $transaction = $payment->transaction(); |
125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
128 | 128 | return $payment; |
129 | 129 | } |
130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
131 | 131 | $primary_registration = $transaction->primary_registration(); |
132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
141 | 141 | 'RETURNURL' => $return_url, |
142 | 142 | 'CANCELURL' => $cancel_url, |
143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
147 | 147 | ); |
148 | 148 | |
149 | 149 | // Show itemized list. |
150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
151 | 151 | $item_num = 0; |
152 | 152 | $itemized_sum = 0; |
153 | 153 | $total_line_items = $transaction->total_line_item(); |
154 | 154 | // Go through each item in the list. |
155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
156 | + if ($line_item instanceof EE_Line_Item) { |
|
157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $unit_price = $line_item->unit_price(); |
163 | 163 | $line_item_quantity = $line_item->quantity(); |
164 | 164 | // This is a discount. |
165 | - if ( $line_item->is_percent() ) { |
|
165 | + if ($line_item->is_percent()) { |
|
166 | 166 | $unit_price = $line_item->total(); |
167 | 167 | $line_item_quantity = 1; |
168 | 168 | } |
169 | 169 | // Item Name. |
170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
171 | 171 | // Item description. |
172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
173 | 173 | // Cost of individual item. |
174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
175 | 175 | // Item Number. |
176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
190 | 190 | |
191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
193 | 193 | // add the difference as an extra line item. |
194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
195 | 195 | // Item Name. |
196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
197 | 197 | // Item description. |
198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
199 | 199 | // Cost of individual item. |
200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
201 | 201 | // Item Number. |
202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | } else { |
210 | 210 | // Just one Item. |
211 | 211 | // Item Name. |
212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
213 | 213 | // Item description. |
214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
215 | 215 | // Cost of individual item. |
216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
217 | 217 | // Item Number. |
218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | // Digital item is sold. |
222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
223 | 223 | // Item's sales S/H and tax amount. |
224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
228 | 228 | } |
229 | 229 | // Automatically filling out shipping and contact information. |
230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
241 | 241 | // Do not request shipping details on the PP Checkout page. |
242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
244 | 244 | |
245 | 245 | } |
246 | 246 | // Used a business/personal logo on the PayPal page. |
247 | - if ( ! empty($this->_image_url) ) { |
|
247 | + if ( ! empty($this->_image_url)) { |
|
248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
249 | 249 | } |
250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | $this |
254 | 254 | ); |
255 | 255 | // Request PayPal token. |
256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
259 | - if ( $token_rstatus['status'] ) { |
|
256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
259 | + if ($token_rstatus['status']) { |
|
260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
261 | - $payment->set_details( $response_args ); |
|
261 | + $payment->set_details($response_args); |
|
262 | 262 | |
263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
265 | 265 | } else { |
266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
268 | 268 | } else { |
269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
270 | 270 | } |
271 | - $payment->set_details( $response_args ); |
|
272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
271 | + $payment->set_details($response_args); |
|
272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | * @param EEI_Transaction $transaction |
286 | 286 | * @return EEI_Payment |
287 | 287 | */ |
288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
288 | + public function handle_payment_update($update_info, $transaction) { |
|
289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
290 | 290 | |
291 | - if ( $payment instanceof EEI_Payment ) { |
|
292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
291 | + if ($payment instanceof EEI_Payment) { |
|
292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
293 | 293 | $transaction = $payment->transaction(); |
294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
297 | 297 | return $payment; |
298 | 298 | } |
299 | 299 | $primary_registrant = $transaction->primary_registration(); |
300 | 300 | $payment_details = $payment->details(); |
301 | 301 | // Check if we still have the token. |
302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
304 | 304 | return $payment; |
305 | 305 | } |
306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
310 | 310 | ); |
311 | 311 | // Request Customer Details. |
312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
315 | - if ( $cdetails_rstatus['status'] ) { |
|
312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
315 | + if ($cdetails_rstatus['status']) { |
|
316 | 316 | // We got the PayerID so now we can Complete the transaction. |
317 | 317 | $docheckout_request_dtls = array( |
318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
324 | 324 | ); |
325 | 325 | // Payment Checkout/Capture. |
326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
329 | - if ( $docheckout_rstatus['status'] ) { |
|
326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
329 | + if ($docheckout_rstatus['status']) { |
|
330 | 330 | // All is well, payment approved. |
331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
335 | - $payment->set_details( $cdata_response_args ); |
|
336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
332 | + $payment->set_extra_accntng($primary_registration_code); |
|
333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
335 | + $payment->set_details($cdata_response_args); |
|
336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
338 | 338 | } else { |
339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
341 | 341 | } else { |
342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
343 | 343 | } |
344 | - $payment->set_details( $docheckout_response_args ); |
|
345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
344 | + $payment->set_details($docheckout_response_args); |
|
345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
346 | 346 | } |
347 | 347 | } else { |
348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
350 | 350 | } else { |
351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
352 | 352 | } |
353 | - $payment->set_details( $cdata_response_args ); |
|
354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
353 | + $payment->set_details($cdata_response_args); |
|
354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
355 | 355 | } |
356 | 356 | } else { |
357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param EEI_Payment $payment |
371 | 371 | * @return mixed |
372 | 372 | */ |
373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
374 | 374 | $request_dtls = array( |
375 | 375 | 'VERSION' => '204.0', |
376 | - 'USER' => urlencode( $this->_api_username ), |
|
377 | - 'PWD' => urlencode( $this->_api_password ), |
|
378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
376 | + 'USER' => urlencode($this->_api_username), |
|
377 | + 'PWD' => urlencode($this->_api_password), |
|
378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
379 | 379 | ); |
380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
380 | + $dtls = array_merge($request_dtls, $request_params); |
|
381 | 381 | |
382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
383 | 383 | // Request Customer Details. |
384 | 384 | $request_response = wp_remote_post( |
385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | 'httpversion' => '1.1', |
390 | 390 | 'cookies' => array(), |
391 | 391 | 'headers' => array(), |
392 | - 'body' => http_build_query( $dtls ) |
|
392 | + 'body' => http_build_query($dtls) |
|
393 | 393 | ) |
394 | 394 | ); |
395 | 395 | // Log the response. |
396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
397 | 397 | |
398 | 398 | return $request_response; |
399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param mixed $request_response |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public function _ppExpress_check_response( $request_response ) { |
|
409 | - if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
|
408 | + public function _ppExpress_check_response($request_response) { |
|
409 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
410 | 410 | // If we got here then there was an error in this request. |
411 | 411 | return array('status' => false, 'args' => $request_response); |
412 | 412 | } |
413 | 413 | $response_args = array(); |
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
415 | 415 | if ( ! isset($response_args['ACK'])) { |
416 | 416 | return array('status' => false, 'args' => $request_response); |
417 | 417 | } |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | * @param string $info |
441 | 441 | * @return void |
442 | 442 | */ |
443 | - private function _log_clean_request($request, $payment, $info ) { |
|
443 | + private function _log_clean_request($request, $payment, $info) { |
|
444 | 444 | $cleaned_request_data = $request; |
445 | 445 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
446 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
446 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | * @param array $data_array |
454 | 454 | * @return array |
455 | 455 | */ |
456 | - private function _get_errors( $data_array ) { |
|
456 | + private function _get_errors($data_array) { |
|
457 | 457 | $errors = array(); |
458 | 458 | $n = 0; |
459 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
459 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
460 | 460 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
461 | 461 | ? $data_array["L_ERRORCODE{$n}"] |
462 | 462 | : ''; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | ? $data_array["L_LONGMESSAGE{$n}"] |
471 | 471 | : ''; |
472 | 472 | |
473 | - if ( $n === 0 ) { |
|
473 | + if ($n === 0) { |
|
474 | 474 | $errors = array( |
475 | 475 | 'L_ERRORCODE' => $l_error_code, |
476 | 476 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | 'L_SEVERITYCODE' => $l_severity_code |
479 | 479 | ); |
480 | 480 | } else { |
481 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
482 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
483 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
484 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
481 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
482 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
483 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
484 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | $n++; |
@@ -286,41 +286,41 @@ discard block |
||
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | 288 | foreach ( $registrations as $REG_ID => $registration ) { |
289 | - /** @var $registration EE_Registration */ |
|
290 | - // has this registration lost it's space ? |
|
289 | + /** @var $registration EE_Registration */ |
|
290 | + // has this registration lost it's space ? |
|
291 | 291 | if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
292 | 292 | $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
293 | 293 | continue; |
294 | 294 | } |
295 | - // event requires admin approval |
|
296 | - if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
297 | - // add event to list of events with pre-approval reg status |
|
298 | - $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
299 | - do_action( |
|
300 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
301 | - $registration->event(), |
|
302 | - $this |
|
303 | - ); |
|
304 | - continue; |
|
305 | - } |
|
306 | - if ( |
|
295 | + // event requires admin approval |
|
296 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
297 | + // add event to list of events with pre-approval reg status |
|
298 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
299 | + do_action( |
|
300 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
301 | + $registration->event(), |
|
302 | + $this |
|
303 | + ); |
|
304 | + continue; |
|
305 | + } |
|
306 | + if ( |
|
307 | 307 | // returning registrant |
308 | 308 | $this->checkout->revisit |
309 | 309 | // anything other than Approved |
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | - && ( |
|
312 | - $registration->event()->is_sold_out() |
|
313 | - || $registration->event()->is_sold_out( true ) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - // add event to list of events that are sold out |
|
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
318 | - do_action( |
|
319 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
320 | - $registration->event(), |
|
321 | - $this |
|
322 | - ); |
|
323 | - continue; |
|
311 | + && ( |
|
312 | + $registration->event()->is_sold_out() |
|
313 | + || $registration->event()->is_sold_out( true ) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + // add event to list of events that are sold out |
|
317 | + $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
318 | + do_action( |
|
319 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
320 | + $registration->event(), |
|
321 | + $this |
|
322 | + ); |
|
323 | + continue; |
|
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | 326 | if ( $registration->owes_monies_and_can_pay() ) { |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | new EE_Billable_Line_Item_Filter( |
429 | 429 | EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
430 | 430 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
431 | - EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
432 | - ) |
|
431 | + EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
432 | + ) |
|
433 | 433 | ) |
434 | 434 | ) |
435 | - ); |
|
435 | + ); |
|
436 | 436 | $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
@@ -481,46 +481,46 @@ discard block |
||
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | 483 | public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
484 | - // registrations per event |
|
484 | + // registrations per event |
|
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
487 | 487 | $event_spaces_remaining = array(); |
488 | - // tickets left sorted by ID |
|
489 | - $tickets_remaining = array(); |
|
490 | - // registrations that have lost their space |
|
488 | + // tickets left sorted by ID |
|
489 | + $tickets_remaining = array(); |
|
490 | + // registrations that have lost their space |
|
491 | 491 | $ejected_registrations = array(); |
492 | 492 | foreach ( $registrations as $REG_ID => $registration ) { |
493 | - if ( |
|
494 | - $registration->status_ID() === EEM_Registration::status_id_approved |
|
495 | - || apply_filters( |
|
496 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
497 | - false, |
|
498 | - $registration, |
|
499 | - $revisit |
|
500 | - ) |
|
501 | - ) { |
|
502 | - continue; |
|
493 | + if ( |
|
494 | + $registration->status_ID() === EEM_Registration::status_id_approved |
|
495 | + || apply_filters( |
|
496 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
497 | + false, |
|
498 | + $registration, |
|
499 | + $revisit |
|
500 | + ) |
|
501 | + ) { |
|
502 | + continue; |
|
503 | 503 | } |
504 | 504 | $EVT_ID = $registration->event_ID(); |
505 | - $ticket = $registration->ticket(); |
|
506 | - if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
507 | - $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
508 | - } |
|
509 | - if ($tickets_remaining[$ticket->ID()] > 0) { |
|
510 | - if ( ! isset($event_reg_count[$EVT_ID])) { |
|
511 | - $event_reg_count[$EVT_ID] = 0; |
|
512 | - } |
|
513 | - $event_reg_count[$EVT_ID]++; |
|
514 | - if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
515 | - $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
516 | - } |
|
517 | - } |
|
505 | + $ticket = $registration->ticket(); |
|
506 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
507 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
508 | + } |
|
509 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
510 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
511 | + $event_reg_count[$EVT_ID] = 0; |
|
512 | + } |
|
513 | + $event_reg_count[$EVT_ID]++; |
|
514 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
515 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
516 | + } |
|
517 | + } |
|
518 | 518 | if ( |
519 | 519 | $revisit |
520 | 520 | && ( |
521 | - $tickets_remaining[$ticket->ID()] === 0 |
|
522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
523 | - ) |
|
521 | + $tickets_remaining[$ticket->ID()] === 0 |
|
522 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
523 | + ) |
|
524 | 524 | ) { |
525 | 525 | $ejected_registrations[ $REG_ID ] = $registration->event(); |
526 | 526 | if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | 'layout_strategy' => new EE_Template_Layout( |
590 | 590 | array( |
591 | 591 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
592 | - . $this->_slug |
|
593 | - . DS |
|
594 | - . 'sold_out_events.template.php', |
|
592 | + . $this->_slug |
|
593 | + . DS |
|
594 | + . 'sold_out_events.template.php', |
|
595 | 595 | 'template_args' => apply_filters( |
596 | 596 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
597 | 597 | array( |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | 'layout_strategy' => new EE_Template_Layout( |
645 | 645 | array( |
646 | 646 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
647 | - . $this->_slug |
|
648 | - . DS |
|
649 | - . 'sold_out_events.template.php', |
|
647 | + . $this->_slug |
|
648 | + . DS |
|
649 | + . 'sold_out_events.template.php', |
|
650 | 650 | 'template_args' => apply_filters( |
651 | 651 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
652 | 652 | array( |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | 'layout_strategy' => new EE_Template_Layout( |
695 | 695 | array( |
696 | 696 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
697 | - . $this->_slug |
|
698 | - . DS |
|
699 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
697 | + . $this->_slug |
|
698 | + . DS |
|
699 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
700 | 700 | 'template_args' => apply_filters( |
701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
702 | 702 | array( |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | 'layout_strategy' => new EE_Template_Layout( |
735 | 735 | array( |
736 | 736 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
737 | - . $this->_slug |
|
738 | - . DS |
|
739 | - . 'no_payment_required.template.php', // layout_template |
|
737 | + . $this->_slug |
|
738 | + . DS |
|
739 | + . 'no_payment_required.template.php', // layout_template |
|
740 | 740 | 'template_args' => apply_filters( |
741 | 741 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
742 | 742 | array( |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
965 | 965 | } |
966 | 966 | $payment_methods_billing_info[ $payment_method->slug() |
967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
967 | + . '-info' ] = $this->_payment_method_billing_info( |
|
968 | 968 | $payment_method |
969 | 969 | ); |
970 | 970 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | // fill form with attendee info if applicable |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
1155 | - && $this->checkout->transaction_has_primary_registrant() |
|
1155 | + && $this->checkout->transaction_has_primary_registrant() |
|
1156 | 1156 | ) { |
1157 | 1157 | $payment_method_billing_form->populate_from_attendee( |
1158 | 1158 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | // and debug content |
1162 | 1162 | if ( |
1163 | 1163 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
1164 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1164 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1165 | 1165 | ) { |
1166 | 1166 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1167 | 1167 | $payment_method_billing_form |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | } |
1337 | 1337 | // and debug content |
1338 | 1338 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1339 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1339 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1340 | 1340 | ) { |
1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1342 | 1342 | $this->checkout->billing_form |
@@ -1506,8 +1506,8 @@ discard block |
||
1506 | 1506 | } |
1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1508 | 1508 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1509 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1511 | 1511 | ) { |
1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1513 | 1513 | array( |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | $payment_status = $payment->status(); |
1755 | 1755 | if ( |
1756 | 1756 | $payment_status === EEM_Payment::status_id_approved |
1757 | - || $payment_status === EEM_Payment::status_id_pending |
|
1757 | + || $payment_status === EEM_Payment::status_id_pending |
|
1758 | 1758 | ) { |
1759 | 1759 | return true; |
1760 | 1760 | } else { |
@@ -1980,8 +1980,8 @@ discard block |
||
1980 | 1980 | return false; |
1981 | 1981 | } |
1982 | 1982 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1983 | - instanceof |
|
1984 | - EE_Attendee |
|
1983 | + instanceof |
|
1984 | + EE_Attendee |
|
1985 | 1985 | ) { |
1986 | 1986 | EE_Error::add_error( |
1987 | 1987 | sprintf( |
@@ -2454,14 +2454,14 @@ discard block |
||
2454 | 2454 | |
2455 | 2455 | |
2456 | 2456 | |
2457 | - /** |
|
2458 | - * _validate_return |
|
2459 | - * |
|
2460 | - * @access private |
|
2461 | - * @return void |
|
2462 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
2463 | - * @throws \EE_Error |
|
2464 | - */ |
|
2457 | + /** |
|
2458 | + * _validate_return |
|
2459 | + * |
|
2460 | + * @access private |
|
2461 | + * @return void |
|
2462 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
2463 | + * @throws \EE_Error |
|
2464 | + */ |
|
2465 | 2465 | private function _validate_offsite_return() { |
2466 | 2466 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
2467 | 2467 | if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
@@ -2487,20 +2487,20 @@ discard block |
||
2487 | 2487 | ? $primary_registrant->session_ID() |
2488 | 2488 | : null; |
2489 | 2489 | // validate current Session ID and compare against valid TXN session ID |
2490 | - if ( |
|
2491 | - $invalid_TXN // if this is already true, then skip other checks |
|
2492 | - || EE_Session::instance()->id() === null |
|
2493 | - || ( |
|
2494 | - // WARNING !!! |
|
2495 | - // this could be PayPal sending back duplicate requests (ya they do that) |
|
2496 | - // or it **could** mean someone is simply registering AGAIN after having just done so |
|
2497 | - // so now we need to determine if this current TXN looks valid or not |
|
2498 | - // and whether this reg step has even been started ? |
|
2499 | - EE_Session::instance()->id() === $valid_TXN_SID |
|
2500 | - // really? you're half way through this reg step, but you never started it ? |
|
2501 | - && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
2502 | - ) |
|
2503 | - ) { |
|
2490 | + if ( |
|
2491 | + $invalid_TXN // if this is already true, then skip other checks |
|
2492 | + || EE_Session::instance()->id() === null |
|
2493 | + || ( |
|
2494 | + // WARNING !!! |
|
2495 | + // this could be PayPal sending back duplicate requests (ya they do that) |
|
2496 | + // or it **could** mean someone is simply registering AGAIN after having just done so |
|
2497 | + // so now we need to determine if this current TXN looks valid or not |
|
2498 | + // and whether this reg step has even been started ? |
|
2499 | + EE_Session::instance()->id() === $valid_TXN_SID |
|
2500 | + // really? you're half way through this reg step, but you never started it ? |
|
2501 | + && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
2502 | + ) |
|
2503 | + ) { |
|
2504 | 2504 | $invalid_TXN = true; |
2505 | 2505 | } |
2506 | 2506 | if ( $invalid_TXN ) { |
@@ -2702,19 +2702,19 @@ discard block |
||
2702 | 2702 | |
2703 | 2703 | |
2704 | 2704 | |
2705 | - /** |
|
2706 | - * __sleep |
|
2707 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
2708 | - * EE_Checkout will handle the reimplementation of itself upon waking, |
|
2709 | - * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
2710 | - * |
|
2711 | - * @return array |
|
2712 | - */ |
|
2713 | - public function __sleep() |
|
2714 | - { |
|
2715 | - // remove the reg form and the checkout |
|
2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2717 | - } |
|
2705 | + /** |
|
2706 | + * __sleep |
|
2707 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
2708 | + * EE_Checkout will handle the reimplementation of itself upon waking, |
|
2709 | + * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
2710 | + * |
|
2711 | + * @return array |
|
2712 | + */ |
|
2713 | + public function __sleep() |
|
2714 | + { |
|
2715 | + // remove the reg form and the checkout |
|
2716 | + return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2717 | + } |
|
2718 | 2718 | |
2719 | 2719 | |
2720 | 2720 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | */ |
129 | - public function __construct( EE_Checkout $checkout ) { |
|
129 | + public function __construct(EE_Checkout $checkout) { |
|
130 | 130 | $this->_slug = 'payment_options'; |
131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
133 | 133 | $this->checkout = $checkout; |
134 | 134 | $this->_reset_success_message(); |
135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param null $line_item_display |
156 | 156 | */ |
157 | - public function set_line_item_display( $line_item_display ) { |
|
157 | + public function set_line_item_display($line_item_display) { |
|
158 | 158 | $this->line_item_display = $line_item_display; |
159 | 159 | } |
160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @param boolean $handle_IPN_in_this_request |
174 | 174 | */ |
175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | public function enqueue_styles_and_scripts() { |
209 | 209 | $transaction = $this->checkout->transaction; |
210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
215 | 215 | $type_obj = $payment_method->type_obj(); |
216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
219 | 219 | $billing_form->enqueue_js(); |
220 | 220 | } |
221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // $ 0.00 transactions (no payment required) |
241 | 241 | ! $this->checkout->payment_required() |
242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
244 | 244 | && ! $this->completed() |
245 | 245 | ) { |
246 | 246 | // and if so, then we no longer need the Payment Options step |
247 | - if ( $this->is_current_step() ) { |
|
247 | + if ($this->is_current_step()) { |
|
248 | 248 | $this->checkout->generate_reg_form = false; |
249 | 249 | } |
250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
250 | + $this->checkout->remove_reg_step($this->_slug); |
|
251 | 251 | // DEBUG LOG |
252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | // load EEM_Payment_Method |
256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
257 | 257 | // get all active payment methods |
258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
259 | 259 | $this->checkout->transaction, |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | $insufficient_spaces_available = array(); |
281 | 281 | $no_payment_required = true; |
282 | 282 | // loop thru registrations to gather info |
283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
285 | 285 | $registrations, |
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
288 | + foreach ($registrations as $REG_ID => $registration) { |
|
289 | 289 | /** @var $registration EE_Registration */ |
290 | 290 | // has this registration lost it's space ? |
291 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
292 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
291 | + if (isset($ejected_registrations[$REG_ID])) { |
|
292 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | // event requires admin approval |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | 311 | && ( |
312 | 312 | $registration->event()->is_sold_out() |
313 | - || $registration->event()->is_sold_out( true ) |
|
313 | + || $registration->event()->is_sold_out(true) |
|
314 | 314 | ) |
315 | 315 | ) { |
316 | 316 | // add event to list of events that are sold out |
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
317 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
318 | 318 | do_action( |
319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
320 | 320 | $registration->event(), |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | continue; |
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
327 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
326 | + if ($registration->owes_monies_and_can_pay()) { |
|
327 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
328 | 328 | do_action( |
329 | 329 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
330 | 330 | $registration->event(), |
@@ -335,29 +335,29 @@ discard block |
||
335 | 335 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
336 | 336 | && $registration->ticket()->is_free() |
337 | 337 | ) { |
338 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
338 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | $subsections = array(); |
342 | 342 | // now decide which template to load |
343 | - if ( ! empty( $sold_out_events ) ) { |
|
344 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
343 | + if ( ! empty($sold_out_events)) { |
|
344 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
345 | 345 | } |
346 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
346 | + if ( ! empty($insufficient_spaces_available)) { |
|
347 | 347 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
348 | 348 | $insufficient_spaces_available |
349 | 349 | ); |
350 | 350 | } |
351 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
351 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
352 | 352 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
353 | 353 | $registrations_requiring_pre_approval |
354 | 354 | ); |
355 | 355 | } |
356 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
357 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
356 | + if ( ! empty($registrations_for_free_events)) { |
|
357 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
358 | 358 | } |
359 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
360 | - if ( $this->checkout->amount_owing > 0 ) { |
|
359 | + if ( ! empty($registrations_requiring_payment)) { |
|
360 | + if ($this->checkout->amount_owing > 0) { |
|
361 | 361 | // autoload Line_Item_Display classes |
362 | 362 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
363 | 363 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | /** @var EE_Line_Item $filtered_line_item_tree */ |
371 | 371 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
372 | 372 | EEH_Autoloader::register_line_item_display_autoloaders(); |
373 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
373 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
374 | 374 | $subsections['payment_options'] = $this->_display_payment_options( |
375 | 375 | $this->line_item_display->display_line_item( |
376 | 376 | $filtered_line_item_tree, |
377 | - array( 'registrations' => $registrations ) |
|
377 | + array('registrations' => $registrations) |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
381 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
381 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
382 | 382 | } |
383 | 383 | $no_payment_required = false; |
384 | 384 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $this->_save_selected_method_of_payment(); |
388 | 388 | |
389 | 389 | $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
390 | - $subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required ); |
|
390 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
391 | 391 | |
392 | 392 | return new EE_Form_Section_Proper( |
393 | 393 | array( |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | * @return \EE_Line_Item_Filter_Collection |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
418 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
417 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
418 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
419 | 419 | return $line_item_filter_collection; |
420 | 420 | } |
421 | - if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) { |
|
421 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
422 | 422 | return $line_item_filter_collection; |
423 | 423 | } |
424 | - if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) { |
|
424 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
425 | 425 | return $line_item_filter_collection; |
426 | 426 | } |
427 | 427 | $line_item_filter_collection->add( |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ) |
434 | 434 | ) |
435 | 435 | ); |
436 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
436 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
439 | 439 | |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @return \EE_Registration[] |
450 | 450 | * @throws \EE_Error |
451 | 451 | */ |
452 | - public static function remove_ejected_registrations( array $registrations ) { |
|
452 | + public static function remove_ejected_registrations(array $registrations) { |
|
453 | 453 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
454 | 454 | $registrations, |
455 | 455 | EE_Registry::instance()->SSN->checkout()->revisit |
456 | 456 | ); |
457 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
457 | + foreach ($registrations as $REG_ID => $registration) { |
|
458 | 458 | // has this registration lost it's space ? |
459 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
460 | - unset( $registrations[ $REG_ID ] ); |
|
459 | + if (isset($ejected_registrations[$REG_ID])) { |
|
460 | + unset($registrations[$REG_ID]); |
|
461 | 461 | continue; |
462 | 462 | } |
463 | 463 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @return array |
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
483 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
484 | 484 | // registrations per event |
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $tickets_remaining = array(); |
490 | 490 | // registrations that have lost their space |
491 | 491 | $ejected_registrations = array(); |
492 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
492 | + foreach ($registrations as $REG_ID => $registration) { |
|
493 | 493 | if ( |
494 | 494 | $registration->status_ID() === EEM_Registration::status_id_approved |
495 | 495 | || apply_filters( |
@@ -519,13 +519,13 @@ discard block |
||
519 | 519 | $revisit |
520 | 520 | && ( |
521 | 521 | $tickets_remaining[$ticket->ID()] === 0 |
522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
522 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
523 | 523 | ) |
524 | 524 | ) { |
525 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
526 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
525 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
526 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
527 | 527 | /** @type EE_Registration_Processor $registration_processor */ |
528 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
528 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
529 | 529 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
530 | 530 | $registration_processor->manually_update_registration_status( |
531 | 531 | $registration, |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | * @return void |
561 | 561 | */ |
562 | 562 | protected function _hide_reg_step_submit_button_if_revisit() { |
563 | - if ( $this->checkout->revisit ) { |
|
564 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
563 | + if ($this->checkout->revisit) { |
|
564 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
@@ -575,13 +575,13 @@ discard block |
||
575 | 575 | * @return \EE_Form_Section_Proper |
576 | 576 | * @throws \EE_Error |
577 | 577 | */ |
578 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
578 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
579 | 579 | // set some defaults |
580 | 580 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
581 | 581 | $sold_out_events = ''; |
582 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
582 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
583 | 583 | $sold_out_events .= EEH_HTML::li( |
584 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
584 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
585 | 585 | ); |
586 | 586 | } |
587 | 587 | return new EE_Form_Section_Proper( |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | 'sold_out_events_msg' => apply_filters( |
600 | 600 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
601 | 601 | sprintf( |
602 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso' ), |
|
602 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso'), |
|
603 | 603 | '<strong>', |
604 | 604 | '</strong>', |
605 | 605 | '<br />' |
@@ -624,14 +624,14 @@ discard block |
||
624 | 624 | * @return \EE_Form_Section_Proper |
625 | 625 | * @throws \EE_Error |
626 | 626 | */ |
627 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
627 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
628 | 628 | // set some defaults |
629 | 629 | $this->checkout->selected_method_of_payment = 'invoice'; |
630 | 630 | $insufficient_space_events = ''; |
631 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
632 | - if ( $event instanceof EE_Event ) { |
|
631 | + foreach ($insufficient_spaces_events_array as $event) { |
|
632 | + if ($event instanceof EE_Event) { |
|
633 | 633 | $insufficient_space_events .= EEH_HTML::li( |
634 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
634 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
635 | 635 | ); |
636 | 636 | } |
637 | 637 | } |
@@ -675,17 +675,17 @@ discard block |
||
675 | 675 | * @return \EE_Form_Section_Proper |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
678 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
679 | 679 | $events_requiring_pre_approval = ''; |
680 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
681 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
682 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
680 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
681 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
682 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
683 | 683 | EEH_HTML::span( |
684 | 684 | '', |
685 | 685 | '', |
686 | 686 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
687 | 687 | ) |
688 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
688 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'template_args' => apply_filters( |
701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
702 | 702 | array( |
703 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
703 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
704 | 704 | 'events_requiring_pre_approval_msg' => apply_filters( |
705 | 705 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
706 | 706 | __( |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @return \EE_Form_Section_Proper |
726 | 726 | * @throws \EE_Error |
727 | 727 | */ |
728 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
728 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
729 | 729 | // set some defaults |
730 | 730 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
731 | 731 | // generate no_payment_required form |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | 'ticket_count' => array(), |
746 | 746 | 'registrations_for_free_events' => $registrations_for_free_events, |
747 | 747 | 'no_payment_required_msg' => EEH_HTML::p( |
748 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
748 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
749 | 749 | ) |
750 | 750 | ) |
751 | 751 | ), |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @return \EE_Form_Section_Proper |
765 | 765 | * @throws \EE_Error |
766 | 766 | */ |
767 | - private function _display_payment_options( $transaction_details = '' ) { |
|
767 | + private function _display_payment_options($transaction_details = '') { |
|
768 | 768 | // has method_of_payment been set by no-js user? |
769 | 769 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
770 | 770 | // build payment options form |
@@ -776,14 +776,14 @@ discard block |
||
776 | 776 | 'before_payment_options' => apply_filters( |
777 | 777 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
778 | 778 | new EE_Form_Section_Proper( |
779 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
779 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
780 | 780 | ) |
781 | 781 | ), |
782 | 782 | 'payment_options' => $this->_setup_payment_options(), |
783 | 783 | 'after_payment_options' => apply_filters( |
784 | 784 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
785 | 785 | new EE_Form_Section_Proper( |
786 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
786 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
787 | 787 | ) |
788 | 788 | ), |
789 | 789 | ), |
@@ -814,10 +814,10 @@ discard block |
||
814 | 814 | * @return \EE_Form_Section_Proper |
815 | 815 | * @throws \EE_Error |
816 | 816 | */ |
817 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
817 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
818 | 818 | return new EE_Form_Section_Proper( |
819 | 819 | array( |
820 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
820 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
821 | 821 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
822 | 822 | 'subsections' => array( |
823 | 823 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -849,16 +849,16 @@ discard block |
||
849 | 849 | * @access protected |
850 | 850 | * @param array $registrations |
851 | 851 | */ |
852 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
852 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
853 | 853 | $payments = array(); |
854 | - foreach ( $registrations as $registration ) { |
|
855 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
854 | + foreach ($registrations as $registration) { |
|
855 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
856 | 856 | $payments += $registration->registration_payments(); |
857 | 857 | } |
858 | 858 | } |
859 | - if ( ! empty( $payments ) ) { |
|
860 | - foreach ( $payments as $payment ) { |
|
861 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
859 | + if ( ! empty($payments)) { |
|
860 | + foreach ($payments as $payment) { |
|
861 | + if ($payment instanceof EE_Registration_Payment) { |
|
862 | 862 | $this->checkout->amount_owing -= $payment->amount(); |
863 | 863 | } |
864 | 864 | } |
@@ -874,11 +874,11 @@ discard block |
||
874 | 874 | * @param bool $force_reset |
875 | 875 | * @return void |
876 | 876 | */ |
877 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
877 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
878 | 878 | $reset_payment_method = $force_reset |
879 | 879 | ? true |
880 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
881 | - if ( $reset_payment_method ) { |
|
880 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
881 | + if ($reset_payment_method) { |
|
882 | 882 | $this->checkout->selected_method_of_payment = null; |
883 | 883 | $this->checkout->payment_method = null; |
884 | 884 | $this->checkout->billing_form = null; |
@@ -897,12 +897,12 @@ discard block |
||
897 | 897 | * @param string $selected_method_of_payment |
898 | 898 | * @return void |
899 | 899 | */ |
900 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
901 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
900 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
901 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
902 | 902 | ? $selected_method_of_payment |
903 | 903 | : $this->checkout->selected_method_of_payment; |
904 | 904 | EE_Registry::instance()->SSN->set_session_data( |
905 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
905 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
906 | 906 | ); |
907 | 907 | } |
908 | 908 | |
@@ -918,19 +918,19 @@ discard block |
||
918 | 918 | // load payment method classes |
919 | 919 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
920 | 920 | // switch up header depending on number of available payment methods |
921 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
921 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
922 | 922 | ? apply_filters( |
923 | 923 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
924 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
924 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
925 | 925 | ) |
926 | 926 | : apply_filters( |
927 | 927 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
928 | - __( 'Method of Payment', 'event_espresso' ) |
|
928 | + __('Method of Payment', 'event_espresso') |
|
929 | 929 | ); |
930 | 930 | $available_payment_methods = array( |
931 | 931 | // display the "Payment Method" header |
932 | 932 | 'payment_method_header' => new EE_Form_Section_HTML( |
933 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
933 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
934 | 934 | ) |
935 | 935 | ); |
936 | 936 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -939,32 +939,32 @@ discard block |
||
939 | 939 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
940 | 940 | $payment_methods_billing_info = array( |
941 | 941 | new EE_Form_Section_HTML( |
942 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
942 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
943 | 943 | ) |
944 | 944 | ); |
945 | 945 | // loop through payment methods |
946 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
947 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
946 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
947 | + if ($payment_method instanceof EE_Payment_Method) { |
|
948 | 948 | $payment_method_button = EEH_HTML::img( |
949 | 949 | $payment_method->button_url(), |
950 | 950 | $payment_method->name(), |
951 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
951 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
952 | 952 | 'spco-payment-method-btn-img' |
953 | 953 | ); |
954 | 954 | // check if any payment methods are set as default |
955 | 955 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
956 | 956 | if ( |
957 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
958 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
957 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
958 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
959 | 959 | ) { |
960 | 960 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
961 | 961 | $this->_save_selected_method_of_payment(); |
962 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
962 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
963 | 963 | } else { |
964 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
964 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
965 | 965 | } |
966 | - $payment_methods_billing_info[ $payment_method->slug() |
|
967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
966 | + $payment_methods_billing_info[$payment_method->slug() |
|
967 | + . '-info'] = $this->_payment_method_billing_info( |
|
968 | 968 | $payment_method |
969 | 969 | ); |
970 | 970 | } |
@@ -994,12 +994,12 @@ discard block |
||
994 | 994 | * @return EE_Payment_Method[] |
995 | 995 | */ |
996 | 996 | protected function _get_available_payment_methods() { |
997 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
997 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
998 | 998 | return $this->checkout->available_payment_methods; |
999 | 999 | } |
1000 | 1000 | $available_payment_methods = array(); |
1001 | 1001 | // load EEM_Payment_Method |
1002 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1002 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1003 | 1003 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1004 | 1004 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1005 | 1005 | // get all active payment methods |
@@ -1007,9 +1007,9 @@ discard block |
||
1007 | 1007 | $this->checkout->transaction, |
1008 | 1008 | EEM_Payment_Method::scope_cart |
1009 | 1009 | ); |
1010 | - foreach ( $payment_methods as $payment_method ) { |
|
1011 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
1012 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
1010 | + foreach ($payment_methods as $payment_method) { |
|
1011 | + if ($payment_method instanceof EE_Payment_Method) { |
|
1012 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | return $available_payment_methods; |
@@ -1024,14 +1024,14 @@ discard block |
||
1024 | 1024 | * @param array $available_payment_method_options |
1025 | 1025 | * @return \EE_Form_Section_Proper |
1026 | 1026 | */ |
1027 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
1027 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
1028 | 1028 | // generate inputs |
1029 | 1029 | return new EE_Form_Section_Proper( |
1030 | 1030 | array( |
1031 | 1031 | 'html_id' => 'ee-available-payment-method-inputs', |
1032 | 1032 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1033 | 1033 | 'subsections' => array( |
1034 | - '' => new EE_Radio_Button_Input ( |
|
1034 | + '' => new EE_Radio_Button_Input( |
|
1035 | 1035 | $available_payment_method_options, |
1036 | 1036 | array( |
1037 | 1037 | 'html_name' => 'selected_method_of_payment', |
@@ -1056,28 +1056,28 @@ discard block |
||
1056 | 1056 | * @return \EE_Form_Section_Proper |
1057 | 1057 | * @throws \EE_Error |
1058 | 1058 | */ |
1059 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
1059 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
1060 | 1060 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
1061 | 1061 | ? true |
1062 | 1062 | : false; |
1063 | 1063 | // generate the billing form for payment method |
1064 | 1064 | $billing_form = $currently_selected |
1065 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
1065 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
1066 | 1066 | : new EE_Form_Section_HTML(); |
1067 | 1067 | $this->checkout->billing_form = $currently_selected |
1068 | 1068 | ? $billing_form |
1069 | 1069 | : $this->checkout->billing_form; |
1070 | 1070 | // it's all in the details |
1071 | 1071 | $info_html = EEH_HTML::h3( |
1072 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
1072 | + __('Important information regarding your payment', 'event_espresso'), |
|
1073 | 1073 | '', |
1074 | 1074 | 'spco-payment-method-hdr' |
1075 | 1075 | ); |
1076 | 1076 | // add some info regarding the step, either from what's saved in the admin, |
1077 | 1077 | // or a default string depending on whether the PM has a billing form or not |
1078 | - if ( $payment_method->description() ) { |
|
1078 | + if ($payment_method->description()) { |
|
1079 | 1079 | $payment_method_info = $payment_method->description(); |
1080 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1080 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
1081 | 1081 | $payment_method_info = sprintf( |
1082 | 1082 | __( |
1083 | 1083 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | ); |
1088 | 1088 | } else { |
1089 | 1089 | $payment_method_info = sprintf( |
1090 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
1090 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
1091 | 1091 | $this->submit_button_text() |
1092 | 1092 | ); |
1093 | 1093 | } |
@@ -1101,13 +1101,13 @@ discard block |
||
1101 | 1101 | ); |
1102 | 1102 | return new EE_Form_Section_Proper( |
1103 | 1103 | array( |
1104 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
1104 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
1105 | 1105 | 'html_class' => 'spco-payment-method-info-dv', |
1106 | 1106 | // only display the selected or default PM |
1107 | 1107 | 'html_style' => $currently_selected ? '' : 'display:none;', |
1108 | 1108 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1109 | 1109 | 'subsections' => array( |
1110 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
1110 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
1111 | 1111 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
1112 | 1112 | ) |
1113 | 1113 | ) |
@@ -1125,15 +1125,15 @@ discard block |
||
1125 | 1125 | */ |
1126 | 1126 | public function get_billing_form_html_for_payment_method() { |
1127 | 1127 | // how have they chosen to pay? |
1128 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1128 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1129 | 1129 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1130 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1130 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1131 | 1131 | return false; |
1132 | 1132 | } |
1133 | - if ( apply_filters( |
|
1133 | + if (apply_filters( |
|
1134 | 1134 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1135 | 1135 | false |
1136 | - ) ) { |
|
1136 | + )) { |
|
1137 | 1137 | EE_Error::add_success( |
1138 | 1138 | apply_filters( |
1139 | 1139 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ); |
1149 | 1149 | } |
1150 | 1150 | // now generate billing form for selected method of payment |
1151 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1151 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1152 | 1152 | // fill form with attendee info if applicable |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1170,10 +1170,10 @@ discard block |
||
1170 | 1170 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
1171 | 1171 | ? $payment_method_billing_form->get_html() |
1172 | 1172 | : ''; |
1173 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
1173 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
1174 | 1174 | // localize validation rules for main form |
1175 | 1175 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
1176 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1176 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1177 | 1177 | return true; |
1178 | 1178 | } |
1179 | 1179 | |
@@ -1187,18 +1187,18 @@ discard block |
||
1187 | 1187 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
1188 | 1188 | * @throws \EE_Error |
1189 | 1189 | */ |
1190 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1190 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1191 | 1191 | $billing_form = $payment_method->type_obj()->billing_form( |
1192 | 1192 | $this->checkout->transaction, |
1193 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1193 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1194 | 1194 | ); |
1195 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1195 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1196 | 1196 | if ( |
1197 | 1197 | apply_filters( |
1198 | 1198 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1199 | 1199 | false |
1200 | 1200 | ) |
1201 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1201 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1202 | 1202 | ) { |
1203 | 1203 | EE_Error::add_success( |
1204 | 1204 | apply_filters( |
@@ -1240,15 +1240,15 @@ discard block |
||
1240 | 1240 | $request_param = 'selected_method_of_payment' |
1241 | 1241 | ) { |
1242 | 1242 | // is selected_method_of_payment set in the request ? |
1243 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1244 | - if ( $selected_method_of_payment ) { |
|
1243 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1244 | + if ($selected_method_of_payment) { |
|
1245 | 1245 | // sanitize it |
1246 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1247 | - ? array_shift( $selected_method_of_payment ) |
|
1246 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1247 | + ? array_shift($selected_method_of_payment) |
|
1248 | 1248 | : $selected_method_of_payment; |
1249 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1249 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1250 | 1250 | // store it in the session so that it's available for all subsequent requests including AJAX |
1251 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1251 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1252 | 1252 | } else { |
1253 | 1253 | // or is is set in the session ? |
1254 | 1254 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | ); |
1257 | 1257 | } |
1258 | 1258 | // do ya really really gotta have it? |
1259 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1259 | + if (empty($selected_method_of_payment) && $required) { |
|
1260 | 1260 | EE_Error::add_error( |
1261 | 1261 | sprintf( |
1262 | 1262 | __( |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | ), |
1266 | 1266 | '<br/>', |
1267 | 1267 | '<br/>', |
1268 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1268 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1269 | 1269 | ), |
1270 | 1270 | __FILE__, |
1271 | 1271 | __FUNCTION__, |
@@ -1292,13 +1292,13 @@ discard block |
||
1292 | 1292 | * @throws \EE_Error |
1293 | 1293 | */ |
1294 | 1294 | public function switch_payment_method() { |
1295 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1295 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1296 | 1296 | return false; |
1297 | 1297 | } |
1298 | - if ( apply_filters( |
|
1298 | + if (apply_filters( |
|
1299 | 1299 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1300 | 1300 | false |
1301 | - ) ) { |
|
1301 | + )) { |
|
1302 | 1302 | EE_Error::add_success( |
1303 | 1303 | apply_filters( |
1304 | 1304 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | ); |
1314 | 1314 | } |
1315 | 1315 | // generate billing form for selected method of payment if it hasn't been done already |
1316 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1316 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1317 | 1317 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1318 | 1318 | $this->checkout->payment_method |
1319 | 1319 | ); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | ); |
1336 | 1336 | } |
1337 | 1337 | // and debug content |
1338 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1338 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1339 | 1339 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1340 | 1340 | ) { |
1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1343,15 +1343,15 @@ discard block |
||
1343 | 1343 | ); |
1344 | 1344 | } |
1345 | 1345 | // get html and validation rules for form |
1346 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1346 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1347 | 1347 | $this->checkout->json_response->set_return_data( |
1348 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1348 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1349 | 1349 | ); |
1350 | 1350 | // localize validation rules for main form |
1351 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1352 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1351 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1352 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1353 | 1353 | } else { |
1354 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1354 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1355 | 1355 | } |
1356 | 1356 | //prevents advancement to next step |
1357 | 1357 | $this->checkout->continue_reg = false; |
@@ -1368,18 +1368,18 @@ discard block |
||
1368 | 1368 | */ |
1369 | 1369 | protected function _verify_payment_method_is_set() { |
1370 | 1370 | // generate billing form for selected method of payment if it hasn't been done already |
1371 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1371 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1372 | 1372 | // how have they chosen to pay? |
1373 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1373 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1374 | 1374 | } else { |
1375 | 1375 | // choose your own adventure based on method_of_payment |
1376 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1376 | + switch ($this->checkout->selected_method_of_payment) { |
|
1377 | 1377 | case 'events_sold_out' : |
1378 | 1378 | EE_Error::add_attention( |
1379 | 1379 | apply_filters( |
1380 | 1380 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
1381 | - __( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1382 | - 'event_espresso' ) |
|
1381 | + __('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1382 | + 'event_espresso') |
|
1383 | 1383 | ), |
1384 | 1384 | __FILE__, __FUNCTION__, __LINE__ |
1385 | 1385 | ); |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | EE_Error::add_attention( |
1390 | 1390 | apply_filters( |
1391 | 1391 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
1392 | - __( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1392 | + __('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1393 | 1393 | ), |
1394 | 1394 | __FILE__, __FUNCTION__, __LINE__ |
1395 | 1395 | ); |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | EE_Error::add_attention( |
1400 | 1400 | apply_filters( |
1401 | 1401 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
1402 | - __( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1402 | + __('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1403 | 1403 | ), |
1404 | 1404 | __FILE__, __FUNCTION__, __LINE__ |
1405 | 1405 | ); |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | } |
1410 | 1410 | } |
1411 | 1411 | // verify payment method |
1412 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1412 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1413 | 1413 | // get payment method for selected method of payment |
1414 | 1414 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1415 | 1415 | } |
@@ -1428,25 +1428,25 @@ discard block |
||
1428 | 1428 | * @throws \EE_Error |
1429 | 1429 | */ |
1430 | 1430 | public function save_payer_details_via_ajax() { |
1431 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1431 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1432 | 1432 | return; |
1433 | 1433 | } |
1434 | 1434 | // generate billing form for selected method of payment if it hasn't been done already |
1435 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1435 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1436 | 1436 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1437 | 1437 | $this->checkout->payment_method |
1438 | 1438 | ); |
1439 | 1439 | } |
1440 | 1440 | // generate primary attendee from payer info if applicable |
1441 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1441 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1442 | 1442 | $attendee = $this->_create_attendee_from_request_data(); |
1443 | - if ( $attendee instanceof EE_Attendee ) { |
|
1444 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1445 | - if ( $registration->is_primary_registrant() ) { |
|
1443 | + if ($attendee instanceof EE_Attendee) { |
|
1444 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1445 | + if ($registration->is_primary_registrant()) { |
|
1446 | 1446 | $this->checkout->primary_attendee_obj = $attendee; |
1447 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1448 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1449 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1447 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1448 | + $registration->set_attendee_id($attendee->ID()); |
|
1449 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | } |
@@ -1464,50 +1464,50 @@ discard block |
||
1464 | 1464 | */ |
1465 | 1465 | protected function _create_attendee_from_request_data() { |
1466 | 1466 | // get State ID |
1467 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1468 | - if ( ! empty( $STA_ID ) ) { |
|
1467 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1468 | + if ( ! empty($STA_ID)) { |
|
1469 | 1469 | // can we get state object from name ? |
1470 | - EE_Registry::instance()->load_model( 'State' ); |
|
1471 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1472 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1470 | + EE_Registry::instance()->load_model('State'); |
|
1471 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1472 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1473 | 1473 | } |
1474 | 1474 | // get Country ISO |
1475 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1476 | - if ( ! empty( $CNT_ISO ) ) { |
|
1475 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1476 | + if ( ! empty($CNT_ISO)) { |
|
1477 | 1477 | // can we get country object from name ? |
1478 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1478 | + EE_Registry::instance()->load_model('Country'); |
|
1479 | 1479 | $country = EEM_Country::instance()->get_col( |
1480 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1480 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1481 | 1481 | 'CNT_ISO' |
1482 | 1482 | ); |
1483 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1483 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1484 | 1484 | } |
1485 | 1485 | // grab attendee data |
1486 | 1486 | $attendee_data = array( |
1487 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1488 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1489 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1490 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1491 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1492 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1487 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1488 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1489 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1490 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1491 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1492 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1493 | 1493 | 'STA_ID' => $STA_ID, |
1494 | 1494 | 'CNT_ISO' => $CNT_ISO, |
1495 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1496 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1495 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1496 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1497 | 1497 | ); |
1498 | 1498 | // validate the email address since it is the most important piece of info |
1499 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1499 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1500 | 1500 | EE_Error::add_error( |
1501 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1501 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1502 | 1502 | __FILE__, |
1503 | 1503 | __FUNCTION__, |
1504 | 1504 | __LINE__ |
1505 | 1505 | ); |
1506 | 1506 | } |
1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1508 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1508 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1509 | + && ! empty($attendee_data['ATT_lname']) |
|
1510 | + && ! empty($attendee_data['ATT_email']) |
|
1511 | 1511 | ) { |
1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1513 | 1513 | array( |
@@ -1516,19 +1516,19 @@ discard block |
||
1516 | 1516 | 'ATT_email' => $attendee_data['ATT_email'] |
1517 | 1517 | ) |
1518 | 1518 | ); |
1519 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1519 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1520 | 1520 | return $existing_attendee; |
1521 | 1521 | } |
1522 | 1522 | } |
1523 | 1523 | // no existing attendee? kk let's create a new one |
1524 | 1524 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1525 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1525 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1526 | 1526 | ? $attendee_data['ATT_fname'] |
1527 | 1527 | : $attendee_data['ATT_email']; |
1528 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1528 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1529 | 1529 | ? $attendee_data['ATT_lname'] |
1530 | 1530 | : $attendee_data['ATT_email']; |
1531 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1531 | + return EE_Attendee::new_instance($attendee_data); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | |
@@ -1546,26 +1546,26 @@ discard block |
||
1546 | 1546 | // how have they chosen to pay? |
1547 | 1547 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1548 | 1548 | ? 'no_payment_required' |
1549 | - : $this->_get_selected_method_of_payment( true ); |
|
1549 | + : $this->_get_selected_method_of_payment(true); |
|
1550 | 1550 | // choose your own adventure based on method_of_payment |
1551 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1551 | + switch ($this->checkout->selected_method_of_payment) { |
|
1552 | 1552 | |
1553 | 1553 | case 'events_sold_out' : |
1554 | 1554 | $this->checkout->redirect = true; |
1555 | 1555 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1556 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1556 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1557 | 1557 | // mark this reg step as completed |
1558 | 1558 | $this->set_completed(); |
1559 | 1559 | return false; |
1560 | 1560 | break; |
1561 | 1561 | |
1562 | 1562 | case 'payments_closed' : |
1563 | - if ( apply_filters( |
|
1563 | + if (apply_filters( |
|
1564 | 1564 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1565 | 1565 | false |
1566 | - ) ) { |
|
1566 | + )) { |
|
1567 | 1567 | EE_Error::add_success( |
1568 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1568 | + __('no payment required at this time.', 'event_espresso'), |
|
1569 | 1569 | __FILE__, |
1570 | 1570 | __FUNCTION__, |
1571 | 1571 | __LINE__ |
@@ -1577,12 +1577,12 @@ discard block |
||
1577 | 1577 | break; |
1578 | 1578 | |
1579 | 1579 | case 'no_payment_required' : |
1580 | - if ( apply_filters( |
|
1580 | + if (apply_filters( |
|
1581 | 1581 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1582 | 1582 | false |
1583 | - ) ) { |
|
1583 | + )) { |
|
1584 | 1584 | EE_Error::add_success( |
1585 | - __( 'no payment required.', 'event_espresso' ), |
|
1585 | + __('no payment required.', 'event_espresso'), |
|
1586 | 1586 | __FILE__, |
1587 | 1587 | __FUNCTION__, |
1588 | 1588 | __LINE__ |
@@ -1602,15 +1602,15 @@ discard block |
||
1602 | 1602 | EE_Registry::instance()->SSN->checkout()->revisit |
1603 | 1603 | ); |
1604 | 1604 | // calculate difference between the two arrays |
1605 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
1606 | - if ( empty( $registrations ) ) { |
|
1605 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
1606 | + if (empty($registrations)) { |
|
1607 | 1607 | $this->_redirect_because_event_sold_out(); |
1608 | 1608 | return false; |
1609 | 1609 | } |
1610 | 1610 | $payment_successful = $this->_process_payment(); |
1611 | - if ( $payment_successful ) { |
|
1611 | + if ($payment_successful) { |
|
1612 | 1612 | $this->checkout->continue_reg = true; |
1613 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1613 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1614 | 1614 | } else { |
1615 | 1615 | $this->checkout->continue_reg = false; |
1616 | 1616 | } |
@@ -1631,10 +1631,10 @@ discard block |
||
1631 | 1631 | $this->checkout->continue_reg = false; |
1632 | 1632 | // set redirect URL |
1633 | 1633 | $this->checkout->redirect_url = add_query_arg( |
1634 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1634 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1635 | 1635 | $this->checkout->current_step->reg_step_url() |
1636 | 1636 | ); |
1637 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1637 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1638 | 1638 | } |
1639 | 1639 | |
1640 | 1640 | |
@@ -1647,8 +1647,8 @@ discard block |
||
1647 | 1647 | * @return void |
1648 | 1648 | * @throws \EE_Error |
1649 | 1649 | */ |
1650 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1651 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1650 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1651 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1652 | 1652 | case EE_PMT_Base::offsite : |
1653 | 1653 | break; |
1654 | 1654 | case EE_PMT_Base::onsite : |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | public function update_reg_step() { |
1672 | 1672 | $success = true; |
1673 | 1673 | // if payment required |
1674 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1674 | + if ($this->checkout->transaction->total() > 0) { |
|
1675 | 1675 | do_action( |
1676 | 1676 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1677 | 1677 | $this->checkout->transaction |
@@ -1679,13 +1679,13 @@ discard block |
||
1679 | 1679 | // attempt payment via payment method |
1680 | 1680 | $success = $this->process_reg_step(); |
1681 | 1681 | } |
1682 | - if ( $success && ! $this->checkout->redirect ) { |
|
1682 | + if ($success && ! $this->checkout->redirect) { |
|
1683 | 1683 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1684 | 1684 | $this->checkout->transaction->ID() |
1685 | 1685 | ); |
1686 | 1686 | // set return URL |
1687 | 1687 | $this->checkout->redirect_url = add_query_arg( |
1688 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1688 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1689 | 1689 | $this->checkout->thank_you_page_url |
1690 | 1690 | ); |
1691 | 1691 | } |
@@ -1703,36 +1703,36 @@ discard block |
||
1703 | 1703 | */ |
1704 | 1704 | private function _process_payment() { |
1705 | 1705 | // basically confirm that the event hasn't sold out since they hit the page |
1706 | - if ( ! $this->_last_second_ticket_verifications() ) { |
|
1706 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
1707 | 1707 | return false; |
1708 | 1708 | } |
1709 | 1709 | // ya gotta make a choice man |
1710 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1710 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1711 | 1711 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1712 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1712 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1713 | 1713 | ); |
1714 | 1714 | return false; |
1715 | 1715 | } |
1716 | 1716 | // get EE_Payment_Method object |
1717 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1717 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1718 | 1718 | return false; |
1719 | 1719 | } |
1720 | 1720 | // setup billing form |
1721 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1721 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1722 | 1722 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1723 | 1723 | $this->checkout->payment_method |
1724 | 1724 | ); |
1725 | 1725 | // bad billing form ? |
1726 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1726 | + if ( ! $this->_billing_form_is_valid()) { |
|
1727 | 1727 | return false; |
1728 | 1728 | } |
1729 | 1729 | } |
1730 | 1730 | // ensure primary registrant has been fully processed |
1731 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1731 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1732 | 1732 | return false; |
1733 | 1733 | } |
1734 | 1734 | // if session is close to expiring (under 10 minutes by default) |
1735 | - if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) { |
|
1735 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
1736 | 1736 | // add some time to session expiration so that payment can be completed |
1737 | 1737 | EE_Registry::instance()->SSN->extend_expiration(); |
1738 | 1738 | } |
@@ -1741,12 +1741,12 @@ discard block |
||
1741 | 1741 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1742 | 1742 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1743 | 1743 | // attempt payment |
1744 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1744 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1745 | 1745 | // process results |
1746 | - $payment = $this->_validate_payment( $payment ); |
|
1747 | - $payment = $this->_post_payment_processing( $payment ); |
|
1746 | + $payment = $this->_validate_payment($payment); |
|
1747 | + $payment = $this->_post_payment_processing($payment); |
|
1748 | 1748 | // verify payment |
1749 | - if ( $payment instanceof EE_Payment ) { |
|
1749 | + if ($payment instanceof EE_Payment) { |
|
1750 | 1750 | // store that for later |
1751 | 1751 | $this->checkout->payment = $payment; |
1752 | 1752 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | } else { |
1761 | 1761 | return false; |
1762 | 1762 | } |
1763 | - } else if ( $payment === true ) { |
|
1763 | + } else if ($payment === true) { |
|
1764 | 1764 | // please note that offline payment methods will NOT make a payment, |
1765 | 1765 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1766 | 1766 | $this->checkout->payment = $payment; |
@@ -1780,22 +1780,22 @@ discard block |
||
1780 | 1780 | */ |
1781 | 1781 | protected function _last_second_ticket_verifications() { |
1782 | 1782 | // don't bother re-validating if not a return visit |
1783 | - if ( ! $this->checkout->revisit ) { |
|
1783 | + if ( ! $this->checkout->revisit) { |
|
1784 | 1784 | return true; |
1785 | 1785 | } |
1786 | 1786 | $registrations = $this->checkout->transaction->registrations(); |
1787 | - if ( empty( $registrations ) ) { |
|
1787 | + if (empty($registrations)) { |
|
1788 | 1788 | return false; |
1789 | 1789 | } |
1790 | - foreach ( $registrations as $registration ) { |
|
1791 | - if ( $registration instanceof EE_Registration ) { |
|
1790 | + foreach ($registrations as $registration) { |
|
1791 | + if ($registration instanceof EE_Registration) { |
|
1792 | 1792 | $event = $registration->event_obj(); |
1793 | - if ( $event instanceof EE_Event && $event->is_sold_out( true ) ) { |
|
1793 | + if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
1794 | 1794 | EE_Error::add_error( |
1795 | 1795 | apply_filters( |
1796 | 1796 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
1797 | 1797 | sprintf( |
1798 | - __( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ), |
|
1798 | + __('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'), |
|
1799 | 1799 | $event->name() |
1800 | 1800 | ) |
1801 | 1801 | ), |
@@ -1825,7 +1825,7 @@ discard block |
||
1825 | 1825 | ); |
1826 | 1826 | $html = $payment_method_billing_info->get_html(); |
1827 | 1827 | $html .= $this->checkout->redirect_form; |
1828 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1828 | + EE_Registry::instance()->REQ->add_output($html); |
|
1829 | 1829 | return true; |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1839,28 +1839,28 @@ discard block |
||
1839 | 1839 | * @throws \EE_Error |
1840 | 1840 | */ |
1841 | 1841 | private function _billing_form_is_valid() { |
1842 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1842 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1843 | 1843 | return true; |
1844 | 1844 | } |
1845 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1846 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1845 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1846 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1847 | 1847 | $this->checkout->billing_form->receive_form_submission(); |
1848 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1848 | + if ($this->checkout->billing_form->is_valid()) { |
|
1849 | 1849 | return true; |
1850 | 1850 | } |
1851 | 1851 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1852 | 1852 | $error_strings = array(); |
1853 | - foreach ( $validation_errors as $validation_error ) { |
|
1854 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1853 | + foreach ($validation_errors as $validation_error) { |
|
1854 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1855 | 1855 | $form_section = $validation_error->get_form_section(); |
1856 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1856 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1857 | 1857 | $label = $form_section->html_label_text(); |
1858 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1858 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1859 | 1859 | $label = $form_section->name(); |
1860 | 1860 | } else { |
1861 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1861 | + $label = __('Validation Error', 'event_espresso'); |
|
1862 | 1862 | } |
1863 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1863 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1864 | 1864 | } |
1865 | 1865 | } |
1866 | 1866 | EE_Error::add_error( |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | 'event_espresso' |
1871 | 1871 | ), |
1872 | 1872 | '<br/>', |
1873 | - implode( '<br/>', $error_strings ) |
|
1873 | + implode('<br/>', $error_strings) |
|
1874 | 1874 | ), |
1875 | 1875 | __FILE__, |
1876 | 1876 | __FUNCTION__, |
@@ -1889,7 +1889,7 @@ discard block |
||
1889 | 1889 | } |
1890 | 1890 | } else { |
1891 | 1891 | EE_Error::add_error( |
1892 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1892 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1893 | 1893 | __FILE__, |
1894 | 1894 | __FUNCTION__, |
1895 | 1895 | __LINE__ |
@@ -1928,7 +1928,7 @@ discard block |
||
1928 | 1928 | // save the TXN ( which clears cached copy of primary_registration) |
1929 | 1929 | $this->checkout->transaction->save(); |
1930 | 1930 | // grab TXN ID and save it to the primary_registration |
1931 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1931 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1932 | 1932 | // save what we have so far |
1933 | 1933 | $primary_registration->save(); |
1934 | 1934 | return true; |
@@ -1946,7 +1946,7 @@ discard block |
||
1946 | 1946 | private function _capture_primary_registration_data_from_billing_form() { |
1947 | 1947 | // convert billing form data into an attendee |
1948 | 1948 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1949 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1949 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1950 | 1950 | EE_Error::add_error( |
1951 | 1951 | sprintf( |
1952 | 1952 | __( |
@@ -1954,7 +1954,7 @@ discard block |
||
1954 | 1954 | 'event_espresso' |
1955 | 1955 | ), |
1956 | 1956 | '<br/>', |
1957 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1957 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1958 | 1958 | ), |
1959 | 1959 | __FILE__, |
1960 | 1960 | __FUNCTION__, |
@@ -1963,7 +1963,7 @@ discard block |
||
1963 | 1963 | return false; |
1964 | 1964 | } |
1965 | 1965 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1966 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1966 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1967 | 1967 | EE_Error::add_error( |
1968 | 1968 | sprintf( |
1969 | 1969 | __( |
@@ -1971,7 +1971,7 @@ discard block |
||
1971 | 1971 | 'event_espresso' |
1972 | 1972 | ), |
1973 | 1973 | '<br/>', |
1974 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1974 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1975 | 1975 | ), |
1976 | 1976 | __FILE__, |
1977 | 1977 | __FUNCTION__, |
@@ -1979,7 +1979,7 @@ discard block |
||
1979 | 1979 | ); |
1980 | 1980 | return false; |
1981 | 1981 | } |
1982 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1982 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1983 | 1983 | instanceof |
1984 | 1984 | EE_Attendee |
1985 | 1985 | ) { |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | 'event_espresso' |
1991 | 1991 | ), |
1992 | 1992 | '<br/>', |
1993 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1993 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1994 | 1994 | ), |
1995 | 1995 | __FILE__, |
1996 | 1996 | __FUNCTION__, |
@@ -1999,9 +1999,9 @@ discard block |
||
1999 | 1999 | return false; |
2000 | 2000 | } |
2001 | 2001 | /** @type EE_Registration_Processor $registration_processor */ |
2002 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
2002 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
2003 | 2003 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
2004 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
2004 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
2005 | 2005 | return true; |
2006 | 2006 | } |
2007 | 2007 | |
@@ -2016,22 +2016,22 @@ discard block |
||
2016 | 2016 | * @throws \EE_Error |
2017 | 2017 | */ |
2018 | 2018 | private function _get_payment_method_for_selected_method_of_payment() { |
2019 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
2019 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
2020 | 2020 | $this->_redirect_because_event_sold_out(); |
2021 | 2021 | return null; |
2022 | 2022 | } |
2023 | 2023 | // get EE_Payment_Method object |
2024 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
2025 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
2024 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
2025 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
2026 | 2026 | } else { |
2027 | 2027 | // load EEM_Payment_Method |
2028 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
2028 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
2029 | 2029 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
2030 | 2030 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
2031 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
2031 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
2032 | 2032 | } |
2033 | 2033 | // verify $payment_method |
2034 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
2034 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
2035 | 2035 | // not a payment |
2036 | 2036 | EE_Error::add_error( |
2037 | 2037 | sprintf( |
@@ -2040,7 +2040,7 @@ discard block |
||
2040 | 2040 | 'event_espresso' |
2041 | 2041 | ), |
2042 | 2042 | '<br/>', |
2043 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2043 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2044 | 2044 | ), |
2045 | 2045 | __FILE__, |
2046 | 2046 | __FUNCTION__, |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | return null; |
2050 | 2050 | } |
2051 | 2051 | // and verify it has a valid Payment_Method Type object |
2052 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
2052 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
2053 | 2053 | // not a payment |
2054 | 2054 | EE_Error::add_error( |
2055 | 2055 | sprintf( |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | 'event_espresso' |
2059 | 2059 | ), |
2060 | 2060 | '<br/>', |
2061 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2061 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2062 | 2062 | ), |
2063 | 2063 | __FILE__, |
2064 | 2064 | __FUNCTION__, |
@@ -2079,29 +2079,29 @@ discard block |
||
2079 | 2079 | * @return mixed EE_Payment | boolean |
2080 | 2080 | * @throws \EE_Error |
2081 | 2081 | */ |
2082 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
2082 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
2083 | 2083 | $payment = null; |
2084 | 2084 | $this->checkout->transaction->save(); |
2085 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2086 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
2085 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2086 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
2087 | 2087 | return false; |
2088 | 2088 | } |
2089 | 2089 | try { |
2090 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
2090 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
2091 | 2091 | // generate payment object |
2092 | 2092 | $payment = $payment_processor->process_payment( |
2093 | 2093 | $payment_method, |
2094 | 2094 | $this->checkout->transaction, |
2095 | 2095 | $this->checkout->amount_owing, |
2096 | 2096 | $this->checkout->billing_form, |
2097 | - $this->_get_return_url( $payment_method ), |
|
2097 | + $this->_get_return_url($payment_method), |
|
2098 | 2098 | 'CART', |
2099 | 2099 | $this->checkout->admin_request, |
2100 | 2100 | true, |
2101 | 2101 | $this->reg_step_url() |
2102 | 2102 | ); |
2103 | - } catch ( Exception $e ) { |
|
2104 | - $this->_handle_payment_processor_exception( $e ); |
|
2103 | + } catch (Exception $e) { |
|
2104 | + $this->_handle_payment_processor_exception($e); |
|
2105 | 2105 | } |
2106 | 2106 | return $payment; |
2107 | 2107 | } |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | * @return void |
2117 | 2117 | * @throws \EE_Error |
2118 | 2118 | */ |
2119 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
2119 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
2120 | 2120 | EE_Error::add_error( |
2121 | 2121 | sprintf( |
2122 | 2122 | __( |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | 'event_espresso' |
2125 | 2125 | ), |
2126 | 2126 | '<br/>', |
2127 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
2127 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
2128 | 2128 | $e->getMessage(), |
2129 | 2129 | $e->getFile(), |
2130 | 2130 | $e->getLine() |
@@ -2145,9 +2145,9 @@ discard block |
||
2145 | 2145 | * @return string |
2146 | 2146 | * @throws \EE_Error |
2147 | 2147 | */ |
2148 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
2148 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
2149 | 2149 | $return_url = ''; |
2150 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
2150 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
2151 | 2151 | case EE_PMT_Base::offsite : |
2152 | 2152 | $return_url = add_query_arg( |
2153 | 2153 | array( |
@@ -2176,12 +2176,12 @@ discard block |
||
2176 | 2176 | * @return EE_Payment | FALSE |
2177 | 2177 | * @throws \EE_Error |
2178 | 2178 | */ |
2179 | - private function _validate_payment( $payment = null ) { |
|
2180 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
2179 | + private function _validate_payment($payment = null) { |
|
2180 | + if ($this->checkout->payment_method->is_off_line()) { |
|
2181 | 2181 | return true; |
2182 | 2182 | } |
2183 | 2183 | // verify payment object |
2184 | - if ( ! $payment instanceof EE_Payment ) { |
|
2184 | + if ( ! $payment instanceof EE_Payment) { |
|
2185 | 2185 | // not a payment |
2186 | 2186 | EE_Error::add_error( |
2187 | 2187 | sprintf( |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | 'event_espresso' |
2191 | 2191 | ), |
2192 | 2192 | '<br/>', |
2193 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2193 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2194 | 2194 | ), |
2195 | 2195 | __FILE__, |
2196 | 2196 | __FUNCTION__, |
@@ -2211,27 +2211,27 @@ discard block |
||
2211 | 2211 | * @return bool |
2212 | 2212 | * @throws \EE_Error |
2213 | 2213 | */ |
2214 | - private function _post_payment_processing( $payment = null ) { |
|
2214 | + private function _post_payment_processing($payment = null) { |
|
2215 | 2215 | // Off-Line payment? |
2216 | - if ( $payment === true ) { |
|
2216 | + if ($payment === true) { |
|
2217 | 2217 | //$this->_setup_redirect_for_next_step(); |
2218 | 2218 | return true; |
2219 | 2219 | // On-Site payment? |
2220 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
2221 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
2220 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
2221 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
2222 | 2222 | //$this->_setup_redirect_for_next_step(); |
2223 | 2223 | $this->checkout->continue_reg = false; |
2224 | 2224 | } |
2225 | 2225 | // Off-Site payment? |
2226 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
2226 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
2227 | 2227 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
2228 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
2229 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
2228 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
2229 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
2230 | 2230 | $this->checkout->redirect = true; |
2231 | 2231 | $this->checkout->redirect_form = $payment->redirect_form(); |
2232 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
2232 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
2233 | 2233 | // set JSON response |
2234 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
2234 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
2235 | 2235 | // set cron job for finalizing the TXN |
2236 | 2236 | // in case the user does not return from the off-site gateway |
2237 | 2237 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | $this->checkout->transaction->ID() |
2240 | 2240 | ); |
2241 | 2241 | // and lastly, let's bump the payment status to pending |
2242 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
2242 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
2243 | 2243 | $payment->save(); |
2244 | 2244 | } else { |
2245 | 2245 | // not a payment |
@@ -2251,7 +2251,7 @@ discard block |
||
2251 | 2251 | 'event_espresso' |
2252 | 2252 | ), |
2253 | 2253 | '<br/>', |
2254 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2254 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2255 | 2255 | ), |
2256 | 2256 | __FILE__, |
2257 | 2257 | __FUNCTION__, |
@@ -2289,21 +2289,21 @@ discard block |
||
2289 | 2289 | * @return bool |
2290 | 2290 | * @throws \EE_Error |
2291 | 2291 | */ |
2292 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
2292 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
2293 | 2293 | // off-line payment? carry on |
2294 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
2294 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
2295 | 2295 | return true; |
2296 | 2296 | } |
2297 | 2297 | // verify payment validity |
2298 | - if ( $payment instanceof EE_Payment ) { |
|
2299 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
2298 | + if ($payment instanceof EE_Payment) { |
|
2299 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
2300 | 2300 | $msg = $payment->gateway_response(); |
2301 | 2301 | // check results |
2302 | - switch ( $payment->status() ) { |
|
2302 | + switch ($payment->status()) { |
|
2303 | 2303 | // good payment |
2304 | 2304 | case EEM_Payment::status_id_approved : |
2305 | 2305 | EE_Error::add_success( |
2306 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
2306 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
2307 | 2307 | __FILE__, |
2308 | 2308 | __FUNCTION__, |
2309 | 2309 | __LINE__ |
@@ -2312,45 +2312,45 @@ discard block |
||
2312 | 2312 | break; |
2313 | 2313 | // slow payment |
2314 | 2314 | case EEM_Payment::status_id_pending : |
2315 | - if ( empty( $msg ) ) { |
|
2315 | + if (empty($msg)) { |
|
2316 | 2316 | $msg = __( |
2317 | 2317 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2318 | 2318 | 'event_espresso' |
2319 | 2319 | ); |
2320 | 2320 | } |
2321 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2321 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2322 | 2322 | return true; |
2323 | 2323 | break; |
2324 | 2324 | // don't wanna payment |
2325 | 2325 | case EEM_Payment::status_id_cancelled : |
2326 | - if ( empty( $msg ) ) { |
|
2326 | + if (empty($msg)) { |
|
2327 | 2327 | $msg = _n( |
2328 | 2328 | 'Payment cancelled. Please try again.', |
2329 | 2329 | 'Payment cancelled. Please try again or select another method of payment.', |
2330 | - count( $this->checkout->available_payment_methods ), |
|
2330 | + count($this->checkout->available_payment_methods), |
|
2331 | 2331 | 'event_espresso' |
2332 | 2332 | ); |
2333 | 2333 | } |
2334 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2334 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2335 | 2335 | return false; |
2336 | 2336 | break; |
2337 | 2337 | // not enough payment |
2338 | 2338 | case EEM_Payment::status_id_declined : |
2339 | - if ( empty( $msg ) ) { |
|
2339 | + if (empty($msg)) { |
|
2340 | 2340 | $msg = _n( |
2341 | 2341 | 'We\'re sorry but your payment was declined. Please try again.', |
2342 | 2342 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2343 | - count( $this->checkout->available_payment_methods ), |
|
2343 | + count($this->checkout->available_payment_methods), |
|
2344 | 2344 | 'event_espresso' |
2345 | 2345 | ); |
2346 | 2346 | } |
2347 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2347 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2348 | 2348 | return false; |
2349 | 2349 | break; |
2350 | 2350 | // bad payment |
2351 | 2351 | case EEM_Payment::status_id_failed : |
2352 | - if ( ! empty( $msg ) ) { |
|
2353 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2352 | + if ( ! empty($msg)) { |
|
2353 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2354 | 2354 | return false; |
2355 | 2355 | } |
2356 | 2356 | // default to error below |
@@ -2359,7 +2359,7 @@ discard block |
||
2359 | 2359 | } |
2360 | 2360 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2361 | 2361 | // the payment processing is just running slower than the registrant's request |
2362 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2362 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2363 | 2363 | return true; |
2364 | 2364 | } |
2365 | 2365 | EE_Error::add_error( |
@@ -2369,7 +2369,7 @@ discard block |
||
2369 | 2369 | 'event_espresso' |
2370 | 2370 | ), |
2371 | 2371 | '<br/>', |
2372 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2372 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2373 | 2373 | ), |
2374 | 2374 | __FILE__, |
2375 | 2375 | __FUNCTION__, |
@@ -2402,13 +2402,13 @@ discard block |
||
2402 | 2402 | public function process_gateway_response() { |
2403 | 2403 | $payment = null; |
2404 | 2404 | // how have they chosen to pay? |
2405 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2405 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2406 | 2406 | // get EE_Payment_Method object |
2407 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2407 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2408 | 2408 | $this->checkout->continue_reg = false; |
2409 | 2409 | return false; |
2410 | 2410 | } |
2411 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2411 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2412 | 2412 | return false; |
2413 | 2413 | } |
2414 | 2414 | $this->_validate_offsite_return(); |
@@ -2422,23 +2422,23 @@ discard block |
||
2422 | 2422 | // true |
2423 | 2423 | //); |
2424 | 2424 | // verify TXN |
2425 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2425 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2426 | 2426 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2427 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2427 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2428 | 2428 | $this->checkout->continue_reg = false; |
2429 | 2429 | return false; |
2430 | 2430 | } |
2431 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2432 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2433 | - $payment = $this->_validate_payment( $payment ); |
|
2431 | + $payment = $this->_process_off_site_payment($gateway); |
|
2432 | + $payment = $this->_process_cancelled_payments($payment); |
|
2433 | + $payment = $this->_validate_payment($payment); |
|
2434 | 2434 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2435 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2435 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2436 | 2436 | //$this->_setup_redirect_for_next_step(); |
2437 | 2437 | // store that for later |
2438 | 2438 | $this->checkout->payment = $payment; |
2439 | 2439 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2440 | 2440 | // because we will complete this step during the IPN processing then |
2441 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2441 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2442 | 2442 | $this->set_completed(); |
2443 | 2443 | } |
2444 | 2444 | return true; |
@@ -2463,21 +2463,21 @@ discard block |
||
2463 | 2463 | * @throws \EE_Error |
2464 | 2464 | */ |
2465 | 2465 | private function _validate_offsite_return() { |
2466 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2467 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2466 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2467 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2468 | 2468 | // Houston... we might have a problem |
2469 | 2469 | $invalid_TXN = false; |
2470 | 2470 | // first gather some info |
2471 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2471 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2472 | 2472 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2473 | 2473 | ? $valid_TXN->primary_registration() |
2474 | 2474 | : null; |
2475 | 2475 | // let's start by retrieving the cart for this TXN |
2476 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2477 | - if ( $cart instanceof EE_Cart ) { |
|
2476 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2477 | + if ($cart instanceof EE_Cart) { |
|
2478 | 2478 | // verify that the current cart has tickets |
2479 | 2479 | $tickets = $cart->get_tickets(); |
2480 | - if ( empty( $tickets ) ) { |
|
2480 | + if (empty($tickets)) { |
|
2481 | 2481 | $invalid_TXN = true; |
2482 | 2482 | } |
2483 | 2483 | } else { |
@@ -2503,21 +2503,21 @@ discard block |
||
2503 | 2503 | ) { |
2504 | 2504 | $invalid_TXN = true; |
2505 | 2505 | } |
2506 | - if ( $invalid_TXN ) { |
|
2506 | + if ($invalid_TXN) { |
|
2507 | 2507 | // is the valid TXN completed ? |
2508 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2508 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2509 | 2509 | // has this step even been started ? |
2510 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
2511 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2510 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
2511 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2512 | 2512 | // so it **looks** like this is a double request from PayPal |
2513 | 2513 | // so let's try to pick up where we left off |
2514 | 2514 | $this->checkout->transaction = $valid_TXN; |
2515 | - $this->checkout->refresh_all_entities( true ); |
|
2515 | + $this->checkout->refresh_all_entities(true); |
|
2516 | 2516 | return; |
2517 | 2517 | } |
2518 | 2518 | } |
2519 | 2519 | // you appear to be lost? |
2520 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2520 | + $this->_redirect_wayward_request($primary_registrant); |
|
2521 | 2521 | } |
2522 | 2522 | } |
2523 | 2523 | } |
@@ -2532,14 +2532,14 @@ discard block |
||
2532 | 2532 | * @return bool |
2533 | 2533 | * @throws \EE_Error |
2534 | 2534 | */ |
2535 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2536 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2535 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2536 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2537 | 2537 | // try redirecting based on the current TXN |
2538 | 2538 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2539 | 2539 | ? $this->checkout->transaction->primary_registration() |
2540 | 2540 | : null; |
2541 | 2541 | } |
2542 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2542 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2543 | 2543 | EE_Error::add_error( |
2544 | 2544 | sprintf( |
2545 | 2545 | __( |
@@ -2547,7 +2547,7 @@ discard block |
||
2547 | 2547 | 'event_espresso' |
2548 | 2548 | ), |
2549 | 2549 | '<br/>', |
2550 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2550 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2551 | 2551 | ), |
2552 | 2552 | __FILE__, |
2553 | 2553 | __FUNCTION__, |
@@ -2578,17 +2578,17 @@ discard block |
||
2578 | 2578 | * @return \EE_Payment |
2579 | 2579 | * @throws \EE_Error |
2580 | 2580 | */ |
2581 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2581 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2582 | 2582 | try { |
2583 | 2583 | $request_data = \EE_Registry::instance()->REQ->params(); |
2584 | 2584 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2585 | 2585 | $this->set_handle_IPN_in_this_request( |
2586 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2586 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2587 | 2587 | ); |
2588 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2588 | + if ($this->handle_IPN_in_this_request()) { |
|
2589 | 2589 | // get payment details and process results |
2590 | 2590 | /** @type EE_Payment_Processor $payment_processor */ |
2591 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2591 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2592 | 2592 | $payment = $payment_processor->process_ipn( |
2593 | 2593 | $request_data, |
2594 | 2594 | $this->checkout->transaction, |
@@ -2601,14 +2601,14 @@ discard block |
||
2601 | 2601 | $payment = $this->checkout->transaction->last_payment(); |
2602 | 2602 | //$payment_source = 'last_payment'; |
2603 | 2603 | } |
2604 | - } catch ( Exception $e ) { |
|
2604 | + } catch (Exception $e) { |
|
2605 | 2605 | // let's just eat the exception and try to move on using any previously set payment info |
2606 | 2606 | $payment = $this->checkout->transaction->last_payment(); |
2607 | 2607 | //$payment_source = 'last_payment after Exception'; |
2608 | 2608 | // but if we STILL don't have a payment object |
2609 | - if ( ! $payment instanceof EE_Payment ) { |
|
2609 | + if ( ! $payment instanceof EE_Payment) { |
|
2610 | 2610 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2611 | - $this->_handle_payment_processor_exception( $e ); |
|
2611 | + $this->_handle_payment_processor_exception($e); |
|
2612 | 2612 | } |
2613 | 2613 | } |
2614 | 2614 | // DEBUG LOG |
@@ -2633,13 +2633,13 @@ discard block |
||
2633 | 2633 | * @return EE_Payment | FALSE |
2634 | 2634 | * @throws \EE_Error |
2635 | 2635 | */ |
2636 | - private function _process_cancelled_payments( $payment = null ) { |
|
2636 | + private function _process_cancelled_payments($payment = null) { |
|
2637 | 2637 | if ( |
2638 | 2638 | $payment instanceof EE_Payment |
2639 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2639 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2640 | 2640 | && $payment->status() === EEM_Payment::status_id_failed |
2641 | 2641 | ) { |
2642 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2642 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2643 | 2643 | } |
2644 | 2644 | return $payment; |
2645 | 2645 | } |
@@ -2656,14 +2656,14 @@ discard block |
||
2656 | 2656 | public function get_transaction_details_for_gateways() { |
2657 | 2657 | $txn_details = array(); |
2658 | 2658 | // ya gotta make a choice man |
2659 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2659 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2660 | 2660 | $txn_details = array( |
2661 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2661 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2662 | 2662 | ); |
2663 | 2663 | } |
2664 | 2664 | // get EE_Payment_Method object |
2665 | 2665 | if ( |
2666 | - empty( $txn_details ) |
|
2666 | + empty($txn_details) |
|
2667 | 2667 | && |
2668 | 2668 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2669 | 2669 | ) { |
@@ -2675,8 +2675,8 @@ discard block |
||
2675 | 2675 | ) |
2676 | 2676 | ); |
2677 | 2677 | } |
2678 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2679 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2678 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2679 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2680 | 2680 | $txn_details = array( |
2681 | 2681 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2682 | 2682 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2687,7 +2687,7 @@ discard block |
||
2687 | 2687 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2688 | 2688 | 'payment_amount' => $this->checkout->amount_owing, |
2689 | 2689 | 'return_url' => $return_url, |
2690 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2690 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2691 | 2691 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2692 | 2692 | array( |
2693 | 2693 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2696,7 +2696,7 @@ discard block |
||
2696 | 2696 | ) |
2697 | 2697 | ); |
2698 | 2698 | } |
2699 | - echo wp_json_encode( $txn_details ); |
|
2699 | + echo wp_json_encode($txn_details); |
|
2700 | 2700 | exit(); |
2701 | 2701 | } |
2702 | 2702 | |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | public function __sleep() |
2714 | 2714 | { |
2715 | 2715 | // remove the reg form and the checkout |
2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2716 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display')); |
|
2717 | 2717 | } |
2718 | 2718 | |
2719 | 2719 |
@@ -17,800 +17,800 @@ discard block |
||
17 | 17 | final class EE_Capabilities extends EE_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * the name of the wp option used to store caps previously initialized |
|
22 | - */ |
|
23 | - const option_name = 'ee_caps_initialized'; |
|
24 | - |
|
25 | - /** |
|
26 | - * instance of EE_Capabilities object |
|
27 | - * |
|
28 | - * @var EE_Capabilities |
|
29 | - */ |
|
30 | - private static $_instance; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * This is a map of caps that correspond to a default WP_Role. |
|
35 | - * Array is indexed by Role and values are ee capabilities. |
|
36 | - * |
|
37 | - * @since 4.5.0 |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - private $_caps_map = array(); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
46 | - * a user depending on context. |
|
47 | - * |
|
48 | - * @var EE_Meta_Capability_Map[] |
|
49 | - */ |
|
50 | - private $_meta_caps = array(); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * singleton method used to instantiate class object |
|
55 | - * |
|
56 | - * @since 4.5.0 |
|
57 | - * |
|
58 | - * @return EE_Capabilities |
|
59 | - */ |
|
60 | - public static function instance() |
|
61 | - { |
|
62 | - //check if instantiated, and if not do so. |
|
63 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
64 | - self::$_instance = new self(); |
|
65 | - } |
|
66 | - return self::$_instance; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * private constructor |
|
72 | - * |
|
73 | - * @since 4.5.0 |
|
74 | - * |
|
75 | - * @return \EE_Capabilities |
|
76 | - */ |
|
77 | - private function __construct() |
|
78 | - { |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
84 | - * |
|
85 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
86 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
87 | - * ensures that they are up to date. |
|
88 | - * |
|
89 | - * |
|
90 | - * @since 4.5.0 |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public function init_caps($reset = false) |
|
94 | - { |
|
95 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
96 | - $this->_caps_map = $this->_init_caps_map(); |
|
97 | - $this->init_role_caps($reset); |
|
98 | - $this->_set_meta_caps(); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * This sets the meta caps property. |
|
105 | - * @since 4.5.0 |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - private function _set_meta_caps() |
|
110 | - { |
|
111 | - //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
112 | - $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
113 | - $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
114 | - //add filter for map_meta_caps but only if models can query. |
|
115 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | - add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * This builds and returns the default meta_caps array only once. |
|
123 | - * |
|
124 | - * @since 4.8.28.rc.012 |
|
125 | - * @return array |
|
126 | - * @throws \EE_Error |
|
127 | - */ |
|
128 | - private function _get_default_meta_caps_array() |
|
129 | - { |
|
130 | - static $default_meta_caps = array(); |
|
131 | - if (empty($default_meta_caps)) { |
|
132 | - $default_meta_caps = array( |
|
133 | - //edits |
|
134 | - new EE_Meta_Capability_Map_Edit( |
|
135 | - 'ee_edit_event', |
|
136 | - array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
137 | - ), |
|
138 | - new EE_Meta_Capability_Map_Edit( |
|
139 | - 'ee_edit_venue', |
|
140 | - array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
141 | - ), |
|
142 | - new EE_Meta_Capability_Map_Edit( |
|
143 | - 'ee_edit_registration', |
|
144 | - array('Registration', '', 'ee_edit_others_registrations', '') |
|
145 | - ), |
|
146 | - new EE_Meta_Capability_Map_Edit( |
|
147 | - 'ee_edit_checkin', |
|
148 | - array('Registration', '', 'ee_edit_others_checkins', '') |
|
149 | - ), |
|
150 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
151 | - 'ee_edit_message', |
|
152 | - array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
153 | - ), |
|
154 | - new EE_Meta_Capability_Map_Edit( |
|
155 | - 'ee_edit_default_ticket', |
|
156 | - array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
157 | - ), |
|
158 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
159 | - 'ee_edit_question', |
|
160 | - array('Question', '', '', 'ee_edit_system_questions') |
|
161 | - ), |
|
162 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
163 | - 'ee_edit_question_group', |
|
164 | - array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
165 | - ), |
|
166 | - new EE_Meta_Capability_Map_Edit( |
|
167 | - 'ee_edit_payment_method', |
|
168 | - array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
169 | - ), |
|
170 | - //reads |
|
171 | - new EE_Meta_Capability_Map_Read( |
|
172 | - 'ee_read_event', |
|
173 | - array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
174 | - ), |
|
175 | - new EE_Meta_Capability_Map_Read( |
|
176 | - 'ee_read_venue', |
|
177 | - array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
178 | - ), |
|
179 | - new EE_Meta_Capability_Map_Read( |
|
180 | - 'ee_read_registration', |
|
181 | - array('Registration', '', '', 'ee_edit_others_registrations') |
|
182 | - ), |
|
183 | - new EE_Meta_Capability_Map_Read( |
|
184 | - 'ee_read_checkin', |
|
185 | - array('Registration', '', '', 'ee_read_others_checkins') |
|
186 | - ), |
|
187 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
188 | - 'ee_read_message', |
|
189 | - array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
190 | - ), |
|
191 | - new EE_Meta_Capability_Map_Read( |
|
192 | - 'ee_read_default_ticket', |
|
193 | - array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
194 | - ), |
|
195 | - new EE_Meta_Capability_Map_Read( |
|
196 | - 'ee_read_payment_method', |
|
197 | - array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
198 | - |
|
199 | - //deletes |
|
200 | - new EE_Meta_Capability_Map_Delete( |
|
201 | - 'ee_delete_event', |
|
202 | - array( |
|
203 | - 'Event', |
|
204 | - 'ee_delete_published_events', |
|
205 | - 'ee_delete_others_events', |
|
206 | - 'ee_delete_private_events', |
|
207 | - ) |
|
208 | - ), |
|
209 | - new EE_Meta_Capability_Map_Delete( |
|
210 | - 'ee_delete_venue', |
|
211 | - array( |
|
212 | - 'Venue', |
|
213 | - 'ee_delete_published_venues', |
|
214 | - 'ee_delete_others_venues', |
|
215 | - 'ee_delete_private_venues', |
|
216 | - ) |
|
217 | - ), |
|
218 | - new EE_Meta_Capability_Map_Delete( |
|
219 | - 'ee_delete_registration', |
|
220 | - array('Registration', '', 'ee_delete_others_registrations', '') |
|
221 | - ), |
|
222 | - new EE_Meta_Capability_Map_Delete( |
|
223 | - 'ee_delete_checkin', |
|
224 | - array('Registration', '', 'ee_delete_others_checkins', '') |
|
225 | - ), |
|
226 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
227 | - 'ee_delete_message', |
|
228 | - array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
229 | - ), |
|
230 | - new EE_Meta_Capability_Map_Delete( |
|
231 | - 'ee_delete_default_ticket', |
|
232 | - array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
233 | - ), |
|
234 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
235 | - 'ee_delete_question', |
|
236 | - array('Question', '', '', 'delete_system_questions') |
|
237 | - ), |
|
238 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
239 | - 'ee_delete_question_group', |
|
240 | - array('Question_Group', '', '', 'delete_system_question_groups') |
|
241 | - ), |
|
242 | - new EE_Meta_Capability_Map_Delete( |
|
243 | - 'ee_delete_payment_method', |
|
244 | - array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
245 | - ), |
|
246 | - ); |
|
247 | - } |
|
248 | - return $default_meta_caps; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
254 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
255 | - * |
|
256 | - * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
257 | - * |
|
258 | - * @since 4.5.0 |
|
259 | - * @see wp-includes/capabilities.php |
|
260 | - * |
|
261 | - * @param array $caps actual users capabilities |
|
262 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
263 | - * @param int $user_id The user id |
|
264 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
265 | - * @return array actual users capabilities |
|
266 | - * @throws EE_Error |
|
267 | - */ |
|
268 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
269 | - { |
|
270 | - if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
271 | - //loop through our _meta_caps array |
|
272 | - foreach ($this->_meta_caps as $meta_map) { |
|
273 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | - continue; |
|
275 | - } |
|
276 | - // don't load models if there is no object ID in the args |
|
277 | - if(!empty($args[0])){ |
|
278 | - $meta_map->ensure_is_model(); |
|
279 | - } |
|
280 | - $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
281 | - } |
|
282 | - } |
|
283 | - return $caps; |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * This sets up and returns the initial capabilities map for Event Espresso |
|
289 | - * |
|
290 | - * @since 4.5.0 |
|
291 | - * |
|
292 | - * @return array |
|
293 | - */ |
|
294 | - private function _init_caps_map() |
|
295 | - { |
|
296 | - $caps = array( |
|
297 | - 'administrator' => array( |
|
298 | - //basic access |
|
299 | - 'ee_read_ee', |
|
300 | - //gateways |
|
301 | - /** |
|
302 | - * note that with payment method capabilities, although we've implemented |
|
303 | - * capability mapping which will be used for accessing payment methods owned by |
|
304 | - * other users. This is not fully implemented yet in the payment method ui. |
|
305 | - * Currently only the "plural" caps are in active use. |
|
306 | - * (Specific payment method caps are in use as well). |
|
307 | - **/ |
|
308 | - 'ee_manage_gateways', |
|
309 | - 'ee_read_payment_method', |
|
310 | - 'ee_read_payment_methods', |
|
311 | - 'ee_read_others_payment_methods', |
|
312 | - 'ee_edit_payment_method', |
|
313 | - 'ee_edit_payment_methods', |
|
314 | - 'ee_edit_others_payment_methods', |
|
315 | - 'ee_delete_payment_method', |
|
316 | - 'ee_delete_payment_methods', |
|
317 | - //events |
|
318 | - 'ee_publish_events', |
|
319 | - 'ee_read_private_events', |
|
320 | - 'ee_read_others_events', |
|
321 | - 'ee_read_event', |
|
322 | - 'ee_read_events', |
|
323 | - 'ee_edit_event', |
|
324 | - 'ee_edit_events', |
|
325 | - 'ee_edit_published_events', |
|
326 | - 'ee_edit_others_events', |
|
327 | - 'ee_edit_private_events', |
|
328 | - 'ee_delete_published_events', |
|
329 | - 'ee_delete_private_events', |
|
330 | - 'ee_delete_event', |
|
331 | - 'ee_delete_events', |
|
332 | - 'ee_delete_others_events', |
|
333 | - //event categories |
|
334 | - 'ee_manage_event_categories', |
|
335 | - 'ee_edit_event_category', |
|
336 | - 'ee_delete_event_category', |
|
337 | - 'ee_assign_event_category', |
|
338 | - //venues |
|
339 | - 'ee_publish_venues', |
|
340 | - 'ee_read_venue', |
|
341 | - 'ee_read_venues', |
|
342 | - 'ee_read_others_venues', |
|
343 | - 'ee_read_private_venues', |
|
344 | - 'ee_edit_venue', |
|
345 | - 'ee_edit_venues', |
|
346 | - 'ee_edit_others_venues', |
|
347 | - 'ee_edit_published_venues', |
|
348 | - 'ee_edit_private_venues', |
|
349 | - 'ee_delete_venue', |
|
350 | - 'ee_delete_venues', |
|
351 | - 'ee_delete_others_venues', |
|
352 | - 'ee_delete_private_venues', |
|
353 | - 'ee_delete_published_venues', |
|
354 | - //venue categories |
|
355 | - 'ee_manage_venue_categories', |
|
356 | - 'ee_edit_venue_category', |
|
357 | - 'ee_delete_venue_category', |
|
358 | - 'ee_assign_venue_category', |
|
359 | - //contacts |
|
360 | - 'ee_read_contact', |
|
361 | - 'ee_read_contacts', |
|
362 | - 'ee_edit_contact', |
|
363 | - 'ee_edit_contacts', |
|
364 | - 'ee_delete_contact', |
|
365 | - 'ee_delete_contacts', |
|
366 | - //registrations |
|
367 | - 'ee_read_registration', |
|
368 | - 'ee_read_registrations', |
|
369 | - 'ee_read_others_registrations', |
|
370 | - 'ee_edit_registration', |
|
371 | - 'ee_edit_registrations', |
|
372 | - 'ee_edit_others_registrations', |
|
373 | - 'ee_delete_registration', |
|
374 | - 'ee_delete_registrations', |
|
375 | - //checkins |
|
376 | - 'ee_read_checkin', |
|
377 | - 'ee_read_others_checkins', |
|
378 | - 'ee_read_checkins', |
|
379 | - 'ee_edit_checkin', |
|
380 | - 'ee_edit_checkins', |
|
381 | - 'ee_edit_others_checkins', |
|
382 | - 'ee_delete_checkin', |
|
383 | - 'ee_delete_checkins', |
|
384 | - 'ee_delete_others_checkins', |
|
385 | - //transactions && payments |
|
386 | - 'ee_read_transaction', |
|
387 | - 'ee_read_transactions', |
|
388 | - 'ee_edit_payments', |
|
389 | - 'ee_delete_payments', |
|
390 | - //messages |
|
391 | - 'ee_read_message', |
|
392 | - 'ee_read_messages', |
|
393 | - 'ee_read_others_messages', |
|
394 | - 'ee_read_global_messages', |
|
395 | - 'ee_edit_global_messages', |
|
396 | - 'ee_edit_message', |
|
397 | - 'ee_edit_messages', |
|
398 | - 'ee_edit_others_messages', |
|
399 | - 'ee_delete_message', |
|
400 | - 'ee_delete_messages', |
|
401 | - 'ee_delete_others_messages', |
|
402 | - 'ee_delete_global_messages', |
|
403 | - 'ee_send_message', |
|
404 | - //tickets |
|
405 | - 'ee_read_default_ticket', |
|
406 | - 'ee_read_default_tickets', |
|
407 | - 'ee_read_others_default_tickets', |
|
408 | - 'ee_edit_default_ticket', |
|
409 | - 'ee_edit_default_tickets', |
|
410 | - 'ee_edit_others_default_tickets', |
|
411 | - 'ee_delete_default_ticket', |
|
412 | - 'ee_delete_default_tickets', |
|
413 | - 'ee_delete_others_default_tickets', |
|
414 | - //prices |
|
415 | - 'ee_edit_default_price', |
|
416 | - 'ee_edit_default_prices', |
|
417 | - 'ee_delete_default_price', |
|
418 | - 'ee_delete_default_prices', |
|
419 | - 'ee_edit_default_price_type', |
|
420 | - 'ee_edit_default_price_types', |
|
421 | - 'ee_delete_default_price_type', |
|
422 | - 'ee_delete_default_price_types', |
|
423 | - 'ee_read_default_prices', |
|
424 | - 'ee_read_default_price_types', |
|
425 | - //registration form |
|
426 | - 'ee_edit_question', |
|
427 | - 'ee_edit_questions', |
|
428 | - 'ee_edit_system_questions', |
|
429 | - 'ee_read_questions', |
|
430 | - 'ee_delete_question', |
|
431 | - 'ee_delete_questions', |
|
432 | - 'ee_edit_question_group', |
|
433 | - 'ee_edit_question_groups', |
|
434 | - 'ee_read_question_groups', |
|
435 | - 'ee_edit_system_question_groups', |
|
436 | - 'ee_delete_question_group', |
|
437 | - 'ee_delete_question_groups', |
|
438 | - //event_type taxonomy |
|
439 | - 'ee_assign_event_type', |
|
440 | - 'ee_manage_event_types', |
|
441 | - 'ee_edit_event_type', |
|
442 | - 'ee_delete_event_type', |
|
443 | - ), |
|
444 | - 'ee_events_administrator' => array( |
|
445 | - //core wp caps |
|
446 | - 'read', |
|
447 | - 'read_private_pages', |
|
448 | - 'read_private_posts', |
|
449 | - 'edit_users', |
|
450 | - 'edit_posts', |
|
451 | - 'edit_pages', |
|
452 | - 'edit_published_posts', |
|
453 | - 'edit_published_pages', |
|
454 | - 'edit_private_pages', |
|
455 | - 'edit_private_posts', |
|
456 | - 'edit_others_posts', |
|
457 | - 'edit_others_pages', |
|
458 | - 'publish_posts', |
|
459 | - 'publish_pages', |
|
460 | - 'delete_posts', |
|
461 | - 'delete_pages', |
|
462 | - 'delete_private_pages', |
|
463 | - 'delete_private_posts', |
|
464 | - 'delete_published_pages', |
|
465 | - 'delete_published_posts', |
|
466 | - 'delete_others_posts', |
|
467 | - 'delete_others_pages', |
|
468 | - 'manage_categories', |
|
469 | - 'manage_links', |
|
470 | - 'moderate_comments', |
|
471 | - 'unfiltered_html', |
|
472 | - 'upload_files', |
|
473 | - 'export', |
|
474 | - 'import', |
|
475 | - 'list_users', |
|
476 | - 'level_1', //required if user with this role shows up in author dropdowns |
|
477 | - //basic ee access |
|
478 | - 'ee_read_ee', |
|
479 | - //events |
|
480 | - 'ee_publish_events', |
|
481 | - 'ee_read_private_events', |
|
482 | - 'ee_read_others_events', |
|
483 | - 'ee_read_event', |
|
484 | - 'ee_read_events', |
|
485 | - 'ee_edit_event', |
|
486 | - 'ee_edit_events', |
|
487 | - 'ee_edit_published_events', |
|
488 | - 'ee_edit_others_events', |
|
489 | - 'ee_edit_private_events', |
|
490 | - 'ee_delete_published_events', |
|
491 | - 'ee_delete_private_events', |
|
492 | - 'ee_delete_event', |
|
493 | - 'ee_delete_events', |
|
494 | - 'ee_delete_others_events', |
|
495 | - //event categories |
|
496 | - 'ee_manage_event_categories', |
|
497 | - 'ee_edit_event_category', |
|
498 | - 'ee_delete_event_category', |
|
499 | - 'ee_assign_event_category', |
|
500 | - //venues |
|
501 | - 'ee_publish_venues', |
|
502 | - 'ee_read_venue', |
|
503 | - 'ee_read_venues', |
|
504 | - 'ee_read_others_venues', |
|
505 | - 'ee_read_private_venues', |
|
506 | - 'ee_edit_venue', |
|
507 | - 'ee_edit_venues', |
|
508 | - 'ee_edit_others_venues', |
|
509 | - 'ee_edit_published_venues', |
|
510 | - 'ee_edit_private_venues', |
|
511 | - 'ee_delete_venue', |
|
512 | - 'ee_delete_venues', |
|
513 | - 'ee_delete_others_venues', |
|
514 | - 'ee_delete_private_venues', |
|
515 | - 'ee_delete_published_venues', |
|
516 | - //venue categories |
|
517 | - 'ee_manage_venue_categories', |
|
518 | - 'ee_edit_venue_category', |
|
519 | - 'ee_delete_venue_category', |
|
520 | - 'ee_assign_venue_category', |
|
521 | - //contacts |
|
522 | - 'ee_read_contact', |
|
523 | - 'ee_read_contacts', |
|
524 | - 'ee_edit_contact', |
|
525 | - 'ee_edit_contacts', |
|
526 | - 'ee_delete_contact', |
|
527 | - 'ee_delete_contacts', |
|
528 | - //registrations |
|
529 | - 'ee_read_registration', |
|
530 | - 'ee_read_registrations', |
|
531 | - 'ee_read_others_registrations', |
|
532 | - 'ee_edit_registration', |
|
533 | - 'ee_edit_registrations', |
|
534 | - 'ee_edit_others_registrations', |
|
535 | - 'ee_delete_registration', |
|
536 | - 'ee_delete_registrations', |
|
537 | - //checkins |
|
538 | - 'ee_read_checkin', |
|
539 | - 'ee_read_others_checkins', |
|
540 | - 'ee_read_checkins', |
|
541 | - 'ee_edit_checkin', |
|
542 | - 'ee_edit_checkins', |
|
543 | - 'ee_edit_others_checkins', |
|
544 | - 'ee_delete_checkin', |
|
545 | - 'ee_delete_checkins', |
|
546 | - 'ee_delete_others_checkins', |
|
547 | - //transactions && payments |
|
548 | - 'ee_read_transaction', |
|
549 | - 'ee_read_transactions', |
|
550 | - 'ee_edit_payments', |
|
551 | - 'ee_delete_payments', |
|
552 | - //messages |
|
553 | - 'ee_read_message', |
|
554 | - 'ee_read_messages', |
|
555 | - 'ee_read_others_messages', |
|
556 | - 'ee_read_global_messages', |
|
557 | - 'ee_edit_global_messages', |
|
558 | - 'ee_edit_message', |
|
559 | - 'ee_edit_messages', |
|
560 | - 'ee_edit_others_messages', |
|
561 | - 'ee_delete_message', |
|
562 | - 'ee_delete_messages', |
|
563 | - 'ee_delete_others_messages', |
|
564 | - 'ee_delete_global_messages', |
|
565 | - 'ee_send_message', |
|
566 | - //tickets |
|
567 | - 'ee_read_default_ticket', |
|
568 | - 'ee_read_default_tickets', |
|
569 | - 'ee_read_others_default_tickets', |
|
570 | - 'ee_edit_default_ticket', |
|
571 | - 'ee_edit_default_tickets', |
|
572 | - 'ee_edit_others_default_tickets', |
|
573 | - 'ee_delete_default_ticket', |
|
574 | - 'ee_delete_default_tickets', |
|
575 | - 'ee_delete_others_default_tickets', |
|
576 | - //prices |
|
577 | - 'ee_edit_default_price', |
|
578 | - 'ee_edit_default_prices', |
|
579 | - 'ee_delete_default_price', |
|
580 | - 'ee_delete_default_prices', |
|
581 | - 'ee_edit_default_price_type', |
|
582 | - 'ee_edit_default_price_types', |
|
583 | - 'ee_delete_default_price_type', |
|
584 | - 'ee_delete_default_price_types', |
|
585 | - 'ee_read_default_prices', |
|
586 | - 'ee_read_default_price_types', |
|
587 | - //registration form |
|
588 | - 'ee_edit_question', |
|
589 | - 'ee_edit_questions', |
|
590 | - 'ee_edit_system_questions', |
|
591 | - 'ee_read_questions', |
|
592 | - 'ee_delete_question', |
|
593 | - 'ee_delete_questions', |
|
594 | - 'ee_edit_question_group', |
|
595 | - 'ee_edit_question_groups', |
|
596 | - 'ee_read_question_groups', |
|
597 | - 'ee_edit_system_question_groups', |
|
598 | - 'ee_delete_question_group', |
|
599 | - 'ee_delete_question_groups', |
|
600 | - //event_type taxonomy |
|
601 | - 'ee_assign_event_type', |
|
602 | - 'ee_manage_event_types', |
|
603 | - 'ee_edit_event_type', |
|
604 | - 'ee_delete_event_type', |
|
605 | - ) |
|
606 | - ); |
|
607 | - $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
608 | - return $caps; |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - /** |
|
613 | - * This adds all the default caps to roles as registered in the _caps_map property. |
|
614 | - * |
|
615 | - * @since 4.5.0 |
|
616 | - * |
|
617 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
618 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
619 | - * and ensures that they are up to date. |
|
620 | - * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
621 | - * up. Note that this should ONLY be called on activation hook or some other one-time |
|
622 | - * task otherwise the caps will be added on every request. |
|
623 | - * |
|
624 | - * @return void |
|
625 | - */ |
|
626 | - public function init_role_caps($reset = false, $custom_map = array()) |
|
627 | - { |
|
628 | - $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
629 | - //first let's determine if these caps have already been set. |
|
630 | - $caps_set_before = get_option(self::option_name, array()); |
|
631 | - //if not reset, see what caps are new for each role. if they're new, add them. |
|
632 | - foreach ($caps_map as $role => $caps_for_role) { |
|
633 | - foreach ($caps_for_role as $cap) { |
|
634 | - //first check we haven't already added this cap before, or it's a reset |
|
635 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
636 | - if ($this->add_cap_to_role($role, $cap)) { |
|
637 | - $caps_set_before[ $role ][] = $cap; |
|
638 | - } |
|
639 | - } |
|
640 | - } |
|
641 | - } |
|
642 | - //now let's just save the cap that has been set. |
|
643 | - update_option(self::option_name, $caps_set_before); |
|
644 | - do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
650 | - * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
651 | - * this is a wrapper for $wp_role->add_cap() |
|
652 | - * |
|
653 | - * @see wp-includes/capabilities.php |
|
654 | - * |
|
655 | - * @since 4.5.0 |
|
656 | - * |
|
657 | - * @param string $role A WordPress role the capability is being added to |
|
658 | - * @param string $cap The capability being added to the role |
|
659 | - * @param bool $grant Whether to grant access to this cap on this role. |
|
660 | - * |
|
661 | - * @return bool |
|
662 | - */ |
|
663 | - public function add_cap_to_role($role, $cap, $grant = true) |
|
664 | - { |
|
665 | - $role_object = get_role($role); |
|
666 | - //if the role isn't available then we create it. |
|
667 | - if (! $role_object instanceof WP_Role) { |
|
668 | - //if a plugin wants to create a specific role name then they should create the role before |
|
669 | - //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
670 | - // - removes any `ee_` namespacing from the start of the slug. |
|
671 | - // - replaces `_` with ` ` (empty space). |
|
672 | - // - sentence case on the resulting string. |
|
673 | - $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
674 | - $role_object = add_role($role, $role_label); |
|
675 | - } |
|
676 | - if ($role_object instanceof WP_Role) { |
|
677 | - $role_object->add_cap($cap, $grant); |
|
678 | - return true; |
|
679 | - } |
|
680 | - return false; |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - /** |
|
685 | - * Functions similarly to add_cap_to_role except removes cap from given role. |
|
686 | - * Wrapper for $wp_role->remove_cap() |
|
687 | - * |
|
688 | - * @see wp-includes/capabilities.php |
|
689 | - * @since 4.5.0 |
|
690 | - * |
|
691 | - * @param string $role A WordPress role the capability is being removed from. |
|
692 | - * @param string $cap The capability being removed |
|
693 | - * |
|
694 | - * @return void |
|
695 | - */ |
|
696 | - public function remove_cap_from_role($role, $cap) |
|
697 | - { |
|
698 | - $role = get_role($role); |
|
699 | - if ($role instanceof WP_Role) { |
|
700 | - $role->remove_cap($cap); |
|
701 | - } |
|
702 | - } |
|
703 | - |
|
704 | - |
|
705 | - /** |
|
706 | - * Wrapper for the native WP current_user_can() method. |
|
707 | - * This is provided as a handy method for a couple things: |
|
708 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
709 | - * write those filters wherever current_user_can is called). |
|
710 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
711 | - * |
|
712 | - * @since 4.5.0 |
|
713 | - * |
|
714 | - * @param string $cap The cap being checked. |
|
715 | - * @param string $context The context where the current_user_can is being called from. |
|
716 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
717 | - * filters. |
|
718 | - * |
|
719 | - * @return bool Whether user can or not. |
|
720 | - */ |
|
721 | - public function current_user_can($cap, $context, $id = 0) |
|
722 | - { |
|
723 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
724 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
725 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
726 | - $id); |
|
727 | - return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
733 | - * |
|
734 | - * @param int|WP_User $user Either the user_id or a WP_User object |
|
735 | - * @param string $cap The capability string being checked |
|
736 | - * @param string $context The context where the user_can is being called from (used in filters). |
|
737 | - * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
738 | - * filters) |
|
739 | - * |
|
740 | - * @return bool Whether user can or not. |
|
741 | - */ |
|
742 | - public function user_can($user, $cap, $context, $id = 0) |
|
743 | - { |
|
744 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
745 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
746 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
747 | - $id); |
|
748 | - return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * Wrapper for the native WP current_user_can_for_blog() method. |
|
754 | - * This is provided as a handy method for a couple things: |
|
755 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
756 | - * write those filters wherever current_user_can is called). |
|
757 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
758 | - * |
|
759 | - * @since 4.5.0 |
|
760 | - * |
|
761 | - * @param int $blog_id The blog id that is being checked for. |
|
762 | - * @param string $cap The cap being checked. |
|
763 | - * @param string $context The context where the current_user_can is being called from. |
|
764 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
765 | - * filters. |
|
766 | - * |
|
767 | - * @return bool Whether user can or not. |
|
768 | - */ |
|
769 | - public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
770 | - { |
|
771 | - $user_can = ! empty($id) |
|
772 | - ? current_user_can_for_blog($blog_id, $cap, $id) |
|
773 | - : current_user_can($blog_id, $cap); |
|
774 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
775 | - $user_can = apply_filters( |
|
776 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
777 | - $user_can, |
|
778 | - $blog_id, |
|
779 | - $cap, |
|
780 | - $id |
|
781 | - ); |
|
782 | - $user_can = apply_filters( |
|
783 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
784 | - $user_can, |
|
785 | - $context, |
|
786 | - $blog_id, |
|
787 | - $cap, |
|
788 | - $id |
|
789 | - ); |
|
790 | - return $user_can; |
|
791 | - } |
|
792 | - |
|
793 | - |
|
794 | - /** |
|
795 | - * This helper method just returns an array of registered EE capabilities. |
|
796 | - * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
797 | - * role. |
|
798 | - * |
|
799 | - * @since 4.5.0 |
|
800 | - * |
|
801 | - * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
802 | - * for the given role are returned. |
|
803 | - * |
|
804 | - * @return array |
|
805 | - */ |
|
806 | - public function get_ee_capabilities($role = 'administrator') |
|
807 | - { |
|
808 | - $capabilities = $this->_init_caps_map(); |
|
809 | - if (empty($role)) { |
|
810 | - return $capabilities; |
|
811 | - } |
|
812 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
813 | - } |
|
20 | + /** |
|
21 | + * the name of the wp option used to store caps previously initialized |
|
22 | + */ |
|
23 | + const option_name = 'ee_caps_initialized'; |
|
24 | + |
|
25 | + /** |
|
26 | + * instance of EE_Capabilities object |
|
27 | + * |
|
28 | + * @var EE_Capabilities |
|
29 | + */ |
|
30 | + private static $_instance; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * This is a map of caps that correspond to a default WP_Role. |
|
35 | + * Array is indexed by Role and values are ee capabilities. |
|
36 | + * |
|
37 | + * @since 4.5.0 |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + private $_caps_map = array(); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
46 | + * a user depending on context. |
|
47 | + * |
|
48 | + * @var EE_Meta_Capability_Map[] |
|
49 | + */ |
|
50 | + private $_meta_caps = array(); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * singleton method used to instantiate class object |
|
55 | + * |
|
56 | + * @since 4.5.0 |
|
57 | + * |
|
58 | + * @return EE_Capabilities |
|
59 | + */ |
|
60 | + public static function instance() |
|
61 | + { |
|
62 | + //check if instantiated, and if not do so. |
|
63 | + if (! self::$_instance instanceof EE_Capabilities) { |
|
64 | + self::$_instance = new self(); |
|
65 | + } |
|
66 | + return self::$_instance; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * private constructor |
|
72 | + * |
|
73 | + * @since 4.5.0 |
|
74 | + * |
|
75 | + * @return \EE_Capabilities |
|
76 | + */ |
|
77 | + private function __construct() |
|
78 | + { |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
84 | + * |
|
85 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
86 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
87 | + * ensures that they are up to date. |
|
88 | + * |
|
89 | + * |
|
90 | + * @since 4.5.0 |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public function init_caps($reset = false) |
|
94 | + { |
|
95 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
96 | + $this->_caps_map = $this->_init_caps_map(); |
|
97 | + $this->init_role_caps($reset); |
|
98 | + $this->_set_meta_caps(); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * This sets the meta caps property. |
|
105 | + * @since 4.5.0 |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + private function _set_meta_caps() |
|
110 | + { |
|
111 | + //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
112 | + $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
113 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
114 | + //add filter for map_meta_caps but only if models can query. |
|
115 | + if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * This builds and returns the default meta_caps array only once. |
|
123 | + * |
|
124 | + * @since 4.8.28.rc.012 |
|
125 | + * @return array |
|
126 | + * @throws \EE_Error |
|
127 | + */ |
|
128 | + private function _get_default_meta_caps_array() |
|
129 | + { |
|
130 | + static $default_meta_caps = array(); |
|
131 | + if (empty($default_meta_caps)) { |
|
132 | + $default_meta_caps = array( |
|
133 | + //edits |
|
134 | + new EE_Meta_Capability_Map_Edit( |
|
135 | + 'ee_edit_event', |
|
136 | + array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
137 | + ), |
|
138 | + new EE_Meta_Capability_Map_Edit( |
|
139 | + 'ee_edit_venue', |
|
140 | + array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
141 | + ), |
|
142 | + new EE_Meta_Capability_Map_Edit( |
|
143 | + 'ee_edit_registration', |
|
144 | + array('Registration', '', 'ee_edit_others_registrations', '') |
|
145 | + ), |
|
146 | + new EE_Meta_Capability_Map_Edit( |
|
147 | + 'ee_edit_checkin', |
|
148 | + array('Registration', '', 'ee_edit_others_checkins', '') |
|
149 | + ), |
|
150 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
151 | + 'ee_edit_message', |
|
152 | + array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
153 | + ), |
|
154 | + new EE_Meta_Capability_Map_Edit( |
|
155 | + 'ee_edit_default_ticket', |
|
156 | + array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
157 | + ), |
|
158 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
159 | + 'ee_edit_question', |
|
160 | + array('Question', '', '', 'ee_edit_system_questions') |
|
161 | + ), |
|
162 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
163 | + 'ee_edit_question_group', |
|
164 | + array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
165 | + ), |
|
166 | + new EE_Meta_Capability_Map_Edit( |
|
167 | + 'ee_edit_payment_method', |
|
168 | + array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
169 | + ), |
|
170 | + //reads |
|
171 | + new EE_Meta_Capability_Map_Read( |
|
172 | + 'ee_read_event', |
|
173 | + array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
174 | + ), |
|
175 | + new EE_Meta_Capability_Map_Read( |
|
176 | + 'ee_read_venue', |
|
177 | + array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
178 | + ), |
|
179 | + new EE_Meta_Capability_Map_Read( |
|
180 | + 'ee_read_registration', |
|
181 | + array('Registration', '', '', 'ee_edit_others_registrations') |
|
182 | + ), |
|
183 | + new EE_Meta_Capability_Map_Read( |
|
184 | + 'ee_read_checkin', |
|
185 | + array('Registration', '', '', 'ee_read_others_checkins') |
|
186 | + ), |
|
187 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
188 | + 'ee_read_message', |
|
189 | + array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
190 | + ), |
|
191 | + new EE_Meta_Capability_Map_Read( |
|
192 | + 'ee_read_default_ticket', |
|
193 | + array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
194 | + ), |
|
195 | + new EE_Meta_Capability_Map_Read( |
|
196 | + 'ee_read_payment_method', |
|
197 | + array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
198 | + |
|
199 | + //deletes |
|
200 | + new EE_Meta_Capability_Map_Delete( |
|
201 | + 'ee_delete_event', |
|
202 | + array( |
|
203 | + 'Event', |
|
204 | + 'ee_delete_published_events', |
|
205 | + 'ee_delete_others_events', |
|
206 | + 'ee_delete_private_events', |
|
207 | + ) |
|
208 | + ), |
|
209 | + new EE_Meta_Capability_Map_Delete( |
|
210 | + 'ee_delete_venue', |
|
211 | + array( |
|
212 | + 'Venue', |
|
213 | + 'ee_delete_published_venues', |
|
214 | + 'ee_delete_others_venues', |
|
215 | + 'ee_delete_private_venues', |
|
216 | + ) |
|
217 | + ), |
|
218 | + new EE_Meta_Capability_Map_Delete( |
|
219 | + 'ee_delete_registration', |
|
220 | + array('Registration', '', 'ee_delete_others_registrations', '') |
|
221 | + ), |
|
222 | + new EE_Meta_Capability_Map_Delete( |
|
223 | + 'ee_delete_checkin', |
|
224 | + array('Registration', '', 'ee_delete_others_checkins', '') |
|
225 | + ), |
|
226 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
227 | + 'ee_delete_message', |
|
228 | + array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
229 | + ), |
|
230 | + new EE_Meta_Capability_Map_Delete( |
|
231 | + 'ee_delete_default_ticket', |
|
232 | + array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
233 | + ), |
|
234 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
235 | + 'ee_delete_question', |
|
236 | + array('Question', '', '', 'delete_system_questions') |
|
237 | + ), |
|
238 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
239 | + 'ee_delete_question_group', |
|
240 | + array('Question_Group', '', '', 'delete_system_question_groups') |
|
241 | + ), |
|
242 | + new EE_Meta_Capability_Map_Delete( |
|
243 | + 'ee_delete_payment_method', |
|
244 | + array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
245 | + ), |
|
246 | + ); |
|
247 | + } |
|
248 | + return $default_meta_caps; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
254 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
255 | + * |
|
256 | + * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
257 | + * |
|
258 | + * @since 4.5.0 |
|
259 | + * @see wp-includes/capabilities.php |
|
260 | + * |
|
261 | + * @param array $caps actual users capabilities |
|
262 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
263 | + * @param int $user_id The user id |
|
264 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
265 | + * @return array actual users capabilities |
|
266 | + * @throws EE_Error |
|
267 | + */ |
|
268 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
269 | + { |
|
270 | + if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
271 | + //loop through our _meta_caps array |
|
272 | + foreach ($this->_meta_caps as $meta_map) { |
|
273 | + if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | + continue; |
|
275 | + } |
|
276 | + // don't load models if there is no object ID in the args |
|
277 | + if(!empty($args[0])){ |
|
278 | + $meta_map->ensure_is_model(); |
|
279 | + } |
|
280 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
281 | + } |
|
282 | + } |
|
283 | + return $caps; |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * This sets up and returns the initial capabilities map for Event Espresso |
|
289 | + * |
|
290 | + * @since 4.5.0 |
|
291 | + * |
|
292 | + * @return array |
|
293 | + */ |
|
294 | + private function _init_caps_map() |
|
295 | + { |
|
296 | + $caps = array( |
|
297 | + 'administrator' => array( |
|
298 | + //basic access |
|
299 | + 'ee_read_ee', |
|
300 | + //gateways |
|
301 | + /** |
|
302 | + * note that with payment method capabilities, although we've implemented |
|
303 | + * capability mapping which will be used for accessing payment methods owned by |
|
304 | + * other users. This is not fully implemented yet in the payment method ui. |
|
305 | + * Currently only the "plural" caps are in active use. |
|
306 | + * (Specific payment method caps are in use as well). |
|
307 | + **/ |
|
308 | + 'ee_manage_gateways', |
|
309 | + 'ee_read_payment_method', |
|
310 | + 'ee_read_payment_methods', |
|
311 | + 'ee_read_others_payment_methods', |
|
312 | + 'ee_edit_payment_method', |
|
313 | + 'ee_edit_payment_methods', |
|
314 | + 'ee_edit_others_payment_methods', |
|
315 | + 'ee_delete_payment_method', |
|
316 | + 'ee_delete_payment_methods', |
|
317 | + //events |
|
318 | + 'ee_publish_events', |
|
319 | + 'ee_read_private_events', |
|
320 | + 'ee_read_others_events', |
|
321 | + 'ee_read_event', |
|
322 | + 'ee_read_events', |
|
323 | + 'ee_edit_event', |
|
324 | + 'ee_edit_events', |
|
325 | + 'ee_edit_published_events', |
|
326 | + 'ee_edit_others_events', |
|
327 | + 'ee_edit_private_events', |
|
328 | + 'ee_delete_published_events', |
|
329 | + 'ee_delete_private_events', |
|
330 | + 'ee_delete_event', |
|
331 | + 'ee_delete_events', |
|
332 | + 'ee_delete_others_events', |
|
333 | + //event categories |
|
334 | + 'ee_manage_event_categories', |
|
335 | + 'ee_edit_event_category', |
|
336 | + 'ee_delete_event_category', |
|
337 | + 'ee_assign_event_category', |
|
338 | + //venues |
|
339 | + 'ee_publish_venues', |
|
340 | + 'ee_read_venue', |
|
341 | + 'ee_read_venues', |
|
342 | + 'ee_read_others_venues', |
|
343 | + 'ee_read_private_venues', |
|
344 | + 'ee_edit_venue', |
|
345 | + 'ee_edit_venues', |
|
346 | + 'ee_edit_others_venues', |
|
347 | + 'ee_edit_published_venues', |
|
348 | + 'ee_edit_private_venues', |
|
349 | + 'ee_delete_venue', |
|
350 | + 'ee_delete_venues', |
|
351 | + 'ee_delete_others_venues', |
|
352 | + 'ee_delete_private_venues', |
|
353 | + 'ee_delete_published_venues', |
|
354 | + //venue categories |
|
355 | + 'ee_manage_venue_categories', |
|
356 | + 'ee_edit_venue_category', |
|
357 | + 'ee_delete_venue_category', |
|
358 | + 'ee_assign_venue_category', |
|
359 | + //contacts |
|
360 | + 'ee_read_contact', |
|
361 | + 'ee_read_contacts', |
|
362 | + 'ee_edit_contact', |
|
363 | + 'ee_edit_contacts', |
|
364 | + 'ee_delete_contact', |
|
365 | + 'ee_delete_contacts', |
|
366 | + //registrations |
|
367 | + 'ee_read_registration', |
|
368 | + 'ee_read_registrations', |
|
369 | + 'ee_read_others_registrations', |
|
370 | + 'ee_edit_registration', |
|
371 | + 'ee_edit_registrations', |
|
372 | + 'ee_edit_others_registrations', |
|
373 | + 'ee_delete_registration', |
|
374 | + 'ee_delete_registrations', |
|
375 | + //checkins |
|
376 | + 'ee_read_checkin', |
|
377 | + 'ee_read_others_checkins', |
|
378 | + 'ee_read_checkins', |
|
379 | + 'ee_edit_checkin', |
|
380 | + 'ee_edit_checkins', |
|
381 | + 'ee_edit_others_checkins', |
|
382 | + 'ee_delete_checkin', |
|
383 | + 'ee_delete_checkins', |
|
384 | + 'ee_delete_others_checkins', |
|
385 | + //transactions && payments |
|
386 | + 'ee_read_transaction', |
|
387 | + 'ee_read_transactions', |
|
388 | + 'ee_edit_payments', |
|
389 | + 'ee_delete_payments', |
|
390 | + //messages |
|
391 | + 'ee_read_message', |
|
392 | + 'ee_read_messages', |
|
393 | + 'ee_read_others_messages', |
|
394 | + 'ee_read_global_messages', |
|
395 | + 'ee_edit_global_messages', |
|
396 | + 'ee_edit_message', |
|
397 | + 'ee_edit_messages', |
|
398 | + 'ee_edit_others_messages', |
|
399 | + 'ee_delete_message', |
|
400 | + 'ee_delete_messages', |
|
401 | + 'ee_delete_others_messages', |
|
402 | + 'ee_delete_global_messages', |
|
403 | + 'ee_send_message', |
|
404 | + //tickets |
|
405 | + 'ee_read_default_ticket', |
|
406 | + 'ee_read_default_tickets', |
|
407 | + 'ee_read_others_default_tickets', |
|
408 | + 'ee_edit_default_ticket', |
|
409 | + 'ee_edit_default_tickets', |
|
410 | + 'ee_edit_others_default_tickets', |
|
411 | + 'ee_delete_default_ticket', |
|
412 | + 'ee_delete_default_tickets', |
|
413 | + 'ee_delete_others_default_tickets', |
|
414 | + //prices |
|
415 | + 'ee_edit_default_price', |
|
416 | + 'ee_edit_default_prices', |
|
417 | + 'ee_delete_default_price', |
|
418 | + 'ee_delete_default_prices', |
|
419 | + 'ee_edit_default_price_type', |
|
420 | + 'ee_edit_default_price_types', |
|
421 | + 'ee_delete_default_price_type', |
|
422 | + 'ee_delete_default_price_types', |
|
423 | + 'ee_read_default_prices', |
|
424 | + 'ee_read_default_price_types', |
|
425 | + //registration form |
|
426 | + 'ee_edit_question', |
|
427 | + 'ee_edit_questions', |
|
428 | + 'ee_edit_system_questions', |
|
429 | + 'ee_read_questions', |
|
430 | + 'ee_delete_question', |
|
431 | + 'ee_delete_questions', |
|
432 | + 'ee_edit_question_group', |
|
433 | + 'ee_edit_question_groups', |
|
434 | + 'ee_read_question_groups', |
|
435 | + 'ee_edit_system_question_groups', |
|
436 | + 'ee_delete_question_group', |
|
437 | + 'ee_delete_question_groups', |
|
438 | + //event_type taxonomy |
|
439 | + 'ee_assign_event_type', |
|
440 | + 'ee_manage_event_types', |
|
441 | + 'ee_edit_event_type', |
|
442 | + 'ee_delete_event_type', |
|
443 | + ), |
|
444 | + 'ee_events_administrator' => array( |
|
445 | + //core wp caps |
|
446 | + 'read', |
|
447 | + 'read_private_pages', |
|
448 | + 'read_private_posts', |
|
449 | + 'edit_users', |
|
450 | + 'edit_posts', |
|
451 | + 'edit_pages', |
|
452 | + 'edit_published_posts', |
|
453 | + 'edit_published_pages', |
|
454 | + 'edit_private_pages', |
|
455 | + 'edit_private_posts', |
|
456 | + 'edit_others_posts', |
|
457 | + 'edit_others_pages', |
|
458 | + 'publish_posts', |
|
459 | + 'publish_pages', |
|
460 | + 'delete_posts', |
|
461 | + 'delete_pages', |
|
462 | + 'delete_private_pages', |
|
463 | + 'delete_private_posts', |
|
464 | + 'delete_published_pages', |
|
465 | + 'delete_published_posts', |
|
466 | + 'delete_others_posts', |
|
467 | + 'delete_others_pages', |
|
468 | + 'manage_categories', |
|
469 | + 'manage_links', |
|
470 | + 'moderate_comments', |
|
471 | + 'unfiltered_html', |
|
472 | + 'upload_files', |
|
473 | + 'export', |
|
474 | + 'import', |
|
475 | + 'list_users', |
|
476 | + 'level_1', //required if user with this role shows up in author dropdowns |
|
477 | + //basic ee access |
|
478 | + 'ee_read_ee', |
|
479 | + //events |
|
480 | + 'ee_publish_events', |
|
481 | + 'ee_read_private_events', |
|
482 | + 'ee_read_others_events', |
|
483 | + 'ee_read_event', |
|
484 | + 'ee_read_events', |
|
485 | + 'ee_edit_event', |
|
486 | + 'ee_edit_events', |
|
487 | + 'ee_edit_published_events', |
|
488 | + 'ee_edit_others_events', |
|
489 | + 'ee_edit_private_events', |
|
490 | + 'ee_delete_published_events', |
|
491 | + 'ee_delete_private_events', |
|
492 | + 'ee_delete_event', |
|
493 | + 'ee_delete_events', |
|
494 | + 'ee_delete_others_events', |
|
495 | + //event categories |
|
496 | + 'ee_manage_event_categories', |
|
497 | + 'ee_edit_event_category', |
|
498 | + 'ee_delete_event_category', |
|
499 | + 'ee_assign_event_category', |
|
500 | + //venues |
|
501 | + 'ee_publish_venues', |
|
502 | + 'ee_read_venue', |
|
503 | + 'ee_read_venues', |
|
504 | + 'ee_read_others_venues', |
|
505 | + 'ee_read_private_venues', |
|
506 | + 'ee_edit_venue', |
|
507 | + 'ee_edit_venues', |
|
508 | + 'ee_edit_others_venues', |
|
509 | + 'ee_edit_published_venues', |
|
510 | + 'ee_edit_private_venues', |
|
511 | + 'ee_delete_venue', |
|
512 | + 'ee_delete_venues', |
|
513 | + 'ee_delete_others_venues', |
|
514 | + 'ee_delete_private_venues', |
|
515 | + 'ee_delete_published_venues', |
|
516 | + //venue categories |
|
517 | + 'ee_manage_venue_categories', |
|
518 | + 'ee_edit_venue_category', |
|
519 | + 'ee_delete_venue_category', |
|
520 | + 'ee_assign_venue_category', |
|
521 | + //contacts |
|
522 | + 'ee_read_contact', |
|
523 | + 'ee_read_contacts', |
|
524 | + 'ee_edit_contact', |
|
525 | + 'ee_edit_contacts', |
|
526 | + 'ee_delete_contact', |
|
527 | + 'ee_delete_contacts', |
|
528 | + //registrations |
|
529 | + 'ee_read_registration', |
|
530 | + 'ee_read_registrations', |
|
531 | + 'ee_read_others_registrations', |
|
532 | + 'ee_edit_registration', |
|
533 | + 'ee_edit_registrations', |
|
534 | + 'ee_edit_others_registrations', |
|
535 | + 'ee_delete_registration', |
|
536 | + 'ee_delete_registrations', |
|
537 | + //checkins |
|
538 | + 'ee_read_checkin', |
|
539 | + 'ee_read_others_checkins', |
|
540 | + 'ee_read_checkins', |
|
541 | + 'ee_edit_checkin', |
|
542 | + 'ee_edit_checkins', |
|
543 | + 'ee_edit_others_checkins', |
|
544 | + 'ee_delete_checkin', |
|
545 | + 'ee_delete_checkins', |
|
546 | + 'ee_delete_others_checkins', |
|
547 | + //transactions && payments |
|
548 | + 'ee_read_transaction', |
|
549 | + 'ee_read_transactions', |
|
550 | + 'ee_edit_payments', |
|
551 | + 'ee_delete_payments', |
|
552 | + //messages |
|
553 | + 'ee_read_message', |
|
554 | + 'ee_read_messages', |
|
555 | + 'ee_read_others_messages', |
|
556 | + 'ee_read_global_messages', |
|
557 | + 'ee_edit_global_messages', |
|
558 | + 'ee_edit_message', |
|
559 | + 'ee_edit_messages', |
|
560 | + 'ee_edit_others_messages', |
|
561 | + 'ee_delete_message', |
|
562 | + 'ee_delete_messages', |
|
563 | + 'ee_delete_others_messages', |
|
564 | + 'ee_delete_global_messages', |
|
565 | + 'ee_send_message', |
|
566 | + //tickets |
|
567 | + 'ee_read_default_ticket', |
|
568 | + 'ee_read_default_tickets', |
|
569 | + 'ee_read_others_default_tickets', |
|
570 | + 'ee_edit_default_ticket', |
|
571 | + 'ee_edit_default_tickets', |
|
572 | + 'ee_edit_others_default_tickets', |
|
573 | + 'ee_delete_default_ticket', |
|
574 | + 'ee_delete_default_tickets', |
|
575 | + 'ee_delete_others_default_tickets', |
|
576 | + //prices |
|
577 | + 'ee_edit_default_price', |
|
578 | + 'ee_edit_default_prices', |
|
579 | + 'ee_delete_default_price', |
|
580 | + 'ee_delete_default_prices', |
|
581 | + 'ee_edit_default_price_type', |
|
582 | + 'ee_edit_default_price_types', |
|
583 | + 'ee_delete_default_price_type', |
|
584 | + 'ee_delete_default_price_types', |
|
585 | + 'ee_read_default_prices', |
|
586 | + 'ee_read_default_price_types', |
|
587 | + //registration form |
|
588 | + 'ee_edit_question', |
|
589 | + 'ee_edit_questions', |
|
590 | + 'ee_edit_system_questions', |
|
591 | + 'ee_read_questions', |
|
592 | + 'ee_delete_question', |
|
593 | + 'ee_delete_questions', |
|
594 | + 'ee_edit_question_group', |
|
595 | + 'ee_edit_question_groups', |
|
596 | + 'ee_read_question_groups', |
|
597 | + 'ee_edit_system_question_groups', |
|
598 | + 'ee_delete_question_group', |
|
599 | + 'ee_delete_question_groups', |
|
600 | + //event_type taxonomy |
|
601 | + 'ee_assign_event_type', |
|
602 | + 'ee_manage_event_types', |
|
603 | + 'ee_edit_event_type', |
|
604 | + 'ee_delete_event_type', |
|
605 | + ) |
|
606 | + ); |
|
607 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
608 | + return $caps; |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + /** |
|
613 | + * This adds all the default caps to roles as registered in the _caps_map property. |
|
614 | + * |
|
615 | + * @since 4.5.0 |
|
616 | + * |
|
617 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
618 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
619 | + * and ensures that they are up to date. |
|
620 | + * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
621 | + * up. Note that this should ONLY be called on activation hook or some other one-time |
|
622 | + * task otherwise the caps will be added on every request. |
|
623 | + * |
|
624 | + * @return void |
|
625 | + */ |
|
626 | + public function init_role_caps($reset = false, $custom_map = array()) |
|
627 | + { |
|
628 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
629 | + //first let's determine if these caps have already been set. |
|
630 | + $caps_set_before = get_option(self::option_name, array()); |
|
631 | + //if not reset, see what caps are new for each role. if they're new, add them. |
|
632 | + foreach ($caps_map as $role => $caps_for_role) { |
|
633 | + foreach ($caps_for_role as $cap) { |
|
634 | + //first check we haven't already added this cap before, or it's a reset |
|
635 | + if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
636 | + if ($this->add_cap_to_role($role, $cap)) { |
|
637 | + $caps_set_before[ $role ][] = $cap; |
|
638 | + } |
|
639 | + } |
|
640 | + } |
|
641 | + } |
|
642 | + //now let's just save the cap that has been set. |
|
643 | + update_option(self::option_name, $caps_set_before); |
|
644 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
650 | + * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
651 | + * this is a wrapper for $wp_role->add_cap() |
|
652 | + * |
|
653 | + * @see wp-includes/capabilities.php |
|
654 | + * |
|
655 | + * @since 4.5.0 |
|
656 | + * |
|
657 | + * @param string $role A WordPress role the capability is being added to |
|
658 | + * @param string $cap The capability being added to the role |
|
659 | + * @param bool $grant Whether to grant access to this cap on this role. |
|
660 | + * |
|
661 | + * @return bool |
|
662 | + */ |
|
663 | + public function add_cap_to_role($role, $cap, $grant = true) |
|
664 | + { |
|
665 | + $role_object = get_role($role); |
|
666 | + //if the role isn't available then we create it. |
|
667 | + if (! $role_object instanceof WP_Role) { |
|
668 | + //if a plugin wants to create a specific role name then they should create the role before |
|
669 | + //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
670 | + // - removes any `ee_` namespacing from the start of the slug. |
|
671 | + // - replaces `_` with ` ` (empty space). |
|
672 | + // - sentence case on the resulting string. |
|
673 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
674 | + $role_object = add_role($role, $role_label); |
|
675 | + } |
|
676 | + if ($role_object instanceof WP_Role) { |
|
677 | + $role_object->add_cap($cap, $grant); |
|
678 | + return true; |
|
679 | + } |
|
680 | + return false; |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + /** |
|
685 | + * Functions similarly to add_cap_to_role except removes cap from given role. |
|
686 | + * Wrapper for $wp_role->remove_cap() |
|
687 | + * |
|
688 | + * @see wp-includes/capabilities.php |
|
689 | + * @since 4.5.0 |
|
690 | + * |
|
691 | + * @param string $role A WordPress role the capability is being removed from. |
|
692 | + * @param string $cap The capability being removed |
|
693 | + * |
|
694 | + * @return void |
|
695 | + */ |
|
696 | + public function remove_cap_from_role($role, $cap) |
|
697 | + { |
|
698 | + $role = get_role($role); |
|
699 | + if ($role instanceof WP_Role) { |
|
700 | + $role->remove_cap($cap); |
|
701 | + } |
|
702 | + } |
|
703 | + |
|
704 | + |
|
705 | + /** |
|
706 | + * Wrapper for the native WP current_user_can() method. |
|
707 | + * This is provided as a handy method for a couple things: |
|
708 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
709 | + * write those filters wherever current_user_can is called). |
|
710 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
711 | + * |
|
712 | + * @since 4.5.0 |
|
713 | + * |
|
714 | + * @param string $cap The cap being checked. |
|
715 | + * @param string $context The context where the current_user_can is being called from. |
|
716 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
717 | + * filters. |
|
718 | + * |
|
719 | + * @return bool Whether user can or not. |
|
720 | + */ |
|
721 | + public function current_user_can($cap, $context, $id = 0) |
|
722 | + { |
|
723 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
724 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
725 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
726 | + $id); |
|
727 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
733 | + * |
|
734 | + * @param int|WP_User $user Either the user_id or a WP_User object |
|
735 | + * @param string $cap The capability string being checked |
|
736 | + * @param string $context The context where the user_can is being called from (used in filters). |
|
737 | + * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
738 | + * filters) |
|
739 | + * |
|
740 | + * @return bool Whether user can or not. |
|
741 | + */ |
|
742 | + public function user_can($user, $cap, $context, $id = 0) |
|
743 | + { |
|
744 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
745 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
746 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
747 | + $id); |
|
748 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * Wrapper for the native WP current_user_can_for_blog() method. |
|
754 | + * This is provided as a handy method for a couple things: |
|
755 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
756 | + * write those filters wherever current_user_can is called). |
|
757 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
758 | + * |
|
759 | + * @since 4.5.0 |
|
760 | + * |
|
761 | + * @param int $blog_id The blog id that is being checked for. |
|
762 | + * @param string $cap The cap being checked. |
|
763 | + * @param string $context The context where the current_user_can is being called from. |
|
764 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
765 | + * filters. |
|
766 | + * |
|
767 | + * @return bool Whether user can or not. |
|
768 | + */ |
|
769 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
770 | + { |
|
771 | + $user_can = ! empty($id) |
|
772 | + ? current_user_can_for_blog($blog_id, $cap, $id) |
|
773 | + : current_user_can($blog_id, $cap); |
|
774 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
775 | + $user_can = apply_filters( |
|
776 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
777 | + $user_can, |
|
778 | + $blog_id, |
|
779 | + $cap, |
|
780 | + $id |
|
781 | + ); |
|
782 | + $user_can = apply_filters( |
|
783 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
784 | + $user_can, |
|
785 | + $context, |
|
786 | + $blog_id, |
|
787 | + $cap, |
|
788 | + $id |
|
789 | + ); |
|
790 | + return $user_can; |
|
791 | + } |
|
792 | + |
|
793 | + |
|
794 | + /** |
|
795 | + * This helper method just returns an array of registered EE capabilities. |
|
796 | + * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
797 | + * role. |
|
798 | + * |
|
799 | + * @since 4.5.0 |
|
800 | + * |
|
801 | + * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
802 | + * for the given role are returned. |
|
803 | + * |
|
804 | + * @return array |
|
805 | + */ |
|
806 | + public function get_ee_capabilities($role = 'administrator') |
|
807 | + { |
|
808 | + $capabilities = $this->_init_caps_map(); |
|
809 | + if (empty($role)) { |
|
810 | + return $capabilities; |
|
811 | + } |
|
812 | + return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
813 | + } |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -827,142 +827,142 @@ discard block |
||
827 | 827 | abstract class EE_Meta_Capability_Map |
828 | 828 | { |
829 | 829 | |
830 | - public $meta_cap; |
|
831 | - |
|
832 | - /** |
|
833 | - * @var EEM_Base |
|
834 | - */ |
|
835 | - protected $_model; |
|
836 | - |
|
837 | - protected $_model_name; |
|
838 | - |
|
839 | - public $published_cap = ''; |
|
840 | - |
|
841 | - public $others_cap = ''; |
|
842 | - |
|
843 | - public $private_cap = ''; |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * constructor. |
|
848 | - * Receives the setup arguments for the map. |
|
849 | - * |
|
850 | - * @since 4.5.0 |
|
851 | - * |
|
852 | - * @param string $meta_cap What meta capability is this mapping. |
|
853 | - * @param array $map_values array { |
|
854 | - * //array of values that MUST match a count of 4. It's okay to send an empty string for |
|
855 | - * capabilities that don't get mapped to. |
|
856 | - * |
|
857 | - * @type $map_values [0] string A string representing the model name. Required. String's |
|
858 | - * should always be used when Menu Maps are registered via the |
|
859 | - * plugin API as models are not allowed to be instantiated when |
|
860 | - * in maintenance mode 2 (migrations). |
|
861 | - * @type $map_values [1] string represents the capability used for published. Optional. |
|
862 | - * @type $map_values [2] string represents the capability used for "others". Optional. |
|
863 | - * @type $map_values [3] string represents the capability used for private. Optional. |
|
864 | - * } |
|
865 | - * @throws EE_Error |
|
866 | - */ |
|
867 | - public function __construct($meta_cap, $map_values) |
|
868 | - { |
|
869 | - $this->meta_cap = $meta_cap; |
|
870 | - //verify there are four args in the $map_values array; |
|
871 | - if (count($map_values) !== 4) { |
|
872 | - throw new EE_Error( |
|
873 | - sprintf( |
|
874 | - __( |
|
875 | - 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
876 | - 'event_espresso' |
|
877 | - ), |
|
878 | - '<br>' . print_r($map_values, true) |
|
879 | - ) |
|
880 | - ); |
|
881 | - } |
|
882 | - //set properties |
|
883 | - $this->_model = null; |
|
884 | - $this->_model_name = $map_values[0]; |
|
885 | - $this->published_cap = (string)$map_values[1]; |
|
886 | - $this->others_cap = (string)$map_values[2]; |
|
887 | - $this->private_cap = (string)$map_values[3]; |
|
888 | - } |
|
889 | - |
|
890 | - /** |
|
891 | - * Makes it so this object stops filtering caps |
|
892 | - */ |
|
893 | - public function remove_filters() |
|
894 | - { |
|
895 | - remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
901 | - * |
|
902 | - * @since 4.5.0 |
|
903 | - * @throws EE_Error |
|
904 | - * |
|
905 | - * @return void |
|
906 | - */ |
|
907 | - public function ensure_is_model() |
|
908 | - { |
|
909 | - //is it already instantiated? |
|
910 | - if ($this->_model instanceof EEM_Base) { |
|
911 | - return; |
|
912 | - } |
|
913 | - //ensure model name is string |
|
914 | - $this->_model_name = (string)$this->_model_name; |
|
915 | - //error proof if the name has EEM in it |
|
916 | - $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
917 | - $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
918 | - if (! $this->_model instanceof EEM_Base) { |
|
919 | - throw new EE_Error( |
|
920 | - sprintf( |
|
921 | - __( |
|
922 | - 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
923 | - 'event_espresso' |
|
924 | - ), |
|
925 | - get_class($this), |
|
926 | - $this->_model |
|
927 | - ) |
|
928 | - ); |
|
929 | - } |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - /** |
|
934 | - * |
|
935 | - * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
936 | - * @since 4.6.x |
|
937 | - * |
|
938 | - * @param $caps |
|
939 | - * @param $cap |
|
940 | - * @param $user_id |
|
941 | - * @param $args |
|
942 | - * |
|
943 | - * @return array |
|
944 | - */ |
|
945 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
946 | - { |
|
947 | - return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
948 | - } |
|
949 | - |
|
950 | - |
|
951 | - /** |
|
952 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
953 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
954 | - * |
|
955 | - * @since 4.5.0 |
|
956 | - * @see wp-includes/capabilities.php |
|
957 | - * |
|
958 | - * @param array $caps actual users capabilities |
|
959 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
960 | - * @param int $user_id The user id |
|
961 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
962 | - * |
|
963 | - * @return array actual users capabilities |
|
964 | - */ |
|
965 | - abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
830 | + public $meta_cap; |
|
831 | + |
|
832 | + /** |
|
833 | + * @var EEM_Base |
|
834 | + */ |
|
835 | + protected $_model; |
|
836 | + |
|
837 | + protected $_model_name; |
|
838 | + |
|
839 | + public $published_cap = ''; |
|
840 | + |
|
841 | + public $others_cap = ''; |
|
842 | + |
|
843 | + public $private_cap = ''; |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * constructor. |
|
848 | + * Receives the setup arguments for the map. |
|
849 | + * |
|
850 | + * @since 4.5.0 |
|
851 | + * |
|
852 | + * @param string $meta_cap What meta capability is this mapping. |
|
853 | + * @param array $map_values array { |
|
854 | + * //array of values that MUST match a count of 4. It's okay to send an empty string for |
|
855 | + * capabilities that don't get mapped to. |
|
856 | + * |
|
857 | + * @type $map_values [0] string A string representing the model name. Required. String's |
|
858 | + * should always be used when Menu Maps are registered via the |
|
859 | + * plugin API as models are not allowed to be instantiated when |
|
860 | + * in maintenance mode 2 (migrations). |
|
861 | + * @type $map_values [1] string represents the capability used for published. Optional. |
|
862 | + * @type $map_values [2] string represents the capability used for "others". Optional. |
|
863 | + * @type $map_values [3] string represents the capability used for private. Optional. |
|
864 | + * } |
|
865 | + * @throws EE_Error |
|
866 | + */ |
|
867 | + public function __construct($meta_cap, $map_values) |
|
868 | + { |
|
869 | + $this->meta_cap = $meta_cap; |
|
870 | + //verify there are four args in the $map_values array; |
|
871 | + if (count($map_values) !== 4) { |
|
872 | + throw new EE_Error( |
|
873 | + sprintf( |
|
874 | + __( |
|
875 | + 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
876 | + 'event_espresso' |
|
877 | + ), |
|
878 | + '<br>' . print_r($map_values, true) |
|
879 | + ) |
|
880 | + ); |
|
881 | + } |
|
882 | + //set properties |
|
883 | + $this->_model = null; |
|
884 | + $this->_model_name = $map_values[0]; |
|
885 | + $this->published_cap = (string)$map_values[1]; |
|
886 | + $this->others_cap = (string)$map_values[2]; |
|
887 | + $this->private_cap = (string)$map_values[3]; |
|
888 | + } |
|
889 | + |
|
890 | + /** |
|
891 | + * Makes it so this object stops filtering caps |
|
892 | + */ |
|
893 | + public function remove_filters() |
|
894 | + { |
|
895 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
901 | + * |
|
902 | + * @since 4.5.0 |
|
903 | + * @throws EE_Error |
|
904 | + * |
|
905 | + * @return void |
|
906 | + */ |
|
907 | + public function ensure_is_model() |
|
908 | + { |
|
909 | + //is it already instantiated? |
|
910 | + if ($this->_model instanceof EEM_Base) { |
|
911 | + return; |
|
912 | + } |
|
913 | + //ensure model name is string |
|
914 | + $this->_model_name = (string)$this->_model_name; |
|
915 | + //error proof if the name has EEM in it |
|
916 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
917 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
918 | + if (! $this->_model instanceof EEM_Base) { |
|
919 | + throw new EE_Error( |
|
920 | + sprintf( |
|
921 | + __( |
|
922 | + 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
923 | + 'event_espresso' |
|
924 | + ), |
|
925 | + get_class($this), |
|
926 | + $this->_model |
|
927 | + ) |
|
928 | + ); |
|
929 | + } |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + /** |
|
934 | + * |
|
935 | + * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
936 | + * @since 4.6.x |
|
937 | + * |
|
938 | + * @param $caps |
|
939 | + * @param $cap |
|
940 | + * @param $user_id |
|
941 | + * @param $args |
|
942 | + * |
|
943 | + * @return array |
|
944 | + */ |
|
945 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
946 | + { |
|
947 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
948 | + } |
|
949 | + |
|
950 | + |
|
951 | + /** |
|
952 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
953 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
954 | + * |
|
955 | + * @since 4.5.0 |
|
956 | + * @see wp-includes/capabilities.php |
|
957 | + * |
|
958 | + * @param array $caps actual users capabilities |
|
959 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
960 | + * @param int $user_id The user id |
|
961 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
962 | + * |
|
963 | + * @return array actual users capabilities |
|
964 | + */ |
|
965 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | |
@@ -978,83 +978,83 @@ discard block |
||
978 | 978 | class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map |
979 | 979 | { |
980 | 980 | |
981 | - /** |
|
982 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
983 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
984 | - * |
|
985 | - * @since 4.5.0 |
|
986 | - * @see wp-includes/capabilities.php |
|
987 | - * |
|
988 | - * @param array $caps actual users capabilities |
|
989 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
990 | - * @param int $user_id The user id |
|
991 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
992 | - * |
|
993 | - * @return array actual users capabilities |
|
994 | - */ |
|
995 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | - { |
|
997 | - //only process if we're checking our mapped_cap |
|
998 | - if ($cap !== $this->meta_cap) { |
|
999 | - return $caps; |
|
1000 | - } |
|
1001 | - |
|
1002 | - //cast $user_id to int for later explicit comparisons |
|
1003 | - $user_id = (int) $user_id; |
|
1004 | - |
|
1005 | - /** @var EE_Base_Class $obj */ |
|
1006 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | - //if no obj then let's just do cap |
|
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1009 | - $caps[] = $cap; |
|
1010 | - return $caps; |
|
1011 | - } |
|
1012 | - if ($obj instanceof EE_CPT_Base) { |
|
1013 | - //if the item author is set and the user is the author... |
|
1014 | - if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | - if (empty($this->published_cap)) { |
|
1016 | - $caps[] = $cap; |
|
1017 | - } else { |
|
1018 | - //if obj is published... |
|
1019 | - if ($obj->status() === 'publish') { |
|
1020 | - $caps[] = $this->published_cap; |
|
1021 | - } else { |
|
1022 | - $caps[] = $cap; |
|
1023 | - } |
|
1024 | - } |
|
1025 | - } else { |
|
1026 | - //the user is trying to edit someone else's obj |
|
1027 | - if (! empty($this->others_cap)) { |
|
1028 | - $caps[] = $this->others_cap; |
|
1029 | - } |
|
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | - $caps[] = $this->published_cap; |
|
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | - $caps[] = $this->private_cap; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } else { |
|
1037 | - //not a cpt object so handled differently |
|
1038 | - $has_cap = false; |
|
1039 | - try { |
|
1040 | - $has_cap = method_exists($obj, 'wp_user') |
|
1041 | - && $obj->wp_user() |
|
1042 | - && $obj->wp_user() === $user_id; |
|
1043 | - } catch (Exception $e) { |
|
1044 | - if (WP_DEBUG) { |
|
1045 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | - } |
|
1047 | - } |
|
1048 | - if ($has_cap) { |
|
1049 | - $caps[] = $cap; |
|
1050 | - } else { |
|
1051 | - if (! empty($this->others_cap)) { |
|
1052 | - $caps[] = $this->others_cap; |
|
1053 | - } |
|
1054 | - } |
|
1055 | - } |
|
1056 | - return $caps; |
|
1057 | - } |
|
981 | + /** |
|
982 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
983 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
984 | + * |
|
985 | + * @since 4.5.0 |
|
986 | + * @see wp-includes/capabilities.php |
|
987 | + * |
|
988 | + * @param array $caps actual users capabilities |
|
989 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
990 | + * @param int $user_id The user id |
|
991 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
992 | + * |
|
993 | + * @return array actual users capabilities |
|
994 | + */ |
|
995 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | + { |
|
997 | + //only process if we're checking our mapped_cap |
|
998 | + if ($cap !== $this->meta_cap) { |
|
999 | + return $caps; |
|
1000 | + } |
|
1001 | + |
|
1002 | + //cast $user_id to int for later explicit comparisons |
|
1003 | + $user_id = (int) $user_id; |
|
1004 | + |
|
1005 | + /** @var EE_Base_Class $obj */ |
|
1006 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | + //if no obj then let's just do cap |
|
1008 | + if (! $obj instanceof EE_Base_Class) { |
|
1009 | + $caps[] = $cap; |
|
1010 | + return $caps; |
|
1011 | + } |
|
1012 | + if ($obj instanceof EE_CPT_Base) { |
|
1013 | + //if the item author is set and the user is the author... |
|
1014 | + if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | + if (empty($this->published_cap)) { |
|
1016 | + $caps[] = $cap; |
|
1017 | + } else { |
|
1018 | + //if obj is published... |
|
1019 | + if ($obj->status() === 'publish') { |
|
1020 | + $caps[] = $this->published_cap; |
|
1021 | + } else { |
|
1022 | + $caps[] = $cap; |
|
1023 | + } |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + //the user is trying to edit someone else's obj |
|
1027 | + if (! empty($this->others_cap)) { |
|
1028 | + $caps[] = $this->others_cap; |
|
1029 | + } |
|
1030 | + if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | + $caps[] = $this->published_cap; |
|
1032 | + } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | + $caps[] = $this->private_cap; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } else { |
|
1037 | + //not a cpt object so handled differently |
|
1038 | + $has_cap = false; |
|
1039 | + try { |
|
1040 | + $has_cap = method_exists($obj, 'wp_user') |
|
1041 | + && $obj->wp_user() |
|
1042 | + && $obj->wp_user() === $user_id; |
|
1043 | + } catch (Exception $e) { |
|
1044 | + if (WP_DEBUG) { |
|
1045 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | + } |
|
1047 | + } |
|
1048 | + if ($has_cap) { |
|
1049 | + $caps[] = $cap; |
|
1050 | + } else { |
|
1051 | + if (! empty($this->others_cap)) { |
|
1052 | + $caps[] = $this->others_cap; |
|
1053 | + } |
|
1054 | + } |
|
1055 | + } |
|
1056 | + return $caps; |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | |
@@ -1071,24 +1071,24 @@ discard block |
||
1071 | 1071 | class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit |
1072 | 1072 | { |
1073 | 1073 | |
1074 | - /** |
|
1075 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | - * |
|
1078 | - * @since 4.5.0 |
|
1079 | - * @see wp-includes/capabilities.php |
|
1080 | - * |
|
1081 | - * @param array $caps actual users capabilities |
|
1082 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1083 | - * @param int $user_id The user id |
|
1084 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1085 | - * |
|
1086 | - * @return array actual users capabilities |
|
1087 | - */ |
|
1088 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1089 | - { |
|
1090 | - return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1091 | - } |
|
1074 | + /** |
|
1075 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | + * |
|
1078 | + * @since 4.5.0 |
|
1079 | + * @see wp-includes/capabilities.php |
|
1080 | + * |
|
1081 | + * @param array $caps actual users capabilities |
|
1082 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1083 | + * @param int $user_id The user id |
|
1084 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1085 | + * |
|
1086 | + * @return array actual users capabilities |
|
1087 | + */ |
|
1088 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1089 | + { |
|
1090 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1091 | + } |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | |
@@ -1104,75 +1104,75 @@ discard block |
||
1104 | 1104 | class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map |
1105 | 1105 | { |
1106 | 1106 | |
1107 | - /** |
|
1108 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1109 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1110 | - * |
|
1111 | - * @since 4.5.0 |
|
1112 | - * @see wp-includes/capabilities.php |
|
1113 | - * |
|
1114 | - * @param array $caps actual users capabilities |
|
1115 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1116 | - * @param int $user_id The user id |
|
1117 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1118 | - * |
|
1119 | - * @return array actual users capabilities |
|
1120 | - */ |
|
1121 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1122 | - { |
|
1123 | - //only process if we're checking our mapped cap; |
|
1124 | - if ($cap !== $this->meta_cap) { |
|
1125 | - return $caps; |
|
1126 | - } |
|
1127 | - |
|
1128 | - //cast $user_id to int for later explicit comparisons |
|
1129 | - $user_id = (int) $user_id; |
|
1130 | - |
|
1131 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1132 | - //if no obj then let's just do cap |
|
1133 | - if (! $obj instanceof EE_Base_Class) { |
|
1134 | - $caps[] = $cap; |
|
1135 | - return $caps; |
|
1136 | - } |
|
1137 | - if ($obj instanceof EE_CPT_Base) { |
|
1138 | - $status_obj = get_post_status_object($obj->status()); |
|
1139 | - if ($status_obj->public) { |
|
1140 | - $caps[] = $cap; |
|
1141 | - return $caps; |
|
1142 | - } |
|
1143 | - //if the item author is set and the user is the author... |
|
1144 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1145 | - $caps[] = $cap; |
|
1146 | - } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1147 | - //the user is trying to view someone else's obj |
|
1148 | - $caps[] = $this->private_cap; |
|
1149 | - } elseif (! empty($this->others_cap)) { |
|
1150 | - $caps[] = $this->others_cap; |
|
1151 | - } else { |
|
1152 | - $caps[] = $cap; |
|
1153 | - } |
|
1154 | - } else { |
|
1155 | - //not a cpt object so handled differently |
|
1156 | - $has_cap = false; |
|
1157 | - try { |
|
1158 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1159 | - } catch (Exception $e) { |
|
1160 | - if (WP_DEBUG) { |
|
1161 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1162 | - } |
|
1163 | - } |
|
1164 | - if ($has_cap) { |
|
1165 | - $caps[] = $cap; |
|
1166 | - } elseif (! empty($this->private_cap)) { |
|
1167 | - $caps[] = $this->private_cap; |
|
1168 | - } elseif (! empty($this->others_cap)) { |
|
1169 | - $caps[] = $this->others_cap; |
|
1170 | - } else { |
|
1171 | - $caps[] = $cap; |
|
1172 | - } |
|
1173 | - } |
|
1174 | - return $caps; |
|
1175 | - } |
|
1107 | + /** |
|
1108 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1109 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1110 | + * |
|
1111 | + * @since 4.5.0 |
|
1112 | + * @see wp-includes/capabilities.php |
|
1113 | + * |
|
1114 | + * @param array $caps actual users capabilities |
|
1115 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1116 | + * @param int $user_id The user id |
|
1117 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1118 | + * |
|
1119 | + * @return array actual users capabilities |
|
1120 | + */ |
|
1121 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1122 | + { |
|
1123 | + //only process if we're checking our mapped cap; |
|
1124 | + if ($cap !== $this->meta_cap) { |
|
1125 | + return $caps; |
|
1126 | + } |
|
1127 | + |
|
1128 | + //cast $user_id to int for later explicit comparisons |
|
1129 | + $user_id = (int) $user_id; |
|
1130 | + |
|
1131 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1132 | + //if no obj then let's just do cap |
|
1133 | + if (! $obj instanceof EE_Base_Class) { |
|
1134 | + $caps[] = $cap; |
|
1135 | + return $caps; |
|
1136 | + } |
|
1137 | + if ($obj instanceof EE_CPT_Base) { |
|
1138 | + $status_obj = get_post_status_object($obj->status()); |
|
1139 | + if ($status_obj->public) { |
|
1140 | + $caps[] = $cap; |
|
1141 | + return $caps; |
|
1142 | + } |
|
1143 | + //if the item author is set and the user is the author... |
|
1144 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1145 | + $caps[] = $cap; |
|
1146 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1147 | + //the user is trying to view someone else's obj |
|
1148 | + $caps[] = $this->private_cap; |
|
1149 | + } elseif (! empty($this->others_cap)) { |
|
1150 | + $caps[] = $this->others_cap; |
|
1151 | + } else { |
|
1152 | + $caps[] = $cap; |
|
1153 | + } |
|
1154 | + } else { |
|
1155 | + //not a cpt object so handled differently |
|
1156 | + $has_cap = false; |
|
1157 | + try { |
|
1158 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1159 | + } catch (Exception $e) { |
|
1160 | + if (WP_DEBUG) { |
|
1161 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1162 | + } |
|
1163 | + } |
|
1164 | + if ($has_cap) { |
|
1165 | + $caps[] = $cap; |
|
1166 | + } elseif (! empty($this->private_cap)) { |
|
1167 | + $caps[] = $this->private_cap; |
|
1168 | + } elseif (! empty($this->others_cap)) { |
|
1169 | + $caps[] = $this->others_cap; |
|
1170 | + } else { |
|
1171 | + $caps[] = $cap; |
|
1172 | + } |
|
1173 | + } |
|
1174 | + return $caps; |
|
1175 | + } |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
@@ -1189,52 +1189,52 @@ discard block |
||
1189 | 1189 | class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map |
1190 | 1190 | { |
1191 | 1191 | |
1192 | - /** |
|
1193 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1194 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1195 | - * |
|
1196 | - * @since 4.5.0 |
|
1197 | - * @see wp-includes/capabilities.php |
|
1198 | - * |
|
1199 | - * @param array $caps actual users capabilities |
|
1200 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1201 | - * @param int $user_id The user id |
|
1202 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1203 | - * |
|
1204 | - * @return array actual users capabilities |
|
1205 | - */ |
|
1206 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1207 | - { |
|
1208 | - //only process if we're checking our mapped_cap |
|
1209 | - if ($cap !== $this->meta_cap) { |
|
1210 | - return $caps; |
|
1211 | - } |
|
1212 | - |
|
1213 | - //cast $user_id to int for later explicit comparisons |
|
1214 | - $user_id = (int) $user_id; |
|
1215 | - |
|
1216 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1217 | - //if no obj then let's just do cap |
|
1218 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1219 | - $caps[] = $cap; |
|
1220 | - return $caps; |
|
1221 | - } |
|
1222 | - $is_global = $obj->is_global(); |
|
1223 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1224 | - if ($is_global) { |
|
1225 | - $caps[] = $this->private_cap; |
|
1226 | - } else { |
|
1227 | - $caps[] = $cap; |
|
1228 | - } |
|
1229 | - } else { |
|
1230 | - if ($is_global) { |
|
1231 | - $caps[] = $this->private_cap; |
|
1232 | - } else { |
|
1233 | - $caps[] = $this->others_cap; |
|
1234 | - } |
|
1235 | - } |
|
1236 | - return $caps; |
|
1237 | - } |
|
1192 | + /** |
|
1193 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1194 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1195 | + * |
|
1196 | + * @since 4.5.0 |
|
1197 | + * @see wp-includes/capabilities.php |
|
1198 | + * |
|
1199 | + * @param array $caps actual users capabilities |
|
1200 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1201 | + * @param int $user_id The user id |
|
1202 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1203 | + * |
|
1204 | + * @return array actual users capabilities |
|
1205 | + */ |
|
1206 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1207 | + { |
|
1208 | + //only process if we're checking our mapped_cap |
|
1209 | + if ($cap !== $this->meta_cap) { |
|
1210 | + return $caps; |
|
1211 | + } |
|
1212 | + |
|
1213 | + //cast $user_id to int for later explicit comparisons |
|
1214 | + $user_id = (int) $user_id; |
|
1215 | + |
|
1216 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1217 | + //if no obj then let's just do cap |
|
1218 | + if (! $obj instanceof EE_Message_Template_Group) { |
|
1219 | + $caps[] = $cap; |
|
1220 | + return $caps; |
|
1221 | + } |
|
1222 | + $is_global = $obj->is_global(); |
|
1223 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1224 | + if ($is_global) { |
|
1225 | + $caps[] = $this->private_cap; |
|
1226 | + } else { |
|
1227 | + $caps[] = $cap; |
|
1228 | + } |
|
1229 | + } else { |
|
1230 | + if ($is_global) { |
|
1231 | + $caps[] = $this->private_cap; |
|
1232 | + } else { |
|
1233 | + $caps[] = $this->others_cap; |
|
1234 | + } |
|
1235 | + } |
|
1236 | + return $caps; |
|
1237 | + } |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1251,41 +1251,41 @@ discard block |
||
1251 | 1251 | class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map |
1252 | 1252 | { |
1253 | 1253 | |
1254 | - /** |
|
1255 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1256 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1257 | - * |
|
1258 | - * @since 4.5.0 |
|
1259 | - * @see wp-includes/capabilities.php |
|
1260 | - * |
|
1261 | - * @param array $caps actual users capabilities |
|
1262 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1263 | - * @param int $user_id The user id |
|
1264 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1265 | - * |
|
1266 | - * @return array actual users capabilities |
|
1267 | - */ |
|
1268 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1269 | - { |
|
1270 | - //only process if we're checking our mapped_cap |
|
1271 | - if ($cap !== $this->meta_cap) { |
|
1272 | - return $caps; |
|
1273 | - } |
|
1274 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1275 | - //if no obj then let's just do cap |
|
1276 | - if (! $obj instanceof EE_Base_Class) { |
|
1277 | - $caps[] = $cap; |
|
1278 | - return $caps; |
|
1279 | - } |
|
1280 | - $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1281 | - $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1282 | - if ($is_system) { |
|
1283 | - $caps[] = $this->private_cap; |
|
1284 | - } else { |
|
1285 | - $caps[] = $cap; |
|
1286 | - } |
|
1287 | - return $caps; |
|
1288 | - } |
|
1254 | + /** |
|
1255 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1256 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1257 | + * |
|
1258 | + * @since 4.5.0 |
|
1259 | + * @see wp-includes/capabilities.php |
|
1260 | + * |
|
1261 | + * @param array $caps actual users capabilities |
|
1262 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1263 | + * @param int $user_id The user id |
|
1264 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1265 | + * |
|
1266 | + * @return array actual users capabilities |
|
1267 | + */ |
|
1268 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1269 | + { |
|
1270 | + //only process if we're checking our mapped_cap |
|
1271 | + if ($cap !== $this->meta_cap) { |
|
1272 | + return $caps; |
|
1273 | + } |
|
1274 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1275 | + //if no obj then let's just do cap |
|
1276 | + if (! $obj instanceof EE_Base_Class) { |
|
1277 | + $caps[] = $cap; |
|
1278 | + return $caps; |
|
1279 | + } |
|
1280 | + $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1281 | + $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1282 | + if ($is_system) { |
|
1283 | + $caps[] = $this->private_cap; |
|
1284 | + } else { |
|
1285 | + $caps[] = $cap; |
|
1286 | + } |
|
1287 | + return $caps; |
|
1288 | + } |
|
1289 | 1289 | |
1290 | 1290 | |
1291 | 1291 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public static function instance() |
61 | 61 | { |
62 | 62 | //check if instantiated, and if not do so. |
63 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
63 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
113 | 113 | $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
114 | 114 | //add filter for map_meta_caps but only if models can query. |
115 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
115 | + if ( ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | 116 | add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
117 | 117 | } |
118 | 118 | } |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
271 | 271 | //loop through our _meta_caps array |
272 | 272 | foreach ($this->_meta_caps as $meta_map) { |
273 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
273 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | 274 | continue; |
275 | 275 | } |
276 | 276 | // don't load models if there is no object ID in the args |
277 | - if(!empty($args[0])){ |
|
277 | + if ( ! empty($args[0])) { |
|
278 | 278 | $meta_map->ensure_is_model(); |
279 | 279 | } |
280 | 280 | $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | foreach ($caps_map as $role => $caps_for_role) { |
633 | 633 | foreach ($caps_for_role as $cap) { |
634 | 634 | //first check we haven't already added this cap before, or it's a reset |
635 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
635 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
636 | 636 | if ($this->add_cap_to_role($role, $cap)) { |
637 | - $caps_set_before[ $role ][] = $cap; |
|
637 | + $caps_set_before[$role][] = $cap; |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $role_object = get_role($role); |
666 | 666 | //if the role isn't available then we create it. |
667 | - if (! $role_object instanceof WP_Role) { |
|
667 | + if ( ! $role_object instanceof WP_Role) { |
|
668 | 668 | //if a plugin wants to create a specific role name then they should create the role before |
669 | 669 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
670 | 670 | // - removes any `ee_` namespacing from the start of the slug. |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function current_user_can($cap, $context, $id = 0) |
722 | 722 | { |
723 | 723 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
724 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
724 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
725 | 725 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
726 | 726 | $id); |
727 | 727 | return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | public function user_can($user, $cap, $context, $id = 0) |
743 | 743 | { |
744 | 744 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
745 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
745 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
746 | 746 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
747 | 747 | $id); |
748 | 748 | return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | : current_user_can($blog_id, $cap); |
774 | 774 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
775 | 775 | $user_can = apply_filters( |
776 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
776 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, |
|
777 | 777 | $user_can, |
778 | 778 | $blog_id, |
779 | 779 | $cap, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | if (empty($role)) { |
810 | 810 | return $capabilities; |
811 | 811 | } |
812 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
812 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
876 | 876 | 'event_espresso' |
877 | 877 | ), |
878 | - '<br>' . print_r($map_values, true) |
|
878 | + '<br>'.print_r($map_values, true) |
|
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | } |
882 | 882 | //set properties |
883 | 883 | $this->_model = null; |
884 | 884 | $this->_model_name = $map_values[0]; |
885 | - $this->published_cap = (string)$map_values[1]; |
|
886 | - $this->others_cap = (string)$map_values[2]; |
|
887 | - $this->private_cap = (string)$map_values[3]; |
|
885 | + $this->published_cap = (string) $map_values[1]; |
|
886 | + $this->others_cap = (string) $map_values[2]; |
|
887 | + $this->private_cap = (string) $map_values[3]; |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -911,11 +911,11 @@ discard block |
||
911 | 911 | return; |
912 | 912 | } |
913 | 913 | //ensure model name is string |
914 | - $this->_model_name = (string)$this->_model_name; |
|
914 | + $this->_model_name = (string) $this->_model_name; |
|
915 | 915 | //error proof if the name has EEM in it |
916 | 916 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
917 | 917 | $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
918 | - if (! $this->_model instanceof EEM_Base) { |
|
918 | + if ( ! $this->_model instanceof EEM_Base) { |
|
919 | 919 | throw new EE_Error( |
920 | 920 | sprintf( |
921 | 921 | __( |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | /** @var EE_Base_Class $obj */ |
1006 | 1006 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1007 | 1007 | //if no obj then let's just do cap |
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1008 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1009 | 1009 | $caps[] = $cap; |
1010 | 1010 | return $caps; |
1011 | 1011 | } |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } else { |
1026 | 1026 | //the user is trying to edit someone else's obj |
1027 | - if (! empty($this->others_cap)) { |
|
1027 | + if ( ! empty($this->others_cap)) { |
|
1028 | 1028 | $caps[] = $this->others_cap; |
1029 | 1029 | } |
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1030 | + if ( ! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | 1031 | $caps[] = $this->published_cap; |
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1032 | + } elseif ( ! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | 1033 | $caps[] = $this->private_cap; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | if ($has_cap) { |
1049 | 1049 | $caps[] = $cap; |
1050 | 1050 | } else { |
1051 | - if (! empty($this->others_cap)) { |
|
1051 | + if ( ! empty($this->others_cap)) { |
|
1052 | 1052 | $caps[] = $this->others_cap; |
1053 | 1053 | } |
1054 | 1054 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1132 | 1132 | //if no obj then let's just do cap |
1133 | - if (! $obj instanceof EE_Base_Class) { |
|
1133 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1134 | 1134 | $caps[] = $cap; |
1135 | 1135 | return $caps; |
1136 | 1136 | } |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | } elseif ($status_obj->private && ! empty($this->private_cap)) { |
1147 | 1147 | //the user is trying to view someone else's obj |
1148 | 1148 | $caps[] = $this->private_cap; |
1149 | - } elseif (! empty($this->others_cap)) { |
|
1149 | + } elseif ( ! empty($this->others_cap)) { |
|
1150 | 1150 | $caps[] = $this->others_cap; |
1151 | 1151 | } else { |
1152 | 1152 | $caps[] = $cap; |
@@ -1163,9 +1163,9 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | if ($has_cap) { |
1165 | 1165 | $caps[] = $cap; |
1166 | - } elseif (! empty($this->private_cap)) { |
|
1166 | + } elseif ( ! empty($this->private_cap)) { |
|
1167 | 1167 | $caps[] = $this->private_cap; |
1168 | - } elseif (! empty($this->others_cap)) { |
|
1168 | + } elseif ( ! empty($this->others_cap)) { |
|
1169 | 1169 | $caps[] = $this->others_cap; |
1170 | 1170 | } else { |
1171 | 1171 | $caps[] = $cap; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1217 | 1217 | //if no obj then let's just do cap |
1218 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1218 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1219 | 1219 | $caps[] = $cap; |
1220 | 1220 | return $caps; |
1221 | 1221 | } |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | } |
1274 | 1274 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1275 | 1275 | //if no obj then let's just do cap |
1276 | - if (! $obj instanceof EE_Base_Class) { |
|
1276 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1277 | 1277 | $caps[] = $cap; |
1278 | 1278 | return $caps; |
1279 | 1279 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @deprecated in 4.9.40 because the currency payment method table has been deprecated |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage{ |
|
17 | +class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage { |
|
18 | 18 | protected $_currency_table_name; |
19 | 19 | protected $_currency_payment_method_table_name; |
20 | 20 | protected $_payment_method_table_name; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ); |
91 | 91 | public function __construct() { |
92 | 92 | global $wpdb; |
93 | - $this->_pretty_name = __( 'Payment Method Currencies', 'event_espresso' ); |
|
93 | + $this->_pretty_name = __('Payment Method Currencies', 'event_espresso'); |
|
94 | 94 | $this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method'; |
95 | 95 | $this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method'; |
96 | 96 | $this->_currency_table_name = $wpdb->prefix.'esp_currency'; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function _count_records_to_migrate() { |
101 | 101 | $count = 0; |
102 | - foreach($this->_gateway_currencies as $currencies){ |
|
103 | - if( $currencies == 'all'){ |
|
102 | + foreach ($this->_gateway_currencies as $currencies) { |
|
103 | + if ($currencies == 'all') { |
|
104 | 104 | $currencies = $this->_get_all_currencies(); |
105 | 105 | } |
106 | 106 | $count += count($currencies); |
@@ -110,20 +110,20 @@ discard block |
||
110 | 110 | |
111 | 111 | |
112 | 112 | |
113 | - protected function _migration_step( $num_items_to_migrate = 50 ) { |
|
113 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
114 | 114 | $items_actually_migrated = 0; |
115 | 115 | $relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate); |
116 | - foreach($relations_to_add_this_step as $pm_slug => $currencies){ |
|
116 | + foreach ($relations_to_add_this_step as $pm_slug => $currencies) { |
|
117 | 117 | |
118 | - $id = $this->get_migration_script()->get_mapping_new_pk( 'EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name ); |
|
119 | - foreach( $currencies as $currency ){ |
|
120 | - if( $id ){ |
|
121 | - $this->_add_currency_relations( $id, $currency ); |
|
118 | + $id = $this->get_migration_script()->get_mapping_new_pk('EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name); |
|
119 | + foreach ($currencies as $currency) { |
|
120 | + if ($id) { |
|
121 | + $this->_add_currency_relations($id, $currency); |
|
122 | 122 | } |
123 | 123 | $items_actually_migrated++; |
124 | 124 | } |
125 | 125 | } |
126 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
126 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
127 | 127 | $this->set_completed(); |
128 | 128 | } |
129 | 129 | return $items_actually_migrated; |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | $relations_to_add_this_step = array(); |
134 | 134 | $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate; |
135 | 135 | $iterator = 0; |
136 | - foreach($this->_gateway_currencies as $pm_slug => $currencies){ |
|
137 | - if( $currencies == 'all' ){ |
|
136 | + foreach ($this->_gateway_currencies as $pm_slug => $currencies) { |
|
137 | + if ($currencies == 'all') { |
|
138 | 138 | $currencies = $this->_get_all_currencies(); |
139 | 139 | } |
140 | - foreach($currencies as $currency_code){ |
|
141 | - if( $this->count_records_migrated() <= $iterator && |
|
142 | - $iterator < $migrate_up_to_count ){ |
|
143 | - $relations_to_add_this_step[ $pm_slug ] [] = $currency_code; |
|
140 | + foreach ($currencies as $currency_code) { |
|
141 | + if ($this->count_records_migrated() <= $iterator && |
|
142 | + $iterator < $migrate_up_to_count) { |
|
143 | + $relations_to_add_this_step[$pm_slug] [] = $currency_code; |
|
144 | 144 | } |
145 | 145 | $iterator++; |
146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * Gets all the currency codes in the database |
152 | 152 | * @return array |
153 | 153 | */ |
154 | - private function _get_all_currencies(){ |
|
154 | + private function _get_all_currencies() { |
|
155 | 155 | global $wpdb; |
156 | 156 | $currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}"); |
157 | 157 | return $currencies; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param int $id |
163 | 163 | * @param string $gateway_slug |
164 | 164 | */ |
165 | - private function _add_currency_relations($pm_id,$currency_code){ |
|
165 | + private function _add_currency_relations($pm_id, $currency_code) { |
|
166 | 166 | global $wpdb; |
167 | 167 | $cur_pm_relation = array( |
168 | 168 | 'CUR_code'=>$currency_code, |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $success = $wpdb->insert($this->_currency_payment_method_table_name, |
172 | 172 | $cur_pm_relation, |
173 | 173 | array( |
174 | - '%s',//CUR_code |
|
175 | - '%d',//PMD_ID |
|
174 | + '%s', //CUR_code |
|
175 | + '%d', //PMD_ID |
|
176 | 176 | )); |
177 | - if( ! $success ){ |
|
178 | - $this->add_error( sprintf( __( 'Could not add currency relation %s because %s', "event_espresso" ), wp_json_encode( $cur_pm_relation ), $wpdb->last_error ) ); |
|
177 | + if ( ! $success) { |
|
178 | + $this->add_error(sprintf(__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error)); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[$matches[1]] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - //no version string provided... this must be pre 4.3 |
|
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + //no version string provided... this must be pre 4.3 |
|
70 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - //note: although this table is no longer in use, |
|
153 | - //it hasn't been removed because then queries to the model will have errors. |
|
154 | - //but you should expect this table and its corresponding model to be removed in |
|
155 | - //the next few months |
|
156 | - $table_name = 'esp_currency_payment_method'; |
|
157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + //note: although this table is no longer in use, |
|
153 | + //it hasn't been removed because then queries to the model will have errors. |
|
154 | + //but you should expect this table and its corresponding model to be removed in |
|
155 | + //the next few months |
|
156 | + $table_name = 'esp_currency_payment_method'; |
|
157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
158 | 158 | CUR_code varchar(6) NOT NULL, |
159 | 159 | PMD_ID int(11) NOT NULL, |
160 | 160 | PRIMARY KEY (CPM_ID), |
161 | 161 | KEY PMD_ID (PMD_ID)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | - $table_name = 'esp_datetime'; |
|
164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | + $table_name = 'esp_datetime'; |
|
164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
179 | 179 | KEY EVT_ID (EVT_ID), |
180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
181 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | - $table_name = "esp_datetime_ticket"; |
|
183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | + $table_name = "esp_datetime_ticket"; |
|
183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
186 | 186 | PRIMARY KEY (DTK_ID), |
187 | 187 | KEY DTT_ID (DTT_ID), |
188 | 188 | KEY TKT_ID (TKT_ID)"; |
189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | - $table_name = 'esp_event_message_template'; |
|
191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | + $table_name = 'esp_event_message_template'; |
|
191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EMT_ID), |
195 | 195 | KEY EVT_ID (EVT_ID), |
196 | 196 | KEY GRP_ID (GRP_ID)"; |
197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_meta'; |
|
199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_meta'; |
|
199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,34 +211,34 @@ discard block |
||
211 | 211 | EVT_donations tinyint(1) NULL, |
212 | 212 | PRIMARY KEY (EVTM_ID), |
213 | 213 | KEY EVT_ID (EVT_ID)"; |
214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | - $table_name = 'esp_event_question_group'; |
|
216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $table_name = 'esp_event_question_group'; |
|
216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
220 | 220 | PRIMARY KEY (EQG_ID), |
221 | 221 | KEY EVT_ID (EVT_ID), |
222 | 222 | KEY QSG_ID (QSG_ID)"; |
223 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_event_venue'; |
|
225 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_event_venue'; |
|
225 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | EVT_ID bigint(20) unsigned NOT NULL, |
227 | 227 | VNU_ID bigint(20) unsigned NOT NULL, |
228 | 228 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
229 | 229 | PRIMARY KEY (EVV_ID)"; |
230 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | - $table_name = 'esp_extra_meta'; |
|
232 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | + $table_name = 'esp_extra_meta'; |
|
232 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
233 | 233 | OBJ_ID int(11) DEFAULT NULL, |
234 | 234 | EXM_type varchar(45) DEFAULT NULL, |
235 | 235 | EXM_key varchar(45) DEFAULT NULL, |
236 | 236 | EXM_value text, |
237 | 237 | PRIMARY KEY (EXM_ID), |
238 | 238 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
239 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | - $table_name = 'esp_extra_join'; |
|
241 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
239 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | + $table_name = 'esp_extra_join'; |
|
241 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
242 | 242 | EXJ_first_model_id varchar(6) NOT NULL, |
243 | 243 | EXJ_first_model_name varchar(20) NOT NULL, |
244 | 244 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | PRIMARY KEY (EXJ_ID), |
247 | 247 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
248 | 248 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
249 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | - $table_name = 'esp_line_item'; |
|
251 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
249 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | + $table_name = 'esp_line_item'; |
|
251 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
252 | 252 | LIN_code varchar(245) NOT NULL DEFAULT '', |
253 | 253 | TXN_ID int(11) DEFAULT NULL, |
254 | 254 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | PRIMARY KEY (LIN_ID), |
268 | 268 | KEY LIN_code (LIN_code(191)), |
269 | 269 | KEY TXN_ID (TXN_ID)"; |
270 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | - $table_name = 'esp_log'; |
|
272 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
270 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | + $table_name = 'esp_log'; |
|
272 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
273 | 273 | LOG_time datetime DEFAULT NULL, |
274 | 274 | OBJ_ID varchar(45) DEFAULT NULL, |
275 | 275 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | KEY LOG_time (LOG_time), |
281 | 281 | KEY OBJ (OBJ_type,OBJ_ID), |
282 | 282 | KEY LOG_type (LOG_type)"; |
283 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
284 | - $table_name = 'esp_message'; |
|
285 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
286 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
287 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
288 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
283 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
284 | + $table_name = 'esp_message'; |
|
285 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
286 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
287 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
288 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | 289 | GRP_ID int(10) unsigned NULL, |
290 | 290 | MSG_token varchar(255) NULL, |
291 | 291 | TXN_ID int(10) unsigned NULL, |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | KEY STS_ID (STS_ID), |
318 | 318 | KEY MSG_created (MSG_created), |
319 | 319 | KEY MSG_modified (MSG_modified)"; |
320 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_message_template'; |
|
322 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_message_template'; |
|
322 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | 323 | GRP_ID int(10) unsigned NOT NULL, |
324 | 324 | MTP_context varchar(50) NOT NULL, |
325 | 325 | MTP_template_field varchar(30) NOT NULL, |
326 | 326 | MTP_content text NOT NULL, |
327 | 327 | PRIMARY KEY (MTP_ID), |
328 | 328 | KEY GRP_ID (GRP_ID)"; |
329 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | - $table_name = 'esp_message_template_group'; |
|
331 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
329 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | + $table_name = 'esp_message_template_group'; |
|
331 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | 332 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
333 | 333 | MTP_name varchar(245) NOT NULL DEFAULT '', |
334 | 334 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
341 | 341 | PRIMARY KEY (GRP_ID), |
342 | 342 | KEY MTP_user_id (MTP_user_id)"; |
343 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | - $table_name = 'esp_payment'; |
|
345 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | + $table_name = 'esp_payment'; |
|
345 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | TXN_ID int(10) unsigned DEFAULT NULL, |
347 | 347 | STS_ID varchar(3) DEFAULT NULL, |
348 | 348 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | PRIMARY KEY (PAY_ID), |
360 | 360 | KEY PAY_timestamp (PAY_timestamp), |
361 | 361 | KEY TXN_ID (TXN_ID)"; |
362 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | - $table_name = 'esp_payment_method'; |
|
364 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
362 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | + $table_name = 'esp_payment_method'; |
|
364 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
365 | 365 | PMD_type varchar(124) DEFAULT NULL, |
366 | 366 | PMD_name varchar(255) DEFAULT NULL, |
367 | 367 | PMD_desc text, |
@@ -377,24 +377,24 @@ discard block |
||
377 | 377 | PRIMARY KEY (PMD_ID), |
378 | 378 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
379 | 379 | KEY PMD_type (PMD_type)"; |
380 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | - $table_name = "esp_ticket_price"; |
|
382 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
380 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | + $table_name = "esp_ticket_price"; |
|
382 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | 383 | TKT_ID int(10) unsigned NOT NULL, |
384 | 384 | PRC_ID int(10) unsigned NOT NULL, |
385 | 385 | PRIMARY KEY (TKP_ID), |
386 | 386 | KEY TKT_ID (TKT_ID), |
387 | 387 | KEY PRC_ID (PRC_ID)"; |
388 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | - $table_name = "esp_ticket_template"; |
|
390 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
388 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | + $table_name = "esp_ticket_template"; |
|
390 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | 391 | TTM_name varchar(45) NOT NULL, |
392 | 392 | TTM_description text, |
393 | 393 | TTM_file varchar(45), |
394 | 394 | PRIMARY KEY (TTM_ID)"; |
395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | - $table_name = 'esp_question'; |
|
397 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | + $table_name = 'esp_question'; |
|
397 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
398 | 398 | QST_display_text text NOT NULL, |
399 | 399 | QST_admin_label varchar(255) NOT NULL, |
400 | 400 | QST_system varchar(25) DEFAULT NULL, |
@@ -408,18 +408,18 @@ discard block |
||
408 | 408 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
409 | 409 | PRIMARY KEY (QST_ID), |
410 | 410 | KEY QST_order (QST_order)'; |
411 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | - $table_name = 'esp_question_group_question'; |
|
413 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | + $table_name = 'esp_question_group_question'; |
|
413 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | 414 | QSG_ID int(10) unsigned NOT NULL, |
415 | 415 | QST_ID int(10) unsigned NOT NULL, |
416 | 416 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
417 | 417 | PRIMARY KEY (QGQ_ID), |
418 | 418 | KEY QST_ID (QST_ID), |
419 | 419 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | - $table_name = 'esp_question_option'; |
|
422 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | + $table_name = 'esp_question_option'; |
|
422 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
423 | 423 | QSO_value varchar(255) NOT NULL, |
424 | 424 | QSO_desc text NOT NULL, |
425 | 425 | QST_ID int(10) unsigned NOT NULL, |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | PRIMARY KEY (QSO_ID), |
430 | 430 | KEY QST_ID (QST_ID), |
431 | 431 | KEY QSO_order (QSO_order)"; |
432 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $table_name = 'esp_registration'; |
|
434 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_registration'; |
|
434 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | 435 | EVT_ID bigint(20) unsigned NOT NULL, |
436 | 436 | ATT_ID bigint(20) unsigned NOT NULL, |
437 | 437 | TXN_ID int(10) unsigned NOT NULL, |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | KEY TKT_ID (TKT_ID), |
456 | 456 | KEY EVT_ID (EVT_ID), |
457 | 457 | KEY STS_ID (STS_ID)"; |
458 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | - $table_name = 'esp_registration_payment'; |
|
460 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
458 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | + $table_name = 'esp_registration_payment'; |
|
460 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
461 | 461 | REG_ID int(10) unsigned NOT NULL, |
462 | 462 | PAY_ID int(10) unsigned NULL, |
463 | 463 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
464 | 464 | PRIMARY KEY (RPY_ID), |
465 | 465 | KEY REG_ID (REG_ID), |
466 | 466 | KEY PAY_ID (PAY_ID)"; |
467 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | - $table_name = 'esp_state'; |
|
469 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
467 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | + $table_name = 'esp_state'; |
|
469 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
470 | 470 | CNT_ISO varchar(2) NOT NULL, |
471 | 471 | STA_abbrev varchar(24) NOT NULL, |
472 | 472 | STA_name varchar(100) NOT NULL, |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | PRIMARY KEY (STA_ID), |
475 | 475 | KEY STA_abbrev (STA_abbrev), |
476 | 476 | KEY CNT_ISO (CNT_ISO)"; |
477 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | - $table_name = 'esp_status'; |
|
479 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
477 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | + $table_name = 'esp_status'; |
|
479 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
480 | 480 | STS_code varchar(45) NOT NULL, |
481 | 481 | STS_type varchar(45) NOT NULL, |
482 | 482 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
485 | 485 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
486 | 486 | KEY STS_type (STS_type)"; |
487 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - $table_name = 'esp_transaction'; |
|
489 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + $table_name = 'esp_transaction'; |
|
489 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
490 | 490 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
491 | 491 | TXN_total decimal(12,3) DEFAULT '0.00', |
492 | 492 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | PRIMARY KEY (TXN_ID), |
499 | 499 | KEY TXN_timestamp (TXN_timestamp), |
500 | 500 | KEY STS_ID (STS_ID)"; |
501 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | - $table_name = 'esp_venue_meta'; |
|
503 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
501 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | + $table_name = 'esp_venue_meta'; |
|
503 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
504 | 504 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
505 | 505 | VNU_address varchar(255) DEFAULT NULL, |
506 | 506 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | KEY VNU_ID (VNU_ID), |
520 | 520 | KEY STA_ID (STA_ID), |
521 | 521 | KEY CNT_ISO (CNT_ISO)"; |
522 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | - //modified tables |
|
524 | - $table_name = "esp_price"; |
|
525 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | + //modified tables |
|
524 | + $table_name = "esp_price"; |
|
525 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
526 | 526 | PRT_ID tinyint(3) unsigned NOT NULL, |
527 | 527 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
528 | 528 | PRC_name varchar(245) NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | PRC_parent int(10) unsigned DEFAULT 0, |
536 | 536 | PRIMARY KEY (PRC_ID), |
537 | 537 | KEY PRT_ID (PRT_ID)"; |
538 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | - $table_name = "esp_price_type"; |
|
540 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = "esp_price_type"; |
|
540 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | PRT_name varchar(45) NOT NULL, |
542 | 542 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
543 | 543 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
547 | 547 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
548 | 548 | PRIMARY KEY (PRT_ID)"; |
549 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | - $table_name = "esp_ticket"; |
|
551 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
549 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | + $table_name = "esp_ticket"; |
|
551 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
552 | 552 | TTM_ID int(10) unsigned NOT NULL, |
553 | 553 | TKT_name varchar(245) NOT NULL DEFAULT '', |
554 | 554 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
572 | 572 | PRIMARY KEY (TKT_ID), |
573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
574 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | - $table_name = 'esp_question_group'; |
|
576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
574 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | + $table_name = 'esp_question_group'; |
|
576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
577 | 577 | QSG_name varchar(255) NOT NULL, |
578 | 578 | QSG_identifier varchar(100) NOT NULL, |
579 | 579 | QSG_desc text NULL, |
@@ -586,138 +586,138 @@ discard block |
||
586 | 586 | PRIMARY KEY (QSG_ID), |
587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
588 | 588 | KEY QSG_order (QSG_order)'; |
589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | - //(because many need to convert old string states to foreign keys into the states table) |
|
593 | - $script_4_1_defaults->insert_default_states(); |
|
594 | - $script_4_1_defaults->insert_default_countries(); |
|
595 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | - $script_4_5_defaults->insert_default_price_types(); |
|
598 | - $script_4_5_defaults->insert_default_prices(); |
|
599 | - $script_4_5_defaults->insert_default_tickets(); |
|
600 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | - $script_4_6_defaults->insert_default_currencies(); |
|
604 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | - $script_4_8_defaults->verify_new_countries(); |
|
607 | - $script_4_8_defaults->verify_new_currencies(); |
|
608 | - $this->verify_db_collations(); |
|
609 | - $this->verify_db_collations_again(); |
|
610 | - return true; |
|
611 | - } |
|
589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | + //(because many need to convert old string states to foreign keys into the states table) |
|
593 | + $script_4_1_defaults->insert_default_states(); |
|
594 | + $script_4_1_defaults->insert_default_countries(); |
|
595 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | + $script_4_5_defaults->insert_default_price_types(); |
|
598 | + $script_4_5_defaults->insert_default_prices(); |
|
599 | + $script_4_5_defaults->insert_default_tickets(); |
|
600 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | + $script_4_6_defaults->insert_default_currencies(); |
|
604 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | + $script_4_8_defaults->verify_new_countries(); |
|
607 | + $script_4_8_defaults->verify_new_currencies(); |
|
608 | + $this->verify_db_collations(); |
|
609 | + $this->verify_db_collations_again(); |
|
610 | + return true; |
|
611 | + } |
|
612 | 612 | |
613 | 613 | |
614 | 614 | |
615 | - /** |
|
616 | - * @return boolean |
|
617 | - */ |
|
618 | - public function schema_changes_after_migration() |
|
619 | - { |
|
620 | - return true; |
|
621 | - } |
|
615 | + /** |
|
616 | + * @return boolean |
|
617 | + */ |
|
618 | + public function schema_changes_after_migration() |
|
619 | + { |
|
620 | + return true; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | |
624 | 624 | |
625 | - public function migration_page_hooks() |
|
626 | - { |
|
627 | - } |
|
625 | + public function migration_page_hooks() |
|
626 | + { |
|
627 | + } |
|
628 | 628 | |
629 | 629 | |
630 | 630 | |
631 | - /** |
|
632 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
633 | - * |
|
634 | - * @return void |
|
635 | - */ |
|
636 | - public function verify_db_collations() |
|
637 | - { |
|
638 | - if (get_option('ee_verified_db_collations', false)) { |
|
639 | - return; |
|
640 | - } |
|
641 | - // grab tables from each model |
|
642 | - $tables_to_check = array(); |
|
643 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
644 | - if (method_exists($model_name, 'instance')) { |
|
645 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
646 | - if ($model_obj instanceof EEM_Base) { |
|
647 | - foreach ($model_obj->get_tables() as $table) { |
|
648 | - if ( |
|
649 | - strpos($table->get_table_name(), 'esp_') |
|
650 | - && (is_main_site()//for main tables, verify global tables |
|
651 | - || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
652 | - ) |
|
653 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
654 | - ) { |
|
655 | - $tables_to_check[] = $table->get_table_name(); |
|
656 | - } |
|
657 | - } |
|
658 | - } |
|
659 | - } |
|
660 | - } |
|
661 | - //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
662 | - //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
663 | - //of hard-coding this |
|
664 | - $addon_tables = array( |
|
665 | - //mailchimp |
|
666 | - 'esp_event_mailchimp_list_group', |
|
667 | - 'esp_event_question_mailchimp_field', |
|
668 | - //multisite |
|
669 | - 'esp_blog_meta', |
|
670 | - //people |
|
671 | - 'esp_people_to_post', |
|
672 | - //promotions |
|
673 | - 'esp_promotion', |
|
674 | - 'esp_promotion_object', |
|
675 | - ); |
|
676 | - foreach ($addon_tables as $table_name) { |
|
677 | - $tables_to_check[] = $table_name; |
|
678 | - } |
|
679 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
680 | - //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
681 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
682 | - //seeing how this ran with the fix from 10435, no need to check again |
|
683 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
684 | - } |
|
631 | + /** |
|
632 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
633 | + * |
|
634 | + * @return void |
|
635 | + */ |
|
636 | + public function verify_db_collations() |
|
637 | + { |
|
638 | + if (get_option('ee_verified_db_collations', false)) { |
|
639 | + return; |
|
640 | + } |
|
641 | + // grab tables from each model |
|
642 | + $tables_to_check = array(); |
|
643 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
644 | + if (method_exists($model_name, 'instance')) { |
|
645 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
646 | + if ($model_obj instanceof EEM_Base) { |
|
647 | + foreach ($model_obj->get_tables() as $table) { |
|
648 | + if ( |
|
649 | + strpos($table->get_table_name(), 'esp_') |
|
650 | + && (is_main_site()//for main tables, verify global tables |
|
651 | + || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
652 | + ) |
|
653 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
654 | + ) { |
|
655 | + $tables_to_check[] = $table->get_table_name(); |
|
656 | + } |
|
657 | + } |
|
658 | + } |
|
659 | + } |
|
660 | + } |
|
661 | + //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
662 | + //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
663 | + //of hard-coding this |
|
664 | + $addon_tables = array( |
|
665 | + //mailchimp |
|
666 | + 'esp_event_mailchimp_list_group', |
|
667 | + 'esp_event_question_mailchimp_field', |
|
668 | + //multisite |
|
669 | + 'esp_blog_meta', |
|
670 | + //people |
|
671 | + 'esp_people_to_post', |
|
672 | + //promotions |
|
673 | + 'esp_promotion', |
|
674 | + 'esp_promotion_object', |
|
675 | + ); |
|
676 | + foreach ($addon_tables as $table_name) { |
|
677 | + $tables_to_check[] = $table_name; |
|
678 | + } |
|
679 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
680 | + //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
681 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
682 | + //seeing how this ran with the fix from 10435, no need to check again |
|
683 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
684 | + } |
|
685 | 685 | |
686 | 686 | |
687 | 687 | |
688 | - /** |
|
689 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
690 | - * which meant some DB collations might not have been updated |
|
691 | - * @return void |
|
692 | - */ |
|
693 | - public function verify_db_collations_again(){ |
|
694 | - if (get_option('ee_verified_db_collations_again', false)) { |
|
695 | - return; |
|
696 | - } |
|
697 | - $tables_to_check = array( |
|
698 | - 'esp_attendee_meta', |
|
699 | - 'esp_message' |
|
700 | - ); |
|
701 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
702 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
703 | - } |
|
688 | + /** |
|
689 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
690 | + * which meant some DB collations might not have been updated |
|
691 | + * @return void |
|
692 | + */ |
|
693 | + public function verify_db_collations_again(){ |
|
694 | + if (get_option('ee_verified_db_collations_again', false)) { |
|
695 | + return; |
|
696 | + } |
|
697 | + $tables_to_check = array( |
|
698 | + 'esp_attendee_meta', |
|
699 | + 'esp_message' |
|
700 | + ); |
|
701 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
702 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
703 | + } |
|
704 | 704 | |
705 | 705 | |
706 | 706 | |
707 | - /** |
|
708 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
709 | - * @param $tables_to_check |
|
710 | - * @return boolean true if logic ran, false if it didn't |
|
711 | - */ |
|
712 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
713 | - { |
|
714 | - foreach ($tables_to_check as $table_name) { |
|
715 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
716 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
717 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
718 | - ) { |
|
719 | - maybe_convert_table_to_utf8mb4($table_name); |
|
720 | - } |
|
721 | - } |
|
722 | - } |
|
707 | + /** |
|
708 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
709 | + * @param $tables_to_check |
|
710 | + * @return boolean true if logic ran, false if it didn't |
|
711 | + */ |
|
712 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
713 | + { |
|
714 | + foreach ($tables_to_check as $table_name) { |
|
715 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
716 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
717 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
718 | + ) { |
|
719 | + maybe_convert_table_to_utf8mb4($table_name); |
|
720 | + } |
|
721 | + } |
|
722 | + } |
|
723 | 723 | } |
724 | 724 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | 16 | foreach ($stages as $filepath) { |
17 | - $matches = array(); |
|
18 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | - $class_to_filepath[$matches[1]] = $filepath; |
|
17 | + $matches = array(); |
|
18 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | + $class_to_filepath[$matches[1]] = $filepath; |
|
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * return EE_DMS_Core_4_6_0 |
|
40 | - * |
|
41 | - * @param TableManager $table_manager |
|
42 | - * @param TableAnalysis $table_analysis |
|
43 | - */ |
|
44 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | - { |
|
46 | - $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | - $this->_priority = 10; |
|
48 | - $this->_migration_stages = array( |
|
49 | - new EE_DMS_4_6_0_gateways(), |
|
50 | - new EE_DMS_4_6_0_question_types(), |
|
51 | - new EE_DMS_4_6_0_country_system_question(), |
|
52 | - new EE_DMS_4_6_0_state_system_question(), |
|
53 | - new EE_DMS_4_6_0_billing_info(), |
|
54 | - new EE_DMS_4_6_0_transactions(), |
|
55 | - new EE_DMS_4_6_0_payments(), |
|
56 | - new EE_DMS_4_6_0_invoice_settings(), |
|
57 | - ); |
|
58 | - parent::__construct($table_manager, $table_analysis); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @param array $version_array |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function can_migrate_from_version($version_array) |
|
68 | - { |
|
69 | - $version_string = $version_array['Core']; |
|
70 | - if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
38 | + /** |
|
39 | + * return EE_DMS_Core_4_6_0 |
|
40 | + * |
|
41 | + * @param TableManager $table_manager |
|
42 | + * @param TableAnalysis $table_analysis |
|
43 | + */ |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | + { |
|
46 | + $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | + $this->_priority = 10; |
|
48 | + $this->_migration_stages = array( |
|
49 | + new EE_DMS_4_6_0_gateways(), |
|
50 | + new EE_DMS_4_6_0_question_types(), |
|
51 | + new EE_DMS_4_6_0_country_system_question(), |
|
52 | + new EE_DMS_4_6_0_state_system_question(), |
|
53 | + new EE_DMS_4_6_0_billing_info(), |
|
54 | + new EE_DMS_4_6_0_transactions(), |
|
55 | + new EE_DMS_4_6_0_payments(), |
|
56 | + new EE_DMS_4_6_0_invoice_settings(), |
|
57 | + ); |
|
58 | + parent::__construct($table_manager, $table_analysis); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @param array $version_array |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function can_migrate_from_version($version_array) |
|
68 | + { |
|
69 | + $version_string = $version_array['Core']; |
|
70 | + if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
71 | 71 | // echo "$version_string can be migrated from"; |
72 | - return true; |
|
73 | - } elseif ( ! $version_string) { |
|
72 | + return true; |
|
73 | + } elseif ( ! $version_string) { |
|
74 | 74 | // echo "no version string provided: $version_string"; |
75 | - //no version string provided... this must be pre 4.3 |
|
76 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | - } else { |
|
75 | + //no version string provided... this must be pre 4.3 |
|
76 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + } else { |
|
78 | 78 | // echo "$version_string doesnt apply"; |
79 | - return false; |
|
80 | - } |
|
81 | - } |
|
79 | + return false; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return bool |
|
87 | - */ |
|
88 | - public function schema_changes_before_migration() |
|
89 | - { |
|
90 | - //relies on 4.1's EEH_Activation::create_table |
|
91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | - $table_name = 'esp_answer'; |
|
93 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
85 | + /** |
|
86 | + * @return bool |
|
87 | + */ |
|
88 | + public function schema_changes_before_migration() |
|
89 | + { |
|
90 | + //relies on 4.1's EEH_Activation::create_table |
|
91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + $table_name = 'esp_answer'; |
|
93 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | 94 | REG_ID INT UNSIGNED NOT NULL, |
95 | 95 | QST_ID INT UNSIGNED NOT NULL, |
96 | 96 | ANS_value TEXT NOT NULL, |
97 | 97 | PRIMARY KEY (ANS_ID)"; |
98 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | - $table_name = 'esp_attendee_meta'; |
|
100 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
98 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | + $table_name = 'esp_attendee_meta'; |
|
100 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
101 | 101 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
102 | 102 | ATT_fname VARCHAR(45) NOT NULL, |
103 | 103 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | KEY ATT_fname (ATT_fname), |
114 | 114 | KEY ATT_lname (ATT_lname), |
115 | 115 | KEY ATT_email (ATT_email)"; |
116 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
116 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
119 | 119 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
120 | 120 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
121 | 121 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | CNT_is_EU TINYINT(1) DEFAULT '0', |
132 | 132 | CNT_active TINYINT(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | - $table_name = 'esp_currency'; |
|
136 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | + $table_name = 'esp_currency'; |
|
136 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
137 | 137 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
138 | 138 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
139 | 139 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
140 | 140 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
141 | 141 | CUR_active TINYINT(1) DEFAULT '0', |
142 | 142 | PRIMARY KEY (CUR_code)"; |
143 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | - $table_name = 'esp_currency_payment_method'; |
|
145 | - $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
143 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | + $table_name = 'esp_currency_payment_method'; |
|
145 | + $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
146 | 146 | CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
147 | 147 | PMD_ID INT(11) NOT NULL, |
148 | 148 | PRIMARY KEY (CPM_ID)"; |
149 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | - $table_name = 'esp_datetime'; |
|
151 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
149 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | + $table_name = 'esp_datetime'; |
|
151 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
152 | 152 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
153 | 153 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
154 | 154 | DTT_description TEXT NOT NULL, |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | PRIMARY KEY (DTT_ID), |
164 | 164 | KEY EVT_ID (EVT_ID), |
165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
166 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | - $table_name = 'esp_event_meta'; |
|
168 | - $sql = " |
|
166 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | + $table_name = 'esp_event_meta'; |
|
168 | + $sql = " |
|
169 | 169 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
170 | 170 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
171 | 171 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -180,31 +180,31 @@ discard block |
||
180 | 180 | EVT_external_URL VARCHAR(200) NULL, |
181 | 181 | EVT_donations TINYINT(1) NULL, |
182 | 182 | PRIMARY KEY (EVTM_ID)"; |
183 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | - $table_name = 'esp_event_question_group'; |
|
185 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | + $table_name = 'esp_event_question_group'; |
|
185 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
186 | 186 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
187 | 187 | QSG_ID INT UNSIGNED NOT NULL, |
188 | 188 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
189 | 189 | PRIMARY KEY (EQG_ID)"; |
190 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | - $table_name = 'esp_event_venue'; |
|
192 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
190 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | + $table_name = 'esp_event_venue'; |
|
192 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
193 | 193 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
194 | 194 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
195 | 195 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
196 | 196 | PRIMARY KEY (EVV_ID)"; |
197 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_extra_meta'; |
|
199 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_extra_meta'; |
|
199 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | OBJ_ID INT(11) DEFAULT NULL, |
201 | 201 | EXM_type VARCHAR(45) DEFAULT NULL, |
202 | 202 | EXM_key VARCHAR(45) DEFAULT NULL, |
203 | 203 | EXM_value TEXT, |
204 | 204 | PRIMARY KEY (EXM_ID)"; |
205 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | - $table_name = 'esp_line_item'; |
|
207 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
205 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | + $table_name = 'esp_line_item'; |
|
207 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
208 | 208 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
209 | 209 | TXN_ID INT(11) DEFAULT NULL, |
210 | 210 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | OBJ_ID INT(11) DEFAULT NULL, |
221 | 221 | OBJ_type VARCHAR(45)DEFAULT NULL, |
222 | 222 | PRIMARY KEY (LIN_ID)"; |
223 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_log'; |
|
225 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_log'; |
|
225 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | LOG_time DATETIME DEFAULT NULL, |
227 | 227 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
228 | 228 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -230,19 +230,19 @@ discard block |
||
230 | 230 | LOG_message TEXT, |
231 | 231 | LOG_wp_user INT(11) DEFAULT NULL, |
232 | 232 | PRIMARY KEY (LOG_ID)"; |
233 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | - $table_name = 'esp_message_template'; |
|
235 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
233 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $table_name = 'esp_message_template'; |
|
235 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
236 | 236 | GRP_ID INT(10) UNSIGNED NOT NULL, |
237 | 237 | MTP_context VARCHAR(50) NOT NULL, |
238 | 238 | MTP_template_field VARCHAR(30) NOT NULL, |
239 | 239 | MTP_content TEXT NOT NULL, |
240 | 240 | PRIMARY KEY (MTP_ID), |
241 | 241 | KEY GRP_ID (GRP_ID)"; |
242 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | - $table_name = 'esp_message_template_group'; |
|
245 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
242 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | + $table_name = 'esp_message_template_group'; |
|
245 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
246 | 246 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
247 | 247 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
248 | 248 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
255 | 255 | PRIMARY KEY (GRP_ID), |
256 | 256 | KEY MTP_user_id (MTP_user_id)"; |
257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | - $table_name = 'esp_event_message_template'; |
|
259 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | + $table_name = 'esp_event_message_template'; |
|
259 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
260 | 260 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
261 | 261 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
262 | 262 | PRIMARY KEY (EMT_ID), |
263 | 263 | KEY EVT_ID (EVT_ID), |
264 | 264 | KEY GRP_ID (GRP_ID)"; |
265 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | - $table_name = 'esp_payment'; |
|
267 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
265 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | + $table_name = 'esp_payment'; |
|
267 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
268 | 268 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
269 | 269 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
270 | 270 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | PRIMARY KEY (PAY_ID), |
282 | 282 | KEY TXN_ID (TXN_ID), |
283 | 283 | KEY PAY_timestamp (PAY_timestamp)"; |
284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | - $table_name = 'esp_payment_method'; |
|
286 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | + $table_name = 'esp_payment_method'; |
|
286 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
287 | 287 | PMD_type VARCHAR(124) DEFAULT NULL, |
288 | 288 | PMD_name VARCHAR(255) DEFAULT NULL, |
289 | 289 | PMD_desc TEXT, |
@@ -298,28 +298,28 @@ discard block |
||
298 | 298 | PMD_scope VARCHAR(255) NULL DEFAULT 'frontend', |
299 | 299 | PRIMARY KEY (PMD_ID), |
300 | 300 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | - $table_name = "esp_ticket_price"; |
|
303 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | + $table_name = "esp_ticket_price"; |
|
303 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
304 | 304 | TKT_ID INT(10) UNSIGNED NOT NULL, |
305 | 305 | PRC_ID INT(10) UNSIGNED NOT NULL, |
306 | 306 | PRIMARY KEY (TKP_ID)"; |
307 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | - $table_name = "esp_datetime_ticket"; |
|
309 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
307 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | + $table_name = "esp_datetime_ticket"; |
|
309 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
310 | 310 | DTT_ID INT(10) UNSIGNED NOT NULL, |
311 | 311 | TKT_ID INT(10) UNSIGNED NOT NULL, |
312 | 312 | PRIMARY KEY (DTK_ID)"; |
313 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | - $table_name = "esp_ticket_template"; |
|
315 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
313 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | + $table_name = "esp_ticket_template"; |
|
315 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
316 | 316 | TTM_name VARCHAR(45) NOT NULL, |
317 | 317 | TTM_description TEXT, |
318 | 318 | TTM_file VARCHAR(45), |
319 | 319 | PRIMARY KEY (TTM_ID)"; |
320 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_question'; |
|
322 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_question'; |
|
322 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
323 | 323 | QST_display_text TEXT NOT NULL, |
324 | 324 | QST_admin_label VARCHAR(255) NOT NULL, |
325 | 325 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -331,25 +331,25 @@ discard block |
||
331 | 331 | QST_wp_user BIGINT UNSIGNED NULL, |
332 | 332 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
333 | 333 | PRIMARY KEY (QST_ID)'; |
334 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | - $table_name = 'esp_question_group_question'; |
|
336 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
334 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | + $table_name = 'esp_question_group_question'; |
|
336 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
337 | 337 | QSG_ID INT UNSIGNED NOT NULL, |
338 | 338 | QST_ID INT UNSIGNED NOT NULL, |
339 | 339 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
340 | 340 | PRIMARY KEY (QGQ_ID) "; |
341 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_question_option'; |
|
343 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
341 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_question_option'; |
|
343 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
344 | 344 | QSO_value VARCHAR(255) NOT NULL, |
345 | 345 | QSO_desc TEXT NOT NULL, |
346 | 346 | QST_ID INT UNSIGNED NOT NULL, |
347 | 347 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
348 | 348 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
349 | 349 | PRIMARY KEY (QSO_ID)"; |
350 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | - $table_name = 'esp_registration'; |
|
352 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_registration'; |
|
352 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
353 | 353 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
354 | 354 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
355 | 355 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | KEY STS_ID (STS_ID), |
373 | 373 | KEY REG_url_link (REG_url_link), |
374 | 374 | KEY REG_code (REG_code)"; |
375 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | - $table_name = 'esp_checkin'; |
|
377 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | + $table_name = 'esp_checkin'; |
|
377 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
378 | 378 | REG_ID INT(10) UNSIGNED NOT NULL, |
379 | 379 | DTT_ID INT(10) UNSIGNED NOT NULL, |
380 | 380 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
381 | 381 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
382 | 382 | PRIMARY KEY (CHK_ID)"; |
383 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_state'; |
|
385 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_state'; |
|
385 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
386 | 386 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
387 | 387 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
388 | 388 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
389 | 389 | STA_active TINYINT(1) DEFAULT '1', |
390 | 390 | PRIMARY KEY (STA_ID)"; |
391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_status'; |
|
393 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_status'; |
|
393 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
394 | 394 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
395 | 395 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
396 | 396 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
399 | 399 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
400 | 400 | KEY STS_type (STS_type)"; |
401 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | - $table_name = 'esp_transaction'; |
|
403 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
401 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | + $table_name = 'esp_transaction'; |
|
403 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
404 | 404 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
405 | 405 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
406 | 406 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | PRIMARY KEY (TXN_ID), |
413 | 413 | KEY TXN_timestamp (TXN_timestamp), |
414 | 414 | KEY STS_ID (STS_ID)"; |
415 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | - $table_name = 'esp_venue_meta'; |
|
417 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_venue_meta'; |
|
417 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
418 | 418 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
419 | 419 | VNU_address VARCHAR(255) DEFAULT NULL, |
420 | 420 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | PRIMARY KEY (VNUM_ID), |
433 | 433 | KEY STA_ID (STA_ID), |
434 | 434 | KEY CNT_ISO (CNT_ISO)"; |
435 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | - //modified tables |
|
437 | - $table_name = "esp_price"; |
|
438 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
435 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | + //modified tables |
|
437 | + $table_name = "esp_price"; |
|
438 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
439 | 439 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
440 | 440 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
441 | 441 | PRC_name VARCHAR(245) NOT NULL, |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | PRC_wp_user BIGINT UNSIGNED NULL, |
448 | 448 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
449 | 449 | PRIMARY KEY (PRC_ID)"; |
450 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | - $table_name = "esp_price_type"; |
|
452 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
450 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | + $table_name = "esp_price_type"; |
|
452 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
453 | 453 | PRT_name VARCHAR(45) NOT NULL, |
454 | 454 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
455 | 455 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
459 | 459 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
460 | 460 | PRIMARY KEY (PRT_ID)"; |
461 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | - $table_name = "esp_ticket"; |
|
463 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
461 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | + $table_name = "esp_ticket"; |
|
463 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
464 | 464 | TTM_ID INT(10) UNSIGNED NOT NULL, |
465 | 465 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
466 | 466 | TKT_description TEXT NOT NULL, |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
482 | 482 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
483 | 483 | PRIMARY KEY (TKT_ID)"; |
484 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | - $table_name = 'esp_question_group'; |
|
487 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
484 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | + $table_name = 'esp_question_group'; |
|
487 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
488 | 488 | QSG_name VARCHAR(255) NOT NULL, |
489 | 489 | QSG_identifier VARCHAR(100) NOT NULL, |
490 | 490 | QSG_desc TEXT NULL, |
@@ -496,119 +496,119 @@ discard block |
||
496 | 496 | QSG_wp_user BIGINT UNSIGNED NULL, |
497 | 497 | PRIMARY KEY (QSG_ID), |
498 | 498 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
499 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | - //(because many need to convert old string states to foreign keys into the states table) |
|
503 | - $script_4_1_defaults->insert_default_states(); |
|
504 | - $script_4_1_defaults->insert_default_countries(); |
|
505 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | - $script_4_5_defaults->insert_default_price_types(); |
|
508 | - $script_4_5_defaults->insert_default_prices(); |
|
509 | - $script_4_5_defaults->insert_default_tickets(); |
|
510 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | - EE_Config::instance()->update_espresso_config(false, true); |
|
512 | - $this->add_default_admin_only_payments(); |
|
513 | - $this->insert_default_currencies(); |
|
514 | - return true; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * @return boolean |
|
521 | - */ |
|
522 | - public function schema_changes_after_migration() |
|
523 | - { |
|
524 | - return true; |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - public function migration_page_hooks() |
|
530 | - { |
|
531 | - } |
|
532 | - |
|
533 | - |
|
534 | - |
|
535 | - public function add_default_admin_only_payments() |
|
536 | - { |
|
537 | - global $wpdb; |
|
538 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | - $default_admin_only_payment_methods = apply_filters( |
|
544 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | - array( |
|
546 | - __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | - __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | - __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | - __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | - __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | - __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | - 'event_espresso'), |
|
553 | - __("Money Order", 'event_espresso') => '', |
|
554 | - __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | - __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | - )); |
|
557 | - //make sure we hae payment method records for the following |
|
558 | - //so admins can record payments for them from the admin page |
|
559 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | - $slug = sanitize_key($nicename); |
|
561 | - //check that such a payment method exists |
|
562 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | - if ( ! $exists) { |
|
564 | - $values = array( |
|
565 | - 'PMD_type' => 'Admin_Only', |
|
566 | - 'PMD_name' => $nicename, |
|
567 | - 'PMD_admin_name' => $nicename, |
|
568 | - 'PMD_admin_desc' => $description, |
|
569 | - 'PMD_slug' => $slug, |
|
570 | - 'PMD_wp_user' => $user_id, |
|
571 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | - ); |
|
573 | - $success = $wpdb->insert( |
|
574 | - $table_name, |
|
575 | - $values, |
|
576 | - array( |
|
577 | - '%s',//PMD_type |
|
578 | - '%s',//PMD_name |
|
579 | - '%s',//PMD_admin_name |
|
580 | - '%s',//PMD_admin_desc |
|
581 | - '%s',//PMD_slug |
|
582 | - '%d',//PMD_wp_user |
|
583 | - '%s',//PMD_scope |
|
584 | - ) |
|
585 | - ); |
|
586 | - if ( ! $success) { |
|
587 | - $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | - "event_espresso"), $this->_json_encode($values))); |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * insert_default_countries |
|
599 | - * |
|
600 | - * @static |
|
601 | - * @return void |
|
602 | - */ |
|
603 | - public function insert_default_currencies() |
|
604 | - { |
|
605 | - global $wpdb; |
|
606 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | - $countries = $wpdb->get_var($SQL); |
|
610 | - if ( ! $countries) { |
|
611 | - $SQL = "INSERT INTO $currency_table |
|
499 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | + //(because many need to convert old string states to foreign keys into the states table) |
|
503 | + $script_4_1_defaults->insert_default_states(); |
|
504 | + $script_4_1_defaults->insert_default_countries(); |
|
505 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | + $script_4_5_defaults->insert_default_price_types(); |
|
508 | + $script_4_5_defaults->insert_default_prices(); |
|
509 | + $script_4_5_defaults->insert_default_tickets(); |
|
510 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | + EE_Config::instance()->update_espresso_config(false, true); |
|
512 | + $this->add_default_admin_only_payments(); |
|
513 | + $this->insert_default_currencies(); |
|
514 | + return true; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * @return boolean |
|
521 | + */ |
|
522 | + public function schema_changes_after_migration() |
|
523 | + { |
|
524 | + return true; |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + public function migration_page_hooks() |
|
530 | + { |
|
531 | + } |
|
532 | + |
|
533 | + |
|
534 | + |
|
535 | + public function add_default_admin_only_payments() |
|
536 | + { |
|
537 | + global $wpdb; |
|
538 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | + $default_admin_only_payment_methods = apply_filters( |
|
544 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | + array( |
|
546 | + __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | + __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | + __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | + __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | + __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | + __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | + 'event_espresso'), |
|
553 | + __("Money Order", 'event_espresso') => '', |
|
554 | + __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | + __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | + )); |
|
557 | + //make sure we hae payment method records for the following |
|
558 | + //so admins can record payments for them from the admin page |
|
559 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | + $slug = sanitize_key($nicename); |
|
561 | + //check that such a payment method exists |
|
562 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | + if ( ! $exists) { |
|
564 | + $values = array( |
|
565 | + 'PMD_type' => 'Admin_Only', |
|
566 | + 'PMD_name' => $nicename, |
|
567 | + 'PMD_admin_name' => $nicename, |
|
568 | + 'PMD_admin_desc' => $description, |
|
569 | + 'PMD_slug' => $slug, |
|
570 | + 'PMD_wp_user' => $user_id, |
|
571 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | + ); |
|
573 | + $success = $wpdb->insert( |
|
574 | + $table_name, |
|
575 | + $values, |
|
576 | + array( |
|
577 | + '%s',//PMD_type |
|
578 | + '%s',//PMD_name |
|
579 | + '%s',//PMD_admin_name |
|
580 | + '%s',//PMD_admin_desc |
|
581 | + '%s',//PMD_slug |
|
582 | + '%d',//PMD_wp_user |
|
583 | + '%s',//PMD_scope |
|
584 | + ) |
|
585 | + ); |
|
586 | + if ( ! $success) { |
|
587 | + $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | + "event_espresso"), $this->_json_encode($values))); |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * insert_default_countries |
|
599 | + * |
|
600 | + * @static |
|
601 | + * @return void |
|
602 | + */ |
|
603 | + public function insert_default_currencies() |
|
604 | + { |
|
605 | + global $wpdb; |
|
606 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | + $countries = $wpdb->get_var($SQL); |
|
610 | + if ( ! $countries) { |
|
611 | + $SQL = "INSERT INTO $currency_table |
|
612 | 612 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
613 | 613 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
614 | 614 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -762,10 +762,10 @@ discard block |
||
762 | 762 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
763 | 763 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
764 | 764 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
765 | - $wpdb->query($SQL); |
|
766 | - } |
|
767 | - } |
|
768 | - } |
|
765 | + $wpdb->query($SQL); |
|
766 | + } |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
771 | 771 |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @param array $query_params like EEM_Base::get_all |
207 | 207 | * @param string $field_to_sum |
208 | - * @return int |
|
208 | + * @return double |
|
209 | 209 | */ |
210 | 210 | public function sum_deleted($query_params = null, $field_to_sum = null) |
211 | 211 | { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
271 | 271 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
272 | 272 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
273 | - * @return boolean success |
|
273 | + * @return integer success |
|
274 | 274 | */ |
275 | 275 | public function delete_permanently($query_params = array(), $allow_blocking = true) |
276 | 276 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -32,362 +32,362 @@ discard block |
||
32 | 32 | abstract class EEM_Soft_Delete_Base extends EEM_Base |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @param null $timezone |
|
37 | - */ |
|
38 | - protected function __construct($timezone = null) |
|
39 | - { |
|
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | - $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | - } |
|
43 | - parent::__construct($timezone); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | - * returns it's name. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public function deleted_field_name() |
|
56 | - { |
|
57 | - $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | - if ($field) { |
|
59 | - return $field->get_name(); |
|
60 | - } else { |
|
61 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | - 'event_espresso'), get_class($this), get_class($this))); |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Gets one item that's been deleted, according to $query_params |
|
70 | - * |
|
71 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | - * @return EE_Soft_Delete_Base_Class |
|
73 | - */ |
|
74 | - public function get_one_deleted($query_params = array()) |
|
75 | - { |
|
76 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | - return parent::get_one($query_params); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | - * |
|
85 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | - * @return EE_Soft_Delete_Base_Class |
|
87 | - */ |
|
88 | - public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | - { |
|
90 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | - return parent::get_one($query_params); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | - * |
|
99 | - * @param int|string $id |
|
100 | - * @return EE_Soft_Delete_Base_Class |
|
101 | - */ |
|
102 | - public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | - { |
|
104 | - return $this->get_one( |
|
105 | - $this->alter_query_params_to_restrict_by_ID( |
|
106 | - $id, |
|
107 | - array('default_where_conditions' => 'default') |
|
108 | - ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Counts all the deleted/trashed items |
|
116 | - * |
|
117 | - * @param array $query_params like EEM_Base::get_all |
|
118 | - * @param string $field_to_count |
|
119 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | - { |
|
124 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | - return parent::count($query_params, $field_to_count, $distinct); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | - * |
|
133 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | - * @return array like EEM_Base::get_all's $query_params |
|
135 | - */ |
|
136 | - protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | - { |
|
138 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | - $query_params[0][$deletedFlagFieldName] = true; |
|
140 | - return $query_params; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | - * |
|
148 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | - * @return array like EEM_Base::get_all's $query_params |
|
150 | - */ |
|
151 | - public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | - { |
|
153 | - return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Alters the query params so each item's deleted status is ignored. |
|
160 | - * |
|
161 | - * @param array $query_params |
|
162 | - * @return array |
|
163 | - */ |
|
164 | - public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | - { |
|
166 | - return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Alters the query params so each item's deleted status is ignored. |
|
173 | - * |
|
174 | - * @param array $query_params |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | - { |
|
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
180 | - $query_params['default_where_conditions'] = 'minimum'; |
|
181 | - } |
|
182 | - return $query_params; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Counts all deleted and undeleted items |
|
189 | - * |
|
190 | - * @param array $query_params like EEM_Base::get_all |
|
191 | - * @param string $field_to_count |
|
192 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | - * @return int |
|
194 | - */ |
|
195 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | - { |
|
197 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | - return parent::count($query_params, $field_to_count, $distinct); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Sum all the deleted items. |
|
205 | - * |
|
206 | - * @param array $query_params like EEM_Base::get_all |
|
207 | - * @param string $field_to_sum |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | - { |
|
212 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | - return parent::sum($query_params, $field_to_sum); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * Sums all the deleted and undeleted items. |
|
220 | - * |
|
221 | - * @param array $query_params lik eEEM_Base::get_all |
|
222 | - * @param string $field_to_sum |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | - { |
|
227 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | - parent::sum($query_params, $field_to_sum); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | - * whether they've been soft-deleted or not |
|
236 | - * |
|
237 | - * @param array $query_params like EEM_Base::get_all |
|
238 | - * @return EE_Soft_Delete_Base_Class[] |
|
239 | - */ |
|
240 | - public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | - { |
|
242 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | - return parent::get_all($query_params); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | - * |
|
251 | - * @param array $query_params like EEM_Base::get_all |
|
252 | - * @return EE_Soft_Delete_Base_Class[] |
|
253 | - */ |
|
254 | - public function get_all_deleted($query_params = array()) |
|
255 | - { |
|
256 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | - return parent::get_all($query_params); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | - * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | - * before you can permanently delete them). |
|
266 | - * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | - * and abort the delete) |
|
268 | - * |
|
269 | - * @param array $query_params like EEM_Base::get_all |
|
270 | - * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | - * @return boolean success |
|
274 | - */ |
|
275 | - public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | - { |
|
277 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | - return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | - * has been soft-deleted or not. |
|
286 | - * |
|
287 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | - * @return boolean success |
|
289 | - */ |
|
290 | - public function restore_by_ID($ID = false) |
|
291 | - { |
|
292 | - return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | - * this function will ignore whether the items have been soft-deleted or not. |
|
300 | - * |
|
301 | - * @param boolean $delete true for delete, false for restore |
|
302 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | - * @return boolean |
|
304 | - */ |
|
305 | - public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | - { |
|
307 | - if (! $ID) { |
|
308 | - return false; |
|
309 | - } |
|
310 | - if ( |
|
311 | - $this->delete_or_restore( |
|
312 | - $delete, |
|
313 | - $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - return true; |
|
317 | - } else { |
|
318 | - return false; |
|
319 | - } |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | - * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | - * Note: because this item will be soft-deleted only, |
|
328 | - * doesn't block because of model dependencies |
|
329 | - * |
|
330 | - * @param array $query_params like EEM_Base::get_all |
|
331 | - * @param bool $block_deletes |
|
332 | - * @return boolean |
|
333 | - */ |
|
334 | - public function delete($query_params = array(), $block_deletes = false) |
|
335 | - { |
|
336 | - //no matter what, we WON'T block soft deletes. |
|
337 | - return $this->delete_or_restore(true, $query_params); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | - * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | - * |
|
346 | - * @param array $query_params like EEM_Base::get_all |
|
347 | - * @return boolean |
|
348 | - */ |
|
349 | - public function restore($query_params = array()) |
|
350 | - { |
|
351 | - return $this->delete_or_restore(false, $query_params); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | - * |
|
359 | - * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | - * @param array $query_params like EEM_Base::get_all |
|
361 | - * @return boolean |
|
362 | - */ |
|
363 | - function delete_or_restore($delete = true, $query_params = array()) |
|
364 | - { |
|
365 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | - if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | - return true; |
|
369 | - } else { |
|
370 | - return false; |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | - * they've been soft-deleted or not |
|
379 | - * |
|
380 | - * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | - * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | - * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | - * be aware that model objects being used could get out-of-sync with the database |
|
386 | - * @return int number of items updated |
|
387 | - */ |
|
388 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | - { |
|
390 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | - } |
|
35 | + /** |
|
36 | + * @param null $timezone |
|
37 | + */ |
|
38 | + protected function __construct($timezone = null) |
|
39 | + { |
|
40 | + if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | + $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | + } |
|
43 | + parent::__construct($timezone); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | + * returns it's name. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public function deleted_field_name() |
|
56 | + { |
|
57 | + $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | + if ($field) { |
|
59 | + return $field->get_name(); |
|
60 | + } else { |
|
61 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | + 'event_espresso'), get_class($this), get_class($this))); |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Gets one item that's been deleted, according to $query_params |
|
70 | + * |
|
71 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | + * @return EE_Soft_Delete_Base_Class |
|
73 | + */ |
|
74 | + public function get_one_deleted($query_params = array()) |
|
75 | + { |
|
76 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | + return parent::get_one($query_params); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | + * |
|
85 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | + * @return EE_Soft_Delete_Base_Class |
|
87 | + */ |
|
88 | + public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | + { |
|
90 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | + return parent::get_one($query_params); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | + * |
|
99 | + * @param int|string $id |
|
100 | + * @return EE_Soft_Delete_Base_Class |
|
101 | + */ |
|
102 | + public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | + { |
|
104 | + return $this->get_one( |
|
105 | + $this->alter_query_params_to_restrict_by_ID( |
|
106 | + $id, |
|
107 | + array('default_where_conditions' => 'default') |
|
108 | + ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Counts all the deleted/trashed items |
|
116 | + * |
|
117 | + * @param array $query_params like EEM_Base::get_all |
|
118 | + * @param string $field_to_count |
|
119 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | + { |
|
124 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | + return parent::count($query_params, $field_to_count, $distinct); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | + * |
|
133 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | + * @return array like EEM_Base::get_all's $query_params |
|
135 | + */ |
|
136 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | + { |
|
138 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | + $query_params[0][$deletedFlagFieldName] = true; |
|
140 | + return $query_params; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | + * |
|
148 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | + * @return array like EEM_Base::get_all's $query_params |
|
150 | + */ |
|
151 | + public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | + { |
|
153 | + return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Alters the query params so each item's deleted status is ignored. |
|
160 | + * |
|
161 | + * @param array $query_params |
|
162 | + * @return array |
|
163 | + */ |
|
164 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | + { |
|
166 | + return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Alters the query params so each item's deleted status is ignored. |
|
173 | + * |
|
174 | + * @param array $query_params |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | + { |
|
179 | + if (! isset($query_params['default_where_conditions'])) { |
|
180 | + $query_params['default_where_conditions'] = 'minimum'; |
|
181 | + } |
|
182 | + return $query_params; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Counts all deleted and undeleted items |
|
189 | + * |
|
190 | + * @param array $query_params like EEM_Base::get_all |
|
191 | + * @param string $field_to_count |
|
192 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | + * @return int |
|
194 | + */ |
|
195 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | + { |
|
197 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | + return parent::count($query_params, $field_to_count, $distinct); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Sum all the deleted items. |
|
205 | + * |
|
206 | + * @param array $query_params like EEM_Base::get_all |
|
207 | + * @param string $field_to_sum |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | + { |
|
212 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | + return parent::sum($query_params, $field_to_sum); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * Sums all the deleted and undeleted items. |
|
220 | + * |
|
221 | + * @param array $query_params lik eEEM_Base::get_all |
|
222 | + * @param string $field_to_sum |
|
223 | + * @return int |
|
224 | + */ |
|
225 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | + { |
|
227 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | + parent::sum($query_params, $field_to_sum); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | + * whether they've been soft-deleted or not |
|
236 | + * |
|
237 | + * @param array $query_params like EEM_Base::get_all |
|
238 | + * @return EE_Soft_Delete_Base_Class[] |
|
239 | + */ |
|
240 | + public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | + { |
|
242 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | + return parent::get_all($query_params); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | + * |
|
251 | + * @param array $query_params like EEM_Base::get_all |
|
252 | + * @return EE_Soft_Delete_Base_Class[] |
|
253 | + */ |
|
254 | + public function get_all_deleted($query_params = array()) |
|
255 | + { |
|
256 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | + return parent::get_all($query_params); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | + * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | + * before you can permanently delete them). |
|
266 | + * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | + * and abort the delete) |
|
268 | + * |
|
269 | + * @param array $query_params like EEM_Base::get_all |
|
270 | + * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | + * @return boolean success |
|
274 | + */ |
|
275 | + public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | + { |
|
277 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | + return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | + * has been soft-deleted or not. |
|
286 | + * |
|
287 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | + * @return boolean success |
|
289 | + */ |
|
290 | + public function restore_by_ID($ID = false) |
|
291 | + { |
|
292 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | + * this function will ignore whether the items have been soft-deleted or not. |
|
300 | + * |
|
301 | + * @param boolean $delete true for delete, false for restore |
|
302 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | + * @return boolean |
|
304 | + */ |
|
305 | + public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | + { |
|
307 | + if (! $ID) { |
|
308 | + return false; |
|
309 | + } |
|
310 | + if ( |
|
311 | + $this->delete_or_restore( |
|
312 | + $delete, |
|
313 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + return true; |
|
317 | + } else { |
|
318 | + return false; |
|
319 | + } |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | + * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | + * Note: because this item will be soft-deleted only, |
|
328 | + * doesn't block because of model dependencies |
|
329 | + * |
|
330 | + * @param array $query_params like EEM_Base::get_all |
|
331 | + * @param bool $block_deletes |
|
332 | + * @return boolean |
|
333 | + */ |
|
334 | + public function delete($query_params = array(), $block_deletes = false) |
|
335 | + { |
|
336 | + //no matter what, we WON'T block soft deletes. |
|
337 | + return $this->delete_or_restore(true, $query_params); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | + * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | + * |
|
346 | + * @param array $query_params like EEM_Base::get_all |
|
347 | + * @return boolean |
|
348 | + */ |
|
349 | + public function restore($query_params = array()) |
|
350 | + { |
|
351 | + return $this->delete_or_restore(false, $query_params); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | + * |
|
359 | + * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | + * @param array $query_params like EEM_Base::get_all |
|
361 | + * @return boolean |
|
362 | + */ |
|
363 | + function delete_or_restore($delete = true, $query_params = array()) |
|
364 | + { |
|
365 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | + if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | + return true; |
|
369 | + } else { |
|
370 | + return false; |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | + * they've been soft-deleted or not |
|
379 | + * |
|
380 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | + * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | + * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | + * be aware that model objects being used could get out-of-sync with the database |
|
386 | + * @return int number of items updated |
|
387 | + */ |
|
388 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | + { |
|
390 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | + } |
|
393 | 393 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function __construct($timezone = null) |
39 | 39 | { |
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
40 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | 41 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
42 | 42 | } |
43 | 43 | parent::__construct($timezone); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
178 | 178 | { |
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
179 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
180 | 180 | $query_params['default_where_conditions'] = 'minimum'; |
181 | 181 | } |
182 | 182 | return $query_params; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function delete_or_restore_by_ID($delete = true, $ID = false) |
306 | 306 | { |
307 | - if (! $ID) { |
|
307 | + if ( ! $ID) { |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | if ( |