@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | - * @return null |
|
| 148 | + * @return EE_Line_Item_Display |
|
| 149 | 149 | */ |
| 150 | 150 | public function line_item_display() |
| 151 | 151 | { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | - * @param null $line_item_display |
|
| 157 | + * @param EE_Line_Item_Display $line_item_display |
|
| 158 | 158 | */ |
| 159 | 159 | public function set_line_item_display($line_item_display) |
| 160 | 160 | { |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * _apply_registration_payments_to_amount_owing |
| 883 | 883 | * |
| 884 | 884 | * @access protected |
| 885 | - * @param array $registrations |
|
| 885 | + * @param EE_Base_Class[] $registrations |
|
| 886 | 886 | * @throws EE_Error |
| 887 | 887 | */ |
| 888 | 888 | protected function _apply_registration_payments_to_amount_owing(array $registrations) |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | * get_billing_form_html_for_payment_method |
| 1189 | 1189 | * |
| 1190 | 1190 | * @access public |
| 1191 | - * @return string |
|
| 1191 | + * @return boolean |
|
| 1192 | 1192 | * @throws EE_Error |
| 1193 | 1193 | * @throws InvalidArgumentException |
| 1194 | 1194 | * @throws ReflectionException |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | * |
| 1256 | 1256 | * @access private |
| 1257 | 1257 | * @param EE_Payment_Method $payment_method |
| 1258 | - * @return EE_Billing_Info_Form|EE_Form_Section_HTML |
|
| 1258 | + * @return EE_Billing_Info_Form |
|
| 1259 | 1259 | * @throws EE_Error |
| 1260 | 1260 | * @throws InvalidArgumentException |
| 1261 | 1261 | * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | * switch_payment_method |
| 1365 | 1365 | * |
| 1366 | 1366 | * @access public |
| 1367 | - * @return string |
|
| 1367 | + * @return boolean |
|
| 1368 | 1368 | * @throws EE_Error |
| 1369 | 1369 | * @throws InvalidArgumentException |
| 1370 | 1370 | * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
@@ -1643,7 +1643,7 @@ discard block |
||
| 1643 | 1643 | /** |
| 1644 | 1644 | * process_reg_step |
| 1645 | 1645 | * |
| 1646 | - * @return bool |
|
| 1646 | + * @return null|boolean |
|
| 1647 | 1647 | * @throws EE_Error |
| 1648 | 1648 | * @throws InvalidArgumentException |
| 1649 | 1649 | * @throws ReflectionException |
@@ -1774,7 +1774,7 @@ discard block |
||
| 1774 | 1774 | * update_reg_step |
| 1775 | 1775 | * this is the final step after a user revisits the site to retry a payment |
| 1776 | 1776 | * |
| 1777 | - * @return bool |
|
| 1777 | + * @return null|boolean |
|
| 1778 | 1778 | * @throws EE_Error |
| 1779 | 1779 | * @throws InvalidArgumentException |
| 1780 | 1780 | * @throws ReflectionException |
@@ -2221,7 +2221,7 @@ discard block |
||
| 2221 | 2221 | * |
| 2222 | 2222 | * @access private |
| 2223 | 2223 | * @type EE_Payment_Method $payment_method |
| 2224 | - * @return mixed EE_Payment | boolean |
|
| 2224 | + * @return EE_Payment|null EE_Payment | boolean |
|
| 2225 | 2225 | * @throws EE_Error |
| 2226 | 2226 | * @throws InvalidArgumentException |
| 2227 | 2227 | * @throws ReflectionException |
@@ -2546,7 +2546,7 @@ discard block |
||
| 2546 | 2546 | * or present the payment options again |
| 2547 | 2547 | * |
| 2548 | 2548 | * @access private |
| 2549 | - * @return EE_Payment|FALSE |
|
| 2549 | + * @return boolean |
|
| 2550 | 2550 | * @throws EE_Error |
| 2551 | 2551 | * @throws InvalidArgumentException |
| 2552 | 2552 | * @throws ReflectionException |
@@ -2686,8 +2686,8 @@ discard block |
||
| 2686 | 2686 | * _redirect_wayward_request |
| 2687 | 2687 | * |
| 2688 | 2688 | * @access private |
| 2689 | - * @param \EE_Registration|null $primary_registrant |
|
| 2690 | - * @return bool |
|
| 2689 | + * @param EE_Registration $primary_registrant |
|
| 2690 | + * @return false|null |
|
| 2691 | 2691 | * @throws EE_Error |
| 2692 | 2692 | * @throws InvalidArgumentException |
| 2693 | 2693 | * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
| 56 | 56 | * EQG_additional. |
| 57 | 57 | * @since 4.10.0.p |
| 58 | - * @param string|boolean|int $context |
|
| 58 | + * @param boolean $context |
|
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | 61 | public function fieldNameForContext($context) |
@@ -7,72 +7,72 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class EEM_Event_Question_Group extends EEM_Base |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Name of the field indicating an event should use the question group for the primary attendee |
|
| 12 | - */ |
|
| 13 | - const PRIMARY = 'EQG_primary'; |
|
| 10 | + /** |
|
| 11 | + * Name of the field indicating an event should use the question group for the primary attendee |
|
| 12 | + */ |
|
| 13 | + const PRIMARY = 'EQG_primary'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Name of hte field indicating an event should use the question group for additional attendees |
|
| 17 | - */ |
|
| 18 | - const ADDITIONAL = 'EQG_additional'; |
|
| 15 | + /** |
|
| 16 | + * Name of hte field indicating an event should use the question group for additional attendees |
|
| 17 | + */ |
|
| 18 | + const ADDITIONAL = 'EQG_additional'; |
|
| 19 | 19 | |
| 20 | - // private instance of the Event_Question_Group object |
|
| 21 | - protected static $_instance = null; |
|
| 20 | + // private instance of the Event_Question_Group object |
|
| 21 | + protected static $_instance = null; |
|
| 22 | 22 | |
| 23 | - protected function __construct($timezone = null) |
|
| 24 | - { |
|
| 25 | - $this->singular_item = __('Event to Question Group Link', 'event_espresso'); |
|
| 26 | - $this->plural_item = __('Event to Question Group Links', 'event_espresso'); |
|
| 27 | - $this->_tables = array( |
|
| 28 | - 'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
| 29 | - ); |
|
| 30 | - $this->_fields = array( |
|
| 31 | - 'Event_Question_Group'=>array( |
|
| 32 | - 'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), |
|
| 33 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
| 34 | - 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
| 35 | - 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false), |
|
| 36 | - 'EQG_additional'=>new EE_Boolean_Field('EQG_additional', __('Flag indicating question is only for additional attendees', 'event_espresso'), false, false) |
|
| 37 | - ) |
|
| 38 | - ); |
|
| 39 | - $this->_model_relations = array( |
|
| 40 | - 'Event'=>new EE_Belongs_To_Relation(), |
|
| 41 | - 'Question_Group'=>new EE_Belongs_To_Relation() |
|
| 42 | - ); |
|
| 43 | - // this model is generally available for reading |
|
| 44 | - $path_to_event = 'Event'; |
|
| 45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
| 46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
| 49 | - parent::__construct($timezone); |
|
| 50 | - } |
|
| 23 | + protected function __construct($timezone = null) |
|
| 24 | + { |
|
| 25 | + $this->singular_item = __('Event to Question Group Link', 'event_espresso'); |
|
| 26 | + $this->plural_item = __('Event to Question Group Links', 'event_espresso'); |
|
| 27 | + $this->_tables = array( |
|
| 28 | + 'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
| 29 | + ); |
|
| 30 | + $this->_fields = array( |
|
| 31 | + 'Event_Question_Group'=>array( |
|
| 32 | + 'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), |
|
| 33 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
| 34 | + 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
| 35 | + 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false), |
|
| 36 | + 'EQG_additional'=>new EE_Boolean_Field('EQG_additional', __('Flag indicating question is only for additional attendees', 'event_espresso'), false, false) |
|
| 37 | + ) |
|
| 38 | + ); |
|
| 39 | + $this->_model_relations = array( |
|
| 40 | + 'Event'=>new EE_Belongs_To_Relation(), |
|
| 41 | + 'Question_Group'=>new EE_Belongs_To_Relation() |
|
| 42 | + ); |
|
| 43 | + // this model is generally available for reading |
|
| 44 | + $path_to_event = 'Event'; |
|
| 45 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
| 46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 47 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 48 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
| 49 | + parent::__construct($timezone); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether |
|
| 54 | - * this is concerning primary attendees or additional attendees. |
|
| 55 | - * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
|
| 56 | - * EQG_additional. |
|
| 57 | - * @since 4.10.0.p |
|
| 58 | - * @param string|boolean|int $context |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function fieldNameForContext($context) |
|
| 62 | - { |
|
| 63 | - // Basically do a strict switch statement. |
|
| 64 | - switch (true) { |
|
| 65 | - case $context === 'additional': |
|
| 66 | - case $context === false: |
|
| 67 | - case $context === 0: |
|
| 68 | - $field_name = EEM_Event_Question_Group::ADDITIONAL; |
|
| 69 | - break; |
|
| 70 | - case $context === 'primary': |
|
| 71 | - case $context === true: |
|
| 72 | - case $context === 1: |
|
| 73 | - default: |
|
| 74 | - $field_name = EEM_Event_Question_Group::PRIMARY; |
|
| 75 | - } |
|
| 76 | - return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context); |
|
| 77 | - } |
|
| 52 | + /** |
|
| 53 | + * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether |
|
| 54 | + * this is concerning primary attendees or additional attendees. |
|
| 55 | + * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
|
| 56 | + * EQG_additional. |
|
| 57 | + * @since 4.10.0.p |
|
| 58 | + * @param string|boolean|int $context |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function fieldNameForContext($context) |
|
| 62 | + { |
|
| 63 | + // Basically do a strict switch statement. |
|
| 64 | + switch (true) { |
|
| 65 | + case $context === 'additional': |
|
| 66 | + case $context === false: |
|
| 67 | + case $context === 0: |
|
| 68 | + $field_name = EEM_Event_Question_Group::ADDITIONAL; |
|
| 69 | + break; |
|
| 70 | + case $context === 'primary': |
|
| 71 | + case $context === true: |
|
| 72 | + case $context === 1: |
|
| 73 | + default: |
|
| 74 | + $field_name = EEM_Event_Question_Group::PRIMARY; |
|
| 75 | + } |
|
| 76 | + return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context); |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -38,103 +38,103 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.000'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.000'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |
@@ -12,94 +12,94 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_State_Select_Input extends EE_Select_Input |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var string the name of the EE_State field to use for option values in the HTML form input. |
|
| 17 | - */ |
|
| 18 | - protected $valueFieldName; |
|
| 15 | + /** |
|
| 16 | + * @var string the name of the EE_State field to use for option values in the HTML form input. |
|
| 17 | + */ |
|
| 18 | + protected $valueFieldName; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param EE_State[]|array|null $state_options. If a flat array of string is provided, |
|
| 22 | - * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for |
|
| 23 | - * the keys (which will become the option values). If null or empty is passed, all active states will be used, |
|
| 24 | - * and $input_settings['value_field_name'] will again be used. * |
|
| 25 | - * @param array $input_settings same as parent, but also { |
|
| 26 | - * @type string $value_field_name the name of the field to use |
|
| 27 | - * for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`. |
|
| 28 | - * } |
|
| 29 | - * @throws EE_Error |
|
| 30 | - * @throws InvalidArgumentException |
|
| 31 | - * @throws InvalidDataTypeException |
|
| 32 | - * @throws InvalidInterfaceException |
|
| 33 | - * @throws ReflectionException |
|
| 34 | - */ |
|
| 35 | - public function __construct($state_options, $input_settings = array()) |
|
| 36 | - { |
|
| 37 | - if (isset($input_settings['value_field_name'])) { |
|
| 38 | - $this->valueFieldName = $input_settings['value_field_name']; |
|
| 39 | - if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
| 40 | - throw new InvalidArgumentException( |
|
| 41 | - sprintf( |
|
| 42 | - esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
|
| 43 | - $this->valueFieldName() |
|
| 44 | - ) |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - $this->valueFieldName = 'STA_ID'; |
|
| 49 | - } |
|
| 50 | - $state_options = apply_filters( |
|
| 51 | - 'FHEE__EE_State_Select_Input____construct__state_options', |
|
| 52 | - $this->get_state_answer_options($state_options), |
|
| 53 | - $this |
|
| 54 | - ); |
|
| 55 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
| 56 | - ? $input_settings['html_class'] . ' ee-state-select-js' |
|
| 57 | - : 'ee-state-select-js'; |
|
| 58 | - parent::__construct($state_options, $input_settings); |
|
| 59 | - } |
|
| 20 | + /** |
|
| 21 | + * @param EE_State[]|array|null $state_options. If a flat array of string is provided, |
|
| 22 | + * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for |
|
| 23 | + * the keys (which will become the option values). If null or empty is passed, all active states will be used, |
|
| 24 | + * and $input_settings['value_field_name'] will again be used. * |
|
| 25 | + * @param array $input_settings same as parent, but also { |
|
| 26 | + * @type string $value_field_name the name of the field to use |
|
| 27 | + * for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`. |
|
| 28 | + * } |
|
| 29 | + * @throws EE_Error |
|
| 30 | + * @throws InvalidArgumentException |
|
| 31 | + * @throws InvalidDataTypeException |
|
| 32 | + * @throws InvalidInterfaceException |
|
| 33 | + * @throws ReflectionException |
|
| 34 | + */ |
|
| 35 | + public function __construct($state_options, $input_settings = array()) |
|
| 36 | + { |
|
| 37 | + if (isset($input_settings['value_field_name'])) { |
|
| 38 | + $this->valueFieldName = $input_settings['value_field_name']; |
|
| 39 | + if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
| 40 | + throw new InvalidArgumentException( |
|
| 41 | + sprintf( |
|
| 42 | + esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
|
| 43 | + $this->valueFieldName() |
|
| 44 | + ) |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + $this->valueFieldName = 'STA_ID'; |
|
| 49 | + } |
|
| 50 | + $state_options = apply_filters( |
|
| 51 | + 'FHEE__EE_State_Select_Input____construct__state_options', |
|
| 52 | + $this->get_state_answer_options($state_options), |
|
| 53 | + $this |
|
| 54 | + ); |
|
| 55 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
| 56 | + ? $input_settings['html_class'] . ' ee-state-select-js' |
|
| 57 | + : 'ee-state-select-js'; |
|
| 58 | + parent::__construct($state_options, $input_settings); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Returns the name of the state field used for the HTML option values. |
|
| 63 | - * @since 4.10.0.p |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 66 | - public function valueFieldName() |
|
| 67 | - { |
|
| 68 | - return $this->valueFieldName; |
|
| 69 | - } |
|
| 61 | + /** |
|
| 62 | + * Returns the name of the state field used for the HTML option values. |
|
| 63 | + * @since 4.10.0.p |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | + public function valueFieldName() |
|
| 67 | + { |
|
| 68 | + return $this->valueFieldName; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * get_state_answer_options |
|
| 74 | - * |
|
| 75 | - * @param array $state_options |
|
| 76 | - * @return array |
|
| 77 | - * @throws EE_Error |
|
| 78 | - * @throws InvalidArgumentException |
|
| 79 | - * @throws ReflectionException |
|
| 80 | - * @throws InvalidDataTypeException |
|
| 81 | - * @throws InvalidInterfaceException |
|
| 82 | - */ |
|
| 83 | - public function get_state_answer_options($state_options = null) |
|
| 84 | - { |
|
| 85 | - // if passed something that is NOT an array |
|
| 86 | - if (! is_array($state_options) || empty($state_options)) { |
|
| 87 | - // get possibly cached list of states |
|
| 88 | - $states = EEM_State::instance()->get_all_active_states(); |
|
| 89 | - } |
|
| 90 | - if (is_array($state_options) && reset($state_options) instanceof EE_State) { |
|
| 91 | - $states = $state_options; |
|
| 92 | - $state_options = array(); |
|
| 93 | - } |
|
| 94 | - if (! empty($states)) { |
|
| 95 | - // set the default |
|
| 96 | - $state_options[''][''] = ''; |
|
| 97 | - foreach ($states as $state) { |
|
| 98 | - if ($state instanceof EE_State) { |
|
| 99 | - $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return $state_options; |
|
| 104 | - } |
|
| 72 | + /** |
|
| 73 | + * get_state_answer_options |
|
| 74 | + * |
|
| 75 | + * @param array $state_options |
|
| 76 | + * @return array |
|
| 77 | + * @throws EE_Error |
|
| 78 | + * @throws InvalidArgumentException |
|
| 79 | + * @throws ReflectionException |
|
| 80 | + * @throws InvalidDataTypeException |
|
| 81 | + * @throws InvalidInterfaceException |
|
| 82 | + */ |
|
| 83 | + public function get_state_answer_options($state_options = null) |
|
| 84 | + { |
|
| 85 | + // if passed something that is NOT an array |
|
| 86 | + if (! is_array($state_options) || empty($state_options)) { |
|
| 87 | + // get possibly cached list of states |
|
| 88 | + $states = EEM_State::instance()->get_all_active_states(); |
|
| 89 | + } |
|
| 90 | + if (is_array($state_options) && reset($state_options) instanceof EE_State) { |
|
| 91 | + $states = $state_options; |
|
| 92 | + $state_options = array(); |
|
| 93 | + } |
|
| 94 | + if (! empty($states)) { |
|
| 95 | + // set the default |
|
| 96 | + $state_options[''][''] = ''; |
|
| 97 | + foreach ($states as $state) { |
|
| 98 | + if ($state instanceof EE_State) { |
|
| 99 | + $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return $state_options; |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -14,172 +14,172 @@ |
||
| 14 | 14 | class EE_Billing_Attendee_Info_Form extends EE_Billing_Info_Form |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * |
|
| 19 | - * @param EE_Payment_Method $payment_method |
|
| 20 | - * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
| 21 | - */ |
|
| 22 | - public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
| 23 | - { |
|
| 24 | - $options_array['subsections'] = array_merge( |
|
| 25 | - array( |
|
| 26 | - 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | - 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | - 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )), |
|
| 29 | - 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | - 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | - 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | - 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | - 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | - 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | - 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 36 | - ), |
|
| 37 | - isset($options_array['subsections']) ? $options_array['subsections'] : array() |
|
| 38 | - ); |
|
| 17 | + /** |
|
| 18 | + * |
|
| 19 | + * @param EE_Payment_Method $payment_method |
|
| 20 | + * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
| 21 | + */ |
|
| 22 | + public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
| 23 | + { |
|
| 24 | + $options_array['subsections'] = array_merge( |
|
| 25 | + array( |
|
| 26 | + 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | + 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | + 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )), |
|
| 29 | + 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | + 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | + 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | + 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | + 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | + 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | + 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 36 | + ), |
|
| 37 | + isset($options_array['subsections']) ? $options_array['subsections'] : array() |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - parent::__construct($payment_method, $options_array); |
|
| 41 | - } |
|
| 40 | + parent::__construct($payment_method, $options_array); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Sets the defaults for the billing form according to the attendee's details |
|
| 45 | - * @param EE_Attendee $attendee |
|
| 46 | - */ |
|
| 47 | - public function populate_from_attendee($attendee) |
|
| 48 | - { |
|
| 49 | - $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee); |
|
| 43 | + /** |
|
| 44 | + * Sets the defaults for the billing form according to the attendee's details |
|
| 45 | + * @param EE_Attendee $attendee |
|
| 46 | + */ |
|
| 47 | + public function populate_from_attendee($attendee) |
|
| 48 | + { |
|
| 49 | + $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee); |
|
| 50 | 50 | |
| 51 | - /** @var $attendee EE_Attendee */ |
|
| 52 | - $this->populate_defaults( |
|
| 53 | - apply_filters( |
|
| 54 | - 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
| 55 | - array( |
|
| 56 | - 'first_name'=>$attendee->fname(), |
|
| 57 | - 'last_name'=>$attendee->lname(), |
|
| 58 | - 'email'=>$attendee->email(), |
|
| 59 | - 'address'=>$attendee->address(), |
|
| 60 | - 'address2'=>$attendee->address2(), |
|
| 61 | - 'city'=>$attendee->city(), |
|
| 62 | - 'state'=> $this->getAttendeeStateValueForForm($attendee), |
|
| 63 | - 'country'=> $attendee->country_ID(), |
|
| 64 | - 'zip'=>$attendee->zip(), |
|
| 65 | - 'phone'=>$attendee->phone(), |
|
| 66 | - ), |
|
| 67 | - $attendee, |
|
| 68 | - $this |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 71 | - } |
|
| 51 | + /** @var $attendee EE_Attendee */ |
|
| 52 | + $this->populate_defaults( |
|
| 53 | + apply_filters( |
|
| 54 | + 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
| 55 | + array( |
|
| 56 | + 'first_name'=>$attendee->fname(), |
|
| 57 | + 'last_name'=>$attendee->lname(), |
|
| 58 | + 'email'=>$attendee->email(), |
|
| 59 | + 'address'=>$attendee->address(), |
|
| 60 | + 'address2'=>$attendee->address2(), |
|
| 61 | + 'city'=>$attendee->city(), |
|
| 62 | + 'state'=> $this->getAttendeeStateValueForForm($attendee), |
|
| 63 | + 'country'=> $attendee->country_ID(), |
|
| 64 | + 'zip'=>$attendee->zip(), |
|
| 65 | + 'phone'=>$attendee->phone(), |
|
| 66 | + ), |
|
| 67 | + $attendee, |
|
| 68 | + $this |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Gets the default value to use for the billing form's state value. |
|
| 75 | - * @since 4.10.0.p |
|
| 76 | - * @param EE_Attendee $attendee |
|
| 77 | - * @return string |
|
| 78 | - * @throws EE_Error2 |
|
| 79 | - */ |
|
| 80 | - protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
|
| 81 | - { |
|
| 82 | - // If the state input was removed, just return a blank string. |
|
| 83 | - if (! $this->has_subsection('state')) { |
|
| 84 | - return ''; |
|
| 85 | - } |
|
| 86 | - $state_input = $this->get_input('state', false); |
|
| 87 | - if ($state_input instanceof EE_State_Select_Input) { |
|
| 88 | - $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | - } else { |
|
| 90 | - $state_field_to_use = 'STA_ID'; |
|
| 91 | - } |
|
| 92 | - switch ($state_field_to_use) { |
|
| 93 | - case 'STA_abbrev': |
|
| 94 | - $state_value = $attendee->state_abbrev(); |
|
| 95 | - break; |
|
| 96 | - case 'STA_name': |
|
| 97 | - $state_value = $attendee->state_name(); |
|
| 98 | - break; |
|
| 99 | - default: |
|
| 100 | - $state_value = $attendee->state_ID(); |
|
| 101 | - } |
|
| 102 | - return $state_value; |
|
| 103 | - } |
|
| 73 | + /** |
|
| 74 | + * Gets the default value to use for the billing form's state value. |
|
| 75 | + * @since 4.10.0.p |
|
| 76 | + * @param EE_Attendee $attendee |
|
| 77 | + * @return string |
|
| 78 | + * @throws EE_Error2 |
|
| 79 | + */ |
|
| 80 | + protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
|
| 81 | + { |
|
| 82 | + // If the state input was removed, just return a blank string. |
|
| 83 | + if (! $this->has_subsection('state')) { |
|
| 84 | + return ''; |
|
| 85 | + } |
|
| 86 | + $state_input = $this->get_input('state', false); |
|
| 87 | + if ($state_input instanceof EE_State_Select_Input) { |
|
| 88 | + $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | + } else { |
|
| 90 | + $state_field_to_use = 'STA_ID'; |
|
| 91 | + } |
|
| 92 | + switch ($state_field_to_use) { |
|
| 93 | + case 'STA_abbrev': |
|
| 94 | + $state_value = $attendee->state_abbrev(); |
|
| 95 | + break; |
|
| 96 | + case 'STA_name': |
|
| 97 | + $state_value = $attendee->state_name(); |
|
| 98 | + break; |
|
| 99 | + default: |
|
| 100 | + $state_value = $attendee->state_ID(); |
|
| 101 | + } |
|
| 102 | + return $state_value; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * copy_billing_form_data_to_attendee |
|
| 109 | - * copies info from the billing form to the attendee's details |
|
| 110 | - * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
| 111 | - * @return \EE_Attendee |
|
| 112 | - */ |
|
| 113 | - public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
| 114 | - { |
|
| 115 | - // grab billing form data |
|
| 116 | - $data = $this->valid_data(); |
|
| 117 | - // copy first_name |
|
| 118 | - if (! empty($data['first_name'])) { |
|
| 119 | - $attendee->set_fname($data['first_name']); |
|
| 120 | - } |
|
| 121 | - // copy last_name |
|
| 122 | - if (! empty($data['last_name'])) { |
|
| 123 | - $attendee->set_lname($data['last_name']); |
|
| 124 | - } |
|
| 125 | - // copy email |
|
| 126 | - if (! empty($data['email'])) { |
|
| 127 | - $attendee->set_email($data['email']); |
|
| 128 | - } |
|
| 129 | - // copy address |
|
| 130 | - if (! empty($data['address'])) { |
|
| 131 | - $attendee->set_address($data['address']); |
|
| 132 | - } |
|
| 133 | - // copy address2 |
|
| 134 | - if (! empty($data['address2'])) { |
|
| 135 | - $attendee->set_address2($data['address2']); |
|
| 136 | - } |
|
| 137 | - // copy city |
|
| 138 | - if (! empty($data['city'])) { |
|
| 139 | - $attendee->set_city($data['city']); |
|
| 140 | - } |
|
| 141 | - // copy state |
|
| 142 | - if (! empty($data['state'])) { |
|
| 143 | - $attendee->set_state($data['state']); |
|
| 144 | - } |
|
| 145 | - // copy country |
|
| 146 | - if (! empty($data['country'])) { |
|
| 147 | - $attendee->set_country($data['country']); |
|
| 148 | - } |
|
| 149 | - // copy zip |
|
| 150 | - if (! empty($data['zip'])) { |
|
| 151 | - $attendee->set_zip($data['zip']); |
|
| 152 | - } |
|
| 153 | - // copy phone |
|
| 154 | - if (! empty($data['phone'])) { |
|
| 155 | - $attendee->set_phone($data['phone']); |
|
| 156 | - } |
|
| 157 | - return $attendee; |
|
| 158 | - } |
|
| 107 | + /** |
|
| 108 | + * copy_billing_form_data_to_attendee |
|
| 109 | + * copies info from the billing form to the attendee's details |
|
| 110 | + * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
| 111 | + * @return \EE_Attendee |
|
| 112 | + */ |
|
| 113 | + public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
| 114 | + { |
|
| 115 | + // grab billing form data |
|
| 116 | + $data = $this->valid_data(); |
|
| 117 | + // copy first_name |
|
| 118 | + if (! empty($data['first_name'])) { |
|
| 119 | + $attendee->set_fname($data['first_name']); |
|
| 120 | + } |
|
| 121 | + // copy last_name |
|
| 122 | + if (! empty($data['last_name'])) { |
|
| 123 | + $attendee->set_lname($data['last_name']); |
|
| 124 | + } |
|
| 125 | + // copy email |
|
| 126 | + if (! empty($data['email'])) { |
|
| 127 | + $attendee->set_email($data['email']); |
|
| 128 | + } |
|
| 129 | + // copy address |
|
| 130 | + if (! empty($data['address'])) { |
|
| 131 | + $attendee->set_address($data['address']); |
|
| 132 | + } |
|
| 133 | + // copy address2 |
|
| 134 | + if (! empty($data['address2'])) { |
|
| 135 | + $attendee->set_address2($data['address2']); |
|
| 136 | + } |
|
| 137 | + // copy city |
|
| 138 | + if (! empty($data['city'])) { |
|
| 139 | + $attendee->set_city($data['city']); |
|
| 140 | + } |
|
| 141 | + // copy state |
|
| 142 | + if (! empty($data['state'])) { |
|
| 143 | + $attendee->set_state($data['state']); |
|
| 144 | + } |
|
| 145 | + // copy country |
|
| 146 | + if (! empty($data['country'])) { |
|
| 147 | + $attendee->set_country($data['country']); |
|
| 148 | + } |
|
| 149 | + // copy zip |
|
| 150 | + if (! empty($data['zip'])) { |
|
| 151 | + $attendee->set_zip($data['zip']); |
|
| 152 | + } |
|
| 153 | + // copy phone |
|
| 154 | + if (! empty($data['phone'])) { |
|
| 155 | + $attendee->set_phone($data['phone']); |
|
| 156 | + } |
|
| 157 | + return $attendee; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * create_attendee_from_billing_form_data |
|
| 163 | - * uses info from the billing form to create a new attendee |
|
| 164 | - * @return \EE_Attendee |
|
| 165 | - */ |
|
| 166 | - public function create_attendee_from_billing_form_data() |
|
| 167 | - { |
|
| 168 | - // grab billing form data |
|
| 169 | - $data = $this->valid_data(); |
|
| 170 | - return EE_Attendee::new_instance(array( |
|
| 171 | - 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
| 172 | - 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
| 173 | - 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
| 174 | - 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
| 175 | - 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
| 176 | - 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
| 177 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
| 178 | - 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
| 179 | - 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
| 180 | - 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
| 181 | - )); |
|
| 182 | - } |
|
| 161 | + /** |
|
| 162 | + * create_attendee_from_billing_form_data |
|
| 163 | + * uses info from the billing form to create a new attendee |
|
| 164 | + * @return \EE_Attendee |
|
| 165 | + */ |
|
| 166 | + public function create_attendee_from_billing_form_data() |
|
| 167 | + { |
|
| 168 | + // grab billing form data |
|
| 169 | + $data = $this->valid_data(); |
|
| 170 | + return EE_Attendee::new_instance(array( |
|
| 171 | + 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
| 172 | + 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
| 173 | + 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
| 174 | + 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
| 175 | + 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
| 176 | + 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
| 177 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
| 178 | + 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
| 179 | + 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
| 180 | + 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
| 181 | + )); |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // End of file EE_Billing_Attendee_Info_Form.form.php |
@@ -21,812 +21,812 @@ |
||
| 21 | 21 | abstract class EE_PMT_Base |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - const onsite = 'on-site'; |
|
| 25 | - const offsite = 'off-site'; |
|
| 26 | - const offline = 'off-line'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var EE_Payment_Method |
|
| 30 | - */ |
|
| 31 | - protected $_pm_instance = null; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var boolean |
|
| 35 | - */ |
|
| 36 | - protected $_requires_https = false; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var boolean |
|
| 40 | - */ |
|
| 41 | - protected $_has_billing_form; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var EE_Gateway |
|
| 45 | - */ |
|
| 46 | - protected $_gateway = null; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var EE_Payment_Method_Form |
|
| 50 | - */ |
|
| 51 | - protected $_settings_form = null; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var EE_Form_Section_Proper |
|
| 55 | - */ |
|
| 56 | - protected $_billing_form = null; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var boolean |
|
| 60 | - */ |
|
| 61 | - protected $_cache_billing_form = true; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * String of the absolute path to the folder containing this file, with a trailing slash. |
|
| 65 | - * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
| 66 | - * |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 69 | - protected $_file_folder = null; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
| 73 | - * like images, js, or css) |
|
| 74 | - * |
|
| 75 | - * @var string |
|
| 76 | - */ |
|
| 77 | - protected $_file_url = null; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Pretty name for the payment method |
|
| 81 | - * |
|
| 82 | - * @var string |
|
| 83 | - */ |
|
| 84 | - protected $_pretty_name = null; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * |
|
| 88 | - * @var string |
|
| 89 | - */ |
|
| 90 | - protected $_default_button_url = null; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * |
|
| 94 | - * @var string |
|
| 95 | - */ |
|
| 96 | - protected $_default_description = null; |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * |
|
| 101 | - * @param EE_Payment_Method $pm_instance |
|
| 102 | - * @throws EE_Error |
|
| 103 | - * @return EE_PMT_Base |
|
| 104 | - */ |
|
| 105 | - public function __construct($pm_instance = null) |
|
| 106 | - { |
|
| 107 | - if ($pm_instance instanceof EE_Payment_Method) { |
|
| 108 | - $this->set_instance($pm_instance); |
|
| 109 | - } |
|
| 110 | - if ($this->_gateway) { |
|
| 111 | - $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
| 112 | - $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
| 113 | - $this->_gateway->set_template_helper(new EEH_Template()); |
|
| 114 | - $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
| 115 | - $this->_gateway->set_money_helper(new EEH_Money()); |
|
| 116 | - $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
| 117 | - $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
| 118 | - do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
| 119 | - } |
|
| 120 | - if (! isset($this->_has_billing_form)) { |
|
| 121 | - // by default, On Site gateways have a billing form |
|
| 122 | - if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
| 123 | - $this->set_has_billing_form(true); |
|
| 124 | - } else { |
|
| 125 | - $this->set_has_billing_form(false); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - if (! $this->_pretty_name) { |
|
| 130 | - throw new EE_Error( |
|
| 131 | - sprintf( |
|
| 132 | - __( |
|
| 133 | - "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
| 134 | - "event_espresso" |
|
| 135 | - ) |
|
| 136 | - ) |
|
| 137 | - ); |
|
| 138 | - } |
|
| 139 | - // if the child didn't specify a default button, use the credit card one |
|
| 140 | - if ($this->_default_button_url === null) { |
|
| 141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @param boolean $has_billing_form |
|
| 148 | - */ |
|
| 149 | - public function set_has_billing_form($has_billing_form) |
|
| 150 | - { |
|
| 151 | - $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * sets the file_folder property |
|
| 157 | - */ |
|
| 158 | - protected function _set_file_folder() |
|
| 159 | - { |
|
| 160 | - $reflector = new ReflectionClass(get_class($this)); |
|
| 161 | - $fn = $reflector->getFileName(); |
|
| 162 | - $this->_file_folder = dirname($fn) . '/'; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * sets the file URL with a trailing slash for this PMT |
|
| 168 | - */ |
|
| 169 | - protected function _set_file_url() |
|
| 170 | - { |
|
| 171 | - $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
| 172 | - $file_folder_fixed = str_replace('\\', '/', $this->file_folder()); |
|
| 173 | - $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
| 174 | - $this->_file_url = set_url_scheme($file_path); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Gets the default description on all payment methods of this type |
|
| 179 | - * |
|
| 180 | - * @return string |
|
| 181 | - */ |
|
| 182 | - public function default_description() |
|
| 183 | - { |
|
| 184 | - return $this->_default_description; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Returns the folder containing the PMT child class, with a trailing slash |
|
| 190 | - * |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 193 | - public function file_folder() |
|
| 194 | - { |
|
| 195 | - if (! $this->_file_folder) { |
|
| 196 | - $this->_set_file_folder(); |
|
| 197 | - } |
|
| 198 | - return $this->_file_folder; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @return string |
|
| 204 | - */ |
|
| 205 | - public function file_url() |
|
| 206 | - { |
|
| 207 | - if (! $this->_file_url) { |
|
| 208 | - $this->_set_file_url(); |
|
| 209 | - } |
|
| 210 | - return $this->_file_url; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Sets the payment method instance this payment method type is for. |
|
| 216 | - * Its important teh payment method instance is set before |
|
| 217 | - * |
|
| 218 | - * @param EE_Payment_Method $payment_method_instance |
|
| 219 | - */ |
|
| 220 | - public function set_instance($payment_method_instance) |
|
| 221 | - { |
|
| 222 | - $this->_pm_instance = $payment_method_instance; |
|
| 223 | - // if they have already requested the settings form, make sure its |
|
| 224 | - // data matches this model object |
|
| 225 | - if ($this->_settings_form) { |
|
| 226 | - $this->settings_form()->populate_model_obj($payment_method_instance); |
|
| 227 | - } |
|
| 228 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 229 | - $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Gets teh form for displaying to admins where they setup the payment method |
|
| 236 | - * |
|
| 237 | - * @return EE_Payment_Method_Form |
|
| 238 | - */ |
|
| 239 | - public function settings_form() |
|
| 240 | - { |
|
| 241 | - if (! $this->_settings_form) { |
|
| 242 | - $this->_settings_form = $this->generate_new_settings_form(); |
|
| 243 | - $this->_settings_form->set_payment_method_type($this); |
|
| 244 | - // if we have already assigned a model object to this pmt, make |
|
| 245 | - // sure its reflected in teh form we just generated |
|
| 246 | - if ($this->_pm_instance) { |
|
| 247 | - $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - return $this->_settings_form; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Gets the form for all the settings related to this payment method type |
|
| 256 | - * |
|
| 257 | - * @return EE_Payment_Method_Form |
|
| 258 | - */ |
|
| 259 | - abstract public function generate_new_settings_form(); |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * Sets the form for settings. This may be useful if we have already received |
|
| 264 | - * a form submission and have form data it in, and want to use it anytime we're showing |
|
| 265 | - * this payment method type's settings form later in the request |
|
| 266 | - * |
|
| 267 | - * @param EE_Payment_Method_Form $form |
|
| 268 | - */ |
|
| 269 | - public function set_settings_form($form) |
|
| 270 | - { |
|
| 271 | - $this->_settings_form = $form; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * @return boolean |
|
| 277 | - */ |
|
| 278 | - public function has_billing_form() |
|
| 279 | - { |
|
| 280 | - return $this->_has_billing_form; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Gets the form for displaying to attendees where they can enter their billing info |
|
| 286 | - * which will be sent to teh gateway (can be null) |
|
| 287 | - * |
|
| 288 | - * @param \EE_Transaction $transaction |
|
| 289 | - * @param array $extra_args |
|
| 290 | - * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
| 291 | - */ |
|
| 292 | - public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
| 293 | - { |
|
| 294 | - // has billing form already been regenerated ? or overwrite cache? |
|
| 295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
| 296 | - $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
| 297 | - } |
|
| 298 | - // if we know who the attendee is, and this is a billing form |
|
| 299 | - // that uses attendee info, populate it |
|
| 300 | - if (apply_filters( |
|
| 301 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
| 302 | - ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 303 | - && $transaction instanceof EE_Transaction |
|
| 304 | - && $transaction->primary_registration() instanceof EE_Registration |
|
| 305 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
| 306 | - ), |
|
| 307 | - $this->_billing_form, |
|
| 308 | - $transaction |
|
| 309 | - )) { |
|
| 310 | - $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
| 311 | - } |
|
| 312 | - return $this->_billing_form; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * Creates the billing form for this payment method type |
|
| 318 | - * |
|
| 319 | - * @param \EE_Transaction $transaction |
|
| 320 | - * @return \EE_Billing_Info_Form |
|
| 321 | - */ |
|
| 322 | - abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
| 323 | - |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * apply_billing_form_debug_settings |
|
| 327 | - * applies debug data to the form |
|
| 328 | - * |
|
| 329 | - * @param \EE_Billing_Info_Form $billing_form |
|
| 330 | - * @return \EE_Billing_Info_Form |
|
| 331 | - */ |
|
| 332 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
| 333 | - { |
|
| 334 | - return $billing_form; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * Sets the billing form for this payment method type. You may want to use this |
|
| 340 | - * if you have form |
|
| 341 | - * |
|
| 342 | - * @param EE_Payment_Method $form |
|
| 343 | - */ |
|
| 344 | - public function set_billing_form($form) |
|
| 345 | - { |
|
| 346 | - $this->_billing_form = $form; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Returns whether or not this payment method requires HTTPS to be used |
|
| 352 | - * |
|
| 353 | - * @return boolean |
|
| 354 | - */ |
|
| 355 | - public function requires_https() |
|
| 356 | - { |
|
| 357 | - return $this->_requires_https; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * |
|
| 363 | - * @param EE_Transaction $transaction |
|
| 364 | - * @param float $amount |
|
| 365 | - * @param EE_Billing_Info_Form $billing_info |
|
| 366 | - * @param string $return_url |
|
| 367 | - * @param string $fail_url |
|
| 368 | - * @param string $method |
|
| 369 | - * @param bool $by_admin |
|
| 370 | - * @return EE_Payment |
|
| 371 | - * @throws EE_Error |
|
| 372 | - */ |
|
| 373 | - public function process_payment( |
|
| 374 | - EE_Transaction $transaction, |
|
| 375 | - $amount = null, |
|
| 376 | - $billing_info = null, |
|
| 377 | - $return_url = null, |
|
| 378 | - $fail_url = '', |
|
| 379 | - $method = 'CART', |
|
| 380 | - $by_admin = false |
|
| 381 | - ) { |
|
| 382 | - // @todo: add surcharge for the payment method, if any |
|
| 383 | - if ($this->_gateway) { |
|
| 384 | - // there is a gateway, so we're going to make a payment object |
|
| 385 | - // but wait! do they already have a payment in progress that we thought was failed? |
|
| 386 | - $duplicate_properties = array( |
|
| 387 | - 'STS_ID' => EEM_Payment::status_id_failed, |
|
| 388 | - 'TXN_ID' => $transaction->ID(), |
|
| 389 | - 'PMD_ID' => $this->_pm_instance->ID(), |
|
| 390 | - 'PAY_source' => $method, |
|
| 391 | - 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
| 392 | - 'PAY_gateway_response' => null, |
|
| 393 | - ); |
|
| 394 | - $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
| 395 | - // if we didn't already have a payment in progress for the same thing, |
|
| 396 | - // then we actually want to make a new payment |
|
| 397 | - if (! $payment instanceof EE_Payment) { |
|
| 398 | - $payment = EE_Payment::new_instance( |
|
| 399 | - array_merge( |
|
| 400 | - $duplicate_properties, |
|
| 401 | - array( |
|
| 402 | - 'PAY_timestamp' => time(), |
|
| 403 | - 'PAY_txn_id_chq_nmbr' => null, |
|
| 404 | - 'PAY_po_number' => null, |
|
| 405 | - 'PAY_extra_accntng' => null, |
|
| 406 | - 'PAY_details' => null, |
|
| 407 | - ) |
|
| 408 | - ) |
|
| 409 | - ); |
|
| 410 | - } |
|
| 411 | - // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
| 412 | - $payment->save(); |
|
| 413 | - $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
| 414 | - |
|
| 415 | - // Offsite Gateway |
|
| 416 | - if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 417 | - $payment = $this->_gateway->set_redirection_info( |
|
| 418 | - $payment, |
|
| 419 | - $billing_values, |
|
| 420 | - $return_url, |
|
| 421 | - EE_Config::instance()->core->txn_page_url( |
|
| 422 | - array( |
|
| 423 | - 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
| 424 | - 'ee_payment_method' => $this->_pm_instance->slug(), |
|
| 425 | - ) |
|
| 426 | - ), |
|
| 427 | - $fail_url |
|
| 428 | - ); |
|
| 429 | - $payment->save(); |
|
| 430 | - // Onsite Gateway |
|
| 431 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
| 432 | - $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
| 433 | - $payment->save(); |
|
| 434 | - } else { |
|
| 435 | - throw new EE_Error( |
|
| 436 | - sprintf( |
|
| 437 | - __( |
|
| 438 | - 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
| 439 | - 'event_espresso' |
|
| 440 | - ), |
|
| 441 | - get_class($this), |
|
| 442 | - gettype($this->_gateway) |
|
| 443 | - ) |
|
| 444 | - ); |
|
| 445 | - } |
|
| 446 | - } else { |
|
| 447 | - // no gateway provided |
|
| 448 | - // there is no payment. Must be an offline gateway |
|
| 449 | - // create a payment object anyways, but dont save it |
|
| 450 | - $payment = EE_Payment::new_instance( |
|
| 451 | - array( |
|
| 452 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
| 453 | - 'TXN_ID' => $transaction->ID(), |
|
| 454 | - 'PMD_ID' => $transaction->payment_method_ID(), |
|
| 455 | - 'PAY_amount' => 0.00, |
|
| 456 | - 'PAY_timestamp' => time(), |
|
| 457 | - ) |
|
| 458 | - ); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - // if there is billing info, clean it and save it now |
|
| 462 | - if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
| 463 | - $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - return $payment; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * Gets the values we want to pass onto the gateway. Normally these |
|
| 471 | - * are just the 'pretty' values, but there may be times the data may need |
|
| 472 | - * a little massaging. Proper subsections will become arrays of inputs |
|
| 473 | - * |
|
| 474 | - * @param EE_Billing_Info_Form $billing_form |
|
| 475 | - * @return array |
|
| 476 | - */ |
|
| 477 | - protected function _get_billing_values_from_form($billing_form) |
|
| 478 | - { |
|
| 479 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 480 | - return $billing_form->input_pretty_values(true); |
|
| 481 | - } else { |
|
| 482 | - return null; |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * Handles an instant payment notification when the transaction is known (by default). |
|
| 489 | - * |
|
| 490 | - * @param array $req_data |
|
| 491 | - * @param EE_Transaction $transaction |
|
| 492 | - * @return EE_Payment |
|
| 493 | - * @throws EE_Error |
|
| 494 | - */ |
|
| 495 | - public function handle_ipn($req_data, $transaction) |
|
| 496 | - { |
|
| 497 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
| 498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 499 | - throw new EE_Error( |
|
| 500 | - sprintf( |
|
| 501 | - __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
| 502 | - print_r($this->_gateway, true) |
|
| 503 | - ) |
|
| 504 | - ); |
|
| 505 | - } |
|
| 506 | - $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
| 507 | - return $payment; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
| 513 | - * cleans it first. |
|
| 514 | - * |
|
| 515 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 516 | - * @param EE_Transaction $transaction |
|
| 517 | - * @return boolean success |
|
| 518 | - */ |
|
| 519 | - protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
| 520 | - { |
|
| 521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
| 522 | - EE_Error::add_error( |
|
| 523 | - __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
| 524 | - __FILE__, |
|
| 525 | - __FUNCTION__, |
|
| 526 | - __LINE__ |
|
| 527 | - ); |
|
| 528 | - return false; |
|
| 529 | - } |
|
| 530 | - $primary_reg = $transaction->primary_registration(); |
|
| 531 | - if (! $primary_reg) { |
|
| 532 | - EE_Error::add_error( |
|
| 533 | - __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
| 534 | - __FILE__, |
|
| 535 | - __FUNCTION__, |
|
| 536 | - __LINE__ |
|
| 537 | - ); |
|
| 538 | - return false; |
|
| 539 | - } |
|
| 540 | - $attendee = $primary_reg->attendee(); |
|
| 541 | - if (! $attendee) { |
|
| 542 | - EE_Error::add_error( |
|
| 543 | - __( |
|
| 544 | - "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
| 545 | - "event_espresso" |
|
| 546 | - ), |
|
| 547 | - __FILE__, |
|
| 548 | - __FUNCTION__, |
|
| 549 | - __LINE__ |
|
| 550 | - ); |
|
| 551 | - return false; |
|
| 552 | - } |
|
| 553 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * Gets the payment this IPN is for. Children may often want to |
|
| 559 | - * override this to inspect the request |
|
| 560 | - * |
|
| 561 | - * @param EE_Transaction $transaction |
|
| 562 | - * @param array $req_data |
|
| 563 | - * @return EE_Payment |
|
| 564 | - */ |
|
| 565 | - protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
| 566 | - { |
|
| 567 | - return $transaction->last_payment(); |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - |
|
| 571 | - /** |
|
| 572 | - * In case generic code cannot provide the payment processor with a specific payment method |
|
| 573 | - * and transaction, it will try calling this method on each activate payment method. |
|
| 574 | - * If the payment method is able to identify the request as being for it, it should fetch |
|
| 575 | - * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
| 576 | - * handle the IPN |
|
| 577 | - * |
|
| 578 | - * @param array $req_data |
|
| 579 | - * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
| 580 | - * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
| 581 | - * @throws EE_Error |
|
| 582 | - */ |
|
| 583 | - public function handle_unclaimed_ipn($req_data = array()) |
|
| 584 | - { |
|
| 585 | - throw new EE_Error( |
|
| 586 | - sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
| 587 | - ); |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - |
|
| 591 | - /** |
|
| 592 | - * Logic to be accomplished when the payment attempt is complete. |
|
| 593 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
| 594 | - * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
| 595 | - * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
| 596 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
| 597 | - * we're dealing with. Returns that last payment (if there is one) |
|
| 598 | - * |
|
| 599 | - * @param EE_Transaction $transaction |
|
| 600 | - * @return EE_Payment |
|
| 601 | - */ |
|
| 602 | - public function finalize_payment_for($transaction) |
|
| 603 | - { |
|
| 604 | - return $transaction->last_payment(); |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - |
|
| 608 | - /** |
|
| 609 | - * Whether or not this payment method's gateway supports sending refund requests |
|
| 610 | - * |
|
| 611 | - * @return boolean |
|
| 612 | - */ |
|
| 613 | - public function supports_sending_refunds() |
|
| 614 | - { |
|
| 615 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 616 | - return $this->_gateway->supports_sending_refunds(); |
|
| 617 | - } else { |
|
| 618 | - return false; |
|
| 619 | - } |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - |
|
| 623 | - /** |
|
| 624 | - * |
|
| 625 | - * @param EE_Payment $payment |
|
| 626 | - * @param array $refund_info |
|
| 627 | - * @throws EE_Error |
|
| 628 | - * @return EE_Payment |
|
| 629 | - */ |
|
| 630 | - public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
| 631 | - { |
|
| 632 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 633 | - return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
| 634 | - } else { |
|
| 635 | - throw new EE_Error( |
|
| 636 | - sprintf( |
|
| 637 | - __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
| 638 | - get_class($this) |
|
| 639 | - ) |
|
| 640 | - ); |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - |
|
| 645 | - /** |
|
| 646 | - * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
| 647 | - * payment method's gateway. |
|
| 648 | - * |
|
| 649 | - * @return string |
|
| 650 | - * @throws EE_Error |
|
| 651 | - */ |
|
| 652 | - public function payment_occurs() |
|
| 653 | - { |
|
| 654 | - if (! $this->_gateway) { |
|
| 655 | - return EE_PMT_Base::offline; |
|
| 656 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
| 657 | - return EE_PMT_Base::onsite; |
|
| 658 | - } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 659 | - return EE_PMT_Base::offsite; |
|
| 660 | - } else { |
|
| 661 | - throw new EE_Error( |
|
| 662 | - sprintf( |
|
| 663 | - __( |
|
| 664 | - "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
| 665 | - "event_espresso" |
|
| 666 | - ), |
|
| 667 | - get_class($this) |
|
| 668 | - ) |
|
| 669 | - ); |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * For adding any html output ab ove the payment overview. |
|
| 676 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
| 677 | - * Other gateways may want to override this, such as offline gateways. |
|
| 678 | - * |
|
| 679 | - * @param EE_Payment $payment |
|
| 680 | - * @return string |
|
| 681 | - */ |
|
| 682 | - public function payment_overview_content(EE_Payment $payment) |
|
| 683 | - { |
|
| 684 | - return EEH_Template::display_template( |
|
| 685 | - EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
| 686 | - array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
| 687 | - true |
|
| 688 | - ); |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * @return array where keys are the help tab name, |
|
| 694 | - * values are: array { |
|
| 695 | - * @type string $title i18n name for the help tab |
|
| 696 | - * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
| 697 | - * @type array $template_args any arguments you want passed to the template file while rendering. |
|
| 698 | - * Keys will be variable names and values with be their values. |
|
| 699 | - */ |
|
| 700 | - public function help_tabs_config() |
|
| 701 | - { |
|
| 702 | - return array(); |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - |
|
| 706 | - /** |
|
| 707 | - * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
| 708 | - * the payment method's table's PMT_type column) |
|
| 709 | - * |
|
| 710 | - * @return string |
|
| 711 | - */ |
|
| 712 | - public function system_name() |
|
| 713 | - { |
|
| 714 | - $classname = get_class($this); |
|
| 715 | - return str_replace("EE_PMT_", '', $classname); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - |
|
| 719 | - /** |
|
| 720 | - * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
| 721 | - * this method. |
|
| 722 | - * @return string |
|
| 723 | - */ |
|
| 724 | - public function defaultFrontendName() |
|
| 725 | - { |
|
| 726 | - return $this->pretty_name(); |
|
| 727 | - } |
|
| 728 | - |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * A pretty i18n version of the PMT name |
|
| 732 | - * |
|
| 733 | - * @return string |
|
| 734 | - */ |
|
| 735 | - public function pretty_name() |
|
| 736 | - { |
|
| 737 | - return $this->_pretty_name; |
|
| 738 | - } |
|
| 739 | - |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * Gets the default absolute URL to the payment method type's button |
|
| 743 | - * |
|
| 744 | - * @return string |
|
| 745 | - */ |
|
| 746 | - public function default_button_url() |
|
| 747 | - { |
|
| 748 | - return $this->_default_button_url; |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - |
|
| 752 | - /** |
|
| 753 | - * Gets the gateway used by this payment method (if any) |
|
| 754 | - * |
|
| 755 | - * @return EE_Gateway |
|
| 756 | - */ |
|
| 757 | - public function get_gateway() |
|
| 758 | - { |
|
| 759 | - return $this->_gateway; |
|
| 760 | - } |
|
| 761 | - |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * @return string html for the link to a help tab |
|
| 765 | - */ |
|
| 766 | - public function get_help_tab_link() |
|
| 767 | - { |
|
| 768 | - return EEH_Template::get_help_tab_link( |
|
| 769 | - $this->get_help_tab_name(), |
|
| 770 | - 'espresso_payment_settings', |
|
| 771 | - 'default' |
|
| 772 | - ); |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - |
|
| 776 | - /** |
|
| 777 | - * Returns the name of the help tab for this PMT |
|
| 778 | - * |
|
| 779 | - * @return string |
|
| 780 | - */ |
|
| 781 | - public function get_help_tab_name() |
|
| 782 | - { |
|
| 783 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
| 784 | - } |
|
| 785 | - |
|
| 786 | - /** |
|
| 787 | - * The name of the wp capability that should be associated with the usage of |
|
| 788 | - * this PMT by an admin |
|
| 789 | - * |
|
| 790 | - * @return string |
|
| 791 | - */ |
|
| 792 | - public function cap_name() |
|
| 793 | - { |
|
| 794 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - /** |
|
| 798 | - * Called by client code to tell the gateway that if it wants to change |
|
| 799 | - * the transaction or line items or registrations related to teh payment it already |
|
| 800 | - * processed (we think, but possibly not) that now's the time to do it. |
|
| 801 | - * It is expected that gateways will store any info they need for this on the PAY_details, |
|
| 802 | - * or maybe an extra meta value |
|
| 803 | - * |
|
| 804 | - * @param EE_Payment $payment |
|
| 805 | - * @return void |
|
| 806 | - */ |
|
| 807 | - public function update_txn_based_on_payment($payment) |
|
| 808 | - { |
|
| 809 | - if ($this->_gateway instanceof EE_Gateway) { |
|
| 810 | - $this->_gateway->update_txn_based_on_payment($payment); |
|
| 811 | - } |
|
| 812 | - } |
|
| 813 | - |
|
| 814 | - /** |
|
| 815 | - * Returns a string of HTML describing this payment method type for an admin, |
|
| 816 | - * primarily intended for them to read before activating it. |
|
| 817 | - * The easiest way to set this is to create a folder 'templates' alongside |
|
| 818 | - * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
| 819 | - * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
| 820 | - * then you'd create a file named "templates" in the same folder as it, and name the file |
|
| 821 | - * "foo_bar_intro.template.php", and its content will be returned by this method |
|
| 822 | - * |
|
| 823 | - * @return string |
|
| 824 | - */ |
|
| 825 | - public function introductory_html() |
|
| 826 | - { |
|
| 827 | - return EEH_Template::locate_template( |
|
| 828 | - $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
| 829 | - array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
| 830 | - ); |
|
| 831 | - } |
|
| 24 | + const onsite = 'on-site'; |
|
| 25 | + const offsite = 'off-site'; |
|
| 26 | + const offline = 'off-line'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var EE_Payment_Method |
|
| 30 | + */ |
|
| 31 | + protected $_pm_instance = null; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var boolean |
|
| 35 | + */ |
|
| 36 | + protected $_requires_https = false; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var boolean |
|
| 40 | + */ |
|
| 41 | + protected $_has_billing_form; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var EE_Gateway |
|
| 45 | + */ |
|
| 46 | + protected $_gateway = null; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var EE_Payment_Method_Form |
|
| 50 | + */ |
|
| 51 | + protected $_settings_form = null; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var EE_Form_Section_Proper |
|
| 55 | + */ |
|
| 56 | + protected $_billing_form = null; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var boolean |
|
| 60 | + */ |
|
| 61 | + protected $_cache_billing_form = true; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * String of the absolute path to the folder containing this file, with a trailing slash. |
|
| 65 | + * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
| 66 | + * |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | + protected $_file_folder = null; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
| 73 | + * like images, js, or css) |
|
| 74 | + * |
|
| 75 | + * @var string |
|
| 76 | + */ |
|
| 77 | + protected $_file_url = null; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Pretty name for the payment method |
|
| 81 | + * |
|
| 82 | + * @var string |
|
| 83 | + */ |
|
| 84 | + protected $_pretty_name = null; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * |
|
| 88 | + * @var string |
|
| 89 | + */ |
|
| 90 | + protected $_default_button_url = null; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * |
|
| 94 | + * @var string |
|
| 95 | + */ |
|
| 96 | + protected $_default_description = null; |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * |
|
| 101 | + * @param EE_Payment_Method $pm_instance |
|
| 102 | + * @throws EE_Error |
|
| 103 | + * @return EE_PMT_Base |
|
| 104 | + */ |
|
| 105 | + public function __construct($pm_instance = null) |
|
| 106 | + { |
|
| 107 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
| 108 | + $this->set_instance($pm_instance); |
|
| 109 | + } |
|
| 110 | + if ($this->_gateway) { |
|
| 111 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
| 112 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
| 113 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
| 114 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
| 115 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
| 116 | + $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
| 117 | + $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
| 118 | + do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
| 119 | + } |
|
| 120 | + if (! isset($this->_has_billing_form)) { |
|
| 121 | + // by default, On Site gateways have a billing form |
|
| 122 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
| 123 | + $this->set_has_billing_form(true); |
|
| 124 | + } else { |
|
| 125 | + $this->set_has_billing_form(false); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + if (! $this->_pretty_name) { |
|
| 130 | + throw new EE_Error( |
|
| 131 | + sprintf( |
|
| 132 | + __( |
|
| 133 | + "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
| 134 | + "event_espresso" |
|
| 135 | + ) |
|
| 136 | + ) |
|
| 137 | + ); |
|
| 138 | + } |
|
| 139 | + // if the child didn't specify a default button, use the credit card one |
|
| 140 | + if ($this->_default_button_url === null) { |
|
| 141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @param boolean $has_billing_form |
|
| 148 | + */ |
|
| 149 | + public function set_has_billing_form($has_billing_form) |
|
| 150 | + { |
|
| 151 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * sets the file_folder property |
|
| 157 | + */ |
|
| 158 | + protected function _set_file_folder() |
|
| 159 | + { |
|
| 160 | + $reflector = new ReflectionClass(get_class($this)); |
|
| 161 | + $fn = $reflector->getFileName(); |
|
| 162 | + $this->_file_folder = dirname($fn) . '/'; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * sets the file URL with a trailing slash for this PMT |
|
| 168 | + */ |
|
| 169 | + protected function _set_file_url() |
|
| 170 | + { |
|
| 171 | + $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
| 172 | + $file_folder_fixed = str_replace('\\', '/', $this->file_folder()); |
|
| 173 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
| 174 | + $this->_file_url = set_url_scheme($file_path); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Gets the default description on all payment methods of this type |
|
| 179 | + * |
|
| 180 | + * @return string |
|
| 181 | + */ |
|
| 182 | + public function default_description() |
|
| 183 | + { |
|
| 184 | + return $this->_default_description; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Returns the folder containing the PMT child class, with a trailing slash |
|
| 190 | + * |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | + public function file_folder() |
|
| 194 | + { |
|
| 195 | + if (! $this->_file_folder) { |
|
| 196 | + $this->_set_file_folder(); |
|
| 197 | + } |
|
| 198 | + return $this->_file_folder; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @return string |
|
| 204 | + */ |
|
| 205 | + public function file_url() |
|
| 206 | + { |
|
| 207 | + if (! $this->_file_url) { |
|
| 208 | + $this->_set_file_url(); |
|
| 209 | + } |
|
| 210 | + return $this->_file_url; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Sets the payment method instance this payment method type is for. |
|
| 216 | + * Its important teh payment method instance is set before |
|
| 217 | + * |
|
| 218 | + * @param EE_Payment_Method $payment_method_instance |
|
| 219 | + */ |
|
| 220 | + public function set_instance($payment_method_instance) |
|
| 221 | + { |
|
| 222 | + $this->_pm_instance = $payment_method_instance; |
|
| 223 | + // if they have already requested the settings form, make sure its |
|
| 224 | + // data matches this model object |
|
| 225 | + if ($this->_settings_form) { |
|
| 226 | + $this->settings_form()->populate_model_obj($payment_method_instance); |
|
| 227 | + } |
|
| 228 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 229 | + $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Gets teh form for displaying to admins where they setup the payment method |
|
| 236 | + * |
|
| 237 | + * @return EE_Payment_Method_Form |
|
| 238 | + */ |
|
| 239 | + public function settings_form() |
|
| 240 | + { |
|
| 241 | + if (! $this->_settings_form) { |
|
| 242 | + $this->_settings_form = $this->generate_new_settings_form(); |
|
| 243 | + $this->_settings_form->set_payment_method_type($this); |
|
| 244 | + // if we have already assigned a model object to this pmt, make |
|
| 245 | + // sure its reflected in teh form we just generated |
|
| 246 | + if ($this->_pm_instance) { |
|
| 247 | + $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + return $this->_settings_form; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Gets the form for all the settings related to this payment method type |
|
| 256 | + * |
|
| 257 | + * @return EE_Payment_Method_Form |
|
| 258 | + */ |
|
| 259 | + abstract public function generate_new_settings_form(); |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * Sets the form for settings. This may be useful if we have already received |
|
| 264 | + * a form submission and have form data it in, and want to use it anytime we're showing |
|
| 265 | + * this payment method type's settings form later in the request |
|
| 266 | + * |
|
| 267 | + * @param EE_Payment_Method_Form $form |
|
| 268 | + */ |
|
| 269 | + public function set_settings_form($form) |
|
| 270 | + { |
|
| 271 | + $this->_settings_form = $form; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * @return boolean |
|
| 277 | + */ |
|
| 278 | + public function has_billing_form() |
|
| 279 | + { |
|
| 280 | + return $this->_has_billing_form; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Gets the form for displaying to attendees where they can enter their billing info |
|
| 286 | + * which will be sent to teh gateway (can be null) |
|
| 287 | + * |
|
| 288 | + * @param \EE_Transaction $transaction |
|
| 289 | + * @param array $extra_args |
|
| 290 | + * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
| 291 | + */ |
|
| 292 | + public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
| 293 | + { |
|
| 294 | + // has billing form already been regenerated ? or overwrite cache? |
|
| 295 | + if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
| 296 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
| 297 | + } |
|
| 298 | + // if we know who the attendee is, and this is a billing form |
|
| 299 | + // that uses attendee info, populate it |
|
| 300 | + if (apply_filters( |
|
| 301 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
| 302 | + ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 303 | + && $transaction instanceof EE_Transaction |
|
| 304 | + && $transaction->primary_registration() instanceof EE_Registration |
|
| 305 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
| 306 | + ), |
|
| 307 | + $this->_billing_form, |
|
| 308 | + $transaction |
|
| 309 | + )) { |
|
| 310 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
| 311 | + } |
|
| 312 | + return $this->_billing_form; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * Creates the billing form for this payment method type |
|
| 318 | + * |
|
| 319 | + * @param \EE_Transaction $transaction |
|
| 320 | + * @return \EE_Billing_Info_Form |
|
| 321 | + */ |
|
| 322 | + abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
| 323 | + |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * apply_billing_form_debug_settings |
|
| 327 | + * applies debug data to the form |
|
| 328 | + * |
|
| 329 | + * @param \EE_Billing_Info_Form $billing_form |
|
| 330 | + * @return \EE_Billing_Info_Form |
|
| 331 | + */ |
|
| 332 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
| 333 | + { |
|
| 334 | + return $billing_form; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * Sets the billing form for this payment method type. You may want to use this |
|
| 340 | + * if you have form |
|
| 341 | + * |
|
| 342 | + * @param EE_Payment_Method $form |
|
| 343 | + */ |
|
| 344 | + public function set_billing_form($form) |
|
| 345 | + { |
|
| 346 | + $this->_billing_form = $form; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Returns whether or not this payment method requires HTTPS to be used |
|
| 352 | + * |
|
| 353 | + * @return boolean |
|
| 354 | + */ |
|
| 355 | + public function requires_https() |
|
| 356 | + { |
|
| 357 | + return $this->_requires_https; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * |
|
| 363 | + * @param EE_Transaction $transaction |
|
| 364 | + * @param float $amount |
|
| 365 | + * @param EE_Billing_Info_Form $billing_info |
|
| 366 | + * @param string $return_url |
|
| 367 | + * @param string $fail_url |
|
| 368 | + * @param string $method |
|
| 369 | + * @param bool $by_admin |
|
| 370 | + * @return EE_Payment |
|
| 371 | + * @throws EE_Error |
|
| 372 | + */ |
|
| 373 | + public function process_payment( |
|
| 374 | + EE_Transaction $transaction, |
|
| 375 | + $amount = null, |
|
| 376 | + $billing_info = null, |
|
| 377 | + $return_url = null, |
|
| 378 | + $fail_url = '', |
|
| 379 | + $method = 'CART', |
|
| 380 | + $by_admin = false |
|
| 381 | + ) { |
|
| 382 | + // @todo: add surcharge for the payment method, if any |
|
| 383 | + if ($this->_gateway) { |
|
| 384 | + // there is a gateway, so we're going to make a payment object |
|
| 385 | + // but wait! do they already have a payment in progress that we thought was failed? |
|
| 386 | + $duplicate_properties = array( |
|
| 387 | + 'STS_ID' => EEM_Payment::status_id_failed, |
|
| 388 | + 'TXN_ID' => $transaction->ID(), |
|
| 389 | + 'PMD_ID' => $this->_pm_instance->ID(), |
|
| 390 | + 'PAY_source' => $method, |
|
| 391 | + 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
| 392 | + 'PAY_gateway_response' => null, |
|
| 393 | + ); |
|
| 394 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
| 395 | + // if we didn't already have a payment in progress for the same thing, |
|
| 396 | + // then we actually want to make a new payment |
|
| 397 | + if (! $payment instanceof EE_Payment) { |
|
| 398 | + $payment = EE_Payment::new_instance( |
|
| 399 | + array_merge( |
|
| 400 | + $duplicate_properties, |
|
| 401 | + array( |
|
| 402 | + 'PAY_timestamp' => time(), |
|
| 403 | + 'PAY_txn_id_chq_nmbr' => null, |
|
| 404 | + 'PAY_po_number' => null, |
|
| 405 | + 'PAY_extra_accntng' => null, |
|
| 406 | + 'PAY_details' => null, |
|
| 407 | + ) |
|
| 408 | + ) |
|
| 409 | + ); |
|
| 410 | + } |
|
| 411 | + // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
| 412 | + $payment->save(); |
|
| 413 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
| 414 | + |
|
| 415 | + // Offsite Gateway |
|
| 416 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 417 | + $payment = $this->_gateway->set_redirection_info( |
|
| 418 | + $payment, |
|
| 419 | + $billing_values, |
|
| 420 | + $return_url, |
|
| 421 | + EE_Config::instance()->core->txn_page_url( |
|
| 422 | + array( |
|
| 423 | + 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
| 424 | + 'ee_payment_method' => $this->_pm_instance->slug(), |
|
| 425 | + ) |
|
| 426 | + ), |
|
| 427 | + $fail_url |
|
| 428 | + ); |
|
| 429 | + $payment->save(); |
|
| 430 | + // Onsite Gateway |
|
| 431 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
| 432 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
| 433 | + $payment->save(); |
|
| 434 | + } else { |
|
| 435 | + throw new EE_Error( |
|
| 436 | + sprintf( |
|
| 437 | + __( |
|
| 438 | + 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
| 439 | + 'event_espresso' |
|
| 440 | + ), |
|
| 441 | + get_class($this), |
|
| 442 | + gettype($this->_gateway) |
|
| 443 | + ) |
|
| 444 | + ); |
|
| 445 | + } |
|
| 446 | + } else { |
|
| 447 | + // no gateway provided |
|
| 448 | + // there is no payment. Must be an offline gateway |
|
| 449 | + // create a payment object anyways, but dont save it |
|
| 450 | + $payment = EE_Payment::new_instance( |
|
| 451 | + array( |
|
| 452 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
| 453 | + 'TXN_ID' => $transaction->ID(), |
|
| 454 | + 'PMD_ID' => $transaction->payment_method_ID(), |
|
| 455 | + 'PAY_amount' => 0.00, |
|
| 456 | + 'PAY_timestamp' => time(), |
|
| 457 | + ) |
|
| 458 | + ); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + // if there is billing info, clean it and save it now |
|
| 462 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
| 463 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + return $payment; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * Gets the values we want to pass onto the gateway. Normally these |
|
| 471 | + * are just the 'pretty' values, but there may be times the data may need |
|
| 472 | + * a little massaging. Proper subsections will become arrays of inputs |
|
| 473 | + * |
|
| 474 | + * @param EE_Billing_Info_Form $billing_form |
|
| 475 | + * @return array |
|
| 476 | + */ |
|
| 477 | + protected function _get_billing_values_from_form($billing_form) |
|
| 478 | + { |
|
| 479 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 480 | + return $billing_form->input_pretty_values(true); |
|
| 481 | + } else { |
|
| 482 | + return null; |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * Handles an instant payment notification when the transaction is known (by default). |
|
| 489 | + * |
|
| 490 | + * @param array $req_data |
|
| 491 | + * @param EE_Transaction $transaction |
|
| 492 | + * @return EE_Payment |
|
| 493 | + * @throws EE_Error |
|
| 494 | + */ |
|
| 495 | + public function handle_ipn($req_data, $transaction) |
|
| 496 | + { |
|
| 497 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
| 498 | + if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 499 | + throw new EE_Error( |
|
| 500 | + sprintf( |
|
| 501 | + __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
| 502 | + print_r($this->_gateway, true) |
|
| 503 | + ) |
|
| 504 | + ); |
|
| 505 | + } |
|
| 506 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
| 507 | + return $payment; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
| 513 | + * cleans it first. |
|
| 514 | + * |
|
| 515 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 516 | + * @param EE_Transaction $transaction |
|
| 517 | + * @return boolean success |
|
| 518 | + */ |
|
| 519 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
| 520 | + { |
|
| 521 | + if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
| 522 | + EE_Error::add_error( |
|
| 523 | + __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
| 524 | + __FILE__, |
|
| 525 | + __FUNCTION__, |
|
| 526 | + __LINE__ |
|
| 527 | + ); |
|
| 528 | + return false; |
|
| 529 | + } |
|
| 530 | + $primary_reg = $transaction->primary_registration(); |
|
| 531 | + if (! $primary_reg) { |
|
| 532 | + EE_Error::add_error( |
|
| 533 | + __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
| 534 | + __FILE__, |
|
| 535 | + __FUNCTION__, |
|
| 536 | + __LINE__ |
|
| 537 | + ); |
|
| 538 | + return false; |
|
| 539 | + } |
|
| 540 | + $attendee = $primary_reg->attendee(); |
|
| 541 | + if (! $attendee) { |
|
| 542 | + EE_Error::add_error( |
|
| 543 | + __( |
|
| 544 | + "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
| 545 | + "event_espresso" |
|
| 546 | + ), |
|
| 547 | + __FILE__, |
|
| 548 | + __FUNCTION__, |
|
| 549 | + __LINE__ |
|
| 550 | + ); |
|
| 551 | + return false; |
|
| 552 | + } |
|
| 553 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * Gets the payment this IPN is for. Children may often want to |
|
| 559 | + * override this to inspect the request |
|
| 560 | + * |
|
| 561 | + * @param EE_Transaction $transaction |
|
| 562 | + * @param array $req_data |
|
| 563 | + * @return EE_Payment |
|
| 564 | + */ |
|
| 565 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
| 566 | + { |
|
| 567 | + return $transaction->last_payment(); |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + |
|
| 571 | + /** |
|
| 572 | + * In case generic code cannot provide the payment processor with a specific payment method |
|
| 573 | + * and transaction, it will try calling this method on each activate payment method. |
|
| 574 | + * If the payment method is able to identify the request as being for it, it should fetch |
|
| 575 | + * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
| 576 | + * handle the IPN |
|
| 577 | + * |
|
| 578 | + * @param array $req_data |
|
| 579 | + * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
| 580 | + * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
| 581 | + * @throws EE_Error |
|
| 582 | + */ |
|
| 583 | + public function handle_unclaimed_ipn($req_data = array()) |
|
| 584 | + { |
|
| 585 | + throw new EE_Error( |
|
| 586 | + sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
| 587 | + ); |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + |
|
| 591 | + /** |
|
| 592 | + * Logic to be accomplished when the payment attempt is complete. |
|
| 593 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
| 594 | + * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
| 595 | + * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
| 596 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
| 597 | + * we're dealing with. Returns that last payment (if there is one) |
|
| 598 | + * |
|
| 599 | + * @param EE_Transaction $transaction |
|
| 600 | + * @return EE_Payment |
|
| 601 | + */ |
|
| 602 | + public function finalize_payment_for($transaction) |
|
| 603 | + { |
|
| 604 | + return $transaction->last_payment(); |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + |
|
| 608 | + /** |
|
| 609 | + * Whether or not this payment method's gateway supports sending refund requests |
|
| 610 | + * |
|
| 611 | + * @return boolean |
|
| 612 | + */ |
|
| 613 | + public function supports_sending_refunds() |
|
| 614 | + { |
|
| 615 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 616 | + return $this->_gateway->supports_sending_refunds(); |
|
| 617 | + } else { |
|
| 618 | + return false; |
|
| 619 | + } |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * |
|
| 625 | + * @param EE_Payment $payment |
|
| 626 | + * @param array $refund_info |
|
| 627 | + * @throws EE_Error |
|
| 628 | + * @return EE_Payment |
|
| 629 | + */ |
|
| 630 | + public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
| 631 | + { |
|
| 632 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 633 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
| 634 | + } else { |
|
| 635 | + throw new EE_Error( |
|
| 636 | + sprintf( |
|
| 637 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
| 638 | + get_class($this) |
|
| 639 | + ) |
|
| 640 | + ); |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + |
|
| 645 | + /** |
|
| 646 | + * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
| 647 | + * payment method's gateway. |
|
| 648 | + * |
|
| 649 | + * @return string |
|
| 650 | + * @throws EE_Error |
|
| 651 | + */ |
|
| 652 | + public function payment_occurs() |
|
| 653 | + { |
|
| 654 | + if (! $this->_gateway) { |
|
| 655 | + return EE_PMT_Base::offline; |
|
| 656 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
| 657 | + return EE_PMT_Base::onsite; |
|
| 658 | + } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 659 | + return EE_PMT_Base::offsite; |
|
| 660 | + } else { |
|
| 661 | + throw new EE_Error( |
|
| 662 | + sprintf( |
|
| 663 | + __( |
|
| 664 | + "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
| 665 | + "event_espresso" |
|
| 666 | + ), |
|
| 667 | + get_class($this) |
|
| 668 | + ) |
|
| 669 | + ); |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * For adding any html output ab ove the payment overview. |
|
| 676 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
| 677 | + * Other gateways may want to override this, such as offline gateways. |
|
| 678 | + * |
|
| 679 | + * @param EE_Payment $payment |
|
| 680 | + * @return string |
|
| 681 | + */ |
|
| 682 | + public function payment_overview_content(EE_Payment $payment) |
|
| 683 | + { |
|
| 684 | + return EEH_Template::display_template( |
|
| 685 | + EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
| 686 | + array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
| 687 | + true |
|
| 688 | + ); |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * @return array where keys are the help tab name, |
|
| 694 | + * values are: array { |
|
| 695 | + * @type string $title i18n name for the help tab |
|
| 696 | + * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
| 697 | + * @type array $template_args any arguments you want passed to the template file while rendering. |
|
| 698 | + * Keys will be variable names and values with be their values. |
|
| 699 | + */ |
|
| 700 | + public function help_tabs_config() |
|
| 701 | + { |
|
| 702 | + return array(); |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + |
|
| 706 | + /** |
|
| 707 | + * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
| 708 | + * the payment method's table's PMT_type column) |
|
| 709 | + * |
|
| 710 | + * @return string |
|
| 711 | + */ |
|
| 712 | + public function system_name() |
|
| 713 | + { |
|
| 714 | + $classname = get_class($this); |
|
| 715 | + return str_replace("EE_PMT_", '', $classname); |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + |
|
| 719 | + /** |
|
| 720 | + * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
| 721 | + * this method. |
|
| 722 | + * @return string |
|
| 723 | + */ |
|
| 724 | + public function defaultFrontendName() |
|
| 725 | + { |
|
| 726 | + return $this->pretty_name(); |
|
| 727 | + } |
|
| 728 | + |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * A pretty i18n version of the PMT name |
|
| 732 | + * |
|
| 733 | + * @return string |
|
| 734 | + */ |
|
| 735 | + public function pretty_name() |
|
| 736 | + { |
|
| 737 | + return $this->_pretty_name; |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * Gets the default absolute URL to the payment method type's button |
|
| 743 | + * |
|
| 744 | + * @return string |
|
| 745 | + */ |
|
| 746 | + public function default_button_url() |
|
| 747 | + { |
|
| 748 | + return $this->_default_button_url; |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + |
|
| 752 | + /** |
|
| 753 | + * Gets the gateway used by this payment method (if any) |
|
| 754 | + * |
|
| 755 | + * @return EE_Gateway |
|
| 756 | + */ |
|
| 757 | + public function get_gateway() |
|
| 758 | + { |
|
| 759 | + return $this->_gateway; |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + |
|
| 763 | + /** |
|
| 764 | + * @return string html for the link to a help tab |
|
| 765 | + */ |
|
| 766 | + public function get_help_tab_link() |
|
| 767 | + { |
|
| 768 | + return EEH_Template::get_help_tab_link( |
|
| 769 | + $this->get_help_tab_name(), |
|
| 770 | + 'espresso_payment_settings', |
|
| 771 | + 'default' |
|
| 772 | + ); |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * Returns the name of the help tab for this PMT |
|
| 778 | + * |
|
| 779 | + * @return string |
|
| 780 | + */ |
|
| 781 | + public function get_help_tab_name() |
|
| 782 | + { |
|
| 783 | + return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + /** |
|
| 787 | + * The name of the wp capability that should be associated with the usage of |
|
| 788 | + * this PMT by an admin |
|
| 789 | + * |
|
| 790 | + * @return string |
|
| 791 | + */ |
|
| 792 | + public function cap_name() |
|
| 793 | + { |
|
| 794 | + return 'ee_payment_method_' . strtolower($this->system_name()); |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + /** |
|
| 798 | + * Called by client code to tell the gateway that if it wants to change |
|
| 799 | + * the transaction or line items or registrations related to teh payment it already |
|
| 800 | + * processed (we think, but possibly not) that now's the time to do it. |
|
| 801 | + * It is expected that gateways will store any info they need for this on the PAY_details, |
|
| 802 | + * or maybe an extra meta value |
|
| 803 | + * |
|
| 804 | + * @param EE_Payment $payment |
|
| 805 | + * @return void |
|
| 806 | + */ |
|
| 807 | + public function update_txn_based_on_payment($payment) |
|
| 808 | + { |
|
| 809 | + if ($this->_gateway instanceof EE_Gateway) { |
|
| 810 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
| 811 | + } |
|
| 812 | + } |
|
| 813 | + |
|
| 814 | + /** |
|
| 815 | + * Returns a string of HTML describing this payment method type for an admin, |
|
| 816 | + * primarily intended for them to read before activating it. |
|
| 817 | + * The easiest way to set this is to create a folder 'templates' alongside |
|
| 818 | + * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
| 819 | + * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
| 820 | + * then you'd create a file named "templates" in the same folder as it, and name the file |
|
| 821 | + * "foo_bar_intro.template.php", and its content will be returned by this method |
|
| 822 | + * |
|
| 823 | + * @return string |
|
| 824 | + */ |
|
| 825 | + public function introductory_html() |
|
| 826 | + { |
|
| 827 | + return EEH_Template::locate_template( |
|
| 828 | + $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
| 829 | + array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
| 830 | + ); |
|
| 831 | + } |
|
| 832 | 832 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
| 118 | 118 | do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
| 119 | 119 | } |
| 120 | - if (! isset($this->_has_billing_form)) { |
|
| 120 | + if ( ! isset($this->_has_billing_form)) { |
|
| 121 | 121 | // by default, On Site gateways have a billing form |
| 122 | 122 | if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
| 123 | 123 | $this->set_has_billing_form(true); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if (! $this->_pretty_name) { |
|
| 129 | + if ( ! $this->_pretty_name) { |
|
| 130 | 130 | throw new EE_Error( |
| 131 | 131 | sprintf( |
| 132 | 132 | __( |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | // if the child didn't specify a default button, use the credit card one |
| 140 | 140 | if ($this->_default_button_url === null) { |
| 141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
| 141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods/pay-by-credit-card.png'; |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $reflector = new ReflectionClass(get_class($this)); |
| 161 | 161 | $fn = $reflector->getFileName(); |
| 162 | - $this->_file_folder = dirname($fn) . '/'; |
|
| 162 | + $this->_file_folder = dirname($fn).'/'; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function file_folder() |
| 194 | 194 | { |
| 195 | - if (! $this->_file_folder) { |
|
| 195 | + if ( ! $this->_file_folder) { |
|
| 196 | 196 | $this->_set_file_folder(); |
| 197 | 197 | } |
| 198 | 198 | return $this->_file_folder; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function file_url() |
| 206 | 206 | { |
| 207 | - if (! $this->_file_url) { |
|
| 207 | + if ( ! $this->_file_url) { |
|
| 208 | 208 | $this->_set_file_url(); |
| 209 | 209 | } |
| 210 | 210 | return $this->_file_url; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function settings_form() |
| 240 | 240 | { |
| 241 | - if (! $this->_settings_form) { |
|
| 241 | + if ( ! $this->_settings_form) { |
|
| 242 | 242 | $this->_settings_form = $this->generate_new_settings_form(); |
| 243 | 243 | $this->_settings_form->set_payment_method_type($this); |
| 244 | 244 | // if we have already assigned a model object to this pmt, make |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
| 293 | 293 | { |
| 294 | 294 | // has billing form already been regenerated ? or overwrite cache? |
| 295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
| 295 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
| 296 | 296 | $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
| 297 | 297 | } |
| 298 | 298 | // if we know who the attendee is, and this is a billing form |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
| 395 | 395 | // if we didn't already have a payment in progress for the same thing, |
| 396 | 396 | // then we actually want to make a new payment |
| 397 | - if (! $payment instanceof EE_Payment) { |
|
| 397 | + if ( ! $payment instanceof EE_Payment) { |
|
| 398 | 398 | $payment = EE_Payment::new_instance( |
| 399 | 399 | array_merge( |
| 400 | 400 | $duplicate_properties, |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | public function handle_ipn($req_data, $transaction) |
| 496 | 496 | { |
| 497 | 497 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
| 498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 498 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 499 | 499 | throw new EE_Error( |
| 500 | 500 | sprintf( |
| 501 | 501 | __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | protected function _save_billing_info_to_attendee($billing_form, $transaction) |
| 520 | 520 | { |
| 521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
| 521 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
| 522 | 522 | EE_Error::add_error( |
| 523 | 523 | __("Cannot save billing info because no transaction was specified", "event_espresso"), |
| 524 | 524 | __FILE__, |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | return false; |
| 529 | 529 | } |
| 530 | 530 | $primary_reg = $transaction->primary_registration(); |
| 531 | - if (! $primary_reg) { |
|
| 531 | + if ( ! $primary_reg) { |
|
| 532 | 532 | EE_Error::add_error( |
| 533 | 533 | __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
| 534 | 534 | __FILE__, |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | return false; |
| 539 | 539 | } |
| 540 | 540 | $attendee = $primary_reg->attendee(); |
| 541 | - if (! $attendee) { |
|
| 541 | + if ( ! $attendee) { |
|
| 542 | 542 | EE_Error::add_error( |
| 543 | 543 | __( |
| 544 | 544 | "Cannot save billing info because the transaction's primary registration has no attendee!", |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | */ |
| 652 | 652 | public function payment_occurs() |
| 653 | 653 | { |
| 654 | - if (! $this->_gateway) { |
|
| 654 | + if ( ! $this->_gateway) { |
|
| 655 | 655 | return EE_PMT_Base::offline; |
| 656 | 656 | } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
| 657 | 657 | return EE_PMT_Base::onsite; |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | public function payment_overview_content(EE_Payment $payment) |
| 683 | 683 | { |
| 684 | 684 | return EEH_Template::display_template( |
| 685 | - EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
| 685 | + EE_LIBRARIES.'payment_methods/templates/payment_details_content.template.php', |
|
| 686 | 686 | array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
| 687 | 687 | true |
| 688 | 688 | ); |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | */ |
| 781 | 781 | public function get_help_tab_name() |
| 782 | 782 | { |
| 783 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
| 783 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | /** |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | */ |
| 792 | 792 | public function cap_name() |
| 793 | 793 | { |
| 794 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
| 794 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | public function introductory_html() |
| 826 | 826 | { |
| 827 | 827 | return EEH_Template::locate_template( |
| 828 | - $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
| 828 | + $this->file_folder().'templates/'.strtolower($this->system_name()).'_intro.template.php', |
|
| 829 | 829 | array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
| 830 | 830 | ); |
| 831 | 831 | } |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
| 16 | 16 | $class_to_filepath = array(); |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | - $matches = array(); |
|
| 19 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 18 | + $matches = array(); |
|
| 19 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -36,68 +36,68 @@ discard block |
||
| 36 | 36 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * return EE_DMS_Core_4_9_0 |
|
| 41 | - * |
|
| 42 | - * @param TableManager $table_manager |
|
| 43 | - * @param TableAnalysis $table_analysis |
|
| 44 | - */ |
|
| 45 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 46 | - { |
|
| 47 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
| 48 | - $this->_priority = 10; |
|
| 49 | - $this->_migration_stages = array( |
|
| 50 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
| 51 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
| 52 | - ); |
|
| 53 | - parent::__construct($table_manager, $table_analysis); |
|
| 54 | - } |
|
| 39 | + /** |
|
| 40 | + * return EE_DMS_Core_4_9_0 |
|
| 41 | + * |
|
| 42 | + * @param TableManager $table_manager |
|
| 43 | + * @param TableAnalysis $table_analysis |
|
| 44 | + */ |
|
| 45 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 46 | + { |
|
| 47 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
| 48 | + $this->_priority = 10; |
|
| 49 | + $this->_migration_stages = array( |
|
| 50 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
| 51 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
| 52 | + ); |
|
| 53 | + parent::__construct($table_manager, $table_analysis); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Whether to migrate or not. |
|
| 60 | - * |
|
| 61 | - * @param array $version_array |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 64 | - public function can_migrate_from_version($version_array) |
|
| 65 | - { |
|
| 66 | - $version_string = $version_array['Core']; |
|
| 67 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
| 68 | - // echo "$version_string can be migrated from"; |
|
| 69 | - return true; |
|
| 70 | - } elseif (! $version_string) { |
|
| 71 | - // echo "no version string provided: $version_string"; |
|
| 72 | - // no version string provided... this must be pre 4.3 |
|
| 73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | - } else { |
|
| 75 | - // echo "$version_string doesnt apply"; |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 78 | - } |
|
| 58 | + /** |
|
| 59 | + * Whether to migrate or not. |
|
| 60 | + * |
|
| 61 | + * @param array $version_array |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public function can_migrate_from_version($version_array) |
|
| 65 | + { |
|
| 66 | + $version_string = $version_array['Core']; |
|
| 67 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
| 68 | + // echo "$version_string can be migrated from"; |
|
| 69 | + return true; |
|
| 70 | + } elseif (! $version_string) { |
|
| 71 | + // echo "no version string provided: $version_string"; |
|
| 72 | + // no version string provided... this must be pre 4.3 |
|
| 73 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | + } else { |
|
| 75 | + // echo "$version_string doesnt apply"; |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - public function schema_changes_before_migration() |
|
| 86 | - { |
|
| 87 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 88 | - $now_in_mysql = current_time('mysql', true); |
|
| 89 | - $table_name = 'esp_answer'; |
|
| 90 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 82 | + /** |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + public function schema_changes_before_migration() |
|
| 86 | + { |
|
| 87 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 88 | + $now_in_mysql = current_time('mysql', true); |
|
| 89 | + $table_name = 'esp_answer'; |
|
| 90 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 91 | 91 | REG_ID int(10) unsigned NOT NULL, |
| 92 | 92 | QST_ID int(10) unsigned NOT NULL, |
| 93 | 93 | ANS_value text NOT NULL, |
| 94 | 94 | PRIMARY KEY (ANS_ID), |
| 95 | 95 | KEY REG_ID (REG_ID), |
| 96 | 96 | KEY QST_ID (QST_ID)"; |
| 97 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 98 | - $table_name = 'esp_attendee_meta'; |
|
| 99 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
| 100 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 97 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 98 | + $table_name = 'esp_attendee_meta'; |
|
| 99 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
| 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, |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | KEY ATT_email (ATT_email(191)), |
| 115 | 115 | KEY ATT_lname (ATT_lname), |
| 116 | 116 | KEY ATT_fname (ATT_fname)"; |
| 117 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 118 | - $table_name = 'esp_checkin'; |
|
| 119 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 117 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 118 | + $table_name = 'esp_checkin'; |
|
| 119 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 120 | 120 | REG_ID int(10) unsigned NOT NULL, |
| 121 | 121 | DTT_ID int(10) unsigned NOT NULL, |
| 122 | 122 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | PRIMARY KEY (CHK_ID), |
| 125 | 125 | KEY REG_ID (REG_ID), |
| 126 | 126 | KEY DTT_ID (DTT_ID)"; |
| 127 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 128 | - $table_name = 'esp_country'; |
|
| 129 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 127 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 128 | + $table_name = 'esp_country'; |
|
| 129 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 130 | 130 | CNT_ISO3 varchar(3) NOT NULL, |
| 131 | 131 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 132 | 132 | CNT_name varchar(45) NOT NULL, |
@@ -142,29 +142,29 @@ discard block |
||
| 142 | 142 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 143 | 143 | CNT_active tinyint(1) DEFAULT '0', |
| 144 | 144 | PRIMARY KEY (CNT_ISO)"; |
| 145 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 146 | - $table_name = 'esp_currency'; |
|
| 147 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
| 145 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 146 | + $table_name = 'esp_currency'; |
|
| 147 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
| 148 | 148 | CUR_single varchar(45) DEFAULT 'dollar', |
| 149 | 149 | CUR_plural varchar(45) DEFAULT 'dollars', |
| 150 | 150 | CUR_sign varchar(45) DEFAULT '$', |
| 151 | 151 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
| 152 | 152 | CUR_active tinyint(1) DEFAULT '0', |
| 153 | 153 | PRIMARY KEY (CUR_code)"; |
| 154 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 155 | - // note: although this table is no longer in use, |
|
| 156 | - // it hasn't been removed because then queries to the model will have errors. |
|
| 157 | - // but you should expect this table and its corresponding model to be removed in |
|
| 158 | - // the next few months |
|
| 159 | - $table_name = 'esp_currency_payment_method'; |
|
| 160 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 154 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 155 | + // note: although this table is no longer in use, |
|
| 156 | + // it hasn't been removed because then queries to the model will have errors. |
|
| 157 | + // but you should expect this table and its corresponding model to be removed in |
|
| 158 | + // the next few months |
|
| 159 | + $table_name = 'esp_currency_payment_method'; |
|
| 160 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 161 | 161 | CUR_code varchar(6) NOT NULL, |
| 162 | 162 | PMD_ID int(11) NOT NULL, |
| 163 | 163 | PRIMARY KEY (CPM_ID), |
| 164 | 164 | KEY PMD_ID (PMD_ID)"; |
| 165 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 166 | - $table_name = 'esp_datetime'; |
|
| 167 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 165 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 166 | + $table_name = 'esp_datetime'; |
|
| 167 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 168 | 168 | EVT_ID bigint(20) unsigned NOT NULL, |
| 169 | 169 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 170 | 170 | DTT_description text NOT NULL, |
@@ -181,25 +181,25 @@ discard block |
||
| 181 | 181 | KEY DTT_EVT_start (DTT_EVT_start), |
| 182 | 182 | KEY EVT_ID (EVT_ID), |
| 183 | 183 | KEY DTT_is_primary (DTT_is_primary)"; |
| 184 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 185 | - $table_name = "esp_datetime_ticket"; |
|
| 186 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 184 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 185 | + $table_name = "esp_datetime_ticket"; |
|
| 186 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 187 | 187 | DTT_ID int(10) unsigned NOT NULL, |
| 188 | 188 | TKT_ID int(10) unsigned NOT NULL, |
| 189 | 189 | PRIMARY KEY (DTK_ID), |
| 190 | 190 | KEY DTT_ID (DTT_ID), |
| 191 | 191 | KEY TKT_ID (TKT_ID)"; |
| 192 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 193 | - $table_name = 'esp_event_message_template'; |
|
| 194 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 192 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 193 | + $table_name = 'esp_event_message_template'; |
|
| 194 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 195 | 195 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 196 | 196 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 197 | 197 | PRIMARY KEY (EMT_ID), |
| 198 | 198 | KEY EVT_ID (EVT_ID), |
| 199 | 199 | KEY GRP_ID (GRP_ID)"; |
| 200 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 201 | - $table_name = 'esp_event_meta'; |
|
| 202 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 200 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 201 | + $table_name = 'esp_event_meta'; |
|
| 202 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 203 | 203 | EVT_ID bigint(20) unsigned NOT NULL, |
| 204 | 204 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 205 | 205 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -214,34 +214,34 @@ discard block |
||
| 214 | 214 | EVT_donations tinyint(1) NULL, |
| 215 | 215 | PRIMARY KEY (EVTM_ID), |
| 216 | 216 | KEY EVT_ID (EVT_ID)"; |
| 217 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 218 | - $table_name = 'esp_event_question_group'; |
|
| 219 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 217 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 218 | + $table_name = 'esp_event_question_group'; |
|
| 219 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 220 | 220 | EVT_ID bigint(20) unsigned NOT NULL, |
| 221 | 221 | QSG_ID int(10) unsigned NOT NULL, |
| 222 | 222 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 223 | 223 | PRIMARY KEY (EQG_ID), |
| 224 | 224 | KEY EVT_ID (EVT_ID), |
| 225 | 225 | KEY QSG_ID (QSG_ID)"; |
| 226 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 227 | - $table_name = 'esp_event_venue'; |
|
| 228 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 226 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 227 | + $table_name = 'esp_event_venue'; |
|
| 228 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 229 | 229 | EVT_ID bigint(20) unsigned NOT NULL, |
| 230 | 230 | VNU_ID bigint(20) unsigned NOT NULL, |
| 231 | 231 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 232 | 232 | PRIMARY KEY (EVV_ID)"; |
| 233 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 234 | - $table_name = 'esp_extra_meta'; |
|
| 235 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 233 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 234 | + $table_name = 'esp_extra_meta'; |
|
| 235 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 236 | 236 | OBJ_ID int(11) DEFAULT NULL, |
| 237 | 237 | EXM_type varchar(45) DEFAULT NULL, |
| 238 | 238 | EXM_key varchar(45) DEFAULT NULL, |
| 239 | 239 | EXM_value text, |
| 240 | 240 | PRIMARY KEY (EXM_ID), |
| 241 | 241 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
| 242 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 243 | - $table_name = 'esp_extra_join'; |
|
| 244 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 242 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 243 | + $table_name = 'esp_extra_join'; |
|
| 244 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 245 | 245 | EXJ_first_model_id varchar(6) NOT NULL, |
| 246 | 246 | EXJ_first_model_name varchar(20) NOT NULL, |
| 247 | 247 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | PRIMARY KEY (EXJ_ID), |
| 250 | 250 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
| 251 | 251 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
| 252 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 253 | - $table_name = 'esp_line_item'; |
|
| 254 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 252 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 253 | + $table_name = 'esp_line_item'; |
|
| 254 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 255 | 255 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 256 | 256 | TXN_ID int(11) DEFAULT NULL, |
| 257 | 257 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
| 273 | 273 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
| 274 | 274 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
| 275 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
| 276 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
| 277 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 278 | - $table_name = 'esp_log'; |
|
| 279 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 275 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
| 276 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
| 277 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 278 | + $table_name = 'esp_log'; |
|
| 279 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 280 | 280 | LOG_time datetime DEFAULT NULL, |
| 281 | 281 | OBJ_ID varchar(45) DEFAULT NULL, |
| 282 | 282 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -287,12 +287,12 @@ discard block |
||
| 287 | 287 | KEY LOG_time (LOG_time), |
| 288 | 288 | KEY OBJ (OBJ_type,OBJ_ID), |
| 289 | 289 | KEY LOG_type (LOG_type)"; |
| 290 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 291 | - $table_name = 'esp_message'; |
|
| 292 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
| 293 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
| 294 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
| 295 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 290 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 291 | + $table_name = 'esp_message'; |
|
| 292 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
| 293 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
| 294 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
| 295 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 296 | 296 | GRP_ID int(10) unsigned NULL, |
| 297 | 297 | MSG_token varchar(255) NULL, |
| 298 | 298 | TXN_ID int(10) unsigned NULL, |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | KEY STS_ID (STS_ID), |
| 325 | 325 | KEY MSG_created (MSG_created), |
| 326 | 326 | KEY MSG_modified (MSG_modified)"; |
| 327 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 328 | - $table_name = 'esp_message_template'; |
|
| 329 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 327 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 328 | + $table_name = 'esp_message_template'; |
|
| 329 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 330 | 330 | GRP_ID int(10) unsigned NOT NULL, |
| 331 | 331 | MTP_context varchar(50) NOT NULL, |
| 332 | 332 | MTP_template_field varchar(30) NOT NULL, |
| 333 | 333 | MTP_content text NOT NULL, |
| 334 | 334 | PRIMARY KEY (MTP_ID), |
| 335 | 335 | KEY GRP_ID (GRP_ID)"; |
| 336 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 337 | - $table_name = 'esp_message_template_group'; |
|
| 338 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 336 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 337 | + $table_name = 'esp_message_template_group'; |
|
| 338 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 339 | 339 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 340 | 340 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 341 | 341 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 348 | 348 | PRIMARY KEY (GRP_ID), |
| 349 | 349 | KEY MTP_user_id (MTP_user_id)"; |
| 350 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 351 | - $table_name = 'esp_payment'; |
|
| 352 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 350 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 351 | + $table_name = 'esp_payment'; |
|
| 352 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 353 | 353 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 354 | 354 | STS_ID varchar(3) DEFAULT NULL, |
| 355 | 355 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | PRIMARY KEY (PAY_ID), |
| 367 | 367 | KEY PAY_timestamp (PAY_timestamp), |
| 368 | 368 | KEY TXN_ID (TXN_ID)"; |
| 369 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 370 | - $table_name = 'esp_payment_method'; |
|
| 371 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 369 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 370 | + $table_name = 'esp_payment_method'; |
|
| 371 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 372 | 372 | PMD_type varchar(124) DEFAULT NULL, |
| 373 | 373 | PMD_name varchar(255) DEFAULT NULL, |
| 374 | 374 | PMD_desc text, |
@@ -384,24 +384,24 @@ discard block |
||
| 384 | 384 | PRIMARY KEY (PMD_ID), |
| 385 | 385 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 386 | 386 | KEY PMD_type (PMD_type)"; |
| 387 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 388 | - $table_name = "esp_ticket_price"; |
|
| 389 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 387 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 388 | + $table_name = "esp_ticket_price"; |
|
| 389 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 390 | 390 | TKT_ID int(10) unsigned NOT NULL, |
| 391 | 391 | PRC_ID int(10) unsigned NOT NULL, |
| 392 | 392 | PRIMARY KEY (TKP_ID), |
| 393 | 393 | KEY TKT_ID (TKT_ID), |
| 394 | 394 | KEY PRC_ID (PRC_ID)"; |
| 395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | - $table_name = "esp_ticket_template"; |
|
| 397 | - $sql = "TTM_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_ticket_template"; |
|
| 397 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 398 | 398 | TTM_name varchar(45) NOT NULL, |
| 399 | 399 | TTM_description text, |
| 400 | 400 | TTM_file varchar(45), |
| 401 | 401 | PRIMARY KEY (TTM_ID)"; |
| 402 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 403 | - $table_name = 'esp_question'; |
|
| 404 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 402 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 403 | + $table_name = 'esp_question'; |
|
| 404 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 405 | 405 | QST_display_text text NOT NULL, |
| 406 | 406 | QST_admin_label varchar(255) NOT NULL, |
| 407 | 407 | QST_system varchar(25) DEFAULT NULL, |
@@ -415,18 +415,18 @@ discard block |
||
| 415 | 415 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 416 | 416 | PRIMARY KEY (QST_ID), |
| 417 | 417 | KEY QST_order (QST_order)'; |
| 418 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 419 | - $table_name = 'esp_question_group_question'; |
|
| 420 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 418 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 419 | + $table_name = 'esp_question_group_question'; |
|
| 420 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 421 | 421 | QSG_ID int(10) unsigned NOT NULL, |
| 422 | 422 | QST_ID int(10) unsigned NOT NULL, |
| 423 | 423 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 424 | 424 | PRIMARY KEY (QGQ_ID), |
| 425 | 425 | KEY QST_ID (QST_ID), |
| 426 | 426 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
| 427 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 428 | - $table_name = 'esp_question_option'; |
|
| 429 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 427 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 428 | + $table_name = 'esp_question_option'; |
|
| 429 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 430 | 430 | QSO_value varchar(255) NOT NULL, |
| 431 | 431 | QSO_desc text NOT NULL, |
| 432 | 432 | QST_ID int(10) unsigned NOT NULL, |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | PRIMARY KEY (QSO_ID), |
| 437 | 437 | KEY QST_ID (QST_ID), |
| 438 | 438 | KEY QSO_order (QSO_order)"; |
| 439 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 440 | - $table_name = 'esp_registration'; |
|
| 441 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 439 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 440 | + $table_name = 'esp_registration'; |
|
| 441 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 442 | 442 | EVT_ID bigint(20) unsigned NOT NULL, |
| 443 | 443 | ATT_ID bigint(20) unsigned NOT NULL, |
| 444 | 444 | TXN_ID int(10) unsigned NOT NULL, |
@@ -462,18 +462,18 @@ discard block |
||
| 462 | 462 | KEY TKT_ID (TKT_ID), |
| 463 | 463 | KEY EVT_ID (EVT_ID), |
| 464 | 464 | KEY STS_ID (STS_ID)"; |
| 465 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 466 | - $table_name = 'esp_registration_payment'; |
|
| 467 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 465 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 466 | + $table_name = 'esp_registration_payment'; |
|
| 467 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 468 | 468 | REG_ID int(10) unsigned NOT NULL, |
| 469 | 469 | PAY_ID int(10) unsigned NULL, |
| 470 | 470 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 471 | 471 | PRIMARY KEY (RPY_ID), |
| 472 | 472 | KEY REG_ID (REG_ID), |
| 473 | 473 | KEY PAY_ID (PAY_ID)"; |
| 474 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 475 | - $table_name = 'esp_state'; |
|
| 476 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 474 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 475 | + $table_name = 'esp_state'; |
|
| 476 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 477 | 477 | CNT_ISO varchar(2) NOT NULL, |
| 478 | 478 | STA_abbrev varchar(24) NOT NULL, |
| 479 | 479 | STA_name varchar(100) NOT NULL, |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | PRIMARY KEY (STA_ID), |
| 482 | 482 | KEY STA_abbrev (STA_abbrev), |
| 483 | 483 | KEY CNT_ISO (CNT_ISO)"; |
| 484 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 485 | - $table_name = 'esp_status'; |
|
| 486 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
| 484 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 485 | + $table_name = 'esp_status'; |
|
| 486 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
| 487 | 487 | STS_code varchar(45) NOT NULL, |
| 488 | 488 | STS_type varchar(45) NOT NULL, |
| 489 | 489 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 492 | 492 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 493 | 493 | KEY STS_type (STS_type)"; |
| 494 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 495 | - $table_name = 'esp_transaction'; |
|
| 496 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 494 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 495 | + $table_name = 'esp_transaction'; |
|
| 496 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 497 | 497 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 498 | 498 | TXN_total decimal(12,3) DEFAULT '0.00', |
| 499 | 499 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -505,9 +505,9 @@ discard block |
||
| 505 | 505 | PRIMARY KEY (TXN_ID), |
| 506 | 506 | KEY TXN_timestamp (TXN_timestamp), |
| 507 | 507 | KEY STS_ID (STS_ID)"; |
| 508 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 509 | - $table_name = 'esp_venue_meta'; |
|
| 510 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 508 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 509 | + $table_name = 'esp_venue_meta'; |
|
| 510 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 511 | 511 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 512 | 512 | VNU_address varchar(255) DEFAULT NULL, |
| 513 | 513 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | KEY VNU_ID (VNU_ID), |
| 527 | 527 | KEY STA_ID (STA_ID), |
| 528 | 528 | KEY CNT_ISO (CNT_ISO)"; |
| 529 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 530 | - // modified tables |
|
| 531 | - $table_name = "esp_price"; |
|
| 532 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 529 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 530 | + // modified tables |
|
| 531 | + $table_name = "esp_price"; |
|
| 532 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 533 | 533 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 534 | 534 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 535 | 535 | PRC_name varchar(245) NOT NULL, |
@@ -542,9 +542,9 @@ discard block |
||
| 542 | 542 | PRC_parent int(10) unsigned DEFAULT 0, |
| 543 | 543 | PRIMARY KEY (PRC_ID), |
| 544 | 544 | KEY PRT_ID (PRT_ID)"; |
| 545 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 546 | - $table_name = "esp_price_type"; |
|
| 547 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 545 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 546 | + $table_name = "esp_price_type"; |
|
| 547 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 548 | 548 | PRT_name varchar(45) NOT NULL, |
| 549 | 549 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 550 | 550 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 554 | 554 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 555 | 555 | PRIMARY KEY (PRT_ID)"; |
| 556 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 557 | - $table_name = "esp_ticket"; |
|
| 558 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 556 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 557 | + $table_name = "esp_ticket"; |
|
| 558 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 559 | 559 | TTM_ID int(10) unsigned NOT NULL, |
| 560 | 560 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 561 | 561 | TKT_description text NOT NULL, |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 579 | 579 | PRIMARY KEY (TKT_ID), |
| 580 | 580 | KEY TKT_start_date (TKT_start_date)"; |
| 581 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 582 | - $table_name = 'esp_question_group'; |
|
| 583 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 581 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 582 | + $table_name = 'esp_question_group'; |
|
| 583 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 584 | 584 | QSG_name varchar(255) NOT NULL, |
| 585 | 585 | QSG_identifier varchar(100) NOT NULL, |
| 586 | 586 | QSG_desc text NULL, |
@@ -593,159 +593,159 @@ discard block |
||
| 593 | 593 | PRIMARY KEY (QSG_ID), |
| 594 | 594 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 595 | 595 | KEY QSG_order (QSG_order)'; |
| 596 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 597 | - $this->insert_default_data(); |
|
| 598 | - return true; |
|
| 599 | - } |
|
| 596 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 597 | + $this->insert_default_data(); |
|
| 598 | + return true; |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | - /** |
|
| 602 | - * Inserts default data after parent was called. |
|
| 603 | - * @since 4.10.0.p |
|
| 604 | - * @throws EE_Error |
|
| 605 | - * @throws InvalidArgumentException |
|
| 606 | - * @throws ReflectionException |
|
| 607 | - * @throws InvalidDataTypeException |
|
| 608 | - * @throws InvalidInterfaceException |
|
| 609 | - */ |
|
| 610 | - public function insert_default_data() |
|
| 611 | - { |
|
| 612 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 613 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 614 | - // (because many need to convert old string states to foreign keys into the states table) |
|
| 615 | - $script_4_1_defaults->insert_default_states(); |
|
| 616 | - $script_4_1_defaults->insert_default_countries(); |
|
| 617 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 618 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 619 | - $script_4_5_defaults->insert_default_price_types(); |
|
| 620 | - $script_4_5_defaults->insert_default_prices(); |
|
| 621 | - $script_4_5_defaults->insert_default_tickets(); |
|
| 622 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
| 623 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
| 624 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
| 625 | - $script_4_6_defaults->insert_default_currencies(); |
|
| 626 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
| 627 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
| 628 | - $script_4_8_defaults->verify_new_countries(); |
|
| 629 | - $script_4_8_defaults->verify_new_currencies(); |
|
| 630 | - $this->verify_db_collations(); |
|
| 631 | - $this->verify_db_collations_again(); |
|
| 632 | - } |
|
| 601 | + /** |
|
| 602 | + * Inserts default data after parent was called. |
|
| 603 | + * @since 4.10.0.p |
|
| 604 | + * @throws EE_Error |
|
| 605 | + * @throws InvalidArgumentException |
|
| 606 | + * @throws ReflectionException |
|
| 607 | + * @throws InvalidDataTypeException |
|
| 608 | + * @throws InvalidInterfaceException |
|
| 609 | + */ |
|
| 610 | + public function insert_default_data() |
|
| 611 | + { |
|
| 612 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 613 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 614 | + // (because many need to convert old string states to foreign keys into the states table) |
|
| 615 | + $script_4_1_defaults->insert_default_states(); |
|
| 616 | + $script_4_1_defaults->insert_default_countries(); |
|
| 617 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 618 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 619 | + $script_4_5_defaults->insert_default_price_types(); |
|
| 620 | + $script_4_5_defaults->insert_default_prices(); |
|
| 621 | + $script_4_5_defaults->insert_default_tickets(); |
|
| 622 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
| 623 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
| 624 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
| 625 | + $script_4_6_defaults->insert_default_currencies(); |
|
| 626 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
| 627 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
| 628 | + $script_4_8_defaults->verify_new_countries(); |
|
| 629 | + $script_4_8_defaults->verify_new_currencies(); |
|
| 630 | + $this->verify_db_collations(); |
|
| 631 | + $this->verify_db_collations_again(); |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | 634 | |
| 635 | 635 | |
| 636 | - /** |
|
| 637 | - * @return boolean |
|
| 638 | - */ |
|
| 639 | - public function schema_changes_after_migration() |
|
| 640 | - { |
|
| 641 | - return true; |
|
| 642 | - } |
|
| 636 | + /** |
|
| 637 | + * @return boolean |
|
| 638 | + */ |
|
| 639 | + public function schema_changes_after_migration() |
|
| 640 | + { |
|
| 641 | + return true; |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | 644 | |
| 645 | 645 | |
| 646 | - public function migration_page_hooks() |
|
| 647 | - { |
|
| 648 | - } |
|
| 646 | + public function migration_page_hooks() |
|
| 647 | + { |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | |
| 651 | 651 | |
| 652 | - /** |
|
| 653 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
| 654 | - * |
|
| 655 | - * @return void |
|
| 656 | - */ |
|
| 657 | - public function verify_db_collations() |
|
| 658 | - { |
|
| 659 | - global $wpdb; |
|
| 660 | - // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
| 661 | - if ('utf8mb4' !== $wpdb->charset |
|
| 662 | - || get_option('ee_verified_db_collations', false)) { |
|
| 663 | - return; |
|
| 664 | - } |
|
| 665 | - // grab tables from each model |
|
| 666 | - $tables_to_check = array(); |
|
| 667 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
| 668 | - if (method_exists($model_name, 'instance')) { |
|
| 669 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
| 670 | - if ($model_obj instanceof EEM_Base) { |
|
| 671 | - foreach ($model_obj->get_tables() as $table) { |
|
| 672 | - if (strpos($table->get_table_name(), 'esp_') |
|
| 673 | - && (is_main_site()// for main tables, verify global tables |
|
| 674 | - || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
| 675 | - ) |
|
| 676 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
| 677 | - ) { |
|
| 678 | - $tables_to_check[] = $table->get_table_name(); |
|
| 679 | - } |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
| 685 | - // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
| 686 | - // of hard-coding this |
|
| 687 | - $addon_tables = array( |
|
| 688 | - // mailchimp |
|
| 689 | - 'esp_event_mailchimp_list_group', |
|
| 690 | - 'esp_event_question_mailchimp_field', |
|
| 691 | - // multisite |
|
| 692 | - 'esp_blog_meta', |
|
| 693 | - // people |
|
| 694 | - 'esp_people_to_post', |
|
| 695 | - // promotions |
|
| 696 | - 'esp_promotion', |
|
| 697 | - 'esp_promotion_object', |
|
| 698 | - ); |
|
| 699 | - foreach ($addon_tables as $table_name) { |
|
| 700 | - $tables_to_check[] = $table_name; |
|
| 701 | - } |
|
| 702 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 703 | - // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
| 704 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
| 705 | - // seeing how this ran with the fix from 10435, no need to check again |
|
| 706 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 707 | - } |
|
| 652 | + /** |
|
| 653 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
| 654 | + * |
|
| 655 | + * @return void |
|
| 656 | + */ |
|
| 657 | + public function verify_db_collations() |
|
| 658 | + { |
|
| 659 | + global $wpdb; |
|
| 660 | + // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
| 661 | + if ('utf8mb4' !== $wpdb->charset |
|
| 662 | + || get_option('ee_verified_db_collations', false)) { |
|
| 663 | + return; |
|
| 664 | + } |
|
| 665 | + // grab tables from each model |
|
| 666 | + $tables_to_check = array(); |
|
| 667 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
| 668 | + if (method_exists($model_name, 'instance')) { |
|
| 669 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
| 670 | + if ($model_obj instanceof EEM_Base) { |
|
| 671 | + foreach ($model_obj->get_tables() as $table) { |
|
| 672 | + if (strpos($table->get_table_name(), 'esp_') |
|
| 673 | + && (is_main_site()// for main tables, verify global tables |
|
| 674 | + || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
| 675 | + ) |
|
| 676 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
| 677 | + ) { |
|
| 678 | + $tables_to_check[] = $table->get_table_name(); |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
| 685 | + // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
| 686 | + // of hard-coding this |
|
| 687 | + $addon_tables = array( |
|
| 688 | + // mailchimp |
|
| 689 | + 'esp_event_mailchimp_list_group', |
|
| 690 | + 'esp_event_question_mailchimp_field', |
|
| 691 | + // multisite |
|
| 692 | + 'esp_blog_meta', |
|
| 693 | + // people |
|
| 694 | + 'esp_people_to_post', |
|
| 695 | + // promotions |
|
| 696 | + 'esp_promotion', |
|
| 697 | + 'esp_promotion_object', |
|
| 698 | + ); |
|
| 699 | + foreach ($addon_tables as $table_name) { |
|
| 700 | + $tables_to_check[] = $table_name; |
|
| 701 | + } |
|
| 702 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 703 | + // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
| 704 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
| 705 | + // seeing how this ran with the fix from 10435, no need to check again |
|
| 706 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | 709 | |
| 710 | 710 | |
| 711 | - /** |
|
| 712 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
| 713 | - * which meant some DB collations might not have been updated |
|
| 714 | - * @return void |
|
| 715 | - */ |
|
| 716 | - public function verify_db_collations_again() |
|
| 717 | - { |
|
| 718 | - global $wpdb; |
|
| 719 | - // double-check we haven't already done this or that the DB doesn't support it |
|
| 720 | - // compare to how WordPress' upgrade_430() function does this check |
|
| 721 | - if ('utf8mb4' !== $wpdb->charset |
|
| 722 | - || get_option('ee_verified_db_collations_again', false)) { |
|
| 723 | - return; |
|
| 724 | - } |
|
| 725 | - $tables_to_check = array( |
|
| 726 | - 'esp_attendee_meta', |
|
| 727 | - 'esp_message' |
|
| 728 | - ); |
|
| 729 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 730 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 731 | - } |
|
| 711 | + /** |
|
| 712 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
| 713 | + * which meant some DB collations might not have been updated |
|
| 714 | + * @return void |
|
| 715 | + */ |
|
| 716 | + public function verify_db_collations_again() |
|
| 717 | + { |
|
| 718 | + global $wpdb; |
|
| 719 | + // double-check we haven't already done this or that the DB doesn't support it |
|
| 720 | + // compare to how WordPress' upgrade_430() function does this check |
|
| 721 | + if ('utf8mb4' !== $wpdb->charset |
|
| 722 | + || get_option('ee_verified_db_collations_again', false)) { |
|
| 723 | + return; |
|
| 724 | + } |
|
| 725 | + $tables_to_check = array( |
|
| 726 | + 'esp_attendee_meta', |
|
| 727 | + 'esp_message' |
|
| 728 | + ); |
|
| 729 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 730 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | 733 | |
| 734 | 734 | |
| 735 | - /** |
|
| 736 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
| 737 | - * @param $tables_to_check |
|
| 738 | - * @return boolean true if logic ran, false if it didn't |
|
| 739 | - */ |
|
| 740 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
| 741 | - { |
|
| 742 | - foreach ($tables_to_check as $table_name) { |
|
| 743 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
| 744 | - if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
| 745 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
| 746 | - ) { |
|
| 747 | - maybe_convert_table_to_utf8mb4($table_name); |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - } |
|
| 735 | + /** |
|
| 736 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
| 737 | + * @param $tables_to_check |
|
| 738 | + * @return boolean true if logic ran, false if it didn't |
|
| 739 | + */ |
|
| 740 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
| 741 | + { |
|
| 742 | + foreach ($tables_to_check as $table_name) { |
|
| 743 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
| 744 | + if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
| 745 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
| 746 | + ) { |
|
| 747 | + maybe_convert_table_to_utf8mb4($table_name); |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + } |
|
| 751 | 751 | } |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
| 16 | 16 | $class_to_filepath = []; |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | - $matches = []; |
|
| 19 | - preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 18 | + $matches = []; |
|
| 19 | + preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -35,67 +35,67 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * |
|
| 40 | - * @param TableManager $table_manager |
|
| 41 | - * @param TableAnalysis $table_analysis |
|
| 42 | - */ |
|
| 43 | - public function __construct( |
|
| 44 | - TableManager $table_manager = null, |
|
| 45 | - TableAnalysis $table_analysis = null, |
|
| 46 | - EE_DMS_Core_4_9_0 $dms_4_9 |
|
| 47 | - ) { |
|
| 48 | - $this->previous_dms = $dms_4_9; |
|
| 49 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
| 50 | - $this->_priority = 10; |
|
| 51 | - $this->_migration_stages = array( |
|
| 52 | - new EE_DMS_4_10_0_Event_Question_Group(), |
|
| 53 | - ); |
|
| 54 | - parent::__construct($table_manager, $table_analysis); |
|
| 55 | - } |
|
| 38 | + /** |
|
| 39 | + * |
|
| 40 | + * @param TableManager $table_manager |
|
| 41 | + * @param TableAnalysis $table_analysis |
|
| 42 | + */ |
|
| 43 | + public function __construct( |
|
| 44 | + TableManager $table_manager = null, |
|
| 45 | + TableAnalysis $table_analysis = null, |
|
| 46 | + EE_DMS_Core_4_9_0 $dms_4_9 |
|
| 47 | + ) { |
|
| 48 | + $this->previous_dms = $dms_4_9; |
|
| 49 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
| 50 | + $this->_priority = 10; |
|
| 51 | + $this->_migration_stages = array( |
|
| 52 | + new EE_DMS_4_10_0_Event_Question_Group(), |
|
| 53 | + ); |
|
| 54 | + parent::__construct($table_manager, $table_analysis); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Whether to migrate or not. |
|
| 61 | - * |
|
| 62 | - * @param array $version_array |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function can_migrate_from_version($version_array) |
|
| 66 | - { |
|
| 67 | - $version_string = $version_array['Core']; |
|
| 68 | - if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) { |
|
| 69 | - // echo "$version_string can be migrated from"; |
|
| 70 | - return true; |
|
| 71 | - } elseif (! $version_string) { |
|
| 72 | - // echo "no version string provided: $version_string"; |
|
| 73 | - // no version string provided... this must be pre 4.3 |
|
| 74 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 75 | - } |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 59 | + /** |
|
| 60 | + * Whether to migrate or not. |
|
| 61 | + * |
|
| 62 | + * @param array $version_array |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + public function can_migrate_from_version($version_array) |
|
| 66 | + { |
|
| 67 | + $version_string = $version_array['Core']; |
|
| 68 | + if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) { |
|
| 69 | + // echo "$version_string can be migrated from"; |
|
| 70 | + return true; |
|
| 71 | + } elseif (! $version_string) { |
|
| 72 | + // echo "no version string provided: $version_string"; |
|
| 73 | + // no version string provided... this must be pre 4.3 |
|
| 74 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 75 | + } |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return bool |
|
| 83 | - */ |
|
| 84 | - public function schema_changes_before_migration() |
|
| 85 | - { |
|
| 86 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 87 | - $now_in_mysql = current_time('mysql', true); |
|
| 88 | - $table_name = 'esp_answer'; |
|
| 89 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 81 | + /** |
|
| 82 | + * @return bool |
|
| 83 | + */ |
|
| 84 | + public function schema_changes_before_migration() |
|
| 85 | + { |
|
| 86 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 87 | + $now_in_mysql = current_time('mysql', true); |
|
| 88 | + $table_name = 'esp_answer'; |
|
| 89 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 90 | 90 | REG_ID int(10) unsigned NOT NULL, |
| 91 | 91 | QST_ID int(10) unsigned NOT NULL, |
| 92 | 92 | ANS_value text NOT NULL, |
| 93 | 93 | PRIMARY KEY (ANS_ID), |
| 94 | 94 | KEY REG_ID (REG_ID), |
| 95 | 95 | KEY QST_ID (QST_ID)"; |
| 96 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 97 | - $table_name = 'esp_attendee_meta'; |
|
| 98 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 96 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 97 | + $table_name = 'esp_attendee_meta'; |
|
| 98 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 99 | 99 | ATT_ID bigint(20) unsigned NOT NULL, |
| 100 | 100 | ATT_fname varchar(45) NOT NULL, |
| 101 | 101 | ATT_lname varchar(45) NOT NULL, |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | KEY ATT_email (ATT_email(191)), |
| 113 | 113 | KEY ATT_lname (ATT_lname), |
| 114 | 114 | KEY ATT_fname (ATT_fname)"; |
| 115 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 116 | - $table_name = 'esp_checkin'; |
|
| 117 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 115 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 116 | + $table_name = 'esp_checkin'; |
|
| 117 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 118 | 118 | REG_ID int(10) unsigned NOT NULL, |
| 119 | 119 | DTT_ID int(10) unsigned NOT NULL, |
| 120 | 120 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | PRIMARY KEY (CHK_ID), |
| 123 | 123 | KEY REG_ID (REG_ID), |
| 124 | 124 | KEY DTT_ID (DTT_ID)"; |
| 125 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 126 | - $table_name = 'esp_country'; |
|
| 127 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 125 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 126 | + $table_name = 'esp_country'; |
|
| 127 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 128 | 128 | CNT_ISO3 varchar(3) NOT NULL, |
| 129 | 129 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 130 | 130 | CNT_name varchar(45) NOT NULL, |
@@ -140,29 +140,29 @@ discard block |
||
| 140 | 140 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 141 | 141 | CNT_active tinyint(1) DEFAULT '0', |
| 142 | 142 | PRIMARY KEY (CNT_ISO)"; |
| 143 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 144 | - $table_name = 'esp_currency'; |
|
| 145 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
| 143 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 144 | + $table_name = 'esp_currency'; |
|
| 145 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
| 146 | 146 | CUR_single varchar(45) DEFAULT 'dollar', |
| 147 | 147 | CUR_plural varchar(45) DEFAULT 'dollars', |
| 148 | 148 | CUR_sign varchar(45) DEFAULT '$', |
| 149 | 149 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
| 150 | 150 | CUR_active tinyint(1) DEFAULT '0', |
| 151 | 151 | PRIMARY KEY (CUR_code)"; |
| 152 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 153 | - // note: although this table is no longer in use, |
|
| 154 | - // it hasn't been removed because then queries to the model will have errors. |
|
| 155 | - // but you should expect this table and its corresponding model to be removed in |
|
| 156 | - // the next few months |
|
| 157 | - $table_name = 'esp_currency_payment_method'; |
|
| 158 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 152 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 153 | + // note: although this table is no longer in use, |
|
| 154 | + // it hasn't been removed because then queries to the model will have errors. |
|
| 155 | + // but you should expect this table and its corresponding model to be removed in |
|
| 156 | + // the next few months |
|
| 157 | + $table_name = 'esp_currency_payment_method'; |
|
| 158 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 159 | 159 | CUR_code varchar(6) NOT NULL, |
| 160 | 160 | PMD_ID int(11) NOT NULL, |
| 161 | 161 | PRIMARY KEY (CPM_ID), |
| 162 | 162 | KEY PMD_ID (PMD_ID)"; |
| 163 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 164 | - $table_name = 'esp_datetime'; |
|
| 165 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 163 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 164 | + $table_name = 'esp_datetime'; |
|
| 165 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 166 | 166 | EVT_ID bigint(20) unsigned NOT NULL, |
| 167 | 167 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 168 | 168 | DTT_description text NOT NULL, |
@@ -179,25 +179,25 @@ discard block |
||
| 179 | 179 | KEY DTT_EVT_start (DTT_EVT_start), |
| 180 | 180 | KEY EVT_ID (EVT_ID), |
| 181 | 181 | KEY DTT_is_primary (DTT_is_primary)"; |
| 182 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 183 | - $table_name = "esp_datetime_ticket"; |
|
| 184 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 182 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 183 | + $table_name = "esp_datetime_ticket"; |
|
| 184 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 185 | 185 | DTT_ID int(10) unsigned NOT NULL, |
| 186 | 186 | TKT_ID int(10) unsigned NOT NULL, |
| 187 | 187 | PRIMARY KEY (DTK_ID), |
| 188 | 188 | KEY DTT_ID (DTT_ID), |
| 189 | 189 | KEY TKT_ID (TKT_ID)"; |
| 190 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 191 | - $table_name = 'esp_event_message_template'; |
|
| 192 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 190 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 191 | + $table_name = 'esp_event_message_template'; |
|
| 192 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 193 | 193 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 194 | 194 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 195 | 195 | PRIMARY KEY (EMT_ID), |
| 196 | 196 | KEY EVT_ID (EVT_ID), |
| 197 | 197 | KEY GRP_ID (GRP_ID)"; |
| 198 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 199 | - $table_name = 'esp_event_meta'; |
|
| 200 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 198 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 199 | + $table_name = 'esp_event_meta'; |
|
| 200 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 201 | 201 | EVT_ID bigint(20) unsigned NOT NULL, |
| 202 | 202 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 203 | 203 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | EVT_donations tinyint(1) NULL, |
| 213 | 213 | PRIMARY KEY (EVTM_ID), |
| 214 | 214 | KEY EVT_ID (EVT_ID)"; |
| 215 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 216 | - $table_name = 'esp_event_question_group'; |
|
| 217 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 215 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 216 | + $table_name = 'esp_event_question_group'; |
|
| 217 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 218 | 218 | EVT_ID bigint(20) unsigned NOT NULL, |
| 219 | 219 | QSG_ID int(10) unsigned NOT NULL, |
| 220 | 220 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -222,25 +222,25 @@ discard block |
||
| 222 | 222 | PRIMARY KEY (EQG_ID), |
| 223 | 223 | KEY EVT_ID (EVT_ID), |
| 224 | 224 | KEY QSG_ID (QSG_ID)"; |
| 225 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 226 | - $table_name = 'esp_event_venue'; |
|
| 227 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 225 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 226 | + $table_name = 'esp_event_venue'; |
|
| 227 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 228 | 228 | EVT_ID bigint(20) unsigned NOT NULL, |
| 229 | 229 | VNU_ID bigint(20) unsigned NOT NULL, |
| 230 | 230 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 231 | 231 | PRIMARY KEY (EVV_ID)"; |
| 232 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 233 | - $table_name = 'esp_extra_meta'; |
|
| 234 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 232 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 233 | + $table_name = 'esp_extra_meta'; |
|
| 234 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 235 | 235 | OBJ_ID int(11) DEFAULT NULL, |
| 236 | 236 | EXM_type varchar(45) DEFAULT NULL, |
| 237 | 237 | EXM_key varchar(45) DEFAULT NULL, |
| 238 | 238 | EXM_value text, |
| 239 | 239 | PRIMARY KEY (EXM_ID), |
| 240 | 240 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
| 241 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 242 | - $table_name = 'esp_extra_join'; |
|
| 243 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 241 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 242 | + $table_name = 'esp_extra_join'; |
|
| 243 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 244 | 244 | EXJ_first_model_id varchar(6) NOT NULL, |
| 245 | 245 | EXJ_first_model_name varchar(20) NOT NULL, |
| 246 | 246 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | PRIMARY KEY (EXJ_ID), |
| 249 | 249 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
| 250 | 250 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
| 251 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 252 | - $table_name = 'esp_line_item'; |
|
| 253 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 251 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 252 | + $table_name = 'esp_line_item'; |
|
| 253 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 254 | 254 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 255 | 255 | TXN_ID int(11) DEFAULT NULL, |
| 256 | 256 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
| 272 | 272 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
| 273 | 273 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
| 274 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | - $table_name = 'esp_log'; |
|
| 276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 274 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | + $table_name = 'esp_log'; |
|
| 276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 277 | 277 | LOG_time datetime DEFAULT NULL, |
| 278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
| 279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | KEY LOG_time (LOG_time), |
| 285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
| 286 | 286 | KEY LOG_type (LOG_type)"; |
| 287 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 288 | - $table_name = 'esp_message'; |
|
| 289 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 288 | + $table_name = 'esp_message'; |
|
| 289 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 290 | 290 | GRP_ID int(10) unsigned NULL, |
| 291 | 291 | MSG_token varchar(255) NULL, |
| 292 | 292 | TXN_ID int(10) unsigned NULL, |
@@ -318,18 +318,18 @@ discard block |
||
| 318 | 318 | KEY STS_ID (STS_ID), |
| 319 | 319 | KEY MSG_created (MSG_created), |
| 320 | 320 | KEY MSG_modified (MSG_modified)"; |
| 321 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 322 | - $table_name = 'esp_message_template'; |
|
| 323 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 321 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 322 | + $table_name = 'esp_message_template'; |
|
| 323 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 324 | 324 | GRP_ID int(10) unsigned NOT NULL, |
| 325 | 325 | MTP_context varchar(50) NOT NULL, |
| 326 | 326 | MTP_template_field varchar(30) NOT NULL, |
| 327 | 327 | MTP_content text NOT NULL, |
| 328 | 328 | PRIMARY KEY (MTP_ID), |
| 329 | 329 | KEY GRP_ID (GRP_ID)"; |
| 330 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 331 | - $table_name = 'esp_message_template_group'; |
|
| 332 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 330 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 331 | + $table_name = 'esp_message_template_group'; |
|
| 332 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 333 | 333 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 334 | 334 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 335 | 335 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 342 | 342 | PRIMARY KEY (GRP_ID), |
| 343 | 343 | KEY MTP_user_id (MTP_user_id)"; |
| 344 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 345 | - $table_name = 'esp_payment'; |
|
| 346 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 344 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 345 | + $table_name = 'esp_payment'; |
|
| 346 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 347 | 347 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 348 | 348 | STS_ID varchar(3) DEFAULT NULL, |
| 349 | 349 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | PRIMARY KEY (PAY_ID), |
| 361 | 361 | KEY PAY_timestamp (PAY_timestamp), |
| 362 | 362 | KEY TXN_ID (TXN_ID)"; |
| 363 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 364 | - $table_name = 'esp_payment_method'; |
|
| 365 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 363 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 364 | + $table_name = 'esp_payment_method'; |
|
| 365 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 366 | 366 | PMD_type varchar(124) DEFAULT NULL, |
| 367 | 367 | PMD_name varchar(255) DEFAULT NULL, |
| 368 | 368 | PMD_desc text, |
@@ -378,24 +378,24 @@ discard block |
||
| 378 | 378 | PRIMARY KEY (PMD_ID), |
| 379 | 379 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 380 | 380 | KEY PMD_type (PMD_type)"; |
| 381 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 382 | - $table_name = "esp_ticket_price"; |
|
| 383 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 381 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 382 | + $table_name = "esp_ticket_price"; |
|
| 383 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 384 | 384 | TKT_ID int(10) unsigned NOT NULL, |
| 385 | 385 | PRC_ID int(10) unsigned NOT NULL, |
| 386 | 386 | PRIMARY KEY (TKP_ID), |
| 387 | 387 | KEY TKT_ID (TKT_ID), |
| 388 | 388 | KEY PRC_ID (PRC_ID)"; |
| 389 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 390 | - $table_name = "esp_ticket_template"; |
|
| 391 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 389 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 390 | + $table_name = "esp_ticket_template"; |
|
| 391 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 392 | 392 | TTM_name varchar(45) NOT NULL, |
| 393 | 393 | TTM_description text, |
| 394 | 394 | TTM_file varchar(45), |
| 395 | 395 | PRIMARY KEY (TTM_ID)"; |
| 396 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 397 | - $table_name = 'esp_question'; |
|
| 398 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 396 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 397 | + $table_name = 'esp_question'; |
|
| 398 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 399 | 399 | QST_display_text text NOT NULL, |
| 400 | 400 | QST_admin_label varchar(255) NOT NULL, |
| 401 | 401 | QST_system varchar(25) DEFAULT NULL, |
@@ -409,18 +409,18 @@ discard block |
||
| 409 | 409 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 410 | 410 | PRIMARY KEY (QST_ID), |
| 411 | 411 | KEY QST_order (QST_order)'; |
| 412 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 413 | - $table_name = 'esp_question_group_question'; |
|
| 414 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 412 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 413 | + $table_name = 'esp_question_group_question'; |
|
| 414 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 415 | 415 | QSG_ID int(10) unsigned NOT NULL, |
| 416 | 416 | QST_ID int(10) unsigned NOT NULL, |
| 417 | 417 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 418 | 418 | PRIMARY KEY (QGQ_ID), |
| 419 | 419 | KEY QST_ID (QST_ID), |
| 420 | 420 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
| 421 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 422 | - $table_name = 'esp_question_option'; |
|
| 423 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 421 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 422 | + $table_name = 'esp_question_option'; |
|
| 423 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 424 | 424 | QSO_value varchar(255) NOT NULL, |
| 425 | 425 | QSO_desc text NOT NULL, |
| 426 | 426 | QST_ID int(10) unsigned NOT NULL, |
@@ -430,9 +430,9 @@ discard block |
||
| 430 | 430 | PRIMARY KEY (QSO_ID), |
| 431 | 431 | KEY QST_ID (QST_ID), |
| 432 | 432 | KEY QSO_order (QSO_order)"; |
| 433 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 434 | - $table_name = 'esp_registration'; |
|
| 435 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 433 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 434 | + $table_name = 'esp_registration'; |
|
| 435 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 436 | 436 | EVT_ID bigint(20) unsigned NOT NULL, |
| 437 | 437 | ATT_ID bigint(20) unsigned NOT NULL, |
| 438 | 438 | TXN_ID int(10) unsigned NOT NULL, |
@@ -456,18 +456,18 @@ discard block |
||
| 456 | 456 | KEY TKT_ID (TKT_ID), |
| 457 | 457 | KEY EVT_ID (EVT_ID), |
| 458 | 458 | KEY STS_ID (STS_ID)"; |
| 459 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 460 | - $table_name = 'esp_registration_payment'; |
|
| 461 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 459 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 460 | + $table_name = 'esp_registration_payment'; |
|
| 461 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 462 | 462 | REG_ID int(10) unsigned NOT NULL, |
| 463 | 463 | PAY_ID int(10) unsigned NULL, |
| 464 | 464 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 465 | 465 | PRIMARY KEY (RPY_ID), |
| 466 | 466 | KEY REG_ID (REG_ID), |
| 467 | 467 | KEY PAY_ID (PAY_ID)"; |
| 468 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 469 | - $table_name = 'esp_state'; |
|
| 470 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 468 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 469 | + $table_name = 'esp_state'; |
|
| 470 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 471 | 471 | CNT_ISO varchar(2) NOT NULL, |
| 472 | 472 | STA_abbrev varchar(24) NOT NULL, |
| 473 | 473 | STA_name varchar(100) NOT NULL, |
@@ -475,9 +475,9 @@ discard block |
||
| 475 | 475 | PRIMARY KEY (STA_ID), |
| 476 | 476 | KEY STA_abbrev (STA_abbrev), |
| 477 | 477 | KEY CNT_ISO (CNT_ISO)"; |
| 478 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 479 | - $table_name = 'esp_status'; |
|
| 480 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
| 478 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 479 | + $table_name = 'esp_status'; |
|
| 480 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
| 481 | 481 | STS_code varchar(45) NOT NULL, |
| 482 | 482 | STS_type varchar(45) NOT NULL, |
| 483 | 483 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -485,9 +485,9 @@ discard block |
||
| 485 | 485 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 486 | 486 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 487 | 487 | KEY STS_type (STS_type)"; |
| 488 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 489 | - $table_name = 'esp_transaction'; |
|
| 490 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 488 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 489 | + $table_name = 'esp_transaction'; |
|
| 490 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 491 | 491 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 492 | 492 | TXN_total decimal(12,3) DEFAULT '0.00', |
| 493 | 493 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -499,9 +499,9 @@ discard block |
||
| 499 | 499 | PRIMARY KEY (TXN_ID), |
| 500 | 500 | KEY TXN_timestamp (TXN_timestamp), |
| 501 | 501 | KEY STS_ID (STS_ID)"; |
| 502 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 503 | - $table_name = 'esp_venue_meta'; |
|
| 504 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 502 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 503 | + $table_name = 'esp_venue_meta'; |
|
| 504 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 505 | 505 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 506 | 506 | VNU_address varchar(255) DEFAULT NULL, |
| 507 | 507 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -520,10 +520,10 @@ discard block |
||
| 520 | 520 | KEY VNU_ID (VNU_ID), |
| 521 | 521 | KEY STA_ID (STA_ID), |
| 522 | 522 | KEY CNT_ISO (CNT_ISO)"; |
| 523 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 524 | - // modified tables |
|
| 525 | - $table_name = "esp_price"; |
|
| 526 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 523 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 524 | + // modified tables |
|
| 525 | + $table_name = "esp_price"; |
|
| 526 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 527 | 527 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 528 | 528 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 529 | 529 | PRC_name varchar(245) NOT NULL, |
@@ -536,9 +536,9 @@ discard block |
||
| 536 | 536 | PRC_parent int(10) unsigned DEFAULT 0, |
| 537 | 537 | PRIMARY KEY (PRC_ID), |
| 538 | 538 | KEY PRT_ID (PRT_ID)"; |
| 539 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 540 | - $table_name = "esp_price_type"; |
|
| 541 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 539 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 540 | + $table_name = "esp_price_type"; |
|
| 541 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 542 | 542 | PRT_name varchar(45) NOT NULL, |
| 543 | 543 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 544 | 544 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 548 | 548 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 549 | 549 | PRIMARY KEY (PRT_ID)"; |
| 550 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 551 | - $table_name = "esp_ticket"; |
|
| 552 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 550 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 551 | + $table_name = "esp_ticket"; |
|
| 552 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 553 | 553 | TTM_ID int(10) unsigned NOT NULL, |
| 554 | 554 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 555 | 555 | TKT_description text NOT NULL, |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 573 | 573 | PRIMARY KEY (TKT_ID), |
| 574 | 574 | KEY TKT_start_date (TKT_start_date)"; |
| 575 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 576 | - $table_name = 'esp_question_group'; |
|
| 577 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 575 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 576 | + $table_name = 'esp_question_group'; |
|
| 577 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 578 | 578 | QSG_name varchar(255) NOT NULL, |
| 579 | 579 | QSG_identifier varchar(100) NOT NULL, |
| 580 | 580 | QSG_desc text NULL, |
@@ -587,38 +587,38 @@ discard block |
||
| 587 | 587 | PRIMARY KEY (QSG_ID), |
| 588 | 588 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 589 | 589 | KEY QSG_order (QSG_order)'; |
| 590 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 591 | - $this->insert_default_data(); |
|
| 592 | - return true; |
|
| 593 | - } |
|
| 590 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 591 | + $this->insert_default_data(); |
|
| 592 | + return true; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - /** |
|
| 596 | - * Inserts default data on new installs |
|
| 597 | - * @since 4.10.0.p |
|
| 598 | - * @throws EE_Error |
|
| 599 | - * @throws InvalidArgumentException |
|
| 600 | - * @throws ReflectionException |
|
| 601 | - * @throws InvalidDataTypeException |
|
| 602 | - * @throws InvalidInterfaceException |
|
| 603 | - */ |
|
| 604 | - public function insert_default_data() |
|
| 605 | - { |
|
| 606 | - $this->previous_dms->insert_default_data(); |
|
| 607 | - } |
|
| 595 | + /** |
|
| 596 | + * Inserts default data on new installs |
|
| 597 | + * @since 4.10.0.p |
|
| 598 | + * @throws EE_Error |
|
| 599 | + * @throws InvalidArgumentException |
|
| 600 | + * @throws ReflectionException |
|
| 601 | + * @throws InvalidDataTypeException |
|
| 602 | + * @throws InvalidInterfaceException |
|
| 603 | + */ |
|
| 604 | + public function insert_default_data() |
|
| 605 | + { |
|
| 606 | + $this->previous_dms->insert_default_data(); |
|
| 607 | + } |
|
| 608 | 608 | |
| 609 | 609 | |
| 610 | 610 | |
| 611 | - /** |
|
| 612 | - * @return boolean |
|
| 613 | - */ |
|
| 614 | - public function schema_changes_after_migration() |
|
| 615 | - { |
|
| 616 | - return true; |
|
| 617 | - } |
|
| 611 | + /** |
|
| 612 | + * @return boolean |
|
| 613 | + */ |
|
| 614 | + public function schema_changes_after_migration() |
|
| 615 | + { |
|
| 616 | + return true; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | |
| 620 | 620 | |
| 621 | - public function migration_page_hooks() |
|
| 622 | - { |
|
| 623 | - } |
|
| 621 | + public function migration_page_hooks() |
|
| 622 | + { |
|
| 623 | + } |
|
| 624 | 624 | } |
@@ -18,184 +18,184 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * |
|
| 23 | - * @var EE_Registration |
|
| 24 | - */ |
|
| 25 | - protected $_registration = null; |
|
| 21 | + /** |
|
| 22 | + * |
|
| 23 | + * @var EE_Registration |
|
| 24 | + */ |
|
| 25 | + protected $_registration = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * |
|
| 29 | - * @param EE_Registration $reg |
|
| 30 | - * @param array $options |
|
| 31 | - */ |
|
| 32 | - public function __construct(EE_Registration $reg, $options = array()) |
|
| 33 | - { |
|
| 34 | - $this->_registration = $reg; |
|
| 35 | - if (! isset($options['layout_strategy'])) { |
|
| 36 | - $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
| 37 | - } |
|
| 38 | - if (! isset($options['html_id'])) { |
|
| 39 | - $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
| 40 | - } |
|
| 41 | - $this->build_form_from_registration(); |
|
| 42 | - parent::__construct($options); |
|
| 43 | - } |
|
| 27 | + /** |
|
| 28 | + * |
|
| 29 | + * @param EE_Registration $reg |
|
| 30 | + * @param array $options |
|
| 31 | + */ |
|
| 32 | + public function __construct(EE_Registration $reg, $options = array()) |
|
| 33 | + { |
|
| 34 | + $this->_registration = $reg; |
|
| 35 | + if (! isset($options['layout_strategy'])) { |
|
| 36 | + $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
| 37 | + } |
|
| 38 | + if (! isset($options['html_id'])) { |
|
| 39 | + $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
| 40 | + } |
|
| 41 | + $this->build_form_from_registration(); |
|
| 42 | + parent::__construct($options); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Gets the registration object this form is about |
|
| 48 | - * @return EE_Registration |
|
| 49 | - */ |
|
| 50 | - public function get_registration() |
|
| 51 | - { |
|
| 52 | - return $this->_registration; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * Gets the registration object this form is about |
|
| 48 | + * @return EE_Registration |
|
| 49 | + */ |
|
| 50 | + public function get_registration() |
|
| 51 | + { |
|
| 52 | + return $this->_registration; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @since 4.10.0.p |
|
| 57 | - * @throws EE_Error |
|
| 58 | - * @throws InvalidArgumentException |
|
| 59 | - * @throws ReflectionException |
|
| 60 | - * @throws InvalidDataTypeException |
|
| 61 | - * @throws InvalidInterfaceException |
|
| 62 | - */ |
|
| 63 | - public function build_form_from_registration() |
|
| 64 | - { |
|
| 65 | - $reg = $this->get_registration(); |
|
| 66 | - if (! $reg instanceof EE_Registration) { |
|
| 67 | - throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
| 68 | - } |
|
| 69 | - // we want to get all their question groups |
|
| 70 | - $question_groups = EEM_Question_Group::instance()->get_all( |
|
| 71 | - [ |
|
| 72 | - [ |
|
| 73 | - 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
| 74 | - 'OR' => [ |
|
| 75 | - 'Question.QST_system*blank' => '', |
|
| 76 | - 'Question.QST_system*null' => ['IS_NULL'] |
|
| 77 | - ], |
|
| 78 | - 'Event_Question_Group.' |
|
| 79 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 80 | - $reg->is_primary_registrant() |
|
| 81 | - ) => true |
|
| 82 | - ], |
|
| 83 | - 'order_by' => ['QSG_order' => 'ASC'] |
|
| 84 | - ] |
|
| 85 | - ); |
|
| 86 | - // get each question groups questions |
|
| 87 | - foreach ($question_groups as $question_group) { |
|
| 88 | - if ($question_group instanceof EE_Question_Group) { |
|
| 89 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 90 | - $question_group, |
|
| 91 | - $reg |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 55 | + /** |
|
| 56 | + * @since 4.10.0.p |
|
| 57 | + * @throws EE_Error |
|
| 58 | + * @throws InvalidArgumentException |
|
| 59 | + * @throws ReflectionException |
|
| 60 | + * @throws InvalidDataTypeException |
|
| 61 | + * @throws InvalidInterfaceException |
|
| 62 | + */ |
|
| 63 | + public function build_form_from_registration() |
|
| 64 | + { |
|
| 65 | + $reg = $this->get_registration(); |
|
| 66 | + if (! $reg instanceof EE_Registration) { |
|
| 67 | + throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
| 68 | + } |
|
| 69 | + // we want to get all their question groups |
|
| 70 | + $question_groups = EEM_Question_Group::instance()->get_all( |
|
| 71 | + [ |
|
| 72 | + [ |
|
| 73 | + 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
| 74 | + 'OR' => [ |
|
| 75 | + 'Question.QST_system*blank' => '', |
|
| 76 | + 'Question.QST_system*null' => ['IS_NULL'] |
|
| 77 | + ], |
|
| 78 | + 'Event_Question_Group.' |
|
| 79 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 80 | + $reg->is_primary_registrant() |
|
| 81 | + ) => true |
|
| 82 | + ], |
|
| 83 | + 'order_by' => ['QSG_order' => 'ASC'] |
|
| 84 | + ] |
|
| 85 | + ); |
|
| 86 | + // get each question groups questions |
|
| 87 | + foreach ($question_groups as $question_group) { |
|
| 88 | + if ($question_group instanceof EE_Question_Group) { |
|
| 89 | + $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 90 | + $question_group, |
|
| 91 | + $reg |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * |
|
| 101 | - * @param EE_Question_Group $question_group |
|
| 102 | - * @param EE_Registration $registration |
|
| 103 | - * @return \EE_Form_Section_Proper |
|
| 104 | - * @throws \EE_Error |
|
| 105 | - */ |
|
| 106 | - public function build_subform_from_question_group($question_group, $registration) |
|
| 107 | - { |
|
| 108 | - if (! $question_group instanceof EE_Question_Group || |
|
| 109 | - ! $registration instanceof EE_Registration) { |
|
| 110 | - throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
| 111 | - } |
|
| 112 | - $parts_of_subsection = array( |
|
| 113 | - 'title' => new EE_Form_Section_HTML( |
|
| 114 | - EEH_HTML::h5( |
|
| 115 | - $question_group->name(), |
|
| 116 | - $question_group->identifier(), |
|
| 117 | - 'espresso-question-group-title-h5 section-title' |
|
| 118 | - ) |
|
| 119 | - ) |
|
| 120 | - ); |
|
| 121 | - $questions = $question_group->questions( |
|
| 122 | - array( |
|
| 123 | - array( |
|
| 124 | - 'OR' => array( |
|
| 125 | - 'QST_system*blank' => '', |
|
| 126 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
| 127 | - ) |
|
| 128 | - ) |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - foreach ($questions as $question) { |
|
| 132 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 133 | - } |
|
| 134 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 135 | - 'ee_edit_registration', |
|
| 136 | - 'edit-reg-questions-mbox', |
|
| 137 | - $this->_registration->ID() |
|
| 138 | - )) { |
|
| 139 | - $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
| 140 | - EEH_HTML::table( |
|
| 141 | - EEH_HTML::tr( |
|
| 142 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 99 | + /** |
|
| 100 | + * |
|
| 101 | + * @param EE_Question_Group $question_group |
|
| 102 | + * @param EE_Registration $registration |
|
| 103 | + * @return \EE_Form_Section_Proper |
|
| 104 | + * @throws \EE_Error |
|
| 105 | + */ |
|
| 106 | + public function build_subform_from_question_group($question_group, $registration) |
|
| 107 | + { |
|
| 108 | + if (! $question_group instanceof EE_Question_Group || |
|
| 109 | + ! $registration instanceof EE_Registration) { |
|
| 110 | + throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
| 111 | + } |
|
| 112 | + $parts_of_subsection = array( |
|
| 113 | + 'title' => new EE_Form_Section_HTML( |
|
| 114 | + EEH_HTML::h5( |
|
| 115 | + $question_group->name(), |
|
| 116 | + $question_group->identifier(), |
|
| 117 | + 'espresso-question-group-title-h5 section-title' |
|
| 118 | + ) |
|
| 119 | + ) |
|
| 120 | + ); |
|
| 121 | + $questions = $question_group->questions( |
|
| 122 | + array( |
|
| 123 | + array( |
|
| 124 | + 'OR' => array( |
|
| 125 | + 'QST_system*blank' => '', |
|
| 126 | + 'QST_system*null' => array( 'IS_NULL' ) |
|
| 127 | + ) |
|
| 128 | + ) |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + foreach ($questions as $question) { |
|
| 132 | + $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 133 | + } |
|
| 134 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 135 | + 'ee_edit_registration', |
|
| 136 | + 'edit-reg-questions-mbox', |
|
| 137 | + $this->_registration->ID() |
|
| 138 | + )) { |
|
| 139 | + $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
| 140 | + EEH_HTML::table( |
|
| 141 | + EEH_HTML::tr( |
|
| 142 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 143 | 143 | <span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span> |
| 144 | 144 | <div class="dashicons dashicons-edit"></div> |
| 145 | 145 | </a></td>' |
| 146 | - ) . |
|
| 147 | - EEH_HTML::no_row('', 2) |
|
| 148 | - ) |
|
| 149 | - ); |
|
| 150 | - } |
|
| 151 | - return new EE_Form_Section_Proper( |
|
| 152 | - array( |
|
| 153 | - 'subsections' => $parts_of_subsection, |
|
| 154 | - 'html_class' => 'question-group-questions', |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - } |
|
| 146 | + ) . |
|
| 147 | + EEH_HTML::no_row('', 2) |
|
| 148 | + ) |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | + return new EE_Form_Section_Proper( |
|
| 152 | + array( |
|
| 153 | + 'subsections' => $parts_of_subsection, |
|
| 154 | + 'html_class' => 'question-group-questions', |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
| 161 | - * from the answers in the DB |
|
| 162 | - * @param array $req_data like $_POST |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 165 | - protected function _normalize($req_data) |
|
| 166 | - { |
|
| 167 | - $this->_received_submission = true; |
|
| 168 | - $this->_validation_errors = array(); |
|
| 169 | - foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 170 | - if ($subsection->form_data_present_in($req_data)) { |
|
| 171 | - try { |
|
| 172 | - $subsection->_normalize($req_data); |
|
| 173 | - } catch (EE_Validation_Error $e) { |
|
| 174 | - $subsection->add_validation_error($e); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 159 | + /** |
|
| 160 | + * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
| 161 | + * from the answers in the DB |
|
| 162 | + * @param array $req_data like $_POST |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | + protected function _normalize($req_data) |
|
| 166 | + { |
|
| 167 | + $this->_received_submission = true; |
|
| 168 | + $this->_validation_errors = array(); |
|
| 169 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 170 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 171 | + try { |
|
| 172 | + $subsection->_normalize($req_data); |
|
| 173 | + } catch (EE_Validation_Error $e) { |
|
| 174 | + $subsection->add_validation_error($e); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Performs validation on this form section and its subsections. For each subsection, |
|
| 184 | - * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection. |
|
| 185 | - * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method, |
|
| 186 | - * calling parent::_validate() first. |
|
| 187 | - */ |
|
| 188 | - protected function _validate() |
|
| 189 | - { |
|
| 190 | - foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 191 | - if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
| 192 | - if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 193 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 194 | - } |
|
| 195 | - $subsection->_validate(); |
|
| 196 | - } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 197 | - $subsection->_received_submission = true; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 182 | + /** |
|
| 183 | + * Performs validation on this form section and its subsections. For each subsection, |
|
| 184 | + * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection. |
|
| 185 | + * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method, |
|
| 186 | + * calling parent::_validate() first. |
|
| 187 | + */ |
|
| 188 | + protected function _validate() |
|
| 189 | + { |
|
| 190 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 191 | + if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
| 192 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 193 | + call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 194 | + } |
|
| 195 | + $subsection->_validate(); |
|
| 196 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 197 | + $subsection->_received_submission = true; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | } |