@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | /** |
580 | 580 | * returns any events attached to this attendee ($_Event property); |
581 | 581 | * |
582 | - * @return array |
|
582 | + * @return EE_Base_Class[] |
|
583 | 583 | */ |
584 | 584 | public function events() |
585 | 585 | { |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * used to save the billing info |
595 | 595 | * |
596 | 596 | * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
597 | - * @return EE_Form_Section_Proper|null |
|
597 | + * @return null|EE_Billing_Info_Form |
|
598 | 598 | */ |
599 | 599 | public function billing_info_for_payment_method($payment_method) |
600 | 600 | { |
@@ -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 | /** |
5 | 5 | * Event Espresso |
@@ -24,671 +24,671 @@ discard block |
||
24 | 24 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * Sets some dynamic defaults |
|
29 | - * |
|
30 | - * @param array $fieldValues |
|
31 | - * @param bool $bydb |
|
32 | - * @param string $timezone |
|
33 | - * @param array $date_formats |
|
34 | - */ |
|
35 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
36 | - { |
|
37 | - if ( ! isset($fieldValues['ATT_full_name'])) { |
|
38 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
39 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
40 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
41 | - } |
|
42 | - if ( ! isset($fieldValues['ATT_slug'])) { |
|
43 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
44 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
45 | - } |
|
46 | - if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
47 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
48 | - } |
|
49 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Set Attendee First Name |
|
56 | - * |
|
57 | - * @access public |
|
58 | - * @param string $fname |
|
59 | - */ |
|
60 | - public function set_fname($fname = '') |
|
61 | - { |
|
62 | - $this->set('ATT_fname', $fname); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Set Attendee Last Name |
|
69 | - * |
|
70 | - * @access public |
|
71 | - * @param string $lname |
|
72 | - */ |
|
73 | - public function set_lname($lname = '') |
|
74 | - { |
|
75 | - $this->set('ATT_lname', $lname); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * Set Attendee Address |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @param string $address |
|
85 | - */ |
|
86 | - public function set_address($address = '') |
|
87 | - { |
|
88 | - $this->set('ATT_address', $address); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Set Attendee Address2 |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @param string $address2 |
|
98 | - */ |
|
99 | - public function set_address2($address2 = '') |
|
100 | - { |
|
101 | - $this->set('ATT_address2', $address2); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * Set Attendee City |
|
108 | - * |
|
109 | - * @access public |
|
110 | - * @param string $city |
|
111 | - */ |
|
112 | - public function set_city($city = '') |
|
113 | - { |
|
114 | - $this->set('ATT_city', $city); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * Set Attendee State ID |
|
121 | - * |
|
122 | - * @access public |
|
123 | - * @param int $STA_ID |
|
124 | - */ |
|
125 | - public function set_state($STA_ID = 0) |
|
126 | - { |
|
127 | - $this->set('STA_ID', $STA_ID); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * Set Attendee Country ISO Code |
|
134 | - * |
|
135 | - * @access public |
|
136 | - * @param string $CNT_ISO |
|
137 | - */ |
|
138 | - public function set_country($CNT_ISO = '') |
|
139 | - { |
|
140 | - $this->set('CNT_ISO', $CNT_ISO); |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Set Attendee Zip/Postal Code |
|
147 | - * |
|
148 | - * @access public |
|
149 | - * @param string $zip |
|
150 | - */ |
|
151 | - public function set_zip($zip = '') |
|
152 | - { |
|
153 | - $this->set('ATT_zip', $zip); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Set Attendee Email Address |
|
160 | - * |
|
161 | - * @access public |
|
162 | - * @param string $email |
|
163 | - */ |
|
164 | - public function set_email($email = '') |
|
165 | - { |
|
166 | - $this->set('ATT_email', $email); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Set Attendee Phone |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @param string $phone |
|
176 | - */ |
|
177 | - public function set_phone($phone = '') |
|
178 | - { |
|
179 | - $this->set('ATT_phone', $phone); |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * set deleted |
|
186 | - * |
|
187 | - * @access public |
|
188 | - * @param bool $ATT_deleted |
|
189 | - */ |
|
190 | - public function set_deleted($ATT_deleted = false) |
|
191 | - { |
|
192 | - $this->set('ATT_deleted', $ATT_deleted); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * Returns the value for the post_author id saved with the cpt |
|
199 | - * |
|
200 | - * @since 4.5.0 |
|
201 | - * @return int |
|
202 | - */ |
|
203 | - public function wp_user() |
|
204 | - { |
|
205 | - return $this->get('ATT_author'); |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * get Attendee First Name |
|
212 | - * |
|
213 | - * @access public |
|
214 | - * @return string |
|
215 | - */ |
|
216 | - public function fname() |
|
217 | - { |
|
218 | - return $this->get('ATT_fname'); |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * echoes out the attendee's first name |
|
225 | - * |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function e_full_name() |
|
229 | - { |
|
230 | - echo $this->full_name(); |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Returns the first and last name concatenated together with a space. |
|
237 | - * |
|
238 | - * @param bool $apply_html_entities |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - public function full_name($apply_html_entities = false) |
|
242 | - { |
|
243 | - $full_name = $this->fname() . ' ' . $this->lname(); |
|
244 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * get Attendee Last Name |
|
251 | - * |
|
252 | - * @access public |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function lname() |
|
256 | - { |
|
257 | - return $this->get('ATT_lname'); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
264 | - * |
|
265 | - * @return array numerically indexed, with each part of the address that is known. |
|
266 | - * Eg, if the user only responded to state and country, |
|
267 | - * it would be array(0=>'Alabama',1=>'USA') |
|
268 | - * @return array |
|
269 | - */ |
|
270 | - public function full_address_as_array() |
|
271 | - { |
|
272 | - $full_address_array = array(); |
|
273 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
274 | - foreach ($initial_address_fields as $address_field_name) { |
|
275 | - $address_fields_value = $this->get($address_field_name); |
|
276 | - if ( ! empty($address_fields_value)) { |
|
277 | - $full_address_array[] = $address_fields_value; |
|
278 | - } |
|
279 | - } |
|
280 | - //now handle state and country |
|
281 | - $state_obj = $this->state_obj(); |
|
282 | - if ( ! empty($state_obj)) { |
|
283 | - $full_address_array[] = $state_obj->name(); |
|
284 | - } |
|
285 | - $country_obj = $this->country_obj(); |
|
286 | - if ( ! empty($country_obj)) { |
|
287 | - $full_address_array[] = $country_obj->name(); |
|
288 | - } |
|
289 | - //lastly get the xip |
|
290 | - $zip_value = $this->zip(); |
|
291 | - if ( ! empty($zip_value)) { |
|
292 | - $full_address_array[] = $zip_value; |
|
293 | - } |
|
294 | - return $full_address_array; |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * get Attendee Address |
|
301 | - * |
|
302 | - * @return string |
|
303 | - */ |
|
304 | - public function address() |
|
305 | - { |
|
306 | - return $this->get('ATT_address'); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * get Attendee Address2 |
|
313 | - * |
|
314 | - * @return string |
|
315 | - */ |
|
316 | - public function address2() |
|
317 | - { |
|
318 | - return $this->get('ATT_address2'); |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * get Attendee City |
|
325 | - * |
|
326 | - * @return string |
|
327 | - */ |
|
328 | - public function city() |
|
329 | - { |
|
330 | - return $this->get('ATT_city'); |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * get Attendee State ID |
|
337 | - * |
|
338 | - * @return string |
|
339 | - */ |
|
340 | - public function state_ID() |
|
341 | - { |
|
342 | - return $this->get('STA_ID'); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @return string |
|
349 | - */ |
|
350 | - public function state_abbrev() |
|
351 | - { |
|
352 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * Gets the state set to this attendee |
|
359 | - * |
|
360 | - * @return EE_State |
|
361 | - */ |
|
362 | - public function state_obj() |
|
363 | - { |
|
364 | - return $this->get_first_related('State'); |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * Returns the state's name, otherwise 'Unknown' |
|
371 | - * |
|
372 | - * @return string |
|
373 | - */ |
|
374 | - public function state_name() |
|
375 | - { |
|
376 | - if ($this->state_obj()) { |
|
377 | - return $this->state_obj()->name(); |
|
378 | - } else { |
|
379 | - return ''; |
|
380 | - } |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * either displays the state abbreviation or the state name, as determined |
|
387 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
388 | - * defaults to abbreviation |
|
389 | - * |
|
390 | - * @return string |
|
391 | - */ |
|
392 | - public function state() |
|
393 | - { |
|
394 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
395 | - return $this->state_abbrev(); |
|
396 | - } else { |
|
397 | - return $this->state_name(); |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * get Attendee Country ISO Code |
|
405 | - * |
|
406 | - * @return string |
|
407 | - */ |
|
408 | - public function country_ID() |
|
409 | - { |
|
410 | - return $this->get('CNT_ISO'); |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - |
|
415 | - /** |
|
416 | - * Gets country set for this attendee |
|
417 | - * |
|
418 | - * @return EE_Country |
|
419 | - */ |
|
420 | - public function country_obj() |
|
421 | - { |
|
422 | - return $this->get_first_related('Country'); |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * Returns the country's name if known, otherwise 'Unknown' |
|
429 | - * |
|
430 | - * @return string |
|
431 | - */ |
|
432 | - public function country_name() |
|
433 | - { |
|
434 | - if ($this->country_obj()) { |
|
435 | - return $this->country_obj()->name(); |
|
436 | - } else { |
|
437 | - return ''; |
|
438 | - } |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * either displays the country ISO2 code or the country name, as determined |
|
445 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
446 | - * defaults to abbreviation |
|
447 | - * |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function country() |
|
451 | - { |
|
452 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
453 | - return $this->country_ID(); |
|
454 | - } else { |
|
455 | - return $this->country_name(); |
|
456 | - } |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * get Attendee Zip/Postal Code |
|
463 | - * |
|
464 | - * @return string |
|
465 | - */ |
|
466 | - public function zip() |
|
467 | - { |
|
468 | - return $this->get('ATT_zip'); |
|
469 | - } |
|
470 | - |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * get Attendee Email Address |
|
475 | - * |
|
476 | - * @return string |
|
477 | - */ |
|
478 | - public function email() |
|
479 | - { |
|
480 | - return $this->get('ATT_email'); |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * get Attendee Phone # |
|
487 | - * |
|
488 | - * @return string |
|
489 | - */ |
|
490 | - public function phone() |
|
491 | - { |
|
492 | - return $this->get('ATT_phone'); |
|
493 | - } |
|
494 | - |
|
495 | - |
|
496 | - |
|
497 | - /** |
|
498 | - * get deleted |
|
499 | - * |
|
500 | - * @return bool |
|
501 | - */ |
|
502 | - public function deleted() |
|
503 | - { |
|
504 | - return $this->get('ATT_deleted'); |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * Gets registrations of this attendee |
|
511 | - * |
|
512 | - * @param array $query_params |
|
513 | - * @return EE_Registration[] |
|
514 | - */ |
|
515 | - public function get_registrations($query_params = array()) |
|
516 | - { |
|
517 | - return $this->get_many_related('Registration', $query_params); |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * Gets the most recent registration of this attendee |
|
524 | - * |
|
525 | - * @return EE_Registration |
|
526 | - */ |
|
527 | - public function get_most_recent_registration() |
|
528 | - { |
|
529 | - return $this->get_first_related('Registration', array('order_by' => array('REG_date' => 'DESC'))); |
|
530 | - } |
|
531 | - |
|
532 | - |
|
533 | - |
|
534 | - /** |
|
535 | - * Gets the most recent registration for this attend at this event |
|
536 | - * |
|
537 | - * @param int $event_id |
|
538 | - * @return EE_Registration |
|
539 | - */ |
|
540 | - public function get_most_recent_registration_for_event($event_id) |
|
541 | - { |
|
542 | - return $this->get_first_related( |
|
543 | - 'Registration', |
|
544 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
545 | - ); |
|
27 | + /** |
|
28 | + * Sets some dynamic defaults |
|
29 | + * |
|
30 | + * @param array $fieldValues |
|
31 | + * @param bool $bydb |
|
32 | + * @param string $timezone |
|
33 | + * @param array $date_formats |
|
34 | + */ |
|
35 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
36 | + { |
|
37 | + if ( ! isset($fieldValues['ATT_full_name'])) { |
|
38 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
39 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
40 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
41 | + } |
|
42 | + if ( ! isset($fieldValues['ATT_slug'])) { |
|
43 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
44 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
45 | + } |
|
46 | + if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
47 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
48 | + } |
|
49 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Set Attendee First Name |
|
56 | + * |
|
57 | + * @access public |
|
58 | + * @param string $fname |
|
59 | + */ |
|
60 | + public function set_fname($fname = '') |
|
61 | + { |
|
62 | + $this->set('ATT_fname', $fname); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Set Attendee Last Name |
|
69 | + * |
|
70 | + * @access public |
|
71 | + * @param string $lname |
|
72 | + */ |
|
73 | + public function set_lname($lname = '') |
|
74 | + { |
|
75 | + $this->set('ATT_lname', $lname); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * Set Attendee Address |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @param string $address |
|
85 | + */ |
|
86 | + public function set_address($address = '') |
|
87 | + { |
|
88 | + $this->set('ATT_address', $address); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Set Attendee Address2 |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @param string $address2 |
|
98 | + */ |
|
99 | + public function set_address2($address2 = '') |
|
100 | + { |
|
101 | + $this->set('ATT_address2', $address2); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * Set Attendee City |
|
108 | + * |
|
109 | + * @access public |
|
110 | + * @param string $city |
|
111 | + */ |
|
112 | + public function set_city($city = '') |
|
113 | + { |
|
114 | + $this->set('ATT_city', $city); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * Set Attendee State ID |
|
121 | + * |
|
122 | + * @access public |
|
123 | + * @param int $STA_ID |
|
124 | + */ |
|
125 | + public function set_state($STA_ID = 0) |
|
126 | + { |
|
127 | + $this->set('STA_ID', $STA_ID); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * Set Attendee Country ISO Code |
|
134 | + * |
|
135 | + * @access public |
|
136 | + * @param string $CNT_ISO |
|
137 | + */ |
|
138 | + public function set_country($CNT_ISO = '') |
|
139 | + { |
|
140 | + $this->set('CNT_ISO', $CNT_ISO); |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Set Attendee Zip/Postal Code |
|
147 | + * |
|
148 | + * @access public |
|
149 | + * @param string $zip |
|
150 | + */ |
|
151 | + public function set_zip($zip = '') |
|
152 | + { |
|
153 | + $this->set('ATT_zip', $zip); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Set Attendee Email Address |
|
160 | + * |
|
161 | + * @access public |
|
162 | + * @param string $email |
|
163 | + */ |
|
164 | + public function set_email($email = '') |
|
165 | + { |
|
166 | + $this->set('ATT_email', $email); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Set Attendee Phone |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @param string $phone |
|
176 | + */ |
|
177 | + public function set_phone($phone = '') |
|
178 | + { |
|
179 | + $this->set('ATT_phone', $phone); |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * set deleted |
|
186 | + * |
|
187 | + * @access public |
|
188 | + * @param bool $ATT_deleted |
|
189 | + */ |
|
190 | + public function set_deleted($ATT_deleted = false) |
|
191 | + { |
|
192 | + $this->set('ATT_deleted', $ATT_deleted); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * Returns the value for the post_author id saved with the cpt |
|
199 | + * |
|
200 | + * @since 4.5.0 |
|
201 | + * @return int |
|
202 | + */ |
|
203 | + public function wp_user() |
|
204 | + { |
|
205 | + return $this->get('ATT_author'); |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * get Attendee First Name |
|
212 | + * |
|
213 | + * @access public |
|
214 | + * @return string |
|
215 | + */ |
|
216 | + public function fname() |
|
217 | + { |
|
218 | + return $this->get('ATT_fname'); |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * echoes out the attendee's first name |
|
225 | + * |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function e_full_name() |
|
229 | + { |
|
230 | + echo $this->full_name(); |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Returns the first and last name concatenated together with a space. |
|
237 | + * |
|
238 | + * @param bool $apply_html_entities |
|
239 | + * @return string |
|
240 | + */ |
|
241 | + public function full_name($apply_html_entities = false) |
|
242 | + { |
|
243 | + $full_name = $this->fname() . ' ' . $this->lname(); |
|
244 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * get Attendee Last Name |
|
251 | + * |
|
252 | + * @access public |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function lname() |
|
256 | + { |
|
257 | + return $this->get('ATT_lname'); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
264 | + * |
|
265 | + * @return array numerically indexed, with each part of the address that is known. |
|
266 | + * Eg, if the user only responded to state and country, |
|
267 | + * it would be array(0=>'Alabama',1=>'USA') |
|
268 | + * @return array |
|
269 | + */ |
|
270 | + public function full_address_as_array() |
|
271 | + { |
|
272 | + $full_address_array = array(); |
|
273 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
274 | + foreach ($initial_address_fields as $address_field_name) { |
|
275 | + $address_fields_value = $this->get($address_field_name); |
|
276 | + if ( ! empty($address_fields_value)) { |
|
277 | + $full_address_array[] = $address_fields_value; |
|
278 | + } |
|
279 | + } |
|
280 | + //now handle state and country |
|
281 | + $state_obj = $this->state_obj(); |
|
282 | + if ( ! empty($state_obj)) { |
|
283 | + $full_address_array[] = $state_obj->name(); |
|
284 | + } |
|
285 | + $country_obj = $this->country_obj(); |
|
286 | + if ( ! empty($country_obj)) { |
|
287 | + $full_address_array[] = $country_obj->name(); |
|
288 | + } |
|
289 | + //lastly get the xip |
|
290 | + $zip_value = $this->zip(); |
|
291 | + if ( ! empty($zip_value)) { |
|
292 | + $full_address_array[] = $zip_value; |
|
293 | + } |
|
294 | + return $full_address_array; |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * get Attendee Address |
|
301 | + * |
|
302 | + * @return string |
|
303 | + */ |
|
304 | + public function address() |
|
305 | + { |
|
306 | + return $this->get('ATT_address'); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * get Attendee Address2 |
|
313 | + * |
|
314 | + * @return string |
|
315 | + */ |
|
316 | + public function address2() |
|
317 | + { |
|
318 | + return $this->get('ATT_address2'); |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * get Attendee City |
|
325 | + * |
|
326 | + * @return string |
|
327 | + */ |
|
328 | + public function city() |
|
329 | + { |
|
330 | + return $this->get('ATT_city'); |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * get Attendee State ID |
|
337 | + * |
|
338 | + * @return string |
|
339 | + */ |
|
340 | + public function state_ID() |
|
341 | + { |
|
342 | + return $this->get('STA_ID'); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @return string |
|
349 | + */ |
|
350 | + public function state_abbrev() |
|
351 | + { |
|
352 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * Gets the state set to this attendee |
|
359 | + * |
|
360 | + * @return EE_State |
|
361 | + */ |
|
362 | + public function state_obj() |
|
363 | + { |
|
364 | + return $this->get_first_related('State'); |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * Returns the state's name, otherwise 'Unknown' |
|
371 | + * |
|
372 | + * @return string |
|
373 | + */ |
|
374 | + public function state_name() |
|
375 | + { |
|
376 | + if ($this->state_obj()) { |
|
377 | + return $this->state_obj()->name(); |
|
378 | + } else { |
|
379 | + return ''; |
|
380 | + } |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * either displays the state abbreviation or the state name, as determined |
|
387 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
388 | + * defaults to abbreviation |
|
389 | + * |
|
390 | + * @return string |
|
391 | + */ |
|
392 | + public function state() |
|
393 | + { |
|
394 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
395 | + return $this->state_abbrev(); |
|
396 | + } else { |
|
397 | + return $this->state_name(); |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * get Attendee Country ISO Code |
|
405 | + * |
|
406 | + * @return string |
|
407 | + */ |
|
408 | + public function country_ID() |
|
409 | + { |
|
410 | + return $this->get('CNT_ISO'); |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + |
|
415 | + /** |
|
416 | + * Gets country set for this attendee |
|
417 | + * |
|
418 | + * @return EE_Country |
|
419 | + */ |
|
420 | + public function country_obj() |
|
421 | + { |
|
422 | + return $this->get_first_related('Country'); |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * Returns the country's name if known, otherwise 'Unknown' |
|
429 | + * |
|
430 | + * @return string |
|
431 | + */ |
|
432 | + public function country_name() |
|
433 | + { |
|
434 | + if ($this->country_obj()) { |
|
435 | + return $this->country_obj()->name(); |
|
436 | + } else { |
|
437 | + return ''; |
|
438 | + } |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * either displays the country ISO2 code or the country name, as determined |
|
445 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
446 | + * defaults to abbreviation |
|
447 | + * |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function country() |
|
451 | + { |
|
452 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
453 | + return $this->country_ID(); |
|
454 | + } else { |
|
455 | + return $this->country_name(); |
|
456 | + } |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * get Attendee Zip/Postal Code |
|
463 | + * |
|
464 | + * @return string |
|
465 | + */ |
|
466 | + public function zip() |
|
467 | + { |
|
468 | + return $this->get('ATT_zip'); |
|
469 | + } |
|
470 | + |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * get Attendee Email Address |
|
475 | + * |
|
476 | + * @return string |
|
477 | + */ |
|
478 | + public function email() |
|
479 | + { |
|
480 | + return $this->get('ATT_email'); |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * get Attendee Phone # |
|
487 | + * |
|
488 | + * @return string |
|
489 | + */ |
|
490 | + public function phone() |
|
491 | + { |
|
492 | + return $this->get('ATT_phone'); |
|
493 | + } |
|
494 | + |
|
495 | + |
|
496 | + |
|
497 | + /** |
|
498 | + * get deleted |
|
499 | + * |
|
500 | + * @return bool |
|
501 | + */ |
|
502 | + public function deleted() |
|
503 | + { |
|
504 | + return $this->get('ATT_deleted'); |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * Gets registrations of this attendee |
|
511 | + * |
|
512 | + * @param array $query_params |
|
513 | + * @return EE_Registration[] |
|
514 | + */ |
|
515 | + public function get_registrations($query_params = array()) |
|
516 | + { |
|
517 | + return $this->get_many_related('Registration', $query_params); |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * Gets the most recent registration of this attendee |
|
524 | + * |
|
525 | + * @return EE_Registration |
|
526 | + */ |
|
527 | + public function get_most_recent_registration() |
|
528 | + { |
|
529 | + return $this->get_first_related('Registration', array('order_by' => array('REG_date' => 'DESC'))); |
|
530 | + } |
|
531 | + |
|
532 | + |
|
533 | + |
|
534 | + /** |
|
535 | + * Gets the most recent registration for this attend at this event |
|
536 | + * |
|
537 | + * @param int $event_id |
|
538 | + * @return EE_Registration |
|
539 | + */ |
|
540 | + public function get_most_recent_registration_for_event($event_id) |
|
541 | + { |
|
542 | + return $this->get_first_related( |
|
543 | + 'Registration', |
|
544 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
545 | + ); |
|
546 | 546 | |
547 | - } |
|
548 | - |
|
549 | - |
|
550 | - |
|
551 | - /** |
|
552 | - * returns any events attached to this attendee ($_Event property); |
|
553 | - * |
|
554 | - * @return array |
|
555 | - */ |
|
556 | - public function events() |
|
557 | - { |
|
558 | - return $this->get_many_related('Event'); |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - |
|
563 | - /** |
|
564 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
565 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
566 | - * used to save the billing info |
|
567 | - * |
|
568 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
569 | - * @return EE_Form_Section_Proper|null |
|
570 | - */ |
|
571 | - public function billing_info_for_payment_method($payment_method) |
|
572 | - { |
|
573 | - $pm_type = $payment_method->type_obj(); |
|
574 | - if ( ! $pm_type instanceof EE_PMT_Base) { |
|
575 | - return null; |
|
576 | - } |
|
577 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
578 | - if ( ! $billing_info) { |
|
579 | - return null; |
|
580 | - } |
|
581 | - $billing_form = $pm_type->billing_form(); |
|
582 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
583 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
584 | - } |
|
585 | - return $billing_form; |
|
586 | - } |
|
587 | - |
|
588 | - |
|
589 | - |
|
590 | - /** |
|
591 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
592 | - * specified payment method |
|
593 | - * |
|
594 | - * @param EE_Payment_Method $payment_method |
|
595 | - * @return string |
|
596 | - */ |
|
597 | - public function get_billing_info_postmeta_name($payment_method) |
|
598 | - { |
|
599 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
600 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
601 | - } else { |
|
602 | - return null; |
|
603 | - } |
|
604 | - } |
|
605 | - |
|
606 | - |
|
607 | - |
|
608 | - /** |
|
609 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
610 | - * retrieve it |
|
611 | - * |
|
612 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
613 | - * @param EE_Payment_Method $payment_method |
|
614 | - * @return boolean |
|
615 | - */ |
|
616 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
617 | - { |
|
618 | - if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
619 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
620 | - return false; |
|
621 | - } |
|
622 | - $billing_form->clean_sensitive_data(); |
|
623 | - return update_post_meta( |
|
624 | - $this->ID(), |
|
625 | - $this->get_billing_info_postmeta_name($payment_method), |
|
626 | - $billing_form->input_values(true) |
|
627 | - ); |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - |
|
632 | - /** |
|
633 | - * Return the link to the admin details for the object. |
|
634 | - * |
|
635 | - * @return string |
|
636 | - */ |
|
637 | - public function get_admin_details_link() |
|
638 | - { |
|
639 | - return $this->get_admin_edit_link(); |
|
640 | - } |
|
641 | - |
|
642 | - |
|
643 | - |
|
644 | - /** |
|
645 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
646 | - * |
|
647 | - * @return string |
|
648 | - */ |
|
649 | - public function get_admin_edit_link() |
|
650 | - { |
|
651 | - EE_Registry::instance()->load_helper('URL'); |
|
652 | - return EEH_URL::add_query_args_and_nonce( |
|
653 | - array( |
|
654 | - 'page' => 'espresso_registrations', |
|
655 | - 'action' => 'edit_attendee', |
|
656 | - 'post' => $this->ID(), |
|
657 | - ), |
|
658 | - admin_url('admin.php') |
|
659 | - ); |
|
660 | - } |
|
661 | - |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * Returns the link to a settings page for the object. |
|
666 | - * |
|
667 | - * @return string |
|
668 | - */ |
|
669 | - public function get_admin_settings_link() |
|
670 | - { |
|
671 | - return $this->get_admin_edit_link(); |
|
672 | - } |
|
673 | - |
|
674 | - |
|
675 | - |
|
676 | - /** |
|
677 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
678 | - * |
|
679 | - * @return string |
|
680 | - */ |
|
681 | - public function get_admin_overview_link() |
|
682 | - { |
|
683 | - EE_Registry::instance()->load_helper('URL'); |
|
684 | - return EEH_URL::add_query_args_and_nonce( |
|
685 | - array( |
|
686 | - 'page' => 'espresso_registrations', |
|
687 | - 'action' => 'contact_list', |
|
688 | - ), |
|
689 | - admin_url('admin.php') |
|
690 | - ); |
|
691 | - } |
|
547 | + } |
|
548 | + |
|
549 | + |
|
550 | + |
|
551 | + /** |
|
552 | + * returns any events attached to this attendee ($_Event property); |
|
553 | + * |
|
554 | + * @return array |
|
555 | + */ |
|
556 | + public function events() |
|
557 | + { |
|
558 | + return $this->get_many_related('Event'); |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + |
|
563 | + /** |
|
564 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
565 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
566 | + * used to save the billing info |
|
567 | + * |
|
568 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
569 | + * @return EE_Form_Section_Proper|null |
|
570 | + */ |
|
571 | + public function billing_info_for_payment_method($payment_method) |
|
572 | + { |
|
573 | + $pm_type = $payment_method->type_obj(); |
|
574 | + if ( ! $pm_type instanceof EE_PMT_Base) { |
|
575 | + return null; |
|
576 | + } |
|
577 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
578 | + if ( ! $billing_info) { |
|
579 | + return null; |
|
580 | + } |
|
581 | + $billing_form = $pm_type->billing_form(); |
|
582 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
583 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
584 | + } |
|
585 | + return $billing_form; |
|
586 | + } |
|
587 | + |
|
588 | + |
|
589 | + |
|
590 | + /** |
|
591 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
592 | + * specified payment method |
|
593 | + * |
|
594 | + * @param EE_Payment_Method $payment_method |
|
595 | + * @return string |
|
596 | + */ |
|
597 | + public function get_billing_info_postmeta_name($payment_method) |
|
598 | + { |
|
599 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
600 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
601 | + } else { |
|
602 | + return null; |
|
603 | + } |
|
604 | + } |
|
605 | + |
|
606 | + |
|
607 | + |
|
608 | + /** |
|
609 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
610 | + * retrieve it |
|
611 | + * |
|
612 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
613 | + * @param EE_Payment_Method $payment_method |
|
614 | + * @return boolean |
|
615 | + */ |
|
616 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
617 | + { |
|
618 | + if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
619 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
620 | + return false; |
|
621 | + } |
|
622 | + $billing_form->clean_sensitive_data(); |
|
623 | + return update_post_meta( |
|
624 | + $this->ID(), |
|
625 | + $this->get_billing_info_postmeta_name($payment_method), |
|
626 | + $billing_form->input_values(true) |
|
627 | + ); |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + |
|
632 | + /** |
|
633 | + * Return the link to the admin details for the object. |
|
634 | + * |
|
635 | + * @return string |
|
636 | + */ |
|
637 | + public function get_admin_details_link() |
|
638 | + { |
|
639 | + return $this->get_admin_edit_link(); |
|
640 | + } |
|
641 | + |
|
642 | + |
|
643 | + |
|
644 | + /** |
|
645 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
646 | + * |
|
647 | + * @return string |
|
648 | + */ |
|
649 | + public function get_admin_edit_link() |
|
650 | + { |
|
651 | + EE_Registry::instance()->load_helper('URL'); |
|
652 | + return EEH_URL::add_query_args_and_nonce( |
|
653 | + array( |
|
654 | + 'page' => 'espresso_registrations', |
|
655 | + 'action' => 'edit_attendee', |
|
656 | + 'post' => $this->ID(), |
|
657 | + ), |
|
658 | + admin_url('admin.php') |
|
659 | + ); |
|
660 | + } |
|
661 | + |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * Returns the link to a settings page for the object. |
|
666 | + * |
|
667 | + * @return string |
|
668 | + */ |
|
669 | + public function get_admin_settings_link() |
|
670 | + { |
|
671 | + return $this->get_admin_edit_link(); |
|
672 | + } |
|
673 | + |
|
674 | + |
|
675 | + |
|
676 | + /** |
|
677 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
678 | + * |
|
679 | + * @return string |
|
680 | + */ |
|
681 | + public function get_admin_overview_link() |
|
682 | + { |
|
683 | + EE_Registry::instance()->load_helper('URL'); |
|
684 | + return EEH_URL::add_query_args_and_nonce( |
|
685 | + array( |
|
686 | + 'page' => 'espresso_registrations', |
|
687 | + 'action' => 'contact_list', |
|
688 | + ), |
|
689 | + admin_url('admin.php') |
|
690 | + ); |
|
691 | + } |
|
692 | 692 | |
693 | 693 | |
694 | 694 | } |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
36 | 36 | { |
37 | 37 | if ( ! isset($fieldValues['ATT_full_name'])) { |
38 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
38 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : ''; |
|
39 | 39 | $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
40 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
40 | + $fieldValues['ATT_full_name'] = $fname.$lname; |
|
41 | 41 | } |
42 | 42 | if ( ! isset($fieldValues['ATT_slug'])) { |
43 | 43 | // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function full_name($apply_html_entities = false) |
242 | 242 | { |
243 | - $full_name = $this->fname() . ' ' . $this->lname(); |
|
243 | + $full_name = $this->fname().' '.$this->lname(); |
|
244 | 244 | return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
245 | 245 | } |
246 | 246 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | public function get_billing_info_postmeta_name($payment_method) |
598 | 598 | { |
599 | 599 | if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
600 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
600 | + return 'billing_info_'.$payment_method->type_obj()->system_name(); |
|
601 | 601 | } else { |
602 | 602 | return null; |
603 | 603 | } |
@@ -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 | /** |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | * was not a new generated template but just reactivated (which only happens for global templates that |
60 | 60 | * already exist in the database. |
61 | 61 | */ |
62 | - public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) { |
|
62 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
|
63 | 63 | //make sure message_type is an array. |
64 | 64 | $message_types = (array) $message_types; |
65 | 65 | $templates = array(); |
66 | 66 | |
67 | - if ( empty( $messenger ) ) { |
|
68 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
67 | + if (empty($messenger)) { |
|
68 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
72 | - if ( empty( $message_types ) ) { |
|
73 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
72 | + if (empty($message_types)) { |
|
73 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | EEH_MSG_Template::_set_autoloader(); |
77 | - foreach ( $message_types as $message_type ) { |
|
77 | + foreach ($message_types as $message_type) { |
|
78 | 78 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
79 | - if ( $global && empty( $GRP_ID ) ) { |
|
79 | + if ($global && empty($GRP_ID)) { |
|
80 | 80 | $GRP_ID = EEM_Message_Template_Group::instance()->get_one( |
81 | 81 | array( |
82 | 82 | array( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // if this is global template generation. |
92 | 92 | // First let's determine if we already HAVE global templates for this messenger and message_type combination. |
93 | 93 | // If we do then NO generation!! |
94 | - if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) { |
|
94 | + if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) { |
|
95 | 95 | $templates[] = array( |
96 | 96 | 'GRP_ID' => $GRP_ID, |
97 | 97 | 'MTP_context' => '', |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | //we already have generated templates for this so let's go to the next message type. |
100 | 100 | continue; |
101 | 101 | } |
102 | - $new_message_template_group = EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
102 | + $new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
103 | 103 | |
104 | - if ( ! $new_message_template_group ) { |
|
104 | + if ( ! $new_message_template_group) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | $templates[] = $new_message_template_group; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | * @param int $GRP_ID GRP ID ( if a custom template) (if not provided then we're just doing global template check) |
119 | 119 | * @return bool true = generated, false = hasn't been generated. |
120 | 120 | */ |
121 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0 ) { |
|
121 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0) { |
|
122 | 122 | EEH_MSG_Template::_set_autoloader(); |
123 | 123 | //what method we use depends on whether we have an GRP_ID or not |
124 | - $count = empty( $GRP_ID ) |
|
124 | + $count = empty($GRP_ID) |
|
125 | 125 | ? EEM_Message_Template::instance()->count( |
126 | 126 | array( |
127 | 127 | array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ) |
132 | 132 | ) |
133 | 133 | ) |
134 | - : EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
134 | + : EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID))); |
|
135 | 135 | |
136 | 136 | return $count > 0; |
137 | 137 | } |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param array $message_type_names Message type slug |
148 | 148 | * @return int count of updated records. |
149 | 149 | */ |
150 | - public static function update_to_active( $messenger_names, $message_type_names ) { |
|
151 | - $messenger_names = is_array( $messenger_names ) ? $messenger_names : array( $messenger_names ); |
|
152 | - $message_type_names = is_array( $message_type_names ) ? $message_type_names : array( $message_type_names ); |
|
150 | + public static function update_to_active($messenger_names, $message_type_names) { |
|
151 | + $messenger_names = is_array($messenger_names) ? $messenger_names : array($messenger_names); |
|
152 | + $message_type_names = is_array($message_type_names) ? $message_type_names : array($message_type_names); |
|
153 | 153 | return EEM_Message_Template_Group::instance()->update( |
154 | - array( 'MTP_is_active' => 1 ), |
|
154 | + array('MTP_is_active' => 1), |
|
155 | 155 | array( |
156 | 156 | array( |
157 | - 'MTP_messenger' => array( 'IN', $messenger_names ), |
|
158 | - 'MTP_message_type' => array( 'IN', $message_type_names ) |
|
157 | + 'MTP_messenger' => array('IN', $messenger_names), |
|
158 | + 'MTP_message_type' => array('IN', $message_type_names) |
|
159 | 159 | ) |
160 | 160 | ) |
161 | 161 | ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return int count of updated records. |
178 | 178 | */ |
179 | - public static function update_to_inactive( $messenger_names = array(), $message_type_names = array() ) { |
|
179 | + public static function update_to_inactive($messenger_names = array(), $message_type_names = array()) { |
|
180 | 180 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
181 | 181 | $messenger_names, |
182 | 182 | $message_type_names |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $type |
194 | 194 | * @return array array consisting of installed messenger objects and installed message type objects. |
195 | 195 | */ |
196 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
196 | + public static function get_installed_message_objects($type = 'all') { |
|
197 | 197 | self::_set_autoloader(); |
198 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
198 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
199 | 199 | return array( |
200 | 200 | 'messenger' => $message_resource_manager->installed_messengers(), |
201 | 201 | 'message_type' => $message_resource_manager->installed_message_types() |
@@ -231,74 +231,74 @@ discard block |
||
231 | 231 | $context = 'admin', |
232 | 232 | $merged = false |
233 | 233 | ) { |
234 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
235 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
234 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
235 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
236 | 236 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
237 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
237 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
238 | 238 | //convert slug to object |
239 | - $messenger = $message_resource_manager->get_messenger( $messenger ); |
|
239 | + $messenger = $message_resource_manager->get_messenger($messenger); |
|
240 | 240 | |
241 | 241 | //if messenger isn't a EE_messenger resource then bail. |
242 | - if ( ! $messenger instanceof EE_messenger ) { |
|
242 | + if ( ! $messenger instanceof EE_messenger) { |
|
243 | 243 | return array(); |
244 | 244 | } |
245 | 245 | |
246 | 246 | //validate class for getting our list of shortcodes |
247 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
248 | - if ( ! class_exists( $classname ) ) { |
|
249 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso' ); |
|
247 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
248 | + if ( ! class_exists($classname)) { |
|
249 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
250 | 250 | $msg[] = sprintf( |
251 | - __( 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso' ), |
|
251 | + __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), |
|
252 | 252 | $classname |
253 | 253 | ); |
254 | - throw new EE_Error( implode( '||', $msg ) ); |
|
254 | + throw new EE_Error(implode('||', $msg)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** @type EE_Messages_Validator $_VLD */ |
258 | - $_VLD = new $classname( array(), $context ); |
|
258 | + $_VLD = new $classname(array(), $context); |
|
259 | 259 | $valid_shortcodes = $_VLD->get_validators(); |
260 | 260 | |
261 | 261 | //let's make sure we're only getting the shortcode part of the validators |
262 | 262 | $shortcodes = array(); |
263 | - foreach ( $valid_shortcodes as $field => $validators ) { |
|
264 | - $shortcodes[ $field ] = $validators['shortcodes']; |
|
263 | + foreach ($valid_shortcodes as $field => $validators) { |
|
264 | + $shortcodes[$field] = $validators['shortcodes']; |
|
265 | 265 | } |
266 | 266 | $valid_shortcodes = $shortcodes; |
267 | 267 | |
268 | 268 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
269 | - if ( ! empty( $fields ) ) { |
|
269 | + if ( ! empty($fields)) { |
|
270 | 270 | $specified_shortcodes = array(); |
271 | - foreach ( $fields as $field ) { |
|
272 | - if ( isset( $valid_shortcodes[ $field ] ) ) { |
|
273 | - $specified_shortcodes[ $field ] = $valid_shortcodes[ $field ]; |
|
271 | + foreach ($fields as $field) { |
|
272 | + if (isset($valid_shortcodes[$field])) { |
|
273 | + $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | $valid_shortcodes = $specified_shortcodes; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if not merged then let's replace the fields with the localized fields |
280 | - if ( ! $merged ) { |
|
280 | + if ( ! $merged) { |
|
281 | 281 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
282 | 282 | $field_settings = $messenger->get_template_fields(); |
283 | 283 | $localized = array(); |
284 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
284 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
285 | 285 | //get localized field label |
286 | - if ( isset( $field_settings[ $field ] ) ) { |
|
286 | + if (isset($field_settings[$field])) { |
|
287 | 287 | //possible that this is used as a main field. |
288 | - if ( empty( $field_settings[ $field ] ) ) { |
|
289 | - if ( isset( $field_settings['extra'][ $field ] ) ) { |
|
290 | - $_field = $field_settings['extra'][ $field ]['main']['label']; |
|
288 | + if (empty($field_settings[$field])) { |
|
289 | + if (isset($field_settings['extra'][$field])) { |
|
290 | + $_field = $field_settings['extra'][$field]['main']['label']; |
|
291 | 291 | } else { |
292 | 292 | $_field = $field; |
293 | 293 | } |
294 | 294 | } else { |
295 | - $_field = $field_settings[ $field ]['label']; |
|
295 | + $_field = $field_settings[$field]['label']; |
|
296 | 296 | } |
297 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
297 | + } else if (isset($field_settings['extra'])) { |
|
298 | 298 | //loop through extra "main fields" and see if any of their children have our field |
299 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
300 | - if ( isset( $fields[ $field ] ) ) { |
|
301 | - $_field = $fields[ $field ]['label']; |
|
299 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
300 | + if (isset($fields[$field])) { |
|
301 | + $_field = $fields[$field]['label']; |
|
302 | 302 | } else { |
303 | 303 | $_field = $field; |
304 | 304 | } |
@@ -306,22 +306,22 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $_field = $field; |
308 | 308 | } |
309 | - if ( isset( $_field ) ) { |
|
310 | - $localized[ $_field ] = $shortcodes; |
|
309 | + if (isset($_field)) { |
|
310 | + $localized[$_field] = $shortcodes; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | $valid_shortcodes = $localized; |
314 | 314 | } |
315 | 315 | |
316 | 316 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
317 | - if ( $merged ) { |
|
317 | + if ($merged) { |
|
318 | 318 | $merged_codes = array(); |
319 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
320 | - foreach ( $shortcode as $code => $label ) { |
|
321 | - if ( isset( $merged_codes[ $code ] ) ) { |
|
319 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
320 | + foreach ($shortcode as $code => $label) { |
|
321 | + if (isset($merged_codes[$code])) { |
|
322 | 322 | continue; |
323 | 323 | } else { |
324 | - $merged_codes[ $code ] = $label; |
|
324 | + $merged_codes[$code] = $label; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | } |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | * @throws \EE_Error |
342 | 342 | * @return EE_messenger |
343 | 343 | */ |
344 | - public static function messenger_obj( $messenger ) { |
|
344 | + public static function messenger_obj($messenger) { |
|
345 | 345 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
346 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
347 | - return $Message_Resource_Manager->get_messenger( $messenger ); |
|
346 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
347 | + return $Message_Resource_Manager->get_messenger($messenger); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @throws \EE_Error |
358 | 358 | * @return EE_message_type |
359 | 359 | */ |
360 | - public static function message_type_obj( $message_type ) { |
|
360 | + public static function message_type_obj($message_type) { |
|
361 | 361 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
362 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
363 | - return $Message_Resource_Manager->get_message_type( $message_type ); |
|
362 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
363 | + return $Message_Resource_Manager->get_message_type($message_type); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * @param string $message_type message type to check for. |
375 | 375 | * @return boolean |
376 | 376 | */ |
377 | - public static function is_mt_active( $message_type ) { |
|
377 | + public static function is_mt_active($message_type) { |
|
378 | 378 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
379 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
379 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
380 | 380 | $active_mts = $Message_Resource_Manager->list_of_active_message_types(); |
381 | - return in_array( $message_type, $active_mts ); |
|
381 | + return in_array($message_type, $active_mts); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param string $messenger slug for messenger to check. |
392 | 392 | * @return boolean |
393 | 393 | */ |
394 | - public static function is_messenger_active( $messenger ) { |
|
394 | + public static function is_messenger_active($messenger) { |
|
395 | 395 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
396 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
397 | - $active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger ); |
|
396 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
397 | + $active_messenger = $Message_Resource_Manager->get_active_messenger($messenger); |
|
398 | 398 | return $active_messenger instanceof EE_messenger ? true : false; |
399 | 399 | } |
400 | 400 | |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | public static function get_active_messengers_in_db() { |
413 | 413 | EE_Error::doing_it_wrong( |
414 | 414 | __METHOD__, |
415 | - __( 'Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso' ), |
|
415 | + __('Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso'), |
|
416 | 416 | '4.9.0' |
417 | 417 | ); |
418 | 418 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
419 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
419 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
420 | 420 | return $Message_Resource_Manager->get_active_messengers_option(); |
421 | 421 | } |
422 | 422 | |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool FALSE if not updated, TRUE if updated. |
435 | 435 | */ |
436 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
436 | + public static function update_active_messengers_in_db($data_to_save) { |
|
437 | 437 | EE_Error::doing_it_wrong( |
438 | 438 | __METHOD__, |
439 | - __( 'Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso' ), |
|
439 | + __('Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso'), |
|
440 | 440 | '4.9.0' |
441 | 441 | ); |
442 | 442 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
443 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
444 | - return $Message_Resource_Manager->update_active_messengers_option( $data_to_save ); |
|
443 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
444 | + return $Message_Resource_Manager->update_active_messengers_option($data_to_save); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -465,34 +465,34 @@ discard block |
||
465 | 465 | $sending_messenger = '' |
466 | 466 | ) { |
467 | 467 | //first determine if the url can be to the EE_Message object. |
468 | - if ( ! $message_type->always_generate() ) { |
|
469 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
468 | + if ( ! $message_type->always_generate()) { |
|
469 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
473 | - if ( ! $registration instanceof EE_Registration ) { |
|
473 | + if ( ! $registration instanceof EE_Registration) { |
|
474 | 474 | throw new EE_Error( |
475 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
475 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
476 | 476 | ); |
477 | 477 | } |
478 | 478 | |
479 | 479 | //validate given context |
480 | 480 | $contexts = $message_type->get_contexts(); |
481 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
481 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $message->context(), |
486 | - get_class( $message_type ) |
|
486 | + get_class($message_type) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | 491 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
492 | - if ( ! empty( $sending_messenger ) ) { |
|
492 | + if ( ! empty($sending_messenger)) { |
|
493 | 493 | $with_messengers = $message_type->with_messengers(); |
494 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
495 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
494 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
495 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | 498 | __( |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'event_espresso' |
501 | 501 | ), |
502 | 502 | $sending_messenger, |
503 | - get_class( $message_type ) |
|
503 | + get_class($message_type) |
|
504 | 504 | ) |
505 | 505 | ); |
506 | 506 | } |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param EE_Message $message |
524 | 524 | * @return string. |
525 | 525 | */ |
526 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
526 | + public static function generate_browser_trigger(EE_Message $message) { |
|
527 | 527 | $query_args = array( |
528 | 528 | 'ee' => 'msg_browser_trigger', |
529 | 529 | 'token' => $message->MSG_token() |
530 | 530 | ); |
531 | 531 | return apply_filters( |
532 | 532 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
533 | - add_query_arg( $query_args, site_url() ), |
|
533 | + add_query_arg($query_args, site_url()), |
|
534 | 534 | $message |
535 | 535 | ); |
536 | 536 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @param EE_Message $message |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
548 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
549 | 549 | return apply_filters( |
550 | 550 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
551 | 551 | add_query_arg( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | 'GRP_ID' => $message_template_group, |
596 | 596 | 'id' => $data_id |
597 | 597 | ); |
598 | - $url = add_query_arg( $query_args, get_home_url() ); |
|
598 | + $url = add_query_arg($query_args, get_home_url()); |
|
599 | 599 | |
600 | 600 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
601 | 601 | $url = apply_filters( |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @param string $type What action to return. |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public static function get_message_action_icon( $type ) { |
|
626 | + public static function get_message_action_icon($type) { |
|
627 | 627 | $action_icons = self::get_message_action_icons(); |
628 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
628 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -637,34 +637,34 @@ discard block |
||
637 | 637 | * @return array |
638 | 638 | */ |
639 | 639 | public static function get_message_action_icons() { |
640 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
640 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
641 | 641 | array( |
642 | 642 | 'view' => array( |
643 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
643 | + 'label' => __('View Message', 'event_espresso'), |
|
644 | 644 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
645 | 645 | ), |
646 | 646 | 'error' => array( |
647 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
647 | + 'label' => __('View Error Message', 'event_espresso'), |
|
648 | 648 | 'css_class' => 'dashicons dashicons-info', |
649 | 649 | ), |
650 | 650 | 'see_notifications_for' => array( |
651 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
651 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
652 | 652 | 'css_class' => 'dashicons dashicons-megaphone', |
653 | 653 | ), |
654 | 654 | 'generate_now' => array( |
655 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
655 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
656 | 656 | 'css_class' => 'dashicons dashicons-admin-tools', |
657 | 657 | ), |
658 | 658 | 'send_now' => array( |
659 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
659 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
660 | 660 | 'css_class' => 'dashicons dashicons-controls-forward', |
661 | 661 | ), |
662 | 662 | 'queue_for_resending' => array( |
663 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
663 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
664 | 664 | 'css_class' => 'dashicons dashicons-controls-repeat', |
665 | 665 | ), |
666 | 666 | 'view_transaction' => array( |
667 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
667 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
668 | 668 | 'css_class' => 'dashicons dashicons-cart', |
669 | 669 | ) |
670 | 670 | ) |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
687 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
688 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
686 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
687 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
688 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -700,15 +700,15 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return array |
702 | 702 | */ |
703 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
704 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
703 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
704 | + EE_Registry::instance()->load_helper('URL'); |
|
705 | 705 | //if $message is not an instance of EE_Message then let's just do a dummy. |
706 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
707 | - $action_urls = apply_filters( |
|
706 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
707 | + $action_urls = apply_filters( |
|
708 | 708 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
709 | 709 | array( |
710 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
711 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
710 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
711 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
712 | 712 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
713 | 713 | array_merge( |
714 | 714 | array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | ), |
719 | 719 | $query_params |
720 | 720 | ), |
721 | - admin_url( 'admin.php' ) |
|
721 | + admin_url('admin.php') |
|
722 | 722 | ), |
723 | 723 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
724 | 724 | array( |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'action' => 'generate_now', |
727 | 727 | 'MSG_ID' => $message->ID() |
728 | 728 | ), |
729 | - admin_url( 'admin.php' ) |
|
729 | + admin_url('admin.php') |
|
730 | 730 | ), |
731 | 731 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
732 | 732 | array( |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'action' => 'send_now', |
735 | 735 | 'MSG_ID' => $message->ID() |
736 | 736 | ), |
737 | - admin_url( 'admin.php' ) |
|
737 | + admin_url('admin.php') |
|
738 | 738 | ), |
739 | 739 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
740 | 740 | array( |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'action' => 'queue_for_resending', |
743 | 743 | 'MSG_ID' => $message->ID() |
744 | 744 | ), |
745 | - admin_url( 'admin.php' ) |
|
745 | + admin_url('admin.php') |
|
746 | 746 | ), |
747 | 747 | ) |
748 | 748 | ); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | 'action' => 'view_transaction', |
761 | 761 | 'TXN_ID' => $message->TXN_ID() |
762 | 762 | ), |
763 | - admin_url( 'admin.php' ) |
|
763 | + admin_url('admin.php') |
|
764 | 764 | ); |
765 | 765 | } else { |
766 | 766 | $action_urls['view_transaction'] = ''; |
@@ -781,26 +781,26 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
785 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
786 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
787 | - $title = isset( $icon_css['label'] ) ? 'title="' . $icon_css['label'] . '"' : ''; |
|
784 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
785 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
786 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
787 | + $title = isset($icon_css['label']) ? 'title="'.$icon_css['label'].'"' : ''; |
|
788 | 788 | |
789 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
789 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
790 | 790 | return ''; |
791 | 791 | } |
792 | 792 | |
793 | 793 | $icon_css['css_class'] .= esc_attr( |
794 | 794 | apply_filters( |
795 | 795 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
796 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
796 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
797 | 797 | $type, |
798 | 798 | $message, |
799 | 799 | $query_params |
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | |
803 | - return '<a href="' . $url . '"' . $title . '><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
803 | + return '<a href="'.$url.'"'.$title.'><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
804 | 804 | |
805 | 805 | } |
806 | 806 | |
@@ -838,9 +838,9 @@ discard block |
||
838 | 838 | * @param $reg_status |
839 | 839 | * @return string |
840 | 840 | */ |
841 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
841 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
842 | 842 | $reg_status_array = self::reg_status_to_message_type_array(); |
843 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
843 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | |
@@ -874,9 +874,9 @@ discard block |
||
874 | 874 | * @param $payment_status |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
877 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
878 | 878 | $payment_status_array = self::payment_status_to_message_type_array(); |
879 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
879 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -887,32 +887,32 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @return EE_Messages_Template_Pack |
889 | 889 | */ |
890 | - public static function get_template_pack( $template_pack_name ) { |
|
891 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
890 | + public static function get_template_pack($template_pack_name) { |
|
891 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
892 | 892 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
893 | 893 | } |
894 | 894 | |
895 | 895 | //first see if in collection already |
896 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
896 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
897 | 897 | |
898 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
898 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
899 | 899 | return $template_pack; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //nope...let's get it. |
903 | 903 | //not set yet so let's attempt to get it. |
904 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
904 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
905 | 905 | ' ', |
906 | 906 | '_', |
907 | 907 | ucwords( |
908 | - str_replace( '_', ' ', $template_pack_name ) |
|
908 | + str_replace('_', ' ', $template_pack_name) |
|
909 | 909 | ) |
910 | 910 | ); |
911 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
912 | - return self::get_template_pack( 'default' ); |
|
911 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
912 | + return self::get_template_pack('default'); |
|
913 | 913 | } else { |
914 | 914 | $template_pack = new $pack_class_name; |
915 | - self::$_template_pack_collection->add( $template_pack ); |
|
915 | + self::$_template_pack_collection->add($template_pack); |
|
916 | 916 | return $template_pack; |
917 | 917 | } |
918 | 918 | } |
@@ -930,26 +930,26 @@ discard block |
||
930 | 930 | */ |
931 | 931 | public static function get_template_pack_collection() { |
932 | 932 | $new_collection = false; |
933 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
933 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
934 | 934 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
935 | 935 | $new_collection = true; |
936 | 936 | } |
937 | 937 | |
938 | 938 | //glob the defaults directory for messages |
939 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
940 | - foreach( $templates as $template_path ) { |
|
939 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
940 | + foreach ($templates as $template_path) { |
|
941 | 941 | //grab folder name |
942 | - $template = basename( $template_path ); |
|
942 | + $template = basename($template_path); |
|
943 | 943 | |
944 | - if ( ! $new_collection ) { |
|
944 | + if ( ! $new_collection) { |
|
945 | 945 | //already have it? |
946 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
946 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
947 | 947 | continue; |
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
951 | 951 | //setup classname. |
952 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
952 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
953 | 953 | ' ', |
954 | 954 | '_', |
955 | 955 | ucwords( |
@@ -960,20 +960,20 @@ discard block |
||
960 | 960 | ) |
961 | 961 | ) |
962 | 962 | ); |
963 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
963 | + if ( ! class_exists($template_pack_class_name)) { |
|
964 | 964 | continue; |
965 | 965 | } |
966 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
966 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
970 | 970 | * Filter for plugins to add in any additional template packs |
971 | 971 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
972 | 972 | */ |
973 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
974 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
975 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
976 | - self::$_template_pack_collection->add( $template_pack ); |
|
973 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
974 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
975 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
976 | + self::$_template_pack_collection->add($template_pack); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | return self::$_template_pack_collection; |
@@ -991,16 +991,16 @@ discard block |
||
991 | 991 | * @return array |
992 | 992 | * @throws \EE_Error |
993 | 993 | */ |
994 | - public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
994 | + public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
995 | 995 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
996 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
997 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
998 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
999 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
996 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
997 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
998 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
999 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
1000 | 1000 | return array(); |
1001 | 1001 | } |
1002 | 1002 | //whew made it this far! Okay, let's go ahead and create the templates then |
1003 | - return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
1003 | + return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
@@ -1012,15 +1012,15 @@ discard block |
||
1012 | 1012 | * @param $global |
1013 | 1013 | * @return array|mixed |
1014 | 1014 | */ |
1015 | - protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
1015 | + protected static function _create_new_templates(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
1016 | 1016 | //if we're creating a custom template then we don't need to use the defaults class |
1017 | - if ( ! $global ) { |
|
1018 | - return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
1017 | + if ( ! $global) { |
|
1018 | + return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
1019 | 1019 | } |
1020 | 1020 | /** @type EE_Messages_Template_Defaults $Message_Template_Defaults */ |
1021 | 1021 | $Message_Template_Defaults = EE_Registry::factory( |
1022 | 1022 | 'EE_Messages_Template_Defaults', |
1023 | - array( $messenger, $message_type, $GRP_ID ) |
|
1023 | + array($messenger, $message_type, $GRP_ID) |
|
1024 | 1024 | ); |
1025 | 1025 | //generate templates |
1026 | 1026 | $success = $Message_Template_Defaults->create_new_templates(); |
@@ -1028,10 +1028,10 @@ discard block |
||
1028 | 1028 | //if creating the template failed. Then we should deactivate the related message_type for the messenger because |
1029 | 1029 | //its not active if it doesn't have a template. Note this is only happening for GLOBAL template creation |
1030 | 1030 | //attempts. |
1031 | - if ( ! $success ) { |
|
1031 | + if ( ! $success) { |
|
1032 | 1032 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
1033 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1034 | - $message_resource_manager->deactivate_message_type_for_messenger( $message_type->name, $messenger->name ); |
|
1033 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1034 | + $message_resource_manager->deactivate_message_type_for_messenger($message_type->name, $messenger->name); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -1059,11 +1059,11 @@ discard block |
||
1059 | 1059 | * ) |
1060 | 1060 | * @access private |
1061 | 1061 | */ |
1062 | - private static function _create_custom_template_group( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1062 | + private static function _create_custom_template_group(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1063 | 1063 | //defaults |
1064 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1064 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1065 | 1065 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
1066 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1066 | + $Message_Template_Group = empty($GRP_ID) |
|
1067 | 1067 | ? EEM_Message_Template_Group::instance()->get_one( |
1068 | 1068 | array( |
1069 | 1069 | array( |
@@ -1073,9 +1073,9 @@ discard block |
||
1073 | 1073 | ) |
1074 | 1074 | ) |
1075 | 1075 | ) |
1076 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1076 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1077 | 1077 | //if we don't have a mtg at this point then we need to bail. |
1078 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1078 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1079 | 1079 | EE_Error::add_error( |
1080 | 1080 | sprintf( |
1081 | 1081 | __( |
@@ -1094,42 +1094,42 @@ discard block |
||
1094 | 1094 | $message_templates = $Message_Template_Group->message_templates(); |
1095 | 1095 | //now we have what we need to setup the new template |
1096 | 1096 | $new_mtg = clone $Message_Template_Group; |
1097 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1098 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1099 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1100 | - ? $_POST[ 'templateName' ] |
|
1097 | + $new_mtg->set('GRP_ID', 0); |
|
1098 | + $new_mtg->set('MTP_is_global', false); |
|
1099 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1100 | + ? $_POST['templateName'] |
|
1101 | 1101 | : __( |
1102 | 1102 | 'New Custom Template', |
1103 | 1103 | 'event_espresso' |
1104 | 1104 | ); |
1105 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1106 | - ? $_POST[ 'templateDescription' ] |
|
1105 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1106 | + ? $_POST['templateDescription'] |
|
1107 | 1107 | : sprintf( |
1108 | 1108 | __( |
1109 | 1109 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1110 | 1110 | 'event_espresso' |
1111 | 1111 | ), |
1112 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1113 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1112 | + $new_mtg->messenger_obj()->label['singular'], |
|
1113 | + $new_mtg->message_type_obj()->label['singular'] |
|
1114 | 1114 | ); |
1115 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1116 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1115 | + $new_mtg->set('MTP_name', $template_name); |
|
1116 | + $new_mtg->set('MTP_description', $template_description); |
|
1117 | 1117 | //remove ALL relations on this template group so they don't get saved! |
1118 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1118 | + $new_mtg->_remove_relations('Message_Template'); |
|
1119 | 1119 | $new_mtg->save(); |
1120 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1121 | - $success[ 'template_name' ] = $template_name; |
|
1120 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1121 | + $success['template_name'] = $template_name; |
|
1122 | 1122 | //add new message templates and add relation to. |
1123 | - foreach ( $message_templates as $message_template ) { |
|
1124 | - if ( ! $message_template instanceof EE_Message_Template ) { |
|
1123 | + foreach ($message_templates as $message_template) { |
|
1124 | + if ( ! $message_template instanceof EE_Message_Template) { |
|
1125 | 1125 | continue; |
1126 | 1126 | } |
1127 | 1127 | $new_message_template = clone $message_template; |
1128 | - $new_message_template->set( 'MTP_ID', 0 ); |
|
1129 | - $new_message_template->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1128 | + $new_message_template->set('MTP_ID', 0); |
|
1129 | + $new_message_template->set('GRP_ID', $new_mtg->ID()); //relation |
|
1130 | 1130 | $new_message_template->save(); |
1131 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1132 | - $success[ 'MTP_context' ] = $new_message_template->get( 'MTP_context' ); |
|
1131 | + if (empty($success['MTP_context'])) { |
|
1132 | + $success['MTP_context'] = $new_message_template->get('MTP_context'); |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | return $success; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $global = false |
1152 | 1152 | ) { |
1153 | 1153 | //is given message_type valid for given messenger (if this is not a global save) |
1154 | - if ( $global ) { |
|
1154 | + if ($global) { |
|
1155 | 1155 | return true; |
1156 | 1156 | } |
1157 | 1157 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | ) |
1164 | 1164 | ) |
1165 | 1165 | ); |
1166 | - if ( $active_templates > 0 ) { |
|
1166 | + if ($active_templates > 0) { |
|
1167 | 1167 | return true; |
1168 | 1168 | } |
1169 | 1169 | EE_Error::add_error( |
@@ -1192,24 +1192,24 @@ discard block |
||
1192 | 1192 | * @param string $message_type_name name of EE_message_type |
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | - public static function get_fields( $messenger_name, $message_type_name ) { |
|
1195 | + public static function get_fields($messenger_name, $message_type_name) { |
|
1196 | 1196 | $template_fields = array(); |
1197 | 1197 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1198 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1199 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1200 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1201 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1198 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1199 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1200 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1201 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1202 | 1202 | return array(); |
1203 | 1203 | } |
1204 | 1204 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1205 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1206 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1207 | - $template_fields[ $context ][ $field ] = $value; |
|
1205 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1206 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1207 | + $template_fields[$context][$field] = $value; |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | - if ( empty( $template_fields ) ) { |
|
1210 | + if (empty($template_fields)) { |
|
1211 | 1211 | EE_Error::add_error( |
1212 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1212 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1213 | 1213 | __FILE__, |
1214 | 1214 | __FUNCTION__, |
1215 | 1215 | __LINE__ |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -17,818 +17,818 @@ discard block |
||
17 | 17 | class EED_Core_Rest_Api extends \EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - const ee_api_namespace = 'ee/v'; |
|
20 | + const ee_api_namespace = 'ee/v'; |
|
21 | 21 | |
22 | - const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/'; |
|
22 | + const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/'; |
|
23 | 23 | |
24 | - const saved_routes_option_names = 'ee_core_routes'; |
|
24 | + const saved_routes_option_names = 'ee_core_routes'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * string used in _links response bodies to make them globally unique. |
|
28 | - * |
|
29 | - * @see http://v2.wp-api.org/extending/linking/ |
|
30 | - */ |
|
31 | - const ee_api_link_namespace = 'https://api.eventespresso.com/'; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var Calculated_Model_Fields |
|
35 | - */ |
|
36 | - protected static $_field_calculator = null; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return EED_Core_Rest_Api |
|
42 | - */ |
|
43 | - public static function instance() |
|
44 | - { |
|
45 | - self::$_field_calculator = new Calculated_Model_Fields(); |
|
46 | - return parent::get_instance(__CLASS__); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public static function set_hooks() |
|
58 | - { |
|
59 | - self::set_hooks_both(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public static function set_hooks_admin() |
|
71 | - { |
|
72 | - self::set_hooks_both(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - public static function set_hooks_both() |
|
78 | - { |
|
79 | - add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
80 | - add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
81 | - add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
82 | - add_filter('rest_index', |
|
83 | - array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
84 | - EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * sets up hooks which only need to be included as part of REST API requests; |
|
91 | - * other requests like to the frontend or admin etc don't need them |
|
92 | - */ |
|
93 | - public static function set_hooks_rest_api() |
|
94 | - { |
|
95 | - //set hooks which account for changes made to the API |
|
96 | - EED_Core_Rest_Api::_set_hooks_for_changes(); |
|
97 | - EED_Core_Rest_Api::maybe_notify_of_basic_auth_removal(); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * public wrapper of _set_hooks_for_changes. |
|
104 | - * Loads all the hooks which make requests to old versions of the API |
|
105 | - * appear the same as they always did |
|
106 | - */ |
|
107 | - public static function set_hooks_for_changes() |
|
108 | - { |
|
109 | - self::_set_hooks_for_changes(); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * If the user appears to be using WP API basic auth, tell them (via a persistent |
|
116 | - * admin notice and an email) that we're going to remove it soon, so they should |
|
117 | - * replace it with application passwords. |
|
118 | - */ |
|
119 | - public static function maybe_notify_of_basic_auth_removal() |
|
120 | - { |
|
121 | - if ( |
|
122 | - apply_filters( |
|
123 | - 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
|
124 | - ! isset($_SERVER['PHP_AUTH_USER']) |
|
125 | - && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
126 | - ) |
|
127 | - ) { |
|
128 | - //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
|
129 | - return; |
|
130 | - } |
|
131 | - //ok they're using the WP API with Basic Auth |
|
132 | - $message = sprintf( |
|
133 | - __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', |
|
134 | - 'event_espresso'), |
|
135 | - '<a href="https://wordpress.org/plugins/application-passwords/">', |
|
136 | - '</a>', |
|
137 | - '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
|
138 | - '<br/>' |
|
139 | - ); |
|
140 | - EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
141 | - if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
142 | - add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
143 | - //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
|
144 | - add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
145 | - //and send the message to the site admin too |
|
146 | - wp_mail(get_option('admin_email'), |
|
147 | - __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
148 | - remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * Loads all the hooks which make requests to old versions of the API |
|
156 | - * appear the same as they always did |
|
157 | - */ |
|
158 | - protected static function _set_hooks_for_changes() |
|
159 | - { |
|
160 | - $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
161 | - foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
162 | - //ignore the base parent class |
|
163 | - if ($classname_in_namespace === 'Changes_In_Base') { |
|
164 | - continue; |
|
165 | - } |
|
166 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
167 | - if (class_exists($full_classname)) { |
|
168 | - $instance_of_class = new $full_classname; |
|
169 | - if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
170 | - $instance_of_class->set_hooks(); |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * Filters the WP routes to add our EE-related ones. This takes a bit of time |
|
180 | - * so we actually prefer to only do it when an EE plugin is activated or upgraded |
|
181 | - */ |
|
182 | - public static function register_routes() |
|
183 | - { |
|
184 | - foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
185 | - foreach ($relative_urls as $endpoint => $routes) { |
|
186 | - foreach ($routes as $route) { |
|
187 | - register_rest_route( |
|
188 | - $namespace, |
|
189 | - $endpoint, |
|
190 | - array( |
|
191 | - 'callback' => $route['callback'], |
|
192 | - 'methods' => $route['methods'], |
|
193 | - 'args' => isset($route['args']) ? $route['args'] : array(), |
|
194 | - ) |
|
195 | - ); |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Checks if there was a version change or something that merits invalidating the cached |
|
205 | - * route data. If so, invalidates the cached route data so that it gets refreshed |
|
206 | - * next time the WP API is used |
|
207 | - */ |
|
208 | - public static function invalidate_cached_route_data_on_version_change() |
|
209 | - { |
|
210 | - if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
211 | - EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
212 | - } |
|
213 | - foreach (EE_Registry::instance()->addons as $addon) { |
|
214 | - if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
215 | - EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * Removes the cached route data so it will get refreshed next time the WP API is used |
|
224 | - */ |
|
225 | - public static function invalidate_cached_route_data() |
|
226 | - { |
|
227 | - //delete the saved EE REST API routes |
|
228 | - foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
229 | - delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Gets the EE route data |
|
237 | - * |
|
238 | - * @return array top-level key is the namespace, next-level key is the route and its value is array{ |
|
239 | - * @type string|array $callback |
|
240 | - * @type string $methods |
|
241 | - * @type boolean $hidden_endpoint |
|
242 | - * } |
|
243 | - */ |
|
244 | - public static function get_ee_route_data() |
|
245 | - { |
|
246 | - $ee_routes = array(); |
|
247 | - foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
248 | - $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
249 | - $hidden_endpoints); |
|
250 | - } |
|
251 | - return $ee_routes; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Gets the EE route data from the wp options if it exists already, |
|
258 | - * otherwise re-generates it and saves it to the option |
|
259 | - * |
|
260 | - * @param string $version |
|
261 | - * @param boolean $hidden_endpoints |
|
262 | - * @return array |
|
263 | - */ |
|
264 | - protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
265 | - { |
|
266 | - $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
267 | - if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
268 | - $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
269 | - } |
|
270 | - return $ee_routes; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Saves the EE REST API route data to a wp option and returns it |
|
277 | - * |
|
278 | - * @param string $version |
|
279 | - * @param boolean $hidden_endpoints |
|
280 | - * @return mixed|null|void |
|
281 | - */ |
|
282 | - protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
283 | - { |
|
284 | - $instance = self::instance(); |
|
285 | - $routes = apply_filters( |
|
286 | - 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
|
287 | - array_replace_recursive( |
|
288 | - $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
289 | - $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
290 | - $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
291 | - $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
292 | - ) |
|
293 | - ); |
|
294 | - $option_name = self::saved_routes_option_names . $version; |
|
295 | - if (get_option($option_name)) { |
|
296 | - update_option($option_name, $routes, true); |
|
297 | - } else { |
|
298 | - add_option($option_name, $routes, null, 'no'); |
|
299 | - } |
|
300 | - return $routes; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * Calculates all the EE routes and saves it to a wordpress option so we don't |
|
307 | - * need to calculate it on every request |
|
308 | - * |
|
309 | - * @deprecated since version 4.9.1 |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - public static function save_ee_routes() |
|
313 | - { |
|
314 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
315 | - $instance = self::instance(); |
|
316 | - $routes = apply_filters( |
|
317 | - 'EED_Core_Rest_Api__save_ee_routes__routes', |
|
318 | - array_replace_recursive( |
|
319 | - $instance->_register_config_routes(), |
|
320 | - $instance->_register_meta_routes(), |
|
321 | - $instance->_register_model_routes(), |
|
322 | - $instance->_register_rpc_routes() |
|
323 | - ) |
|
324 | - ); |
|
325 | - update_option(self::saved_routes_option_names, $routes, true); |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * Gets all the route information relating to EE models |
|
333 | - * |
|
334 | - * @return array @see get_ee_route_data |
|
335 | - * @deprecated since version 4.9.1 |
|
336 | - */ |
|
337 | - protected function _register_model_routes() |
|
338 | - { |
|
339 | - $model_routes = array(); |
|
340 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
341 | - $model_routes[EED_Core_Rest_Api::ee_api_namespace |
|
342 | - . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
343 | - } |
|
344 | - return $model_routes; |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * Gets the route data for EE models in the specified version |
|
351 | - * |
|
352 | - * @param string $version |
|
353 | - * @param boolean $hidden_endpoint |
|
354 | - * @return array |
|
355 | - */ |
|
356 | - protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) |
|
357 | - { |
|
358 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
359 | - $models_to_register = apply_filters( |
|
360 | - 'FHEE__EED_Core_REST_API___register_model_routes', |
|
361 | - $model_version_info->models_for_requested_version() |
|
362 | - ); |
|
363 | - //let's not bother having endpoints for extra metas |
|
364 | - unset($models_to_register['Extra_Meta']); |
|
365 | - unset($models_to_register['Extra_Join']); |
|
366 | - $model_routes = array(); |
|
367 | - foreach ($models_to_register as $model_name => $model_classname) { |
|
368 | - $model = \EE_Registry::instance()->load_model($model_name); |
|
369 | - //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
|
370 | - $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
371 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
372 | - $model_routes[$plural_model_route] = array( |
|
373 | - array( |
|
374 | - 'callback' => array( |
|
375 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
376 | - 'handle_request_get_all', |
|
377 | - ), |
|
378 | - 'methods' => WP_REST_Server::READABLE, |
|
379 | - 'hidden_endpoint' => $hidden_endpoint, |
|
380 | - 'args' => $this->_get_read_query_params($model, $version), |
|
381 | - '_links' => array( |
|
382 | - 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
383 | - ), |
|
384 | - ), |
|
385 | - // array( |
|
386 | - // 'callback' => array( |
|
387 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
388 | - // 'handle_request_create_one' ), |
|
389 | - // 'methods' => WP_REST_Server::CREATABLE, |
|
390 | - // 'hidden_endpoint' => $hidden_endpoint |
|
391 | - // ) |
|
392 | - ); |
|
393 | - $model_routes[$singular_model_route] = array( |
|
394 | - array( |
|
395 | - 'callback' => array( |
|
396 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
397 | - 'handle_request_get_one', |
|
398 | - ), |
|
399 | - 'methods' => WP_REST_Server::READABLE, |
|
400 | - 'hidden_endpoint' => $hidden_endpoint, |
|
401 | - 'args' => $this->_get_response_selection_query_params($model, $version), |
|
402 | - ), |
|
403 | - // array( |
|
404 | - // 'callback' => array( |
|
405 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
406 | - // 'handle_request_edit_one' ), |
|
407 | - // 'methods' => WP_REST_Server::EDITABLE, |
|
408 | - // 'hidden_endpoint' => $hidden_endpoint |
|
409 | - // ), |
|
410 | - ); |
|
411 | - //@todo: also handle DELETE for a single item |
|
412 | - foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
413 | - $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
|
414 | - $relation_name, |
|
415 | - $relation_obj |
|
416 | - ); |
|
417 | - $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
418 | - array( |
|
419 | - 'callback' => array( |
|
420 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
421 | - 'handle_request_get_related', |
|
422 | - ), |
|
423 | - 'methods' => WP_REST_Server::READABLE, |
|
424 | - 'hidden_endpoint' => $hidden_endpoint, |
|
425 | - 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
426 | - ), |
|
427 | - // array( |
|
428 | - // 'callback' => array( |
|
429 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
430 | - // 'handle_request_create_or_update_related' ), |
|
431 | - // 'methods' => WP_REST_Server::EDITABLE, |
|
432 | - // 'hidden_endpoint' => $hidden_endpoint |
|
433 | - // ) |
|
434 | - ); |
|
435 | - //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish) |
|
436 | - } |
|
437 | - } |
|
438 | - return $model_routes; |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * Adds all the RPC-style routes (remote procedure call-like routes, ie |
|
445 | - * routes that don't conform to the traditional REST CRUD-style). |
|
446 | - * |
|
447 | - * @deprecated since 4.9.1 |
|
448 | - */ |
|
449 | - protected function _register_rpc_routes() |
|
450 | - { |
|
451 | - $routes = array(); |
|
452 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
453 | - $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | - $hidden_endpoint); |
|
455 | - } |
|
456 | - return $routes; |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * @param string $version |
|
463 | - * @param boolean $hidden_endpoint |
|
464 | - * @return array |
|
465 | - */ |
|
466 | - protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) |
|
467 | - { |
|
468 | - $this_versions_routes = array(); |
|
469 | - //checkin endpoint |
|
470 | - $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
471 | - array( |
|
472 | - 'callback' => array( |
|
473 | - 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
|
474 | - 'handle_request_toggle_checkin', |
|
475 | - ), |
|
476 | - 'methods' => WP_REST_Server::CREATABLE, |
|
477 | - 'hidden_endpoint' => $hidden_endpoint, |
|
478 | - 'args' => array( |
|
479 | - 'force' => array( |
|
480 | - 'required' => false, |
|
481 | - 'default' => false, |
|
482 | - 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', |
|
483 | - 'event_espresso'), |
|
484 | - ), |
|
485 | - ), |
|
486 | - ), |
|
487 | - ); |
|
488 | - return apply_filters( |
|
489 | - 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
490 | - $this_versions_routes, |
|
491 | - $version, |
|
492 | - $hidden_endpoint |
|
493 | - ); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * Gets the query params that can be used when request one or many |
|
500 | - * |
|
501 | - * @param EEM_Base $model |
|
502 | - * @param string $version |
|
503 | - * @return array |
|
504 | - */ |
|
505 | - protected function _get_response_selection_query_params(\EEM_Base $model, $version) |
|
506 | - { |
|
507 | - return apply_filters( |
|
508 | - 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
|
509 | - array( |
|
510 | - 'include' => array( |
|
511 | - 'required' => false, |
|
512 | - 'default' => '*', |
|
513 | - ), |
|
514 | - 'calculate' => array( |
|
515 | - 'required' => false, |
|
516 | - 'default' => '', |
|
517 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model), |
|
518 | - ), |
|
519 | - ), |
|
520 | - $model, |
|
521 | - $version |
|
522 | - ); |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - |
|
527 | - /** |
|
528 | - * Gets info about reading query params that are acceptable |
|
529 | - * |
|
530 | - * @param \EEM_Base $model eg 'Event' or 'Venue' |
|
531 | - * @param string $version |
|
532 | - * @return array describing the args acceptable when querying this model |
|
533 | - * @throws \EE_Error |
|
534 | - */ |
|
535 | - protected function _get_read_query_params(\EEM_Base $model, $version) |
|
536 | - { |
|
537 | - $default_orderby = array(); |
|
538 | - foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
539 | - $default_orderby[$key_field->get_name()] = 'ASC'; |
|
540 | - } |
|
541 | - return array_merge( |
|
542 | - $this->_get_response_selection_query_params($model, $version), |
|
543 | - array( |
|
544 | - 'where' => array( |
|
545 | - 'required' => false, |
|
546 | - 'default' => array(), |
|
547 | - ), |
|
548 | - 'limit' => array( |
|
549 | - 'required' => false, |
|
550 | - 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
|
551 | - ), |
|
552 | - 'order_by' => array( |
|
553 | - 'required' => false, |
|
554 | - 'default' => $default_orderby, |
|
555 | - ), |
|
556 | - 'group_by' => array( |
|
557 | - 'required' => false, |
|
558 | - 'default' => null, |
|
559 | - ), |
|
560 | - 'having' => array( |
|
561 | - 'required' => false, |
|
562 | - 'default' => null, |
|
563 | - ), |
|
564 | - 'caps' => array( |
|
565 | - 'required' => false, |
|
566 | - 'default' => EEM_Base::caps_read, |
|
567 | - ), |
|
568 | - ) |
|
569 | - ); |
|
570 | - } |
|
571 | - |
|
572 | - |
|
573 | - |
|
574 | - /** |
|
575 | - * Gets routes for the config |
|
576 | - * |
|
577 | - * @return array @see _register_model_routes |
|
578 | - * @deprecated since version 4.9.1 |
|
579 | - */ |
|
580 | - protected function _register_config_routes() |
|
581 | - { |
|
582 | - $config_routes = array(); |
|
583 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
584 | - $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
585 | - $hidden_endpoint); |
|
586 | - } |
|
587 | - return $config_routes; |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * Gets routes for the config for the specified version |
|
594 | - * |
|
595 | - * @param string $version |
|
596 | - * @param boolean $hidden_endpoint |
|
597 | - * @return array |
|
598 | - */ |
|
599 | - protected function _get_config_route_data_for_version($version, $hidden_endpoint) |
|
600 | - { |
|
601 | - return array( |
|
602 | - 'config' => array( |
|
603 | - array( |
|
604 | - 'callback' => array( |
|
605 | - 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
606 | - 'handle_request', |
|
607 | - ), |
|
608 | - 'methods' => WP_REST_Server::READABLE, |
|
609 | - 'hidden_endpoint' => $hidden_endpoint, |
|
610 | - ), |
|
611 | - ), |
|
612 | - 'site_info' => array( |
|
613 | - array( |
|
614 | - 'callback' => array( |
|
615 | - 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
616 | - 'handle_request_site_info', |
|
617 | - ), |
|
618 | - 'methods' => WP_REST_Server::READABLE, |
|
619 | - 'hidden_endpoint' => $hidden_endpoint, |
|
620 | - ), |
|
621 | - ), |
|
622 | - ); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * Gets the meta info routes |
|
629 | - * |
|
630 | - * @return array @see _register_model_routes |
|
631 | - * @deprecated since version 4.9.1 |
|
632 | - */ |
|
633 | - protected function _register_meta_routes() |
|
634 | - { |
|
635 | - $meta_routes = array(); |
|
636 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
637 | - $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
638 | - $hidden_endpoint); |
|
639 | - } |
|
640 | - return $meta_routes; |
|
641 | - } |
|
642 | - |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * @param string $version |
|
647 | - * @param boolean $hidden_endpoint |
|
648 | - * @return array |
|
649 | - */ |
|
650 | - protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) |
|
651 | - { |
|
652 | - return array( |
|
653 | - 'resources' => array( |
|
654 | - array( |
|
655 | - 'callback' => array( |
|
656 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
|
657 | - 'handle_request_models_meta', |
|
658 | - ), |
|
659 | - 'methods' => WP_REST_Server::READABLE, |
|
660 | - 'hidden_endpoint' => $hidden_endpoint, |
|
661 | - ), |
|
662 | - ), |
|
663 | - ); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * Tries to hide old 4.6 endpoints from the |
|
670 | - * |
|
671 | - * @param array $route_data |
|
672 | - * @return array |
|
673 | - */ |
|
674 | - public static function hide_old_endpoints($route_data) |
|
675 | - { |
|
676 | - //allow API clients to override which endpoints get hidden, in case |
|
677 | - //they want to discover particular endpoints |
|
678 | - //also, we don't have access to the request so we have to just grab it from the superglobal |
|
679 | - $force_show_ee_namespace = ltrim( |
|
680 | - EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
681 | - '/' |
|
682 | - ); |
|
683 | - foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
684 | - foreach ($relative_urls as $endpoint => $routes) { |
|
685 | - foreach ($routes as $route) { |
|
686 | - //by default, hide "hidden_endpoint"s, unless the request indicates |
|
687 | - //to $force_show_ee_namespace, in which case only show that one |
|
688 | - //namespace's endpoints (and hide all others) |
|
689 | - if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
690 | - || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
|
691 | - ) { |
|
692 | - $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
693 | - unset($route_data[$full_route]); |
|
694 | - } |
|
695 | - } |
|
696 | - } |
|
697 | - } |
|
698 | - return $route_data; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * Returns an array describing which versions of core support serving requests for. |
|
705 | - * Keys are core versions' major and minor version, and values are the |
|
706 | - * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like |
|
707 | - * data by just removing a few models and fields from the responses. However, 4.15 might remove |
|
708 | - * the answers table entirely, in which case it would be very difficult for |
|
709 | - * it to serve 4.6-style responses. |
|
710 | - * Versions of core that are missing from this array are unknowns. |
|
711 | - * previous ver |
|
712 | - * |
|
713 | - * @return array |
|
714 | - */ |
|
715 | - public static function version_compatibilities() |
|
716 | - { |
|
717 | - return apply_filters( |
|
718 | - 'FHEE__EED_Core_REST_API__version_compatibilities', |
|
719 | - array( |
|
720 | - '4.8.29' => '4.8.29', |
|
721 | - '4.8.33' => '4.8.29', |
|
722 | - '4.8.34' => '4.8.29', |
|
723 | - '4.8.36' => '4.8.29', |
|
724 | - ) |
|
725 | - ); |
|
726 | - } |
|
727 | - |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * Gets the latest API version served. Eg if there |
|
732 | - * are two versions served of the API, 4.8.29 and 4.8.32, and |
|
733 | - * we are on core version 4.8.34, it will return the string "4.8.32" |
|
734 | - * |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public static function latest_rest_api_version() |
|
738 | - { |
|
739 | - $versions_served = \EED_Core_Rest_Api::versions_served(); |
|
740 | - $versions_served_keys = array_keys($versions_served); |
|
741 | - return end($versions_served_keys); |
|
742 | - } |
|
743 | - |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of |
|
748 | - * EE the API can serve requests for. Eg, if we are on 4.15 of core, and |
|
749 | - * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ). |
|
750 | - * We also indicate whether or not this version should be put in the index or not |
|
751 | - * |
|
752 | - * @return array keys are API version numbers (just major and minor numbers), and values |
|
753 | - * are whether or not they should be hidden |
|
754 | - */ |
|
755 | - public static function versions_served() |
|
756 | - { |
|
757 | - $versions_served = array(); |
|
758 | - $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
|
759 | - $lowest_compatible_version = end($possibly_served_versions); |
|
760 | - reset($possibly_served_versions); |
|
761 | - $versions_served_historically = array_keys($possibly_served_versions); |
|
762 | - $latest_version = end($versions_served_historically); |
|
763 | - reset($versions_served_historically); |
|
764 | - //for each version of core we have ever served: |
|
765 | - foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
766 | - //if it's not above the current core version, and it's compatible with the current version of core |
|
767 | - if ($key_versioned_endpoint == $latest_version) { |
|
768 | - //don't hide the latest version in the index |
|
769 | - $versions_served[$key_versioned_endpoint] = false; |
|
770 | - } else if ( |
|
771 | - $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
|
772 | - && $key_versioned_endpoint >= $lowest_compatible_version |
|
773 | - ) { |
|
774 | - //include, but hide, previous versions which are still supported |
|
775 | - $versions_served[$key_versioned_endpoint] = true; |
|
776 | - } elseif ( |
|
777 | - apply_filters( |
|
778 | - 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
|
779 | - false, |
|
780 | - $possibly_served_versions |
|
781 | - ) |
|
782 | - ) { |
|
783 | - //if a version is no longer supported, don't include it in index or list of versions served |
|
784 | - $versions_served[$key_versioned_endpoint] = true; |
|
785 | - } |
|
786 | - } |
|
787 | - return $versions_served; |
|
788 | - } |
|
789 | - |
|
790 | - |
|
791 | - |
|
792 | - /** |
|
793 | - * Gets the major and minor version of EE core's version string |
|
794 | - * |
|
795 | - * @return string |
|
796 | - */ |
|
797 | - public static function core_version() |
|
798 | - { |
|
799 | - return apply_filters('FHEE__EED_Core_REST_API__core_version', |
|
800 | - implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
801 | - } |
|
802 | - |
|
803 | - |
|
804 | - |
|
805 | - /** |
|
806 | - * Gets the default limit that should be used when querying for resources |
|
807 | - * |
|
808 | - * @return int |
|
809 | - */ |
|
810 | - public static function get_default_query_limit() |
|
811 | - { |
|
812 | - //we actually don't use a const because we want folks to always use |
|
813 | - //this method, not the const directly |
|
814 | - return apply_filters( |
|
815 | - 'FHEE__EED_Core_Rest_Api__get_default_query_limit', |
|
816 | - 50 |
|
817 | - ); |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - |
|
822 | - /** |
|
823 | - * run - initial module setup |
|
824 | - * |
|
825 | - * @access public |
|
826 | - * @param WP $WP |
|
827 | - * @return void |
|
828 | - */ |
|
829 | - public function run($WP) |
|
830 | - { |
|
831 | - } |
|
26 | + /** |
|
27 | + * string used in _links response bodies to make them globally unique. |
|
28 | + * |
|
29 | + * @see http://v2.wp-api.org/extending/linking/ |
|
30 | + */ |
|
31 | + const ee_api_link_namespace = 'https://api.eventespresso.com/'; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var Calculated_Model_Fields |
|
35 | + */ |
|
36 | + protected static $_field_calculator = null; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return EED_Core_Rest_Api |
|
42 | + */ |
|
43 | + public static function instance() |
|
44 | + { |
|
45 | + self::$_field_calculator = new Calculated_Model_Fields(); |
|
46 | + return parent::get_instance(__CLASS__); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public static function set_hooks() |
|
58 | + { |
|
59 | + self::set_hooks_both(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public static function set_hooks_admin() |
|
71 | + { |
|
72 | + self::set_hooks_both(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + public static function set_hooks_both() |
|
78 | + { |
|
79 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
80 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
81 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
82 | + add_filter('rest_index', |
|
83 | + array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
84 | + EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * sets up hooks which only need to be included as part of REST API requests; |
|
91 | + * other requests like to the frontend or admin etc don't need them |
|
92 | + */ |
|
93 | + public static function set_hooks_rest_api() |
|
94 | + { |
|
95 | + //set hooks which account for changes made to the API |
|
96 | + EED_Core_Rest_Api::_set_hooks_for_changes(); |
|
97 | + EED_Core_Rest_Api::maybe_notify_of_basic_auth_removal(); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * public wrapper of _set_hooks_for_changes. |
|
104 | + * Loads all the hooks which make requests to old versions of the API |
|
105 | + * appear the same as they always did |
|
106 | + */ |
|
107 | + public static function set_hooks_for_changes() |
|
108 | + { |
|
109 | + self::_set_hooks_for_changes(); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * If the user appears to be using WP API basic auth, tell them (via a persistent |
|
116 | + * admin notice and an email) that we're going to remove it soon, so they should |
|
117 | + * replace it with application passwords. |
|
118 | + */ |
|
119 | + public static function maybe_notify_of_basic_auth_removal() |
|
120 | + { |
|
121 | + if ( |
|
122 | + apply_filters( |
|
123 | + 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
|
124 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
125 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
126 | + ) |
|
127 | + ) { |
|
128 | + //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
|
129 | + return; |
|
130 | + } |
|
131 | + //ok they're using the WP API with Basic Auth |
|
132 | + $message = sprintf( |
|
133 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', |
|
134 | + 'event_espresso'), |
|
135 | + '<a href="https://wordpress.org/plugins/application-passwords/">', |
|
136 | + '</a>', |
|
137 | + '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
|
138 | + '<br/>' |
|
139 | + ); |
|
140 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
141 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
142 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
143 | + //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
|
144 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
145 | + //and send the message to the site admin too |
|
146 | + wp_mail(get_option('admin_email'), |
|
147 | + __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
148 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * Loads all the hooks which make requests to old versions of the API |
|
156 | + * appear the same as they always did |
|
157 | + */ |
|
158 | + protected static function _set_hooks_for_changes() |
|
159 | + { |
|
160 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
161 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
162 | + //ignore the base parent class |
|
163 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
164 | + continue; |
|
165 | + } |
|
166 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
167 | + if (class_exists($full_classname)) { |
|
168 | + $instance_of_class = new $full_classname; |
|
169 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
170 | + $instance_of_class->set_hooks(); |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * Filters the WP routes to add our EE-related ones. This takes a bit of time |
|
180 | + * so we actually prefer to only do it when an EE plugin is activated or upgraded |
|
181 | + */ |
|
182 | + public static function register_routes() |
|
183 | + { |
|
184 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
185 | + foreach ($relative_urls as $endpoint => $routes) { |
|
186 | + foreach ($routes as $route) { |
|
187 | + register_rest_route( |
|
188 | + $namespace, |
|
189 | + $endpoint, |
|
190 | + array( |
|
191 | + 'callback' => $route['callback'], |
|
192 | + 'methods' => $route['methods'], |
|
193 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
194 | + ) |
|
195 | + ); |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Checks if there was a version change or something that merits invalidating the cached |
|
205 | + * route data. If so, invalidates the cached route data so that it gets refreshed |
|
206 | + * next time the WP API is used |
|
207 | + */ |
|
208 | + public static function invalidate_cached_route_data_on_version_change() |
|
209 | + { |
|
210 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
211 | + EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
212 | + } |
|
213 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
214 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
215 | + EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * Removes the cached route data so it will get refreshed next time the WP API is used |
|
224 | + */ |
|
225 | + public static function invalidate_cached_route_data() |
|
226 | + { |
|
227 | + //delete the saved EE REST API routes |
|
228 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
229 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Gets the EE route data |
|
237 | + * |
|
238 | + * @return array top-level key is the namespace, next-level key is the route and its value is array{ |
|
239 | + * @type string|array $callback |
|
240 | + * @type string $methods |
|
241 | + * @type boolean $hidden_endpoint |
|
242 | + * } |
|
243 | + */ |
|
244 | + public static function get_ee_route_data() |
|
245 | + { |
|
246 | + $ee_routes = array(); |
|
247 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
248 | + $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
249 | + $hidden_endpoints); |
|
250 | + } |
|
251 | + return $ee_routes; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Gets the EE route data from the wp options if it exists already, |
|
258 | + * otherwise re-generates it and saves it to the option |
|
259 | + * |
|
260 | + * @param string $version |
|
261 | + * @param boolean $hidden_endpoints |
|
262 | + * @return array |
|
263 | + */ |
|
264 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
265 | + { |
|
266 | + $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
267 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
268 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
269 | + } |
|
270 | + return $ee_routes; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Saves the EE REST API route data to a wp option and returns it |
|
277 | + * |
|
278 | + * @param string $version |
|
279 | + * @param boolean $hidden_endpoints |
|
280 | + * @return mixed|null|void |
|
281 | + */ |
|
282 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
283 | + { |
|
284 | + $instance = self::instance(); |
|
285 | + $routes = apply_filters( |
|
286 | + 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
|
287 | + array_replace_recursive( |
|
288 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
289 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
290 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
291 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
292 | + ) |
|
293 | + ); |
|
294 | + $option_name = self::saved_routes_option_names . $version; |
|
295 | + if (get_option($option_name)) { |
|
296 | + update_option($option_name, $routes, true); |
|
297 | + } else { |
|
298 | + add_option($option_name, $routes, null, 'no'); |
|
299 | + } |
|
300 | + return $routes; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * Calculates all the EE routes and saves it to a wordpress option so we don't |
|
307 | + * need to calculate it on every request |
|
308 | + * |
|
309 | + * @deprecated since version 4.9.1 |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + public static function save_ee_routes() |
|
313 | + { |
|
314 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
315 | + $instance = self::instance(); |
|
316 | + $routes = apply_filters( |
|
317 | + 'EED_Core_Rest_Api__save_ee_routes__routes', |
|
318 | + array_replace_recursive( |
|
319 | + $instance->_register_config_routes(), |
|
320 | + $instance->_register_meta_routes(), |
|
321 | + $instance->_register_model_routes(), |
|
322 | + $instance->_register_rpc_routes() |
|
323 | + ) |
|
324 | + ); |
|
325 | + update_option(self::saved_routes_option_names, $routes, true); |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * Gets all the route information relating to EE models |
|
333 | + * |
|
334 | + * @return array @see get_ee_route_data |
|
335 | + * @deprecated since version 4.9.1 |
|
336 | + */ |
|
337 | + protected function _register_model_routes() |
|
338 | + { |
|
339 | + $model_routes = array(); |
|
340 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
341 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace |
|
342 | + . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
343 | + } |
|
344 | + return $model_routes; |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * Gets the route data for EE models in the specified version |
|
351 | + * |
|
352 | + * @param string $version |
|
353 | + * @param boolean $hidden_endpoint |
|
354 | + * @return array |
|
355 | + */ |
|
356 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) |
|
357 | + { |
|
358 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
359 | + $models_to_register = apply_filters( |
|
360 | + 'FHEE__EED_Core_REST_API___register_model_routes', |
|
361 | + $model_version_info->models_for_requested_version() |
|
362 | + ); |
|
363 | + //let's not bother having endpoints for extra metas |
|
364 | + unset($models_to_register['Extra_Meta']); |
|
365 | + unset($models_to_register['Extra_Join']); |
|
366 | + $model_routes = array(); |
|
367 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
368 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
369 | + //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
|
370 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
371 | + $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
372 | + $model_routes[$plural_model_route] = array( |
|
373 | + array( |
|
374 | + 'callback' => array( |
|
375 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
376 | + 'handle_request_get_all', |
|
377 | + ), |
|
378 | + 'methods' => WP_REST_Server::READABLE, |
|
379 | + 'hidden_endpoint' => $hidden_endpoint, |
|
380 | + 'args' => $this->_get_read_query_params($model, $version), |
|
381 | + '_links' => array( |
|
382 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
383 | + ), |
|
384 | + ), |
|
385 | + // array( |
|
386 | + // 'callback' => array( |
|
387 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
388 | + // 'handle_request_create_one' ), |
|
389 | + // 'methods' => WP_REST_Server::CREATABLE, |
|
390 | + // 'hidden_endpoint' => $hidden_endpoint |
|
391 | + // ) |
|
392 | + ); |
|
393 | + $model_routes[$singular_model_route] = array( |
|
394 | + array( |
|
395 | + 'callback' => array( |
|
396 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
397 | + 'handle_request_get_one', |
|
398 | + ), |
|
399 | + 'methods' => WP_REST_Server::READABLE, |
|
400 | + 'hidden_endpoint' => $hidden_endpoint, |
|
401 | + 'args' => $this->_get_response_selection_query_params($model, $version), |
|
402 | + ), |
|
403 | + // array( |
|
404 | + // 'callback' => array( |
|
405 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
406 | + // 'handle_request_edit_one' ), |
|
407 | + // 'methods' => WP_REST_Server::EDITABLE, |
|
408 | + // 'hidden_endpoint' => $hidden_endpoint |
|
409 | + // ), |
|
410 | + ); |
|
411 | + //@todo: also handle DELETE for a single item |
|
412 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
413 | + $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
|
414 | + $relation_name, |
|
415 | + $relation_obj |
|
416 | + ); |
|
417 | + $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
418 | + array( |
|
419 | + 'callback' => array( |
|
420 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
421 | + 'handle_request_get_related', |
|
422 | + ), |
|
423 | + 'methods' => WP_REST_Server::READABLE, |
|
424 | + 'hidden_endpoint' => $hidden_endpoint, |
|
425 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
426 | + ), |
|
427 | + // array( |
|
428 | + // 'callback' => array( |
|
429 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
430 | + // 'handle_request_create_or_update_related' ), |
|
431 | + // 'methods' => WP_REST_Server::EDITABLE, |
|
432 | + // 'hidden_endpoint' => $hidden_endpoint |
|
433 | + // ) |
|
434 | + ); |
|
435 | + //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish) |
|
436 | + } |
|
437 | + } |
|
438 | + return $model_routes; |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * Adds all the RPC-style routes (remote procedure call-like routes, ie |
|
445 | + * routes that don't conform to the traditional REST CRUD-style). |
|
446 | + * |
|
447 | + * @deprecated since 4.9.1 |
|
448 | + */ |
|
449 | + protected function _register_rpc_routes() |
|
450 | + { |
|
451 | + $routes = array(); |
|
452 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
453 | + $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | + $hidden_endpoint); |
|
455 | + } |
|
456 | + return $routes; |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * @param string $version |
|
463 | + * @param boolean $hidden_endpoint |
|
464 | + * @return array |
|
465 | + */ |
|
466 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) |
|
467 | + { |
|
468 | + $this_versions_routes = array(); |
|
469 | + //checkin endpoint |
|
470 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
471 | + array( |
|
472 | + 'callback' => array( |
|
473 | + 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
|
474 | + 'handle_request_toggle_checkin', |
|
475 | + ), |
|
476 | + 'methods' => WP_REST_Server::CREATABLE, |
|
477 | + 'hidden_endpoint' => $hidden_endpoint, |
|
478 | + 'args' => array( |
|
479 | + 'force' => array( |
|
480 | + 'required' => false, |
|
481 | + 'default' => false, |
|
482 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', |
|
483 | + 'event_espresso'), |
|
484 | + ), |
|
485 | + ), |
|
486 | + ), |
|
487 | + ); |
|
488 | + return apply_filters( |
|
489 | + 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
490 | + $this_versions_routes, |
|
491 | + $version, |
|
492 | + $hidden_endpoint |
|
493 | + ); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * Gets the query params that can be used when request one or many |
|
500 | + * |
|
501 | + * @param EEM_Base $model |
|
502 | + * @param string $version |
|
503 | + * @return array |
|
504 | + */ |
|
505 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) |
|
506 | + { |
|
507 | + return apply_filters( |
|
508 | + 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
|
509 | + array( |
|
510 | + 'include' => array( |
|
511 | + 'required' => false, |
|
512 | + 'default' => '*', |
|
513 | + ), |
|
514 | + 'calculate' => array( |
|
515 | + 'required' => false, |
|
516 | + 'default' => '', |
|
517 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model), |
|
518 | + ), |
|
519 | + ), |
|
520 | + $model, |
|
521 | + $version |
|
522 | + ); |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + |
|
527 | + /** |
|
528 | + * Gets info about reading query params that are acceptable |
|
529 | + * |
|
530 | + * @param \EEM_Base $model eg 'Event' or 'Venue' |
|
531 | + * @param string $version |
|
532 | + * @return array describing the args acceptable when querying this model |
|
533 | + * @throws \EE_Error |
|
534 | + */ |
|
535 | + protected function _get_read_query_params(\EEM_Base $model, $version) |
|
536 | + { |
|
537 | + $default_orderby = array(); |
|
538 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
539 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
540 | + } |
|
541 | + return array_merge( |
|
542 | + $this->_get_response_selection_query_params($model, $version), |
|
543 | + array( |
|
544 | + 'where' => array( |
|
545 | + 'required' => false, |
|
546 | + 'default' => array(), |
|
547 | + ), |
|
548 | + 'limit' => array( |
|
549 | + 'required' => false, |
|
550 | + 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
|
551 | + ), |
|
552 | + 'order_by' => array( |
|
553 | + 'required' => false, |
|
554 | + 'default' => $default_orderby, |
|
555 | + ), |
|
556 | + 'group_by' => array( |
|
557 | + 'required' => false, |
|
558 | + 'default' => null, |
|
559 | + ), |
|
560 | + 'having' => array( |
|
561 | + 'required' => false, |
|
562 | + 'default' => null, |
|
563 | + ), |
|
564 | + 'caps' => array( |
|
565 | + 'required' => false, |
|
566 | + 'default' => EEM_Base::caps_read, |
|
567 | + ), |
|
568 | + ) |
|
569 | + ); |
|
570 | + } |
|
571 | + |
|
572 | + |
|
573 | + |
|
574 | + /** |
|
575 | + * Gets routes for the config |
|
576 | + * |
|
577 | + * @return array @see _register_model_routes |
|
578 | + * @deprecated since version 4.9.1 |
|
579 | + */ |
|
580 | + protected function _register_config_routes() |
|
581 | + { |
|
582 | + $config_routes = array(); |
|
583 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
584 | + $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
585 | + $hidden_endpoint); |
|
586 | + } |
|
587 | + return $config_routes; |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * Gets routes for the config for the specified version |
|
594 | + * |
|
595 | + * @param string $version |
|
596 | + * @param boolean $hidden_endpoint |
|
597 | + * @return array |
|
598 | + */ |
|
599 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) |
|
600 | + { |
|
601 | + return array( |
|
602 | + 'config' => array( |
|
603 | + array( |
|
604 | + 'callback' => array( |
|
605 | + 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
606 | + 'handle_request', |
|
607 | + ), |
|
608 | + 'methods' => WP_REST_Server::READABLE, |
|
609 | + 'hidden_endpoint' => $hidden_endpoint, |
|
610 | + ), |
|
611 | + ), |
|
612 | + 'site_info' => array( |
|
613 | + array( |
|
614 | + 'callback' => array( |
|
615 | + 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
616 | + 'handle_request_site_info', |
|
617 | + ), |
|
618 | + 'methods' => WP_REST_Server::READABLE, |
|
619 | + 'hidden_endpoint' => $hidden_endpoint, |
|
620 | + ), |
|
621 | + ), |
|
622 | + ); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * Gets the meta info routes |
|
629 | + * |
|
630 | + * @return array @see _register_model_routes |
|
631 | + * @deprecated since version 4.9.1 |
|
632 | + */ |
|
633 | + protected function _register_meta_routes() |
|
634 | + { |
|
635 | + $meta_routes = array(); |
|
636 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
637 | + $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
638 | + $hidden_endpoint); |
|
639 | + } |
|
640 | + return $meta_routes; |
|
641 | + } |
|
642 | + |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * @param string $version |
|
647 | + * @param boolean $hidden_endpoint |
|
648 | + * @return array |
|
649 | + */ |
|
650 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) |
|
651 | + { |
|
652 | + return array( |
|
653 | + 'resources' => array( |
|
654 | + array( |
|
655 | + 'callback' => array( |
|
656 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
|
657 | + 'handle_request_models_meta', |
|
658 | + ), |
|
659 | + 'methods' => WP_REST_Server::READABLE, |
|
660 | + 'hidden_endpoint' => $hidden_endpoint, |
|
661 | + ), |
|
662 | + ), |
|
663 | + ); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * Tries to hide old 4.6 endpoints from the |
|
670 | + * |
|
671 | + * @param array $route_data |
|
672 | + * @return array |
|
673 | + */ |
|
674 | + public static function hide_old_endpoints($route_data) |
|
675 | + { |
|
676 | + //allow API clients to override which endpoints get hidden, in case |
|
677 | + //they want to discover particular endpoints |
|
678 | + //also, we don't have access to the request so we have to just grab it from the superglobal |
|
679 | + $force_show_ee_namespace = ltrim( |
|
680 | + EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
681 | + '/' |
|
682 | + ); |
|
683 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
684 | + foreach ($relative_urls as $endpoint => $routes) { |
|
685 | + foreach ($routes as $route) { |
|
686 | + //by default, hide "hidden_endpoint"s, unless the request indicates |
|
687 | + //to $force_show_ee_namespace, in which case only show that one |
|
688 | + //namespace's endpoints (and hide all others) |
|
689 | + if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
690 | + || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
|
691 | + ) { |
|
692 | + $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
693 | + unset($route_data[$full_route]); |
|
694 | + } |
|
695 | + } |
|
696 | + } |
|
697 | + } |
|
698 | + return $route_data; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * Returns an array describing which versions of core support serving requests for. |
|
705 | + * Keys are core versions' major and minor version, and values are the |
|
706 | + * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like |
|
707 | + * data by just removing a few models and fields from the responses. However, 4.15 might remove |
|
708 | + * the answers table entirely, in which case it would be very difficult for |
|
709 | + * it to serve 4.6-style responses. |
|
710 | + * Versions of core that are missing from this array are unknowns. |
|
711 | + * previous ver |
|
712 | + * |
|
713 | + * @return array |
|
714 | + */ |
|
715 | + public static function version_compatibilities() |
|
716 | + { |
|
717 | + return apply_filters( |
|
718 | + 'FHEE__EED_Core_REST_API__version_compatibilities', |
|
719 | + array( |
|
720 | + '4.8.29' => '4.8.29', |
|
721 | + '4.8.33' => '4.8.29', |
|
722 | + '4.8.34' => '4.8.29', |
|
723 | + '4.8.36' => '4.8.29', |
|
724 | + ) |
|
725 | + ); |
|
726 | + } |
|
727 | + |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * Gets the latest API version served. Eg if there |
|
732 | + * are two versions served of the API, 4.8.29 and 4.8.32, and |
|
733 | + * we are on core version 4.8.34, it will return the string "4.8.32" |
|
734 | + * |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public static function latest_rest_api_version() |
|
738 | + { |
|
739 | + $versions_served = \EED_Core_Rest_Api::versions_served(); |
|
740 | + $versions_served_keys = array_keys($versions_served); |
|
741 | + return end($versions_served_keys); |
|
742 | + } |
|
743 | + |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of |
|
748 | + * EE the API can serve requests for. Eg, if we are on 4.15 of core, and |
|
749 | + * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ). |
|
750 | + * We also indicate whether or not this version should be put in the index or not |
|
751 | + * |
|
752 | + * @return array keys are API version numbers (just major and minor numbers), and values |
|
753 | + * are whether or not they should be hidden |
|
754 | + */ |
|
755 | + public static function versions_served() |
|
756 | + { |
|
757 | + $versions_served = array(); |
|
758 | + $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
|
759 | + $lowest_compatible_version = end($possibly_served_versions); |
|
760 | + reset($possibly_served_versions); |
|
761 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
762 | + $latest_version = end($versions_served_historically); |
|
763 | + reset($versions_served_historically); |
|
764 | + //for each version of core we have ever served: |
|
765 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
766 | + //if it's not above the current core version, and it's compatible with the current version of core |
|
767 | + if ($key_versioned_endpoint == $latest_version) { |
|
768 | + //don't hide the latest version in the index |
|
769 | + $versions_served[$key_versioned_endpoint] = false; |
|
770 | + } else if ( |
|
771 | + $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
|
772 | + && $key_versioned_endpoint >= $lowest_compatible_version |
|
773 | + ) { |
|
774 | + //include, but hide, previous versions which are still supported |
|
775 | + $versions_served[$key_versioned_endpoint] = true; |
|
776 | + } elseif ( |
|
777 | + apply_filters( |
|
778 | + 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
|
779 | + false, |
|
780 | + $possibly_served_versions |
|
781 | + ) |
|
782 | + ) { |
|
783 | + //if a version is no longer supported, don't include it in index or list of versions served |
|
784 | + $versions_served[$key_versioned_endpoint] = true; |
|
785 | + } |
|
786 | + } |
|
787 | + return $versions_served; |
|
788 | + } |
|
789 | + |
|
790 | + |
|
791 | + |
|
792 | + /** |
|
793 | + * Gets the major and minor version of EE core's version string |
|
794 | + * |
|
795 | + * @return string |
|
796 | + */ |
|
797 | + public static function core_version() |
|
798 | + { |
|
799 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', |
|
800 | + implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
801 | + } |
|
802 | + |
|
803 | + |
|
804 | + |
|
805 | + /** |
|
806 | + * Gets the default limit that should be used when querying for resources |
|
807 | + * |
|
808 | + * @return int |
|
809 | + */ |
|
810 | + public static function get_default_query_limit() |
|
811 | + { |
|
812 | + //we actually don't use a const because we want folks to always use |
|
813 | + //this method, not the const directly |
|
814 | + return apply_filters( |
|
815 | + 'FHEE__EED_Core_Rest_Api__get_default_query_limit', |
|
816 | + 50 |
|
817 | + ); |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + |
|
822 | + /** |
|
823 | + * run - initial module setup |
|
824 | + * |
|
825 | + * @access public |
|
826 | + * @param WP $WP |
|
827 | + * @return void |
|
828 | + */ |
|
829 | + public function run($WP) |
|
830 | + { |
|
831 | + } |
|
832 | 832 | |
833 | 833 | |
834 | 834 |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected static function _set_hooks_for_changes() |
159 | 159 | { |
160 | - $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
160 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
161 | 161 | foreach ($folder_contents as $classname_in_namespace => $filepath) { |
162 | 162 | //ignore the base parent class |
163 | 163 | if ($classname_in_namespace === 'Changes_In_Base') { |
164 | 164 | continue; |
165 | 165 | } |
166 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
166 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
167 | 167 | if (class_exists($full_classname)) { |
168 | 168 | $instance_of_class = new $full_classname; |
169 | 169 | if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | //delete the saved EE REST API routes |
228 | 228 | foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
229 | - delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
229 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | $ee_routes = array(); |
247 | 247 | foreach (self::versions_served() as $version => $hidden_endpoints) { |
248 | - $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
248 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, |
|
249 | 249 | $hidden_endpoints); |
250 | 250 | } |
251 | 251 | return $ee_routes; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
265 | 265 | { |
266 | - $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
266 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
267 | 267 | if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
268 | 268 | $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
269 | 269 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
292 | 292 | ) |
293 | 293 | ); |
294 | - $option_name = self::saved_routes_option_names . $version; |
|
294 | + $option_name = self::saved_routes_option_names.$version; |
|
295 | 295 | if (get_option($option_name)) { |
296 | 296 | update_option($option_name, $routes, true); |
297 | 297 | } else { |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $model = \EE_Registry::instance()->load_model($model_name); |
369 | 369 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
370 | 370 | $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
371 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
371 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
372 | 372 | $model_routes[$plural_model_route] = array( |
373 | 373 | array( |
374 | 374 | 'callback' => array( |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | 'hidden_endpoint' => $hidden_endpoint, |
380 | 380 | 'args' => $this->_get_read_query_params($model, $version), |
381 | 381 | '_links' => array( |
382 | - 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
382 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
383 | 383 | ), |
384 | 384 | ), |
385 | 385 | // array( |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $relation_name, |
415 | 415 | $relation_obj |
416 | 416 | ); |
417 | - $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
417 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
418 | 418 | array( |
419 | 419 | 'callback' => array( |
420 | 420 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | { |
451 | 451 | $routes = array(); |
452 | 452 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
453 | - $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
453 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | 454 | $hidden_endpoint); |
455 | 455 | } |
456 | 456 | return $routes; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | { |
582 | 582 | $config_routes = array(); |
583 | 583 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
584 | - $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
584 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, |
|
585 | 585 | $hidden_endpoint); |
586 | 586 | } |
587 | 587 | return $config_routes; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | { |
635 | 635 | $meta_routes = array(); |
636 | 636 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
637 | - $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
637 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, |
|
638 | 638 | $hidden_endpoint); |
639 | 639 | } |
640 | 640 | return $meta_routes; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
690 | 690 | || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
691 | 691 | ) { |
692 | - $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
692 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
693 | 693 | unset($route_data[$full_route]); |
694 | 694 | } |
695 | 695 | } |
@@ -146,7 +146,7 @@ |
||
146 | 146 | } |
147 | 147 | } |
148 | 148 | global $wpdb; |
149 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
149 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
150 | 150 | return $tables_to_delete; |
151 | 151 | } |
152 | 152 |
@@ -17,211 +17,211 @@ |
||
17 | 17 | class TableManager extends \EE_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var TableAnalysis $table_analysis |
|
22 | - */ |
|
23 | - private $table_analysis; |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * TableManager constructor. |
|
29 | - * |
|
30 | - * @param TableAnalysis $TableAnalysis |
|
31 | - */ |
|
32 | - public function __construct(TableAnalysis $TableAnalysis) |
|
33 | - { |
|
34 | - $this->table_analysis = $TableAnalysis; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Gets the injected table analyzer, or throws an exception |
|
41 | - * |
|
42 | - * @return TableAnalysis |
|
43 | - * @throws \EE_Error |
|
44 | - */ |
|
45 | - protected function getTableAnalysis() |
|
46 | - { |
|
47 | - if ($this->table_analysis instanceof TableAnalysis) { |
|
48 | - return $this->table_analysis; |
|
49 | - } else { |
|
50 | - throw new \EE_Error( |
|
51 | - sprintf( |
|
52 | - __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
53 | - get_class($this) |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
63 | - * @param string $column_name |
|
64 | - * @param string $column_info |
|
65 | - * @return bool|false|int |
|
66 | - */ |
|
67 | - public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
68 | - { |
|
69 | - if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
70 | - return false; |
|
71 | - } |
|
72 | - global $wpdb; |
|
73 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
74 | - $columns = $this->getTableColumns($table_name); |
|
75 | - if ( ! in_array($column_name, $columns)) { |
|
76 | - $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
77 | - return $wpdb->query($alter_query); |
|
78 | - } |
|
79 | - return true; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Gets the name of all columns on the table. $table_name can |
|
86 | - * optionally start with $wpdb->prefix or not |
|
87 | - * |
|
88 | - * @global \wpdb $wpdb |
|
89 | - * @param string $table_name |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function getTableColumns($table_name) |
|
93 | - { |
|
94 | - global $wpdb; |
|
95 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
96 | - $fieldArray = array(); |
|
97 | - if ( ! empty($table_name)) { |
|
98 | - $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
|
99 | - if ($columns !== false) { |
|
100 | - foreach ($columns as $column) { |
|
101 | - $fieldArray[] = $column->Field; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - return $fieldArray; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Drops the specified table from the database. $table_name can |
|
112 | - * optionally start with $wpdb->prefix or not |
|
113 | - * |
|
114 | - * @global \wpdb $wpdb |
|
115 | - * @param string $table_name |
|
116 | - * @return int |
|
117 | - */ |
|
118 | - public function dropTable($table_name) |
|
119 | - { |
|
120 | - global $wpdb; |
|
121 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
122 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
123 | - return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
124 | - } |
|
125 | - return 0; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
132 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
133 | - * Returns the list actually deleted |
|
134 | - * |
|
135 | - * @global WPDB $wpdb |
|
136 | - * @param array $table_names |
|
137 | - * @return array of table names which we deleted |
|
138 | - */ |
|
139 | - public function dropTables($table_names) |
|
140 | - { |
|
141 | - $tables_to_delete = array(); |
|
142 | - foreach ($table_names as $table_name) { |
|
143 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
144 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
145 | - $tables_to_delete[] = $table_name; |
|
146 | - } |
|
147 | - } |
|
148 | - global $wpdb; |
|
149 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
150 | - return $tables_to_delete; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * Drops the specified index from the specified table. $table_name can |
|
157 | - * optionally start with $wpdb->prefix or not |
|
158 | - * |
|
159 | - * @global \wpdb $wpdb |
|
160 | - * @param string $table_name |
|
161 | - * @param string $indexName |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - public function dropIndex($table_name, $indexName) |
|
165 | - { |
|
166 | - if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
167 | - return false; |
|
168 | - } |
|
169 | - global $wpdb; |
|
170 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
171 | - $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
|
172 | - if ( |
|
173 | - $this->getTableAnalysis()->tableExists($table_name) |
|
174 | - && $wpdb->get_var($index_exists_query) |
|
175 | - === $table_name //using get_var with the $index_exists_query returns the table's name |
|
176 | - ) { |
|
177 | - return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
178 | - } |
|
179 | - return 0; |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * Just creates the requested table. $table_name can |
|
186 | - * optionally start with $wpdb->prefix or not |
|
187 | - * |
|
188 | - * @param string $table_name |
|
189 | - * @param string $createSql defining the table's columns and indexes |
|
190 | - * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
191 | - * @return void |
|
192 | - * @throws \EE_Error |
|
193 | - */ |
|
194 | - public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
195 | - { |
|
196 | - // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
197 | - if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
198 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
199 | - $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
|
200 | - /** @var \wpdb $wpdb */ |
|
201 | - global $wpdb; |
|
202 | - //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
203 | - //happened. And then we can choose to tell the end user |
|
204 | - $old_show_errors_policy = $wpdb->show_errors(true); |
|
205 | - $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
206 | - ob_start(); |
|
207 | - dbDelta($SQL); |
|
208 | - $output = ob_get_contents(); |
|
209 | - ob_end_clean(); |
|
210 | - $wpdb->show_errors($old_show_errors_policy); |
|
211 | - $wpdb->suppress_errors($old_error_suppression_policy); |
|
212 | - if ( ! empty($output)) { |
|
213 | - throw new \EE_Error($output); |
|
214 | - } |
|
215 | - } else { |
|
216 | - throw new \EE_Error( |
|
217 | - sprintf( |
|
218 | - __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
219 | - 'event_espresso'), |
|
220 | - '<br />', |
|
221 | - $createSql |
|
222 | - ) |
|
223 | - ); |
|
224 | - } |
|
225 | - } |
|
20 | + /** |
|
21 | + * @var TableAnalysis $table_analysis |
|
22 | + */ |
|
23 | + private $table_analysis; |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * TableManager constructor. |
|
29 | + * |
|
30 | + * @param TableAnalysis $TableAnalysis |
|
31 | + */ |
|
32 | + public function __construct(TableAnalysis $TableAnalysis) |
|
33 | + { |
|
34 | + $this->table_analysis = $TableAnalysis; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Gets the injected table analyzer, or throws an exception |
|
41 | + * |
|
42 | + * @return TableAnalysis |
|
43 | + * @throws \EE_Error |
|
44 | + */ |
|
45 | + protected function getTableAnalysis() |
|
46 | + { |
|
47 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
48 | + return $this->table_analysis; |
|
49 | + } else { |
|
50 | + throw new \EE_Error( |
|
51 | + sprintf( |
|
52 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
53 | + get_class($this) |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
63 | + * @param string $column_name |
|
64 | + * @param string $column_info |
|
65 | + * @return bool|false|int |
|
66 | + */ |
|
67 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
68 | + { |
|
69 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
70 | + return false; |
|
71 | + } |
|
72 | + global $wpdb; |
|
73 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
74 | + $columns = $this->getTableColumns($table_name); |
|
75 | + if ( ! in_array($column_name, $columns)) { |
|
76 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
77 | + return $wpdb->query($alter_query); |
|
78 | + } |
|
79 | + return true; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Gets the name of all columns on the table. $table_name can |
|
86 | + * optionally start with $wpdb->prefix or not |
|
87 | + * |
|
88 | + * @global \wpdb $wpdb |
|
89 | + * @param string $table_name |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function getTableColumns($table_name) |
|
93 | + { |
|
94 | + global $wpdb; |
|
95 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
96 | + $fieldArray = array(); |
|
97 | + if ( ! empty($table_name)) { |
|
98 | + $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
|
99 | + if ($columns !== false) { |
|
100 | + foreach ($columns as $column) { |
|
101 | + $fieldArray[] = $column->Field; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + return $fieldArray; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Drops the specified table from the database. $table_name can |
|
112 | + * optionally start with $wpdb->prefix or not |
|
113 | + * |
|
114 | + * @global \wpdb $wpdb |
|
115 | + * @param string $table_name |
|
116 | + * @return int |
|
117 | + */ |
|
118 | + public function dropTable($table_name) |
|
119 | + { |
|
120 | + global $wpdb; |
|
121 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
122 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
123 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
124 | + } |
|
125 | + return 0; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
132 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
133 | + * Returns the list actually deleted |
|
134 | + * |
|
135 | + * @global WPDB $wpdb |
|
136 | + * @param array $table_names |
|
137 | + * @return array of table names which we deleted |
|
138 | + */ |
|
139 | + public function dropTables($table_names) |
|
140 | + { |
|
141 | + $tables_to_delete = array(); |
|
142 | + foreach ($table_names as $table_name) { |
|
143 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
144 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
145 | + $tables_to_delete[] = $table_name; |
|
146 | + } |
|
147 | + } |
|
148 | + global $wpdb; |
|
149 | + $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
150 | + return $tables_to_delete; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * Drops the specified index from the specified table. $table_name can |
|
157 | + * optionally start with $wpdb->prefix or not |
|
158 | + * |
|
159 | + * @global \wpdb $wpdb |
|
160 | + * @param string $table_name |
|
161 | + * @param string $indexName |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + public function dropIndex($table_name, $indexName) |
|
165 | + { |
|
166 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
167 | + return false; |
|
168 | + } |
|
169 | + global $wpdb; |
|
170 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
171 | + $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
|
172 | + if ( |
|
173 | + $this->getTableAnalysis()->tableExists($table_name) |
|
174 | + && $wpdb->get_var($index_exists_query) |
|
175 | + === $table_name //using get_var with the $index_exists_query returns the table's name |
|
176 | + ) { |
|
177 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
178 | + } |
|
179 | + return 0; |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * Just creates the requested table. $table_name can |
|
186 | + * optionally start with $wpdb->prefix or not |
|
187 | + * |
|
188 | + * @param string $table_name |
|
189 | + * @param string $createSql defining the table's columns and indexes |
|
190 | + * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
191 | + * @return void |
|
192 | + * @throws \EE_Error |
|
193 | + */ |
|
194 | + public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
195 | + { |
|
196 | + // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
197 | + if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
198 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
199 | + $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
|
200 | + /** @var \wpdb $wpdb */ |
|
201 | + global $wpdb; |
|
202 | + //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
203 | + //happened. And then we can choose to tell the end user |
|
204 | + $old_show_errors_policy = $wpdb->show_errors(true); |
|
205 | + $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
206 | + ob_start(); |
|
207 | + dbDelta($SQL); |
|
208 | + $output = ob_get_contents(); |
|
209 | + ob_end_clean(); |
|
210 | + $wpdb->show_errors($old_show_errors_policy); |
|
211 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
212 | + if ( ! empty($output)) { |
|
213 | + throw new \EE_Error($output); |
|
214 | + } |
|
215 | + } else { |
|
216 | + throw new \EE_Error( |
|
217 | + sprintf( |
|
218 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
219 | + 'event_espresso'), |
|
220 | + '<br />', |
|
221 | + $createSql |
|
222 | + ) |
|
223 | + ); |
|
224 | + } |
|
225 | + } |
|
226 | 226 | |
227 | 227 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | //unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | //instead of construction, because it only gets constructed on first page load |
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
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 | 15 | $matches = array(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } elseif ( ! $version_string) { |
68 | 68 | // echo "no version string provided: $version_string"; |
69 | 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 |
|
70 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | 71 | } else { |
72 | 72 | // echo "$version_string doesnt apply"; |
73 | 73 | return false; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function schema_changes_before_migration() |
93 | 93 | { |
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
94 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
95 | 95 | $now_in_mysql = current_time('mysql', true); |
96 | 96 | $table_name = 'esp_answer'; |
97 | 97 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -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,77 +33,77 @@ 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 = __("Data Migration to Event Espresso 4.9.0.P", "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 = __("Data Migration to Event Espresso 4.9.0.P", "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', '>=')) { |
|
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 | 65 | // echo "$version_string can be migrated from"; |
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | 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 { |
|
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 | 72 | // echo "$version_string doesnt apply"; |
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return string|void |
|
81 | - */ |
|
82 | - public function pretty_name() |
|
83 | - { |
|
84 | - return __("Core Data Migration to version 4.9.0", "event_espresso"); |
|
85 | - } |
|
79 | + /** |
|
80 | + * @return string|void |
|
81 | + */ |
|
82 | + public function pretty_name() |
|
83 | + { |
|
84 | + return __("Core Data Migration to version 4.9.0", "event_espresso"); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function schema_changes_before_migration() |
|
93 | - { |
|
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | - $now_in_mysql = current_time('mysql', true); |
|
96 | - $table_name = 'esp_answer'; |
|
97 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
89 | + /** |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function schema_changes_before_migration() |
|
93 | + { |
|
94 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | + $now_in_mysql = current_time('mysql', true); |
|
96 | + $table_name = 'esp_answer'; |
|
97 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | REG_ID int(10) unsigned NOT NULL, |
99 | 99 | QST_ID int(10) unsigned NOT NULL, |
100 | 100 | ANS_value text NOT NULL, |
101 | 101 | PRIMARY KEY (ANS_ID), |
102 | 102 | KEY REG_ID (REG_ID), |
103 | 103 | KEY QST_ID (QST_ID)"; |
104 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
105 | - $table_name = 'esp_attendee_meta'; |
|
106 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
104 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
105 | + $table_name = 'esp_attendee_meta'; |
|
106 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
107 | 107 | ATT_ID bigint(20) unsigned NOT NULL, |
108 | 108 | ATT_fname varchar(45) NOT NULL, |
109 | 109 | ATT_lname varchar(45) NOT NULL, |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | KEY ATT_email (ATT_email), |
121 | 121 | KEY ATT_lname (ATT_lname), |
122 | 122 | KEY ATT_fname (ATT_fname)"; |
123 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
124 | - $table_name = 'esp_checkin'; |
|
125 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
123 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
124 | + $table_name = 'esp_checkin'; |
|
125 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
126 | 126 | REG_ID int(10) unsigned NOT NULL, |
127 | 127 | DTT_ID int(10) unsigned NOT NULL, |
128 | 128 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | PRIMARY KEY (CHK_ID), |
131 | 131 | KEY REG_ID (REG_ID), |
132 | 132 | KEY DTT_ID (DTT_ID)"; |
133 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
134 | - $table_name = 'esp_country'; |
|
135 | - $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
133 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
134 | + $table_name = 'esp_country'; |
|
135 | + $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
136 | 136 | CNT_ISO3 varchar(3) collate utf8_bin NOT NULL, |
137 | 137 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
138 | 138 | CNT_name varchar(45) collate utf8_bin NOT NULL, |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | CNT_is_EU tinyint(1) DEFAULT '0', |
149 | 149 | CNT_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CNT_ISO)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_currency'; |
|
153 | - $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_currency'; |
|
153 | + $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
154 | 154 | CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar', |
155 | 155 | CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars', |
156 | 156 | CUR_sign varchar(45) collate utf8_bin DEFAULT '$', |
157 | 157 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
158 | 158 | CUR_active tinyint(1) DEFAULT '0', |
159 | 159 | PRIMARY KEY (CUR_code)"; |
160 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | - $table_name = 'esp_currency_payment_method'; |
|
162 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
160 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | + $table_name = 'esp_currency_payment_method'; |
|
162 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
163 | 163 | CUR_code varchar(6) collate utf8_bin NOT NULL, |
164 | 164 | PMD_ID int(11) NOT NULL, |
165 | 165 | PRIMARY KEY (CPM_ID), |
166 | 166 | KEY PMD_ID (PMD_ID)"; |
167 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
168 | - $table_name = 'esp_datetime'; |
|
169 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
167 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
168 | + $table_name = 'esp_datetime'; |
|
169 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
170 | 170 | EVT_ID bigint(20) unsigned NOT NULL, |
171 | 171 | DTT_name varchar(255) NOT NULL DEFAULT '', |
172 | 172 | DTT_description text NOT NULL, |
@@ -182,25 +182,25 @@ discard block |
||
182 | 182 | KEY DTT_EVT_start (DTT_EVT_start), |
183 | 183 | KEY EVT_ID (EVT_ID), |
184 | 184 | KEY DTT_is_primary (DTT_is_primary)"; |
185 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | - $table_name = "esp_datetime_ticket"; |
|
187 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
185 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $table_name = "esp_datetime_ticket"; |
|
187 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | 188 | DTT_ID int(10) unsigned NOT NULL, |
189 | 189 | TKT_ID int(10) unsigned NOT NULL, |
190 | 190 | PRIMARY KEY (DTK_ID), |
191 | 191 | KEY DTT_ID (DTT_ID), |
192 | 192 | KEY TKT_ID (TKT_ID)"; |
193 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | - $table_name = 'esp_event_message_template'; |
|
195 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
193 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | + $table_name = 'esp_event_message_template'; |
|
195 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
196 | 196 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
197 | 197 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
198 | 198 | PRIMARY KEY (EMT_ID), |
199 | 199 | KEY EVT_ID (EVT_ID), |
200 | 200 | KEY GRP_ID (GRP_ID)"; |
201 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | - $table_name = 'esp_event_meta'; |
|
203 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
201 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | + $table_name = 'esp_event_meta'; |
|
203 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
204 | 204 | EVT_ID bigint(20) unsigned NOT NULL, |
205 | 205 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
206 | 206 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -215,34 +215,34 @@ discard block |
||
215 | 215 | EVT_donations tinyint(1) NULL, |
216 | 216 | PRIMARY KEY (EVTM_ID), |
217 | 217 | KEY EVT_ID (EVT_ID)"; |
218 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
219 | - $table_name = 'esp_event_question_group'; |
|
220 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
218 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
219 | + $table_name = 'esp_event_question_group'; |
|
220 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
221 | 221 | EVT_ID bigint(20) unsigned NOT NULL, |
222 | 222 | QSG_ID int(10) unsigned NOT NULL, |
223 | 223 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
224 | 224 | PRIMARY KEY (EQG_ID), |
225 | 225 | KEY EVT_ID (EVT_ID), |
226 | 226 | KEY QSG_ID (QSG_ID)"; |
227 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | - $table_name = 'esp_event_venue'; |
|
229 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
227 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | + $table_name = 'esp_event_venue'; |
|
229 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | 230 | EVT_ID bigint(20) unsigned NOT NULL, |
231 | 231 | VNU_ID bigint(20) unsigned NOT NULL, |
232 | 232 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
233 | 233 | PRIMARY KEY (EVV_ID)"; |
234 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | - $table_name = 'esp_extra_meta'; |
|
236 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
234 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | + $table_name = 'esp_extra_meta'; |
|
236 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
237 | 237 | OBJ_ID int(11) DEFAULT NULL, |
238 | 238 | EXM_type varchar(45) DEFAULT NULL, |
239 | 239 | EXM_key varchar(45) DEFAULT NULL, |
240 | 240 | EXM_value text, |
241 | 241 | PRIMARY KEY (EXM_ID), |
242 | 242 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
243 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
244 | - $table_name = 'esp_extra_join'; |
|
245 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
243 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
244 | + $table_name = 'esp_extra_join'; |
|
245 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | 246 | EXJ_first_model_id varchar(6) NOT NULL, |
247 | 247 | EXJ_first_model_name varchar(20) NOT NULL, |
248 | 248 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | PRIMARY KEY (EXJ_ID), |
251 | 251 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
252 | 252 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
253 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
254 | - $table_name = 'esp_line_item'; |
|
255 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
253 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
254 | + $table_name = 'esp_line_item'; |
|
255 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
256 | 256 | LIN_code varchar(245) NOT NULL DEFAULT '', |
257 | 257 | TXN_ID int(11) DEFAULT NULL, |
258 | 258 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | PRIMARY KEY (LIN_ID), |
272 | 272 | KEY LIN_code (LIN_code(191)), |
273 | 273 | KEY TXN_ID (TXN_ID)"; |
274 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | - $table_name = 'esp_log'; |
|
276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
274 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $table_name = 'esp_log'; |
|
276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
277 | 277 | LOG_time datetime DEFAULT NULL, |
278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | KEY LOG_time (LOG_time), |
285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
286 | 286 | KEY LOG_type (LOG_type)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | - $table_name = 'esp_message'; |
|
289 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | + $table_name = 'esp_message'; |
|
289 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | 290 | GRP_ID int(10) unsigned NULL, |
291 | 291 | MSG_token varchar(255) NULL, |
292 | 292 | TXN_ID int(10) unsigned NULL, |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | KEY STS_ID (STS_ID), |
319 | 319 | KEY MSG_created (MSG_created), |
320 | 320 | KEY MSG_modified (MSG_modified)"; |
321 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
322 | - $table_name = 'esp_message_template'; |
|
323 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
321 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
322 | + $table_name = 'esp_message_template'; |
|
323 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | 324 | GRP_ID int(10) unsigned NOT NULL, |
325 | 325 | MTP_context varchar(50) NOT NULL, |
326 | 326 | MTP_template_field varchar(30) NOT NULL, |
327 | 327 | MTP_content text NOT NULL, |
328 | 328 | PRIMARY KEY (MTP_ID), |
329 | 329 | KEY GRP_ID (GRP_ID)"; |
330 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
331 | - $table_name = 'esp_message_template_group'; |
|
332 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
330 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
331 | + $table_name = 'esp_message_template_group'; |
|
332 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | 333 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
334 | 334 | MTP_name varchar(245) NOT NULL DEFAULT '', |
335 | 335 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
342 | 342 | PRIMARY KEY (GRP_ID), |
343 | 343 | KEY MTP_user_id (MTP_user_id)"; |
344 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | - $table_name = 'esp_payment'; |
|
346 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | + $table_name = 'esp_payment'; |
|
346 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | 347 | TXN_ID int(10) unsigned DEFAULT NULL, |
348 | 348 | STS_ID varchar(3) collate utf8_bin DEFAULT NULL, |
349 | 349 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | PRIMARY KEY (PAY_ID), |
361 | 361 | KEY PAY_timestamp (PAY_timestamp), |
362 | 362 | KEY TXN_ID (TXN_ID)"; |
363 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
364 | - $table_name = 'esp_payment_method'; |
|
365 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
363 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
364 | + $table_name = 'esp_payment_method'; |
|
365 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
366 | 366 | PMD_type varchar(124) DEFAULT NULL, |
367 | 367 | PMD_name varchar(255) DEFAULT NULL, |
368 | 368 | PMD_desc text, |
@@ -378,24 +378,24 @@ discard block |
||
378 | 378 | PRIMARY KEY (PMD_ID), |
379 | 379 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
380 | 380 | KEY PMD_type (PMD_type)"; |
381 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
382 | - $table_name = "esp_ticket_price"; |
|
383 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
381 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
382 | + $table_name = "esp_ticket_price"; |
|
383 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | 384 | TKT_ID int(10) unsigned NOT NULL, |
385 | 385 | PRC_ID int(10) unsigned NOT NULL, |
386 | 386 | PRIMARY KEY (TKP_ID), |
387 | 387 | KEY TKT_ID (TKT_ID), |
388 | 388 | KEY PRC_ID (PRC_ID)"; |
389 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
390 | - $table_name = "esp_ticket_template"; |
|
391 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
389 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
390 | + $table_name = "esp_ticket_template"; |
|
391 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
392 | 392 | TTM_name varchar(45) NOT NULL, |
393 | 393 | TTM_description text, |
394 | 394 | TTM_file varchar(45), |
395 | 395 | PRIMARY KEY (TTM_ID)"; |
396 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
397 | - $table_name = 'esp_question'; |
|
398 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
396 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
397 | + $table_name = 'esp_question'; |
|
398 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | 399 | QST_display_text text NOT NULL, |
400 | 400 | QST_admin_label varchar(255) NOT NULL, |
401 | 401 | QST_system varchar(25) DEFAULT NULL, |
@@ -409,18 +409,18 @@ discard block |
||
409 | 409 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
410 | 410 | PRIMARY KEY (QST_ID), |
411 | 411 | KEY QST_order (QST_order)'; |
412 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | - $table_name = 'esp_question_group_question'; |
|
414 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
412 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | + $table_name = 'esp_question_group_question'; |
|
414 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
415 | 415 | QSG_ID int(10) unsigned NOT NULL, |
416 | 416 | QST_ID int(10) unsigned NOT NULL, |
417 | 417 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
418 | 418 | PRIMARY KEY (QGQ_ID), |
419 | 419 | KEY QST_ID (QST_ID), |
420 | 420 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
421 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
422 | - $table_name = 'esp_question_option'; |
|
423 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
421 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
422 | + $table_name = 'esp_question_option'; |
|
423 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | 424 | QSO_value varchar(255) NOT NULL, |
425 | 425 | QSO_desc text NOT NULL, |
426 | 426 | QST_ID int(10) unsigned NOT NULL, |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | PRIMARY KEY (QSO_ID), |
431 | 431 | KEY QST_ID (QST_ID), |
432 | 432 | KEY QSO_order (QSO_order)"; |
433 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | - $table_name = 'esp_registration'; |
|
435 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
433 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | + $table_name = 'esp_registration'; |
|
435 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
436 | 436 | EVT_ID bigint(20) unsigned NOT NULL, |
437 | 437 | ATT_ID bigint(20) unsigned NOT NULL, |
438 | 438 | TXN_ID int(10) unsigned NOT NULL, |
@@ -456,18 +456,18 @@ discard block |
||
456 | 456 | KEY TKT_ID (TKT_ID), |
457 | 457 | KEY EVT_ID (EVT_ID), |
458 | 458 | KEY STS_ID (STS_ID)"; |
459 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
460 | - $table_name = 'esp_registration_payment'; |
|
461 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
459 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
460 | + $table_name = 'esp_registration_payment'; |
|
461 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
462 | 462 | REG_ID int(10) unsigned NOT NULL, |
463 | 463 | PAY_ID int(10) unsigned NULL, |
464 | 464 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
465 | 465 | PRIMARY KEY (RPY_ID), |
466 | 466 | KEY REG_ID (REG_ID), |
467 | 467 | KEY PAY_ID (PAY_ID)"; |
468 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
469 | - $table_name = 'esp_state'; |
|
470 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
468 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
469 | + $table_name = 'esp_state'; |
|
470 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
471 | 471 | CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
472 | 472 | STA_abbrev varchar(24) collate utf8_bin NOT NULL, |
473 | 473 | STA_name varchar(100) collate utf8_bin NOT NULL, |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | PRIMARY KEY (STA_ID), |
476 | 476 | KEY STA_abbrev (STA_abbrev), |
477 | 477 | KEY CNT_ISO (CNT_ISO)"; |
478 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
479 | - $table_name = 'esp_status'; |
|
480 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
478 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
479 | + $table_name = 'esp_status'; |
|
480 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
481 | 481 | STS_code varchar(45) NOT NULL, |
482 | 482 | STS_type varchar(45) NOT NULL, |
483 | 483 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
486 | 486 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
487 | 487 | KEY STS_type (STS_type)"; |
488 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
489 | - $table_name = 'esp_transaction'; |
|
490 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
488 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
489 | + $table_name = 'esp_transaction'; |
|
490 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | 491 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
492 | 492 | TXN_total decimal(10,3) DEFAULT '0.00', |
493 | 493 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | PRIMARY KEY (TXN_ID), |
500 | 500 | KEY TXN_timestamp (TXN_timestamp), |
501 | 501 | KEY STS_ID (STS_ID)"; |
502 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
503 | - $table_name = 'esp_venue_meta'; |
|
504 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
502 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
503 | + $table_name = 'esp_venue_meta'; |
|
504 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
505 | 505 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
506 | 506 | VNU_address varchar(255) DEFAULT NULL, |
507 | 507 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | KEY VNU_ID (VNU_ID), |
521 | 521 | KEY STA_ID (STA_ID), |
522 | 522 | KEY CNT_ISO (CNT_ISO)"; |
523 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
524 | - //modified tables |
|
525 | - $table_name = "esp_price"; |
|
526 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
523 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
524 | + //modified tables |
|
525 | + $table_name = "esp_price"; |
|
526 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
527 | 527 | PRT_ID tinyint(3) unsigned NOT NULL, |
528 | 528 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
529 | 529 | PRC_name varchar(245) NOT NULL, |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | PRC_parent int(10) unsigned DEFAULT 0, |
537 | 537 | PRIMARY KEY (PRC_ID), |
538 | 538 | KEY PRT_ID (PRT_ID)"; |
539 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | - $table_name = "esp_price_type"; |
|
541 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
539 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | + $table_name = "esp_price_type"; |
|
541 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
542 | 542 | PRT_name varchar(45) NOT NULL, |
543 | 543 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
544 | 544 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
548 | 548 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
549 | 549 | PRIMARY KEY (PRT_ID)"; |
550 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
551 | - $table_name = "esp_ticket"; |
|
552 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
550 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
551 | + $table_name = "esp_ticket"; |
|
552 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
553 | 553 | TTM_ID int(10) unsigned NOT NULL, |
554 | 554 | TKT_name varchar(245) NOT NULL DEFAULT '', |
555 | 555 | 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_has_not_changed_since_previous($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_has_not_changed_since_previous($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,41 +586,41 @@ 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 | - return true; |
|
609 | - } |
|
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 | + return true; |
|
609 | + } |
|
610 | 610 | |
611 | 611 | |
612 | 612 | |
613 | - /** |
|
614 | - * @return boolean |
|
615 | - */ |
|
616 | - public function schema_changes_after_migration() |
|
617 | - { |
|
618 | - return true; |
|
619 | - } |
|
613 | + /** |
|
614 | + * @return boolean |
|
615 | + */ |
|
616 | + public function schema_changes_after_migration() |
|
617 | + { |
|
618 | + return true; |
|
619 | + } |
|
620 | 620 | |
621 | 621 | |
622 | 622 | |
623 | - public function migration_page_hooks() |
|
624 | - { |
|
625 | - } |
|
623 | + public function migration_page_hooks() |
|
624 | + { |
|
625 | + } |
|
626 | 626 | } |
627 | 627 | \ No newline at end of file |
@@ -1,36 +1,36 @@ |
||
1 | 1 | <div id="admin-primary-mbox-reg-details-dv" class="admin-primary-mbox-dv"> |
2 | 2 | |
3 | - <?php do_action( 'AHEE__reg_admin_details_main_meta_box_reg_details__top', $REG_ID ); ?> |
|
3 | + <?php do_action('AHEE__reg_admin_details_main_meta_box_reg_details__top', $REG_ID); ?> |
|
4 | 4 | <?php echo $resend_registration_button; ?> |
5 | 5 | <?php echo $view_transaction_button; ?> |
6 | 6 | <br/> |
7 | 7 | |
8 | - <h3 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-clipboard"></span><?php _e( 'Registration Items', 'event_espresso' );?></h3> |
|
8 | + <h3 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-clipboard"></span><?php _e('Registration Items', 'event_espresso'); ?></h3> |
|
9 | 9 | |
10 | 10 | <?php echo $line_item_table; ?> |
11 | 11 | |
12 | 12 | <a id="display-additional-registration-session-info" class="display-the-hidden smaller-text" rel="additional-registration-session-info"> |
13 | - <span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional registration session details', 'event_espresso' );?> |
|
13 | + <span class="dashicons dashicons-plus-alt"></span><?php _e('view additional registration session details', 'event_espresso'); ?> |
|
14 | 14 | </a> |
15 | 15 | |
16 | 16 | <div id="additional-registration-session-info-dv" class="hidden"> |
17 | 17 | |
18 | 18 | <a id="hide-additional-registration-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-registration-session-info"> |
19 | - <span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional registration session details', 'event_espresso' );?> |
|
19 | + <span class="dashicons dashicons-dismiss"></span><?php _e('hide additional registration session details', 'event_espresso'); ?> |
|
20 | 20 | </a> |
21 | 21 | <br class="clear"/> |
22 | 22 | |
23 | - <h3 class="admin-primary-mbox-h4"><?php _e( 'Registration Session Details', 'event_espresso' );?></h3> |
|
23 | + <h3 class="admin-primary-mbox-h4"><?php _e('Registration Session Details', 'event_espresso'); ?></h3> |
|
24 | 24 | |
25 | 25 | <table id="admin-primary-mbox-reg-extra-session-info-tbl" class="form-table skinny-rows"> |
26 | 26 | <tbody> |
27 | - <?php foreach ( $reg_details as $key => $reg_detail ) : ?> |
|
27 | + <?php foreach ($reg_details as $key => $reg_detail) : ?> |
|
28 | 28 | <tr> |
29 | 29 | <th> |
30 | - <label for="<?php echo $key;?>"><?php echo $reg_detail['label'];?></label> |
|
30 | + <label for="<?php echo $key; ?>"><?php echo $reg_detail['label']; ?></label> |
|
31 | 31 | </th> |
32 | 32 | <td> |
33 | - <?php echo $reg_detail['value'];?> |
|
33 | + <?php echo $reg_detail['value']; ?> |
|
34 | 34 | </td> |
35 | 35 | </tr> |
36 | 36 | <?php endforeach; // $reg_details?> |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv"> |
2 | 2 | |
3 | 3 | <h3 class="admin-primary-mbox-h4 hdr-has-icon"> |
4 | - <span class="dashicons dashicons-cart"></span><?php _e( 'Transaction Items', 'event_espresso' );?> |
|
4 | + <span class="dashicons dashicons-cart"></span><?php _e('Transaction Items', 'event_espresso'); ?> |
|
5 | 5 | </h3> |
6 | 6 | |
7 | 7 | <div class="admin-primary-mbox-tbl-wrap"> |
@@ -10,27 +10,27 @@ discard block |
||
10 | 10 | </div> |
11 | 11 | |
12 | 12 | <a id="display-additional-transaction-session-info" class="display-the-hidden smaller-text" rel="additional-transaction-session-info"> |
13 | - <span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional transaction session details', 'event_espresso' );?> |
|
13 | + <span class="dashicons dashicons-plus-alt"></span><?php _e('view additional transaction session details', 'event_espresso'); ?> |
|
14 | 14 | </a> |
15 | 15 | |
16 | 16 | <div id="additional-transaction-session-info-dv" class="hidden"> |
17 | 17 | |
18 | 18 | <a id="hide-additional-transaction-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-transaction-session-info"> |
19 | - <span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional transaction session details', 'event_espresso' );?> |
|
19 | + <span class="dashicons dashicons-dismiss"></span><?php _e('hide additional transaction session details', 'event_espresso'); ?> |
|
20 | 20 | </a> |
21 | 21 | <br class="clear"/> |
22 | 22 | |
23 | - <h3 class="admin-primary-mbox-h4"><?php _e( 'Transaction Session Details', 'event_espresso' );?></h3> |
|
23 | + <h3 class="admin-primary-mbox-h4"><?php _e('Transaction Session Details', 'event_espresso'); ?></h3> |
|
24 | 24 | |
25 | 25 | <table id="admin-primary-mbox-txn-extra-session-info-tbl" class="form-table skinny-rows"> |
26 | 26 | <tbody> |
27 | - <?php foreach ( $txn_details as $key => $txn_detail ) : ?> |
|
27 | + <?php foreach ($txn_details as $key => $txn_detail) : ?> |
|
28 | 28 | <tr> |
29 | 29 | <th> |
30 | - <label for="<?php echo $key;?>"><?php echo $txn_detail['label'];?></label> |
|
30 | + <label for="<?php echo $key; ?>"><?php echo $txn_detail['label']; ?></label> |
|
31 | 31 | </th> |
32 | 32 | <td> |
33 | - <?php echo $txn_detail['value'];?> |
|
33 | + <?php echo $txn_detail['value']; ?> |
|
34 | 34 | </td> |
35 | 35 | </tr> |
36 | 36 | <?php endforeach; // $txn_details?> |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | <br class="clear"/> |
41 | 41 | |
42 | 42 | |
43 | - <?php if ( $attendee instanceof EE_Attendee && ( $grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty( $payments ) ) ) : ?> |
|
43 | + <?php if ($attendee instanceof EE_Attendee && ($grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty($payments))) : ?> |
|
44 | 44 | |
45 | 45 | <h3 class="admin-primary-mbox-h4 hdr-has-icon"> |
46 | - <span class="ee-icon ee-icon-cash"></span><?php _e( 'Payment Details', 'event_espresso' );?> |
|
46 | + <span class="ee-icon ee-icon-cash"></span><?php _e('Payment Details', 'event_espresso'); ?> |
|
47 | 47 | </h3> |
48 | 48 | |
49 | 49 | <div class="admin-primary-mbox-tbl-wrap"> |
@@ -52,79 +52,79 @@ discard block |
||
52 | 52 | <tr> |
53 | 53 | <th></th> |
54 | 54 | <th class="jst-cntr"></th> |
55 | - <th class="jst-cntr"><?php _e( 'ID', 'event_espresso' );?></th> |
|
56 | - <th class="jst-left"><?php _e( 'Date', 'event_espresso' );?></th> |
|
57 | - <th class="jst-cntr"><?php _e( 'Source', 'event_espresso' );?></th> |
|
58 | - <th class="jst-left"><?php _e( 'Method', 'event_espresso' );?></th> |
|
59 | - <th class="jst-left"><?php _e( 'Gateway Response', 'event_espresso' );?></th> |
|
60 | - <th class="jst-left"><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></th> |
|
61 | - <th class="jst-left"><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></th> |
|
62 | - <th class="jst-left"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></th> |
|
63 | - <!--<th class="jst-left"><?php _e( 'Details', 'event_espresso' );?></th>--> |
|
64 | - <th class="jst-cntr"><?php _e( 'Amount', 'event_espresso' );?></th> |
|
55 | + <th class="jst-cntr"><?php _e('ID', 'event_espresso'); ?></th> |
|
56 | + <th class="jst-left"><?php _e('Date', 'event_espresso'); ?></th> |
|
57 | + <th class="jst-cntr"><?php _e('Source', 'event_espresso'); ?></th> |
|
58 | + <th class="jst-left"><?php _e('Method', 'event_espresso'); ?></th> |
|
59 | + <th class="jst-left"><?php _e('Gateway Response', 'event_espresso'); ?></th> |
|
60 | + <th class="jst-left"><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></th> |
|
61 | + <th class="jst-left"><?php _e('P.O. / S.O. #', 'event_espresso'); ?></th> |
|
62 | + <th class="jst-left"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></th> |
|
63 | + <!--<th class="jst-left"><?php _e('Details', 'event_espresso'); ?></th>--> |
|
64 | + <th class="jst-cntr"><?php _e('Amount', 'event_espresso'); ?></th> |
|
65 | 65 | </tr> |
66 | 66 | </thead> |
67 | 67 | <tbody> |
68 | - <?php if ( $payments ) : ?> |
|
68 | + <?php if ($payments) : ?> |
|
69 | 69 | <?php $payment_total = 0; ?> |
70 | - <?php foreach ( $payments as $PAY_ID => $payment ) : |
|
71 | - $existing_reg_payment_json = isset( $existing_reg_payments[ $PAY_ID ] ) |
|
72 | - ? wp_json_encode( $existing_reg_payments[ $PAY_ID ] ) |
|
70 | + <?php foreach ($payments as $PAY_ID => $payment) : |
|
71 | + $existing_reg_payment_json = isset($existing_reg_payments[$PAY_ID]) |
|
72 | + ? wp_json_encode($existing_reg_payments[$PAY_ID]) |
|
73 | 73 | : '{}'; |
74 | 74 | ?> |
75 | - <tr id="txn-admin-payment-tr-<?php echo $PAY_ID;?>"> |
|
75 | + <tr id="txn-admin-payment-tr-<?php echo $PAY_ID; ?>"> |
|
76 | 76 | <td> |
77 | 77 | <span id="payment-status-<?php echo $PAY_ID; ?>" class="ee-status-strip-td ee-status-strip pymt-status-<?php echo $payment->STS_ID(); ?>"></span> |
78 | - <div id="payment-STS_ID-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->STS_ID();?></div> |
|
79 | - <div id="reg-payments-<?php echo $PAY_ID;?>" class="hidden"><?php echo $existing_reg_payment_json; ?></div> |
|
78 | + <div id="payment-STS_ID-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->STS_ID(); ?></div> |
|
79 | + <div id="reg-payments-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $existing_reg_payment_json; ?></div> |
|
80 | 80 | </td> |
81 | 81 | <td class=" jst-cntr"> |
82 | 82 | <ul class="txn-overview-actions-ul"> |
83 | 83 | <li> |
84 | - <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>"> |
|
84 | + <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>"> |
|
85 | 85 | <div class="dashicons dashicons-edit" style="margin: 0;"></div> |
86 | 86 | </a> |
87 | 87 | </li> |
88 | 88 | <li> |
89 | - <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>"> |
|
89 | + <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>"> |
|
90 | 90 | <div class="dashicons dashicons-trash" style="margin: 0;"></div> |
91 | 91 | </a> |
92 | 92 | </li> |
93 | 93 | </ul> |
94 | 94 | </td> |
95 | 95 | <td class=" jst-rght"> |
96 | - <div id="payment-id-<?php echo $PAY_ID;?>"><?php echo $PAY_ID;?></div> |
|
96 | + <div id="payment-id-<?php echo $PAY_ID; ?>"><?php echo $PAY_ID; ?></div> |
|
97 | 97 | </td> |
98 | 98 | <td class=" jst-left"> |
99 | - <div id="payment-date-<?php echo $PAY_ID;?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a');?></div> |
|
99 | + <div id="payment-date-<?php echo $PAY_ID; ?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a'); ?></div> |
|
100 | 100 | </td> |
101 | 101 | <td class=" jst-cntr"> |
102 | - <div id="payment-method-<?php echo $PAY_ID;?>"> |
|
103 | - <?php echo $payment->source();?> |
|
102 | + <div id="payment-method-<?php echo $PAY_ID; ?>"> |
|
103 | + <?php echo $payment->source(); ?> |
|
104 | 104 | </div> |
105 | 105 | </td> |
106 | 106 | <td class=" jst-left"> |
107 | - <div id="payment-gateway-<?php echo $PAY_ID;?>"> |
|
108 | - <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso');?> |
|
107 | + <div id="payment-gateway-<?php echo $PAY_ID; ?>"> |
|
108 | + <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'); ?> |
|
109 | 109 | </div> |
110 | - <div id="payment-gateway-id-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0;?></div> |
|
110 | + <div id="payment-gateway-id-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0; ?></div> |
|
111 | 111 | </td> |
112 | 112 | <td class=" jst-left"> |
113 | - <div id="payment-response-<?php echo $PAY_ID;?>"><?php echo $payment->gateway_response();?></div> |
|
113 | + <div id="payment-response-<?php echo $PAY_ID; ?>"><?php echo $payment->gateway_response(); ?></div> |
|
114 | 114 | </td> |
115 | 115 | <td class=" jst-left"> |
116 | - <div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->txn_id_chq_nmbr();?></div> |
|
116 | + <div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->txn_id_chq_nmbr(); ?></div> |
|
117 | 117 | </td> |
118 | 118 | <td class=" jst-left"> |
119 | - <div id="payment-po-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->po_number();?></div> |
|
119 | + <div id="payment-po-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->po_number(); ?></div> |
|
120 | 120 | </td> |
121 | 121 | <td class=" jst-left"> |
122 | - <div id="payment-accntng-<?php echo $PAY_ID;?>"><?php echo $payment->extra_accntng();?></div> |
|
122 | + <div id="payment-accntng-<?php echo $PAY_ID; ?>"><?php echo $payment->extra_accntng(); ?></div> |
|
123 | 123 | </td> |
124 | 124 | <td class=" jst-rght"> |
125 | - <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-' . $payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?> |
|
126 | - <span class="<?php echo $payment_class;?>"> |
|
127 | - <div id="payment-amount-<?php echo $PAY_ID;?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE ); ?></div> |
|
125 | + <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-'.$payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?> |
|
126 | + <span class="<?php echo $payment_class; ?>"> |
|
127 | + <div id="payment-amount-<?php echo $PAY_ID; ?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE); ?></div> |
|
128 | 128 | </span> |
129 | 129 | </td> |
130 | 130 | </tr> |
@@ -134,25 +134,25 @@ discard block |
||
134 | 134 | <?php endforeach; // $payment?> |
135 | 135 | <?php |
136 | 136 | $pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : ''; |
137 | - $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . __( 'This transaction has been overpaid ! ', 'event_espresso' ) . '</span>' : ''; |
|
137 | + $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">'.__('This transaction has been overpaid ! ', 'event_espresso').'</span>' : ''; |
|
138 | 138 | ?> |
139 | 139 | <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden"> |
140 | 140 | <td class=" jst-rght" colspan="11"> |
141 | - <span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span> |
|
141 | + <span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span> |
|
142 | 142 | </td> |
143 | 143 | </tr> |
144 | - <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class;?>"> |
|
145 | - <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid . sprintf( __( 'Payments Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' );?></span></th> |
|
146 | - <th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE);?></span></th> |
|
144 | + <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class; ?>"> |
|
145 | + <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid.sprintf(__('Payments Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); ?></span></th> |
|
146 | + <th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE); ?></span></th> |
|
147 | 147 | </tr> |
148 | 148 | <?php else : ?> |
149 | 149 | <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr"> |
150 | 150 | <td class=" jst-rght" colspan="11"> |
151 | - <span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span> |
|
151 | + <span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span> |
|
152 | 152 | </td> |
153 | 153 | </tr> |
154 | 154 | <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden"> |
155 | - <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __( 'Payments Total', 'event_espresso' );?></span></th> |
|
155 | + <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __('Payments Total', 'event_espresso'); ?></span></th> |
|
156 | 156 | <th class=" jst-rght"><span id="txn-admin-payment-total"></span></th> |
157 | 157 | </tr> |
158 | 158 | <?php endif; // $payments?> |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | <td class=" jst-cntr"> |
166 | 166 | <ul class="txn-overview-actions-ul"> |
167 | 167 | <li> |
168 | - <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="PAY_ID"> |
|
168 | + <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID"> |
|
169 | 169 | <div class="dashicons dashicons-edit" style="margin: 0;"></div> |
170 | 170 | </a> |
171 | 171 | </li> |
172 | 172 | <li> |
173 | - <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="PAY_ID"> |
|
173 | + <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID"> |
|
174 | 174 | <div class="dashicons dashicons-trash" style="margin: 0;"></div> |
175 | 175 | </a> |
176 | 176 | </li> |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | <ul id="txn-admin-payment-options-ul"> |
218 | 218 | <li> |
219 | 219 | <a id="display-txn-admin-apply-payment" class="button-primary no-icon no-hide" rel="txn-admin-apply-payment" > <!--display-the-hidden --> |
220 | - <?php _e( 'Apply Payment', 'event_espresso' );?> |
|
220 | + <?php _e('Apply Payment', 'event_espresso'); ?> |
|
221 | 221 | </a> |
222 | 222 | </li> |
223 | 223 | <li> |
224 | 224 | <a id="display-txn-admin-apply-refund" class="button-secondary no-icon no-hide" rel="txn-admin-apply-refund" > <!--display-the-hidden --> |
225 | - <?php _e( 'Apply Refund', 'event_espresso' );?> |
|
225 | + <?php _e('Apply Refund', 'event_espresso'); ?> |
|
226 | 226 | </a> |
227 | 227 | </li> |
228 | 228 | </ul> |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | |
233 | 233 | <h2 id="admin-modal-dialog-apply-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
234 | 234 | <div class="ee-icon ee-icon-cash-add float-left"></div> |
235 | - <?php echo __( 'Apply a Payment to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
235 | + <?php echo __('Apply a Payment to Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
236 | 236 | </h2> |
237 | 237 | |
238 | 238 | <h2 id="admin-modal-dialog-edit-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
239 | 239 | <div class="ee-icon ee-icon-cash-edit float-left"></div> |
240 | 240 | <?php |
241 | 241 | echo sprintf( |
242 | - __( 'Edit Payment #%s for Transaction #%s', 'event_espresso' ), |
|
242 | + __('Edit Payment #%s for Transaction #%s', 'event_espresso'), |
|
243 | 243 | '<span></span>', |
244 | 244 | $txn_nmbr['value'] |
245 | 245 | ); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | <div class="ee-icon ee-icon-cash-edit float-left"></div> |
251 | 251 | <?php |
252 | 252 | echo sprintf( |
253 | - __( 'Edit Refund #%s for Transaction #%s', 'event_espresso' ), |
|
253 | + __('Edit Refund #%s for Transaction #%s', 'event_espresso'), |
|
254 | 254 | '<span></span>', |
255 | 255 | $txn_nmbr['value'] |
256 | 256 | ); |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | |
260 | 260 | <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
261 | 261 | <div class="ee-icon ee-icon-cash-remove float-left"></div> |
262 | - <?php echo __( 'Apply a Refund to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
262 | + <?php echo __('Apply a Refund to Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
263 | 263 | </h2> |
264 | 264 | |
265 | 265 | <form name="txn-admin-apply-payment-frm" id="txn-admin-apply-payment-frm" action="<?php echo $apply_payment_form_url; ?>"> |
266 | 266 | <div class="admin-modal-dialog-wrap"> |
267 | 267 | <div class="admin-modal-dialog-inner"> |
268 | 268 | |
269 | - <input type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_apply_payment_nonce' );?>"/> |
|
269 | + <input type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce('espresso_apply_payment_nonce'); ?>"/> |
|
270 | 270 | <input type="hidden" name="espresso_ajax" id="espresso-ajax" value="0"/> |
271 | 271 | <input type="hidden" name="noheader" id="txn-admin-noheader-inp" value="0"/> |
272 | 272 | <input type="hidden" name="txn_admin_payment[PAY_ID]" id="txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/> |
@@ -274,108 +274,108 @@ discard block |
||
274 | 274 | <input type="hidden" name="txn_admin_payment[type]" id="txn-admin-payment-type-inp" value="1"/> |
275 | 275 | <input type="hidden" name="txn_admin_payment[details]" id="txn-admin-payment-details-inp" value=""/> |
276 | 276 | <input type="hidden" name="txn_admin_delete_payment_form_url" id="txn-admin-delete-payment-form-url-inp" value="<?php echo $delete_payment_form_url; ?>"/> |
277 | - <input type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date( 'Y-m-d h:i a', current_time( 'timestamp' )); ?>"/> |
|
277 | + <input type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date('Y-m-d h:i a', current_time('timestamp')); ?>"/> |
|
278 | 278 | |
279 | 279 | <div class="txn-admin-apply-payment-date-dv admin-modal-dialog-row"> |
280 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
281 | - <label for="txn-admin-payment-date-inp" class=""><?php _e( 'Payment Date', 'event_espresso' );?></label> |
|
282 | - <input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date( 'Y-m-d g:i a', current_time( 'timestamp' )); ?>"/> |
|
283 | - <p class="description"><?php _e( 'The date the payment was actually made on', 'event_espresso' );?></p> |
|
280 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
281 | + <label for="txn-admin-payment-date-inp" class=""><?php _e('Payment Date', 'event_espresso'); ?></label> |
|
282 | + <input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date('Y-m-d g:i a', current_time('timestamp')); ?>"/> |
|
283 | + <p class="description"><?php _e('The date the payment was actually made on', 'event_espresso'); ?></p> |
|
284 | 284 | </div> |
285 | 285 | |
286 | 286 | <div class="txn-admin-apply-payment-amount-dv admin-modal-dialog-row"> |
287 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
288 | - <label for="txn-admin-payment-amount-inp" class=""><?php _e( 'Amount', 'event_espresso' );?></label> |
|
287 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
288 | + <label for="txn-admin-payment-amount-inp" class=""><?php _e('Amount', 'event_espresso'); ?></label> |
|
289 | 289 | <input name="txn_admin_payment[amount]" id="txn-admin-payment-amount-inp" class="txn-admin-apply-payment-inp required" type="text" value=""/> |
290 | - <p class="description"><?php _e( 'The amount of the payment', 'event_espresso' );?></p> |
|
290 | + <p class="description"><?php _e('The amount of the payment', 'event_espresso'); ?></p> |
|
291 | 291 | </div> |
292 | 292 | |
293 | 293 | <div class="txn-admin-apply-payment-method-dv admin-modal-dialog-row"> |
294 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
295 | - <label for="txn-admin-payment-method-inp" class=""><?php _e( 'Method of Payment', 'event_espresso' );?></label> |
|
294 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
295 | + <label for="txn-admin-payment-method-inp" class=""><?php _e('Method of Payment', 'event_espresso'); ?></label> |
|
296 | 296 | <select name="txn_admin_payment[PMD_ID]" id="txn-admin-payment-method-slct" class="txn-admin-apply-payment-slct required" type="text" > |
297 | - <?php foreach ( $payment_methods as $method ) : ?> |
|
297 | + <?php foreach ($payment_methods as $method) : ?> |
|
298 | 298 | <?php $selected = $method->slug() == 'cash' ? ' selected="selected"' : ''; ?> |
299 | - <option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key( $method->admin_desc() ) ? substr( $method->admin_desc(), 0, 128) : $method->admin_name() ; ?> </option> |
|
299 | + <option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key($method->admin_desc()) ? substr($method->admin_desc(), 0, 128) : $method->admin_name(); ?> </option> |
|
300 | 300 | <?php endforeach; ?> |
301 | 301 | </select> |
302 | - <p class="description"><?php _e( 'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso' );?></p> |
|
302 | + <p class="description"><?php _e('Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso'); ?></p> |
|
303 | 303 | </div> |
304 | 304 | |
305 | 305 | <div class="mop-PP mop-CC mop-CHQ mop"> |
306 | 306 | <div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row"> |
307 | - <label for="txn-admin-payment-txn-id-inp" class=""><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></label> |
|
307 | + <label for="txn-admin-payment-txn-id-inp" class=""><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></label> |
|
308 | 308 | <input name="txn_admin_payment[txn_id_chq_nmbr]" id="txn-admin-payment-txn-id-chq-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/> |
309 | - <p class="description"><?php _e( 'The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso' );?></p> |
|
309 | + <p class="description"><?php _e('The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso'); ?></p> |
|
310 | 310 | </div> |
311 | 311 | </div> |
312 | 312 | |
313 | 313 | <div class="mop-CC mop" style="display:none"> |
314 | 314 | <div class="txn-admin-apply-payment-response-dv admin-modal-dialog-row"> |
315 | - <label for="txn-admin-payment-gateway-response-inp" class=""><?php _e( 'Gateway Response', 'event_espresso' );?></label> |
|
315 | + <label for="txn-admin-payment-gateway-response-inp" class=""><?php _e('Gateway Response', 'event_espresso'); ?></label> |
|
316 | 316 | <input name="txn_admin_payment[gateway_response]" id="txn-admin-payment-gateway-response-inp" class="txn-admin-apply-payment-inp" type="text"/> |
317 | - <p class="description"><?php _e( 'The gateway response string (optional)', 'event_espresso' );?></p> |
|
317 | + <p class="description"><?php _e('The gateway response string (optional)', 'event_espresso'); ?></p> |
|
318 | 318 | </div> |
319 | 319 | </div> |
320 | 320 | |
321 | 321 | <div class="mop-PP mop-CC mop"> |
322 | 322 | <div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row"> |
323 | - <label for="txn-admin-payment-status-inp" class=""><?php _e( 'Payment Status', 'event_espresso' );?></label> |
|
323 | + <label for="txn-admin-payment-status-inp" class=""><?php _e('Payment Status', 'event_espresso'); ?></label> |
|
324 | 324 | <select name="txn_admin_payment[status]" id="txn-admin-payment-status-slct" class="txn-admin-apply-payment-slct" type="text" > |
325 | - <?php foreach ( $payment_status as $STS_ID => $STS_code ) : ?> |
|
325 | + <?php foreach ($payment_status as $STS_ID => $STS_code) : ?> |
|
326 | 326 | <?php $selected = $STS_ID == 'PAP' ? ' selected="selected"' : ''; ?> |
327 | 327 | <option id="payment-status-opt-<?php echo $STS_ID; ?>" value="<?php echo $STS_ID; ?>"<?php echo $selected; ?>><?php echo $STS_code; ?> </option> |
328 | 328 | <?php endforeach; ?> |
329 | 329 | </select> |
330 | - <p class="description"><?php _e( 'Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso' );?></p> |
|
330 | + <p class="description"><?php _e('Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso'); ?></p> |
|
331 | 331 | </div> |
332 | 332 | </div> |
333 | 333 | |
334 | 334 | <div class="txn-admin-apply-payment-po-nmbr-dv admin-modal-dialog-row"> |
335 | - <label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></label> |
|
335 | + <label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e('P.O. / S.O. #', 'event_espresso'); ?></label> |
|
336 | 336 | <input name="txn_admin_payment[po_number]" id="txn-admin-payment-po-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/> |
337 | - <p class="description"><?php _e( 'The Purchase or Sales Order Number if any (optional)', 'event_espresso' );?></p> |
|
337 | + <p class="description"><?php _e('The Purchase or Sales Order Number if any (optional)', 'event_espresso'); ?></p> |
|
338 | 338 | </div> |
339 | 339 | |
340 | 340 | <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
341 | - <label for="txn-admin-payment-accounting-inp" class="last"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></label> |
|
341 | + <label for="txn-admin-payment-accounting-inp" class="last"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></label> |
|
342 | 342 | <input name="txn_admin_payment[accounting]" id="txn-admin-payment-accounting-inp" class="txn-admin-apply-payment-inp" type="text" value="<?php echo $REG_code; ?>" maxlength="100"/> <input type="hidden" id="txn-admin-reg-code-inp" value="<?php echo $REG_code; ?>"/> |
343 | - <p class="description"><?php _e( 'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso' );?></p> |
|
343 | + <p class="description"><?php _e('An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso'); ?></p> |
|
344 | 344 | </div> |
345 | 345 | |
346 | 346 | <div class="txn-admin-apply-payment-registrations-dv admin-modal-dialog-row"> |
347 | - <label for="txn-admin-payment-registrations-inp" class="last"><?php _e( 'Registrations to Apply Payment to:', 'event_espresso' ); ?></label> |
|
347 | + <label for="txn-admin-payment-registrations-inp" class="last"><?php _e('Registrations to Apply Payment to:', 'event_espresso'); ?></label> |
|
348 | 348 | <label class="txn-admin-apply-payment-to-registrations-lbl"> |
349 | 349 | <input type="radio" value="1" id="txn-admin-apply-payment-to-all-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" checked="checked"/> |
350 | - <?php _e( 'ALL Registrations', 'event_espresso' ); ?> |
|
350 | + <?php _e('ALL Registrations', 'event_espresso'); ?> |
|
351 | 351 | </label> |
352 | 352 | <label class="txn-admin-apply-payment-to-registrations-lbl"> |
353 | 353 | <input type="radio" value="0" id="txn-admin-apply-payment-to-some-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" /> |
354 | - <?php _e( 'Just the following Registrations', 'event_espresso' ); ?> |
|
354 | + <?php _e('Just the following Registrations', 'event_espresso'); ?> |
|
355 | 355 | </label> |
356 | 356 | <?php echo $registrations_to_apply_payment_to; ?> |
357 | 357 | </div> |
358 | 358 | |
359 | 359 | <div class="txn-admin-payment-reg-status-dv admin-modal-dialog-row"> |
360 | - <label for="txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label> |
|
360 | + <label for="txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label> |
|
361 | 361 | <?php echo $status_change_select; ?> |
362 | - <p class="description"><?php _e( 'If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso' ); ?></p> |
|
362 | + <p class="description"><?php _e('If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso'); ?></p> |
|
363 | 363 | <br/> |
364 | 364 | </div> |
365 | 365 | |
366 | 366 | <div class="txn-admin-apply-payment-send-notifications-dv admin-modal-dialog-row"> |
367 | 367 | |
368 | - <label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label> |
|
368 | + <label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label> |
|
369 | 369 | <label class="txn-admin-payment-send-notifications-lbl"> |
370 | 370 | <input type="checkbox" value="1" name="txn_payments[send_notifications]" checked="checked" aria-checked="true" style="vertical-align: middle;"> |
371 | - <?php _e( 'Payment Messages?', 'event_espresso' ); ?> |
|
371 | + <?php _e('Payment Messages?', 'event_espresso'); ?> |
|
372 | 372 | </label> |
373 | 373 | <label class="txn-admin-payment-send-notifications-lbl"> |
374 | 374 | <input type="checkbox" value="1" name="txn_reg_status_change[send_notifications]" style="vertical-align: middle;"> |
375 | - <?php _e( 'Registration Messages?', 'event_espresso' ); ?> |
|
375 | + <?php _e('Registration Messages?', 'event_espresso'); ?> |
|
376 | 376 | </label> |
377 | 377 | <br class="clear-float"/> |
378 | - <p class="description"><?php printf( __('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />' ); ?></p> |
|
378 | + <p class="description"><?php printf(__('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />'); ?></p> |
|
379 | 379 | <label></label> |
380 | 380 | </div> |
381 | 381 | <div class="clear"></div> |
@@ -386,27 +386,27 @@ discard block |
||
386 | 386 | <ul id="admin-modal-dialog-options-ul"> |
387 | 387 | <li> |
388 | 388 | <a id="txn-admin-modal-dialog-apply-payment-lnk" class="button-primary no-icon" style="display:none;" > |
389 | - <?php _e( 'Apply Payment', 'event_espresso' );?> |
|
389 | + <?php _e('Apply Payment', 'event_espresso'); ?> |
|
390 | 390 | </a> |
391 | 391 | </li> |
392 | 392 | <li> |
393 | 393 | <a id="txn-admin-modal-dialog-edit-payment-lnk" class="button-primary no-icon" style="display:none;" > |
394 | - <?php _e( 'Save Payment Details', 'event_espresso' );?> |
|
394 | + <?php _e('Save Payment Details', 'event_espresso'); ?> |
|
395 | 395 | </a> |
396 | 396 | </li> |
397 | 397 | <li> |
398 | 398 | <a id="txn-admin-modal-dialog-edit-refund-lnk" class="button-primary no-icon" style="display:none;" > |
399 | - <?php _e( 'Save Refund Details', 'event_espresso' );?> |
|
399 | + <?php _e('Save Refund Details', 'event_espresso'); ?> |
|
400 | 400 | </a> |
401 | 401 | </li> |
402 | 402 | <li> |
403 | 403 | <a id="txn-admin-modal-dialog-apply-refund-lnk" class="button-primary no-icon" style="display:none;" > |
404 | - <?php _e( 'Apply Refund', 'event_espresso' );?> |
|
404 | + <?php _e('Apply Refund', 'event_espresso'); ?> |
|
405 | 405 | </a> |
406 | 406 | </li> |
407 | 407 | <li> |
408 | 408 | <a id="txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" > |
409 | - <?php _e( 'Cancel', 'event_espresso' );?> |
|
409 | + <?php _e('Cancel', 'event_espresso'); ?> |
|
410 | 410 | </a> |
411 | 411 | </li> |
412 | 412 | <li> |
@@ -423,29 +423,29 @@ discard block |
||
423 | 423 | |
424 | 424 | <h2 id="admin-modal-dialog-delete-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
425 | 425 | <span class="ee-icon ee-icon-cash-add"></span> |
426 | - <?php echo __( 'Delete Payment/Refund for Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
426 | + <?php echo __('Delete Payment/Refund for Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
427 | 427 | </h2> |
428 | 428 | |
429 | 429 | <form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm" action="<?php echo $delete_payment_url; ?>"> |
430 | 430 | <div class="admin-modal-dialog-wrap"> |
431 | 431 | <div class="admin-modal-dialog-inner"> |
432 | 432 | |
433 | - <input type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_delete_payment_nonce' );?>"/> |
|
433 | + <input type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce('espresso_delete_payment_nonce'); ?>"/> |
|
434 | 434 | <input type="hidden" name="delete_espresso_ajax" id="delete-espresso-ajax" value="0"/> |
435 | 435 | <input type="hidden" name="delete_noheader" id="delete-txn-admin-noheader-inp" value="0"/> |
436 | 436 | <input type="hidden" name="delete_txn_admin_payment[PAY_ID]" id="delete-txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/> |
437 | 437 | <input type="hidden" name="delete_txn_admin_payment[TXN_ID]" id="delete-txn-admin-payment-txn-id-inp" value="<?php echo $txn_nmbr['value']; ?>"/> |
438 | 438 | |
439 | 439 | <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
440 | - <label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label> |
|
440 | + <label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label> |
|
441 | 441 | <?php echo $delete_status_change_select; ?> |
442 | - <p class="description"><?php printf( __('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
442 | + <p class="description"><?php printf(__('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
443 | 443 | </div> |
444 | 444 | |
445 | 445 | <div class="ee-attention txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
446 | - <label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label> |
|
446 | + <label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label> |
|
447 | 447 | <input type="checkbox" value="1" name="delete_txn_reg_status_change[send_notifications]"> |
448 | - <p class="description"><?php _e( 'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso' );?></p> |
|
448 | + <p class="description"><?php _e('If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso'); ?></p> |
|
449 | 449 | </div> |
450 | 450 | <div class="clear"></div> |
451 | 451 | |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | <ul id="del-admin-modal-dialog-options-ul"> |
456 | 456 | <li> |
457 | 457 | <a id="txn-admin-modal-dialog-delete-lnk" class="button-primary no-icon" style="display:none;" > |
458 | - <?php _e( 'Delete', 'event_espresso' );?> |
|
458 | + <?php _e('Delete', 'event_espresso'); ?> |
|
459 | 459 | </a> |
460 | 460 | </li> |
461 | 461 | <li> |
462 | 462 | <a id="del-txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" > |
463 | - <?php _e( 'Cancel', 'event_espresso' );?> |
|
463 | + <?php _e('Cancel', 'event_espresso'); ?> |
|
464 | 464 | </a> |
465 | 465 | </li> |
466 | 466 | <li> |
@@ -476,30 +476,30 @@ discard block |
||
476 | 476 | <?php endif; // $grand_raw_total > 0?> |
477 | 477 | |
478 | 478 | <?php |
479 | - if ( WP_DEBUG ) { |
|
480 | - $delivered_messages = get_option( 'EED_Messages__payment', array() ); |
|
481 | - if ( isset( $delivered_messages[ $TXN_ID ] )) { |
|
479 | + if (WP_DEBUG) { |
|
480 | + $delivered_messages = get_option('EED_Messages__payment', array()); |
|
481 | + if (isset($delivered_messages[$TXN_ID])) { |
|
482 | 482 | ?> |
483 | - <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e( 'Messages Sent to Primary Registrant', 'event_espresso' );?></h4> |
|
483 | + <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e('Messages Sent to Primary Registrant', 'event_espresso'); ?></h4> |
|
484 | 484 | |
485 | 485 | <div class="admin-primary-mbox-tbl-wrap"> |
486 | 486 | <table class="admin-primary-mbox-tbl"> |
487 | 487 | <thead> |
488 | 488 | <tr> |
489 | - <th class="jst-left"><?php _e( 'Date & Time', 'event_espresso' );?></th> |
|
490 | - <th class="jst-left"><?php _e( 'Message Type', 'event_espresso' );?></th> |
|
491 | - <th class="jst-left"><?php _e( 'Payment Status Upon Sending', 'event_espresso' );?></th> |
|
492 | - <th class="jst-left"><?php _e( 'TXN Status Upon Sending', 'event_espresso' );?></th> |
|
489 | + <th class="jst-left"><?php _e('Date & Time', 'event_espresso'); ?></th> |
|
490 | + <th class="jst-left"><?php _e('Message Type', 'event_espresso'); ?></th> |
|
491 | + <th class="jst-left"><?php _e('Payment Status Upon Sending', 'event_espresso'); ?></th> |
|
492 | + <th class="jst-left"><?php _e('TXN Status Upon Sending', 'event_espresso'); ?></th> |
|
493 | 493 | </tr> |
494 | 494 | </thead> |
495 | 495 | <tbody> |
496 | - <?php foreach ( $delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message ) : |
|
496 | + <?php foreach ($delivered_messages[$TXN_ID] as $timestamp => $delivered_message) : |
|
497 | 497 | ?> |
498 | 498 | <tr> |
499 | - <td class="jst-left"><?php echo date( get_option('date_format') . ' ' . get_option('time_format'), ( $timestamp + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );?></td> |
|
500 | - <td class="jst-left"><?php echo isset( $delivered_message['message_type'] ) ? $delivered_message['message_type'] : '';?></td> |
|
501 | - <td class="jst-left"><?php echo isset( $delivered_message['pay_status'] ) ? $delivered_message['pay_status'] : '';?></td> |
|
502 | - <td class="jst-left"><?php echo isset( $delivered_message['txn_status'] ) ? $delivered_message['txn_status'] : '';?></td> |
|
499 | + <td class="jst-left"><?php echo date(get_option('date_format').' '.get_option('time_format'), ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td> |
|
500 | + <td class="jst-left"><?php echo isset($delivered_message['message_type']) ? $delivered_message['message_type'] : ''; ?></td> |
|
501 | + <td class="jst-left"><?php echo isset($delivered_message['pay_status']) ? $delivered_message['pay_status'] : ''; ?></td> |
|
502 | + <td class="jst-left"><?php echo isset($delivered_message['txn_status']) ? $delivered_message['txn_status'] : ''; ?></td> |
|
503 | 503 | </tr> |
504 | 504 | <?php endforeach; // $delivered_messages?> |
505 | 505 | </tbody> |
@@ -105,41 +105,41 @@ discard block |
||
105 | 105 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
106 | 106 | * @return \EEM_Line_Item |
107 | 107 | */ |
108 | - protected function __construct( $timezone ) { |
|
109 | - $this->singular_item = __('Line Item','event_espresso'); |
|
110 | - $this->plural_item = __('Line Items','event_espresso'); |
|
108 | + protected function __construct($timezone) { |
|
109 | + $this->singular_item = __('Line Item', 'event_espresso'); |
|
110 | + $this->plural_item = __('Line Items', 'event_espresso'); |
|
111 | 111 | |
112 | 112 | $this->_tables = array( |
113 | - 'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID') |
|
113 | + 'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID') |
|
114 | 114 | ); |
115 | - $line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) ); |
|
115 | + $line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event')); |
|
116 | 116 | $this->_fields = array( |
117 | 117 | 'Line_Item' => array( |
118 | - 'LIN_ID' => new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ), |
|
119 | - 'LIN_code' => new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ), |
|
120 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ), |
|
121 | - 'LIN_name' => new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ), |
|
122 | - 'LIN_desc' => new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ), |
|
123 | - 'LIN_unit_price' => new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ), |
|
124 | - 'LIN_percent' => new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ), |
|
125 | - 'LIN_is_taxable' => new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ), |
|
126 | - 'LIN_order' => new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ), |
|
127 | - 'LIN_total' => new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ), |
|
128 | - 'LIN_quantity' => new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ), |
|
129 | - 'LIN_parent' => new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ), |
|
130 | - 'LIN_type' => new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array( |
|
118 | + 'LIN_ID' => new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")), |
|
119 | + 'LIN_code' => new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE), |
|
120 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'), |
|
121 | + 'LIN_name' => new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''), |
|
122 | + 'LIN_desc' => new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE), |
|
123 | + 'LIN_unit_price' => new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0), |
|
124 | + 'LIN_percent' => new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0), |
|
125 | + 'LIN_is_taxable' => new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE), |
|
126 | + 'LIN_order' => new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1), |
|
127 | + 'LIN_total' => new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0), |
|
128 | + 'LIN_quantity' => new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1), |
|
129 | + 'LIN_parent' => new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL), |
|
130 | + 'LIN_type' => new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array( |
|
131 | 131 | self::type_line_item => __("Line Item", "event_espresso"), |
132 | 132 | self::type_sub_line_item => __("Sub-Item", "event_espresso"), |
133 | 133 | self::type_sub_total => __("Subtotal", "event_espresso"), |
134 | 134 | self::type_tax_sub_total => __("Tax Subtotal", "event_espresso"), |
135 | 135 | self::type_tax => __("Tax", "event_espresso"), |
136 | 136 | self::type_total => __("Total", "event_espresso"), |
137 | - self::type_cancellation => __( 'Cancellation', 'event_espresso' ) |
|
137 | + self::type_cancellation => __('Cancellation', 'event_espresso') |
|
138 | 138 | ) |
139 | 139 | ), |
140 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ), |
|
141 | - 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ), |
|
142 | - 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
140 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for), |
|
141 | + 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for), |
|
142 | + 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | $this->_model_relations = array( |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
152 | 152 | $this->_caps_slug = 'transactions'; |
153 | - parent::__construct( $timezone ); |
|
153 | + parent::__construct($timezone); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param EE_Transaction|int $transaction |
162 | 162 | * @return EE_Line_Item[] |
163 | 163 | */ |
164 | - public function get_all_of_type_for_transaction( $line_item_type, $transaction ){ |
|
165 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
166 | - return $this->get_all( array( array( |
|
164 | + public function get_all_of_type_for_transaction($line_item_type, $transaction) { |
|
165 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
166 | + return $this->get_all(array(array( |
|
167 | 167 | 'LIN_type' => $line_item_type, |
168 | 168 | 'TXN_ID' => $transaction |
169 | 169 | ))); |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | * @param EE_Transaction|int $transaction |
178 | 178 | * @return EE_Line_Item[] |
179 | 179 | */ |
180 | - public function get_all_non_ticket_line_items_for_transaction( $transaction ) { |
|
181 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
182 | - return $this->get_all( array( array( |
|
180 | + public function get_all_non_ticket_line_items_for_transaction($transaction) { |
|
181 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
182 | + return $this->get_all(array(array( |
|
183 | 183 | 'LIN_type' => self::type_line_item, |
184 | 184 | 'TXN_ID' => $transaction, |
185 | 185 | 'OR' => array( |
186 | - 'OBJ_type*notticket' => array( '!=', 'Ticket'), |
|
187 | - 'OBJ_type*null' => array( 'IS_NULL' )) |
|
186 | + 'OBJ_type*notticket' => array('!=', 'Ticket'), |
|
187 | + 'OBJ_type*null' => array('IS_NULL')) |
|
188 | 188 | ))); |
189 | 189 | } |
190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * because if there are spam bots afoot there will be LOTS of line items |
195 | 195 | * @return int count of how many deleted |
196 | 196 | */ |
197 | - public function delete_line_items_with_no_transaction(){ |
|
197 | + public function delete_line_items_with_no_transaction() { |
|
198 | 198 | /** @type WPDB $wpdb */ |
199 | 199 | global $wpdb; |
200 | 200 | $time_to_leave_alone = apply_filters( |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | ); |
203 | 203 | $query = $wpdb->prepare( |
204 | 204 | 'DELETE li |
205 | - FROM ' . $this->table() . ' li |
|
206 | - LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID |
|
205 | + FROM ' . $this->table().' li |
|
206 | + LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID |
|
207 | 207 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
208 | 208 | // use GMT time because that's what TXN_timestamps are in |
209 | - date( 'Y-m-d H:i:s', time() - $time_to_leave_alone ) |
|
209 | + date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
210 | 210 | ); |
211 | - return $wpdb->query( $query ); |
|
211 | + return $wpdb->query($query); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param \EE_Base_Class $object |
222 | 222 | * @return EE_Line_Item[] |
223 | 223 | */ |
224 | - public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){ |
|
225 | - return $this->get_all( array( array( |
|
224 | + public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) { |
|
225 | + return $this->get_all(array(array( |
|
226 | 226 | 'TXN_ID' => $TXN_ID, |
227 | - 'OBJ_type' => str_replace( 'EE_', '', get_class( $object )), |
|
227 | + 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
228 | 228 | 'OBJ_ID' => $object->ID() |
229 | 229 | ))); |
230 | 230 | } |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * @param array $OBJ_IDs |
241 | 241 | * @return EE_Line_Item[] |
242 | 242 | */ |
243 | - public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){ |
|
243 | + public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) { |
|
244 | 244 | $query_params = array( |
245 | 245 | 'OBJ_type' => $OBJ_type, |
246 | 246 | // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
247 | - 'OBJ_ID' => is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs |
|
247 | + 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs |
|
248 | 248 | ); |
249 | - if ( $TXN_ID ) { |
|
249 | + if ($TXN_ID) { |
|
250 | 250 | $query_params['TXN_ID'] = $TXN_ID; |
251 | 251 | } |
252 | - return $this->get_all( array( $query_params )); |
|
252 | + return $this->get_all(array($query_params)); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * @param EE_Transaction $transaction |
261 | 261 | * @return EE_Line_Item[] |
262 | 262 | */ |
263 | - public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) { |
|
264 | - return $this->get_all( array( |
|
263 | + public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) { |
|
264 | + return $this->get_all(array( |
|
265 | 265 | array( |
266 | 266 | 'TXN_ID' => $transaction->ID(), |
267 | 267 | 'OBJ_type' => 'Ticket', |
268 | 268 | ) |
269 | - ) ); |
|
269 | + )); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | * @param int $TKT_ID |
279 | 279 | * @return \EE_Line_Item |
280 | 280 | */ |
281 | - public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) { |
|
282 | - return $this->get_one( array( |
|
281 | + public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) { |
|
282 | + return $this->get_one(array( |
|
283 | 283 | array( |
284 | - 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ), |
|
284 | + 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
285 | 285 | 'OBJ_ID' => $TKT_ID, |
286 | 286 | 'OBJ_type' => 'Ticket', |
287 | 287 | ) |
288 | - ) ); |
|
288 | + )); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param EE_Promotion $promotion |
301 | 301 | * @return EE_Line_Item |
302 | 302 | */ |
303 | - public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) { |
|
304 | - return $this->get_one( array( |
|
303 | + public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) { |
|
304 | + return $this->get_one(array( |
|
305 | 305 | array( |
306 | 306 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
307 | 307 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param EE_Line_Item $parent_line_item |
323 | 323 | * @return EE_Line_Item[] |
324 | 324 | */ |
325 | - public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) { |
|
326 | - return $this->get_all( array( |
|
325 | + public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) { |
|
326 | + return $this->get_all(array( |
|
327 | 327 | array( |
328 | 328 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
329 | 329 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @param EE_Registration $registration |
341 | 341 | * @return EE_Line_ITem |
342 | 342 | */ |
343 | - public function get_line_item_for_registration( EE_Registration $registration ) { |
|
344 | - return $this->get_one( $this->line_item_for_registration_query_params( $registration )); |
|
343 | + public function get_line_item_for_registration(EE_Registration $registration) { |
|
344 | + return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * @param array $original_query_params any extra query params you'd like to be merged with |
351 | 351 | * @return array like EEM_Base::get_all()'s $query_params |
352 | 352 | */ |
353 | - public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) { |
|
354 | - return array_replace_recursive( $original_query_params, array( |
|
353 | + public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) { |
|
354 | + return array_replace_recursive($original_query_params, array( |
|
355 | 355 | array( |
356 | 356 | 'OBJ_ID' => $registration->ticket_ID(), |
357 | 357 | 'OBJ_type' => 'Ticket', |
358 | 358 | 'TXN_ID' => $registration->transaction_ID() |
359 | 359 | ) |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | * @throws \EE_Error |
55 | 55 | */ |
56 | - public static function get_valid_timezone_string( $timezone_string = '' ) { |
|
56 | + public static function get_valid_timezone_string($timezone_string = '') { |
|
57 | 57 | // if passed a value, then use that, else get WP option |
58 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
58 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
59 | 59 | // value from above exists, use that, else get timezone string from gmt_offset |
60 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | - EEH_DTT_Helper::validate_timezone( $timezone_string ); |
|
60 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
62 | 62 | return $timezone_string; |
63 | 63 | } |
64 | 64 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @return bool |
75 | 75 | * @throws \EE_Error |
76 | 76 | */ |
77 | - public static function validate_timezone( $timezone_string, $throw_error = true ) { |
|
77 | + public static function validate_timezone($timezone_string, $throw_error = true) { |
|
78 | 78 | // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
79 | 79 | try { |
80 | - new DateTimeZone( $timezone_string ); |
|
81 | - } catch ( Exception $e ) { |
|
80 | + new DateTimeZone($timezone_string); |
|
81 | + } catch (Exception $e) { |
|
82 | 82 | // sometimes we take exception to exceptions |
83 | - if ( ! $throw_error ) { |
|
83 | + if ( ! $throw_error) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | throw new EE_Error( |
87 | 87 | sprintf( |
88 | - __( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
88 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
89 | 89 | $timezone_string, |
90 | 90 | '<a href="http://www.php.net/manual/en/timezones.php">', |
91 | 91 | '</a>' |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param string $gmt_offset |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) { |
|
107 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') { |
|
108 | 108 | $timezone_string = 'UTC'; |
109 | - $gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' ); |
|
110 | - if ( $gmt_offset !== '' ) { |
|
109 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
110 | + if ($gmt_offset !== '') { |
|
111 | 111 | // convert GMT offset to seconds |
112 | 112 | $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
113 | 113 | // account for WP offsets that aren't valid UTC |
114 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset ); |
|
114 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
115 | 115 | // although we don't know the TZ abbreviation, we know the UTC offset |
116 | - $timezone_string = timezone_name_from_abbr( null, $gmt_offset ); |
|
116 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
117 | 117 | } |
118 | 118 | // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
119 | - $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset ); |
|
119 | + $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
120 | 120 | return $timezone_string; |
121 | 121 | } |
122 | 122 | |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * @return int seconds offset |
128 | 128 | */ |
129 | 129 | public static function get_site_timezone_gmt_offset() { |
130 | - $timezone_string = get_option( 'timezone_string' ); |
|
131 | - if ( $timezone_string ) { |
|
130 | + $timezone_string = get_option('timezone_string'); |
|
131 | + if ($timezone_string) { |
|
132 | 132 | try { |
133 | - $timezone = new DateTimeZone( $timezone_string ); |
|
134 | - return $timezone->getOffset( new DateTime() ); //in WordPress DateTime defaults to UTC |
|
135 | - } catch( Exception $e ){} |
|
133 | + $timezone = new DateTimeZone($timezone_string); |
|
134 | + return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
135 | + } catch (Exception $e) {} |
|
136 | 136 | } |
137 | - $offset = get_option( 'gmt_offset' ); |
|
138 | - return (int) ( $offset * HOUR_IN_SECONDS ); |
|
137 | + $offset = get_option('gmt_offset'); |
|
138 | + return (int) ($offset * HOUR_IN_SECONDS); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @param int $gmt_offset |
148 | 148 | * @return int |
149 | 149 | */ |
150 | - public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) { |
|
150 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) { |
|
151 | 151 | //make sure $gmt_offset is int |
152 | 152 | $gmt_offset = (int) $gmt_offset; |
153 | - switch ( $gmt_offset ) { |
|
153 | + switch ($gmt_offset) { |
|
154 | 154 | |
155 | 155 | // case -30600 : |
156 | 156 | // $gmt_offset = -28800; |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | * @return string |
203 | 203 | * @throws \EE_Error |
204 | 204 | */ |
205 | - public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) { |
|
205 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) { |
|
206 | 206 | $abbreviations = timezone_abbreviations_list(); |
207 | - foreach ( $abbreviations as $abbreviation ) { |
|
208 | - foreach ( $abbreviation as $city ) { |
|
209 | - if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) { |
|
207 | + foreach ($abbreviations as $abbreviation) { |
|
208 | + foreach ($abbreviation as $city) { |
|
209 | + if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) { |
|
210 | 210 | // check if the timezone is valid but don't throw any errors if it isn't |
211 | - if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) { |
|
211 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
212 | 212 | return $city['timezone_id']; |
213 | 213 | } |
214 | 214 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | throw new EE_Error( |
218 | 218 | sprintf( |
219 | - __( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
219 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
220 | 220 | $gmt_offset, |
221 | 221 | '<a href="http://www.php.net/manual/en/timezones.php">', |
222 | 222 | '</a>' |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @access public |
231 | 231 | * @param string $timezone_string |
232 | 232 | */ |
233 | - public static function timezone_select_input( $timezone_string = '' ) { |
|
233 | + public static function timezone_select_input($timezone_string = '') { |
|
234 | 234 | // get WP date time format |
235 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
235 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
236 | 236 | // if passed a value, then use that, else get WP option |
237 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
237 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
238 | 238 | // check if the timezone is valid but don't throw any errors if it isn't |
239 | - $timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false ); |
|
239 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
240 | 240 | $gmt_offset = get_option('gmt_offset'); |
241 | 241 | |
242 | 242 | $check_zone_info = true; |
243 | - if ( empty( $timezone_string )) { |
|
243 | + if (empty($timezone_string)) { |
|
244 | 244 | // Create a UTC+- zone if no timezone string exists |
245 | 245 | $check_zone_info = false; |
246 | - if ( $gmt_offset > 0 ) { |
|
247 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
248 | - } elseif ( $gmt_offset < 0 ) { |
|
249 | - $timezone_string = 'UTC' . $gmt_offset; |
|
246 | + if ($gmt_offset > 0) { |
|
247 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
248 | + } elseif ($gmt_offset < 0) { |
|
249 | + $timezone_string = 'UTC'.$gmt_offset; |
|
250 | 250 | } else { |
251 | 251 | $timezone_string = 'UTC'; |
252 | 252 | } |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | __('%1$sUTC%2$s time is %3$s'), |
269 | 269 | '<abbr title="Coordinated Universal Time">', |
270 | 270 | '</abbr>', |
271 | - '<code>' . date_i18n( $datetime_format , false, true ) . '</code>' |
|
271 | + '<code>'.date_i18n($datetime_format, false, true).'</code>' |
|
272 | 272 | ); |
273 | 273 | ?></span> |
274 | - <?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?> |
|
275 | - <br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span> |
|
274 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
275 | + <br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
276 | 276 | <?php endif; ?> |
277 | 277 | |
278 | 278 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -304,10 +304,9 @@ discard block |
||
304 | 304 | |
305 | 305 | if ($found) { |
306 | 306 | $message = $tr['isdst'] ? |
307 | - __(' Daylight saving time begins on: %s.' ) : |
|
308 | - __(' Standard time begins on: %s.'); |
|
307 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
309 | 308 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
310 | - printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' ); |
|
309 | + printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
311 | 310 | } else { |
312 | 311 | _e('This timezone does not observe daylight saving time.'); |
313 | 312 | } |
@@ -337,14 +336,14 @@ discard block |
||
337 | 336 | * |
338 | 337 | * @return int $unix_timestamp with the offset applied for the given timezone. |
339 | 338 | */ |
340 | - public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) { |
|
339 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') { |
|
341 | 340 | $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
342 | - $timezone_string = self::get_valid_timezone_string( $timezone_string ); |
|
343 | - $TimeZone = new DateTimeZone( $timezone_string ); |
|
341 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
342 | + $TimeZone = new DateTimeZone($timezone_string); |
|
344 | 343 | |
345 | - $DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone ); |
|
346 | - $offset = timezone_offset_get( $TimeZone, $DateTime ); |
|
347 | - return (int)$DateTime->format( 'U' ) + (int)$offset; |
|
344 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
345 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
346 | + return (int) $DateTime->format('U') + (int) $offset; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | |
@@ -359,17 +358,17 @@ discard block |
||
359 | 358 | * @param string $datetime_field_name the datetime fieldname to be manipulated |
360 | 359 | * @return EE_Base_Class |
361 | 360 | */ |
362 | - protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) { |
|
361 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) { |
|
363 | 362 | // grab current datetime format |
364 | 363 | $current_format = $obj->get_format(); |
365 | 364 | // set new full timestamp format |
366 | - $obj->set_date_format( EE_Datetime_Field::mysql_date_format ); |
|
367 | - $obj->set_time_format( EE_Datetime_Field::mysql_time_format ); |
|
365 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
366 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
368 | 367 | // set the new date value using a full timestamp format so that no data is lost |
369 | - $obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) ); |
|
368 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
370 | 369 | // reset datetime formats |
371 | - $obj->set_date_format( $current_format[0] ); |
|
372 | - $obj->set_time_format( $current_format[1] ); |
|
370 | + $obj->set_date_format($current_format[0]); |
|
371 | + $obj->set_time_format($current_format[1]); |
|
373 | 372 | return $obj; |
374 | 373 | } |
375 | 374 | |
@@ -386,11 +385,11 @@ discard block |
||
386 | 385 | * @param integer $value what you want to increment the time by |
387 | 386 | * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it (chaining) |
388 | 387 | */ |
389 | - public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
388 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
390 | 389 | //get the raw UTC date. |
391 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
392 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value ); |
|
393 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
390 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
391 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
392 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
394 | 393 | } |
395 | 394 | |
396 | 395 | |
@@ -405,11 +404,11 @@ discard block |
||
405 | 404 | * @param int $value |
406 | 405 | * @return \EE_Base_Class |
407 | 406 | */ |
408 | - public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
407 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
409 | 408 | //get the raw UTC date |
410 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
411 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' ); |
|
412 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
409 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
410 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
411 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
413 | 412 | } |
414 | 413 | |
415 | 414 | |
@@ -422,44 +421,44 @@ discard block |
||
422 | 421 | * @return \DateTime return whatever type came in. |
423 | 422 | * @throws \EE_Error |
424 | 423 | */ |
425 | - protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) { |
|
426 | - if ( ! $DateTime instanceof DateTime ) { |
|
424 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') { |
|
425 | + if ( ! $DateTime instanceof DateTime) { |
|
427 | 426 | throw new EE_Error( |
428 | 427 | sprintf( |
429 | - __( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ), |
|
430 | - print_r( $DateTime, true ) |
|
428 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
429 | + print_r($DateTime, true) |
|
431 | 430 | ) |
432 | 431 | ); |
433 | 432 | } |
434 | - switch ( $period ) { |
|
433 | + switch ($period) { |
|
435 | 434 | case 'years' : |
436 | - $value = 'P' . $value . 'Y'; |
|
435 | + $value = 'P'.$value.'Y'; |
|
437 | 436 | break; |
438 | 437 | case 'months' : |
439 | - $value = 'P' . $value . 'M'; |
|
438 | + $value = 'P'.$value.'M'; |
|
440 | 439 | break; |
441 | 440 | case 'weeks' : |
442 | - $value = 'P' . $value . 'W'; |
|
441 | + $value = 'P'.$value.'W'; |
|
443 | 442 | break; |
444 | 443 | case 'days' : |
445 | - $value = 'P' . $value . 'D'; |
|
444 | + $value = 'P'.$value.'D'; |
|
446 | 445 | break; |
447 | 446 | case 'hours' : |
448 | - $value = 'PT' . $value . 'H'; |
|
447 | + $value = 'PT'.$value.'H'; |
|
449 | 448 | break; |
450 | 449 | case 'minutes' : |
451 | - $value = 'PT' . $value . 'M'; |
|
450 | + $value = 'PT'.$value.'M'; |
|
452 | 451 | break; |
453 | 452 | case 'seconds' : |
454 | - $value = 'PT' . $value . 'S'; |
|
453 | + $value = 'PT'.$value.'S'; |
|
455 | 454 | break; |
456 | 455 | } |
457 | - switch ( $operand ) { |
|
456 | + switch ($operand) { |
|
458 | 457 | case '+': |
459 | - $DateTime->add( new DateInterval( $value ) ); |
|
458 | + $DateTime->add(new DateInterval($value)); |
|
460 | 459 | break; |
461 | 460 | case '-': |
462 | - $DateTime->sub( new DateInterval( $value ) ); |
|
461 | + $DateTime->sub(new DateInterval($value)); |
|
463 | 462 | break; |
464 | 463 | } |
465 | 464 | return $DateTime; |
@@ -475,16 +474,16 @@ discard block |
||
475 | 474 | * @return \DateTime return whatever type came in. |
476 | 475 | * @throws \EE_Error |
477 | 476 | */ |
478 | - protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
479 | - if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) { |
|
477 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
478 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
480 | 479 | throw new EE_Error( |
481 | 480 | sprintf( |
482 | - __( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ), |
|
483 | - print_r( $timestamp, true ) |
|
481 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
482 | + print_r($timestamp, true) |
|
484 | 483 | ) |
485 | 484 | ); |
486 | 485 | } |
487 | - switch ( $period ) { |
|
486 | + switch ($period) { |
|
488 | 487 | case 'years' : |
489 | 488 | $value = YEAR_IN_SECONDS * $value; |
490 | 489 | break; |
@@ -504,9 +503,9 @@ discard block |
||
504 | 503 | $value = MINUTE_IN_SECONDS * $value; |
505 | 504 | break; |
506 | 505 | } |
507 | - switch ( $operand ) { |
|
506 | + switch ($operand) { |
|
508 | 507 | case '+': |
509 | - $timestamp += $value; |
|
508 | + $timestamp += $value; |
|
510 | 509 | break; |
511 | 510 | case '-': |
512 | 511 | $timestamp -= $value; |
@@ -526,11 +525,11 @@ discard block |
||
526 | 525 | * @param string $operand What operand you wish to use for the calculation |
527 | 526 | * @return mixed string|DateTime return whatever type came in. |
528 | 527 | */ |
529 | - public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
530 | - if ( $DateTime_or_timestamp instanceof DateTime ) { |
|
531 | - return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand ); |
|
532 | - } else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) { |
|
533 | - return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand ); |
|
528 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
529 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
530 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
531 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
532 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
534 | 533 | } else { |
535 | 534 | //error |
536 | 535 | return $DateTime_or_timestamp; |
@@ -560,24 +559,24 @@ discard block |
||
560 | 559 | * 'moment' => //date and time format. |
561 | 560 | * ) |
562 | 561 | */ |
563 | - public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) { |
|
564 | - if ( $date_format_string === null ) { |
|
565 | - $date_format_string = get_option( 'date_format' ); |
|
562 | + public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) { |
|
563 | + if ($date_format_string === null) { |
|
564 | + $date_format_string = get_option('date_format'); |
|
566 | 565 | } |
567 | 566 | |
568 | - if ( $time_format_string === null ) { |
|
569 | - $time_format_string = get_option( 'time_format' ); |
|
567 | + if ($time_format_string === null) { |
|
568 | + $time_format_string = get_option('time_format'); |
|
570 | 569 | } |
571 | 570 | |
572 | - $date_format = self::_php_to_js_moment_converter( $date_format_string ); |
|
573 | - $time_format = self::_php_to_js_moment_converter( $time_format_string ); |
|
571 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
572 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
574 | 573 | |
575 | 574 | return array( |
576 | 575 | 'js' => array( |
577 | 576 | 'date' => $date_format['js'], |
578 | 577 | 'time' => $time_format['js'] |
579 | 578 | ), |
580 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment' ] |
|
579 | + 'moment' => $date_format['moment'].' '.$time_format['moment'] |
|
581 | 580 | ); |
582 | 581 | } |
583 | 582 | |
@@ -591,7 +590,7 @@ discard block |
||
591 | 590 | * |
592 | 591 | * @return array js and moment formats. |
593 | 592 | */ |
594 | - protected static function _php_to_js_moment_converter( $format_string ) { |
|
593 | + protected static function _php_to_js_moment_converter($format_string) { |
|
595 | 594 | /** |
596 | 595 | * This is a map of symbols for formats. |
597 | 596 | * The index is the php symbol, the equivalent values are in the array. |
@@ -748,15 +747,15 @@ discard block |
||
748 | 747 | $jquery_ui_format = ""; |
749 | 748 | $moment_format = ""; |
750 | 749 | $escaping = false; |
751 | - for ( $i = 0; $i < strlen($format_string); $i++ ) { |
|
750 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
752 | 751 | $char = $format_string[$i]; |
753 | - if ( $char === '\\' ) { // PHP date format escaping character |
|
752 | + if ($char === '\\') { // PHP date format escaping character |
|
754 | 753 | $i++; |
755 | - if ( $escaping ) { |
|
754 | + if ($escaping) { |
|
756 | 755 | $jquery_ui_format .= $format_string[$i]; |
757 | 756 | $moment_format .= $format_string[$i]; |
758 | 757 | } else { |
759 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
758 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
760 | 759 | $moment_format .= $format_string[$i]; |
761 | 760 | } |
762 | 761 | $escaping = true; |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | } |
776 | 775 | } |
777 | 776 | } |
778 | - return array( 'js' => $jquery_ui_format, 'moment' => $moment_format ); |
|
777 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
779 | 778 | } |
780 | 779 | |
781 | 780 | |
@@ -790,25 +789,25 @@ discard block |
||
790 | 789 | * errors is returned. So for client code calling, check for is_array() to |
791 | 790 | * indicate failed validations. |
792 | 791 | */ |
793 | - public static function validate_format_string( $format_string ) { |
|
792 | + public static function validate_format_string($format_string) { |
|
794 | 793 | $error_msg = array(); |
795 | 794 | //time format checks |
796 | - switch ( true ) { |
|
797 | - case strpos( $format_string, 'h' ) !== false : |
|
798 | - case strpos( $format_string, 'g' ) !== false : |
|
795 | + switch (true) { |
|
796 | + case strpos($format_string, 'h') !== false : |
|
797 | + case strpos($format_string, 'g') !== false : |
|
799 | 798 | /** |
800 | 799 | * if the time string has a lowercase 'h' which == 12 hour time format and there |
801 | 800 | * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
802 | 801 | * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
803 | 802 | */ |
804 | - if ( strpos( strtoupper( $format_string ), 'A' ) === false ) { |
|
805 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' ); |
|
803 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
804 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso'); |
|
806 | 805 | } |
807 | 806 | break; |
808 | 807 | |
809 | 808 | } |
810 | 809 | |
811 | - return empty( $error_msg ) ? true : $error_msg; |
|
810 | + return empty($error_msg) ? true : $error_msg; |
|
812 | 811 | } |
813 | 812 | |
814 | 813 | |
@@ -830,11 +829,11 @@ discard block |
||
830 | 829 | * @param mixed $date_2 |
831 | 830 | * @return bool |
832 | 831 | */ |
833 | - public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) { |
|
832 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) { |
|
834 | 833 | |
835 | 834 | if ( |
836 | - ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) || |
|
837 | - ( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' ) |
|
835 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
836 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
838 | 837 | ) { |
839 | 838 | return false; |
840 | 839 | } |
@@ -851,11 +850,11 @@ discard block |
||
851 | 850 | * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
852 | 851 | * @return string |
853 | 852 | */ |
854 | - public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) { |
|
853 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) { |
|
855 | 854 | try { |
856 | 855 | /** need to account for timezone offset on the selects */ |
857 | - $DateTimeZone = new DateTimeZone( $timezone_string ); |
|
858 | - } catch ( Exception $e ) { |
|
856 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
857 | + } catch (Exception $e) { |
|
859 | 858 | $DateTimeZone = null; |
860 | 859 | } |
861 | 860 | |
@@ -863,10 +862,10 @@ discard block |
||
863 | 862 | * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
864 | 863 | * Hence we do the calc for DateTimeZone::getOffset. |
865 | 864 | */ |
866 | - $offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' ); |
|
865 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
867 | 866 | $query_interval = $offset < 0 |
868 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)' |
|
869 | - : 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)'; |
|
867 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
868 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
870 | 869 | return $query_interval; |
871 | 870 | } |
872 | 871 | |
@@ -878,47 +877,47 @@ discard block |
||
878 | 877 | * @return string |
879 | 878 | */ |
880 | 879 | public static function get_timezone_string_for_display() { |
881 | - $pretty_timezone = apply_filters( 'FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '' ); |
|
882 | - if( ! empty( $pretty_timezone ) ) { |
|
883 | - return esc_html( $pretty_timezone ); |
|
880 | + $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
881 | + if ( ! empty($pretty_timezone)) { |
|
882 | + return esc_html($pretty_timezone); |
|
884 | 883 | } |
885 | - $timezone_string = get_option( 'timezone_string' ); |
|
886 | - if( $timezone_string ) { |
|
884 | + $timezone_string = get_option('timezone_string'); |
|
885 | + if ($timezone_string) { |
|
887 | 886 | static $mo_loaded = false; |
888 | 887 | // Load translations for continents and cities just like wp_timezone_choice does |
889 | - if ( ! $mo_loaded ) { |
|
888 | + if ( ! $mo_loaded) { |
|
890 | 889 | $locale = get_locale(); |
891 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
892 | - load_textdomain( 'continents-cities', $mofile ); |
|
890 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
891 | + load_textdomain('continents-cities', $mofile); |
|
893 | 892 | $mo_loaded = true; |
894 | 893 | } |
895 | 894 | //well that was easy. |
896 | - $parts = explode('/', $timezone_string ); |
|
895 | + $parts = explode('/', $timezone_string); |
|
897 | 896 | //remove the continent |
898 | - unset( $parts[0] ); |
|
897 | + unset($parts[0]); |
|
899 | 898 | $t_parts = array(); |
900 | - foreach( $parts as $part ) { |
|
901 | - $t_parts[] = translate( str_replace( '_', ' ', $part ), 'continents-cities' ); |
|
899 | + foreach ($parts as $part) { |
|
900 | + $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
902 | 901 | } |
903 | - return implode( ' - ', $t_parts ); |
|
902 | + return implode(' - ', $t_parts); |
|
904 | 903 | } |
905 | 904 | //they haven't set the timezone string, so let's return a string like "UTC+1" |
906 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
907 | - if( intval( $gmt_offset ) >= 0 ) { |
|
905 | + $gmt_offset = get_option('gmt_offset'); |
|
906 | + if (intval($gmt_offset) >= 0) { |
|
908 | 907 | $prefix = '+'; |
909 | 908 | } else { |
910 | 909 | $prefix = ''; |
911 | 910 | } |
912 | - $parts = explode( '.', (string) $gmt_offset ); |
|
913 | - if( count( $parts ) === 1 ) { |
|
911 | + $parts = explode('.', (string) $gmt_offset); |
|
912 | + if (count($parts) === 1) { |
|
914 | 913 | $parts[1] = '00'; |
915 | 914 | } else { |
916 | 915 | //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
917 | 916 | //to minutes, eg 30 or 15, respectively |
918 | - $hour_fraction = (float)( '0.' . $parts[1] ); |
|
919 | - $parts[1] = (string)$hour_fraction * 60; |
|
917 | + $hour_fraction = (float) ('0.'.$parts[1]); |
|
918 | + $parts[1] = (string) $hour_fraction * 60; |
|
920 | 919 | } |
921 | - return sprintf( __( 'UTC%1$s', 'event_espresso' ), $prefix . implode( ':', $parts ) ); |
|
920 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts)); |
|
922 | 921 | } |
923 | 922 | |
924 | 923 |