@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,407 +17,407 @@ discard block |
||
17 | 17 | class EE_Payment_Method_Manager |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * instance of the EE_Payment_Method_Manager object |
|
22 | - * |
|
23 | - * @var $_instance |
|
24 | - * @access private |
|
25 | - */ |
|
26 | - private static $_instance; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var array keys are classnames without 'EE_PMT_', values are their filepaths |
|
30 | - */ |
|
31 | - protected $_payment_method_types = array(); |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @singleton method used to instantiate class object |
|
37 | - * @access public |
|
38 | - * @return EE_Payment_Method_Manager instance |
|
39 | - */ |
|
40 | - public static function instance() |
|
41 | - { |
|
42 | - // check if class object is instantiated, and instantiated properly |
|
43 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
44 | - self::$_instance = new self(); |
|
45 | - } |
|
46 | - EE_Registry::instance()->load_lib('PMT_Base'); |
|
47 | - return self::$_instance; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Resets the instance and returns a new one |
|
54 | - * |
|
55 | - * @return EE_Payment_Method_Manager |
|
56 | - */ |
|
57 | - public static function reset() |
|
58 | - { |
|
59 | - self::$_instance = null; |
|
60 | - return self::instance(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * If necessary, re-register payment methods |
|
67 | - * |
|
68 | - * @param boolean $force_recheck whether to recheck for payment method types, |
|
69 | - * or just re-use the PMTs we found last time we checked during this request (if |
|
70 | - * we have not yet checked during this request, then we need to check anyways) |
|
71 | - */ |
|
72 | - public function maybe_register_payment_methods($force_recheck = false) |
|
73 | - { |
|
74 | - if ( ! $this->_payment_method_types || $force_recheck) { |
|
75 | - $this->_register_payment_methods(); |
|
76 | - //if in admin lets ensure caps are set. |
|
77 | - if (is_admin()) { |
|
78 | - add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
79 | - EE_Registry::instance()->CAP->init_caps(); |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * register_payment_methods |
|
88 | - * |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - protected function _register_payment_methods() |
|
92 | - { |
|
93 | - // grab list of installed modules |
|
94 | - $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
95 | - // filter list of modules to register |
|
96 | - $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
97 | - $pm_to_register); |
|
98 | - // loop through folders |
|
99 | - foreach ($pm_to_register as $pm_path) { |
|
100 | - $this->register_payment_method($pm_path); |
|
101 | - } |
|
102 | - do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
103 | - // filter list of installed modules |
|
104 | - //keep them organized alphabetically by the payment method type's name |
|
105 | - ksort($this->_payment_method_types); |
|
106 | - return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', |
|
107 | - $this->_payment_method_types); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * register_payment_method- makes core aware of this payment method |
|
114 | - * |
|
115 | - * @access public |
|
116 | - * @param string $payment_method_path - full path up to and including payment method folder |
|
117 | - * @return boolean |
|
118 | - */ |
|
119 | - public function register_payment_method($payment_method_path = '') |
|
120 | - { |
|
121 | - do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
122 | - $module_ext = '.pm.php'; |
|
123 | - // make all separators match |
|
124 | - $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
125 | - // grab and sanitize module name |
|
126 | - $module_dir = basename($payment_method_path); |
|
127 | - // create classname from module directory name |
|
128 | - $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
129 | - // add class prefix |
|
130 | - $module_class = 'EE_PMT_' . $module; |
|
131 | - // does the module exist ? |
|
132 | - if ( ! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
133 | - $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', |
|
134 | - 'event_espresso'), $module); |
|
135 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
136 | - return false; |
|
137 | - } |
|
138 | - if (WP_DEBUG === true) { |
|
139 | - EEH_Debug_Tools::instance()->start_timer(); |
|
140 | - } |
|
141 | - // load the module class file |
|
142 | - require_once($payment_method_path . DS . $module_class . $module_ext); |
|
143 | - if (WP_DEBUG === true) { |
|
144 | - EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); |
|
145 | - } |
|
146 | - // verify that class exists |
|
147 | - if ( ! class_exists($module_class)) { |
|
148 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
149 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
150 | - return false; |
|
151 | - } |
|
152 | - // add to array of registered modules |
|
153 | - $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
154 | - return true; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * Checks if a payment method has been registered, and if so includes it |
|
161 | - * |
|
162 | - * @param string $payment_method_name like 'Paypal_Pro', (ie classname without the prefix 'EEPM_') |
|
163 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
164 | - * @return boolean |
|
165 | - */ |
|
166 | - public function payment_method_type_exists($payment_method_name, $force_recheck = false) |
|
167 | - { |
|
168 | - if ( |
|
169 | - $force_recheck |
|
170 | - || ! is_array($this->_payment_method_types) |
|
171 | - || ! isset($this->_payment_method_types[$payment_method_name]) |
|
172 | - ) { |
|
173 | - $this->maybe_register_payment_methods($force_recheck); |
|
174 | - } |
|
175 | - if (isset($this->_payment_method_types[$payment_method_name])) { |
|
176 | - require_once($this->_payment_method_types[$payment_method_name]); |
|
177 | - return true; |
|
178 | - } else { |
|
179 | - return false; |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * Returns all the classnames of the various payment method types |
|
187 | - * |
|
188 | - * @param boolean $with_prefixes TRUE: get payment method type classnames; false just their 'names' |
|
189 | - * (what you'd find in wp_esp_payment_method.PMD_type) |
|
190 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function payment_method_type_names($with_prefixes = false, $force_recheck = false) |
|
194 | - { |
|
195 | - $this->maybe_register_payment_methods($force_recheck); |
|
196 | - if ($with_prefixes) { |
|
197 | - $classnames = array_keys($this->_payment_method_types); |
|
198 | - $payment_methods = array(); |
|
199 | - foreach ($classnames as $classname) { |
|
200 | - $payment_methods[] = $this->payment_method_class_from_type($classname); |
|
201 | - } |
|
202 | - return $payment_methods; |
|
203 | - } else { |
|
204 | - return array_keys($this->_payment_method_types); |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * Gets an object of each payment method type, none of which are bound to a |
|
212 | - * payment method instance |
|
213 | - * |
|
214 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
215 | - * @return EE_PMT_Base[] |
|
216 | - */ |
|
217 | - public function payment_method_types($force_recheck = false) |
|
218 | - { |
|
219 | - $this->maybe_register_payment_methods($force_recheck); |
|
220 | - $pmt_objs = array(); |
|
221 | - foreach ($this->payment_method_type_names(true) as $classname) { |
|
222 | - $pmt_objs[] = new $classname; |
|
223 | - } |
|
224 | - return $pmt_objs; |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * Changes the payment method's classname into the payment method type's name |
|
231 | - * (as used on the payment method's table's PMD_type field) |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - public function payment_method_type_sans_class_prefix($classname) |
|
237 | - { |
|
238 | - return str_replace("EE_PMT_", "", $classname); |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * Does the opposite of payment-method_type_sans_prefix |
|
245 | - * |
|
246 | - * @param string $type |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function payment_method_class_from_type($type) |
|
250 | - { |
|
251 | - $this->maybe_register_payment_methods(); |
|
252 | - return "EE_PMT_" . $type; |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * Activates a payment method of the given type. |
|
259 | - * |
|
260 | - * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice' |
|
261 | - * @return \EE_Payment_Method |
|
262 | - * @throws \EE_Error |
|
263 | - */ |
|
264 | - public function activate_a_payment_method_of_type($payment_method_type) |
|
265 | - { |
|
266 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
|
267 | - if ( ! $payment_method instanceof EE_Payment_Method) { |
|
268 | - $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
|
269 | - if (class_exists($pm_type_class)) { |
|
270 | - /** @var $pm_type_obj EE_PMT_Base */ |
|
271 | - $pm_type_obj = new $pm_type_class; |
|
272 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
|
273 | - if ( ! $payment_method) { |
|
274 | - $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
275 | - } |
|
276 | - $payment_method->set_type($payment_method_type); |
|
277 | - $this->initialize_payment_method($payment_method); |
|
278 | - } else { |
|
279 | - throw new EE_Error( |
|
280 | - sprintf( |
|
281 | - __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
282 | - $pm_type_class) |
|
283 | - ); |
|
284 | - } |
|
285 | - } |
|
286 | - $payment_method->set_active(); |
|
287 | - $payment_method->save(); |
|
288 | - if ($payment_method->type() === 'Invoice') { |
|
289 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
290 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
291 | - $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
292 | - $message_resource_manager->ensure_messenger_is_active('pdf'); |
|
293 | - EE_Error::add_persistent_admin_notice( |
|
294 | - 'invoice_pm_requirements_notice', |
|
295 | - sprintf( |
|
296 | - __('The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.', |
|
297 | - 'event_espresso'), |
|
298 | - '<a href="' . admin_url('admin.php?page=espresso_messages') . '">', |
|
299 | - '</a>' |
|
300 | - ), |
|
301 | - true |
|
302 | - ); |
|
303 | - } |
|
304 | - return $payment_method; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * Creates a payment method of the specified type. Does not save it. |
|
311 | - * |
|
312 | - * @global WP_User $current_user |
|
313 | - * @param EE_PMT_Base $pm_type_obj |
|
314 | - * @return EE_Payment_Method |
|
315 | - * @throws \EE_Error |
|
316 | - */ |
|
317 | - public function create_payment_method_of_type($pm_type_obj) |
|
318 | - { |
|
319 | - global $current_user; |
|
320 | - $payment_method = EE_Payment_Method::new_instance( |
|
321 | - array( |
|
322 | - 'PMD_type' => $pm_type_obj->system_name(), |
|
323 | - 'PMD_name' => $pm_type_obj->pretty_name(), |
|
324 | - 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
|
325 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
326 | - 'PMD_wp_user' => $current_user->ID, |
|
327 | - 'PMD_order' => EEM_Payment_Method::instance()->count( |
|
328 | - array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
329 | - ) * 10, |
|
330 | - ) |
|
331 | - ); |
|
332 | - return $payment_method; |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * Sets the initial payment method properties (including extra meta) |
|
339 | - * |
|
340 | - * @param EE_Payment_Method $payment_method |
|
341 | - * @return EE_Payment_Method |
|
342 | - * @throws \EE_Error |
|
343 | - */ |
|
344 | - public function initialize_payment_method($payment_method) |
|
345 | - { |
|
346 | - $pm_type_obj = $payment_method->type_obj(); |
|
347 | - $payment_method->set_description($pm_type_obj->default_description()); |
|
348 | - if ( ! $payment_method->button_url()) { |
|
349 | - $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
350 | - } |
|
351 | - //now add setup its default extra meta properties |
|
352 | - $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
|
353 | - if ( ! empty($extra_metas)) { |
|
354 | - //verify the payment method has an ID before adding extra meta |
|
355 | - if ( ! $payment_method->ID()) { |
|
356 | - $payment_method->save(); |
|
357 | - } |
|
358 | - foreach ($extra_metas as $meta_name => $input) { |
|
359 | - $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
360 | - } |
|
361 | - } |
|
362 | - return $payment_method; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * Makes sure the payment method is related to the specified payment method |
|
369 | - * @deprecated in 4.9.40 because the currency payment method table is being deprecated |
|
370 | - * @param EE_Payment_Method $payment_method |
|
371 | - * @return EE_Payment_Method |
|
372 | - * @throws \EE_Error |
|
373 | - */ |
|
374 | - public function set_usable_currencies_on_payment_method($payment_method) |
|
375 | - { |
|
376 | - EE_Error::doing_it_wrong( |
|
377 | - 'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method', |
|
378 | - esc_html__('We no longer define what currencies are usable by payment methods. Its not used nor efficient.', 'event_espresso'), |
|
379 | - '4.9.40'); |
|
380 | - return $payment_method; |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * Deactivates a payment method of the given payment method slug. |
|
387 | - * |
|
388 | - * @param string $payment_method_slug The slug for the payment method to deactivate. |
|
389 | - * @return int count of rows updated. |
|
390 | - */ |
|
391 | - public function deactivate_payment_method($payment_method_slug) |
|
392 | - { |
|
393 | - EE_Log::instance()->log( |
|
394 | - __FILE__, |
|
395 | - __FUNCTION__, |
|
396 | - sprintf( |
|
397 | - __('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'), |
|
398 | - $payment_method_slug |
|
399 | - ), |
|
400 | - 'payment_method_change' |
|
401 | - ); |
|
402 | - $count_updated = EEM_Payment_Method::instance()->update( |
|
403 | - array('PMD_scope' => array()), |
|
404 | - array(array('PMD_slug' => $payment_method_slug)) |
|
405 | - ); |
|
406 | - return $count_updated; |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method |
|
413 | - * access caps. |
|
414 | - * |
|
415 | - * @param array $caps capabilities being filtered |
|
416 | - * @return array |
|
417 | - */ |
|
418 | - public function add_payment_method_caps($caps) |
|
419 | - { |
|
420 | - /* add dynamic caps from payment methods |
|
20 | + /** |
|
21 | + * instance of the EE_Payment_Method_Manager object |
|
22 | + * |
|
23 | + * @var $_instance |
|
24 | + * @access private |
|
25 | + */ |
|
26 | + private static $_instance; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var array keys are classnames without 'EE_PMT_', values are their filepaths |
|
30 | + */ |
|
31 | + protected $_payment_method_types = array(); |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @singleton method used to instantiate class object |
|
37 | + * @access public |
|
38 | + * @return EE_Payment_Method_Manager instance |
|
39 | + */ |
|
40 | + public static function instance() |
|
41 | + { |
|
42 | + // check if class object is instantiated, and instantiated properly |
|
43 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
44 | + self::$_instance = new self(); |
|
45 | + } |
|
46 | + EE_Registry::instance()->load_lib('PMT_Base'); |
|
47 | + return self::$_instance; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Resets the instance and returns a new one |
|
54 | + * |
|
55 | + * @return EE_Payment_Method_Manager |
|
56 | + */ |
|
57 | + public static function reset() |
|
58 | + { |
|
59 | + self::$_instance = null; |
|
60 | + return self::instance(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * If necessary, re-register payment methods |
|
67 | + * |
|
68 | + * @param boolean $force_recheck whether to recheck for payment method types, |
|
69 | + * or just re-use the PMTs we found last time we checked during this request (if |
|
70 | + * we have not yet checked during this request, then we need to check anyways) |
|
71 | + */ |
|
72 | + public function maybe_register_payment_methods($force_recheck = false) |
|
73 | + { |
|
74 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
75 | + $this->_register_payment_methods(); |
|
76 | + //if in admin lets ensure caps are set. |
|
77 | + if (is_admin()) { |
|
78 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
79 | + EE_Registry::instance()->CAP->init_caps(); |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * register_payment_methods |
|
88 | + * |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + protected function _register_payment_methods() |
|
92 | + { |
|
93 | + // grab list of installed modules |
|
94 | + $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
95 | + // filter list of modules to register |
|
96 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
97 | + $pm_to_register); |
|
98 | + // loop through folders |
|
99 | + foreach ($pm_to_register as $pm_path) { |
|
100 | + $this->register_payment_method($pm_path); |
|
101 | + } |
|
102 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
103 | + // filter list of installed modules |
|
104 | + //keep them organized alphabetically by the payment method type's name |
|
105 | + ksort($this->_payment_method_types); |
|
106 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', |
|
107 | + $this->_payment_method_types); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * register_payment_method- makes core aware of this payment method |
|
114 | + * |
|
115 | + * @access public |
|
116 | + * @param string $payment_method_path - full path up to and including payment method folder |
|
117 | + * @return boolean |
|
118 | + */ |
|
119 | + public function register_payment_method($payment_method_path = '') |
|
120 | + { |
|
121 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
122 | + $module_ext = '.pm.php'; |
|
123 | + // make all separators match |
|
124 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
125 | + // grab and sanitize module name |
|
126 | + $module_dir = basename($payment_method_path); |
|
127 | + // create classname from module directory name |
|
128 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
129 | + // add class prefix |
|
130 | + $module_class = 'EE_PMT_' . $module; |
|
131 | + // does the module exist ? |
|
132 | + if ( ! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
133 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', |
|
134 | + 'event_espresso'), $module); |
|
135 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
136 | + return false; |
|
137 | + } |
|
138 | + if (WP_DEBUG === true) { |
|
139 | + EEH_Debug_Tools::instance()->start_timer(); |
|
140 | + } |
|
141 | + // load the module class file |
|
142 | + require_once($payment_method_path . DS . $module_class . $module_ext); |
|
143 | + if (WP_DEBUG === true) { |
|
144 | + EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); |
|
145 | + } |
|
146 | + // verify that class exists |
|
147 | + if ( ! class_exists($module_class)) { |
|
148 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
149 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
150 | + return false; |
|
151 | + } |
|
152 | + // add to array of registered modules |
|
153 | + $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
154 | + return true; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * Checks if a payment method has been registered, and if so includes it |
|
161 | + * |
|
162 | + * @param string $payment_method_name like 'Paypal_Pro', (ie classname without the prefix 'EEPM_') |
|
163 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
164 | + * @return boolean |
|
165 | + */ |
|
166 | + public function payment_method_type_exists($payment_method_name, $force_recheck = false) |
|
167 | + { |
|
168 | + if ( |
|
169 | + $force_recheck |
|
170 | + || ! is_array($this->_payment_method_types) |
|
171 | + || ! isset($this->_payment_method_types[$payment_method_name]) |
|
172 | + ) { |
|
173 | + $this->maybe_register_payment_methods($force_recheck); |
|
174 | + } |
|
175 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
176 | + require_once($this->_payment_method_types[$payment_method_name]); |
|
177 | + return true; |
|
178 | + } else { |
|
179 | + return false; |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * Returns all the classnames of the various payment method types |
|
187 | + * |
|
188 | + * @param boolean $with_prefixes TRUE: get payment method type classnames; false just their 'names' |
|
189 | + * (what you'd find in wp_esp_payment_method.PMD_type) |
|
190 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function payment_method_type_names($with_prefixes = false, $force_recheck = false) |
|
194 | + { |
|
195 | + $this->maybe_register_payment_methods($force_recheck); |
|
196 | + if ($with_prefixes) { |
|
197 | + $classnames = array_keys($this->_payment_method_types); |
|
198 | + $payment_methods = array(); |
|
199 | + foreach ($classnames as $classname) { |
|
200 | + $payment_methods[] = $this->payment_method_class_from_type($classname); |
|
201 | + } |
|
202 | + return $payment_methods; |
|
203 | + } else { |
|
204 | + return array_keys($this->_payment_method_types); |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * Gets an object of each payment method type, none of which are bound to a |
|
212 | + * payment method instance |
|
213 | + * |
|
214 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
215 | + * @return EE_PMT_Base[] |
|
216 | + */ |
|
217 | + public function payment_method_types($force_recheck = false) |
|
218 | + { |
|
219 | + $this->maybe_register_payment_methods($force_recheck); |
|
220 | + $pmt_objs = array(); |
|
221 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
222 | + $pmt_objs[] = new $classname; |
|
223 | + } |
|
224 | + return $pmt_objs; |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * Changes the payment method's classname into the payment method type's name |
|
231 | + * (as used on the payment method's table's PMD_type field) |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + public function payment_method_type_sans_class_prefix($classname) |
|
237 | + { |
|
238 | + return str_replace("EE_PMT_", "", $classname); |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * Does the opposite of payment-method_type_sans_prefix |
|
245 | + * |
|
246 | + * @param string $type |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function payment_method_class_from_type($type) |
|
250 | + { |
|
251 | + $this->maybe_register_payment_methods(); |
|
252 | + return "EE_PMT_" . $type; |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * Activates a payment method of the given type. |
|
259 | + * |
|
260 | + * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice' |
|
261 | + * @return \EE_Payment_Method |
|
262 | + * @throws \EE_Error |
|
263 | + */ |
|
264 | + public function activate_a_payment_method_of_type($payment_method_type) |
|
265 | + { |
|
266 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
|
267 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
268 | + $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
|
269 | + if (class_exists($pm_type_class)) { |
|
270 | + /** @var $pm_type_obj EE_PMT_Base */ |
|
271 | + $pm_type_obj = new $pm_type_class; |
|
272 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
|
273 | + if ( ! $payment_method) { |
|
274 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
275 | + } |
|
276 | + $payment_method->set_type($payment_method_type); |
|
277 | + $this->initialize_payment_method($payment_method); |
|
278 | + } else { |
|
279 | + throw new EE_Error( |
|
280 | + sprintf( |
|
281 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
282 | + $pm_type_class) |
|
283 | + ); |
|
284 | + } |
|
285 | + } |
|
286 | + $payment_method->set_active(); |
|
287 | + $payment_method->save(); |
|
288 | + if ($payment_method->type() === 'Invoice') { |
|
289 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
290 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
291 | + $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
292 | + $message_resource_manager->ensure_messenger_is_active('pdf'); |
|
293 | + EE_Error::add_persistent_admin_notice( |
|
294 | + 'invoice_pm_requirements_notice', |
|
295 | + sprintf( |
|
296 | + __('The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.', |
|
297 | + 'event_espresso'), |
|
298 | + '<a href="' . admin_url('admin.php?page=espresso_messages') . '">', |
|
299 | + '</a>' |
|
300 | + ), |
|
301 | + true |
|
302 | + ); |
|
303 | + } |
|
304 | + return $payment_method; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * Creates a payment method of the specified type. Does not save it. |
|
311 | + * |
|
312 | + * @global WP_User $current_user |
|
313 | + * @param EE_PMT_Base $pm_type_obj |
|
314 | + * @return EE_Payment_Method |
|
315 | + * @throws \EE_Error |
|
316 | + */ |
|
317 | + public function create_payment_method_of_type($pm_type_obj) |
|
318 | + { |
|
319 | + global $current_user; |
|
320 | + $payment_method = EE_Payment_Method::new_instance( |
|
321 | + array( |
|
322 | + 'PMD_type' => $pm_type_obj->system_name(), |
|
323 | + 'PMD_name' => $pm_type_obj->pretty_name(), |
|
324 | + 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
|
325 | + 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
326 | + 'PMD_wp_user' => $current_user->ID, |
|
327 | + 'PMD_order' => EEM_Payment_Method::instance()->count( |
|
328 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
329 | + ) * 10, |
|
330 | + ) |
|
331 | + ); |
|
332 | + return $payment_method; |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * Sets the initial payment method properties (including extra meta) |
|
339 | + * |
|
340 | + * @param EE_Payment_Method $payment_method |
|
341 | + * @return EE_Payment_Method |
|
342 | + * @throws \EE_Error |
|
343 | + */ |
|
344 | + public function initialize_payment_method($payment_method) |
|
345 | + { |
|
346 | + $pm_type_obj = $payment_method->type_obj(); |
|
347 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
348 | + if ( ! $payment_method->button_url()) { |
|
349 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
350 | + } |
|
351 | + //now add setup its default extra meta properties |
|
352 | + $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
|
353 | + if ( ! empty($extra_metas)) { |
|
354 | + //verify the payment method has an ID before adding extra meta |
|
355 | + if ( ! $payment_method->ID()) { |
|
356 | + $payment_method->save(); |
|
357 | + } |
|
358 | + foreach ($extra_metas as $meta_name => $input) { |
|
359 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
360 | + } |
|
361 | + } |
|
362 | + return $payment_method; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * Makes sure the payment method is related to the specified payment method |
|
369 | + * @deprecated in 4.9.40 because the currency payment method table is being deprecated |
|
370 | + * @param EE_Payment_Method $payment_method |
|
371 | + * @return EE_Payment_Method |
|
372 | + * @throws \EE_Error |
|
373 | + */ |
|
374 | + public function set_usable_currencies_on_payment_method($payment_method) |
|
375 | + { |
|
376 | + EE_Error::doing_it_wrong( |
|
377 | + 'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method', |
|
378 | + esc_html__('We no longer define what currencies are usable by payment methods. Its not used nor efficient.', 'event_espresso'), |
|
379 | + '4.9.40'); |
|
380 | + return $payment_method; |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * Deactivates a payment method of the given payment method slug. |
|
387 | + * |
|
388 | + * @param string $payment_method_slug The slug for the payment method to deactivate. |
|
389 | + * @return int count of rows updated. |
|
390 | + */ |
|
391 | + public function deactivate_payment_method($payment_method_slug) |
|
392 | + { |
|
393 | + EE_Log::instance()->log( |
|
394 | + __FILE__, |
|
395 | + __FUNCTION__, |
|
396 | + sprintf( |
|
397 | + __('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'), |
|
398 | + $payment_method_slug |
|
399 | + ), |
|
400 | + 'payment_method_change' |
|
401 | + ); |
|
402 | + $count_updated = EEM_Payment_Method::instance()->update( |
|
403 | + array('PMD_scope' => array()), |
|
404 | + array(array('PMD_slug' => $payment_method_slug)) |
|
405 | + ); |
|
406 | + return $count_updated; |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method |
|
413 | + * access caps. |
|
414 | + * |
|
415 | + * @param array $caps capabilities being filtered |
|
416 | + * @return array |
|
417 | + */ |
|
418 | + public function add_payment_method_caps($caps) |
|
419 | + { |
|
420 | + /* add dynamic caps from payment methods |
|
421 | 421 | * at the time of writing, october 20 2014, these are the caps added: |
422 | 422 | * ee_payment_method_admin_only |
423 | 423 | * ee_payment_method_aim |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | * their related capability automatically added too, so long as they are |
432 | 432 | * registered properly using EE_Register_Payment_Method::register() |
433 | 433 | */ |
434 | - foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
435 | - $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
|
436 | - } |
|
437 | - return $caps; |
|
438 | - } |
|
434 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
435 | + $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
|
436 | + } |
|
437 | + return $caps; |
|
438 | + } |
|
439 | 439 | |
440 | 440 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @deprecated in 4.9.40 because the currency payment method table has been deprecated |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage{ |
|
17 | +class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage { |
|
18 | 18 | protected $_currency_table_name; |
19 | 19 | protected $_currency_payment_method_table_name; |
20 | 20 | protected $_payment_method_table_name; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ); |
91 | 91 | public function __construct() { |
92 | 92 | global $wpdb; |
93 | - $this->_pretty_name = __( 'Payment Method Currencies', 'event_espresso' ); |
|
93 | + $this->_pretty_name = __('Payment Method Currencies', 'event_espresso'); |
|
94 | 94 | $this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method'; |
95 | 95 | $this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method'; |
96 | 96 | $this->_currency_table_name = $wpdb->prefix.'esp_currency'; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function _count_records_to_migrate() { |
101 | 101 | $count = 0; |
102 | - foreach($this->_gateway_currencies as $currencies){ |
|
103 | - if( $currencies == 'all'){ |
|
102 | + foreach ($this->_gateway_currencies as $currencies) { |
|
103 | + if ($currencies == 'all') { |
|
104 | 104 | $currencies = $this->_get_all_currencies(); |
105 | 105 | } |
106 | 106 | $count += count($currencies); |
@@ -110,20 +110,20 @@ discard block |
||
110 | 110 | |
111 | 111 | |
112 | 112 | |
113 | - protected function _migration_step( $num_items_to_migrate = 50 ) { |
|
113 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
114 | 114 | $items_actually_migrated = 0; |
115 | 115 | $relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate); |
116 | - foreach($relations_to_add_this_step as $pm_slug => $currencies){ |
|
116 | + foreach ($relations_to_add_this_step as $pm_slug => $currencies) { |
|
117 | 117 | |
118 | - $id = $this->get_migration_script()->get_mapping_new_pk( 'EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name ); |
|
119 | - foreach( $currencies as $currency ){ |
|
120 | - if( $id ){ |
|
121 | - $this->_add_currency_relations( $id, $currency ); |
|
118 | + $id = $this->get_migration_script()->get_mapping_new_pk('EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name); |
|
119 | + foreach ($currencies as $currency) { |
|
120 | + if ($id) { |
|
121 | + $this->_add_currency_relations($id, $currency); |
|
122 | 122 | } |
123 | 123 | $items_actually_migrated++; |
124 | 124 | } |
125 | 125 | } |
126 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
126 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
127 | 127 | $this->set_completed(); |
128 | 128 | } |
129 | 129 | return $items_actually_migrated; |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | $relations_to_add_this_step = array(); |
134 | 134 | $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate; |
135 | 135 | $iterator = 0; |
136 | - foreach($this->_gateway_currencies as $pm_slug => $currencies){ |
|
137 | - if( $currencies == 'all' ){ |
|
136 | + foreach ($this->_gateway_currencies as $pm_slug => $currencies) { |
|
137 | + if ($currencies == 'all') { |
|
138 | 138 | $currencies = $this->_get_all_currencies(); |
139 | 139 | } |
140 | - foreach($currencies as $currency_code){ |
|
141 | - if( $this->count_records_migrated() <= $iterator && |
|
142 | - $iterator < $migrate_up_to_count ){ |
|
143 | - $relations_to_add_this_step[ $pm_slug ] [] = $currency_code; |
|
140 | + foreach ($currencies as $currency_code) { |
|
141 | + if ($this->count_records_migrated() <= $iterator && |
|
142 | + $iterator < $migrate_up_to_count) { |
|
143 | + $relations_to_add_this_step[$pm_slug] [] = $currency_code; |
|
144 | 144 | } |
145 | 145 | $iterator++; |
146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * Gets all the currency codes in the database |
152 | 152 | * @return array |
153 | 153 | */ |
154 | - private function _get_all_currencies(){ |
|
154 | + private function _get_all_currencies() { |
|
155 | 155 | global $wpdb; |
156 | 156 | $currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}"); |
157 | 157 | return $currencies; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param int $id |
163 | 163 | * @param string $gateway_slug |
164 | 164 | */ |
165 | - private function _add_currency_relations($pm_id,$currency_code){ |
|
165 | + private function _add_currency_relations($pm_id, $currency_code) { |
|
166 | 166 | global $wpdb; |
167 | 167 | $cur_pm_relation = array( |
168 | 168 | 'CUR_code'=>$currency_code, |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $success = $wpdb->insert($this->_currency_payment_method_table_name, |
172 | 172 | $cur_pm_relation, |
173 | 173 | array( |
174 | - '%s',//CUR_code |
|
175 | - '%d',//PMD_ID |
|
174 | + '%s', //CUR_code |
|
175 | + '%d', //PMD_ID |
|
176 | 176 | )); |
177 | - if( ! $success ){ |
|
178 | - $this->add_error( sprintf( __( 'Could not add currency relation %s because %s', "event_espresso" ), wp_json_encode( $cur_pm_relation ), $wpdb->last_error ) ); |
|
177 | + if ( ! $success) { |
|
178 | + $this->add_error(sprintf(__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error)); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[$matches[1]] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - //no version string provided... this must be pre 4.3 |
|
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + //no version string provided... this must be pre 4.3 |
|
70 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - //note: although this table is no longer in use, |
|
153 | - //it hasn't been removed because then queries to the model will have errors. |
|
154 | - //but you should expect this table and its corresponding model to be removed in |
|
155 | - //the next few months |
|
156 | - $table_name = 'esp_currency_payment_method'; |
|
157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + //note: although this table is no longer in use, |
|
153 | + //it hasn't been removed because then queries to the model will have errors. |
|
154 | + //but you should expect this table and its corresponding model to be removed in |
|
155 | + //the next few months |
|
156 | + $table_name = 'esp_currency_payment_method'; |
|
157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
158 | 158 | CUR_code varchar(6) NOT NULL, |
159 | 159 | PMD_ID int(11) NOT NULL, |
160 | 160 | PRIMARY KEY (CPM_ID), |
161 | 161 | KEY PMD_ID (PMD_ID)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | - $table_name = 'esp_datetime'; |
|
164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | + $table_name = 'esp_datetime'; |
|
164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
179 | 179 | KEY EVT_ID (EVT_ID), |
180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
181 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | - $table_name = "esp_datetime_ticket"; |
|
183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | + $table_name = "esp_datetime_ticket"; |
|
183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
186 | 186 | PRIMARY KEY (DTK_ID), |
187 | 187 | KEY DTT_ID (DTT_ID), |
188 | 188 | KEY TKT_ID (TKT_ID)"; |
189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | - $table_name = 'esp_event_message_template'; |
|
191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | + $table_name = 'esp_event_message_template'; |
|
191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EMT_ID), |
195 | 195 | KEY EVT_ID (EVT_ID), |
196 | 196 | KEY GRP_ID (GRP_ID)"; |
197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_meta'; |
|
199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_meta'; |
|
199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,34 +211,34 @@ discard block |
||
211 | 211 | EVT_donations tinyint(1) NULL, |
212 | 212 | PRIMARY KEY (EVTM_ID), |
213 | 213 | KEY EVT_ID (EVT_ID)"; |
214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | - $table_name = 'esp_event_question_group'; |
|
216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $table_name = 'esp_event_question_group'; |
|
216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
220 | 220 | PRIMARY KEY (EQG_ID), |
221 | 221 | KEY EVT_ID (EVT_ID), |
222 | 222 | KEY QSG_ID (QSG_ID)"; |
223 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_event_venue'; |
|
225 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_event_venue'; |
|
225 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | EVT_ID bigint(20) unsigned NOT NULL, |
227 | 227 | VNU_ID bigint(20) unsigned NOT NULL, |
228 | 228 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
229 | 229 | PRIMARY KEY (EVV_ID)"; |
230 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | - $table_name = 'esp_extra_meta'; |
|
232 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | + $table_name = 'esp_extra_meta'; |
|
232 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
233 | 233 | OBJ_ID int(11) DEFAULT NULL, |
234 | 234 | EXM_type varchar(45) DEFAULT NULL, |
235 | 235 | EXM_key varchar(45) DEFAULT NULL, |
236 | 236 | EXM_value text, |
237 | 237 | PRIMARY KEY (EXM_ID), |
238 | 238 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
239 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | - $table_name = 'esp_extra_join'; |
|
241 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
239 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | + $table_name = 'esp_extra_join'; |
|
241 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
242 | 242 | EXJ_first_model_id varchar(6) NOT NULL, |
243 | 243 | EXJ_first_model_name varchar(20) NOT NULL, |
244 | 244 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | PRIMARY KEY (EXJ_ID), |
247 | 247 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
248 | 248 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
249 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | - $table_name = 'esp_line_item'; |
|
251 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
249 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | + $table_name = 'esp_line_item'; |
|
251 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
252 | 252 | LIN_code varchar(245) NOT NULL DEFAULT '', |
253 | 253 | TXN_ID int(11) DEFAULT NULL, |
254 | 254 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | PRIMARY KEY (LIN_ID), |
268 | 268 | KEY LIN_code (LIN_code(191)), |
269 | 269 | KEY TXN_ID (TXN_ID)"; |
270 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | - $table_name = 'esp_log'; |
|
272 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
270 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | + $table_name = 'esp_log'; |
|
272 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
273 | 273 | LOG_time datetime DEFAULT NULL, |
274 | 274 | OBJ_ID varchar(45) DEFAULT NULL, |
275 | 275 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | KEY LOG_time (LOG_time), |
281 | 281 | KEY OBJ (OBJ_type,OBJ_ID), |
282 | 282 | KEY LOG_type (LOG_type)"; |
283 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
284 | - $table_name = 'esp_message'; |
|
285 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
286 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
287 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
288 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
283 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
284 | + $table_name = 'esp_message'; |
|
285 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
286 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
287 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
288 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | 289 | GRP_ID int(10) unsigned NULL, |
290 | 290 | MSG_token varchar(255) NULL, |
291 | 291 | TXN_ID int(10) unsigned NULL, |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | KEY STS_ID (STS_ID), |
318 | 318 | KEY MSG_created (MSG_created), |
319 | 319 | KEY MSG_modified (MSG_modified)"; |
320 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_message_template'; |
|
322 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_message_template'; |
|
322 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | 323 | GRP_ID int(10) unsigned NOT NULL, |
324 | 324 | MTP_context varchar(50) NOT NULL, |
325 | 325 | MTP_template_field varchar(30) NOT NULL, |
326 | 326 | MTP_content text NOT NULL, |
327 | 327 | PRIMARY KEY (MTP_ID), |
328 | 328 | KEY GRP_ID (GRP_ID)"; |
329 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | - $table_name = 'esp_message_template_group'; |
|
331 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
329 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | + $table_name = 'esp_message_template_group'; |
|
331 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | 332 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
333 | 333 | MTP_name varchar(245) NOT NULL DEFAULT '', |
334 | 334 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
341 | 341 | PRIMARY KEY (GRP_ID), |
342 | 342 | KEY MTP_user_id (MTP_user_id)"; |
343 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | - $table_name = 'esp_payment'; |
|
345 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | + $table_name = 'esp_payment'; |
|
345 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | TXN_ID int(10) unsigned DEFAULT NULL, |
347 | 347 | STS_ID varchar(3) DEFAULT NULL, |
348 | 348 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | PRIMARY KEY (PAY_ID), |
360 | 360 | KEY PAY_timestamp (PAY_timestamp), |
361 | 361 | KEY TXN_ID (TXN_ID)"; |
362 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | - $table_name = 'esp_payment_method'; |
|
364 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
362 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | + $table_name = 'esp_payment_method'; |
|
364 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
365 | 365 | PMD_type varchar(124) DEFAULT NULL, |
366 | 366 | PMD_name varchar(255) DEFAULT NULL, |
367 | 367 | PMD_desc text, |
@@ -377,24 +377,24 @@ discard block |
||
377 | 377 | PRIMARY KEY (PMD_ID), |
378 | 378 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
379 | 379 | KEY PMD_type (PMD_type)"; |
380 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | - $table_name = "esp_ticket_price"; |
|
382 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
380 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | + $table_name = "esp_ticket_price"; |
|
382 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | 383 | TKT_ID int(10) unsigned NOT NULL, |
384 | 384 | PRC_ID int(10) unsigned NOT NULL, |
385 | 385 | PRIMARY KEY (TKP_ID), |
386 | 386 | KEY TKT_ID (TKT_ID), |
387 | 387 | KEY PRC_ID (PRC_ID)"; |
388 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | - $table_name = "esp_ticket_template"; |
|
390 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
388 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | + $table_name = "esp_ticket_template"; |
|
390 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | 391 | TTM_name varchar(45) NOT NULL, |
392 | 392 | TTM_description text, |
393 | 393 | TTM_file varchar(45), |
394 | 394 | PRIMARY KEY (TTM_ID)"; |
395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | - $table_name = 'esp_question'; |
|
397 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | + $table_name = 'esp_question'; |
|
397 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
398 | 398 | QST_display_text text NOT NULL, |
399 | 399 | QST_admin_label varchar(255) NOT NULL, |
400 | 400 | QST_system varchar(25) DEFAULT NULL, |
@@ -408,18 +408,18 @@ discard block |
||
408 | 408 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
409 | 409 | PRIMARY KEY (QST_ID), |
410 | 410 | KEY QST_order (QST_order)'; |
411 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | - $table_name = 'esp_question_group_question'; |
|
413 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | + $table_name = 'esp_question_group_question'; |
|
413 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | 414 | QSG_ID int(10) unsigned NOT NULL, |
415 | 415 | QST_ID int(10) unsigned NOT NULL, |
416 | 416 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
417 | 417 | PRIMARY KEY (QGQ_ID), |
418 | 418 | KEY QST_ID (QST_ID), |
419 | 419 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | - $table_name = 'esp_question_option'; |
|
422 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | + $table_name = 'esp_question_option'; |
|
422 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
423 | 423 | QSO_value varchar(255) NOT NULL, |
424 | 424 | QSO_desc text NOT NULL, |
425 | 425 | QST_ID int(10) unsigned NOT NULL, |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | PRIMARY KEY (QSO_ID), |
430 | 430 | KEY QST_ID (QST_ID), |
431 | 431 | KEY QSO_order (QSO_order)"; |
432 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $table_name = 'esp_registration'; |
|
434 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_registration'; |
|
434 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | 435 | EVT_ID bigint(20) unsigned NOT NULL, |
436 | 436 | ATT_ID bigint(20) unsigned NOT NULL, |
437 | 437 | TXN_ID int(10) unsigned NOT NULL, |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | KEY TKT_ID (TKT_ID), |
456 | 456 | KEY EVT_ID (EVT_ID), |
457 | 457 | KEY STS_ID (STS_ID)"; |
458 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | - $table_name = 'esp_registration_payment'; |
|
460 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
458 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | + $table_name = 'esp_registration_payment'; |
|
460 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
461 | 461 | REG_ID int(10) unsigned NOT NULL, |
462 | 462 | PAY_ID int(10) unsigned NULL, |
463 | 463 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
464 | 464 | PRIMARY KEY (RPY_ID), |
465 | 465 | KEY REG_ID (REG_ID), |
466 | 466 | KEY PAY_ID (PAY_ID)"; |
467 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | - $table_name = 'esp_state'; |
|
469 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
467 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | + $table_name = 'esp_state'; |
|
469 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
470 | 470 | CNT_ISO varchar(2) NOT NULL, |
471 | 471 | STA_abbrev varchar(24) NOT NULL, |
472 | 472 | STA_name varchar(100) NOT NULL, |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | PRIMARY KEY (STA_ID), |
475 | 475 | KEY STA_abbrev (STA_abbrev), |
476 | 476 | KEY CNT_ISO (CNT_ISO)"; |
477 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | - $table_name = 'esp_status'; |
|
479 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
477 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | + $table_name = 'esp_status'; |
|
479 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
480 | 480 | STS_code varchar(45) NOT NULL, |
481 | 481 | STS_type varchar(45) NOT NULL, |
482 | 482 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
485 | 485 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
486 | 486 | KEY STS_type (STS_type)"; |
487 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - $table_name = 'esp_transaction'; |
|
489 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + $table_name = 'esp_transaction'; |
|
489 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
490 | 490 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
491 | 491 | TXN_total decimal(12,3) DEFAULT '0.00', |
492 | 492 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | PRIMARY KEY (TXN_ID), |
499 | 499 | KEY TXN_timestamp (TXN_timestamp), |
500 | 500 | KEY STS_ID (STS_ID)"; |
501 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | - $table_name = 'esp_venue_meta'; |
|
503 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
501 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | + $table_name = 'esp_venue_meta'; |
|
503 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
504 | 504 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
505 | 505 | VNU_address varchar(255) DEFAULT NULL, |
506 | 506 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | KEY VNU_ID (VNU_ID), |
520 | 520 | KEY STA_ID (STA_ID), |
521 | 521 | KEY CNT_ISO (CNT_ISO)"; |
522 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | - //modified tables |
|
524 | - $table_name = "esp_price"; |
|
525 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | + //modified tables |
|
524 | + $table_name = "esp_price"; |
|
525 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
526 | 526 | PRT_ID tinyint(3) unsigned NOT NULL, |
527 | 527 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
528 | 528 | PRC_name varchar(245) NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | PRC_parent int(10) unsigned DEFAULT 0, |
536 | 536 | PRIMARY KEY (PRC_ID), |
537 | 537 | KEY PRT_ID (PRT_ID)"; |
538 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | - $table_name = "esp_price_type"; |
|
540 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = "esp_price_type"; |
|
540 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | PRT_name varchar(45) NOT NULL, |
542 | 542 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
543 | 543 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
547 | 547 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
548 | 548 | PRIMARY KEY (PRT_ID)"; |
549 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | - $table_name = "esp_ticket"; |
|
551 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
549 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | + $table_name = "esp_ticket"; |
|
551 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
552 | 552 | TTM_ID int(10) unsigned NOT NULL, |
553 | 553 | TKT_name varchar(245) NOT NULL DEFAULT '', |
554 | 554 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
572 | 572 | PRIMARY KEY (TKT_ID), |
573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
574 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | - $table_name = 'esp_question_group'; |
|
576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
574 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | + $table_name = 'esp_question_group'; |
|
576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
577 | 577 | QSG_name varchar(255) NOT NULL, |
578 | 578 | QSG_identifier varchar(100) NOT NULL, |
579 | 579 | QSG_desc text NULL, |
@@ -586,138 +586,138 @@ discard block |
||
586 | 586 | PRIMARY KEY (QSG_ID), |
587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
588 | 588 | KEY QSG_order (QSG_order)'; |
589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | - //(because many need to convert old string states to foreign keys into the states table) |
|
593 | - $script_4_1_defaults->insert_default_states(); |
|
594 | - $script_4_1_defaults->insert_default_countries(); |
|
595 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | - $script_4_5_defaults->insert_default_price_types(); |
|
598 | - $script_4_5_defaults->insert_default_prices(); |
|
599 | - $script_4_5_defaults->insert_default_tickets(); |
|
600 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | - $script_4_6_defaults->insert_default_currencies(); |
|
604 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | - $script_4_8_defaults->verify_new_countries(); |
|
607 | - $script_4_8_defaults->verify_new_currencies(); |
|
608 | - $this->verify_db_collations(); |
|
609 | - $this->verify_db_collations_again(); |
|
610 | - return true; |
|
611 | - } |
|
589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | + //(because many need to convert old string states to foreign keys into the states table) |
|
593 | + $script_4_1_defaults->insert_default_states(); |
|
594 | + $script_4_1_defaults->insert_default_countries(); |
|
595 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | + $script_4_5_defaults->insert_default_price_types(); |
|
598 | + $script_4_5_defaults->insert_default_prices(); |
|
599 | + $script_4_5_defaults->insert_default_tickets(); |
|
600 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | + $script_4_6_defaults->insert_default_currencies(); |
|
604 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | + $script_4_8_defaults->verify_new_countries(); |
|
607 | + $script_4_8_defaults->verify_new_currencies(); |
|
608 | + $this->verify_db_collations(); |
|
609 | + $this->verify_db_collations_again(); |
|
610 | + return true; |
|
611 | + } |
|
612 | 612 | |
613 | 613 | |
614 | 614 | |
615 | - /** |
|
616 | - * @return boolean |
|
617 | - */ |
|
618 | - public function schema_changes_after_migration() |
|
619 | - { |
|
620 | - return true; |
|
621 | - } |
|
615 | + /** |
|
616 | + * @return boolean |
|
617 | + */ |
|
618 | + public function schema_changes_after_migration() |
|
619 | + { |
|
620 | + return true; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | |
624 | 624 | |
625 | - public function migration_page_hooks() |
|
626 | - { |
|
627 | - } |
|
625 | + public function migration_page_hooks() |
|
626 | + { |
|
627 | + } |
|
628 | 628 | |
629 | 629 | |
630 | 630 | |
631 | - /** |
|
632 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
633 | - * |
|
634 | - * @return void |
|
635 | - */ |
|
636 | - public function verify_db_collations() |
|
637 | - { |
|
638 | - if (get_option('ee_verified_db_collations', false)) { |
|
639 | - return; |
|
640 | - } |
|
641 | - // grab tables from each model |
|
642 | - $tables_to_check = array(); |
|
643 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
644 | - if (method_exists($model_name, 'instance')) { |
|
645 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
646 | - if ($model_obj instanceof EEM_Base) { |
|
647 | - foreach ($model_obj->get_tables() as $table) { |
|
648 | - if ( |
|
649 | - strpos($table->get_table_name(), 'esp_') |
|
650 | - && (is_main_site()//for main tables, verify global tables |
|
651 | - || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
652 | - ) |
|
653 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
654 | - ) { |
|
655 | - $tables_to_check[] = $table->get_table_name(); |
|
656 | - } |
|
657 | - } |
|
658 | - } |
|
659 | - } |
|
660 | - } |
|
661 | - //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
662 | - //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
663 | - //of hard-coding this |
|
664 | - $addon_tables = array( |
|
665 | - //mailchimp |
|
666 | - 'esp_event_mailchimp_list_group', |
|
667 | - 'esp_event_question_mailchimp_field', |
|
668 | - //multisite |
|
669 | - 'esp_blog_meta', |
|
670 | - //people |
|
671 | - 'esp_people_to_post', |
|
672 | - //promotions |
|
673 | - 'esp_promotion', |
|
674 | - 'esp_promotion_object', |
|
675 | - ); |
|
676 | - foreach ($addon_tables as $table_name) { |
|
677 | - $tables_to_check[] = $table_name; |
|
678 | - } |
|
679 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
680 | - //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
681 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
682 | - //seeing how this ran with the fix from 10435, no need to check again |
|
683 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
684 | - } |
|
631 | + /** |
|
632 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
633 | + * |
|
634 | + * @return void |
|
635 | + */ |
|
636 | + public function verify_db_collations() |
|
637 | + { |
|
638 | + if (get_option('ee_verified_db_collations', false)) { |
|
639 | + return; |
|
640 | + } |
|
641 | + // grab tables from each model |
|
642 | + $tables_to_check = array(); |
|
643 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
644 | + if (method_exists($model_name, 'instance')) { |
|
645 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
646 | + if ($model_obj instanceof EEM_Base) { |
|
647 | + foreach ($model_obj->get_tables() as $table) { |
|
648 | + if ( |
|
649 | + strpos($table->get_table_name(), 'esp_') |
|
650 | + && (is_main_site()//for main tables, verify global tables |
|
651 | + || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
652 | + ) |
|
653 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
654 | + ) { |
|
655 | + $tables_to_check[] = $table->get_table_name(); |
|
656 | + } |
|
657 | + } |
|
658 | + } |
|
659 | + } |
|
660 | + } |
|
661 | + //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
662 | + //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
663 | + //of hard-coding this |
|
664 | + $addon_tables = array( |
|
665 | + //mailchimp |
|
666 | + 'esp_event_mailchimp_list_group', |
|
667 | + 'esp_event_question_mailchimp_field', |
|
668 | + //multisite |
|
669 | + 'esp_blog_meta', |
|
670 | + //people |
|
671 | + 'esp_people_to_post', |
|
672 | + //promotions |
|
673 | + 'esp_promotion', |
|
674 | + 'esp_promotion_object', |
|
675 | + ); |
|
676 | + foreach ($addon_tables as $table_name) { |
|
677 | + $tables_to_check[] = $table_name; |
|
678 | + } |
|
679 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
680 | + //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
681 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
682 | + //seeing how this ran with the fix from 10435, no need to check again |
|
683 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
684 | + } |
|
685 | 685 | |
686 | 686 | |
687 | 687 | |
688 | - /** |
|
689 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
690 | - * which meant some DB collations might not have been updated |
|
691 | - * @return void |
|
692 | - */ |
|
693 | - public function verify_db_collations_again(){ |
|
694 | - if (get_option('ee_verified_db_collations_again', false)) { |
|
695 | - return; |
|
696 | - } |
|
697 | - $tables_to_check = array( |
|
698 | - 'esp_attendee_meta', |
|
699 | - 'esp_message' |
|
700 | - ); |
|
701 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
702 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
703 | - } |
|
688 | + /** |
|
689 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
690 | + * which meant some DB collations might not have been updated |
|
691 | + * @return void |
|
692 | + */ |
|
693 | + public function verify_db_collations_again(){ |
|
694 | + if (get_option('ee_verified_db_collations_again', false)) { |
|
695 | + return; |
|
696 | + } |
|
697 | + $tables_to_check = array( |
|
698 | + 'esp_attendee_meta', |
|
699 | + 'esp_message' |
|
700 | + ); |
|
701 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
702 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
703 | + } |
|
704 | 704 | |
705 | 705 | |
706 | 706 | |
707 | - /** |
|
708 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
709 | - * @param $tables_to_check |
|
710 | - * @return boolean true if logic ran, false if it didn't |
|
711 | - */ |
|
712 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
713 | - { |
|
714 | - foreach ($tables_to_check as $table_name) { |
|
715 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
716 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
717 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
718 | - ) { |
|
719 | - maybe_convert_table_to_utf8mb4($table_name); |
|
720 | - } |
|
721 | - } |
|
722 | - } |
|
707 | + /** |
|
708 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
709 | + * @param $tables_to_check |
|
710 | + * @return boolean true if logic ran, false if it didn't |
|
711 | + */ |
|
712 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
713 | + { |
|
714 | + foreach ($tables_to_check as $table_name) { |
|
715 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
716 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
717 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
718 | + ) { |
|
719 | + maybe_convert_table_to_utf8mb4($table_name); |
|
720 | + } |
|
721 | + } |
|
722 | + } |
|
723 | 723 | } |
724 | 724 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | 16 | foreach ($stages as $filepath) { |
17 | - $matches = array(); |
|
18 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | - $class_to_filepath[$matches[1]] = $filepath; |
|
17 | + $matches = array(); |
|
18 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | + $class_to_filepath[$matches[1]] = $filepath; |
|
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * return EE_DMS_Core_4_6_0 |
|
40 | - * |
|
41 | - * @param TableManager $table_manager |
|
42 | - * @param TableAnalysis $table_analysis |
|
43 | - */ |
|
44 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | - { |
|
46 | - $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | - $this->_priority = 10; |
|
48 | - $this->_migration_stages = array( |
|
49 | - new EE_DMS_4_6_0_gateways(), |
|
50 | - new EE_DMS_4_6_0_question_types(), |
|
51 | - new EE_DMS_4_6_0_country_system_question(), |
|
52 | - new EE_DMS_4_6_0_state_system_question(), |
|
53 | - new EE_DMS_4_6_0_billing_info(), |
|
54 | - new EE_DMS_4_6_0_transactions(), |
|
55 | - new EE_DMS_4_6_0_payments(), |
|
56 | - new EE_DMS_4_6_0_invoice_settings(), |
|
57 | - ); |
|
58 | - parent::__construct($table_manager, $table_analysis); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @param array $version_array |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function can_migrate_from_version($version_array) |
|
68 | - { |
|
69 | - $version_string = $version_array['Core']; |
|
70 | - if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
38 | + /** |
|
39 | + * return EE_DMS_Core_4_6_0 |
|
40 | + * |
|
41 | + * @param TableManager $table_manager |
|
42 | + * @param TableAnalysis $table_analysis |
|
43 | + */ |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | + { |
|
46 | + $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | + $this->_priority = 10; |
|
48 | + $this->_migration_stages = array( |
|
49 | + new EE_DMS_4_6_0_gateways(), |
|
50 | + new EE_DMS_4_6_0_question_types(), |
|
51 | + new EE_DMS_4_6_0_country_system_question(), |
|
52 | + new EE_DMS_4_6_0_state_system_question(), |
|
53 | + new EE_DMS_4_6_0_billing_info(), |
|
54 | + new EE_DMS_4_6_0_transactions(), |
|
55 | + new EE_DMS_4_6_0_payments(), |
|
56 | + new EE_DMS_4_6_0_invoice_settings(), |
|
57 | + ); |
|
58 | + parent::__construct($table_manager, $table_analysis); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @param array $version_array |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function can_migrate_from_version($version_array) |
|
68 | + { |
|
69 | + $version_string = $version_array['Core']; |
|
70 | + if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
71 | 71 | // echo "$version_string can be migrated from"; |
72 | - return true; |
|
73 | - } elseif ( ! $version_string) { |
|
72 | + return true; |
|
73 | + } elseif ( ! $version_string) { |
|
74 | 74 | // echo "no version string provided: $version_string"; |
75 | - //no version string provided... this must be pre 4.3 |
|
76 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | - } else { |
|
75 | + //no version string provided... this must be pre 4.3 |
|
76 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + } else { |
|
78 | 78 | // echo "$version_string doesnt apply"; |
79 | - return false; |
|
80 | - } |
|
81 | - } |
|
79 | + return false; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return bool |
|
87 | - */ |
|
88 | - public function schema_changes_before_migration() |
|
89 | - { |
|
90 | - //relies on 4.1's EEH_Activation::create_table |
|
91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | - $table_name = 'esp_answer'; |
|
93 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
85 | + /** |
|
86 | + * @return bool |
|
87 | + */ |
|
88 | + public function schema_changes_before_migration() |
|
89 | + { |
|
90 | + //relies on 4.1's EEH_Activation::create_table |
|
91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + $table_name = 'esp_answer'; |
|
93 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | 94 | REG_ID INT UNSIGNED NOT NULL, |
95 | 95 | QST_ID INT UNSIGNED NOT NULL, |
96 | 96 | ANS_value TEXT NOT NULL, |
97 | 97 | PRIMARY KEY (ANS_ID)"; |
98 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | - $table_name = 'esp_attendee_meta'; |
|
100 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
98 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | + $table_name = 'esp_attendee_meta'; |
|
100 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
101 | 101 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
102 | 102 | ATT_fname VARCHAR(45) NOT NULL, |
103 | 103 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | KEY ATT_fname (ATT_fname), |
114 | 114 | KEY ATT_lname (ATT_lname), |
115 | 115 | KEY ATT_email (ATT_email)"; |
116 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
116 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
119 | 119 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
120 | 120 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
121 | 121 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | CNT_is_EU TINYINT(1) DEFAULT '0', |
132 | 132 | CNT_active TINYINT(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | - $table_name = 'esp_currency'; |
|
136 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | + $table_name = 'esp_currency'; |
|
136 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
137 | 137 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
138 | 138 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
139 | 139 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
140 | 140 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
141 | 141 | CUR_active TINYINT(1) DEFAULT '0', |
142 | 142 | PRIMARY KEY (CUR_code)"; |
143 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | - $table_name = 'esp_currency_payment_method'; |
|
145 | - $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
143 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | + $table_name = 'esp_currency_payment_method'; |
|
145 | + $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
146 | 146 | CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
147 | 147 | PMD_ID INT(11) NOT NULL, |
148 | 148 | PRIMARY KEY (CPM_ID)"; |
149 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | - $table_name = 'esp_datetime'; |
|
151 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
149 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | + $table_name = 'esp_datetime'; |
|
151 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
152 | 152 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
153 | 153 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
154 | 154 | DTT_description TEXT NOT NULL, |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | PRIMARY KEY (DTT_ID), |
164 | 164 | KEY EVT_ID (EVT_ID), |
165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
166 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | - $table_name = 'esp_event_meta'; |
|
168 | - $sql = " |
|
166 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | + $table_name = 'esp_event_meta'; |
|
168 | + $sql = " |
|
169 | 169 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
170 | 170 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
171 | 171 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -180,31 +180,31 @@ discard block |
||
180 | 180 | EVT_external_URL VARCHAR(200) NULL, |
181 | 181 | EVT_donations TINYINT(1) NULL, |
182 | 182 | PRIMARY KEY (EVTM_ID)"; |
183 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | - $table_name = 'esp_event_question_group'; |
|
185 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | + $table_name = 'esp_event_question_group'; |
|
185 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
186 | 186 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
187 | 187 | QSG_ID INT UNSIGNED NOT NULL, |
188 | 188 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
189 | 189 | PRIMARY KEY (EQG_ID)"; |
190 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | - $table_name = 'esp_event_venue'; |
|
192 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
190 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | + $table_name = 'esp_event_venue'; |
|
192 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
193 | 193 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
194 | 194 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
195 | 195 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
196 | 196 | PRIMARY KEY (EVV_ID)"; |
197 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_extra_meta'; |
|
199 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_extra_meta'; |
|
199 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | OBJ_ID INT(11) DEFAULT NULL, |
201 | 201 | EXM_type VARCHAR(45) DEFAULT NULL, |
202 | 202 | EXM_key VARCHAR(45) DEFAULT NULL, |
203 | 203 | EXM_value TEXT, |
204 | 204 | PRIMARY KEY (EXM_ID)"; |
205 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | - $table_name = 'esp_line_item'; |
|
207 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
205 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | + $table_name = 'esp_line_item'; |
|
207 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
208 | 208 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
209 | 209 | TXN_ID INT(11) DEFAULT NULL, |
210 | 210 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | OBJ_ID INT(11) DEFAULT NULL, |
221 | 221 | OBJ_type VARCHAR(45)DEFAULT NULL, |
222 | 222 | PRIMARY KEY (LIN_ID)"; |
223 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_log'; |
|
225 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_log'; |
|
225 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | LOG_time DATETIME DEFAULT NULL, |
227 | 227 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
228 | 228 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -230,19 +230,19 @@ discard block |
||
230 | 230 | LOG_message TEXT, |
231 | 231 | LOG_wp_user INT(11) DEFAULT NULL, |
232 | 232 | PRIMARY KEY (LOG_ID)"; |
233 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | - $table_name = 'esp_message_template'; |
|
235 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
233 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $table_name = 'esp_message_template'; |
|
235 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
236 | 236 | GRP_ID INT(10) UNSIGNED NOT NULL, |
237 | 237 | MTP_context VARCHAR(50) NOT NULL, |
238 | 238 | MTP_template_field VARCHAR(30) NOT NULL, |
239 | 239 | MTP_content TEXT NOT NULL, |
240 | 240 | PRIMARY KEY (MTP_ID), |
241 | 241 | KEY GRP_ID (GRP_ID)"; |
242 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | - $table_name = 'esp_message_template_group'; |
|
245 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
242 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | + $table_name = 'esp_message_template_group'; |
|
245 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
246 | 246 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
247 | 247 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
248 | 248 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
255 | 255 | PRIMARY KEY (GRP_ID), |
256 | 256 | KEY MTP_user_id (MTP_user_id)"; |
257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | - $table_name = 'esp_event_message_template'; |
|
259 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | + $table_name = 'esp_event_message_template'; |
|
259 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
260 | 260 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
261 | 261 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
262 | 262 | PRIMARY KEY (EMT_ID), |
263 | 263 | KEY EVT_ID (EVT_ID), |
264 | 264 | KEY GRP_ID (GRP_ID)"; |
265 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | - $table_name = 'esp_payment'; |
|
267 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
265 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | + $table_name = 'esp_payment'; |
|
267 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
268 | 268 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
269 | 269 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
270 | 270 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | PRIMARY KEY (PAY_ID), |
282 | 282 | KEY TXN_ID (TXN_ID), |
283 | 283 | KEY PAY_timestamp (PAY_timestamp)"; |
284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | - $table_name = 'esp_payment_method'; |
|
286 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | + $table_name = 'esp_payment_method'; |
|
286 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
287 | 287 | PMD_type VARCHAR(124) DEFAULT NULL, |
288 | 288 | PMD_name VARCHAR(255) DEFAULT NULL, |
289 | 289 | PMD_desc TEXT, |
@@ -298,28 +298,28 @@ discard block |
||
298 | 298 | PMD_scope VARCHAR(255) NULL DEFAULT 'frontend', |
299 | 299 | PRIMARY KEY (PMD_ID), |
300 | 300 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | - $table_name = "esp_ticket_price"; |
|
303 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | + $table_name = "esp_ticket_price"; |
|
303 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
304 | 304 | TKT_ID INT(10) UNSIGNED NOT NULL, |
305 | 305 | PRC_ID INT(10) UNSIGNED NOT NULL, |
306 | 306 | PRIMARY KEY (TKP_ID)"; |
307 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | - $table_name = "esp_datetime_ticket"; |
|
309 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
307 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | + $table_name = "esp_datetime_ticket"; |
|
309 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
310 | 310 | DTT_ID INT(10) UNSIGNED NOT NULL, |
311 | 311 | TKT_ID INT(10) UNSIGNED NOT NULL, |
312 | 312 | PRIMARY KEY (DTK_ID)"; |
313 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | - $table_name = "esp_ticket_template"; |
|
315 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
313 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | + $table_name = "esp_ticket_template"; |
|
315 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
316 | 316 | TTM_name VARCHAR(45) NOT NULL, |
317 | 317 | TTM_description TEXT, |
318 | 318 | TTM_file VARCHAR(45), |
319 | 319 | PRIMARY KEY (TTM_ID)"; |
320 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_question'; |
|
322 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_question'; |
|
322 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
323 | 323 | QST_display_text TEXT NOT NULL, |
324 | 324 | QST_admin_label VARCHAR(255) NOT NULL, |
325 | 325 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -331,25 +331,25 @@ discard block |
||
331 | 331 | QST_wp_user BIGINT UNSIGNED NULL, |
332 | 332 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
333 | 333 | PRIMARY KEY (QST_ID)'; |
334 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | - $table_name = 'esp_question_group_question'; |
|
336 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
334 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | + $table_name = 'esp_question_group_question'; |
|
336 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
337 | 337 | QSG_ID INT UNSIGNED NOT NULL, |
338 | 338 | QST_ID INT UNSIGNED NOT NULL, |
339 | 339 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
340 | 340 | PRIMARY KEY (QGQ_ID) "; |
341 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_question_option'; |
|
343 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
341 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_question_option'; |
|
343 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
344 | 344 | QSO_value VARCHAR(255) NOT NULL, |
345 | 345 | QSO_desc TEXT NOT NULL, |
346 | 346 | QST_ID INT UNSIGNED NOT NULL, |
347 | 347 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
348 | 348 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
349 | 349 | PRIMARY KEY (QSO_ID)"; |
350 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | - $table_name = 'esp_registration'; |
|
352 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_registration'; |
|
352 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
353 | 353 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
354 | 354 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
355 | 355 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | KEY STS_ID (STS_ID), |
373 | 373 | KEY REG_url_link (REG_url_link), |
374 | 374 | KEY REG_code (REG_code)"; |
375 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | - $table_name = 'esp_checkin'; |
|
377 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | + $table_name = 'esp_checkin'; |
|
377 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
378 | 378 | REG_ID INT(10) UNSIGNED NOT NULL, |
379 | 379 | DTT_ID INT(10) UNSIGNED NOT NULL, |
380 | 380 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
381 | 381 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
382 | 382 | PRIMARY KEY (CHK_ID)"; |
383 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_state'; |
|
385 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_state'; |
|
385 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
386 | 386 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
387 | 387 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
388 | 388 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
389 | 389 | STA_active TINYINT(1) DEFAULT '1', |
390 | 390 | PRIMARY KEY (STA_ID)"; |
391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_status'; |
|
393 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_status'; |
|
393 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
394 | 394 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
395 | 395 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
396 | 396 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
399 | 399 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
400 | 400 | KEY STS_type (STS_type)"; |
401 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | - $table_name = 'esp_transaction'; |
|
403 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
401 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | + $table_name = 'esp_transaction'; |
|
403 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
404 | 404 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
405 | 405 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
406 | 406 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | PRIMARY KEY (TXN_ID), |
413 | 413 | KEY TXN_timestamp (TXN_timestamp), |
414 | 414 | KEY STS_ID (STS_ID)"; |
415 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | - $table_name = 'esp_venue_meta'; |
|
417 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_venue_meta'; |
|
417 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
418 | 418 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
419 | 419 | VNU_address VARCHAR(255) DEFAULT NULL, |
420 | 420 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | PRIMARY KEY (VNUM_ID), |
433 | 433 | KEY STA_ID (STA_ID), |
434 | 434 | KEY CNT_ISO (CNT_ISO)"; |
435 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | - //modified tables |
|
437 | - $table_name = "esp_price"; |
|
438 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
435 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | + //modified tables |
|
437 | + $table_name = "esp_price"; |
|
438 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
439 | 439 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
440 | 440 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
441 | 441 | PRC_name VARCHAR(245) NOT NULL, |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | PRC_wp_user BIGINT UNSIGNED NULL, |
448 | 448 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
449 | 449 | PRIMARY KEY (PRC_ID)"; |
450 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | - $table_name = "esp_price_type"; |
|
452 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
450 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | + $table_name = "esp_price_type"; |
|
452 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
453 | 453 | PRT_name VARCHAR(45) NOT NULL, |
454 | 454 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
455 | 455 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
459 | 459 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
460 | 460 | PRIMARY KEY (PRT_ID)"; |
461 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | - $table_name = "esp_ticket"; |
|
463 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
461 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | + $table_name = "esp_ticket"; |
|
463 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
464 | 464 | TTM_ID INT(10) UNSIGNED NOT NULL, |
465 | 465 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
466 | 466 | TKT_description TEXT NOT NULL, |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
482 | 482 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
483 | 483 | PRIMARY KEY (TKT_ID)"; |
484 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | - $table_name = 'esp_question_group'; |
|
487 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
484 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | + $table_name = 'esp_question_group'; |
|
487 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
488 | 488 | QSG_name VARCHAR(255) NOT NULL, |
489 | 489 | QSG_identifier VARCHAR(100) NOT NULL, |
490 | 490 | QSG_desc TEXT NULL, |
@@ -496,119 +496,119 @@ discard block |
||
496 | 496 | QSG_wp_user BIGINT UNSIGNED NULL, |
497 | 497 | PRIMARY KEY (QSG_ID), |
498 | 498 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
499 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | - //(because many need to convert old string states to foreign keys into the states table) |
|
503 | - $script_4_1_defaults->insert_default_states(); |
|
504 | - $script_4_1_defaults->insert_default_countries(); |
|
505 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | - $script_4_5_defaults->insert_default_price_types(); |
|
508 | - $script_4_5_defaults->insert_default_prices(); |
|
509 | - $script_4_5_defaults->insert_default_tickets(); |
|
510 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | - EE_Config::instance()->update_espresso_config(false, true); |
|
512 | - $this->add_default_admin_only_payments(); |
|
513 | - $this->insert_default_currencies(); |
|
514 | - return true; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * @return boolean |
|
521 | - */ |
|
522 | - public function schema_changes_after_migration() |
|
523 | - { |
|
524 | - return true; |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - public function migration_page_hooks() |
|
530 | - { |
|
531 | - } |
|
532 | - |
|
533 | - |
|
534 | - |
|
535 | - public function add_default_admin_only_payments() |
|
536 | - { |
|
537 | - global $wpdb; |
|
538 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | - $default_admin_only_payment_methods = apply_filters( |
|
544 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | - array( |
|
546 | - __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | - __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | - __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | - __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | - __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | - __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | - 'event_espresso'), |
|
553 | - __("Money Order", 'event_espresso') => '', |
|
554 | - __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | - __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | - )); |
|
557 | - //make sure we hae payment method records for the following |
|
558 | - //so admins can record payments for them from the admin page |
|
559 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | - $slug = sanitize_key($nicename); |
|
561 | - //check that such a payment method exists |
|
562 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | - if ( ! $exists) { |
|
564 | - $values = array( |
|
565 | - 'PMD_type' => 'Admin_Only', |
|
566 | - 'PMD_name' => $nicename, |
|
567 | - 'PMD_admin_name' => $nicename, |
|
568 | - 'PMD_admin_desc' => $description, |
|
569 | - 'PMD_slug' => $slug, |
|
570 | - 'PMD_wp_user' => $user_id, |
|
571 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | - ); |
|
573 | - $success = $wpdb->insert( |
|
574 | - $table_name, |
|
575 | - $values, |
|
576 | - array( |
|
577 | - '%s',//PMD_type |
|
578 | - '%s',//PMD_name |
|
579 | - '%s',//PMD_admin_name |
|
580 | - '%s',//PMD_admin_desc |
|
581 | - '%s',//PMD_slug |
|
582 | - '%d',//PMD_wp_user |
|
583 | - '%s',//PMD_scope |
|
584 | - ) |
|
585 | - ); |
|
586 | - if ( ! $success) { |
|
587 | - $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | - "event_espresso"), $this->_json_encode($values))); |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * insert_default_countries |
|
599 | - * |
|
600 | - * @static |
|
601 | - * @return void |
|
602 | - */ |
|
603 | - public function insert_default_currencies() |
|
604 | - { |
|
605 | - global $wpdb; |
|
606 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | - $countries = $wpdb->get_var($SQL); |
|
610 | - if ( ! $countries) { |
|
611 | - $SQL = "INSERT INTO $currency_table |
|
499 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | + //(because many need to convert old string states to foreign keys into the states table) |
|
503 | + $script_4_1_defaults->insert_default_states(); |
|
504 | + $script_4_1_defaults->insert_default_countries(); |
|
505 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | + $script_4_5_defaults->insert_default_price_types(); |
|
508 | + $script_4_5_defaults->insert_default_prices(); |
|
509 | + $script_4_5_defaults->insert_default_tickets(); |
|
510 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | + EE_Config::instance()->update_espresso_config(false, true); |
|
512 | + $this->add_default_admin_only_payments(); |
|
513 | + $this->insert_default_currencies(); |
|
514 | + return true; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * @return boolean |
|
521 | + */ |
|
522 | + public function schema_changes_after_migration() |
|
523 | + { |
|
524 | + return true; |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + public function migration_page_hooks() |
|
530 | + { |
|
531 | + } |
|
532 | + |
|
533 | + |
|
534 | + |
|
535 | + public function add_default_admin_only_payments() |
|
536 | + { |
|
537 | + global $wpdb; |
|
538 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | + $default_admin_only_payment_methods = apply_filters( |
|
544 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | + array( |
|
546 | + __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | + __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | + __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | + __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | + __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | + __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | + 'event_espresso'), |
|
553 | + __("Money Order", 'event_espresso') => '', |
|
554 | + __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | + __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | + )); |
|
557 | + //make sure we hae payment method records for the following |
|
558 | + //so admins can record payments for them from the admin page |
|
559 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | + $slug = sanitize_key($nicename); |
|
561 | + //check that such a payment method exists |
|
562 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | + if ( ! $exists) { |
|
564 | + $values = array( |
|
565 | + 'PMD_type' => 'Admin_Only', |
|
566 | + 'PMD_name' => $nicename, |
|
567 | + 'PMD_admin_name' => $nicename, |
|
568 | + 'PMD_admin_desc' => $description, |
|
569 | + 'PMD_slug' => $slug, |
|
570 | + 'PMD_wp_user' => $user_id, |
|
571 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | + ); |
|
573 | + $success = $wpdb->insert( |
|
574 | + $table_name, |
|
575 | + $values, |
|
576 | + array( |
|
577 | + '%s',//PMD_type |
|
578 | + '%s',//PMD_name |
|
579 | + '%s',//PMD_admin_name |
|
580 | + '%s',//PMD_admin_desc |
|
581 | + '%s',//PMD_slug |
|
582 | + '%d',//PMD_wp_user |
|
583 | + '%s',//PMD_scope |
|
584 | + ) |
|
585 | + ); |
|
586 | + if ( ! $success) { |
|
587 | + $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | + "event_espresso"), $this->_json_encode($values))); |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * insert_default_countries |
|
599 | + * |
|
600 | + * @static |
|
601 | + * @return void |
|
602 | + */ |
|
603 | + public function insert_default_currencies() |
|
604 | + { |
|
605 | + global $wpdb; |
|
606 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | + $countries = $wpdb->get_var($SQL); |
|
610 | + if ( ! $countries) { |
|
611 | + $SQL = "INSERT INTO $currency_table |
|
612 | 612 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
613 | 613 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
614 | 614 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -762,10 +762,10 @@ discard block |
||
762 | 762 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
763 | 763 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
764 | 764 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
765 | - $wpdb->query($SQL); |
|
766 | - } |
|
767 | - } |
|
768 | - } |
|
765 | + $wpdb->query($SQL); |
|
766 | + } |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
771 | 771 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace EventEspresso\core\exceptions; |
4 | 4 | |
5 | 5 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('No direct script access allowed'); |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -18,32 +18,32 @@ discard block |
||
18 | 18 | class InvalidEntityException extends \InvalidArgumentException |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * InvalidInterfaceException constructor. |
|
23 | - * |
|
24 | - * @param string $actual classname of what we got |
|
25 | - * @param string $expected classname of the entity we wanted |
|
26 | - * @param string $message |
|
27 | - * @param int $code |
|
28 | - * @param \Exception $previous |
|
29 | - */ |
|
30 | - public function __construct($actual, $expected, $message = '', $code = 0, \Exception $previous = null) |
|
31 | - { |
|
32 | - if (empty($message)) { |
|
33 | - $message = sprintf( |
|
34 | - __( |
|
35 | - 'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s', |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - is_object($actual) |
|
39 | - ? get_class($actual) |
|
40 | - : gettype($actual), |
|
41 | - $expected, |
|
42 | - var_export($actual, true) |
|
43 | - ); |
|
44 | - } |
|
45 | - parent::__construct($message, $code, $previous); |
|
46 | - } |
|
21 | + /** |
|
22 | + * InvalidInterfaceException constructor. |
|
23 | + * |
|
24 | + * @param string $actual classname of what we got |
|
25 | + * @param string $expected classname of the entity we wanted |
|
26 | + * @param string $message |
|
27 | + * @param int $code |
|
28 | + * @param \Exception $previous |
|
29 | + */ |
|
30 | + public function __construct($actual, $expected, $message = '', $code = 0, \Exception $previous = null) |
|
31 | + { |
|
32 | + if (empty($message)) { |
|
33 | + $message = sprintf( |
|
34 | + __( |
|
35 | + 'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s', |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + is_object($actual) |
|
39 | + ? get_class($actual) |
|
40 | + : gettype($actual), |
|
41 | + $expected, |
|
42 | + var_export($actual, true) |
|
43 | + ); |
|
44 | + } |
|
45 | + parent::__construct($message, $code, $previous); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | // End of file InvalidEntityException.php |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace EventEspresso\core\exceptions; |
4 | 4 | |
5 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -15,117 +15,117 @@ discard block |
||
15 | 15 | class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param null $validation_error_message |
|
20 | - */ |
|
21 | - public function __construct($validation_error_message = null) |
|
22 | - { |
|
23 | - if (! $validation_error_message) { |
|
24 | - $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
|
25 | - } |
|
26 | - parent::__construct($validation_error_message); |
|
27 | - } |
|
18 | + /** |
|
19 | + * @param null $validation_error_message |
|
20 | + */ |
|
21 | + public function __construct($validation_error_message = null) |
|
22 | + { |
|
23 | + if (! $validation_error_message) { |
|
24 | + $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
|
25 | + } |
|
26 | + parent::__construct($validation_error_message); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * just checks the field isn't blank |
|
33 | - * |
|
34 | - * @param $normalized_value |
|
35 | - * @return bool |
|
36 | - * @throws \EE_Validation_Error |
|
37 | - */ |
|
38 | - public function validate($normalized_value) |
|
39 | - { |
|
40 | - if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
41 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
42 | - } |
|
43 | - } |
|
31 | + /** |
|
32 | + * just checks the field isn't blank |
|
33 | + * |
|
34 | + * @param $normalized_value |
|
35 | + * @return bool |
|
36 | + * @throws \EE_Validation_Error |
|
37 | + */ |
|
38 | + public function validate($normalized_value) |
|
39 | + { |
|
40 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
41 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function get_jquery_validation_rule_array() |
|
51 | - { |
|
52 | - return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
53 | - } |
|
47 | + /** |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function get_jquery_validation_rule_array() |
|
51 | + { |
|
52 | + return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Validate an email address. |
|
59 | - * Provide email address (raw input) |
|
60 | - * |
|
61 | - * @param $email |
|
62 | - * @return bool of whether the email is valid or not |
|
63 | - * @throws \EE_Validation_Error |
|
64 | - */ |
|
65 | - private function _validate_email($email) |
|
66 | - { |
|
67 | - $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
68 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
69 | - : 'wp_default'; |
|
70 | - if (! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
71 | - // email not in correct {string}@{string} format |
|
72 | - return false; |
|
73 | - } else { |
|
74 | - $atIndex = strrpos($email, "@"); |
|
75 | - $domain = substr($email, $atIndex + 1); |
|
76 | - $local = substr($email, 0, $atIndex); |
|
77 | - $localLen = strlen($local); |
|
78 | - $domainLen = strlen($domain); |
|
79 | - if ($localLen < 1 || $localLen > 64) { |
|
80 | - // local part length exceeded |
|
81 | - return false; |
|
82 | - } else if ($domainLen < 1 || $domainLen > 255) { |
|
83 | - // domain part length exceeded |
|
84 | - return false; |
|
85 | - } else if ($local[0] === '.' || $local[$localLen - 1] === '.') { |
|
86 | - // local part starts or ends with '.' |
|
87 | - return false; |
|
88 | - } else if (preg_match('/\\.\\./', $local)) { |
|
89 | - // local part has two consecutive dots |
|
90 | - return false; |
|
91 | - } else if (preg_match('/\\.\\./', $domain)) { |
|
92 | - // domain part has two consecutive dots |
|
93 | - return false; |
|
94 | - } else if ($validation_level === 'wp_default') { |
|
95 | - return is_email($email); |
|
96 | - } else if ( |
|
97 | - ($validation_level === 'i18n' || $validation_level === 'i18n_dns') |
|
98 | - // plz see http://stackoverflow.com/a/24817336 re: the following regex |
|
99 | - && ! preg_match( |
|
100 | - '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u', |
|
101 | ||
102 | - ) |
|
103 | - ) { |
|
104 | - return false; |
|
105 | - } |
|
106 | - if ($validation_level === 'i18n_dns') { |
|
107 | - if (! checkdnsrr($domain, "MX")) { |
|
108 | - // domain not found in MX records |
|
109 | - throw new EE_Validation_Error( |
|
110 | - __( |
|
111 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
112 | - 'event_espresso' |
|
113 | - ) |
|
114 | - ); |
|
115 | - } else if (! checkdnsrr($domain, "A")) { |
|
116 | - // domain not found in A records |
|
117 | - throw new EE_Validation_Error( |
|
118 | - __( |
|
119 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
120 | - 'event_espresso' |
|
121 | - ) |
|
122 | - ); |
|
123 | - } |
|
124 | - } |
|
125 | - } |
|
126 | - // you have successfully run the gauntlet young Padawan |
|
127 | - return true; |
|
128 | - } |
|
57 | + /** |
|
58 | + * Validate an email address. |
|
59 | + * Provide email address (raw input) |
|
60 | + * |
|
61 | + * @param $email |
|
62 | + * @return bool of whether the email is valid or not |
|
63 | + * @throws \EE_Validation_Error |
|
64 | + */ |
|
65 | + private function _validate_email($email) |
|
66 | + { |
|
67 | + $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
68 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
69 | + : 'wp_default'; |
|
70 | + if (! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
71 | + // email not in correct {string}@{string} format |
|
72 | + return false; |
|
73 | + } else { |
|
74 | + $atIndex = strrpos($email, "@"); |
|
75 | + $domain = substr($email, $atIndex + 1); |
|
76 | + $local = substr($email, 0, $atIndex); |
|
77 | + $localLen = strlen($local); |
|
78 | + $domainLen = strlen($domain); |
|
79 | + if ($localLen < 1 || $localLen > 64) { |
|
80 | + // local part length exceeded |
|
81 | + return false; |
|
82 | + } else if ($domainLen < 1 || $domainLen > 255) { |
|
83 | + // domain part length exceeded |
|
84 | + return false; |
|
85 | + } else if ($local[0] === '.' || $local[$localLen - 1] === '.') { |
|
86 | + // local part starts or ends with '.' |
|
87 | + return false; |
|
88 | + } else if (preg_match('/\\.\\./', $local)) { |
|
89 | + // local part has two consecutive dots |
|
90 | + return false; |
|
91 | + } else if (preg_match('/\\.\\./', $domain)) { |
|
92 | + // domain part has two consecutive dots |
|
93 | + return false; |
|
94 | + } else if ($validation_level === 'wp_default') { |
|
95 | + return is_email($email); |
|
96 | + } else if ( |
|
97 | + ($validation_level === 'i18n' || $validation_level === 'i18n_dns') |
|
98 | + // plz see http://stackoverflow.com/a/24817336 re: the following regex |
|
99 | + && ! preg_match( |
|
100 | + '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u', |
|
101 | ||
102 | + ) |
|
103 | + ) { |
|
104 | + return false; |
|
105 | + } |
|
106 | + if ($validation_level === 'i18n_dns') { |
|
107 | + if (! checkdnsrr($domain, "MX")) { |
|
108 | + // domain not found in MX records |
|
109 | + throw new EE_Validation_Error( |
|
110 | + __( |
|
111 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
112 | + 'event_espresso' |
|
113 | + ) |
|
114 | + ); |
|
115 | + } else if (! checkdnsrr($domain, "A")) { |
|
116 | + // domain not found in A records |
|
117 | + throw new EE_Validation_Error( |
|
118 | + __( |
|
119 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
120 | + 'event_espresso' |
|
121 | + ) |
|
122 | + ); |
|
123 | + } |
|
124 | + } |
|
125 | + } |
|
126 | + // you have successfully run the gauntlet young Padawan |
|
127 | + return true; |
|
128 | + } |
|
129 | 129 | |
130 | 130 | |
131 | 131 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct($validation_error_message = null) |
22 | 22 | { |
23 | - if (! $validation_error_message) { |
|
23 | + if ( ! $validation_error_message) { |
|
24 | 24 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
25 | 25 | } |
26 | 26 | parent::__construct($validation_error_message); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
68 | 68 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
69 | 69 | : 'wp_default'; |
70 | - if (! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
70 | + if ( ! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
71 | 71 | // email not in correct {string}@{string} format |
72 | 72 | return false; |
73 | 73 | } else { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | if ($validation_level === 'i18n_dns') { |
107 | - if (! checkdnsrr($domain, "MX")) { |
|
107 | + if ( ! checkdnsrr($domain, "MX")) { |
|
108 | 108 | // domain not found in MX records |
109 | 109 | throw new EE_Validation_Error( |
110 | 110 | __( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | 'event_espresso' |
113 | 113 | ) |
114 | 114 | ); |
115 | - } else if (! checkdnsrr($domain, "A")) { |
|
115 | + } else if ( ! checkdnsrr($domain, "A")) { |
|
116 | 116 | // domain not found in A records |
117 | 117 | throw new EE_Validation_Error( |
118 | 118 | __( |
@@ -47,7 +47,7 @@ |
||
47 | 47 | /** |
48 | 48 | * This retrieves any EE_Message_Template_Group in the repo by its ID. |
49 | 49 | * |
50 | - * @param $GRP_ID |
|
50 | + * @param integer $GRP_ID |
|
51 | 51 | * @return EE_Message_Template_Group | null |
52 | 52 | */ |
53 | 53 | public function get_by_ID($GRP_ID) |
@@ -14,115 +14,115 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * EE_Message_Template_Group_Collection constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->interface = 'EE_Message_Template_Group'; |
|
23 | - } |
|
17 | + /** |
|
18 | + * EE_Message_Template_Group_Collection constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->interface = 'EE_Message_Template_Group'; |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Adds the Message Template Group object to the repository. |
|
28 | - * |
|
29 | - * @param $message_template_group |
|
30 | - * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | - * indexing the template by key. If this template is shared among multiple events then |
|
32 | - * include the events as an array. |
|
33 | - * @return bool |
|
34 | - */ |
|
35 | - public function add($message_template_group, $EVT_ID = array()) |
|
36 | - { |
|
37 | - $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | - if ($message_template_group instanceof $this->interface) { |
|
39 | - $data['key'] = $this->getKey( |
|
40 | - $message_template_group->messenger(), |
|
41 | - $message_template_group->message_type(), |
|
42 | - $EVT_ID |
|
43 | - ); |
|
44 | - return parent::add($message_template_group, $data); |
|
45 | - } |
|
46 | - return false; |
|
47 | - } |
|
26 | + /** |
|
27 | + * Adds the Message Template Group object to the repository. |
|
28 | + * |
|
29 | + * @param $message_template_group |
|
30 | + * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | + * indexing the template by key. If this template is shared among multiple events then |
|
32 | + * include the events as an array. |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | + public function add($message_template_group, $EVT_ID = array()) |
|
36 | + { |
|
37 | + $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | + if ($message_template_group instanceof $this->interface) { |
|
39 | + $data['key'] = $this->getKey( |
|
40 | + $message_template_group->messenger(), |
|
41 | + $message_template_group->message_type(), |
|
42 | + $EVT_ID |
|
43 | + ); |
|
44 | + return parent::add($message_template_group, $data); |
|
45 | + } |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | - * |
|
53 | - * @param $GRP_ID |
|
54 | - * @return EE_Message_Template_Group | null |
|
55 | - */ |
|
56 | - public function get_by_ID($GRP_ID) |
|
57 | - { |
|
58 | - $this->rewind(); |
|
59 | - while ($this->valid()) { |
|
60 | - if ($this->current()->ID() === $GRP_ID) { |
|
61 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | - $message_template_group = $this->current(); |
|
63 | - $this->rewind(); |
|
64 | - return $message_template_group; |
|
65 | - } |
|
66 | - $this->next(); |
|
67 | - } |
|
68 | - return null; |
|
69 | - } |
|
50 | + /** |
|
51 | + * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | + * |
|
53 | + * @param $GRP_ID |
|
54 | + * @return EE_Message_Template_Group | null |
|
55 | + */ |
|
56 | + public function get_by_ID($GRP_ID) |
|
57 | + { |
|
58 | + $this->rewind(); |
|
59 | + while ($this->valid()) { |
|
60 | + if ($this->current()->ID() === $GRP_ID) { |
|
61 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | + $message_template_group = $this->current(); |
|
63 | + $this->rewind(); |
|
64 | + return $message_template_group; |
|
65 | + } |
|
66 | + $this->next(); |
|
67 | + } |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Generates a hash used to identify a given Message Template Group. |
|
74 | - * |
|
75 | - * @param string $messenger The EE_messenger->name |
|
76 | - * @param string $message_type The EE_message_type->name |
|
77 | - * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | - * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | - { |
|
83 | - $EVT_ID = (array) $EVT_ID; |
|
84 | - return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | - } |
|
72 | + /** |
|
73 | + * Generates a hash used to identify a given Message Template Group. |
|
74 | + * |
|
75 | + * @param string $messenger The EE_messenger->name |
|
76 | + * @param string $message_type The EE_message_type->name |
|
77 | + * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | + * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | + { |
|
83 | + $EVT_ID = (array) $EVT_ID; |
|
84 | + return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * Generates a hash used to identify a given Message Template Group |
|
90 | - * @param string $messenger The EE_messenger->name |
|
91 | - * @param string $message_type The EE_message_type->name |
|
92 | - * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | - * be included. |
|
94 | - * @since 4.9.40.rc.017 |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | - { |
|
99 | - sort($EVT_ID); |
|
100 | - $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
102 | - } |
|
88 | + /** |
|
89 | + * Generates a hash used to identify a given Message Template Group |
|
90 | + * @param string $messenger The EE_messenger->name |
|
91 | + * @param string $message_type The EE_message_type->name |
|
92 | + * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | + * be included. |
|
94 | + * @since 4.9.40.rc.017 |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | + { |
|
99 | + sort($EVT_ID); |
|
100 | + $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | + return md5($messenger . $message_type . $EVT_ID); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | - * the given string. |
|
108 | - * |
|
109 | - * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | - * @return null|EE_Message_Template_Group |
|
111 | - */ |
|
112 | - public function get_by_key($key) |
|
113 | - { |
|
114 | - $this->rewind(); |
|
115 | - while ($this->valid()) { |
|
116 | - $data = $this->getInfo(); |
|
117 | - if (isset($data['key']) && $data['key'] === $key) { |
|
118 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | - $message_template_group = $this->current(); |
|
120 | - $this->rewind(); |
|
121 | - return $message_template_group; |
|
122 | - } |
|
123 | - $this->next(); |
|
124 | - } |
|
125 | - return null; |
|
126 | - } |
|
105 | + /** |
|
106 | + * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | + * the given string. |
|
108 | + * |
|
109 | + * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | + * @return null|EE_Message_Template_Group |
|
111 | + */ |
|
112 | + public function get_by_key($key) |
|
113 | + { |
|
114 | + $this->rewind(); |
|
115 | + while ($this->valid()) { |
|
116 | + $data = $this->getInfo(); |
|
117 | + if (isset($data['key']) && $data['key'] === $key) { |
|
118 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | + $message_template_group = $this->current(); |
|
120 | + $this->rewind(); |
|
121 | + return $message_template_group; |
|
122 | + } |
|
123 | + $this->next(); |
|
124 | + } |
|
125 | + return null; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | { |
99 | 99 | sort($EVT_ID); |
100 | 100 | $EVT_ID = implode(',', array_unique($EVT_ID)); |
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
101 | + return md5($messenger.$message_type.$EVT_ID); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\exceptions\InvalidSessionDataException; |
3 | 3 | use EventEspresso\core\services\cache\CacheStorageInterface; |
4 | 4 | |
5 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
6 | 6 | /** |
7 | 7 | * |
8 | 8 | * EE_Session class |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * array for defining default session vars |
109 | 109 | * @var array |
110 | 110 | */ |
111 | - private $_default_session_vars = array ( |
|
111 | + private $_default_session_vars = array( |
|
112 | 112 | 'id' => null, |
113 | 113 | 'user_id' => null, |
114 | 114 | 'ip_address' => null, |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | // check if class object is instantiated |
137 | 137 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
138 | 138 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
139 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
140 | - self::$_instance = new self($cache_storage, $encryption ); |
|
139 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
140 | + self::$_instance = new self($cache_storage, $encryption); |
|
141 | 141 | } |
142 | 142 | return self::$_instance; |
143 | 143 | } |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | * @throws \EE_Error |
153 | 153 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
154 | 154 | */ |
155 | - protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null ) { |
|
155 | + protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null) { |
|
156 | 156 | |
157 | 157 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
158 | - if ( ! apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
158 | + if ( ! apply_filters('FHEE_load_EE_Session', true)) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
162 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
163 | - define( 'ESPRESSO_SESSION', true ); |
|
161 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
162 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
163 | + define('ESPRESSO_SESSION', true); |
|
164 | 164 | } |
165 | 165 | // default session lifespan in seconds |
166 | 166 | $this->_lifespan = apply_filters( |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * } |
175 | 175 | */ |
176 | 176 | // retrieve session options from db |
177 | - $session_settings = (array) get_option( 'ee_session_settings', array() ); |
|
178 | - if ( ! empty( $session_settings )) { |
|
177 | + $session_settings = (array) get_option('ee_session_settings', array()); |
|
178 | + if ( ! empty($session_settings)) { |
|
179 | 179 | // cycle though existing session options |
180 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
180 | + foreach ($session_settings as $var_name => $session_setting) { |
|
181 | 181 | // set values for class properties |
182 | - $var_name = '_' . $var_name; |
|
182 | + $var_name = '_'.$var_name; |
|
183 | 183 | $this->{$var_name} = $session_setting; |
184 | 184 | } |
185 | 185 | } |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | // encrypt data via: $this->encryption->encrypt(); |
191 | 191 | $this->encryption = $encryption; |
192 | 192 | // filter hook allows outside functions/classes/plugins to change default empty cart |
193 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
194 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
193 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
194 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
195 | 195 | // apply default session vars |
196 | 196 | $this->_set_defaults(); |
197 | 197 | add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
198 | 198 | // check request for 'clear_session' param |
199 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
199 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
200 | 200 | // once everything is all said and done, |
201 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
201 | + add_action('shutdown', array($this, 'update'), 100); |
|
202 | 202 | $this->configure_garbage_collection_filters(); |
203 | 203 | } |
204 | 204 | |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function _set_defaults() { |
288 | 288 | // set some defaults |
289 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
290 | - if ( is_array( $default_var )) { |
|
291 | - $this->_session_data[ $key ] = array(); |
|
289 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
290 | + if (is_array($default_var)) { |
|
291 | + $this->_session_data[$key] = array(); |
|
292 | 292 | } else { |
293 | - $this->_session_data[ $key ] = ''; |
|
293 | + $this->_session_data[$key] = ''; |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param \EE_Checkout $checkout |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function set_checkout( EE_Checkout $checkout ) { |
|
348 | + public function set_checkout(EE_Checkout $checkout) { |
|
349 | 349 | $this->_session_data['checkout'] = $checkout; |
350 | 350 | return TRUE; |
351 | 351 | } |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | * @return bool |
379 | 379 | * @throws \EE_Error |
380 | 380 | */ |
381 | - public function set_transaction( EE_Transaction $transaction ) { |
|
381 | + public function set_transaction(EE_Transaction $transaction) { |
|
382 | 382 | // first remove the session from the transaction before we save the transaction in the session |
383 | - $transaction->set_txn_session_data( NULL ); |
|
383 | + $transaction->set_txn_session_data(NULL); |
|
384 | 384 | $this->_session_data['transaction'] = $transaction; |
385 | 385 | return TRUE; |
386 | 386 | } |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | * @param bool $reset_cache |
417 | 417 | * @return array |
418 | 418 | */ |
419 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
420 | - if ( $reset_cache ) { |
|
419 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
420 | + if ($reset_cache) { |
|
421 | 421 | $this->reset_cart(); |
422 | 422 | $this->reset_checkout(); |
423 | 423 | $this->reset_transaction(); |
424 | 424 | } |
425 | - if ( ! empty( $key )) { |
|
426 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
427 | - } else { |
|
425 | + if ( ! empty($key)) { |
|
426 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
427 | + } else { |
|
428 | 428 | return $this->_session_data; |
429 | 429 | } |
430 | 430 | } |
@@ -437,20 +437,20 @@ discard block |
||
437 | 437 | * @param array $data |
438 | 438 | * @return TRUE on success, FALSE on fail |
439 | 439 | */ |
440 | - public function set_session_data( $data ) { |
|
440 | + public function set_session_data($data) { |
|
441 | 441 | |
442 | 442 | // nothing ??? bad data ??? go home! |
443 | - if ( empty( $data ) || ! is_array( $data )) { |
|
444 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
443 | + if (empty($data) || ! is_array($data)) { |
|
444 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
445 | 445 | return FALSE; |
446 | 446 | } |
447 | 447 | |
448 | - foreach ( $data as $key =>$value ) { |
|
449 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
450 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
448 | + foreach ($data as $key =>$value) { |
|
449 | + if (isset($this->_default_session_vars[$key])) { |
|
450 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
451 | 451 | return FALSE; |
452 | 452 | } else { |
453 | - $this->_session_data[ $key ] = $value; |
|
453 | + $this->_session_data[$key] = $value; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | * @throws \EE_Error |
469 | 469 | */ |
470 | 470 | private function _espresso_session() { |
471 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
471 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
472 | 472 | // check that session has started |
473 | - if ( session_id() === '' ) { |
|
473 | + if (session_id() === '') { |
|
474 | 474 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
475 | 475 | session_start(); |
476 | 476 | } |
@@ -479,39 +479,39 @@ discard block |
||
479 | 479 | // and the visitors IP |
480 | 480 | $this->_ip_address = $this->_visitor_ip(); |
481 | 481 | // set the "user agent" |
482 | - $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
482 | + $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
483 | 483 | // now let's retrieve what's in the db |
484 | 484 | $session_data = $this->_retrieve_session_data(); |
485 | - if (! empty($session_data)) { |
|
485 | + if ( ! empty($session_data)) { |
|
486 | 486 | // get the current time in UTC |
487 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
487 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
488 | 488 | // and reset the session expiration |
489 | - $this->_expiration = isset( $session_data['expiration'] ) |
|
489 | + $this->_expiration = isset($session_data['expiration']) |
|
490 | 490 | ? $session_data['expiration'] |
491 | 491 | : $this->_time + $this->_lifespan; |
492 | 492 | } else { |
493 | 493 | // set initial site access time and the session expiration |
494 | 494 | $this->_set_init_access_and_expiration(); |
495 | 495 | // set referer |
496 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) |
|
497 | - ? esc_attr( $_SERVER['HTTP_REFERER'] ) |
|
496 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) |
|
497 | + ? esc_attr($_SERVER['HTTP_REFERER']) |
|
498 | 498 | : ''; |
499 | 499 | // no previous session = go back and create one (on top of the data above) |
500 | 500 | return FALSE; |
501 | 501 | } |
502 | 502 | // now the user agent |
503 | - if ( $session_data['user_agent'] !== $this->_user_agent ) { |
|
503 | + if ($session_data['user_agent'] !== $this->_user_agent) { |
|
504 | 504 | return FALSE; |
505 | 505 | } |
506 | 506 | // wait a minute... how old are you? |
507 | - if ( $this->_time > $this->_expiration ) { |
|
507 | + if ($this->_time > $this->_expiration) { |
|
508 | 508 | // yer too old fer me! |
509 | 509 | $this->_expired = true; |
510 | 510 | // wipe out everything that isn't a default session datum |
511 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
511 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
512 | 512 | } |
513 | 513 | // make event espresso session data available to plugin |
514 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
514 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
515 | 515 | return TRUE; |
516 | 516 | |
517 | 517 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | */ |
528 | 528 | protected function _retrieve_session_data() |
529 | 529 | { |
530 | - $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
530 | + $ssn_key = EE_Session::session_id_prefix.$this->_sid; |
|
531 | 531 | try { |
532 | 532 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
533 | 533 | $session_data = $this->cache_storage->get($ssn_key, false); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | } |
537 | 537 | if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
538 | 538 | $hash_check = $this->cache_storage->get( |
539 | - EE_Session::hash_check_prefix . $this->_sid, |
|
539 | + EE_Session::hash_check_prefix.$this->_sid, |
|
540 | 540 | false |
541 | 541 | ); |
542 | 542 | if ($hash_check && $hash_check !== md5($session_data)) { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', |
547 | 547 | 'event_espresso' |
548 | 548 | ), |
549 | - EE_Session::session_id_prefix . $this->_sid |
|
549 | + EE_Session::session_id_prefix.$this->_sid |
|
550 | 550 | ), |
551 | 551 | __FILE__, __FUNCTION__, __LINE__ |
552 | 552 | ); |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | $row = $wpdb->get_row( |
559 | 559 | $wpdb->prepare( |
560 | 560 | "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
561 | - '_transient_' . $ssn_key |
|
561 | + '_transient_'.$ssn_key |
|
562 | 562 | ) |
563 | 563 | ); |
564 | 564 | $session_data = is_object($row) ? $row->option_value : null; |
565 | 565 | if ($session_data) { |
566 | 566 | $session_data = preg_replace_callback( |
567 | 567 | '!s:(d+):"(.*?)";!', |
568 | - function ($match) { |
|
568 | + function($match) { |
|
569 | 569 | return $match[1] === strlen($match[2]) |
570 | 570 | ? $match[0] |
571 | - : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
571 | + : 's:'.strlen($match[2]).':"'.$match[2].'";'; |
|
572 | 572 | }, |
573 | 573 | $session_data |
574 | 574 | ); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | 'event_espresso' |
590 | 590 | ); |
591 | 591 | $msg .= WP_DEBUG |
592 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
592 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
593 | 593 | : ''; |
594 | 594 | throw new InvalidSessionDataException($msg, 0, $e); |
595 | 595 | } |
@@ -602,11 +602,11 @@ discard block |
||
602 | 602 | 'event_espresso' |
603 | 603 | ); |
604 | 604 | $msg .= WP_DEBUG |
605 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
605 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
606 | 606 | : ''; |
607 | 607 | throw new InvalidSessionDataException($msg); |
608 | 608 | } |
609 | - if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) { |
|
609 | + if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) { |
|
610 | 610 | $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
611 | 611 | $session_data['transaction'] |
612 | 612 | ); |
@@ -627,12 +627,12 @@ discard block |
||
627 | 627 | */ |
628 | 628 | protected function _generate_session_id() { |
629 | 629 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
630 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
631 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
630 | + if (isset($_REQUEST['EESID'])) { |
|
631 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
632 | 632 | } else { |
633 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
633 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
634 | 634 | } |
635 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
635 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -644,20 +644,20 @@ discard block |
||
644 | 644 | */ |
645 | 645 | protected function _get_sid_salt() { |
646 | 646 | // was session id salt already saved to db ? |
647 | - if ( empty( $this->_sid_salt ) ) { |
|
647 | + if (empty($this->_sid_salt)) { |
|
648 | 648 | // no? then maybe use WP defined constant |
649 | - if ( defined( 'AUTH_SALT' ) ) { |
|
649 | + if (defined('AUTH_SALT')) { |
|
650 | 650 | $this->_sid_salt = AUTH_SALT; |
651 | 651 | } |
652 | 652 | // if salt doesn't exist or is too short |
653 | - if ( strlen( $this->_sid_salt ) < 32 ) { |
|
653 | + if (strlen($this->_sid_salt) < 32) { |
|
654 | 654 | // create a new one |
655 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
655 | + $this->_sid_salt = wp_generate_password(64); |
|
656 | 656 | } |
657 | 657 | // and save it as a permanent session setting |
658 | - $session_settings = get_option( 'ee_session_settings' ); |
|
659 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
660 | - update_option( 'ee_session_settings', $session_settings ); |
|
658 | + $session_settings = get_option('ee_session_settings'); |
|
659 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
660 | + update_option('ee_session_settings', $session_settings); |
|
661 | 661 | } |
662 | 662 | return $this->_sid_salt; |
663 | 663 | } |
@@ -686,19 +686,19 @@ discard block |
||
686 | 686 | * @return TRUE on success, FALSE on fail |
687 | 687 | * @throws \EE_Error |
688 | 688 | */ |
689 | - public function update( $new_session = FALSE ) { |
|
690 | - $this->_session_data = isset( $this->_session_data ) |
|
691 | - && is_array( $this->_session_data ) |
|
692 | - && isset( $this->_session_data['id']) |
|
689 | + public function update($new_session = FALSE) { |
|
690 | + $this->_session_data = isset($this->_session_data) |
|
691 | + && is_array($this->_session_data) |
|
692 | + && isset($this->_session_data['id']) |
|
693 | 693 | ? $this->_session_data |
694 | 694 | : array(); |
695 | - if ( empty( $this->_session_data )) { |
|
695 | + if (empty($this->_session_data)) { |
|
696 | 696 | $this->_set_defaults(); |
697 | 697 | } |
698 | 698 | $session_data = array(); |
699 | - foreach ( $this->_session_data as $key => $value ) { |
|
699 | + foreach ($this->_session_data as $key => $value) { |
|
700 | 700 | |
701 | - switch( $key ) { |
|
701 | + switch ($key) { |
|
702 | 702 | |
703 | 703 | case 'id' : |
704 | 704 | // session ID |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | break; |
717 | 717 | |
718 | 718 | case 'init_access' : |
719 | - $session_data['init_access'] = absint( $value ); |
|
719 | + $session_data['init_access'] = absint($value); |
|
720 | 720 | break; |
721 | 721 | |
722 | 722 | case 'last_access' : |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | |
727 | 727 | case 'expiration' : |
728 | 728 | // when the session expires |
729 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
729 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
730 | 730 | ? $this->_expiration |
731 | 731 | : $session_data['init_access'] + $this->_lifespan; |
732 | 732 | break; |
@@ -738,11 +738,11 @@ discard block |
||
738 | 738 | |
739 | 739 | case 'pages_visited' : |
740 | 740 | $page_visit = $this->_get_page_visit(); |
741 | - if ( $page_visit ) { |
|
741 | + if ($page_visit) { |
|
742 | 742 | // set pages visited where the first will be the http referrer |
743 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
743 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
744 | 744 | // we'll only save the last 10 page visits. |
745 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
745 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
746 | 746 | } |
747 | 747 | break; |
748 | 748 | |
@@ -756,9 +756,9 @@ discard block |
||
756 | 756 | |
757 | 757 | $this->_session_data = $session_data; |
758 | 758 | // creating a new session does not require saving to the db just yet |
759 | - if ( ! $new_session ) { |
|
759 | + if ( ! $new_session) { |
|
760 | 760 | // ready? let's save |
761 | - if ( $this->_save_session_to_db() ) { |
|
761 | + if ($this->_save_session_to_db()) { |
|
762 | 762 | return TRUE; |
763 | 763 | } else { |
764 | 764 | return FALSE; |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | * @throws \EE_Error |
779 | 779 | */ |
780 | 780 | private function _create_espresso_session( ) { |
781 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
781 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
782 | 782 | // use the update function for now with $new_session arg set to TRUE |
783 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
783 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | EE_Registry::instance()->REQ->front_ajax |
801 | 801 | || ( |
802 | 802 | // OR an admin request that is NOT AJAX |
803 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
803 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
804 | 804 | && is_admin() |
805 | 805 | ) |
806 | 806 | || ( |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | $transaction = $this->transaction(); |
816 | - if ( $transaction instanceof EE_Transaction ) { |
|
817 | - if ( ! $transaction->ID() ) { |
|
816 | + if ($transaction instanceof EE_Transaction) { |
|
817 | + if ( ! $transaction->ID()) { |
|
818 | 818 | $transaction->save(); |
819 | 819 | } |
820 | 820 | $this->_session_data['transaction'] = $transaction->ID(); |
@@ -823,19 +823,19 @@ discard block |
||
823 | 823 | $session_data = serialize($this->_session_data); |
824 | 824 | // do we need to also encode it to avoid corrupted data when saved to the db? |
825 | 825 | $session_data = $this->_use_encryption |
826 | - ? $this->encryption->base64_string_encode( $session_data ) |
|
826 | + ? $this->encryption->base64_string_encode($session_data) |
|
827 | 827 | : $session_data; |
828 | 828 | // maybe save hash check |
829 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
829 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
830 | 830 | $this->cache_storage->add( |
831 | - EE_Session::hash_check_prefix . $this->_sid, |
|
831 | + EE_Session::hash_check_prefix.$this->_sid, |
|
832 | 832 | md5($session_data), |
833 | 833 | $this->_lifespan |
834 | 834 | ); |
835 | 835 | } |
836 | 836 | // we're using the Transient API for storing session data, |
837 | 837 | return $this->cache_storage->add( |
838 | - EE_Session::session_id_prefix . $this->_sid, |
|
838 | + EE_Session::session_id_prefix.$this->_sid, |
|
839 | 839 | $session_data, |
840 | 840 | $this->_lifespan |
841 | 841 | ); |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | 'HTTP_FORWARDED', |
865 | 865 | 'REMOTE_ADDR' |
866 | 866 | ); |
867 | - foreach ( $server_keys as $key ){ |
|
868 | - if ( isset( $_SERVER[ $key ] )) { |
|
869 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
870 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
867 | + foreach ($server_keys as $key) { |
|
868 | + if (isset($_SERVER[$key])) { |
|
869 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
870 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
871 | 871 | $visitor_ip = $ip; |
872 | 872 | } |
873 | 873 | } |
@@ -886,32 +886,32 @@ discard block |
||
886 | 886 | * @return string |
887 | 887 | */ |
888 | 888 | public function _get_page_visit() { |
889 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
889 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
890 | 890 | // check for request url |
891 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
891 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
892 | 892 | $http_host = ''; |
893 | 893 | $page_id = '?'; |
894 | 894 | $e_reg = ''; |
895 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
896 | - $ru_bits = explode( '?', $request_uri ); |
|
895 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
896 | + $ru_bits = explode('?', $request_uri); |
|
897 | 897 | $request_uri = $ru_bits[0]; |
898 | 898 | // check for and grab host as well |
899 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
900 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
899 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
900 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
901 | 901 | } |
902 | 902 | // check for page_id in SERVER REQUEST |
903 | - if ( isset( $_REQUEST['page_id'] )) { |
|
903 | + if (isset($_REQUEST['page_id'])) { |
|
904 | 904 | // rebuild $e_reg without any of the extra parameters |
905 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
905 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
906 | 906 | } |
907 | 907 | // check for $e_reg in SERVER REQUEST |
908 | - if ( isset( $_REQUEST['ee'] )) { |
|
908 | + if (isset($_REQUEST['ee'])) { |
|
909 | 909 | // rebuild $e_reg without any of the extra parameters |
910 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
910 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
911 | 911 | } |
912 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
912 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
913 | 913 | } |
914 | - return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
914 | + return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
915 | 915 | |
916 | 916 | } |
917 | 917 | |
@@ -941,14 +941,14 @@ discard block |
||
941 | 941 | * @return void |
942 | 942 | * @throws \EE_Error |
943 | 943 | */ |
944 | - public function clear_session( $class = '', $function = '' ) { |
|
944 | + public function clear_session($class = '', $function = '') { |
|
945 | 945 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
946 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
946 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
947 | 947 | $this->reset_cart(); |
948 | 948 | $this->reset_checkout(); |
949 | 949 | $this->reset_transaction(); |
950 | 950 | // wipe out everything that isn't a default session datum |
951 | - $this->reset_data( array_keys( $this->_session_data )); |
|
951 | + $this->reset_data(array_keys($this->_session_data)); |
|
952 | 952 | // reset initial site access time and the session expiration |
953 | 953 | $this->_set_init_access_and_expiration(); |
954 | 954 | $this->_save_session_to_db(); |
@@ -963,42 +963,42 @@ discard block |
||
963 | 963 | * @param bool $show_all_notices |
964 | 964 | * @return TRUE on success, FALSE on fail |
965 | 965 | */ |
966 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
966 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
967 | 967 | // if $data_to_reset is not in an array, then put it in one |
968 | - if ( ! is_array( $data_to_reset ) ) { |
|
969 | - $data_to_reset = array ( $data_to_reset ); |
|
968 | + if ( ! is_array($data_to_reset)) { |
|
969 | + $data_to_reset = array($data_to_reset); |
|
970 | 970 | } |
971 | 971 | // nothing ??? go home! |
972 | - if ( empty( $data_to_reset )) { |
|
973 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
972 | + if (empty($data_to_reset)) { |
|
973 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
974 | 974 | return FALSE; |
975 | 975 | } |
976 | 976 | $return_value = TRUE; |
977 | 977 | // since $data_to_reset is an array, cycle through the values |
978 | - foreach ( $data_to_reset as $reset ) { |
|
978 | + foreach ($data_to_reset as $reset) { |
|
979 | 979 | |
980 | 980 | // first check to make sure it is a valid session var |
981 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
981 | + if (isset($this->_session_data[$reset])) { |
|
982 | 982 | // then check to make sure it is not a default var |
983 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
983 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
984 | 984 | // remove session var |
985 | - unset( $this->_session_data[ $reset ] ); |
|
986 | - if ( $show_all_notices ) { |
|
987 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
985 | + unset($this->_session_data[$reset]); |
|
986 | + if ($show_all_notices) { |
|
987 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
988 | 988 | } |
989 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
989 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
990 | 990 | |
991 | 991 | } else { |
992 | 992 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
993 | - if ( $show_all_notices ) { |
|
994 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
993 | + if ($show_all_notices) { |
|
994 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
995 | 995 | } |
996 | 996 | $return_value = FALSE; |
997 | 997 | } |
998 | 998 | |
999 | - } else if ( $show_all_notices ) { |
|
999 | + } else if ($show_all_notices) { |
|
1000 | 1000 | // oops! that session var does not exist! |
1001 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1001 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | 1002 | $return_value = FALSE; |
1003 | 1003 | } |
1004 | 1004 | |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | * @throws \EE_Error |
1018 | 1018 | */ |
1019 | 1019 | public function wp_loaded() { |
1020 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
1021 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
1020 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
1021 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | // or use that for the new transient cleanup query limit |
1055 | 1055 | add_filter( |
1056 | 1056 | 'FHEE__TransientCacheStorage__clearExpiredTransients__limit', |
1057 | - function () use ($expired_session_transient_delete_query_limit) { |
|
1057 | + function() use ($expired_session_transient_delete_query_limit) { |
|
1058 | 1058 | return $expired_session_transient_delete_query_limit; |
1059 | 1059 | } |
1060 | 1060 | ); |
@@ -1068,34 +1068,34 @@ discard block |
||
1068 | 1068 | * @param $data1 |
1069 | 1069 | * @return string |
1070 | 1070 | */ |
1071 | - private function find_serialize_error( $data1 ) { |
|
1071 | + private function find_serialize_error($data1) { |
|
1072 | 1072 | $error = '<pre>'; |
1073 | 1073 | $data2 = preg_replace_callback( |
1074 | 1074 | '!s:(\d+):"(.*?)";!', |
1075 | - function ( $match ) { |
|
1076 | - return ( $match[1] === strlen( $match[2] ) ) |
|
1075 | + function($match) { |
|
1076 | + return ($match[1] === strlen($match[2])) |
|
1077 | 1077 | ? $match[0] |
1078 | 1078 | : 's:' |
1079 | - . strlen( $match[2] ) |
|
1079 | + . strlen($match[2]) |
|
1080 | 1080 | . ':"' |
1081 | 1081 | . $match[2] |
1082 | 1082 | . '";'; |
1083 | 1083 | }, |
1084 | 1084 | $data1 |
1085 | 1085 | ); |
1086 | - $max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 ); |
|
1087 | - $error .= $data1 . PHP_EOL; |
|
1088 | - $error .= $data2 . PHP_EOL; |
|
1089 | - for ( $i = 0; $i < $max; $i++ ) { |
|
1090 | - if ( @$data1[ $i ] !== @$data2[ $i ] ) { |
|
1091 | - $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL; |
|
1092 | - $error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . ' != ' . ord( @$data2[ $i ] ) . PHP_EOL; |
|
1093 | - $error .= "\t-> Line Number = $i" . PHP_EOL; |
|
1094 | - $start = ( $i - 20 ); |
|
1095 | - $start = ( $start < 0 ) ? 0 : $start; |
|
1086 | + $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2); |
|
1087 | + $error .= $data1.PHP_EOL; |
|
1088 | + $error .= $data2.PHP_EOL; |
|
1089 | + for ($i = 0; $i < $max; $i++) { |
|
1090 | + if (@$data1[$i] !== @$data2[$i]) { |
|
1091 | + $error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL; |
|
1092 | + $error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL; |
|
1093 | + $error .= "\t-> Line Number = $i".PHP_EOL; |
|
1094 | + $start = ($i - 20); |
|
1095 | + $start = ($start < 0) ? 0 : $start; |
|
1096 | 1096 | $length = 40; |
1097 | 1097 | $point = $max - $i; |
1098 | - if ( $point < 20 ) { |
|
1098 | + if ($point < 20) { |
|
1099 | 1099 | $rlength = 1; |
1100 | 1100 | $rpoint = -$point; |
1101 | 1101 | } else { |
@@ -1104,16 +1104,16 @@ discard block |
||
1104 | 1104 | } |
1105 | 1105 | $error .= "\t-> Section Data1 = "; |
1106 | 1106 | $error .= substr_replace( |
1107 | - substr( $data1, $start, $length ), |
|
1108 | - "<b style=\"color:green\">{$data1[ $i ]}</b>", |
|
1107 | + substr($data1, $start, $length), |
|
1108 | + "<b style=\"color:green\">{$data1[$i]}</b>", |
|
1109 | 1109 | $rpoint, |
1110 | 1110 | $rlength |
1111 | 1111 | ); |
1112 | 1112 | $error .= PHP_EOL; |
1113 | 1113 | $error .= "\t-> Section Data2 = "; |
1114 | 1114 | $error .= substr_replace( |
1115 | - substr( $data2, $start, $length ), |
|
1116 | - "<b style=\"color:red\">{$data2[ $i ]}</b>", |
|
1115 | + substr($data2, $start, $length), |
|
1116 | + "<b style=\"color:red\">{$data2[$i]}</b>", |
|
1117 | 1117 | $rpoint, |
1118 | 1118 | $rlength |
1119 | 1119 | ); |
@@ -24,82 +24,82 @@ |
||
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * the actual shortcode tag that gets registered with WordPress |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getTag() |
|
33 | - { |
|
34 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * the time in seconds to cache the results of the processShortcode() method |
|
41 | - * 0 means the processShortcode() results will NOT be cached at all |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function cacheExpiration() |
|
46 | - { |
|
47 | - return MINUTE_IN_SECONDS; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
53 | - * this may be required for shortcodes that utilize a corresponding module, |
|
54 | - * and need to enqueue assets for that module |
|
55 | - * |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function initializeShortcode() |
|
59 | - { |
|
60 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
61 | - $this->shortcodeHasBeenInitialized(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * callback that runs when the shortcode is encountered in post content. |
|
68 | - * IMPORTANT !!! |
|
69 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
70 | - * |
|
71 | - * @param array $attributes |
|
72 | - * @return string |
|
73 | - * @throws InvalidArgumentException |
|
74 | - */ |
|
75 | - public function processShortcode($attributes = array()) |
|
76 | - { |
|
77 | - extract($attributes, EXTR_OVERWRITE); |
|
78 | - $event_id = isset($event_id) ? $event_id : 0; |
|
79 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
80 | - if (! $event instanceof EE_Event) { |
|
81 | - new ExceptionStackTraceDisplay( |
|
82 | - new InvalidArgumentException( |
|
83 | - sprintf( |
|
84 | - esc_html__( |
|
85 | - 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that it\'s value corresponds to a valid Event ID.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - $this->getTag(), |
|
89 | - $event_id, |
|
90 | - 'event_id', |
|
91 | - '<br />' |
|
92 | - ) |
|
93 | - ) |
|
94 | - ); |
|
95 | - return ''; |
|
96 | - } |
|
97 | - ob_start(); |
|
98 | - do_action('AHEE_event_details_before_post', $event_id); |
|
99 | - espresso_ticket_selector($event); |
|
100 | - do_action('AHEE_event_details_after_post'); |
|
101 | - return ob_get_clean(); |
|
102 | - } |
|
27 | + /** |
|
28 | + * the actual shortcode tag that gets registered with WordPress |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getTag() |
|
33 | + { |
|
34 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * the time in seconds to cache the results of the processShortcode() method |
|
41 | + * 0 means the processShortcode() results will NOT be cached at all |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function cacheExpiration() |
|
46 | + { |
|
47 | + return MINUTE_IN_SECONDS; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
53 | + * this may be required for shortcodes that utilize a corresponding module, |
|
54 | + * and need to enqueue assets for that module |
|
55 | + * |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function initializeShortcode() |
|
59 | + { |
|
60 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
61 | + $this->shortcodeHasBeenInitialized(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * callback that runs when the shortcode is encountered in post content. |
|
68 | + * IMPORTANT !!! |
|
69 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
70 | + * |
|
71 | + * @param array $attributes |
|
72 | + * @return string |
|
73 | + * @throws InvalidArgumentException |
|
74 | + */ |
|
75 | + public function processShortcode($attributes = array()) |
|
76 | + { |
|
77 | + extract($attributes, EXTR_OVERWRITE); |
|
78 | + $event_id = isset($event_id) ? $event_id : 0; |
|
79 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
80 | + if (! $event instanceof EE_Event) { |
|
81 | + new ExceptionStackTraceDisplay( |
|
82 | + new InvalidArgumentException( |
|
83 | + sprintf( |
|
84 | + esc_html__( |
|
85 | + 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that it\'s value corresponds to a valid Event ID.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + $this->getTag(), |
|
89 | + $event_id, |
|
90 | + 'event_id', |
|
91 | + '<br />' |
|
92 | + ) |
|
93 | + ) |
|
94 | + ); |
|
95 | + return ''; |
|
96 | + } |
|
97 | + ob_start(); |
|
98 | + do_action('AHEE_event_details_before_post', $event_id); |
|
99 | + espresso_ticket_selector($event); |
|
100 | + do_action('AHEE_event_details_after_post'); |
|
101 | + return ob_get_clean(); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | extract($attributes, EXTR_OVERWRITE); |
78 | 78 | $event_id = isset($event_id) ? $event_id : 0; |
79 | 79 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
80 | - if (! $event instanceof EE_Event) { |
|
80 | + if ( ! $event instanceof EE_Event) { |
|
81 | 81 | new ExceptionStackTraceDisplay( |
82 | 82 | new InvalidArgumentException( |
83 | 83 | sprintf( |