@@ -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 | * CSV Import Export class |
4 | 4 | * |
@@ -45,31 +45,31 @@ discard block |
||
45 | 45 | global $wpdb; |
46 | 46 | |
47 | 47 | $this->_primary_keys = array( |
48 | - $wpdb->prefix . 'esp_answer' => array( 'ANS_ID' ), |
|
49 | - $wpdb->prefix . 'esp_attendee' => array( 'ATT_ID' ), |
|
50 | - $wpdb->prefix . 'esp_datetime' => array( 'DTT_ID' ), |
|
51 | - $wpdb->prefix . 'esp_event_question_group' => array( 'EQG_ID' ), |
|
52 | - $wpdb->prefix . 'esp_message_template' => array( 'MTP_ID' ), |
|
53 | - $wpdb->prefix . 'esp_payment' => array( 'PAY_ID' ), |
|
54 | - $wpdb->prefix . 'esp_price' => array( 'PRC_ID' ), |
|
55 | - $wpdb->prefix . 'esp_price_type' => array( 'PRT_ID' ), |
|
56 | - $wpdb->prefix . 'esp_question' => array( 'QST_ID' ), |
|
57 | - $wpdb->prefix . 'esp_question_group' => array( 'QSG_ID' ), |
|
58 | - $wpdb->prefix . 'esp_question_group_question' => array( 'QGQ_ID' ), |
|
59 | - $wpdb->prefix . 'esp_question_option' => array( 'QSO_ID' ), |
|
60 | - $wpdb->prefix . 'esp_registration' => array( 'REG_ID' ), |
|
61 | - $wpdb->prefix . 'esp_status' => array( 'STS_ID' ), |
|
62 | - $wpdb->prefix . 'esp_transaction' => array( 'TXN_ID' ), |
|
63 | - $wpdb->prefix . 'esp_transaction' => array( 'TXN_ID' ), |
|
64 | - $wpdb->prefix . 'events_detail' => array( 'id' ), |
|
65 | - $wpdb->prefix . 'events_category_detail' => array( 'id' ), |
|
66 | - $wpdb->prefix . 'events_category_rel' => array( 'id' ), |
|
67 | - $wpdb->prefix . 'events_venue' => array( 'id' ), |
|
68 | - $wpdb->prefix . 'events_venue_rel' => array( 'emeta_id' ), |
|
69 | - $wpdb->prefix . 'events_locale' => array( 'id' ), |
|
70 | - $wpdb->prefix . 'events_locale_rel' => array( 'id' ), |
|
71 | - $wpdb->prefix . 'events_personnel' => array( 'id' ), |
|
72 | - $wpdb->prefix . 'events_personnel_rel' => array( 'id' ), |
|
48 | + $wpdb->prefix.'esp_answer' => array('ANS_ID'), |
|
49 | + $wpdb->prefix.'esp_attendee' => array('ATT_ID'), |
|
50 | + $wpdb->prefix.'esp_datetime' => array('DTT_ID'), |
|
51 | + $wpdb->prefix.'esp_event_question_group' => array('EQG_ID'), |
|
52 | + $wpdb->prefix.'esp_message_template' => array('MTP_ID'), |
|
53 | + $wpdb->prefix.'esp_payment' => array('PAY_ID'), |
|
54 | + $wpdb->prefix.'esp_price' => array('PRC_ID'), |
|
55 | + $wpdb->prefix.'esp_price_type' => array('PRT_ID'), |
|
56 | + $wpdb->prefix.'esp_question' => array('QST_ID'), |
|
57 | + $wpdb->prefix.'esp_question_group' => array('QSG_ID'), |
|
58 | + $wpdb->prefix.'esp_question_group_question' => array('QGQ_ID'), |
|
59 | + $wpdb->prefix.'esp_question_option' => array('QSO_ID'), |
|
60 | + $wpdb->prefix.'esp_registration' => array('REG_ID'), |
|
61 | + $wpdb->prefix.'esp_status' => array('STS_ID'), |
|
62 | + $wpdb->prefix.'esp_transaction' => array('TXN_ID'), |
|
63 | + $wpdb->prefix.'esp_transaction' => array('TXN_ID'), |
|
64 | + $wpdb->prefix.'events_detail' => array('id'), |
|
65 | + $wpdb->prefix.'events_category_detail' => array('id'), |
|
66 | + $wpdb->prefix.'events_category_rel' => array('id'), |
|
67 | + $wpdb->prefix.'events_venue' => array('id'), |
|
68 | + $wpdb->prefix.'events_venue_rel' => array('emeta_id'), |
|
69 | + $wpdb->prefix.'events_locale' => array('id'), |
|
70 | + $wpdb->prefix.'events_locale_rel' => array('id'), |
|
71 | + $wpdb->prefix.'events_personnel' => array('id'), |
|
72 | + $wpdb->prefix.'events_personnel_rel' => array('id'), |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @ access public |
82 | 82 | * @return EE_CSV |
83 | 83 | */ |
84 | - public static function instance ( ) { |
|
84 | + public static function instance( ) { |
|
85 | 85 | // check if class object is instantiated |
86 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_CSV )) { |
|
86 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) { |
|
87 | 87 | self::$_instance = new self(); |
88 | 88 | } |
89 | 89 | return self::$_instance; |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | * @throws EE_Error |
97 | 97 | */ |
98 | - private function read_unicode_file($file_path){ |
|
98 | + private function read_unicode_file($file_path) { |
|
99 | 99 | $fc = ""; |
100 | - $fh = fopen($file_path,"rb"); |
|
101 | - if( ! $fh ){ |
|
102 | - throw new EE_Error( sprintf( __("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path ) ); |
|
100 | + $fh = fopen($file_path, "rb"); |
|
101 | + if ( ! $fh) { |
|
102 | + throw new EE_Error(sprintf(__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path)); |
|
103 | 103 | } |
104 | 104 | $flen = filesize($file_path); |
105 | 105 | $bc = fread($fh, $flen); |
106 | - for ($i=0; $i<$flen; $i++){ |
|
107 | - $c = substr($bc,$i,1); |
|
108 | - if ((ord($c) != 0) && (ord($c) != 13)){ |
|
109 | - $fc = $fc . $c; |
|
106 | + for ($i = 0; $i < $flen; $i++) { |
|
107 | + $c = substr($bc, $i, 1); |
|
108 | + if ((ord($c) != 0) && (ord($c) != 13)) { |
|
109 | + $fc = $fc.$c; |
|
110 | 110 | } |
111 | 111 | } |
112 | - if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254)) |
|
113 | - $fc = substr($fc,2); |
|
112 | + if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254)) |
|
113 | + $fc = substr($fc, 2); |
|
114 | 114 | return ($fc); |
115 | 115 | } |
116 | 116 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * @param string $path_to_file |
123 | 123 | * @return array of arrays. Top-level array has rows, second-level array has each item |
124 | 124 | */ |
125 | - public function import_csv_to_multi_dimensional_array($path_to_file){ |
|
125 | + public function import_csv_to_multi_dimensional_array($path_to_file) { |
|
126 | 126 | // needed to deal with Mac line endings |
127 | - ini_set('auto_detect_line_endings',TRUE); |
|
127 | + ini_set('auto_detect_line_endings', TRUE); |
|
128 | 128 | |
129 | 129 | // because fgetcsv does not correctly deal with backslashed quotes such as \" |
130 | 130 | // we'll read the file into a string |
131 | - $file_contents = $this->read_unicode_file( $path_to_file ); |
|
131 | + $file_contents = $this->read_unicode_file($path_to_file); |
|
132 | 132 | // replace backslashed quotes with CSV enclosures |
133 | - $file_contents = str_replace ( '\\"', '"""', $file_contents ); |
|
133 | + $file_contents = str_replace('\\"', '"""', $file_contents); |
|
134 | 134 | // HEY YOU! PUT THAT FILE BACK!!! |
135 | 135 | file_put_contents($path_to_file, $file_contents); |
136 | 136 | |
@@ -140,25 +140,25 @@ discard block |
||
140 | 140 | $csvarray = array(); |
141 | 141 | |
142 | 142 | // in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what? |
143 | - if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { |
|
143 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
144 | 144 | |
145 | 145 | // PHP 5.2- version |
146 | 146 | |
147 | 147 | // loop through each row of the file |
148 | - while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){ |
|
149 | - $csvarray[]= $data; |
|
148 | + while (($data = fgetcsv($file_handle, 0, ',', '"')) !== FALSE) { |
|
149 | + $csvarray[] = $data; |
|
150 | 150 | } |
151 | - }else{ |
|
151 | + } else { |
|
152 | 152 | // loop through each row of the file |
153 | - while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) { |
|
154 | - $csvarray[]=$data; |
|
153 | + while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== FALSE) { |
|
154 | + $csvarray[] = $data; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | # Close the File. |
158 | 158 | fclose($file_handle); |
159 | 159 | return $csvarray; |
160 | - }else{ |
|
161 | - EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ ); |
|
160 | + } else { |
|
161 | + EE_Error::add_error(sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), __FILE__, __FUNCTION__, __LINE__); |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * ... |
189 | 189 | * ) |
190 | 190 | */ |
191 | - public function import_csv_to_model_data_array( $path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE ) { |
|
191 | + public function import_csv_to_model_data_array($path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE) { |
|
192 | 192 | $multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file); |
193 | - if( ! $multi_dimensional_array ){ |
|
193 | + if ( ! $multi_dimensional_array) { |
|
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | // gotta start somewhere |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | $ee_formatted_data = array(); |
200 | 200 | // array to store headers (column names) |
201 | 201 | $headers = array(); |
202 | - foreach($multi_dimensional_array as $data){ |
|
202 | + foreach ($multi_dimensional_array as $data) { |
|
203 | 203 | // if first cell is MODEL, then second cell is the MODEL name |
204 | - if ( $data[0] == 'MODEL' ) { |
|
204 | + if ($data[0] == 'MODEL') { |
|
205 | 205 | $model_name = $data[1]; |
206 | 206 | //don't bother looking for model data in this row. The rest of this |
207 | 207 | //row should be blank |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $headers = array(); |
212 | 212 | continue; |
213 | 213 | } |
214 | - if( strpos( $data[0], EE_CSV::metadata_header ) !==FALSE ){ |
|
214 | + if (strpos($data[0], EE_CSV::metadata_header) !== FALSE) { |
|
215 | 215 | $model_name = EE_CSV::metadata_header; |
216 | 216 | //store like model data, we just won't try importing it etc. |
217 | 217 | $row = 1; |
@@ -224,31 +224,31 @@ discard block |
||
224 | 224 | |
225 | 225 | $model_entry = array(); |
226 | 226 | // loop through each column |
227 | - for ( $i=0; $i < $columns; $i++ ) { |
|
227 | + for ($i = 0; $i < $columns; $i++) { |
|
228 | 228 | |
229 | 229 | //replace csv_enclosures with backslashed quotes |
230 | - $data[$i] = str_replace ( '"""', '\\"', $data[$i] ); |
|
230 | + $data[$i] = str_replace('"""', '\\"', $data[$i]); |
|
231 | 231 | // do we need to grab the column names? |
232 | - if ( $row === 1){ |
|
233 | - if( $first_row_is_headers ) { |
|
232 | + if ($row === 1) { |
|
233 | + if ($first_row_is_headers) { |
|
234 | 234 | // store the column names to use for keys |
235 | 235 | $column_name = $data[$i]; |
236 | 236 | //check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end... |
237 | - if(!$column_name){continue;} |
|
237 | + if ( ! $column_name) {continue; } |
|
238 | 238 | $matches = array(); |
239 | - if($model_name == EE_CSV::metadata_header){ |
|
239 | + if ($model_name == EE_CSV::metadata_header) { |
|
240 | 240 | $headers[$i] = $column_name; |
241 | - }else{ |
|
241 | + } else { |
|
242 | 242 | //now get the db table name from it (the part between square brackets) |
243 | - $success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches); |
|
244 | - if (!$success){ |
|
245 | - EE_Error::add_error( sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"),$column_name,implode(",",$data)), __FILE__, __FUNCTION__, __LINE__ ); |
|
243 | + $success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches); |
|
244 | + if ( ! $success) { |
|
245 | + EE_Error::add_error(sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"), $column_name, implode(",", $data)), __FILE__, __FUNCTION__, __LINE__); |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | $headers[$i] = $matches[2]; |
249 | 249 | } |
250 | 250 | |
251 | - }else{ |
|
251 | + } else { |
|
252 | 252 | // no column names means our final array will just use counters for keys |
253 | 253 | $model_entry[$headers[$i]] = $data[$i]; |
254 | 254 | $headers[$i] = $i; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | // and we need to store csv data |
257 | 257 | } else { |
258 | 258 | // this column isn' ta header, store it if there is a header for it |
259 | - if(isset($headers[$i])){ |
|
259 | + if (isset($headers[$i])) { |
|
260 | 260 | $model_entry[$headers[$i]] = $data[$i]; |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | 264 | } |
265 | 265 | //save the row's data IF it's a non-header-row |
266 | - if( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)){ |
|
266 | + if ( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)) { |
|
267 | 267 | $ee_formatted_data[$model_name][] = $model_entry; |
268 | 268 | } |
269 | 269 | // advance to next row |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | - public function save_csv_to_db( $csv_data_array, $model_name = FALSE ) { |
|
286 | - EE_Error::doing_it_wrong('save_csv_to_db', __( 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso' ), '4.6.7' ); |
|
287 | - return EE_Import::instance()->save_csv_data_array_to_db( $csv_data_array, $model_name ); |
|
285 | + public function save_csv_to_db($csv_data_array, $model_name = FALSE) { |
|
286 | + EE_Error::doing_it_wrong('save_csv_to_db', __('Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso'), '4.6.7'); |
|
287 | + return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * @param string $new_filename the name of the file that the user will download |
295 | 295 | * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc. |
296 | 296 | */ |
297 | - public function begin_sending_csv($filename){ |
|
297 | + public function begin_sending_csv($filename) { |
|
298 | 298 | // grab file extension |
299 | 299 | $ext = substr(strrchr($filename, '.'), 1); |
300 | - if ( $ext == '.csv' or $ext == '.xls' ) { |
|
301 | - str_replace( $ext, '', $filename ); |
|
300 | + if ($ext == '.csv' or $ext == '.xls') { |
|
301 | + str_replace($ext, '', $filename); |
|
302 | 302 | } |
303 | 303 | $filename .= '.csv'; |
304 | 304 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | // header("Content-Type: application/download"); |
320 | 320 | header('Content-disposition: attachment; filename='.$filename); |
321 | 321 | header("Content-Type: text/csv; charset=utf-8"); |
322 | - do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' ); |
|
323 | - echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
|
322 | + do_action('AHEE__EE_CSV__begin_sending_csv__headers'); |
|
323 | + echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF"); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
|
324 | 324 | $fh = fopen('php://output', 'w'); |
325 | 325 | return $fh; |
326 | 326 | } |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | * mentioning the version and timezone |
331 | 331 | * @param resource $filehandle |
332 | 332 | */ |
333 | - public function write_metadata_to_csv($filehandle){ |
|
334 | - $data_row = array(EE_CSV::metadata_header);//do NOT translate because this exact string is used when importing |
|
333 | + public function write_metadata_to_csv($filehandle) { |
|
334 | + $data_row = array(EE_CSV::metadata_header); //do NOT translate because this exact string is used when importing |
|
335 | 335 | $this->fputcsv2($filehandle, $data_row); |
336 | - $meta_data = array( 0=> array( |
|
336 | + $meta_data = array(0=> array( |
|
337 | 337 | 'version'=>espresso_version(), |
338 | 338 | 'timezone'=> EEH_DTT_Helper::get_timezone(), |
339 | 339 | 'time_of_export'=>current_time('mysql'), |
@@ -351,29 +351,29 @@ discard block |
||
351 | 351 | * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..." |
352 | 352 | * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success (because we wrote everything there was...nothing) |
353 | 353 | */ |
354 | - public function write_data_array_to_csv($filehandle, $data){ |
|
354 | + public function write_data_array_to_csv($filehandle, $data) { |
|
355 | 355 | |
356 | 356 | |
357 | 357 | //determine if $data is actually a 2d array |
358 | - if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){ |
|
358 | + if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) { |
|
359 | 359 | //make sure top level is numerically indexed, |
360 | 360 | |
361 | - if( EEH_Array::is_associative_array($data)){ |
|
362 | - throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s","event_espresso"),implode(",",array_keys($data)))); |
|
361 | + if (EEH_Array::is_associative_array($data)) { |
|
362 | + throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data)))); |
|
363 | 363 | } |
364 | 364 | $item_in_top_level_array = EEH_Array::get_one_item_from_array($data); |
365 | 365 | //now, is the last item in the top-level array of $data an associative or numeric array? |
366 | - if(EEH_Array::is_associative_array($item_in_top_level_array)){ |
|
366 | + if (EEH_Array::is_associative_array($item_in_top_level_array)) { |
|
367 | 367 | //its associative, so we want to output its keys as column headers |
368 | 368 | $keys = array_keys($item_in_top_level_array); |
369 | 369 | echo $this->fputcsv2($filehandle, $keys); |
370 | 370 | } |
371 | 371 | //start writing data |
372 | - foreach($data as $data_row){ |
|
372 | + foreach ($data as $data_row) { |
|
373 | 373 | echo $this->fputcsv2($filehandle, $data_row); |
374 | 374 | } |
375 | 375 | return true; |
376 | - }else{ |
|
376 | + } else { |
|
377 | 377 | //no data TO write... so we can assume that's a success |
378 | 378 | return true; |
379 | 379 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * Calls exit to prevent polluting the CSV file with other junk |
419 | 419 | * @param resource $fh filehandle where we're writing the CSV to |
420 | 420 | */ |
421 | - public function end_sending_csv($fh){ |
|
421 | + public function end_sending_csv($fh) { |
|
422 | 422 | fclose($fh); |
423 | 423 | exit(0); |
424 | 424 | } |
@@ -431,23 +431,23 @@ discard block |
||
431 | 431 | * has all the attributes o fthat model object (eg, the event's id, name, etc) |
432 | 432 | * @return boolean success |
433 | 433 | */ |
434 | - public function write_model_data_to_csv($filehandle,$model_data_array){ |
|
434 | + public function write_model_data_to_csv($filehandle, $model_data_array) { |
|
435 | 435 | $this->write_metadata_to_csv($filehandle); |
436 | - foreach($model_data_array as $model_name => $model_instance_arrays){ |
|
436 | + foreach ($model_data_array as $model_name => $model_instance_arrays) { |
|
437 | 437 | //first: output a special row stating the model |
438 | - echo $this->fputcsv2($filehandle,array('MODEL',$model_name)); |
|
438 | + echo $this->fputcsv2($filehandle, array('MODEL', $model_name)); |
|
439 | 439 | //if we have items to put in the CSV, do it normally |
440 | 440 | |
441 | - if( ! empty($model_instance_arrays) ){ |
|
441 | + if ( ! empty($model_instance_arrays)) { |
|
442 | 442 | $this->write_data_array_to_csv($filehandle, $model_instance_arrays); |
443 | - }else{ |
|
443 | + } else { |
|
444 | 444 | // echo "no data to write... so just write the headers"; |
445 | 445 | //so there's actually NO model objects for that model. |
446 | 446 | //probably still want to show the columns |
447 | 447 | $model = EE_Registry::instance()->load_model($model_name); |
448 | 448 | $column_names = array(); |
449 | - foreach($model->field_settings() as $field){ |
|
450 | - $column_names[$field->get_nicename()."[".$field->get_name()."]"] = null ; |
|
449 | + foreach ($model->field_settings() as $field) { |
|
450 | + $column_names[$field->get_nicename()."[".$field->get_name()."]"] = null; |
|
451 | 451 | } |
452 | 452 | $this->write_data_array_to_csv($filehandle, array($column_names)); |
453 | 453 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv() |
462 | 462 | * @return bool | void writes CSV file to output and dies |
463 | 463 | */ |
464 | - public function export_multiple_model_data_to_csv($filename,$model_data_array){ |
|
464 | + public function export_multiple_model_data_to_csv($filename, $model_data_array) { |
|
465 | 465 | $filehandle = $this->begin_sending_csv($filename); |
466 | 466 | $this->write_model_data_to_csv($filehandle, $model_data_array); |
467 | 467 | $this->end_sending_csv($filehandle); |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | * @param string $filename - name for newly created csv file |
474 | 474 | * @return TRUE on success, FALSE on fail |
475 | 475 | */ |
476 | - public function export_array_to_csv( $data = FALSE, $filename = FALSE ) { |
|
476 | + public function export_array_to_csv($data = FALSE, $filename = FALSE) { |
|
477 | 477 | |
478 | 478 | // no data file?? get outta here |
479 | - if ( ! $data or ! is_array( $data ) or empty( $data ) ) { |
|
479 | + if ( ! $data or ! is_array($data) or empty($data)) { |
|
480 | 480 | return FALSE; |
481 | 481 | } |
482 | 482 | |
483 | 483 | // no filename?? get outta here |
484 | - if ( ! $filename ) { |
|
484 | + if ( ! $filename) { |
|
485 | 485 | return FALSE; |
486 | 486 | } |
487 | 487 | |
@@ -507,11 +507,11 @@ discard block |
||
507 | 507 | * @param int $percent_of_max - desired percentage of the max upload_mb |
508 | 508 | * @return int KB |
509 | 509 | */ |
510 | - public function get_max_upload_size ( $percent_of_max = FALSE ) { |
|
510 | + public function get_max_upload_size($percent_of_max = FALSE) { |
|
511 | 511 | |
512 | - $max_upload = (int)(ini_get('upload_max_filesize')); |
|
513 | - $max_post = (int)(ini_get('post_max_size')); |
|
514 | - $memory_limit = (int)(ini_get('memory_limit')); |
|
512 | + $max_upload = (int) (ini_get('upload_max_filesize')); |
|
513 | + $max_post = (int) (ini_get('post_max_size')); |
|
514 | + $memory_limit = (int) (ini_get('memory_limit')); |
|
515 | 515 | |
516 | 516 | // determine the smallest of the three values from above |
517 | 517 | $upload_mb = min($max_upload, $max_post, $memory_limit); |
@@ -520,9 +520,9 @@ discard block |
||
520 | 520 | $upload_mb = $upload_mb * 1024; |
521 | 521 | |
522 | 522 | // don't want the full monty? then reduce the max uplaod size |
523 | - if ( $percent_of_max ) { |
|
523 | + if ($percent_of_max) { |
|
524 | 524 | // is percent_of_max like this -> 50 or like this -> 0.50 ? |
525 | - if ( $percent_of_max > 1 ) { |
|
525 | + if ($percent_of_max > 1) { |
|
526 | 526 | // chnages 50 to 0.50 |
527 | 527 | $percent_of_max = $percent_of_max / 100; |
528 | 528 | } |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | * @param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - private function fputcsv2 ($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) { |
|
547 | + private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) { |
|
548 | 548 | //Allow user to filter the csv delimiter and enclosure for other countries csv standards |
549 | - $delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter ); |
|
550 | - $enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure ); |
|
549 | + $delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter); |
|
550 | + $enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure); |
|
551 | 551 | |
552 | 552 | $delimiter_esc = preg_quote($delimiter, '/'); |
553 | 553 | $enclosure_esc = preg_quote($enclosure, '/'); |
554 | 554 | |
555 | 555 | $output = array(); |
556 | 556 | foreach ($row as $field_value) { |
557 | - if(is_object($field_value) || is_array($field_value)){ |
|
557 | + if (is_object($field_value) || is_array($field_value)) { |
|
558 | 558 | $field_value = serialize($field_value); |
559 | 559 | } |
560 | 560 | if ($field_value === null && $mysql_null) { |
@@ -563,10 +563,10 @@ discard block |
||
563 | 563 | } |
564 | 564 | |
565 | 565 | $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ? |
566 | - ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value; |
|
566 | + ($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value; |
|
567 | 567 | } |
568 | 568 | |
569 | - fwrite($fh, join($delimiter, $output) . PHP_EOL); |
|
569 | + fwrite($fh, join($delimiter, $output).PHP_EOL); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | * @param string $current_format |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - public function get_date_format_for_csv( $current_format = null ) { |
|
608 | - return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format ); |
|
607 | + public function get_date_format_for_csv($current_format = null) { |
|
608 | + return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | * @param string $current_format |
614 | 614 | * @return string |
615 | 615 | */ |
616 | - public function get_time_format_for_csv( $current_format = null ) { |
|
617 | - return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format ); |
|
616 | + public function get_time_format_for_csv($current_format = null) { |
|
617 | + return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | * @param array $arguments |
40 | 40 | * @return \EE_CPT_Venue_Strategy |
41 | 41 | */ |
42 | - public function __construct( $arguments = array() ) { |
|
43 | - $this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : NULL; |
|
44 | - $WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : NULL; |
|
45 | - if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_tag ) { |
|
46 | - $WP_Query->is_espresso_venue_single = is_singular() && isset( $WP_Query->query->post_type ) && $WP_Query->query->post_type == 'espresso_venues' ? TRUE : FALSE; |
|
42 | + public function __construct($arguments = array()) { |
|
43 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : NULL; |
|
44 | + $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : NULL; |
|
45 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_tag) { |
|
46 | + $WP_Query->is_espresso_venue_single = is_singular() && isset($WP_Query->query->post_type) && $WP_Query->query->post_type == 'espresso_venues' ? TRUE : FALSE; |
|
47 | 47 | $WP_Query->is_espresso_venue_archive = is_post_type_archive('espresso_venues') ? TRUE : FALSE; |
48 | - $WP_Query->is_espresso_venue_taxonomy = is_tax( 'espresso_venue_categories' ) ? TRUE : FALSE; |
|
48 | + $WP_Query->is_espresso_venue_taxonomy = is_tax('espresso_venue_categories') ? TRUE : FALSE; |
|
49 | 49 | } |
50 | - add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
|
50 | + add_filter('the_posts', array($this, 'the_posts'), 1, 2); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param WP_Query $wp_query |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - public function the_posts( $posts, WP_Query $wp_query) { |
|
63 | + public function the_posts($posts, WP_Query $wp_query) { |
|
64 | 64 | // automagically load the EEH_Venue_View helper so that it's functions are available |
65 | - if ( isset( EE_Registry::instance()->CFG->map_settings->use_google_maps ) && EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
65 | + if (isset(EE_Registry::instance()->CFG->map_settings->use_google_maps) && EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
66 | 66 | EEH_Maps::espresso_google_map_js(); |
67 | 67 | } |
68 | - remove_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
|
68 | + remove_filter('the_posts', array($this, 'the_posts'), 1, 2); |
|
69 | 69 | return $posts; |
70 | 70 | } |
71 | 71 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\address\formatters; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param string $CNT_ISO |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) { |
|
31 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) { |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\address\formatters; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | // swap address part placeholders for the real text |
42 | 42 | $formatted_address = str_replace( |
43 | 43 | // find |
44 | - array( '{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}' ), |
|
44 | + array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
45 | 45 | // replace |
46 | - array( $address, $address2, $city, $state, $zip, $country ), |
|
46 | + array($address, $address2, $city, $state, $zip, $country), |
|
47 | 47 | // string |
48 | 48 | $formatted_address |
49 | 49 | ); |
50 | 50 | // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
51 | - return preg_replace( '/%+/', $sub, trim( $formatted_address, '%' ) ); |
|
51 | + return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\address\formatters; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param string $CNT_ISO |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) { |
|
31 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) { |
|
32 | 32 | $address_formats = apply_filters( |
33 | 33 | 'FHEE__EE_Inline_Address_Formatter__address_formats', |
34 | 34 | array( |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ) |
40 | 40 | ); |
41 | 41 | // if the incoming country has a set format, use that, else use the default |
42 | - $formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ] |
|
42 | + $formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO] |
|
43 | 43 | : $address_formats['ZZZ']; |
44 | 44 | return $this->parse_formatted_address( |
45 | 45 | $address, |
@@ -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 | * Class EE_Log |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @return EE_Log |
63 | 63 | */ |
64 | 64 | public static function instance() { |
65 | - if ( ! self::$_instance instanceof EE_Log ) { |
|
65 | + if ( ! self::$_instance instanceof EE_Log) { |
|
66 | 66 | self::$_instance = new self(); |
67 | 67 | } |
68 | 68 | return self::$_instance; |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function __construct() { |
76 | 76 | |
77 | - if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging ) { |
|
77 | + if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - $this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS; |
|
81 | + $this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS; |
|
82 | 82 | $this->_log_file = EE_Registry::instance()->CFG->admin->log_file_name(); |
83 | 83 | $this->_log = ''; |
84 | 84 | $this->_debug_file = EE_Registry::instance()->CFG->admin->debug_file_name(); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
87 | 87 | $this->_remote_log = ''; |
88 | 88 | |
89 | - add_action( 'admin_init', array( $this, 'verify_filesystem' ), -10 ); |
|
90 | - add_action( 'AHEE_log', array( $this, 'log' ), 10, 4 ); |
|
91 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
92 | - add_action( 'shutdown', array( $this, 'write_log' ), 9999 ); |
|
89 | + add_action('admin_init', array($this, 'verify_filesystem'), -10); |
|
90 | + add_action('AHEE_log', array($this, 'log'), 10, 4); |
|
91 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
92 | + add_action('shutdown', array($this, 'write_log'), 9999); |
|
93 | 93 | // if WP_DEBUG |
94 | - add_action( 'shutdown', array( $this, 'write_debug' ), 9999 ); |
|
94 | + add_action('shutdown', array($this, 'write_debug'), 9999); |
|
95 | 95 | } |
96 | - if ( EE_Registry::instance()->CFG->admin->use_remote_logging ) { |
|
97 | - add_action( 'shutdown', array( $this, 'send_log' ), 9999 ); |
|
96 | + if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
97 | + add_action('shutdown', array($this, 'send_log'), 9999); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function verify_filesystem() { |
110 | 110 | try { |
111 | - EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_log_file ); |
|
112 | - EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_debug_file ); |
|
113 | - EEH_File::add_htaccess_deny_from_all( $this->_logs_folder ); |
|
114 | - } catch( EE_Error $e ){ |
|
115 | - EE_Error::add_error( sprintf( __( 'Event Espresso logging could not be setup because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_log_file); |
|
112 | + EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_debug_file); |
|
113 | + EEH_File::add_htaccess_deny_from_all($this->_logs_folder); |
|
114 | + } catch (EE_Error $e) { |
|
115 | + EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | } |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * @param string $type |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - private function _format_message( $file = '', $function = '', $message = '', $type = '' ) { |
|
133 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
134 | - $msg .= '[' . current_time( 'mysql' ) . '] '; |
|
135 | - $msg .= ! empty( $file ) ? basename( $file ) : ''; |
|
136 | - $msg .= ! empty( $file ) && ! empty( $function ) ? ' -> ' : ''; |
|
137 | - $msg .= ! empty( $function ) ? $function . '()' : ''; |
|
132 | + private function _format_message($file = '', $function = '', $message = '', $type = '') { |
|
133 | + $msg = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
134 | + $msg .= '['.current_time('mysql').'] '; |
|
135 | + $msg .= ! empty($file) ? basename($file) : ''; |
|
136 | + $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
137 | + $msg .= ! empty($function) ? $function.'()' : ''; |
|
138 | 138 | $msg .= PHP_EOL; |
139 | - $type = ! empty( $type ) ? $type : 'log message'; |
|
140 | - $msg .= ! empty( $message ) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
139 | + $type = ! empty($type) ? $type : 'log message'; |
|
140 | + $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : ''; |
|
141 | 141 | return $msg; |
142 | 142 | } |
143 | 143 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param string $message |
153 | 153 | * @param string $type |
154 | 154 | */ |
155 | - public function log( $file = '', $function = '', $message = '', $type = '' ) { |
|
156 | - $this->_log .= $this->_format_message( $file, $function, $message, $type ); |
|
155 | + public function log($file = '', $function = '', $message = '', $type = '') { |
|
156 | + $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | public function write_log() { |
166 | 166 | try { |
167 | 167 | //get existing log file and append new log info |
168 | - $this->_log = EEH_File::get_file_contents( $this->_logs_folder . $this->_log_file ) . $this->_log; |
|
169 | - EEH_File::write_to_file( $this->_logs_folder . $this->_log_file, $this->_log, 'Event Espresso Log' ); |
|
170 | - } catch( EE_Error $e ){ |
|
171 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
168 | + $this->_log = EEH_File::get_file_contents($this->_logs_folder.$this->_log_file).$this->_log; |
|
169 | + EEH_File::write_to_file($this->_logs_folder.$this->_log_file, $this->_log, 'Event Espresso Log'); |
|
170 | + } catch (EE_Error $e) { |
|
171 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | } |
@@ -181,31 +181,31 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function send_log() { |
183 | 183 | |
184 | - if ( empty( $this->_remote_logging_url )) { |
|
184 | + if (empty($this->_remote_logging_url)) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | 187 | |
188 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
189 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
190 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
191 | - $data .= '&time=' . time(); |
|
192 | - $data .= '&remote_log=' . $this->_log; |
|
193 | - $data .= '&request_array=' . json_encode( $_REQUEST ); |
|
188 | + $data = 'domain='.$_SERVER['HTTP_HOST']; |
|
189 | + $data .= '&ip='.$_SERVER['SERVER_ADDR']; |
|
190 | + $data .= '&server_type='.$_SERVER['SERVER_SOFTWARE']; |
|
191 | + $data .= '&time='.time(); |
|
192 | + $data .= '&remote_log='.$this->_log; |
|
193 | + $data .= '&request_array='.json_encode($_REQUEST); |
|
194 | 194 | $data .= '&action=save'; |
195 | 195 | |
196 | - if ( defined( 'EELOGGING_PASS' )) { |
|
197 | - $data .= '&pass=' . EELOGGING_PASS; |
|
196 | + if (defined('EELOGGING_PASS')) { |
|
197 | + $data .= '&pass='.EELOGGING_PASS; |
|
198 | 198 | } |
199 | - if ( defined( 'EELOGGING_KEY' )) { |
|
200 | - $data .= '&key=' . EELOGGING_KEY; |
|
199 | + if (defined('EELOGGING_KEY')) { |
|
200 | + $data .= '&key='.EELOGGING_KEY; |
|
201 | 201 | } |
202 | 202 | |
203 | - $c = curl_init( $this->_remote_logging_url ); |
|
204 | - curl_setopt( $c, CURLOPT_POST, TRUE ); |
|
205 | - curl_setopt( $c, CURLOPT_POSTFIELDS, $data ); |
|
206 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, TRUE ); |
|
207 | - curl_exec( $c ); |
|
208 | - curl_close( $c ); |
|
203 | + $c = curl_init($this->_remote_logging_url); |
|
204 | + curl_setopt($c, CURLOPT_POST, TRUE); |
|
205 | + curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
206 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); |
|
207 | + curl_exec($c); |
|
208 | + curl_close($c); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | * previous entries are overwritten |
217 | 217 | */ |
218 | 218 | public function write_debug() { |
219 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
219 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
220 | 220 | $this->_debug_log = ''; |
221 | - foreach ( $_GET as $key => $value ) { |
|
222 | - $this->_debug_log .= '$_GET["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
221 | + foreach ($_GET as $key => $value) { |
|
222 | + $this->_debug_log .= '$_GET["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
223 | 223 | } |
224 | - foreach ( $_POST as $key => $value ) { |
|
225 | - $this->_debug_log .= '$_POST["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
224 | + foreach ($_POST as $key => $value) { |
|
225 | + $this->_debug_log .= '$_POST["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
226 | 226 | } |
227 | 227 | try { |
228 | - EEH_File::write_to_file( $this->_logs_folder . $this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log' ); |
|
229 | - } catch( EE_Error $e ){ |
|
230 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso debug log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
228 | + EEH_File::write_to_file($this->_logs_folder.$this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log'); |
|
229 | + } catch (EE_Error $e) { |
|
230 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso debug log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * __clone |
240 | 240 | */ |
241 | 241 | public function __clone() { |
242 | - trigger_error( __( 'Clone is not allowed.', 'event_espresso' ), E_USER_ERROR ); |
|
242 | + trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param boolean $IPN |
34 | 34 | */ |
35 | - public static function set_IPN( $IPN ) { |
|
36 | - self::$IPN = filter_var( $IPN, FILTER_VALIDATE_BOOLEAN ); |
|
35 | + public static function set_IPN($IPN) { |
|
36 | + self::$IPN = filter_var($IPN, FILTER_VALIDATE_BOOLEAN); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $revisit |
45 | 45 | * @return void |
46 | 46 | */ |
47 | - public function set_revisit( $revisit = false ) { |
|
48 | - $this->_revisit = filter_var( $revisit, FILTER_VALIDATE_BOOLEAN ); |
|
47 | + public function set_revisit($revisit = false) { |
|
48 | + $this->_revisit = filter_var($revisit, FILTER_VALIDATE_BOOLEAN); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param array $info |
61 | 61 | * @param bool $display_request |
62 | 62 | */ |
63 | - protected function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
64 | - if ( WP_DEBUG && false ) { |
|
65 | - if ( $transaction instanceof EE_Transaction ) { |
|
63 | + protected function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
64 | + if (WP_DEBUG && false) { |
|
65 | + if ($transaction instanceof EE_Transaction) { |
|
66 | 66 | // don't serialize objects |
67 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
68 | - if ( $transaction->ID() ) { |
|
69 | - $info[ 'TXN_status' ] = $transaction->status_ID(); |
|
70 | - $info[ 'TXN_reg_steps' ] = $transaction->reg_steps(); |
|
71 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
72 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
67 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
68 | + if ($transaction->ID()) { |
|
69 | + $info['TXN_status'] = $transaction->status_ID(); |
|
70 | + $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
71 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
72 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Registration_Processor |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function instance() { |
62 | 62 | // check if class object is instantiated |
63 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
63 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -96,37 +96,37 @@ discard block |
||
96 | 96 | * @return \EE_Registration | null |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public function generate_ONE_registration_from_line_item( EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1 ) { |
|
99 | + public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1) { |
|
100 | 100 | // grab the related ticket object for this line_item |
101 | 101 | $ticket = $line_item->ticket(); |
102 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
103 | - EE_Error::add_error( sprintf( __( "Line item %s did not contain a valid ticket", "event_espresso" ), $line_item->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
102 | + if ( ! $ticket instanceof EE_Ticket) { |
|
103 | + EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
104 | 104 | return null; |
105 | 105 | } |
106 | - $first_datetime = $ticket->get_first_related( 'Datetime' ); |
|
107 | - if ( ! $first_datetime instanceof EE_Datetime ) { |
|
108 | - EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with any valid datetimes.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
106 | + $first_datetime = $ticket->get_first_related('Datetime'); |
|
107 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
108 | + EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__); |
|
109 | 109 | return null; |
110 | 110 | } |
111 | - $event = $first_datetime->get_first_related( 'Event' ); |
|
112 | - if ( ! $event instanceof EE_Event ) { |
|
113 | - EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with a valid event.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + $event = $first_datetime->get_first_related('Event'); |
|
112 | + if ( ! $event instanceof EE_Event) { |
|
113 | + EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__); |
|
114 | 114 | return null; |
115 | 115 | } |
116 | - $reg_url_link = $this->generate_reg_url_link( $att_nmbr, $line_item ); |
|
116 | + $reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item); |
|
117 | 117 | |
118 | - if( $this->_reg_final_price_per_tkt_line_item === null ) { |
|
119 | - $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
118 | + if ($this->_reg_final_price_per_tkt_line_item === null) { |
|
119 | + $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
120 | 120 | } |
121 | 121 | //ok now find this new registration's final price |
122 | - if( isset( $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ) ) { |
|
123 | - $final_price = $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ; |
|
124 | - }else{ |
|
125 | - $message = sprintf( __( 'The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso' ), $line_item->ID() ); |
|
126 | - if( WP_DEBUG ){ |
|
127 | - throw new EE_Error( $message ); |
|
128 | - }else{ |
|
129 | - EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message ); |
|
122 | + if (isset($this->_reg_final_price_per_tkt_line_item[$line_item->ID()])) { |
|
123 | + $final_price = $this->_reg_final_price_per_tkt_line_item[$line_item->ID()]; |
|
124 | + } else { |
|
125 | + $message = sprintf(__('The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso'), $line_item->ID()); |
|
126 | + if (WP_DEBUG) { |
|
127 | + throw new EE_Error($message); |
|
128 | + } else { |
|
129 | + EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message); |
|
130 | 130 | } |
131 | 131 | $final_price = $ticket->get_ticket_total_with_taxes(); |
132 | 132 | |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | 'REG_url_link' => $reg_url_link |
147 | 147 | ) |
148 | 148 | ); |
149 | - $registration->set_reg_code( $this->generate_reg_code( $registration ) ); |
|
149 | + $registration->set_reg_code($this->generate_reg_code($registration)); |
|
150 | 150 | $registration->save(); |
151 | - $registration->_add_relation_to( $event, 'Event', array(), $event->ID() ); |
|
152 | - $registration->_add_relation_to( $line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID() ); |
|
153 | - $transaction->_add_relation_to( $registration, 'Registration' ); |
|
151 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
152 | + $registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID()); |
|
153 | + $transaction->_add_relation_to($registration, 'Registration'); |
|
154 | 154 | return $registration; |
155 | 155 | } |
156 | 156 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * @param EE_Line_Item | string $item |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function generate_reg_url_link( $att_nmbr, $item ) { |
|
166 | + public function generate_reg_url_link($att_nmbr, $item) { |
|
167 | 167 | $reg_url_link = $item instanceof EE_Line_Item ? $item->code() : $item; |
168 | - $reg_url_link = $att_nmbr . '-' . md5( $reg_url_link . microtime() ); |
|
168 | + $reg_url_link = $att_nmbr.'-'.md5($reg_url_link.microtime()); |
|
169 | 169 | return $reg_url_link; |
170 | 170 | } |
171 | 171 | |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | * @param \EE_Registration $registration |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function generate_reg_code( EE_Registration $registration ) { |
|
180 | + public function generate_reg_code(EE_Registration $registration) { |
|
181 | 181 | // figure out where to start parsing the reg code |
182 | - $chars = strpos( $registration->reg_url_link(), '-' ) + 5; |
|
182 | + $chars = strpos($registration->reg_url_link(), '-') + 5; |
|
183 | 183 | // TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link |
184 | 184 | $new_reg_code = array( |
185 | 185 | $registration->transaction_ID(), |
186 | 186 | $registration->ticket_ID(), |
187 | - substr( $registration->reg_url_link(), 0, $chars ) |
|
187 | + substr($registration->reg_url_link(), 0, $chars) |
|
188 | 188 | ); |
189 | 189 | // now put it all together |
190 | - $new_reg_code = implode( '-', $new_reg_code ); |
|
191 | - return apply_filters( 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration ); |
|
190 | + $new_reg_code = implode('-', $new_reg_code); |
|
191 | + return apply_filters('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param int $REG_ID |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function old_reg_status( $REG_ID ) { |
|
201 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
200 | + public function old_reg_status($REG_ID) { |
|
201 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | * @param int $REG_ID |
208 | 208 | * @param string $old_reg_status |
209 | 209 | */ |
210 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
210 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
211 | 211 | // only set the first time |
212 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
213 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
212 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
213 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param int $REG_ID |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function new_reg_status( $REG_ID ) { |
|
224 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
223 | + public function new_reg_status($REG_ID) { |
|
224 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param int $REG_ID |
231 | 231 | * @param string $new_reg_status |
232 | 232 | */ |
233 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
234 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
233 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
234 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @param int $REG_ID |
243 | 243 | * @return bool |
244 | 244 | */ |
245 | - public function reg_status_updated( $REG_ID ) { |
|
246 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
245 | + public function reg_status_updated($REG_ID) { |
|
246 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
258 | 258 | * @return boolean |
259 | 259 | */ |
260 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
260 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
261 | 261 | // set initial REG_Status |
262 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
262 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
263 | 263 | // set incoming REG_Status |
264 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
264 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
265 | 265 | // toggle reg status but only if it has changed and the user can do so |
266 | 266 | if ( |
267 | - $this->reg_status_updated( $registration->ID() ) && |
|
268 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
267 | + $this->reg_status_updated($registration->ID()) && |
|
268 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
269 | 269 | ) { |
270 | 270 | // change status to new value |
271 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) )) { |
|
272 | - if ( $save ) { |
|
271 | + if ($registration->set_status($this->new_reg_status($registration->ID()))) { |
|
272 | + if ($save) { |
|
273 | 273 | $registration->save(); |
274 | 274 | } |
275 | 275 | } |
@@ -290,30 +290,30 @@ discard block |
||
290 | 290 | * @return void |
291 | 291 | * @throws \EE_Error |
292 | 292 | */ |
293 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
293 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
294 | 294 | $existing_reg_status = $registration->status_ID(); |
295 | 295 | // set initial REG_Status |
296 | - $this->set_old_reg_status( $registration->ID(), $existing_reg_status ); |
|
296 | + $this->set_old_reg_status($registration->ID(), $existing_reg_status); |
|
297 | 297 | // is the registration currently incomplete ? |
298 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
298 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
299 | 299 | // grab default reg status for the event, if set |
300 | 300 | $event_default_registration_status = $registration->event()->default_registration_status(); |
301 | 301 | // if no default reg status is set for the event, then use the global value |
302 | - $STS_ID = ! empty( $event_default_registration_status ) |
|
302 | + $STS_ID = ! empty($event_default_registration_status) |
|
303 | 303 | ? $event_default_registration_status |
304 | 304 | : EE_Registry::instance()->CFG->registration->default_STS_ID; |
305 | 305 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
306 | 306 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
307 | 307 | // set incoming REG_Status |
308 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
309 | - $registration->set_status( $STS_ID ); |
|
310 | - if ( $save ) { |
|
308 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
309 | + $registration->set_status($STS_ID); |
|
310 | + if ($save) { |
|
311 | 311 | $registration->save(); |
312 | 312 | } |
313 | 313 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
314 | - if ( ! EE_Processor_Base::$IPN ) { |
|
314 | + if ( ! EE_Processor_Base::$IPN) { |
|
315 | 315 | // otherwise, send out notifications |
316 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
316 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
317 | 317 | } |
318 | 318 | // DEBUG LOG |
319 | 319 | //$this->log( |
@@ -337,25 +337,25 @@ discard block |
||
337 | 337 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
338 | 338 | * @return boolean |
339 | 339 | */ |
340 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
340 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
341 | 341 | // set initial REG_Status |
342 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
342 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
343 | 343 | // if not already, toggle reg status to approved IF the event default reg status is approved |
344 | 344 | if ( |
345 | 345 | $registration->status_ID() !== EEM_Registration::status_id_approved && |
346 | 346 | $registration->event()->default_registration_status() == EEM_Registration::status_id_approved |
347 | 347 | ) { |
348 | 348 | // set incoming REG_Status |
349 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
349 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
350 | 350 | // toggle status to approved |
351 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
352 | - if ( $save ) { |
|
351 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
352 | + if ($save) { |
|
353 | 353 | $registration->save(); |
354 | 354 | } |
355 | 355 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
356 | - if ( ! EE_Processor_Base::$IPN ) { |
|
356 | + if ( ! EE_Processor_Base::$IPN) { |
|
357 | 357 | // otherwise, send out notifications |
358 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
358 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
359 | 359 | } |
360 | 360 | // DEBUG LOG |
361 | 361 | //$this->log( |
@@ -383,19 +383,19 @@ discard block |
||
383 | 383 | * @return bool |
384 | 384 | * @throws \EE_Error |
385 | 385 | */ |
386 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
386 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
387 | 387 | // set initial REG_Status |
388 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
388 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
389 | 389 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
390 | 390 | // was a payment just made ? |
391 | 391 | if ( |
392 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
393 | - $additional_details[ 'payment_updates' ] && |
|
394 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
392 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
393 | + $additional_details['payment_updates'] && |
|
394 | + $additional_details['last_payment'] instanceof EE_Payment |
|
395 | 395 | ) { |
396 | - $payment = $additional_details[ 'last_payment' ]; |
|
396 | + $payment = $additional_details['last_payment']; |
|
397 | 397 | $total_paid = 0; |
398 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
398 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
399 | 399 | $total_paid += $amount_paid; |
400 | 400 | } |
401 | 401 | } else { |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | $registration->transaction()->is_completed() || |
420 | 420 | $registration->transaction()->is_overpaid() || |
421 | 421 | $registration->transaction()->is_free() || |
422 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
422 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
423 | 423 | ) || ( |
424 | 424 | $payment instanceof EE_Payment && |
425 | 425 | $payment->is_approved() && |
426 | 426 | // this specific registration has not yet been paid for |
427 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
427 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
428 | 428 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
429 | 429 | $payment->amount() - $total_paid >= $registration->final_price() |
430 | 430 | ) |
431 | 431 | ) |
432 | 432 | ) { |
433 | 433 | // mark as paid |
434 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
434 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
435 | 435 | // track new REG_Status |
436 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
436 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
437 | 437 | // toggle status to approved |
438 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
439 | - if ( $save ) { |
|
438 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
439 | + if ($save) { |
|
440 | 440 | $registration->save(); |
441 | 441 | } |
442 | 442 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
443 | - if ( ! EE_Processor_Base::$IPN ) { |
|
443 | + if ( ! EE_Processor_Base::$IPN) { |
|
444 | 444 | // otherwise, send out notifications |
445 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
445 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
446 | 446 | } |
447 | 447 | // DEBUG LOG |
448 | 448 | //$this->log( |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | * @param array $additional_details |
469 | 469 | * @return void |
470 | 470 | */ |
471 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
471 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
472 | 472 | try { |
473 | - if ( ! $registration instanceof EE_Registration ) { |
|
474 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
473 | + if ( ! $registration instanceof EE_Registration) { |
|
474 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
475 | 475 | } |
476 | - EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $registration->transaction(), $additional_details ), false, 'EE_Transaction: ' . $registration->transaction()->ID() ); |
|
476 | + EEH_Debug_Tools::log(__CLASS__, __FUNCTION__, __LINE__, array($registration->transaction(), $additional_details), false, 'EE_Transaction: '.$registration->transaction()->ID()); |
|
477 | 477 | do_action( |
478 | 478 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
479 | 479 | $registration, |
480 | 480 | $additional_details |
481 | 481 | ); |
482 | - } catch( Exception $e ) { |
|
483 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
482 | + } catch (Exception $e) { |
|
483 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | * @param array $additional_details |
494 | 494 | * @return bool |
495 | 495 | */ |
496 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
496 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
497 | 497 | // set initial REG_Status |
498 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
498 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
499 | 499 | |
500 | 500 | // if the registration status gets updated, then save the registration |
501 | - if ( $this->toggle_registration_status_for_default_approved_events( $registration, false ) || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )) { |
|
501 | + if ($this->toggle_registration_status_for_default_approved_events($registration, false) || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)) { |
|
502 | 502 | $registration->save(); |
503 | 503 | } |
504 | 504 | |
505 | 505 | // set new REG_Status |
506 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
507 | - return $this->reg_status_updated( $registration->ID() ) && $this->new_reg_status( $registration->ID() ) == EEM_Registration::status_id_approved ? true : false; |
|
506 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
507 | + return $this->reg_status_updated($registration->ID()) && $this->new_reg_status($registration->ID()) == EEM_Registration::status_id_approved ? true : false; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -514,19 +514,19 @@ discard block |
||
514 | 514 | * @param boolean $save_regs whether to immediately save registrations in this function or not |
515 | 515 | * @return void |
516 | 516 | */ |
517 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
518 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
519 | - foreach( $transaction->registrations() as $registration ) { |
|
520 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
521 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
522 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
523 | - if( $save_regs ) { |
|
517 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
518 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
519 | + foreach ($transaction->registrations() as $registration) { |
|
520 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
521 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
522 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
523 | + if ($save_regs) { |
|
524 | 524 | $registration->save(); |
525 | 525 | } |
526 | 526 | } |
527 | 527 | } |
528 | 528 | //and make sure there's no rounding problem |
529 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
529 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @param EE_Transaction $transaction |
543 | 543 | * @return boolean success verifying that there is NO difference after this method is done |
544 | 544 | */ |
545 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
545 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
546 | 546 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
547 | 547 | array( |
548 | 548 | array( |
@@ -551,9 +551,9 @@ discard block |
||
551 | 551 | ), |
552 | 552 | 'REG_final_price' |
553 | 553 | ); |
554 | - $diff = $transaction->total() - floatval( $reg_final_price_sum ); |
|
554 | + $diff = $transaction->total() - floatval($reg_final_price_sum); |
|
555 | 555 | //ok then, just grab one of the registrations |
556 | - if( $diff != 0 ) { |
|
556 | + if ($diff != 0) { |
|
557 | 557 | $a_reg = EEM_Registration::instance()->get_one( |
558 | 558 | array( |
559 | 559 | array( |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | )); |
563 | 563 | $success = $a_reg instanceof EE_Registration ? $a_reg->save( |
564 | 564 | array( |
565 | - 'REG_final_price' => ( $a_reg->final_price() + $diff ) |
|
565 | + 'REG_final_price' => ($a_reg->final_price() + $diff) |
|
566 | 566 | ) |
567 | 567 | ) : false; |
568 | 568 | return $success ? true : false; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | public static function load_textdomain() { |
40 | 40 | self::_maybe_get_langfile(); |
41 | 41 | //now load the textdomain |
42 | - if ( ! empty( self::$_lang ) && is_readable( EE_LANGUAGES_SAFE_DIR . 'event_espresso-' . self::$_lang . '.mo' ) ) { |
|
42 | + if ( ! empty(self::$_lang) && is_readable(EE_LANGUAGES_SAFE_DIR.'event_espresso-'.self::$_lang.'.mo')) { |
|
43 | 43 | load_plugin_textdomain('event_espresso', FALSE, EE_LANGUAGES_SAFE_LOC); |
44 | - } else if ( ! empty( self::$_lang ) && is_readable( EE_LANGUAGES_SAFE_DIR . 'event-espresso-4-' . self::$_lang . '.mo' ) ) { |
|
45 | - load_textdomain( 'event_espresso', EE_LANGUAGES_SAFE_DIR . 'event-espresso-4-' . self::$_lang . '.mo' ); |
|
44 | + } else if ( ! empty(self::$_lang) && is_readable(EE_LANGUAGES_SAFE_DIR.'event-espresso-4-'.self::$_lang.'.mo')) { |
|
45 | + load_textdomain('event_espresso', EE_LANGUAGES_SAFE_DIR.'event-espresso-4-'.self::$_lang.'.mo'); |
|
46 | 46 | } else { |
47 | - load_plugin_textdomain( 'event_espresso', FALSE, dirname( EE_PLUGIN_BASENAME ) . '/languages/'); |
|
47 | + load_plugin_textdomain('event_espresso', FALSE, dirname(EE_PLUGIN_BASENAME).'/languages/'); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | */ |
60 | 60 | private static function _maybe_get_langfile() { |
61 | 61 | self::$_lang = get_locale(); |
62 | - if ( $has_check = get_option( 'ee_lang_check_' . self::$_lang . '_' . EVENT_ESPRESSO_VERSION ) || empty( self::$_lang ) ) |
|
62 | + if ($has_check = get_option('ee_lang_check_'.self::$_lang.'_'.EVENT_ESPRESSO_VERSION) || empty(self::$_lang)) |
|
63 | 63 | return; |
64 | 64 | |
65 | 65 | //if lang is en_US or empty then lets just get out. (Event Espresso core is en_US) |
66 | - if ( empty( self::$_lang ) || self::$_lang == 'en_US' ) |
|
66 | + if (empty(self::$_lang) || self::$_lang == 'en_US') |
|
67 | 67 | return; |
68 | 68 | |
69 | 69 | //made it here so let's get the file from the github repo |
70 | 70 | $sideloader_args = array( |
71 | - '_upload_to' => EE_PLUGIN_DIR_PATH . 'languages/', |
|
72 | - '_upload_from' => 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso-' . self::$_lang . '.mo?raw=true', |
|
73 | - '_new_file_name' => 'event_espresso-' . self::$_lang . '.mo' |
|
71 | + '_upload_to' => EE_PLUGIN_DIR_PATH.'languages/', |
|
72 | + '_upload_from' => 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso-'.self::$_lang.'.mo?raw=true', |
|
73 | + '_new_file_name' => 'event_espresso-'.self::$_lang.'.mo' |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | |
77 | - $sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, FALSE ); |
|
77 | + $sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, FALSE); |
|
78 | 78 | |
79 | 79 | $sideloader->sideload(); |
80 | - update_option( 'ee_lang_check_' . self::$_lang . '_' . EVENT_ESPRESSO_VERSION, 1 ); |
|
80 | + update_option('ee_lang_check_'.self::$_lang.'_'.EVENT_ESPRESSO_VERSION, 1); |
|
81 | 81 | } |
82 | 82 | } //end EE_Load_Textdomain |