Completed
Branch FET-9795-new-interfaces (ea072c)
by
unknown
127:10 queued 107:02
created
core/db_classes/EE_Import.class.php 4 patches
Doc Comments   +4 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,10 +79,6 @@  discard block
 block discarded – undo
79 79
 	 *	@ access 	public
80 80
 	 * 	@param 	string 		$title - heading for the form
81 81
 	 * 	@param 	string 		$intro - additional text explaing what to do
82
-	 * 	@param 	string 		$page - EE Admin page to direct form to - in the form "espresso_{pageslug}"
83
-	 * 	@param 	string 		$action - EE Admin page route array "action" that form will direct to
84
-	 * 	@param 	string 		$type - type of file to import
85
-	 *	@ return 	string
86 82
 	 */
87 83
 	public function upload_form ( $title, $intro, $form_url, $action, $type  ) {
88 84
 
@@ -121,7 +117,7 @@  discard block
 block discarded – undo
121 117
 	/**
122 118
 	 *	@Import Event Espresso data - some code "borrowed" from event espresso csv_import.php
123 119
 	 *	@access public
124
-	 *	@return boolean success
120
+	 *	@return boolean|null success
125 121
 	 */
126 122
 	public function import() {
127 123
 
@@ -269,8 +265,7 @@  discard block
 block discarded – undo
269 265
 	 * update that event, instead of adding a new event).
270 266
 	 *		  @access public
271 267
 	 *			@param array $csv_data_array - the array containing the csv data produced from EE_CSV::import_csv_to_model_data_array()
272
-	 *			@param array $fields_to_save - an array containing the csv column names as keys with the corresponding db table fields they will be saved to
273
-	 *			@return TRUE on success, FALSE on fail
268
+	 * @return boolean
274 269
 	 */
275 270
 	public function save_csv_data_array_to_db( $csv_data_array, $model_name = FALSE ) {
276 271
 
@@ -367,7 +362,7 @@  discard block
 block discarded – undo
367 362
 	 * we need to insert a new row for that ID, and then map from the non-existent ID
368 363
 	 * to the newly-inserted real ID.
369 364
 	 * @param type $csv_data_array
370
-	 * @param type $export_from_site_a_to_b
365
+	 * @param boolean $export_from_site_a_to_b
371 366
 	 * @param type $old_db_to_new_db_mapping
372 367
 	 * @return array updated $old_db_to_new_db_mapping
373 368
 	 */
@@ -484,7 +479,6 @@  discard block
 block discarded – undo
484 479
 	 * @param type $id_in_csv
485 480
 	 * @param type $model_object_data
486 481
 	 * @param EEM_Base $model
487
-	 * @param type $old_db_to_new_db_mapping
488 482
 	 * @return
489 483
 	 */
490 484
 	protected function _decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model ) {
@@ -594,7 +588,7 @@  discard block
 block discarded – undo
594 588
 	 * @param type $object_id
595 589
 	 * @param string $model_name
596 590
 	 * @param array $old_db_to_new_db_mapping
597
-	 * @param type $export_from_site_a_to_b
591
+	 * @param boolean $export_from_site_a_to_b
598 592
 	 * @return int
599 593
 	 */
600 594
 	protected function _find_mapping_in( $object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -131,43 +131,43 @@  discard block
 block discarded – undo
131 131
 		if ( isset( $_REQUEST['import'] )) {
132 132
 			if( isset( $_POST['csv_submitted'] )) {
133 133
 
134
-			    switch ( $_FILES['file']['error'][0] ) {
135
-			        case UPLOAD_ERR_OK:
136
-			            $error_msg = FALSE;
137
-			            break;
138
-			        case UPLOAD_ERR_INI_SIZE:
139
-			            $error_msg = __("'The uploaded file exceeds the upload_max_filesize directive in php.ini.'", "event_espresso");
140
-			            break;
141
-			        case UPLOAD_ERR_FORM_SIZE:
142
-			            $error_msg = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', "event_espresso");
143
-			            break;
144
-			        case UPLOAD_ERR_PARTIAL:
145
-			            $error_msg = __('The uploaded file was only partially uploaded.', "event_espresso");
146
-			            break;
147
-			        case UPLOAD_ERR_NO_FILE:
148
-			            $error_msg = __('No file was uploaded.', "event_espresso");
149
-			            break;
150
-			        case UPLOAD_ERR_NO_TMP_DIR:
151
-			            $error_msg = __('Missing a temporary folder.', "event_espresso");
152
-			            break;
153
-			        case UPLOAD_ERR_CANT_WRITE:
154
-			            $error_msg = __('Failed to write file to disk.', "event_espresso");
155
-			            break;
156
-			        case UPLOAD_ERR_EXTENSION:
157
-			            $error_msg = __('File upload stopped by extension.', "event_espresso");
158
-			            break;
159
-			        default:
160
-			            $error_msg = __('An unknown error occurred and the file could not be uploaded', "event_espresso");
161
-			            break;
162
-			    }
134
+				switch ( $_FILES['file']['error'][0] ) {
135
+					case UPLOAD_ERR_OK:
136
+						$error_msg = FALSE;
137
+						break;
138
+					case UPLOAD_ERR_INI_SIZE:
139
+						$error_msg = __("'The uploaded file exceeds the upload_max_filesize directive in php.ini.'", "event_espresso");
140
+						break;
141
+					case UPLOAD_ERR_FORM_SIZE:
142
+						$error_msg = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', "event_espresso");
143
+						break;
144
+					case UPLOAD_ERR_PARTIAL:
145
+						$error_msg = __('The uploaded file was only partially uploaded.', "event_espresso");
146
+						break;
147
+					case UPLOAD_ERR_NO_FILE:
148
+						$error_msg = __('No file was uploaded.', "event_espresso");
149
+						break;
150
+					case UPLOAD_ERR_NO_TMP_DIR:
151
+						$error_msg = __('Missing a temporary folder.', "event_espresso");
152
+						break;
153
+					case UPLOAD_ERR_CANT_WRITE:
154
+						$error_msg = __('Failed to write file to disk.', "event_espresso");
155
+						break;
156
+					case UPLOAD_ERR_EXTENSION:
157
+						$error_msg = __('File upload stopped by extension.', "event_espresso");
158
+						break;
159
+					default:
160
+						$error_msg = __('An unknown error occurred and the file could not be uploaded', "event_espresso");
161
+						break;
162
+				}
163 163
 
164 164
 				if ( ! $error_msg ) {
165 165
 
166
-				    $filename	= $_FILES['file']['name'][0];
166
+					$filename	= $_FILES['file']['name'][0];
167 167
 					$file_ext 		= substr( strrchr( $filename, '.' ), 1 );
168
-				    $file_type 	= $_FILES['file']['type'][0];
169
-				    $temp_file	= $_FILES['file']['tmp_name'][0];
170
-				    $filesize    	= $_FILES['file']['size'][0] / 1024;//convert from bytes to KB
168
+					$file_type 	= $_FILES['file']['type'][0];
169
+					$temp_file	= $_FILES['file']['tmp_name'][0];
170
+					$filesize    	= $_FILES['file']['size'][0] / 1024;//convert from bytes to KB
171 171
 
172 172
 					if ( $file_ext=='csv' ) {
173 173
 
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 			unset($csv_data_array[EE_CSV::metadata_header]);
303 303
 		}
304 304
 		/**
305
-		* @var $old_db_to_new_db_mapping 2d array: toplevel keys being model names, bottom-level keys being the original key, and
306
-		* the value will be the newly-inserted ID.
307
-		* If we have already imported data from the same website via CSV, it shoudl be kept in this wp option
308
-		*/
305
+		 * @var $old_db_to_new_db_mapping 2d array: toplevel keys being model names, bottom-level keys being the original key, and
306
+		 * the value will be the newly-inserted ID.
307
+		 * If we have already imported data from the same website via CSV, it shoudl be kept in this wp option
308
+		 */
309 309
 	   $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url),array());
310 310
 	   if( $old_db_to_new_db_mapping){
311 311
 		   EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"),$old_site_url,site_url()));
Please login to merge, or discard this patch.
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\ResettableInterface;
2 2
 
3
-if (!defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
4
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
4
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
5 5
 /**
6 6
  * EE_Import class
7 7
  *
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public static function instance() {
60 60
 		// check if class object is instantiated
61
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Import )) {
61
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Import)) {
62 62
 			self::$_instance = new self();
63 63
 		}
64 64
 		return self::$_instance;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * Resets the importer
69 69
 	 * @return EE_Import
70 70
 	 */
71
-	public static function reset(){
71
+	public static function reset() {
72 72
 		self::$_instance = null;
73 73
 		return self::instance();
74 74
 	}
@@ -86,27 +86,27 @@  discard block
 block discarded – undo
86 86
 	 * 	@param 	string 		$type - type of file to import
87 87
 	 *	@ return 	string
88 88
 	 */
89
-	public function upload_form ( $title, $intro, $form_url, $action, $type  ) {
89
+	public function upload_form($title, $intro, $form_url, $action, $type) {
90 90
 
91
-		$form_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => $action ), $form_url );
91
+		$form_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => $action), $form_url);
92 92
 
93 93
 		ob_start();
94 94
 ?>
95 95
 	<div class="ee-upload-form-dv">
96
-		<h3><?php echo $title;?></h3>
97
-		<p><?php echo $intro;?></p>
96
+		<h3><?php echo $title; ?></h3>
97
+		<p><?php echo $intro; ?></p>
98 98
 
99 99
 		<form action="<?php echo $form_url?>" method="post" enctype="multipart/form-data">
100
-			<input type="hidden" name="csv_submitted" value="TRUE" id="<?php echo time();?>">
101
-			<input name="import" type="hidden" value="<?php echo $type;?>" />
100
+			<input type="hidden" name="csv_submitted" value="TRUE" id="<?php echo time(); ?>">
101
+			<input name="import" type="hidden" value="<?php echo $type; ?>" />
102 102
 			<input type="file" name="file[]" size="90" >
103
-			<input class="button-primary" type="submit" value="<?php _e( 'Upload File', 'event_espresso' );?>">
103
+			<input class="button-primary" type="submit" value="<?php _e('Upload File', 'event_espresso'); ?>">
104 104
 		</form>
105 105
 
106 106
 		<p class="ee-attention">
107
-			<b><?php _e( 'Attention', 'event_espresso' );?></b><br/>
108
-			<?php echo sprintf( __( 'Accepts .%s file types only.', 'event_espresso' ), $type ) ;?>
109
-			<?php echo __( 'Please only import CSV files exported from Event Espresso, or compatible 3rd-party software.', 'event_espresso' );?>
107
+			<b><?php _e('Attention', 'event_espresso'); ?></b><br/>
108
+			<?php echo sprintf(__('Accepts .%s file types only.', 'event_espresso'), $type); ?>
109
+			<?php echo __('Please only import CSV files exported from Event Espresso, or compatible 3rd-party software.', 'event_espresso'); ?>
110 110
 		</p>
111 111
 
112 112
 	</div>
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function import() {
129 129
 
130
-		require_once( EE_CLASSES . 'EE_CSV.class.php' );
130
+		require_once(EE_CLASSES.'EE_CSV.class.php');
131 131
 		$this->EE_CSV = EE_CSV::instance();
132 132
 
133
-		if ( isset( $_REQUEST['import'] )) {
134
-			if( isset( $_POST['csv_submitted'] )) {
133
+		if (isset($_REQUEST['import'])) {
134
+			if (isset($_POST['csv_submitted'])) {
135 135
 
136
-			    switch ( $_FILES['file']['error'][0] ) {
136
+			    switch ($_FILES['file']['error'][0]) {
137 137
 			        case UPLOAD_ERR_OK:
138 138
 			            $error_msg = FALSE;
139 139
 			            break;
@@ -163,32 +163,32 @@  discard block
 block discarded – undo
163 163
 			            break;
164 164
 			    }
165 165
 
166
-				if ( ! $error_msg ) {
166
+				if ( ! $error_msg) {
167 167
 
168
-				    $filename	= $_FILES['file']['name'][0];
169
-					$file_ext 		= substr( strrchr( $filename, '.' ), 1 );
170
-				    $file_type 	= $_FILES['file']['type'][0];
171
-				    $temp_file	= $_FILES['file']['tmp_name'][0];
172
-				    $filesize    	= $_FILES['file']['size'][0] / 1024;//convert from bytes to KB
168
+				    $filename = $_FILES['file']['name'][0];
169
+					$file_ext = substr(strrchr($filename, '.'), 1);
170
+				    $file_type = $_FILES['file']['type'][0];
171
+				    $temp_file = $_FILES['file']['tmp_name'][0];
172
+				    $filesize = $_FILES['file']['size'][0] / 1024; //convert from bytes to KB
173 173
 
174
-					if ( $file_ext=='csv' ) {
174
+					if ($file_ext == 'csv') {
175 175
 
176
-						$max_upload = $this->EE_CSV->get_max_upload_size();//max upload size in KB
177
-						if ( $filesize < $max_upload || true) {
176
+						$max_upload = $this->EE_CSV->get_max_upload_size(); //max upload size in KB
177
+						if ($filesize < $max_upload || true) {
178 178
 
179
-							$wp_upload_dir = str_replace( array( '\\', '/' ), DS, wp_upload_dir());
180
-							$path_to_file = $wp_upload_dir['basedir'] . DS . 'espresso' . DS . $filename;
179
+							$wp_upload_dir = str_replace(array('\\', '/'), DS, wp_upload_dir());
180
+							$path_to_file = $wp_upload_dir['basedir'].DS.'espresso'.DS.$filename;
181 181
 
182
-							if( move_uploaded_file( $temp_file, $path_to_file )) {
182
+							if (move_uploaded_file($temp_file, $path_to_file)) {
183 183
 
184 184
 								// convert csv to array
185
-								$this->csv_array = $this->EE_CSV->import_csv_to_model_data_array( $path_to_file );
185
+								$this->csv_array = $this->EE_CSV->import_csv_to_model_data_array($path_to_file);
186 186
 
187 187
 								// was data successfully stored in an array?
188
-								if ( is_array( $this->csv_array ) ) {
188
+								if (is_array($this->csv_array)) {
189 189
 
190
-									$import_what = str_replace( 'csv_import_', '', $_REQUEST['action'] );
191
-									$import_what = str_replace( '_', ' ', ucwords( $import_what ));
190
+									$import_what = str_replace('csv_import_', '', $_REQUEST['action']);
191
+									$import_what = str_replace('_', ' ', ucwords($import_what));
192 192
 									$processed_data = $this->csv_array;
193 193
 									$this->columns_to_save = FALSE;
194 194
 
@@ -207,33 +207,33 @@  discard block
 block discarded – undo
207 207
 
208 208
 									}
209 209
 									// save processed codes to db
210
-									if ( $this->save_csv_data_array_to_db( $processed_data, $this->columns_to_save ) ) {
210
+									if ($this->save_csv_data_array_to_db($processed_data, $this->columns_to_save)) {
211 211
 										return TRUE;
212 212
 
213 213
 									}
214 214
 								} else {
215 215
 									// no array? must be an error
216
-									EE_Error::add_error(sprintf(__("No file seems to have been uploaded", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
216
+									EE_Error::add_error(sprintf(__("No file seems to have been uploaded", "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
217 217
 									return FALSE;
218 218
 								}
219 219
 
220 220
 							} else {
221
-								EE_Error::add_error(sprintf(__("%s was not successfully uploaded", "event_espresso"),$filename), __FILE__, __FUNCTION__, __LINE__ );
221
+								EE_Error::add_error(sprintf(__("%s was not successfully uploaded", "event_espresso"), $filename), __FILE__, __FUNCTION__, __LINE__);
222 222
 								return FALSE;
223 223
 							}
224 224
 
225 225
 						} else {
226
-							EE_Error::add_error( sprintf(__("%s was too large of a file and could not be uploaded. The max filesize is %s' KB.", "event_espresso"),$filename,$max_upload), __FILE__, __FUNCTION__, __LINE__ );
226
+							EE_Error::add_error(sprintf(__("%s was too large of a file and could not be uploaded. The max filesize is %s' KB.", "event_espresso"), $filename, $max_upload), __FILE__, __FUNCTION__, __LINE__);
227 227
 							return FALSE;
228 228
 						}
229 229
 
230 230
 					} else {
231
-						EE_Error::add_error( sprintf(__("%s  had an invalid file extension, not uploaded", "event_espresso"),$filename), __FILE__, __FUNCTION__, __LINE__ );
231
+						EE_Error::add_error(sprintf(__("%s  had an invalid file extension, not uploaded", "event_espresso"), $filename), __FILE__, __FUNCTION__, __LINE__);
232 232
 						return FALSE;
233 233
 					}
234 234
 
235 235
 				} else {
236
-					EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
236
+					EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
237 237
 					return FALSE;
238 238
 				}
239 239
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 *			@param array $fields_to_save - an array containing the csv column names as keys with the corresponding db table fields they will be saved to
275 275
 	 *			@return TRUE on success, FALSE on fail
276 276
 	 */
277
-	public function save_csv_data_array_to_db( $csv_data_array, $model_name = FALSE ) {
277
+	public function save_csv_data_array_to_db($csv_data_array, $model_name = FALSE) {
278 278
 
279 279
 
280 280
 		$success = FALSE;
@@ -284,22 +284,22 @@  discard block
 block discarded – undo
284 284
 		$export_from_site_a_to_b = true;
285 285
 		// first level of array is not table information but a table name was passed to the function
286 286
 		// array is only two levels deep, so let's fix that by adding a level, else the next steps will fail
287
-		if($model_name){
287
+		if ($model_name) {
288 288
 			$csv_data_array = array($csv_data_array);
289 289
 		}
290 290
 		// begin looking through the $csv_data_array, expecting the toplevel key to be the model's name...
291 291
 		$old_site_url = 'none-specified';
292 292
 
293 293
 		//hanlde metadata
294
-		if(isset($csv_data_array[EE_CSV::metadata_header]) ){
294
+		if (isset($csv_data_array[EE_CSV::metadata_header])) {
295 295
 			$csv_metadata = array_shift($csv_data_array[EE_CSV::metadata_header]);
296 296
 			//ok so its metadata, dont try to save it to ehte db obviously...
297
-			if(isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()){
297
+			if (isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()) {
298 298
 				EE_Error::add_attention(sprintf(__("CSV Data appears to be from the same database, so attempting to update data", "event_espresso")));
299 299
 				$export_from_site_a_to_b = false;
300
-			}else{
301
-				$old_site_url = isset( $csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url;
302
-				EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"),$old_site_url,site_url()));
300
+			} else {
301
+				$old_site_url = isset($csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url;
302
+				EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"), $old_site_url, site_url()));
303 303
 			};
304 304
 			unset($csv_data_array[EE_CSV::metadata_header]);
305 305
 		}
@@ -308,40 +308,40 @@  discard block
 block discarded – undo
308 308
 		* the value will be the newly-inserted ID.
309 309
 		* If we have already imported data from the same website via CSV, it shoudl be kept in this wp option
310 310
 		*/
311
-	   $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url),array());
312
-	   if( $old_db_to_new_db_mapping){
313
-		   EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"),$old_site_url,site_url()));
311
+	   $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url), array());
312
+	   if ($old_db_to_new_db_mapping) {
313
+		   EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"), $old_site_url, site_url()));
314 314
 	   }
315 315
 	   $old_db_to_new_db_mapping = $this->save_data_rows_to_db($csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping);
316 316
 
317 317
 		//save the mapping from old db to new db in case they try re-importing the same data from the same website again
318
-		update_option('ee_id_mapping_from'.sanitize_title($old_site_url),$old_db_to_new_db_mapping);
318
+		update_option('ee_id_mapping_from'.sanitize_title($old_site_url), $old_db_to_new_db_mapping);
319 319
 
320
-		if ( $this->_total_updates > 0 ) {
321
-			EE_Error::add_success( sprintf(__("%s existing records in the database were updated.", "event_espresso"),$this->_total_updates));
320
+		if ($this->_total_updates > 0) {
321
+			EE_Error::add_success(sprintf(__("%s existing records in the database were updated.", "event_espresso"), $this->_total_updates));
322 322
 			$success = true;
323 323
 		}
324
-		if ( $this->_total_inserts > 0 ) {
325
-			EE_Error::add_success(sprintf(__("%s new records were added to the database.", "event_espresso"),$this->_total_inserts));
324
+		if ($this->_total_inserts > 0) {
325
+			EE_Error::add_success(sprintf(__("%s new records were added to the database.", "event_espresso"), $this->_total_inserts));
326 326
 			$success = true;
327 327
 		}
328 328
 
329
-		if ( $this->_total_update_errors > 0 ) {
330
-			EE_Error::add_error(sprintf(__("'One or more errors occurred, and a total of %s existing records in the database were <strong>not</strong> updated.'", "event_espresso"),$this->_total_update_errors), __FILE__, __FUNCTION__, __LINE__ );
329
+		if ($this->_total_update_errors > 0) {
330
+			EE_Error::add_error(sprintf(__("'One or more errors occurred, and a total of %s existing records in the database were <strong>not</strong> updated.'", "event_espresso"), $this->_total_update_errors), __FILE__, __FUNCTION__, __LINE__);
331 331
 			$error = true;
332 332
 		}
333
-		if ( $this->_total_insert_errors > 0 ) {
334
-			EE_Error::add_error(sprintf(__("One or more errors occurred, and a total of %s new records were <strong>not</strong> added to the database.'", "event_espresso"),$this->_total_insert_errors), __FILE__, __FUNCTION__, __LINE__ );
333
+		if ($this->_total_insert_errors > 0) {
334
+			EE_Error::add_error(sprintf(__("One or more errors occurred, and a total of %s new records were <strong>not</strong> added to the database.'", "event_espresso"), $this->_total_insert_errors), __FILE__, __FUNCTION__, __LINE__);
335 335
 			$error = true;
336 336
 		}
337 337
 
338 338
 		//lastly, we need to update the datetime and ticket sold amounts
339 339
 		//as those may ahve been affected by this
340
-		EEM_Datetime::instance()->update_sold( EEM_Datetime::instance()->get_all() );
340
+		EEM_Datetime::instance()->update_sold(EEM_Datetime::instance()->get_all());
341 341
 		EEM_Ticket::instance()->update_tickets_sold(EEM_Ticket::instance()->get_all());
342 342
 
343 343
 		// if there was at least one success and absolutely no errors
344
-		if ( $success && ! $error ) {
344
+		if ($success && ! $error) {
345 345
 			return TRUE;
346 346
 		} else {
347 347
 			return FALSE;
@@ -373,81 +373,81 @@  discard block
 block discarded – undo
373 373
 	 * @param type $old_db_to_new_db_mapping
374 374
 	 * @return array updated $old_db_to_new_db_mapping
375 375
 	 */
376
-	public function save_data_rows_to_db( $csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping ) {
377
-		foreach ( $csv_data_array as $model_name_in_csv_data => $model_data_from_import ) {
376
+	public function save_data_rows_to_db($csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping) {
377
+		foreach ($csv_data_array as $model_name_in_csv_data => $model_data_from_import) {
378 378
 			//now check that assumption was correct. If
379
-			if ( EE_Registry::instance()->is_model_name($model_name_in_csv_data)) {
379
+			if (EE_Registry::instance()->is_model_name($model_name_in_csv_data)) {
380 380
 				$model_name = $model_name_in_csv_data;
381
-			}else {
381
+			} else {
382 382
 				// no table info in the array and no table name passed to the function?? FAIL
383
-				EE_Error::add_error( __('No table information was specified and/or found, therefore the import could not be completed','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
383
+				EE_Error::add_error(__('No table information was specified and/or found, therefore the import could not be completed', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
384 384
 				return FALSE;
385 385
 			}
386 386
 			/* @var $model EEM_Base */
387 387
 			$model = EE_Registry::instance()->load_model($model_name);
388 388
 
389 389
 			//so without further ado, scanning all the data provided for primary keys and their inital values
390
-			foreach ( $model_data_from_import as $model_object_data ) {
390
+			foreach ($model_data_from_import as $model_object_data) {
391 391
 				//before we do ANYTHING, make sure the csv row wasn't just completely blank
392 392
 				$row_is_completely_empty = true;
393
-				foreach($model_object_data as $field){
394
-					if($field){
393
+				foreach ($model_object_data as $field) {
394
+					if ($field) {
395 395
 						$row_is_completely_empty = false;
396 396
 					}
397 397
 				}
398
-				if($row_is_completely_empty){
398
+				if ($row_is_completely_empty) {
399 399
 					continue;
400 400
 				}
401 401
 				//find the PK in the row of data (or a combined key if
402 402
 				//there is no primary key)
403
-				if($model->has_primary_key_field()){
404
-					$id_in_csv =  $model_object_data[$model->primary_key_name()];
405
-				}else{
403
+				if ($model->has_primary_key_field()) {
404
+					$id_in_csv = $model_object_data[$model->primary_key_name()];
405
+				} else {
406 406
 					$id_in_csv = $model->get_index_primary_key_string($model_object_data);
407 407
 				}
408 408
 
409 409
 
410
-				$model_object_data = $this->_replace_temp_ids_with_mappings( $model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b );
410
+				$model_object_data = $this->_replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b);
411 411
 				//now we need to decide if we're going to add a new model object given the $model_object_data,
412 412
 				//or just update.
413
-				if($export_from_site_a_to_b){
414
-					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
415
-				}else{//this is just a re-import
416
-					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
413
+				if ($export_from_site_a_to_b) {
414
+					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
415
+				} else {//this is just a re-import
416
+					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
417 417
 				}
418
-				if( $what_to_do == self::do_nothing ) {
418
+				if ($what_to_do == self::do_nothing) {
419 419
 					continue;
420 420
 				}
421 421
 
422 422
 				//double-check we actually want to insert, if that's what we're planning
423 423
 				//based on whether this item would be unique in the DB or not
424
-				if( $what_to_do == self::do_insert ) {
424
+				if ($what_to_do == self::do_insert) {
425 425
 					//we're supposed to be inserting. But wait, will this thing
426 426
 					//be acceptable if inserted?
427
-					$conflicting = $model->get_one_conflicting( $model_object_data, false );
428
-					if($conflicting){
427
+					$conflicting = $model->get_one_conflicting($model_object_data, false);
428
+					if ($conflicting) {
429 429
 						//ok, this item would conflict if inserted. Just update the item that it conflicts with.
430 430
 						$what_to_do = self::do_update;
431 431
 						//and if this model has a primary key, remember its mapping
432
-						if($model->has_primary_key_field()){
432
+						if ($model->has_primary_key_field()) {
433 433
 							$old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID();
434 434
 							$model_object_data[$model->primary_key_name()] = $conflicting->ID();
435
-						}else{
435
+						} else {
436 436
 							//we want to update this conflicting item, instead of inserting a conflicting item
437 437
 							//so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields
438 438
 							//for the WHERE conditions in the update). At the time of this comment, there were no models like this
439
-							foreach($model->get_combined_primary_key_fields() as $key_field){
439
+							foreach ($model->get_combined_primary_key_fields() as $key_field) {
440 440
 								$model_object_data[$key_field->get_name()] = $conflicting->get($key_field->get_name());
441 441
 							}
442 442
 						}
443 443
 					}
444 444
 				}
445
-				if( $what_to_do == self::do_insert ) {
446
-					$old_db_to_new_db_mapping = $this->_insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
447
-				}elseif( $what_to_do == self::do_update ) {
448
-					$old_db_to_new_db_mapping = $this->_update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
449
-				}else{
450
-					throw new EE_Error( sprintf( __( 'Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso' ), $what_to_do ) );
445
+				if ($what_to_do == self::do_insert) {
446
+					$old_db_to_new_db_mapping = $this->_insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
447
+				}elseif ($what_to_do == self::do_update) {
448
+					$old_db_to_new_db_mapping = $this->_update_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
449
+				} else {
450
+					throw new EE_Error(sprintf(__('Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso'), $what_to_do));
451 451
 				}
452 452
 			}
453 453
 		}
@@ -468,13 +468,13 @@  discard block
 block discarded – undo
468 468
 	 * @param array $old_db_to_new_db_mapping by reference so it can be modified
469 469
 	 * @return string one of the consts on this class that starts with do_*
470 470
 	 */
471
-	protected function _decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) {
471
+	protected function _decide_whether_to_insert_or_update_given_data_from_other_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) {
472 472
 		$model_name = $model->get_this_model_name();
473 473
 		//if it's a site-to-site export-and-import, see if this modelobject's id
474 474
 		//in the old data that we know of
475
-		if( isset($old_db_to_new_db_mapping[$model_name][$id_in_csv]) ){
475
+		if (isset($old_db_to_new_db_mapping[$model_name][$id_in_csv])) {
476 476
 			return self::do_update;
477
-		}else{
477
+		} else {
478 478
 			return self::do_insert;
479 479
 		}
480 480
 	}
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 	 * @param type $old_db_to_new_db_mapping
490 490
 	 * @return
491 491
 	 */
492
-	protected function _decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model ) {
492
+	protected function _decide_whether_to_insert_or_update_given_data_from_same_db($id_in_csv, $model_object_data, $model) {
493 493
 		//in this case, check if this thing ACTUALLY exists in the database
494
-		if( $model->get_one_conflicting( $model_object_data ) ){
494
+		if ($model->get_one_conflicting($model_object_data)) {
495 495
 			return self::do_update;
496
-		}else{
496
+		} else {
497 497
 			return self::do_insert;
498 498
 		}
499 499
 	}
@@ -512,55 +512,55 @@  discard block
 block discarded – undo
512 512
 	 * @param boolean $export_from_site_a_to_b
513 513
 	 * @return array updated model object data with temp IDs removed
514 514
 	 */
515
-	protected function _replace_temp_ids_with_mappings( $model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b ) {
515
+	protected function _replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
516 516
 		//if this model object's primary key is in the mapping, replace it
517
-		if( $model->has_primary_key_field() &&
517
+		if ($model->has_primary_key_field() &&
518 518
 				$model->get_primary_key_field()->is_auto_increment() &&
519
-				isset( $old_db_to_new_db_mapping[ $model->get_this_model_name() ] ) &&
520
-				isset( $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $model_object_data[ $model->primary_key_name() ] ] ) ) {
521
-			$model_object_data[ $model->primary_key_name() ] = $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $model_object_data[ $model->primary_key_name() ] ];
519
+				isset($old_db_to_new_db_mapping[$model->get_this_model_name()]) &&
520
+				isset($old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]])) {
521
+			$model_object_data[$model->primary_key_name()] = $old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]];
522 522
 		}
523 523
 
524
-		try{
524
+		try {
525 525
 			$model_name_field = $model->get_field_containing_related_model_name();
526 526
 			$models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to();
527
-		}catch( EE_Error $e ){
527
+		} catch (EE_Error $e) {
528 528
 			$model_name_field = NULL;
529 529
 			$models_pointed_to_by_model_name_field = array();
530 530
 		}
531
-		foreach( $model->field_settings( true )  as $field_obj ){
532
-			if( $field_obj instanceof EE_Foreign_Key_Int_Field ) {
531
+		foreach ($model->field_settings(true)  as $field_obj) {
532
+			if ($field_obj instanceof EE_Foreign_Key_Int_Field) {
533 533
 				$models_pointed_to = $field_obj->get_model_names_pointed_to();
534 534
 				$found_a_mapping = false;
535
-				foreach( $models_pointed_to as $model_pointed_to_by_fk ) {
535
+				foreach ($models_pointed_to as $model_pointed_to_by_fk) {
536 536
 
537
-					if( $model_name_field ){
538
-						$value_of_model_name_field = $model_object_data[ $model_name_field->get_name() ];
539
-						if( $value_of_model_name_field == $model_pointed_to_by_fk ) {
540
-							$model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in(
541
-									$model_object_data[ $field_obj->get_name() ],
537
+					if ($model_name_field) {
538
+						$value_of_model_name_field = $model_object_data[$model_name_field->get_name()];
539
+						if ($value_of_model_name_field == $model_pointed_to_by_fk) {
540
+							$model_object_data[$field_obj->get_name()] = $this->_find_mapping_in(
541
+									$model_object_data[$field_obj->get_name()],
542 542
 									$model_pointed_to_by_fk,
543 543
 									$old_db_to_new_db_mapping,
544 544
 									$export_from_site_a_to_b );
545 545
 								$found_a_mapping = true;
546 546
 								break;
547 547
 						}
548
-					}else{
549
-						$model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in(
550
-								$model_object_data[ $field_obj->get_name() ],
548
+					} else {
549
+						$model_object_data[$field_obj->get_name()] = $this->_find_mapping_in(
550
+								$model_object_data[$field_obj->get_name()],
551 551
 								$model_pointed_to_by_fk,
552 552
 								$old_db_to_new_db_mapping,
553 553
 								$export_from_site_a_to_b );
554 554
 						$found_a_mapping = true;
555 555
 					}
556 556
 					//once we've found a mapping for this field no need to continue
557
-					if( $found_a_mapping ) {
557
+					if ($found_a_mapping) {
558 558
 						break;
559 559
 					}
560 560
 
561 561
 
562 562
 				}
563
-			}else{
563
+			} else {
564 564
 				//it's a string foreign key (which we leave alone, because those are things
565 565
 				//like country names, which we'd really rather not make 2 USAs etc (we'd actually
566 566
 				//prefer to just update one)
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 			}
569 569
 		}
570 570
 		//
571
-		if( $model instanceof EEM_Term_Taxonomy ){
572
-			$model_object_data = $this->_handle_split_term_ids( $model_object_data );
571
+		if ($model instanceof EEM_Term_Taxonomy) {
572
+			$model_object_data = $this->_handle_split_term_ids($model_object_data);
573 573
 		}
574 574
 		return $model_object_data;
575 575
 	}
@@ -581,11 +581,11 @@  discard block
 block discarded – undo
581 581
 	 * @param type $model_object_data
582 582
 	 * @return array new model object data
583 583
 	 */
584
-	protected function _handle_split_term_ids( $model_object_data ){
585
-		if( isset( $model_object_data['term_id'] ) && isset( $model_object_data[ 'taxonomy' ]) && apply_filters( 'FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists( 'wp_get_split_term' ), $model_object_data ) ) {
586
-			$new_term_id = wp_get_split_term( $model_object_data[ 'term_id' ], $model_object_data[ 'taxonomy' ] );
587
-			if( $new_term_id ){
588
-				$model_object_data[ 'term_id' ] = $new_term_id;
584
+	protected function _handle_split_term_ids($model_object_data) {
585
+		if (isset($model_object_data['term_id']) && isset($model_object_data['taxonomy']) && apply_filters('FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists('wp_get_split_term'), $model_object_data)) {
586
+			$new_term_id = wp_get_split_term($model_object_data['term_id'], $model_object_data['taxonomy']);
587
+			if ($new_term_id) {
588
+				$model_object_data['term_id'] = $new_term_id;
589 589
 			}
590 590
 		}
591 591
 		return $model_object_data;
@@ -599,18 +599,18 @@  discard block
 block discarded – undo
599 599
 	 * @param type $export_from_site_a_to_b
600 600
 	 * @return int
601 601
 	 */
602
-	protected function _find_mapping_in( $object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
603
-		if(	isset( $old_db_to_new_db_mapping[ $model_name ][ $object_id ] ) ){
602
+	protected function _find_mapping_in($object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
603
+		if (isset($old_db_to_new_db_mapping[$model_name][$object_id])) {
604 604
 
605
-				return $old_db_to_new_db_mapping[ $model_name ][ $object_id ];
606
-			}elseif( $object_id == '0' || $object_id == '' ) {
605
+				return $old_db_to_new_db_mapping[$model_name][$object_id];
606
+			}elseif ($object_id == '0' || $object_id == '') {
607 607
 				//leave as-is
608 608
 				return $object_id;
609
-			}elseif( $export_from_site_a_to_b ){
609
+			}elseif ($export_from_site_a_to_b) {
610 610
 				//we couldn't find a mapping for this, and it's from a different site,
611 611
 				//so blank it out
612 612
 				return NULL;
613
-			}elseif( ! $export_from_site_a_to_b ) {
613
+			}elseif ( ! $export_from_site_a_to_b) {
614 614
 				//we coudln't find a mapping for this, but it's from thsi DB anyway
615 615
 				//so let's just leave it as-is
616 616
 				return $object_id;
@@ -625,36 +625,36 @@  discard block
 block discarded – undo
625 625
 	 * @param type $old_db_to_new_db_mapping
626 626
 	 * @return array updated $old_db_to_new_db_mapping
627 627
 	 */
628
-	protected function _insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) {
628
+	protected function _insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) {
629 629
 		//remove the primary key, if there is one (we don't want it for inserts OR updates)
630 630
 		//we'll put it back in if we need it
631
-		if($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()){
631
+		if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()) {
632 632
 			$effective_id = $model_object_data[$model->primary_key_name()];
633 633
 			unset($model_object_data[$model->primary_key_name()]);
634
-		}else{
635
-			$effective_id = $model->get_index_primary_key_string( $model_object_data );
634
+		} else {
635
+			$effective_id = $model->get_index_primary_key_string($model_object_data);
636 636
 		}
637 637
 		//the model takes care of validating the CSV's input
638
-		try{
638
+		try {
639 639
 			$new_id = $model->insert($model_object_data);
640
-			if( $new_id ){
640
+			if ($new_id) {
641 641
 				$old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id;
642 642
 				$this->_total_inserts++;
643
-				EE_Error::add_success( sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"),$model->get_this_model_name(),$new_id, implode(",",$model_object_data)));
644
-			}else{
643
+				EE_Error::add_success(sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"), $model->get_this_model_name(), $new_id, implode(",", $model_object_data)));
644
+			} else {
645 645
 				$this->_total_insert_errors++;
646 646
 				//put the ID used back in there for the error message
647
-				if($model->has_primary_key_field()){
647
+				if ($model->has_primary_key_field()) {
648 648
 					$model_object_data[$model->primary_key_name()] = $effective_id;
649 649
 				}
650
-				EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__ );
650
+				EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__);
651 651
 			}
652
-		}catch(EE_Error $e){
652
+		} catch (EE_Error $e) {
653 653
 			$this->_total_insert_errors++;
654
-			if($model->has_primary_key_field()){
654
+			if ($model->has_primary_key_field()) {
655 655
 				$model_object_data[$model->primary_key_name()] = $effective_id;
656 656
 			}
657
-			EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage()), __FILE__, __FUNCTION__, __LINE__ );
657
+			EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
658 658
 		}
659 659
 		return $old_db_to_new_db_mapping;
660 660
 	}
@@ -667,55 +667,55 @@  discard block
 block discarded – undo
667 667
 	 * @param array $old_db_to_new_db_mapping
668 668
 	 * @return array updated $old_db_to_new_db_mapping
669 669
 	 */
670
-	protected function _update_from_data_array( $id_in_csv,  $model_object_data, $model, $old_db_to_new_db_mapping ) {
671
-		try{
670
+	protected function _update_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) {
671
+		try {
672 672
 			//let's keep two copies of the model object data:
673 673
 			//one for performing an update, one for everthing else
674 674
 			$model_object_data_for_update = $model_object_data;
675
-			if($model->has_primary_key_field()){
675
+			if ($model->has_primary_key_field()) {
676 676
 				$conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]);
677 677
 				//remove the primary key because we shouldn't use it for updating
678 678
 				unset($model_object_data_for_update[$model->primary_key_name()]);
679
-			}elseif($model->get_combined_primary_key_fields() > 1 ){
679
+			}elseif ($model->get_combined_primary_key_fields() > 1) {
680 680
 				$conditions = array();
681
-				foreach($model->get_combined_primary_key_fields() as $key_field){
681
+				foreach ($model->get_combined_primary_key_fields() as $key_field) {
682 682
 					$conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()];
683 683
 				}
684
-			}else{
685
-				$model->primary_key_name();//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
684
+			} else {
685
+				$model->primary_key_name(); //this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
686 686
 			}
687 687
 
688
-			$success = $model->update($model_object_data_for_update,array($conditions));
689
-			if($success){
688
+			$success = $model->update($model_object_data_for_update, array($conditions));
689
+			if ($success) {
690 690
 				$this->_total_updates++;
691
-				EE_Error::add_success( sprintf(__("Successfully updated %s with csv data %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data_for_update)));
691
+				EE_Error::add_success(sprintf(__("Successfully updated %s with csv data %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data_for_update)));
692 692
 				//we should still record the mapping even though it was an update
693 693
 				//because if we were going to insert somethign but it was going to conflict
694 694
 				//we would have last-minute decided to update. So we'd like to know what we updated
695 695
 				//and so we record what record ended up being updated using the mapping
696
-				if( $model->has_primary_key_field() ){
697
-					$new_key_for_mapping = $model_object_data[ $model->primary_key_name() ];
698
-				}else{
696
+				if ($model->has_primary_key_field()) {
697
+					$new_key_for_mapping = $model_object_data[$model->primary_key_name()];
698
+				} else {
699 699
 					//no primary key just a combined key
700
-					$new_key_for_mapping = $model->get_index_primary_key_string( $model_object_data );
700
+					$new_key_for_mapping = $model->get_index_primary_key_string($model_object_data);
701 701
 				}
702
-				$old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $id_in_csv ] = $new_key_for_mapping;
703
-			}else{
702
+				$old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_key_for_mapping;
703
+			} else {
704 704
 				$matched_items = $model->get_all(array($conditions));
705
-				if( ! $matched_items){
705
+				if ( ! $matched_items) {
706 706
 					//no items were matched (so we shouldn't have updated)... but then we should have inserted? what the heck?
707 707
 					$this->_total_update_errors++;
708
-					EE_Error::add_error( sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data),http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__ );
709
-				}else{
708
+					EE_Error::add_error(sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data), http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__);
709
+				} else {
710 710
 					$this->_total_updates++;
711
-					EE_Error::add_success( sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data)));
711
+					EE_Error::add_success(sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data)));
712 712
 				}
713 713
 			}
714
-		}catch(EE_Error $e){
714
+		} catch (EE_Error $e) {
715 715
 			$this->_total_update_errors++;
716
-			$basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage());
717
-			$debug_message = $basic_message . ' Stack trace: ' . $e->getTraceAsString();
718
-			EE_Error::add_error( "$basic_message | $debug_message", __FILE__, __FUNCTION__, __LINE__ );
716
+			$basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage());
717
+			$debug_message = $basic_message.' Stack trace: '.$e->getTraceAsString();
718
+			EE_Error::add_error("$basic_message | $debug_message", __FILE__, __FUNCTION__, __LINE__);
719 719
 		}
720 720
 		return $old_db_to_new_db_mapping;
721 721
 	}
@@ -724,28 +724,28 @@  discard block
 block discarded – undo
724 724
 	 * Gets the number of inserts performed since importer was instantiated or reset
725 725
 	 * @return int
726 726
 	 */
727
-	public function get_total_inserts(){
727
+	public function get_total_inserts() {
728 728
 		return $this->_total_inserts;
729 729
 	}
730 730
 	/**
731 731
 	 *  Gets the number of insert errors since importer was instantiated or reset
732 732
 	 * @return int
733 733
 	 */
734
-	public function get_total_insert_errors(){
734
+	public function get_total_insert_errors() {
735 735
 		return $this->_total_insert_errors;
736 736
 	}
737 737
 	/**
738 738
 	 *  Gets the number of updates performed since importer was instantiated or reset
739 739
 	 * @return int
740 740
 	 */
741
-	public function get_total_updates(){
741
+	public function get_total_updates() {
742 742
 		return $this->_total_updates;
743 743
 	}
744 744
 	/**
745 745
 	 *  Gets the number of update errors since importer was instantiated or reset
746 746
 	 * @return int
747 747
 	 */
748
-	public function get_total_update_errors(){
748
+	public function get_total_update_errors() {
749 749
 		return $this->_total_update_errors;
750 750
 	}
751 751
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\ResettableInterface;
2 2
 
3
-if (!defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
3
+if (!defined( 'EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5
+}
4 6
 do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
5 7
 /**
6 8
  * EE_Import class
@@ -297,7 +299,7 @@  discard block
 block discarded – undo
297 299
 			if(isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()){
298 300
 				EE_Error::add_attention(sprintf(__("CSV Data appears to be from the same database, so attempting to update data", "event_espresso")));
299 301
 				$export_from_site_a_to_b = false;
300
-			}else{
302
+			} else{
301 303
 				$old_site_url = isset( $csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url;
302 304
 				EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"),$old_site_url,site_url()));
303 305
 			};
@@ -378,7 +380,7 @@  discard block
 block discarded – undo
378 380
 			//now check that assumption was correct. If
379 381
 			if ( EE_Registry::instance()->is_model_name($model_name_in_csv_data)) {
380 382
 				$model_name = $model_name_in_csv_data;
381
-			}else {
383
+			} else {
382 384
 				// no table info in the array and no table name passed to the function?? FAIL
383 385
 				EE_Error::add_error( __('No table information was specified and/or found, therefore the import could not be completed','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
384 386
 				return FALSE;
@@ -402,7 +404,7 @@  discard block
 block discarded – undo
402 404
 				//there is no primary key)
403 405
 				if($model->has_primary_key_field()){
404 406
 					$id_in_csv =  $model_object_data[$model->primary_key_name()];
405
-				}else{
407
+				} else{
406 408
 					$id_in_csv = $model->get_index_primary_key_string($model_object_data);
407 409
 				}
408 410
 
@@ -412,7 +414,7 @@  discard block
 block discarded – undo
412 414
 				//or just update.
413 415
 				if($export_from_site_a_to_b){
414 416
 					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
415
-				}else{//this is just a re-import
417
+				} else{//this is just a re-import
416 418
 					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
417 419
 				}
418 420
 				if( $what_to_do == self::do_nothing ) {
@@ -432,7 +434,7 @@  discard block
 block discarded – undo
432 434
 						if($model->has_primary_key_field()){
433 435
 							$old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID();
434 436
 							$model_object_data[$model->primary_key_name()] = $conflicting->ID();
435
-						}else{
437
+						} else{
436 438
 							//we want to update this conflicting item, instead of inserting a conflicting item
437 439
 							//so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields
438 440
 							//for the WHERE conditions in the update). At the time of this comment, there were no models like this
@@ -444,9 +446,9 @@  discard block
 block discarded – undo
444 446
 				}
445 447
 				if( $what_to_do == self::do_insert ) {
446 448
 					$old_db_to_new_db_mapping = $this->_insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
447
-				}elseif( $what_to_do == self::do_update ) {
449
+				} elseif( $what_to_do == self::do_update ) {
448 450
 					$old_db_to_new_db_mapping = $this->_update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
449
-				}else{
451
+				} else{
450 452
 					throw new EE_Error( sprintf( __( 'Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso' ), $what_to_do ) );
451 453
 				}
452 454
 			}
@@ -474,7 +476,7 @@  discard block
 block discarded – undo
474 476
 		//in the old data that we know of
475 477
 		if( isset($old_db_to_new_db_mapping[$model_name][$id_in_csv]) ){
476 478
 			return self::do_update;
477
-		}else{
479
+		} else{
478 480
 			return self::do_insert;
479 481
 		}
480 482
 	}
@@ -493,7 +495,7 @@  discard block
 block discarded – undo
493 495
 		//in this case, check if this thing ACTUALLY exists in the database
494 496
 		if( $model->get_one_conflicting( $model_object_data ) ){
495 497
 			return self::do_update;
496
-		}else{
498
+		} else{
497 499
 			return self::do_insert;
498 500
 		}
499 501
 	}
@@ -524,7 +526,7 @@  discard block
 block discarded – undo
524 526
 		try{
525 527
 			$model_name_field = $model->get_field_containing_related_model_name();
526 528
 			$models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to();
527
-		}catch( EE_Error $e ){
529
+		} catch( EE_Error $e ){
528 530
 			$model_name_field = NULL;
529 531
 			$models_pointed_to_by_model_name_field = array();
530 532
 		}
@@ -545,7 +547,7 @@  discard block
 block discarded – undo
545 547
 								$found_a_mapping = true;
546 548
 								break;
547 549
 						}
548
-					}else{
550
+					} else{
549 551
 						$model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in(
550 552
 								$model_object_data[ $field_obj->get_name() ],
551 553
 								$model_pointed_to_by_fk,
@@ -560,7 +562,7 @@  discard block
 block discarded – undo
560 562
 
561 563
 
562 564
 				}
563
-			}else{
565
+			} else{
564 566
 				//it's a string foreign key (which we leave alone, because those are things
565 567
 				//like country names, which we'd really rather not make 2 USAs etc (we'd actually
566 568
 				//prefer to just update one)
@@ -603,14 +605,14 @@  discard block
 block discarded – undo
603 605
 		if(	isset( $old_db_to_new_db_mapping[ $model_name ][ $object_id ] ) ){
604 606
 
605 607
 				return $old_db_to_new_db_mapping[ $model_name ][ $object_id ];
606
-			}elseif( $object_id == '0' || $object_id == '' ) {
608
+			} elseif( $object_id == '0' || $object_id == '' ) {
607 609
 				//leave as-is
608 610
 				return $object_id;
609
-			}elseif( $export_from_site_a_to_b ){
611
+			} elseif( $export_from_site_a_to_b ){
610 612
 				//we couldn't find a mapping for this, and it's from a different site,
611 613
 				//so blank it out
612 614
 				return NULL;
613
-			}elseif( ! $export_from_site_a_to_b ) {
615
+			} elseif( ! $export_from_site_a_to_b ) {
614 616
 				//we coudln't find a mapping for this, but it's from thsi DB anyway
615 617
 				//so let's just leave it as-is
616 618
 				return $object_id;
@@ -631,7 +633,7 @@  discard block
 block discarded – undo
631 633
 		if($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()){
632 634
 			$effective_id = $model_object_data[$model->primary_key_name()];
633 635
 			unset($model_object_data[$model->primary_key_name()]);
634
-		}else{
636
+		} else{
635 637
 			$effective_id = $model->get_index_primary_key_string( $model_object_data );
636 638
 		}
637 639
 		//the model takes care of validating the CSV's input
@@ -641,7 +643,7 @@  discard block
 block discarded – undo
641 643
 				$old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id;
642 644
 				$this->_total_inserts++;
643 645
 				EE_Error::add_success( sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"),$model->get_this_model_name(),$new_id, implode(",",$model_object_data)));
644
-			}else{
646
+			} else{
645 647
 				$this->_total_insert_errors++;
646 648
 				//put the ID used back in there for the error message
647 649
 				if($model->has_primary_key_field()){
@@ -649,7 +651,7 @@  discard block
 block discarded – undo
649 651
 				}
650 652
 				EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__ );
651 653
 			}
652
-		}catch(EE_Error $e){
654
+		} catch(EE_Error $e){
653 655
 			$this->_total_insert_errors++;
654 656
 			if($model->has_primary_key_field()){
655 657
 				$model_object_data[$model->primary_key_name()] = $effective_id;
@@ -676,12 +678,12 @@  discard block
 block discarded – undo
676 678
 				$conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]);
677 679
 				//remove the primary key because we shouldn't use it for updating
678 680
 				unset($model_object_data_for_update[$model->primary_key_name()]);
679
-			}elseif($model->get_combined_primary_key_fields() > 1 ){
681
+			} elseif($model->get_combined_primary_key_fields() > 1 ){
680 682
 				$conditions = array();
681 683
 				foreach($model->get_combined_primary_key_fields() as $key_field){
682 684
 					$conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()];
683 685
 				}
684
-			}else{
686
+			} else{
685 687
 				$model->primary_key_name();//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
686 688
 			}
687 689
 
@@ -695,23 +697,23 @@  discard block
 block discarded – undo
695 697
 				//and so we record what record ended up being updated using the mapping
696 698
 				if( $model->has_primary_key_field() ){
697 699
 					$new_key_for_mapping = $model_object_data[ $model->primary_key_name() ];
698
-				}else{
700
+				} else{
699 701
 					//no primary key just a combined key
700 702
 					$new_key_for_mapping = $model->get_index_primary_key_string( $model_object_data );
701 703
 				}
702 704
 				$old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $id_in_csv ] = $new_key_for_mapping;
703
-			}else{
705
+			} else{
704 706
 				$matched_items = $model->get_all(array($conditions));
705 707
 				if( ! $matched_items){
706 708
 					//no items were matched (so we shouldn't have updated)... but then we should have inserted? what the heck?
707 709
 					$this->_total_update_errors++;
708 710
 					EE_Error::add_error( sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data),http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__ );
709
-				}else{
711
+				} else{
710 712
 					$this->_total_updates++;
711 713
 					EE_Error::add_success( sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data)));
712 714
 				}
713 715
 			}
714
-		}catch(EE_Error $e){
716
+		} catch(EE_Error $e){
715 717
 			$this->_total_update_errors++;
716 718
 			$basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage());
717 719
 			$debug_message = $basic_message . ' Stack trace: ' . $e->getTraceAsString();
Please login to merge, or discard this patch.
core/db_classes/EE_Question_Form_Input.class.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 *        generate_question_form_inputs_for_object
227 227
 	 *
228 228
 	 * @access    protected
229
-	 * @param bool|object $object $object
229
+	 * @param EE_Base_Class|null $object $object
230 230
 	 * @param    array    $input_types
231 231
 	 * @return        array
232 232
 	 */
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 *    add_temp_option
325 325
 	 * @access public
326 326
 	 * @param \EE_Question_Option $QSO EE_Question_Option
327
-	 * @return boolean
327
+	 * @return boolean|null
328 328
 	 */
329 329
 	public function add_temp_option( EE_Question_Option $QSO ) {
330 330
 		$this->_QST->add_temp_option( $QSO );
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * set property values for question form input
337 337
 	 * @access public
338 338
 	 * @param    string $property
339
-	 * @param    mixed  $value
340
-	 * @return mixed
339
+	 * @param    boolean  $value
340
+	 * @return boolean|null
341 341
 	 */
342 342
 	public function set( $property = NULL, $value = NULL ) {
343 343
 		if ( ! empty( $property ) ) {
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 *    get_meta
378 378
 	 * @access public
379
-	 * @param mixed $key
379
+	 * @param string $key
380 380
 	 * @return mixed
381 381
 	 */
382 382
 	public function get_meta( $key = FALSE ) {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 * @access public
83 83
 	 * @return \EE_Question_Form_Input
84 84
 	 */
85
-	public function __construct( EE_Question $QST = NULL, EE_Answer $ANS = NULL, $q_meta = array() ) {
86
-		if ( empty( $QST ) || empty( $ANS ) ) {
87
-			EE_Error::add_error( __( 'An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
85
+	public function __construct(EE_Question $QST = NULL, EE_Answer $ANS = NULL, $q_meta = array()) {
86
+		if (empty($QST) || empty($ANS)) {
87
+			EE_Error::add_error(__('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
88 88
 			return NULL;
89 89
 		}
90 90
 		$this->_QST = $QST;
91 91
 		$this->_ANS = $ANS;
92
-		$this->set_question_form_input_meta( $q_meta );
92
+		$this->set_question_form_input_meta($q_meta);
93 93
 		$this->set_question_form_input_init();
94 94
 	}
95 95
 
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param array $q_meta
102 102
 	 * @return void
103 103
 	 */
104
-	public function set_question_form_input_meta( $q_meta = array() ) {
105
-		$default_q_meta = array( 'att_nmbr' => 1, 'ticket_id' => '', 'date' => '', 'time' => '', 'input_name' => '', 'input_id' => '', 'input_class' => '', 'input_prefix' => 'qstn', 'append_qstn_id' => TRUE, 'htmlentities' => TRUE, 'allow_null' => FALSE );
106
-		$this->_QST_meta = array_merge( $default_q_meta, $q_meta );
104
+	public function set_question_form_input_meta($q_meta = array()) {
105
+		$default_q_meta = array('att_nmbr' => 1, 'ticket_id' => '', 'date' => '', 'time' => '', 'input_name' => '', 'input_id' => '', 'input_class' => '', 'input_prefix' => 'qstn', 'append_qstn_id' => TRUE, 'htmlentities' => TRUE, 'allow_null' => FALSE);
106
+		$this->_QST_meta = array_merge($default_q_meta, $q_meta);
107 107
 	}
108 108
 
109 109
 
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function set_question_form_input_init() {
117 117
 		$qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID();
118
-		$this->_set_input_name( $qstn_id );
119
-		$this->_set_input_id( $qstn_id );
120
-		$this->_set_input_class( $qstn_id );
121
-		$this->set_question_form_input_answer( $qstn_id );
118
+		$this->_set_input_name($qstn_id);
119
+		$this->_set_input_id($qstn_id);
120
+		$this->_set_input_class($qstn_id);
121
+		$this->set_question_form_input_answer($qstn_id);
122 122
 	}
123 123
 
124 124
 
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	 * @param $qstn_id
130 130
 	 * @return void
131 131
 	 */
132
-	private function _set_input_name( $qstn_id ) {
133
-		if ( ! empty( $qstn_id ) ) {
134
-			$ANS_ID = $this->get( 'ANS_ID' );
135
-			$qstn_id = ! empty( $ANS_ID ) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']';
132
+	private function _set_input_name($qstn_id) {
133
+		if ( ! empty($qstn_id)) {
134
+			$ANS_ID = $this->get('ANS_ID');
135
+			$qstn_id = ! empty($ANS_ID) ? '['.$qstn_id.']['.$ANS_ID.']' : '['.$qstn_id.']';
136 136
 		}
137
-		$this->QST_input_name = $this->_QST_meta[ 'append_qstn_id' ] && ! empty( $qstn_id ) ? $this->_QST_meta[ 'input_prefix' ] . $this->_QST_meta[ 'input_name' ] . $qstn_id : $this->_QST_meta[ 'input_prefix' ] . $this->_QST_meta[ 'input_name' ];
137
+		$this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) ? $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'].$qstn_id : $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'];
138 138
 	}
139 139
 
140 140
 
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 	 * @param    string $property
146 146
 	 * @return mixed
147 147
 	 */
148
-	public function get( $property = NULL ) {
149
-		if ( ! empty( $property ) ) {
150
-			if ( EEM_Question::instance()->has_field( $property ) ) {
151
-				return $this->_QST->get( $property );
152
-			} else if ( EEM_Answer::instance()->has_field( $property ) ) {
153
-				return $this->_ANS->get( $property );
154
-			} else if ( $this->_question_form_input_property_exists( __CLASS__, $property ) ) {
148
+	public function get($property = NULL) {
149
+		if ( ! empty($property)) {
150
+			if (EEM_Question::instance()->has_field($property)) {
151
+				return $this->_QST->get($property);
152
+			} else if (EEM_Answer::instance()->has_field($property)) {
153
+				return $this->_ANS->get($property);
154
+			} else if ($this->_question_form_input_property_exists(__CLASS__, $property)) {
155 155
 				return $this->{$property};
156 156
 			}
157 157
 		}
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 	 * @param    string $property
168 168
 	 * @return boolean
169 169
 	 */
170
-	private function _question_form_input_property_exists( $classname, $property ) {
170
+	private function _question_form_input_property_exists($classname, $property) {
171 171
 		// first try regular property exists method which works as expected in PHP 5.3+
172
-		$prop = EEH_Class_Tools::has_property( $classname, $property );
173
-		if ( ! $prop ) {
172
+		$prop = EEH_Class_Tools::has_property($classname, $property);
173
+		if ( ! $prop) {
174 174
 			// use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction
175
-			$reflector = new ReflectionClass( $classname );
176
-			$prop = $reflector->hasProperty( $property );
175
+			$reflector = new ReflectionClass($classname);
176
+			$prop = $reflector->hasProperty($property);
177 177
 		}
178 178
 		return $prop;
179 179
 	}
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 	 * @param $qstn_id
187 187
 	 * @return void
188 188
 	 */
189
-	private function _set_input_id( $qstn_id ) {
190
-		$input_id = isset( $this->_QST_meta[ 'input_id' ] ) && ! empty( $this->_QST_meta[ 'input_id' ] ) ? $this->_QST_meta[ 'input_id' ] : sanitize_key( strip_tags( $this->_QST->get( 'QST_display_text' ) ) );
191
-		$this->QST_input_id = $this->_QST_meta[ 'append_qstn_id' ] && ! empty( $qstn_id ) ? $input_id . '-' . $qstn_id : $input_id;
189
+	private function _set_input_id($qstn_id) {
190
+		$input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id']) ? $this->_QST_meta['input_id'] : sanitize_key(strip_tags($this->_QST->get('QST_display_text')));
191
+		$this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) ? $input_id.'-'.$qstn_id : $input_id;
192 192
 	}
193 193
 
194 194
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @return void
200 200
 	 */
201 201
 	private function _set_input_class() {
202
-		$this->QST_input_class = isset( $this->_QST_meta[ 'input_class' ] ) ? $this->_QST_meta[ 'input_class' ] : '';
202
+		$this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : '';
203 203
 	}
204 204
 
205 205
 
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 	 * @param mixed    int | string    $qstn_id
211 211
 	 * @return void
212 212
 	 */
213
-	public function set_question_form_input_answer( $qstn_id ) {
213
+	public function set_question_form_input_answer($qstn_id) {
214 214
 		// check for answer in $_REQUEST in case we are reprocessing a form after an error
215
-		if ( isset( $this->_QST_meta[ 'EVT_ID' ] ) && isset( $this->_QST_meta[ 'att_nmbr' ] ) && isset( $this->_QST_meta[ 'date' ] ) && isset( $this->_QST_meta[ 'time' ] ) && isset( $this->_QST_meta[ 'price_id' ] ) ) {
216
-			if ( isset( $_REQUEST[ 'qstn' ][ $this->_QST_meta[ 'EVT_ID' ] ][ $this->_QST_meta[ 'att_nmbr' ] ][ $this->_QST_meta[ 'date' ] ][ $this->_QST_meta[ 'time' ] ][ $this->_QST_meta[ 'price_id' ] ][ $qstn_id ] ) ) {
217
-				$answer = $_REQUEST[ 'qstn' ][ $this->_QST_meta[ 'EVT_ID' ] ][ $this->_QST_meta[ 'att_nmbr' ] ][ $this->_QST_meta[ 'date' ] ][ $this->_QST_meta[ 'time' ] ][ $this->_QST_meta[ 'price_id' ] ][ $qstn_id ];
218
-				$this->_ANS->set( 'ANS_value', $answer );
215
+		if (isset($this->_QST_meta['EVT_ID']) && isset($this->_QST_meta['att_nmbr']) && isset($this->_QST_meta['date']) && isset($this->_QST_meta['time']) && isset($this->_QST_meta['price_id'])) {
216
+			if (isset($_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id])) {
217
+				$answer = $_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id];
218
+				$this->_ANS->set('ANS_value', $answer);
219 219
 			}
220 220
 		}
221 221
 	}
@@ -230,40 +230,40 @@  discard block
 block discarded – undo
230 230
 	 * @param    array    $input_types
231 231
 	 * @return        array
232 232
 	 */
233
-	static function generate_question_form_inputs_for_object( $object = FALSE, $input_types = array() ) {
234
-		if ( ! is_object( $object ) ) {
233
+	static function generate_question_form_inputs_for_object($object = FALSE, $input_types = array()) {
234
+		if ( ! is_object($object)) {
235 235
 			return FALSE;
236 236
 		}
237 237
 		$inputs = array();
238
-		$fields = $object->get_model()->field_settings( FALSE );
238
+		$fields = $object->get_model()->field_settings(FALSE);
239 239
 		//		$pk = $object->ID(); <<< NO!
240 240
 		//		EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
241 241
 		//		EEH_Debug_Tools::printr( $fields, '$fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
242 242
 		//		EEH_Debug_Tools::printr( $input_types, '$input_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
243
-		foreach ( $fields as $field_ID => $field ) {
244
-			if ( $field instanceof EE_Model_Field_Base ) {
243
+		foreach ($fields as $field_ID => $field) {
244
+			if ($field instanceof EE_Model_Field_Base) {
245 245
 				//			echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
246 246
 				//			EEH_Debug_Tools::printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
247
-				if ( isset( $input_types[ $field_ID ] ) ) {
247
+				if (isset($input_types[$field_ID])) {
248 248
 					// get saved value for field
249
-					$value = $object->get( $field_ID );
249
+					$value = $object->get($field_ID);
250 250
 					//				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
251 251
 					// if no saved value, then use default
252 252
 					$value = $value !== NULL ? $value : $field->get_default_value();
253 253
 					//			if ( $field_ID == 'CNT_active' )
254 254
 					//				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
255 255
 					// determine question type
256
-					$type = isset( $input_types[ $field_ID ] ) ? $input_types[ $field_ID ][ 'type' ] : 'TEXT';
256
+					$type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT';
257 257
 					// input name
258
-					$input_name = isset( $input_types[ $field_ID ] ) && isset( $input_types[ $field_ID ][ 'input_name' ] ) ? $input_types[ $field_ID ][ 'input_name' ] . '[' . $field_ID . ']' : $field_ID;
258
+					$input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) ? $input_types[$field_ID]['input_name'].'['.$field_ID.']' : $field_ID;
259 259
 					// css class for input
260
-					$class = isset( $input_types[ $field_ID ][ 'class' ] ) && ! empty( $input_types[ $field_ID ][ 'class' ] ) ? ' ' . $input_types[ $field_ID ][ 'class' ] : '';
260
+					$class = isset($input_types[$field_ID]['class']) && ! empty($input_types[$field_ID]['class']) ? ' '.$input_types[$field_ID]['class'] : '';
261 261
 					// whether to apply htmlentities to answer
262
-					$htmlentities = isset( $input_types[ $field_ID ][ 'htmlentities' ] ) ? $input_types[ $field_ID ][ 'htmlentities' ] : TRUE;
262
+					$htmlentities = isset($input_types[$field_ID]['htmlentities']) ? $input_types[$field_ID]['htmlentities'] : TRUE;
263 263
 					// whether to apply htmlentities to answer
264
-					$label_b4 = isset( $input_types[ $field_ID ][ 'label_b4' ] ) ? $input_types[ $field_ID ][ 'label_b4' ] : FALSE;
264
+					$label_b4 = isset($input_types[$field_ID]['label_b4']) ? $input_types[$field_ID]['label_b4'] : FALSE;
265 265
 					// whether to apply htmlentities to answer
266
-					$use_desc_4_label = isset( $input_types[ $field_ID ][ 'use_desc_4_label' ] ) ? $input_types[ $field_ID ][ 'use_desc_4_label' ] : FALSE;
266
+					$use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) ? $input_types[$field_ID]['use_desc_4_label'] : FALSE;
267 267
 
268 268
 					// create EE_Question_Form_Input object
269 269
 					$QFI = new EE_Question_Form_Input(
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 							)
284 284
 						),
285 285
 						array(
286
-							'input_id' => $field_ID . '-' . $object->ID(),
286
+							'input_id' => $field_ID.'-'.$object->ID(),
287 287
 							'input_name' => $input_name,
288
-							'input_class' => $field_ID . $class,
288
+							'input_class' => $field_ID.$class,
289 289
 							'input_prefix' => '',
290 290
 							'append_qstn_id' => FALSE,
291 291
 							'htmlentities' => $htmlentities,
@@ -294,21 +294,21 @@  discard block
 block discarded – undo
294 294
 						)
295 295
 					);
296 296
 					// does question type have options ?
297
-					if ( in_array( $type, array( 'DROPDOWN', 'RADIO_BTN', 'CHECKBOX' ) ) && isset ( $input_types[ $field_ID ] ) && isset ( $input_types[ $field_ID ][ 'options' ] ) ) {
298
-						foreach ( $input_types[ $field_ID ][ 'options' ] as $option ) {
299
-							$option = stripslashes_deep( $option );
300
-							$option_id = ! empty( $option[ 'id' ] ) ? $option[ 'id' ] : 0;
301
-							$QSO = EE_Question_Option::new_instance( array( 'QSO_value' => (string)$option_id, 'QSO_desc' => $option[ 'text' ], 'QSO_deleted' => FALSE ) );
297
+					if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) && isset ($input_types[$field_ID]) && isset ($input_types[$field_ID]['options'])) {
298
+						foreach ($input_types[$field_ID]['options'] as $option) {
299
+							$option = stripslashes_deep($option);
300
+							$option_id = ! empty($option['id']) ? $option['id'] : 0;
301
+							$QSO = EE_Question_Option::new_instance(array('QSO_value' => (string) $option_id, 'QSO_desc' => $option['text'], 'QSO_deleted' => FALSE));
302 302
 							// all QST (and ANS) properties can be accessed indirectly thru QFI
303
-							$QFI->add_temp_option( $QSO );
303
+							$QFI->add_temp_option($QSO);
304 304
 						}
305 305
 					}
306 306
 					// we don't want ppl manually changing primary keys cuz that would just lead to total craziness man
307
-					if ( $field_ID == $object->get_model()->primary_key_name() ) {
308
-						$QFI->set( 'QST_disabled', TRUE );
307
+					if ($field_ID == $object->get_model()->primary_key_name()) {
308
+						$QFI->set('QST_disabled', TRUE);
309 309
 					}
310 310
 					//EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
311
-					$inputs[ $field_ID ] = $QFI;
311
+					$inputs[$field_ID] = $QFI;
312 312
 					//			if ( $field_ID == 'CNT_active' ) {
313 313
 					//				EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
314 314
 					//			}
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	 * @param \EE_Question_Option $QSO EE_Question_Option
327 327
 	 * @return boolean
328 328
 	 */
329
-	public function add_temp_option( EE_Question_Option $QSO ) {
330
-		$this->_QST->add_temp_option( $QSO );
329
+	public function add_temp_option(EE_Question_Option $QSO) {
330
+		$this->_QST->add_temp_option($QSO);
331 331
 	}
332 332
 
333 333
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @param    mixed  $value
340 340
 	 * @return mixed
341 341
 	 */
342
-	public function set( $property = NULL, $value = NULL ) {
343
-		if ( ! empty( $property ) ) {
344
-			if ( EEM_Question::instance()->has_field( $property ) ) {
345
-				$this->_QST->set( $property, $value );
346
-			} else if ( EEM_Answer::instance()->has_field( $property ) ) {
347
-				$this->_ANS->set( $property, $value );
348
-			} else if ( $this->_question_form_input_property_exists( __CLASS__, $property ) ) {
342
+	public function set($property = NULL, $value = NULL) {
343
+		if ( ! empty($property)) {
344
+			if (EEM_Question::instance()->has_field($property)) {
345
+				$this->_QST->set($property, $value);
346
+			} else if (EEM_Answer::instance()->has_field($property)) {
347
+				$this->_ANS->set($property, $value);
348
+			} else if ($this->_question_form_input_property_exists(__CLASS__, $property)) {
349 349
 				echo "<hr>$property is a prop of QFI";
350 350
 				$this->{$property} = $value;
351 351
 				return TRUE;
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 	 *                                                       whether it was trashed or not.
367 367
 	 * @return EE_Question_Option
368 368
 	 */
369
-	public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) {
369
+	public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) {
370 370
 		$temp_options = $this->_QST->temp_options();
371
-		return ! empty( $temp_options ) ? $temp_options : $this->_QST->options( $notDeletedOptionsOnly, $selected_value_to_always_include );
371
+		return ! empty($temp_options) ? $temp_options : $this->_QST->options($notDeletedOptionsOnly, $selected_value_to_always_include);
372 372
 	}
373 373
 
374 374
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param mixed $key
380 380
 	 * @return mixed
381 381
 	 */
382
-	public function get_meta( $key = FALSE ) {
383
-		return $key && isset( $this->_QST_meta[ $key ] ) ? $this->_QST_meta[ $key ] : FALSE;
382
+	public function get_meta($key = FALSE) {
383
+		return $key && isset($this->_QST_meta[$key]) ? $this->_QST_meta[$key] : FALSE;
384 384
 	}
385 385
 
386 386
 
Please login to merge, or discard this patch.
core/db_models/EEM_Change_Log.model.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
118 118
 	 * @param mixed $message array|string of the message you want to record
119 119
 	 * @param EE_Base_Class $related_model_obj
120
-	 * @return EE_Change_Log
120
+	 * @return EE_Attendee
121 121
 	 */
122 122
 	public function log($log_type,$message,$related_model_obj){
123 123
 		if($related_model_obj instanceof EE_Base_Class){
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param mixed $related_obj_id
146 146
 	 * @param string $related_obj_type
147 147
 	 * @throws EE_Error
148
-	 * @return EE_Change_Log
148
+	 * @return EE_Attendee
149 149
 	 */
150 150
 	public function gateway_log( $message, $related_obj_id, $related_obj_type ){
151 151
 		if( ! EE_Registry::instance()->is_model_name($related_obj_type)){
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -99,7 +100,7 @@  discard block
 block discarded – undo
99 100
 		foreach($models_this_can_attach_to as $model){
100 101
 			if( $model == 'WP_User' ){
101 102
 				$this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
102
-			}elseif( $model != 'Change_Log' ) {
103
+			} elseif( $model != 'Change_Log' ) {
103 104
 				$this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
104 105
 			}
105 106
 		}
@@ -123,7 +124,7 @@  discard block
 block discarded – undo
123 124
 		if($related_model_obj instanceof EE_Base_Class){
124 125
 			$obj_id = $related_model_obj->ID();
125 126
 			$obj_type = $related_model_obj->get_model()->get_this_model_name();
126
-		}else{
127
+		} else{
127 128
 			$obj_id = NULL;
128 129
 			$obj_type = NULL;
129 130
 		}
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Change_Log extends EEM_Base{
28
+class EEM_Change_Log extends EEM_Base {
29 29
 
30 30
 	/**
31 31
 	 * the related object was created log type
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
 	 *	@access protected
69 69
 	 *	@return EEM_Change_Log
70 70
 	 */
71
-	protected function __construct( $timezone = null ){
71
+	protected function __construct($timezone = null) {
72 72
 		global $current_user;
73
-		$this->singular_item = __('Log','event_espresso');
74
-		$this->plural_item = __('Logs','event_espresso');
73
+		$this->singular_item = __('Log', 'event_espresso');
74
+		$this->plural_item = __('Logs', 'event_espresso');
75 75
 		$this->_tables = array(
76 76
 			'Log'=> new EE_Primary_Table('esp_log', 'LOG_ID')
77 77
 		);
78 78
 		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
79 79
 		$this->_fields = array(
80 80
 			'Log'=>array(
81
-				'LOG_ID'=> new EE_Primary_Key_Int_Field('LOG_ID', __('Log ID','event_espresso')),
82
-				'LOG_time'=>new EE_Datetime_Field('LOG_time', __("Log Time", 'event_espresso'), false, EE_Datetime_Field::now ),
83
-				'OBJ_ID'=>new EE_Foreign_Key_String_Field('OBJ_ID', __("Object ID (int or string)", 'event_espresso'), true, NULL,$models_this_can_attach_to),
81
+				'LOG_ID'=> new EE_Primary_Key_Int_Field('LOG_ID', __('Log ID', 'event_espresso')),
82
+				'LOG_time'=>new EE_Datetime_Field('LOG_time', __("Log Time", 'event_espresso'), false, EE_Datetime_Field::now),
83
+				'OBJ_ID'=>new EE_Foreign_Key_String_Field('OBJ_ID', __("Object ID (int or string)", 'event_espresso'), true, NULL, $models_this_can_attach_to),
84 84
 				'OBJ_type'=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Object Type", 'event_espresso'), true, NULL, $models_this_can_attach_to),
85 85
 				'LOG_type'=>new EE_Enum_Text_Field('LOG_type', __("Type of log entry", "event_espresso"), false, self::type_debug,
86 86
 						array(
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
 							self::type_gateway=> __("Gateway Interaction (IPN or Direct Payment)", 'event_espresso'),
93 93
 							)),
94 94
 				'LOG_message'=>new EE_Maybe_Serialized_Text_Field('LOG_message', __("Log Message (body)", 'event_espresso'), true),
95
-				'LOG_wp_user' => new EE_WP_User_Field('LOG_wp_user', __("User who was logged in while this occurred", 'event_espresso'), true ),
95
+				'LOG_wp_user' => new EE_WP_User_Field('LOG_wp_user', __("User who was logged in while this occurred", 'event_espresso'), true),
96 96
 
97 97
 			));
98 98
 		$this->_model_relations = array();
99
-		foreach($models_this_can_attach_to as $model){
100
-			if( $model == 'WP_User' ){
101
-				$this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
102
-			}elseif( $model != 'Change_Log' ) {
99
+		foreach ($models_this_can_attach_to as $model) {
100
+			if ($model == 'WP_User') {
101
+				$this->_model_relations[$model] = new EE_Belongs_To_Relation();
102
+			}elseif ($model != 'Change_Log') {
103 103
 				$this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
104 104
 			}
105 105
 		}
106 106
 		//use completely custom caps for this
107 107
 		$this->_cap_restriction_generators = false;
108 108
 		//caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
109
-		foreach( $this->_cap_contexts_to_cap_action_map as $cap_context => $action ) {
110
-			$this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions();
109
+		foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
110
+			$this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()] = new EE_Return_None_Where_Conditions();
111 111
 		}
112
-		parent::__construct( $timezone );
112
+		parent::__construct($timezone);
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * @param EE_Base_Class $related_model_obj
120 120
 	 * @return EE_Change_Log
121 121
 	 */
122
-	public function log($log_type,$message,$related_model_obj){
123
-		if($related_model_obj instanceof EE_Base_Class){
122
+	public function log($log_type, $message, $related_model_obj) {
123
+		if ($related_model_obj instanceof EE_Base_Class) {
124 124
 			$obj_id = $related_model_obj->ID();
125 125
 			$obj_type = $related_model_obj->get_model()->get_this_model_name();
126
-		}else{
126
+		} else {
127 127
 			$obj_id = NULL;
128 128
 			$obj_type = NULL;
129 129
 		}
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @throws EE_Error
148 148
 	 * @return EE_Change_Log
149 149
 	 */
150
-	public function gateway_log( $message, $related_obj_id, $related_obj_type ){
151
-		if( ! EE_Registry::instance()->is_model_name($related_obj_type)){
152
-			throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"),$related_obj_type));
150
+	public function gateway_log($message, $related_obj_id, $related_obj_type) {
151
+		if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) {
152
+			throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"), $related_obj_type));
153 153
 		}
154 154
 		$log = EE_Change_Log::new_instance(array(
155 155
 				'LOG_type'=>EEM_Change_Log::type_gateway,
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param array $query_params @see EEM_Base::get_all
169 169
 	 * @return array of arrays
170 170
 	 */
171
-	public function get_all_efficiently($query_params){
171
+	public function get_all_efficiently($query_params) {
172 172
 		return $this->_get_all_wpdb_results($query_params);
173 173
 	}
174 174
 
Please login to merge, or discard this patch.
core/db_models/EEM_Price_Type.model.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	/**
44 44
 	 * return an array of Base types. Keys are INTs which are used in the database,
45 45
 	 * values are text-representations of the base type.
46
-	 * @return array
46
+	 * @return integer
47 47
 	 */
48 48
 	public function get_base_types(){
49 49
 		return $this->base_types;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * 		instantiate a new price type object with blank/empty properties
122 122
 	 *
123 123
 	 * 		@access		public
124
-	 * 		@return		mixed		array on success, FALSE on fail
124
+	 * 		@return		EE_Price_Type		array on success, FALSE on fail
125 125
 	 */
126 126
 	public function get_new_price_type() {
127 127
 		return EE_Price_Type::new_instance();
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	public $type = NULL;
34 34
 
35 35
 	/**
36
-	*	Price Base types
37
-	*
38
-	*	@access	private
39
-	*	@var int
40
-	*/
36
+	 *	Price Base types
37
+	 *
38
+	 *	@access	private
39
+	 *	@var int
40
+	 */
41 41
 	public $base_types = null;
42 42
 
43 43
 	/**
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
  *
145 145
  * @param type $query_params
146 146
  * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
147
-	 * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
148
-	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
147
+ * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
148
+ * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
149 149
  * @return boolean
150 150
  */
151 151
 	public function delete_permanently($query_params = array(), $allow_blocking = true) {
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Price_Type.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Price_Type.class.php');
26 26
 
27 27
 
28 28
 class EEM_Price_Type extends EEM_Soft_Delete_Base {
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * values are text-representations of the base type.
46 46
 	 * @return array
47 47
 	 */
48
-	public function get_base_types(){
48
+	public function get_base_types() {
49 49
 		return $this->base_types;
50 50
 	}
51 51
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param type $base_type_int
55 55
 	 * @return type
56 56
 	 */
57
-	public function get_base_type_name($base_type_int){
57
+	public function get_base_type_name($base_type_int) {
58 58
 		return $this->base_types[$base_type_int];
59 59
 	}
60 60
 
@@ -79,27 +79,27 @@  discard block
 block discarded – undo
79 79
 	 * 		@access protected
80 80
 	 * 		@return void
81 81
 	 */
82
-	protected function __construct( $timezone = NULL ) {
82
+	protected function __construct($timezone = NULL) {
83 83
 		$this->base_types = array(
84
-			EEM_Price_Type::base_type_base_price => __('Price','event_espresso'),
85
-			EEM_Price_Type::base_type_discount => __('Discount','event_espresso'),
86
-			EEM_Price_Type::base_type_surcharge => __('Surcharge','event_espresso'),
87
-			EEM_Price_Type::base_type_tax => __('Tax','event_espresso') );
88
-		$this->singular_item = __('Price Type','event_espresso');
89
-		$this->plural_item = __('Price Types','event_espresso');
84
+			EEM_Price_Type::base_type_base_price => __('Price', 'event_espresso'),
85
+			EEM_Price_Type::base_type_discount => __('Discount', 'event_espresso'),
86
+			EEM_Price_Type::base_type_surcharge => __('Surcharge', 'event_espresso'),
87
+			EEM_Price_Type::base_type_tax => __('Tax', 'event_espresso') );
88
+		$this->singular_item = __('Price Type', 'event_espresso');
89
+		$this->plural_item = __('Price Types', 'event_espresso');
90 90
 
91 91
 		$this->_tables = array(
92
-			'Price_Type'=>new EE_Primary_Table('esp_price_type','PRT_ID')
92
+			'Price_Type'=>new EE_Primary_Table('esp_price_type', 'PRT_ID')
93 93
 		);
94 94
 		$this->_fields = array(
95 95
 			'Price_Type'=>array(
96
-				'PRT_ID'=>new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID','event_espresso')),
97
-				'PRT_name'=>new EE_Plain_Text_Field('PRT_name', __('Price Type Name','event_espresso'), false, ''),
98
-				'PBT_ID'=>new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax','event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types),
99
-				'PRT_is_percent'=>new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage','event_espresso'), false, false),
100
-				'PRT_order'=>new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ','event_espresso'), false, 0),
101
-				'PRT_deleted'=>new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed','event_espresso'), false, false),
102
-				'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), FALSE ),
96
+				'PRT_ID'=>new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID', 'event_espresso')),
97
+				'PRT_name'=>new EE_Plain_Text_Field('PRT_name', __('Price Type Name', 'event_espresso'), false, ''),
98
+				'PBT_ID'=>new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax', 'event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types),
99
+				'PRT_is_percent'=>new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage', 'event_espresso'), false, false),
100
+				'PRT_order'=>new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ', 'event_espresso'), false, 0),
101
+				'PRT_deleted'=>new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed', 'event_espresso'), false, false),
102
+				'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), FALSE),
103 103
 			)
104 104
 		);
105 105
 		$this->_model_relations = array(
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 			'WP_User' => new EE_Belongs_To_Relation(),
108 108
 		);
109 109
 		//this model is generally available for reading
110
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
110
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
111 111
 		//all price types are "default" in terms of capability names
112 112
 		$this->_caps_slug = 'default_price_types';
113
-		parent::__construct( $timezone );
113
+		parent::__construct($timezone);
114 114
 
115 115
 	}
116 116
 
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 		$ID = $query_params[0][$this->get_primary_key_field()->get_name()];
157 157
 
158 158
 		//check if any prices use this price type
159
-		$prc_query_params = array(array('PRT_ID'=>array('IN',$would_be_deleted_price_type_ids)));
160
-		if ( $prices = $this->get_all_related($ID,'Price',$prc_query_params)) {
159
+		$prc_query_params = array(array('PRT_ID'=>array('IN', $would_be_deleted_price_type_ids)));
160
+		if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) {
161 161
 			$prices_names_and_ids = array();
162
-			foreach($prices as $price){
162
+			foreach ($prices as $price) {
163 163
 				/* @var $price EE_Price */
164 164
 				$prices_names_and_ids[] = $price->name()."(".$price->ID().")";
165 165
 			}
166
-			$msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type.  If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'),implode(",",$prices_names_and_ids));
167
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
166
+			$msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type.  If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'), implode(",", $prices_names_and_ids));
167
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
168 168
 			return FALSE;
169 169
 		}
170 170
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 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
  *
Please login to merge, or discard this patch.
core/db_models/EEM_State.model.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 	*
166 166
 	* 		@access		public
167 167
 	* 		@param		$STA_ID
168
-	*		@return 		mixed		array on success, FALSE on fail
168
+	*		@return 		boolean		array on success, FALSE on fail
169 169
 	*/
170 170
 	public function delete_by_ID( $STA_ID = FALSE ) {
171 171
 
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 
65 65
 
66 66
 	/**
67
-	*	reset_cached_states
68
-	*
69
-	* 	@access		private
70
-	*	@return 		void
71
-	*/
67
+	 *	reset_cached_states
68
+	 *
69
+	 * 	@access		private
70
+	 *	@return 		void
71
+	 */
72 72
 	public function reset_cached_states() {
73 73
 		EEM_State::$_active_states = array();
74 74
 		EEM_State::$_all_states = array();
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 
79 79
 
80 80
 	/**
81
-	*		_get_states
82
-	*
83
-	* 		@access		private
84
-	*		@return 		array
85
-	*/
81
+	 *		_get_states
82
+	 *
83
+	 * 		@access		private
84
+	 *		@return 		array
85
+	 */
86 86
 	public function get_all_states() {
87 87
 		if ( ! self::$_all_states ) {
88 88
 			self::$_all_states = $this->get_all( array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 )));
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 
162 162
 
163 163
 	/**
164
-	*		delete  a single state from db via their ID
165
-	*
166
-	* 		@access		public
167
-	* 		@param		$STA_ID
168
-	*		@return 		mixed		array on success, FALSE on fail
169
-	*/
164
+	 *		delete  a single state from db via their ID
165
+	 *
166
+	 * 		@access		public
167
+	 * 		@param		$STA_ID
168
+	 *		@return 		mixed		array on success, FALSE on fail
169
+	 */
170 170
 	public function delete_by_ID( $STA_ID = FALSE ) {
171 171
 
172 172
 		if ( ! $STA_ID ) {
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_State.class.php' );
24
+require_once (EE_MODELS.'EEM_Base.model.php');
25
+require_once (EE_CLASSES.'EE_State.class.php');
26 26
 
27 27
 class EEM_State extends EEM_Base {
28 28
 
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
   	// array of all active states
34 34
 	private static $_active_states = FALSE;
35 35
 
36
-	protected function __construct( $timezone = NULL ) {
37
-		$this->singular_item = __('State/Province','event_espresso');
38
-		$this->plural_item = __('States/Provinces','event_espresso');
36
+	protected function __construct($timezone = NULL) {
37
+		$this->singular_item = __('State/Province', 'event_espresso');
38
+		$this->plural_item = __('States/Provinces', 'event_espresso');
39 39
 
40 40
 		$this->_tables = array(
41 41
 			'State'=> new EE_Primary_Table('esp_state', 'STA_ID')
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 
44 44
 		$this->_fields = array(
45 45
 			'State'=>array(
46
-				'STA_ID'=> new EE_Primary_Key_Int_Field('STA_ID', __('State ID','event_espresso')),
47
-				'CNT_ISO'=> new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code','event_espresso'), false, NULL, 'Country'),
48
-				'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation','event_espresso'), false, ''),
49
-				'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name','event_espresso'), false, ''),
46
+				'STA_ID'=> new EE_Primary_Key_Int_Field('STA_ID', __('State ID', 'event_espresso')),
47
+				'CNT_ISO'=> new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso'), false, NULL, 'Country'),
48
+				'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation', 'event_espresso'), false, ''),
49
+				'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name', 'event_espresso'), false, ''),
50 50
 				'STA_active'=> new EE_Boolean_Field('STA_active', __('State Active Flag', 'event_espresso'), false, false)
51 51
 				));
52 52
 		$this->_model_relations = array(
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 			'Venue'=>new EE_Has_Many_Relation(),
56 56
 		);
57 57
 		//this model is generally available for reading
58
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
58
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
59 59
 		//@todo: only show STA_active 
60
-		parent::__construct( $timezone );
60
+		parent::__construct($timezone);
61 61
 	}
62 62
 
63 63
 
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	*		@return 		array
85 85
 	*/
86 86
 	public function get_all_states() {
87
-		if ( ! self::$_all_states ) {
88
-			self::$_all_states = $this->get_all( array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 )));
87
+		if ( ! self::$_all_states) {
88
+			self::$_all_states = $this->get_all(array('order_by'=>array('STA_name'=>'ASC'), 'limit'=> array(0, 99999)));
89 89
 		}
90 90
 		return self::$_all_states;
91 91
 	}
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @param bool  $flush_cache
101 101
 	 * @return        array
102 102
 	 */
103
-	public function get_all_active_states( $countries = array(), $flush_cache = FALSE ) {
104
-		if ( ! self::$_active_states || $flush_cache ) {
105
-			$countries = is_array( $countries ) && ! empty( $countries ) ? $countries : EEM_Country::instance()->get_all_active_countries();
106
-			self::$_active_states =  $this->get_all( array(
107
-				array( 'STA_active' => TRUE, 'CNT_ISO' => array( 'IN', array_keys( $countries ))),
108
-				'order_by' => array( 'STA_name'=>'ASC' ),
109
-				'limit' => array( 0, 99999 ),
110
-				'force_join' => array( 'Country' )
103
+	public function get_all_active_states($countries = array(), $flush_cache = FALSE) {
104
+		if ( ! self::$_active_states || $flush_cache) {
105
+			$countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
106
+			self::$_active_states = $this->get_all(array(
107
+				array('STA_active' => TRUE, 'CNT_ISO' => array('IN', array_keys($countries))),
108
+				'order_by' => array('STA_name'=>'ASC'),
109
+				'limit' => array(0, 99999),
110
+				'force_join' => array('Country')
111 111
 			));
112 112
 		}
113 113
 		return self::$_active_states;
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * 	get_all_states_of_active_countries
120 120
 	 * @return array
121 121
 	 */
122
-	public function get_all_states_of_active_countries(){
123
-		if ( $states = $this->get_all( array( array( 'Country.CNT_active' => TRUE, 'STA_active' => TRUE ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
122
+	public function get_all_states_of_active_countries() {
123
+		if ($states = $this->get_all(array(array('Country.CNT_active' => TRUE, 'STA_active' => TRUE), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
124 124
 			return $states;
125 125
 		}
126 126
 		return FALSE;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 * 	get_all_states_of_active_countries
133 133
 	 * @return array
134 134
 	 */
135
-	public function get_all_active_states_for_these_countries( $countries ){
136
-		if ( ! $countries ) {
135
+	public function get_all_active_states_for_these_countries($countries) {
136
+		if ( ! $countries) {
137 137
 			return FALSE;
138 138
 		}
139
-		if ( $states = $this->get_all( array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys( $countries )), 'STA_active' => TRUE ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
139
+		if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries)), 'STA_active' => TRUE), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
140 140
 			return $states;
141 141
 		}
142 142
 		return FALSE;
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	 * 	get_all_states_of_active_countries
149 149
 	 * @return array
150 150
 	 */
151
-	public function get_all_states_for_these_countries( $countries ){
152
-		if ( ! $countries ) {
151
+	public function get_all_states_for_these_countries($countries) {
152
+		if ( ! $countries) {
153 153
 			return FALSE;
154 154
 		}
155
-		if ( $states = $this->get_all( array( array( 'Country.CNT_ISO' => array( 'IN', array_keys( $countries ))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
155
+		if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries))), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
156 156
 			return $states;
157 157
 		}
158 158
 		return FALSE;
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	* 		@param		$STA_ID
168 168
 	*		@return 		mixed		array on success, FALSE on fail
169 169
 	*/
170
-	public function delete_by_ID( $STA_ID = FALSE ) {
170
+	public function delete_by_ID($STA_ID = FALSE) {
171 171
 
172
-		if ( ! $STA_ID ) {
172
+		if ( ! $STA_ID) {
173 173
 			return FALSE;
174 174
 		}
175 175
 
176 176
 		// retrieve a particular transaction
177
-		$where_cols_n_values = array( array( 'STA_ID' => $STA_ID ));
178
-		if ( $answer = $this->delete ( $where_cols_n_values )) {
177
+		$where_cols_n_values = array(array('STA_ID' => $STA_ID));
178
+		if ($answer = $this->delete($where_cols_n_values)) {
179 179
 			return TRUE;
180 180
 		} else {
181 181
 			return FALSE;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 * @param string $state_ID
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_state_name_by_ID( $state_ID ){
192
-		if( isset( self::$_all_states[ $state_ID ] ) &&
193
-				self::$_all_states[ $state_ID ] instanceof EE_State ){
194
-			return self::$_all_states[ $state_ID ]->name();
191
+	public function get_state_name_by_ID($state_ID) {
192
+		if (isset(self::$_all_states[$state_ID]) &&
193
+				self::$_all_states[$state_ID] instanceof EE_State) {
194
+			return self::$_all_states[$state_ID]->name();
195 195
 		}
196
-		$names = $this->get_col( array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name' );
197
-		if( is_array( $names ) && ! empty( $names ) ){
198
-			return reset( $names );
199
-		}else{
196
+		$names = $this->get_col(array(array('STA_ID' => $state_ID), 'limit' => 1), 'STA_name');
197
+		if (is_array($names) && ! empty($names)) {
198
+			return reset($names);
199
+		} else {
200 200
 			return '';
201 201
 		}
202 202
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 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
  * EEH_URL helper
4 6
  * Helper class for URL-related PHP functions
@@ -62,7 +64,7 @@  discard block
 block discarded – undo
62 64
 				isset($results['response']['code']) &&
63 65
 				$results['response']['code'] == '200'){
64 66
 			return true;
65
-		}else{
67
+		} else{
66 68
 			return false;
67 69
 		}
68 70
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_System_Status.model.php 4 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,8 +14,6 @@  discard block
 block discarded – undo
14 14
 	 * 		This function is a singleton method used to instantiate the EEM_Attendee object
15 15
 	 *
16 16
 	 * 		@access public
17
-	 * 		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
18
-	 * 		@return EEM_System_Status
19 17
 	 */
20 18
 	public static function instance() {
21 19
 
@@ -147,7 +145,7 @@  discard block
 block discarded – undo
147 145
 
148 146
 	/**
149 147
 	 *
150
-	 * @return array like EE_Config class
148
+	 * @return EE_Config like EE_Config class
151 149
 	 */
152 150
 	function get_ee_config(){
153 151
 		return EE_Config::instance();
@@ -197,7 +195,7 @@  discard block
 block discarded – undo
197 195
 
198 196
 	/**
199 197
 	 * Checks if site responds ot HTTPS
200
-	 * @return boolean
198
+	 * @return string
201 199
 	 */
202 200
 	function get_https_enabled(){
203 201
 		$home = str_replace("http://", "https://", home_url());
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	function get_active_plugins(){
83 83
 		$active_plugins = (array) get_option( 'active_plugins', array() );
84
-		if ( is_multisite() )
85
-			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
84
+		if ( is_multisite() ) {
85
+					$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
86
+		}
86 87
 		$active_plugins = array_map( 'strtolower', $active_plugins );
87 88
 		$plugin_info = array();
88 89
 		foreach ( $active_plugins as $plugin ) {
@@ -187,8 +188,9 @@  discard block
 block discarded – undo
187 188
 		  preg_match_all(
188 189
 		  '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
189 190
 			$section, $askapache, PREG_SET_ORDER);
190
-		  foreach($askapache as $m)
191
-			  $m2 = isset($m[2]) ? $m[2] : null;
191
+		  foreach($askapache as $m) {
192
+		  			  $m2 = isset($m[2]) ? $m[2] : null;
193
+		  }
192 194
 			  $pi[$n][$m[1]]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m,2);
193 195
 		}
194 196
 
@@ -232,7 +234,7 @@  discard block
 block discarded – undo
232 234
 			$status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
233 235
 		} elseif( $curl_works ) {
234 236
 			$status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
235
-		}else{
237
+		} else{
236 238
 			$status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>';
237 239
 		}
238 240
 		return $status;
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -215,17 +215,17 @@
 block discarded – undo
215 215
 	 * Whether or not a .maintenance file is detected
216 216
 	 * @return string descripting wp_maintenance_mode status
217 217
 	 */
218
-    function get_wp_maintenance_mode() {
219
-        $opened = file_exists( ABSPATH . '.maintenance' );
220
-        return $opened ? sprintf( __('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>','</strong>' ) : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
221
-    }
218
+	function get_wp_maintenance_mode() {
219
+		$opened = file_exists( ABSPATH . '.maintenance' );
220
+		return $opened ? sprintf( __('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>','</strong>' ) : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
221
+	}
222 222
 	/**
223 223
 	 * Whether or not logging is enabled
224 224
 	 * @return string descripting logging's status
225 225
 	 */
226 226
 	function get_logging_enabled(){
227
-            $opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' );
228
-            return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ;
227
+			$opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' );
228
+			return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ;
229 229
 	}
230 230
 	/**
231 231
 	 *  Whether curl ro fsock works
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Model for retrieving Information about the Event Espresso status.
5 5
  */
6
-class EEM_System_Status{
6
+class EEM_System_Status {
7 7
 
8 8
 	// private instance of the EEM_System_Status object
9 9
 	protected static $_instance = NULL;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		}
27 27
 		return self::$_instance;
28 28
 	}
29
-	private function __construct(){
29
+	private function __construct() {
30 30
 
31 31
 	}
32 32
 	/**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return array where each key is a function name on this class, and each value is SOMETHING--
35 35
 	 * it might be a value, an array, or an object
36 36
 	 */
37
-	function get_system_stati(){
37
+	function get_system_stati() {
38 38
 		return array(
39 39
 				'ee_version'=>$this->get_ee_version(),
40 40
 				'ee_activation_history'=>$this->get_ee_activation_history(),
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return string
57 57
 	 */
58
-	function get_ee_version(){
58
+	function get_ee_version() {
59 59
 		return espresso_version();
60 60
 	}
61 61
 	/**
62 62
 	 *
63 63
 	 * @return string
64 64
 	 */
65
-	function php_version(){
65
+	function php_version() {
66 66
 		return phpversion();
67 67
 	}
68 68
 	/**
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 		'DomainPath' => 'Domain Path',
80 80
 		'Network' => 'Network',
81 81
 	 */
82
-	function get_active_plugins(){
83
-		$active_plugins = (array) get_option( 'active_plugins', array() );
84
-		if ( is_multisite() )
85
-			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
86
-		$active_plugins = array_map( 'strtolower', $active_plugins );
82
+	function get_active_plugins() {
83
+		$active_plugins = (array) get_option('active_plugins', array());
84
+		if (is_multisite())
85
+			$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
86
+		$active_plugins = array_map('strtolower', $active_plugins);
87 87
 		$plugin_info = array();
88
-		foreach ( $active_plugins as $plugin ) {
89
-				$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
88
+		foreach ($active_plugins as $plugin) {
89
+				$plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
90 90
 
91
-				$plugin_info[ $plugin ] = $plugin_data;
91
+				$plugin_info[$plugin] = $plugin_data;
92 92
 		}
93 93
 		return $plugin_info;
94 94
 	}
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return array with keys 'home_url' and 'site_url'
99 99
 	 */
100
-	function get_wp_settings(){
101
-		$wp_memory_int = $this->let_to_num( WP_MEMORY_LIMIT );
102
-		if ( $wp_memory_int < 67108864 ) {
103
-			$wp_memory_to_display = '<mark class="error">' . sprintf( __('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"' ) . '</mark>';
100
+	function get_wp_settings() {
101
+		$wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT);
102
+		if ($wp_memory_int < 67108864) {
103
+			$wp_memory_to_display = '<mark class="error">'.sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"').'</mark>';
104 104
 		} else {
105
-			$wp_memory_to_display = '<mark class="yes">' . size_format( $wp_memory_int ) . '</mark>';
105
+			$wp_memory_to_display = '<mark class="yes">'.size_format($wp_memory_int).'</mark>';
106 106
 		}
107 107
 		return array(
108
-			'name'=>get_bloginfo('name','display'),
108
+			'name'=>get_bloginfo('name', 'display'),
109 109
 			'is_multisite'=>is_multisite(),
110
-			'version'=>  get_bloginfo( 'version', 'display' ),
110
+			'version'=>  get_bloginfo('version', 'display'),
111 111
 			'home_url'=>home_url(),
112 112
 			'site_url'=>site_url(),
113 113
 			'WP_DEBUG'=>WP_DEBUG,
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 			'gmt_offset'=>get_option('gmt_offset'),
117 117
 			'timezone_string'=>get_option('timezone_string'),
118 118
 			'admin_email'=>  get_bloginfo('admin_email', 'display'),
119
-			'language'=>get_bloginfo('language','display'),
120
-			'wp_max_upload_size' => size_format( wp_max_upload_size() ),
119
+			'language'=>get_bloginfo('language', 'display'),
120
+			'wp_max_upload_size' => size_format(wp_max_upload_size()),
121 121
 			'wp_memory' => $wp_memory_to_display
122 122
 			);
123 123
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * Gets an array of information about the history of ee versions installed
127 127
 	 * @return array
128 128
 	 */
129
-	function get_ee_activation_history(){
129
+	function get_ee_activation_history() {
130 130
 		return get_option('espresso_db_update');
131 131
 	}
132 132
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed
136 136
 	 * @return EE_Data_Migration_Script_Base[]
137 137
 	 */
138
-	function get_ee_migration_history(){
138
+	function get_ee_migration_history() {
139 139
 		$options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
140 140
 		$presentable_migration_scripts = array();
141
-		foreach($options as $option_array){
142
-			$presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$option_array['option_name'])] = maybe_unserialize($option_array['option_value']);
141
+		foreach ($options as $option_array) {
142
+			$presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name'])] = maybe_unserialize($option_array['option_value']);
143 143
 		}
144 144
 		return $presentable_migration_scripts;
145 145
 //		return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran();
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return array like EE_Config class
151 151
 	 */
152
-	function get_ee_config(){
152
+	function get_ee_config() {
153 153
 		return EE_Config::instance();
154 154
 	}
155 155
 
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 	 * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463
158 158
 	 * @return array like the output of phpinfo(), but in an array
159 159
 	 */
160
-	function get_php_info(){
160
+	function get_php_info() {
161 161
 		ob_start();
162 162
 		phpinfo(-1);
163 163
 
164 164
 		$pi = preg_replace(
165 165
 		array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
166
-		'#<h1>Configuration</h1>#',  "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
166
+		'#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
167 167
 		"#[ \t]+#", '#&nbsp;#', '#  +#', '# class=".*?"#', '%&#039;%',
168 168
 		 '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
169 169
 		 .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
170 170
 		 '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
171 171
 		 '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
172 172
 		 "# +#", '#<tr>#', '#</tr>#'),
173
-		array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
173
+		array('$1', '', '', '', '</$1>'."\n", '<', ' ', ' ', ' ', '', ' ',
174 174
 		 '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'.
175 175
 		 "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>',
176 176
 		 '<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
177
-		 '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
177
+		 '<tr><td>Zend Engine</td><td>$2</td></tr>'."\n".
178 178
 		 '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'),
179 179
 		ob_get_clean());
180 180
 
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 		unset($sections[0]);
183 183
 
184 184
 		$pi = array();
185
-		foreach($sections as $section){
185
+		foreach ($sections as $section) {
186 186
 		  $n = substr($section, 0, strpos($section, '</h2>'));
187 187
 		  preg_match_all(
188 188
 		  '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
189 189
 			$section, $askapache, PREG_SET_ORDER);
190
-		  foreach($askapache as $m)
190
+		  foreach ($askapache as $m)
191 191
 			  $m2 = isset($m[2]) ? $m[2] : null;
192
-			  $pi[$n][$m[1]]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m,2);
192
+			  $pi[$n][$m[1]] = ( ! isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2);
193 193
 		}
194 194
 
195 195
 		return $pi;
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 	 * Checks if site responds ot HTTPS
200 200
 	 * @return boolean
201 201
 	 */
202
-	function get_https_enabled(){
202
+	function get_https_enabled() {
203 203
 		$home = str_replace("http://", "https://", home_url());
204 204
 		$response = wp_remote_get($home);
205
-		if($response instanceof WP_Error){
205
+		if ($response instanceof WP_Error) {
206 206
 			$error_string = '';
207
-			foreach($response->errors as $short_name => $description_array){
208
-				$error_string .= "<b>$short_name</b>: ".implode(", ",$description_array);
207
+			foreach ($response->errors as $short_name => $description_array) {
208
+				$error_string .= "<b>$short_name</b>: ".implode(", ", $description_array);
209 209
 			}
210 210
 			return $error_string;
211 211
 		}
@@ -216,32 +216,32 @@  discard block
 block discarded – undo
216 216
 	 * @return string descripting wp_maintenance_mode status
217 217
 	 */
218 218
     function get_wp_maintenance_mode() {
219
-        $opened = file_exists( ABSPATH . '.maintenance' );
220
-        return $opened ? sprintf( __('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>','</strong>' ) : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
219
+        $opened = file_exists(ABSPATH.'.maintenance');
220
+        return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso');
221 221
     }
222 222
 	/**
223 223
 	 * Whether or not logging is enabled
224 224
 	 * @return string descripting logging's status
225 225
 	 */
226
-	function get_logging_enabled(){
227
-            $opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' );
228
-            return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ;
226
+	function get_logging_enabled() {
227
+            $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR.'/logs/espresso_log.txt', 'a');
228
+            return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>');
229 229
 	}
230 230
 	/**
231 231
 	 *  Whether curl ro fsock works
232 232
 	 * @return string describing posting's status
233 233
 	 */
234
-	function get_remote_posting(){
235
-		$fsock_works = function_exists( 'fsockopen' );
236
-		$curl_works = function_exists( 'curl_init' );
237
-		if ( $fsock_works && $curl_works ) {
234
+	function get_remote_posting() {
235
+		$fsock_works = function_exists('fsockopen');
236
+		$curl_works = function_exists('curl_init');
237
+		if ($fsock_works && $curl_works) {
238 238
 			$status = __('Your server has fsockopen and cURL enabled.', 'event_espresso');
239
-		} elseif ( $fsock_works ) {
239
+		} elseif ($fsock_works) {
240 240
 			$status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
241
-		} elseif( $curl_works ) {
241
+		} elseif ($curl_works) {
242 242
 			$status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
243
-		}else{
244
-			$status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>';
243
+		} else {
244
+			$status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso').'</mark>';
245 245
 		}
246 246
 		return $status;
247 247
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * Gets all the php.ini settings
251 251
 	 * @return array
252 252
 	 */
253
-	function get_php_ini_all(){
253
+	function get_php_ini_all() {
254 254
 		return ini_get_all();
255 255
 	}
256 256
 	/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 * @param type $size
260 260
 	 * @return int
261 261
 	 */
262
-	function let_to_num( $size ) {
263
-		$l 		= substr( $size, -1 );
264
-		$ret 	= substr( $size, 0, -1 );
265
-		switch( strtoupper( $l ) ) {
262
+	function let_to_num($size) {
263
+		$l = substr($size, -1);
264
+		$ret = substr($size, 0, -1);
265
+		switch (strtoupper($l)) {
266 266
 			case 'P':
267 267
 				$ret *= 1024;
268 268
 			case 'T':
Please login to merge, or discard this patch.
core/db_models/fields/EE_Field_With_Model_Name.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	/**
28 28
 	 * Returns the name of the model(s) pointed to
29 29
 	 * @deprecated since version 4.6.7
30
-	 * @return mixed string or array of strings
30
+	 * @return string string or array of strings
31 31
 	 */
32 32
 	function get_model_name_pointed_to(){
33 33
 		EE_Error::doing_it_wrong( 'get_model_name_pointed_to', __( 'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', 'event_espresso' ), '4.6.7' );
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * with the EE_Foreign_Key_Field to create a relation between any two models)
6 6
  * also required basically the exact same functionality, except NOT be a foreign key.
7 7
  */
8
-abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base{
8
+abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base {
9 9
 	/**
10 10
 	 * Usually the name of a single model. However, as in the case for custom post types,
11 11
 	 * it can actually be an array of models
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul dbe a string
21 21
 	 * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the "EEM_"
22 22
 	 */
23
-	function __construct($table_column, $nicename, $nullable, $default_value,$model_name){
23
+	function __construct($table_column, $nicename, $nullable, $default_value, $model_name) {
24 24
 		$this->_model_name_pointed_to = $model_name;
25 25
 		parent::__construct($table_column, $nicename, $nullable, $default_value);
26 26
 	}
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 * @deprecated since version 4.6.7
30 30
 	 * @return mixed string or array of strings
31 31
 	 */
32
-	function get_model_name_pointed_to(){
33
-		EE_Error::doing_it_wrong( 'get_model_name_pointed_to', __( 'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', 'event_espresso' ), '4.6.7' );
32
+	function get_model_name_pointed_to() {
33
+		EE_Error::doing_it_wrong('get_model_name_pointed_to', __('This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', 'event_espresso'), '4.6.7');
34 34
 		return $this->_model_name_pointed_to;
35 35
 	}
36 36
 	/**
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
 	 * @return array of model names pointed to by this field
40 40
 	 */
41 41
 	function get_model_names_pointed_to() {
42
-		if( is_array( $this->_model_name_pointed_to ) ) {
42
+		if (is_array($this->_model_name_pointed_to)) {
43 43
 			return $this->_model_name_pointed_to;
44
-		}else{
45
-			return array( $this->_model_name_pointed_to );
44
+		} else {
45
+			return array($this->_model_name_pointed_to);
46 46
 		}
47 47
 	}
48 48
 	/**
49 49
 	 * Returns the model's classname (eg EE_Event instead of just Event)
50 50
 	 * @return array
51 51
 	 */
52
-	function get_model_class_names_pointed_to(){
52
+	function get_model_class_names_pointed_to() {
53 53
 		$model_names = array();
54
-		if(is_array($this->_model_name_pointed_to)){
55
-			foreach($this->_model_name_pointed_to as $model_name){
54
+		if (is_array($this->_model_name_pointed_to)) {
55
+			foreach ($this->_model_name_pointed_to as $model_name) {
56 56
 				$model_names[] = "EE_".$model_name;
57 57
 			}
58
-		}else{
58
+		} else {
59 59
 			$model_names = array("EE_".$this->_model_name_pointed_to);
60 60
 		}
61 61
 		return $model_names;
62 62
 	}
63 63
 
64
-	function is_model_obj_of_type_pointed_to($model_obj_or_ID){
65
-		foreach($this->get_model_class_names_pointed_to() as $model_obj_classname){
66
-			if($model_obj_or_ID instanceof $model_obj_classname){
64
+	function is_model_obj_of_type_pointed_to($model_obj_or_ID) {
65
+		foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
66
+			if ($model_obj_or_ID instanceof $model_obj_classname) {
67 67
 				return true;
68 68
 			}
69 69
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 				$validation_error_message = $default_validation_strategy->get_validation_error_message();
43 43
 			}
44 44
 			throw new EE_Validation_Error( $validation_error_message, 'float_only' );
45
-		}else{
45
+		} else{
46 46
 			return floatval($normalized_value);
47 47
 		}
48 48
 	}
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	public function unnormalize($normalized_value) {
56 56
 		if( empty( $normalized_value ) ){
57 57
 			return '0.00';
58
-		}else{
58
+		} else{
59 59
 			return "$normalized_value";
60 60
 		}
61 61
 	}
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_Field_Base.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -4,6 +4,7 @@
 block discarded – undo
4 4
 	 * Overrides parent so it doesn't need to provide so many non-applicable fields
5 5
 	 * @param string $table_column
6 6
 	 * @param string $nicename
7
+	 * @param integer|null $default
7 8
 	 */
8 9
 	public function __construct($table_column, $nicename,$default) {
9 10
 		parent::__construct($table_column, $nicename, false, $default, null);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2
-abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name{
2
+abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name {
3 3
 	/**
4 4
 	 * Overrides parent so it doesn't need to provide so many non-applicable fields
5 5
 	 * @param string $table_column
6 6
 	 * @param string $nicename
7 7
 	 */
8
-	public function __construct($table_column, $nicename,$default) {
8
+	public function __construct($table_column, $nicename, $default) {
9 9
 		parent::__construct($table_column, $nicename, false, $default, null);
10 10
 	}
11 11
 	/**
12 12
 	 * @param $table_alias
13 13
 	 * @param $name
14 14
 	 */
15
-	function _construct_finalize($table_alias, $name, $model_name){
15
+	function _construct_finalize($table_alias, $name, $model_name) {
16 16
 		$this->_model_name_pointed_to = $model_name;
17 17
 		parent::_construct_finalize($table_alias, $name, $model_name);
18 18
 	}
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_String_Field.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -4,6 +4,10 @@
 block discarded – undo
4 4
 	function get_wpdb_data_type(){
5 5
 		return '%s';
6 6
 	}
7
+
8
+	/**
9
+	 * @param string $table_column
10
+	 */
7 11
 	public function __construct($table_column, $nicename) {
8 12
 		parent::__construct($table_column, $nicename, NULL);
9 13
 	}
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once('EE_Primary_Key_Field_Base.php');
3
-class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base{
4
-	function get_wpdb_data_type(){
3
+class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base {
4
+	function get_wpdb_data_type() {
5 5
 		return '%s';
6 6
 	}
7 7
 	public function __construct($table_column, $nicename) {
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	 * @return string
14 14
 	 */
15 15
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
16
-	if($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)){
16
+	if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
17 17
 			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
18 18
 		}
19 19
 		return wp_strip_all_tags($value_inputted_for_field_on_model_object);
Please login to merge, or discard this patch.