@@ -16,230 +16,230 @@ discard block |
||
| 16 | 16 | class EEM_Transaction extends EEM_Base |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - // private instance of the Transaction object |
|
| 20 | - protected static $_instance; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
| 24 | - * but payment is pending. This is the state for transactions where payment is promised |
|
| 25 | - * from an offline gateway. |
|
| 26 | - */ |
|
| 27 | - // const open_status_code = 'TPN'; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
| 31 | - * either due to a technical reason (server or computer crash during registration), |
|
| 32 | - * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
| 33 | - */ |
|
| 34 | - const failed_status_code = 'TFL'; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
| 38 | - * either due to a technical reason (server or computer crash during registration), |
|
| 39 | - * or due to an abandoned cart after registrant chose not to complete the registration process |
|
| 40 | - * HOWEVER... |
|
| 41 | - * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
| 42 | - * registrant |
|
| 43 | - */ |
|
| 44 | - const abandoned_status_code = 'TAB'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
| 48 | - * meaning that monies are still owing: TXN_paid < TXN_total |
|
| 49 | - */ |
|
| 50 | - const incomplete_status_code = 'TIN'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
| 54 | - * meaning that NO monies are owing: TXN_paid == TXN_total |
|
| 55 | - */ |
|
| 56 | - const complete_status_code = 'TCM'; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
| 60 | - * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
| 61 | - */ |
|
| 62 | - const overpaid_status_code = 'TOP'; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * private constructor to prevent direct creation |
|
| 67 | - * |
|
| 68 | - * @Constructor |
|
| 69 | - * @access protected |
|
| 70 | - * |
|
| 71 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
| 72 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
| 73 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
| 74 | - * timezone in the 'timezone_string' wp option) |
|
| 75 | - * |
|
| 76 | - * @return EEM_Transaction |
|
| 77 | - * @throws \EE_Error |
|
| 78 | - */ |
|
| 79 | - protected function __construct($timezone) |
|
| 80 | - { |
|
| 81 | - $this->singular_item = __('Transaction', 'event_espresso'); |
|
| 82 | - $this->plural_item = __('Transactions', 'event_espresso'); |
|
| 83 | - |
|
| 84 | - $this->_tables = array( |
|
| 85 | - 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
| 86 | - ); |
|
| 87 | - $this->_fields = array( |
|
| 88 | - 'TransactionTable' => array( |
|
| 89 | - 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
| 90 | - 'TXN_timestamp' => new EE_Datetime_Field( |
|
| 91 | - 'TXN_timestamp', |
|
| 92 | - __('date when transaction was created', 'event_espresso'), |
|
| 93 | - false, |
|
| 94 | - EE_Datetime_Field::now, |
|
| 95 | - $timezone |
|
| 96 | - ), |
|
| 97 | - 'TXN_total' => new EE_Money_Field( |
|
| 98 | - 'TXN_total', |
|
| 99 | - __('Total value of Transaction', 'event_espresso'), |
|
| 100 | - false, |
|
| 101 | - 0 |
|
| 102 | - ), |
|
| 103 | - 'TXN_paid' => new EE_Money_Field( |
|
| 104 | - 'TXN_paid', |
|
| 105 | - __('Amount paid towards transaction to date', 'event_espresso'), |
|
| 106 | - false, |
|
| 107 | - 0 |
|
| 108 | - ), |
|
| 109 | - 'STS_ID' => new EE_Foreign_Key_String_Field( |
|
| 110 | - 'STS_ID', |
|
| 111 | - __('Status ID', 'event_espresso'), |
|
| 112 | - false, |
|
| 113 | - EEM_Transaction::failed_status_code, |
|
| 114 | - 'Status' |
|
| 115 | - ), |
|
| 116 | - 'TXN_session_data' => new EE_Serialized_Text_Field( |
|
| 117 | - 'TXN_session_data', |
|
| 118 | - __('Serialized session data', 'event_espresso'), |
|
| 119 | - true, |
|
| 120 | - '' |
|
| 121 | - ), |
|
| 122 | - 'TXN_hash_salt' => new EE_Plain_Text_Field( |
|
| 123 | - 'TXN_hash_salt', |
|
| 124 | - __('Transaction Hash Salt', 'event_espresso'), |
|
| 125 | - true, |
|
| 126 | - '' |
|
| 127 | - ), |
|
| 128 | - 'PMD_ID' => new EE_Foreign_Key_Int_Field( |
|
| 129 | - 'PMD_ID', |
|
| 130 | - __("Last Used Payment Method", 'event_espresso'), |
|
| 131 | - true, |
|
| 132 | - null, |
|
| 133 | - 'Payment_Method' |
|
| 134 | - ), |
|
| 135 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field( |
|
| 136 | - 'TXN_reg_steps', |
|
| 137 | - __('Registration Steps', 'event_espresso'), |
|
| 138 | - false, |
|
| 139 | - array() |
|
| 140 | - ), |
|
| 141 | - ) |
|
| 142 | - ); |
|
| 143 | - $this->_model_relations = array( |
|
| 144 | - 'Registration' => new EE_Has_Many_Relation(), |
|
| 145 | - 'Payment' => new EE_Has_Many_Relation(), |
|
| 146 | - 'Status' => new EE_Belongs_To_Relation(), |
|
| 147 | - 'Line_Item' => new EE_Has_Many_Relation(false), |
|
| 148 | - // you can delete a transaction without needing to delete its line items |
|
| 149 | - 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
| 150 | - 'Message' => new EE_Has_Many_Relation() |
|
| 151 | - ); |
|
| 152 | - $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
| 153 | - parent::__construct($timezone); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * txn_status_array |
|
| 159 | - * get list of transaction statuses |
|
| 160 | - * |
|
| 161 | - * @access public |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - public static function txn_status_array() |
|
| 165 | - { |
|
| 166 | - return apply_filters( |
|
| 167 | - 'FHEE__EEM_Transaction__txn_status_array', |
|
| 168 | - array( |
|
| 169 | - EEM_Transaction::overpaid_status_code, |
|
| 170 | - EEM_Transaction::complete_status_code, |
|
| 171 | - EEM_Transaction::incomplete_status_code, |
|
| 172 | - EEM_Transaction::abandoned_status_code, |
|
| 173 | - EEM_Transaction::failed_status_code, |
|
| 174 | - ) |
|
| 175 | - ); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * get the revenue per day for the Transaction Admin page Reports Tab |
|
| 180 | - * |
|
| 181 | - * @access public |
|
| 182 | - * |
|
| 183 | - * @param string $period |
|
| 184 | - * |
|
| 185 | - * @return \stdClass[] |
|
| 186 | - */ |
|
| 187 | - public function get_revenue_per_day_report($period = '-1 month') |
|
| 188 | - { |
|
| 189 | - $sql_date = $this->convert_datetime_for_query( |
|
| 190 | - 'TXN_timestamp', |
|
| 191 | - date('Y-m-d H:i:s', strtotime($period)), |
|
| 192 | - 'Y-m-d H:i:s', |
|
| 193 | - 'UTC' |
|
| 194 | - ); |
|
| 195 | - |
|
| 196 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
| 197 | - |
|
| 198 | - return $this->_get_all_wpdb_results( |
|
| 199 | - array( |
|
| 200 | - array( |
|
| 201 | - 'TXN_timestamp' => array('>=', $sql_date) |
|
| 202 | - ), |
|
| 203 | - 'group_by' => 'txnDate', |
|
| 204 | - 'order_by' => array('TXN_timestamp' => 'ASC') |
|
| 205 | - ), |
|
| 206 | - OBJECT, |
|
| 207 | - array( |
|
| 208 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
| 209 | - 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
| 210 | - ) |
|
| 211 | - ); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * get the revenue per event for the Transaction Admin page Reports Tab |
|
| 217 | - * |
|
| 218 | - * @access public |
|
| 219 | - * |
|
| 220 | - * @param string $period |
|
| 221 | - * |
|
| 222 | - * @throws \EE_Error |
|
| 223 | - * @return mixed |
|
| 224 | - */ |
|
| 225 | - public function get_revenue_per_event_report($period = '-1 month') |
|
| 226 | - { |
|
| 227 | - global $wpdb; |
|
| 228 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 229 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 230 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
| 231 | - $event_table = $wpdb->posts; |
|
| 232 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
| 233 | - $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
| 234 | - $approved_payment_status = EEM_Payment::status_id_approved; |
|
| 235 | - $extra_event_on_join = ''; |
|
| 236 | - // exclude events not authored by user if permissions in effect |
|
| 237 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 238 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $wpdb->get_results( |
|
| 242 | - "SELECT |
|
| 19 | + // private instance of the Transaction object |
|
| 20 | + protected static $_instance; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
| 24 | + * but payment is pending. This is the state for transactions where payment is promised |
|
| 25 | + * from an offline gateway. |
|
| 26 | + */ |
|
| 27 | + // const open_status_code = 'TPN'; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
| 31 | + * either due to a technical reason (server or computer crash during registration), |
|
| 32 | + * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
| 33 | + */ |
|
| 34 | + const failed_status_code = 'TFL'; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
| 38 | + * either due to a technical reason (server or computer crash during registration), |
|
| 39 | + * or due to an abandoned cart after registrant chose not to complete the registration process |
|
| 40 | + * HOWEVER... |
|
| 41 | + * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
| 42 | + * registrant |
|
| 43 | + */ |
|
| 44 | + const abandoned_status_code = 'TAB'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
| 48 | + * meaning that monies are still owing: TXN_paid < TXN_total |
|
| 49 | + */ |
|
| 50 | + const incomplete_status_code = 'TIN'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
| 54 | + * meaning that NO monies are owing: TXN_paid == TXN_total |
|
| 55 | + */ |
|
| 56 | + const complete_status_code = 'TCM'; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
| 60 | + * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
| 61 | + */ |
|
| 62 | + const overpaid_status_code = 'TOP'; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * private constructor to prevent direct creation |
|
| 67 | + * |
|
| 68 | + * @Constructor |
|
| 69 | + * @access protected |
|
| 70 | + * |
|
| 71 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
| 72 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
| 73 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
| 74 | + * timezone in the 'timezone_string' wp option) |
|
| 75 | + * |
|
| 76 | + * @return EEM_Transaction |
|
| 77 | + * @throws \EE_Error |
|
| 78 | + */ |
|
| 79 | + protected function __construct($timezone) |
|
| 80 | + { |
|
| 81 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
| 82 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
| 83 | + |
|
| 84 | + $this->_tables = array( |
|
| 85 | + 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
| 86 | + ); |
|
| 87 | + $this->_fields = array( |
|
| 88 | + 'TransactionTable' => array( |
|
| 89 | + 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
| 90 | + 'TXN_timestamp' => new EE_Datetime_Field( |
|
| 91 | + 'TXN_timestamp', |
|
| 92 | + __('date when transaction was created', 'event_espresso'), |
|
| 93 | + false, |
|
| 94 | + EE_Datetime_Field::now, |
|
| 95 | + $timezone |
|
| 96 | + ), |
|
| 97 | + 'TXN_total' => new EE_Money_Field( |
|
| 98 | + 'TXN_total', |
|
| 99 | + __('Total value of Transaction', 'event_espresso'), |
|
| 100 | + false, |
|
| 101 | + 0 |
|
| 102 | + ), |
|
| 103 | + 'TXN_paid' => new EE_Money_Field( |
|
| 104 | + 'TXN_paid', |
|
| 105 | + __('Amount paid towards transaction to date', 'event_espresso'), |
|
| 106 | + false, |
|
| 107 | + 0 |
|
| 108 | + ), |
|
| 109 | + 'STS_ID' => new EE_Foreign_Key_String_Field( |
|
| 110 | + 'STS_ID', |
|
| 111 | + __('Status ID', 'event_espresso'), |
|
| 112 | + false, |
|
| 113 | + EEM_Transaction::failed_status_code, |
|
| 114 | + 'Status' |
|
| 115 | + ), |
|
| 116 | + 'TXN_session_data' => new EE_Serialized_Text_Field( |
|
| 117 | + 'TXN_session_data', |
|
| 118 | + __('Serialized session data', 'event_espresso'), |
|
| 119 | + true, |
|
| 120 | + '' |
|
| 121 | + ), |
|
| 122 | + 'TXN_hash_salt' => new EE_Plain_Text_Field( |
|
| 123 | + 'TXN_hash_salt', |
|
| 124 | + __('Transaction Hash Salt', 'event_espresso'), |
|
| 125 | + true, |
|
| 126 | + '' |
|
| 127 | + ), |
|
| 128 | + 'PMD_ID' => new EE_Foreign_Key_Int_Field( |
|
| 129 | + 'PMD_ID', |
|
| 130 | + __("Last Used Payment Method", 'event_espresso'), |
|
| 131 | + true, |
|
| 132 | + null, |
|
| 133 | + 'Payment_Method' |
|
| 134 | + ), |
|
| 135 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field( |
|
| 136 | + 'TXN_reg_steps', |
|
| 137 | + __('Registration Steps', 'event_espresso'), |
|
| 138 | + false, |
|
| 139 | + array() |
|
| 140 | + ), |
|
| 141 | + ) |
|
| 142 | + ); |
|
| 143 | + $this->_model_relations = array( |
|
| 144 | + 'Registration' => new EE_Has_Many_Relation(), |
|
| 145 | + 'Payment' => new EE_Has_Many_Relation(), |
|
| 146 | + 'Status' => new EE_Belongs_To_Relation(), |
|
| 147 | + 'Line_Item' => new EE_Has_Many_Relation(false), |
|
| 148 | + // you can delete a transaction without needing to delete its line items |
|
| 149 | + 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
| 150 | + 'Message' => new EE_Has_Many_Relation() |
|
| 151 | + ); |
|
| 152 | + $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
| 153 | + parent::__construct($timezone); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * txn_status_array |
|
| 159 | + * get list of transaction statuses |
|
| 160 | + * |
|
| 161 | + * @access public |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + public static function txn_status_array() |
|
| 165 | + { |
|
| 166 | + return apply_filters( |
|
| 167 | + 'FHEE__EEM_Transaction__txn_status_array', |
|
| 168 | + array( |
|
| 169 | + EEM_Transaction::overpaid_status_code, |
|
| 170 | + EEM_Transaction::complete_status_code, |
|
| 171 | + EEM_Transaction::incomplete_status_code, |
|
| 172 | + EEM_Transaction::abandoned_status_code, |
|
| 173 | + EEM_Transaction::failed_status_code, |
|
| 174 | + ) |
|
| 175 | + ); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * get the revenue per day for the Transaction Admin page Reports Tab |
|
| 180 | + * |
|
| 181 | + * @access public |
|
| 182 | + * |
|
| 183 | + * @param string $period |
|
| 184 | + * |
|
| 185 | + * @return \stdClass[] |
|
| 186 | + */ |
|
| 187 | + public function get_revenue_per_day_report($period = '-1 month') |
|
| 188 | + { |
|
| 189 | + $sql_date = $this->convert_datetime_for_query( |
|
| 190 | + 'TXN_timestamp', |
|
| 191 | + date('Y-m-d H:i:s', strtotime($period)), |
|
| 192 | + 'Y-m-d H:i:s', |
|
| 193 | + 'UTC' |
|
| 194 | + ); |
|
| 195 | + |
|
| 196 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
| 197 | + |
|
| 198 | + return $this->_get_all_wpdb_results( |
|
| 199 | + array( |
|
| 200 | + array( |
|
| 201 | + 'TXN_timestamp' => array('>=', $sql_date) |
|
| 202 | + ), |
|
| 203 | + 'group_by' => 'txnDate', |
|
| 204 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
| 205 | + ), |
|
| 206 | + OBJECT, |
|
| 207 | + array( |
|
| 208 | + 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
| 209 | + 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
| 210 | + ) |
|
| 211 | + ); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * get the revenue per event for the Transaction Admin page Reports Tab |
|
| 217 | + * |
|
| 218 | + * @access public |
|
| 219 | + * |
|
| 220 | + * @param string $period |
|
| 221 | + * |
|
| 222 | + * @throws \EE_Error |
|
| 223 | + * @return mixed |
|
| 224 | + */ |
|
| 225 | + public function get_revenue_per_event_report($period = '-1 month') |
|
| 226 | + { |
|
| 227 | + global $wpdb; |
|
| 228 | + $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 229 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 230 | + $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
| 231 | + $event_table = $wpdb->posts; |
|
| 232 | + $payment_table = $wpdb->prefix . 'esp_payment'; |
|
| 233 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
| 234 | + $approved_payment_status = EEM_Payment::status_id_approved; |
|
| 235 | + $extra_event_on_join = ''; |
|
| 236 | + // exclude events not authored by user if permissions in effect |
|
| 237 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 238 | + $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $wpdb->get_results( |
|
| 242 | + "SELECT |
|
| 243 | 243 | Transaction_Event.event_name AS event_name, |
| 244 | 244 | SUM(Transaction_Event.paid) AS revenue |
| 245 | 245 | FROM |
@@ -267,231 +267,231 @@ discard block |
||
| 267 | 267 | $extra_event_on_join |
| 268 | 268 | ) AS Transaction_Event |
| 269 | 269 | GROUP BY event_name", |
| 270 | - OBJECT |
|
| 271 | - ); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
| 277 | - * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
| 278 | - * the registration pointed to by reg_url_link), if not returns null |
|
| 279 | - * |
|
| 280 | - * @param string $reg_url_link |
|
| 281 | - * |
|
| 282 | - * @return EE_Transaction |
|
| 283 | - */ |
|
| 284 | - public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
| 285 | - { |
|
| 286 | - return $this->get_one(array( |
|
| 287 | - array( |
|
| 288 | - 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get( |
|
| 289 | - 'e_reg_url_link', |
|
| 290 | - '' |
|
| 291 | - ) |
|
| 292 | - ) |
|
| 293 | - )); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Updates the provided EE_Transaction with all the applicable payments |
|
| 299 | - * (or fetch the EE_Transaction from its ID) |
|
| 300 | - * |
|
| 301 | - * @deprecated |
|
| 302 | - * |
|
| 303 | - * @param EE_Transaction|int $transaction_obj_or_id |
|
| 304 | - * @param boolean $save_txn whether or not to save the transaction during this function call |
|
| 305 | - * |
|
| 306 | - * @return boolean |
|
| 307 | - * @throws \EE_Error |
|
| 308 | - */ |
|
| 309 | - public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
| 310 | - { |
|
| 311 | - EE_Error::doing_it_wrong( |
|
| 312 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 313 | - sprintf( |
|
| 314 | - __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
| 315 | - 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' |
|
| 316 | - ), |
|
| 317 | - '4.6.0' |
|
| 318 | - ); |
|
| 319 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 320 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 321 | - |
|
| 322 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
| 323 | - $this->ensure_is_obj($transaction_obj_or_id) |
|
| 324 | - ); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
| 329 | - * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
| 330 | - * and so we only use wpdb directly and only do minimal joins. |
|
| 331 | - * Transactions are considered "junk" if they're failed for longer than a week. |
|
| 332 | - * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
| 333 | - * it, it's probably not junk (regardless of what status it has). |
|
| 334 | - * The downside to this approach is that is addons are listening for object deletions |
|
| 335 | - * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
| 336 | - * to catch these types of deletions. |
|
| 337 | - * |
|
| 338 | - * @global WPDB $wpdb |
|
| 339 | - * @return mixed |
|
| 340 | - */ |
|
| 341 | - public function delete_junk_transactions() |
|
| 342 | - { |
|
| 343 | - /** @type WPDB $wpdb */ |
|
| 344 | - global $wpdb; |
|
| 345 | - $deleted = false; |
|
| 346 | - $time_to_leave_alone = apply_filters( |
|
| 347 | - 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone', |
|
| 348 | - WEEK_IN_SECONDS |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
| 354 | - * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
| 355 | - * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
| 356 | - */ |
|
| 357 | - $ids_query = apply_filters( |
|
| 358 | - 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
| 359 | - array( |
|
| 360 | - 0 => array( |
|
| 361 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 362 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
| 363 | - 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
| 364 | - ) |
|
| 365 | - ), |
|
| 366 | - $time_to_leave_alone |
|
| 367 | - ); |
|
| 368 | - |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
| 372 | - * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
| 373 | - */ |
|
| 374 | - $txn_ids = apply_filters( |
|
| 375 | - 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
| 376 | - EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
| 377 | - $time_to_leave_alone |
|
| 378 | - ); |
|
| 379 | - // now that we have the ids to delete |
|
| 380 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
| 381 | - // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
| 382 | - EEM_Transaction::unset_locked_transactions($txn_ids); |
|
| 383 | - |
|
| 384 | - // Create IDs placeholder. |
|
| 385 | - $placeholders = array_fill(0, count($txn_ids), '%d'); |
|
| 270 | + OBJECT |
|
| 271 | + ); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
| 277 | + * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
| 278 | + * the registration pointed to by reg_url_link), if not returns null |
|
| 279 | + * |
|
| 280 | + * @param string $reg_url_link |
|
| 281 | + * |
|
| 282 | + * @return EE_Transaction |
|
| 283 | + */ |
|
| 284 | + public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
| 285 | + { |
|
| 286 | + return $this->get_one(array( |
|
| 287 | + array( |
|
| 288 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get( |
|
| 289 | + 'e_reg_url_link', |
|
| 290 | + '' |
|
| 291 | + ) |
|
| 292 | + ) |
|
| 293 | + )); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Updates the provided EE_Transaction with all the applicable payments |
|
| 299 | + * (or fetch the EE_Transaction from its ID) |
|
| 300 | + * |
|
| 301 | + * @deprecated |
|
| 302 | + * |
|
| 303 | + * @param EE_Transaction|int $transaction_obj_or_id |
|
| 304 | + * @param boolean $save_txn whether or not to save the transaction during this function call |
|
| 305 | + * |
|
| 306 | + * @return boolean |
|
| 307 | + * @throws \EE_Error |
|
| 308 | + */ |
|
| 309 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
| 310 | + { |
|
| 311 | + EE_Error::doing_it_wrong( |
|
| 312 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 313 | + sprintf( |
|
| 314 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
| 315 | + 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' |
|
| 316 | + ), |
|
| 317 | + '4.6.0' |
|
| 318 | + ); |
|
| 319 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 320 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 321 | + |
|
| 322 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
| 323 | + $this->ensure_is_obj($transaction_obj_or_id) |
|
| 324 | + ); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
| 329 | + * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
| 330 | + * and so we only use wpdb directly and only do minimal joins. |
|
| 331 | + * Transactions are considered "junk" if they're failed for longer than a week. |
|
| 332 | + * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
| 333 | + * it, it's probably not junk (regardless of what status it has). |
|
| 334 | + * The downside to this approach is that is addons are listening for object deletions |
|
| 335 | + * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
| 336 | + * to catch these types of deletions. |
|
| 337 | + * |
|
| 338 | + * @global WPDB $wpdb |
|
| 339 | + * @return mixed |
|
| 340 | + */ |
|
| 341 | + public function delete_junk_transactions() |
|
| 342 | + { |
|
| 343 | + /** @type WPDB $wpdb */ |
|
| 344 | + global $wpdb; |
|
| 345 | + $deleted = false; |
|
| 346 | + $time_to_leave_alone = apply_filters( |
|
| 347 | + 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone', |
|
| 348 | + WEEK_IN_SECONDS |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
| 354 | + * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
| 355 | + * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
| 356 | + */ |
|
| 357 | + $ids_query = apply_filters( |
|
| 358 | + 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
| 359 | + array( |
|
| 360 | + 0 => array( |
|
| 361 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 362 | + 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
| 363 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
| 364 | + ) |
|
| 365 | + ), |
|
| 366 | + $time_to_leave_alone |
|
| 367 | + ); |
|
| 368 | + |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
| 372 | + * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
| 373 | + */ |
|
| 374 | + $txn_ids = apply_filters( |
|
| 375 | + 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
| 376 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
| 377 | + $time_to_leave_alone |
|
| 378 | + ); |
|
| 379 | + // now that we have the ids to delete |
|
| 380 | + if (! empty($txn_ids) && is_array($txn_ids)) { |
|
| 381 | + // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
| 382 | + EEM_Transaction::unset_locked_transactions($txn_ids); |
|
| 383 | + |
|
| 384 | + // Create IDs placeholder. |
|
| 385 | + $placeholders = array_fill(0, count($txn_ids), '%d'); |
|
| 386 | 386 | |
| 387 | - // Glue it together to use inside $wpdb->prepare. |
|
| 388 | - $format = implode(', ', $placeholders); |
|
| 389 | - |
|
| 390 | - // let's get deletin'... |
|
| 391 | - // We got the ids from the original query to get them FROM |
|
| 392 | - // the db (which is sanitized) so no need to prepare them again. |
|
| 393 | - $query = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids); |
|
| 394 | - $deleted = $wpdb->query($query); |
|
| 395 | - } |
|
| 396 | - if ($deleted) { |
|
| 397 | - /** |
|
| 398 | - * Allows code to do something after the transactions have been deleted. |
|
| 399 | - */ |
|
| 400 | - do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - return $deleted; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @param array $transaction_IDs |
|
| 409 | - * |
|
| 410 | - * @return bool |
|
| 411 | - */ |
|
| 412 | - public static function unset_locked_transactions(array $transaction_IDs) |
|
| 413 | - { |
|
| 414 | - $locked_transactions = get_option('ee_locked_transactions', array()); |
|
| 415 | - $update = false; |
|
| 416 | - foreach ($transaction_IDs as $TXN_ID) { |
|
| 417 | - if (isset($locked_transactions[ $TXN_ID ])) { |
|
| 418 | - unset($locked_transactions[ $TXN_ID ]); |
|
| 419 | - $update = true; |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - if ($update) { |
|
| 423 | - update_option('ee_locked_transactions', $locked_transactions); |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - return $update; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * returns an array of EE_Transaction objects whose timestamp is greater than |
|
| 433 | - * the current time minus the session lifespan, which defaults to 60 minutes |
|
| 434 | - * |
|
| 435 | - * @return EE_Base_Class[]|EE_Transaction[] |
|
| 436 | - * @throws EE_Error |
|
| 437 | - * @throws InvalidArgumentException |
|
| 438 | - * @throws InvalidDataTypeException |
|
| 439 | - * @throws InvalidInterfaceException |
|
| 440 | - */ |
|
| 441 | - public function get_transactions_in_progress() |
|
| 442 | - { |
|
| 443 | - return $this->_get_transactions_in_progress(); |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * returns an array of EE_Transaction objects whose timestamp is less than |
|
| 450 | - * the current time minus the session lifespan, which defaults to 60 minutes |
|
| 451 | - * |
|
| 452 | - * @return EE_Base_Class[]|EE_Transaction[] |
|
| 453 | - * @throws EE_Error |
|
| 454 | - * @throws InvalidArgumentException |
|
| 455 | - * @throws InvalidDataTypeException |
|
| 456 | - * @throws InvalidInterfaceException |
|
| 457 | - */ |
|
| 458 | - public function get_transactions_not_in_progress() |
|
| 459 | - { |
|
| 460 | - return $this->_get_transactions_in_progress('<='); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * @param string $comparison |
|
| 467 | - * @return EE_Base_Class[]|EE_Transaction[] |
|
| 468 | - * @throws EE_Error |
|
| 469 | - * @throws InvalidArgumentException |
|
| 470 | - * @throws InvalidDataTypeException |
|
| 471 | - * @throws InvalidInterfaceException |
|
| 472 | - */ |
|
| 473 | - private function _get_transactions_in_progress($comparison = '>=') |
|
| 474 | - { |
|
| 475 | - $comparison = $comparison === '>=' || $comparison === '<=' |
|
| 476 | - ? $comparison |
|
| 477 | - : '>='; |
|
| 478 | - /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
| 479 | - $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
| 480 | - 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
| 481 | - ); |
|
| 482 | - return $this->get_all( |
|
| 483 | - array( |
|
| 484 | - array( |
|
| 485 | - 'TXN_timestamp' => array( |
|
| 486 | - $comparison, |
|
| 487 | - $session_lifespan->expiration() |
|
| 488 | - ), |
|
| 489 | - 'STS_ID' => array( |
|
| 490 | - '!=', |
|
| 491 | - EEM_Transaction::complete_status_code |
|
| 492 | - ), |
|
| 493 | - ) |
|
| 494 | - ) |
|
| 495 | - ); |
|
| 496 | - } |
|
| 387 | + // Glue it together to use inside $wpdb->prepare. |
|
| 388 | + $format = implode(', ', $placeholders); |
|
| 389 | + |
|
| 390 | + // let's get deletin'... |
|
| 391 | + // We got the ids from the original query to get them FROM |
|
| 392 | + // the db (which is sanitized) so no need to prepare them again. |
|
| 393 | + $query = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids); |
|
| 394 | + $deleted = $wpdb->query($query); |
|
| 395 | + } |
|
| 396 | + if ($deleted) { |
|
| 397 | + /** |
|
| 398 | + * Allows code to do something after the transactions have been deleted. |
|
| 399 | + */ |
|
| 400 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + return $deleted; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @param array $transaction_IDs |
|
| 409 | + * |
|
| 410 | + * @return bool |
|
| 411 | + */ |
|
| 412 | + public static function unset_locked_transactions(array $transaction_IDs) |
|
| 413 | + { |
|
| 414 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
| 415 | + $update = false; |
|
| 416 | + foreach ($transaction_IDs as $TXN_ID) { |
|
| 417 | + if (isset($locked_transactions[ $TXN_ID ])) { |
|
| 418 | + unset($locked_transactions[ $TXN_ID ]); |
|
| 419 | + $update = true; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + if ($update) { |
|
| 423 | + update_option('ee_locked_transactions', $locked_transactions); |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + return $update; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * returns an array of EE_Transaction objects whose timestamp is greater than |
|
| 433 | + * the current time minus the session lifespan, which defaults to 60 minutes |
|
| 434 | + * |
|
| 435 | + * @return EE_Base_Class[]|EE_Transaction[] |
|
| 436 | + * @throws EE_Error |
|
| 437 | + * @throws InvalidArgumentException |
|
| 438 | + * @throws InvalidDataTypeException |
|
| 439 | + * @throws InvalidInterfaceException |
|
| 440 | + */ |
|
| 441 | + public function get_transactions_in_progress() |
|
| 442 | + { |
|
| 443 | + return $this->_get_transactions_in_progress(); |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * returns an array of EE_Transaction objects whose timestamp is less than |
|
| 450 | + * the current time minus the session lifespan, which defaults to 60 minutes |
|
| 451 | + * |
|
| 452 | + * @return EE_Base_Class[]|EE_Transaction[] |
|
| 453 | + * @throws EE_Error |
|
| 454 | + * @throws InvalidArgumentException |
|
| 455 | + * @throws InvalidDataTypeException |
|
| 456 | + * @throws InvalidInterfaceException |
|
| 457 | + */ |
|
| 458 | + public function get_transactions_not_in_progress() |
|
| 459 | + { |
|
| 460 | + return $this->_get_transactions_in_progress('<='); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * @param string $comparison |
|
| 467 | + * @return EE_Base_Class[]|EE_Transaction[] |
|
| 468 | + * @throws EE_Error |
|
| 469 | + * @throws InvalidArgumentException |
|
| 470 | + * @throws InvalidDataTypeException |
|
| 471 | + * @throws InvalidInterfaceException |
|
| 472 | + */ |
|
| 473 | + private function _get_transactions_in_progress($comparison = '>=') |
|
| 474 | + { |
|
| 475 | + $comparison = $comparison === '>=' || $comparison === '<=' |
|
| 476 | + ? $comparison |
|
| 477 | + : '>='; |
|
| 478 | + /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
| 479 | + $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
| 480 | + 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
| 481 | + ); |
|
| 482 | + return $this->get_all( |
|
| 483 | + array( |
|
| 484 | + array( |
|
| 485 | + 'TXN_timestamp' => array( |
|
| 486 | + $comparison, |
|
| 487 | + $session_lifespan->expiration() |
|
| 488 | + ), |
|
| 489 | + 'STS_ID' => array( |
|
| 490 | + '!=', |
|
| 491 | + EEM_Transaction::complete_status_code |
|
| 492 | + ), |
|
| 493 | + ) |
|
| 494 | + ) |
|
| 495 | + ); |
|
| 496 | + } |
|
| 497 | 497 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ), |
| 141 | 141 | ) |
| 142 | 142 | ); |
| 143 | - $this->_model_relations = array( |
|
| 143 | + $this->_model_relations = array( |
|
| 144 | 144 | 'Registration' => new EE_Has_Many_Relation(), |
| 145 | 145 | 'Payment' => new EE_Has_Many_Relation(), |
| 146 | 146 | 'Status' => new EE_Belongs_To_Relation(), |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | ), |
| 206 | 206 | OBJECT, |
| 207 | 207 | array( |
| 208 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
| 208 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
| 209 | 209 | 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
| 210 | 210 | ) |
| 211 | 211 | ); |
@@ -225,17 +225,17 @@ discard block |
||
| 225 | 225 | public function get_revenue_per_event_report($period = '-1 month') |
| 226 | 226 | { |
| 227 | 227 | global $wpdb; |
| 228 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 229 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
| 230 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
| 228 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
| 229 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
| 230 | + $registration_payment_table = $wpdb->prefix.'esp_registration_payment'; |
|
| 231 | 231 | $event_table = $wpdb->posts; |
| 232 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
| 232 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
| 233 | 233 | $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
| 234 | 234 | $approved_payment_status = EEM_Payment::status_id_approved; |
| 235 | 235 | $extra_event_on_join = ''; |
| 236 | 236 | // exclude events not authored by user if permissions in effect |
| 237 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 238 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
| 237 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
| 238 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | return $wpdb->get_results( |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
| 310 | 310 | { |
| 311 | 311 | EE_Error::doing_it_wrong( |
| 312 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 312 | + __CLASS__.'::'.__FUNCTION__, |
|
| 313 | 313 | sprintf( |
| 314 | 314 | __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
| 315 | 315 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | array( |
| 360 | 360 | 0 => array( |
| 361 | 361 | 'STS_ID' => EEM_Transaction::failed_status_code, |
| 362 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
| 362 | + 'Payment.PAY_ID' => array('IS NULL'), |
|
| 363 | 363 | 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
| 364 | 364 | ) |
| 365 | 365 | ), |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $time_to_leave_alone |
| 378 | 378 | ); |
| 379 | 379 | // now that we have the ids to delete |
| 380 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
| 380 | + if ( ! empty($txn_ids) && is_array($txn_ids)) { |
|
| 381 | 381 | // first, make sure these TXN's are removed the "ee_locked_transactions" array |
| 382 | 382 | EEM_Transaction::unset_locked_transactions($txn_ids); |
| 383 | 383 | |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | // let's get deletin'... |
| 391 | 391 | // We got the ids from the original query to get them FROM |
| 392 | 392 | // the db (which is sanitized) so no need to prepare them again. |
| 393 | - $query = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids); |
|
| 393 | + $query = $wpdb->prepare("DELETE FROM ".$this->table()." WHERE TXN_ID IN ( $format )", $txn_ids); |
|
| 394 | 394 | $deleted = $wpdb->query($query); |
| 395 | 395 | } |
| 396 | 396 | if ($deleted) { |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | $locked_transactions = get_option('ee_locked_transactions', array()); |
| 415 | 415 | $update = false; |
| 416 | 416 | foreach ($transaction_IDs as $TXN_ID) { |
| 417 | - if (isset($locked_transactions[ $TXN_ID ])) { |
|
| 418 | - unset($locked_transactions[ $TXN_ID ]); |
|
| 417 | + if (isset($locked_transactions[$TXN_ID])) { |
|
| 418 | + unset($locked_transactions[$TXN_ID]); |
|
| 419 | 419 | $update = true; |
| 420 | 420 | } |
| 421 | 421 | } |
@@ -38,103 +38,103 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.059'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.059'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |