@@ -257,7 +257,7 @@ |
||
257 | 257 | * @param int $TXN_ID |
258 | 258 | * @param int $ATT_ID |
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | - * @return mixed array on success, FALSE on fail |
|
260 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
261 | 261 | */ |
262 | 262 | public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
263 | 263 | return $this->get_one(array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
3 | -require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
3 | +require_once (EE_CLASSES.'EE_Registration.class.php'); |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Registration Model |
@@ -92,31 +92,31 @@ discard block |
||
92 | 92 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
93 | 93 | * @return \EEM_Registration |
94 | 94 | */ |
95 | - protected function __construct( $timezone ) { |
|
96 | - $this->singular_item = __('Registration','event_espresso'); |
|
97 | - $this->plural_item = __('Registrations','event_espresso'); |
|
95 | + protected function __construct($timezone) { |
|
96 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
97 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | $this->_tables = array( |
100 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
100 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
101 | 101 | ); |
102 | 102 | $this->_fields = array( |
103 | 103 | 'Registration'=>array( |
104 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
105 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
106 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
107 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
108 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
109 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, time(), $timezone ), |
|
111 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
112 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
113 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
114 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
115 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
116 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
117 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
118 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
119 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
104 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
105 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
106 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
107 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
108 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
109 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, time(), $timezone), |
|
111 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
112 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
113 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
114 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
115 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
116 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
117 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
118 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
119 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | $this->_model_relations = array( |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'Answer'=>new EE_Has_Many_Relation(), |
129 | 129 | 'Checkin'=>new EE_Has_Many_Relation(), |
130 | 130 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
131 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
131 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
132 | 132 | ); |
133 | 133 | $this->_model_chain_to_wp_user = 'Event'; |
134 | 134 | |
135 | - parent::__construct( $timezone ); |
|
135 | + parent::__construct($timezone); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param bool $translated If true will return the values as singular localized strings |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
169 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
170 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
168 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
169 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
170 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param array $exclude |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - private function _get_registration_status_array( $exclude = array() ) { |
|
181 | + private function _get_registration_status_array($exclude = array()) { |
|
182 | 182 | //in the very rare circumstance that we are deleting a model's table's data |
183 | 183 | //and the table hasn't actually been created, this could have an error |
184 | 184 | /** @type WPDB $wpdb */ |
185 | 185 | global $wpdb; |
186 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
187 | - if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){ |
|
188 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
189 | - $results = $wpdb->get_results( $SQL ); |
|
186 | + EE_Registry::instance()->load_helper('Activation'); |
|
187 | + if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) { |
|
188 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
189 | + $results = $wpdb->get_results($SQL); |
|
190 | 190 | self::$_reg_status = array(); |
191 | - foreach ( $results as $status ) { |
|
192 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
193 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
191 | + foreach ($results as $status) { |
|
192 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
193 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
206 | 206 | * @return wpdb results array |
207 | 207 | */ |
208 | - public function get_reg_months_and_years( $where_params ) { |
|
208 | + public function get_reg_months_and_years($where_params) { |
|
209 | 209 | $query_params[0] = $where_params; |
210 | 210 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
211 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
211 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
212 | 212 | $columns_to_select = array( |
213 | 213 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
214 | 214 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
215 | 215 | ); |
216 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
216 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param int $ATT_ID |
226 | 226 | * @return EE_Registration[] |
227 | 227 | */ |
228 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
229 | - if ( ! $ATT_ID ) { |
|
228 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
229 | + if ( ! $ATT_ID) { |
|
230 | 230 | return FALSE; |
231 | 231 | } |
232 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
232 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @param string $REG_url_link |
241 | 241 | * @return EE_Registration |
242 | 242 | */ |
243 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
244 | - if(!$REG_url_link){ |
|
243 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
244 | + if ( ! $REG_url_link) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | 260 | * @return mixed array on success, FALSE on fail |
261 | 261 | */ |
262 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
262 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
263 | 263 | return $this->get_one(array( |
264 | 264 | array( |
265 | 265 | 'TXN_ID'=>$TXN_ID, |
266 | 266 | 'ATT_ID'=>$ATT_ID |
267 | 267 | ), |
268 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
268 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
269 | 269 | )); |
270 | 270 | } |
271 | 271 | |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
278 | 278 | * @return stdClass[] with properties regDate and total |
279 | 279 | */ |
280 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
280 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
281 | 281 | |
282 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
283 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
282 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
283 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
284 | 284 | |
285 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
285 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
286 | 286 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
287 | 287 | } |
288 | 288 | |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | ), |
295 | 295 | OBJECT, |
296 | 296 | array( |
297 | - 'regDate'=>array('DATE(Registration.REG_date)','%s'), |
|
298 | - 'total'=>array('count(REG_ID)','%d') |
|
297 | + 'regDate'=>array('DATE(Registration.REG_date)', '%s'), |
|
298 | + 'total'=>array('count(REG_ID)', '%d') |
|
299 | 299 | )); |
300 | 300 | return $results; |
301 | 301 | } |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
311 | 311 | * @return stdClass[] each with properties event_name, reg_limit, and total |
312 | 312 | */ |
313 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
313 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
314 | 314 | |
315 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
316 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
315 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
316 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
317 | 317 | |
318 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
318 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
319 | 319 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
320 | 320 | } |
321 | 321 | $results = $this->_get_all_wpdb_results(array( |
322 | 322 | $where, |
323 | 323 | 'group_by'=>'Event.EVT_name', |
324 | 324 | 'order_by'=>'Event.EVT_name', |
325 | - 'limit'=>array(0,24)), |
|
325 | + 'limit'=>array(0, 24)), |
|
326 | 326 | OBJECT, |
327 | 327 | array( |
328 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
329 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
328 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
329 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
330 | 330 | ) |
331 | 331 | ); |
332 | 332 | |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | * @param int $TXN_ID |
341 | 341 | * @return EE_Registration |
342 | 342 | */ |
343 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
344 | - if( ! $TXN_ID ){ |
|
343 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
344 | + if ( ! $TXN_ID) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
347 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | * @param boolean $for_incomplete_payments |
357 | 357 | * @return int |
358 | 358 | */ |
359 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
359 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
360 | 360 | // we only count approved registrations towards registration limits |
361 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
362 | - if( $for_incomplete_payments ){ |
|
363 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
361 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
362 | + if ($for_incomplete_payments) { |
|
363 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return $this->count($query_params); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /** @type WPDB $wpdb */ |
377 | 377 | global $wpdb; |
378 | 378 | return $wpdb->query( |
379 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
379 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Sum all the deleted items. |
147 | 147 | * @param array $query_params like EEM_Base::get_all |
148 | 148 | * @param string $field_to_sum |
149 | - * @return int |
|
149 | + * @return double |
|
150 | 150 | */ |
151 | 151 | public function sum_deleted($query_params = null, $field_to_sum = null){ |
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
196 | 196 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | - * @return boolean success |
|
198 | + * @return integer success |
|
199 | 199 | */ |
200 | 200 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Updates all the items of this model which match the $query params, regardless of whether |
280 | 280 | * they've been soft-deleted or not |
281 | - * @param array $field_n_values like EEM_Base::update's $fields_n_value |
|
281 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
282 | 282 | * @param array $query_params like EEM_base::get_all's $query_params |
283 | 283 | * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
284 | 284 | * in this model's entity map according to $fields_n_values that match $query_params. This |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @subpackage includes/models/ |
26 | 26 | * @author Michael Nelson |
27 | 27 | */ |
28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param null $timezone |
32 | 32 | */ |
33 | 33 | protected function __construct($timezone = NULL) { |
34 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
36 | 36 | } |
37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | * @throws EE_Error |
44 | 44 | */ |
45 | - public function deleted_field_name(){ |
|
45 | + public function deleted_field_name() { |
|
46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
47 | - if($field){ |
|
47 | + if ($field) { |
|
48 | 48 | return $field->get_name(); |
49 | - }else{ |
|
50 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
49 | + } else { |
|
50 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
58 | 58 | * @return EE_Soft_Delete_Base_Class |
59 | 59 | */ |
60 | - public function get_one_deleted($query_params = array()){ |
|
60 | + public function get_one_deleted($query_params = array()) { |
|
61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
62 | 62 | return parent::get_one($query_params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
68 | 68 | * @return EE_Soft_Delete_Base_Class |
69 | 69 | */ |
70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
72 | 72 | return parent::get_one($query_params); |
73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param int|string $id |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
81 | 81 | return $this->get_one( |
82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
83 | 83 | $id, |
84 | - array( 'default_where_conditions' => 'default' ) |
|
84 | + array('default_where_conditions' => 'default') |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
104 | 104 | * @return array like EEM_Base::get_all's $query_params |
105 | 105 | */ |
106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
109 | 109 | return $query_params; |
110 | 110 | } |
111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param array $query_params |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
117 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
118 | 118 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
119 | 119 | } |
120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param array $query_params |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
127 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
126 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
127 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
128 | 128 | $query_params['default_where_conditions'] = 'minimum'; |
129 | 129 | } |
130 | 130 | return $query_params; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
138 | 138 | * @return int |
139 | 139 | */ |
140 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
140 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
141 | 141 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
142 | - return parent::count($query_params,$field_to_count, $distinct); |
|
142 | + return parent::count($query_params, $field_to_count, $distinct); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $field_to_sum |
149 | 149 | * @return int |
150 | 150 | */ |
151 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
151 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
153 | 153 | return parent::sum($query_params, $field_to_sum); |
154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field_to_sum |
160 | 160 | * @reutrn int |
161 | 161 | */ |
162 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
162 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
163 | 163 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
164 | 164 | parent::sum($query_params, $field_to_sum); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $query_params like EEM_Base::get_all |
170 | 170 | * @return EE_Soft_Delete_Base_Class[] |
171 | 171 | */ |
172 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
172 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
173 | 173 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
174 | 174 | return parent::get_all($query_params); |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $query_params like EEM_Base::get_all |
180 | 180 | * @return EE_Soft_Delete_Base_Class[] |
181 | 181 | */ |
182 | - public function get_all_deleted($query_params = array()){ |
|
182 | + public function get_all_deleted($query_params = array()) { |
|
183 | 183 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
184 | 184 | return parent::get_all($query_params); |
185 | 185 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | 198 | * @return boolean success |
199 | 199 | */ |
200 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
200 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
202 | 202 | return parent::delete_permanently($query_params, $allow_blocking); |
203 | 203 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param mixed $ID int if primary key is an int, string otherwise |
209 | 209 | * @return boolean success |
210 | 210 | */ |
211 | - public function restore_by_ID($ID=FALSE){ |
|
212 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
211 | + public function restore_by_ID($ID = FALSE) { |
|
212 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param mixed $ID int if primary key is an int, string otherwise |
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
222 | - if ( ! $ID ) { |
|
221 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
222 | + if ( ! $ID) { |
|
223 | 223 | return FALSE; |
224 | 224 | } |
225 | 225 | if ( |
226 | 226 | $this->delete_or_restore( |
227 | 227 | $delete, |
228 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
228 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
229 | 229 | ) |
230 | 230 | ) { |
231 | 231 | return TRUE; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param bool $block_deletes |
246 | 246 | * @return boolean |
247 | 247 | */ |
248 | - public function delete($query_params = array(), $block_deletes = false){ |
|
248 | + public function delete($query_params = array(), $block_deletes = false) { |
|
249 | 249 | //no matter what, we WON'T block soft deletes. |
250 | 250 | return $this->delete_or_restore(true, $query_params); |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array $query_params like EEM_Base::get_all |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - public function restore($query_params = array()){ |
|
259 | + public function restore($query_params = array()) { |
|
260 | 260 | return $this->delete_or_restore(false, $query_params); |
261 | 261 | } |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @param array $query_params like EEM_Base::get_all |
266 | 266 | * @return boolean |
267 | 267 | */ |
268 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
269 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
268 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
269 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
270 | 270 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
271 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
271 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
272 | 272 | return TRUE; |
273 | 273 | } else { |
274 | 274 | return FALSE; |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * be aware that model objects being used could get out-of-sync with the database |
287 | 287 | * @return int number of items updated |
288 | 288 | */ |
289 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
289 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
290 | 290 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
291 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
291 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
292 | 292 | } |
293 | 293 | } |
@@ -7,6 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | protected $_post_type; |
9 | 9 | protected $_meta_field; |
10 | + |
|
11 | + /** |
|
12 | + * @param string $post_type |
|
13 | + */ |
|
10 | 14 | function __construct($post_type, $meta_field_to_chk = ''){ |
11 | 15 | $this->_post_type = $post_type; |
12 | 16 | $this->_meta_field = $meta_field_to_chk; |
@@ -27,7 +31,6 @@ discard block |
||
27 | 31 | } |
28 | 32 | /** |
29 | 33 | * Gets the where default where conditions for a custom post type model |
30 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
31 | 34 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
32 | 35 | */ |
33 | 36 | protected function _get_default_where_conditions() { |
@@ -3,18 +3,18 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * |
|
7 | - * Class EE_CPT_Minimum_Where_Conditions |
|
8 | - * |
|
9 | - * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | - * But only sets the minimum, so any row of the right type will get used |
|
11 | - * |
|
12 | - * @package Event Espresso |
|
13 | - * @subpackage core/db_models |
|
14 | - * @author Mike Nelson |
|
15 | - * @since 4.8.29.rc.010 |
|
16 | - * |
|
17 | - */ |
|
6 | + * |
|
7 | + * Class EE_CPT_Minimum_Where_Conditions |
|
8 | + * |
|
9 | + * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | + * But only sets the minimum, so any row of the right type will get used |
|
11 | + * |
|
12 | + * @package Event Espresso |
|
13 | + * @subpackage core/db_models |
|
14 | + * @author Mike Nelson |
|
15 | + * @since 4.8.29.rc.010 |
|
16 | + * |
|
17 | + */ |
|
18 | 18 | class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{ |
19 | 19 | |
20 | 20 | protected $_post_type; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @since 4.8.29.rc.010 |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{ |
|
18 | +class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions { |
|
19 | 19 | |
20 | 20 | protected $_post_type; |
21 | 21 | protected $_meta_field; |
22 | - function __construct($post_type, $meta_field_to_chk = ''){ |
|
22 | + function __construct($post_type, $meta_field_to_chk = '') { |
|
23 | 23 | $this->_post_type = $post_type; |
24 | 24 | $this->_meta_field = $meta_field_to_chk; |
25 | 25 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * @param string $column column name |
30 | 30 | * @return EE_Model_Field_Base |
31 | 31 | */ |
32 | - protected function _get_field_on_column($column){ |
|
32 | + protected function _get_field_on_column($column) { |
|
33 | 33 | $all_fields = $this->_model->field_settings(true); |
34 | - foreach($all_fields as $field_name => $field_obj){ |
|
35 | - if($column == $field_obj->get_table_column()){ |
|
34 | + foreach ($all_fields as $field_name => $field_obj) { |
|
35 | + if ($column == $field_obj->get_table_column()) { |
|
36 | 36 | return $field_obj; |
37 | 37 | } |
38 | 38 | } |
@@ -17,7 +17,6 @@ |
||
17 | 17 | class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
21 | 20 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
22 | 21 | */ |
23 | 22 | protected function _get_default_where_conditions() { |
@@ -3,17 +3,17 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * |
|
7 | - * Class EE_Default_Where_Conditions |
|
8 | - * |
|
9 | - * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | - * |
|
11 | - * @package Event Espresso |
|
12 | - * @subpackage core/db_models |
|
13 | - * @author Mike Nelson |
|
14 | - * * @since 4.6.0 |
|
15 | - * |
|
16 | - */ |
|
6 | + * |
|
7 | + * Class EE_Default_Where_Conditions |
|
8 | + * |
|
9 | + * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | + * |
|
11 | + * @package Event Espresso |
|
12 | + * @subpackage core/db_models |
|
13 | + * @author Mike Nelson |
|
14 | + * * @since 4.6.0 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * * @since 4.6.0 |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
|
17 | +class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions { |
|
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | 20 | * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | return array_merge( |
26 | 26 | parent::_get_default_where_conditions(), |
27 | 27 | array( |
28 | - $status_field->get_name() => array('NOT IN',array('auto-draft','trash') ) |
|
28 | + $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash')) |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @access protected |
239 | 239 | * @param \EE_Ticket $ticket |
240 | 240 | * @param int $quantity |
241 | - * @return bool |
|
241 | + * @return integer |
|
242 | 242 | * @throws \EE_Error |
243 | 243 | */ |
244 | 244 | protected function _reserve_ticket( EE_Ticket $ticket, $quantity = 1 ) { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @access protected |
258 | 258 | * @param EE_Ticket $ticket |
259 | 259 | * @param int $quantity |
260 | - * @return bool |
|
260 | + * @return integer |
|
261 | 261 | * @throws \EE_Error |
262 | 262 | */ |
263 | 263 | protected function _release_reserved_ticket( EE_Ticket $ticket, $quantity = 1 ) { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @access protected |
282 | 282 | * @param \EE_Ticket $ticket |
283 | - * @return bool |
|
283 | + * @return boolean|null |
|
284 | 284 | * @throws \EE_Error |
285 | 285 | */ |
286 | 286 | protected function _ticket_sold_out( EE_Ticket $ticket ) { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @access protected |
301 | 301 | * @param \EE_Ticket $ticket |
302 | - * @return bool |
|
302 | + * @return boolean|null |
|
303 | 303 | */ |
304 | 304 | protected function _ticket_quantity_decremented( EE_Ticket $ticket ) { |
305 | 305 | if ( self::debug ) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EED_Ticket_Sales_Monitor |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class EED_Ticket_Sales_Monitor extends EED_Module { |
19 | 19 | |
20 | - const debug = false; // true false |
|
20 | + const debug = false; // true false |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * an array of raw ticket data from EED_Ticket_Selector |
@@ -59,58 +59,58 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function set_hooks() { |
61 | 61 | // check ticket reserves AFTER MER does it's check (hence priority 20) |
62 | - add_filter( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', |
|
63 | - array( 'EED_Ticket_Sales_Monitor', 'validate_ticket_sale' ), |
|
62 | + add_filter('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', |
|
63 | + array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'), |
|
64 | 64 | 20, 3 |
65 | 65 | ); |
66 | 66 | // add notices for sold out tickets |
67 | - add_action( 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
68 | - array( 'EED_Ticket_Sales_Monitor', 'post_notices' ), |
|
67 | + add_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
68 | + array('EED_Ticket_Sales_Monitor', 'post_notices'), |
|
69 | 69 | 10 |
70 | 70 | ); |
71 | 71 | // handle ticket quantities adjusted in cart |
72 | 72 | add_action( |
73 | 73 | 'FHEE__EED_Multi_Event_Registration__adjust_line_item_quantity__line_item_quantity_updated', |
74 | - array( 'EED_Ticket_Sales_Monitor', 'ticket_quantity_updated' ), |
|
74 | + array('EED_Ticket_Sales_Monitor', 'ticket_quantity_updated'), |
|
75 | 75 | 10, 2 |
76 | 76 | ); |
77 | 77 | // handle tickets deleted from cart |
78 | 78 | add_action( |
79 | 79 | 'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart', |
80 | - array( 'EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart' ), |
|
80 | + array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'), |
|
81 | 81 | 10, 2 |
82 | 82 | ); |
83 | 83 | // handle emptied carts |
84 | 84 | add_action( |
85 | 85 | 'AHEE__EE_Session__reset_cart__before_reset', |
86 | - array( 'EED_Ticket_Sales_Monitor', 'session_cart_reset' ), |
|
86 | + array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
87 | 87 | 10, 1 |
88 | 88 | ); |
89 | 89 | add_action( |
90 | 90 | 'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart', |
91 | - array( 'EED_Ticket_Sales_Monitor', 'session_cart_reset' ), |
|
91 | + array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
92 | 92 | 10, 1 |
93 | 93 | ); |
94 | 94 | // handle cancelled registrations |
95 | 95 | add_action( |
96 | 96 | 'AHEE__EE_Session__reset_checkout__before_reset', |
97 | - array( 'EED_Ticket_Sales_Monitor', 'session_checkout_reset' ), |
|
97 | + array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'), |
|
98 | 98 | 10, 1 |
99 | 99 | ); |
100 | 100 | // cron tasks |
101 | 101 | add_action( |
102 | 102 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', |
103 | - array( 'EED_Ticket_Sales_Monitor', 'process_abandoned_transactions' ), |
|
103 | + array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
104 | 104 | 10, 1 |
105 | 105 | ); |
106 | 106 | add_action( |
107 | 107 | 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
108 | - array( 'EED_Ticket_Sales_Monitor', 'process_abandoned_transactions' ), |
|
108 | + array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
109 | 109 | 10, 1 |
110 | 110 | ); |
111 | 111 | add_action( |
112 | 112 | 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
113 | - array( 'EED_Ticket_Sales_Monitor', 'process_failed_transactions' ), |
|
113 | + array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'), |
|
114 | 114 | 10, 1 |
115 | 115 | ); |
116 | 116 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @return EED_Ticket_Sales_Monitor |
135 | 135 | */ |
136 | 136 | public static function instance() { |
137 | - return parent::get_instance( __CLASS__ ); |
|
137 | + return parent::get_instance(__CLASS__); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param WP_Query $WP_Query |
147 | 147 | * @return void |
148 | 148 | */ |
149 | - public function run( $WP_Query ) { |
|
149 | + public function run($WP_Query) { |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | * @param \EE_Ticket $ticket |
165 | 165 | * @return bool |
166 | 166 | */ |
167 | - public static function validate_ticket_sale( $qty = 1, EE_Ticket $ticket ) { |
|
168 | - $qty = absint( $qty ); |
|
169 | - if ( $qty > 0 ) { |
|
170 | - $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale( $ticket, $qty ); |
|
167 | + public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) { |
|
168 | + $qty = absint($qty); |
|
169 | + if ($qty > 0) { |
|
170 | + $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty); |
|
171 | 171 | } |
172 | - if ( self::debug ) { |
|
173 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
174 | - echo "\n qty: " . $qty; |
|
172 | + if (self::debug) { |
|
173 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
174 | + echo "\n qty: ".$qty; |
|
175 | 175 | } |
176 | 176 | return $qty; |
177 | 177 | } |
@@ -187,45 +187,45 @@ discard block |
||
187 | 187 | * @param int $qty |
188 | 188 | * @return int |
189 | 189 | */ |
190 | - protected function _validate_ticket_sale( EE_Ticket $ticket, $qty = 1 ) { |
|
191 | - if ( self::debug ) { |
|
192 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
190 | + protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) { |
|
191 | + if (self::debug) { |
|
192 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
193 | 193 | } |
194 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
194 | + if ( ! $ticket instanceof EE_Ticket) { |
|
195 | 195 | return 0; |
196 | 196 | } |
197 | - if ( self::debug ) { |
|
198 | - echo "\n . ticket->ID: " . $ticket->ID() . '<br />'; |
|
199 | - echo "\n . original ticket->reserved: " . $ticket->reserved() . '<br />'; |
|
197 | + if (self::debug) { |
|
198 | + echo "\n . ticket->ID: ".$ticket->ID().'<br />'; |
|
199 | + echo "\n . original ticket->reserved: ".$ticket->reserved().'<br />'; |
|
200 | 200 | } |
201 | 201 | $ticket->refresh_from_db(); |
202 | 202 | // first let's determine the ticket availability based on sales |
203 | - $available = $ticket->qty( 'saleable' ); |
|
204 | - if ( self::debug ) { |
|
205 | - echo "\n . . . ticket->qty: " . $ticket->qty() . '<br />'; |
|
206 | - echo "\n . . . ticket->sold: " . $ticket->sold() . '<br />'; |
|
207 | - echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />'; |
|
208 | - echo "\n . . . ticket->qty(saleable): " . $ticket->qty( 'saleable' ) . '<br />'; |
|
209 | - echo "\n . . . available: " . $available . '<br />'; |
|
210 | - } |
|
211 | - if ( $available < 1 ) { |
|
212 | - $this->_ticket_sold_out( $ticket ); |
|
203 | + $available = $ticket->qty('saleable'); |
|
204 | + if (self::debug) { |
|
205 | + echo "\n . . . ticket->qty: ".$ticket->qty().'<br />'; |
|
206 | + echo "\n . . . ticket->sold: ".$ticket->sold().'<br />'; |
|
207 | + echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />'; |
|
208 | + echo "\n . . . ticket->qty(saleable): ".$ticket->qty('saleable').'<br />'; |
|
209 | + echo "\n . . . available: ".$available.'<br />'; |
|
210 | + } |
|
211 | + if ($available < 1) { |
|
212 | + $this->_ticket_sold_out($ticket); |
|
213 | 213 | return 0; |
214 | 214 | } |
215 | - if ( self::debug ) { |
|
216 | - echo "\n . . . qty: " . $qty . '<br />'; |
|
215 | + if (self::debug) { |
|
216 | + echo "\n . . . qty: ".$qty.'<br />'; |
|
217 | 217 | } |
218 | - if ( $available < $qty ) { |
|
218 | + if ($available < $qty) { |
|
219 | 219 | $qty = $available; |
220 | - if ( self::debug ) { |
|
221 | - echo "\n . . . QTY ADJUSTED: " . $qty . '<br />'; |
|
220 | + if (self::debug) { |
|
221 | + echo "\n . . . QTY ADJUSTED: ".$qty.'<br />'; |
|
222 | 222 | } |
223 | - $this->_ticket_quantity_decremented( $ticket ); |
|
223 | + $this->_ticket_quantity_decremented($ticket); |
|
224 | 224 | } |
225 | - if ( self::debug ) { |
|
226 | - echo "\n\n . . . INCREASE RESERVED: " . $qty . '<br/><br/>'; |
|
225 | + if (self::debug) { |
|
226 | + echo "\n\n . . . INCREASE RESERVED: ".$qty.'<br/><br/>'; |
|
227 | 227 | } |
228 | - $this->_reserve_ticket( $ticket, $qty ); |
|
228 | + $this->_reserve_ticket($ticket, $qty); |
|
229 | 229 | return $qty; |
230 | 230 | } |
231 | 231 | |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | * @return bool |
242 | 242 | * @throws \EE_Error |
243 | 243 | */ |
244 | - protected function _reserve_ticket( EE_Ticket $ticket, $quantity = 1 ) { |
|
245 | - if ( self::debug ) { |
|
246 | - echo "\n\n . . . INCREASE RESERVED: " . $quantity . '<br/><br/>'; |
|
244 | + protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1) { |
|
245 | + if (self::debug) { |
|
246 | + echo "\n\n . . . INCREASE RESERVED: ".$quantity.'<br/><br/>'; |
|
247 | 247 | } |
248 | - $ticket->increase_reserved( $quantity ); |
|
248 | + $ticket->increase_reserved($quantity); |
|
249 | 249 | return $ticket->save(); |
250 | 250 | } |
251 | 251 | |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | * @return bool |
261 | 261 | * @throws \EE_Error |
262 | 262 | */ |
263 | - protected function _release_reserved_ticket( EE_Ticket $ticket, $quantity = 1 ) { |
|
264 | - if ( self::debug ) { |
|
265 | - echo "\n . . . ticket->ID: " . $ticket->ID() . '<br />'; |
|
266 | - echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />'; |
|
263 | + protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1) { |
|
264 | + if (self::debug) { |
|
265 | + echo "\n . . . ticket->ID: ".$ticket->ID().'<br />'; |
|
266 | + echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />'; |
|
267 | 267 | } |
268 | - $ticket->decrease_reserved( $quantity ); |
|
269 | - if ( self::debug ) { |
|
270 | - echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />'; |
|
268 | + $ticket->decrease_reserved($quantity); |
|
269 | + if (self::debug) { |
|
270 | + echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />'; |
|
271 | 271 | } |
272 | 272 | return $ticket->save() ? 1 : 0; |
273 | 273 | } |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | * @return bool |
284 | 284 | * @throws \EE_Error |
285 | 285 | */ |
286 | - protected function _ticket_sold_out( EE_Ticket $ticket ) { |
|
287 | - if ( self::debug ) { |
|
288 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
289 | - echo "\n . . ticket->name: " . $this->_get_ticket_and_event_name( $ticket ) . '<br />'; |
|
286 | + protected function _ticket_sold_out(EE_Ticket $ticket) { |
|
287 | + if (self::debug) { |
|
288 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
289 | + echo "\n . . ticket->name: ".$this->_get_ticket_and_event_name($ticket).'<br />'; |
|
290 | 290 | } |
291 | - $this->sold_out_tickets[] = $this->_get_ticket_and_event_name( $ticket ); |
|
291 | + $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | * @param \EE_Ticket $ticket |
302 | 302 | * @return bool |
303 | 303 | */ |
304 | - protected function _ticket_quantity_decremented( EE_Ticket $ticket ) { |
|
305 | - if ( self::debug ) { |
|
306 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
307 | - echo "\n . . ticket->name: " . $this->_get_ticket_and_event_name( $ticket ) . '<br />'; |
|
304 | + protected function _ticket_quantity_decremented(EE_Ticket $ticket) { |
|
305 | + if (self::debug) { |
|
306 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
307 | + echo "\n . . ticket->name: ".$this->_get_ticket_and_event_name($ticket).'<br />'; |
|
308 | 308 | } |
309 | - $this->decremented_tickets[] = $this->_get_ticket_and_event_name( $ticket ); |
|
309 | + $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | * @param \EE_Ticket $ticket |
320 | 320 | * @return string |
321 | 321 | */ |
322 | - protected function _get_ticket_and_event_name( EE_Ticket $ticket ) { |
|
322 | + protected function _get_ticket_and_event_name(EE_Ticket $ticket) { |
|
323 | 323 | $event = $ticket->get_related_event(); |
324 | - if ( $event instanceof EE_Event ) { |
|
324 | + if ($event instanceof EE_Event) { |
|
325 | 325 | $ticket_name = sprintf( |
326 | - _x( '%1$s for %2$s', 'ticket name for event name', 'event_espresso' ), |
|
326 | + _x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'), |
|
327 | 327 | $ticket->name(), |
328 | 328 | $event->name() |
329 | 329 | ); |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | * @param int $quantity |
349 | 349 | * @return void |
350 | 350 | */ |
351 | - public static function ticket_quantity_updated( EE_Line_Item $line_item, $quantity = 1 ) { |
|
352 | - $ticket = EEM_Ticket::instance()->get_one_by_ID( absint( $line_item->OBJ_ID() ) ); |
|
353 | - if ( $ticket instanceof EE_Ticket ) { |
|
354 | - if ( $quantity > 0 ) { |
|
355 | - EED_Ticket_Sales_Monitor::instance()->_reserve_ticket( $ticket, $quantity ); |
|
351 | + public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1) { |
|
352 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID())); |
|
353 | + if ($ticket instanceof EE_Ticket) { |
|
354 | + if ($quantity > 0) { |
|
355 | + EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity); |
|
356 | 356 | } else { |
357 | - EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket( $ticket, $quantity ); |
|
357 | + EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | } |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | * @param int $quantity |
371 | 371 | * @return void |
372 | 372 | */ |
373 | - public static function ticket_removed_from_cart( EE_Ticket $ticket, $quantity = 1 ) { |
|
374 | - EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket( $ticket, $quantity ); |
|
373 | + public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1) { |
|
374 | + EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -399,34 +399,34 @@ discard block |
||
399 | 399 | * @return void |
400 | 400 | */ |
401 | 401 | protected function _post_notices() { |
402 | - if ( self::debug ) { |
|
403 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
402 | + if (self::debug) { |
|
403 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
404 | 404 | } |
405 | - if ( ! empty( $this->sold_out_tickets ) ) { |
|
405 | + if ( ! empty($this->sold_out_tickets)) { |
|
406 | 406 | EE_Error::add_attention( |
407 | 407 | sprintf( |
408 | 408 | apply_filters( |
409 | 409 | 'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice', |
410 | - __( 'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso' ) |
|
410 | + __('We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso') |
|
411 | 411 | ), |
412 | 412 | '<br />', |
413 | - implode( '<br />', $this->sold_out_tickets ) |
|
413 | + implode('<br />', $this->sold_out_tickets) |
|
414 | 414 | ) |
415 | 415 | ); |
416 | 416 | // alter code flow in the Ticket Selector for better UX |
417 | - add_filter( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true' ); |
|
418 | - add_filter( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false' ); |
|
417 | + add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true'); |
|
418 | + add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false'); |
|
419 | 419 | $this->sold_out_tickets = array(); |
420 | 420 | } |
421 | - if ( ! empty( $this->decremented_tickets ) ) { |
|
421 | + if ( ! empty($this->decremented_tickets)) { |
|
422 | 422 | EE_Error::add_attention( |
423 | 423 | sprintf( |
424 | 424 | apply_filters( |
425 | 425 | 'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice', |
426 | - __( 'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso' ) |
|
426 | + __('We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso') |
|
427 | 427 | ), |
428 | 428 | '<br />', |
429 | - implode( '<br />', $this->decremented_tickets ) |
|
429 | + implode('<br />', $this->decremented_tickets) |
|
430 | 430 | ) |
431 | 431 | ); |
432 | 432 | $this->decremented_tickets = array(); |
@@ -448,27 +448,27 @@ discard block |
||
448 | 448 | * @param EE_Transaction $transaction |
449 | 449 | * @return int |
450 | 450 | */ |
451 | - protected function _release_all_reserved_tickets_for_transaction( EE_Transaction $transaction ) { |
|
452 | - if ( self::debug ) { |
|
453 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
454 | - echo "\n . transaction->ID: " . $transaction->ID() . '<br />'; |
|
451 | + protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) { |
|
452 | + if (self::debug) { |
|
453 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
454 | + echo "\n . transaction->ID: ".$transaction->ID().'<br />'; |
|
455 | 455 | } |
456 | 456 | /** @type EE_Transaction_Processor $transaction_processor */ |
457 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
457 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
458 | 458 | // check if 'finalize_registration' step has been completed... |
459 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
460 | - if ( self::debug ) { |
|
459 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
460 | + if (self::debug) { |
|
461 | 461 | // DEBUG LOG |
462 | 462 | EEH_Debug_Tools::log( |
463 | 463 | __CLASS__, __FUNCTION__, __LINE__, |
464 | - array( 'finalized' => $finalized ), |
|
465 | - false, 'EE_Transaction: ' . $transaction->ID() |
|
464 | + array('finalized' => $finalized), |
|
465 | + false, 'EE_Transaction: '.$transaction->ID() |
|
466 | 466 | ); |
467 | 467 | } |
468 | 468 | // how many tickets were released |
469 | 469 | $count = 0; |
470 | - if ( self::debug ) { |
|
471 | - echo "\n . . . finalized: " . $finalized . '<br />'; |
|
470 | + if (self::debug) { |
|
471 | + echo "\n . . . finalized: ".$finalized.'<br />'; |
|
472 | 472 | } |
473 | 473 | $release_tickets_with_TXN_status = array( |
474 | 474 | EEM_Transaction::failed_status_code, |
@@ -476,13 +476,13 @@ discard block |
||
476 | 476 | EEM_Transaction::incomplete_status_code, |
477 | 477 | ); |
478 | 478 | // if the session is getting cleared BEFORE the TXN has been finalized |
479 | - if ( ! $finalized || in_array( $transaction->status_ID(), $release_tickets_with_TXN_status ) ) { |
|
479 | + if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status)) { |
|
480 | 480 | // let's cancel any reserved tickets |
481 | 481 | $registrations = $transaction->registrations(); |
482 | - if ( ! empty( $registrations ) ) { |
|
483 | - foreach ( $registrations as $registration ) { |
|
484 | - if ( $registration instanceof EE_Registration ) { |
|
485 | - $count += $this->_release_reserved_ticket_for_registration( $registration, $transaction ); |
|
482 | + if ( ! empty($registrations)) { |
|
483 | + foreach ($registrations as $registration) { |
|
484 | + if ($registration instanceof EE_Registration) { |
|
485 | + $count += $this->_release_reserved_ticket_for_registration($registration, $transaction); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | } |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | * @return int |
504 | 504 | * @throws \EE_Error |
505 | 505 | */ |
506 | - protected function _release_reserved_ticket_for_registration( EE_Registration $registration, EE_Transaction $transaction ) { |
|
507 | - if ( self::debug ) { |
|
508 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
509 | - echo "\n . . registration->ID: " . $registration->ID() . '<br />'; |
|
510 | - echo "\n . . registration->status_ID: " . $registration->status_ID() . '<br />'; |
|
511 | - echo "\n . . transaction->status_ID(): " . $transaction->status_ID() . '<br />'; |
|
506 | + protected function _release_reserved_ticket_for_registration(EE_Registration $registration, EE_Transaction $transaction) { |
|
507 | + if (self::debug) { |
|
508 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
509 | + echo "\n . . registration->ID: ".$registration->ID().'<br />'; |
|
510 | + echo "\n . . registration->status_ID: ".$registration->status_ID().'<br />'; |
|
511 | + echo "\n . . transaction->status_ID(): ".$transaction->status_ID().'<br />'; |
|
512 | 512 | } |
513 | 513 | if ( |
514 | 514 | // release Tickets for Failed Transactions and Abandoned Transactions |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | ) |
522 | 522 | ) { |
523 | 523 | $ticket = $registration->ticket(); |
524 | - if ( $ticket instanceof EE_Ticket ) { |
|
525 | - return $this->_release_reserved_ticket( $ticket ); |
|
524 | + if ($ticket instanceof EE_Ticket) { |
|
525 | + return $this->_release_reserved_ticket($ticket); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | return 0; |
@@ -542,20 +542,20 @@ discard block |
||
542 | 542 | * @param EE_Session $session |
543 | 543 | * @return void |
544 | 544 | */ |
545 | - public static function session_cart_reset( EE_Session $session ) { |
|
546 | - if ( self::debug ) { |
|
547 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
545 | + public static function session_cart_reset(EE_Session $session) { |
|
546 | + if (self::debug) { |
|
547 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
548 | 548 | } |
549 | 549 | $cart = $session->cart(); |
550 | - if ( $cart instanceof EE_Cart ) { |
|
551 | - if ( self::debug ) { |
|
552 | - echo "\n\n cart instanceof EE_Cart: " . "<br />"; |
|
550 | + if ($cart instanceof EE_Cart) { |
|
551 | + if (self::debug) { |
|
552 | + echo "\n\n cart instanceof EE_Cart: "."<br />"; |
|
553 | 553 | } |
554 | - EED_Ticket_Sales_Monitor::instance()->_session_cart_reset( $cart ); |
|
554 | + EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart); |
|
555 | 555 | } else { |
556 | - if ( self::debug ) { |
|
557 | - echo "\n\n invalid EE_Cart: " . "<br />"; |
|
558 | - var_dump( $cart ); |
|
556 | + if (self::debug) { |
|
557 | + echo "\n\n invalid EE_Cart: "."<br />"; |
|
558 | + var_dump($cart); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | } |
@@ -570,30 +570,30 @@ discard block |
||
570 | 570 | * @param EE_Cart $cart |
571 | 571 | * @return void |
572 | 572 | */ |
573 | - protected function _session_cart_reset( EE_Cart $cart ) { |
|
574 | - if ( self::debug ) { |
|
575 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
573 | + protected function _session_cart_reset(EE_Cart $cart) { |
|
574 | + if (self::debug) { |
|
575 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
576 | 576 | } |
577 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
577 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
578 | 578 | $ticket_line_items = $cart->get_tickets(); |
579 | - if ( empty( $ticket_line_items ) ) { |
|
579 | + if (empty($ticket_line_items)) { |
|
580 | 580 | return; |
581 | 581 | } |
582 | - foreach ( $ticket_line_items as $ticket_line_item ) { |
|
583 | - if ( self::debug ) { |
|
584 | - echo "\n . ticket_line_item->ID(): " . $ticket_line_item->ID() . "<br />"; |
|
582 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
583 | + if (self::debug) { |
|
584 | + echo "\n . ticket_line_item->ID(): ".$ticket_line_item->ID()."<br />"; |
|
585 | 585 | } |
586 | - if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() == 'Ticket' ) { |
|
587 | - if ( self::debug ) { |
|
588 | - echo "\n . . ticket_line_item->OBJ_ID(): " . $ticket_line_item->OBJ_ID() . "<br />"; |
|
586 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() == 'Ticket') { |
|
587 | + if (self::debug) { |
|
588 | + echo "\n . . ticket_line_item->OBJ_ID(): ".$ticket_line_item->OBJ_ID()."<br />"; |
|
589 | 589 | } |
590 | - $ticket = EEM_Ticket::instance()->get_one_by_ID( $ticket_line_item->OBJ_ID() ); |
|
591 | - if ( $ticket instanceof EE_Ticket ) { |
|
592 | - if ( self::debug ) { |
|
593 | - echo "\n . . ticket->ID(): " . $ticket->ID() . "<br />"; |
|
594 | - echo "\n . . ticket_line_item->quantity(): " . $ticket_line_item->quantity() . "<br />"; |
|
590 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID()); |
|
591 | + if ($ticket instanceof EE_Ticket) { |
|
592 | + if (self::debug) { |
|
593 | + echo "\n . . ticket->ID(): ".$ticket->ID()."<br />"; |
|
594 | + echo "\n . . ticket_line_item->quantity(): ".$ticket_line_item->quantity()."<br />"; |
|
595 | 595 | } |
596 | - $this->_release_reserved_ticket( $ticket, $ticket_line_item->quantity() ); |
|
596 | + $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity()); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
@@ -613,10 +613,10 @@ discard block |
||
613 | 613 | * @param EE_Session $session |
614 | 614 | * @return void |
615 | 615 | */ |
616 | - public static function session_checkout_reset( EE_Session $session ) { |
|
616 | + public static function session_checkout_reset(EE_Session $session) { |
|
617 | 617 | $checkout = $session->checkout(); |
618 | - if ( $checkout instanceof EE_Checkout ) { |
|
619 | - EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset( $checkout ); |
|
618 | + if ($checkout instanceof EE_Checkout) { |
|
619 | + EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
@@ -630,15 +630,15 @@ discard block |
||
630 | 630 | * @param EE_Checkout $checkout |
631 | 631 | * @return void |
632 | 632 | */ |
633 | - protected function _session_checkout_reset( EE_Checkout $checkout ) { |
|
634 | - if ( self::debug ) { |
|
635 | - echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
|
633 | + protected function _session_checkout_reset(EE_Checkout $checkout) { |
|
634 | + if (self::debug) { |
|
635 | + echo "\n\n ".__LINE__.") ".__METHOD__."() <br />"; |
|
636 | 636 | } |
637 | 637 | // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit |
638 | - if ( $checkout->revisit || ! $checkout->transaction instanceof EE_Transaction ) { |
|
638 | + if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) { |
|
639 | 639 | return; |
640 | 640 | } |
641 | - $this->_release_all_reserved_tickets_for_transaction( $checkout->transaction ); |
|
641 | + $this->_release_all_reserved_tickets_for_transaction($checkout->transaction); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @param EE_Session $session |
655 | 655 | * @return void |
656 | 656 | */ |
657 | - public static function session_expired_reset( EE_Session $session ) { |
|
657 | + public static function session_expired_reset(EE_Session $session) { |
|
658 | 658 | |
659 | 659 | } |
660 | 660 | |
@@ -673,30 +673,30 @@ discard block |
||
673 | 673 | * @param EE_Transaction $transaction |
674 | 674 | * @return void |
675 | 675 | */ |
676 | - public static function process_abandoned_transactions( EE_Transaction $transaction ) { |
|
676 | + public static function process_abandoned_transactions(EE_Transaction $transaction) { |
|
677 | 677 | // is this TXN free or has any money been paid towards this TXN? If so, then leave it alone |
678 | - if ( $transaction->is_free() || $transaction->paid() > 0 ) { |
|
679 | - if ( self::debug ) { |
|
678 | + if ($transaction->is_free() || $transaction->paid() > 0) { |
|
679 | + if (self::debug) { |
|
680 | 680 | // DEBUG LOG |
681 | 681 | EEH_Debug_Tools::log( |
682 | 682 | __CLASS__, __FUNCTION__, __LINE__, |
683 | - array( $transaction ), |
|
684 | - false, 'EE_Transaction: ' . $transaction->ID() |
|
683 | + array($transaction), |
|
684 | + false, 'EE_Transaction: '.$transaction->ID() |
|
685 | 685 | ); |
686 | 686 | } |
687 | 687 | return; |
688 | 688 | } |
689 | 689 | // have their been any successful payments made ? |
690 | 690 | $payments = $transaction->payments(); |
691 | - foreach ( $payments as $payment ) { |
|
692 | - if ( $payment instanceof EE_Payment ) { |
|
693 | - if ( $payment->status() === EEM_Payment::status_id_approved ) { |
|
694 | - if ( self::debug ) { |
|
691 | + foreach ($payments as $payment) { |
|
692 | + if ($payment instanceof EE_Payment) { |
|
693 | + if ($payment->status() === EEM_Payment::status_id_approved) { |
|
694 | + if (self::debug) { |
|
695 | 695 | // DEBUG LOG |
696 | 696 | EEH_Debug_Tools::log( |
697 | 697 | __CLASS__, __FUNCTION__, __LINE__, |
698 | - array( $payment ), |
|
699 | - false, 'EE_Transaction: ' . $transaction->ID() |
|
698 | + array($payment), |
|
699 | + false, 'EE_Transaction: '.$transaction->ID() |
|
700 | 700 | ); |
701 | 701 | } |
702 | 702 | return; |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | } |
705 | 705 | } |
706 | 706 | // since you haven't even attempted to pay for your ticket... |
707 | - EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction( $transaction ); |
|
707 | + EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | |
@@ -721,9 +721,9 @@ discard block |
||
721 | 721 | * @param EE_Transaction $transaction |
722 | 722 | * @return void |
723 | 723 | */ |
724 | - public static function process_failed_transactions( EE_Transaction $transaction ) { |
|
724 | + public static function process_failed_transactions(EE_Transaction $transaction) { |
|
725 | 725 | // since you haven't even attempted to pay for your ticket... |
726 | - EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction( $transaction ); |
|
726 | + EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @access public |
543 | 543 | * @access public |
544 | - * @return string |
|
544 | + * @return false|null |
|
545 | 545 | */ |
546 | 546 | public static function cancel_ticket_selections() { |
547 | 547 | // check nonce |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @access public |
610 | 610 | * @access public |
611 | - * @return bool |
|
611 | + * @return boolean|null |
|
612 | 612 | */ |
613 | 613 | public function process_ticket_selections() { |
614 | 614 | do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | * @return EED_Ticket_Selector |
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | - return parent::get_instance( __CLASS__ ); |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function set_config(){ |
|
66 | - $this->set_config_section( 'template_settings' ); |
|
67 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
68 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
65 | + protected function set_config() { |
|
66 | + $this->set_config_section('template_settings'); |
|
67 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
68 | + $this->set_config_name('EED_Ticket_Selector'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function set_hooks() { |
82 | 82 | // routing |
83 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
84 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
85 | - EE_Config::register_route( 'cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections' ); |
|
86 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
83 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
84 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
85 | + EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
|
86 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
87 | 87 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
88 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
88 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
89 | 89 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
90 | 90 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
91 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
91 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | * @return void |
101 | 101 | */ |
102 | 102 | public static function set_hooks_admin() { |
103 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
103 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
104 | 104 | //add button for iframe code to event editor. |
105 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
106 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
105 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
106 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | * @return void |
116 | 116 | */ |
117 | 117 | public static function set_definitions() { |
118 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
119 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
118 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
119 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
120 | 120 | |
121 | 121 | //if config is not set, initialize |
122 | 122 | //If config is not set, set it. |
123 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
123 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
124 | 124 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
125 | 125 | } |
126 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
126 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param object $WP |
135 | 135 | * @return void |
136 | 136 | */ |
137 | - public function run( $WP ) {} |
|
137 | + public function run($WP) {} |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -146,23 +146,23 @@ discard block |
||
146 | 146 | public function ticket_selector_iframe() { |
147 | 147 | self::$_in_iframe = true; |
148 | 148 | /** @type EEM_Event $EEM_Event */ |
149 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
149 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
150 | 150 | $event = $EEM_Event->get_one_by_ID( |
151 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
151 | + EE_Registry::instance()->REQ->get('event', 0) |
|
152 | 152 | ); |
153 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
154 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
153 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
154 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
155 | 155 | $template_args['css'] = apply_filters( |
156 | 156 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
157 | 157 | array( |
158 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
159 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
160 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
161 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
158 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
159 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
160 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
161 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
162 | 162 | ) |
163 | 163 | ); |
164 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
165 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
164 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
165 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
166 | 166 | $template_args['eei18n'] = apply_filters( |
167 | 167 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
168 | 168 | EE_Registry::localize_i18n_js_strings() |
@@ -170,19 +170,19 @@ discard block |
||
170 | 170 | $template_args['js'] = apply_filters( |
171 | 171 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
172 | 172 | array( |
173 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
174 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
175 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
173 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
174 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
175 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
176 | 176 | ) |
177 | 177 | ); |
178 | 178 | EE_Registry::instance()->load_helper('Template'); |
179 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
180 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
179 | + $template_args['notices'] = EEH_Template::display_template( |
|
180 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
181 | 181 | array(), |
182 | 182 | true |
183 | 183 | ); |
184 | 184 | EEH_Template::display_template( |
185 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
185 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
186 | 186 | $template_args |
187 | 187 | ); |
188 | 188 | exit; |
@@ -201,23 +201,23 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string The new html string for the permalink area. |
203 | 203 | */ |
204 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
204 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
205 | 205 | //make sure this is ONLY when editing and the event id has been set. |
206 | - if ( ! empty( $id ) ) { |
|
207 | - $post = get_post( $id ); |
|
206 | + if ( ! empty($id)) { |
|
207 | + $post = get_post($id); |
|
208 | 208 | |
209 | 209 | //if NOT event then let's get out. |
210 | - if ( $post->post_type !== 'espresso_events' ) { |
|
210 | + if ($post->post_type !== 'espresso_events') { |
|
211 | 211 | return $permalink_string; |
212 | 212 | } |
213 | 213 | |
214 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
214 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
215 | 215 | |
216 | - $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' . __('Embed', 'event_espresso') . '</a> '; |
|
216 | + $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">'.__('Embed', 'event_espresso').'</a> '; |
|
217 | 217 | $permalink_string .= ' |
218 | 218 | <div id="js-ts-iframe" style="display:none"> |
219 | 219 | <div style="width:100%; height: 500px;"> |
220 | - <iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe> |
|
220 | + <iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe> |
|
221 | 221 | </div> |
222 | 222 | </div>'; |
223 | 223 | } |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | * @param mixed $event |
237 | 237 | * @return bool |
238 | 238 | */ |
239 | - protected static function set_event( $event = null ) { |
|
240 | - if( $event === null ) { |
|
239 | + protected static function set_event($event = null) { |
|
240 | + if ($event === null) { |
|
241 | 241 | global $post; |
242 | 242 | $event = $post; |
243 | 243 | } |
244 | - if ( $event instanceof EE_Event ) { |
|
244 | + if ($event instanceof EE_Event) { |
|
245 | 245 | self::$_event = $event; |
246 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
246 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
247 | 247 | self::$_event = $event->EE_Event; |
248 | - } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
|
249 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
248 | + } else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') { |
|
249 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
250 | 250 | self::$_event = $event->EE_Event; |
251 | 251 | } else { |
252 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
253 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
254 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
252 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
253 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
254 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | return true; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * @param bool $view_details |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
273 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
274 | 274 | // reset filter for displaying submit button |
275 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
275 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
276 | 276 | // poke and prod incoming event till it tells us what it is |
277 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
277 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | && ( |
286 | 286 | ! self::$_event->display_ticket_selector() |
287 | 287 | || $view_details |
288 | - || post_password_required( $event_post ) |
|
288 | + || post_password_required($event_post) |
|
289 | 289 | || ( |
290 | 290 | $_event_active_status != EE_Datetime::active |
291 | 291 | && $_event_active_status != EE_Datetime::upcoming |
@@ -303,70 +303,70 @@ discard block |
||
303 | 303 | $template_args = array(); |
304 | 304 | $template_args['event_status'] = $_event_active_status; |
305 | 305 | |
306 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
307 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
306 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
307 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
308 | 308 | |
309 | 309 | $template_args['EVT_ID'] = self::$_event->ID(); |
310 | 310 | $template_args['event'] = self::$_event; |
311 | 311 | |
312 | 312 | // is the event expired ? |
313 | 313 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
314 | - if ( $template_args['event_is_expired'] ) { |
|
315 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
314 | + if ($template_args['event_is_expired']) { |
|
315 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $ticket_query_args = array( |
319 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
320 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
319 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
320 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
321 | 321 | ); |
322 | 322 | |
323 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
323 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
324 | 324 | //use the correct applicable time query depending on what version of core is being run. |
325 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
326 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
325 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
326 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | // get all tickets for this event ordered by the datetime |
330 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
330 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
331 | 331 | |
332 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
333 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
332 | + if (count($template_args['tickets']) < 1) { |
|
333 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
337 | - $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
|
338 | - if ( $template_args['max_atndz'] < 1 ) { |
|
339 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
340 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
341 | - $sales_closed_msg .= sprintf( |
|
342 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
337 | + $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); |
|
338 | + if ($template_args['max_atndz'] < 1) { |
|
339 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
340 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
341 | + $sales_closed_msg .= sprintf( |
|
342 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
343 | 343 | '<div class="ee-attention" style="text-align: left;"><b>', |
344 | 344 | '</b><br />', |
345 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
345 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
346 | 346 | '</a></span></div>' |
347 | 347 | ); |
348 | 348 | } |
349 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
349 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
350 | 350 | } |
351 | 351 | |
352 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
353 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
352 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
353 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
354 | 354 | |
355 | 355 | // redirecting to another site for registration ?? |
356 | 356 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
357 | 357 | // set up the form (but not for the admin) |
358 | - $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
|
358 | + $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; |
|
359 | 359 | // if not redirecting to another site for registration |
360 | - if ( ! $external_url ) { |
|
361 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
362 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
360 | + if ( ! $external_url) { |
|
361 | + EE_Registry::instance()->load_helper('Template'); |
|
362 | + EE_Registry::instance()->load_helper('URL'); |
|
363 | 363 | // then display the ticket selector |
364 | - $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
364 | + $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
365 | 365 | } else { |
366 | 366 | // if not we still need to trigger the display of the submit button |
367 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
367 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
368 | 368 | //display notice to admin that registration is external |
369 | - $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
369 | + $ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
370 | 370 | } |
371 | 371 | // submit button and form close tag |
372 | 372 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -386,27 +386,27 @@ discard block |
||
386 | 386 | * @param string $external_url |
387 | 387 | * @return string |
388 | 388 | */ |
389 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
389 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
390 | 390 | // if redirecting, we don't need any anything else |
391 | - if ( $external_url ) { |
|
392 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
393 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
394 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
395 | - foreach ( $query_args as $query_arg => $value ) { |
|
396 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
391 | + if ($external_url) { |
|
392 | + EE_Registry::instance()->load_helper('URL'); |
|
393 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
394 | + $query_args = EEH_URL::get_query_string($external_url); |
|
395 | + foreach ($query_args as $query_arg => $value) { |
|
396 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
397 | 397 | } |
398 | 398 | return $html; |
399 | 399 | } |
400 | - EE_Registry::instance()->load_helper( 'Event_View' ); |
|
401 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
402 | - if ( ! $checkout_url ) { |
|
403 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
400 | + EE_Registry::instance()->load_helper('Event_View'); |
|
401 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
402 | + if ( ! $checkout_url) { |
|
403 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
404 | 404 | } |
405 | 405 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
406 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
407 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
|
406 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
407 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); |
|
408 | 408 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
409 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
409 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
410 | 410 | return $html; |
411 | 411 | } |
412 | 412 | |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | * @return string |
422 | 422 | */ |
423 | 423 | public static function display_ticket_selector_submit() { |
424 | - if ( ! is_admin() ) { |
|
425 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
|
424 | + if ( ! is_admin()) { |
|
425 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) { |
|
426 | 426 | $btn_text = apply_filters( |
427 | 427 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
428 | - __('Register Now', 'event_espresso' ), |
|
428 | + __('Register Now', 'event_espresso'), |
|
429 | 429 | self::$_event |
430 | 430 | ); |
431 | - $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
|
431 | + $html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"'; |
|
432 | 432 | $html .= ' class="ticket-selector-submit-btn ticket-selector-submit-ajax"'; |
433 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
434 | - $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
|
433 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
434 | + $html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event); |
|
435 | 435 | $html .= '<div class="clear"><br/></div></form>'; |
436 | 436 | return $html; |
437 | - } else if ( is_archive() ) { |
|
438 | - return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
|
439 | - } else if ( EE_Registry::instance()->SSN->cart() instanceof EE_Cart ) { |
|
440 | - if ( ! EE_Registry::instance()->SSN->cart()->all_ticket_quantity_count() ) { |
|
437 | + } else if (is_archive()) { |
|
438 | + return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn(); |
|
439 | + } else if (EE_Registry::instance()->SSN->cart() instanceof EE_Cart) { |
|
440 | + if ( ! EE_Registry::instance()->SSN->cart()->all_ticket_quantity_count()) { |
|
441 | 441 | return ''; |
442 | 442 | } |
443 | 443 | return EED_Ticket_Selector::display_proceed_btn_when_tickets_in_cart(); |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | $html .= '">'; |
466 | 466 | $html .= apply_filters( |
467 | 467 | 'FHEE__EED_Ticket_Selector__proceed_to_registration_btn_txt', |
468 | - __( 'Proceed to Registration', 'event_espresso' ) |
|
468 | + __('Proceed to Registration', 'event_espresso') |
|
469 | 469 | ); |
470 | 470 | $html .= ' <span class="dashicons dashicons-arrow-right-alt2"></span>'; |
471 | 471 | $html .= '</a>'; |
472 | 472 | $html .= '<div class="clear"></div>'; |
473 | - $cancel_url = EEH_Event_View::event_link_url( self::$_event->ID() ); |
|
473 | + $cancel_url = EEH_Event_View::event_link_url(self::$_event->ID()); |
|
474 | 474 | $cancel_url = add_query_arg( |
475 | 475 | array( |
476 | 476 | 'ee' => 'cancel_ticket_selections', |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | ), |
480 | 480 | $cancel_url |
481 | 481 | ); |
482 | - $cancel_url = wp_nonce_url( $cancel_url, 'cancel_ticket_selections', 'cancel_ticket_selections_nonce' ); |
|
483 | - $html .= '<a class="ticket-selector-submit-btn small-text" href="' . $cancel_url . '">'; |
|
482 | + $cancel_url = wp_nonce_url($cancel_url, 'cancel_ticket_selections', 'cancel_ticket_selections_nonce'); |
|
483 | + $html .= '<a class="ticket-selector-submit-btn small-text" href="'.$cancel_url.'">'; |
|
484 | 484 | $html .= apply_filters( |
485 | 485 | 'FHEE__EED_Ticket_Selector__cancel_ticket_selections_txt', |
486 | - __( 'cancel ticket selection', 'event_espresso' ) |
|
486 | + __('cancel ticket selection', 'event_espresso') |
|
487 | 487 | ); |
488 | 488 | $html .= '</a>'; |
489 | 489 | $html .= '<div class="clear"><br/></div>'; |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | * @return string |
517 | 517 | */ |
518 | 518 | public static function display_view_details_btn() { |
519 | - if ( ! self::$_event->get_permalink() ) { |
|
520 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
519 | + if ( ! self::$_event->get_permalink()) { |
|
520 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
521 | 521 | } |
522 | 522 | $view_details_btn = '<form method="POST" action="'; |
523 | 523 | $view_details_btn .= apply_filters( |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | self::$_event |
527 | 527 | ); |
528 | 528 | $view_details_btn .= '">'; |
529 | - $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
|
530 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
531 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
529 | + $btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event); |
|
530 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
531 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
532 | 532 | $view_details_btn .= '<div class="clear"><br/></div>'; |
533 | 533 | $view_details_btn .= '</form>'; |
534 | 534 | return $view_details_btn; |
@@ -545,19 +545,19 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public static function cancel_ticket_selections() { |
547 | 547 | // check nonce |
548 | - if ( ! EED_Ticket_Selector::process_ticket_selector_nonce( 'cancel_ticket_selections_nonce' ) ) { |
|
548 | + if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('cancel_ticket_selections_nonce')) { |
|
549 | 549 | return false; |
550 | 550 | } |
551 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__ ); |
|
552 | - if ( EE_Registry::instance()->REQ->is_set( 'event_id' ) ) { |
|
551 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
552 | + if (EE_Registry::instance()->REQ->is_set('event_id')) { |
|
553 | 553 | wp_safe_redirect( |
554 | 554 | EEH_Event_View::event_link_url( |
555 | - EE_Registry::instance()->REQ->get( 'event_id' ) |
|
555 | + EE_Registry::instance()->REQ->get('event_id') |
|
556 | 556 | ) |
557 | 557 | ); |
558 | 558 | } else { |
559 | 559 | wp_safe_redirect( |
560 | - site_url( '/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/' ) |
|
560 | + site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/') |
|
561 | 561 | ); |
562 | 562 | } |
563 | 563 | die(); |
@@ -572,15 +572,15 @@ discard block |
||
572 | 572 | * @param string $nonce_name |
573 | 573 | * @return bool |
574 | 574 | */ |
575 | - public static function process_ticket_selector_nonce( $nonce_name ) { |
|
575 | + public static function process_ticket_selector_nonce($nonce_name) { |
|
576 | 576 | if ( |
577 | 577 | ! is_admin() |
578 | 578 | && ( |
579 | - ! EE_Registry::instance()->REQ->is_set( $nonce_name ) |
|
579 | + ! EE_Registry::instance()->REQ->is_set($nonce_name) |
|
580 | 580 | || |
581 | 581 | ! wp_verify_nonce( |
582 | - EE_Registry::instance()->REQ->get( $nonce_name ), |
|
583 | - str_replace( '_nonce', '', $nonce_name ) |
|
582 | + EE_Registry::instance()->REQ->get($nonce_name), |
|
583 | + str_replace('_nonce', '', $nonce_name) |
|
584 | 584 | ) |
585 | 585 | ) |
586 | 586 | ) { |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | * @return bool |
612 | 612 | */ |
613 | 613 | public function process_ticket_selections() { |
614 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
614 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
615 | 615 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
616 | 616 | // check nonce |
617 | - if ( ! EED_Ticket_Selector::process_ticket_selector_nonce( 'process_ticket_selections_nonce' ) ) { |
|
617 | + if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('process_ticket_selections_nonce')) { |
|
618 | 618 | return false; |
619 | 619 | } |
620 | 620 | |
@@ -624,111 +624,111 @@ discard block |
||
624 | 624 | ); |
625 | 625 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
626 | 626 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
627 | - EE_Registry::instance()->load_core( 'Session' ); |
|
627 | + EE_Registry::instance()->load_core('Session'); |
|
628 | 628 | // unless otherwise requested, clear the session |
629 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
630 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
629 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
630 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
631 | 631 | } |
632 | 632 | //d( EE_Registry::instance()->SSN ); |
633 | 633 | |
634 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
634 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
635 | 635 | // do we have an event id? |
636 | - if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
636 | + if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
637 | 637 | // validate/sanitize data |
638 | 638 | $valid = self::_validate_post_data(); |
639 | 639 | //check total tickets ordered vs max number of attendees that can register |
640 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
640 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
641 | 641 | |
642 | 642 | // ordering too many tickets !!! |
643 | 643 | $singular = 'You have attempted to purchase %s ticket.'; |
644 | 644 | $plural = 'You have attempted to purchase %s tickets.'; |
645 | - $limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] ); |
|
645 | + $limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']); |
|
646 | 646 | // dev only message |
647 | 647 | $singular = 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
648 | 648 | $plural = 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
649 | - $limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] ); |
|
650 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
649 | + $limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']); |
|
650 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
651 | 651 | } else { |
652 | 652 | |
653 | 653 | // all data appears to be valid |
654 | 654 | $tckts_slctd = false; |
655 | 655 | $tickets_added = 0; |
656 | 656 | // validate/sanitize data |
657 | - $valid = apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid ); |
|
658 | - if ( $valid[ 'total_tickets' ] >0 ) { |
|
657 | + $valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid); |
|
658 | + if ($valid['total_tickets'] > 0) { |
|
659 | 659 | // load cart |
660 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
660 | + EE_Registry::instance()->load_core('Cart'); |
|
661 | 661 | |
662 | 662 | // cycle thru the number of data rows sent from the event listing |
663 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
663 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
664 | 664 | // does this row actually contain a ticket quantity? |
665 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
665 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
666 | 666 | // YES we have a ticket quantity |
667 | 667 | $tckts_slctd = TRUE; |
668 | 668 | // d( $valid['ticket_obj'][$x] ); |
669 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
669 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
670 | 670 | // then add ticket to cart |
671 | - $tickets_added += self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
671 | + $tickets_added += self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
672 | 672 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />"; |
673 | 673 | //echo "\n . ticket_added: " . $ticket_added . '<br />'; |
674 | - if ( EE_Error::has_error() ) { |
|
674 | + if (EE_Error::has_error()) { |
|
675 | 675 | break; |
676 | 676 | } |
677 | 677 | } else { |
678 | 678 | // nothing added to cart retrieved |
679 | 679 | EE_Error::add_error( |
680 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
680 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
681 | 681 | __FILE__, __FUNCTION__, __LINE__ |
682 | 682 | ); |
683 | 683 | } |
684 | 684 | } |
685 | 685 | } |
686 | 686 | } |
687 | - do_action( 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', EE_Registry::instance()->CART, $this ); |
|
687 | + do_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', EE_Registry::instance()->CART, $this); |
|
688 | 688 | //d( EE_Registry::instance()->CART ); |
689 | 689 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
690 | 690 | |
691 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd ) ) { |
|
692 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added ) ) { |
|
693 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
691 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) { |
|
692 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
693 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
694 | 694 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
695 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
695 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
696 | 696 | EE_Registry::instance()->SSN->update(); |
697 | 697 | //d( EE_Registry::instance()->CART ); |
698 | 698 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
699 | 699 | // just return TRUE for registrations being made from admin |
700 | - if ( is_admin() ) { |
|
700 | + if (is_admin()) { |
|
701 | 701 | return TRUE; |
702 | 702 | } |
703 | 703 | |
704 | - EE_Error::get_notices( false, true ); |
|
705 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
704 | + EE_Error::get_notices(false, true); |
|
705 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
706 | 706 | exit(); |
707 | 707 | |
708 | 708 | } else { |
709 | - if ( ! EE_Error::has_error() ) { |
|
709 | + if ( ! EE_Error::has_error()) { |
|
710 | 710 | // nothing added to cart |
711 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
711 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
715 | 715 | } else { |
716 | 716 | // no ticket quantities were selected |
717 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
717 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
721 | 721 | // at this point, just return if registration is being made from admin |
722 | - if ( is_admin() ) { |
|
722 | + if (is_admin()) { |
|
723 | 723 | return FALSE; |
724 | 724 | } |
725 | - if ( $valid['return_url'] ) { |
|
726 | - EE_Error::get_notices( FALSE, TRUE ); |
|
727 | - wp_safe_redirect( $valid['return_url'] ); |
|
725 | + if ($valid['return_url']) { |
|
726 | + EE_Error::get_notices(FALSE, TRUE); |
|
727 | + wp_safe_redirect($valid['return_url']); |
|
728 | 728 | exit(); |
729 | - } elseif ( isset( $event_to_add['id'] )) { |
|
730 | - EE_Error::get_notices( FALSE, TRUE ); |
|
731 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
729 | + } elseif (isset($event_to_add['id'])) { |
|
730 | + EE_Error::get_notices(FALSE, TRUE); |
|
731 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
732 | 732 | exit(); |
733 | 733 | } else { |
734 | 734 | echo EE_Error::get_notices(); |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | } else { |
738 | 738 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
739 | 739 | EE_Error::add_error( |
740 | - sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
740 | + sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
741 | 741 | __FILE__, __FUNCTION__, __LINE__ |
742 | 742 | ); |
743 | 743 | } |
@@ -755,18 +755,18 @@ discard block |
||
755 | 755 | * @return array or FALSE |
756 | 756 | */ |
757 | 757 | private static function _validate_post_data() { |
758 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
758 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
759 | 759 | |
760 | 760 | // start with an empty array() |
761 | 761 | $valid_data = array(); |
762 | 762 | // d( $_POST ); |
763 | 763 | //if event id is valid |
764 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' )); |
|
765 | - if ( $id ) { |
|
764 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
765 | + if ($id) { |
|
766 | 766 | // grab valid id |
767 | 767 | $valid_data['id'] = $id; |
768 | 768 | // grab and sanitize return-url |
769 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
769 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
770 | 770 | // array of other form names |
771 | 771 | $inputs_to_clean = array( |
772 | 772 | 'event_id' => 'tkt-slctr-event-id', |
@@ -779,22 +779,22 @@ discard block |
||
779 | 779 | // let's track the total number of tickets ordered.' |
780 | 780 | $valid_data['total_tickets'] = 0; |
781 | 781 | // cycle through $inputs_to_clean array |
782 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
782 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
783 | 783 | // check for POST data |
784 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
784 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
785 | 785 | // grab value |
786 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
786 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
787 | 787 | switch ($what) { |
788 | 788 | |
789 | 789 | // integers |
790 | 790 | case 'event_id': |
791 | - $valid_data[$what] = absint( $input_value ); |
|
791 | + $valid_data[$what] = absint($input_value); |
|
792 | 792 | // get event via the event id we put in the form |
793 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
793 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
794 | 794 | break; |
795 | 795 | case 'rows': |
796 | 796 | case 'max_atndz': |
797 | - $valid_data[$what] = absint( $input_value ); |
|
797 | + $valid_data[$what] = absint($input_value); |
|
798 | 798 | break; |
799 | 799 | |
800 | 800 | // arrays of integers |
@@ -802,27 +802,27 @@ discard block |
||
802 | 802 | // d( $input_value ); |
803 | 803 | $row_qty = $input_value; |
804 | 804 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
805 | - if( ! is_array( $row_qty )) { |
|
805 | + if ( ! is_array($row_qty)) { |
|
806 | 806 | // get number of rows |
807 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
807 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
808 | 808 | // d( $rows ); |
809 | 809 | // explode ints by the dash |
810 | - $row_qty = explode( '-', $row_qty ); |
|
811 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
812 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
813 | - $row_qty = array( $row => $qty ); |
|
810 | + $row_qty = explode('-', $row_qty); |
|
811 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
812 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
813 | + $row_qty = array($row => $qty); |
|
814 | 814 | // d( $row_qty ); |
815 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
816 | - if ( ! isset( $row_qty[$x] )) { |
|
815 | + for ($x = 1; $x <= $rows; $x++) { |
|
816 | + if ( ! isset($row_qty[$x])) { |
|
817 | 817 | $row_qty[$x] = 0; |
818 | 818 | } |
819 | 819 | } |
820 | 820 | } |
821 | - ksort( $row_qty ); |
|
821 | + ksort($row_qty); |
|
822 | 822 | // d( $row_qty ); |
823 | 823 | // cycle thru values |
824 | - foreach ( $row_qty as $qty ) { |
|
825 | - $qty = absint( $qty ); |
|
824 | + foreach ($row_qty as $qty) { |
|
825 | + $qty = absint($qty); |
|
826 | 826 | // sanitize as integers |
827 | 827 | $valid_data[$what][] = $qty; |
828 | 828 | $valid_data['total_tickets'] += $qty; |
@@ -833,19 +833,19 @@ discard block |
||
833 | 833 | case 'ticket_id': |
834 | 834 | $value_array = array(); |
835 | 835 | // cycle thru values |
836 | - foreach ( $input_value as $key=>$value ) { |
|
836 | + foreach ($input_value as $key=>$value) { |
|
837 | 837 | // allow only numbers, letters, spaces, commas and dashes |
838 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
838 | + $value_array[$key] = wp_strip_all_tags($value); |
|
839 | 839 | // get ticket via the ticket id we put in the form |
840 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
841 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
840 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
841 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
842 | 842 | } |
843 | - $valid_data[ $what ] = $value_array; |
|
843 | + $valid_data[$what] = $value_array; |
|
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'return_url' : |
847 | 847 | // grab and sanitize return-url |
848 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
848 | + $valid_data[$what] = esc_url_raw($input_value); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | } // end switch $what |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | } // end foreach $inputs_to_clean |
854 | 854 | |
855 | 855 | } else { |
856 | - EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
856 | + EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
857 | 857 | return FALSE; |
858 | 858 | } |
859 | 859 | |
@@ -871,12 +871,12 @@ discard block |
||
871 | 871 | * @param int $qty |
872 | 872 | * @return int quantity of tickets added |
873 | 873 | */ |
874 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
875 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
874 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
875 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
876 | 876 | // get the number of spaces left for this datetime ticket |
877 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
877 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
878 | 878 | // compare available spaces against the number of tickets being purchased |
879 | - if ( $available_spaces >= $qty ) { |
|
879 | + if ($available_spaces >= $qty) { |
|
880 | 880 | // allow addons to prevent a ticket from being added to cart |
881 | 881 | if ( |
882 | 882 | ! apply_filters( |
@@ -889,10 +889,10 @@ discard block |
||
889 | 889 | ) { |
890 | 890 | return 0; |
891 | 891 | } |
892 | - $qty = apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket ); |
|
892 | + $qty = apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket); |
|
893 | 893 | // add event to cart |
894 | - if( $qty && EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
895 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
894 | + if ($qty && EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
895 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
896 | 896 | return $qty; |
897 | 897 | } else { |
898 | 898 | return 0; |
@@ -900,9 +900,9 @@ discard block |
||
900 | 900 | } else { |
901 | 901 | // tickets can not be purchased but let's find the exact number left |
902 | 902 | // for the last ticket selected PRIOR to subtracting tickets |
903 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
903 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
904 | 904 | // greedy greedy greedy eh? |
905 | - if ( $available_spaces > 0 ) { |
|
905 | + if ($available_spaces > 0) { |
|
906 | 906 | if ( |
907 | 907 | apply_filters( |
908 | 908 | 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error', |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | $available_spaces |
913 | 913 | ) |
914 | 914 | ) { |
915 | - EED_Ticket_Selector::_display_availability_error( $available_spaces ); |
|
915 | + EED_Ticket_Selector::_display_availability_error($available_spaces); |
|
916 | 916 | } |
917 | 917 | } else { |
918 | 918 | EE_Error::add_error( |
@@ -937,10 +937,10 @@ discard block |
||
937 | 937 | * @access private |
938 | 938 | * @param int $available_spaces |
939 | 939 | */ |
940 | - private static function _display_availability_error( $available_spaces = 1 ) { |
|
940 | + private static function _display_availability_error($available_spaces = 1) { |
|
941 | 941 | // add error messaging - we're using the _n function that will generate |
942 | 942 | // the appropriate singular or plural message based on the number of $available_spaces |
943 | - if ( EE_Registry::instance()->CART->all_ticket_quantity_count() ) { |
|
943 | + if (EE_Registry::instance()->CART->all_ticket_quantity_count()) { |
|
944 | 944 | $msg = sprintf( |
945 | 945 | _n( |
946 | 946 | 'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.', |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | '<br />' |
964 | 964 | ); |
965 | 965 | } |
966 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
966 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | |
@@ -978,22 +978,22 @@ discard block |
||
978 | 978 | * @param bool $get_original_ticket_spaces |
979 | 979 | * @return int |
980 | 980 | */ |
981 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
981 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
982 | 982 | // if the $_available_spaces array has not been set up yet... |
983 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
984 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
983 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
984 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
985 | 985 | } |
986 | 986 | $available_spaces = $ticket->qty() - $ticket->sold(); |
987 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
987 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
988 | 988 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
989 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
989 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
990 | 990 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
991 | - if ( $get_original_ticket_spaces ) { |
|
991 | + if ($get_original_ticket_spaces) { |
|
992 | 992 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
993 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
993 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
994 | 994 | } else { |
995 | 995 | // we want the updated ticket availability as stored in the "datetimes" array |
996 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
996 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
997 | 997 | } |
998 | 998 | } |
999 | 999 | } |
@@ -1009,23 +1009,23 @@ discard block |
||
1009 | 1009 | * @param EE_Ticket $ticket |
1010 | 1010 | * @return int |
1011 | 1011 | */ |
1012 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
1012 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
1013 | 1013 | // first, get all of the datetimes that are available to this ticket |
1014 | 1014 | $datetimes = $ticket->get_many_related( |
1015 | 1015 | 'Datetime', |
1016 | - array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' )) |
|
1016 | + array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1017 | 1017 | ); |
1018 | - if ( ! empty( $datetimes )) { |
|
1018 | + if ( ! empty($datetimes)) { |
|
1019 | 1019 | // now loop thru all of the datetimes |
1020 | - foreach ( $datetimes as $datetime ) { |
|
1021 | - if ( $datetime instanceof EE_Datetime ) { |
|
1020 | + foreach ($datetimes as $datetime) { |
|
1021 | + if ($datetime instanceof EE_Datetime) { |
|
1022 | 1022 | // the number of spaces available for the datetime without considering individual ticket quantities |
1023 | 1023 | $spaces_remaining = $datetime->spaces_remaining(); |
1024 | 1024 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
1025 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
1025 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
1026 | 1026 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
1027 | 1027 | // else just take the datetime spaces remaining, and assign to the datetimes array |
1028 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
1028 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
1029 | 1029 | } |
1030 | 1030 | } |
1031 | 1031 | } |
@@ -1041,12 +1041,12 @@ discard block |
||
1041 | 1041 | * @param int $qty |
1042 | 1042 | * @return int |
1043 | 1043 | */ |
1044 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
1045 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
1044 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
1045 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
1046 | 1046 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
1047 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
1047 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
1048 | 1048 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
1049 | - self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty; |
|
1049 | + self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty; |
|
1050 | 1050 | } |
1051 | 1051 | } |
1052 | 1052 | } |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | */ |
1064 | 1064 | public static function load_tckt_slctr_assets() { |
1065 | 1065 | // add some style |
1066 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
1067 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
1066 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
1067 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
1068 | 1068 | wp_enqueue_style('ticket_selector'); |
1069 | 1069 | // make it dance |
1070 | 1070 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | public static function load_tckt_slctr_assets_admin() { |
1080 | 1080 | //iframe button js on admin event editor page |
1081 | - if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) { |
|
1082 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
1083 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
1081 | + if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') { |
|
1082 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1083 | + wp_enqueue_script('ticket_selector_embed'); |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Paypal_Pro extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Paypal_Pro extends EE_Onsite_Gateway { |
|
29 | 29 | /** |
30 | 30 | * |
31 | 31 | * @var $_paypal_api_username string |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | * } @see parent::do_direct_payment for more info |
89 | 89 | * @return \EE_Payment|\EEI_Payment |
90 | 90 | */ |
91 | - public function do_direct_payment($payment,$billing_info = null){ |
|
91 | + public function do_direct_payment($payment, $billing_info = null) { |
|
92 | 92 | $transaction = $payment->transaction(); |
93 | 93 | $primary_registrant = $transaction->primary_registration(); |
94 | - $order_description = sprintf(__("Event Registrations from %s", "event_espresso"),get_bloginfo('name')); |
|
94 | + $order_description = sprintf(__("Event Registrations from %s", "event_espresso"), get_bloginfo('name')); |
|
95 | 95 | //charge for the full amount. Show itemized list |
96 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
96 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
97 | 97 | $item_num = 1; |
98 | 98 | $total_line_item = $transaction->total_line_item(); |
99 | 99 | $order_items = array(); |
100 | 100 | foreach ($total_line_item->get_items() as $line_item) { |
101 | 101 | //ignore line items with a quantity of 0 |
102 | - if( $line_item->quantity() == 0 ) { |
|
102 | + if ($line_item->quantity() == 0) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | $item = array( |
106 | 106 | // Item Name. 127 char max. |
107 | - 'l_name' => substr($line_item->name(),0,127), |
|
107 | + 'l_name' => substr($line_item->name(), 0, 127), |
|
108 | 108 | // Item description. 127 char max. |
109 | - 'l_desc' => substr($line_item->desc(),0,127), |
|
109 | + 'l_desc' => substr($line_item->desc(), 0, 127), |
|
110 | 110 | // Cost of individual item. |
111 | 111 | 'l_amt' => $line_item->unit_price(), |
112 | 112 | // Item Number. 127 char max. |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | } |
128 | 128 | $item_amount = $total_line_item->get_items_total(); |
129 | 129 | $tax_amount = $total_line_item->get_total_tax(); |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | $order_items = array(); |
132 | 132 | $item_amount = $payment->amount(); |
133 | - $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
|
133 | + $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code()); |
|
134 | 134 | $tax_amount = 0; |
135 | - array_push($order_items,array( |
|
135 | + array_push($order_items, array( |
|
136 | 136 | // Item Name. 127 char max. |
137 | - 'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'),$primary_registrant->reg_code()), |
|
137 | + 'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'), $primary_registrant->reg_code()), |
|
138 | 138 | // Item description. 127 char max. |
139 | 139 | 'l_desc' => $single_item_desc, |
140 | 140 | // Cost of individual item. |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | // Payer's salutation. 20 char max. |
182 | 182 | 'salutation' => '', |
183 | 183 | // Payer's first name. 25 char max. |
184 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
184 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
185 | 185 | // Payer's middle name. 25 char max. |
186 | 186 | 'middlename' => '', |
187 | 187 | // Payer's last name. 25 char max. |
188 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
188 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
189 | 189 | // Payer's suffix. 12 char max. |
190 | 190 | 'suffix' => '' |
191 | 191 | ); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | // Required. Name of City. |
199 | 199 | 'city' => $billing_info['city'], |
200 | 200 | // Required. Name of State or Province. |
201 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
201 | + 'state' => substr($billing_info['state'], 0, 40), |
|
202 | 202 | // Required. Country code. |
203 | 203 | 'countrycode' => $billing_info['country'], |
204 | 204 | // Required. Postal code of payer. |
205 | 205 | 'zip' => $billing_info['zip'], |
206 | 206 | // Phone Number of payer. 20 char max. |
207 | - 'shiptophonenum' => substr($billing_info['phone'],0,20) |
|
207 | + 'shiptophonenum' => substr($billing_info['phone'], 0, 20) |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // Required. Three-letter currency code. Default is USD. |
215 | 215 | 'currencycode' => $payment->currency_code(), |
216 | 216 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
217 | - 'itemamt' => $this->format_currency($item_amount),// |
|
217 | + 'itemamt' => $this->format_currency($item_amount), // |
|
218 | 218 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
219 | 219 | 'shippingamt' => '', |
220 | 220 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | // Free-form field for your own use. 256 char max. |
227 | 227 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
228 | 228 | // Your own invoice or tracking number |
229 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
229 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
230 | 230 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
231 | 231 | 'notifyurl' => '', |
232 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
232 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
233 | 233 | ); |
234 | 234 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
235 | 235 | $PayPalRequestData = array( |
@@ -242,32 +242,32 @@ discard block |
||
242 | 242 | 'OrderItems' => $order_items, |
243 | 243 | ); |
244 | 244 | $this->_log_clean_request($PayPalRequestData, $payment); |
245 | - try{ |
|
245 | + try { |
|
246 | 246 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
247 | 247 | //remove PCI-sensitive data so it doesn't get stored |
248 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
248 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
249 | 249 | |
250 | 250 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
251 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
252 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
253 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
251 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
252 | + $payment->set_status($this->_pay_model->failed_status()); |
|
253 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
254 | 254 | $payment->set_details($PayPalResult); |
255 | - }else{ |
|
256 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
255 | + } else { |
|
256 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
257 | 257 | $payment->set_status($this->_pay_model->approved_status()); |
258 | - }else{ |
|
258 | + } else { |
|
259 | 259 | $payment->set_status($this->_pay_model->declined_status()); |
260 | 260 | } |
261 | 261 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
262 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
262 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
263 | 263 | $payment->set_gateway_response($message); |
264 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
264 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
265 | 265 | |
266 | 266 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
267 | 267 | $payment->set_extra_accntng($primary_registration_code); |
268 | 268 | $payment->set_details($PayPalResult); |
269 | 269 | } |
270 | - }catch(Exception $e){ |
|
270 | + } catch (Exception $e) { |
|
271 | 271 | $payment->set_status($this->_pay_model->failed_status()); |
272 | 272 | $payment->set_gateway_response($e->getMessage()); |
273 | 273 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param EEI_Payment $payment |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - private function _log_clean_request($request,$payment){ |
|
287 | + private function _log_clean_request($request, $payment) { |
|
288 | 288 | $cleaned_request_data = $request; |
289 | 289 | unset($cleaned_request_data['CCDetails']['acct']); |
290 | 290 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | * @param EEI_Payment $payment |
301 | 301 | * @return array cleaned |
302 | 302 | */ |
303 | - private function _log_clean_response($response,$payment){ |
|
303 | + private function _log_clean_response($response, $payment) { |
|
304 | 304 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
305 | 305 | unset($response['REQUESTDATA']['ACCT']); |
306 | 306 | unset($response['REQUESTDATA']['EXPDATE']); |
307 | 307 | unset($response['REQUESTDATA']['CVV2']); |
308 | 308 | unset($response['RAWREQUEST']); |
309 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
309 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
310 | 310 | return $response; |
311 | 311 | } |
312 | 312 | |
@@ -331,32 +331,32 @@ discard block |
||
331 | 331 | // DP Fields |
332 | 332 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
333 | 333 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
334 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
334 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
335 | 335 | |
336 | 336 | // CC Details Fields |
337 | 337 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
338 | 338 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
339 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
339 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
340 | 340 | |
341 | 341 | // PayerInfo Type Fields |
342 | 342 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
343 | 343 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
344 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
344 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
345 | 345 | |
346 | 346 | // Payer Name Fields |
347 | 347 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
348 | 348 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
349 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
349 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
350 | 350 | |
351 | 351 | // Address Fields (Billing) |
352 | 352 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
353 | 353 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
354 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
354 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
355 | 355 | |
356 | 356 | // Payment Details Type Fields |
357 | 357 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
358 | 358 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
359 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
359 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
360 | 360 | |
361 | 361 | // Payment Details Item Type Fields |
362 | 362 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -364,22 +364,22 @@ discard block |
||
364 | 364 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
365 | 365 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
366 | 366 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
367 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
367 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
368 | 368 | $n++; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Ship To Address Fields |
372 | 372 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
373 | 373 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
374 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
374 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
375 | 375 | |
376 | 376 | // 3D Secure Fields |
377 | 377 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
378 | 378 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
379 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
379 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
380 | 380 | |
381 | 381 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
382 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
382 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
383 | 383 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
384 | 384 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
385 | 385 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | private function _CURLRequest($Request) { |
404 | 404 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
405 | 405 | $curl = curl_init(); |
406 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
406 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
407 | 407 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
408 | 408 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
409 | 409 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | private function _APICallSuccessful($PayPalResult) { |
454 | 454 | $approved = false; |
455 | 455 | // check main response message from PayPal |
456 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
456 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
457 | 457 | $ack = strtoupper($PayPalResult['ACK']); |
458 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
458 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | return $approved; |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | |
472 | 472 | $Errors = array(); |
473 | 473 | $n = 0; |
474 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
475 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
476 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
477 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
478 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
474 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
475 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
476 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
477 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
478 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
479 | 479 | |
480 | 480 | $CurrentItem = array( |
481 | 481 | 'L_ERRORCODE' => $LErrorCode, |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
516 | 516 | $CurrentVarName = 'Severity Code'; |
517 | 517 | |
518 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
518 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | return $error; |
@@ -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 | * Event Espresso |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * array for defining default session vars |
111 | 111 | * @var array |
112 | 112 | */ |
113 | - private $_default_session_vars = array ( |
|
113 | + private $_default_session_vars = array( |
|
114 | 114 | 'id' => null, |
115 | 115 | 'user_id' => null, |
116 | 116 | 'ip_address' => null, |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * @access public |
133 | 133 | * @return EE_Session |
134 | 134 | */ |
135 | - public static function instance ( ) { |
|
135 | + public static function instance( ) { |
|
136 | 136 | // check if class object is instantiated |
137 | - if ( ! self::$_instance instanceof EE_Session ) { |
|
137 | + if ( ! self::$_instance instanceof EE_Session) { |
|
138 | 138 | self::$_instance = new self(); |
139 | 139 | } |
140 | 140 | return self::$_instance; |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | private function __construct() { |
152 | 152 | |
153 | 153 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
154 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
154 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
155 | 155 | return null; |
156 | 156 | } |
157 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
158 | - define( 'ESPRESSO_SESSION', TRUE ); |
|
157 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
158 | + define('ESPRESSO_SESSION', TRUE); |
|
159 | 159 | // default session lifespan in seconds |
160 | 160 | $this->_lifespan = apply_filters( |
161 | 161 | 'FHEE__EE_Session__construct___lifespan', |
@@ -168,35 +168,35 @@ discard block |
||
168 | 168 | * } |
169 | 169 | */ |
170 | 170 | // retrieve session options from db |
171 | - $session_settings = get_option( 'ee_session_settings' ); |
|
172 | - if ( $session_settings !== FALSE ) { |
|
171 | + $session_settings = get_option('ee_session_settings'); |
|
172 | + if ($session_settings !== FALSE) { |
|
173 | 173 | // cycle though existing session options |
174 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
174 | + foreach ($session_settings as $var_name => $session_setting) { |
|
175 | 175 | // set values for class properties |
176 | - $var_name = '_' . $var_name; |
|
176 | + $var_name = '_'.$var_name; |
|
177 | 177 | $this->{$var_name} = $session_setting; |
178 | 178 | } |
179 | 179 | } |
180 | 180 | // are we using encryption? |
181 | - if ( $this->_use_encryption ) { |
|
181 | + if ($this->_use_encryption) { |
|
182 | 182 | // instantiate the class object making all properties and methods accessible via $this->encryption ex: $this->encryption->encrypt(); |
183 | - $this->encryption = EE_Registry::instance()->load_core( 'Encryption' ); |
|
183 | + $this->encryption = EE_Registry::instance()->load_core('Encryption'); |
|
184 | 184 | } |
185 | 185 | // filter hook allows outside functions/classes/plugins to change default empty cart |
186 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
187 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
186 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
187 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
188 | 188 | // apply default session vars |
189 | 189 | $this->_set_defaults(); |
190 | 190 | // check for existing session and retrieve it from db |
191 | - if ( ! $this->_espresso_session() ) { |
|
191 | + if ( ! $this->_espresso_session()) { |
|
192 | 192 | // or just start a new one |
193 | 193 | $this->_create_espresso_session(); |
194 | 194 | } |
195 | 195 | // check request for 'clear_session' param |
196 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
196 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
197 | 197 | // once everything is all said and done, |
198 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
199 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
198 | + add_action('shutdown', array($this, 'update'), 100); |
|
199 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
200 | 200 | |
201 | 201 | } |
202 | 202 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @return int |
234 | 234 | */ |
235 | 235 | public function extension() { |
236 | - return apply_filters( 'FHEE__EE_Session__extend_expiration__seconds_added', ( 10 * MINUTE_IN_SECONDS ) ); |
|
236 | + return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | * @param int $time number of seconds to add to session expiration |
243 | 243 | * @return int |
244 | 244 | */ |
245 | - public function extend_expiration( $time = 0 ) { |
|
245 | + public function extend_expiration($time = 0) { |
|
246 | 246 | $time = $time ? $time : $this->extension(); |
247 | - $this->_expiration += absint( $time ); |
|
247 | + $this->_expiration += absint($time); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | */ |
267 | 267 | private function _set_defaults() { |
268 | 268 | // set some defaults |
269 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
270 | - $this->_session_data[ $key ] = $default_var; |
|
269 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
270 | + $this->_session_data[$key] = $default_var; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param \EE_Cart $cart |
289 | 289 | * @return bool |
290 | 290 | */ |
291 | - public function set_cart( EE_Cart $cart ) { |
|
291 | + public function set_cart(EE_Cart $cart) { |
|
292 | 292 | $this->_session_data['cart'] = $cart; |
293 | 293 | return TRUE; |
294 | 294 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * reset_cart |
300 | 300 | */ |
301 | 301 | public function reset_cart() { |
302 | - do_action( 'AHEE__EE_Session__reset_cart__before_reset', $this ); |
|
302 | + do_action('AHEE__EE_Session__reset_cart__before_reset', $this); |
|
303 | 303 | $this->_session_data['cart'] = NULL; |
304 | 304 | } |
305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return \EE_Cart |
310 | 310 | */ |
311 | 311 | public function cart() { |
312 | - return isset( $this->_session_data['cart'] ) && $this->_session_data[ 'cart' ] instanceof EE_Cart ? $this->_session_data['cart'] : NULL; |
|
312 | + return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart ? $this->_session_data['cart'] : NULL; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @param \EE_Checkout $checkout |
319 | 319 | * @return bool |
320 | 320 | */ |
321 | - public function set_checkout( EE_Checkout $checkout ) { |
|
321 | + public function set_checkout(EE_Checkout $checkout) { |
|
322 | 322 | $this->_session_data['checkout'] = $checkout; |
323 | 323 | return TRUE; |
324 | 324 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * reset_checkout |
330 | 330 | */ |
331 | 331 | public function reset_checkout() { |
332 | - do_action( 'AHEE__EE_Session__reset_checkout__before_reset', $this ); |
|
332 | + do_action('AHEE__EE_Session__reset_checkout__before_reset', $this); |
|
333 | 333 | $this->_session_data['checkout'] = NULL; |
334 | 334 | } |
335 | 335 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return \EE_Checkout |
340 | 340 | */ |
341 | 341 | public function checkout() { |
342 | - return isset( $this->_session_data['checkout'] ) && $this->_session_data[ 'checkout' ] instanceof EE_Checkout ? $this->_session_data['checkout'] : NULL; |
|
342 | + return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout ? $this->_session_data['checkout'] : NULL; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @param \EE_Transaction $transaction |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public function set_transaction( EE_Transaction $transaction ) { |
|
351 | + public function set_transaction(EE_Transaction $transaction) { |
|
352 | 352 | // first remove the session from the transaction before we save the transaction in the session |
353 | - $transaction->set_txn_session_data( NULL ); |
|
353 | + $transaction->set_txn_session_data(NULL); |
|
354 | 354 | $this->_session_data['transaction'] = $transaction; |
355 | 355 | return TRUE; |
356 | 356 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * reset_transaction |
362 | 362 | */ |
363 | 363 | public function reset_transaction() { |
364 | - do_action( 'AHEE__EE_Session__reset_transaction__before_reset', $this ); |
|
364 | + do_action('AHEE__EE_Session__reset_transaction__before_reset', $this); |
|
365 | 365 | $this->_session_data['transaction'] = NULL; |
366 | 366 | } |
367 | 367 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return \EE_Transaction |
372 | 372 | */ |
373 | 373 | public function transaction() { |
374 | - return isset( $this->_session_data['transaction'] ) && $this->_session_data[ 'transaction' ] instanceof EE_Transaction ? $this->_session_data['transaction'] : NULL; |
|
374 | + return isset($this->_session_data['transaction']) && $this->_session_data['transaction'] instanceof EE_Transaction ? $this->_session_data['transaction'] : NULL; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | * @param bool $reset_cache |
384 | 384 | * @return array |
385 | 385 | */ |
386 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
387 | - if ( $reset_cache ) { |
|
386 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
387 | + if ($reset_cache) { |
|
388 | 388 | $this->reset_cart(); |
389 | 389 | $this->reset_checkout(); |
390 | 390 | $this->reset_transaction(); |
391 | 391 | } |
392 | - if ( ! empty( $key )) { |
|
393 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
394 | - } else { |
|
392 | + if ( ! empty($key)) { |
|
393 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
394 | + } else { |
|
395 | 395 | return $this->_session_data; |
396 | 396 | } |
397 | 397 | } |
@@ -404,23 +404,23 @@ discard block |
||
404 | 404 | * @param array $data |
405 | 405 | * @return TRUE on success, FALSE on fail |
406 | 406 | */ |
407 | - public function set_session_data( $data ) { |
|
407 | + public function set_session_data($data) { |
|
408 | 408 | |
409 | 409 | // nothing ??? bad data ??? go home! |
410 | - if ( empty( $data ) || ! is_array( $data )) { |
|
411 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
410 | + if (empty($data) || ! is_array($data)) { |
|
411 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
412 | 412 | return FALSE; |
413 | 413 | } |
414 | 414 | |
415 | - foreach ( $data as $key =>$value ) { |
|
416 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
415 | + foreach ($data as $key =>$value) { |
|
416 | + if (isset($this->_default_session_vars[$key])) { |
|
417 | 417 | EE_Error::add_error( |
418 | - sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), |
|
418 | + sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), |
|
419 | 419 | __FILE__, __FUNCTION__, __LINE__ |
420 | 420 | ); |
421 | 421 | return FALSE; |
422 | 422 | } else { |
423 | - $this->_session_data[ $key ] = $value; |
|
423 | + $this->_session_data[$key] = $value; |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
@@ -437,9 +437,9 @@ discard block |
||
437 | 437 | * @throws \EE_Error |
438 | 438 | */ |
439 | 439 | private function _espresso_session() { |
440 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
440 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
441 | 441 | // check that session has started |
442 | - if ( session_id() === '' ) { |
|
442 | + if (session_id() === '') { |
|
443 | 443 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
444 | 444 | session_start(); |
445 | 445 | } |
@@ -448,57 +448,57 @@ discard block |
||
448 | 448 | // and the visitors IP |
449 | 449 | $this->_ip_address = $this->_visitor_ip(); |
450 | 450 | // set the "user agent" |
451 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
451 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
452 | 452 | // now let's retrieve what's in the db |
453 | 453 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
454 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
455 | - if ( $session_data ) { |
|
456 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
457 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
458 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
454 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
455 | + if ($session_data) { |
|
456 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
457 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
458 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
459 | 459 | EE_Error::add_error( |
460 | 460 | sprintf( |
461 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
462 | - EE_Session::session_id_prefix . $this->_sid |
|
461 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
462 | + EE_Session::session_id_prefix.$this->_sid |
|
463 | 463 | ), |
464 | 464 | __FILE__, __FUNCTION__, __LINE__ |
465 | 465 | ); |
466 | 466 | } |
467 | 467 | } |
468 | 468 | // un-encrypt the data |
469 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
469 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
470 | 470 | // unserialize |
471 | - $session_data = maybe_unserialize( $session_data ); |
|
471 | + $session_data = maybe_unserialize($session_data); |
|
472 | 472 | // just a check to make sure the session array is indeed an array |
473 | - if ( ! is_array( $session_data ) ) { |
|
473 | + if ( ! is_array($session_data)) { |
|
474 | 474 | // no?!?! then something is wrong |
475 | 475 | return FALSE; |
476 | 476 | } |
477 | 477 | // get the current time in UTC |
478 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
478 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
479 | 479 | // and reset the session expiration |
480 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
480 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
481 | 481 | |
482 | 482 | } else { |
483 | 483 | // set initial site access time and the session expiration |
484 | 484 | $this->_set_init_access_and_expiration(); |
485 | 485 | // set referer |
486 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
486 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
487 | 487 | // no previous session = go back and create one (on top of the data above) |
488 | 488 | return FALSE; |
489 | 489 | } |
490 | 490 | // now the user agent |
491 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
491 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
492 | 492 | return FALSE; |
493 | 493 | } |
494 | 494 | // make event espresso session data available to plugin |
495 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
495 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
496 | 496 | // wait a minute... how old are you? |
497 | - if ( $this->_time > $this->_expiration ) { |
|
497 | + if ($this->_time > $this->_expiration) { |
|
498 | 498 | // yer too old fer me! |
499 | 499 | $this->_expired = true; |
500 | 500 | // wipe out everything that isn't a default session datum, and set expired flag to true |
501 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
501 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
502 | 502 | } |
503 | 503 | return TRUE; |
504 | 504 | |
@@ -517,12 +517,12 @@ discard block |
||
517 | 517 | */ |
518 | 518 | protected function _generate_session_id() { |
519 | 519 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
520 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
521 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
520 | + if (isset($_REQUEST['EESID'])) { |
|
521 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
522 | 522 | } else { |
523 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
523 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
524 | 524 | } |
525 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
525 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | |
@@ -534,20 +534,20 @@ discard block |
||
534 | 534 | */ |
535 | 535 | protected function _get_sid_salt() { |
536 | 536 | // was session id salt already saved to db ? |
537 | - if ( empty( $this->_sid_salt ) ) { |
|
537 | + if (empty($this->_sid_salt)) { |
|
538 | 538 | // no? then maybe use WP defined constant |
539 | - if ( defined( 'AUTH_SALT' ) ) { |
|
539 | + if (defined('AUTH_SALT')) { |
|
540 | 540 | $this->_sid_salt = AUTH_SALT; |
541 | 541 | } |
542 | 542 | // if salt doesn't exist or is too short |
543 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
543 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
544 | 544 | // create a new one |
545 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
545 | + $this->_sid_salt = wp_generate_password(64); |
|
546 | 546 | } |
547 | 547 | // and save it as a permanent session setting |
548 | - $session_settings = get_option( 'ee_session_settings' ); |
|
549 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
550 | - update_option( 'ee_session_settings', $session_settings ); |
|
548 | + $session_settings = get_option('ee_session_settings'); |
|
549 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
550 | + update_option('ee_session_settings', $session_settings); |
|
551 | 551 | } |
552 | 552 | return $this->_sid_salt; |
553 | 553 | } |
@@ -575,18 +575,18 @@ discard block |
||
575 | 575 | * @param bool $new_session |
576 | 576 | * @return TRUE on success, FALSE on fail |
577 | 577 | */ |
578 | - public function update( $new_session = FALSE ) { |
|
579 | - $this->_session_data = isset( $this->_session_data ) |
|
580 | - && is_array( $this->_session_data ) |
|
581 | - && isset( $this->_session_data['id']) |
|
578 | + public function update($new_session = FALSE) { |
|
579 | + $this->_session_data = isset($this->_session_data) |
|
580 | + && is_array($this->_session_data) |
|
581 | + && isset($this->_session_data['id']) |
|
582 | 582 | ? $this->_session_data |
583 | 583 | : NULL; |
584 | - if ( empty( $this->_session_data )) { |
|
584 | + if (empty($this->_session_data)) { |
|
585 | 585 | $this->_set_defaults(); |
586 | 586 | } |
587 | - foreach ( $this->_session_data as $key => $value ) { |
|
587 | + foreach ($this->_session_data as $key => $value) { |
|
588 | 588 | |
589 | - switch( $key ) { |
|
589 | + switch ($key) { |
|
590 | 590 | |
591 | 591 | case 'id' : |
592 | 592 | // session ID |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | break; |
605 | 605 | |
606 | 606 | case 'init_access' : |
607 | - $this->_session_data['init_access'] = absint( $value ); |
|
607 | + $this->_session_data['init_access'] = absint($value); |
|
608 | 608 | break; |
609 | 609 | |
610 | 610 | case 'last_access' : |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | |
615 | 615 | case 'expiration' : |
616 | 616 | // when the session expires |
617 | - $this->_session_data['expiration'] = ! empty( $this->_expiration ) |
|
617 | + $this->_session_data['expiration'] = ! empty($this->_expiration) |
|
618 | 618 | ? $this->_expiration |
619 | 619 | : $this->_session_data['init_access'] + $this->_lifespan; |
620 | 620 | break; |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | |
627 | 627 | case 'pages_visited' : |
628 | 628 | $page_visit = $this->_get_page_visit(); |
629 | - if ( $page_visit ) { |
|
629 | + if ($page_visit) { |
|
630 | 630 | // set pages visited where the first will be the http referrer |
631 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
631 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
632 | 632 | // we'll only save the last 10 page visits. |
633 | - $this->_session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
633 | + $this->_session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
634 | 634 | } |
635 | 635 | break; |
636 | 636 | |
@@ -638,9 +638,9 @@ discard block |
||
638 | 638 | |
639 | 639 | } |
640 | 640 | // creating a new session does not require saving to the db just yet |
641 | - if ( ! $new_session ) { |
|
641 | + if ( ! $new_session) { |
|
642 | 642 | // ready? let's save |
643 | - if ( $this->_save_session_to_db() ) { |
|
643 | + if ($this->_save_session_to_db()) { |
|
644 | 644 | return TRUE; |
645 | 645 | } else { |
646 | 646 | return FALSE; |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | * @return bool |
662 | 662 | */ |
663 | 663 | private function _create_espresso_session( ) { |
664 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
664 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
665 | 665 | // use the update function for now with $new_session arg set to TRUE |
666 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
666 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | |
@@ -688,19 +688,19 @@ discard block |
||
688 | 688 | } |
689 | 689 | EE_Registry::instance()->SSN = $this; |
690 | 690 | // first serialize all of our session data |
691 | - $session_data = serialize( $this->_session_data ); |
|
691 | + $session_data = serialize($this->_session_data); |
|
692 | 692 | // encrypt it if we are using encryption |
693 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
693 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
694 | 694 | // add an hour to the session transient expiration (NOT the session expiration itself), |
695 | 695 | // which allows us to still retrieve expired sessions instead of having the transients deleted on us immediately, |
696 | 696 | // which looks no different than the session having never existed at all |
697 | 697 | $expiry = $this->_lifespan + HOUR_IN_SECONDS; |
698 | 698 | // maybe save hash check |
699 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
700 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $expiry ); |
|
699 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
700 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $expiry); |
|
701 | 701 | } |
702 | 702 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
703 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $expiry ); |
|
703 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $expiry); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -726,10 +726,10 @@ discard block |
||
726 | 726 | 'HTTP_FORWARDED', |
727 | 727 | 'REMOTE_ADDR' |
728 | 728 | ); |
729 | - foreach ( $server_keys as $key ){ |
|
730 | - if ( isset( $_SERVER[ $key ] )) { |
|
731 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
732 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
729 | + foreach ($server_keys as $key) { |
|
730 | + if (isset($_SERVER[$key])) { |
|
731 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
732 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
733 | 733 | $visitor_ip = $ip; |
734 | 734 | } |
735 | 735 | } |
@@ -749,41 +749,41 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function _get_page_visit() { |
751 | 751 | |
752 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
752 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
753 | 753 | |
754 | 754 | // check for request url |
755 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
755 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
756 | 756 | |
757 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
757 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
758 | 758 | |
759 | - $ru_bits = explode( '?', $request_uri ); |
|
759 | + $ru_bits = explode('?', $request_uri); |
|
760 | 760 | $request_uri = $ru_bits[0]; |
761 | 761 | // check for and grab host as well |
762 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
763 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
762 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
763 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
764 | 764 | } else { |
765 | 765 | $http_host = ''; |
766 | 766 | } |
767 | 767 | // check for page_id in SERVER REQUEST |
768 | - if ( isset( $_REQUEST['page_id'] )) { |
|
768 | + if (isset($_REQUEST['page_id'])) { |
|
769 | 769 | // rebuild $e_reg without any of the extra parameters |
770 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
770 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
771 | 771 | } else { |
772 | 772 | $page_id = '?'; |
773 | 773 | } |
774 | 774 | // check for $e_reg in SERVER REQUEST |
775 | - if ( isset( $_REQUEST['ee'] )) { |
|
775 | + if (isset($_REQUEST['ee'])) { |
|
776 | 776 | // rebuild $e_reg without any of the extra parameters |
777 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
777 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
778 | 778 | } else { |
779 | 779 | $e_reg = ''; |
780 | 780 | } |
781 | 781 | |
782 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
782 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
783 | 783 | |
784 | 784 | } |
785 | 785 | |
786 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
786 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
787 | 787 | |
788 | 788 | } |
789 | 789 | |
@@ -811,13 +811,13 @@ discard block |
||
811 | 811 | * @param string $class |
812 | 812 | * @param string $function |
813 | 813 | */ |
814 | - public function clear_session( $class = '', $function = '' ) { |
|
815 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
814 | + public function clear_session($class = '', $function = '') { |
|
815 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
816 | 816 | $this->reset_cart(); |
817 | 817 | $this->reset_checkout(); |
818 | 818 | $this->reset_transaction(); |
819 | 819 | // wipe out everything that isn't a default session datum |
820 | - $this->reset_data( array_keys( $this->_session_data )); |
|
820 | + $this->reset_data(array_keys($this->_session_data)); |
|
821 | 821 | // reset initial site access time and the session expiration |
822 | 822 | $this->_set_init_access_and_expiration(); |
823 | 823 | $this->_save_session_to_db(); |
@@ -832,41 +832,41 @@ discard block |
||
832 | 832 | * @param bool $show_all_notices |
833 | 833 | * @return TRUE on success, FALSE on fail |
834 | 834 | */ |
835 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
835 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
836 | 836 | // if $data_to_reset is not in an array, then put it in one |
837 | - if ( ! is_array( $data_to_reset ) ) { |
|
838 | - $data_to_reset = array ( $data_to_reset ); |
|
837 | + if ( ! is_array($data_to_reset)) { |
|
838 | + $data_to_reset = array($data_to_reset); |
|
839 | 839 | } |
840 | 840 | // nothing ??? go home! |
841 | - if ( empty( $data_to_reset )) { |
|
842 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
841 | + if (empty($data_to_reset)) { |
|
842 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
843 | 843 | return FALSE; |
844 | 844 | } |
845 | 845 | $return_value = TRUE; |
846 | 846 | // since $data_to_reset is an array, cycle through the values |
847 | - foreach ( $data_to_reset as $reset ) { |
|
847 | + foreach ($data_to_reset as $reset) { |
|
848 | 848 | |
849 | 849 | // first check to make sure it is a valid session var |
850 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
850 | + if (isset($this->_session_data[$reset])) { |
|
851 | 851 | // then check to make sure it is not a default var |
852 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
852 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
853 | 853 | // remove session var |
854 | - unset( $this->_session_data[ $reset ] ); |
|
855 | - if ( $show_all_notices ) { |
|
856 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
854 | + unset($this->_session_data[$reset]); |
|
855 | + if ($show_all_notices) { |
|
856 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | } else { |
860 | 860 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
861 | - if ( $show_all_notices ) { |
|
862 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
861 | + if ($show_all_notices) { |
|
862 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
863 | 863 | } |
864 | 864 | $return_value = FALSE; |
865 | 865 | } |
866 | 866 | |
867 | - } else if ( $show_all_notices ) { |
|
867 | + } else if ($show_all_notices) { |
|
868 | 868 | // oops! that session var does not exist! |
869 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
869 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
870 | 870 | $return_value = FALSE; |
871 | 871 | } |
872 | 872 | |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | * @return string |
888 | 888 | */ |
889 | 889 | public function wp_loaded() { |
890 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
891 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
890 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
891 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
892 | 892 | } |
893 | 893 | } |
894 | 894 | |
@@ -913,24 +913,24 @@ discard block |
||
913 | 913 | */ |
914 | 914 | public function garbage_collection() { |
915 | 915 | // only perform during regular requests |
916 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
916 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
917 | 917 | /** @type WPDB $wpdb */ |
918 | 918 | global $wpdb; |
919 | 919 | // since transient expiration timestamps are set in the future, we can compare against NOW |
920 | 920 | $expiration = time(); |
921 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ) + HOUR_IN_SECONDS; |
|
921 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2) + HOUR_IN_SECONDS; |
|
922 | 922 | // filter the query limit. Set to 0 to turn off garbage collection |
923 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
923 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
924 | 924 | // non-zero LIMIT means take out the trash |
925 | - if ( $expired_session_transient_delete_query_limit ) { |
|
925 | + if ($expired_session_transient_delete_query_limit) { |
|
926 | 926 | //array of transient keys that require garbage collection |
927 | 927 | $session_keys = array( |
928 | 928 | EE_Session::session_id_prefix, |
929 | 929 | EE_Session::hash_check_prefix, |
930 | 930 | ); |
931 | - foreach ( $session_keys as $session_key ) { |
|
932 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
933 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
931 | + foreach ($session_keys as $session_key) { |
|
932 | + $session_key = str_replace('_', '\_', $session_key); |
|
933 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
934 | 934 | $SQL = " |
935 | 935 | SELECT option_name |
936 | 936 | FROM {$wpdb->options} |
@@ -940,28 +940,28 @@ discard block |
||
940 | 940 | OR option_value > {$too_far_in_the_the_future} ) |
941 | 941 | LIMIT {$expired_session_transient_delete_query_limit} |
942 | 942 | "; |
943 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
943 | + $expired_sessions = $wpdb->get_col($SQL); |
|
944 | 944 | // valid results? |
945 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
945 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
946 | 946 | // format array of results into something usable within the actual DELETE query's IN clause |
947 | 947 | $expired = array(); |
948 | - foreach ( $expired_sessions as $expired_session ) { |
|
949 | - $expired[ ] = "'" . $expired_session . "'"; |
|
950 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
948 | + foreach ($expired_sessions as $expired_session) { |
|
949 | + $expired[] = "'".$expired_session."'"; |
|
950 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
951 | 951 | } |
952 | - $expired = implode( ', ', $expired ); |
|
952 | + $expired = implode(', ', $expired); |
|
953 | 953 | $SQL = " |
954 | 954 | DELETE FROM {$wpdb->options} |
955 | 955 | WHERE option_name |
956 | 956 | IN ( $expired ); |
957 | 957 | "; |
958 | - $results = $wpdb->query( $SQL ); |
|
958 | + $results = $wpdb->query($SQL); |
|
959 | 959 | // if something went wrong, then notify the admin |
960 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
961 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
960 | + if ($results instanceof WP_Error && is_admin()) { |
|
961 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
962 | 962 | } |
963 | 963 | } |
964 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
964 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | } |
@@ -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 |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @access public |
120 | 120 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
121 | 121 | */ |
122 | - public function set_start_date( $date ) { |
|
123 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
122 | + public function set_start_date($date) { |
|
123 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @access public |
134 | 134 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
135 | 135 | */ |
136 | - public function set_start_time( $time ) { |
|
137 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
136 | + public function set_start_time($time) { |
|
137 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @access public |
148 | 148 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
149 | 149 | */ |
150 | - public function set_end_date( $date ) { |
|
151 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
150 | + public function set_end_date($date) { |
|
151 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @access public |
162 | 162 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
163 | 163 | */ |
164 | - public function set_end_time( $time ) { |
|
165 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
164 | + public function set_end_time($time) { |
|
165 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param int $reg_limit |
177 | 177 | */ |
178 | - public function set_reg_limit( $reg_limit ) { |
|
179 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
178 | + public function set_reg_limit($reg_limit) { |
|
179 | + $this->set('DTT_reg_limit', $reg_limit); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @return mixed int on success, FALSE on fail |
189 | 189 | */ |
190 | 190 | public function sold() { |
191 | - return $this->get_raw( 'DTT_sold' ); |
|
191 | + return $this->get_raw('DTT_sold'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @access public |
200 | 200 | * @param int $sold |
201 | 201 | */ |
202 | - public function set_sold( $sold ) { |
|
202 | + public function set_sold($sold) { |
|
203 | 203 | // sold can not go below zero |
204 | - $sold = max( 0, $sold ); |
|
205 | - $this->set( 'DTT_sold', $sold ); |
|
204 | + $sold = max(0, $sold); |
|
205 | + $this->set('DTT_sold', $sold); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * increments sold by amount passed by $qty |
212 | 212 | * @param int $qty |
213 | 213 | */ |
214 | - function increase_sold( $qty = 1 ) { |
|
214 | + function increase_sold($qty = 1) { |
|
215 | 215 | $sold = $this->sold() + $qty; |
216 | 216 | // remove ticket reservation |
217 | - $this->decrease_reserved( $qty ); |
|
218 | - $this->set_sold( $sold ); |
|
217 | + $this->decrease_reserved($qty); |
|
218 | + $this->set_sold($sold); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * decrements (subtracts) sold amount passed by $qty |
225 | 225 | * @param int $qty |
226 | 226 | */ |
227 | - function decrease_sold( $qty = 1 ) { |
|
227 | + function decrease_sold($qty = 1) { |
|
228 | 228 | $sold = $this->sold() - $qty; |
229 | - $this->set_sold( $sold ); |
|
229 | + $this->set_sold($sold); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return int |
238 | 238 | */ |
239 | 239 | function reserved() { |
240 | - return $this->get_raw( 'DTT_reserved' ); |
|
240 | + return $this->get_raw('DTT_reserved'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | * @param int $reserved |
249 | 249 | * @return boolean |
250 | 250 | */ |
251 | - function set_reserved( $reserved ) { |
|
251 | + function set_reserved($reserved) { |
|
252 | 252 | // reserved can not go below zero |
253 | - $reserved = max( 0, intval( $reserved ) ); |
|
254 | - $this->set( 'DTT_reserved', $reserved ); |
|
253 | + $reserved = max(0, intval($reserved)); |
|
254 | + $this->set('DTT_reserved', $reserved); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | * @param int $qty |
263 | 263 | * @return boolean |
264 | 264 | */ |
265 | - function increase_reserved( $qty = 1 ) { |
|
266 | - $reserved = $this->reserved() + absint( $qty ); |
|
267 | - return $this->set_reserved( $reserved ); |
|
265 | + function increase_reserved($qty = 1) { |
|
266 | + $reserved = $this->reserved() + absint($qty); |
|
267 | + return $this->set_reserved($reserved); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param int $qty |
276 | 276 | * @return boolean |
277 | 277 | */ |
278 | - function decrease_reserved( $qty = 1 ) { |
|
279 | - $reserved = $this->reserved() - absint( $qty ); |
|
280 | - return $this->set_reserved( $reserved ); |
|
278 | + function decrease_reserved($qty = 1) { |
|
279 | + $reserved = $this->reserved() - absint($qty); |
|
280 | + return $this->set_reserved($reserved); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return string |
299 | 299 | */ |
300 | 300 | public function name() { |
301 | - return $this->get( 'DTT_name' ); |
|
301 | + return $this->get('DTT_name'); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return string |
309 | 309 | */ |
310 | 310 | public function description() { |
311 | - return $this->get( 'DTT_description' ); |
|
311 | + return $this->get('DTT_description'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return boolean TRUE if is primary, FALSE if not. |
319 | 319 | */ |
320 | 320 | public function is_primary() { |
321 | - return $this->get( 'DTT_is_primary' ); |
|
321 | + return $this->get('DTT_is_primary'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return int The order of the datetime for this event. |
329 | 329 | */ |
330 | 330 | public function order() { |
331 | - return $this->get( 'DTT_order' ); |
|
331 | + return $this->get('DTT_order'); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @return int |
339 | 339 | */ |
340 | 340 | public function parent() { |
341 | - return $this->get( 'DTT_parent' ); |
|
341 | + return $this->get('DTT_parent'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
355 | 355 | * @return string|bool|void string on success, FALSE on fail |
356 | 356 | */ |
357 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
357 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
358 | 358 | $field_name = "DTT_EVT_{$start_or_end}"; |
359 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
360 | - if ( ! $echo ) { |
|
359 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
360 | + if ( ! $echo) { |
|
361 | 361 | return $dtt; |
362 | 362 | } |
363 | 363 | return ''; |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
374 | 374 | * @return mixed string on success, FALSE on fail |
375 | 375 | */ |
376 | - public function start_date( $dt_frmt = NULL ) { |
|
377 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
376 | + public function start_date($dt_frmt = NULL) { |
|
377 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | * Echoes start_date() |
384 | 384 | * @param string $dt_frmt |
385 | 385 | */ |
386 | - public function e_start_date( $dt_frmt = NULL ) { |
|
387 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
386 | + public function e_start_date($dt_frmt = NULL) { |
|
387 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
398 | 398 | * @return mixed string on success, FALSE on fail |
399 | 399 | */ |
400 | - public function end_date( $dt_frmt = NULL ) { |
|
401 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
400 | + public function end_date($dt_frmt = NULL) { |
|
401 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * Echoes the end date. See end_date() |
408 | 408 | * @param string $dt_frmt |
409 | 409 | */ |
410 | - public function e_end_date( $dt_frmt = NULL ) { |
|
411 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
410 | + public function e_end_date($dt_frmt = NULL) { |
|
411 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
422 | 422 | * @return mixed string on success, FALSE on fail |
423 | 423 | */ |
424 | - public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
425 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
426 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
427 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
428 | - return $start != $end ? $start . $conjunction . $end : $start; |
|
424 | + public function date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
425 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
426 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
427 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
428 | + return $start != $end ? $start.$conjunction.$end : $start; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @param null $dt_frmt |
435 | 435 | * @param string $conjunction |
436 | 436 | */ |
437 | - public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
438 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
437 | + public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
438 | + echo $this->date_range($dt_frmt, $conjunction); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
448 | 448 | * @return mixed string on success, FALSE on fail |
449 | 449 | */ |
450 | - public function start_time( $tm_format = NULL ) { |
|
451 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
450 | + public function start_time($tm_format = NULL) { |
|
451 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @param null $tm_format |
458 | 458 | */ |
459 | - public function e_start_time( $tm_format = NULL ) { |
|
460 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
459 | + public function e_start_time($tm_format = NULL) { |
|
460 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
470 | 470 | * @return mixed string on success, FALSE on fail |
471 | 471 | */ |
472 | - public function end_time( $tm_format = NULL ) { |
|
473 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
472 | + public function end_time($tm_format = NULL) { |
|
473 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | /** |
479 | 479 | * @param null $tm_format |
480 | 480 | */ |
481 | - public function e_end_time( $tm_format = NULL ) { |
|
482 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
481 | + public function e_end_time($tm_format = NULL) { |
|
482 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
493 | 493 | * @return mixed string on success, FALSE on fail |
494 | 494 | */ |
495 | - public function time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
496 | - $tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
495 | + public function time_range($tm_format = NULL, $conjunction = ' - ') { |
|
496 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
497 | 497 | |
498 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
499 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
500 | - return $start != $end ? $start . $conjunction . $end : $start; |
|
498 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
499 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
500 | + return $start != $end ? $start.$conjunction.$end : $start; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | * @param null $tm_format |
507 | 507 | * @param string $conjunction |
508 | 508 | */ |
509 | - public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
510 | - echo $this->time_range( $tm_format, $conjunction ); |
|
509 | + public function e_time_range($tm_format = NULL, $conjunction = ' - ') { |
|
510 | + echo $this->time_range($tm_format, $conjunction); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
521 | 521 | * @return mixed string on success, FALSE on fail |
522 | 522 | */ |
523 | - public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) { |
|
524 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
523 | + public function start_date_and_time($dt_format = NULL, $tm_format = NULL) { |
|
524 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @param null $dt_frmt |
531 | 531 | * @param null $tm_format |
532 | 532 | */ |
533 | - public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) { |
|
534 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
533 | + public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) { |
|
534 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | * @param bool $round_up |
546 | 546 | * @return float|int|mixed |
547 | 547 | */ |
548 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
549 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
550 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
548 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
549 | + $start = $this->get_raw('DTT_EVT_start'); |
|
550 | + $end = $this->get_raw('DTT_EVT_end'); |
|
551 | 551 | $length_in_units = $end - $start; |
552 | - switch ( $units ) { |
|
552 | + switch ($units) { |
|
553 | 553 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
554 | 554 | /** @noinspection PhpMissingBreakStatementInspection */ |
555 | 555 | case 'days': |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | $length_in_units /= 60; |
563 | 563 | case 'seconds': |
564 | 564 | default: |
565 | - $length_in_units = ceil( $length_in_units ); |
|
565 | + $length_in_units = ceil($length_in_units); |
|
566 | 566 | } |
567 | - if ( $round_up ) { |
|
568 | - $length_in_units = max( $length_in_units, 1 ); |
|
567 | + if ($round_up) { |
|
568 | + $length_in_units = max($length_in_units, 1); |
|
569 | 569 | } |
570 | 570 | return $length_in_units; |
571 | 571 | } |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @param bool | string $tm_format - string representation of time format defaults to 'g:i a' |
581 | 581 | * @return mixed string on success, FALSE on fail |
582 | 582 | */ |
583 | - public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
584 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
583 | + public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
584 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @param bool $dt_frmt |
591 | 591 | * @param bool $tm_format |
592 | 592 | */ |
593 | - public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
594 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
593 | + public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
594 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @return int |
604 | 604 | */ |
605 | 605 | public function start() { |
606 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
606 | + return $this->get_raw('DTT_EVT_start'); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @return int |
616 | 616 | */ |
617 | 617 | public function end() { |
618 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
618 | + return $this->get_raw('DTT_EVT_end'); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @return mixed int on success, FALSE on fail |
628 | 628 | */ |
629 | 629 | public function reg_limit() { |
630 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
630 | + return $this->get_raw('DTT_reg_limit'); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | |
@@ -656,15 +656,15 @@ discard block |
||
656 | 656 | * the spaces remaining for this particular datetime, hence the flag. |
657 | 657 | * @return int |
658 | 658 | */ |
659 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
659 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
660 | 660 | // tickets remaining available for purchase |
661 | 661 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
662 | 662 | $dtt_remaining = $this->reg_limit() - $this->sold(); |
663 | - if ( ! $consider_tickets ) { |
|
663 | + if ( ! $consider_tickets) { |
|
664 | 664 | return $dtt_remaining; |
665 | 665 | } |
666 | 666 | $tickets_remaining = $this->tickets_remaining(); |
667 | - return min( $dtt_remaining, $tickets_remaining ); |
|
667 | + return min($dtt_remaining, $tickets_remaining); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -675,19 +675,19 @@ discard block |
||
675 | 675 | * @param array $query_params like EEM_Base::get_all's |
676 | 676 | * @return int |
677 | 677 | */ |
678 | - public function tickets_remaining( $query_params = array() ) { |
|
678 | + public function tickets_remaining($query_params = array()) { |
|
679 | 679 | $sum = 0; |
680 | - $tickets = $this->tickets( $query_params ); |
|
681 | - if ( ! empty( $tickets ) ) { |
|
682 | - foreach ( $tickets as $ticket ) { |
|
683 | - if ( $ticket instanceof EE_Ticket ) { |
|
680 | + $tickets = $this->tickets($query_params); |
|
681 | + if ( ! empty($tickets)) { |
|
682 | + foreach ($tickets as $ticket) { |
|
683 | + if ($ticket instanceof EE_Ticket) { |
|
684 | 684 | // get the actual amount of tickets that can be sold |
685 | - $qty = $ticket->qty( 'saleable' ); |
|
686 | - if ( $qty === EE_INF ) { |
|
685 | + $qty = $ticket->qty('saleable'); |
|
686 | + if ($qty === EE_INF) { |
|
687 | 687 | return EE_INF; |
688 | 688 | } |
689 | 689 | // no negative ticket quantities plz |
690 | - if ( $qty > 0 ) { |
|
690 | + if ($qty > 0) { |
|
691 | 691 | $sum += $qty; |
692 | 692 | } |
693 | 693 | } |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | * @param array $query_params like EEM_Base::get_all's |
705 | 705 | * @return int |
706 | 706 | */ |
707 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
708 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
707 | + public function sum_tickets_initially_available($query_params = array()) { |
|
708 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @return int |
718 | 718 | */ |
719 | 719 | public function total_tickets_available_at_this_datetime() { |
720 | - return $this->spaces_remaining( true ); |
|
720 | + return $this->spaces_remaining(true); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @return boolean |
729 | 729 | */ |
730 | 730 | public function is_upcoming() { |
731 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
731 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | * @return boolean |
739 | 739 | */ |
740 | 740 | public function is_active() { |
741 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
741 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * @return boolean |
749 | 749 | */ |
750 | 750 | public function is_expired() { |
751 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
751 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -759,16 +759,16 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public function get_active_status() { |
761 | 761 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
762 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
762 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
763 | 763 | return EE_Datetime::sold_out; |
764 | 764 | } |
765 | - if ( $this->is_expired() ) { |
|
765 | + if ($this->is_expired()) { |
|
766 | 766 | return EE_Datetime::expired; |
767 | 767 | } |
768 | - if ( $this->is_upcoming() ) { |
|
768 | + if ($this->is_upcoming()) { |
|
769 | 769 | return EE_Datetime::upcoming; |
770 | 770 | } |
771 | - if ( $this->is_active() ) { |
|
771 | + if ($this->is_active()) { |
|
772 | 772 | return EE_Datetime::active; |
773 | 773 | } |
774 | 774 | return NULL; |
@@ -782,24 +782,24 @@ discard block |
||
782 | 782 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
783 | 783 | * @return string |
784 | 784 | */ |
785 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
786 | - if ( $use_dtt_name ) { |
|
785 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
786 | + if ($use_dtt_name) { |
|
787 | 787 | $dtt_name = $this->name(); |
788 | - if ( !empty( $dtt_name ) ) { |
|
788 | + if ( ! empty($dtt_name)) { |
|
789 | 789 | return $dtt_name; |
790 | 790 | } |
791 | 791 | } |
792 | 792 | //first condition is to see if the months are different |
793 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
794 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
793 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
794 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
795 | 795 | //next condition is if its the same month but different day |
796 | 796 | } |
797 | 797 | else { |
798 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
799 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
798 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
799 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
800 | 800 | } |
801 | 801 | else { |
802 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
802 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | return $display_date; |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | *@param array $query_params see EEM_Base::get_all() |
814 | 814 | * @return EE_Ticket[] |
815 | 815 | */ |
816 | - public function tickets( $query_params = array() ) { |
|
817 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
816 | + public function tickets($query_params = array()) { |
|
817 | + return $this->get_many_related('Ticket', $query_params); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | |
@@ -824,21 +824,21 @@ discard block |
||
824 | 824 | * @param array $query_params like EEM_Base::get_all's |
825 | 825 | * @return EE_Ticket[] |
826 | 826 | */ |
827 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
827 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
828 | 828 | // first check if datetime is valid |
829 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
829 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
830 | 830 | return array(); |
831 | 831 | } |
832 | - if ( empty( $query_params ) ) { |
|
832 | + if (empty($query_params)) { |
|
833 | 833 | $query_params = array( |
834 | 834 | array( |
835 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
836 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
835 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
836 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
837 | 837 | 'TKT_deleted' => false |
838 | 838 | ) |
839 | 839 | ); |
840 | 840 | } |
841 | - return $this->tickets( $query_params ); |
|
841 | + return $this->tickets($query_params); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | * @return EE_Event |
849 | 849 | */ |
850 | 850 | public function event() { |
851 | - return $this->get_first_related( 'Event' ); |
|
851 | + return $this->get_first_related('Event'); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | |
@@ -860,13 +860,13 @@ discard block |
||
860 | 860 | */ |
861 | 861 | public function update_sold() { |
862 | 862 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
863 | - array( array( |
|
863 | + array(array( |
|
864 | 864 | 'STS_ID' => EEM_Registration::status_id_approved, |
865 | 865 | 'REG_deleted' => 0, |
866 | 866 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
867 | - ) ) |
|
867 | + )) |
|
868 | 868 | ); |
869 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
869 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
870 | 870 | $this->save(); |
871 | 871 | return $count_regs_for_this_datetime; |
872 | 872 | } |