Completed
Branch BUG-7537 (42ca46)
by
unknown
88:54 queued 73:30
created
core/helpers/EEH_Export.helper.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,13 +87,13 @@
 block discarded – undo
87 87
 
88 88
 	 /**
89 89
 	  *
90
-	 *	Writes a row to the csv file
91
-	 *	@param array $row - individual row of csv data
92
-	 *	@param string $delimiter - csv delimiter
93
-	 *	@param string $enclosure - csv enclosure
94
-	 *	@param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
95
-	 *	@return string of text for teh csv file
96
-	 */
90
+	  *	Writes a row to the csv file
91
+	  *	@param array $row - individual row of csv data
92
+	  *	@param string $delimiter - csv delimiter
93
+	  *	@param string $enclosure - csv enclosure
94
+	  *	@param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
95
+	  *	@return string of text for teh csv file
96
+	  */
97 97
 	public static function get_csv_row ( array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false ) {
98 98
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
99 99
 		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param EE_Model_Field_Base $field
31 31
 	 * @return string
32 32
 	 */
33
-	public static function get_column_name_for_field(EE_Model_Field_Base $field){
33
+	public static function get_column_name_for_field(EE_Model_Field_Base $field) {
34 34
 		return $field->get_nicename()."[".$field->get_name()."]";
35 35
 	}
36 36
 
@@ -52,32 +52,32 @@  discard block
 block discarded – undo
52 52
 	 * 						we consider that a success (because we wrote everything there was...nothing)
53 53
 	 * @throws EE_Error
54 54
 	 */
55
-	public static function write_data_array_to_csv( $filepath, $data, $write_column_headers = true ){
55
+	public static function write_data_array_to_csv($filepath, $data, $write_column_headers = true) {
56 56
 		EE_Registry::instance()->load_helper('Array');
57 57
 
58 58
 		$new_file_contents = '';
59 59
 		//determine if $data is actually a 2d array
60
-		if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){
60
+		if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
61 61
 			//make sure top level is numerically indexed,
62 62
 
63
-			if( EEH_Array::is_associative_array($data)){
64
-				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))));
63
+			if (EEH_Array::is_associative_array($data)) {
64
+				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))));
65 65
 			}
66 66
 			$item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
67 67
 			//now, is the last item in the top-level array of $data an associative or numeric array?
68
-			if( $write_column_headers &&
69
-					EEH_Array::is_associative_array($item_in_top_level_array)){
68
+			if ($write_column_headers &&
69
+					EEH_Array::is_associative_array($item_in_top_level_array)) {
70 70
 				//its associative, so we want to output its keys as column headers
71 71
 				$keys = array_keys($item_in_top_level_array);
72
-				$new_file_contents .=  EEH_Export::get_csv_row( $keys );
72
+				$new_file_contents .= EEH_Export::get_csv_row($keys);
73 73
 
74 74
 			}
75 75
 			//start writing data
76
-			foreach($data as $data_row){
77
-				$new_file_contents .= EEH_Export::get_csv_row( $data_row);
76
+			foreach ($data as $data_row) {
77
+				$new_file_contents .= EEH_Export::get_csv_row($data_row);
78 78
 			}
79
-			return EEH_File::write_to_file( $filepath, EEH_File::get_file_contents( $filepath ) . $new_file_contents );
80
-		}else{
79
+			return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath).$new_file_contents);
80
+		} else {
81 81
 			//no data TO write... so we can assume that's a success
82 82
 			return true;
83 83
 		}
@@ -94,29 +94,29 @@  discard block
 block discarded – undo
94 94
 	 *	@param bool $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
95 95
 	 *	@return string of text for teh csv file
96 96
 	 */
97
-	public static function get_csv_row ( array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false ) {
97
+	public static function get_csv_row(array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false) {
98 98
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
99
-		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
100
-		$enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure );
99
+		$delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
100
+		$enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
101 101
 
102 102
 		$delimiter_esc = preg_quote($delimiter, '/');
103 103
 		$enclosure_esc = preg_quote($enclosure, '/');
104 104
 
105 105
 		$output = array();
106 106
 		foreach ($row as $field_value) {
107
-			if(is_object($field_value) || is_array($field_value)){
107
+			if (is_object($field_value) || is_array($field_value)) {
108 108
 				$field_value = serialize($field_value);
109 109
 			}
110
-			if ($field_value === null && $mysql_null ) {
110
+			if ($field_value === null && $mysql_null) {
111 111
 				$output[] = 'NULL';
112 112
 				continue;
113 113
 			}
114 114
 
115 115
 			$output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
116
-				( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
116
+				($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value;
117 117
 		}
118 118
 
119
-		return  implode($delimiter, $output) . PHP_EOL;
119
+		return  implode($delimiter, $output).PHP_EOL;
120 120
 	}
121 121
 
122 122
 
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
 	 * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
130 130
 	 * @return string
131 131
 	 */
132
-	public static function prepare_value_from_db_for_display( $model, $field_name,  $raw_db_value, $pretty_schema = true ) {
133
-		$field_obj = $model->field_settings_for( $field_name );
134
-		$value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value );
135
-		if( $field_obj instanceof EE_Datetime_Field ) {
136
-			$field_obj->set_date_format( EEH_Export::get_date_format_for_export( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema );
137
-			$field_obj->set_time_format( EEH_Export::get_time_format_for_export( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema );
132
+	public static function prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) {
133
+		$field_obj = $model->field_settings_for($field_name);
134
+		$value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
135
+		if ($field_obj instanceof EE_Datetime_Field) {
136
+			$field_obj->set_date_format(EEH_Export::get_date_format_for_export($field_obj->get_date_format($pretty_schema)), $pretty_schema);
137
+			$field_obj->set_time_format(EEH_Export::get_time_format_for_export($field_obj->get_time_format($pretty_schema)), $pretty_schema);
138 138
 		}
139
-		if( $pretty_schema === true){
140
-			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
141
-		}elseif( is_string( $pretty_schema ) ) {
142
-			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
143
-		}else{
144
-			return $field_obj->prepare_for_get( $value_on_model_obj );
139
+		if ($pretty_schema === true) {
140
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
141
+		}elseif (is_string($pretty_schema)) {
142
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
143
+		} else {
144
+			return $field_obj->prepare_for_get($value_on_model_obj);
145 145
 		}
146 146
 	}
147 147
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @param string $current_format
153 153
 	 * @return string
154 154
 	 */
155
-	public static function get_date_format_for_export( $current_format = null ) {
156
-		return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format );
155
+	public static function get_date_format_for_export($current_format = null) {
156
+		return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
157 157
 	}
158 158
 
159 159
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 	 * @param string $current_format
164 164
 	 * @return string
165 165
 	 */
166
-	public static function get_time_format_for_export( $current_format = null ) {
167
-		return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format );
166
+	public static function get_time_format_for_export($current_format = null) {
167
+		return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
168 168
 	}
169 169
 
170 170
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
@@ -77,7 +79,7 @@  discard block
 block discarded – undo
77 79
 				$new_file_contents .= EEH_Export::get_csv_row( $data_row);
78 80
 			}
79 81
 			return EEH_File::write_to_file( $filepath, EEH_File::get_file_contents( $filepath ) . $new_file_contents );
80
-		}else{
82
+		} else{
81 83
 			//no data TO write... so we can assume that's a success
82 84
 			return true;
83 85
 		}
@@ -138,9 +140,9 @@  discard block
 block discarded – undo
138 140
 		}
139 141
 		if( $pretty_schema === true){
140 142
 			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
141
-		}elseif( is_string( $pretty_schema ) ) {
143
+		} elseif( is_string( $pretty_schema ) ) {
142 144
 			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
143
-		}else{
145
+		} else{
144 146
 			return $field_obj->prepare_for_get( $value_on_model_obj );
145 147
 		}
146 148
 	}
Please login to merge, or discard this patch.
core/libraries/batch/BatchRequestProcessor.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 use EventEspressoBatchRequest\Helpers\JobParameters;
24 24
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
25 25
 
26
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
27
-	exit( 'No direct script access allowed' );
26
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
27
+	exit('No direct script access allowed');
28 28
 }
29 29
 
30 30
 
@@ -50,32 +50,32 @@  discard block
 block discarded – undo
50 50
 	 * @param array $request_data to be used by the batch job handler
51 51
 	 * @return JobStepResponse
52 52
 	 */
53
-	public function create_job( $batch_job_handler_class, $request_data ) {
53
+	public function create_job($batch_job_handler_class, $request_data) {
54 54
 		try {
55
-			$this->_job_id = wp_generate_password( 15, false );
56
-			$obj = $this->instantiate_batch_job_handler_from_classname( $batch_job_handler_class );
57
-			$this->_job_parameters = new JobParameters( $this->_job_id, $batch_job_handler_class, $request_data );
58
-			$response = $obj->create_job( $this->_job_parameters );
59
-			if( ! $response instanceof JobStepResponse ) {
55
+			$this->_job_id = wp_generate_password(15, false);
56
+			$obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class);
57
+			$this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data);
58
+			$response = $obj->create_job($this->_job_parameters);
59
+			if ( ! $response instanceof JobStepResponse) {
60 60
 				throw new BatchRequestException(
61 61
 					sprintf(
62
-						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
63
-						wp_json_encode( $request_data )
62
+						__('The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso'),
63
+						wp_json_encode($request_data)
64 64
 					)
65 65
 				);
66 66
 			}
67
-			$success = $this->_job_parameters->save( true );
68
-			if( ! $success ) {
67
+			$success = $this->_job_parameters->save(true);
68
+			if ( ! $success) {
69 69
 				throw new BatchRequestException(
70 70
 					sprintf(
71 71
 						__('Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', 'event_espresso'),
72 72
 						$this->_job_id,
73
-						wp_json_encode( $request_data )
73
+						wp_json_encode($request_data)
74 74
 					)
75 75
 				);
76 76
 			}
77
-		} catch( \Exception $e ) {
78
-			$response = $this->_get_error_response( $e, 'create_job' );
77
+		} catch (\Exception $e) {
78
+			$response = $this->_get_error_response($e, 'create_job');
79 79
 		}
80 80
 		return $response;
81 81
 	}
@@ -88,26 +88,26 @@  discard block
 block discarded – undo
88 88
 	 * @param int $batch_size
89 89
 	 * @return JobStepResponse
90 90
 	 */
91
-	public function continue_job( $job_id, $batch_size = 50 ) {
91
+	public function continue_job($job_id, $batch_size = 50) {
92 92
 		try {
93 93
 			$this->_job_id = $job_id;
94
-			$batch_size = defined( 'EE_BATCHRUNNER_BATCH_SIZE' ) ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size;
94
+			$batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size;
95 95
 			//get the corresponding WordPress option for the job
96
-			$this->_job_parameters = JobParameters::load( $this->_job_id );
97
-			$handler_obj = $this->instantiate_batch_job_handler_from_classname( $this->_job_parameters->classname() );
96
+			$this->_job_parameters = JobParameters::load($this->_job_id);
97
+			$handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname());
98 98
 			//continue it
99
-			$response = $handler_obj->continue_job( $this->_job_parameters, $batch_size );
100
-			if( ! $response instanceof JobStepResponse ) {
99
+			$response = $handler_obj->continue_job($this->_job_parameters, $batch_size);
100
+			if ( ! $response instanceof JobStepResponse) {
101 101
 				throw new BatchRequestException(
102 102
 					sprintf(
103
-						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
103
+						__('The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'),
104 104
 						$this->_job_id
105 105
 					)
106 106
 				);
107 107
 			}
108 108
 			$this->_job_parameters->save();
109
-		} catch( \Exception $e ) {
110
-			$response = $this->_get_error_response( $e, 'continue_job' );
109
+		} catch (\Exception $e) {
110
+			$response = $this->_get_error_response($e, 'continue_job');
111 111
 		}
112 112
 		return $response;
113 113
 	}
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @return JobHandlerInterface
123 123
 	 * @throws BatchRequestException
124 124
 	 */
125
-	public function instantiate_batch_job_handler_from_classname( $classname ) {
126
-		if( ! class_exists( $classname ) ) {
125
+	public function instantiate_batch_job_handler_from_classname($classname) {
126
+		if ( ! class_exists($classname)) {
127 127
 			throw new BatchRequestException(
128 128
 				sprintf(
129 129
 					__('The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', 'event_espresso'),
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			);
133 133
 		}
134 134
 		$obj = new $classname;
135
-		if( ! $obj instanceof JobHandlerInterface ) {
135
+		if ( ! $obj instanceof JobHandlerInterface) {
136 136
 			throw new BatchRequestException(
137 137
 				sprintf(
138 138
 					__('The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', 'event_espresso'),
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
 	 * @return JobStepResponse
153 153
 	 * @throws BatchRequestException
154 154
 	 */
155
-	public function cleanup_job( $job_id ) {
156
-		try{
155
+	public function cleanup_job($job_id) {
156
+		try {
157 157
 			$this->_job_id = $job_id;
158
-			$job_parameters = JobParameters::load( $this->_job_id );
159
-			$handler_obj = $this->instantiate_batch_job_handler_from_classname( $job_parameters->classname() );
158
+			$job_parameters = JobParameters::load($this->_job_id);
159
+			$handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname());
160 160
 			//continue it
161
-			$response = $handler_obj->cleanup_job( $job_parameters );
162
-			if( ! $response instanceof JobStepResponse ) {
161
+			$response = $handler_obj->cleanup_job($job_parameters);
162
+			if ( ! $response instanceof JobStepResponse) {
163 163
 				throw new BatchRequestException(
164 164
 					sprintf(
165
-						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
165
+						__('The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso'),
166 166
 						$this->_job_id
167 167
 					)
168 168
 				);
169 169
 			}
170
-			$job_parameters->set_status( JobParameters::status_cleaned_up );
170
+			$job_parameters->set_status(JobParameters::status_cleaned_up);
171 171
 			$job_parameters->delete();
172 172
 			return $response;
173
-		} catch( \Exception $e ) {
174
-			$response = $this->_get_error_response( $e, 'cleanup_job' );
173
+		} catch (\Exception $e) {
174
+			$response = $this->_get_error_response($e, 'cleanup_job');
175 175
 		}
176 176
 		return $response;
177 177
 	}
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 	 * @param string $method_name
185 185
 	 * @return JobStepResponse
186 186
 	 */
187
-	protected function _get_error_response( \Exception $exception, $method_name ) {
188
-		if( ! $this->_job_parameters instanceof JobParameters ) {
189
-			$this->_job_parameters = new JobParameters( $this->_job_id, __( '__Unknown__', 'event_espresso' ), array() );
187
+	protected function _get_error_response(\Exception $exception, $method_name) {
188
+		if ( ! $this->_job_parameters instanceof JobParameters) {
189
+			$this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array());
190 190
 		}
191
-		$this->_job_parameters->set_status( JobParameters::status_error );
191
+		$this->_job_parameters->set_status(JobParameters::status_error);
192 192
 		return new JobStepResponse(
193 193
 			$this->_job_parameters,
194 194
 			sprintf(
195 195
 				__('An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', 'event_espresso'),
196
-				get_class( $exception ),
197
-				'BatchRunner::' . $method_name . '()',
196
+				get_class($exception),
197
+				'BatchRunner::'.$method_name.'()',
198 198
 				$exception->getMessage(),
199 199
 				$exception->getTraceAsString()
200 200
 			)
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
  /**
3
- *
4
- * Class BatchRequetProcessor
3
+  *
4
+  * Class BatchRequetProcessor
5 5
   * 
6
- * Responsible for receiving a request to start a job and assign it a job Id.
7
- * Then when subsequent requests come in to continue that job, dispatches
8
- * the request to the appropriate JobHandler, which processes a step of the batch,
9
- * and then returns the job's new status.
10
- * This class is used by controller code, and the controller code is sent HTTP
11
- * requests from the batch_runner.js library
12
- *
13
- * @package         Event Espresso
14
- * @subpackage    batch
15
- * @author				Mike Nelson
16
- * @since		 	   4.8.26
17
- *
18
- */
6
+  * Responsible for receiving a request to start a job and assign it a job Id.
7
+  * Then when subsequent requests come in to continue that job, dispatches
8
+  * the request to the appropriate JobHandler, which processes a step of the batch,
9
+  * and then returns the job's new status.
10
+  * This class is used by controller code, and the controller code is sent HTTP
11
+  * requests from the batch_runner.js library
12
+  *
13
+  * @package         Event Espresso
14
+  * @subpackage    batch
15
+  * @author				Mike Nelson
16
+  * @since		 	   4.8.26
17
+  *
18
+  */
19 19
 namespace EventEspressoBatchRequest;
20 20
 
21 21
 use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerInterface;
Please login to merge, or discard this patch.
core/libraries/batch/Helpers/BatchRequestException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 namespace EventEspressoBatchRequest\Helpers;
16 16
 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
17 17
 
18
-class BatchRequestException extends \Exception{
18
+class BatchRequestException extends \Exception {
19 19
 	//so far the same as exception
20 20
 }
21 21
 
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php 
2 2
  /**
3
- *
4
- * Class BatchRequestException
5
- *
6
- * Exception class for whenever we have trouble running start, continuing, or finishing
7
- * a batch job.
8
- *
9
- * @package         Event Espresso
10
- * @subpackage    batch
11
- * @author				Mike Nelson
12
- * @since		 	   4.8.26
13
- *
14
- */
3
+  *
4
+  * Class BatchRequestException
5
+  *
6
+  * Exception class for whenever we have trouble running start, continuing, or finishing
7
+  * a batch job.
8
+  *
9
+  * @package         Event Espresso
10
+  * @subpackage    batch
11
+  * @author				Mike Nelson
12
+  * @since		 	   4.8.26
13
+  *
14
+  */
15 15
 namespace EventEspressoBatchRequest\Helpers;
16 16
 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
17 17
 
Please login to merge, or discard this patch.
core/libraries/batch/Helpers/JobParameters.php 3 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 * @param array $request_data
97 97
 	 * @param array $extra_data
98 98
 	 */
99
-	function __construct( $job_id, $classname, $request_data, $extra_data = array() ) {
100
-		$this->set_job_id( $job_id );
101
-		$this->set_classname( $classname );
102
-		$this->set_request_data( $request_data );
103
-		$this->set_extra_data( $extra_data );
104
-		$this->set_status( JobParameters::status_continue );
99
+	function __construct($job_id, $classname, $request_data, $extra_data = array()) {
100
+		$this->set_job_id($job_id);
101
+		$this->set_classname($classname);
102
+		$this->set_request_data($request_data);
103
+		$this->set_extra_data($extra_data);
104
+		$this->set_status(JobParameters::status_continue);
105 105
 	}
106 106
 
107 107
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 * @param boolean $first
127 127
 	 * @return boolean success
128 128
 	 */
129
-	function save( $first = false ) {
130
-		$object_vars = wp_json_encode( get_object_vars( $this ) );
131
-		if( $first ) {
132
-			return add_option( $this->option_name(), $object_vars, null, 'no' );
133
-		} else{
134
-			return update_option( $this->option_name(), $object_vars );
129
+	function save($first = false) {
130
+		$object_vars = wp_json_encode(get_object_vars($this));
131
+		if ($first) {
132
+			return add_option($this->option_name(), $object_vars, null, 'no');
133
+		} else {
134
+			return update_option($this->option_name(), $object_vars);
135 135
 		}
136 136
 	}
137 137
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @return boolean
144 144
 	 */
145 145
 	function delete() {
146
-		return delete_option( $this->option_name() );
146
+		return delete_option($this->option_name());
147 147
 	}
148 148
 
149 149
 
@@ -154,26 +154,26 @@  discard block
 block discarded – undo
154 154
 	 * @return JobParameters
155 155
 	 * @throws BatchRequestException
156 156
 	 */
157
-	static function load( $job_id ) {
158
-		$job_parameter_vars = json_decode( get_option( JobParameters::wp_option_prefix . $job_id ), true );
159
-		if(
160
-			! is_array( $job_parameter_vars ) ||
161
-			! isset( $job_parameter_vars[ '_classname' ] ) ||
162
-			! isset( $job_parameter_vars[ '_request_data' ] )
157
+	static function load($job_id) {
158
+		$job_parameter_vars = json_decode(get_option(JobParameters::wp_option_prefix.$job_id), true);
159
+		if (
160
+			! is_array($job_parameter_vars) ||
161
+			! isset($job_parameter_vars['_classname']) ||
162
+			! isset($job_parameter_vars['_request_data'])
163 163
 		) {
164 164
 			throw new BatchRequestException(
165 165
 				sprintf( 
166 166
 					__('Could not retrieve job %1$s from the Wordpress options table, and so the job could not continue. The wordpress option was %2$s', 'event_espresso'),
167 167
 					$job_id,
168
-					get_option( JobParameters::wp_option_prefix . $job_id )
168
+					get_option(JobParameters::wp_option_prefix.$job_id)
169 169
 				)
170 170
 			);
171 171
 		}
172 172
 		$job_parameters = new JobParameters( 
173 173
 				$job_id, 
174
-				$job_parameter_vars[ '_classname' ], 
175
-				$job_parameter_vars[ '_request_data'] );
176
-		foreach( $job_parameter_vars as $key => $value ) {
174
+				$job_parameter_vars['_classname'], 
175
+				$job_parameter_vars['_request_data'] );
176
+		foreach ($job_parameter_vars as $key => $value) {
177 177
 			$job_parameters->$key = $value;
178 178
 		}
179 179
 		return $job_parameters;
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	 * @param string|array $default
218 218
 	 * @return string|array
219 219
 	 */
220
-	function request_datum( $key, $default = '' ) {
221
-		if( isset( $this->_request_data[ $key ] ) ) {
222
-			return $this->_request_data[ $key ];
220
+	function request_datum($key, $default = '') {
221
+		if (isset($this->_request_data[$key])) {
222
+			return $this->_request_data[$key];
223 223
 		} else {
224 224
 			return $default;
225 225
 		}
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	 * @param string|array $default
234 234
 	 * @return string|array
235 235
 	 */
236
-	function extra_datum( $key, $default = '' ) {
237
-		if( isset( $this->_extra_data[ $key ] ) ) {
238
-			return $this->_extra_data[ $key ];
236
+	function extra_datum($key, $default = '') {
237
+		if (isset($this->_extra_data[$key])) {
238
+			return $this->_extra_data[$key];
239 239
 		} else {
240 240
 			return $default;
241 241
 		}
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param string $key
249 249
 	 * @param string|int|array|null $value almost any extra data you want to store
250 250
 	 */
251
-	function add_extra_data( $key, $value ) {
252
-		$this->_extra_data[ $key ] = $value;
251
+	function add_extra_data($key, $value) {
252
+		$this->_extra_data[$key] = $value;
253 253
 	}
254 254
 
255 255
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * Sets the job size. You decide what units to use
279 279
 	 * @param int $size
280 280
 	 */
281
-	function set_job_size( $size ) {
281
+	function set_job_size($size) {
282 282
 		$this->_job_size = $size;
283 283
 	}
284 284
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param int $newly_processed
300 300
 	 * @return int updated units processed
301 301
 	 */
302
-	function mark_processed( $newly_processed ) {
302
+	function mark_processed($newly_processed) {
303 303
 		$this->_units_processed += $newly_processed;
304 304
 		return $this->_units_processed;
305 305
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * Sets the total count of units processed. You might prefer to use mark_processed
311 311
 	 * @param int $total_units_processed
312 312
 	 */
313
-	function set_units_processed( $total_units_processed ) {
313
+	function set_units_processed($total_units_processed) {
314 314
 		$this->_units_processed = $total_units_processed;
315 315
 	}
316 316
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * Sets the job's ID
321 321
 	 * @param string $job_id
322 322
 	 */
323
-	function set_job_id( $job_id ) {
323
+	function set_job_id($job_id) {
324 324
 		$this->_job_id = $job_id;
325 325
 	}
326 326
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * sets the classname
331 331
 	 * @param string $classname
332 332
 	 */
333
-	function set_classname( $classname ) {
333
+	function set_classname($classname) {
334 334
 		$this->_classname = $classname;
335 335
 	}
336 336
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * Sets the request data
341 341
 	 * @param array $request_data
342 342
 	 */
343
-	function set_request_data( $request_data ) {
343
+	function set_request_data($request_data) {
344 344
 		$this->_request_data = $request_data;
345 345
 	}
346 346
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * Sets the array of extra data we want to store on this request
351 351
 	 * @param array $extra_data
352 352
 	 */
353
-	function set_extra_data( $extra_data ) {
353
+	function set_extra_data($extra_data) {
354 354
 		$this->_extra_data = $extra_data;
355 355
 	}
356 356
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @return string
362 362
 	 */
363 363
 	function option_name() {
364
-		return JobParameters::wp_option_prefix . $this->job_id();
364
+		return JobParameters::wp_option_prefix.$this->job_id();
365 365
 	}
366 366
 
367 367
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @param string $status on eof JobParameters::valid_stati()
382 382
 	 */
383
-	public function set_status( $status ) {
383
+	public function set_status($status) {
384 384
 		$this->_status = $status;
385 385
 	}
386 386
 
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- *
4
- * Class JobParameters
5
- *
6
- * Class for storing information about a job. Takes care of serializing the
7
- * data for storing in a wordpress option
8
- *
9
- * @package         Event Espresso
10
- * @subpackage    batch
11
- * @author				Mike Nelson
12
- * @since		 	   4.8.26
13
- *
14
- */
3
+	 *
4
+	 * Class JobParameters
5
+	 *
6
+	 * Class for storing information about a job. Takes care of serializing the
7
+	 * data for storing in a wordpress option
8
+	 *
9
+	 * @package         Event Espresso
10
+	 * @subpackage    batch
11
+	 * @author				Mike Nelson
12
+	 * @since		 	   4.8.26
13
+	 *
14
+	 */
15 15
 namespace EventEspressoBatchRequest\Helpers;
16 16
 
17 17
 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@
 block discarded – undo
214 214
 	/**
215 215
 	 * Gets a single item from the request data
216 216
 	 * @param string $key
217
-	 * @param string|array $default
217
+	 * @param string $default
218 218
 	 * @return string|array
219 219
 	 */
220 220
 	function request_datum( $key, $default = '' ) {
Please login to merge, or discard this patch.
core/libraries/batch/Helpers/JobStepResponse.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@
 block discarded – undo
43 43
 	 * @param string $update_text
44 44
 	 * @param array $extra_data
45 45
 	 */
46
-	public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array() ) {
47
-		$this->_job_parameters 	= $job_parameters;
46
+	public function __construct(JobParameters $job_parameters, $update_text, $extra_data = array()) {
47
+		$this->_job_parameters = $job_parameters;
48 48
 		$this->_update_text 	= $update_text;
49
-		$this->_extra_data 		= (array)$extra_data;
49
+		$this->_extra_data 		= (array) $extra_data;
50 50
 	}
51 51
 
52 52
 
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- *
4
- * Class JobStepResponse
5
- *
6
- * Response object describing the current state of a job
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    batch
10
- * @author				Mike Nelson
11
- * @since		 	   4.8.26
12
- *
13
- */
3
+	 *
4
+	 * Class JobStepResponse
5
+	 *
6
+	 * Response object describing the current state of a job
7
+	 *
8
+	 * @package         Event Espresso
9
+	 * @subpackage    batch
10
+	 * @author				Mike Nelson
11
+	 * @since		 	   4.8.26
12
+	 *
13
+	 */
14 14
 namespace EventEspressoBatchRequest\Helpers;
15 15
 
16 16
 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandlerFile.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 
17 17
 use EventEspressoBatchRequest\Helpers\BatchRequestException;
18 18
 
19
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
-	exit( 'No direct script access allowed' );
19
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	protected $_file_helper = null;
31 31
 	const temp_folder_name = 'batch_temp_folder';
32
-	public function __construct( EEHI_File $file_helper = null ) {
33
-		if( ! $file_helper ) {
32
+	public function __construct(EEHI_File $file_helper = null) {
33
+		if ( ! $file_helper) {
34 34
 			$this->_file_helper = new \EEH_File();
35 35
 		}
36 36
 	}
@@ -45,30 +45,30 @@  discard block
 block discarded – undo
45 45
 	 * @return string
46 46
 	 * @throws BatchRequestException
47 47
 	 */
48
-	public function create_file_from_job_with_name( $job_id, $filename ) {
48
+	public function create_file_from_job_with_name($job_id, $filename) {
49 49
 		$filepath = '';
50
-		try{
50
+		try {
51 51
 			$success = $this->_file_helper->ensure_folder_exists_and_is_writable(
52
-				EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name
52
+				EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name
53 53
 			);
54
-			if ( $success ) {
54
+			if ($success) {
55 55
 				$success = $this->_file_helper->ensure_folder_exists_and_is_writable(
56
-					EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id
56
+					EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id
57 57
 				);
58 58
 			}
59
-			if( $success ) {
60
-				$filepath = EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id . DS. $filename;
61
-				$success = $this->_file_helper->ensure_file_exists_and_is_writable( $filepath );
59
+			if ($success) {
60
+				$filepath = EVENT_ESPRESSO_UPLOAD_DIR.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename;
61
+				$success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
62 62
 			}
63 63
 			//those methods normally fail with an exception, but if not, let's do it
64
-			if( ! $success ) {
65
-				throw new \EE_Error( 'could_not_create_temp_file',
66
-				__( 'An unknown error occurred', 'event_espresso' ));
64
+			if ( ! $success) {
65
+				throw new \EE_Error('could_not_create_temp_file',
66
+				__('An unknown error occurred', 'event_espresso'));
67 67
 			}
68
-		} catch( \EE_Error $e ) {
68
+		} catch (\EE_Error $e) {
69 69
 			throw new BatchRequestException(
70 70
 				sprintf(
71
-					__( 'Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso' ),
71
+					__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'),
72 72
 					$job_id,
73 73
 					$e->getMessage()
74 74
 				),
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @param string $filepath
85 85
 	 * @return string url to file
86 86
 	 */
87
-	public function get_url_to_file( $filepath ) {
88
-		return str_replace( EVENT_ESPRESSO_UPLOAD_DIR, EVENT_ESPRESSO_UPLOAD_URL, $filepath );
87
+	public function get_url_to_file($filepath) {
88
+		return str_replace(EVENT_ESPRESSO_UPLOAD_DIR, EVENT_ESPRESSO_UPLOAD_URL, $filepath);
89 89
 	}
90 90
 }
91 91
 
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandlerInterface.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 use EventEspressoBatchRequest\Helpers\JobParameters;
21 21
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
22 22
 
23
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
24
-	exit( 'No direct script access allowed' );
23
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
24
+	exit('No direct script access allowed');
25 25
 }
26 26
 
27 27
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @throws BatchRequestException
36 36
 	 * @return JobStepResponse
37 37
 	 */
38
-	public function create_job( JobParameters $job_parameters );
38
+	public function create_job(JobParameters $job_parameters);
39 39
 
40 40
 	/**
41 41
 	 * Performs another step of the job
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @return JobStepResponse
45 45
 	 * @throws BatchRequestException
46 46
 	 */
47
-	public function continue_job( JobParameters $job_parameters, $batch_size = 50 );
47
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50);
48 48
 
49 49
 	/**
50 50
 	 * Performs any clean-up logic when we know the job is completed
@@ -52,5 +52,5 @@  discard block
 block discarded – undo
52 52
 	 * @return JobStepResponse
53 53
 	 * @throws BatchRequestException
54 54
 	 */
55
-	public function cleanup_job( JobParameters $job_parameters );
55
+	public function cleanup_job(JobParameters $job_parameters);
56 56
 }
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 3 patches
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			if( ! $event_slug ) {
76 76
 				$event_slug = __( 'unknown', 'event_espresso' );
77 77
 			}
78
-		}else{
78
+		} else{
79 79
 			$event_slug = __( 'all', 'event_espresso' );
80 80
 		}
81 81
 		return sprintf( "registrations-for-%s.csv", $event_slug );
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		);
163 163
 		if( $event_id ){
164 164
 			$query_params[0]['EVT_ID'] =  $event_id;
165
-		}else{
165
+		} else{
166 166
 			$query_params[ 'force_join' ][] = 'Event';
167 167
 		}
168 168
 		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 					$field = $reg_model->field_settings_for($field_name);
192 192
 					if($field_name == 'REG_final_price'){
193 193
 						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
194
-					}elseif( $field_name == 'REG_count' ){
194
+					} elseif( $field_name == 'REG_count' ){
195 195
 						$value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
196
-					}elseif( $field_name == 'REG_date' ) {
196
+					} elseif( $field_name == 'REG_date' ) {
197 197
 						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
198
-					}else{
198
+					} else{
199 199
 						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
200 200
 					}
201 201
 					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 					if( $reg_row[ 'Attendee_CPT.ID' ]){
268 268
 						if($att_field_name == 'STA_ID'){
269 269
 							$value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
270
-						}elseif($att_field_name == 'CNT_ISO'){
270
+						} elseif($att_field_name == 'CNT_ISO'){
271 271
 							$value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
272
-						}else{
272
+						} else{
273 273
 							$value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
274 274
 						}
275
-					}else{
275
+					} else{
276 276
 						$value = '';
277 277
 					}
278 278
 
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 use EventEspressoBatchRequest\Helpers\JobParameters;
20 20
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
21 21
 
22
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
23
-	exit( 'No direct script access allowed' );
22
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
23
+	exit('No direct script access allowed');
24 24
 }
25 25
 
26 26
 
@@ -35,36 +35,36 @@  discard block
 block discarded – undo
35 35
 	 * @throws BatchRequestException
36 36
 	 * @return JobStepResponse
37 37
 	 */
38
-	public function create_job( JobParameters $job_parameters ) {
39
-		$event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) );
40
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) {
38
+	public function create_job(JobParameters $job_parameters) {
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41 41
 			throw new BatchRequestException(
42
-				__( 'You do not have permission to view registrations', 'event_espresso')
42
+				__('You do not have permission to view registrations', 'event_espresso')
43 43
 			);
44 44
 		}
45 45
 		$filepath = $this->create_file_from_job_with_name(
46 46
 			$job_parameters->job_id(),
47
-			$this->get_filename_from_event( $event_id )
47
+			$this->get_filename_from_event($event_id)
48 48
 		);
49
-		$job_parameters->add_extra_data( 'filepath', $filepath );
50
-		$question_data_for_columns = $this->_get_questions_for_report( $event_id );
51
-		$job_parameters->add_extra_data( 'questions_data', $question_data_for_columns );
52
-		$job_parameters->set_job_size( $this->count_units_to_process( $event_id ) );
49
+		$job_parameters->add_extra_data('filepath', $filepath);
50
+		$question_data_for_columns = $this->_get_questions_for_report($event_id);
51
+		$job_parameters->add_extra_data('questions_data', $question_data_for_columns);
52
+		$job_parameters->set_job_size($this->count_units_to_process($event_id));
53 53
 		//we should also set the header columns
54 54
 		$csv_data_for_row = $this->get_csv_data_for(
55 55
 			$event_id,
56 56
 			0,
57 57
 			1,
58
-			$job_parameters->extra_datum( 'questions_data' ) );
59
-		\EE_Registry::instance()->load_helper( 'Export' );
60
-		\EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true );
58
+			$job_parameters->extra_datum('questions_data') );
59
+		\EE_Registry::instance()->load_helper('Export');
60
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
61 61
 		//if we actually processed a row there, record it
62
-		if( $job_parameters->job_size() ) {
63
-			$job_parameters->mark_processed( 1 );
62
+		if ($job_parameters->job_size()) {
63
+			$job_parameters->mark_processed(1);
64 64
 		}
65 65
 		return new JobStepResponse(
66 66
 			$job_parameters,
67
-			__( 'Registrations report started successfully...', 'event_espresso' )
67
+			__('Registrations report started successfully...', 'event_espresso')
68 68
 		);
69 69
 	}
70 70
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 	 * @param int $event_id
76 76
 	 * @return string
77 77
 	 */
78
-	protected function get_filename_from_event( $event_id ) {
79
-		if( $event_id ){
80
-			$event_slug =  \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
81
-			if( ! $event_slug ) {
82
-				$event_slug = __( 'unknown', 'event_espresso' );
78
+	protected function get_filename_from_event($event_id) {
79
+		if ($event_id) {
80
+			$event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
81
+			if ( ! $event_slug) {
82
+				$event_slug = __('unknown', 'event_espresso');
83 83
 			}
84
-		}else{
85
-			$event_slug = __( 'all', 'event_espresso' );
84
+		} else {
85
+			$event_slug = __('all', 'event_espresso');
86 86
 		}
87
-		return sprintf( "registrations-for-%s.csv", $event_slug );
87
+		return sprintf("registrations-for-%s.csv", $event_slug);
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * @param int|null $event_id
94 94
 	 * @return array of wpdb results for questions which are to be used for this report
95 95
 	 */
96
-	protected function _get_questions_for_report( $event_id ) {
96
+	protected function _get_questions_for_report($event_id) {
97 97
 		$question_query_params = array(
98 98
 			array(
99
-				'Answer.ANS_ID' => array( 'IS_NOT_NULL' ),
99
+				'Answer.ANS_ID' => array('IS_NOT_NULL'),
100 100
 			),
101
-			'group_by' => array( 'QST_ID' )
101
+			'group_by' => array('QST_ID')
102 102
 		);
103
-		if( $event_id ) {
103
+		if ($event_id) {
104 104
 			$question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id;
105 105
 		}
106
-		return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params );
106
+		return \EEM_Question::instance()->get_all_wpdb_results($question_query_params);
107 107
 	}
108 108
 
109 109
 
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
 	 * @return JobStepResponse
117 117
 	 * @throws \EE_Error
118 118
 	 */
119
-	public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) {
119
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50) {
120 120
 		$csv_data = $this->get_csv_data_for(
121
-			$job_parameters->request_datum( 'EVT_ID', '0'),
121
+			$job_parameters->request_datum('EVT_ID', '0'),
122 122
 			$job_parameters->units_processed(),
123 123
 			$batch_size,
124
-			$job_parameters->extra_datum( 'questions_data' ) );
125
-		\EE_Registry::instance()->load_helper( 'Export' );
126
-		\EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false );
127
-		$units_processed = count( $csv_data );
128
-		$job_parameters->mark_processed( $units_processed );
124
+			$job_parameters->extra_datum('questions_data') );
125
+		\EE_Registry::instance()->load_helper('Export');
126
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
127
+		$units_processed = count($csv_data);
128
+		$job_parameters->mark_processed($units_processed);
129 129
 		$extra_response_data = array(
130 130
 			'file_url' => ''
131 131
 		);
132
-		if( $units_processed < $batch_size ) {
133
-			$job_parameters->set_status( JobParameters::status_complete );
134
-			$extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) );
132
+		if ($units_processed < $batch_size) {
133
+			$job_parameters->set_status(JobParameters::status_complete);
134
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
135 135
 		}
136 136
 		return new JobStepResponse(
137 137
 				$job_parameters,
138 138
 				sprintf(
139
-					__( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ),
140
-					count( $csv_data ) ),
139
+					__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
140
+					count($csv_data) ),
141 141
 				$extra_response_data );
142 142
 	}
143 143
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @return array top-level keys are numeric, next-level keys are column headers
151 151
 	 *
152 152
 	 */
153
-	function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) {
154
-		\EE_Registry::instance()->load_helper( 'Export' );
153
+	function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) {
154
+		\EE_Registry::instance()->load_helper('Export');
155 155
 		$reg_fields_to_include = array(
156 156
 			'TXN_ID',
157 157
 			'ATT_ID',
@@ -182,165 +182,165 @@  discard block
 block discarded – undo
182 182
 				array(
183 183
 					'OR' => array(
184 184
 						//don't include registrations from failed or abandoned transactions...
185
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
185
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
186 186
 						//unless the registration is approved, in which case include it regardless of transaction status
187 187
 						'STS_ID' => \EEM_Registration::status_id_approved
188 188
 						),
189
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
189
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
190 190
 					),
191
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
192
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
193
-				'limit' => array( $offset, $limit ),
191
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
192
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
193
+				'limit' => array($offset, $limit),
194 194
 			),
195 195
 			$event_id
196 196
 		);
197
-		if( $event_id ){
198
-			$query_params[0]['EVT_ID'] =  $event_id;
199
-		}else{
200
-			$query_params[ 'force_join' ][] = 'Event';
197
+		if ($event_id) {
198
+			$query_params[0]['EVT_ID'] = $event_id;
199
+		} else {
200
+			$query_params['force_join'][] = 'Event';
201 201
 		}
202
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
202
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
203 203
 		//get all questions which relate to someone in this group
204 204
 		$registration_ids = array();
205
-		foreach( $registration_rows as $reg_row ) {
206
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
205
+		foreach ($registration_rows as $reg_row) {
206
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
207 207
 		}
208 208
 
209
-		foreach($registration_rows as $reg_row){
210
-			if ( is_array( $reg_row ) ) {
209
+		foreach ($registration_rows as $reg_row) {
210
+			if (is_array($reg_row)) {
211 211
 				$reg_csv_array = array();
212
-				if( ! $event_id ){
212
+				if ( ! $event_id) {
213 213
 					//get the event's name and Id
214
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
214
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
215 215
 				}
216
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
216
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
217 217
 				/*@var $reg_row EE_Registration */
218
-				foreach($reg_fields_to_include as $field_name){
218
+				foreach ($reg_fields_to_include as $field_name) {
219 219
 					$field = $reg_model->field_settings_for($field_name);
220
-					if($field_name == 'REG_final_price'){
221
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
222
-					}elseif( $field_name == 'REG_count' ){
223
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
224
-					}elseif( $field_name == 'REG_date' ) {
225
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
226
-					}else{
227
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
220
+					if ($field_name == 'REG_final_price') {
221
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
222
+					}elseif ($field_name == 'REG_count') {
223
+						$value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
224
+					}elseif ($field_name == 'REG_date') {
225
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
226
+					} else {
227
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
228 228
 					}
229 229
 					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
230
-					if($field_name == 'REG_final_price'){
230
+					if ($field_name == 'REG_final_price') {
231 231
 						//add a column named Currency after the final price
232 232
 						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
233 233
 					}
234 234
 				}
235 235
 				//get pretty status
236
-				$stati = \EEM_Status::instance()->localized_status( array(
237
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
238
-					$reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
236
+				$stati = \EEM_Status::instance()->localized_status(array(
237
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
238
+					$reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ),
239 239
 						FALSE,
240
-						'sentence' );
241
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
240
+						'sentence');
241
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
242 242
 				//get pretty transaction status
243
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ];
244
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00';
245
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00';
243
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']];
244
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00';
245
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00';
246 246
 				$payment_methods = array();
247 247
 				$gateway_txn_ids_etc = array();
248 248
 				$payment_times = array();
249
-				if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){
249
+				if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) {
250 250
 					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(
251 251
 							array(
252 252
 								array(
253
-									'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ],
253
+									'TXN_ID' => $reg_row['Transaction.TXN_ID'],
254 254
 									'STS_ID' => \EEM_Payment::status_id_approved
255 255
 								),
256
-								'force_join' => array( 'Payment_Method' ),
256
+								'force_join' => array('Payment_Method'),
257 257
 
258 258
 							),
259 259
 							ARRAY_A,
260 260
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
261 261
 
262
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
263
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
264
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
265
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
262
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
263
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
264
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
265
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
266 266
 					}
267 267
 
268 268
 				}
269
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
270
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
271
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
269
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
270
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
271
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
272 272
 
273 273
 				//get whether or not the user has checked in
274
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
274
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
275 275
 				//get ticket of registration and its price
276 276
 				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
277
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
278
-					$ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
277
+				if ($reg_row['Ticket.TKT_ID']) {
278
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
279 279
 					$datetimes_strings = array();
280
-					foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
281
-						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
280
+					foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
281
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
282 282
 					}
283 283
 
284 284
 				} else {
285
-					$ticket_name = __( 'Unknown', 'event_espresso' );
286
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
285
+					$ticket_name = __('Unknown', 'event_espresso');
286
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
287 287
 				}
288 288
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
289 289
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
290 290
 				//get datetime(s) of registration
291 291
 
292 292
 				//add attendee columns
293
-				foreach($att_fields_to_include as $att_field_name){
293
+				foreach ($att_fields_to_include as $att_field_name) {
294 294
 					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
295
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
296
-						if($att_field_name == 'STA_ID'){
297
-							$value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
298
-						}elseif($att_field_name == 'CNT_ISO'){
299
-							$value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
300
-						}else{
301
-							$value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
295
+					if ($reg_row['Attendee_CPT.ID']) {
296
+						if ($att_field_name == 'STA_ID') {
297
+							$value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
298
+						}elseif ($att_field_name == 'CNT_ISO') {
299
+							$value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
300
+						} else {
301
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
302 302
 						}
303
-					}else{
303
+					} else {
304 304
 						$value = '';
305 305
 					}
306 306
 
307
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value;
307
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
308 308
 				}
309 309
 
310 310
 				//make sure each registration has the same questions in the same order
311
-				foreach($questions_for_these_regs_rows as $question_row){
312
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
313
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
311
+				foreach ($questions_for_these_regs_rows as $question_row) {
312
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
313
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
314 314
 					}
315 315
 				}
316 316
 				$answers = \EEM_Answer::instance()->get_all_wpdb_results(
317 317
 					array(
318
-						array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ),
319
-						'force_join' => array( 'Question' )
318
+						array('REG_ID' => $reg_row['Registration.REG_ID']),
319
+						'force_join' => array('Question')
320 320
 					)
321 321
 				);
322 322
 				//now fill out the questions THEY answered
323
-				foreach( $answers as $answer_row ){
324
-					if( $answer_row[ 'Question.QST_ID' ] ){
323
+				foreach ($answers as $answer_row) {
324
+					if ($answer_row['Question.QST_ID']) {
325 325
 						$question_label = \EEH_Export::prepare_value_from_db_for_display(
326 326
 							\EEM_Question::instance(),
327 327
 							'QST_admin_label',
328
-							$answer_row[ 'Question.QST_admin_label' ]
328
+							$answer_row['Question.QST_admin_label']
329 329
 						);
330 330
 					} else {
331
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
331
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
332 332
 					}
333
-					if ( isset( $answer_row[ 'Question.QST_type' ] )
334
-						 && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state
333
+					if (isset($answer_row['Question.QST_type'])
334
+						 && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
335 335
 					) {
336
-						$reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID(
337
-							$answer_row[ 'Answer.ANS_value' ]
336
+						$reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID(
337
+							$answer_row['Answer.ANS_value']
338 338
 						);
339 339
 					} else {
340
-						$reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display(
340
+						$reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display(
341 341
 							\EEM_Answer::instance(),
342 342
 							'ANS_value',
343
-							$answer_row[ 'Answer.ANS_value' ]
343
+							$answer_row['Answer.ANS_value']
344 344
 						);
345 345
 					}
346 346
 				}
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 			}
352 352
 		}
353 353
 		//if we couldn't export anything, we want to at least show the column headers
354
-		if ( empty( $registrations_csv_ready_array ) ) {
354
+		if (empty($registrations_csv_ready_array)) {
355 355
 			$reg_csv_array = array();
356 356
 			$model_and_fields_to_include = array(
357 357
 				'Registration' => $reg_fields_to_include,
358 358
 				'Attendee'     => $att_fields_to_include
359 359
 			);
360
-			foreach ( $model_and_fields_to_include as $model_name => $field_list ) {
361
-				$model = \EE_Registry::instance()->load_model( $model_name );
362
-				foreach ( $field_list as $field_name ) {
363
-					$field = $model->field_settings_for( $field_name );
364
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null;
360
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
361
+				$model = \EE_Registry::instance()->load_model($model_name);
362
+				foreach ($field_list as $field_name) {
363
+					$field = $model->field_settings_for($field_name);
364
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
365 365
 				}
366 366
 			}
367 367
 			$registrations_csv_ready_array[] = $reg_csv_array;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 * @param int $event_id
378 378
 	 * @return int
379 379
 	 */
380
-	public function count_units_to_process( $event_id ) {
380
+	public function count_units_to_process($event_id) {
381 381
 		//use the legacy filter
382 382
 		$query_params = apply_filters(
383 383
 			'FHEE__EE_Export__report_registration_for_event',
@@ -385,23 +385,23 @@  discard block
 block discarded – undo
385 385
 				array(
386 386
 					'OR' => array(
387 387
 						//don't include registrations from failed or abandoned transactions...
388
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
388
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
389 389
 						//unless the registration is approved, in which case include it regardless of transaction status
390 390
 						'STS_ID' => \EEM_Registration::status_id_approved
391 391
 						),
392
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
392
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
393 393
 					),
394
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
395
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' )
394
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
395
+				'force_join' => array('Transaction', 'Ticket', 'Attendee')
396 396
 			),
397 397
 			$event_id
398 398
 		);
399
-		if( $event_id ){
400
-			$query_params[0]['EVT_ID'] =  $event_id;
399
+		if ($event_id) {
400
+			$query_params[0]['EVT_ID'] = $event_id;
401 401
 		} else {
402
-			$query_params[ 'force_join' ][] = 'Event';
402
+			$query_params['force_join'][] = 'Event';
403 403
 		}
404
-		return \EEM_Registration::instance()->count( $query_params );
404
+		return \EEM_Registration::instance()->count($query_params);
405 405
 	}
406 406
 
407 407
 
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 	 * @param JobParameters $job_parameters
413 413
 	 * @return boolean
414 414
 	 */
415
-	public function cleanup_job( JobParameters $job_parameters ){
415
+	public function cleanup_job(JobParameters $job_parameters) {
416 416
 		$this->_file_helper->delete(
417
-			\EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ),
417
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
418 418
 			true,
419 419
 			'd'
420 420
 		);
421
-		return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) );
421
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
422 422
 	}
423 423
 }
424 424
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -410,7 +410,7 @@
 block discarded – undo
410 410
 	 * Performs any clean-up logic when we know the job is completed.
411 411
 	 * In this case, we delete the temporary file
412 412
 	 * @param JobParameters $job_parameters
413
-	 * @return boolean
413
+	 * @return JobStepResponse
414 414
 	 */
415 415
 	public function cleanup_job( JobParameters $job_parameters ){
416 416
 		$this->_file_helper->delete(
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 1 patch
Spacing   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
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,14 +80,14 @@  discard block
 block discarded – undo
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
-		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
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
86 86
 		//add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 );
87
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
87
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
88 88
 		//add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 );
89 89
 		//add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 );
90
-		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
90
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
91 91
 	}
92 92
 
93 93
 
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 *  @return 	void
100 100
 	 */
101 101
 	public static function set_hooks_admin() {
102
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
102
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
103 103
 		//add button for iframe code to event editor.
104
-		add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 );
105
-		add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 );
104
+		add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4);
105
+		add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
106 106
 	}
107 107
 
108 108
 
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 	 *  @return 	void
115 115
 	 */
116 116
 	public static function set_definitions() {
117
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
118
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
117
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
118
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
119 119
 
120 120
 		//if config is not set, initialize
121 121
 		//If config is not set, set it.
122
-		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) {
122
+		if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) {
123 123
 			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
124 124
 		}
125
-		EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' );
125
+		EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
126 126
 	}
127 127
 
128 128
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * 	@param	object 			$WP
134 134
 	 * 	@return 	void
135 135
 	 */
136
-	public function run( $WP ) {}
136
+	public function run($WP) {}
137 137
 
138 138
 
139 139
 	/**
@@ -145,23 +145,23 @@  discard block
 block discarded – undo
145 145
 	public function ticket_selector_iframe() {
146 146
 		self::$_in_iframe = true;
147 147
 		/** @type EEM_Event $EEM_Event */
148
-		$EEM_Event = EE_Registry::instance()->load_model( 'Event' );
148
+		$EEM_Event = EE_Registry::instance()->load_model('Event');
149 149
 		$event = $EEM_Event->get_one_by_ID(
150
-			EE_Registry::instance()->REQ->get( 'event', 0 )
150
+			EE_Registry::instance()->REQ->get('event', 0)
151 151
 		);
152
-		EE_Registry::instance()->REQ->set_espresso_page( true );
153
-		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event );
152
+		EE_Registry::instance()->REQ->set_espresso_page(true);
153
+		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
154 154
 		$template_args['css'] = apply_filters(
155 155
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
156 156
 			array(
157
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
158
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
159
-				includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ),
160
-				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
157
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION,
158
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION,
159
+				includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']),
160
+				EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
161 161
 			)
162 162
 		);
163
-		EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true;
164
-		EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' );
163
+		EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
164
+		EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso');
165 165
 		$template_args['eei18n'] = apply_filters(
166 166
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
167 167
 			EE_Registry::localize_i18n_js_strings()
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 		$template_args['js'] = apply_filters(
170 170
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
171 171
 			array(
172
-				includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ),
173
-				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
174
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION
172
+				includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']),
173
+				EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
174
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION
175 175
 			)
176 176
 		);
177 177
 		EE_Registry::instance()->load_helper('Template');
178
-		$template_args[ 'notices' ] = EEH_Template::display_template(
179
-			EE_TEMPLATES . 'espresso-ajax-notices.template.php',
178
+		$template_args['notices'] = EEH_Template::display_template(
179
+			EE_TEMPLATES.'espresso-ajax-notices.template.php',
180 180
 			array(),
181 181
 			true
182 182
 		);
183 183
 		EEH_Template::display_template(
184
-			TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
184
+			TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php',
185 185
 			$template_args
186 186
 		);
187 187
 		exit;
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return string The new html string for the permalink area.
202 202
 	 */
203
-	public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) {
203
+	public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) {
204 204
 		//make sure this is ONLY when editing and the event id has been set.
205
-		if ( ! empty( $id ) )  {
206
-			$post = get_post( $id );
205
+		if ( ! empty($id)) {
206
+			$post = get_post($id);
207 207
 
208 208
 			//if NOT event then let's get out.
209
-			if ( $post->post_type !== 'espresso_events' ) {
209
+			if ($post->post_type !== 'espresso_events') {
210 210
 				return $permalink_string;
211 211
 			}
212 212
 
213
-			$ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() );
213
+			$ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
214 214
 
215
-			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">' . __('Embed', 'event_espresso') . '</a> ';
215
+			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'.__('Embed', 'event_espresso').'</a> ';
216 216
 			$permalink_string .= '
217 217
 <div id="js-ts-iframe" style="display:none">
218 218
 	<div style="width:100%; height: 500px;">
219
-		<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>
219
+		<iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe>
220 220
 	</div>
221 221
 </div>';
222 222
 		}
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 	 * @param 	mixed $event
236 236
 	 * @return 	bool
237 237
 	 */
238
-	protected static function set_event( $event = null ) {
239
-		if( $event === null ) {
238
+	protected static function set_event($event = null) {
239
+		if ($event === null) {
240 240
 			global $post;
241 241
 			$event = $post;
242 242
 		}
243
-		if ( $event instanceof EE_Event ) {
243
+		if ($event instanceof EE_Event) {
244 244
 			self::$_event = $event;
245
-		} else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
245
+		} else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
246 246
 			self::$_event = $event->EE_Event;
247
-		} else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) {
248
-			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
247
+		} else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') {
248
+			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
249 249
 			self::$_event = $event->EE_Event;
250 250
 		} else {
251
-			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
252
-			$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' );
253
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
251
+			$user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
252
+			$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');
253
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
254 254
 			return false;
255 255
 		}
256 256
 		return true;
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 	 * @param 	bool 	$view_details
270 270
 	 * @return 	string
271 271
 	 */
272
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
272
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
273 273
 		// reset filter for displaying submit button
274
-		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
274
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
275 275
 		// poke and prod incoming event till it tells us what it is
276
-		if ( ! EED_Ticket_Selector::set_event( $event )) {
276
+		if ( ! EED_Ticket_Selector::set_event($event)) {
277 277
 			return false;
278 278
 		}
279 279
 		$event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 			&& (
285 285
 				! self::$_event->display_ticket_selector()
286 286
 				|| $view_details
287
-				|| post_password_required( $event_post )
287
+				|| post_password_required($event_post)
288 288
 				|| (
289 289
 					$_event_active_status != EE_Datetime::active
290 290
 					&& $_event_active_status != EE_Datetime::upcoming
@@ -302,70 +302,70 @@  discard block
 block discarded – undo
302 302
 		$template_args = array();
303 303
 		$template_args['event_status'] = $_event_active_status;
304 304
 
305
-		$template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) );
306
-		$template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) );
305
+		$template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format'));
306
+		$template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format'));
307 307
 
308 308
 		$template_args['EVT_ID'] = self::$_event->ID();
309 309
 		$template_args['event'] = self::$_event;
310 310
 
311 311
 		// is the event expired ?
312 312
 		$template_args['event_is_expired'] = self::$_event->is_expired();
313
-		if ( $template_args['event_is_expired'] ) {
314
-			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>';
313
+		if ($template_args['event_is_expired']) {
314
+			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>';
315 315
 		}
316 316
 
317 317
 		$ticket_query_args = array(
318
-			array( 'Datetime.EVT_ID' => self::$_event->ID() ),
319
-			'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' )
318
+			array('Datetime.EVT_ID' => self::$_event->ID()),
319
+			'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC')
320 320
 		);
321 321
 
322
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) {
322
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
323 323
 			//use the correct applicable time query depending on what version of core is being run.
324
-			$current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp');
325
-			$ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time );
324
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp');
325
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
326 326
 		}
327 327
 
328 328
 		// get all tickets for this event ordered by the datetime
329
-		$template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args );
329
+		$template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
330 330
 
331
-		if ( count( $template_args['tickets'] ) < 1 ) {
332
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>';
331
+		if (count($template_args['tickets']) < 1) {
332
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>';
333 333
 		}
334 334
 
335 335
 		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
336
-		$template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() );
337
-		if ( $template_args['max_atndz'] < 1 ) {
338
-			$sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' );
339
-			if ( current_user_can( 'edit_post', self::$_event->ID() )) {
340
-				$sales_closed_msg .=  sprintf(
341
-					__( '%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' ),
336
+		$template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit());
337
+		if ($template_args['max_atndz'] < 1) {
338
+			$sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso');
339
+			if (current_user_can('edit_post', self::$_event->ID())) {
340
+				$sales_closed_msg .= sprintf(
341
+					__('%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'),
342 342
 					'<div class="ee-attention" style="text-align: left;"><b>',
343 343
 					'</b><br />',
344
-					$link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">',
344
+					$link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">',
345 345
 					'</a></span></div>'
346 346
 				);
347 347
 			}
348
-			return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
348
+			return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
349 349
 		}
350 350
 
351
-		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
352
-		$templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event );
351
+		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php';
352
+		$templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event);
353 353
 
354 354
 		// redirecting to another site for registration ??
355 355
 		$external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE;
356 356
 		// set up the form (but not for the admin)
357
-		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : '';
357
+		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : '';
358 358
 		// if not redirecting to another site for registration
359
-		if ( ! $external_url ) {
360
-			EE_Registry::instance()->load_helper( 'Template' );
361
-			EE_Registry::instance()->load_helper( 'URL' );
359
+		if ( ! $external_url) {
360
+			EE_Registry::instance()->load_helper('Template');
361
+			EE_Registry::instance()->load_helper('URL');
362 362
 			// then display the ticket selector
363
-			$ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args );
363
+			$ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args);
364 364
 		} else {
365 365
 			// if not we still need to trigger the display of the submit button
366
-			add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
366
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
367 367
 			//display notice to admin that registration is external
368
-			$ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' );
368
+			$ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso');
369 369
 		}
370 370
 		// submit button and form close tag
371 371
 		$ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : '';
@@ -385,27 +385,27 @@  discard block
 block discarded – undo
385 385
 	 * @param 		string $external_url
386 386
 	 * @return 		string
387 387
 	 */
388
-	public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) {
388
+	public static function ticket_selector_form_open($ID = 0, $external_url = '') {
389 389
 		// if redirecting, we don't need any anything else
390
-		if ( $external_url ) {
391
-			EE_Registry::instance()->load_helper( 'URL' );
392
-			$html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">';
393
-			$query_args = EEH_URL::get_query_string( $external_url );
394
-			foreach ( $query_args as $query_arg => $value ) {
395
-				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
390
+		if ($external_url) {
391
+			EE_Registry::instance()->load_helper('URL');
392
+			$html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">';
393
+			$query_args = EEH_URL::get_query_string($external_url);
394
+			foreach ($query_args as $query_arg => $value) {
395
+				$html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
396 396
 			}
397 397
 			return $html;
398 398
 		}
399
-		EE_Registry::instance()->load_helper( 'Event_View' );
400
-		$checkout_url = EEH_Event_View::event_link_url( $ID );
401
-		if ( ! $checkout_url ) {
402
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
399
+		EE_Registry::instance()->load_helper('Event_View');
400
+		$checkout_url = EEH_Event_View::event_link_url($ID);
401
+		if ( ! $checkout_url) {
402
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
403 403
 		}
404 404
 		$extra_params = self::$_in_iframe ? ' target="_blank"' : '';
405
-		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
406
-		$html .= wp_nonce_field( 	'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE );
405
+		$html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
406
+		$html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE);
407 407
 		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
408
-		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event );
408
+		$html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
409 409
 		return $html;
410 410
 	}
411 411
 
@@ -420,21 +420,21 @@  discard block
 block discarded – undo
420 420
 	 * 	@return		string
421 421
 	 */
422 422
 	public static function display_ticket_selector_submit() {
423
-		if ( ! is_admin() ) {
424
-			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) {
423
+		if ( ! is_admin()) {
424
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) {
425 425
 				$btn_text = apply_filters(
426 426
 					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
427
-					__('Register Now', 'event_espresso' ),
427
+					__('Register Now', 'event_espresso'),
428 428
 					self::$_event
429 429
 				);
430
-				$html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"';
430
+				$html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"';
431 431
 				$html .= ' class="ticket-selector-submit-btn ticket-selector-submit-ajax"';
432
-				$html .= ' type="submit" value="' . $btn_text . '" />';
433
-				$html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event );
432
+				$html .= ' type="submit" value="'.$btn_text.'" />';
433
+				$html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event);
434 434
 				$html .= '<div class="clear"><br/></div></form>';
435 435
 				return $html;
436
-			} else if ( is_archive() ) {
437
-				return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn();
436
+			} else if (is_archive()) {
437
+				return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn();
438 438
 			}
439 439
 		}
440 440
 		return '';
@@ -466,13 +466,13 @@  discard block
 block discarded – undo
466 466
 	 * 	@return		string
467 467
 	 */
468 468
 	public static function display_view_details_btn() {
469
-		if ( ! self::$_event->get_permalink() ) {
470
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
469
+		if ( ! self::$_event->get_permalink()) {
470
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
471 471
 		}
472
-		$view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">';
473
-		$btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event );
474
-		$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 . '" />';
475
-		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event );
472
+		$view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">';
473
+		$btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event);
474
+		$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.'" />';
475
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
476 476
 		$view_details_btn .= '<div class="clear"><br/></div>';
477 477
 		$view_details_btn .= '</form>';
478 478
 		return $view_details_btn;
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	 * 	@return		array  or FALSE
492 492
 	 */
493 493
 	public function process_ticket_selections() {
494
-		do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
494
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
495 495
 		// check nonce
496
-		if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) {
496
+		if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) {
497 497
 			EE_Error::add_error(
498
-				sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
498
+				sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
499 499
 				__FILE__, __FUNCTION__, __LINE__
500 500
 			);
501 501
 			return FALSE;
@@ -509,16 +509,16 @@  discard block
 block discarded – undo
509 509
 
510 510
 		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
511 511
 		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
512
-		EE_Registry::instance()->load_core( 'Session' );
512
+		EE_Registry::instance()->load_core('Session');
513 513
 		// unless otherwise requested, clear the session
514
-		if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) {
515
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
514
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) {
515
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
516 516
 		}
517 517
 		//d( EE_Registry::instance()->SSN );
518 518
 
519
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
519
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
520 520
 		// do we have an event id?
521
-		if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) {
521
+		if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
522 522
 			// validate/sanitize data
523 523
 			$valid = self::_validate_post_data();
524 524
 
@@ -528,43 +528,43 @@  discard block
 block discarded – undo
528 528
 			//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
529 529
 
530 530
 			//check total tickets ordered vs max number of attendees that can register
531
-			if ( $valid['total_tickets'] > $valid['max_atndz'] ) {
531
+			if ($valid['total_tickets'] > $valid['max_atndz']) {
532 532
 
533 533
 				// ordering too many tickets !!!
534 534
 				$singular = 'You have attempted to purchase %s ticket.';
535 535
 				$plural = 'You have attempted to purchase %s tickets.';
536
-				$limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] );
536
+				$limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']);
537 537
 				// dev only message
538 538
 				$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.';
539 539
 				$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.';
540
-				$limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] );
541
-				EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ );
540
+				$limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']);
541
+				EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
542 542
 			} else {
543 543
 
544 544
 				// all data appears to be valid
545 545
 				$tckts_slctd = FALSE;
546 546
 				$success = TRUE;
547 547
 				// load cart
548
-				EE_Registry::instance()->load_core( 'Cart' );
548
+				EE_Registry::instance()->load_core('Cart');
549 549
 
550 550
 				// cycle thru the number of data rows sent from the event listing
551
-				for ( $x = 0; $x < $valid['rows']; $x++ ) {
551
+				for ($x = 0; $x < $valid['rows']; $x++) {
552 552
 					// does this row actually contain a ticket quantity?
553
-					if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) {
553
+					if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
554 554
 						// YES we have a ticket quantity
555 555
 						$tckts_slctd = TRUE;
556 556
 						//						d( $valid['ticket_obj'][$x] );
557
-						if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) {
557
+						if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
558 558
 							// then add ticket to cart
559
-							$ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] );
559
+							$ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
560 560
 							$success = ! $ticket_added ? FALSE : $success;
561
-							if ( EE_Error::has_error() ) {
561
+							if (EE_Error::has_error()) {
562 562
 								break;
563 563
 							}
564 564
 						} else {
565 565
 							// nothing added to cart retrieved
566 566
 							EE_Error::add_error(
567
-								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/>' ),
567
+								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/>'),
568 568
 								__FILE__, __FUNCTION__, __LINE__
569 569
 							);
570 570
 						}
@@ -573,45 +573,45 @@  discard block
 block discarded – undo
573 573
 				//d( EE_Registry::instance()->CART );
574 574
 				//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
575 575
 
576
-				if ( $tckts_slctd ) {
577
-					if ( $success ) {
578
-						do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this );
576
+				if ($tckts_slctd) {
577
+					if ($success) {
578
+						do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this);
579 579
 						EE_Registry::instance()->CART->recalculate_all_cart_totals();
580
-						EE_Registry::instance()->CART->save_cart( FALSE );
580
+						EE_Registry::instance()->CART->save_cart(FALSE);
581 581
 						EE_Registry::instance()->SSN->update();
582 582
 						//d( EE_Registry::instance()->CART );
583 583
 						//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
584 584
 						// just return TRUE for registrations being made from admin
585
-						if ( is_admin() ) {
585
+						if (is_admin()) {
586 586
 							return TRUE;
587 587
 						}
588
-						wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() ));
588
+						wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url()));
589 589
 						exit();
590 590
 
591 591
 					} else {
592
-						if ( ! EE_Error::has_error() ) {
592
+						if ( ! EE_Error::has_error()) {
593 593
 							// nothing added to cart
594
-							EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
594
+							EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
595 595
 						}
596 596
 					}
597 597
 
598 598
 				} else {
599 599
 					// no ticket quantities were selected
600
-					EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
600
+					EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
601 601
 				}
602 602
 			}
603 603
 			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
604 604
 			// at this point, just return if registration is being made from admin
605
-			if ( is_admin() ) {
605
+			if (is_admin()) {
606 606
 				return FALSE;
607 607
 			}
608
-			if ( $valid['return_url'] ) {
609
-				EE_Error::get_notices( FALSE, TRUE );
610
-				wp_safe_redirect( $valid['return_url'] );
608
+			if ($valid['return_url']) {
609
+				EE_Error::get_notices(FALSE, TRUE);
610
+				wp_safe_redirect($valid['return_url']);
611 611
 				exit();
612
-			} elseif ( isset( $event_to_add['id'] )) {
613
-				EE_Error::get_notices( FALSE, TRUE );
614
-				wp_safe_redirect( get_permalink( $event_to_add['id'] ));
612
+			} elseif (isset($event_to_add['id'])) {
613
+				EE_Error::get_notices(FALSE, TRUE);
614
+				wp_safe_redirect(get_permalink($event_to_add['id']));
615 615
 				exit();
616 616
 			} else {
617 617
 				echo EE_Error::get_notices();
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 		} else {
621 621
 			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
622 622
 			EE_Error::add_error(
623
-				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/>' ),
623
+				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/>'),
624 624
 				__FILE__, __FUNCTION__, __LINE__
625 625
 			);
626 626
 		}
@@ -638,18 +638,18 @@  discard block
 block discarded – undo
638 638
 	 * @return        array  or FALSE
639 639
 	 */
640 640
 	private static function _validate_post_data() {
641
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
641
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
642 642
 
643 643
 		// start with an empty array()
644 644
 		$valid_data = array();
645 645
 		//		d( $_POST );
646 646
 		//if event id is valid
647
-		$id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ));
648
-		if ( $id ) {
647
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
648
+		if ($id) {
649 649
 			// grab valid id
650 650
 			$valid_data['id'] = $id;
651 651
 			// grab and sanitize return-url
652
-			$valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id ));
652
+			$valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id));
653 653
 			// array of other form names
654 654
 			$inputs_to_clean = array(
655 655
 				'event_id' => 'tkt-slctr-event-id',
@@ -662,22 +662,22 @@  discard block
 block discarded – undo
662 662
 			// let's track the total number of tickets ordered.'
663 663
 			$valid_data['total_tickets'] = 0;
664 664
 			// cycle through $inputs_to_clean array
665
-			foreach ( $inputs_to_clean as $what => $input_to_clean ) {
665
+			foreach ($inputs_to_clean as $what => $input_to_clean) {
666 666
 				// check for POST data
667
-				if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) {
667
+				if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
668 668
 					// grab value
669
-					$input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id );
669
+					$input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
670 670
 					switch ($what) {
671 671
 
672 672
 						// integers
673 673
 						case 'event_id':
674
-							$valid_data[$what] = absint( $input_value );
674
+							$valid_data[$what] = absint($input_value);
675 675
 							// get event via the event id we put in the form
676
-							$valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] );
676
+							$valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']);
677 677
 							break;
678 678
 						case 'rows':
679 679
 						case 'max_atndz':
680
-							$valid_data[$what] = absint( $input_value );
680
+							$valid_data[$what] = absint($input_value);
681 681
 							break;
682 682
 
683 683
 						// arrays of integers
@@ -685,27 +685,27 @@  discard block
 block discarded – undo
685 685
 							//							d( $input_value );
686 686
 							$row_qty = $input_value;
687 687
 							// if qty is coming from a radio button input, then we need to assemble an array of rows
688
-							if( ! is_array( $row_qty )) {
688
+							if ( ! is_array($row_qty)) {
689 689
 								// get number of rows
690
-								$rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1;
690
+								$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1;
691 691
 								//								d( $rows );
692 692
 								// explode ints by the dash
693
-								$row_qty = explode( '-', $row_qty );
694
-								$row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1;
695
-								$qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0;
696
-								$row_qty = array( $row => $qty );
693
+								$row_qty = explode('-', $row_qty);
694
+								$row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1;
695
+								$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
696
+								$row_qty = array($row => $qty);
697 697
 								//								 d( $row_qty );
698
-								for( $x = 1; $x <= $rows; $x++ ) {
699
-									if ( ! isset( $row_qty[$x] )) {
698
+								for ($x = 1; $x <= $rows; $x++) {
699
+									if ( ! isset($row_qty[$x])) {
700 700
 										$row_qty[$x] = 0;
701 701
 									}
702 702
 								}
703 703
 							}
704
-							ksort( $row_qty );
704
+							ksort($row_qty);
705 705
 							//							 d( $row_qty );
706 706
 							// cycle thru values
707
-							foreach ( $row_qty as $qty ) {
708
-								$qty = absint( $qty );
707
+							foreach ($row_qty as $qty) {
708
+								$qty = absint($qty);
709 709
 								// sanitize as integers
710 710
 								$valid_data[$what][] = $qty;
711 711
 								$valid_data['total_tickets'] += $qty;
@@ -716,19 +716,19 @@  discard block
 block discarded – undo
716 716
 						case 'ticket_id':
717 717
 							$value_array = array();
718 718
 							// cycle thru values
719
-							foreach ( $input_value as $key=>$value ) {
719
+							foreach ($input_value as $key=>$value) {
720 720
 								// allow only numbers, letters,  spaces, commas and dashes
721
-								$value_array[ $key ] = wp_strip_all_tags( $value );
721
+								$value_array[$key] = wp_strip_all_tags($value);
722 722
 								// get ticket via the ticket id we put in the form
723
-								$ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value );
724
-								$valid_data['ticket_obj'][ $key ] = $ticket_obj;
723
+								$ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
724
+								$valid_data['ticket_obj'][$key] = $ticket_obj;
725 725
 							}
726
-							$valid_data[ $what ] = $value_array;
726
+							$valid_data[$what] = $value_array;
727 727
 							break;
728 728
 
729 729
 						case 'return_url' :
730 730
 							// grab and sanitize return-url
731
-							$valid_data[$what] = esc_url_raw( $input_value );
731
+							$valid_data[$what] = esc_url_raw($input_value);
732 732
 							break;
733 733
 
734 734
 					} 	// end switch $what
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 			} 	// end foreach $inputs_to_clean
737 737
 
738 738
 		} else {
739
-			EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
739
+			EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
740 740
 			return FALSE;
741 741
 		}
742 742
 
@@ -754,28 +754,28 @@  discard block
 block discarded – undo
754 754
 	 * @param int       $qty
755 755
 	 * @return TRUE on success, FALSE on fail
756 756
 	 */
757
-	private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) {
758
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
757
+	private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) {
758
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
759 759
 		// get the number of spaces left for this datetime ticket
760
-		$available_spaces = self::_ticket_datetime_availability( $ticket );
760
+		$available_spaces = self::_ticket_datetime_availability($ticket);
761 761
 		// compare available spaces against the number of tickets being purchased
762
-		if ( $available_spaces >= $qty ) {
762
+		if ($available_spaces >= $qty) {
763 763
 			// allow addons to prevent a ticket from being added to cart
764
-			if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) {
764
+			if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) {
765 765
 				return false;
766 766
 			}
767 767
 			// add event to cart
768
-			if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) {
769
-				self::_recalculate_ticket_datetime_availability( $ticket, $qty );
768
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
769
+				self::_recalculate_ticket_datetime_availability($ticket, $qty);
770 770
 				return true;
771 771
 			} else {
772 772
 				return false;
773 773
 			}
774 774
 		} else {
775 775
 			// tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
776
-			$available_spaces = self::_ticket_datetime_availability( $ticket, true );
776
+			$available_spaces = self::_ticket_datetime_availability($ticket, true);
777 777
 			// greedy greedy greedy eh?
778
-			if ( $available_spaces > 0 ) {
778
+			if ($available_spaces > 0) {
779 779
 				// add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces
780 780
 				EE_Error::add_error(
781 781
 					sprintf(
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 					__FILE__, __FUNCTION__, __LINE__
792 792
 				);
793 793
 			} else {
794
-				EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
794
+				EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
795 795
 			}
796 796
 			return false;
797 797
 		}
@@ -809,22 +809,22 @@  discard block
 block discarded – undo
809 809
 	 * @param 	bool         $get_original_ticket_spaces
810 810
 	 * @return 	int
811 811
 	 */
812
-	private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) {
812
+	private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) {
813 813
 		// if the $_available_spaces array has not been set up yet...
814
-		if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
815
-				self::_set_initial_ticket_datetime_availability( $ticket );
814
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
815
+				self::_set_initial_ticket_datetime_availability($ticket);
816 816
 		}
817 817
 		$available_spaces = $ticket->qty() - $ticket->sold();
818
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
818
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
819 819
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
820
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
820
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
821 821
 				// if we want the original datetime availability BEFORE we started subtracting tickets ?
822
-				if ( $get_original_ticket_spaces ) {
822
+				if ($get_original_ticket_spaces) {
823 823
 					// then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
824
-					$available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] );
824
+					$available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
825 825
 				} else {
826 826
 					// we want the updated ticket availability as stored in the "datetimes" array
827
-					$available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] );
827
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
828 828
 				}
829 829
 			}
830 830
 		}
@@ -840,23 +840,23 @@  discard block
 block discarded – undo
840 840
 	 * @param 	EE_Ticket $ticket
841 841
 	 * @return 	int
842 842
 	 */
843
-	private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) {
843
+	private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) {
844 844
 		// first, get all of the datetimes that are available to this ticket
845 845
 		$datetimes = $ticket->get_many_related(
846 846
 			'Datetime',
847
-			array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ))
847
+			array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC'))
848 848
 		);
849
-		if ( ! empty( $datetimes )) {
849
+		if ( ! empty($datetimes)) {
850 850
 			// now loop thru all of the datetimes
851
-			foreach ( $datetimes as $datetime  ) {
852
-				if ( $datetime instanceof EE_Datetime ) {
851
+			foreach ($datetimes as $datetime) {
852
+				if ($datetime instanceof EE_Datetime) {
853 853
 					// the number of spaces available for the datetime without considering individual ticket quantities
854 854
 					$spaces_remaining = $datetime->spaces_remaining();
855 855
 					// 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
856
-					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining );
856
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining);
857 857
 					// if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
858 858
 					// else just take the datetime spaces remaining, and assign to the datetimes array
859
-					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining;
859
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining;
860 860
 				}
861 861
 			}
862 862
 		}
@@ -872,12 +872,12 @@  discard block
 block discarded – undo
872 872
 	 * @param 	int   $qty
873 873
 	 * @return 	int
874 874
 	 */
875
-	private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) {
876
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
875
+	private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) {
876
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
877 877
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
878
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
878
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
879 879
 				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
880
-				self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty;
880
+				self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty;
881 881
 			}
882 882
 		}
883 883
 	}
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 	*/
895 895
 	public static function load_tckt_slctr_assets() {
896 896
 		// add some style
897
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
898
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
897
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
898
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
899 899
 			wp_enqueue_style('ticket_selector');
900 900
 			// make it dance
901 901
 			//			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
@@ -909,9 +909,9 @@  discard block
 block discarded – undo
909 909
 
910 910
 	public static function load_tckt_slctr_assets_admin() {
911 911
 		//iframe button js on admin event editor page
912
-		if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) {
913
-			wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true );
914
-			wp_enqueue_script( 'ticket_selector_embed' );
912
+		if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') {
913
+			wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
914
+			wp_enqueue_script('ticket_selector_embed');
915 915
 		}
916 916
 	}
917 917
 
Please login to merge, or discard this patch.