@@ -13,46 +13,46 @@ |
||
13 | 13 | class EE_Request_Stack_Builder |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * EE_Request_Stack_Builder |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - EE_Error::doing_it_wrong( |
|
22 | - __METHOD__, |
|
23 | - sprintf( |
|
24 | - esc_html__( |
|
25 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
26 | - 'event_espresso' |
|
27 | - ), |
|
28 | - 'EventEspresso\core\services\request\RequestStackBuilder', |
|
29 | - '\core\services\request', |
|
30 | - 'EventEspresso\core\services\request' |
|
31 | - ), |
|
32 | - '4.9.53' |
|
33 | - ); |
|
34 | - } |
|
16 | + /** |
|
17 | + * EE_Request_Stack_Builder |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + EE_Error::doing_it_wrong( |
|
22 | + __METHOD__, |
|
23 | + sprintf( |
|
24 | + esc_html__( |
|
25 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
26 | + 'event_espresso' |
|
27 | + ), |
|
28 | + 'EventEspresso\core\services\request\RequestStackBuilder', |
|
29 | + '\core\services\request', |
|
30 | + 'EventEspresso\core\services\request' |
|
31 | + ), |
|
32 | + '4.9.53' |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @deprecated 4.9.53 |
|
38 | - */ |
|
39 | - public function unshift() |
|
40 | - { |
|
41 | - } |
|
36 | + /** |
|
37 | + * @deprecated 4.9.53 |
|
38 | + */ |
|
39 | + public function unshift() |
|
40 | + { |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @deprecated 4.9.53 |
|
46 | - */ |
|
47 | - public function push() |
|
48 | - { |
|
49 | - } |
|
44 | + /** |
|
45 | + * @deprecated 4.9.53 |
|
46 | + */ |
|
47 | + public function push() |
|
48 | + { |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @deprecated 4.9.53 |
|
54 | - */ |
|
55 | - public function resolve(EEI_Request_Decorator $application) |
|
56 | - { |
|
57 | - } |
|
52 | + /** |
|
53 | + * @deprecated 4.9.53 |
|
54 | + */ |
|
55 | + public function resolve(EEI_Request_Decorator $application) |
|
56 | + { |
|
57 | + } |
|
58 | 58 | } |
@@ -13,25 +13,25 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @deprecated 4.9.53 |
|
18 | - * @param EEI_Request_Decorator $application |
|
19 | - * @param array $middlewares |
|
20 | - */ |
|
21 | - public function __construct(EEI_Request_Decorator $application, $middlewares = array()) |
|
22 | - { |
|
23 | - EE_Error::doing_it_wrong( |
|
24 | - __METHOD__, |
|
25 | - sprintf( |
|
26 | - esc_html__( |
|
27 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - 'EventEspresso\core\services\request\RequestStack', |
|
31 | - '\core\services\request', |
|
32 | - 'EventEspresso\core\services\request' |
|
33 | - ), |
|
34 | - '4.9.53' |
|
35 | - ); |
|
36 | - } |
|
16 | + /** |
|
17 | + * @deprecated 4.9.53 |
|
18 | + * @param EEI_Request_Decorator $application |
|
19 | + * @param array $middlewares |
|
20 | + */ |
|
21 | + public function __construct(EEI_Request_Decorator $application, $middlewares = array()) |
|
22 | + { |
|
23 | + EE_Error::doing_it_wrong( |
|
24 | + __METHOD__, |
|
25 | + sprintf( |
|
26 | + esc_html__( |
|
27 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + 'EventEspresso\core\services\request\RequestStack', |
|
31 | + '\core\services\request', |
|
32 | + 'EventEspresso\core\services\request' |
|
33 | + ), |
|
34 | + '4.9.53' |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | } |
@@ -12,184 +12,184 @@ |
||
12 | 12 | abstract class EES_Shortcode extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @protected public |
|
17 | - * @var array $_attributes |
|
18 | - */ |
|
19 | - protected $_attributes = array(); |
|
20 | - |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | - */ |
|
26 | - final public function __construct() |
|
27 | - { |
|
28 | - $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | - // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | - add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | - // make sure system knows this is an EE page |
|
32 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * run - initial shortcode module setup called during "parse_request" hook by |
|
39 | - * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request ! |
|
40 | - * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented |
|
41 | - * by a theme or plugin in a non-standard way. |
|
42 | - * Basically this method is primarily used for loading resources and assets like CSS or JS |
|
43 | - * that will be required by the shortcode when it is actually processed. |
|
44 | - * Please note that assets may not load if the fallback_shortcode_processor() is being used. |
|
45 | - * |
|
46 | - * @access public |
|
47 | - * @param WP $WP |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - abstract public function run(WP $WP); |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * process_shortcode |
|
56 | - * this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content |
|
57 | - * |
|
58 | - * @access public |
|
59 | - * @param array $attributes |
|
60 | - * @return mixed |
|
61 | - */ |
|
62 | - abstract public function process_shortcode($attributes = array()); |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * instance - returns instance of child class object |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @param string $shortcode_class |
|
71 | - * @return \EES_Shortcode |
|
72 | - */ |
|
73 | - final public static function instance($shortcode_class = null) |
|
74 | - { |
|
75 | - $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
76 | - if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
77 | - return null; |
|
78 | - } |
|
79 | - $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
80 | - $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode}) |
|
81 | - ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
82 | - : null; |
|
83 | - return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
|
84 | - ? $shortcode_obj |
|
85 | - : new $shortcode_class(); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * fallback_shortcode_processor - create instance and call process_shortcode |
|
93 | - * NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @param $attributes |
|
97 | - * @return mixed |
|
98 | - */ |
|
99 | - final public static function fallback_shortcode_processor($attributes) |
|
100 | - { |
|
101 | - if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
102 | - return null; |
|
103 | - } |
|
104 | - // what shortcode was actually parsed ? |
|
105 | - $shortcode_class = get_called_class(); |
|
106 | - // notify rest of system that fallback processor was triggered |
|
107 | - add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
108 | - // get instance of actual shortcode |
|
109 | - $shortcode_obj = self::instance($shortcode_class); |
|
110 | - // verify class |
|
111 | - if ($shortcode_obj instanceof EES_Shortcode) { |
|
112 | - global $wp; |
|
113 | - $shortcode_obj->run($wp); |
|
114 | - // set attributes and run the shortcode |
|
115 | - $shortcode_obj->_attributes = (array) $attributes; |
|
116 | - return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
117 | - } else { |
|
118 | - return null; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * invalid_shortcode_processor - used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param $attributes |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - final public static function invalid_shortcode_processor($attributes) |
|
133 | - { |
|
134 | - return ''; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Performs basic sanitization on shortcode attributes |
|
143 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
144 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
145 | - * This can be overridden by supplying an array for the $custom_sanitization param, |
|
146 | - * where keys match keys in your attributes array, |
|
147 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
148 | - * So for example, if you had an integer attribute named "event_id" |
|
149 | - * that you wanted to be sanitized using absint(), |
|
150 | - * then you would pass the following for your $custom_sanitization array: |
|
151 | - * array('event_id' => 'absint') |
|
152 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
153 | - * |
|
154 | - * @param array $attributes |
|
155 | - * @param array $custom_sanitization |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
159 | - { |
|
160 | - foreach ($attributes as $key => $value) { |
|
161 | - // is a custom sanitization callback specified ? |
|
162 | - if (isset($custom_sanitization[ $key ])) { |
|
163 | - $callback = $custom_sanitization[ $key ]; |
|
164 | - if ($callback === 'skip_sanitization') { |
|
165 | - $attributes[ $key ] = $value; |
|
166 | - continue; |
|
167 | - } elseif (function_exists($callback)) { |
|
168 | - $attributes[ $key ] = $callback($value); |
|
169 | - continue; |
|
170 | - } |
|
171 | - } |
|
172 | - switch (true) { |
|
173 | - case $value === null: |
|
174 | - case is_int($value): |
|
175 | - case is_float($value): |
|
176 | - // typical booleans |
|
177 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
|
178 | - $attributes[ $key ] = $value; |
|
179 | - break; |
|
180 | - case is_string($value): |
|
181 | - $attributes[ $key ] = sanitize_text_field($value); |
|
182 | - break; |
|
183 | - case is_array($value): |
|
184 | - $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | - break; |
|
186 | - default: |
|
187 | - // only remaining data types are Object and Resource |
|
188 | - // which are not allowed as shortcode attributes |
|
189 | - $attributes[ $key ] = null; |
|
190 | - break; |
|
191 | - } |
|
192 | - } |
|
193 | - return $attributes; |
|
194 | - } |
|
15 | + /** |
|
16 | + * @protected public |
|
17 | + * @var array $_attributes |
|
18 | + */ |
|
19 | + protected $_attributes = array(); |
|
20 | + |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | + */ |
|
26 | + final public function __construct() |
|
27 | + { |
|
28 | + $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | + // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | + // make sure system knows this is an EE page |
|
32 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * run - initial shortcode module setup called during "parse_request" hook by |
|
39 | + * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request ! |
|
40 | + * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented |
|
41 | + * by a theme or plugin in a non-standard way. |
|
42 | + * Basically this method is primarily used for loading resources and assets like CSS or JS |
|
43 | + * that will be required by the shortcode when it is actually processed. |
|
44 | + * Please note that assets may not load if the fallback_shortcode_processor() is being used. |
|
45 | + * |
|
46 | + * @access public |
|
47 | + * @param WP $WP |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + abstract public function run(WP $WP); |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * process_shortcode |
|
56 | + * this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content |
|
57 | + * |
|
58 | + * @access public |
|
59 | + * @param array $attributes |
|
60 | + * @return mixed |
|
61 | + */ |
|
62 | + abstract public function process_shortcode($attributes = array()); |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * instance - returns instance of child class object |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @param string $shortcode_class |
|
71 | + * @return \EES_Shortcode |
|
72 | + */ |
|
73 | + final public static function instance($shortcode_class = null) |
|
74 | + { |
|
75 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
76 | + if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
77 | + return null; |
|
78 | + } |
|
79 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
80 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode}) |
|
81 | + ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
82 | + : null; |
|
83 | + return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
|
84 | + ? $shortcode_obj |
|
85 | + : new $shortcode_class(); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * fallback_shortcode_processor - create instance and call process_shortcode |
|
93 | + * NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @param $attributes |
|
97 | + * @return mixed |
|
98 | + */ |
|
99 | + final public static function fallback_shortcode_processor($attributes) |
|
100 | + { |
|
101 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
102 | + return null; |
|
103 | + } |
|
104 | + // what shortcode was actually parsed ? |
|
105 | + $shortcode_class = get_called_class(); |
|
106 | + // notify rest of system that fallback processor was triggered |
|
107 | + add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
108 | + // get instance of actual shortcode |
|
109 | + $shortcode_obj = self::instance($shortcode_class); |
|
110 | + // verify class |
|
111 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
112 | + global $wp; |
|
113 | + $shortcode_obj->run($wp); |
|
114 | + // set attributes and run the shortcode |
|
115 | + $shortcode_obj->_attributes = (array) $attributes; |
|
116 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
117 | + } else { |
|
118 | + return null; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * invalid_shortcode_processor - used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param $attributes |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + final public static function invalid_shortcode_processor($attributes) |
|
133 | + { |
|
134 | + return ''; |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Performs basic sanitization on shortcode attributes |
|
143 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
144 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
145 | + * This can be overridden by supplying an array for the $custom_sanitization param, |
|
146 | + * where keys match keys in your attributes array, |
|
147 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
148 | + * So for example, if you had an integer attribute named "event_id" |
|
149 | + * that you wanted to be sanitized using absint(), |
|
150 | + * then you would pass the following for your $custom_sanitization array: |
|
151 | + * array('event_id' => 'absint') |
|
152 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
153 | + * |
|
154 | + * @param array $attributes |
|
155 | + * @param array $custom_sanitization |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
159 | + { |
|
160 | + foreach ($attributes as $key => $value) { |
|
161 | + // is a custom sanitization callback specified ? |
|
162 | + if (isset($custom_sanitization[ $key ])) { |
|
163 | + $callback = $custom_sanitization[ $key ]; |
|
164 | + if ($callback === 'skip_sanitization') { |
|
165 | + $attributes[ $key ] = $value; |
|
166 | + continue; |
|
167 | + } elseif (function_exists($callback)) { |
|
168 | + $attributes[ $key ] = $callback($value); |
|
169 | + continue; |
|
170 | + } |
|
171 | + } |
|
172 | + switch (true) { |
|
173 | + case $value === null: |
|
174 | + case is_int($value): |
|
175 | + case is_float($value): |
|
176 | + // typical booleans |
|
177 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
|
178 | + $attributes[ $key ] = $value; |
|
179 | + break; |
|
180 | + case is_string($value): |
|
181 | + $attributes[ $key ] = sanitize_text_field($value); |
|
182 | + break; |
|
183 | + case is_array($value): |
|
184 | + $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | + break; |
|
186 | + default: |
|
187 | + // only remaining data types are Object and Resource |
|
188 | + // which are not allowed as shortcode attributes |
|
189 | + $attributes[ $key ] = null; |
|
190 | + break; |
|
191 | + } |
|
192 | + } |
|
193 | + return $attributes; |
|
194 | + } |
|
195 | 195 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // what shortcode was actually parsed ? |
105 | 105 | $shortcode_class = get_called_class(); |
106 | 106 | // notify rest of system that fallback processor was triggered |
107 | - add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
107 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
108 | 108 | // get instance of actual shortcode |
109 | 109 | $shortcode_obj = self::instance($shortcode_class); |
110 | 110 | // verify class |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | { |
160 | 160 | foreach ($attributes as $key => $value) { |
161 | 161 | // is a custom sanitization callback specified ? |
162 | - if (isset($custom_sanitization[ $key ])) { |
|
163 | - $callback = $custom_sanitization[ $key ]; |
|
162 | + if (isset($custom_sanitization[$key])) { |
|
163 | + $callback = $custom_sanitization[$key]; |
|
164 | 164 | if ($callback === 'skip_sanitization') { |
165 | - $attributes[ $key ] = $value; |
|
165 | + $attributes[$key] = $value; |
|
166 | 166 | continue; |
167 | 167 | } elseif (function_exists($callback)) { |
168 | - $attributes[ $key ] = $callback($value); |
|
168 | + $attributes[$key] = $callback($value); |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | } |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | case is_float($value): |
176 | 176 | // typical booleans |
177 | 177 | case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
178 | - $attributes[ $key ] = $value; |
|
178 | + $attributes[$key] = $value; |
|
179 | 179 | break; |
180 | 180 | case is_string($value): |
181 | - $attributes[ $key ] = sanitize_text_field($value); |
|
181 | + $attributes[$key] = sanitize_text_field($value); |
|
182 | 182 | break; |
183 | 183 | case is_array($value): |
184 | - $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
184 | + $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | 185 | break; |
186 | 186 | default: |
187 | 187 | // only remaining data types are Object and Resource |
188 | 188 | // which are not allowed as shortcode attributes |
189 | - $attributes[ $key ] = null; |
|
189 | + $attributes[$key] = null; |
|
190 | 190 | break; |
191 | 191 | } |
192 | 192 | } |
@@ -16,108 +16,108 @@ |
||
16 | 16 | abstract class EE_Base_Class_Repository extends EE_Object_Repository implements EEI_Deletable |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * EE_Base_Class_Repository constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->persist_method = 'save'; |
|
25 | - } |
|
19 | + /** |
|
20 | + * EE_Base_Class_Repository constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->persist_method = 'save'; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * save |
|
30 | - * |
|
31 | - * calls EE_Base_Class::save() on the current object |
|
32 | - * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(), |
|
33 | - * where each element of the $arguments array corresponds to a parameter for the callback method |
|
34 | - * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
35 | - * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @param array $arguments arrays of arguments that will be passed to the object's save method |
|
39 | - * @return bool | int |
|
40 | - */ |
|
41 | - public function save($arguments = array()) |
|
42 | - { |
|
43 | - return $this->persist('save', $arguments); |
|
44 | - } |
|
28 | + /** |
|
29 | + * save |
|
30 | + * |
|
31 | + * calls EE_Base_Class::save() on the current object |
|
32 | + * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(), |
|
33 | + * where each element of the $arguments array corresponds to a parameter for the callback method |
|
34 | + * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
35 | + * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param array $arguments arrays of arguments that will be passed to the object's save method |
|
39 | + * @return bool | int |
|
40 | + */ |
|
41 | + public function save($arguments = array()) |
|
42 | + { |
|
43 | + return $this->persist('save', $arguments); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * save_all |
|
49 | - * |
|
50 | - * calls EE_Base_Class::save() on ALL objects in the repository |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return bool | int |
|
54 | - */ |
|
55 | - public function save_all() |
|
56 | - { |
|
57 | - return $this->persist_all('save'); |
|
58 | - } |
|
47 | + /** |
|
48 | + * save_all |
|
49 | + * |
|
50 | + * calls EE_Base_Class::save() on ALL objects in the repository |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return bool | int |
|
54 | + */ |
|
55 | + public function save_all() |
|
56 | + { |
|
57 | + return $this->persist_all('save'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Calls EE_Base_Class::delete() on the current object |
|
63 | - * Keep in mind that this always detaches the object from the collection |
|
64 | - * regardless of whether the delete was successful for the db. This is because |
|
65 | - * its possible that the object ONLY existed in the collection. |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function delete() |
|
71 | - { |
|
72 | - $success = $this->_call_user_func_array_on_current('delete'); |
|
73 | - $this->remove($this->current()); |
|
74 | - return $success; |
|
75 | - } |
|
61 | + /** |
|
62 | + * Calls EE_Base_Class::delete() on the current object |
|
63 | + * Keep in mind that this always detaches the object from the collection |
|
64 | + * regardless of whether the delete was successful for the db. This is because |
|
65 | + * its possible that the object ONLY existed in the collection. |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function delete() |
|
71 | + { |
|
72 | + $success = $this->_call_user_func_array_on_current('delete'); |
|
73 | + $this->remove($this->current()); |
|
74 | + return $success; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * delete_all |
|
80 | - * |
|
81 | - * calls EE_Base_Class::delete() on ALL objects in the repository |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - public function delete_all() |
|
87 | - { |
|
88 | - $success = true; |
|
89 | - $this->rewind(); |
|
90 | - while ($this->valid()) { |
|
91 | - // any db error will result in false being returned |
|
92 | - $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false; |
|
93 | - // can't remove current object because valid() requires it |
|
94 | - // so just capture current object temporarily |
|
95 | - $object = $this->current(); |
|
96 | - // advance the pointer |
|
97 | - $this->next(); |
|
98 | - // THEN remove the object from the repository |
|
99 | - $this->remove($object); |
|
100 | - } |
|
101 | - return $success; |
|
102 | - } |
|
78 | + /** |
|
79 | + * delete_all |
|
80 | + * |
|
81 | + * calls EE_Base_Class::delete() on ALL objects in the repository |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + public function delete_all() |
|
87 | + { |
|
88 | + $success = true; |
|
89 | + $this->rewind(); |
|
90 | + while ($this->valid()) { |
|
91 | + // any db error will result in false being returned |
|
92 | + $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false; |
|
93 | + // can't remove current object because valid() requires it |
|
94 | + // so just capture current object temporarily |
|
95 | + $object = $this->current(); |
|
96 | + // advance the pointer |
|
97 | + $this->next(); |
|
98 | + // THEN remove the object from the repository |
|
99 | + $this->remove($object); |
|
100 | + } |
|
101 | + return $success; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * update_extra_meta |
|
107 | - * |
|
108 | - * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @param string $meta_key |
|
112 | - * @param string $meta_value |
|
113 | - * @param string $previous_value |
|
114 | - * @return bool | int |
|
115 | - */ |
|
116 | - public function update_extra_meta($meta_key, $meta_value, $previous_value = null) |
|
117 | - { |
|
118 | - return $this->_call_user_func_array_on_current( |
|
119 | - 'update_extra_meta', |
|
120 | - array($meta_key, $meta_value, $previous_value) |
|
121 | - ); |
|
122 | - } |
|
105 | + /** |
|
106 | + * update_extra_meta |
|
107 | + * |
|
108 | + * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @param string $meta_key |
|
112 | + * @param string $meta_value |
|
113 | + * @param string $previous_value |
|
114 | + * @return bool | int |
|
115 | + */ |
|
116 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = null) |
|
117 | + { |
|
118 | + return $this->_call_user_func_array_on_current( |
|
119 | + 'update_extra_meta', |
|
120 | + array($meta_key, $meta_value, $previous_value) |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | } |
@@ -10,143 +10,143 @@ |
||
10 | 10 | abstract class EE_Configurable extends EE_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @var $_config |
|
15 | - * @type EE_Config_Base |
|
16 | - */ |
|
17 | - protected $_config; |
|
18 | - |
|
19 | - /** |
|
20 | - * @var $_config_section |
|
21 | - * @type string |
|
22 | - */ |
|
23 | - protected $_config_section = ''; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var $_config_class |
|
27 | - * @type string |
|
28 | - */ |
|
29 | - protected $_config_class = ''; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var $_config_name |
|
33 | - * @type string |
|
34 | - */ |
|
35 | - protected $_config_name = ''; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $config_section |
|
40 | - */ |
|
41 | - public function set_config_section($config_section = '') |
|
42 | - { |
|
43 | - $this->_config_section = ! empty($config_section) ? $config_section : 'modules'; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @return mixed |
|
49 | - */ |
|
50 | - public function config_section() |
|
51 | - { |
|
52 | - return $this->_config_section; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @param string $config_class |
|
58 | - */ |
|
59 | - public function set_config_class($config_class = '') |
|
60 | - { |
|
61 | - $this->_config_class = $config_class; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @return mixed |
|
67 | - */ |
|
68 | - public function config_class() |
|
69 | - { |
|
70 | - return $this->_config_class; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param mixed $config_name |
|
76 | - */ |
|
77 | - public function set_config_name($config_name) |
|
78 | - { |
|
79 | - $this->_config_name = ! empty($config_name) ? $config_name : get_called_class(); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @return mixed |
|
85 | - */ |
|
86 | - public function config_name() |
|
87 | - { |
|
88 | - return $this->_config_name; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * set_config |
|
94 | - * this method integrates directly with EE_Config to set up the config object for this class |
|
95 | - * |
|
96 | - * @access protected |
|
97 | - * @param EE_Config_Base $config_obj |
|
98 | - * @return mixed EE_Config_Base | NULL |
|
99 | - */ |
|
100 | - protected function _set_config(EE_Config_Base $config_obj = null) |
|
101 | - { |
|
102 | - return EE_Config::instance()->set_config( |
|
103 | - $this->config_section(), |
|
104 | - $this->config_name(), |
|
105 | - $this->config_class(), |
|
106 | - $config_obj |
|
107 | - ); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * _update_config |
|
113 | - * this method integrates directly with EE_Config to update an existing config object for this class |
|
114 | - * |
|
115 | - * @access protected |
|
116 | - * @param EE_Config_Base $config_obj |
|
117 | - * @throws \EE_Error |
|
118 | - * @return mixed EE_Config_Base | NULL |
|
119 | - */ |
|
120 | - public function _update_config(EE_Config_Base $config_obj = null) |
|
121 | - { |
|
122 | - $config_class = $this->config_class(); |
|
123 | - if (! $config_obj instanceof $config_class) { |
|
124 | - throw new EE_Error( |
|
125 | - sprintf( |
|
126 | - __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
127 | - print_r($config_obj, true), |
|
128 | - $config_class |
|
129 | - ) |
|
130 | - ); |
|
131 | - } |
|
132 | - return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * gets the class's config object |
|
138 | - * |
|
139 | - * @return EE_Config_Base |
|
140 | - */ |
|
141 | - public function config() |
|
142 | - { |
|
143 | - if (empty($this->_config)) { |
|
144 | - $this->_config = EE_Config::instance()->get_config( |
|
145 | - $this->config_section(), |
|
146 | - $this->config_name(), |
|
147 | - $this->config_class() |
|
148 | - ); |
|
149 | - } |
|
150 | - return $this->_config; |
|
151 | - } |
|
13 | + /** |
|
14 | + * @var $_config |
|
15 | + * @type EE_Config_Base |
|
16 | + */ |
|
17 | + protected $_config; |
|
18 | + |
|
19 | + /** |
|
20 | + * @var $_config_section |
|
21 | + * @type string |
|
22 | + */ |
|
23 | + protected $_config_section = ''; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var $_config_class |
|
27 | + * @type string |
|
28 | + */ |
|
29 | + protected $_config_class = ''; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var $_config_name |
|
33 | + * @type string |
|
34 | + */ |
|
35 | + protected $_config_name = ''; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $config_section |
|
40 | + */ |
|
41 | + public function set_config_section($config_section = '') |
|
42 | + { |
|
43 | + $this->_config_section = ! empty($config_section) ? $config_section : 'modules'; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @return mixed |
|
49 | + */ |
|
50 | + public function config_section() |
|
51 | + { |
|
52 | + return $this->_config_section; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @param string $config_class |
|
58 | + */ |
|
59 | + public function set_config_class($config_class = '') |
|
60 | + { |
|
61 | + $this->_config_class = $config_class; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @return mixed |
|
67 | + */ |
|
68 | + public function config_class() |
|
69 | + { |
|
70 | + return $this->_config_class; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param mixed $config_name |
|
76 | + */ |
|
77 | + public function set_config_name($config_name) |
|
78 | + { |
|
79 | + $this->_config_name = ! empty($config_name) ? $config_name : get_called_class(); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @return mixed |
|
85 | + */ |
|
86 | + public function config_name() |
|
87 | + { |
|
88 | + return $this->_config_name; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * set_config |
|
94 | + * this method integrates directly with EE_Config to set up the config object for this class |
|
95 | + * |
|
96 | + * @access protected |
|
97 | + * @param EE_Config_Base $config_obj |
|
98 | + * @return mixed EE_Config_Base | NULL |
|
99 | + */ |
|
100 | + protected function _set_config(EE_Config_Base $config_obj = null) |
|
101 | + { |
|
102 | + return EE_Config::instance()->set_config( |
|
103 | + $this->config_section(), |
|
104 | + $this->config_name(), |
|
105 | + $this->config_class(), |
|
106 | + $config_obj |
|
107 | + ); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * _update_config |
|
113 | + * this method integrates directly with EE_Config to update an existing config object for this class |
|
114 | + * |
|
115 | + * @access protected |
|
116 | + * @param EE_Config_Base $config_obj |
|
117 | + * @throws \EE_Error |
|
118 | + * @return mixed EE_Config_Base | NULL |
|
119 | + */ |
|
120 | + public function _update_config(EE_Config_Base $config_obj = null) |
|
121 | + { |
|
122 | + $config_class = $this->config_class(); |
|
123 | + if (! $config_obj instanceof $config_class) { |
|
124 | + throw new EE_Error( |
|
125 | + sprintf( |
|
126 | + __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
127 | + print_r($config_obj, true), |
|
128 | + $config_class |
|
129 | + ) |
|
130 | + ); |
|
131 | + } |
|
132 | + return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * gets the class's config object |
|
138 | + * |
|
139 | + * @return EE_Config_Base |
|
140 | + */ |
|
141 | + public function config() |
|
142 | + { |
|
143 | + if (empty($this->_config)) { |
|
144 | + $this->_config = EE_Config::instance()->get_config( |
|
145 | + $this->config_section(), |
|
146 | + $this->config_name(), |
|
147 | + $this->config_class() |
|
148 | + ); |
|
149 | + } |
|
150 | + return $this->_config; |
|
151 | + } |
|
152 | 152 | } |
@@ -120,7 +120,7 @@ |
||
120 | 120 | public function _update_config(EE_Config_Base $config_obj = null) |
121 | 121 | { |
122 | 122 | $config_class = $this->config_class(); |
123 | - if (! $config_obj instanceof $config_class) { |
|
123 | + if ( ! $config_obj instanceof $config_class) { |
|
124 | 124 | throw new EE_Error( |
125 | 125 | sprintf( |
126 | 126 | __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
@@ -10,128 +10,128 @@ |
||
10 | 10 | class EEM_Term_Taxonomy extends EEM_Base |
11 | 11 | { |
12 | 12 | |
13 | - // private instance of the Attendee object |
|
14 | - protected static $_instance = null; |
|
13 | + // private instance of the Attendee object |
|
14 | + protected static $_instance = null; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | - protected function __construct($timezone = null) |
|
19 | - { |
|
20 | - $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
|
21 | - $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
|
22 | - $this->_tables = array( |
|
23 | - 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
|
24 | - ); |
|
25 | - $this->_fields = array( |
|
26 | - 'Term_Taxonomy' => array( |
|
27 | - 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
|
28 | - 'term_taxonomy_id', |
|
29 | - __('Term-Taxonomy ID', 'event_espresso') |
|
30 | - ), |
|
31 | - 'term_id' => new EE_Foreign_Key_Int_Field( |
|
32 | - 'term_id', |
|
33 | - __("Term Id", "event_espresso"), |
|
34 | - false, |
|
35 | - 0, |
|
36 | - 'Term' |
|
37 | - ), |
|
38 | - 'taxonomy' => new EE_Plain_Text_Field( |
|
39 | - 'taxonomy', |
|
40 | - __('Taxonomy Name', 'event_espresso'), |
|
41 | - false, |
|
42 | - 'category' |
|
43 | - ), |
|
44 | - 'description' => new EE_Post_Content_Field( |
|
45 | - 'description', |
|
46 | - __("Description of Term", "event_espresso"), |
|
47 | - false, |
|
48 | - '' |
|
49 | - ), |
|
50 | - 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
|
51 | - 'term_count' => new EE_Integer_Field( |
|
52 | - 'count', |
|
53 | - __("Count of Objects attached", 'event_espresso'), |
|
54 | - false, |
|
55 | - 0 |
|
56 | - ), |
|
57 | - ), |
|
58 | - ); |
|
59 | - $this->_model_relations = array( |
|
60 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
61 | - 'Term' => new EE_Belongs_To_Relation(), |
|
62 | - ); |
|
63 | - $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
64 | - foreach ($cpt_models as $model_name) { |
|
65 | - $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship'); |
|
66 | - } |
|
67 | - $this->_wp_core_model = true; |
|
68 | - $this->_indexes = array( |
|
69 | - 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
|
70 | - ); |
|
71 | - $path_to_tax_model = ''; |
|
72 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
73 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
74 | - $path_to_tax_model |
|
75 | - ); |
|
76 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
77 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
78 | - // add cap restrictions for editing relating to the "ee_edit_*" |
|
79 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
80 | - array( |
|
81 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
82 | - ) |
|
83 | - ); |
|
84 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
85 | - array( |
|
86 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
87 | - ) |
|
88 | - ); |
|
89 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
90 | - array( |
|
91 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
92 | - ) |
|
93 | - ); |
|
94 | - // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
95 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
96 | - array( |
|
97 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
98 | - ) |
|
99 | - ); |
|
100 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
101 | - array( |
|
102 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
103 | - ) |
|
104 | - ); |
|
105 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
106 | - array( |
|
107 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
108 | - ) |
|
109 | - ); |
|
110 | - parent::__construct($timezone); |
|
111 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
|
112 | - } |
|
18 | + protected function __construct($timezone = null) |
|
19 | + { |
|
20 | + $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
|
21 | + $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
|
22 | + $this->_tables = array( |
|
23 | + 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
|
24 | + ); |
|
25 | + $this->_fields = array( |
|
26 | + 'Term_Taxonomy' => array( |
|
27 | + 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
|
28 | + 'term_taxonomy_id', |
|
29 | + __('Term-Taxonomy ID', 'event_espresso') |
|
30 | + ), |
|
31 | + 'term_id' => new EE_Foreign_Key_Int_Field( |
|
32 | + 'term_id', |
|
33 | + __("Term Id", "event_espresso"), |
|
34 | + false, |
|
35 | + 0, |
|
36 | + 'Term' |
|
37 | + ), |
|
38 | + 'taxonomy' => new EE_Plain_Text_Field( |
|
39 | + 'taxonomy', |
|
40 | + __('Taxonomy Name', 'event_espresso'), |
|
41 | + false, |
|
42 | + 'category' |
|
43 | + ), |
|
44 | + 'description' => new EE_Post_Content_Field( |
|
45 | + 'description', |
|
46 | + __("Description of Term", "event_espresso"), |
|
47 | + false, |
|
48 | + '' |
|
49 | + ), |
|
50 | + 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
|
51 | + 'term_count' => new EE_Integer_Field( |
|
52 | + 'count', |
|
53 | + __("Count of Objects attached", 'event_espresso'), |
|
54 | + false, |
|
55 | + 0 |
|
56 | + ), |
|
57 | + ), |
|
58 | + ); |
|
59 | + $this->_model_relations = array( |
|
60 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
61 | + 'Term' => new EE_Belongs_To_Relation(), |
|
62 | + ); |
|
63 | + $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
64 | + foreach ($cpt_models as $model_name) { |
|
65 | + $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship'); |
|
66 | + } |
|
67 | + $this->_wp_core_model = true; |
|
68 | + $this->_indexes = array( |
|
69 | + 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
|
70 | + ); |
|
71 | + $path_to_tax_model = ''; |
|
72 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
73 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
74 | + $path_to_tax_model |
|
75 | + ); |
|
76 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
77 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
78 | + // add cap restrictions for editing relating to the "ee_edit_*" |
|
79 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
80 | + array( |
|
81 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
82 | + ) |
|
83 | + ); |
|
84 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
85 | + array( |
|
86 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
87 | + ) |
|
88 | + ); |
|
89 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
90 | + array( |
|
91 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
92 | + ) |
|
93 | + ); |
|
94 | + // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
95 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
96 | + array( |
|
97 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
98 | + ) |
|
99 | + ); |
|
100 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
101 | + array( |
|
102 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
103 | + ) |
|
104 | + ); |
|
105 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
106 | + array( |
|
107 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
108 | + ) |
|
109 | + ); |
|
110 | + parent::__construct($timezone); |
|
111 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Makes sure that during REST API queries, we only return term-taxonomies |
|
118 | - * for term taxonomies which should be shown in the rest api |
|
119 | - * |
|
120 | - * @param array $model_query_params |
|
121 | - * @param array $querystring_query_params |
|
122 | - * @param EEM_Base $model |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
126 | - { |
|
127 | - if ($model === EEM_Term_Taxonomy::instance()) { |
|
128 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
129 | - if (! empty($taxonomies)) { |
|
130 | - $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
|
131 | - } |
|
132 | - } |
|
133 | - return $model_query_params; |
|
134 | - } |
|
116 | + /** |
|
117 | + * Makes sure that during REST API queries, we only return term-taxonomies |
|
118 | + * for term taxonomies which should be shown in the rest api |
|
119 | + * |
|
120 | + * @param array $model_query_params |
|
121 | + * @param array $querystring_query_params |
|
122 | + * @param EEM_Base $model |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
126 | + { |
|
127 | + if ($model === EEM_Term_Taxonomy::instance()) { |
|
128 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
129 | + if (! empty($taxonomies)) { |
|
130 | + $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
|
131 | + } |
|
132 | + } |
|
133 | + return $model_query_params; |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | // End of file EEM_Term_Taxonomy.model.php |
137 | 137 | // Location: /includes/models/EEM_Term_Taxonomy.model.php |
@@ -62,49 +62,49 @@ discard block |
||
62 | 62 | ); |
63 | 63 | $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
64 | 64 | foreach ($cpt_models as $model_name) { |
65 | - $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship'); |
|
65 | + $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
|
66 | 66 | } |
67 | 67 | $this->_wp_core_model = true; |
68 | 68 | $this->_indexes = array( |
69 | 69 | 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
70 | 70 | ); |
71 | 71 | $path_to_tax_model = ''; |
72 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
73 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
72 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
73 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
74 | 74 | $path_to_tax_model |
75 | 75 | ); |
76 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
77 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
76 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
77 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
78 | 78 | // add cap restrictions for editing relating to the "ee_edit_*" |
79 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
79 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
80 | 80 | array( |
81 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
81 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
82 | 82 | ) |
83 | 83 | ); |
84 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
84 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
85 | 85 | array( |
86 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
86 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
87 | 87 | ) |
88 | 88 | ); |
89 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
89 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
90 | 90 | array( |
91 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
91 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | // add cap restrictions for deleting relating to the "ee_deleting_*" |
95 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
95 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
96 | 96 | array( |
97 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
97 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
98 | 98 | ) |
99 | 99 | ); |
100 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
100 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
101 | 101 | array( |
102 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
102 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
103 | 103 | ) |
104 | 104 | ); |
105 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
105 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
106 | 106 | array( |
107 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
107 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
108 | 108 | ) |
109 | 109 | ); |
110 | 110 | parent::__construct($timezone); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | if ($model === EEM_Term_Taxonomy::instance()) { |
128 | 128 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
129 | - if (! empty($taxonomies)) { |
|
129 | + if ( ! empty($taxonomies)) { |
|
130 | 130 | $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
131 | 131 | } |
132 | 132 | } |
@@ -38,10 +38,10 @@ |
||
38 | 38 | )); |
39 | 39 | $this->_model_relations = array(); |
40 | 40 | foreach ($models_this_can_attach_to as $model) { |
41 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
41 | + $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
|
42 | 42 | } |
43 | 43 | foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
44 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
44 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
45 | 45 | } |
46 | 46 | parent::__construct($timezone); |
47 | 47 | } |
@@ -17,33 +17,33 @@ |
||
17 | 17 | class EEM_Extra_Meta extends EEM_Base |
18 | 18 | { |
19 | 19 | |
20 | - // private instance of the Attendee object |
|
21 | - protected static $_instance = null; |
|
20 | + // private instance of the Attendee object |
|
21 | + protected static $_instance = null; |
|
22 | 22 | |
23 | - protected function __construct($timezone = null) |
|
24 | - { |
|
25 | - $this->singular_item = __('Extra Meta', 'event_espresso'); |
|
26 | - $this->plural_item = __('Extra Metas', 'event_espresso'); |
|
27 | - $this->_tables = array( |
|
28 | - 'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
|
29 | - ); |
|
30 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
31 | - $this->_fields = array( |
|
32 | - 'Extra_Meta' => array( |
|
33 | - 'EXM_ID' => new EE_Primary_Key_Int_Field('EXM_ID', __("Extra Meta ID", "event_espresso")), |
|
34 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to), |
|
35 | - 'EXM_type' => new EE_Any_Foreign_Model_Name_Field('EXM_type', __("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to), |
|
36 | - 'EXM_key' => new EE_Plain_Text_Field('EXM_key', __("Meta Key", "event_espresso"), false, ''), |
|
37 | - 'EXM_value' => new EE_Maybe_Serialized_Text_Field('EXM_value', __("Meta Value", "event_espresso"), true) |
|
23 | + protected function __construct($timezone = null) |
|
24 | + { |
|
25 | + $this->singular_item = __('Extra Meta', 'event_espresso'); |
|
26 | + $this->plural_item = __('Extra Metas', 'event_espresso'); |
|
27 | + $this->_tables = array( |
|
28 | + 'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
|
29 | + ); |
|
30 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
31 | + $this->_fields = array( |
|
32 | + 'Extra_Meta' => array( |
|
33 | + 'EXM_ID' => new EE_Primary_Key_Int_Field('EXM_ID', __("Extra Meta ID", "event_espresso")), |
|
34 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to), |
|
35 | + 'EXM_type' => new EE_Any_Foreign_Model_Name_Field('EXM_type', __("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to), |
|
36 | + 'EXM_key' => new EE_Plain_Text_Field('EXM_key', __("Meta Key", "event_espresso"), false, ''), |
|
37 | + 'EXM_value' => new EE_Maybe_Serialized_Text_Field('EXM_value', __("Meta Value", "event_espresso"), true) |
|
38 | 38 | |
39 | - )); |
|
40 | - $this->_model_relations = array(); |
|
41 | - foreach ($models_this_can_attach_to as $model) { |
|
42 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
43 | - } |
|
44 | - foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
45 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
46 | - } |
|
47 | - parent::__construct($timezone); |
|
48 | - } |
|
39 | + )); |
|
40 | + $this->_model_relations = array(); |
|
41 | + foreach ($models_this_can_attach_to as $model) { |
|
42 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
43 | + } |
|
44 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
45 | + $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
46 | + } |
|
47 | + parent::__construct($timezone); |
|
48 | + } |
|
49 | 49 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function get_attendee_field_for_system_question($system_question_string) |
286 | 286 | { |
287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
287 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
288 | + ? $this->_system_question_to_attendee_field_name[$system_question_string] |
|
289 | 289 | : null; |
290 | 290 | } |
291 | 291 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | $attendee = $this->get_all(array($where_cols_n_values)); |
356 | - if (! empty($attendee)) { |
|
356 | + if ( ! empty($attendee)) { |
|
357 | 357 | return array_shift($attendee); |
358 | 358 | } |
359 | 359 | return false; |
@@ -12,432 +12,432 @@ |
||
12 | 12 | class EEM_Attendee extends EEM_CPT_Base |
13 | 13 | { |
14 | 14 | |
15 | - // private instance of the Attendee object |
|
16 | - protected static $_instance = null; |
|
15 | + // private instance of the Attendee object |
|
16 | + protected static $_instance = null; |
|
17 | 17 | |
18 | - /** |
|
19 | - * QST_system for questions are strings not integers now, |
|
20 | - * so these constants are deprecated. |
|
21 | - * Please instead use the EEM_Attendee::system_question_* constants |
|
22 | - * |
|
23 | - * @deprecated |
|
24 | - */ |
|
25 | - const fname_question_id = 1; |
|
18 | + /** |
|
19 | + * QST_system for questions are strings not integers now, |
|
20 | + * so these constants are deprecated. |
|
21 | + * Please instead use the EEM_Attendee::system_question_* constants |
|
22 | + * |
|
23 | + * @deprecated |
|
24 | + */ |
|
25 | + const fname_question_id = 1; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @deprecated |
|
29 | - */ |
|
30 | - const lname_question_id = 2; |
|
27 | + /** |
|
28 | + * @deprecated |
|
29 | + */ |
|
30 | + const lname_question_id = 2; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @deprecated |
|
35 | - */ |
|
36 | - const email_question_id = 3; |
|
33 | + /** |
|
34 | + * @deprecated |
|
35 | + */ |
|
36 | + const email_question_id = 3; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @deprecated |
|
41 | - */ |
|
42 | - const address_question_id = 4; |
|
39 | + /** |
|
40 | + * @deprecated |
|
41 | + */ |
|
42 | + const address_question_id = 4; |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @deprecated |
|
47 | - */ |
|
48 | - const address2_question_id = 5; |
|
45 | + /** |
|
46 | + * @deprecated |
|
47 | + */ |
|
48 | + const address2_question_id = 5; |
|
49 | 49 | |
50 | - |
|
51 | - /** |
|
52 | - * @deprecated |
|
53 | - */ |
|
54 | - const city_question_id = 6; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @deprecated |
|
59 | - */ |
|
60 | - const state_question_id = 7; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @deprecated |
|
65 | - */ |
|
66 | - const country_question_id = 8; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @deprecated |
|
71 | - */ |
|
72 | - const zip_question_id = 9; |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @deprecated |
|
77 | - */ |
|
78 | - const phone_question_id = 10; |
|
79 | - |
|
80 | - /** |
|
81 | - * When looking for questions that correspond to attendee fields, |
|
82 | - * look for the question with this QST_system value. |
|
83 | - * These replace the old constants like EEM_Attendee::*_question_id |
|
84 | - */ |
|
85 | - const system_question_fname = 'fname'; |
|
86 | - |
|
87 | - const system_question_lname = 'lname'; |
|
88 | - |
|
89 | - const system_question_email = 'email'; |
|
90 | - |
|
91 | - const system_question_email_confirm = 'email_confirm'; |
|
92 | - |
|
93 | - const system_question_address = 'address'; |
|
94 | - |
|
95 | - const system_question_address2 = 'address2'; |
|
96 | - |
|
97 | - const system_question_city = 'city'; |
|
98 | - |
|
99 | - const system_question_state = 'state'; |
|
100 | - |
|
101 | - const system_question_country = 'country'; |
|
102 | - |
|
103 | - const system_question_zip = 'zip'; |
|
104 | - |
|
105 | - const system_question_phone = 'phone'; |
|
106 | - |
|
107 | - /** |
|
108 | - * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
109 | - * also all the values of QST_system in the questions table, and values |
|
110 | - * are their corresponding Attendee field names |
|
111 | - * |
|
112 | - * @var array |
|
113 | - */ |
|
114 | - protected $_system_question_to_attendee_field_name = array( |
|
115 | - EEM_Attendee::system_question_fname => 'ATT_fname', |
|
116 | - EEM_Attendee::system_question_lname => 'ATT_lname', |
|
117 | - EEM_Attendee::system_question_email => 'ATT_email', |
|
118 | - EEM_Attendee::system_question_address => 'ATT_address', |
|
119 | - EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
120 | - EEM_Attendee::system_question_city => 'ATT_city', |
|
121 | - EEM_Attendee::system_question_state => 'STA_ID', |
|
122 | - EEM_Attendee::system_question_country => 'CNT_ISO', |
|
123 | - EEM_Attendee::system_question_zip => 'ATT_zip', |
|
124 | - EEM_Attendee::system_question_phone => 'ATT_phone', |
|
125 | - ); |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * EEM_Attendee constructor. |
|
131 | - * |
|
132 | - * @param null $timezone |
|
133 | - * @param ModelFieldFactory $model_field_factory |
|
134 | - * @throws EE_Error |
|
135 | - * @throws InvalidArgumentException |
|
136 | - */ |
|
137 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
138 | - { |
|
139 | - $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
140 | - $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
141 | - $this->_tables = array( |
|
142 | - 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
143 | - 'Attendee_Meta' => new EE_Secondary_Table( |
|
144 | - 'esp_attendee_meta', |
|
145 | - 'ATTM_ID', |
|
146 | - 'ATT_ID' |
|
147 | - ), |
|
148 | - ); |
|
149 | - $this->_fields = array( |
|
150 | - 'Attendee_CPT' => array( |
|
151 | - 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
152 | - 'ID', |
|
153 | - esc_html__('Attendee ID', 'event_espresso') |
|
154 | - ), |
|
155 | - 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
156 | - 'post_title', |
|
157 | - esc_html__('Attendee Full Name', 'event_espresso'), |
|
158 | - false, |
|
159 | - esc_html__('Unknown', 'event_espresso') |
|
160 | - ), |
|
161 | - 'ATT_bio' => $model_field_factory->createPostContentField( |
|
162 | - 'post_content', |
|
163 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
164 | - false, |
|
165 | - esc_html__('No Biography Provided', 'event_espresso') |
|
166 | - ), |
|
167 | - 'ATT_slug' => $model_field_factory->createSlugField( |
|
168 | - 'post_name', |
|
169 | - esc_html__('Attendee URL Slug', 'event_espresso') |
|
170 | - ), |
|
171 | - 'ATT_created' => $model_field_factory->createDatetimeField( |
|
172 | - 'post_date', |
|
173 | - esc_html__('Time Attendee Created', 'event_espresso') |
|
174 | - ), |
|
175 | - 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
176 | - 'post_excerpt', |
|
177 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
178 | - true, |
|
179 | - esc_html__('No Biography Provided', 'event_espresso') |
|
180 | - ), |
|
181 | - 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
182 | - 'post_modified', |
|
183 | - esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
184 | - ), |
|
185 | - 'ATT_author' => $model_field_factory->createWpUserField( |
|
186 | - 'post_author', |
|
187 | - esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
188 | - false |
|
189 | - ), |
|
190 | - 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
191 | - 'post_parent', |
|
192 | - esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
193 | - false, |
|
194 | - 0 |
|
195 | - ), |
|
196 | - 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
197 | - 'status' => $model_field_factory->createWpPostStatusField( |
|
198 | - 'post_status', |
|
199 | - esc_html__('Attendee Status', 'event_espresso'), |
|
200 | - false, |
|
201 | - 'publish' |
|
202 | - ), |
|
203 | - 'password' => new EE_Password_Field( |
|
204 | - 'post_password', |
|
205 | - __('Password', 'event_espresso'), |
|
206 | - false, |
|
207 | - '', |
|
208 | - array( |
|
209 | - 'ATT_bio', |
|
210 | - 'ATT_short_bio', |
|
211 | - 'ATT_address', |
|
212 | - 'ATT_address2', |
|
213 | - 'ATT_city', |
|
214 | - 'STA_ID', |
|
215 | - 'CNT_ISO', |
|
216 | - 'ATT_zip', |
|
217 | - 'ATT_email', |
|
218 | - 'ATT_phone' |
|
219 | - ) |
|
220 | - ) |
|
221 | - ), |
|
222 | - 'Attendee_Meta' => array( |
|
223 | - 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
224 | - 'ATTM_ID', |
|
225 | - esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
226 | - false |
|
227 | - ), |
|
228 | - 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
229 | - 'ATT_ID', |
|
230 | - esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
231 | - false |
|
232 | - ), |
|
233 | - 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
234 | - 'ATT_fname', |
|
235 | - esc_html__('First Name', 'event_espresso') |
|
236 | - ), |
|
237 | - 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
238 | - 'ATT_lname', |
|
239 | - esc_html__('Last Name', 'event_espresso') |
|
240 | - ), |
|
241 | - 'ATT_address' => $model_field_factory->createPlainTextField( |
|
242 | - 'ATT_address', |
|
243 | - esc_html__('Address Part 1', 'event_espresso') |
|
244 | - ), |
|
245 | - 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
246 | - 'ATT_address2', |
|
247 | - esc_html__('Address Part 2', 'event_espresso') |
|
248 | - ), |
|
249 | - 'ATT_city' => $model_field_factory->createPlainTextField( |
|
250 | - 'ATT_city', |
|
251 | - esc_html__('City', 'event_espresso') |
|
252 | - ), |
|
253 | - 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
254 | - 'STA_ID', |
|
255 | - esc_html__('State', 'event_espresso'), |
|
256 | - true, |
|
257 | - 0, |
|
258 | - 'State' |
|
259 | - ), |
|
260 | - 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
261 | - 'CNT_ISO', |
|
262 | - esc_html__('Country', 'event_espresso'), |
|
263 | - true, |
|
264 | - '', |
|
265 | - 'Country' |
|
266 | - ), |
|
267 | - 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
268 | - 'ATT_zip', |
|
269 | - esc_html__('ZIP/Postal Code', 'event_espresso') |
|
270 | - ), |
|
271 | - 'ATT_email' => $model_field_factory->createEmailField( |
|
272 | - 'ATT_email', |
|
273 | - esc_html__('Email Address', 'event_espresso') |
|
274 | - ), |
|
275 | - 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
276 | - 'ATT_phone', |
|
277 | - esc_html__('Phone', 'event_espresso') |
|
278 | - ), |
|
279 | - ), |
|
280 | - ); |
|
281 | - $this->_model_relations = array( |
|
282 | - 'Registration' => new EE_Has_Many_Relation(), |
|
283 | - 'State' => new EE_Belongs_To_Relation(), |
|
284 | - 'Country' => new EE_Belongs_To_Relation(), |
|
285 | - 'Event' => new EE_HABTM_Relation('Registration', false), |
|
286 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
287 | - 'Message' => new EE_Has_Many_Any_Relation(false), |
|
288 | - // allow deletion of attendees even if they have messages in the queue for them. |
|
289 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
290 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
291 | - ); |
|
292 | - $this->_caps_slug = 'contacts'; |
|
293 | - $this->model_chain_to_password = ''; |
|
294 | - parent::__construct($timezone); |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * Gets the name of the field on the attendee model corresponding to the system question string |
|
301 | - * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
302 | - * |
|
303 | - * @param string $system_question_string |
|
304 | - * @return string|null if not found |
|
305 | - */ |
|
306 | - public function get_attendee_field_for_system_question($system_question_string) |
|
307 | - { |
|
308 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
309 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
310 | - : null; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
317 | - * |
|
318 | - * @return array |
|
319 | - */ |
|
320 | - public function system_question_to_attendee_field_mapping() |
|
321 | - { |
|
322 | - return $this->_system_question_to_attendee_field_name; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
329 | - * |
|
330 | - * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
331 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
332 | - * @throws EE_Error |
|
333 | - */ |
|
334 | - public function get_attendees_for_transaction($transaction_id_or_obj) |
|
335 | - { |
|
336 | - return $this->get_all( |
|
337 | - array( |
|
338 | - array( |
|
339 | - 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
340 | - ? $transaction_id_or_obj->ID() |
|
341 | - : $transaction_id_or_obj, |
|
342 | - ), |
|
343 | - ) |
|
344 | - ); |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * retrieve a single attendee from db via their ID |
|
351 | - * |
|
352 | - * @param $ATT_ID |
|
353 | - * @return mixed array on success, FALSE on fail |
|
354 | - * @deprecated |
|
355 | - */ |
|
356 | - public function get_attendee_by_ID($ATT_ID = false) |
|
357 | - { |
|
358 | - // retrieve a particular EE_Attendee |
|
359 | - return $this->get_one_by_ID($ATT_ID); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * retrieve a single attendee from db via their ID |
|
366 | - * |
|
367 | - * @param array $where_cols_n_values |
|
368 | - * @return mixed array on success, FALSE on fail |
|
369 | - * @throws EE_Error |
|
370 | - */ |
|
371 | - public function get_attendee($where_cols_n_values = array()) |
|
372 | - { |
|
373 | - if (empty($where_cols_n_values)) { |
|
374 | - return false; |
|
375 | - } |
|
376 | - $attendee = $this->get_all(array($where_cols_n_values)); |
|
377 | - if (! empty($attendee)) { |
|
378 | - return array_shift($attendee); |
|
379 | - } |
|
380 | - return false; |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * Search for an existing Attendee record in the DB |
|
387 | - * |
|
388 | - * @param array $where_cols_n_values |
|
389 | - * @return bool|mixed |
|
390 | - * @throws EE_Error |
|
391 | - */ |
|
392 | - public function find_existing_attendee($where_cols_n_values = null) |
|
393 | - { |
|
394 | - // search by combo of first and last names plus the email address |
|
395 | - $attendee_data_keys = array( |
|
396 | - 'ATT_fname' => $this->_ATT_fname, |
|
397 | - 'ATT_lname' => $this->_ATT_lname, |
|
398 | - 'ATT_email' => $this->_ATT_email, |
|
399 | - ); |
|
400 | - // no search params means attendee object already exists. |
|
401 | - $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
402 | - ? $where_cols_n_values |
|
403 | - : $attendee_data_keys; |
|
404 | - $valid_data = true; |
|
405 | - // check for required values |
|
406 | - $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
407 | - ? $valid_data |
|
408 | - : false; |
|
409 | - $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
410 | - ? $valid_data |
|
411 | - : false; |
|
412 | - $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
413 | - ? $valid_data |
|
414 | - : false; |
|
415 | - if ($valid_data) { |
|
416 | - $attendee = $this->get_attendee($where_cols_n_values); |
|
417 | - if ($attendee instanceof EE_Attendee) { |
|
418 | - return $attendee; |
|
419 | - } |
|
420 | - } |
|
421 | - return false; |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * Takes an incoming array of EE_Registration ids |
|
428 | - * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
429 | - * |
|
430 | - * @since 4.3.0 |
|
431 | - * @param array $ids array of EE_Registration ids |
|
432 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
433 | - * @throws EE_Error |
|
434 | - */ |
|
435 | - public function get_array_of_contacts_from_reg_ids($ids) |
|
436 | - { |
|
437 | - $ids = (array) $ids; |
|
438 | - $_where = array( |
|
439 | - 'Registration.REG_ID' => array('in', $ids), |
|
440 | - ); |
|
441 | - return $this->get_all(array($_where)); |
|
442 | - } |
|
50 | + |
|
51 | + /** |
|
52 | + * @deprecated |
|
53 | + */ |
|
54 | + const city_question_id = 6; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @deprecated |
|
59 | + */ |
|
60 | + const state_question_id = 7; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @deprecated |
|
65 | + */ |
|
66 | + const country_question_id = 8; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @deprecated |
|
71 | + */ |
|
72 | + const zip_question_id = 9; |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @deprecated |
|
77 | + */ |
|
78 | + const phone_question_id = 10; |
|
79 | + |
|
80 | + /** |
|
81 | + * When looking for questions that correspond to attendee fields, |
|
82 | + * look for the question with this QST_system value. |
|
83 | + * These replace the old constants like EEM_Attendee::*_question_id |
|
84 | + */ |
|
85 | + const system_question_fname = 'fname'; |
|
86 | + |
|
87 | + const system_question_lname = 'lname'; |
|
88 | + |
|
89 | + const system_question_email = 'email'; |
|
90 | + |
|
91 | + const system_question_email_confirm = 'email_confirm'; |
|
92 | + |
|
93 | + const system_question_address = 'address'; |
|
94 | + |
|
95 | + const system_question_address2 = 'address2'; |
|
96 | + |
|
97 | + const system_question_city = 'city'; |
|
98 | + |
|
99 | + const system_question_state = 'state'; |
|
100 | + |
|
101 | + const system_question_country = 'country'; |
|
102 | + |
|
103 | + const system_question_zip = 'zip'; |
|
104 | + |
|
105 | + const system_question_phone = 'phone'; |
|
106 | + |
|
107 | + /** |
|
108 | + * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
109 | + * also all the values of QST_system in the questions table, and values |
|
110 | + * are their corresponding Attendee field names |
|
111 | + * |
|
112 | + * @var array |
|
113 | + */ |
|
114 | + protected $_system_question_to_attendee_field_name = array( |
|
115 | + EEM_Attendee::system_question_fname => 'ATT_fname', |
|
116 | + EEM_Attendee::system_question_lname => 'ATT_lname', |
|
117 | + EEM_Attendee::system_question_email => 'ATT_email', |
|
118 | + EEM_Attendee::system_question_address => 'ATT_address', |
|
119 | + EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
120 | + EEM_Attendee::system_question_city => 'ATT_city', |
|
121 | + EEM_Attendee::system_question_state => 'STA_ID', |
|
122 | + EEM_Attendee::system_question_country => 'CNT_ISO', |
|
123 | + EEM_Attendee::system_question_zip => 'ATT_zip', |
|
124 | + EEM_Attendee::system_question_phone => 'ATT_phone', |
|
125 | + ); |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * EEM_Attendee constructor. |
|
131 | + * |
|
132 | + * @param null $timezone |
|
133 | + * @param ModelFieldFactory $model_field_factory |
|
134 | + * @throws EE_Error |
|
135 | + * @throws InvalidArgumentException |
|
136 | + */ |
|
137 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
138 | + { |
|
139 | + $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
140 | + $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
141 | + $this->_tables = array( |
|
142 | + 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
143 | + 'Attendee_Meta' => new EE_Secondary_Table( |
|
144 | + 'esp_attendee_meta', |
|
145 | + 'ATTM_ID', |
|
146 | + 'ATT_ID' |
|
147 | + ), |
|
148 | + ); |
|
149 | + $this->_fields = array( |
|
150 | + 'Attendee_CPT' => array( |
|
151 | + 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
152 | + 'ID', |
|
153 | + esc_html__('Attendee ID', 'event_espresso') |
|
154 | + ), |
|
155 | + 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
156 | + 'post_title', |
|
157 | + esc_html__('Attendee Full Name', 'event_espresso'), |
|
158 | + false, |
|
159 | + esc_html__('Unknown', 'event_espresso') |
|
160 | + ), |
|
161 | + 'ATT_bio' => $model_field_factory->createPostContentField( |
|
162 | + 'post_content', |
|
163 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
164 | + false, |
|
165 | + esc_html__('No Biography Provided', 'event_espresso') |
|
166 | + ), |
|
167 | + 'ATT_slug' => $model_field_factory->createSlugField( |
|
168 | + 'post_name', |
|
169 | + esc_html__('Attendee URL Slug', 'event_espresso') |
|
170 | + ), |
|
171 | + 'ATT_created' => $model_field_factory->createDatetimeField( |
|
172 | + 'post_date', |
|
173 | + esc_html__('Time Attendee Created', 'event_espresso') |
|
174 | + ), |
|
175 | + 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
176 | + 'post_excerpt', |
|
177 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
178 | + true, |
|
179 | + esc_html__('No Biography Provided', 'event_espresso') |
|
180 | + ), |
|
181 | + 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
182 | + 'post_modified', |
|
183 | + esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
184 | + ), |
|
185 | + 'ATT_author' => $model_field_factory->createWpUserField( |
|
186 | + 'post_author', |
|
187 | + esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
188 | + false |
|
189 | + ), |
|
190 | + 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
191 | + 'post_parent', |
|
192 | + esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
193 | + false, |
|
194 | + 0 |
|
195 | + ), |
|
196 | + 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
197 | + 'status' => $model_field_factory->createWpPostStatusField( |
|
198 | + 'post_status', |
|
199 | + esc_html__('Attendee Status', 'event_espresso'), |
|
200 | + false, |
|
201 | + 'publish' |
|
202 | + ), |
|
203 | + 'password' => new EE_Password_Field( |
|
204 | + 'post_password', |
|
205 | + __('Password', 'event_espresso'), |
|
206 | + false, |
|
207 | + '', |
|
208 | + array( |
|
209 | + 'ATT_bio', |
|
210 | + 'ATT_short_bio', |
|
211 | + 'ATT_address', |
|
212 | + 'ATT_address2', |
|
213 | + 'ATT_city', |
|
214 | + 'STA_ID', |
|
215 | + 'CNT_ISO', |
|
216 | + 'ATT_zip', |
|
217 | + 'ATT_email', |
|
218 | + 'ATT_phone' |
|
219 | + ) |
|
220 | + ) |
|
221 | + ), |
|
222 | + 'Attendee_Meta' => array( |
|
223 | + 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
224 | + 'ATTM_ID', |
|
225 | + esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
226 | + false |
|
227 | + ), |
|
228 | + 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
229 | + 'ATT_ID', |
|
230 | + esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
231 | + false |
|
232 | + ), |
|
233 | + 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
234 | + 'ATT_fname', |
|
235 | + esc_html__('First Name', 'event_espresso') |
|
236 | + ), |
|
237 | + 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
238 | + 'ATT_lname', |
|
239 | + esc_html__('Last Name', 'event_espresso') |
|
240 | + ), |
|
241 | + 'ATT_address' => $model_field_factory->createPlainTextField( |
|
242 | + 'ATT_address', |
|
243 | + esc_html__('Address Part 1', 'event_espresso') |
|
244 | + ), |
|
245 | + 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
246 | + 'ATT_address2', |
|
247 | + esc_html__('Address Part 2', 'event_espresso') |
|
248 | + ), |
|
249 | + 'ATT_city' => $model_field_factory->createPlainTextField( |
|
250 | + 'ATT_city', |
|
251 | + esc_html__('City', 'event_espresso') |
|
252 | + ), |
|
253 | + 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
254 | + 'STA_ID', |
|
255 | + esc_html__('State', 'event_espresso'), |
|
256 | + true, |
|
257 | + 0, |
|
258 | + 'State' |
|
259 | + ), |
|
260 | + 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
261 | + 'CNT_ISO', |
|
262 | + esc_html__('Country', 'event_espresso'), |
|
263 | + true, |
|
264 | + '', |
|
265 | + 'Country' |
|
266 | + ), |
|
267 | + 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
268 | + 'ATT_zip', |
|
269 | + esc_html__('ZIP/Postal Code', 'event_espresso') |
|
270 | + ), |
|
271 | + 'ATT_email' => $model_field_factory->createEmailField( |
|
272 | + 'ATT_email', |
|
273 | + esc_html__('Email Address', 'event_espresso') |
|
274 | + ), |
|
275 | + 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
276 | + 'ATT_phone', |
|
277 | + esc_html__('Phone', 'event_espresso') |
|
278 | + ), |
|
279 | + ), |
|
280 | + ); |
|
281 | + $this->_model_relations = array( |
|
282 | + 'Registration' => new EE_Has_Many_Relation(), |
|
283 | + 'State' => new EE_Belongs_To_Relation(), |
|
284 | + 'Country' => new EE_Belongs_To_Relation(), |
|
285 | + 'Event' => new EE_HABTM_Relation('Registration', false), |
|
286 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
287 | + 'Message' => new EE_Has_Many_Any_Relation(false), |
|
288 | + // allow deletion of attendees even if they have messages in the queue for them. |
|
289 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
290 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
291 | + ); |
|
292 | + $this->_caps_slug = 'contacts'; |
|
293 | + $this->model_chain_to_password = ''; |
|
294 | + parent::__construct($timezone); |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * Gets the name of the field on the attendee model corresponding to the system question string |
|
301 | + * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
302 | + * |
|
303 | + * @param string $system_question_string |
|
304 | + * @return string|null if not found |
|
305 | + */ |
|
306 | + public function get_attendee_field_for_system_question($system_question_string) |
|
307 | + { |
|
308 | + return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
309 | + ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
310 | + : null; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
317 | + * |
|
318 | + * @return array |
|
319 | + */ |
|
320 | + public function system_question_to_attendee_field_mapping() |
|
321 | + { |
|
322 | + return $this->_system_question_to_attendee_field_name; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
329 | + * |
|
330 | + * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
331 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
332 | + * @throws EE_Error |
|
333 | + */ |
|
334 | + public function get_attendees_for_transaction($transaction_id_or_obj) |
|
335 | + { |
|
336 | + return $this->get_all( |
|
337 | + array( |
|
338 | + array( |
|
339 | + 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
340 | + ? $transaction_id_or_obj->ID() |
|
341 | + : $transaction_id_or_obj, |
|
342 | + ), |
|
343 | + ) |
|
344 | + ); |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * retrieve a single attendee from db via their ID |
|
351 | + * |
|
352 | + * @param $ATT_ID |
|
353 | + * @return mixed array on success, FALSE on fail |
|
354 | + * @deprecated |
|
355 | + */ |
|
356 | + public function get_attendee_by_ID($ATT_ID = false) |
|
357 | + { |
|
358 | + // retrieve a particular EE_Attendee |
|
359 | + return $this->get_one_by_ID($ATT_ID); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * retrieve a single attendee from db via their ID |
|
366 | + * |
|
367 | + * @param array $where_cols_n_values |
|
368 | + * @return mixed array on success, FALSE on fail |
|
369 | + * @throws EE_Error |
|
370 | + */ |
|
371 | + public function get_attendee($where_cols_n_values = array()) |
|
372 | + { |
|
373 | + if (empty($where_cols_n_values)) { |
|
374 | + return false; |
|
375 | + } |
|
376 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
377 | + if (! empty($attendee)) { |
|
378 | + return array_shift($attendee); |
|
379 | + } |
|
380 | + return false; |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * Search for an existing Attendee record in the DB |
|
387 | + * |
|
388 | + * @param array $where_cols_n_values |
|
389 | + * @return bool|mixed |
|
390 | + * @throws EE_Error |
|
391 | + */ |
|
392 | + public function find_existing_attendee($where_cols_n_values = null) |
|
393 | + { |
|
394 | + // search by combo of first and last names plus the email address |
|
395 | + $attendee_data_keys = array( |
|
396 | + 'ATT_fname' => $this->_ATT_fname, |
|
397 | + 'ATT_lname' => $this->_ATT_lname, |
|
398 | + 'ATT_email' => $this->_ATT_email, |
|
399 | + ); |
|
400 | + // no search params means attendee object already exists. |
|
401 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
402 | + ? $where_cols_n_values |
|
403 | + : $attendee_data_keys; |
|
404 | + $valid_data = true; |
|
405 | + // check for required values |
|
406 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
407 | + ? $valid_data |
|
408 | + : false; |
|
409 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
410 | + ? $valid_data |
|
411 | + : false; |
|
412 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
413 | + ? $valid_data |
|
414 | + : false; |
|
415 | + if ($valid_data) { |
|
416 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
417 | + if ($attendee instanceof EE_Attendee) { |
|
418 | + return $attendee; |
|
419 | + } |
|
420 | + } |
|
421 | + return false; |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * Takes an incoming array of EE_Registration ids |
|
428 | + * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
429 | + * |
|
430 | + * @since 4.3.0 |
|
431 | + * @param array $ids array of EE_Registration ids |
|
432 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
433 | + * @throws EE_Error |
|
434 | + */ |
|
435 | + public function get_array_of_contacts_from_reg_ids($ids) |
|
436 | + { |
|
437 | + $ids = (array) $ids; |
|
438 | + $_where = array( |
|
439 | + 'Registration.REG_ID' => array('in', $ids), |
|
440 | + ); |
|
441 | + return $this->get_all(array($_where)); |
|
442 | + } |
|
443 | 443 | } |
@@ -23,32 +23,32 @@ |
||
23 | 23 | */ |
24 | 24 | class EEM_Extra_Join extends EEM_Base |
25 | 25 | { |
26 | - // private instance of the Extra Join object |
|
27 | - protected static $_instance = null; |
|
26 | + // private instance of the Extra Join object |
|
27 | + protected static $_instance = null; |
|
28 | 28 | |
29 | - public function __construct($timezone = null) |
|
30 | - { |
|
31 | - $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
32 | - $this->_tables = array( |
|
33 | - 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
34 | - ); |
|
35 | - $this->_fields = array( |
|
36 | - 'Extra_Join' => array( |
|
37 | - 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
38 | - 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
39 | - 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
40 | - 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | - 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
29 | + public function __construct($timezone = null) |
|
30 | + { |
|
31 | + $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
32 | + $this->_tables = array( |
|
33 | + 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
34 | + ); |
|
35 | + $this->_fields = array( |
|
36 | + 'Extra_Join' => array( |
|
37 | + 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
38 | + 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
39 | + 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
40 | + 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | + 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
42 | 42 | |
43 | - ) |
|
44 | - ); |
|
45 | - // this model is weird in that it has two foreign key columns which can point to any model/table. |
|
46 | - // eg a foreign key to event will be in "EXJ_first_model_ID", provided the other |
|
47 | - // model linked to is alphabetically greater than event (eg venue). |
|
48 | - // but if the model linked to is alphabetically lower (eg attendee), |
|
49 | - // the foreign key to the event will be in "EXJ_second_model_ID" |
|
50 | - // so normal usage of foreign keys is weird. So don't define any |
|
51 | - // relations to other models because they won't work properly with this model |
|
52 | - parent::__construct($timezone); |
|
53 | - } |
|
43 | + ) |
|
44 | + ); |
|
45 | + // this model is weird in that it has two foreign key columns which can point to any model/table. |
|
46 | + // eg a foreign key to event will be in "EXJ_first_model_ID", provided the other |
|
47 | + // model linked to is alphabetically greater than event (eg venue). |
|
48 | + // but if the model linked to is alphabetically lower (eg attendee), |
|
49 | + // the foreign key to the event will be in "EXJ_second_model_ID" |
|
50 | + // so normal usage of foreign keys is weird. So don't define any |
|
51 | + // relations to other models because they won't work properly with this model |
|
52 | + parent::__construct($timezone); |
|
53 | + } |
|
54 | 54 | } |