@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
| 4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | __('Registration Steps', 'event_espresso'), false, array()), |
| 106 | 106 | ) |
| 107 | 107 | ); |
| 108 | - $this->_model_relations = array( |
|
| 108 | + $this->_model_relations = array( |
|
| 109 | 109 | 'Registration' => new EE_Has_Many_Relation(), |
| 110 | 110 | 'Payment' => new EE_Has_Many_Relation(), |
| 111 | 111 | 'Status' => new EE_Belongs_To_Relation(), |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | ), |
| 168 | 168 | OBJECT, |
| 169 | 169 | array( |
| 170 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
| 170 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
| 171 | 171 | 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
| 172 | 172 | ) |
| 173 | 173 | ); |
@@ -187,17 +187,17 @@ discard block |
||
| 187 | 187 | public function get_revenue_per_event_report($period = '-1 month') |
| 188 | 188 | { |
| 189 | 189 | global $wpdb; |
| 190 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 191 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 192 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
| 190 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
| 191 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
| 192 | + $registration_payment_table = $wpdb->prefix.'esp_registration_payment'; |
|
| 193 | 193 | $event_table = $wpdb->posts; |
| 194 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
| 194 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
| 195 | 195 | $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
| 196 | 196 | $approved_payment_status = EEM_Payment::status_id_approved; |
| 197 | 197 | $extra_event_on_join = ''; |
| 198 | 198 | //exclude events not authored by user if permissions in effect |
| 199 | 199 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
| 200 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
| 200 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return $wpdb->get_results( |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
| 269 | 269 | { |
| 270 | 270 | EE_Error::doing_it_wrong( |
| 271 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 271 | + __CLASS__.'::'.__FUNCTION__, |
|
| 272 | 272 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
| 273 | 273 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
| 274 | 274 | '4.6.0' |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | array( |
| 317 | 317 | 0 => array( |
| 318 | 318 | 'STS_ID' => EEM_Transaction::failed_status_code, |
| 319 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
| 319 | + 'Payment.PAY_ID' => array('IS NULL'), |
|
| 320 | 320 | 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
| 321 | 321 | ) |
| 322 | 322 | ), |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | $time_to_leave_alone |
| 335 | 335 | ); |
| 336 | 336 | //now that we have the ids to delete |
| 337 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
| 337 | + if ( ! empty($txn_ids) && is_array($txn_ids)) { |
|
| 338 | 338 | // first, make sure these TXN's are removed the "ee_locked_transactions" array |
| 339 | 339 | EEM_Transaction::unset_locked_transactions($txn_ids); |
| 340 | 340 | // let's get deletin'... |
| 341 | 341 | // Why no wpdb->prepare? Because the data is trusted. |
| 342 | 342 | // We got the ids from the original query to get them FROM |
| 343 | 343 | // the db (which is sanitized) so no need to prepare them again. |
| 344 | - $query = ' |
|
| 344 | + $query = ' |
|
| 345 | 345 | DELETE |
| 346 | - FROM ' . $this->table() . ' |
|
| 346 | + FROM ' . $this->table().' |
|
| 347 | 347 | WHERE |
| 348 | - TXN_ID IN ( ' . implode(",", $txn_ids) . ')'; |
|
| 348 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
| 349 | 349 | $deleted = $wpdb->query($query); |
| 350 | 350 | } |
| 351 | 351 | if ($deleted) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
| 5 | 5 | |
@@ -15,193 +15,193 @@ discard block |
||
| 15 | 15 | class EEM_Transaction extends EEM_Base |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - // private instance of the Transaction object |
|
| 19 | - protected static $_instance; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
| 23 | - * but payment is pending. This is the state for transactions where payment is promised |
|
| 24 | - * from an offline gateway. |
|
| 25 | - */ |
|
| 26 | - // const open_status_code = 'TPN'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
| 30 | - * either due to a technical reason (server or computer crash during registration), |
|
| 31 | - * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
| 32 | - */ |
|
| 33 | - const failed_status_code = 'TFL'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
| 37 | - * either due to a technical reason (server or computer crash during registration), |
|
| 38 | - * or due to an abandoned cart after registrant chose not to complete the registration process |
|
| 39 | - * HOWEVER... |
|
| 40 | - * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
| 41 | - * registrant |
|
| 42 | - */ |
|
| 43 | - const abandoned_status_code = 'TAB'; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
| 47 | - * meaning that monies are still owing: TXN_paid < TXN_total |
|
| 48 | - */ |
|
| 49 | - const incomplete_status_code = 'TIN'; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
| 53 | - * meaning that NO monies are owing: TXN_paid == TXN_total |
|
| 54 | - */ |
|
| 55 | - const complete_status_code = 'TCM'; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
| 59 | - * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
| 60 | - */ |
|
| 61 | - const overpaid_status_code = 'TOP'; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * private constructor to prevent direct creation |
|
| 66 | - * |
|
| 67 | - * @Constructor |
|
| 68 | - * @access protected |
|
| 69 | - * |
|
| 70 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
| 71 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
| 72 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
| 73 | - * timezone in the 'timezone_string' wp option) |
|
| 74 | - * |
|
| 75 | - * @return EEM_Transaction |
|
| 76 | - * @throws \EE_Error |
|
| 77 | - */ |
|
| 78 | - protected function __construct($timezone) |
|
| 79 | - { |
|
| 80 | - $this->singular_item = __('Transaction', 'event_espresso'); |
|
| 81 | - $this->plural_item = __('Transactions', 'event_espresso'); |
|
| 82 | - |
|
| 83 | - $this->_tables = array( |
|
| 84 | - 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
| 85 | - ); |
|
| 86 | - $this->_fields = array( |
|
| 87 | - 'TransactionTable' => array( |
|
| 88 | - 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
| 89 | - 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', |
|
| 90 | - __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now, |
|
| 91 | - $timezone), |
|
| 92 | - 'TXN_total' => new EE_Money_Field('TXN_total', |
|
| 93 | - __('Total value of Transaction', 'event_espresso'), false, 0), |
|
| 94 | - 'TXN_paid' => new EE_Money_Field('TXN_paid', |
|
| 95 | - __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
| 96 | - 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
| 97 | - false, EEM_Transaction::failed_status_code, 'Status'), |
|
| 98 | - 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', |
|
| 99 | - __('Serialized session data', 'event_espresso'), true, ''), |
|
| 100 | - 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', |
|
| 101 | - __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
| 102 | - 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', |
|
| 103 | - __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'), |
|
| 104 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', |
|
| 105 | - __('Registration Steps', 'event_espresso'), false, array()), |
|
| 106 | - ) |
|
| 107 | - ); |
|
| 108 | - $this->_model_relations = array( |
|
| 109 | - 'Registration' => new EE_Has_Many_Relation(), |
|
| 110 | - 'Payment' => new EE_Has_Many_Relation(), |
|
| 111 | - 'Status' => new EE_Belongs_To_Relation(), |
|
| 112 | - 'Line_Item' => new EE_Has_Many_Relation(false), |
|
| 113 | - //you can delete a transaction without needing to delete its line items |
|
| 114 | - 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
| 115 | - 'Message' => new EE_Has_Many_Relation() |
|
| 116 | - ); |
|
| 117 | - $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
| 118 | - parent::__construct($timezone); |
|
| 119 | - |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * txn_status_array |
|
| 125 | - * get list of transaction statuses |
|
| 126 | - * |
|
| 127 | - * @access public |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public static function txn_status_array() |
|
| 131 | - { |
|
| 132 | - return apply_filters( |
|
| 133 | - 'FHEE__EEM_Transaction__txn_status_array', |
|
| 134 | - array( |
|
| 135 | - EEM_Transaction::overpaid_status_code, |
|
| 136 | - EEM_Transaction::complete_status_code, |
|
| 137 | - EEM_Transaction::incomplete_status_code, |
|
| 138 | - EEM_Transaction::abandoned_status_code, |
|
| 139 | - EEM_Transaction::failed_status_code, |
|
| 140 | - ) |
|
| 141 | - ); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * get the revenue per day for the Transaction Admin page Reports Tab |
|
| 146 | - * |
|
| 147 | - * @access public |
|
| 148 | - * |
|
| 149 | - * @param string $period |
|
| 150 | - * |
|
| 151 | - * @return \stdClass[] |
|
| 152 | - */ |
|
| 153 | - public function get_revenue_per_day_report($period = '-1 month') |
|
| 154 | - { |
|
| 155 | - $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), |
|
| 156 | - 'Y-m-d H:i:s', 'UTC'); |
|
| 157 | - |
|
| 158 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
| 159 | - |
|
| 160 | - return $this->_get_all_wpdb_results( |
|
| 161 | - array( |
|
| 162 | - array( |
|
| 163 | - 'TXN_timestamp' => array('>=', $sql_date) |
|
| 164 | - ), |
|
| 165 | - 'group_by' => 'txnDate', |
|
| 166 | - 'order_by' => array('TXN_timestamp' => 'ASC') |
|
| 167 | - ), |
|
| 168 | - OBJECT, |
|
| 169 | - array( |
|
| 170 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
| 171 | - 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
| 172 | - ) |
|
| 173 | - ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * get the revenue per event for the Transaction Admin page Reports Tab |
|
| 179 | - * |
|
| 180 | - * @access public |
|
| 181 | - * |
|
| 182 | - * @param string $period |
|
| 183 | - * |
|
| 184 | - * @throws \EE_Error |
|
| 185 | - * @return mixed |
|
| 186 | - */ |
|
| 187 | - public function get_revenue_per_event_report($period = '-1 month') |
|
| 188 | - { |
|
| 189 | - global $wpdb; |
|
| 190 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 191 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 192 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
| 193 | - $event_table = $wpdb->posts; |
|
| 194 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
| 195 | - $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
| 196 | - $approved_payment_status = EEM_Payment::status_id_approved; |
|
| 197 | - $extra_event_on_join = ''; |
|
| 198 | - //exclude events not authored by user if permissions in effect |
|
| 199 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 200 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - return $wpdb->get_results( |
|
| 204 | - "SELECT |
|
| 18 | + // private instance of the Transaction object |
|
| 19 | + protected static $_instance; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
| 23 | + * but payment is pending. This is the state for transactions where payment is promised |
|
| 24 | + * from an offline gateway. |
|
| 25 | + */ |
|
| 26 | + // const open_status_code = 'TPN'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
| 30 | + * either due to a technical reason (server or computer crash during registration), |
|
| 31 | + * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
| 32 | + */ |
|
| 33 | + const failed_status_code = 'TFL'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
| 37 | + * either due to a technical reason (server or computer crash during registration), |
|
| 38 | + * or due to an abandoned cart after registrant chose not to complete the registration process |
|
| 39 | + * HOWEVER... |
|
| 40 | + * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
| 41 | + * registrant |
|
| 42 | + */ |
|
| 43 | + const abandoned_status_code = 'TAB'; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
| 47 | + * meaning that monies are still owing: TXN_paid < TXN_total |
|
| 48 | + */ |
|
| 49 | + const incomplete_status_code = 'TIN'; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
| 53 | + * meaning that NO monies are owing: TXN_paid == TXN_total |
|
| 54 | + */ |
|
| 55 | + const complete_status_code = 'TCM'; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
| 59 | + * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
| 60 | + */ |
|
| 61 | + const overpaid_status_code = 'TOP'; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * private constructor to prevent direct creation |
|
| 66 | + * |
|
| 67 | + * @Constructor |
|
| 68 | + * @access protected |
|
| 69 | + * |
|
| 70 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
| 71 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
| 72 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
| 73 | + * timezone in the 'timezone_string' wp option) |
|
| 74 | + * |
|
| 75 | + * @return EEM_Transaction |
|
| 76 | + * @throws \EE_Error |
|
| 77 | + */ |
|
| 78 | + protected function __construct($timezone) |
|
| 79 | + { |
|
| 80 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
| 81 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
| 82 | + |
|
| 83 | + $this->_tables = array( |
|
| 84 | + 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
| 85 | + ); |
|
| 86 | + $this->_fields = array( |
|
| 87 | + 'TransactionTable' => array( |
|
| 88 | + 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
| 89 | + 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', |
|
| 90 | + __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now, |
|
| 91 | + $timezone), |
|
| 92 | + 'TXN_total' => new EE_Money_Field('TXN_total', |
|
| 93 | + __('Total value of Transaction', 'event_espresso'), false, 0), |
|
| 94 | + 'TXN_paid' => new EE_Money_Field('TXN_paid', |
|
| 95 | + __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
| 96 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
| 97 | + false, EEM_Transaction::failed_status_code, 'Status'), |
|
| 98 | + 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', |
|
| 99 | + __('Serialized session data', 'event_espresso'), true, ''), |
|
| 100 | + 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', |
|
| 101 | + __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
| 102 | + 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', |
|
| 103 | + __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'), |
|
| 104 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', |
|
| 105 | + __('Registration Steps', 'event_espresso'), false, array()), |
|
| 106 | + ) |
|
| 107 | + ); |
|
| 108 | + $this->_model_relations = array( |
|
| 109 | + 'Registration' => new EE_Has_Many_Relation(), |
|
| 110 | + 'Payment' => new EE_Has_Many_Relation(), |
|
| 111 | + 'Status' => new EE_Belongs_To_Relation(), |
|
| 112 | + 'Line_Item' => new EE_Has_Many_Relation(false), |
|
| 113 | + //you can delete a transaction without needing to delete its line items |
|
| 114 | + 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
| 115 | + 'Message' => new EE_Has_Many_Relation() |
|
| 116 | + ); |
|
| 117 | + $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
| 118 | + parent::__construct($timezone); |
|
| 119 | + |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * txn_status_array |
|
| 125 | + * get list of transaction statuses |
|
| 126 | + * |
|
| 127 | + * @access public |
|
| 128 | + * @return array |
|
| 129 | + */ |
|
| 130 | + public static function txn_status_array() |
|
| 131 | + { |
|
| 132 | + return apply_filters( |
|
| 133 | + 'FHEE__EEM_Transaction__txn_status_array', |
|
| 134 | + array( |
|
| 135 | + EEM_Transaction::overpaid_status_code, |
|
| 136 | + EEM_Transaction::complete_status_code, |
|
| 137 | + EEM_Transaction::incomplete_status_code, |
|
| 138 | + EEM_Transaction::abandoned_status_code, |
|
| 139 | + EEM_Transaction::failed_status_code, |
|
| 140 | + ) |
|
| 141 | + ); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * get the revenue per day for the Transaction Admin page Reports Tab |
|
| 146 | + * |
|
| 147 | + * @access public |
|
| 148 | + * |
|
| 149 | + * @param string $period |
|
| 150 | + * |
|
| 151 | + * @return \stdClass[] |
|
| 152 | + */ |
|
| 153 | + public function get_revenue_per_day_report($period = '-1 month') |
|
| 154 | + { |
|
| 155 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), |
|
| 156 | + 'Y-m-d H:i:s', 'UTC'); |
|
| 157 | + |
|
| 158 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
| 159 | + |
|
| 160 | + return $this->_get_all_wpdb_results( |
|
| 161 | + array( |
|
| 162 | + array( |
|
| 163 | + 'TXN_timestamp' => array('>=', $sql_date) |
|
| 164 | + ), |
|
| 165 | + 'group_by' => 'txnDate', |
|
| 166 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
| 167 | + ), |
|
| 168 | + OBJECT, |
|
| 169 | + array( |
|
| 170 | + 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
| 171 | + 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
| 172 | + ) |
|
| 173 | + ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * get the revenue per event for the Transaction Admin page Reports Tab |
|
| 179 | + * |
|
| 180 | + * @access public |
|
| 181 | + * |
|
| 182 | + * @param string $period |
|
| 183 | + * |
|
| 184 | + * @throws \EE_Error |
|
| 185 | + * @return mixed |
|
| 186 | + */ |
|
| 187 | + public function get_revenue_per_event_report($period = '-1 month') |
|
| 188 | + { |
|
| 189 | + global $wpdb; |
|
| 190 | + $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 191 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 192 | + $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
| 193 | + $event_table = $wpdb->posts; |
|
| 194 | + $payment_table = $wpdb->prefix . 'esp_payment'; |
|
| 195 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
| 196 | + $approved_payment_status = EEM_Payment::status_id_approved; |
|
| 197 | + $extra_event_on_join = ''; |
|
| 198 | + //exclude events not authored by user if permissions in effect |
|
| 199 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 200 | + $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + return $wpdb->get_results( |
|
| 204 | + "SELECT |
|
| 205 | 205 | Transaction_Event.event_name AS event_name, |
| 206 | 206 | SUM(Transaction_Event.paid) AS revenue |
| 207 | 207 | FROM |
@@ -228,185 +228,185 @@ discard block |
||
| 228 | 228 | $extra_event_on_join |
| 229 | 229 | ) AS Transaction_Event |
| 230 | 230 | GROUP BY event_name", |
| 231 | - OBJECT |
|
| 232 | - ); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
| 238 | - * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
| 239 | - * the registration pointed to by reg_url_link), if not returns null |
|
| 240 | - * |
|
| 241 | - * @param string $reg_url_link |
|
| 242 | - * |
|
| 243 | - * @return EE_Transaction |
|
| 244 | - */ |
|
| 245 | - public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
| 246 | - { |
|
| 247 | - return $this->get_one(array( |
|
| 248 | - array( |
|
| 249 | - 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', |
|
| 250 | - '') |
|
| 251 | - ) |
|
| 252 | - )); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * Updates the provided EE_Transaction with all the applicable payments |
|
| 258 | - * (or fetch the EE_Transaction from its ID) |
|
| 259 | - * |
|
| 260 | - * @deprecated |
|
| 261 | - * |
|
| 262 | - * @param EE_Transaction|int $transaction_obj_or_id |
|
| 263 | - * @param boolean $save_txn whether or not to save the transaction during this function call |
|
| 264 | - * |
|
| 265 | - * @return boolean |
|
| 266 | - * @throws \EE_Error |
|
| 267 | - */ |
|
| 268 | - public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
| 269 | - { |
|
| 270 | - EE_Error::doing_it_wrong( |
|
| 271 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 272 | - sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
| 273 | - 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
| 274 | - '4.6.0' |
|
| 275 | - ); |
|
| 276 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 277 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 278 | - |
|
| 279 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
| 280 | - $this->ensure_is_obj($transaction_obj_or_id) |
|
| 281 | - ); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
| 286 | - * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
| 287 | - * and so we only use wpdb directly and only do minimal joins. |
|
| 288 | - * Transactions are considered "junk" if they're failed for longer than a week. |
|
| 289 | - * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
| 290 | - * it, it's probably not junk (regardless of what status it has). |
|
| 291 | - * The downside to this approach is that is addons are listening for object deletions |
|
| 292 | - * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
| 293 | - * to catch these types of deletions. |
|
| 294 | - * |
|
| 295 | - * @global WPDB $wpdb |
|
| 296 | - * @return mixed |
|
| 297 | - */ |
|
| 298 | - public function delete_junk_transactions() |
|
| 299 | - { |
|
| 300 | - /** @type WPDB $wpdb */ |
|
| 301 | - global $wpdb; |
|
| 302 | - $deleted = false; |
|
| 303 | - $time_to_leave_alone = apply_filters( |
|
| 304 | - 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone' |
|
| 305 | - , WEEK_IN_SECONDS |
|
| 306 | - ); |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
| 311 | - * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
| 312 | - * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
| 313 | - */ |
|
| 314 | - $ids_query = apply_filters( |
|
| 315 | - 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
| 316 | - array( |
|
| 317 | - 0 => array( |
|
| 318 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 319 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
| 320 | - 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
| 321 | - ) |
|
| 322 | - ), |
|
| 323 | - $time_to_leave_alone |
|
| 324 | - ); |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
| 329 | - * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
| 330 | - */ |
|
| 331 | - $txn_ids = apply_filters( |
|
| 332 | - 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
| 333 | - EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
| 334 | - $time_to_leave_alone |
|
| 335 | - ); |
|
| 336 | - //now that we have the ids to delete |
|
| 337 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
| 338 | - // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
| 339 | - EEM_Transaction::unset_locked_transactions($txn_ids); |
|
| 340 | - // let's get deletin'... |
|
| 341 | - // Why no wpdb->prepare? Because the data is trusted. |
|
| 342 | - // We got the ids from the original query to get them FROM |
|
| 343 | - // the db (which is sanitized) so no need to prepare them again. |
|
| 344 | - $query = ' |
|
| 231 | + OBJECT |
|
| 232 | + ); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
| 238 | + * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
| 239 | + * the registration pointed to by reg_url_link), if not returns null |
|
| 240 | + * |
|
| 241 | + * @param string $reg_url_link |
|
| 242 | + * |
|
| 243 | + * @return EE_Transaction |
|
| 244 | + */ |
|
| 245 | + public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
| 246 | + { |
|
| 247 | + return $this->get_one(array( |
|
| 248 | + array( |
|
| 249 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', |
|
| 250 | + '') |
|
| 251 | + ) |
|
| 252 | + )); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * Updates the provided EE_Transaction with all the applicable payments |
|
| 258 | + * (or fetch the EE_Transaction from its ID) |
|
| 259 | + * |
|
| 260 | + * @deprecated |
|
| 261 | + * |
|
| 262 | + * @param EE_Transaction|int $transaction_obj_or_id |
|
| 263 | + * @param boolean $save_txn whether or not to save the transaction during this function call |
|
| 264 | + * |
|
| 265 | + * @return boolean |
|
| 266 | + * @throws \EE_Error |
|
| 267 | + */ |
|
| 268 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
| 269 | + { |
|
| 270 | + EE_Error::doing_it_wrong( |
|
| 271 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 272 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
| 273 | + 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
| 274 | + '4.6.0' |
|
| 275 | + ); |
|
| 276 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 277 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 278 | + |
|
| 279 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
| 280 | + $this->ensure_is_obj($transaction_obj_or_id) |
|
| 281 | + ); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
| 286 | + * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
| 287 | + * and so we only use wpdb directly and only do minimal joins. |
|
| 288 | + * Transactions are considered "junk" if they're failed for longer than a week. |
|
| 289 | + * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
| 290 | + * it, it's probably not junk (regardless of what status it has). |
|
| 291 | + * The downside to this approach is that is addons are listening for object deletions |
|
| 292 | + * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
| 293 | + * to catch these types of deletions. |
|
| 294 | + * |
|
| 295 | + * @global WPDB $wpdb |
|
| 296 | + * @return mixed |
|
| 297 | + */ |
|
| 298 | + public function delete_junk_transactions() |
|
| 299 | + { |
|
| 300 | + /** @type WPDB $wpdb */ |
|
| 301 | + global $wpdb; |
|
| 302 | + $deleted = false; |
|
| 303 | + $time_to_leave_alone = apply_filters( |
|
| 304 | + 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone' |
|
| 305 | + , WEEK_IN_SECONDS |
|
| 306 | + ); |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
| 311 | + * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
| 312 | + * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
| 313 | + */ |
|
| 314 | + $ids_query = apply_filters( |
|
| 315 | + 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
| 316 | + array( |
|
| 317 | + 0 => array( |
|
| 318 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 319 | + 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
| 320 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
| 321 | + ) |
|
| 322 | + ), |
|
| 323 | + $time_to_leave_alone |
|
| 324 | + ); |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
| 329 | + * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
| 330 | + */ |
|
| 331 | + $txn_ids = apply_filters( |
|
| 332 | + 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
| 333 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
| 334 | + $time_to_leave_alone |
|
| 335 | + ); |
|
| 336 | + //now that we have the ids to delete |
|
| 337 | + if (! empty($txn_ids) && is_array($txn_ids)) { |
|
| 338 | + // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
| 339 | + EEM_Transaction::unset_locked_transactions($txn_ids); |
|
| 340 | + // let's get deletin'... |
|
| 341 | + // Why no wpdb->prepare? Because the data is trusted. |
|
| 342 | + // We got the ids from the original query to get them FROM |
|
| 343 | + // the db (which is sanitized) so no need to prepare them again. |
|
| 344 | + $query = ' |
|
| 345 | 345 | DELETE |
| 346 | 346 | FROM ' . $this->table() . ' |
| 347 | 347 | WHERE |
| 348 | 348 | TXN_ID IN ( ' . implode(",", $txn_ids) . ')'; |
| 349 | - $deleted = $wpdb->query($query); |
|
| 350 | - } |
|
| 351 | - if ($deleted) { |
|
| 352 | - /** |
|
| 353 | - * Allows code to do something after the transactions have been deleted. |
|
| 354 | - */ |
|
| 355 | - do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - return $deleted; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * @param array $transaction_IDs |
|
| 364 | - * |
|
| 365 | - * @return bool |
|
| 366 | - */ |
|
| 367 | - public static function unset_locked_transactions(array $transaction_IDs) |
|
| 368 | - { |
|
| 369 | - $locked_transactions = get_option('ee_locked_transactions', array()); |
|
| 370 | - $update = false; |
|
| 371 | - foreach ($transaction_IDs as $TXN_ID) { |
|
| 372 | - if (isset($locked_transactions[$TXN_ID])) { |
|
| 373 | - unset($locked_transactions[$TXN_ID]); |
|
| 374 | - $update = true; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - if ($update) { |
|
| 378 | - update_option('ee_locked_transactions', $locked_transactions); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - return $update; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * returns an array of EE_Transaction objects whose timestamp is less than |
|
| 388 | - * the current time minus the session lifespan, which defaults to 60 minutes |
|
| 389 | - * |
|
| 390 | - * @return EE_Base_Class[]|EE_Transaction[] |
|
| 391 | - * @throws \EE_Error |
|
| 392 | - */ |
|
| 393 | - public function get_transactions_in_progress() |
|
| 394 | - { |
|
| 395 | - return $this->get_all( |
|
| 396 | - array( |
|
| 397 | - array( |
|
| 398 | - 'TXN_timestamp' => array( |
|
| 399 | - '>', |
|
| 400 | - time() - EE_Registry::instance()->SSN->lifespan() |
|
| 401 | - ), |
|
| 402 | - 'STS_ID' => array( |
|
| 403 | - '!=', |
|
| 404 | - EEM_Transaction::complete_status_code |
|
| 405 | - ), |
|
| 406 | - ) |
|
| 407 | - ) |
|
| 408 | - ); |
|
| 409 | - } |
|
| 349 | + $deleted = $wpdb->query($query); |
|
| 350 | + } |
|
| 351 | + if ($deleted) { |
|
| 352 | + /** |
|
| 353 | + * Allows code to do something after the transactions have been deleted. |
|
| 354 | + */ |
|
| 355 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + return $deleted; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * @param array $transaction_IDs |
|
| 364 | + * |
|
| 365 | + * @return bool |
|
| 366 | + */ |
|
| 367 | + public static function unset_locked_transactions(array $transaction_IDs) |
|
| 368 | + { |
|
| 369 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
| 370 | + $update = false; |
|
| 371 | + foreach ($transaction_IDs as $TXN_ID) { |
|
| 372 | + if (isset($locked_transactions[$TXN_ID])) { |
|
| 373 | + unset($locked_transactions[$TXN_ID]); |
|
| 374 | + $update = true; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + if ($update) { |
|
| 378 | + update_option('ee_locked_transactions', $locked_transactions); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + return $update; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * returns an array of EE_Transaction objects whose timestamp is less than |
|
| 388 | + * the current time minus the session lifespan, which defaults to 60 minutes |
|
| 389 | + * |
|
| 390 | + * @return EE_Base_Class[]|EE_Transaction[] |
|
| 391 | + * @throws \EE_Error |
|
| 392 | + */ |
|
| 393 | + public function get_transactions_in_progress() |
|
| 394 | + { |
|
| 395 | + return $this->get_all( |
|
| 396 | + array( |
|
| 397 | + array( |
|
| 398 | + 'TXN_timestamp' => array( |
|
| 399 | + '>', |
|
| 400 | + time() - EE_Registry::instance()->SSN->lifespan() |
|
| 401 | + ), |
|
| 402 | + 'STS_ID' => array( |
|
| 403 | + '!=', |
|
| 404 | + EEM_Transaction::complete_status_code |
|
| 405 | + ), |
|
| 406 | + ) |
|
| 407 | + ) |
|
| 408 | + ); |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | 411 | |
| 412 | 412 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | *@param array $settings_array |
| 98 | 98 | */ |
| 99 | - public function set_settings( $settings_array ) { |
|
| 99 | + public function set_settings($settings_array) { |
|
| 100 | 100 | parent::set_settings($settings_array); |
| 101 | 101 | // Redirect URL. |
| 102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | * @return \EE_Payment|\EEI_Payment |
| 116 | 116 | * @throws \EE_Error |
| 117 | 117 | */ |
| 118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
| 119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
| 120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
| 121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
| 119 | + if ( ! $payment instanceof EEI_Payment) { |
|
| 120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
| 121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 122 | 122 | return $payment; |
| 123 | 123 | } |
| 124 | 124 | $transaction = $payment->transaction(); |
| 125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
| 126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
| 127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
| 126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
| 127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 128 | 128 | return $payment; |
| 129 | 129 | } |
| 130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
| 130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
| 131 | 131 | $primary_registration = $transaction->primary_registration(); |
| 132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
| 133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
| 141 | 141 | 'RETURNURL' => $return_url, |
| 142 | 142 | 'CANCELURL' => $cancel_url, |
| 143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
| 144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
| 145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
| 144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
| 145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
| 146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | 149 | // Show itemized list. |
| 150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
| 150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
| 151 | 151 | $item_num = 0; |
| 152 | 152 | $itemized_sum = 0; |
| 153 | 153 | $total_line_items = $transaction->total_line_item(); |
| 154 | 154 | // Go through each item in the list. |
| 155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
| 156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
| 155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
| 156 | + if ($line_item instanceof EE_Line_Item) { |
|
| 157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
| 158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
| 158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $unit_price = $line_item->unit_price(); |
| 163 | 163 | $line_item_quantity = $line_item->quantity(); |
| 164 | 164 | // This is a discount. |
| 165 | - if ( $line_item->is_percent() ) { |
|
| 165 | + if ($line_item->is_percent()) { |
|
| 166 | 166 | $unit_price = $line_item->total(); |
| 167 | 167 | $line_item_quantity = 1; |
| 168 | 168 | } |
| 169 | 169 | // Item Name. |
| 170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
| 170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
| 171 | 171 | // Item description. |
| 172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
| 172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
| 173 | 173 | // Cost of individual item. |
| 174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
| 174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
| 175 | 175 | // Item Number. |
| 176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
| 177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
| 188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
| 189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
| 190 | 190 | |
| 191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
| 191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
| 192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
| 193 | 193 | // add the difference as an extra line item. |
| 194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
| 194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
| 195 | 195 | // Item Name. |
| 196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
| 196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
| 197 | 197 | // Item description. |
| 198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
| 199 | 199 | // Cost of individual item. |
| 200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
| 200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
| 201 | 201 | // Item Number. |
| 202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
| 203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | } else { |
| 210 | 210 | // Just one Item. |
| 211 | 211 | // Item Name. |
| 212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
| 212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
| 213 | 213 | // Item description. |
| 214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
| 214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
| 215 | 215 | // Cost of individual item. |
| 216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
| 216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
| 217 | 217 | // Item Number. |
| 218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
| 219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | // Digital item is sold. |
| 222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
| 223 | 223 | // Item's sales S/H and tax amount. |
| 224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
| 224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
| 225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
| 226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
| 227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
| 228 | 228 | } |
| 229 | 229 | // Automatically filling out shipping and contact information. |
| 230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
| 231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
| 230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
| 231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
| 232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
| 233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
| 234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
| 238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
| 239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
| 240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
| 240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
| 241 | 241 | // Do not request shipping details on the PP Checkout page. |
| 242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
| 243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | // Used a business/personal logo on the PayPal page. |
| 247 | - if ( ! empty($this->_image_url) ) { |
|
| 247 | + if ( ! empty($this->_image_url)) { |
|
| 248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
| 249 | 249 | } |
| 250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
| 253 | 253 | $this |
| 254 | 254 | ); |
| 255 | 255 | // Request PayPal token. |
| 256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
| 257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
| 258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
| 259 | - if ( $token_rstatus['status'] ) { |
|
| 256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
| 257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
| 258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
| 259 | + if ($token_rstatus['status']) { |
|
| 260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
| 261 | - $payment->set_details( $response_args ); |
|
| 261 | + $payment->set_details($response_args); |
|
| 262 | 262 | |
| 263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
| 264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
| 264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
| 265 | 265 | } else { |
| 266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
| 267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
| 266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
| 267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
| 268 | 268 | } else { |
| 269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
| 269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
| 270 | 270 | } |
| 271 | - $payment->set_details( $response_args ); |
|
| 272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 271 | + $payment->set_details($response_args); |
|
| 272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
| 285 | 285 | * @param EEI_Transaction $transaction |
| 286 | 286 | * @return EEI_Payment |
| 287 | 287 | */ |
| 288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
| 288 | + public function handle_payment_update($update_info, $transaction) { |
|
| 289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
| 290 | 290 | |
| 291 | - if ( $payment instanceof EEI_Payment ) { |
|
| 292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
| 291 | + if ($payment instanceof EEI_Payment) { |
|
| 292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
| 293 | 293 | $transaction = $payment->transaction(); |
| 294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
| 295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
| 296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
| 295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
| 296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 297 | 297 | return $payment; |
| 298 | 298 | } |
| 299 | 299 | $primary_registrant = $transaction->primary_registration(); |
| 300 | 300 | $payment_details = $payment->details(); |
| 301 | 301 | // Check if we still have the token. |
| 302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
| 303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
| 303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 304 | 304 | return $payment; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
| 310 | 310 | ); |
| 311 | 311 | // Request Customer Details. |
| 312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
| 313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
| 314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
| 315 | - if ( $cdetails_rstatus['status'] ) { |
|
| 312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
| 313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
| 314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
| 315 | + if ($cdetails_rstatus['status']) { |
|
| 316 | 316 | // We got the PayerID so now we can Complete the transaction. |
| 317 | 317 | $docheckout_request_dtls = array( |
| 318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
| 323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
| 324 | 324 | ); |
| 325 | 325 | // Payment Checkout/Capture. |
| 326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
| 327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
| 328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
| 329 | - if ( $docheckout_rstatus['status'] ) { |
|
| 326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
| 327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
| 328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
| 329 | + if ($docheckout_rstatus['status']) { |
|
| 330 | 330 | // All is well, payment approved. |
| 331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
| 332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
| 333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
| 334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
| 335 | - $payment->set_details( $cdata_response_args ); |
|
| 336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
| 337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
| 332 | + $payment->set_extra_accntng($primary_registration_code); |
|
| 333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
| 334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
| 335 | + $payment->set_details($cdata_response_args); |
|
| 336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
| 337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
| 338 | 338 | } else { |
| 339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
| 340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
| 339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
| 340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
| 341 | 341 | } else { |
| 342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
| 342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
| 343 | 343 | } |
| 344 | - $payment->set_details( $docheckout_response_args ); |
|
| 345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
| 344 | + $payment->set_details($docheckout_response_args); |
|
| 345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
| 346 | 346 | } |
| 347 | 347 | } else { |
| 348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
| 349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
| 348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
| 349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
| 350 | 350 | } else { |
| 351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
| 351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
| 352 | 352 | } |
| 353 | - $payment->set_details( $cdata_response_args ); |
|
| 354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 353 | + $payment->set_details($cdata_response_args); |
|
| 354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 355 | 355 | } |
| 356 | 356 | } else { |
| 357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
| 358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
| 358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
| 370 | 370 | * @param EEI_Payment $payment |
| 371 | 371 | * @return mixed |
| 372 | 372 | */ |
| 373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
| 373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
| 374 | 374 | $request_dtls = array( |
| 375 | 375 | 'VERSION' => '204.0', |
| 376 | - 'USER' => urlencode( $this->_api_username ), |
|
| 377 | - 'PWD' => urlencode( $this->_api_password ), |
|
| 378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
| 376 | + 'USER' => urlencode($this->_api_username), |
|
| 377 | + 'PWD' => urlencode($this->_api_password), |
|
| 378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
| 379 | 379 | ); |
| 380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
| 380 | + $dtls = array_merge($request_dtls, $request_params); |
|
| 381 | 381 | |
| 382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
| 382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
| 383 | 383 | // Request Customer Details. |
| 384 | 384 | $request_response = wp_remote_post( |
| 385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | 'httpversion' => '1.1', |
| 390 | 390 | 'cookies' => array(), |
| 391 | 391 | 'headers' => array(), |
| 392 | - 'body' => http_build_query( $dtls ) |
|
| 392 | + 'body' => http_build_query($dtls) |
|
| 393 | 393 | ) |
| 394 | 394 | ); |
| 395 | 395 | // Log the response. |
| 396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
| 396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
| 397 | 397 | |
| 398 | 398 | return $request_response; |
| 399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
| 405 | 405 | * @param mixed $request_response |
| 406 | 406 | * @return array |
| 407 | 407 | */ |
| 408 | - public function _ppExpress_check_response( $request_response ) { |
|
| 409 | - if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
|
| 408 | + public function _ppExpress_check_response($request_response) { |
|
| 409 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
| 410 | 410 | // If we got here then there was an error in this request. |
| 411 | 411 | return array('status' => false, 'args' => $request_response); |
| 412 | 412 | } |
| 413 | 413 | $response_args = array(); |
| 414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
| 414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
| 415 | 415 | if ( ! isset($response_args['ACK'])) { |
| 416 | 416 | return array('status' => false, 'args' => $request_response); |
| 417 | 417 | } |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | * @param string $info |
| 442 | 442 | * @return void |
| 443 | 443 | */ |
| 444 | - private function _log_clean_request($request, $payment, $info ) { |
|
| 444 | + private function _log_clean_request($request, $payment, $info) { |
|
| 445 | 445 | $cleaned_request_data = $request; |
| 446 | 446 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
| 447 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
| 447 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
@@ -454,10 +454,10 @@ discard block |
||
| 454 | 454 | * @param array $data_array |
| 455 | 455 | * @return array |
| 456 | 456 | */ |
| 457 | - private function _get_errors( $data_array ) { |
|
| 457 | + private function _get_errors($data_array) { |
|
| 458 | 458 | $errors = array(); |
| 459 | 459 | $n = 0; |
| 460 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
| 460 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
| 461 | 461 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
| 462 | 462 | ? $data_array["L_ERRORCODE{$n}"] |
| 463 | 463 | : ''; |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | ? $data_array["L_LONGMESSAGE{$n}"] |
| 472 | 472 | : ''; |
| 473 | 473 | |
| 474 | - if ( $n === 0 ) { |
|
| 474 | + if ($n === 0) { |
|
| 475 | 475 | $errors = array( |
| 476 | 476 | 'L_ERRORCODE' => $l_error_code, |
| 477 | 477 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -479,10 +479,10 @@ discard block |
||
| 479 | 479 | 'L_SEVERITYCODE' => $l_severity_code |
| 480 | 480 | ); |
| 481 | 481 | } else { |
| 482 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
| 483 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
| 484 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
| 485 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
| 482 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
| 483 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
| 484 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
| 485 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | $n++; |
@@ -44,77 +44,76 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected $_image_url; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * gateway URL variable |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - protected $_base_gateway_url = ''; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * EEG_Paypal_Express constructor. |
|
| 58 | - */ |
|
| 59 | - public function __construct() |
|
| 60 | - { |
|
| 61 | - $this->_currencies_supported = array( |
|
| 62 | - 'USD', |
|
| 63 | - 'AUD', |
|
| 64 | - 'BRL', |
|
| 65 | - 'CAD', |
|
| 66 | - 'CZK', |
|
| 67 | - 'DKK', |
|
| 68 | - 'EUR', |
|
| 69 | - 'HKD', |
|
| 70 | - 'HUF', |
|
| 71 | - 'ILS', |
|
| 72 | - 'JPY', |
|
| 73 | - 'MYR', |
|
| 74 | - 'MXN', |
|
| 75 | - 'NOK', |
|
| 76 | - 'NZD', |
|
| 77 | - 'PHP', |
|
| 78 | - 'PLN', |
|
| 79 | - 'GBP', |
|
| 80 | - 'RUB', |
|
| 81 | - 'SGD', |
|
| 82 | - 'SEK', |
|
| 83 | - 'CHF', |
|
| 84 | - 'TWD', |
|
| 85 | - 'THB', |
|
| 86 | - 'TRY' |
|
| 87 | - ); |
|
| 88 | - parent::__construct(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
| 47 | + /** |
|
| 48 | + * gateway URL variable |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + protected $_base_gateway_url = ''; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * EEG_Paypal_Express constructor. |
|
| 58 | + */ |
|
| 59 | + public function __construct() |
|
| 60 | + { |
|
| 61 | + $this->_currencies_supported = array( |
|
| 62 | + 'USD', |
|
| 63 | + 'AUD', |
|
| 64 | + 'BRL', |
|
| 65 | + 'CAD', |
|
| 66 | + 'CZK', |
|
| 67 | + 'DKK', |
|
| 68 | + 'EUR', |
|
| 69 | + 'HKD', |
|
| 70 | + 'HUF', |
|
| 71 | + 'ILS', |
|
| 72 | + 'JPY', |
|
| 73 | + 'MYR', |
|
| 74 | + 'MXN', |
|
| 75 | + 'NOK', |
|
| 76 | + 'NZD', |
|
| 77 | + 'PHP', |
|
| 78 | + 'PLN', |
|
| 79 | + 'GBP', |
|
| 80 | + 'RUB', |
|
| 81 | + 'SGD', |
|
| 82 | + 'SEK', |
|
| 83 | + 'CHF', |
|
| 84 | + 'TWD', |
|
| 85 | + 'THB', |
|
| 86 | + 'TRY' |
|
| 87 | + ); |
|
| 88 | + parent::__construct(); |
|
| 89 | + } |
|
| 90 | + |
|
| 95 | 91 | |
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
| 96 | 95 | * |
| 97 | 96 | *@param array $settings_array |
| 98 | 97 | */ |
| 99 | 98 | public function set_settings( $settings_array ) { |
| 100 | 99 | parent::set_settings($settings_array); |
| 101 | 100 | // Redirect URL. |
| 102 | - $this->_base_gateway_url = $this->_debug_mode |
|
| 103 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
| 104 | - : 'https://api-3t.paypal.com/nvp'; |
|
| 101 | + $this->_base_gateway_url = $this->_debug_mode |
|
| 102 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
| 103 | + : 'https://api-3t.paypal.com/nvp'; |
|
| 105 | 104 | } |
| 106 | 105 | |
| 107 | 106 | |
| 108 | 107 | |
| 109 | - /** |
|
| 110 | - * @param EEI_Payment $payment |
|
| 111 | - * @param array $billing_info |
|
| 112 | - * @param string $return_url |
|
| 113 | - * @param string $notify_url |
|
| 114 | - * @param string $cancel_url |
|
| 115 | - * @return \EE_Payment|\EEI_Payment |
|
| 116 | - * @throws \EE_Error |
|
| 117 | - */ |
|
| 108 | + /** |
|
| 109 | + * @param EEI_Payment $payment |
|
| 110 | + * @param array $billing_info |
|
| 111 | + * @param string $return_url |
|
| 112 | + * @param string $notify_url |
|
| 113 | + * @param string $cancel_url |
|
| 114 | + * @return \EE_Payment|\EEI_Payment |
|
| 115 | + * @throws \EE_Error |
|
| 116 | + */ |
|
| 118 | 117 | public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
| 119 | 118 | if ( ! $payment instanceof EEI_Payment ) { |
| 120 | 119 | $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
@@ -202,9 +201,9 @@ discard block |
||
| 202 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
| 203 | 202 | // Item quantity. |
| 204 | 203 | $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
| 205 | - // Digital item is sold. |
|
| 206 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
| 207 | - $item_num++; |
|
| 204 | + // Digital item is sold. |
|
| 205 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
| 206 | + $item_num++; |
|
| 208 | 207 | } |
| 209 | 208 | } else { |
| 210 | 209 | // Just one Item. |
@@ -277,7 +276,6 @@ discard block |
||
| 277 | 276 | |
| 278 | 277 | |
| 279 | 278 | /** |
| 280 | - |
|
| 281 | 279 | * @param array $update_info { |
| 282 | 280 | * @type string $gateway_txn_id |
| 283 | 281 | * @type string status an EEMI_Payment status |
@@ -297,8 +295,8 @@ discard block |
||
| 297 | 295 | return $payment; |
| 298 | 296 | } |
| 299 | 297 | $primary_registrant = $transaction->primary_registration(); |
| 300 | - $payment_details = $payment->details(); |
|
| 301 | - // Check if we still have the token. |
|
| 298 | + $payment_details = $payment->details(); |
|
| 299 | + // Check if we still have the token. |
|
| 302 | 300 | if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
| 303 | 301 | $payment->set_status( $this->_pay_model->failed_status() ); |
| 304 | 302 | return $payment; |
@@ -407,36 +405,36 @@ discard block |
||
| 407 | 405 | */ |
| 408 | 406 | public function _ppExpress_check_response( $request_response ) { |
| 409 | 407 | if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
| 410 | - // If we got here then there was an error in this request. |
|
| 411 | - return array('status' => false, 'args' => $request_response); |
|
| 412 | - } |
|
| 413 | - $response_args = array(); |
|
| 414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
| 415 | - if ( ! isset($response_args['ACK'])) { |
|
| 416 | - return array('status' => false, 'args' => $request_response); |
|
| 417 | - } |
|
| 418 | - if ( |
|
| 419 | - $response_args['ACK'] === 'Success' |
|
| 420 | - && ( |
|
| 421 | - isset($response_args['PAYERID']) |
|
| 422 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 423 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
| 424 | - || isset($response_args['TOKEN']) |
|
| 425 | - ) |
|
| 426 | - ) { |
|
| 427 | - // Response status OK, return response parameters for further processing. |
|
| 428 | - return array('status' => true, 'args' => $response_args); |
|
| 429 | - } else { |
|
| 430 | - $errors = $this->_get_errors($response_args); |
|
| 431 | - return array('status' => false, 'args' => $errors); |
|
| 432 | - } |
|
| 408 | + // If we got here then there was an error in this request. |
|
| 409 | + return array('status' => false, 'args' => $request_response); |
|
| 410 | + } |
|
| 411 | + $response_args = array(); |
|
| 412 | + parse_str( urldecode($request_response['body']), $response_args ); |
|
| 413 | + if ( ! isset($response_args['ACK'])) { |
|
| 414 | + return array('status' => false, 'args' => $request_response); |
|
| 415 | + } |
|
| 416 | + if ( |
|
| 417 | + $response_args['ACK'] === 'Success' |
|
| 418 | + && ( |
|
| 419 | + isset($response_args['PAYERID']) |
|
| 420 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 421 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
| 422 | + || isset($response_args['TOKEN']) |
|
| 423 | + ) |
|
| 424 | + ) { |
|
| 425 | + // Response status OK, return response parameters for further processing. |
|
| 426 | + return array('status' => true, 'args' => $response_args); |
|
| 427 | + } else { |
|
| 428 | + $errors = $this->_get_errors($response_args); |
|
| 429 | + return array('status' => false, 'args' => $errors); |
|
| 430 | + } |
|
| 433 | 431 | } |
| 434 | 432 | |
| 435 | 433 | |
| 436 | 434 | /** |
| 437 | - * Log a "Cleared" request. |
|
| 438 | - * |
|
| 439 | - * @param array $request |
|
| 435 | + * Log a "Cleared" request. |
|
| 436 | + * |
|
| 437 | + * @param array $request |
|
| 440 | 438 | * @param EEI_Payment $payment |
| 441 | 439 | * @param string $info |
| 442 | 440 | * @return void |
@@ -459,17 +457,17 @@ discard block |
||
| 459 | 457 | $n = 0; |
| 460 | 458 | while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
| 461 | 459 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
| 462 | - ? $data_array["L_ERRORCODE{$n}"] |
|
| 463 | - : ''; |
|
| 460 | + ? $data_array["L_ERRORCODE{$n}"] |
|
| 461 | + : ''; |
|
| 464 | 462 | $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
| 465 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
| 466 | - : ''; |
|
| 463 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
| 464 | + : ''; |
|
| 467 | 465 | $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
| 468 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
| 469 | - : ''; |
|
| 466 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
| 467 | + : ''; |
|
| 470 | 468 | $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
| 471 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
| 472 | - : ''; |
|
| 469 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
| 470 | + : ''; |
|
| 473 | 471 | |
| 474 | 472 | if ( $n === 0 ) { |
| 475 | 473 | $errors = array( |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * Gets the html "type" attribute's value |
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | - public function get_type(){ |
|
| 37 | + public function get_type(){ |
|
| 38 | 38 | if ( |
| 39 | 39 | $this->_type === 'email' |
| 40 | 40 | && ! apply_filters( 'FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false ) |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string of html to display the field |
| 52 | 52 | */ |
| 53 | - public function display(){ |
|
| 53 | + public function display(){ |
|
| 54 | 54 | $input = '<input type="'. $this->get_type() .'"'; |
| 55 | 55 | $input .= ' name="' . $this->_input->html_name() . '"'; |
| 56 | 56 | $input .= ' id="' . $this->_input->html_id() . '"'; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @since 4.6 |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base{ |
|
| 14 | +class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base { |
|
| 15 | 15 | /** |
| 16 | 16 | * The html "type" attribute value. default is "text" |
| 17 | 17 | * @var string |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @param string $type |
| 25 | 25 | */ |
| 26 | - public function __construct( $type = 'text' ) { |
|
| 26 | + public function __construct($type = 'text') { |
|
| 27 | 27 | $this->_type = $type; |
| 28 | 28 | parent::__construct(); |
| 29 | 29 | } |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * Gets the html "type" attribute's value |
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | - public function get_type(){ |
|
| 37 | + public function get_type() { |
|
| 38 | 38 | if ( |
| 39 | 39 | $this->_type === 'email' |
| 40 | - && ! apply_filters( 'FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false ) |
|
| 40 | + && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
| 41 | 41 | ) { |
| 42 | 42 | return 'text'; |
| 43 | 43 | } |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string of html to display the field |
| 52 | 52 | */ |
| 53 | - public function display(){ |
|
| 54 | - $input = '<input type="'. $this->get_type() .'"'; |
|
| 55 | - $input .= ' name="' . $this->_input->html_name() . '"'; |
|
| 56 | - $input .= ' id="' . $this->_input->html_id() . '"'; |
|
| 57 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
| 58 | - $input .= ' class="' . $class . '"'; |
|
| 53 | + public function display() { |
|
| 54 | + $input = '<input type="'.$this->get_type().'"'; |
|
| 55 | + $input .= ' name="'.$this->_input->html_name().'"'; |
|
| 56 | + $input .= ' id="'.$this->_input->html_id().'"'; |
|
| 57 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
| 58 | + $input .= ' class="'.$class.'"'; |
|
| 59 | 59 | // add html5 required |
| 60 | 60 | $input .= $this->_input->required() ? ' required' : ''; |
| 61 | - $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
| 62 | - $input .= ' style="' . $this->_input->html_style() . '"'; |
|
| 61 | + $input .= ' value="'.$this->_input->raw_value_in_form().'"'; |
|
| 62 | + $input .= ' style="'.$this->_input->html_style().'"'; |
|
| 63 | 63 | $input .= $this->_input->other_html_attributes(); |
| 64 | 64 | $input .= '/>'; |
| 65 | 65 | return $input; |
@@ -15,37 +15,37 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @param array $input_settings |
|
| 20 | - */ |
|
| 21 | - public function __construct($input_settings = array()) |
|
| 22 | - { |
|
| 23 | - $this->_set_display_strategy( |
|
| 24 | - new EE_Number_Input_Display_Strategy( |
|
| 25 | - isset($input_settings['min_value']) |
|
| 26 | - ? $input_settings['min_value'] |
|
| 27 | - : null, |
|
| 28 | - isset($input_settings['max_value']) |
|
| 29 | - ? $input_settings['max_value'] |
|
| 30 | - : null |
|
| 31 | - ) |
|
| 32 | - ); |
|
| 33 | - $this->_set_normalization_strategy( |
|
| 34 | - new EE_Int_Normalization( |
|
| 35 | - isset($input_settings['validation_error_message']) |
|
| 36 | - ? $input_settings['validation_error_message'] |
|
| 37 | - : null |
|
| 38 | - ) |
|
| 39 | - ); |
|
| 40 | - $this->_add_validation_strategy( |
|
| 41 | - new EE_Int_Validation_Strategy( |
|
| 42 | - isset($input_settings['validation_error_message']) |
|
| 43 | - ? $input_settings['validation_error_message'] |
|
| 44 | - : null |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - parent::__construct($input_settings); |
|
| 48 | - } |
|
| 18 | + /** |
|
| 19 | + * @param array $input_settings |
|
| 20 | + */ |
|
| 21 | + public function __construct($input_settings = array()) |
|
| 22 | + { |
|
| 23 | + $this->_set_display_strategy( |
|
| 24 | + new EE_Number_Input_Display_Strategy( |
|
| 25 | + isset($input_settings['min_value']) |
|
| 26 | + ? $input_settings['min_value'] |
|
| 27 | + : null, |
|
| 28 | + isset($input_settings['max_value']) |
|
| 29 | + ? $input_settings['max_value'] |
|
| 30 | + : null |
|
| 31 | + ) |
|
| 32 | + ); |
|
| 33 | + $this->_set_normalization_strategy( |
|
| 34 | + new EE_Int_Normalization( |
|
| 35 | + isset($input_settings['validation_error_message']) |
|
| 36 | + ? $input_settings['validation_error_message'] |
|
| 37 | + : null |
|
| 38 | + ) |
|
| 39 | + ); |
|
| 40 | + $this->_add_validation_strategy( |
|
| 41 | + new EE_Int_Validation_Strategy( |
|
| 42 | + isset($input_settings['validation_error_message']) |
|
| 43 | + ? $input_settings['validation_error_message'] |
|
| 44 | + : null |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + parent::__construct($input_settings); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | // End of file EE_Integer_Input.php |
@@ -16,6 +16,6 @@ |
||
| 16 | 16 | $this->_set_normalization_strategy(new EE_Float_Normalization( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
| 17 | 17 | $this->_add_validation_strategy( new EE_Float_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
| 18 | 18 | parent::__construct($input_settings); |
| 19 | - $this->_other_html_attributes .= ' step="any"'; |
|
| 19 | + $this->_other_html_attributes .= ' step="any"'; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Float_Input extends EE_Form_Input_Base{ |
|
| 9 | +class EE_Float_Input extends EE_Form_Input_Base { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param array $input_settings |
| 13 | 13 | */ |
| 14 | - function __construct($input_settings = array()){ |
|
| 14 | + function __construct($input_settings = array()) { |
|
| 15 | 15 | $this->_set_display_strategy(new EE_Number_Input_Display_Strategy()); |
| 16 | - $this->_set_normalization_strategy(new EE_Float_Normalization( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
| 17 | - $this->_add_validation_strategy( new EE_Float_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
| 16 | + $this->_set_normalization_strategy(new EE_Float_Normalization(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
| 17 | + $this->_add_validation_strategy(new EE_Float_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
| 18 | 18 | parent::__construct($input_settings); |
| 19 | 19 | $this->_other_html_attributes .= ' step="any"'; |
| 20 | 20 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function _append_chars($string = '', $chars = '-') |
| 63 | 63 | { |
| 64 | - return $this->_remove_chars($string, $chars) . $chars; |
|
| 64 | + return $this->_remove_chars($string, $chars).$chars; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -16,229 +16,229 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var string $_tag |
|
| 21 | - */ |
|
| 22 | - protected $_tag = ''; |
|
| 19 | + /** |
|
| 20 | + * @var string $_tag |
|
| 21 | + */ |
|
| 22 | + protected $_tag = ''; |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * returns HTML and javascript related to the displaying of this input |
|
| 30 | - * |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - abstract public function display(); |
|
| 28 | + /** |
|
| 29 | + * returns HTML and javascript related to the displaying of this input |
|
| 30 | + * |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + abstract public function display(); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
| 39 | - * is already there |
|
| 40 | - * |
|
| 41 | - * @param string $string - the string being processed |
|
| 42 | - * @param string $chars - exact string of characters to remove |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - protected function _remove_chars($string = '', $chars = '-') |
|
| 46 | - { |
|
| 47 | - $char_length = strlen($chars) * -1; |
|
| 48 | - // if last three characters of string is " - ", then remove it |
|
| 49 | - return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
| 50 | - } |
|
| 37 | + /** |
|
| 38 | + * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
| 39 | + * is already there |
|
| 40 | + * |
|
| 41 | + * @param string $string - the string being processed |
|
| 42 | + * @param string $chars - exact string of characters to remove |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + protected function _remove_chars($string = '', $chars = '-') |
|
| 46 | + { |
|
| 47 | + $char_length = strlen($chars) * -1; |
|
| 48 | + // if last three characters of string is " - ", then remove it |
|
| 49 | + return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
| 56 | - * already there |
|
| 57 | - * |
|
| 58 | - * @param string $string - the string being processed |
|
| 59 | - * @param string $chars - exact string of characters to be added to end of string |
|
| 60 | - * @return string |
|
| 61 | - */ |
|
| 62 | - protected function _append_chars($string = '', $chars = '-') |
|
| 63 | - { |
|
| 64 | - return $this->_remove_chars($string, $chars) . $chars; |
|
| 65 | - } |
|
| 54 | + /** |
|
| 55 | + * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
| 56 | + * already there |
|
| 57 | + * |
|
| 58 | + * @param string $string - the string being processed |
|
| 59 | + * @param string $chars - exact string of characters to be added to end of string |
|
| 60 | + * @return string |
|
| 61 | + */ |
|
| 62 | + protected function _append_chars($string = '', $chars = '-') |
|
| 63 | + { |
|
| 64 | + return $this->_remove_chars($string, $chars) . $chars; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Gets the HTML IDs of all the inputs |
|
| 71 | - * |
|
| 72 | - * @param bool $add_pound_sign |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - public function get_html_input_ids($add_pound_sign = false) |
|
| 76 | - { |
|
| 77 | - return array($this->get_input()->html_id($add_pound_sign)); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Adds js variables for localization to the $other_js_data. These should be put |
|
| 84 | - * in each form's "other_data" javascript object. |
|
| 85 | - * |
|
| 86 | - * @param array $other_js_data |
|
| 87 | - * @return array |
|
| 88 | - */ |
|
| 89 | - public function get_other_js_data($other_js_data = array()) |
|
| 90 | - { |
|
| 91 | - return $other_js_data; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
| 98 | - * This should be called during wp_enqueue_scripts |
|
| 99 | - */ |
|
| 100 | - public function enqueue_js() |
|
| 101 | - { |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * returns string like: '<tag' |
|
| 108 | - * |
|
| 109 | - * @param string $tag |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 112 | - protected function _opening_tag($tag) |
|
| 113 | - { |
|
| 114 | - $this->_tag = $tag; |
|
| 115 | - return "<{$this->_tag}"; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * returns string like: '</tag> |
|
| 122 | - * |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - protected function _closing_tag() |
|
| 126 | - { |
|
| 127 | - return "</{$this->_tag}>"; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * returns string like: '/>' |
|
| 134 | - * |
|
| 135 | - * @return string |
|
| 136 | - */ |
|
| 137 | - protected function _close_tag() |
|
| 138 | - { |
|
| 139 | - return '/>'; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
| 146 | - * where string keys represent named attributes like id, class, etc |
|
| 147 | - * and numeric keys represent single attributes like 'required'. |
|
| 148 | - * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
| 149 | - * it. |
|
| 150 | - * |
|
| 151 | - * @return array |
|
| 152 | - */ |
|
| 153 | - protected function _standard_attributes_array() |
|
| 154 | - { |
|
| 155 | - return array( |
|
| 156 | - 'name' => $this->_input->html_name(), |
|
| 157 | - 'id' => $this->_input->html_id(), |
|
| 158 | - 'class' => $this->_input->html_class(true), |
|
| 159 | - 0 => array('required', $this->_input->required()), |
|
| 160 | - 1 => $this->_input->other_html_attributes(), |
|
| 161 | - 'style' => $this->_input->html_style(), |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * sets the attributes using the incoming array |
|
| 169 | - * and returns a string of all attributes rendered as valid HTML |
|
| 170 | - * |
|
| 171 | - * @param array $attributes |
|
| 172 | - * @return string |
|
| 173 | - */ |
|
| 174 | - protected function _attributes_string($attributes = array()) |
|
| 175 | - { |
|
| 176 | - $attributes = apply_filters( |
|
| 177 | - 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
| 178 | - $attributes, |
|
| 179 | - $this, |
|
| 180 | - $this->_input |
|
| 181 | - ); |
|
| 182 | - $attributes_string = ''; |
|
| 183 | - foreach ($attributes as $attribute => $value) { |
|
| 184 | - if (is_numeric($attribute)) { |
|
| 185 | - $add = true; |
|
| 186 | - if (is_array($value)) { |
|
| 187 | - $attribute = isset($value[0]) ? $value[0] : ''; |
|
| 188 | - $add = isset($value[1]) ? $value[1] : false; |
|
| 189 | - } else { |
|
| 190 | - $attribute = $value; |
|
| 191 | - } |
|
| 192 | - $attributes_string .= $this->_single_attribute($attribute, $add); |
|
| 193 | - } else { |
|
| 194 | - $attributes_string .= $this->_attribute($attribute, $value); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - return $attributes_string; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * returns string like: ' attribute="value"' |
|
| 204 | - * returns an empty string if $value is null |
|
| 205 | - * |
|
| 206 | - * @param string $attribute |
|
| 207 | - * @param string $value |
|
| 208 | - * @return string |
|
| 209 | - */ |
|
| 210 | - protected function _attribute($attribute, $value = '') |
|
| 211 | - { |
|
| 212 | - return $value !== null ? " {$attribute}=\"{$value}\"" : ''; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * returns string like: ' data-attribute="value"' |
|
| 219 | - * returns an empty string if $value is null |
|
| 220 | - * |
|
| 221 | - * @param string $attribute |
|
| 222 | - * @param string $value |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - protected function _data_attribute($attribute, $value = '') |
|
| 226 | - { |
|
| 227 | - return $value !== null ? " data-{$attribute}=\"{$value}\"" : ''; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * returns string like: ' attribute' if $add is true |
|
| 234 | - * |
|
| 235 | - * @param string $attribute |
|
| 236 | - * @param boolean $add |
|
| 237 | - * @return string |
|
| 238 | - */ |
|
| 239 | - protected function _single_attribute($attribute, $add = true) |
|
| 240 | - { |
|
| 241 | - return $add ? " {$attribute}" : ''; |
|
| 242 | - } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Gets the HTML IDs of all the inputs |
|
| 71 | + * |
|
| 72 | + * @param bool $add_pound_sign |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + public function get_html_input_ids($add_pound_sign = false) |
|
| 76 | + { |
|
| 77 | + return array($this->get_input()->html_id($add_pound_sign)); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Adds js variables for localization to the $other_js_data. These should be put |
|
| 84 | + * in each form's "other_data" javascript object. |
|
| 85 | + * |
|
| 86 | + * @param array $other_js_data |
|
| 87 | + * @return array |
|
| 88 | + */ |
|
| 89 | + public function get_other_js_data($other_js_data = array()) |
|
| 90 | + { |
|
| 91 | + return $other_js_data; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
| 98 | + * This should be called during wp_enqueue_scripts |
|
| 99 | + */ |
|
| 100 | + public function enqueue_js() |
|
| 101 | + { |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * returns string like: '<tag' |
|
| 108 | + * |
|
| 109 | + * @param string $tag |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | + protected function _opening_tag($tag) |
|
| 113 | + { |
|
| 114 | + $this->_tag = $tag; |
|
| 115 | + return "<{$this->_tag}"; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * returns string like: '</tag> |
|
| 122 | + * |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + protected function _closing_tag() |
|
| 126 | + { |
|
| 127 | + return "</{$this->_tag}>"; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * returns string like: '/>' |
|
| 134 | + * |
|
| 135 | + * @return string |
|
| 136 | + */ |
|
| 137 | + protected function _close_tag() |
|
| 138 | + { |
|
| 139 | + return '/>'; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
| 146 | + * where string keys represent named attributes like id, class, etc |
|
| 147 | + * and numeric keys represent single attributes like 'required'. |
|
| 148 | + * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
| 149 | + * it. |
|
| 150 | + * |
|
| 151 | + * @return array |
|
| 152 | + */ |
|
| 153 | + protected function _standard_attributes_array() |
|
| 154 | + { |
|
| 155 | + return array( |
|
| 156 | + 'name' => $this->_input->html_name(), |
|
| 157 | + 'id' => $this->_input->html_id(), |
|
| 158 | + 'class' => $this->_input->html_class(true), |
|
| 159 | + 0 => array('required', $this->_input->required()), |
|
| 160 | + 1 => $this->_input->other_html_attributes(), |
|
| 161 | + 'style' => $this->_input->html_style(), |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * sets the attributes using the incoming array |
|
| 169 | + * and returns a string of all attributes rendered as valid HTML |
|
| 170 | + * |
|
| 171 | + * @param array $attributes |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 174 | + protected function _attributes_string($attributes = array()) |
|
| 175 | + { |
|
| 176 | + $attributes = apply_filters( |
|
| 177 | + 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
| 178 | + $attributes, |
|
| 179 | + $this, |
|
| 180 | + $this->_input |
|
| 181 | + ); |
|
| 182 | + $attributes_string = ''; |
|
| 183 | + foreach ($attributes as $attribute => $value) { |
|
| 184 | + if (is_numeric($attribute)) { |
|
| 185 | + $add = true; |
|
| 186 | + if (is_array($value)) { |
|
| 187 | + $attribute = isset($value[0]) ? $value[0] : ''; |
|
| 188 | + $add = isset($value[1]) ? $value[1] : false; |
|
| 189 | + } else { |
|
| 190 | + $attribute = $value; |
|
| 191 | + } |
|
| 192 | + $attributes_string .= $this->_single_attribute($attribute, $add); |
|
| 193 | + } else { |
|
| 194 | + $attributes_string .= $this->_attribute($attribute, $value); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + return $attributes_string; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * returns string like: ' attribute="value"' |
|
| 204 | + * returns an empty string if $value is null |
|
| 205 | + * |
|
| 206 | + * @param string $attribute |
|
| 207 | + * @param string $value |
|
| 208 | + * @return string |
|
| 209 | + */ |
|
| 210 | + protected function _attribute($attribute, $value = '') |
|
| 211 | + { |
|
| 212 | + return $value !== null ? " {$attribute}=\"{$value}\"" : ''; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * returns string like: ' data-attribute="value"' |
|
| 219 | + * returns an empty string if $value is null |
|
| 220 | + * |
|
| 221 | + * @param string $attribute |
|
| 222 | + * @param string $value |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + protected function _data_attribute($attribute, $value = '') |
|
| 226 | + { |
|
| 227 | + return $value !== null ? " data-{$attribute}=\"{$value}\"" : ''; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * returns string like: ' attribute' if $add is true |
|
| 234 | + * |
|
| 235 | + * @param string $attribute |
|
| 236 | + * @param boolean $add |
|
| 237 | + * @return string |
|
| 238 | + */ |
|
| 239 | + protected function _single_attribute($attribute, $add = true) |
|
| 240 | + { |
|
| 241 | + return $add ? " {$attribute}" : ''; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | 244 | } |
| 245 | 245 | \ No newline at end of file |
@@ -9,40 +9,40 @@ |
||
| 9 | 9 | abstract class EE_Form_Input_Strategy_Base |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Form Input to display |
|
| 14 | - * |
|
| 15 | - * @var EE_Form_Input_Base |
|
| 16 | - */ |
|
| 17 | - protected $_input; |
|
| 12 | + /** |
|
| 13 | + * Form Input to display |
|
| 14 | + * |
|
| 15 | + * @var EE_Form_Input_Base |
|
| 16 | + */ |
|
| 17 | + protected $_input; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - } |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * The form input on which this strategy is to perform |
|
| 29 | - * |
|
| 30 | - * @param EE_Form_Input_Base $form_input |
|
| 31 | - */ |
|
| 32 | - public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
| 33 | - { |
|
| 34 | - $this->_input = $form_input; |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * The form input on which this strategy is to perform |
|
| 29 | + * |
|
| 30 | + * @param EE_Form_Input_Base $form_input |
|
| 31 | + */ |
|
| 32 | + public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
| 33 | + { |
|
| 34 | + $this->_input = $form_input; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Gets this strategy's input |
|
| 41 | - * |
|
| 42 | - * @return EE_Form_Input_Base |
|
| 43 | - */ |
|
| 44 | - public function get_input() |
|
| 45 | - { |
|
| 46 | - return $this->_input; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Gets this strategy's input |
|
| 41 | + * |
|
| 42 | + * @return EE_Form_Input_Base |
|
| 43 | + */ |
|
| 44 | + public function get_input() |
|
| 45 | + { |
|
| 46 | + return $this->_input; |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | * date_format and the second value is the time format |
| 38 | 38 | * @return EE_Question |
| 39 | 39 | */ |
| 40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
| 41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
| 42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
| 40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
| 41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * the website will be used. |
| 51 | 51 | * @return EE_Question |
| 52 | 52 | */ |
| 53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
| 54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
| 53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
| 54 | + return new self($props_n_values, TRUE, $timezone); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | * @access public |
| 63 | 63 | * @param string $QST_display_text |
| 64 | 64 | */ |
| 65 | - public function set_display_text( $QST_display_text = '' ) { |
|
| 66 | - $this->set( 'QST_display_text', $QST_display_text ); |
|
| 65 | + public function set_display_text($QST_display_text = '') { |
|
| 66 | + $this->set('QST_display_text', $QST_display_text); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @access public |
| 75 | 75 | * @param string $QST_admin_label |
| 76 | 76 | */ |
| 77 | - public function set_admin_label( $QST_admin_label = '' ) { |
|
| 78 | - $this->set( 'QST_admin_label', $QST_admin_label ); |
|
| 77 | + public function set_admin_label($QST_admin_label = '') { |
|
| 78 | + $this->set('QST_admin_label', $QST_admin_label); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * @access public |
| 87 | 87 | * @param mixed $QST_system |
| 88 | 88 | */ |
| 89 | - public function set_system_ID( $QST_system = '' ) { |
|
| 90 | - $this->set( 'QST_system', $QST_system ); |
|
| 89 | + public function set_system_ID($QST_system = '') { |
|
| 90 | + $this->set('QST_system', $QST_system); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * @access public |
| 99 | 99 | * @param string $QST_type |
| 100 | 100 | */ |
| 101 | - public function set_question_type( $QST_type = '' ) { |
|
| 102 | - $this->set( 'QST_type', $QST_type ); |
|
| 101 | + public function set_question_type($QST_type = '') { |
|
| 102 | + $this->set('QST_type', $QST_type); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * @access public |
| 111 | 111 | * @param bool $QST_required |
| 112 | 112 | */ |
| 113 | - public function set_required( $QST_required = FALSE ) { |
|
| 114 | - $this->set( 'QST_required', $QST_required ); |
|
| 113 | + public function set_required($QST_required = FALSE) { |
|
| 114 | + $this->set('QST_required', $QST_required); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * @access public |
| 123 | 123 | * @param string $QST_required_text |
| 124 | 124 | */ |
| 125 | - public function set_required_text( $QST_required_text = '' ) { |
|
| 126 | - $this->set( 'QST_required_text', $QST_required_text ); |
|
| 125 | + public function set_required_text($QST_required_text = '') { |
|
| 126 | + $this->set('QST_required_text', $QST_required_text); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @access public |
| 135 | 135 | * @param int $QST_order |
| 136 | 136 | */ |
| 137 | - public function set_order( $QST_order = 0 ) { |
|
| 138 | - $this->set( 'QST_order', $QST_order ); |
|
| 137 | + public function set_order($QST_order = 0) { |
|
| 138 | + $this->set('QST_order', $QST_order); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * @access public |
| 147 | 147 | * @param bool $QST_admin_only |
| 148 | 148 | */ |
| 149 | - public function set_admin_only( $QST_admin_only = FALSE ) { |
|
| 150 | - $this->set( 'QST_admin_only', $QST_admin_only ); |
|
| 149 | + public function set_admin_only($QST_admin_only = FALSE) { |
|
| 150 | + $this->set('QST_admin_only', $QST_admin_only); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @access public |
| 159 | 159 | * @param int $QST_wp_user |
| 160 | 160 | */ |
| 161 | - public function set_wp_user( $QST_wp_user = 1 ) { |
|
| 162 | - $this->set( 'QST_wp_user', $QST_wp_user ); |
|
| 161 | + public function set_wp_user($QST_wp_user = 1) { |
|
| 162 | + $this->set('QST_wp_user', $QST_wp_user); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | * @access public |
| 176 | 176 | * @param bool $QST_deleted |
| 177 | 177 | */ |
| 178 | - public function set_deleted( $QST_deleted = FALSE ) { |
|
| 179 | - $this->set( 'QST_deleted', $QST_deleted ); |
|
| 178 | + public function set_deleted($QST_deleted = FALSE) { |
|
| 179 | + $this->set('QST_deleted', $QST_deleted); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | 189 | public function display_text() { |
| 190 | - return $this->get( 'QST_display_text' ); |
|
| 190 | + return $this->get('QST_display_text'); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | 200 | public function admin_label() { |
| 201 | - return $this->get( 'QST_admin_label' ); |
|
| 201 | + return $this->get('QST_admin_label'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | 211 | public function system_ID() { |
| 212 | - return $this->get( 'QST_system' ); |
|
| 212 | + return $this->get('QST_system'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @return boolean |
| 221 | 221 | */ |
| 222 | 222 | public function required() { |
| 223 | - return $this->get( 'QST_required' ); |
|
| 223 | + return $this->get('QST_required'); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @return string |
| 233 | 233 | */ |
| 234 | 234 | public function required_text() { |
| 235 | - return $this->get( 'QST_required_text' ); |
|
| 235 | + return $this->get('QST_required_text'); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | 245 | public function type() { |
| 246 | - return $this->get( 'QST_type' ); |
|
| 246 | + return $this->get('QST_type'); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @return int |
| 256 | 256 | */ |
| 257 | 257 | public function order() { |
| 258 | - return $this->get( 'QST_order' ); |
|
| 258 | + return $this->get('QST_order'); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @return boolean |
| 268 | 268 | */ |
| 269 | 269 | public function admin_only() { |
| 270 | - return $this->get( 'QST_admin_only' ); |
|
| 270 | + return $this->get('QST_admin_only'); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @return int |
| 279 | 279 | */ |
| 280 | 280 | public function wp_user() { |
| 281 | - return $this->get( 'QST_wp_user' ); |
|
| 281 | + return $this->get('QST_wp_user'); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @return boolean |
| 290 | 290 | */ |
| 291 | 291 | public function deleted() { |
| 292 | - return $this->get( 'QST_deleted' ); |
|
| 292 | + return $this->get('QST_deleted'); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return EE_Answer[] |
| 300 | 300 | */ |
| 301 | 301 | public function answers() { |
| 302 | - return $this->get_many_related( 'Answer' ); |
|
| 302 | + return $this->get_many_related('Answer'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @return boolean true = has answers, false = no answers. |
| 310 | 310 | */ |
| 311 | 311 | public function has_answers() { |
| 312 | - return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE; |
|
| 312 | + return $this->count_related('Answer') > 0 ? TRUE : FALSE; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @return EE_Question_Group[] |
| 320 | 320 | */ |
| 321 | 321 | public function question_groups() { |
| 322 | - return $this->get_many_related( 'Question_Group' ); |
|
| 322 | + return $this->get_many_related('Question_Group'); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -333,24 +333,24 @@ discard block |
||
| 333 | 333 | * whether it was trashed or not. |
| 334 | 334 | * @return EE_Question_Option[] |
| 335 | 335 | */ |
| 336 | - public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) { |
|
| 337 | - if ( ! $this->ID() ) { |
|
| 336 | + public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) { |
|
| 337 | + if ( ! $this->ID()) { |
|
| 338 | 338 | return array(); |
| 339 | 339 | } |
| 340 | 340 | $query_params = array(); |
| 341 | - if ( $selected_value_to_always_include ) { |
|
| 342 | - if ( is_array( $selected_value_to_always_include ) ) { |
|
| 343 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include ); |
|
| 341 | + if ($selected_value_to_always_include) { |
|
| 342 | + if (is_array($selected_value_to_always_include)) { |
|
| 343 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
| 344 | 344 | } else { |
| 345 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include; |
|
| 345 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | - if ( $notDeletedOptionsOnly ) { |
|
| 349 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE; |
|
| 348 | + if ($notDeletedOptionsOnly) { |
|
| 349 | + $query_params[0]['OR*options-query']['QSO_deleted'] = FALSE; |
|
| 350 | 350 | } |
| 351 | 351 | //order by QSO_order |
| 352 | - $query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' ); |
|
| 353 | - return $this->get_many_related( 'Question_Option', $query_params ); |
|
| 352 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
| 353 | + return $this->get_many_related('Question_Option', $query_params); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * @return \EE_Question_Option[] |
| 361 | 361 | */ |
| 362 | 362 | public function temp_options() { |
| 363 | - return $this->_model_relations[ 'Question_Option' ]; |
|
| 363 | + return $this->_model_relations['Question_Option']; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | * @param EE_Question_Option $option |
| 372 | 372 | * @return boolean success |
| 373 | 373 | */ |
| 374 | - public function add_option( EE_Question_Option $option ) { |
|
| 375 | - return $this->_add_relation_to( $option, 'Question_Option' ); |
|
| 374 | + public function add_option(EE_Question_Option $option) { |
|
| 375 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * @param EE_Question_Option $option |
| 383 | 383 | * @return boolean success |
| 384 | 384 | */ |
| 385 | - public function add_temp_option( EE_Question_Option $option ) { |
|
| 386 | - $this->_model_relations[ 'Question_Option' ][ ] = $option; |
|
| 385 | + public function add_temp_option(EE_Question_Option $option) { |
|
| 386 | + $this->_model_relations['Question_Option'][] = $option; |
|
| 387 | 387 | return TRUE; |
| 388 | 388 | } |
| 389 | 389 | |
@@ -394,8 +394,8 @@ discard block |
||
| 394 | 394 | * @param EE_Question_Option $option |
| 395 | 395 | * @return boolean success |
| 396 | 396 | */ |
| 397 | - public function remove_option( EE_Question_Option $option ) { |
|
| 398 | - return $this->_remove_relation_to( $option, 'Question_Option' ); |
|
| 397 | + public function remove_option(EE_Question_Option $option) { |
|
| 398 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @return bool |
| 405 | 405 | */ |
| 406 | 406 | public function is_system_question() { |
| 407 | - $system_ID = $this->get( 'QST_system' ); |
|
| 408 | - return ! empty( $system_ID ) ? TRUE : FALSE; |
|
| 407 | + $system_ID = $this->get('QST_system'); |
|
| 408 | + return ! empty($system_ID) ? TRUE : FALSE; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function set_order_to_latest() { |
| 420 | 420 | $latest_order = $this->get_model()->get_latest_question_order(); |
| 421 | - $latest_order ++; |
|
| 422 | - $this->set( 'QST_order', $latest_order ); |
|
| 421 | + $latest_order++; |
|
| 422 | + $this->set('QST_order', $latest_order); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -438,20 +438,20 @@ discard block |
||
| 438 | 438 | * Duplicates this question and its question options |
| 439 | 439 | * @return \EE_Question |
| 440 | 440 | */ |
| 441 | - public function duplicate( $options = array() ) { |
|
| 441 | + public function duplicate($options = array()) { |
|
| 442 | 442 | $new_question = clone $this; |
| 443 | - $new_question->set( 'QST_ID', null ); |
|
| 444 | - $new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) ); |
|
| 445 | - $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
|
| 446 | - $new_question->set_system_ID( null ); |
|
| 447 | - $new_question->set_wp_user( get_current_user_id() ); |
|
| 443 | + $new_question->set('QST_ID', null); |
|
| 444 | + $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
| 445 | + $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
| 446 | + $new_question->set_system_ID(null); |
|
| 447 | + $new_question->set_wp_user(get_current_user_id()); |
|
| 448 | 448 | //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
| 449 | - $new_question->set_deleted( false ); |
|
| 449 | + $new_question->set_deleted(false); |
|
| 450 | 450 | $success = $new_question->save(); |
| 451 | - if( $success ) { |
|
| 451 | + if ($success) { |
|
| 452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
| 453 | - foreach( $this->options() as $question_option ) { |
|
| 454 | - $question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) ); |
|
| 453 | + foreach ($this->options() as $question_option) { |
|
| 454 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
| 455 | 455 | } |
| 456 | 456 | return $new_question; |
| 457 | 457 | } else { |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @return int|float |
| 465 | 465 | */ |
| 466 | 466 | public function max() { |
| 467 | - return $this->get( 'QST_max' ); |
|
| 467 | + return $this->get('QST_max'); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | * @param int|float $new_max |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function set_max( $new_max ) { |
|
| 476 | - $this->set( 'QST_max', $new_max ); |
|
| 475 | + public function set_max($new_max) { |
|
| 476 | + $this->set('QST_max', $new_max); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * @param array $input_constructor_args |
| 486 | 486 | * @return EE_Form_Input_Base |
| 487 | 487 | */ |
| 488 | - public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) { |
|
| 488 | + public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) { |
|
| 489 | 489 | $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
| 490 | 490 | |
| 491 | 491 | $input_constructor_args = array_merge( |
@@ -496,29 +496,29 @@ discard block |
||
| 496 | 496 | ), |
| 497 | 497 | $input_constructor_args |
| 498 | 498 | ); |
| 499 | - if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) { |
|
| 500 | - $answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() ); |
|
| 499 | + if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
| 500 | + $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
| 501 | 501 | } |
| 502 | 502 | // has this question been answered ? |
| 503 | - if ( $answer instanceof EE_Answer |
|
| 503 | + if ($answer instanceof EE_Answer |
|
| 504 | 504 | && $answer->value() !== '' |
| 505 | 505 | ) { |
| 506 | 506 | //answer gets htmlspecialchars called on it, undo that please |
| 507 | 507 | //because the form input's display strategy may call esc_attr too |
| 508 | 508 | //which also does html special characters |
| 509 | 509 | $values_with_html_special_chars = $answer->value(); |
| 510 | - if( is_array( $values_with_html_special_chars ) ) { |
|
| 511 | - $default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars ); |
|
| 510 | + if (is_array($values_with_html_special_chars)) { |
|
| 511 | + $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
| 512 | 512 | } else { |
| 513 | - $default_value = htmlspecialchars_decode( $values_with_html_special_chars ); |
|
| 513 | + $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
| 514 | 514 | } |
| 515 | 515 | $input_constructor_args['default'] = $default_value; |
| 516 | 516 | } |
| 517 | - $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() ); |
|
| 518 | - if( EEM_Question::instance()->question_type_is_in_category( $this->type(), 'text' ) ) { |
|
| 519 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy( |
|
| 517 | + $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
| 518 | + if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) { |
|
| 519 | + $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
| 520 | 520 | null, |
| 521 | - min( $max_max_for_question, $this->max() ) |
|
| 521 | + min($max_max_for_question, $this->max()) |
|
| 522 | 522 | ); |
| 523 | 523 | } |
| 524 | 524 | $input_constructor_args = apply_filters( |
@@ -530,22 +530,22 @@ discard block |
||
| 530 | 530 | ); |
| 531 | 531 | |
| 532 | 532 | $result = null; |
| 533 | - switch ( $this->type() ) { |
|
| 533 | + switch ($this->type()) { |
|
| 534 | 534 | // Text |
| 535 | 535 | case EEM_Question::QST_type_text : |
| 536 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
| 536 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 537 | 537 | break; |
| 538 | 538 | // Textarea |
| 539 | 539 | case EEM_Question::QST_type_textarea : |
| 540 | - $result = new EE_Text_Area_Input( $input_constructor_args ); |
|
| 540 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 541 | 541 | break; |
| 542 | 542 | // Radio Buttons |
| 543 | 543 | case EEM_Question::QST_type_radio : |
| 544 | - $result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args ); |
|
| 544 | + $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
| 545 | 545 | break; |
| 546 | 546 | // Dropdown |
| 547 | 547 | case EEM_Question::QST_type_dropdown : |
| 548 | - $result = new EE_Select_Input( $this->options(), $input_constructor_args ); |
|
| 548 | + $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
| 549 | 549 | break; |
| 550 | 550 | // State Dropdown |
| 551 | 551 | case EEM_Question::QST_type_state : |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | $registration, |
| 557 | 557 | $answer |
| 558 | 558 | ); |
| 559 | - $result = new EE_State_Select_Input( $state_options, $input_constructor_args ); |
|
| 559 | + $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
| 560 | 560 | break; |
| 561 | 561 | // Country Dropdown |
| 562 | 562 | case EEM_Question::QST_type_country : |
@@ -567,47 +567,47 @@ discard block |
||
| 567 | 567 | $registration, |
| 568 | 568 | $answer |
| 569 | 569 | ); |
| 570 | - $result = new EE_Country_Select_Input( $country_options, $input_constructor_args ); |
|
| 570 | + $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
| 571 | 571 | break; |
| 572 | 572 | // Checkboxes |
| 573 | 573 | case EEM_Question::QST_type_checkbox : |
| 574 | - $result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args ); |
|
| 574 | + $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
| 575 | 575 | break; |
| 576 | 576 | // Date |
| 577 | 577 | case EEM_Question::QST_type_date : |
| 578 | - $result = new EE_Datepicker_Input( $input_constructor_args ); |
|
| 578 | + $result = new EE_Datepicker_Input($input_constructor_args); |
|
| 579 | 579 | break; |
| 580 | 580 | case EEM_Question::QST_type_html_textarea : |
| 581 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy(); |
|
| 582 | - $result = new EE_Text_Area_Input( $input_constructor_args ); |
|
| 583 | - $result->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' ); |
|
| 581 | + $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
| 582 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 583 | + $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
| 584 | 584 | break; |
| 585 | 585 | case EEM_Question::QST_type_email : |
| 586 | - $result = new EE_Email_Input( $input_constructor_args ); |
|
| 586 | + $result = new EE_Email_Input($input_constructor_args); |
|
| 587 | 587 | break; |
| 588 | 588 | case EEM_Question::QST_type_us_phone : |
| 589 | - $result = new EE_Phone_Input( $input_constructor_args ); |
|
| 589 | + $result = new EE_Phone_Input($input_constructor_args); |
|
| 590 | 590 | break; |
| 591 | 591 | case EEM_Question::QST_type_int : |
| 592 | - $result = new EE_Integer_Input( $input_constructor_args ); |
|
| 592 | + $result = new EE_Integer_Input($input_constructor_args); |
|
| 593 | 593 | break; |
| 594 | 594 | case EEM_Question::QST_type_decimal : |
| 595 | - $result = new EE_Float_Input( $input_constructor_args ); |
|
| 595 | + $result = new EE_Float_Input($input_constructor_args); |
|
| 596 | 596 | break; |
| 597 | 597 | case EEM_Question::QST_type_url : |
| 598 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_URL_Validation_Strategy(); |
|
| 599 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
| 598 | + $input_constructor_args['validation_strategies'][] = new EE_URL_Validation_Strategy(); |
|
| 599 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 600 | 600 | break; |
| 601 | 601 | case EEM_Question::QST_type_year : |
| 602 | 602 | $result = new EE_Year_Input( |
| 603 | 603 | $input_constructor_args, |
| 604 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this ), |
|
| 605 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this ), |
|
| 606 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this ) |
|
| 604 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this), |
|
| 605 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this), |
|
| 606 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this) |
|
| 607 | 607 | ); |
| 608 | 608 | break; |
| 609 | 609 | case EEM_Question::QST_type_multi_select : |
| 610 | - $result = new EE_Select_Multiple_Input( $this->options(), $input_constructor_args ); |
|
| 610 | + $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
| 611 | 611 | break; |
| 612 | 612 | // fallback |
| 613 | 613 | default : |
@@ -618,12 +618,12 @@ discard block |
||
| 618 | 618 | $this, |
| 619 | 619 | $input_constructor_args |
| 620 | 620 | ); |
| 621 | - if( ! $default_input ){ |
|
| 622 | - $default_input = new EE_Text_Input( $input_constructor_args ); |
|
| 621 | + if ( ! $default_input) { |
|
| 622 | + $default_input = new EE_Text_Input($input_constructor_args); |
|
| 623 | 623 | } |
| 624 | 624 | $result = $default_input; |
| 625 | 625 | } |
| 626 | - return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer ); |
|
| 626 | + return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
@@ -14,56 +14,56 @@ |
||
| 14 | 14 | class EE_Number_Input_Display_Strategy extends EE_Display_Strategy_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * minimum value for number field |
|
| 19 | - * |
|
| 20 | - * @var int|null $min |
|
| 21 | - */ |
|
| 22 | - protected $min; |
|
| 17 | + /** |
|
| 18 | + * minimum value for number field |
|
| 19 | + * |
|
| 20 | + * @var int|null $min |
|
| 21 | + */ |
|
| 22 | + protected $min; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * maximum value for number field |
|
| 26 | - * |
|
| 27 | - * @var int|null $max |
|
| 28 | - */ |
|
| 29 | - protected $max; |
|
| 24 | + /** |
|
| 25 | + * maximum value for number field |
|
| 26 | + * |
|
| 27 | + * @var int|null $max |
|
| 28 | + */ |
|
| 29 | + protected $max; |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * EE_Number_Input_Display_Strategy constructor. |
|
| 35 | - * |
|
| 36 | - * @param int $min |
|
| 37 | - * @param int $max |
|
| 38 | - */ |
|
| 39 | - public function __construct($min = null, $max = null) |
|
| 40 | - { |
|
| 41 | - $this->min = $min; |
|
| 42 | - $this->max = $max; |
|
| 43 | - } |
|
| 33 | + /** |
|
| 34 | + * EE_Number_Input_Display_Strategy constructor. |
|
| 35 | + * |
|
| 36 | + * @param int $min |
|
| 37 | + * @param int $max |
|
| 38 | + */ |
|
| 39 | + public function __construct($min = null, $max = null) |
|
| 40 | + { |
|
| 41 | + $this->min = $min; |
|
| 42 | + $this->max = $max; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @return string of html to display the field |
|
| 49 | - */ |
|
| 50 | - public function display() |
|
| 51 | - { |
|
| 52 | - $input = $this->_opening_tag('input'); |
|
| 53 | - $input .= $this->_attributes_string( |
|
| 54 | - array_merge( |
|
| 55 | - $this->_standard_attributes_array(), |
|
| 56 | - array( |
|
| 57 | - 'type' => 'number', |
|
| 58 | - 'min' => $this->min, |
|
| 59 | - 'max' => $this->max, |
|
| 60 | - 'value' => $this->_input->raw_value_in_form() |
|
| 61 | - ) |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 64 | - $input .= $this->_close_tag(); |
|
| 65 | - return $input; |
|
| 66 | - } |
|
| 47 | + /** |
|
| 48 | + * @return string of html to display the field |
|
| 49 | + */ |
|
| 50 | + public function display() |
|
| 51 | + { |
|
| 52 | + $input = $this->_opening_tag('input'); |
|
| 53 | + $input .= $this->_attributes_string( |
|
| 54 | + array_merge( |
|
| 55 | + $this->_standard_attributes_array(), |
|
| 56 | + array( |
|
| 57 | + 'type' => 'number', |
|
| 58 | + 'min' => $this->min, |
|
| 59 | + 'max' => $this->max, |
|
| 60 | + 'value' => $this->_input->raw_value_in_form() |
|
| 61 | + ) |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | + $input .= $this->_close_tag(); |
|
| 65 | + return $input; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | // End of file EE_Number_Input_Display_Strategy.php |