@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '7.2.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '7.2.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.46.rc.001'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.46.rc.001'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | \ No newline at end of file |
@@ -25,751 +25,751 @@ |
||
25 | 25 | */ |
26 | 26 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, AddressInterface, EEI_Admin_Links, EEI_Attendee |
27 | 27 | { |
28 | - /** |
|
29 | - * Sets some dynamic defaults |
|
30 | - * |
|
31 | - * @param array $fieldValues |
|
32 | - * @param bool $bydb |
|
33 | - * @param string $timezone |
|
34 | - * @param array $date_formats |
|
35 | - * @throws EE_Error |
|
36 | - */ |
|
37 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
38 | - { |
|
39 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
40 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
41 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
42 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
43 | - } |
|
44 | - if (! isset($fieldValues['ATT_slug'])) { |
|
45 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
46 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
47 | - } |
|
48 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
49 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
50 | - } |
|
51 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param array $props_n_values incoming values |
|
57 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
58 | - * used.) |
|
59 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
60 | - * date_format and the second value is the time format |
|
61 | - * @return EE_Attendee |
|
62 | - * @throws EE_Error |
|
63 | - */ |
|
64 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
65 | - { |
|
66 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
67 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param array $props_n_values incoming values from the database |
|
73 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
74 | - * the website will be used. |
|
75 | - * @return EE_Attendee |
|
76 | - */ |
|
77 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
78 | - { |
|
79 | - return new self($props_n_values, true, $timezone); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * Set Attendee First Name |
|
85 | - * |
|
86 | - * @access public |
|
87 | - * @param string $fname |
|
88 | - * @throws EE_Error |
|
89 | - */ |
|
90 | - public function set_fname($fname = '') |
|
91 | - { |
|
92 | - $this->set('ATT_fname', $fname); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Set Attendee Last Name |
|
98 | - * |
|
99 | - * @access public |
|
100 | - * @param string $lname |
|
101 | - * @throws EE_Error |
|
102 | - */ |
|
103 | - public function set_lname($lname = '') |
|
104 | - { |
|
105 | - $this->set('ATT_lname', $lname); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * Set Attendee Address |
|
111 | - * |
|
112 | - * @access public |
|
113 | - * @param string $address |
|
114 | - * @throws EE_Error |
|
115 | - */ |
|
116 | - public function set_address($address = '') |
|
117 | - { |
|
118 | - $this->set('ATT_address', $address); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Set Attendee Address2 |
|
124 | - * |
|
125 | - * @access public |
|
126 | - * @param string $address2 |
|
127 | - * @throws EE_Error |
|
128 | - */ |
|
129 | - public function set_address2($address2 = '') |
|
130 | - { |
|
131 | - $this->set('ATT_address2', $address2); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * Set Attendee City |
|
137 | - * |
|
138 | - * @access public |
|
139 | - * @param string $city |
|
140 | - * @throws EE_Error |
|
141 | - */ |
|
142 | - public function set_city($city = '') |
|
143 | - { |
|
144 | - $this->set('ATT_city', $city); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Set Attendee State ID |
|
150 | - * |
|
151 | - * @access public |
|
152 | - * @param int $STA_ID |
|
153 | - * @throws EE_Error |
|
154 | - */ |
|
155 | - public function set_state($STA_ID = 0) |
|
156 | - { |
|
157 | - $this->set('STA_ID', $STA_ID); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Set Attendee Country ISO Code |
|
163 | - * |
|
164 | - * @access public |
|
165 | - * @param string $CNT_ISO |
|
166 | - * @throws EE_Error |
|
167 | - */ |
|
168 | - public function set_country($CNT_ISO = '') |
|
169 | - { |
|
170 | - $this->set('CNT_ISO', $CNT_ISO); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Set Attendee Zip/Postal Code |
|
176 | - * |
|
177 | - * @access public |
|
178 | - * @param string $zip |
|
179 | - * @throws EE_Error |
|
180 | - */ |
|
181 | - public function set_zip($zip = '') |
|
182 | - { |
|
183 | - $this->set('ATT_zip', $zip); |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Set Attendee Email Address |
|
189 | - * |
|
190 | - * @access public |
|
191 | - * @param string $email |
|
192 | - * @throws EE_Error |
|
193 | - */ |
|
194 | - public function set_email($email = '') |
|
195 | - { |
|
196 | - $this->set('ATT_email', $email); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * Set Attendee Phone |
|
202 | - * |
|
203 | - * @access public |
|
204 | - * @param string $phone |
|
205 | - * @throws EE_Error |
|
206 | - */ |
|
207 | - public function set_phone($phone = '') |
|
208 | - { |
|
209 | - $this->set('ATT_phone', $phone); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * set deleted |
|
215 | - * |
|
216 | - * @access public |
|
217 | - * @param bool $ATT_deleted |
|
218 | - * @throws EE_Error |
|
219 | - */ |
|
220 | - public function set_deleted($ATT_deleted = false) |
|
221 | - { |
|
222 | - $this->set('ATT_deleted', $ATT_deleted); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * Returns the value for the post_author id saved with the cpt |
|
228 | - * |
|
229 | - * @since 4.5.0 |
|
230 | - * @return int |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - public function wp_user() |
|
234 | - { |
|
235 | - return $this->get('ATT_author'); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * get Attendee First Name |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @return string |
|
244 | - * @throws EE_Error |
|
245 | - */ |
|
246 | - public function fname() |
|
247 | - { |
|
248 | - return $this->get('ATT_fname'); |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * echoes out the attendee's first name |
|
254 | - * |
|
255 | - * @return void |
|
256 | - * @throws EE_Error |
|
257 | - */ |
|
258 | - public function e_full_name() |
|
259 | - { |
|
260 | - echo esc_html($this->full_name()); |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * Returns the first and last name concatenated together with a space. |
|
266 | - * |
|
267 | - * @param bool $apply_html_entities |
|
268 | - * @return string |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - public function full_name($apply_html_entities = false) |
|
272 | - { |
|
273 | - $full_name = array( |
|
274 | - $this->fname(), |
|
275 | - $this->lname(), |
|
276 | - ); |
|
277 | - $full_name = array_filter($full_name); |
|
278 | - $full_name = implode(' ', $full_name); |
|
279 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
285 | - * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
286 | - * attendee. |
|
287 | - * |
|
288 | - * @param bool $apply_html_entities |
|
289 | - * @return string |
|
290 | - * @throws EE_Error |
|
291 | - */ |
|
292 | - public function ATT_full_name($apply_html_entities = false) |
|
293 | - { |
|
294 | - return $apply_html_entities |
|
295 | - ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
296 | - : $this->get('ATT_full_name'); |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * get Attendee Last Name |
|
302 | - * |
|
303 | - * @access public |
|
304 | - * @return string |
|
305 | - * @throws EE_Error |
|
306 | - */ |
|
307 | - public function lname() |
|
308 | - { |
|
309 | - return $this->get('ATT_lname'); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
315 | - * |
|
316 | - * @return array numerically indexed, with each part of the address that is known. |
|
317 | - * Eg, if the user only responded to state and country, |
|
318 | - * it would be array(0=>'Alabama',1=>'USA') |
|
319 | - * @return array |
|
320 | - * @throws EE_Error |
|
321 | - */ |
|
322 | - public function full_address_as_array() |
|
323 | - { |
|
324 | - $full_address_array = array(); |
|
325 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
326 | - foreach ($initial_address_fields as $address_field_name) { |
|
327 | - $address_fields_value = $this->get($address_field_name); |
|
328 | - if (! empty($address_fields_value)) { |
|
329 | - $full_address_array[] = $address_fields_value; |
|
330 | - } |
|
331 | - } |
|
332 | - // now handle state and country |
|
333 | - $state_obj = $this->state_obj(); |
|
334 | - if ($state_obj instanceof EE_State) { |
|
335 | - $full_address_array[] = $state_obj->name(); |
|
336 | - } |
|
337 | - $country_obj = $this->country_obj(); |
|
338 | - if ($country_obj instanceof EE_Country) { |
|
339 | - $full_address_array[] = $country_obj->name(); |
|
340 | - } |
|
341 | - // lastly get the xip |
|
342 | - $zip_value = $this->zip(); |
|
343 | - if (! empty($zip_value)) { |
|
344 | - $full_address_array[] = $zip_value; |
|
345 | - } |
|
346 | - return $full_address_array; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * get Attendee Address |
|
352 | - * |
|
353 | - * @return string |
|
354 | - * @throws EE_Error |
|
355 | - */ |
|
356 | - public function address(): string |
|
357 | - { |
|
358 | - return (string) $this->get('ATT_address'); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * get Attendee Address2 |
|
364 | - * |
|
365 | - * @return string |
|
366 | - * @throws EE_Error |
|
367 | - */ |
|
368 | - public function address2(): string |
|
369 | - { |
|
370 | - return (string) $this->get('ATT_address2'); |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * get Attendee City |
|
376 | - * |
|
377 | - * @return string |
|
378 | - * @throws EE_Error |
|
379 | - */ |
|
380 | - public function city(): string |
|
381 | - { |
|
382 | - return (string) $this->get('ATT_city'); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * get Attendee State ID |
|
388 | - * |
|
389 | - * @return int |
|
390 | - * @throws EE_Error |
|
391 | - */ |
|
392 | - public function state_ID(): int |
|
393 | - { |
|
394 | - return (int) $this->get('STA_ID'); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * @return string |
|
400 | - * @throws EE_Error |
|
401 | - */ |
|
402 | - public function state_abbrev(): string |
|
403 | - { |
|
404 | - return $this->state_obj() instanceof EE_State ? (string) $this->state_obj()->abbrev() : ''; |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * Gets the state set to this attendee |
|
410 | - * |
|
411 | - * @return EE_State|null |
|
412 | - * @throws EE_Error |
|
413 | - */ |
|
414 | - public function state_obj(): ?EE_State |
|
415 | - { |
|
416 | - return $this->get_first_related('State'); |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * Returns the state's name, otherwise 'Unknown' |
|
422 | - * |
|
423 | - * @return string |
|
424 | - * @throws EE_Error |
|
425 | - */ |
|
426 | - public function state_name(): string |
|
427 | - { |
|
428 | - if ($this->state_obj()) { |
|
429 | - return (string) $this->state_obj()->name(); |
|
430 | - } else { |
|
431 | - return ''; |
|
432 | - } |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * either displays the state abbreviation or the state name, as determined |
|
438 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
439 | - * defaults to abbreviation |
|
440 | - * |
|
441 | - * @return string |
|
442 | - * @throws EE_Error |
|
443 | - */ |
|
444 | - public function state(): string |
|
445 | - { |
|
446 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
447 | - return (string) $this->state_abbrev(); |
|
448 | - } |
|
449 | - return (string) $this->state_name(); |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * get Attendee Country ISO Code |
|
455 | - * |
|
456 | - * @return string |
|
457 | - * @throws EE_Error |
|
458 | - */ |
|
459 | - public function country_ID(): string |
|
460 | - { |
|
461 | - return (string) $this->get('CNT_ISO'); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * Gets country set for this attendee |
|
467 | - * |
|
468 | - * @return EE_Country|null |
|
469 | - * @throws EE_Error |
|
470 | - */ |
|
471 | - public function country_obj(): ?EE_Country |
|
472 | - { |
|
473 | - return $this->get_first_related('Country'); |
|
474 | - } |
|
475 | - |
|
476 | - |
|
477 | - /** |
|
478 | - * Returns the country's name if known, otherwise 'Unknown' |
|
479 | - * |
|
480 | - * @return string |
|
481 | - * @throws EE_Error |
|
482 | - */ |
|
483 | - public function country_name(): string |
|
484 | - { |
|
485 | - if ($this->country_obj()) { |
|
486 | - return (string) $this->country_obj()->name(); |
|
487 | - } |
|
488 | - return ''; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * either displays the country ISO2 code or the country name, as determined |
|
494 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
495 | - * defaults to abbreviation |
|
496 | - * |
|
497 | - * @return string |
|
498 | - * @throws EE_Error |
|
499 | - */ |
|
500 | - public function country(): string |
|
501 | - { |
|
502 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
503 | - return (string) $this->country_ID(); |
|
504 | - } |
|
505 | - return (string) $this->country_name(); |
|
506 | - } |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * get Attendee Zip/Postal Code |
|
511 | - * |
|
512 | - * @return string |
|
513 | - * @throws EE_Error |
|
514 | - */ |
|
515 | - public function zip(): string |
|
516 | - { |
|
517 | - return (string) $this->get('ATT_zip'); |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * get Attendee Email Address |
|
523 | - * |
|
524 | - * @return string |
|
525 | - * @throws EE_Error |
|
526 | - */ |
|
527 | - public function email() |
|
528 | - { |
|
529 | - return $this->get('ATT_email'); |
|
530 | - } |
|
531 | - |
|
532 | - |
|
533 | - /** |
|
534 | - * get Attendee Phone # |
|
535 | - * |
|
536 | - * @return string |
|
537 | - * @throws EE_Error |
|
538 | - */ |
|
539 | - public function phone() |
|
540 | - { |
|
541 | - return $this->get('ATT_phone'); |
|
542 | - } |
|
543 | - |
|
544 | - |
|
545 | - /** |
|
546 | - * get deleted |
|
547 | - * |
|
548 | - * @return bool |
|
549 | - * @throws EE_Error |
|
550 | - */ |
|
551 | - public function deleted() |
|
552 | - { |
|
553 | - return $this->get('ATT_deleted'); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Gets registrations of this attendee |
|
559 | - * |
|
560 | - * @param array $query_params |
|
561 | - * @return EE_Registration[] |
|
562 | - * @throws EE_Error |
|
563 | - */ |
|
564 | - public function get_registrations($query_params = array()) |
|
565 | - { |
|
566 | - return $this->get_many_related('Registration', $query_params); |
|
567 | - } |
|
568 | - |
|
569 | - |
|
570 | - /** |
|
571 | - * Gets the most recent registration of this attendee |
|
572 | - * |
|
573 | - * @return EE_Registration |
|
574 | - * @throws EE_Error |
|
575 | - */ |
|
576 | - public function get_most_recent_registration() |
|
577 | - { |
|
578 | - return $this->get_first_related( |
|
579 | - 'Registration', |
|
580 | - array('order_by' => array('REG_date' => 'DESC')) |
|
581 | - ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * Gets the most recent registration for this attend at this event |
|
587 | - * |
|
588 | - * @param int $event_id |
|
589 | - * @return EE_Registration |
|
590 | - * @throws EE_Error |
|
591 | - */ |
|
592 | - public function get_most_recent_registration_for_event($event_id) |
|
593 | - { |
|
594 | - return $this->get_first_related( |
|
595 | - 'Registration', |
|
596 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
597 | - ); |
|
598 | - } |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * returns any events attached to this attendee ($_Event property); |
|
603 | - * |
|
604 | - * @return array |
|
605 | - * @throws EE_Error |
|
606 | - */ |
|
607 | - public function events() |
|
608 | - { |
|
609 | - return $this->get_many_related('Event'); |
|
610 | - } |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
615 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
616 | - * used to save the billing info |
|
617 | - * |
|
618 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
619 | - * @return EE_Form_Section_Proper|null |
|
620 | - * @throws EE_Error |
|
621 | - */ |
|
622 | - public function billing_info_for_payment_method($payment_method) |
|
623 | - { |
|
624 | - $pm_type = $payment_method->type_obj(); |
|
625 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
626 | - return null; |
|
627 | - } |
|
628 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
629 | - if (! $billing_info) { |
|
630 | - return null; |
|
631 | - } |
|
632 | - $billing_form = $pm_type->billing_form(); |
|
633 | - // double-check the form isn't totally hidden, in which case pretend there is no form |
|
634 | - $form_totally_hidden = true; |
|
635 | - foreach ($billing_form->inputs_in_subsections() as $input) { |
|
636 | - if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
637 | - $form_totally_hidden = false; |
|
638 | - break; |
|
639 | - } |
|
640 | - } |
|
641 | - if ($form_totally_hidden) { |
|
642 | - return null; |
|
643 | - } |
|
644 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
645 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
646 | - } |
|
647 | - |
|
648 | - return $billing_form; |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
654 | - * specified payment method |
|
655 | - * |
|
656 | - * @param EE_Payment_Method $payment_method |
|
657 | - * @return string |
|
658 | - * @throws EE_Error |
|
659 | - */ |
|
660 | - public function get_billing_info_postmeta_name($payment_method) |
|
661 | - { |
|
662 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
663 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
664 | - } |
|
665 | - return null; |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - /** |
|
670 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
671 | - * retrieve it |
|
672 | - * |
|
673 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
674 | - * @param EE_Payment_Method $payment_method |
|
675 | - * @return boolean |
|
676 | - * @throws EE_Error |
|
677 | - */ |
|
678 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
679 | - { |
|
680 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
681 | - EE_Error::add_error( |
|
682 | - esc_html__('Cannot save billing info because there is none.', 'event_espresso'), |
|
683 | - __FILE__, |
|
684 | - __FUNCTION__, |
|
685 | - __LINE__ |
|
686 | - ); |
|
687 | - return false; |
|
688 | - } |
|
689 | - $billing_form->clean_sensitive_data(); |
|
690 | - return update_post_meta( |
|
691 | - $this->ID(), |
|
692 | - $this->get_billing_info_postmeta_name($payment_method), |
|
693 | - $billing_form->input_values(true) |
|
694 | - ); |
|
695 | - } |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * Return the link to the admin details for the object. |
|
700 | - * |
|
701 | - * @return string |
|
702 | - * @throws EE_Error |
|
703 | - * @throws InvalidArgumentException |
|
704 | - * @throws InvalidDataTypeException |
|
705 | - * @throws InvalidInterfaceException |
|
706 | - * @throws ReflectionException |
|
707 | - */ |
|
708 | - public function get_admin_details_link() |
|
709 | - { |
|
710 | - return $this->get_admin_edit_link(); |
|
711 | - } |
|
712 | - |
|
713 | - |
|
714 | - /** |
|
715 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
716 | - * |
|
717 | - * @return string |
|
718 | - * @throws EE_Error |
|
719 | - * @throws InvalidArgumentException |
|
720 | - * @throws ReflectionException |
|
721 | - * @throws InvalidDataTypeException |
|
722 | - * @throws InvalidInterfaceException |
|
723 | - */ |
|
724 | - public function get_admin_edit_link() |
|
725 | - { |
|
726 | - EE_Registry::instance()->load_helper('URL'); |
|
727 | - return EEH_URL::add_query_args_and_nonce( |
|
728 | - array( |
|
729 | - 'page' => 'espresso_registrations', |
|
730 | - 'action' => 'edit_attendee', |
|
731 | - 'post' => $this->ID(), |
|
732 | - ), |
|
733 | - admin_url('admin.php') |
|
734 | - ); |
|
735 | - } |
|
736 | - |
|
737 | - |
|
738 | - /** |
|
739 | - * Returns the link to a settings page for the object. |
|
740 | - * |
|
741 | - * @return string |
|
742 | - * @throws EE_Error |
|
743 | - * @throws InvalidArgumentException |
|
744 | - * @throws InvalidDataTypeException |
|
745 | - * @throws InvalidInterfaceException |
|
746 | - * @throws ReflectionException |
|
747 | - */ |
|
748 | - public function get_admin_settings_link() |
|
749 | - { |
|
750 | - return $this->get_admin_edit_link(); |
|
751 | - } |
|
752 | - |
|
753 | - |
|
754 | - /** |
|
755 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
756 | - * |
|
757 | - * @return string |
|
758 | - * @throws EE_Error |
|
759 | - * @throws InvalidArgumentException |
|
760 | - * @throws ReflectionException |
|
761 | - * @throws InvalidDataTypeException |
|
762 | - * @throws InvalidInterfaceException |
|
763 | - */ |
|
764 | - public function get_admin_overview_link() |
|
765 | - { |
|
766 | - EE_Registry::instance()->load_helper('URL'); |
|
767 | - return EEH_URL::add_query_args_and_nonce( |
|
768 | - array( |
|
769 | - 'page' => 'espresso_registrations', |
|
770 | - 'action' => 'contact_list', |
|
771 | - ), |
|
772 | - admin_url('admin.php') |
|
773 | - ); |
|
774 | - } |
|
28 | + /** |
|
29 | + * Sets some dynamic defaults |
|
30 | + * |
|
31 | + * @param array $fieldValues |
|
32 | + * @param bool $bydb |
|
33 | + * @param string $timezone |
|
34 | + * @param array $date_formats |
|
35 | + * @throws EE_Error |
|
36 | + */ |
|
37 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
38 | + { |
|
39 | + if (! isset($fieldValues['ATT_full_name'])) { |
|
40 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
41 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
42 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
43 | + } |
|
44 | + if (! isset($fieldValues['ATT_slug'])) { |
|
45 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
46 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
47 | + } |
|
48 | + if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
49 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
50 | + } |
|
51 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param array $props_n_values incoming values |
|
57 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
58 | + * used.) |
|
59 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
60 | + * date_format and the second value is the time format |
|
61 | + * @return EE_Attendee |
|
62 | + * @throws EE_Error |
|
63 | + */ |
|
64 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
65 | + { |
|
66 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
67 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param array $props_n_values incoming values from the database |
|
73 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
74 | + * the website will be used. |
|
75 | + * @return EE_Attendee |
|
76 | + */ |
|
77 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
78 | + { |
|
79 | + return new self($props_n_values, true, $timezone); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * Set Attendee First Name |
|
85 | + * |
|
86 | + * @access public |
|
87 | + * @param string $fname |
|
88 | + * @throws EE_Error |
|
89 | + */ |
|
90 | + public function set_fname($fname = '') |
|
91 | + { |
|
92 | + $this->set('ATT_fname', $fname); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Set Attendee Last Name |
|
98 | + * |
|
99 | + * @access public |
|
100 | + * @param string $lname |
|
101 | + * @throws EE_Error |
|
102 | + */ |
|
103 | + public function set_lname($lname = '') |
|
104 | + { |
|
105 | + $this->set('ATT_lname', $lname); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * Set Attendee Address |
|
111 | + * |
|
112 | + * @access public |
|
113 | + * @param string $address |
|
114 | + * @throws EE_Error |
|
115 | + */ |
|
116 | + public function set_address($address = '') |
|
117 | + { |
|
118 | + $this->set('ATT_address', $address); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Set Attendee Address2 |
|
124 | + * |
|
125 | + * @access public |
|
126 | + * @param string $address2 |
|
127 | + * @throws EE_Error |
|
128 | + */ |
|
129 | + public function set_address2($address2 = '') |
|
130 | + { |
|
131 | + $this->set('ATT_address2', $address2); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * Set Attendee City |
|
137 | + * |
|
138 | + * @access public |
|
139 | + * @param string $city |
|
140 | + * @throws EE_Error |
|
141 | + */ |
|
142 | + public function set_city($city = '') |
|
143 | + { |
|
144 | + $this->set('ATT_city', $city); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Set Attendee State ID |
|
150 | + * |
|
151 | + * @access public |
|
152 | + * @param int $STA_ID |
|
153 | + * @throws EE_Error |
|
154 | + */ |
|
155 | + public function set_state($STA_ID = 0) |
|
156 | + { |
|
157 | + $this->set('STA_ID', $STA_ID); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Set Attendee Country ISO Code |
|
163 | + * |
|
164 | + * @access public |
|
165 | + * @param string $CNT_ISO |
|
166 | + * @throws EE_Error |
|
167 | + */ |
|
168 | + public function set_country($CNT_ISO = '') |
|
169 | + { |
|
170 | + $this->set('CNT_ISO', $CNT_ISO); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Set Attendee Zip/Postal Code |
|
176 | + * |
|
177 | + * @access public |
|
178 | + * @param string $zip |
|
179 | + * @throws EE_Error |
|
180 | + */ |
|
181 | + public function set_zip($zip = '') |
|
182 | + { |
|
183 | + $this->set('ATT_zip', $zip); |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Set Attendee Email Address |
|
189 | + * |
|
190 | + * @access public |
|
191 | + * @param string $email |
|
192 | + * @throws EE_Error |
|
193 | + */ |
|
194 | + public function set_email($email = '') |
|
195 | + { |
|
196 | + $this->set('ATT_email', $email); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * Set Attendee Phone |
|
202 | + * |
|
203 | + * @access public |
|
204 | + * @param string $phone |
|
205 | + * @throws EE_Error |
|
206 | + */ |
|
207 | + public function set_phone($phone = '') |
|
208 | + { |
|
209 | + $this->set('ATT_phone', $phone); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * set deleted |
|
215 | + * |
|
216 | + * @access public |
|
217 | + * @param bool $ATT_deleted |
|
218 | + * @throws EE_Error |
|
219 | + */ |
|
220 | + public function set_deleted($ATT_deleted = false) |
|
221 | + { |
|
222 | + $this->set('ATT_deleted', $ATT_deleted); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * Returns the value for the post_author id saved with the cpt |
|
228 | + * |
|
229 | + * @since 4.5.0 |
|
230 | + * @return int |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + public function wp_user() |
|
234 | + { |
|
235 | + return $this->get('ATT_author'); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * get Attendee First Name |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @return string |
|
244 | + * @throws EE_Error |
|
245 | + */ |
|
246 | + public function fname() |
|
247 | + { |
|
248 | + return $this->get('ATT_fname'); |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * echoes out the attendee's first name |
|
254 | + * |
|
255 | + * @return void |
|
256 | + * @throws EE_Error |
|
257 | + */ |
|
258 | + public function e_full_name() |
|
259 | + { |
|
260 | + echo esc_html($this->full_name()); |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * Returns the first and last name concatenated together with a space. |
|
266 | + * |
|
267 | + * @param bool $apply_html_entities |
|
268 | + * @return string |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + public function full_name($apply_html_entities = false) |
|
272 | + { |
|
273 | + $full_name = array( |
|
274 | + $this->fname(), |
|
275 | + $this->lname(), |
|
276 | + ); |
|
277 | + $full_name = array_filter($full_name); |
|
278 | + $full_name = implode(' ', $full_name); |
|
279 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
285 | + * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
286 | + * attendee. |
|
287 | + * |
|
288 | + * @param bool $apply_html_entities |
|
289 | + * @return string |
|
290 | + * @throws EE_Error |
|
291 | + */ |
|
292 | + public function ATT_full_name($apply_html_entities = false) |
|
293 | + { |
|
294 | + return $apply_html_entities |
|
295 | + ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
296 | + : $this->get('ATT_full_name'); |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * get Attendee Last Name |
|
302 | + * |
|
303 | + * @access public |
|
304 | + * @return string |
|
305 | + * @throws EE_Error |
|
306 | + */ |
|
307 | + public function lname() |
|
308 | + { |
|
309 | + return $this->get('ATT_lname'); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
315 | + * |
|
316 | + * @return array numerically indexed, with each part of the address that is known. |
|
317 | + * Eg, if the user only responded to state and country, |
|
318 | + * it would be array(0=>'Alabama',1=>'USA') |
|
319 | + * @return array |
|
320 | + * @throws EE_Error |
|
321 | + */ |
|
322 | + public function full_address_as_array() |
|
323 | + { |
|
324 | + $full_address_array = array(); |
|
325 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
326 | + foreach ($initial_address_fields as $address_field_name) { |
|
327 | + $address_fields_value = $this->get($address_field_name); |
|
328 | + if (! empty($address_fields_value)) { |
|
329 | + $full_address_array[] = $address_fields_value; |
|
330 | + } |
|
331 | + } |
|
332 | + // now handle state and country |
|
333 | + $state_obj = $this->state_obj(); |
|
334 | + if ($state_obj instanceof EE_State) { |
|
335 | + $full_address_array[] = $state_obj->name(); |
|
336 | + } |
|
337 | + $country_obj = $this->country_obj(); |
|
338 | + if ($country_obj instanceof EE_Country) { |
|
339 | + $full_address_array[] = $country_obj->name(); |
|
340 | + } |
|
341 | + // lastly get the xip |
|
342 | + $zip_value = $this->zip(); |
|
343 | + if (! empty($zip_value)) { |
|
344 | + $full_address_array[] = $zip_value; |
|
345 | + } |
|
346 | + return $full_address_array; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * get Attendee Address |
|
352 | + * |
|
353 | + * @return string |
|
354 | + * @throws EE_Error |
|
355 | + */ |
|
356 | + public function address(): string |
|
357 | + { |
|
358 | + return (string) $this->get('ATT_address'); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * get Attendee Address2 |
|
364 | + * |
|
365 | + * @return string |
|
366 | + * @throws EE_Error |
|
367 | + */ |
|
368 | + public function address2(): string |
|
369 | + { |
|
370 | + return (string) $this->get('ATT_address2'); |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * get Attendee City |
|
376 | + * |
|
377 | + * @return string |
|
378 | + * @throws EE_Error |
|
379 | + */ |
|
380 | + public function city(): string |
|
381 | + { |
|
382 | + return (string) $this->get('ATT_city'); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * get Attendee State ID |
|
388 | + * |
|
389 | + * @return int |
|
390 | + * @throws EE_Error |
|
391 | + */ |
|
392 | + public function state_ID(): int |
|
393 | + { |
|
394 | + return (int) $this->get('STA_ID'); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * @return string |
|
400 | + * @throws EE_Error |
|
401 | + */ |
|
402 | + public function state_abbrev(): string |
|
403 | + { |
|
404 | + return $this->state_obj() instanceof EE_State ? (string) $this->state_obj()->abbrev() : ''; |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * Gets the state set to this attendee |
|
410 | + * |
|
411 | + * @return EE_State|null |
|
412 | + * @throws EE_Error |
|
413 | + */ |
|
414 | + public function state_obj(): ?EE_State |
|
415 | + { |
|
416 | + return $this->get_first_related('State'); |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * Returns the state's name, otherwise 'Unknown' |
|
422 | + * |
|
423 | + * @return string |
|
424 | + * @throws EE_Error |
|
425 | + */ |
|
426 | + public function state_name(): string |
|
427 | + { |
|
428 | + if ($this->state_obj()) { |
|
429 | + return (string) $this->state_obj()->name(); |
|
430 | + } else { |
|
431 | + return ''; |
|
432 | + } |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * either displays the state abbreviation or the state name, as determined |
|
438 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
439 | + * defaults to abbreviation |
|
440 | + * |
|
441 | + * @return string |
|
442 | + * @throws EE_Error |
|
443 | + */ |
|
444 | + public function state(): string |
|
445 | + { |
|
446 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
447 | + return (string) $this->state_abbrev(); |
|
448 | + } |
|
449 | + return (string) $this->state_name(); |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * get Attendee Country ISO Code |
|
455 | + * |
|
456 | + * @return string |
|
457 | + * @throws EE_Error |
|
458 | + */ |
|
459 | + public function country_ID(): string |
|
460 | + { |
|
461 | + return (string) $this->get('CNT_ISO'); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * Gets country set for this attendee |
|
467 | + * |
|
468 | + * @return EE_Country|null |
|
469 | + * @throws EE_Error |
|
470 | + */ |
|
471 | + public function country_obj(): ?EE_Country |
|
472 | + { |
|
473 | + return $this->get_first_related('Country'); |
|
474 | + } |
|
475 | + |
|
476 | + |
|
477 | + /** |
|
478 | + * Returns the country's name if known, otherwise 'Unknown' |
|
479 | + * |
|
480 | + * @return string |
|
481 | + * @throws EE_Error |
|
482 | + */ |
|
483 | + public function country_name(): string |
|
484 | + { |
|
485 | + if ($this->country_obj()) { |
|
486 | + return (string) $this->country_obj()->name(); |
|
487 | + } |
|
488 | + return ''; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * either displays the country ISO2 code or the country name, as determined |
|
494 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
495 | + * defaults to abbreviation |
|
496 | + * |
|
497 | + * @return string |
|
498 | + * @throws EE_Error |
|
499 | + */ |
|
500 | + public function country(): string |
|
501 | + { |
|
502 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
503 | + return (string) $this->country_ID(); |
|
504 | + } |
|
505 | + return (string) $this->country_name(); |
|
506 | + } |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * get Attendee Zip/Postal Code |
|
511 | + * |
|
512 | + * @return string |
|
513 | + * @throws EE_Error |
|
514 | + */ |
|
515 | + public function zip(): string |
|
516 | + { |
|
517 | + return (string) $this->get('ATT_zip'); |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * get Attendee Email Address |
|
523 | + * |
|
524 | + * @return string |
|
525 | + * @throws EE_Error |
|
526 | + */ |
|
527 | + public function email() |
|
528 | + { |
|
529 | + return $this->get('ATT_email'); |
|
530 | + } |
|
531 | + |
|
532 | + |
|
533 | + /** |
|
534 | + * get Attendee Phone # |
|
535 | + * |
|
536 | + * @return string |
|
537 | + * @throws EE_Error |
|
538 | + */ |
|
539 | + public function phone() |
|
540 | + { |
|
541 | + return $this->get('ATT_phone'); |
|
542 | + } |
|
543 | + |
|
544 | + |
|
545 | + /** |
|
546 | + * get deleted |
|
547 | + * |
|
548 | + * @return bool |
|
549 | + * @throws EE_Error |
|
550 | + */ |
|
551 | + public function deleted() |
|
552 | + { |
|
553 | + return $this->get('ATT_deleted'); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Gets registrations of this attendee |
|
559 | + * |
|
560 | + * @param array $query_params |
|
561 | + * @return EE_Registration[] |
|
562 | + * @throws EE_Error |
|
563 | + */ |
|
564 | + public function get_registrations($query_params = array()) |
|
565 | + { |
|
566 | + return $this->get_many_related('Registration', $query_params); |
|
567 | + } |
|
568 | + |
|
569 | + |
|
570 | + /** |
|
571 | + * Gets the most recent registration of this attendee |
|
572 | + * |
|
573 | + * @return EE_Registration |
|
574 | + * @throws EE_Error |
|
575 | + */ |
|
576 | + public function get_most_recent_registration() |
|
577 | + { |
|
578 | + return $this->get_first_related( |
|
579 | + 'Registration', |
|
580 | + array('order_by' => array('REG_date' => 'DESC')) |
|
581 | + ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * Gets the most recent registration for this attend at this event |
|
587 | + * |
|
588 | + * @param int $event_id |
|
589 | + * @return EE_Registration |
|
590 | + * @throws EE_Error |
|
591 | + */ |
|
592 | + public function get_most_recent_registration_for_event($event_id) |
|
593 | + { |
|
594 | + return $this->get_first_related( |
|
595 | + 'Registration', |
|
596 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
597 | + ); |
|
598 | + } |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * returns any events attached to this attendee ($_Event property); |
|
603 | + * |
|
604 | + * @return array |
|
605 | + * @throws EE_Error |
|
606 | + */ |
|
607 | + public function events() |
|
608 | + { |
|
609 | + return $this->get_many_related('Event'); |
|
610 | + } |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
615 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
616 | + * used to save the billing info |
|
617 | + * |
|
618 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
619 | + * @return EE_Form_Section_Proper|null |
|
620 | + * @throws EE_Error |
|
621 | + */ |
|
622 | + public function billing_info_for_payment_method($payment_method) |
|
623 | + { |
|
624 | + $pm_type = $payment_method->type_obj(); |
|
625 | + if (! $pm_type instanceof EE_PMT_Base) { |
|
626 | + return null; |
|
627 | + } |
|
628 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
629 | + if (! $billing_info) { |
|
630 | + return null; |
|
631 | + } |
|
632 | + $billing_form = $pm_type->billing_form(); |
|
633 | + // double-check the form isn't totally hidden, in which case pretend there is no form |
|
634 | + $form_totally_hidden = true; |
|
635 | + foreach ($billing_form->inputs_in_subsections() as $input) { |
|
636 | + if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
637 | + $form_totally_hidden = false; |
|
638 | + break; |
|
639 | + } |
|
640 | + } |
|
641 | + if ($form_totally_hidden) { |
|
642 | + return null; |
|
643 | + } |
|
644 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
645 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
646 | + } |
|
647 | + |
|
648 | + return $billing_form; |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
654 | + * specified payment method |
|
655 | + * |
|
656 | + * @param EE_Payment_Method $payment_method |
|
657 | + * @return string |
|
658 | + * @throws EE_Error |
|
659 | + */ |
|
660 | + public function get_billing_info_postmeta_name($payment_method) |
|
661 | + { |
|
662 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
663 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
664 | + } |
|
665 | + return null; |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + /** |
|
670 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
671 | + * retrieve it |
|
672 | + * |
|
673 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
674 | + * @param EE_Payment_Method $payment_method |
|
675 | + * @return boolean |
|
676 | + * @throws EE_Error |
|
677 | + */ |
|
678 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
679 | + { |
|
680 | + if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
681 | + EE_Error::add_error( |
|
682 | + esc_html__('Cannot save billing info because there is none.', 'event_espresso'), |
|
683 | + __FILE__, |
|
684 | + __FUNCTION__, |
|
685 | + __LINE__ |
|
686 | + ); |
|
687 | + return false; |
|
688 | + } |
|
689 | + $billing_form->clean_sensitive_data(); |
|
690 | + return update_post_meta( |
|
691 | + $this->ID(), |
|
692 | + $this->get_billing_info_postmeta_name($payment_method), |
|
693 | + $billing_form->input_values(true) |
|
694 | + ); |
|
695 | + } |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * Return the link to the admin details for the object. |
|
700 | + * |
|
701 | + * @return string |
|
702 | + * @throws EE_Error |
|
703 | + * @throws InvalidArgumentException |
|
704 | + * @throws InvalidDataTypeException |
|
705 | + * @throws InvalidInterfaceException |
|
706 | + * @throws ReflectionException |
|
707 | + */ |
|
708 | + public function get_admin_details_link() |
|
709 | + { |
|
710 | + return $this->get_admin_edit_link(); |
|
711 | + } |
|
712 | + |
|
713 | + |
|
714 | + /** |
|
715 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
716 | + * |
|
717 | + * @return string |
|
718 | + * @throws EE_Error |
|
719 | + * @throws InvalidArgumentException |
|
720 | + * @throws ReflectionException |
|
721 | + * @throws InvalidDataTypeException |
|
722 | + * @throws InvalidInterfaceException |
|
723 | + */ |
|
724 | + public function get_admin_edit_link() |
|
725 | + { |
|
726 | + EE_Registry::instance()->load_helper('URL'); |
|
727 | + return EEH_URL::add_query_args_and_nonce( |
|
728 | + array( |
|
729 | + 'page' => 'espresso_registrations', |
|
730 | + 'action' => 'edit_attendee', |
|
731 | + 'post' => $this->ID(), |
|
732 | + ), |
|
733 | + admin_url('admin.php') |
|
734 | + ); |
|
735 | + } |
|
736 | + |
|
737 | + |
|
738 | + /** |
|
739 | + * Returns the link to a settings page for the object. |
|
740 | + * |
|
741 | + * @return string |
|
742 | + * @throws EE_Error |
|
743 | + * @throws InvalidArgumentException |
|
744 | + * @throws InvalidDataTypeException |
|
745 | + * @throws InvalidInterfaceException |
|
746 | + * @throws ReflectionException |
|
747 | + */ |
|
748 | + public function get_admin_settings_link() |
|
749 | + { |
|
750 | + return $this->get_admin_edit_link(); |
|
751 | + } |
|
752 | + |
|
753 | + |
|
754 | + /** |
|
755 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
756 | + * |
|
757 | + * @return string |
|
758 | + * @throws EE_Error |
|
759 | + * @throws InvalidArgumentException |
|
760 | + * @throws ReflectionException |
|
761 | + * @throws InvalidDataTypeException |
|
762 | + * @throws InvalidInterfaceException |
|
763 | + */ |
|
764 | + public function get_admin_overview_link() |
|
765 | + { |
|
766 | + EE_Registry::instance()->load_helper('URL'); |
|
767 | + return EEH_URL::add_query_args_and_nonce( |
|
768 | + array( |
|
769 | + 'page' => 'espresso_registrations', |
|
770 | + 'action' => 'contact_list', |
|
771 | + ), |
|
772 | + admin_url('admin.php') |
|
773 | + ); |
|
774 | + } |
|
775 | 775 | } |