@@ -10,564 +10,564 @@ |
||
10 | 10 | class EE_Venue extends EE_CPT_Base implements EEI_Address |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * |
|
15 | - * @param array $props_n_values incoming values |
|
16 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | - * used.) |
|
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | - * date_format and the second value is the time format |
|
20 | - * @return EE_Attendee |
|
21 | - */ |
|
22 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
23 | - { |
|
24 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @param array $props_n_values incoming values from the database |
|
31 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
32 | - * the website will be used. |
|
33 | - * @return EE_Attendee |
|
34 | - */ |
|
35 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
36 | - { |
|
37 | - return new self($props_n_values, true, $timezone); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Gets name |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function name() |
|
47 | - { |
|
48 | - return $this->get('VNU_name'); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Gets phone |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function phone() |
|
58 | - { |
|
59 | - return $this->get('VNU_phone'); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * venue_url |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function venue_url() |
|
69 | - { |
|
70 | - return $this->get('VNU_url'); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Gets desc |
|
76 | - * |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function description() |
|
80 | - { |
|
81 | - return $this->get('VNU_desc'); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Gets short description (AKA: the excerpt) |
|
87 | - * |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function excerpt() |
|
91 | - { |
|
92 | - return $this->get('VNU_short_desc'); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Gets identifier |
|
98 | - * |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function identifier() |
|
102 | - { |
|
103 | - return $this->get('VNU_identifier'); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Gets address |
|
109 | - * |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function address() |
|
113 | - { |
|
114 | - return $this->get('VNU_address'); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * Gets address2 |
|
120 | - * |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function address2() |
|
124 | - { |
|
125 | - return $this->get('VNU_address2'); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * Gets city |
|
131 | - * |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function city() |
|
135 | - { |
|
136 | - return $this->get('VNU_city'); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Gets state |
|
141 | - * |
|
142 | - * @return int |
|
143 | - */ |
|
144 | - public function state_ID() |
|
145 | - { |
|
146 | - return $this->get('STA_ID'); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function state_abbrev() |
|
154 | - { |
|
155 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @return string |
|
161 | - */ |
|
162 | - public function state_name() |
|
163 | - { |
|
164 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : ''; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * Gets the state for this venue |
|
170 | - * |
|
171 | - * @return EE_State |
|
172 | - */ |
|
173 | - public function state_obj() |
|
174 | - { |
|
175 | - return $this->get_first_related('State'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * either displays the state abbreviation or the state name, as determined |
|
181 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
182 | - * defaults to abbreviation |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - public function state() |
|
187 | - { |
|
188 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
189 | - return $this->state_abbrev(); |
|
190 | - } else { |
|
191 | - return $this->state_name(); |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * country_ID |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function country_ID() |
|
202 | - { |
|
203 | - return $this->get('CNT_ISO'); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - public function country_name() |
|
211 | - { |
|
212 | - return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : ''; |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * Gets the country of this venue |
|
218 | - * |
|
219 | - * @return EE_Country |
|
220 | - */ |
|
221 | - public function country_obj() |
|
222 | - { |
|
223 | - return $this->get_first_related('Country'); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * either displays the country ISO2 code or the country name, as determined |
|
229 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
230 | - * defaults to abbreviation |
|
231 | - * |
|
232 | - * @return string |
|
233 | - */ |
|
234 | - public function country() |
|
235 | - { |
|
236 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
237 | - return $this->country_ID(); |
|
238 | - } else { |
|
239 | - return $this->country_name(); |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * Gets zip |
|
246 | - * |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function zip() |
|
250 | - { |
|
251 | - return $this->get('VNU_zip'); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * Gets capacity |
|
257 | - * |
|
258 | - * @return int |
|
259 | - */ |
|
260 | - public function capacity() |
|
261 | - { |
|
262 | - return $this->get_pretty('VNU_capacity', 'symbol'); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * Gets created |
|
268 | - * |
|
269 | - * @return string |
|
270 | - */ |
|
271 | - public function created() |
|
272 | - { |
|
273 | - return $this->get('VNU_created'); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * Gets modified |
|
279 | - * |
|
280 | - * @return string |
|
281 | - */ |
|
282 | - public function modified() |
|
283 | - { |
|
284 | - return $this->get('VNU_modified'); |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * Gets order |
|
290 | - * |
|
291 | - * @return int |
|
292 | - */ |
|
293 | - public function order() |
|
294 | - { |
|
295 | - return $this->get('VNU_order'); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * Gets wp_user |
|
301 | - * |
|
302 | - * @return int |
|
303 | - */ |
|
304 | - public function wp_user() |
|
305 | - { |
|
306 | - return $this->get('VNU_wp_user'); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * @return string |
|
312 | - */ |
|
313 | - public function virtual_phone() |
|
314 | - { |
|
315 | - return $this->get('VNU_virtual_phone'); |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * @return string |
|
321 | - */ |
|
322 | - public function virtual_url() |
|
323 | - { |
|
324 | - return $this->get('VNU_virtual_url'); |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * @return bool |
|
330 | - */ |
|
331 | - public function enable_for_gmap() |
|
332 | - { |
|
333 | - return $this->get('VNU_enable_for_gmap'); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * @return string |
|
339 | - */ |
|
340 | - public function google_map_link() |
|
341 | - { |
|
342 | - return $this->get('VNU_google_map_link'); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * Gets all events happening at this venue. Query parameters can be added to |
|
348 | - * fetch a subset of those events. |
|
349 | - * |
|
350 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
351 | - * @param bool $upcoming |
|
352 | - * @return EE_Event[] |
|
353 | - */ |
|
354 | - public function events($query_params = array(), $upcoming = false) |
|
355 | - { |
|
356 | - if ($upcoming) { |
|
357 | - $query_params = array( |
|
358 | - array( |
|
359 | - 'status' => 'publish', |
|
360 | - 'Datetime.DTT_EVT_start' => array( |
|
361 | - '>', |
|
362 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
363 | - ), |
|
364 | - ), |
|
365 | - ); |
|
366 | - } |
|
367 | - return $this->get_many_related('Event', $query_params); |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * Sets address |
|
373 | - */ |
|
374 | - public function set_address($address = '') |
|
375 | - { |
|
376 | - $this->set('VNU_address', $address); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @param string $address2 |
|
382 | - */ |
|
383 | - public function set_address2($address2 = '') |
|
384 | - { |
|
385 | - $this->set('VNU_address2', $address2); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @param string $city |
|
391 | - */ |
|
392 | - public function set_city($city = '') |
|
393 | - { |
|
394 | - $this->set('VNU_city', $city); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * @param int $state |
|
400 | - */ |
|
401 | - public function set_state_ID($state = 0) |
|
402 | - { |
|
403 | - $this->set('STA_ID', $state); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Sets the state, given either a state id or state object |
|
409 | - * |
|
410 | - * @param EE_State /int $state_id_or_obj |
|
411 | - * @return EE_State |
|
412 | - */ |
|
413 | - public function set_state_obj($state_id_or_obj) |
|
414 | - { |
|
415 | - return $this->_add_relation_to($state_id_or_obj, 'State'); |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * @param int $country_ID |
|
421 | - */ |
|
422 | - public function set_country_ID($country_ID = 0) |
|
423 | - { |
|
424 | - $this->set('CNT_ISO', $country_ID); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * Sets the country on the venue |
|
430 | - * |
|
431 | - * @param EE_Country /string $country_id_or_obj |
|
432 | - * @return EE_Country |
|
433 | - */ |
|
434 | - public function set_country_obj($country_id_or_obj) |
|
435 | - { |
|
436 | - return $this->_add_relation_to($country_id_or_obj, 'Country'); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * @param string $zip |
|
442 | - */ |
|
443 | - public function set_zip($zip = '') |
|
444 | - { |
|
445 | - $this->set('VNU_zip', $zip); |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * @param int $capacity |
|
451 | - */ |
|
452 | - public function set_capacity($capacity = 0) |
|
453 | - { |
|
454 | - $this->set('VNU_capacity', $capacity); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - /** |
|
459 | - * @param string $created |
|
460 | - */ |
|
461 | - public function set_created($created = '') |
|
462 | - { |
|
463 | - $this->set('VNU_created', $created); |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * @param string $desc |
|
469 | - */ |
|
470 | - public function set_description($desc = '') |
|
471 | - { |
|
472 | - $this->set('VNU_desc', $desc); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * @param string $identifier |
|
478 | - */ |
|
479 | - public function set_identifier($identifier = '') |
|
480 | - { |
|
481 | - $this->set('VNU_identifier', $identifier); |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * @param string $modified |
|
487 | - */ |
|
488 | - public function set_modified($modified = '') |
|
489 | - { |
|
490 | - $this->set('VNU_modified', $modified); |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * @param string $name |
|
496 | - */ |
|
497 | - public function set_name($name = '') |
|
498 | - { |
|
499 | - $this->set('VNU_name', $name); |
|
500 | - } |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * @param int $order |
|
505 | - */ |
|
506 | - public function set_order($order = 0) |
|
507 | - { |
|
508 | - $this->set('VNU_order', $order); |
|
509 | - } |
|
510 | - |
|
511 | - |
|
512 | - /** |
|
513 | - * @param string $phone |
|
514 | - */ |
|
515 | - public function set_phone($phone = '') |
|
516 | - { |
|
517 | - $this->set('VNU_phone', $phone); |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * @param int $wp_user |
|
523 | - */ |
|
524 | - public function set_wp_user($wp_user = 1) |
|
525 | - { |
|
526 | - $this->set('VNU_wp_user', $wp_user); |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * @param string $url |
|
532 | - */ |
|
533 | - public function set_venue_url($url = '') |
|
534 | - { |
|
535 | - $this->set('VNU_url', $url); |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * @param string $phone |
|
541 | - */ |
|
542 | - public function set_virtual_phone($phone = '') |
|
543 | - { |
|
544 | - $this->set('VNU_virtual_phone', $phone); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * @param string $url |
|
550 | - */ |
|
551 | - public function set_virtual_url($url = '') |
|
552 | - { |
|
553 | - $this->set('VNU_virtual_url', $url); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * @param string $enable |
|
559 | - */ |
|
560 | - public function set_enable_for_gmap($enable = '') |
|
561 | - { |
|
562 | - $this->set('VNU_enable_for_gmap', $enable); |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * @param string $google_map_link |
|
568 | - */ |
|
569 | - public function set_google_map_link($google_map_link = '') |
|
570 | - { |
|
571 | - $this->set('VNU_google_map_link', $google_map_link); |
|
572 | - } |
|
13 | + /** |
|
14 | + * |
|
15 | + * @param array $props_n_values incoming values |
|
16 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | + * used.) |
|
18 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | + * date_format and the second value is the time format |
|
20 | + * @return EE_Attendee |
|
21 | + */ |
|
22 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
23 | + { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @param array $props_n_values incoming values from the database |
|
31 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
32 | + * the website will be used. |
|
33 | + * @return EE_Attendee |
|
34 | + */ |
|
35 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
36 | + { |
|
37 | + return new self($props_n_values, true, $timezone); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Gets name |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function name() |
|
47 | + { |
|
48 | + return $this->get('VNU_name'); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Gets phone |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function phone() |
|
58 | + { |
|
59 | + return $this->get('VNU_phone'); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * venue_url |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function venue_url() |
|
69 | + { |
|
70 | + return $this->get('VNU_url'); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Gets desc |
|
76 | + * |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function description() |
|
80 | + { |
|
81 | + return $this->get('VNU_desc'); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Gets short description (AKA: the excerpt) |
|
87 | + * |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function excerpt() |
|
91 | + { |
|
92 | + return $this->get('VNU_short_desc'); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Gets identifier |
|
98 | + * |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function identifier() |
|
102 | + { |
|
103 | + return $this->get('VNU_identifier'); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Gets address |
|
109 | + * |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function address() |
|
113 | + { |
|
114 | + return $this->get('VNU_address'); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * Gets address2 |
|
120 | + * |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function address2() |
|
124 | + { |
|
125 | + return $this->get('VNU_address2'); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * Gets city |
|
131 | + * |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function city() |
|
135 | + { |
|
136 | + return $this->get('VNU_city'); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Gets state |
|
141 | + * |
|
142 | + * @return int |
|
143 | + */ |
|
144 | + public function state_ID() |
|
145 | + { |
|
146 | + return $this->get('STA_ID'); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function state_abbrev() |
|
154 | + { |
|
155 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @return string |
|
161 | + */ |
|
162 | + public function state_name() |
|
163 | + { |
|
164 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : ''; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * Gets the state for this venue |
|
170 | + * |
|
171 | + * @return EE_State |
|
172 | + */ |
|
173 | + public function state_obj() |
|
174 | + { |
|
175 | + return $this->get_first_related('State'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * either displays the state abbreviation or the state name, as determined |
|
181 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
182 | + * defaults to abbreviation |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + public function state() |
|
187 | + { |
|
188 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
189 | + return $this->state_abbrev(); |
|
190 | + } else { |
|
191 | + return $this->state_name(); |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * country_ID |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function country_ID() |
|
202 | + { |
|
203 | + return $this->get('CNT_ISO'); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + public function country_name() |
|
211 | + { |
|
212 | + return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : ''; |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * Gets the country of this venue |
|
218 | + * |
|
219 | + * @return EE_Country |
|
220 | + */ |
|
221 | + public function country_obj() |
|
222 | + { |
|
223 | + return $this->get_first_related('Country'); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * either displays the country ISO2 code or the country name, as determined |
|
229 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
230 | + * defaults to abbreviation |
|
231 | + * |
|
232 | + * @return string |
|
233 | + */ |
|
234 | + public function country() |
|
235 | + { |
|
236 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
237 | + return $this->country_ID(); |
|
238 | + } else { |
|
239 | + return $this->country_name(); |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * Gets zip |
|
246 | + * |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function zip() |
|
250 | + { |
|
251 | + return $this->get('VNU_zip'); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * Gets capacity |
|
257 | + * |
|
258 | + * @return int |
|
259 | + */ |
|
260 | + public function capacity() |
|
261 | + { |
|
262 | + return $this->get_pretty('VNU_capacity', 'symbol'); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * Gets created |
|
268 | + * |
|
269 | + * @return string |
|
270 | + */ |
|
271 | + public function created() |
|
272 | + { |
|
273 | + return $this->get('VNU_created'); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * Gets modified |
|
279 | + * |
|
280 | + * @return string |
|
281 | + */ |
|
282 | + public function modified() |
|
283 | + { |
|
284 | + return $this->get('VNU_modified'); |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * Gets order |
|
290 | + * |
|
291 | + * @return int |
|
292 | + */ |
|
293 | + public function order() |
|
294 | + { |
|
295 | + return $this->get('VNU_order'); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * Gets wp_user |
|
301 | + * |
|
302 | + * @return int |
|
303 | + */ |
|
304 | + public function wp_user() |
|
305 | + { |
|
306 | + return $this->get('VNU_wp_user'); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * @return string |
|
312 | + */ |
|
313 | + public function virtual_phone() |
|
314 | + { |
|
315 | + return $this->get('VNU_virtual_phone'); |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * @return string |
|
321 | + */ |
|
322 | + public function virtual_url() |
|
323 | + { |
|
324 | + return $this->get('VNU_virtual_url'); |
|
325 | + } |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * @return bool |
|
330 | + */ |
|
331 | + public function enable_for_gmap() |
|
332 | + { |
|
333 | + return $this->get('VNU_enable_for_gmap'); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * @return string |
|
339 | + */ |
|
340 | + public function google_map_link() |
|
341 | + { |
|
342 | + return $this->get('VNU_google_map_link'); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * Gets all events happening at this venue. Query parameters can be added to |
|
348 | + * fetch a subset of those events. |
|
349 | + * |
|
350 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
351 | + * @param bool $upcoming |
|
352 | + * @return EE_Event[] |
|
353 | + */ |
|
354 | + public function events($query_params = array(), $upcoming = false) |
|
355 | + { |
|
356 | + if ($upcoming) { |
|
357 | + $query_params = array( |
|
358 | + array( |
|
359 | + 'status' => 'publish', |
|
360 | + 'Datetime.DTT_EVT_start' => array( |
|
361 | + '>', |
|
362 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
363 | + ), |
|
364 | + ), |
|
365 | + ); |
|
366 | + } |
|
367 | + return $this->get_many_related('Event', $query_params); |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * Sets address |
|
373 | + */ |
|
374 | + public function set_address($address = '') |
|
375 | + { |
|
376 | + $this->set('VNU_address', $address); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @param string $address2 |
|
382 | + */ |
|
383 | + public function set_address2($address2 = '') |
|
384 | + { |
|
385 | + $this->set('VNU_address2', $address2); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @param string $city |
|
391 | + */ |
|
392 | + public function set_city($city = '') |
|
393 | + { |
|
394 | + $this->set('VNU_city', $city); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * @param int $state |
|
400 | + */ |
|
401 | + public function set_state_ID($state = 0) |
|
402 | + { |
|
403 | + $this->set('STA_ID', $state); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Sets the state, given either a state id or state object |
|
409 | + * |
|
410 | + * @param EE_State /int $state_id_or_obj |
|
411 | + * @return EE_State |
|
412 | + */ |
|
413 | + public function set_state_obj($state_id_or_obj) |
|
414 | + { |
|
415 | + return $this->_add_relation_to($state_id_or_obj, 'State'); |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * @param int $country_ID |
|
421 | + */ |
|
422 | + public function set_country_ID($country_ID = 0) |
|
423 | + { |
|
424 | + $this->set('CNT_ISO', $country_ID); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * Sets the country on the venue |
|
430 | + * |
|
431 | + * @param EE_Country /string $country_id_or_obj |
|
432 | + * @return EE_Country |
|
433 | + */ |
|
434 | + public function set_country_obj($country_id_or_obj) |
|
435 | + { |
|
436 | + return $this->_add_relation_to($country_id_or_obj, 'Country'); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * @param string $zip |
|
442 | + */ |
|
443 | + public function set_zip($zip = '') |
|
444 | + { |
|
445 | + $this->set('VNU_zip', $zip); |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * @param int $capacity |
|
451 | + */ |
|
452 | + public function set_capacity($capacity = 0) |
|
453 | + { |
|
454 | + $this->set('VNU_capacity', $capacity); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + /** |
|
459 | + * @param string $created |
|
460 | + */ |
|
461 | + public function set_created($created = '') |
|
462 | + { |
|
463 | + $this->set('VNU_created', $created); |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * @param string $desc |
|
469 | + */ |
|
470 | + public function set_description($desc = '') |
|
471 | + { |
|
472 | + $this->set('VNU_desc', $desc); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * @param string $identifier |
|
478 | + */ |
|
479 | + public function set_identifier($identifier = '') |
|
480 | + { |
|
481 | + $this->set('VNU_identifier', $identifier); |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * @param string $modified |
|
487 | + */ |
|
488 | + public function set_modified($modified = '') |
|
489 | + { |
|
490 | + $this->set('VNU_modified', $modified); |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * @param string $name |
|
496 | + */ |
|
497 | + public function set_name($name = '') |
|
498 | + { |
|
499 | + $this->set('VNU_name', $name); |
|
500 | + } |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * @param int $order |
|
505 | + */ |
|
506 | + public function set_order($order = 0) |
|
507 | + { |
|
508 | + $this->set('VNU_order', $order); |
|
509 | + } |
|
510 | + |
|
511 | + |
|
512 | + /** |
|
513 | + * @param string $phone |
|
514 | + */ |
|
515 | + public function set_phone($phone = '') |
|
516 | + { |
|
517 | + $this->set('VNU_phone', $phone); |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * @param int $wp_user |
|
523 | + */ |
|
524 | + public function set_wp_user($wp_user = 1) |
|
525 | + { |
|
526 | + $this->set('VNU_wp_user', $wp_user); |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * @param string $url |
|
532 | + */ |
|
533 | + public function set_venue_url($url = '') |
|
534 | + { |
|
535 | + $this->set('VNU_url', $url); |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * @param string $phone |
|
541 | + */ |
|
542 | + public function set_virtual_phone($phone = '') |
|
543 | + { |
|
544 | + $this->set('VNU_virtual_phone', $phone); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * @param string $url |
|
550 | + */ |
|
551 | + public function set_virtual_url($url = '') |
|
552 | + { |
|
553 | + $this->set('VNU_virtual_url', $url); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * @param string $enable |
|
559 | + */ |
|
560 | + public function set_enable_for_gmap($enable = '') |
|
561 | + { |
|
562 | + $this->set('VNU_enable_for_gmap', $enable); |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * @param string $google_map_link |
|
568 | + */ |
|
569 | + public function set_google_map_link($google_map_link = '') |
|
570 | + { |
|
571 | + $this->set('VNU_google_map_link', $google_map_link); |
|
572 | + } |
|
573 | 573 | } |
@@ -18,17 +18,17 @@ |
||
18 | 18 | */ |
19 | 19 | class RestPasswordRequiredException extends RestException |
20 | 20 | { |
21 | - public function __construct($previous = null) |
|
22 | - { |
|
23 | - parent::__construct( |
|
24 | - 'rest_post_password_required', |
|
25 | - esc_html__('A password is required to access this content.', 'event_espresso'), |
|
26 | - array( |
|
27 | - 'status' => 403, |
|
28 | - ), |
|
29 | - $previous |
|
30 | - ); |
|
31 | - } |
|
21 | + public function __construct($previous = null) |
|
22 | + { |
|
23 | + parent::__construct( |
|
24 | + 'rest_post_password_required', |
|
25 | + esc_html__('A password is required to access this content.', 'event_espresso'), |
|
26 | + array( |
|
27 | + 'status' => 403, |
|
28 | + ), |
|
29 | + $previous |
|
30 | + ); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | // End of file RestPasswordRequired.php |
34 | 34 | // Location: EventEspresso\core\exceptions/RestPasswordRequired.php |
@@ -18,27 +18,27 @@ |
||
18 | 18 | */ |
19 | 19 | class ModelConfigurationException extends DomainException |
20 | 20 | { |
21 | - /** |
|
22 | - * ModelConfigurationException constructor. |
|
23 | - * |
|
24 | - * @param EEM_Base $model |
|
25 | - * @param string $message Describe what's misconfigured about this model (don't bother mentioning which model, |
|
26 | - * that will be automatically added to the message based on the $model provided in the previous parameter). |
|
27 | - * @param int $code |
|
28 | - * @param Exception $previous |
|
29 | - */ |
|
30 | - public function __construct(EEM_Base $model, $message, $code = 0, Exception $previous = null) |
|
31 | - { |
|
32 | - $message_part_1 = sprintf( |
|
33 | - /* |
|
21 | + /** |
|
22 | + * ModelConfigurationException constructor. |
|
23 | + * |
|
24 | + * @param EEM_Base $model |
|
25 | + * @param string $message Describe what's misconfigured about this model (don't bother mentioning which model, |
|
26 | + * that will be automatically added to the message based on the $model provided in the previous parameter). |
|
27 | + * @param int $code |
|
28 | + * @param Exception $previous |
|
29 | + */ |
|
30 | + public function __construct(EEM_Base $model, $message, $code = 0, Exception $previous = null) |
|
31 | + { |
|
32 | + $message_part_1 = sprintf( |
|
33 | + /* |
|
34 | 34 | * translators: 1: the model name |
35 | 35 | */ |
36 | - esc_html__('The model "%1$s" appears to be misconfigured.', 'event_espresso'), |
|
37 | - $model->get_this_model_name() |
|
38 | - ); |
|
39 | - $message = $message_part_1 . ' ' . $message; |
|
40 | - parent::__construct($message, $code, $previous); |
|
41 | - } |
|
36 | + esc_html__('The model "%1$s" appears to be misconfigured.', 'event_espresso'), |
|
37 | + $model->get_this_model_name() |
|
38 | + ); |
|
39 | + $message = $message_part_1 . ' ' . $message; |
|
40 | + parent::__construct($message, $code, $previous); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | // End of file ModelConfigurationException.php |
44 | 44 | // Location: EventEspresso\core\exceptions/ModelConfigurationException.php |
@@ -36,7 +36,7 @@ |
||
36 | 36 | esc_html__('The model "%1$s" appears to be misconfigured.', 'event_espresso'), |
37 | 37 | $model->get_this_model_name() |
38 | 38 | ); |
39 | - $message = $message_part_1 . ' ' . $message; |
|
39 | + $message = $message_part_1.' '.$message; |
|
40 | 40 | parent::__construct($message, $code, $previous); |
41 | 41 | } |
42 | 42 | } |
@@ -16,17 +16,17 @@ |
||
16 | 16 | */ |
17 | 17 | class RestPasswordIncorrectException extends RestException |
18 | 18 | { |
19 | - public function __construct($previous = null) |
|
20 | - { |
|
21 | - parent::__construct( |
|
22 | - 'rest_post_incorrect_password', |
|
23 | - esc_html__('Incorrect password.', 'event_espresso'), |
|
24 | - array( |
|
25 | - 'status' => 403, |
|
26 | - ), |
|
27 | - $previous |
|
28 | - ); |
|
29 | - } |
|
19 | + public function __construct($previous = null) |
|
20 | + { |
|
21 | + parent::__construct( |
|
22 | + 'rest_post_incorrect_password', |
|
23 | + esc_html__('Incorrect password.', 'event_espresso'), |
|
24 | + array( |
|
25 | + 'status' => 403, |
|
26 | + ), |
|
27 | + $previous |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | // End of file RestPasswordIncorrectException.php |
32 | 32 | // Location: EventEspresso\core\exceptions/RestPasswordIncorrectException.php |
@@ -42,10 +42,10 @@ |
||
42 | 42 | ); |
43 | 43 | // this model is generally available for reading |
44 | 44 | $path_to_event = 'Datetime.Event'; |
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
45 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
46 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
49 | 49 | $this->model_chain_to_password = $path_to_event; |
50 | 50 | parent::__construct($timezone); |
51 | 51 | } |
@@ -13,41 +13,41 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - // private instance of the EEM_Datetime_Ticket object |
|
17 | - protected static $_instance = null; |
|
16 | + // private instance of the EEM_Datetime_Ticket object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | - /** |
|
20 | - * private constructor to prevent direct creation |
|
21 | - * @Constructor |
|
22 | - * @access private |
|
23 | - * @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) |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - protected function __construct($timezone) |
|
27 | - { |
|
28 | - $this->singular_item = esc_html__('Datetime Ticket', 'event_espresso'); |
|
29 | - $this->plural_item = esc_html__('Datetime Tickets', 'event_espresso'); |
|
19 | + /** |
|
20 | + * private constructor to prevent direct creation |
|
21 | + * @Constructor |
|
22 | + * @access private |
|
23 | + * @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) |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + protected function __construct($timezone) |
|
27 | + { |
|
28 | + $this->singular_item = esc_html__('Datetime Ticket', 'event_espresso'); |
|
29 | + $this->plural_item = esc_html__('Datetime Tickets', 'event_espresso'); |
|
30 | 30 | |
31 | - $this->_tables = array( |
|
32 | - 'Datetime_Ticket' => new EE_Primary_Table('esp_datetime_ticket', 'DTK_ID') |
|
33 | - ); |
|
34 | - $this->_fields = array( |
|
35 | - 'Datetime_Ticket' => array( |
|
36 | - 'DTK_ID' => new EE_Primary_Key_Int_Field('DTK_ID', esc_html__('Datetime Ticket ID', 'event_espresso')), |
|
37 | - 'DTT_ID' => new EE_Foreign_Key_Int_Field('DTT_ID', esc_html__('The ID to the Datetime', 'event_espresso'), false, 0, 'Datetime'), |
|
38 | - 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', esc_html__('The ID to the Ticket', 'event_espresso'), false, 0, 'Ticket') |
|
39 | - )); |
|
40 | - $this->_model_relations = array( |
|
41 | - 'Ticket' => new EE_Belongs_To_Relation(), |
|
42 | - 'Datetime' => new EE_Belongs_To_Relation() |
|
43 | - ); |
|
44 | - // this model is generally available for reading |
|
45 | - $path_to_event = 'Datetime.Event'; |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
50 | - $this->model_chain_to_password = $path_to_event; |
|
51 | - parent::__construct($timezone); |
|
52 | - } |
|
31 | + $this->_tables = array( |
|
32 | + 'Datetime_Ticket' => new EE_Primary_Table('esp_datetime_ticket', 'DTK_ID') |
|
33 | + ); |
|
34 | + $this->_fields = array( |
|
35 | + 'Datetime_Ticket' => array( |
|
36 | + 'DTK_ID' => new EE_Primary_Key_Int_Field('DTK_ID', esc_html__('Datetime Ticket ID', 'event_espresso')), |
|
37 | + 'DTT_ID' => new EE_Foreign_Key_Int_Field('DTT_ID', esc_html__('The ID to the Datetime', 'event_espresso'), false, 0, 'Datetime'), |
|
38 | + 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', esc_html__('The ID to the Ticket', 'event_espresso'), false, 0, 'Ticket') |
|
39 | + )); |
|
40 | + $this->_model_relations = array( |
|
41 | + 'Ticket' => new EE_Belongs_To_Relation(), |
|
42 | + 'Datetime' => new EE_Belongs_To_Relation() |
|
43 | + ); |
|
44 | + // this model is generally available for reading |
|
45 | + $path_to_event = 'Datetime.Event'; |
|
46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
49 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
50 | + $this->model_chain_to_password = $path_to_event; |
|
51 | + parent::__construct($timezone); |
|
52 | + } |
|
53 | 53 | } |
@@ -58,24 +58,24 @@ discard block |
||
58 | 58 | 'Term_Taxonomy' => new EE_Belongs_To_Relation(), |
59 | 59 | ); |
60 | 60 | foreach ($models_this_can_attach_to as $model_name) { |
61 | - $this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation(); |
|
61 | + $this->_model_relations[$model_name] = new EE_Belongs_To_Relation(); |
|
62 | 62 | } |
63 | 63 | $this->_wp_core_model = true; |
64 | 64 | $this->_indexes = array( |
65 | 65 | 'PRIMARY' => new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')), |
66 | 66 | ); |
67 | 67 | $path_to_event_model = 'Event'; |
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public( |
|
69 | 69 | $path_to_event_model |
70 | 70 | ); |
71 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
71 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = |
|
72 | 72 | new EE_Restriction_Generator_Event_Related_Protected( |
73 | 73 | $path_to_event_model |
74 | 74 | ); |
75 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
75 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected( |
|
76 | 76 | $path_to_event_model |
77 | 77 | ); |
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
78 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = |
|
79 | 79 | new EE_Restriction_Generator_Event_Related_Protected( |
80 | 80 | $path_to_event_model, |
81 | 81 | EEM_Base::caps_edit |
@@ -85,27 +85,27 @@ discard block |
||
85 | 85 | // and for deleting term relations too |
86 | 86 | $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
87 | 87 | foreach ($cap_contexts_affected as $cap_context_affected) { |
88 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = |
|
88 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = |
|
89 | 89 | new EE_Default_Where_Conditions( |
90 | 90 | array( |
91 | - $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
|
91 | + $path_to_tax_model.'taxonomy*ee_assign_event_category' => array( |
|
92 | 92 | '!=', |
93 | 93 | 'espresso_event_categories', |
94 | 94 | ), |
95 | 95 | ) |
96 | 96 | ); |
97 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = |
|
97 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = |
|
98 | 98 | new EE_Default_Where_Conditions( |
99 | 99 | array( |
100 | - $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
|
100 | + $path_to_tax_model.'taxonomy*ee_assign_venue_category' => array( |
|
101 | 101 | '!=', |
102 | 102 | 'espresso_venue_categories', |
103 | 103 | ), |
104 | 104 | ) |
105 | 105 | ); |
106 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
106 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
107 | 107 | array( |
108 | - $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
108 | + $path_to_tax_model.'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
109 | 109 | ) |
110 | 110 | ); |
111 | 111 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | if ($model === EEM_Term_Relationship::instance()) { |
234 | 234 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
235 | - if (! empty($taxonomies)) { |
|
235 | + if ( ! empty($taxonomies)) { |
|
236 | 236 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
237 | 237 | } |
238 | 238 | } |
@@ -10,233 +10,233 @@ |
||
10 | 10 | class EEM_Term_Relationship extends EEM_Base |
11 | 11 | { |
12 | 12 | |
13 | - // private instance of the Attendee object |
|
14 | - protected static $_instance = null; |
|
15 | - |
|
16 | - |
|
17 | - |
|
18 | - /** |
|
19 | - * EEM_Term_Relationship constructor. |
|
20 | - * |
|
21 | - * @param string $timezone |
|
22 | - */ |
|
23 | - protected function __construct($timezone = null) |
|
24 | - { |
|
25 | - $this->singular_item = esc_html__('Term Relationship', 'event_espresso'); |
|
26 | - $this->plural_item = esc_html__('Term Relationships', 'event_espresso'); |
|
27 | - $this->_tables = array( |
|
28 | - 'Term_Relationship' => new EE_Primary_Table('term_relationships'), |
|
29 | - ); |
|
30 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
31 | - $this->_fields = array( |
|
32 | - 'Term_Relationship' => array( |
|
33 | - 'object_id' => new EE_Foreign_Key_Int_Field( |
|
34 | - 'object_id', |
|
35 | - esc_html__('Object(Post) ID', 'event_espresso'), |
|
36 | - false, |
|
37 | - 0, |
|
38 | - $models_this_can_attach_to |
|
39 | - ), |
|
40 | - 'term_taxonomy_id' => new EE_Foreign_Key_Int_Field( |
|
41 | - 'term_taxonomy_id', |
|
42 | - esc_html__( |
|
43 | - 'Term (in context of a taxonomy) ID', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - false, |
|
47 | - 0, |
|
48 | - 'Term_Taxonomy' |
|
49 | - ), |
|
50 | - 'term_order' => new EE_Integer_Field( |
|
51 | - 'term_order', |
|
52 | - esc_html__('Term Order', 'event_espresso'), |
|
53 | - false, |
|
54 | - 0 |
|
55 | - ), |
|
56 | - ), |
|
57 | - ); |
|
58 | - $this->_model_relations = array( |
|
59 | - 'Term_Taxonomy' => new EE_Belongs_To_Relation(), |
|
60 | - ); |
|
61 | - foreach ($models_this_can_attach_to as $model_name) { |
|
62 | - $this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation(); |
|
63 | - } |
|
64 | - $this->_wp_core_model = true; |
|
65 | - $this->_indexes = array( |
|
66 | - 'PRIMARY' => new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')), |
|
67 | - ); |
|
68 | - $path_to_event_model = 'Event'; |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
70 | - $path_to_event_model |
|
71 | - ); |
|
72 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
73 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
74 | - $path_to_event_model |
|
75 | - ); |
|
76 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
77 | - $path_to_event_model |
|
78 | - ); |
|
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
80 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
81 | - $path_to_event_model, |
|
82 | - EEM_Base::caps_edit |
|
83 | - ); |
|
84 | - $path_to_tax_model = 'Term_Taxonomy.'; |
|
85 | - // add cap restrictions for editing term relations to the "ee_assign_*" |
|
86 | - // and for deleting term relations too |
|
87 | - $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
|
88 | - foreach ($cap_contexts_affected as $cap_context_affected) { |
|
89 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = |
|
90 | - new EE_Default_Where_Conditions( |
|
91 | - array( |
|
92 | - $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
|
93 | - '!=', |
|
94 | - 'espresso_event_categories', |
|
95 | - ), |
|
96 | - ) |
|
97 | - ); |
|
98 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = |
|
99 | - new EE_Default_Where_Conditions( |
|
100 | - array( |
|
101 | - $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
|
102 | - '!=', |
|
103 | - 'espresso_venue_categories', |
|
104 | - ), |
|
105 | - ) |
|
106 | - ); |
|
107 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
108 | - array( |
|
109 | - $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
110 | - ) |
|
111 | - ); |
|
112 | - } |
|
113 | - parent::__construct($timezone); |
|
114 | - add_filter( |
|
115 | - 'FHEE__Read__create_model_query_params', |
|
116 | - array('EEM_Term_Relationship', 'rest_api_query_params'), |
|
117 | - 10, |
|
118 | - 3 |
|
119 | - ); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * Makes sure all term-taxonomy counts are correct |
|
125 | - * |
|
126 | - * @param int $term_taxonomy_id the id of the term taxonomy to update. If NULL, updates ALL |
|
127 | - * @global wpdb $wpdb |
|
128 | - * @return int the number of rows affected |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function update_term_taxonomy_counts($term_taxonomy_id = null) |
|
132 | - { |
|
133 | - // because this uses a subquery and sometimes assigning to column to be another column's |
|
134 | - // value, we just write the SQL directly. |
|
135 | - global $wpdb; |
|
136 | - |
|
137 | - $query = " |
|
13 | + // private instance of the Attendee object |
|
14 | + protected static $_instance = null; |
|
15 | + |
|
16 | + |
|
17 | + |
|
18 | + /** |
|
19 | + * EEM_Term_Relationship constructor. |
|
20 | + * |
|
21 | + * @param string $timezone |
|
22 | + */ |
|
23 | + protected function __construct($timezone = null) |
|
24 | + { |
|
25 | + $this->singular_item = esc_html__('Term Relationship', 'event_espresso'); |
|
26 | + $this->plural_item = esc_html__('Term Relationships', 'event_espresso'); |
|
27 | + $this->_tables = array( |
|
28 | + 'Term_Relationship' => new EE_Primary_Table('term_relationships'), |
|
29 | + ); |
|
30 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
31 | + $this->_fields = array( |
|
32 | + 'Term_Relationship' => array( |
|
33 | + 'object_id' => new EE_Foreign_Key_Int_Field( |
|
34 | + 'object_id', |
|
35 | + esc_html__('Object(Post) ID', 'event_espresso'), |
|
36 | + false, |
|
37 | + 0, |
|
38 | + $models_this_can_attach_to |
|
39 | + ), |
|
40 | + 'term_taxonomy_id' => new EE_Foreign_Key_Int_Field( |
|
41 | + 'term_taxonomy_id', |
|
42 | + esc_html__( |
|
43 | + 'Term (in context of a taxonomy) ID', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + false, |
|
47 | + 0, |
|
48 | + 'Term_Taxonomy' |
|
49 | + ), |
|
50 | + 'term_order' => new EE_Integer_Field( |
|
51 | + 'term_order', |
|
52 | + esc_html__('Term Order', 'event_espresso'), |
|
53 | + false, |
|
54 | + 0 |
|
55 | + ), |
|
56 | + ), |
|
57 | + ); |
|
58 | + $this->_model_relations = array( |
|
59 | + 'Term_Taxonomy' => new EE_Belongs_To_Relation(), |
|
60 | + ); |
|
61 | + foreach ($models_this_can_attach_to as $model_name) { |
|
62 | + $this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation(); |
|
63 | + } |
|
64 | + $this->_wp_core_model = true; |
|
65 | + $this->_indexes = array( |
|
66 | + 'PRIMARY' => new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')), |
|
67 | + ); |
|
68 | + $path_to_event_model = 'Event'; |
|
69 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
70 | + $path_to_event_model |
|
71 | + ); |
|
72 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
73 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
74 | + $path_to_event_model |
|
75 | + ); |
|
76 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
77 | + $path_to_event_model |
|
78 | + ); |
|
79 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
80 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
81 | + $path_to_event_model, |
|
82 | + EEM_Base::caps_edit |
|
83 | + ); |
|
84 | + $path_to_tax_model = 'Term_Taxonomy.'; |
|
85 | + // add cap restrictions for editing term relations to the "ee_assign_*" |
|
86 | + // and for deleting term relations too |
|
87 | + $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
|
88 | + foreach ($cap_contexts_affected as $cap_context_affected) { |
|
89 | + $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = |
|
90 | + new EE_Default_Where_Conditions( |
|
91 | + array( |
|
92 | + $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
|
93 | + '!=', |
|
94 | + 'espresso_event_categories', |
|
95 | + ), |
|
96 | + ) |
|
97 | + ); |
|
98 | + $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = |
|
99 | + new EE_Default_Where_Conditions( |
|
100 | + array( |
|
101 | + $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
|
102 | + '!=', |
|
103 | + 'espresso_venue_categories', |
|
104 | + ), |
|
105 | + ) |
|
106 | + ); |
|
107 | + $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
108 | + array( |
|
109 | + $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
110 | + ) |
|
111 | + ); |
|
112 | + } |
|
113 | + parent::__construct($timezone); |
|
114 | + add_filter( |
|
115 | + 'FHEE__Read__create_model_query_params', |
|
116 | + array('EEM_Term_Relationship', 'rest_api_query_params'), |
|
117 | + 10, |
|
118 | + 3 |
|
119 | + ); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * Makes sure all term-taxonomy counts are correct |
|
125 | + * |
|
126 | + * @param int $term_taxonomy_id the id of the term taxonomy to update. If NULL, updates ALL |
|
127 | + * @global wpdb $wpdb |
|
128 | + * @return int the number of rows affected |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function update_term_taxonomy_counts($term_taxonomy_id = null) |
|
132 | + { |
|
133 | + // because this uses a subquery and sometimes assigning to column to be another column's |
|
134 | + // value, we just write the SQL directly. |
|
135 | + global $wpdb; |
|
136 | + |
|
137 | + $query = " |
|
138 | 138 | UPDATE {$wpdb->term_taxonomy} AS tt |
139 | 139 | SET count = ( |
140 | 140 | select count(*) as proper_count from {$wpdb->term_relationships} AS tr |
141 | 141 | WHERE tt.term_taxonomy_id = tr.term_taxonomy_id |
142 | 142 | )"; |
143 | 143 | |
144 | - if ($term_taxonomy_id) { |
|
145 | - $query .= ' WHERE tt.term_taxonomy_id = %d'; |
|
146 | - $query = $wpdb->prepare( |
|
147 | - $query, |
|
148 | - $term_taxonomy_id |
|
149 | - ); |
|
150 | - } |
|
151 | - $rows_affected = $this->_do_wpdb_query( |
|
152 | - 'query', |
|
153 | - array( |
|
154 | - $query, |
|
155 | - ) |
|
156 | - ); |
|
157 | - return $rows_affected; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Overrides the parent to also make sure term-taxonomy counts are up-to-date after |
|
164 | - * inserting |
|
165 | - * |
|
166 | - * @param array $field_n_values @see EEM_Base::insert |
|
167 | - * @return boolean |
|
168 | - */ |
|
169 | - public function insert($field_n_values) |
|
170 | - { |
|
171 | - $return = parent::insert($field_n_values); |
|
172 | - if (isset($field_n_values['term_taxonomy_id'])) { |
|
173 | - $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
174 | - } |
|
175 | - return $return; |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * Overrides parent so that after an update, we also check the term_taxonomy_counts are |
|
182 | - * all ok |
|
183 | - * |
|
184 | - * @param array $fields_n_values see EEM_Base::update |
|
185 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
186 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
187 | - * in this model's entity map according to $fields_n_values that match |
|
188 | - * $query_params. This obviously has some overhead, so you can disable it |
|
189 | - * by setting this to FALSE, but be aware that model objects being used |
|
190 | - * could get out-of-sync with the database |
|
191 | - * @return int |
|
192 | - */ |
|
193 | - public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
194 | - { |
|
195 | - $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
196 | - if ($count) { |
|
197 | - $this->update_term_taxonomy_counts(); |
|
198 | - } |
|
199 | - return $count; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * Overrides parent so that after running this, we also double-check |
|
206 | - * the term taxonomy counts are up-to-date |
|
207 | - * |
|
208 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
209 | - * @param boolean $allow_blocking |
|
210 | - * @return int @see EEM_Base::delete |
|
211 | - */ |
|
212 | - public function delete($query_params, $allow_blocking = true) |
|
213 | - { |
|
214 | - $count = parent::delete($query_params, $allow_blocking); |
|
215 | - if ($count) { |
|
216 | - $this->update_term_taxonomy_counts(); |
|
217 | - } |
|
218 | - return $count; |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * Makes sure that during REST API queries, we only return term relationships |
|
225 | - * for term taxonomies which should be shown in the rest api |
|
226 | - * |
|
227 | - * @param array $model_query_params |
|
228 | - * @param array $querystring_query_params |
|
229 | - * @param EEM_Base $model |
|
230 | - * @return array |
|
231 | - */ |
|
232 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
233 | - { |
|
234 | - if ($model === EEM_Term_Relationship::instance()) { |
|
235 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
236 | - if (! empty($taxonomies)) { |
|
237 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
238 | - } |
|
239 | - } |
|
240 | - return $model_query_params; |
|
241 | - } |
|
144 | + if ($term_taxonomy_id) { |
|
145 | + $query .= ' WHERE tt.term_taxonomy_id = %d'; |
|
146 | + $query = $wpdb->prepare( |
|
147 | + $query, |
|
148 | + $term_taxonomy_id |
|
149 | + ); |
|
150 | + } |
|
151 | + $rows_affected = $this->_do_wpdb_query( |
|
152 | + 'query', |
|
153 | + array( |
|
154 | + $query, |
|
155 | + ) |
|
156 | + ); |
|
157 | + return $rows_affected; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Overrides the parent to also make sure term-taxonomy counts are up-to-date after |
|
164 | + * inserting |
|
165 | + * |
|
166 | + * @param array $field_n_values @see EEM_Base::insert |
|
167 | + * @return boolean |
|
168 | + */ |
|
169 | + public function insert($field_n_values) |
|
170 | + { |
|
171 | + $return = parent::insert($field_n_values); |
|
172 | + if (isset($field_n_values['term_taxonomy_id'])) { |
|
173 | + $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
174 | + } |
|
175 | + return $return; |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * Overrides parent so that after an update, we also check the term_taxonomy_counts are |
|
182 | + * all ok |
|
183 | + * |
|
184 | + * @param array $fields_n_values see EEM_Base::update |
|
185 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
186 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
187 | + * in this model's entity map according to $fields_n_values that match |
|
188 | + * $query_params. This obviously has some overhead, so you can disable it |
|
189 | + * by setting this to FALSE, but be aware that model objects being used |
|
190 | + * could get out-of-sync with the database |
|
191 | + * @return int |
|
192 | + */ |
|
193 | + public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
194 | + { |
|
195 | + $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
196 | + if ($count) { |
|
197 | + $this->update_term_taxonomy_counts(); |
|
198 | + } |
|
199 | + return $count; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * Overrides parent so that after running this, we also double-check |
|
206 | + * the term taxonomy counts are up-to-date |
|
207 | + * |
|
208 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
209 | + * @param boolean $allow_blocking |
|
210 | + * @return int @see EEM_Base::delete |
|
211 | + */ |
|
212 | + public function delete($query_params, $allow_blocking = true) |
|
213 | + { |
|
214 | + $count = parent::delete($query_params, $allow_blocking); |
|
215 | + if ($count) { |
|
216 | + $this->update_term_taxonomy_counts(); |
|
217 | + } |
|
218 | + return $count; |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * Makes sure that during REST API queries, we only return term relationships |
|
225 | + * for term taxonomies which should be shown in the rest api |
|
226 | + * |
|
227 | + * @param array $model_query_params |
|
228 | + * @param array $querystring_query_params |
|
229 | + * @param EEM_Base $model |
|
230 | + * @return array |
|
231 | + */ |
|
232 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
233 | + { |
|
234 | + if ($model === EEM_Term_Relationship::instance()) { |
|
235 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
236 | + if (! empty($taxonomies)) { |
|
237 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
238 | + } |
|
239 | + } |
|
240 | + return $model_query_params; |
|
241 | + } |
|
242 | 242 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | ); |
33 | 33 | // this model is generally available for reading |
34 | 34 | $path_to_event = 'Event'; |
35 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
36 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
37 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
38 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
35 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
36 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
37 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
38 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
39 | 39 | $this->model_chain_to_password = $path_to_event; |
40 | 40 | parent::__construct($timezone); |
41 | 41 | } |
@@ -8,36 +8,36 @@ |
||
8 | 8 | */ |
9 | 9 | class EEM_Event_Venue extends EEM_Base |
10 | 10 | { |
11 | - // private instance of the Attendee object |
|
12 | - protected static $_instance = null; |
|
11 | + // private instance of the Attendee object |
|
12 | + protected static $_instance = null; |
|
13 | 13 | |
14 | - protected function __construct($timezone = null) |
|
15 | - { |
|
16 | - $this->singular_item = esc_html__('Event to Question Group Link', 'event_espresso'); |
|
17 | - $this->plural_item = esc_html__('Event to Question Group Links', 'event_espresso'); |
|
18 | - $this->_tables = array( |
|
19 | - 'Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID') |
|
20 | - ); |
|
21 | - $this->_fields = array( |
|
22 | - 'Event_Venue' => array( |
|
23 | - 'EVV_ID' => new EE_Primary_Key_Int_Field('EVV_ID', esc_html__('Event to Venue Link ID', 'event_espresso')), |
|
24 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', esc_html__('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
25 | - 'VNU_ID' => new EE_Foreign_Key_Int_Field('VNU_ID', esc_html__('Venue ID', 'event_espresso'), false, 0, 'Venue'), |
|
26 | - 'EVV_primary' => new EE_Boolean_Field('EVV_primary', esc_html__("Flag indicating venue is primary one for event", "event_espresso"), false, true) |
|
14 | + protected function __construct($timezone = null) |
|
15 | + { |
|
16 | + $this->singular_item = esc_html__('Event to Question Group Link', 'event_espresso'); |
|
17 | + $this->plural_item = esc_html__('Event to Question Group Links', 'event_espresso'); |
|
18 | + $this->_tables = array( |
|
19 | + 'Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID') |
|
20 | + ); |
|
21 | + $this->_fields = array( |
|
22 | + 'Event_Venue' => array( |
|
23 | + 'EVV_ID' => new EE_Primary_Key_Int_Field('EVV_ID', esc_html__('Event to Venue Link ID', 'event_espresso')), |
|
24 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', esc_html__('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
25 | + 'VNU_ID' => new EE_Foreign_Key_Int_Field('VNU_ID', esc_html__('Venue ID', 'event_espresso'), false, 0, 'Venue'), |
|
26 | + 'EVV_primary' => new EE_Boolean_Field('EVV_primary', esc_html__("Flag indicating venue is primary one for event", "event_espresso"), false, true) |
|
27 | 27 | |
28 | - ) |
|
29 | - ); |
|
30 | - $this->_model_relations = array( |
|
31 | - 'Event' => new EE_Belongs_To_Relation(), |
|
32 | - 'Venue' => new EE_Belongs_To_Relation() |
|
33 | - ); |
|
34 | - // this model is generally available for reading |
|
35 | - $path_to_event = 'Event'; |
|
36 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
37 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
38 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
39 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
40 | - $this->model_chain_to_password = $path_to_event; |
|
41 | - parent::__construct($timezone); |
|
42 | - } |
|
28 | + ) |
|
29 | + ); |
|
30 | + $this->_model_relations = array( |
|
31 | + 'Event' => new EE_Belongs_To_Relation(), |
|
32 | + 'Venue' => new EE_Belongs_To_Relation() |
|
33 | + ); |
|
34 | + // this model is generally available for reading |
|
35 | + $path_to_event = 'Event'; |
|
36 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
37 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
38 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
39 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
40 | + $this->model_chain_to_password = $path_to_event; |
|
41 | + parent::__construct($timezone); |
|
42 | + } |
|
43 | 43 | } |
@@ -12,45 +12,45 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Password_Field extends EE_Text_Field_Base |
14 | 14 | { |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected $protected_fields; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected $protected_fields; |
|
19 | 19 | |
20 | - /** |
|
21 | - * EE_Password_Field constructor. |
|
22 | - * @param $table_column |
|
23 | - * @param $nicename |
|
24 | - * @param $nullable |
|
25 | - * @param null $default_value |
|
26 | - * @param array $protected_fields |
|
27 | - */ |
|
28 | - public function __construct($table_column, $nicename, $nullable, $default_value = null, $protected_fields = array()) |
|
29 | - { |
|
30 | - $this->protected_fields = $protected_fields; |
|
31 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
32 | - } |
|
20 | + /** |
|
21 | + * EE_Password_Field constructor. |
|
22 | + * @param $table_column |
|
23 | + * @param $nicename |
|
24 | + * @param $nullable |
|
25 | + * @param null $default_value |
|
26 | + * @param array $protected_fields |
|
27 | + */ |
|
28 | + public function __construct($table_column, $nicename, $nullable, $default_value = null, $protected_fields = array()) |
|
29 | + { |
|
30 | + $this->protected_fields = $protected_fields; |
|
31 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Returns the names of the fields on this model that this password field should protect |
|
36 | - * @since 4.9.74.p |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function protectedFields() |
|
40 | - { |
|
41 | - return $this->protected_fields; |
|
42 | - } |
|
34 | + /** |
|
35 | + * Returns the names of the fields on this model that this password field should protect |
|
36 | + * @since 4.9.74.p |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function protectedFields() |
|
40 | + { |
|
41 | + return $this->protected_fields; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Returns whether or not the specified field is protected by this model |
|
46 | - * @since 4.9.74.p |
|
47 | - * @param $field_name |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - public function fieldIsProtected($field_name) |
|
51 | - { |
|
52 | - return in_array($field_name, $this->protectedFields(), true); |
|
53 | - } |
|
44 | + /** |
|
45 | + * Returns whether or not the specified field is protected by this model |
|
46 | + * @since 4.9.74.p |
|
47 | + * @param $field_name |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + public function fieldIsProtected($field_name) |
|
51 | + { |
|
52 | + return in_array($field_name, $this->protectedFields(), true); |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | // End of file EE_Password_Field.php |
56 | 56 | // Location: ${NAMESPACE}/EE_Password_Field.php |
@@ -16,52 +16,52 @@ |
||
16 | 16 | class EventEditorHeartbeat |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var Domain $domain |
|
21 | - */ |
|
22 | - protected $domain; |
|
19 | + /** |
|
20 | + * @var Domain $domain |
|
21 | + */ |
|
22 | + protected $domain; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var EE_Environment_Config $environment |
|
26 | - */ |
|
27 | - protected $environment; |
|
24 | + /** |
|
25 | + * @var EE_Environment_Config $environment |
|
26 | + */ |
|
27 | + protected $environment; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * EventEditorHeartbeat constructor. |
|
32 | - * |
|
33 | - * @param Domain $domain |
|
34 | - * @param EE_Environment_Config $environment |
|
35 | - */ |
|
36 | - public function __construct(Domain $domain, EE_Environment_Config $environment) |
|
37 | - { |
|
38 | - $this->domain = $domain; |
|
39 | - $this->environment = $environment; |
|
40 | - if ($this->domain->isCaffeinated()) { |
|
41 | - add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 2); |
|
42 | - } |
|
43 | - } |
|
30 | + /** |
|
31 | + * EventEditorHeartbeat constructor. |
|
32 | + * |
|
33 | + * @param Domain $domain |
|
34 | + * @param EE_Environment_Config $environment |
|
35 | + */ |
|
36 | + public function __construct(Domain $domain, EE_Environment_Config $environment) |
|
37 | + { |
|
38 | + $this->domain = $domain; |
|
39 | + $this->environment = $environment; |
|
40 | + if ($this->domain->isCaffeinated()) { |
|
41 | + add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 2); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
48 | - * accordingly. |
|
49 | - * |
|
50 | - * @param array $response The existing heartbeat response array. |
|
51 | - * @param array $data The incoming data package. |
|
52 | - * @return array possibly appended response. |
|
53 | - */ |
|
54 | - public function heartbeatResponse($response, $data) |
|
55 | - { |
|
56 | - /** |
|
57 | - * check whether count of tickets is approaching the potential |
|
58 | - * limits for the server. |
|
59 | - */ |
|
60 | - if (! empty($data['input_count'])) { |
|
61 | - $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check( |
|
62 | - $data['input_count'] |
|
63 | - ); |
|
64 | - } |
|
65 | - return $response; |
|
66 | - } |
|
46 | + /** |
|
47 | + * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
48 | + * accordingly. |
|
49 | + * |
|
50 | + * @param array $response The existing heartbeat response array. |
|
51 | + * @param array $data The incoming data package. |
|
52 | + * @return array possibly appended response. |
|
53 | + */ |
|
54 | + public function heartbeatResponse($response, $data) |
|
55 | + { |
|
56 | + /** |
|
57 | + * check whether count of tickets is approaching the potential |
|
58 | + * limits for the server. |
|
59 | + */ |
|
60 | + if (! empty($data['input_count'])) { |
|
61 | + $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check( |
|
62 | + $data['input_count'] |
|
63 | + ); |
|
64 | + } |
|
65 | + return $response; |
|
66 | + } |
|
67 | 67 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * check whether count of tickets is approaching the potential |
58 | 58 | * limits for the server. |
59 | 59 | */ |
60 | - if (! empty($data['input_count'])) { |
|
60 | + if ( ! empty($data['input_count'])) { |
|
61 | 61 | $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check( |
62 | 62 | $data['input_count'] |
63 | 63 | ); |