Completed
Branch FET-8394-move-rules-into-core (5a0f96)
by
unknown
62:42 queued 53:38
created
core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 // (all other times it gets resurrected from a wordpress option)
15 15
 $stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*');
16 16
 $class_to_filepath = array();
17
-foreach($stages as $filepath){
17
+foreach ($stages as $filepath) {
18 18
 	$matches = array();
19
-	preg_match('~4_7_0_stages/(.*).dmsstage.php~',$filepath,$matches);
19
+	preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20 20
 	$class_to_filepath[$matches[1]] = $filepath;
21 21
 }
22 22
 //give addons a chance to autoload their stages too
23
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages',$class_to_filepath);
23
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
24 24
 EEH_Autoloader::register_autoloader($class_to_filepath);
25 25
 
26 26
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  * @since                4.7.0
37 37
  *
38 38
  */
39
-class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base{
39
+class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base {
40 40
 
41 41
 	/**
42 42
 	 * return EE_DMS_Core_4_7_0
@@ -58,18 +58,18 @@  discard block
 block discarded – undo
58 58
 	 * @return bool
59 59
 	 */
60 60
 	public function can_migrate_from_version($version_array) {
61
-		EE_Registry::instance()->load_helper( 'Activation' );
61
+		EE_Registry::instance()->load_helper('Activation');
62 62
 		$version_string = $version_array['Core'];
63 63
 		if (
64
-			( $version_string <= '4.7.0' && $version_string >= '4.6.0' )
64
+			($version_string <= '4.7.0' && $version_string >= '4.6.0')
65 65
 			||
66
-			( $version_string >= '4.7.0' &&
67
-					! EEH_Activation::table_exists( 'esp_registration_payment' ) &&
68
-					EEH_Activation::table_exists( 'esp_registration' ) ) ) {
66
+			($version_string >= '4.7.0' &&
67
+					! EEH_Activation::table_exists('esp_registration_payment') &&
68
+					EEH_Activation::table_exists('esp_registration')) ) {
69 69
 			return true;
70
-		} elseif ( ! $version_string ) {
70
+		} elseif ( ! $version_string) {
71 71
 			//no version string provided... this must be pre 4.3
72
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
72
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
73 73
 		} else {
74 74
 			return false;
75 75
 		}
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function schema_changes_before_migration() {
93 93
 		//relies on 4.1's EEH_Activation::create_table
94
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
95
-		$table_name='esp_answer';
96
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
94
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID INT UNSIGNED NOT NULL,
98 98
 					QST_ID INT UNSIGNED NOT NULL,
99 99
 					ANS_value TEXT NOT NULL,
100 100
 					PRIMARY KEY  (ANS_ID)";
101
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
101
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
102 102
 
103 103
 		$table_name = 'esp_attendee_meta';
104 104
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
138 138
 					  CNT_active TINYINT(1) DEFAULT '0',
139 139
 					  PRIMARY KEY  (CNT_ISO)";
140
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
140
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
141 141
 
142 142
 		$table_name = 'esp_currency';
143 143
 		$sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
148 148
 				CUR_active TINYINT(1) DEFAULT '0',
149 149
 				PRIMARY KEY  (CUR_code)";
150
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
150
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
151 151
 
152 152
 
153 153
 		$table_name = 'esp_currency_payment_method';
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
 
180
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
180
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
181 181
 		$table_name = 'esp_event_meta';
182 182
 		$sql = "
183 183
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -194,41 +194,41 @@  discard block
 block discarded – undo
194 194
 			EVT_external_URL VARCHAR(200) NULL,
195 195
 			EVT_donations TINYINT(1) NULL,
196 196
 			PRIMARY KEY  (EVTM_ID)";
197
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
197
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
198 198
 
199 199
 
200 200
 
201
-		$table_name='esp_event_question_group';
202
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
201
+		$table_name = 'esp_event_question_group';
202
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
203 203
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
204 204
 					QSG_ID INT UNSIGNED NOT NULL,
205 205
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
206 206
 					PRIMARY KEY  (EQG_ID)";
207
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
207
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
208 208
 
209 209
 
210 210
 
211
-		$table_name='esp_event_venue';
212
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
211
+		$table_name = 'esp_event_venue';
212
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
213 213
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
214 214
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
215 215
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
216 216
 				PRIMARY KEY  (EVV_ID)";
217
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
217
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218 218
 
219 219
 
220 220
 
221
-		$table_name='esp_extra_meta';
222
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
221
+		$table_name = 'esp_extra_meta';
222
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
223 223
 				OBJ_ID INT(11) DEFAULT NULL,
224 224
 				EXM_type VARCHAR(45) DEFAULT NULL,
225 225
 				EXM_key VARCHAR(45) DEFAULT NULL,
226 226
 				EXM_value TEXT,
227 227
 				PRIMARY KEY  (EXM_ID)";
228
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
228
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
229 229
 
230
-		$table_name='esp_line_item';
231
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
230
+		$table_name = 'esp_line_item';
231
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
232 232
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
233 233
 				TXN_ID INT(11) DEFAULT NULL,
234 234
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 				OBJ_ID INT(11) DEFAULT NULL,
245 245
 				OBJ_type VARCHAR(45)DEFAULT NULL,
246 246
 				PRIMARY KEY  (LIN_ID)";
247
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB' );
247
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
248 248
 
249 249
 		$table_name = 'esp_log';
250 250
 		$sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 					KEY GRP_ID (GRP_ID)";
268 268
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269 269
 
270
-		EEH_Activation::drop_index( 'esp_message_template_group', 'EVT_ID' );
270
+		EEH_Activation::drop_index('esp_message_template_group', 'EVT_ID');
271 271
 
272 272
 		$table_name = 'esp_message_template_group';
273 273
 		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
283 283
 					PRIMARY KEY  (GRP_ID),
284 284
 					KEY MTP_user_id (MTP_user_id)";
285
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
285
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
286 286
 
287 287
 		$table_name = 'esp_event_message_template';
288 288
 		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 					PRIMARY KEY  (EMT_ID),
292 292
 					KEY EVT_ID (EVT_ID),
293 293
 					KEY GRP_ID (GRP_ID)";
294
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
294
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
295 295
 
296 296
 
297 297
 		$table_name = 'esp_payment';
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 					  PRIMARY KEY  (TTM_ID)";
360 360
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
361 361
 
362
-		$table_name='esp_question';
363
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
362
+		$table_name = 'esp_question';
363
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
364 364
 					QST_display_text TEXT NOT NULL,
365 365
 					QST_admin_label VARCHAR(255) NOT NULL,
366 366
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -372,27 +372,27 @@  discard block
 block discarded – undo
372 372
 					QST_wp_user BIGINT UNSIGNED NULL,
373 373
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
374 374
 					PRIMARY KEY  (QST_ID)';
375
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
375
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
376 376
 
377
-		$table_name='esp_question_group_question';
378
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
377
+		$table_name = 'esp_question_group_question';
378
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
379 379
 					QSG_ID INT UNSIGNED NOT NULL,
380 380
 					QST_ID INT UNSIGNED NOT NULL,
381 381
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
382 382
 					PRIMARY KEY  (QGQ_ID) ";
383
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
383
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
384 384
 
385 385
 
386 386
 
387
-		$table_name='esp_question_option';
388
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
387
+		$table_name = 'esp_question_option';
388
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
389 389
 					QSO_value VARCHAR(255) NOT NULL,
390 390
 					QSO_desc TEXT NOT NULL,
391 391
 					QST_ID INT UNSIGNED NOT NULL,
392 392
 					QSO_order INT UNSIGNED NOT NULL DEFAULT 0,
393 393
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
394 394
 					PRIMARY KEY  (QSO_ID)";
395
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
395
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396 396
 
397 397
 
398 398
 
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 
439 439
 
440 440
 
441
-		$table_name='esp_checkin';
442
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
441
+		$table_name = 'esp_checkin';
442
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
443 443
 					REG_ID INT(10) UNSIGNED NOT NULL,
444 444
 					DTT_ID INT(10) UNSIGNED NOT NULL,
445 445
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 					  PRC_wp_user BIGINT UNSIGNED NULL,
529 529
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
530 530
 					  PRIMARY KEY  (PRC_ID)";
531
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
531
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
532 532
 
533 533
 		$table_name = "esp_price_type";
534 534
 		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
566 566
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
567 567
 					  PRIMARY KEY  (TKT_ID)";
568
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
568
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
569 569
 
570
-		EEH_Activation::drop_index( 'esp_question_group', 'QSG_identifier_UNIQUE' );
570
+		EEH_Activation::drop_index('esp_question_group', 'QSG_identifier_UNIQUE');
571 571
 
572 572
 		$table_name = 'esp_question_group';
573
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
573
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
574 574
 					QSG_name VARCHAR(255) NOT NULL,
575 575
 					QSG_identifier VARCHAR(100) NOT NULL,
576 576
 					QSG_desc TEXT NULL,
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 					QSG_wp_user BIGINT UNSIGNED NULL,
583 583
 					PRIMARY KEY  (QSG_ID),
584 584
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
585
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
585
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
586 586
 
587 587
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
588 588
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		return true;
615 615
 	}
616 616
 
617
-	public function migration_page_hooks(){
617
+	public function migration_page_hooks() {
618 618
 
619 619
 	}
620 620
 
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@
 block discarded – undo
65 65
 		if( $version_string <= '4.8.0' && $version_string >= '4.7.0' ){
66 66
 //			echo "$version_string can be migrated from";
67 67
 			return true;
68
-		}elseif( ! $version_string ){
68
+		} elseif( ! $version_string ){
69 69
 //			echo "no version string provided: $version_string";
70 70
 			//no version string provided... this must be pre 4.3
71 71
 			return false;//changed mind. dont want people thinking they should migrate yet because they cant
72
-		}else{
72
+		} else{
73 73
 //			echo "$version_string doesnt apply";
74 74
 			return false;
75 75
 		}
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 //(all other times it gets resurrected from a wordpress option)
14 14
 $stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*');
15 15
 $class_to_filepath = array();
16
-foreach($stages as $filepath){
16
+foreach ($stages as $filepath) {
17 17
 	$matches = array();
18
-	preg_match('~4_8_0_stages/(.*).dmsstage.php~',$filepath,$matches);
18
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19 19
 	$class_to_filepath[$matches[1]] = $filepath;
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages',$class_to_filepath);
22
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
23 23
 EEH_Autoloader::register_autoloader($class_to_filepath);
24 24
 
25 25
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  * @since                4.6.0
36 36
  *
37 37
  */
38
-class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base{
38
+class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base {
39 39
 
40 40
 	/**
41 41
 	 * return EE_DMS_Core_4_8_0
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function can_migrate_from_version($version_array) {
64 64
 		$version_string = $version_array['Core'];
65
-		if( $version_string <= '4.8.0' && $version_string >= '4.7.0' ){
65
+		if ($version_string <= '4.8.0' && $version_string >= '4.7.0') {
66 66
 //			echo "$version_string can be migrated from";
67 67
 			return true;
68
-		}elseif( ! $version_string ){
68
+		}elseif ( ! $version_string) {
69 69
 //			echo "no version string provided: $version_string";
70 70
 			//no version string provided... this must be pre 4.3
71
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
72
-		}else{
71
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
72
+		} else {
73 73
 //			echo "$version_string doesnt apply";
74 74
 			return false;
75 75
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		return $script_4_7_defaults->schema_changes_after_migration();
107 107
 	}
108 108
 
109
-	public function migration_page_hooks(){
109
+	public function migration_page_hooks() {
110 110
 
111 111
 	}
112 112
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Unknown_1_0_0.core.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
  */
18 18
 /**
19 19
  */
20
-class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base{
20
+class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base {
21 21
 
22 22
 	/**
23 23
 	 * Returns whether or not this data migration script can operate on the given version of the database.
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Base.core.php 2 patches
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences!
118 118
 	 */
119 119
 	public function __construct() {
120
-		$this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages',$this->_migration_stages);
121
-		foreach($this->_migration_stages as $migration_stage){
122
-			if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) {
120
+		$this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages', $this->_migration_stages);
121
+		foreach ($this->_migration_stages as $migration_stage) {
122
+			if ($migration_stage instanceof EE_Data_Migration_Script_Stage) {
123 123
 				$migration_stage->_construct_finalize($this);
124 124
 			}
125 125
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * Place to add hooks and filters for tweaking the migrations page, in order
133 133
 	 * to customize it
134 134
 	 */
135
-	public function migration_page_hooks(){
135
+	public function migration_page_hooks() {
136 136
 		//by default none are added because we normally like the default look of the migration page
137 137
 	}
138 138
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @param int|string $new_pk eg posts.ID
148 148
 	 * @return void
149 149
 	 */
150
-	public function set_mapping($old_table,$old_pk,$new_table,$new_pk){
150
+	public function set_mapping($old_table, $old_pk, $new_table, $new_pk) {
151 151
 		//make sure it has the needed keys
152
-		if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){
152
+		if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) {
153 153
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
154 154
 		}
155 155
 		$this->_mappings[$old_table][$new_table][$old_pk] = $new_pk;
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts
166 166
 	 * @return mixed the primary key on the new table
167 167
 	 */
168
-	public function get_mapping_new_pk($old_table,$old_pk,$new_table){
169
-		if( ! isset($this->_mappings[$old_table]) ||
170
-			! isset($this->_mappings[$old_table][$new_table])){
168
+	public function get_mapping_new_pk($old_table, $old_pk, $new_table) {
169
+		if ( ! isset($this->_mappings[$old_table]) ||
170
+			! isset($this->_mappings[$old_table][$new_table])) {
171 171
 			//try fetching the option
172 172
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
173 173
 		}
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 	 * @param mixed $new_pk
185 185
 	 * @return mixed
186 186
 	 */
187
-	public function get_mapping_old_pk($old_table,$new_table,$new_pk){
188
-		if( ! isset($this->_mappings[$old_table]) ||
189
-			! isset($this->_mappings[$old_table][$new_table])){
187
+	public function get_mapping_old_pk($old_table, $new_table, $new_pk) {
188
+		if ( ! isset($this->_mappings[$old_table]) ||
189
+			! isset($this->_mappings[$old_table][$new_table])) {
190 190
 			//try fetching the option
191 191
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
192 192
 		}
193
-		if(isset($this->_mappings[$old_table][$new_table])){
193
+		if (isset($this->_mappings[$old_table][$new_table])) {
194 194
 			$new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]);
195
-			if(isset($new_pk_to_old_pk[$new_pk])){
195
+			if (isset($new_pk_to_old_pk[$new_pk])) {
196 196
 				return $new_pk_to_old_pk[$new_pk];
197 197
 			}
198 198
 		}
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param string $new_table_name
208 208
 	 * @return array
209 209
 	 */
210
-	protected function _get_mapping_option($old_table_name,$new_table_name){
211
-		$option =  get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array());
210
+	protected function _get_mapping_option($old_table_name, $new_table_name) {
211
+		$option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array());
212 212
 		return $option;
213 213
 	}
214 214
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	 * @param array $mapping_array
222 222
 	 * @return boolean success of updating option
223 223
 	 */
224
-	protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){
224
+	protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) {
225 225
 //		echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>";
226
-		$success =  update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array);
226
+		$success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array);
227 227
 		return $success;
228 228
 	}
229 229
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param string $new_table_name
236 236
 	 * @return string
237 237
 	 */
238
-	protected function _get_mapping_option_name($old_table_name,$new_table_name){
238
+	protected function _get_mapping_option_name($old_table_name, $new_table_name) {
239 239
 		global $wpdb;
240
-		$old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name);
241
-		$new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name);
240
+		$old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name);
241
+		$new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name);
242 242
 		$migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
243
-		return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 );
243
+		return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64);
244 244
 	}
245 245
 
246 246
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete.
258 258
 	 * @return int
259 259
 	 */
260
-	protected function _count_records_to_migrate(){
260
+	protected function _count_records_to_migrate() {
261 261
 		$count = 0;
262
-		foreach($this->stages() as $stage){
263
-			$count+= $stage->count_records_to_migrate();
262
+		foreach ($this->stages() as $stage) {
263
+			$count += $stage->count_records_to_migrate();
264 264
 		}
265 265
 		return $count;
266 266
 	}
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 	 * by just setting a transient and updating it after each migration_step
273 273
 	 * @return int
274 274
 	 */
275
-	public function count_records_migrated(){
275
+	public function count_records_migrated() {
276 276
 		$count = 0;
277
-		foreach($this->stages() as $stage){
278
-			$count+= $stage->count_records_migrated();
277
+		foreach ($this->stages() as $stage) {
278
+			$count += $stage->count_records_migrated();
279 279
 		}
280 280
 		$this->_records_migrated = $count;
281 281
 		return $count;
@@ -289,24 +289,24 @@  discard block
 block discarded – undo
289 289
 	 * @throws EE_Error
290 290
 	 * @throws Exception
291 291
 	 */
292
-	public function migration_step($num_records_to_migrate_limit){
292
+	public function migration_step($num_records_to_migrate_limit) {
293 293
 		//reset the feedback message
294 294
 		$this->_feedback_message = '';
295 295
 		//if we haven't yet done the 1st schema changes, do them now. buffer any output
296 296
 		$this->_maybe_do_schema_changes(true);
297 297
 
298
-		$num_records_actually_migrated =0;
298
+		$num_records_actually_migrated = 0;
299 299
 		$records_migrated_per_stage = array();
300 300
 		//setup the 'stage' variable, which should hold the last run stage of the migration  (or none at all if nothing runs)
301 301
 		$stage = null;
302 302
 		//get the next stage that isn't complete
303
-		foreach($this->stages() as $stage){
304
-			if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){
305
-				try{
303
+		foreach ($this->stages() as $stage) {
304
+			if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) {
305
+				try {
306 306
 					$records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated);
307 307
 					$num_records_actually_migrated += $records_migrated_during_stage;
308 308
 					$records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage;
309
-				}catch(Exception $e){
309
+				} catch (Exception $e) {
310 310
 					//yes if we catch an exception here, we consider that migration stage borked.
311 311
 					$stage->set_status(EE_Data_Migration_Manager::status_fatal_error);
312 312
 					$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 					throw $e;
315 315
 				}
316 316
 				//check that the migration stage didn't mark itself as having a fatal error
317
-				if($stage->is_broken()){
317
+				if ($stage->is_broken()) {
318 318
 					$this->set_broken();
319 319
 					throw new EE_Error($stage->get_last_error());
320 320
 				}
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 			//once we've migrated all the number we intended to (possibly from different stages), stop migrating
323 323
 			//or if we had a fatal error
324 324
 			//or if the current script stopped early- its not done, but it's done all it thinks we should do on this step
325
-			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){
325
+			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) {
326 326
 				break;
327 327
 			}
328 328
 		}
329 329
 		//check if we're all done this data migration...
330 330
 		//which is indicated by being done early AND the last stage claims to be done
331
-		if($stage == NULL){
331
+		if ($stage == NULL) {
332 332
 			//this migration script apparently has NO stages... which is super weird, but whatever
333 333
 			$this->set_completed();
334 334
 			$this->_maybe_do_schema_changes(false);
335
-		}else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){
335
+		} else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) {
336 336
 			//apparently we're done, because we couldn't migrate the number we intended to
337 337
 			$this->set_completed();
338 338
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
339 339
 			//do schema changes for after the migration now
340 340
 			//first double-check we haven't already done this
341 341
 			$this->_maybe_do_schema_changes(false);
342
-		}else{
342
+		} else {
343 343
 			//update feedback message, keeping in mind that we show them with the most recent at the top
344 344
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
345 345
 		}
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 	 * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage
354 354
 	 * @return void
355 355
 	 */
356
-	private function _update_feedback_message($records_migrated_per_stage){
356
+	private function _update_feedback_message($records_migrated_per_stage) {
357 357
 		$feedback_message_array = array();
358
-		foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){
359
-			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ;
358
+		foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) {
359
+			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name);
360 360
 		}
361
-		$this->_feedback_message .= implode("<br>",$feedback_message_array);
361
+		$this->_feedback_message .= implode("<br>", $feedback_message_array);
362 362
 	}
363 363
 
364 364
 
@@ -370,27 +370,27 @@  discard block
 block discarded – undo
370 370
 	 * @throws Exception
371 371
 	 * @return void
372 372
 	 */
373
-	private function _maybe_do_schema_changes($before = true){
373
+	private function _maybe_do_schema_changes($before = true) {
374 374
 		//so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran
375
-		$property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran';
376
-		if ( ! $this->$property_name ){
377
-			try{
375
+		$property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran';
376
+		if ( ! $this->$property_name) {
377
+			try {
378 378
 				ob_start();
379
-				if($before){
379
+				if ($before) {
380 380
 					$this->schema_changes_before_migration();
381
-				}else{
381
+				} else {
382 382
 					$this->schema_changes_after_migration();
383 383
 				}
384 384
 				$output = ob_get_contents();
385 385
 				ob_end_clean();
386
-			}catch(Exception $e){
386
+			} catch (Exception $e) {
387 387
 				$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
388 388
 				throw $e;
389 389
 			}
390 390
 			//record that we've done these schema changes
391 391
 			$this->$property_name = true;
392 392
 			//if there were any warnings etc, record them as non-fatal errors
393
-			if( $output ){
393
+			if ($output) {
394 394
 				//there were some warnings
395 395
 				$this->_errors[] = $output;
396 396
 			}
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 	 * @param string $table_definition_sql
418 418
 	 * @param string $engine_string
419 419
 	 */
420
-	protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){
420
+	protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') {
421 421
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name );
422
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  true ) );
422
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true));
423 423
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name  );
424 424
 	}
425 425
 
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
 	 * @param string $table_definition_sql
433 433
 	 * @param string $engine_string
434 434
 	 */
435
-	protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
435
+	protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
436 436
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name );
437
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
437
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
438 438
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name  );
439 439
 	}
440 440
 
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 	 * @param string $table_name
446 446
 	 * @return boolean
447 447
 	 */
448
-	protected function _old_table_exists( $table_name ) {
449
-		EE_Registry::instance()->load_helper( 'Activation' );
450
-		return EEH_Activation::table_exists( $table_name );
448
+	protected function _old_table_exists($table_name) {
449
+		EE_Registry::instance()->load_helper('Activation');
450
+		return EEH_Activation::table_exists($table_name);
451 451
 	}
452 452
 
453 453
 
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 	 * @param string $table_definition_sql
466 466
 	 * @param string $engine_string
467 467
 	 */
468
-	protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
468
+	protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
469 469
 //		EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name );
470
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
470
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
471 471
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
472 472
 	}
473 473
 
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
 	 * @param string $table_definition_sql
482 482
 	 * @param string $engine_string
483 483
 	 */
484
-	protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
485
-		if( $this->_currently_migrating() ) {
484
+	protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
485
+		if ($this->_currently_migrating()) {
486 486
 			//if we're doing a migration, and this table apparently already exists, then we don't need do anything right?
487 487
 //			EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
488 488
 			return;
489 489
 		}
490
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
490
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
491 491
 	}
492 492
 
493 493
 	/**
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	protected function _currently_migrating() {
498 498
 		//we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM)
499 499
 		return $this->_migrating &&
500
-					$this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) &&
500
+					$this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) &&
501 501
 					EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance;
502 502
 	}
503 503
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
 	 * @param boolean $table_is_new
508 508
 	 * @return boolean
509 509
 	 */
510
-	protected function _pre_existing_table_should_be_dropped( $table_is_new ) {
511
-		if( $table_is_new ) {
512
-			if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation  || $this->_currently_migrating() ){
510
+	protected function _pre_existing_table_should_be_dropped($table_is_new) {
511
+		if ($table_is_new) {
512
+			if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) {
513 513
 				return true;
514
-			}else{
514
+			} else {
515 515
 				return false;
516 516
 			}
517
-		}else{
518
-			if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){
517
+		} else {
518
+			if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) {
519 519
 				return true;
520
-			}else{
520
+			} else {
521 521
 				return false;
522 522
 			}
523 523
 		}
@@ -530,13 +530,13 @@  discard block
 block discarded – undo
530 530
 	 * @param string $engine_string
531 531
 	 * @param boolean $drop_pre_existing_tables
532 532
 	 */
533
-	private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){
533
+	private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) {
534 534
 		EE_Registry::instance()->load_helper('Activation');
535
-		try{
536
-			EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables);
537
-		}catch( EE_Error $e ) {
538
-			$message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString();
539
-			$this->add_error( $message  );
535
+		try {
536
+			EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables);
537
+		} catch (EE_Error $e) {
538
+			$message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString();
539
+			$this->add_error($message);
540 540
 			$this->_feedback_message .= $message;
541 541
 		}
542 542
 	}
@@ -548,15 +548,15 @@  discard block
 block discarded – undo
548 548
 	 * @return int one of EE_System::_req_type_* constants
549 549
 	 * @throws EE_Error
550 550
 	 */
551
-	private function _get_req_type_for_plugin_corresponding_to_this_dms(){
552
-		if($this->slug() == 'Core'){
551
+	private function _get_req_type_for_plugin_corresponding_to_this_dms() {
552
+		if ($this->slug() == 'Core') {
553 553
 			return EE_System::instance()->detect_req_type();
554
-		}else{//it must be for an addon
554
+		} else {//it must be for an addon
555 555
 			$addon_name = $this->slug();
556
-			if( EE_Registry::instance()->get_addon_by_name($addon_name)){
556
+			if (EE_Registry::instance()->get_addon_by_name($addon_name)) {
557 557
 				return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type();
558
-			}else{
559
-				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ;
558
+			} else {
559
+				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))));
560 560
 			}
561 561
 		}
562 562
 	}
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
 	 * returns an array of strings describing errors by all the script's stages
568 568
 	 * @return array
569 569
 	 */
570
-	public function get_errors(){
570
+	public function get_errors() {
571 571
 		$all_errors = $this->_errors;
572
-		if( ! is_array($all_errors)){
572
+		if ( ! is_array($all_errors)) {
573 573
 			$all_errors = array();
574 574
 		}
575
-		foreach($this->stages() as $stage){
576
-			$all_errors = array_merge($stage->get_errors(),$all_errors);
575
+		foreach ($this->stages() as $stage) {
576
+			$all_errors = array_merge($stage->get_errors(), $all_errors);
577 577
 		}
578 578
 		return $all_errors;
579 579
 	}
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 * Indicates whether or not this migration script should continue
585 585
 	 * @return boolean
586 586
 	 */
587
-	public function can_continue(){
588
-		return in_array($this->get_status(),  EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
587
+	public function can_continue() {
588
+		return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
589 589
 	}
590 590
 
591 591
 
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
 	 * get ordered by the indexes
598 598
 	 * @return EE_Data_Migration_Script_Stage[]
599 599
 	 */
600
-	protected function stages(){
601
-		$stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages );
600
+	protected function stages() {
601
+		$stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages);
602 602
 		ksort($stages);
603 603
 		return $stages;
604 604
 	}
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 * can be displayed to the user
611 611
 	 * @return string
612 612
 	 */
613
-	public function get_feedback_message(){
613
+	public function get_feedback_message() {
614 614
 		return $this->_feedback_message;
615 615
 	}
616 616
 
@@ -622,16 +622,16 @@  discard block
 block discarded – undo
622 622
 	 * possible that this class is defined when it goes to sleep, but NOT available when it
623 623
 	 * awakes (eg, this class is part of an addon that is deactivated at some point).
624 624
 	 */
625
-	public function properties_as_array(){
625
+	public function properties_as_array() {
626 626
 		$properties = parent::properties_as_array();
627 627
 		$properties['_migration_stages'] = array();
628
-		foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){
628
+		foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) {
629 629
 			$properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array();
630 630
 		}
631 631
 		unset($properties['_mappings']);
632 632
 
633
-		foreach($this->_mappings as $old_table_name => $mapping_to_new_table){
634
-			foreach($mapping_to_new_table as $new_table_name => $mapping){
633
+		foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) {
634
+			foreach ($mapping_to_new_table as $new_table_name => $mapping) {
635 635
 				$this->_set_mapping_option($old_table_name, $new_table_name, $mapping);
636 636
 			}
637 637
 		}
@@ -646,19 +646,19 @@  discard block
 block discarded – undo
646 646
 	 * @param array $array_of_properties like what's produced from properties_as_array() method
647 647
 	 * @return void
648 648
 	 */
649
-	public function instantiate_from_array_of_properties($array_of_properties){
649
+	public function instantiate_from_array_of_properties($array_of_properties) {
650 650
 		$stages_properties_arrays = $array_of_properties['_migration_stages'];
651 651
 		unset($array_of_properties['_migration_stages']);
652 652
 		unset($array_of_properties['class']);
653
-		foreach($array_of_properties as $property_name => $property_value){
653
+		foreach ($array_of_properties as $property_name => $property_value) {
654 654
 			$this->$property_name = $property_value;
655 655
 		}
656 656
 		//_migration_stages are already instantiated, but have only default data
657
-		foreach($this->_migration_stages as $stage){
658
-			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays);
657
+		foreach ($this->_migration_stages as $stage) {
658
+			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays);
659 659
 			//SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by
660 660
 			//an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet)
661
-			if($stage_data){
661
+			if ($stage_data) {
662 662
 				$stage->instantiate_from_array_of_properties($stage_data);
663 663
 			}
664 664
 		}
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 	 * @param array $migration_stage_data_arrays
675 675
 	 * @return null
676 676
 	 */
677
-	private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){
678
-		foreach($migration_stage_data_arrays as $migration_stage_data_array){
679
-			if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){
677
+	private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) {
678
+		foreach ($migration_stage_data_arrays as $migration_stage_data_array) {
679
+			if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) {
680 680
 				return $migration_stage_data_array;
681 681
 			}
682 682
 		}
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin
693 693
 	 * that will be updated to. Eg array('Core','4.1.0')
694 694
 	 */
695
-	public final function migrates_to_version(){
696
-		return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) );
695
+	public final function migrates_to_version() {
696
+		return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
697 697
 	}
698 698
 
699 699
 
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
 	 * Or 'Core' for core (non-addon).
706 706
 	 * @return string
707 707
 	 */
708
-	public function slug(){
708
+	public function slug() {
709 709
 		$migrates_to_version_info = $this->migrates_to_version();
710 710
 		//the slug is the first part of the array
711
-		return $migrates_to_version_info[ 'slug' ];
711
+		return $migrates_to_version_info['slug'];
712 712
 	}
713 713
 
714 714
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 * the database up so it can run), then you can set "A" to priority 3 or something.
723 723
 	 * @return int
724 724
 	 */
725
-	public function priority(){
725
+	public function priority() {
726 726
 		return $this->_priority;
727 727
 	}
728 728
 
@@ -735,18 +735,18 @@  discard block
 block discarded – undo
735 735
 	 * @param boolean $migrating
736 736
 	 * @return void
737 737
 	 */
738
-	public function set_migrating( $migrating = TRUE ){
738
+	public function set_migrating($migrating = TRUE) {
739 739
 		$this->_migrating = $migrating;
740 740
 	}
741 741
 
742 742
 	/**
743 743
 	 * Marks that we think this migration class can continue to migrate
744 744
 	 */
745
-	public function reattempt(){
745
+	public function reattempt() {
746 746
 		parent::reattempt();
747 747
 		//also, we want to reattempt any stages that were marked as borked
748
-		foreach( $this->stages() as $stage ) {
749
-			if( $stage->is_broken() ) {
748
+		foreach ($this->stages() as $stage) {
749
+			if ($stage->is_broken()) {
750 750
 				$stage->reattempt();
751 751
 			}
752 752
 		}
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 					$records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated);
307 307
 					$num_records_actually_migrated += $records_migrated_during_stage;
308 308
 					$records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage;
309
-				}catch(Exception $e){
309
+				} catch(Exception $e){
310 310
 					//yes if we catch an exception here, we consider that migration stage borked.
311 311
 					$stage->set_status(EE_Data_Migration_Manager::status_fatal_error);
312 312
 					$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 			//this migration script apparently has NO stages... which is super weird, but whatever
333 333
 			$this->set_completed();
334 334
 			$this->_maybe_do_schema_changes(false);
335
-		}else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){
335
+		} else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){
336 336
 			//apparently we're done, because we couldn't migrate the number we intended to
337 337
 			$this->set_completed();
338 338
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
339 339
 			//do schema changes for after the migration now
340 340
 			//first double-check we haven't already done this
341 341
 			$this->_maybe_do_schema_changes(false);
342
-		}else{
342
+		} else{
343 343
 			//update feedback message, keeping in mind that we show them with the most recent at the top
344 344
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
345 345
 		}
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 				ob_start();
379 379
 				if($before){
380 380
 					$this->schema_changes_before_migration();
381
-				}else{
381
+				} else{
382 382
 					$this->schema_changes_after_migration();
383 383
 				}
384 384
 				$output = ob_get_contents();
385 385
 				ob_end_clean();
386
-			}catch(Exception $e){
386
+			} catch(Exception $e){
387 387
 				$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
388 388
 				throw $e;
389 389
 			}
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 		if( $table_is_new ) {
512 512
 			if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation  || $this->_currently_migrating() ){
513 513
 				return true;
514
-			}else{
514
+			} else{
515 515
 				return false;
516 516
 			}
517
-		}else{
517
+		} else{
518 518
 			if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){
519 519
 				return true;
520
-			}else{
520
+			} else{
521 521
 				return false;
522 522
 			}
523 523
 		}
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 		EE_Registry::instance()->load_helper('Activation');
535 535
 		try{
536 536
 			EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables);
537
-		}catch( EE_Error $e ) {
537
+		} catch( EE_Error $e ) {
538 538
 			$message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString();
539 539
 			$this->add_error( $message  );
540 540
 			$this->_feedback_message .= $message;
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
 	private function _get_req_type_for_plugin_corresponding_to_this_dms(){
552 552
 		if($this->slug() == 'Core'){
553 553
 			return EE_System::instance()->detect_req_type();
554
-		}else{//it must be for an addon
554
+		} else{//it must be for an addon
555 555
 			$addon_name = $this->slug();
556 556
 			if( EE_Registry::instance()->get_addon_by_name($addon_name)){
557 557
 				return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type();
558
-			}else{
558
+			} else{
559 559
 				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ;
560 560
 			}
561 561
 		}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage.core.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * _migration_step() (ie, it its a count of rows in the old attendees table in _count_records_to_migrate(), it should also be OLD attendee rows migrated
35 35
  * on each call to _migration_step().
36 36
  */
37
-abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base{
37
+abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base {
38 38
 	/**
39 39
 	 * The migration script this is a stage of
40 40
 	 * @var EE_Data_Migration_Script_Base
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
48 48
 	 * @param EE_Data_Migration_Script_Base $migration_script
49 49
 	 */
50
-	public function _construct_finalize($migration_script){
50
+	public function _construct_finalize($migration_script) {
51 51
 		$this->_migration_script = $migration_script;
52 52
 	}
53 53
 
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 	 * @param int $num_items_to_migrate
59 59
 	 * @return int
60 60
 	 */
61
-	public function migration_step($num_items_to_migrate=50){
61
+	public function migration_step($num_items_to_migrate = 50) {
62 62
 		//before we run the migration step, we want ot take note of warnings that get outputted
63 63
 		ob_start();
64 64
 		$items_migrated = $this->_migration_step($num_items_to_migrate);
65 65
 		$output = ob_get_contents();
66 66
 		ob_end_clean();
67
-		if( $output ){
67
+		if ($output) {
68 68
 			$this->add_error($output);
69 69
 		}
70 70
 		$this->_records_migrated += $items_migrated;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param int $num_items_to_migrate
83 83
 	 * @return int number of items ACTUALLY migrated
84 84
 	 */
85
-	abstract protected function _migration_step($num_items_to_migrate=50);
85
+	abstract protected function _migration_step($num_items_to_migrate = 50);
86 86
 
87 87
 	/**
88 88
 	 * Counts the records that have been migrated so far
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * returns an array of strings describing errors
97 97
 	 * @return array
98 98
 	 */
99
-	public function get_errors(){
99
+	public function get_errors() {
100 100
 		return $this->_errors;
101 101
 	}
102 102
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	 * to have been made from the properties_as_array() function.
107 107
 	 * @param array $array_of_properties like what's produced from properties_as_array() method
108 108
 	 */
109
-	public function instantiate_from_array_of_properties($array_of_properties){
109
+	public function instantiate_from_array_of_properties($array_of_properties) {
110 110
 		unset($array_of_properties['class']);
111
-		foreach($array_of_properties as $property_name => $property_value){
111
+		foreach ($array_of_properties as $property_name => $property_value) {
112 112
 			$this->$property_name = $property_value;
113 113
 		}
114 114
 	}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * Gets the script this is a stage of
118 118
 	 * @return EE_Data_Migration_Script_Base
119 119
 	 */
120
-	protected function get_migration_script(){
120
+	protected function get_migration_script() {
121 121
 		return $this->_migration_script;
122 122
 	}
123 123
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage_Table.core.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
 	protected $_old_table;
22 22
 
23 23
 /**
24
-	 * Set in the constructor to add this sql to both the counting query in
25
-	 * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and
26
-	 * EE_Data_Migration_Script_Stage_Table::_get_rows().
27
-	 * Eg "where column_name like '%some_value%'"
28
-	 * @var string
29
-	 */
24
+ * Set in the constructor to add this sql to both the counting query in
25
+ * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and
26
+ * EE_Data_Migration_Script_Stage_Table::_get_rows().
27
+ * Eg "where column_name like '%some_value%'"
28
+ * @var string
29
+ */
30 30
 	protected $_extra_where_sql;
31 31
 
32 32
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 * @param int $num_items
42 42
 	 * @return int number of items ACTUALLY migrated
43 43
 	 */
44
-	function _migration_step($num_items=50){
45
-		$rows = $this->_get_rows( $num_items );
44
+	function _migration_step($num_items = 50) {
45
+		$rows = $this->_get_rows($num_items);
46 46
 		$items_actually_migrated = 0;
47
-		foreach($rows as $old_row){
47
+		foreach ($rows as $old_row) {
48 48
 			$this->_migrate_old_row($old_row);
49 49
 			$items_actually_migrated++;
50 50
 		}
51
-		if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){
51
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
52 52
 			$this->set_completed();
53 53
 		}
54 54
 		return $items_actually_migrated;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @param int $limit
61 61
 	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
62 62
 	 */
63
-	protected function _get_rows( $limit ){
63
+	protected function _get_rows($limit) {
64 64
 		global $wpdb;
65 65
 		$start_at_record = $this->count_records_migrated();
66
-		$query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare("LIMIT %d, %d",$start_at_record,$limit);
67
-		return $wpdb->get_results($query,ARRAY_A);
66
+		$query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit);
67
+		return $wpdb->get_results($query, ARRAY_A);
68 68
 	}
69 69
 
70 70
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	function _count_records_to_migrate() {
77 77
 		global $wpdb;
78
-		$query =  "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}";
79
-		$count = $wpdb->get_var( $query );
78
+		$query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}";
79
+		$count = $wpdb->get_var($query);
80 80
 		return $count;
81 81
 	}
82 82
 
Please login to merge, or discard this patch.
core/db_classes/EE_Base_Class.class.php 4 patches
Braces   +72 added lines, -64 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
 do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
3 5
 /**
4 6
  *
@@ -170,7 +172,7 @@  discard block
 block discarded – undo
170 172
 		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171 173
 			if($relation_obj instanceof EE_Belongs_To_Relation){
172 174
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
175
+			} else{
174 176
 				$this->_model_relations[$relation_name] = array();
175 177
 			}
176 178
 		}
@@ -215,7 +217,7 @@  discard block
 block discarded – undo
215 217
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216 218
 				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
217 219
 			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
220
+		} else{
219 221
 			return NULL;
220 222
 		}
221 223
 	}
@@ -264,7 +266,7 @@  discard block
 block discarded – undo
264 266
 					empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] );
265 267
 				}
266 268
 
267
-			}else{
269
+			} else{
268 270
 				$this->_fields[$field_name] = $holder_of_value;
269 271
 			}
270 272
 
@@ -292,7 +294,7 @@  discard block
 block discarded – undo
292 294
 			}
293 295
 			//let's unset any cache for this field_name from the $_cached_properties property.
294 296
 			$this->_clear_cached_property( $field_name );
295
-		}else{
297
+		} else{
296 298
 			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
297 299
 		}
298 300
 
@@ -588,8 +590,9 @@  discard block
 block discarded – undo
588 590
 	 * @return void
589 591
 	 */
590 592
 	protected function _clear_cached_property( $property_name ) {
591
-		if ( isset( $this->_cached_properties[ $property_name ] ) )
592
-			unset( $this->_cached_properties[ $property_name ] );
593
+		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
594
+					unset( $this->_cached_properties[ $property_name ] );
595
+		}
593 596
 	}
594 597
 
595 598
 
@@ -629,10 +632,10 @@  discard block
 block discarded – undo
629 632
 		if($clear_all){
630 633
 			$obj_removed = true;
631 634
 			$this->_model_relations[$relationName]  = null;
632
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
635
+		} elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
633 636
 			$obj_removed = $this->_model_relations[$relationName];
634 637
 			$this->_model_relations[$relationName]  = null;
635
-		}else{
638
+		} else{
636 639
 			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
637 640
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
638 641
 				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
@@ -646,20 +649,20 @@  discard block
 block discarded – undo
646 649
 					}
647 650
 					if($index_found_at){
648 651
 						$index_in_cache = $index_found_at;
649
-					}else{
652
+					} else{
650 653
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
651 654
 						//if it wasn't in it to begin with. So we're done
652 655
 						return $object_to_remove_or_index_into_array;
653 656
 					}
654 657
 				}
655
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
658
+			} elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
656 659
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
657 660
 				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
658 661
 					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
659 662
 						$index_in_cache = $index;
660 663
 					}
661 664
 				}
662
-			}else{
665
+			} else{
663 666
 				$index_in_cache = $object_to_remove_or_index_into_array;
664 667
 			}
665 668
 			//supposedly we've found it. But it could just be that the client code
@@ -668,7 +671,7 @@  discard block
 block discarded – undo
668 671
 					isset( $this->_model_relations[$relationName][$index_in_cache])){
669 672
 				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
670 673
 				unset($this->_model_relations[$relationName][$index_in_cache]);
671
-			}else{
674
+			} else{
672 675
 				//that thing was never cached anyways.
673 676
 				$obj_removed = NULL;
674 677
 			}
@@ -724,7 +727,7 @@  discard block
 block discarded – undo
724 727
 		$cached_array_or_object =  $this->_model_relations[$relationName];
725 728
 		if(is_array($cached_array_or_object)){
726 729
 			return array_shift($cached_array_or_object);
727
-		}else{
730
+		} else{
728 731
 			return $cached_array_or_object;
729 732
 		}
730 733
 	}
@@ -743,10 +746,10 @@  discard block
 block discarded – undo
743 746
 		$cached_array_or_object =  $this->_model_relations[$relationName];
744 747
 		if(is_array($cached_array_or_object)){
745 748
 			$objects = $cached_array_or_object;
746
-		}elseif($cached_array_or_object){
749
+		} elseif($cached_array_or_object){
747 750
 			//if the result is not an array, but exists, make it an array
748 751
 			$objects = array($cached_array_or_object);
749
-		}else{
752
+		} else{
750 753
 			//if nothing was found, return an empty array
751 754
 			$objects = array();
752 755
 		}
@@ -761,7 +764,7 @@  discard block
 block discarded – undo
761 764
 				if( $model_object->ID() ){
762 765
 					$model->add_to_entity_map( $model_object );
763 766
 				}
764
-			}else{
767
+			} else{
765 768
 				throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object )));
766 769
 			}
767 770
 		}
@@ -886,10 +889,10 @@  discard block
 block discarded – undo
886 889
 				if( $field_obj->is_nullable()){
887 890
 					//if the field allows nulls, then let it be null
888 891
 					$field_value = NULL;
889
-				}else{
892
+				} else{
890 893
 					$field_value = $field_obj->get_default_value();
891 894
 				}
892
-			}else{
895
+			} else{
893 896
 				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
894 897
 			}
895 898
 			$this->_fields[$field_name] = $field_value;
@@ -1009,15 +1012,17 @@  discard block
 block discarded – undo
1009 1012
 			$this->_tm_frmt = $in_tm_frmt;
1010 1013
 		}
1011 1014
 
1012
-		if ( $echo )
1013
-			$field->set_pretty_date_format( $in_dt_frmt );
1014
-		else
1015
-			$field->set_date_format( $in_dt_frmt );
1015
+		if ( $echo ) {
1016
+					$field->set_pretty_date_format( $in_dt_frmt );
1017
+		} else {
1018
+					$field->set_date_format( $in_dt_frmt );
1019
+		}
1016 1020
 
1017
-		if ( $echo )
1018
-			$field->set_pretty_time_format( $in_tm_frmt );
1019
-		else
1020
-			$field->set_time_format( $in_tm_frmt );
1021
+		if ( $echo ) {
1022
+					$field->set_pretty_time_format( $in_tm_frmt );
1023
+		} else {
1024
+					$field->set_time_format( $in_tm_frmt );
1025
+		}
1021 1026
 
1022 1027
 		//set timezone in field object
1023 1028
 		$field->set_timezone( $this->_timezone );
@@ -1240,8 +1245,9 @@  discard block
 block discarded – undo
1240 1245
 		EE_Registry::instance()->load_helper('DTT_Helper');
1241 1246
 		$timezone = EEH_DTT_Helper::get_timezone();
1242 1247
 
1243
-		if ( $timezone == $this->_timezone )
1244
-			return '';
1248
+		if ( $timezone == $this->_timezone ) {
1249
+					return '';
1250
+		}
1245 1251
 
1246 1252
 		$original_timezone = $this->_timezone;
1247 1253
 		$this->set_timezone( $timezone );
@@ -1249,8 +1255,9 @@  discard block
 block discarded – undo
1249 1255
 		$fn = (array) $field_name;
1250 1256
 		$args = array_merge( $fn, (array) $args );
1251 1257
 
1252
-		if ( !method_exists( $this, $callback ) )
1253
-			throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1258
+		if ( !method_exists( $this, $callback ) ) {
1259
+					throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1260
+		}
1254 1261
 		$args = (array) $args;
1255 1262
 		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1256 1263
 
@@ -1292,7 +1299,7 @@  discard block
 block discarded – undo
1292 1299
 		$model=$this->get_model();
1293 1300
 		if($model instanceof EEM_Soft_Delete_Base){
1294 1301
 			$result=$model->delete_permanently_by_ID($this->ID());
1295
-		}else{
1302
+		} else{
1296 1303
 			$result = $this->delete();
1297 1304
 		}
1298 1305
 		return $result ? true : false;
@@ -1362,7 +1369,7 @@  discard block
 block discarded – undo
1362 1369
 						$this->_update_cached_related_model_objs_fks();
1363 1370
 					}
1364 1371
 				}
1365
-			}else{//PK is NOT auto-increment
1372
+			} else{//PK is NOT auto-increment
1366 1373
 				//so check if one like it already exists in the db
1367 1374
 				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1368 1375
 					if( ! $this->in_entity_map() && WP_DEBUG ){
@@ -1377,12 +1384,12 @@  discard block
 block discarded – undo
1377 1384
 						);
1378 1385
 					}
1379 1386
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1380
-				}else{
1387
+				} else{
1381 1388
 					$results = $this->get_model()->insert($save_cols_n_values);
1382 1389
 					$this->_update_cached_related_model_objs_fks();
1383 1390
 				}
1384 1391
 			}
1385
-		}else{//there is NO primary key
1392
+		} else{//there is NO primary key
1386 1393
 			$already_in_db = false;
1387 1394
 			foreach($this->get_model()->unique_indexes() as $index){
1388 1395
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
@@ -1393,7 +1400,7 @@  discard block
 block discarded – undo
1393 1400
 			if( $already_in_db ){
1394 1401
 				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1395 1402
 				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1396
-			}else{
1403
+			} else{
1397 1404
 				$results = $this->get_model()->insert( $save_cols_n_values );
1398 1405
 			}
1399 1406
 		}
@@ -1445,7 +1452,7 @@  discard block
 block discarded – undo
1445 1452
 		//make sure this has been saved
1446 1453
 		if( ! $this->ID()){
1447 1454
 			$id = $this->save();
1448
-		}else{
1455
+		} else{
1449 1456
 			$id = $this->ID();
1450 1457
 		}
1451 1458
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
@@ -1464,7 +1471,7 @@  discard block
 block discarded – undo
1464 1471
 						$this->_add_relation_to($related_model_obj, $relationName);
1465 1472
 						$related_model_obj->save_new_cached_related_model_objs();
1466 1473
 //					}
1467
-				}else{
1474
+				} else{
1468 1475
 					foreach($this->_model_relations[$relationName] as $related_model_obj){
1469 1476
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1470 1477
 						//but ONLY if it DOES NOT exist in the DB
@@ -1523,13 +1530,13 @@  discard block
 block discarded – undo
1523 1530
 
1524 1531
 			if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1525 1532
 				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] );
1526
-			}else{
1533
+			} else{
1527 1534
 				$existing = null;
1528 1535
 			}
1529
-		}elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1536
+		} elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1530 1537
 			//no primary key on this model, but there's still a matching item in the DB
1531 1538
 				$existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) );
1532
-		}else{
1539
+		} else{
1533 1540
 			$existing = null;
1534 1541
 		}
1535 1542
 		if ( $existing ) {
@@ -1587,7 +1594,7 @@  discard block
 block discarded – undo
1587 1594
 	private static function _get_model_classname( $model_name = null){
1588 1595
 		if(strpos($model_name,"EE_")===0){
1589 1596
 			$model_classname=str_replace("EE_","EEM_",$model_name);
1590
-		}else{
1597
+		} else{
1591 1598
 			$model_classname = "EEM_".$model_name;
1592 1599
 		}
1593 1600
 		return $model_classname;
@@ -1621,7 +1628,7 @@  discard block
 block discarded – undo
1621 1628
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1622 1629
 		if( $this->get_model()->has_primary_key_field() ) {
1623 1630
 			return $this->_fields[self::_get_primary_key_name( get_class($this) )];
1624
-		}else{
1631
+		} else{
1625 1632
 			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1626 1633
 		}
1627 1634
 	}
@@ -1679,7 +1686,7 @@  discard block
 block discarded – undo
1679 1686
 		if($this->ID()){//if this exists in the DB, save the relation change to the DB too
1680 1687
 			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query );
1681 1688
 			$this->clear_cache($relationName, $otherObject);
1682
-		}else{//this doesn't exist in the DB, just remove it from the cache
1689
+		} else{//this doesn't exist in the DB, just remove it from the cache
1683 1690
 			$otherObject = $this->clear_cache($relationName,$otherObjectModelObjectOrID);
1684 1691
 		}
1685 1692
 		return $otherObject;
@@ -1695,7 +1702,7 @@  discard block
 block discarded – undo
1695 1702
 		if($this->ID()){//if this exists in the DB, save the relation change to the DB too
1696 1703
 			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params );
1697 1704
 			$this->clear_cache($relationName,null,true);
1698
-		}else{//this doesn't exist in the DB, just remove it from the cache
1705
+		} else{//this doesn't exist in the DB, just remove it from the cache
1699 1706
 			$otherObjects = $this->clear_cache($relationName,null,true);
1700 1707
 		}
1701 1708
 		return $otherObjects;
@@ -1718,7 +1725,7 @@  discard block
 block discarded – undo
1718 1725
 			//if there are query parameters, forget about caching the related model objects.
1719 1726
 			if( $query_params ){
1720 1727
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1721
-			}else{
1728
+			} else{
1722 1729
 				//did we already cache the result of this query?
1723 1730
 				$cached_results = $this->get_all_from_cache($relationName);
1724 1731
 				if ( ! $cached_results ){
@@ -1728,11 +1735,11 @@  discard block
 block discarded – undo
1728 1735
 					foreach($related_model_objects as $related_model_object){
1729 1736
 						$this->cache($relationName, $related_model_object);
1730 1737
 					}
1731
-				}else{
1738
+				} else{
1732 1739
 					$related_model_objects = $cached_results;
1733 1740
 				}
1734 1741
 			}
1735
-		}else{//this doesn't exist itn eh DB, so just get the related things from the cache
1742
+		} else{//this doesn't exist itn eh DB, so just get the related things from the cache
1736 1743
 			$related_model_objects = $this->get_all_from_cache($relationName);
1737 1744
 		}
1738 1745
 		return $related_model_objects;
@@ -1784,22 +1791,22 @@  discard block
 block discarded – undo
1784 1791
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
1785 1792
 			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1786 1793
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1787
-			}else{
1794
+			} else{
1788 1795
 				//first, check if we've already cached the result of this query
1789 1796
 				$cached_result = $this->get_one_from_cache($relationName);
1790 1797
 				if ( ! $cached_result ){
1791 1798
 
1792 1799
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1793 1800
 					$this->cache($relationName,$related_model_object);
1794
-				}else{
1801
+				} else{
1795 1802
 					$related_model_object = $cached_result;
1796 1803
 				}
1797 1804
 			}
1798
-		}else{
1805
+		} else{
1799 1806
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
1800 1807
 			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1801 1808
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1802
-			}else{
1809
+			} else{
1803 1810
 				$related_model_object = null;
1804 1811
 			}
1805 1812
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
@@ -1825,7 +1832,7 @@  discard block
 block discarded – undo
1825 1832
 	public function delete_related($relationName,$query_params = array()){
1826 1833
 		if($this->ID()){
1827 1834
 			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
1828
-		}else{
1835
+		} else{
1829 1836
 			$count = count($this->get_all_from_cache($relationName));
1830 1837
 			$this->clear_cache($relationName,NULL,TRUE);
1831 1838
 		}
@@ -1845,7 +1852,7 @@  discard block
 block discarded – undo
1845 1852
 	public function delete_related_permanently($relationName,$query_params = array()){
1846 1853
 		if($this->ID()){
1847 1854
 			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1848
-		}else{
1855
+		} else{
1849 1856
 			$count = count($this->get_all_from_cache($relationName));
1850 1857
 		}
1851 1858
 		$this->clear_cache($relationName,NULL,TRUE);
@@ -1880,8 +1887,9 @@  discard block
 block discarded – undo
1880 1887
 
1881 1888
 		foreach ( (array) $properties as $property_name ) {
1882 1889
 			//first make sure this property exists
1883
-			if ( ! $this->_fields[ $property_name ] )
1884
-				throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1890
+			if ( ! $this->_fields[ $property_name ] ) {
1891
+							throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1892
+			}
1885 1893
 		}
1886 1894
 
1887 1895
 		return TRUE;
@@ -1961,7 +1969,7 @@  discard block
 block discarded – undo
1961 1969
 		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
1962 1970
 		if( ! $existing_rows_like_that){
1963 1971
 			return $this->add_extra_meta($meta_key, $meta_value);
1964
-		}else{
1972
+		} else{
1965 1973
 			foreach( $existing_rows_like_that as $existing_row){
1966 1974
 				$existing_row->save( array( 'EXM_value' => $meta_value ) );
1967 1975
 			}
@@ -2027,10 +2035,10 @@  discard block
 block discarded – undo
2027 2035
 			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2028 2036
 			if ( $result instanceof EE_Extra_Meta ){
2029 2037
 				return $result->value();
2030
-			}else{
2038
+			} else{
2031 2039
 				return $default;
2032 2040
 			}
2033
-		}else{
2041
+		} else{
2034 2042
 			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2035 2043
 			if($results){
2036 2044
 				$values = array();
@@ -2040,7 +2048,7 @@  discard block
 block discarded – undo
2040 2048
 					}
2041 2049
 				}
2042 2050
 				return $values;
2043
-			}else{
2051
+			} else{
2044 2052
 				return $default;
2045 2053
 			}
2046 2054
 		}
@@ -2066,7 +2074,7 @@  discard block
 block discarded – undo
2066 2074
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2067 2075
 				}
2068 2076
 			}
2069
-		}else{
2077
+		} else{
2070 2078
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2071 2079
 			foreach($extra_meta_objs as $extra_meta_obj){
2072 2080
 				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
@@ -2088,7 +2096,7 @@  discard block
 block discarded – undo
2088 2096
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2089 2097
 		if($field_we_can_use){
2090 2098
 			return $this->get($field_we_can_use->get_name());
2091
-		}else{
2099
+		} else{
2092 2100
 			$first_few_properties = $this->model_field_array();
2093 2101
 			$first_few_properties = array_slice($first_few_properties,0,3);
2094 2102
 			$name_parts = array();
@@ -2108,7 +2116,7 @@  discard block
 block discarded – undo
2108 2116
 		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2109 2117
 			//well, if we looked, did we find it in the entity map?
2110 2118
 			return TRUE;
2111
-		}else{
2119
+		} else{
2112 2120
 			return FALSE;
2113 2121
 		}
2114 2122
 	}
@@ -2122,7 +2130,7 @@  discard block
 block discarded – undo
2122 2130
 	public function refresh_from_db(){
2123 2131
 		if( $this->ID() && $this->in_entity_map() ){
2124 2132
 			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2125
-		}else{
2133
+		} else{
2126 2134
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2127 2135
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2128 2136
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -47,25 +47,25 @@
 block discarded – undo
47 47
 
48 48
 
49 49
 	/**
50
-    *	date format
51
-	*
52
-    *	pattern or format for displaying dates
53
-	*
54
-	*	@access	protected
55
-    *	@var string
56
-    */
50
+	 *	date format
51
+	 *
52
+	 *	pattern or format for displaying dates
53
+	 *
54
+	 *	@access	protected
55
+	 *	@var string
56
+	 */
57 57
 	protected $_dt_frmt;
58 58
 
59 59
 
60 60
 
61
-    /**
62
-    *	time format
63
-	*
64
-    *	pattern or format for displaying time
65
-	*
66
-	*	@access	protected
67
-    *	@var string
68
-    */
61
+	/**
62
+	 *	time format
63
+	 *
64
+	 *	pattern or format for displaying time
65
+	 *
66
+	 *	@access	protected
67
+	 *	@var string
68
+	 */
69 69
 	protected $_tm_frmt;
70 70
 
71 71
 
Please login to merge, or discard this patch.
Spacing   +446 added lines, -446 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, ' FILE LOADED', '');
3 3
 /**
4 4
  *
5 5
  * Event Espresso
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -108,60 +108,60 @@  discard block
 block discarded – undo
108 108
 	 * @throws EE_Error
109 109
 	 * @return \EE_Base_Class
110 110
 	 */
111
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
111
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
112 112
 
113
-		$className=get_class($this);
113
+		$className = get_class($this);
114 114
 
115
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
116
-		$model=$this->get_model();
117
-		$model_fields = $model->field_settings( FALSE );
115
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
116
+		$model = $this->get_model();
117
+		$model_fields = $model->field_settings(FALSE);
118 118
 		// ensure $fieldValues is an array
119
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
119
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
120 120
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
121 121
 		// verify client code has not passed any invalid field names
122
-		foreach($fieldValues as $field_name=> $field_value){
123
-			if( ! isset( $model_fields[ $field_name] ) ){
124
-				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields))));
122
+		foreach ($fieldValues as $field_name=> $field_value) {
123
+			if ( ! isset($model_fields[$field_name])) {
124
+				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields))));
125 125
 			}
126 126
 		}
127 127
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
128
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
129
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
128
+		EE_Registry::instance()->load_helper('DTT_Helper');
129
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
130 130
 
131
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
131
+		if ( ! empty($date_formats) && is_array($date_formats)) {
132 132
 			$this->_dt_frmt = $date_formats[0];
133 133
 			$this->_tm_frmt = $date_formats[1];
134 134
 		} else {
135 135
 			//set default formats for date and time
136
-			$this->_dt_frmt = get_option( 'date_format' );
137
-			$this->_tm_frmt = get_option( 'time_format' );
136
+			$this->_dt_frmt = get_option('date_format');
137
+			$this->_tm_frmt = get_option('time_format');
138 138
 		}
139 139
 
140 140
 		//if db model is instantiating
141
-		if ( $bydb ){
141
+		if ($bydb) {
142 142
 			//client code has indicated these field values are from the database
143
-			foreach( $model_fields as $fieldName => $field ){
144
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
143
+			foreach ($model_fields as $fieldName => $field) {
144
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
145 145
 			}
146 146
 		} else {
147 147
 			//we're constructing a brand
148 148
 			//new instance of the model object. Generally, this means we'll need to do more field validation
149
-			foreach( $model_fields as $fieldName => $field ){
150
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
149
+			foreach ($model_fields as $fieldName => $field) {
150
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
151 151
 			}
152 152
 		}
153 153
 
154 154
 		//remember what values were passed to this constructor
155 155
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
156 156
 		//remember in entity mapper
157
-		if($model->has_primary_key_field() && $this->ID() && ! $bydb ){
157
+		if ($model->has_primary_key_field() && $this->ID() && ! $bydb) {
158 158
 			$model->add_to_entity_map($this);
159 159
 		}
160 160
 		//setup all the relations
161
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
162
-			if($relation_obj instanceof EE_Belongs_To_Relation){
161
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
162
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
163 163
 				$this->_model_relations[$relation_name] = NULL;
164
-			}else{
164
+			} else {
165 165
 				$this->_model_relations[$relation_name] = array();
166 166
 			}
167 167
 		}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		 * Action done at the end of each model object construction
170 170
 		 * @param EE_Base_Class $this the model object just created
171 171
 		 */
172
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
172
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
173 173
 	}
174 174
 
175 175
 
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 	 * @param string $field_name
182 182
 	 * @return mixed|null
183 183
 	 */
184
-	public function get_original( $field_name ){
185
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
186
-				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
187
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
188
-		}else{
184
+	public function get_original($field_name) {
185
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
186
+				$field_settings = $this->get_Model()->field_settings_for($field_name)) {
187
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
188
+		} else {
189 189
 			return NULL;
190 190
 		}
191 191
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @param EE_Base_Class $obj
196 196
 	 * @return string
197 197
 	 */
198
-	public function get_class($obj){
198
+	public function get_class($obj) {
199 199
 		return get_class($obj);
200 200
 	}
201 201
 
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
 	 * @param	mixed 	$field_value
209 209
 	 * @param bool 	$use_default
210 210
 	 */
211
-	public function set( $field_name, $field_value, $use_default = FALSE ){
212
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
213
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
211
+	public function set($field_name, $field_value, $use_default = FALSE) {
212
+		$field_obj = $this->get_model()->field_settings_for($field_name);
213
+		if ($field_obj instanceof EE_Model_Field_Base) {
214 214
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
215
-			if ( $field_obj instanceof EE_Datetime_Field ) {
216
-				$field_obj->set_timezone( $this->_timezone );
217
-				$field_obj->set_date_format( $this->_dt_frmt );
218
-				$field_obj->set_time_format( $this->_tm_frmt );
215
+			if ($field_obj instanceof EE_Datetime_Field) {
216
+				$field_obj->set_timezone($this->_timezone);
217
+				$field_obj->set_date_format($this->_dt_frmt);
218
+				$field_obj->set_time_format($this->_tm_frmt);
219 219
 			}
220 220
 
221 221
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
222 222
 			//should the value be null?
223
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
223
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
224 224
 				$this->_fields[$field_name] = $field_obj->get_default_value();
225 225
 
226 226
 				/**
@@ -230,19 +230,19 @@  discard block
 block discarded – undo
230 230
 				 * object.
231 231
 				 * @since 4.6.10+
232 232
 				 */
233
-				if ( $field_obj instanceof EE_Datetime_Field && ! is_null( $this->_fields[$field_name] ) && ! $this->_fields[$field_name] instanceof DateTime ) {
234
-					empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] );
233
+				if ($field_obj instanceof EE_Datetime_Field && ! is_null($this->_fields[$field_name]) && ! $this->_fields[$field_name] instanceof DateTime) {
234
+					empty($this->_fields[$field_name]) ? $this->set($field_name, time()) : $this->set($field_name, $this->_fields[$field_name]);
235 235
 				}
236 236
 
237
-			}else{
237
+			} else {
238 238
 				$this->_fields[$field_name] = $holder_of_value;
239 239
 			}
240 240
 
241 241
 			//if we're not in the constructor...
242 242
 			//now check if what we set was a primary key
243
-			if($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor
243
+			if ($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor
244 244
 				$field_name == $this->_get_primary_key_name(get_class($this)) &&
245
-				$field_value){
245
+				$field_value) {
246 246
 				//if so, we want all this object's fields to be filled either with
247 247
 				//what we've explicitly set on this model
248 248
 				//or what we have in the db
@@ -250,20 +250,20 @@  discard block
 block discarded – undo
250 250
 				$fields_on_model = $this->_get_model(get_class($this))->field_settings();
251 251
 
252 252
 				$obj_in_db = $this->_get_model(get_class($this))->get_one_by_ID($field_value);
253
-				foreach($fields_on_model as $field_obj){
254
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
255
-						&& $field_obj->get_name() != $field_name ){
253
+				foreach ($fields_on_model as $field_obj) {
254
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
255
+						&& $field_obj->get_name() != $field_name) {
256 256
 
257
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
257
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
258 258
 					}
259 259
 				}
260 260
 				//oh this model object has an ID? well make sure its in the entity mapper
261 261
 				$this->get_model()->add_to_entity_map($this);
262 262
 			}
263 263
 			//let's unset any cache for this field_name from the $_cached_properties property.
264
-			$this->_clear_cached_property( $field_name );
265
-		}else{
266
-			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
264
+			$this->_clear_cached_property($field_name);
265
+		} else {
266
+			throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name));
267 267
 		}
268 268
 
269 269
 	}
@@ -278,19 +278,19 @@  discard block
 block discarded – undo
278 278
 	 * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
279 279
 	 * @return void
280 280
 	 */
281
-	public function set_timezone( $timezone = '' ) {
281
+	public function set_timezone($timezone = '') {
282 282
 		EE_Registry::instance()->load_helper('DTT_Helper');
283
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
283
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
284 284
 		//make sure we clear all cached properties because they won't be relevant now
285 285
 		$this->_clear_cached_properties();
286 286
 
287 287
 		//make sure we update field settings and the date for all EE_Datetime_Fields
288
-		$model_fields = $this->get_model()->field_settings( false );
289
-		foreach ( $model_fields as $field_name => $field_obj ) {
290
-			if ( $field_obj instanceof EE_Datetime_Field ) {
291
-				$field_obj->set_timezone( $this->_timezone );
292
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
293
-					$this->_fields[$field_name]->setTimeZone( new DateTimeZone( $this->_timezone ) );
288
+		$model_fields = $this->get_model()->field_settings(false);
289
+		foreach ($model_fields as $field_name => $field_obj) {
290
+			if ($field_obj instanceof EE_Datetime_Field) {
291
+				$field_obj->set_timezone($this->_timezone);
292
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
293
+					$this->_fields[$field_name]->setTimeZone(new DateTimeZone($this->_timezone));
294 294
 				}
295 295
 			}
296 296
 		}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 *
320 320
 	 * @param string $format   should be a format recognizable by PHP date() functions.
321 321
 	 */
322
-	public function set_date_format( $format ) {
322
+	public function set_date_format($format) {
323 323
 		$this->_dt_frmt = $format;
324 324
 		//clear cached_properties because they won't be relevant now.
325 325
 		$this->_clear_cached_properties();
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	 * @since 4.6
336 336
 	 * @param string $format should be a format recognizable by PHP date() functions.
337 337
 	 */
338
-	public function set_time_format( $format ) {
338
+	public function set_time_format($format) {
339 339
 		$this->_tm_frmt = $format;
340 340
 		//clear cached_properties because they won't be relevant now.
341 341
 		$this->_clear_cached_properties();
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 *
353 353
 	 * @return mixed string|array
354 354
 	 */
355
-	public function get_format( $full = true ) {
356
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
355
+	public function get_format($full = true) {
356
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
357 357
 	}
358 358
 
359 359
 
@@ -371,17 +371,17 @@  discard block
 block discarded – undo
371 371
 	 * @throws EE_Error
372 372
 	 * @return mixed    index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array)
373 373
 	 */
374
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
374
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
375 375
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
376
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
376
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
377 377
 			return FALSE;
378 378
 		}
379 379
 		// also get "how" the object is related, or throw an error
380
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
381
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
380
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
381
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
382 382
 		}
383 383
 		// how many things are related ?
384
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
384
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
385 385
 			// if it's a "belongs to" relationship, then there's only one related model object  eg, if this is a registration, there's only 1 attendee for it
386 386
 			// so for these model objects just set it to be cached
387 387
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -389,26 +389,26 @@  discard block
 block discarded – undo
389 389
 		} else {
390 390
 			// otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type.
391 391
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
392
-			if( ! is_array( $this->_model_relations[$relationName] )) {
392
+			if ( ! is_array($this->_model_relations[$relationName])) {
393 393
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
394
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
394
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
395 395
 			}
396 396
 			// first check for a cache_id which is normally empty
397
-			if ( ! empty( $cache_id )) {
397
+			if ( ! empty($cache_id)) {
398 398
 				// if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on
399
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
399
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
400 400
 				$return = $cache_id;
401
-			} elseif ( $object_to_cache->ID() ) {
401
+			} elseif ($object_to_cache->ID()) {
402 402
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
403
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
403
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
404 404
 				$return = $object_to_cache->ID();
405 405
 			} else {
406 406
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
407 407
 				$this->_model_relations[$relationName][] = $object_to_cache;
408 408
 				  // move the internal pointer to the end of the array
409
-				end( $this->_model_relations[$relationName] );
409
+				end($this->_model_relations[$relationName]);
410 410
 				// and grab the key so that we can return it
411
-				$return = key( $this->_model_relations[$relationName] );
411
+				$return = key($this->_model_relations[$relationName]);
412 412
 			}
413 413
 
414 414
 		}
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 	 * @param null   $cache_type
427 427
 	 * @return void
428 428
 	 */
429
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
429
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
430 430
 		//first make sure this property exists
431 431
 		$this->get_model()->field_settings_for($fieldname);
432 432
 
433
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
433
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
434 434
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
435 435
 	}
436 436
 
@@ -445,34 +445,34 @@  discard block
 block discarded – undo
445 445
 	 *                                 It can also accept certain pre-defined "schema" strings to define how to output the property. see the field's prepare_for_pretty_echoing for what strings can be used
446 446
 	 * @return mixed                whatever the value for the property is we're retrieving
447 447
 	 */
448
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
448
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
449 449
 		//verify the field exists
450 450
 		$this->get_model()->field_settings_for($fieldname);
451 451
 
452 452
 		$cache_type = $pretty ? 'pretty' : 'standard';
453
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
453
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
454 454
 
455
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
455
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
456 456
 			return $this->_cached_properties[$fieldname][$cache_type];
457 457
 		}
458 458
 
459 459
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
460
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
460
+		if ($field_obj instanceof EE_Model_Field_Base) {
461 461
 			/**
462 462
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
463 463
 			 * formats are correct.
464 464
 			 */
465
-			if ( $field_obj instanceof EE_Datetime_Field ) {
466
-				$field_obj->set_timezone( $this->_timezone );
467
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
468
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
465
+			if ($field_obj instanceof EE_Datetime_Field) {
466
+				$field_obj->set_timezone($this->_timezone);
467
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
468
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
469 469
 			}
470 470
 
471
-			if( ! isset($this->_fields[$fieldname])){
471
+			if ( ! isset($this->_fields[$fieldname])) {
472 472
 				$this->_fields[$fieldname] = NULL;
473 473
 			}
474
-			$value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname] );
475
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
474
+			$value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname]);
475
+			$this->_set_cached_property($fieldname, $value, $cache_type);
476 476
 			return $value;
477 477
 		}
478 478
 		return FALSE;
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
499 499
 	 * @return void
500 500
 	 */
501
-	protected function _clear_cached_property( $property_name ) {
502
-		if ( isset( $this->_cached_properties[ $property_name ] ) )
503
-			unset( $this->_cached_properties[ $property_name ] );
501
+	protected function _clear_cached_property($property_name) {
502
+		if (isset($this->_cached_properties[$property_name]))
503
+			unset($this->_cached_properties[$property_name]);
504 504
 	}
505 505
 
506 506
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 * @param string $model_name name of the related thing, eg 'Attendee',
512 512
 	 * @return EE_Base_Class
513 513
 	 */
514
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
514
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
515 515
 		$other_model_instance = self::_get_model_instance_with_name(self::_get_model_classname($model_name), $this->_timezone);
516 516
 		$model_obj = $other_model_instance->ensure_is_obj($object_or_id);
517 517
 		return $model_obj;
@@ -531,55 +531,55 @@  discard block
 block discarded – undo
531 531
 	 * @throws EE_Error
532 532
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
533 533
 	 */
534
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
534
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
535 535
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
536 536
 		$index_in_cache = '';
537
-		if( ! $relationship_to_model){
538
-			throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache",'event_espresso'),$relationName,get_class($this)));
537
+		if ( ! $relationship_to_model) {
538
+			throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), $relationName, get_class($this)));
539 539
 		}
540
-		if($clear_all){
540
+		if ($clear_all) {
541 541
 			$obj_removed = true;
542 542
 			$this->_model_relations[$relationName]  = null;
543
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
543
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
544 544
 			$obj_removed = $this->_model_relations[$relationName];
545 545
 			$this->_model_relations[$relationName]  = null;
546
-		}else{
547
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
546
+		} else {
547
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
548 548
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
549
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
549
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
550 550
 					$index_found_at = NULL;
551 551
 					//find this object in the array even though it has a different key
552
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
553
-						if( $obj instanceof EE_Base_Class && ( $obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID() )) {
552
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
553
+						if ($obj instanceof EE_Base_Class && ($obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID())) {
554 554
 							$index_found_at = $index;
555 555
 							break;
556 556
 						}
557 557
 					}
558
-					if($index_found_at){
558
+					if ($index_found_at) {
559 559
 						$index_in_cache = $index_found_at;
560
-					}else{
560
+					} else {
561 561
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
562 562
 						//if it wasn't in it to begin with. So we're done
563 563
 						return $object_to_remove_or_index_into_array;
564 564
 					}
565 565
 				}
566
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
566
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
567 567
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
568
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
569
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
568
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
569
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
570 570
 						$index_in_cache = $index;
571 571
 					}
572 572
 				}
573
-			}else{
573
+			} else {
574 574
 				$index_in_cache = $object_to_remove_or_index_into_array;
575 575
 			}
576 576
 			//supposedly we've found it. But it could just be that the client code
577 577
 			//provided a bad index/object
578
-			if(isset( $this->_model_relations[$relationName]) &&
579
-					isset( $this->_model_relations[$relationName][$index_in_cache])){
578
+			if (isset($this->_model_relations[$relationName]) &&
579
+					isset($this->_model_relations[$relationName][$index_in_cache])) {
580 580
 				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
581 581
 				unset($this->_model_relations[$relationName][$index_in_cache]);
582
-			}else{
582
+			} else {
583 583
 				//that thing was never cached anyways.
584 584
 				$obj_removed = NULL;
585 585
 			}
@@ -598,24 +598,24 @@  discard block
 block discarded – undo
598 598
 	 * @param string                $current_cache_id   - the ID that was used when originally caching the object
599 599
 	 * @return boolean TRUE on success, FALSE on fail
600 600
 	 */
601
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
601
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
602 602
 		// verify that incoming object is of the correct type
603
-		$obj_class = 'EE_' . $relationName;
604
-		if ( $newly_saved_object instanceof $obj_class ) {
603
+		$obj_class = 'EE_'.$relationName;
604
+		if ($newly_saved_object instanceof $obj_class) {
605 605
 			/* @type EE_Base_Class $newly_saved_object*/
606 606
 			// now get the type of relation
607
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
607
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
608 608
 			// if this is a 1:1 relationship
609
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
609
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
610 610
 				// then just replace the cached object with the newly saved object
611 611
 				$this->_model_relations[$relationName] = $newly_saved_object;
612 612
 				return TRUE;
613 613
 			// or if it's some kind of sordid feral polyamorous relationship...
614
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
614
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
615 615
 				// then remove the current cached item
616
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
616
+				unset($this->_model_relations[$relationName][$current_cache_id]);
617 617
 				// and cache the newly saved object using it's new ID
618
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
618
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
619 619
 				return TRUE;
620 620
 			}
621 621
 		}
@@ -631,11 +631,11 @@  discard block
 block discarded – undo
631 631
 	 * @param string $relationName
632 632
 	 * @return EE_Base_Class
633 633
 	 */
634
-	public function get_one_from_cache($relationName){
635
-		$cached_array_or_object =  $this->_model_relations[$relationName];
636
-		if(is_array($cached_array_or_object)){
634
+	public function get_one_from_cache($relationName) {
635
+		$cached_array_or_object = $this->_model_relations[$relationName];
636
+		if (is_array($cached_array_or_object)) {
637 637
 			return array_shift($cached_array_or_object);
638
-		}else{
638
+		} else {
639 639
 			return $cached_array_or_object;
640 640
 		}
641 641
 	}
@@ -650,14 +650,14 @@  discard block
 block discarded – undo
650 650
 	 * @throws \EE_Error
651 651
 	 * @return EE_Base_Class[]
652 652
 	 */
653
-	public function get_all_from_cache($relationName){
654
-		$cached_array_or_object =  $this->_model_relations[$relationName];
655
-		if(is_array($cached_array_or_object)){
653
+	public function get_all_from_cache($relationName) {
654
+		$cached_array_or_object = $this->_model_relations[$relationName];
655
+		if (is_array($cached_array_or_object)) {
656 656
 			$objects = $cached_array_or_object;
657
-		}elseif($cached_array_or_object){
657
+		}elseif ($cached_array_or_object) {
658 658
 			//if the result is not an array, but exists, make it an array
659 659
 			$objects = array($cached_array_or_object);
660
-		}else{
660
+		} else {
661 661
 			//if nothing was found, return an empty array
662 662
 			$objects = array();
663 663
 		}
@@ -665,15 +665,15 @@  discard block
 block discarded – undo
665 665
 		//basically, if this model object was stored in the session, and these cached model objects
666 666
 		//already have IDs, let's make sure they're in their model's entity mapper
667 667
 		//otherwise we will have duplicates next time we call EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
668
-		foreach( $objects as $model_object ){
669
-			$model = EE_Registry::instance()->load_model( $relationName );
670
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
668
+		foreach ($objects as $model_object) {
669
+			$model = EE_Registry::instance()->load_model($relationName);
670
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
671 671
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
672
-				if( $model_object->ID() ){
673
-					$model->add_to_entity_map( $model_object );
672
+				if ($model_object->ID()) {
673
+					$model->add_to_entity_map($model_object);
674 674
 				}
675
-			}else{
676
-				throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object )));
675
+			} else {
676
+				throw new EE_Error(sprintf(__('Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso'), $relationName, gettype($model_object)));
677 677
 			}
678 678
 		}
679 679
 		return $objects;
@@ -692,13 +692,13 @@  discard block
 block discarded – undo
692 692
 	 *
693 693
 	 * @return array|EE_Base_Class[]
694 694
 	 */
695
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
696
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
697
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
698
-		if ( empty( $field ) || empty( $current_value ) ) {
695
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
696
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
697
+		$current_value = ! empty($field) ? $this->get($field) : null;
698
+		if (empty($field) || empty($current_value)) {
699 699
 			return array();
700 700
 		}
701
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
701
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
702 702
 	}
703 703
 
704 704
 
@@ -717,13 +717,13 @@  discard block
 block discarded – undo
717 717
 	 *
718 718
 	 * @return array|EE_Base_Class[]
719 719
 	 */
720
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
721
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
722
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
723
-		if ( empty( $field ) || empty( $current_value ) ) {
720
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
721
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
722
+		$current_value = ! empty($field) ? $this->get($field) : null;
723
+		if (empty($field) || empty($current_value)) {
724 724
 			return array();
725 725
 		}
726
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
726
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
727 727
 	}
728 728
 
729 729
 
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
 	 *
742 742
 	 * @return array|EE_Base_Class
743 743
 	 */
744
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
745
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
746
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
747
-		if ( empty( $field ) || empty( $current_value ) ) {
744
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
745
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
746
+		$current_value = ! empty($field) ? $this->get($field) : null;
747
+		if (empty($field) || empty($current_value)) {
748 748
 			return array();
749 749
 		}
750
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
750
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
751 751
 	}
752 752
 
753 753
 
@@ -766,13 +766,13 @@  discard block
 block discarded – undo
766 766
 	 *
767 767
 	 * @return array|EE_Base_Class
768 768
 	 */
769
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
770
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
771
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
772
-		if ( empty( $field ) || empty( $current_value ) ) {
769
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
770
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
771
+		$current_value = ! empty($field) ? $this->get($field) : null;
772
+		if (empty($field) || empty($current_value)) {
773 773
 			return array();
774 774
 		}
775
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
775
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
776 776
 	}
777 777
 
778 778
 
@@ -786,25 +786,25 @@  discard block
 block discarded – undo
786 786
 	 * @param string $field_name
787 787
 	 * @param mixed  $field_value_from_db
788 788
 	 */
789
-	public function set_from_db($field_name,$field_value_from_db){
789
+	public function set_from_db($field_name, $field_value_from_db) {
790 790
 		$field_obj = $this->get_model()->field_settings_for($field_name);
791
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
791
+		if ($field_obj instanceof EE_Model_Field_Base) {
792 792
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
793 793
 			//eg, a CPT model object could have an entry in the posts table, but no
794 794
 			//entry in the meta table. Meaning that all its columns in the meta table
795 795
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
796
-			if($field_value_from_db === NULL ){
797
-				if( $field_obj->is_nullable()){
796
+			if ($field_value_from_db === NULL) {
797
+				if ($field_obj->is_nullable()) {
798 798
 					//if the field allows nulls, then let it be null
799 799
 					$field_value = NULL;
800
-				}else{
800
+				} else {
801 801
 					$field_value = $field_obj->get_default_value();
802 802
 				}
803
-			}else{
804
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
803
+			} else {
804
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
805 805
 			}
806 806
 			$this->_fields[$field_name] = $field_value;
807
-			$this->_clear_cached_property( $field_name );
807
+			$this->_clear_cached_property($field_name);
808 808
 		}
809 809
 	}
810 810
 
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 	 * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
817 817
 	 * @return boolean
818 818
 	 */
819
-	public function get($field_name, $extra_cache_ref = NULL ){
820
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
819
+	public function get($field_name, $extra_cache_ref = NULL) {
820
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
821 821
 	}
822 822
 
823 823
 
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 	 *                    				     just null is returned (because that indicates that likely
848 848
 	 *                    				     this field is nullable).
849 849
 	 */
850
-	public function get_DateTime_object( $field_name ) {
851
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
850
+	public function get_DateTime_object($field_name) {
851
+		$field_settings = $this->get_model()->field_settings_for($field_name);
852 852
 
853
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
854
-			EE_Error::add_error( sprintf( __('The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.', 'event_espresso' ), $field_name ), __FILE__, __FUNCTION__, __LINE__ );
853
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
854
+			EE_Error::add_error(sprintf(__('The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.', 'event_espresso'), $field_name), __FILE__, __FUNCTION__, __LINE__);
855 855
 			return false;
856 856
 		}
857 857
 
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 	 * @param string         $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
868 868
 	 * @return void
869 869
 	 */
870
-	public function e($field_name, $extra_cache_ref = NULL){
870
+	public function e($field_name, $extra_cache_ref = NULL) {
871 871
 		echo $this->get_pretty($field_name, $extra_cache_ref);
872 872
 	}
873 873
 	/**
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 * @param string $field_name
877 877
 	 * @return void
878 878
 	 */
879
-	public function f($field_name){
880
-		$this->e($field_name,'form_input');
879
+	public function f($field_name) {
880
+		$this->e($field_name, 'form_input');
881 881
 	}
882 882
 
883 883
 	/**
@@ -886,8 +886,8 @@  discard block
 block discarded – undo
886 886
 	 * @param string         $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
887 887
 	 * @return mixed
888 888
 	 */
889
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
890
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
889
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
890
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
891 891
 	}
892 892
 
893 893
 
@@ -904,37 +904,37 @@  discard block
 block discarded – undo
904 904
 	 * @param  boolean $echo         Whether the dtt is echoing using pretty echoing or just returned using vanilla get
905 905
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
906 906
 	 */
907
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
907
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
908 908
 
909
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
909
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
910 910
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
911 911
 
912 912
 		//validate field for datetime and returns field settings if valid.
913
-		$field = $this->_get_dtt_field_settings( $field_name );
913
+		$field = $this->_get_dtt_field_settings($field_name);
914 914
 
915 915
 		//clear cached property if either formats are not null.
916
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
917
-			$this->_clear_cached_property( $field_name, $date_or_time );
916
+		if ($dt_frmt !== null || $tm_frmt !== null) {
917
+			$this->_clear_cached_property($field_name, $date_or_time);
918 918
 			//reset format properties because they are used in get()
919 919
 			$this->_dt_frmt = $in_dt_frmt;
920 920
 			$this->_tm_frmt = $in_tm_frmt;
921 921
 		}
922 922
 
923
-		if ( $echo )
924
-			$field->set_pretty_date_format( $in_dt_frmt );
923
+		if ($echo)
924
+			$field->set_pretty_date_format($in_dt_frmt);
925 925
 		else
926
-			$field->set_date_format( $in_dt_frmt );
926
+			$field->set_date_format($in_dt_frmt);
927 927
 
928
-		if ( $echo )
929
-			$field->set_pretty_time_format( $in_tm_frmt );
928
+		if ($echo)
929
+			$field->set_pretty_time_format($in_tm_frmt);
930 930
 		else
931
-			$field->set_time_format( $in_tm_frmt );
931
+			$field->set_time_format($in_tm_frmt);
932 932
 
933 933
 		//set timezone in field object
934
-		$field->set_timezone( $this->_timezone );
934
+		$field->set_timezone($this->_timezone);
935 935
 
936 936
 		//set the output returned
937
-		switch ( $date_or_time ) {
937
+		switch ($date_or_time) {
938 938
 
939 939
 			case 'D' :
940 940
 				$field->set_date_time_output('date');
@@ -949,11 +949,11 @@  discard block
 block discarded – undo
949 949
 		}
950 950
 
951 951
 
952
-		if ( $echo ) {
953
-			$this->e( $field_name, $date_or_time );
952
+		if ($echo) {
953
+			$this->e($field_name, $date_or_time);
954 954
 			return '';
955 955
 		 }
956
-		return $this->get( $field_name, $date_or_time );
956
+		return $this->get($field_name, $date_or_time);
957 957
 	}
958 958
 
959 959
 
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
 	 * @param  string $format     format for the date returned (if NULL we use default in dt_frmt property)
964 964
 	 * @return string            datetime value formatted
965 965
 	 */
966
-	public function get_date( $field_name, $format = NULL ) {
967
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
966
+	public function get_date($field_name, $format = NULL) {
967
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
968 968
 	}
969 969
 
970 970
 
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 	 * @param      $field_name
974 974
 	 * @param null $format
975 975
 	 */
976
-	public function e_date( $field_name, $format = NULL ) {
977
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
976
+	public function e_date($field_name, $format = NULL) {
977
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
978 978
 	}
979 979
 
980 980
 
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
 	 * @param  string $format     format for the time returned ( if NULL we use default in tm_frmt property)
985 985
 	 * @return string             datetime value formatted
986 986
 	 */
987
-	public function get_time( $field_name, $format = NULL ) {
988
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
987
+	public function get_time($field_name, $format = NULL) {
988
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
989 989
 	}
990 990
 
991 991
 
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
 	 * @param      $field_name
995 995
 	 * @param null $format
996 996
 	 */
997
-	public function e_time( $field_name, $format = NULL ) {
998
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
997
+	public function e_time($field_name, $format = NULL) {
998
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
999 999
 	}
1000 1000
 
1001 1001
 
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
 	 * @param  string $tm_frmt    format for the time returned (if NULL we use default in tm_frmt property)
1009 1009
 	 * @return string             datetime value formatted
1010 1010
 	 */
1011
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1012
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1011
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1012
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1013 1013
 	}
1014 1014
 
1015 1015
 
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 	 * @param null $dt_frmt
1020 1020
 	 * @param null $tm_frmt
1021 1021
 	 */
1022
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1023
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1022
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1023
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1024 1024
 	}
1025 1025
 
1026 1026
 
@@ -1035,10 +1035,10 @@  discard block
 block discarded – undo
1035 1035
 	 * @return string Date and time string in set locale or false if no field exists for the given
1036 1036
 	 *                         field name.
1037 1037
 	 */
1038
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1039
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1040
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1041
-		return date_i18n( $format, EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) );
1038
+	public function get_i18n_datetime($field_name, $format = NULL) {
1039
+		EE_Registry::instance()->load_helper('DTT_Helper');
1040
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1041
+		return date_i18n($format, EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone));
1042 1042
 	}
1043 1043
 
1044 1044
 
@@ -1050,14 +1050,14 @@  discard block
 block discarded – undo
1050 1050
 	 * @throws EE_Error
1051 1051
 	 * @return EE_Datetime_Field
1052 1052
 	 */
1053
-	protected function _get_dtt_field_settings( $field_name ) {
1053
+	protected function _get_dtt_field_settings($field_name) {
1054 1054
 		$field = $this->get_model()->field_settings_for($field_name);
1055 1055
 
1056 1056
 		//check if field is dtt
1057
-		if ( $field instanceof EE_Datetime_Field ) {
1057
+		if ($field instanceof EE_Datetime_Field) {
1058 1058
 			return $field;
1059 1059
 		} else {
1060
-			throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) );
1060
+			throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this))));
1061 1061
 		}
1062 1062
 	}
1063 1063
 
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 	 * @param string|Datetime $time      a valid time string for php datetime functions (or DateTime object)
1079 1079
 	 * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1080 1080
 	 */
1081
-	protected function _set_time_for( $time, $fieldname ) {
1082
-		$this->_set_date_time( 'T', $time, $fieldname );
1081
+	protected function _set_time_for($time, $fieldname) {
1082
+		$this->_set_date_time('T', $time, $fieldname);
1083 1083
 	}
1084 1084
 
1085 1085
 
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	 * @param string|DateTime $date      a valid date string for php datetime functions ( or DateTime object)
1094 1094
 	 * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1095 1095
 	 */
1096
-	protected function _set_date_for( $date, $fieldname ) {
1097
-		$this->_set_date_time( 'D', $date, $fieldname );
1096
+	protected function _set_date_for($date, $fieldname) {
1097
+		$this->_set_date_time('D', $date, $fieldname);
1098 1098
 	}
1099 1099
 
1100 1100
 
@@ -1110,21 +1110,21 @@  discard block
 block discarded – undo
1110 1110
 	 * @param string|DateTime $datetime_value A valid Date or Time string (or DateTime object)
1111 1111
 	 * @param string $fieldname     the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1112 1112
 	 */
1113
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1114
-		$field = $this->_get_dtt_field_settings( $fieldname );
1115
-		$field->set_timezone( $this->_timezone );
1116
-		$field->set_date_format( $this->_dt_frmt );
1117
-		$field->set_time_format( $this->_tm_frmt );
1113
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1114
+		$field = $this->_get_dtt_field_settings($fieldname);
1115
+		$field->set_timezone($this->_timezone);
1116
+		$field->set_date_format($this->_dt_frmt);
1117
+		$field->set_time_format($this->_tm_frmt);
1118 1118
 
1119
-		switch ( $what ) {
1119
+		switch ($what) {
1120 1120
 			case 'T' :
1121
-				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( $datetime_value, $this->_fields[$fieldname] );
1121
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time($datetime_value, $this->_fields[$fieldname]);
1122 1122
 				break;
1123 1123
 			case 'D' :
1124
-				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( $datetime_value, $this->_fields[$fieldname] );
1124
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date($datetime_value, $this->_fields[$fieldname]);
1125 1125
 				break;
1126 1126
 			case 'B' :
1127
-				$this->_fields[$fieldname] = $field->prepare_for_set( $datetime_value );
1127
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1128 1128
 				break;
1129 1129
 		}
1130 1130
 
@@ -1147,25 +1147,25 @@  discard block
 block discarded – undo
1147 1147
 	 * @throws EE_Error
1148 1148
 	 * @return string timestamp
1149 1149
 	 */
1150
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1150
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1151 1151
 		EE_Registry::instance()->load_helper('DTT_Helper');
1152 1152
 		$timezone = EEH_DTT_Helper::get_timezone();
1153 1153
 
1154
-		if ( $timezone == $this->_timezone )
1154
+		if ($timezone == $this->_timezone)
1155 1155
 			return '';
1156 1156
 
1157 1157
 		$original_timezone = $this->_timezone;
1158
-		$this->set_timezone( $timezone );
1158
+		$this->set_timezone($timezone);
1159 1159
 
1160 1160
 		$fn = (array) $field_name;
1161
-		$args = array_merge( $fn, (array) $args );
1161
+		$args = array_merge($fn, (array) $args);
1162 1162
 
1163
-		if ( !method_exists( $this, $callback ) )
1164
-			throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1163
+		if ( ! method_exists($this, $callback))
1164
+			throw new EE_Error(sprintf(__('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback));
1165 1165
 		$args = (array) $args;
1166
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1166
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1167 1167
 
1168
-		$this->set_timezone( $original_timezone );
1168
+		$this->set_timezone($original_timezone);
1169 1169
 		return $return;
1170 1170
 	}
1171 1171
 
@@ -1176,20 +1176,20 @@  discard block
 block discarded – undo
1176 1176
 	 * Deletes this model object. That may mean just 'soft deleting' it though.
1177 1177
 	 * @return boolean | int
1178 1178
 	 */
1179
-	public function delete(){
1179
+	public function delete() {
1180 1180
 		/**
1181 1181
 		 * Called just before deleting a model object
1182 1182
 		 *
1183 1183
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1184 1184
 		 */
1185
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1186
-		$result = $this->get_model()->delete_by_ID( $this->ID() );
1185
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1186
+		$result = $this->get_model()->delete_by_ID($this->ID());
1187 1187
 		/**
1188 1188
 		 * Called just after deleting a model object
1189 1189
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1190 1190
 		 * @param boolean $result
1191 1191
 		 */
1192
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1192
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1193 1193
 		return $result;
1194 1194
 	}
1195 1195
 
@@ -1199,11 +1199,11 @@  discard block
 block discarded – undo
1199 1199
 	 * Deletes this model object permanently from db (but keep in mind related models my block the delete and return an error)
1200 1200
 	 * @return bool
1201 1201
 	 */
1202
-	public function delete_permanently(){
1203
-		$model=$this->get_model();
1204
-		if($model instanceof EEM_Soft_Delete_Base){
1205
-			$result=$model->delete_permanently_by_ID($this->ID());
1206
-		}else{
1202
+	public function delete_permanently() {
1203
+		$model = $this->get_model();
1204
+		if ($model instanceof EEM_Soft_Delete_Base) {
1205
+			$result = $model->delete_permanently_by_ID($this->ID());
1206
+		} else {
1207 1207
 			$result = $this->delete();
1208 1208
 		}
1209 1209
 		return $result ? true : false;
@@ -1221,17 +1221,17 @@  discard block
 block discarded – undo
1221 1221
 	 * @throws \EE_Error
1222 1222
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure
1223 1223
 	 */
1224
-	public function save($set_cols_n_values=array()) {
1224
+	public function save($set_cols_n_values = array()) {
1225 1225
 		/**
1226 1226
 		 * Filters the fields we're about to save on the model object
1227 1227
 		 *
1228 1228
 		 * @param array $set_cols_n_values
1229 1229
 		 * @param EE_Base_Class $model_object
1230 1230
 		 */
1231
-		$set_cols_n_values = apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1231
+		$set_cols_n_values = apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1232 1232
 		//set attributes as provided in $set_cols_n_values
1233
-		foreach($set_cols_n_values as $column=>$value){
1234
-			$this->set($column,$value);
1233
+		foreach ($set_cols_n_values as $column=>$value) {
1234
+			$this->set($column, $value);
1235 1235
 		}
1236 1236
 		/**
1237 1237
 		 * Saving a model object.
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 		 * Before we perform a save, this action is fired.
1240 1240
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1241 1241
 		 */
1242
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1242
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1243 1243
 		//now get current attribute values
1244 1244
 		$save_cols_n_values = $this->_fields;
1245 1245
 		//if the object already has an ID, update it. Otherwise, insert it
@@ -1247,61 +1247,61 @@  discard block
 block discarded – undo
1247 1247
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1248 1248
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1249 1249
 		//does this model have an autoincrement PK?
1250
-		if($this->get_model()->has_primary_key_field()){
1251
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1250
+		if ($this->get_model()->has_primary_key_field()) {
1251
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1252 1252
 				//ok check if it's set, if so: update; if not, insert
1253
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1254
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1253
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1254
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1255 1255
 				} else {
1256
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1257
-					$results = $this->get_model()->insert( $save_cols_n_values, true);
1258
-					if($results){
1256
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1257
+					$results = $this->get_model()->insert($save_cols_n_values, true);
1258
+					if ($results) {
1259 1259
 						//if successful, set the primary key
1260 1260
 						//but don't use the normal SET method, because it will check if
1261 1261
 						//an item with the same ID exists in the mapper & db, then
1262 1262
 						//will find it in the db (because we just added it) and THAT object
1263 1263
 						//will get added to the mapper before we can add this one!
1264 1264
 						//but if we just avoid using the SET method, all that headache can be avoided
1265
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1265
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1266 1266
 						$this->_fields[$pk_field_name] = $results;
1267 1267
 						$this->_clear_cached_property($pk_field_name);
1268
-						$this->get_model()->add_to_entity_map( $this );
1268
+						$this->get_model()->add_to_entity_map($this);
1269 1269
 						$this->_update_cached_related_model_objs_fks();
1270 1270
 					}
1271 1271
 				}
1272
-			}else{//PK is NOT auto-increment
1272
+			} else {//PK is NOT auto-increment
1273 1273
 				//so check if one like it already exists in the db
1274
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1275
-					if( ! $this->in_entity_map() && WP_DEBUG ){
1274
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1275
+					if ( ! $this->in_entity_map() && WP_DEBUG) {
1276 1276
 						throw new EE_Error(
1277 1277
 							sprintf(
1278
-								__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ),
1278
+								__('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'),
1279 1279
 								get_class($this),
1280
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1281
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1280
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1281
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1282 1282
 								'<br />'
1283 1283
 							)
1284 1284
 						);
1285 1285
 					}
1286 1286
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1287
-				}else{
1287
+				} else {
1288 1288
 					$results = $this->get_model()->insert($save_cols_n_values);
1289 1289
 					$this->_update_cached_related_model_objs_fks();
1290 1290
 				}
1291 1291
 			}
1292
-		}else{//there is NO primary key
1292
+		} else {//there is NO primary key
1293 1293
 			$already_in_db = false;
1294
-			foreach($this->get_model()->unique_indexes() as $index){
1294
+			foreach ($this->get_model()->unique_indexes() as $index) {
1295 1295
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1296
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1296
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1297 1297
 					$already_in_db = true;
1298 1298
 				}
1299 1299
 			}
1300
-			if( $already_in_db ){
1301
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1302
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1303
-			}else{
1304
-				$results = $this->get_model()->insert( $save_cols_n_values );
1300
+			if ($already_in_db) {
1301
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1302
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1303
+			} else {
1304
+				$results = $this->get_model()->insert($save_cols_n_values);
1305 1305
 			}
1306 1306
 		}
1307 1307
 		//restore the old assumption about values being prepared by the model object
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1315 1315
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1316 1316
 		 */
1317
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1317
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1318 1318
 		return $results;
1319 1319
 	}
1320 1320
 
@@ -1326,13 +1326,13 @@  discard block
 block discarded – undo
1326 1326
 	 * and we want to let its cached relations with foreign keys to it know about that change. Eg: we've created a transaction but haven't saved it to the db. We also create a registration and don't save it to the DB, but we DO cache it on the transaction. Now, when we save the transaction, the registration's TXN_ID will be automatically updated, whether or not they exist in the DB (if they do, their DB records will be automatically updated)
1327 1327
 	 * @return void
1328 1328
 	 */
1329
-	protected function _update_cached_related_model_objs_fks(){
1330
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1331
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1332
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1333
-					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( $this->get_model()->get_this_model_name() );
1334
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1335
-					if( $related_model_obj_in_cache->ID() ){
1329
+	protected function _update_cached_related_model_objs_fks() {
1330
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1331
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1332
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1333
+					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to($this->get_model()->get_this_model_name());
1334
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1335
+					if ($related_model_obj_in_cache->ID()) {
1336 1336
 						$related_model_obj_in_cache->save();
1337 1337
 					}
1338 1338
 				}
@@ -1348,21 +1348,21 @@  discard block
 block discarded – undo
1348 1348
 	 * and this object and properly setup
1349 1349
 	 * @return int ID of new model object on save; 0 on failure+
1350 1350
 	 */
1351
-	public function save_new_cached_related_model_objs(){
1351
+	public function save_new_cached_related_model_objs() {
1352 1352
 		//make sure this has been saved
1353
-		if( ! $this->ID()){
1353
+		if ( ! $this->ID()) {
1354 1354
 			$id = $this->save();
1355
-		}else{
1355
+		} else {
1356 1356
 			$id = $this->ID();
1357 1357
 		}
1358 1358
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1359
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1359
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1360 1360
 
1361 1361
 
1362
-			if($this->_model_relations[$relationName]){
1362
+			if ($this->_model_relations[$relationName]) {
1363 1363
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1364 1364
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1365
-				if($relationObj instanceof EE_Belongs_To_Relation){
1365
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1366 1366
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1367 1367
 					//but ONLY if it DOES NOT exist in the DB
1368 1368
 					/* @var $related_model_obj EE_Base_Class */
@@ -1371,8 +1371,8 @@  discard block
 block discarded – undo
1371 1371
 						$this->_add_relation_to($related_model_obj, $relationName);
1372 1372
 						$related_model_obj->save_new_cached_related_model_objs();
1373 1373
 //					}
1374
-				}else{
1375
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1374
+				} else {
1375
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1376 1376
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1377 1377
 						//but ONLY if it DOES NOT exist in the DB
1378 1378
 //						if( ! $related_model_obj->ID()){
@@ -1393,8 +1393,8 @@  discard block
 block discarded – undo
1393 1393
 	 * @return \EEM_Base | \EEM_CPT_Base
1394 1394
 	 */
1395 1395
 	public function get_model() {
1396
-		$modelName = self::_get_model_classname( get_class($this) );
1397
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1396
+		$modelName = self::_get_model_classname(get_class($this));
1397
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1398 1398
 	}
1399 1399
 
1400 1400
 
@@ -1404,10 +1404,10 @@  discard block
 block discarded – undo
1404 1404
 	 * @param $classname
1405 1405
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1406 1406
 	 */
1407
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1407
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1408 1408
 		//TODO: will not work for Term_Relationships because they have no PK!
1409
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1410
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1409
+		$primary_id_ref = self::_get_primary_key_name($classname);
1410
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1411 1411
 			$id = $props_n_values[$primary_id_ref];
1412 1412
 			return self::_get_model($classname)->get_from_entity_map($id);
1413 1413
 		}
@@ -1424,24 +1424,24 @@  discard block
 block discarded – undo
1424 1424
 	 * @param null    $timezone
1425 1425
 	 * @return mixed (EE_Base_Class|bool)
1426 1426
 	 */
1427
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) {
1428
-		if( self::_get_model( $classname )->has_primary_key_field()){
1429
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1427
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL) {
1428
+		if (self::_get_model($classname)->has_primary_key_field()) {
1429
+			$primary_id_ref = self::_get_primary_key_name($classname);
1430 1430
 
1431
-			if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1432
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] );
1433
-			}else{
1431
+			if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1432
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID($props_n_values[$primary_id_ref]);
1433
+			} else {
1434 1434
 				$existing = null;
1435 1435
 			}
1436
-		}elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1436
+		}elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1437 1437
 			//no primary key on this model, but there's still a matching item in the DB
1438
-				$existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) );
1439
-		}else{
1438
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values));
1439
+		} else {
1440 1440
 			$existing = null;
1441 1441
 		}
1442
-		if ( $existing ) {
1443
-			foreach ( $props_n_values as $property => $field_value ) {
1444
-				$existing->set( $property, $field_value );
1442
+		if ($existing) {
1443
+			foreach ($props_n_values as $property => $field_value) {
1444
+				$existing->set($property, $field_value);
1445 1445
 			}
1446 1446
 			return $existing;
1447 1447
 		} else {
@@ -1459,13 +1459,13 @@  discard block
 block discarded – undo
1459 1459
 	 * @throws EE_Error
1460 1460
 	 * @return EEM_Base
1461 1461
 	 */
1462
-	protected static function  _get_model( $classname, $timezone = NULL ){
1462
+	protected static function  _get_model($classname, $timezone = NULL) {
1463 1463
 		//find model for this class
1464
-		if( ! $classname ){
1465
-			throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"),$classname));
1464
+		if ( ! $classname) {
1465
+			throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"), $classname));
1466 1466
 		}
1467
-		$modelName=self::_get_model_classname($classname);
1468
-		return self::_get_model_instance_with_name($modelName, $timezone );
1467
+		$modelName = self::_get_model_classname($classname);
1468
+		return self::_get_model_instance_with_name($modelName, $timezone);
1469 1469
 	}
1470 1470
 
1471 1471
 
@@ -1476,10 +1476,10 @@  discard block
 block discarded – undo
1476 1476
 	 * @param null   $timezone
1477 1477
 	 * @return EEM_Base
1478 1478
 	 */
1479
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1480
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1481
-		$model = EE_Registry::instance()->load_model( $model_classname );
1482
-		$model->set_timezone( $timezone );
1479
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1480
+		$model_classname = str_replace('EEM_', '', $model_classname);
1481
+		$model = EE_Registry::instance()->load_model($model_classname);
1482
+		$model->set_timezone($timezone);
1483 1483
 		return $model;
1484 1484
 	}
1485 1485
 
@@ -1491,10 +1491,10 @@  discard block
 block discarded – undo
1491 1491
 	 * @param null $model_name
1492 1492
 	 * @return string like EEM_Attendee
1493 1493
 	 */
1494
-	private static function _get_model_classname( $model_name = null){
1495
-		if(strpos($model_name,"EE_")===0){
1496
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1497
-		}else{
1494
+	private static function _get_model_classname($model_name = null) {
1495
+		if (strpos($model_name, "EE_") === 0) {
1496
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1497
+		} else {
1498 1498
 			$model_classname = "EEM_".$model_name;
1499 1499
 		}
1500 1500
 		return $model_classname;
@@ -1508,11 +1508,11 @@  discard block
 block discarded – undo
1508 1508
 	 * @throws EE_Error
1509 1509
 	 * @return string
1510 1510
 	 */
1511
-	protected static function _get_primary_key_name( $classname = NULL ){
1512
-		if( ! $classname){
1513
-			throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),$classname));
1511
+	protected static function _get_primary_key_name($classname = NULL) {
1512
+		if ( ! $classname) {
1513
+			throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), $classname));
1514 1514
 		}
1515
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1515
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1516 1516
 	}
1517 1517
 
1518 1518
 
@@ -1524,12 +1524,12 @@  discard block
 block discarded – undo
1524 1524
 	 * Usually defaults for integer primary keys are 0; string primary keys are usually NULL).
1525 1525
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1526 1526
 	 */
1527
-	public function ID(){
1527
+	public function ID() {
1528 1528
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1529
-		if( $this->get_model()->has_primary_key_field() ) {
1530
-			return $this->_fields[self::_get_primary_key_name( get_class($this) )];
1531
-		}else{
1532
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1529
+		if ($this->get_model()->has_primary_key_field()) {
1530
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1531
+		} else {
1532
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1533 1533
 		}
1534 1534
 	}
1535 1535
 
@@ -1547,24 +1547,24 @@  discard block
 block discarded – undo
1547 1547
 	 * @throws EE_Error
1548 1548
 	 * @return EE_Base_Class the object the relation was added to
1549 1549
 	 */
1550
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $where_query = array(), $cache_id = NULL ){
1550
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array(), $cache_id = NULL) {
1551 1551
 		//if this thing exists in the DB, save the relation to the DB
1552
-		if( $this->ID() ){
1553
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1552
+		if ($this->ID()) {
1553
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1554 1554
 			//clear cache so future get_many_related and get_first_related() return new results.
1555
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1555
+			$this->clear_cache($relationName, $otherObject, TRUE);
1556 1556
 		} else {
1557 1557
 			//this thing doesn't exist in the DB,  so just cache it
1558
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1559
-				throw new EE_Error( sprintf(
1560
-					__( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ),
1558
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1559
+				throw new EE_Error(sprintf(
1560
+					__('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'),
1561 1561
 					$otherObjectModelObjectOrID,
1562
-					get_class( $this )
1562
+					get_class($this)
1563 1563
 				));
1564 1564
 			} else {
1565 1565
 				$otherObject = $otherObjectModelObjectOrID;
1566 1566
 			}
1567
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1567
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1568 1568
 		}
1569 1569
 
1570 1570
 
@@ -1582,12 +1582,12 @@  discard block
 block discarded – undo
1582 1582
 	 * @param array  $where_query You can optionally include an array of key=>value pairs that allow you to further constrict the relation to being added.  However, keep in mind that the columns (keys) given must match a column on the JOIN table and currently only the HABTM models accept these additional conditions.  Also remember that if an exact match isn't found for these extra cols/val pairs, then a NEW row is created in the join table.
1583 1583
 	 * @return EE_Base_Class the relation was removed from
1584 1584
 	 */
1585
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1586
-		if($this->ID()){//if this exists in the DB, save the relation change to the DB too
1587
-			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query );
1585
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1586
+		if ($this->ID()) {//if this exists in the DB, save the relation change to the DB too
1587
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1588 1588
 			$this->clear_cache($relationName, $otherObject);
1589
-		}else{//this doesn't exist in the DB, just remove it from the cache
1590
-			$otherObject = $this->clear_cache($relationName,$otherObjectModelObjectOrID);
1589
+		} else {//this doesn't exist in the DB, just remove it from the cache
1590
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1591 1591
 		}
1592 1592
 		return $otherObject;
1593 1593
 	}
@@ -1598,12 +1598,12 @@  discard block
 block discarded – undo
1598 1598
 	 * @param array $where_query_params like EEM_Base::get_all's $query_params[0] (where conditions)
1599 1599
 	 * @return EE_Base_Class
1600 1600
 	 */
1601
-	public function _remove_relations($relationName,$where_query_params = array()){
1602
-		if($this->ID()){//if this exists in the DB, save the relation change to the DB too
1603
-			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params );
1604
-			$this->clear_cache($relationName,null,true);
1605
-		}else{//this doesn't exist in the DB, just remove it from the cache
1606
-			$otherObjects = $this->clear_cache($relationName,null,true);
1601
+	public function _remove_relations($relationName, $where_query_params = array()) {
1602
+		if ($this->ID()) {//if this exists in the DB, save the relation change to the DB too
1603
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1604
+			$this->clear_cache($relationName, null, true);
1605
+		} else {//this doesn't exist in the DB, just remove it from the cache
1606
+			$otherObjects = $this->clear_cache($relationName, null, true);
1607 1607
 		}
1608 1608
 		return $otherObjects;
1609 1609
 	}
@@ -1619,26 +1619,26 @@  discard block
 block discarded – undo
1619 1619
 	 * @param array  $query_params  like EEM_Base::get_all
1620 1620
 	 * @return EE_Base_Class[]
1621 1621
 	 */
1622
-	public function get_many_related($relationName,$query_params = array()){
1623
-		if($this->ID()){//this exists in the DB, so get the related things from either the cache or the DB
1622
+	public function get_many_related($relationName, $query_params = array()) {
1623
+		if ($this->ID()) {//this exists in the DB, so get the related things from either the cache or the DB
1624 1624
 			//if there are query parameters, forget about caching the related model objects.
1625
-			if( $query_params ){
1625
+			if ($query_params) {
1626 1626
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1627
-			}else{
1627
+			} else {
1628 1628
 				//did we already cache the result of this query?
1629 1629
 				$cached_results = $this->get_all_from_cache($relationName);
1630
-				if ( ! $cached_results ){
1630
+				if ( ! $cached_results) {
1631 1631
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1632 1632
 					//if no query parameters were passed, then we got all the related model objects
1633 1633
 					//for that relation. We can cache them then.
1634
-					foreach($related_model_objects as $related_model_object){
1634
+					foreach ($related_model_objects as $related_model_object) {
1635 1635
 						$this->cache($relationName, $related_model_object);
1636 1636
 					}
1637
-				}else{
1637
+				} else {
1638 1638
 					$related_model_objects = $cached_results;
1639 1639
 				}
1640 1640
 			}
1641
-		}else{//this doesn't exist itn eh DB, so just get the related things from the cache
1641
+		} else {//this doesn't exist itn eh DB, so just get the related things from the cache
1642 1642
 			$related_model_objects = $this->get_all_from_cache($relationName);
1643 1643
 		}
1644 1644
 		return $related_model_objects;
@@ -1655,8 +1655,8 @@  discard block
 block discarded – undo
1655 1655
 	 * @param bool   	$distinct       if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1656 1656
 	 * @return int
1657 1657
 	 */
1658
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1659
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1658
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1659
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1660 1660
 	}
1661 1661
 
1662 1662
 
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1671 1671
 	 * @return int
1672 1672
 	 */
1673
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
1673
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
1674 1674
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
1675 1675
 	}
1676 1676
 
@@ -1682,34 +1682,34 @@  discard block
 block discarded – undo
1682 1682
 	 * @param array  $query_params  like EEM_Base::get_all
1683 1683
 	 * @return EE_Base_Class (not an array, a single object)
1684 1684
 	 */
1685
-	public function get_first_related($relationName,$query_params = array()){
1686
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
1685
+	public function get_first_related($relationName, $query_params = array()) {
1686
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
1687 1687
 
1688 1688
 			//if they've provided some query parameters, don't bother trying to cache the result
1689 1689
 			//also make sure we're not caching the result of get_first_related
1690 1690
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
1691
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1692
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1693
-			}else{
1691
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
1692
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1693
+			} else {
1694 1694
 				//first, check if we've already cached the result of this query
1695 1695
 				$cached_result = $this->get_one_from_cache($relationName);
1696
-				if ( ! $cached_result ){
1696
+				if ( ! $cached_result) {
1697 1697
 
1698 1698
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1699
-					$this->cache($relationName,$related_model_object);
1700
-				}else{
1699
+					$this->cache($relationName, $related_model_object);
1700
+				} else {
1701 1701
 					$related_model_object = $cached_result;
1702 1702
 				}
1703 1703
 			}
1704
-		}else{
1704
+		} else {
1705 1705
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
1706
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1707
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1708
-			}else{
1706
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
1707
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1708
+			} else {
1709 1709
 				$related_model_object = null;
1710 1710
 			}
1711 1711
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
1712
-			if( ! $related_model_object){
1712
+			if ( ! $related_model_object) {
1713 1713
 				$related_model_object = $this->get_one_from_cache($relationName);
1714 1714
 			}
1715 1715
 
@@ -1728,12 +1728,12 @@  discard block
 block discarded – undo
1728 1728
 	 * @param array $query_params like EEM_Base::get_all's
1729 1729
 	 * @return int how many deleted
1730 1730
 	 */
1731
-	public function delete_related($relationName,$query_params = array()){
1732
-		if($this->ID()){
1733
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
1734
-		}else{
1731
+	public function delete_related($relationName, $query_params = array()) {
1732
+		if ($this->ID()) {
1733
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
1734
+		} else {
1735 1735
 			$count = count($this->get_all_from_cache($relationName));
1736
-			$this->clear_cache($relationName,NULL,TRUE);
1736
+			$this->clear_cache($relationName, NULL, TRUE);
1737 1737
 		}
1738 1738
 		return $count;
1739 1739
 	}
@@ -1748,13 +1748,13 @@  discard block
 block discarded – undo
1748 1748
 	 * @param array $query_params like EEM_Base::get_all's
1749 1749
 	 * @return int how many deleted (including those soft deleted)
1750 1750
 	 */
1751
-	public function delete_related_permanently($relationName,$query_params = array()){
1752
-		if($this->ID()){
1753
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1754
-		}else{
1751
+	public function delete_related_permanently($relationName, $query_params = array()) {
1752
+		if ($this->ID()) {
1753
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1754
+		} else {
1755 1755
 			$count = count($this->get_all_from_cache($relationName));
1756 1756
 		}
1757
-		$this->clear_cache($relationName,NULL,TRUE);
1757
+		$this->clear_cache($relationName, NULL, TRUE);
1758 1758
 		return $count;
1759 1759
 	}
1760 1760
 
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
 	 * @param  string $field_name property to check
1771 1771
 	 * @return bool            				  TRUE if existing,FALSE if not.
1772 1772
 	 */
1773
-	public function is_set( $field_name ) {
1773
+	public function is_set($field_name) {
1774 1774
 		return isset($this->_fields[$field_name]);
1775 1775
 	}
1776 1776
 
@@ -1782,12 +1782,12 @@  discard block
 block discarded – undo
1782 1782
 	 * @throws EE_Error
1783 1783
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
1784 1784
 	 */
1785
-	protected function _property_exists( $properties ) {
1785
+	protected function _property_exists($properties) {
1786 1786
 
1787
-		foreach ( (array) $properties as $property_name ) {
1787
+		foreach ((array) $properties as $property_name) {
1788 1788
 			//first make sure this property exists
1789
-			if ( ! $this->_fields[ $property_name ] )
1790
-				throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1789
+			if ( ! $this->_fields[$property_name])
1790
+				throw new EE_Error(sprintf(__('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name));
1791 1791
 		}
1792 1792
 
1793 1793
 		return TRUE;
@@ -1804,7 +1804,7 @@  discard block
 block discarded – undo
1804 1804
 		$fields = $this->get_model()->field_settings(FALSE);
1805 1805
 		$properties = array();
1806 1806
 		//remove prepended underscore
1807
-		foreach ( $fields as $field_name => $settings ) {
1807
+		foreach ($fields as $field_name => $settings) {
1808 1808
 			$properties[$field_name] = $this->get($field_name);
1809 1809
 		}
1810 1810
 		return $properties;
@@ -1834,14 +1834,14 @@  discard block
 block discarded – undo
1834 1834
 	 * @throws EE_Error
1835 1835
 	 * @return mixed whatever the plugin which calls add_filter decides
1836 1836
 	 */
1837
-	public function __call($methodName,$args){
1838
-		$className=get_class($this);
1839
-		$tagName="FHEE__{$className}__{$methodName}";
1840
-		if(!has_filter($tagName)){
1841
-			throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}","event_espresso"),
1842
-										$methodName,$className,$tagName));
1837
+	public function __call($methodName, $args) {
1838
+		$className = get_class($this);
1839
+		$tagName = "FHEE__{$className}__{$methodName}";
1840
+		if ( ! has_filter($tagName)) {
1841
+			throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}", "event_espresso"),
1842
+										$methodName, $className, $tagName));
1843 1843
 		}
1844
-		return apply_filters($tagName,null,$this,$args);
1844
+		return apply_filters($tagName, null, $this, $args);
1845 1845
 	}
1846 1846
 
1847 1847
 
@@ -1856,22 +1856,22 @@  discard block
 block discarded – undo
1856 1856
 	 * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row)
1857 1857
 	 * NOTE: if the values haven't changed, returns 0
1858 1858
 	 */
1859
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
1860
-		$query_params  = array(array(
1859
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
1860
+		$query_params = array(array(
1861 1861
 			'EXM_key'=>$meta_key,
1862 1862
 			'OBJ_ID'=>$this->ID(),
1863 1863
 			'EXM_type'=>$this->get_model()->get_this_model_name()));
1864
-		if($previous_value !== NULL){
1864
+		if ($previous_value !== NULL) {
1865 1865
 			$query_params[0]['EXM_value'] = $meta_value;
1866 1866
 		}
1867 1867
 		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
1868
-		if( ! $existing_rows_like_that){
1868
+		if ( ! $existing_rows_like_that) {
1869 1869
 			return $this->add_extra_meta($meta_key, $meta_value);
1870
-		}else{
1871
-			foreach( $existing_rows_like_that as $existing_row){
1872
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
1870
+		} else {
1871
+			foreach ($existing_rows_like_that as $existing_row) {
1872
+				$existing_row->save(array('EXM_value' => $meta_value));
1873 1873
 			}
1874
-			return count( $existing_rows_like_that );
1874
+			return count($existing_rows_like_that);
1875 1875
 		}
1876 1876
 	}
1877 1877
 
@@ -1884,10 +1884,10 @@  discard block
 block discarded – undo
1884 1884
 	 * @param boolean $unique
1885 1885
 	 * @return boolean
1886 1886
 	 */
1887
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
1888
-		if($unique){
1889
-			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key,'OBJ_ID'=>$this->ID(),'EXM_type'=>$this->_get_model_classname(get_class($this)))));
1890
-			if($existing_extra_meta){
1887
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
1888
+		if ($unique) {
1889
+			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key, 'OBJ_ID'=>$this->ID(), 'EXM_type'=>$this->_get_model_classname(get_class($this)))));
1890
+			if ($existing_extra_meta) {
1891 1891
 				return false;
1892 1892
 			}
1893 1893
 		}
@@ -1907,12 +1907,12 @@  discard block
 block discarded – undo
1907 1907
 	 * @param string $meta_value
1908 1908
 	 * @return int number of extra meta rows deleted
1909 1909
 	 */
1910
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
1911
-		$query_params  = array(array(
1910
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
1911
+		$query_params = array(array(
1912 1912
 			'EXM_key'=>$meta_key,
1913 1913
 			'OBJ_ID'=>$this->ID(),
1914 1914
 			'EXM_type'=>$this->get_model()->get_this_model_name()));
1915
-		if($meta_value !== NULL){
1915
+		if ($meta_value !== NULL) {
1916 1916
 			$query_params[0]['EXM_value'] = $meta_value;
1917 1917
 		}
1918 1918
 		$count_deleted = EEM_Extra_Meta::instance()->delete($query_params);
@@ -1928,25 +1928,25 @@  discard block
 block discarded – undo
1928 1928
 	 * @param mixed $default if we don't find anything, what should we return?
1929 1929
 	 * @return mixed single value if $single; array if ! $single
1930 1930
 	 */
1931
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
1932
-		if($single){
1933
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
1934
-			if ( $result instanceof EE_Extra_Meta ){
1931
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
1932
+		if ($single) {
1933
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
1934
+			if ($result instanceof EE_Extra_Meta) {
1935 1935
 				return $result->value();
1936
-			}else{
1936
+			} else {
1937 1937
 				return $default;
1938 1938
 			}
1939
-		}else{
1940
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
1941
-			if($results){
1939
+		} else {
1940
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
1941
+			if ($results) {
1942 1942
 				$values = array();
1943
-				foreach($results as $result){
1944
-					if ( $result instanceof EE_Extra_Meta ){
1943
+				foreach ($results as $result) {
1944
+					if ($result instanceof EE_Extra_Meta) {
1945 1945
 						$values[$result->ID()] = $result->value();
1946 1946
 					}
1947 1947
 				}
1948 1948
 				return $values;
1949
-			}else{
1949
+			} else {
1950 1950
 				return $default;
1951 1951
 			}
1952 1952
 		}
@@ -1963,20 +1963,20 @@  discard block
 block discarded – undo
1963 1963
 	 * @param boolean $one_of_each_key
1964 1964
 	 * @return array
1965 1965
 	 */
1966
-	public function all_extra_meta_array($one_of_each_key = true){
1966
+	public function all_extra_meta_array($one_of_each_key = true) {
1967 1967
 		$return_array = array();
1968
-		if($one_of_each_key){
1968
+		if ($one_of_each_key) {
1969 1969
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
1970
-			foreach($extra_meta_objs as $extra_meta_obj){
1971
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
1970
+			foreach ($extra_meta_objs as $extra_meta_obj) {
1971
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
1972 1972
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
1973 1973
 				}
1974 1974
 			}
1975
-		}else{
1975
+		} else {
1976 1976
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
1977
-			foreach($extra_meta_objs as $extra_meta_obj){
1978
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
1979
-					if( ! isset($return_array[$extra_meta_obj->key()])){
1977
+			foreach ($extra_meta_objs as $extra_meta_obj) {
1978
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
1979
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
1980 1980
 						$return_array[$extra_meta_obj->key()] = array();
1981 1981
 					}
1982 1982
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -1989,19 +1989,19 @@  discard block
 block discarded – undo
1989 1989
 	 * Gets a pretty nice displayable nice for this model object. Often overridden
1990 1990
 	 * @return string
1991 1991
 	 */
1992
-	public function name(){
1992
+	public function name() {
1993 1993
 		//find a field that's not a text field
1994 1994
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
1995
-		if($field_we_can_use){
1995
+		if ($field_we_can_use) {
1996 1996
 			return $this->get($field_we_can_use->get_name());
1997
-		}else{
1997
+		} else {
1998 1998
 			$first_few_properties = $this->model_field_array();
1999
-			$first_few_properties = array_slice($first_few_properties,0,3);
1999
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2000 2000
 			$name_parts = array();
2001
-			foreach( $first_few_properties as $name=> $value ){
2001
+			foreach ($first_few_properties as $name=> $value) {
2002 2002
 				$name_parts[] = "$name:$value";
2003 2003
 			}
2004
-			return implode(",",$name_parts);
2004
+			return implode(",", $name_parts);
2005 2005
 		}
2006 2006
 	}
2007 2007
 
@@ -2010,11 +2010,11 @@  discard block
 block discarded – undo
2010 2010
 	 * Checks if this model object has been proven to already be in the entity map
2011 2011
 	 * @return boolean
2012 2012
 	 */
2013
-	public function in_entity_map(){
2014
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2013
+	public function in_entity_map() {
2014
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2015 2015
 			//well, if we looked, did we find it in the entity map?
2016 2016
 			return TRUE;
2017
-		}else{
2017
+		} else {
2018 2018
 			return FALSE;
2019 2019
 		}
2020 2020
 	}
@@ -2025,21 +2025,21 @@  discard block
 block discarded – undo
2025 2025
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2026 2026
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2027 2027
 	 */
2028
-	public function refresh_from_db(){
2029
-		if( $this->ID() && $this->in_entity_map() ){
2030
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2031
-		}else{
2028
+	public function refresh_from_db() {
2029
+		if ($this->ID() && $this->in_entity_map()) {
2030
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2031
+		} else {
2032 2032
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2033 2033
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2034 2034
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2035 2035
 			//absolutely nothing in it for this ID
2036
-			if( WP_DEBUG ) {
2036
+			if (WP_DEBUG) {
2037 2037
 				throw new EE_Error(
2038 2038
 					sprintf(
2039
-						__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ),
2039
+						__('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'),
2040 2040
 						$this->ID(),
2041
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2042
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2041
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2042
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2043 2043
 					)
2044 2044
 				);
2045 2045
 			}
@@ -2051,8 +2051,8 @@  discard block
 block discarded – undo
2051 2051
 	 * (probably a bad assumption they have made, oh well)
2052 2052
 	 * @return string
2053 2053
 	 */
2054
-	public function __toString(){
2055
-		return sprintf( '%s (%s)', $this->name(), $this->ID() );
2054
+	public function __toString() {
2055
+		return sprintf('%s (%s)', $this->name(), $this->ID());
2056 2056
 	}
2057 2057
 
2058 2058
 
Please login to merge, or discard this patch.
Doc Comments   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * @access protected
424 424
 	 * @param string $fieldname the property item the corresponding value is for.
425 425
 	 * @param mixed  $value     The value we are caching.
426
-	 * @param null   $cache_type
426
+	 * @param string   $cache_type
427 427
 	 * @return void
428 428
 	 */
429 429
 	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @param null $field_to_order_by   What field is being used as the reference point.
738 738
 	 * @param array $query_params       Any additional conditions on the query.
739
-	 * @param null $columns_to_select   If left null, then an array of EE_Base_Class objects is returned, otherwise
739
+	 * @param string $columns_to_select   If left null, then an array of EE_Base_Class objects is returned, otherwise
740 740
 	 *                                  you can indicate just the columns you want returned
741 741
 	 *
742 742
 	 * @return array|EE_Base_Class
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 *
762 762
 	 * @param null $field_to_order_by   What field is being used as the reference point.
763 763
 	 * @param array $query_params       Any additional conditions on the query.
764
-	 * @param null $columns_to_select   If left null, then an EE_Base_Class object is returned, otherwise
764
+	 * @param string $columns_to_select   If left null, then an EE_Base_Class object is returned, otherwise
765 765
 	 *                                  you can indicate just the column you want returned
766 766
 	 *
767 767
 	 * @return array|EE_Base_Class
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	/**
825 825
 	 * This method simply returns the RAW unprocessed value for the given property in this class
826 826
 	 * @param  string $field_name A valid fieldname
827
-	 * @return mixed              Whatever the raw value stored on the property is.
827
+	 * @return integer|null              Whatever the raw value stored on the property is.
828 828
 	 * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist.
829 829
 	 */
830 830
 	public function get_raw($field_name) {
@@ -898,11 +898,11 @@  discard block
 block discarded – undo
898 898
 	 *
899 899
 	 * @access   protected
900 900
 	 * @param  string  $field_name   Field on the instantiated EE_Base_Class child object
901
-	 * @param null     $dt_frmt 	valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format)
902
-	 * @param null     $tm_frmt 	Same as above except this is for time format
901
+	 * @param string|null     $dt_frmt 	valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format)
902
+	 * @param null|string     $tm_frmt 	Same as above except this is for time format
903 903
 	 * @param string   $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time.
904 904
 	 * @param  boolean $echo         Whether the dtt is echoing using pretty echoing or just returned using vanilla get
905
-	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
905
+	 * @return string|boolean | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
906 906
 	 */
907 907
 	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
908 908
 
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 	 * sets the time on a datetime property
1076 1076
 	 *
1077 1077
 	 * @access protected
1078
-	 * @param string|Datetime $time      a valid time string for php datetime functions (or DateTime object)
1078
+	 * @param string $time      a valid time string for php datetime functions (or DateTime object)
1079 1079
 	 * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1080 1080
 	 */
1081 1081
 	protected function _set_time_for( $time, $fieldname ) {
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	 * sets the date on a datetime property
1091 1091
 	 *
1092 1092
 	 * @access protected
1093
-	 * @param string|DateTime $date      a valid date string for php datetime functions ( or DateTime object)
1093
+	 * @param string $date      a valid date string for php datetime functions ( or DateTime object)
1094 1094
 	 * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1095 1095
 	 */
1096 1096
 	protected function _set_date_for( $date, $fieldname ) {
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 
1391 1391
 	/**
1392 1392
 	 * for getting a model while instantiated.
1393
-	 * @return \EEM_Base | \EEM_CPT_Base
1393
+	 * @return boolean | \EEM_CPT_Base
1394 1394
 	 */
1395 1395
 	public function get_model() {
1396 1396
 		$modelName = self::_get_model_classname( get_class($this) );
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 	 * If there is a key in the incoming array that matches the primary key for the model AND it is not null, then we check the db. If there's a an object we return it.  If not we return false.
1422 1422
 	 * @param  array  $props_n_values incoming array of properties and their values
1423 1423
 	 * @param  string $classname      the classname of the child class
1424
-	 * @param null    $timezone
1424
+	 * @param null|string    $timezone
1425 1425
 	 * @return mixed (EE_Base_Class|bool)
1426 1426
 	 */
1427 1427
 	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) {
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 	 * @param      $classname
1458 1458
 	 * @param null $timezone
1459 1459
 	 * @throws EE_Error
1460
-	 * @return EEM_Base
1460
+	 * @return boolean
1461 1461
 	 */
1462 1462
 	protected static function  _get_model( $classname, $timezone = NULL ){
1463 1463
 		//find model for this class
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
 	/**
1474 1474
 	 * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee)
1475 1475
 	 * @param string $model_classname
1476
-	 * @param null   $timezone
1477
-	 * @return EEM_Base
1476
+	 * @param string|null   $timezone
1477
+	 * @return boolean
1478 1478
 	 */
1479 1479
 	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1480 1480
 		$model_classname = str_replace( 'EEM_', '', $model_classname );
@@ -1925,7 +1925,7 @@  discard block
 block discarded – undo
1925 1925
 	 * You can specify $default is case you haven't found the extra meta
1926 1926
 	 * @param string $meta_key
1927 1927
 	 * @param boolean $single
1928
-	 * @param mixed $default if we don't find anything, what should we return?
1928
+	 * @param string|false $default if we don't find anything, what should we return?
1929 1929
 	 * @return mixed single value if $single; array if ! $single
1930 1930
 	 */
1931 1931
 	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
Please login to merge, or discard this patch.
core/db_classes/EE_CPT_Base.class.php 2 patches
Spacing   +56 added lines, -56 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
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * @param int    $parent_term_taxonomy_id optional
48 48
 	 * @return EE_Term_Taxonomy
49 49
 	 */
50
-	function add_event_category( $category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL ) {
51
-		return $this->get_model()->add_event_category( $this, $category_name, $category_description, $parent_term_taxonomy_id );
50
+	function add_event_category($category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL) {
51
+		return $this->get_model()->add_event_category($this, $category_name, $category_description, $parent_term_taxonomy_id);
52 52
 	}
53 53
 
54 54
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 * @param string $category_name
59 59
 	 * @return bool
60 60
 	 */
61
-	function remove_event_category( $category_name ) {
62
-		return $this->get_model()->remove_event_category( $this, $category_name );
61
+	function remove_event_category($category_name) {
62
+		return $this->get_model()->remove_event_category($this, $category_name);
63 63
 	}
64 64
 
65 65
 
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 	 * @param EE_Term_Taxonomy $term_taxonomy
71 71
 	 * @return EE_Base_Class the relation was removed from
72 72
 	 */
73
-	function remove_relation_to_term_taxonomy( $term_taxonomy ) {
74
-		if ( !$term_taxonomy ) {
75
-			EE_Error::add_error( sprintf( __( "No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso" ), get_class( $this ), $this->ID() ), __FILE__, __FUNCTION__, __LINE__ );
73
+	function remove_relation_to_term_taxonomy($term_taxonomy) {
74
+		if ( ! $term_taxonomy) {
75
+			EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__);
76 76
 			return NULL;
77 77
 		}
78
-		$term_taxonomy->set_count( $term_taxonomy->count() - 1 );
78
+		$term_taxonomy->set_count($term_taxonomy->count() - 1);
79 79
 		$term_taxonomy->save();
80
-		return $this->_remove_relation_to( $term_taxonomy, 'Term_Taxonomy' );
80
+		return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy');
81 81
 	}
82 82
 
83 83
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return int
102 102
 	 */
103 103
 	public function parent() {
104
-		return $this->get( 'parent' );
104
+		return $this->get('parent');
105 105
 	}
106 106
 
107 107
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return string
112 112
 	 */
113 113
 	public function status() {
114
-		return $this->get( 'status' );
114
+		return $this->get('status');
115 115
 	}
116 116
 
117 117
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	/**
120 120
 	 * @param string $status
121 121
 	 */
122
-	public function set_status( $status ) {
123
-		$this->set( 'status', $status );
122
+	public function set_status($status) {
123
+		$this->set('status', $status);
124 124
 	}
125 125
 
126 126
 
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 	 * @param string|array $attr Optional. Query string or array of attributes.
135 135
 	 * @return string HTML image element
136 136
 	 */
137
-	protected function _get_feature_image( $size, $attr ) {
137
+	protected function _get_feature_image($size, $attr) {
138 138
 		//first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size
139
-		$attr_key = is_array( $attr ) ? implode( '_', $attr ) : $attr;
140
-		$cache_key = is_array( $size ) ? implode( '_', $size ) . $attr_key : $size . $attr_key;
141
-		$this->_feature_image[ $cache_key ] = isset( $this->_feature_image[ $cache_key ] ) ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image( $this->ID(), $size, $attr );
142
-		return $this->_feature_image[ $cache_key ];
139
+		$attr_key = is_array($attr) ? implode('_', $attr) : $attr;
140
+		$cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key;
141
+		$this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr);
142
+		return $this->_feature_image[$cache_key];
143 143
 	}
144 144
 
145 145
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param string|array $attr
151 151
 	 * @return string of html
152 152
 	 */
153
-	public function feature_image( $size = 'thumbnail', $attr = '' ) {
154
-		return $this->_get_feature_image( $size, $attr );
153
+	public function feature_image($size = 'thumbnail', $attr = '') {
154
+		return $this->_get_feature_image($size, $attr);
155 155
 	}
156 156
 
157 157
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 * @param  string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32).
162 162
 	 * @return string|boolean          the url of the image or false if not found
163 163
 	 */
164
-	public function feature_image_url( $size = 'thumbnail' ) {
165
-		$attachment = wp_get_attachment_image_src( get_post_thumbnail_id( $this->ID() ), $size );
166
-		return !empty( $attachment ) ? $attachment[ 0 ] : FALSE;
164
+	public function feature_image_url($size = 'thumbnail') {
165
+		$attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size);
166
+		return ! empty($attachment) ? $attachment[0] : FALSE;
167 167
 	}
168 168
 
169 169
 
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
 	 * @internal param array|string $related_obj_names if included this will be used to restore for related obj if not included then we just do restore on the meta.  We will accept an array of related_obj_names for restoration here.
177 177
 	 * @return void
178 178
 	 */
179
-	public function restore_revision( $revision_id, $related_obj_names = array(), $where_query = array() ) {
179
+	public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) {
180 180
 		//get revision object
181
-		$revision_obj = $this->get_model()->get_one_by_ID( $revision_id );
182
-		if ( $revision_obj instanceof EE_CPT_Base ) {
181
+		$revision_obj = $this->get_model()->get_one_by_ID($revision_id);
182
+		if ($revision_obj instanceof EE_CPT_Base) {
183 183
 			//no related_obj_name so we assume we're saving a revision on this object.
184
-			if ( empty( $related_obj_names ) ) {
184
+			if (empty($related_obj_names)) {
185 185
 				$fields = $this->get_model()->get_meta_table_fields();
186
-				foreach ( $fields as $field ) {
187
-					$this->set( $field, $revision_obj->get( $field ) );
186
+				foreach ($fields as $field) {
187
+					$this->set($field, $revision_obj->get($field));
188 188
 				}
189 189
 				$this->save();
190 190
 			}
191
-			$related_obj_names = (array)$related_obj_names;
192
-			foreach ( $related_obj_names as $related_name ) {
191
+			$related_obj_names = (array) $related_obj_names;
192
+			foreach ($related_obj_names as $related_name) {
193 193
 				//related_obj_name so we're saving a revision on an object related to this object
194 194
 				//do we have $where_query params for this related object?  If we do then we include that.
195
-				$cols_n_values = isset( $where_query[ $related_name ] ) ? $where_query[ $related_name ] : array();
196
-				$where_params = !empty( $cols_n_values ) ? array( $cols_n_values ) : array();
197
-				$related_objs = $this->get_many_related( $related_name, $where_params );
198
-				$revision_related_objs = $revision_obj->get_many_related( $related_name, $where_params );
195
+				$cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array();
196
+				$where_params = ! empty($cols_n_values) ? array($cols_n_values) : array();
197
+				$related_objs = $this->get_many_related($related_name, $where_params);
198
+				$revision_related_objs = $revision_obj->get_many_related($related_name, $where_params);
199 199
 				//load helper
200
-				EE_Registry::instance()->load_helper( 'Array' );
200
+				EE_Registry::instance()->load_helper('Array');
201 201
 				//remove related objs from this object that are not in revision
202 202
 				//array_diff *should* work cause I think objects are indexed by ID?
203
-				$related_to_remove = EEH_Array::object_array_diff( $related_objs, $revision_related_objs );
204
-				foreach ( $related_to_remove as $rr ) {
205
-					$this->_remove_relation_to( $rr, $related_name, $cols_n_values );
203
+				$related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs);
204
+				foreach ($related_to_remove as $rr) {
205
+					$this->_remove_relation_to($rr, $related_name, $cols_n_values);
206 206
 				}
207 207
 				//add all related objs attached to revision to this object
208
-				foreach ( $revision_related_objs as $r_obj ) {
209
-					$this->_add_relation_to( $r_obj, $related_name, $cols_n_values );
208
+				foreach ($revision_related_objs as $r_obj) {
209
+					$this->_add_relation_to($r_obj, $related_name, $cols_n_values);
210 210
 				}
211 211
 			}
212 212
 		}
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li>
223 223
 	 * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul>
224 224
 	 */
225
-	public function get_post_meta( $meta_key = NULL, $single = FALSE ) {
226
-		return get_post_meta( $this->ID(), $meta_key, $single );
225
+	public function get_post_meta($meta_key = NULL, $single = FALSE) {
226
+		return get_post_meta($this->ID(), $meta_key, $single);
227 227
 	}
228 228
 
229 229
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
 	 * @throws EE_Error
237 237
 	 * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false.
238 238
 	 */
239
-	public function update_post_meta( $meta_key, $meta_value, $prev_value = NULL ) {
240
-		if ( !$this->ID() ) {
241
-			throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) );
239
+	public function update_post_meta($meta_key, $meta_value, $prev_value = NULL) {
240
+		if ( ! $this->ID()) {
241
+			throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso")));
242 242
 		}
243
-		return update_post_meta( $this->ID(), $meta_key, $meta_value, $prev_value );
243
+		return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value);
244 244
 	}
245 245
 
246 246
 
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 	 * @throws EE_Error
254 254
 	 * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned.
255 255
 	 */
256
-	public function add_post_meta( $meta_key, $meta_value, $unique = FALSE ) {
257
-		if ( !$this->ID() ) {
258
-			throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) );
256
+	public function add_post_meta($meta_key, $meta_value, $unique = FALSE) {
257
+		if ( ! $this->ID()) {
258
+			throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso")));
259 259
 		}
260
-		return add_post_meta( $this->ID(), $meta_key, $meta_value, $unique );
260
+		return add_post_meta($this->ID(), $meta_key, $meta_value, $unique);
261 261
 	}
262 262
 
263 263
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return string
268 268
 	 */
269 269
 	public function get_permalink() {
270
-		return get_permalink( $this->ID() );
270
+		return get_permalink($this->ID());
271 271
 	}
272 272
 
273 273
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param array $query_params
278 278
 	 * @return EE_Term_Taxonomy
279 279
 	 */
280
-	public function term_taxonomies( $query_params = array() ) {
281
-		return $this->get_many_related( 'Term_Taxonomy', $query_params );
280
+	public function term_taxonomies($query_params = array()) {
281
+		return $this->get_many_related('Term_Taxonomy', $query_params);
282 282
 	}
283 283
 
284 284
 
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * The main purpose of this method is to return the parent for the model object
99 99
 	 *
100 100
 	 * @access public
101
-	 * @return int
101
+	 * @return boolean
102 102
 	 */
103 103
 	public function parent() {
104 104
 		return $this->get( 'parent' );
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 	/**
110 110
 	 * return the _status property
111
-	 * @return string
111
+	 * @return boolean
112 112
 	 */
113 113
 	public function status() {
114 114
 		return $this->get( 'status' );
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @link   http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
132 132
 	 * @access protected
133
-	 * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ).
133
+	 * @param string $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ).
134 134
 	 * @param string|array $attr Optional. Query string or array of attributes.
135 135
 	 * @return string HTML image element
136 136
 	 */
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 	/**
160 160
 	 * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class using the given size params.
161
-	 * @param  string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32).
161
+	 * @param  integer[] $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32).
162 162
 	 * @return string|boolean          the url of the image or false if not found
163 163
 	 */
164 164
 	public function feature_image_url( $size = 'thumbnail' ) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	/**
276 276
 	 * Gets all the term-taxonomies for this CPT
277 277
 	 * @param array $query_params
278
-	 * @return EE_Term_Taxonomy
278
+	 * @return EE_Base_Class[]
279 279
 	 */
280 280
 	public function term_taxonomies( $query_params = array() ) {
281 281
 		return $this->get_many_related( 'Term_Taxonomy', $query_params );
Please login to merge, or discard this patch.
core/db_classes/EE_Event.class.php 3 patches
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -281,8 +281,7 @@  discard block
 block discarded – undo
281 281
 		$short_desc = $this->get( 'EVT_short_desc' );
282 282
 		if ( !empty( $short_desc ) || $not_full_desc ) {
283 283
 			return $short_desc;
284
-		}
285
-		else {
284
+		} else {
286 285
 			$full_desc = $this->get( 'EVT_desc' );
287 286
 			return wp_trim_words( $full_desc, $num_words, $more );
288 287
 		}
@@ -665,8 +664,7 @@  discard block
 block discarded – undo
665 664
 				// if datetime has unlimited reg limit then the event can never be sold out
666 665
 				if ( $dtt_spaces_remaining === INF ) {
667 666
 					return FALSE;
668
-				}
669
-				else {
667
+				} else {
670 668
 					$spaces_remaining = max( $dtt_spaces_remaining, $spaces_remaining );
671 669
 				}
672 670
 			}
@@ -677,8 +675,7 @@  discard block
 block discarded – undo
677 675
 				$this->save();
678 676
 			}
679 677
 			$sold_out = TRUE;
680
-		}
681
-		else {
678
+		} else {
682 679
 			$sold_out = FALSE;
683 680
 		}
684 681
 		//note: I considered changing the EEM_Event status away from sold_out if this status check reveals that it's no longer sold out (yet the status is still set as sold out) but the problem is... what do we change the status BACK to?  We can't always assume that the previous event status was 'published' because this status check is always done in the admin and its entirely possible the event admin manually changes to sold_out status from some other status.  We also don't want a draft event to become a "publish event" because the sold out check reveals its NOT sold out.
@@ -876,8 +873,7 @@  discard block
 block discarded – undo
876 873
 	public function is_sold_out( $actual = FALSE ) {
877 874
 		if ( !$actual ) {
878 875
 			return $this->status() == EEM_Event::sold_out;
879
-		}
880
-		else {
876
+		} else {
881 877
 			return $this->perform_sold_out_status_check();
882 878
 		}
883 879
 	}
@@ -1067,8 +1063,7 @@  discard block
 block discarded – undo
1067 1063
 	public function get_permalink() {
1068 1064
 		if ( $this->external_url() ) {
1069 1065
 			return $this->external_url();
1070
-		}
1071
-		else {
1066
+		} else {
1072 1067
 			return parent::get_permalink();
1073 1068
 		}
1074 1069
 	}
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @param array $props_n_values  incoming values from the database
62 62
 	 * @param string $timezone  incoming timezone as set by the model.  If not set the timezone for
63 63
 	 *                          		the website will be used.
64
-	 * @return EE_Attendee
64
+	 * @return EE_Event
65 65
 	 */
66 66
 	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
67 67
 		return new self( $props_n_values, TRUE, $timezone );
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 	 *
975 975
 	 * @access public
976 976
 	 * @param boolean $echo     whether to return (FALSE), or echo out the result (TRUE)
977
-	 * @return mixed void|string
977
+	 * @return null|string void|string
978 978
 	 */
979 979
 	public function pretty_active_status( $echo = TRUE ) {
980 980
 		$active_status = $this->get_active_status();
Please login to merge, or discard this patch.
Spacing   +191 added lines, -191 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
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 *                             		    date_format and the second value is the time format
51 51
 	 * @return EE_Attendee
52 52
 	 */
53
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
54
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
55
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
53
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
54
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
55
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
56 56
 	}
57 57
 
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 *                          		the website will be used.
64 64
 	 * @return EE_Attendee
65 65
 	 */
66
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
67
-		return new self( $props_n_values, TRUE, $timezone );
66
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
67
+		return new self($props_n_values, TRUE, $timezone);
68 68
 	}
69 69
 
70 70
 
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param boolean $show_deleted whether or not to include deleted events
79 79
 	 * @return EE_Datetime[]
80 80
 	 */
81
-	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE, $limit = NULL ) {
82
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit );
81
+	public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE, $limit = NULL) {
82
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit);
83 83
 	}
84 84
 
85 85
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return EE_Datetime
90 90
 	 */
91 91
 	public function first_datetime() {
92
-		return $this->get_first_related( 'Datetime' );
92
+		return $this->get_first_related('Datetime');
93 93
 	}
94 94
 
95 95
 
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 * @param bool $try_to_exclude_deleted
101 101
 	 * @return EE_Datetime
102 102
 	 */
103
-	public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) {
104
-		if ( !empty ( $this->_Primary_Datetime ) ) {
103
+	public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) {
104
+		if ( ! empty ($this->_Primary_Datetime)) {
105 105
 			return $this->_Primary_Datetime;
106 106
 		}
107
-		$this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted );
107
+		$this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted);
108 108
 		return $this->_Primary_Datetime;
109 109
 	}
110 110
 
@@ -115,30 +115,30 @@  discard block
 block discarded – undo
115 115
 	 * @param array $query_params like EEM_Base::get_all
116 116
 	 * @return EE_Ticket[]
117 117
 	 */
118
-	public function tickets( $query_params = array() ) {
118
+	public function tickets($query_params = array()) {
119 119
 		//first get all datetimes
120 120
 		$datetimes = $this->datetimes_ordered();
121
-		if ( ! $datetimes ) {
121
+		if ( ! $datetimes) {
122 122
 			return array();
123 123
 		}
124 124
 
125 125
 		$datetime_ids = array();
126
-		foreach ( $datetimes as $datetime ) {
126
+		foreach ($datetimes as $datetime) {
127 127
 			$datetime_ids[] = $datetime->ID();
128 128
 		}
129 129
 
130
-		$where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) );
130
+		$where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
131 131
 
132 132
 		//if incoming $query_params has where conditions let's merge but not override existing.
133
-		if ( is_array( $query_params ) && isset( $query_params[0]) ) {
134
-			$where_params = array_merge( $query_params[0], $where_params );
135
-			unset( $query_params[0] );
133
+		if (is_array($query_params) && isset($query_params[0])) {
134
+			$where_params = array_merge($query_params[0], $where_params);
135
+			unset($query_params[0]);
136 136
 		}
137 137
 
138 138
 		//now add $where_params to $query_params
139 139
 		$query_params[0] = $where_params;
140 140
 
141
-		return EEM_Ticket::instance()->get_all( $query_params );
141
+		return EEM_Ticket::instance()->get_all($query_params);
142 142
 	}
143 143
 
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return bool
148 148
 	 */
149 149
 	function additional_limit() {
150
-		return $this->get( 'EVT_additional_limit' );
150
+		return $this->get('EVT_additional_limit');
151 151
 	}
152 152
 
153 153
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @return bool
157 157
 	 */
158 158
 	function allow_overflow() {
159
-		return $this->get( 'EVT_allow_overflow' );
159
+		return $this->get('EVT_allow_overflow');
160 160
 	}
161 161
 
162 162
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @return bool
166 166
 	 */
167 167
 	function created() {
168
-		return $this->get( 'EVT_created' );
168
+		return $this->get('EVT_created');
169 169
 	}
170 170
 
171 171
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return bool
175 175
 	 */
176 176
 	function description() {
177
-		return $this->get( 'EVT_desc' );
177
+		return $this->get('EVT_desc');
178 178
 	}
179 179
 
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 * @return string of html
185 185
 	 */
186 186
 	function description_filtered() {
187
-		return $this->get_pretty( 'EVT_desc' );
187
+		return $this->get_pretty('EVT_desc');
188 188
 	}
189 189
 
190 190
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @return bool
194 194
 	 */
195 195
 	function display_description() {
196
-		return $this->get( 'EVT_display_desc' );
196
+		return $this->get('EVT_display_desc');
197 197
 	}
198 198
 
199 199
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @return bool
203 203
 	 */
204 204
 	function display_ticket_selector() {
205
-		return (bool)$this->get( 'EVT_display_ticket_selector' );
205
+		return (bool) $this->get('EVT_display_ticket_selector');
206 206
 	}
207 207
 
208 208
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 * @return bool
212 212
 	 */
213 213
 	function external_url() {
214
-		return $this->get( 'EVT_external_URL' );
214
+		return $this->get('EVT_external_URL');
215 215
 	}
216 216
 
217 217
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return bool
221 221
 	 */
222 222
 	function member_only() {
223
-		return $this->get( 'EVT_member_only' );
223
+		return $this->get('EVT_member_only');
224 224
 	}
225 225
 
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @return bool
230 230
 	 */
231 231
 	function phone() {
232
-		return $this->get( 'EVT_phone' );
232
+		return $this->get('EVT_phone');
233 233
 	}
234 234
 
235 235
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 * @return bool
239 239
 	 */
240 240
 	function modified() {
241
-		return $this->get( 'EVT_modified' );
241
+		return $this->get('EVT_modified');
242 242
 	}
243 243
 
244 244
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 * @return bool
248 248
 	 */
249 249
 	function name() {
250
-		return $this->get( 'EVT_name' );
250
+		return $this->get('EVT_name');
251 251
 	}
252 252
 
253 253
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @return bool
257 257
 	 */
258 258
 	function order() {
259
-		return $this->get( 'EVT_order' );
259
+		return $this->get('EVT_order');
260 260
 	}
261 261
 
262 262
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @return bool|string
266 266
 	 */
267 267
 	function default_registration_status() {
268
-		$event_default_registration_status = $this->get( 'EVT_default_registration_status' );
269
-		return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID;
268
+		$event_default_registration_status = $this->get('EVT_default_registration_status');
269
+		return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID;
270 270
 	}
271 271
 
272 272
 
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
 	 * @param bool $not_full_desc
278 278
 	 * @return bool|string
279 279
 	 */
280
-	function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) {
281
-		$short_desc = $this->get( 'EVT_short_desc' );
282
-		if ( !empty( $short_desc ) || $not_full_desc ) {
280
+	function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) {
281
+		$short_desc = $this->get('EVT_short_desc');
282
+		if ( ! empty($short_desc) || $not_full_desc) {
283 283
 			return $short_desc;
284 284
 		}
285 285
 		else {
286
-			$full_desc = $this->get( 'EVT_desc' );
287
-			return wp_trim_words( $full_desc, $num_words, $more );
286
+			$full_desc = $this->get('EVT_desc');
287
+			return wp_trim_words($full_desc, $num_words, $more);
288 288
 		}
289 289
 	}
290 290
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @return bool
295 295
 	 */
296 296
 	function slug() {
297
-		return $this->get( 'EVT_slug' );
297
+		return $this->get('EVT_slug');
298 298
 	}
299 299
 
300 300
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 * @return bool
304 304
 	 */
305 305
 	function timezone_string() {
306
-		return $this->get( 'EVT_timezone_string' );
306
+		return $this->get('EVT_timezone_string');
307 307
 	}
308 308
 
309 309
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @return bool
313 313
 	 */
314 314
 	function visible_on() {
315
-		return $this->get( 'EVT_visible_on' );
315
+		return $this->get('EVT_visible_on');
316 316
 	}
317 317
 
318 318
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 * @return bool
322 322
 	 */
323 323
 	function wp_user() {
324
-		return $this->get( 'EVT_wp_user' );
324
+		return $this->get('EVT_wp_user');
325 325
 	}
326 326
 
327 327
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @return bool
331 331
 	 */
332 332
 	function donations() {
333
-		return $this->get( 'EVT_donations' );
333
+		return $this->get('EVT_donations');
334 334
 	}
335 335
 
336 336
 
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	/**
339 339
 	 * @param $limit
340 340
 	 */
341
-	function set_additional_limit( $limit ) {
342
-		$this->set( 'EVT_additional_limit', $limit );
341
+	function set_additional_limit($limit) {
342
+		$this->set('EVT_additional_limit', $limit);
343 343
 	}
344 344
 
345 345
 
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	/**
348 348
 	 * @param $created
349 349
 	 */
350
-	function set_created( $created ) {
351
-		$this->set( 'EVT_created', $created );
350
+	function set_created($created) {
351
+		$this->set('EVT_created', $created);
352 352
 	}
353 353
 
354 354
 
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	/**
357 357
 	 * @param $desc
358 358
 	 */
359
-	function set_description( $desc ) {
360
-		$this->set( 'EVT_desc', $desc );
359
+	function set_description($desc) {
360
+		$this->set('EVT_desc', $desc);
361 361
 	}
362 362
 
363 363
 
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	/**
366 366
 	 * @param $display_desc
367 367
 	 */
368
-	function set_display_description( $display_desc ) {
369
-		$this->set( 'EVT_display_desc', $display_desc );
368
+	function set_display_description($display_desc) {
369
+		$this->set('EVT_display_desc', $display_desc);
370 370
 	}
371 371
 
372 372
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 	/**
375 375
 	 * @param $display_ticket_selector
376 376
 	 */
377
-	function set_display_ticket_selector( $display_ticket_selector ) {
378
-		$this->set( 'EVT_display_ticket_selector', $display_ticket_selector );
377
+	function set_display_ticket_selector($display_ticket_selector) {
378
+		$this->set('EVT_display_ticket_selector', $display_ticket_selector);
379 379
 	}
380 380
 
381 381
 
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 	/**
384 384
 	 * @param $external_url
385 385
 	 */
386
-	function set_external_url( $external_url ) {
387
-		$this->set( 'EVT_external_URL', $external_url );
386
+	function set_external_url($external_url) {
387
+		$this->set('EVT_external_URL', $external_url);
388 388
 	}
389 389
 
390 390
 
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	/**
393 393
 	 * @param $member_only
394 394
 	 */
395
-	function set_member_only( $member_only ) {
396
-		$this->set( 'EVT_member_only', $member_only );
395
+	function set_member_only($member_only) {
396
+		$this->set('EVT_member_only', $member_only);
397 397
 	}
398 398
 
399 399
 
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 	/**
402 402
 	 * @param $event_phone
403 403
 	 */
404
-	function set_event_phone( $event_phone ) {
405
-		$this->set( 'EVT_phone', $event_phone );
404
+	function set_event_phone($event_phone) {
405
+		$this->set('EVT_phone', $event_phone);
406 406
 	}
407 407
 
408 408
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 	/**
411 411
 	 * @param $modified
412 412
 	 */
413
-	function set_modified( $modified ) {
414
-		$this->set( 'EVT_modified', $modified );
413
+	function set_modified($modified) {
414
+		$this->set('EVT_modified', $modified);
415 415
 	}
416 416
 
417 417
 
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * @param $name
421 421
 	 */
422
-	function set_name( $name ) {
423
-		$this->set( 'EVT_name', $name );
422
+	function set_name($name) {
423
+		$this->set('EVT_name', $name);
424 424
 	}
425 425
 
426 426
 
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	/**
429 429
 	 * @param $order
430 430
 	 */
431
-	function set_order( $order ) {
432
-		$this->set( 'EVT_order', $order );
431
+	function set_order($order) {
432
+		$this->set('EVT_order', $order);
433 433
 	}
434 434
 
435 435
 
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	/**
438 438
 	 * @param $short_desc
439 439
 	 */
440
-	function set_short_description( $short_desc ) {
441
-		$this->set( 'EVT_short_desc', $short_desc );
440
+	function set_short_description($short_desc) {
441
+		$this->set('EVT_short_desc', $short_desc);
442 442
 	}
443 443
 
444 444
 
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
 	/**
447 447
 	 * @param $slug
448 448
 	 */
449
-	function set_slug( $slug ) {
450
-		$this->set( 'EVT_slug', $slug );
449
+	function set_slug($slug) {
450
+		$this->set('EVT_slug', $slug);
451 451
 	}
452 452
 
453 453
 
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 	/**
456 456
 	 * @param $timezone_string
457 457
 	 */
458
-	function set_timezone_string( $timezone_string ) {
459
-		$this->set( 'EVT_timezone_string', $timezone_string );
458
+	function set_timezone_string($timezone_string) {
459
+		$this->set('EVT_timezone_string', $timezone_string);
460 460
 	}
461 461
 
462 462
 
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 	/**
465 465
 	 * @param $visible_on
466 466
 	 */
467
-	function set_visible_on( $visible_on ) {
468
-		$this->set( 'EVT_visible_on', $visible_on );
467
+	function set_visible_on($visible_on) {
468
+		$this->set('EVT_visible_on', $visible_on);
469 469
 	}
470 470
 
471 471
 
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	/**
474 474
 	 * @param $wp_user
475 475
 	 */
476
-	function set_wp_user( $wp_user ) {
477
-		$this->set( 'EVT_wp_user', $wp_user );
476
+	function set_wp_user($wp_user) {
477
+		$this->set('EVT_wp_user', $wp_user);
478 478
 	}
479 479
 
480 480
 
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	/**
483 483
 	 * @param $default_registration_status
484 484
 	 */
485
-	function set_default_registration_status( $default_registration_status ) {
486
-		$this->set( 'EVT_default_registration_status', $default_registration_status );
485
+	function set_default_registration_status($default_registration_status) {
486
+		$this->set('EVT_default_registration_status', $default_registration_status);
487 487
 	}
488 488
 
489 489
 
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	/**
492 492
 	 * @param $donations
493 493
 	 */
494
-	function set_donations( $donations ) {
495
-		$this->set( 'EVT_donations', $donations );
494
+	function set_donations($donations) {
495
+		$this->set('EVT_donations', $donations);
496 496
 	}
497 497
 
498 498
 
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param EE_Venue /int $venue_id_or_obj
503 503
 	 * @return EE_Venue
504 504
 	 */
505
-	function add_venue( $venue_id_or_obj ) {
506
-		return $this->_add_relation_to( $venue_id_or_obj, 'Venue' );
505
+	function add_venue($venue_id_or_obj) {
506
+		return $this->_add_relation_to($venue_id_or_obj, 'Venue');
507 507
 	}
508 508
 
509 509
 
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	 * @param EE_Venue /int $venue_id_or_obj
514 514
 	 * @return EE_Venue
515 515
 	 */
516
-	function remove_venue( $venue_id_or_obj ) {
517
-		return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' );
516
+	function remove_venue($venue_id_or_obj) {
517
+		return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
518 518
 	}
519 519
 
520 520
 
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 	 * @param array $query_params like EEM_Base::get_all's $query_params
525 525
 	 * @return EE_Venue[]
526 526
 	 */
527
-	function venues( $query_params = array() ) {
528
-		return $this->get_many_related( 'Venue', $query_params );
527
+	function venues($query_params = array()) {
528
+		return $this->get_many_related('Venue', $query_params);
529 529
 	}
530 530
 
531 531
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	 */
538 538
 	private function _has_ID_and_is_published() {
539 539
 		// first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses)
540
-		return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE;
540
+		return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE;
541 541
 	}
542 542
 
543 543
 
@@ -549,21 +549,21 @@  discard block
 block discarded – undo
549 549
 	 */
550 550
 	public function is_upcoming() {
551 551
 		// check if event id is present and if this event is published
552
-		if ( $this->is_inactive() ) {
552
+		if ($this->is_inactive()) {
553 553
 			return FALSE;
554 554
 		}
555 555
 		// set initial value
556 556
 		$upcoming = FALSE;
557 557
 		//next let's get all datetimes and loop through them
558
-		$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
559
-		foreach ( $datetimes as $datetime ) {
560
-			if ( $datetime instanceof EE_Datetime ) {
558
+		$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
559
+		foreach ($datetimes as $datetime) {
560
+			if ($datetime instanceof EE_Datetime) {
561 561
 				//if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
562
-				if ( $datetime->is_expired() ) {
562
+				if ($datetime->is_expired()) {
563 563
 					continue;
564 564
 				}
565 565
 				//if this dtt is active then we return false.
566
-				if ( $datetime->is_active() ) {
566
+				if ($datetime->is_active()) {
567 567
 					return FALSE;
568 568
 				}
569 569
 				//otherwise let's check upcoming status
@@ -580,21 +580,21 @@  discard block
 block discarded – undo
580 580
 	 */
581 581
 	public function is_active() {
582 582
 		// check if event id is present and if this event is published
583
-		if ( $this->is_inactive() ) {
583
+		if ($this->is_inactive()) {
584 584
 			return FALSE;
585 585
 		}
586 586
 		// set initial value
587 587
 		$active = FALSE;
588 588
 		//next let's get all datetimes and loop through them
589
-		$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
590
-		foreach ( $datetimes as $datetime ) {
591
-			if ( $datetime instanceof EE_Datetime ) {
589
+		$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
590
+		foreach ($datetimes as $datetime) {
591
+			if ($datetime instanceof EE_Datetime) {
592 592
 				//if this dtt is expired then we continue cause one of the other datetimes might be active.
593
-				if ( $datetime->is_expired() ) {
593
+				if ($datetime->is_expired()) {
594 594
 					continue;
595 595
 				}
596 596
 				//if this dtt is upcoming then we return false.
597
-				if ( $datetime->is_upcoming() ) {
597
+				if ($datetime->is_upcoming()) {
598 598
 					return FALSE;
599 599
 				}
600 600
 				//otherwise let's check active status
@@ -611,17 +611,17 @@  discard block
 block discarded – undo
611 611
 	 */
612 612
 	public function is_expired() {
613 613
 		// check if event id is present and if this event is published
614
-		if ( $this->is_inactive() ) {
614
+		if ($this->is_inactive()) {
615 615
 			return FALSE;
616 616
 		}
617 617
 		// set initial value
618 618
 		$expired = FALSE;
619 619
 		//first let's get all datetimes and loop through them
620
-		$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
621
-		foreach ( $datetimes as $datetime ) {
622
-			if ( $datetime instanceof EE_Datetime ) {
620
+		$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
621
+		foreach ($datetimes as $datetime) {
622
+			if ($datetime instanceof EE_Datetime) {
623 623
 				//if this dtt is upcoming or active then we return false.
624
-				if ( $datetime->is_upcoming() || $datetime->is_active() ) {
624
+				if ($datetime->is_upcoming() || $datetime->is_active()) {
625 625
 					return FALSE;
626 626
 				}
627 627
 				//otherwise let's check active status
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 	 */
639 639
 	public function is_inactive() {
640 640
 		// check if event id is present and if this event is published
641
-		if ( $this->_has_ID_and_is_published() ) {
641
+		if ($this->_has_ID_and_is_published()) {
642 642
 			return FALSE;
643 643
 		}
644 644
 		return TRUE;
@@ -658,22 +658,22 @@  discard block
 block discarded – undo
658 658
 		// set initial value
659 659
 		$spaces_remaining = 0;
660 660
 		//next let's get all datetimes and loop through them
661
-		$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
662
-		foreach ( $datetimes as $datetime ) {
663
-			if ( $datetime instanceof EE_Datetime ) {
664
-				$dtt_spaces_remaining = $datetime->spaces_remaining( TRUE );
661
+		$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
662
+		foreach ($datetimes as $datetime) {
663
+			if ($datetime instanceof EE_Datetime) {
664
+				$dtt_spaces_remaining = $datetime->spaces_remaining(TRUE);
665 665
 				// if datetime has unlimited reg limit then the event can never be sold out
666
-				if ( $dtt_spaces_remaining === INF ) {
666
+				if ($dtt_spaces_remaining === INF) {
667 667
 					return FALSE;
668 668
 				}
669 669
 				else {
670
-					$spaces_remaining = max( $dtt_spaces_remaining, $spaces_remaining );
670
+					$spaces_remaining = max($dtt_spaces_remaining, $spaces_remaining);
671 671
 				}
672 672
 			}
673 673
 		}
674
-		if ( $spaces_remaining === 0 ) {
675
-			$this->set_status( EEM_Event::sold_out );
676
-			if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) {
674
+		if ($spaces_remaining === 0) {
675
+			$this->set_status(EEM_Event::sold_out);
676
+			if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) {
677 677
 				$this->save();
678 678
 			}
679 679
 			$sold_out = TRUE;
@@ -701,15 +701,15 @@  discard block
 block discarded – undo
701 701
 	 */
702 702
 	public function spaces_remaining_for_sale() {
703 703
 		//first get total available spaces including consideration for tickets that have already sold.
704
-		$spaces_available = $this->total_available_spaces( true );
704
+		$spaces_available = $this->total_available_spaces(true);
705 705
 
706 706
 		//if total available = 0, then exit right away because that means everything is expired.
707
-		if ( $spaces_available === 0 ) {
707
+		if ($spaces_available === 0) {
708 708
 			return 0;
709 709
 		}
710 710
 
711 711
 		//subtract total approved registrations from spaces available to get how many are remaining.
712
-		$spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true );
712
+		$spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true);
713 713
 		$spaces_remaining = $spaces_available - $spots_taken;
714 714
 
715 715
 		return $spaces_remaining > 0 ? $spaces_remaining : 0;
@@ -742,53 +742,53 @@  discard block
 block discarded – undo
742 742
 	 *
743 743
 	 * @return  int|float  (Note: if INF is returned its considered a float by PHP)
744 744
 	 */
745
-	public function total_available_spaces( $current_total_available = false ) {
745
+	public function total_available_spaces($current_total_available = false) {
746 746
 		$spaces_available = 0;
747 747
 
748 748
 		//first get all tickets on the event and include expired tickets
749
-		$tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) );
749
+		$tickets = $this->tickets(array('default_where_conditions' => 'none'));
750 750
 		$ticket_sums = array();
751 751
 		$datetime_limits = array();
752 752
 
753 753
 		//loop through tickets and normalize them
754
-		foreach ( $tickets as $ticket ) {
755
-			$datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) );
754
+		foreach ($tickets as $ticket) {
755
+			$datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC')));
756 756
 
757
-			if ( empty( $datetimes ) ) {
757
+			if (empty($datetimes)) {
758 758
 				continue;
759 759
 			}
760 760
 
761 761
 			//first datetime should be the lowest datetime
762
-			$least_datetime = reset( $datetimes );
762
+			$least_datetime = reset($datetimes);
763 763
 
764 764
 			//lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity
765 765
 			//IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit.
766
-			if ( $current_total_available ) {
767
-				if ( $ticket->is_remaining() ) {
766
+			if ($current_total_available) {
767
+				if ($ticket->is_remaining()) {
768 768
 					$remaining = $ticket->remaining();
769 769
 				} else {
770
-					$spaces_available += $ticket->get( 'TKT_sold' );
770
+					$spaces_available += $ticket->get('TKT_sold');
771 771
 					//and we don't cache this ticket to our list because its sold out.
772 772
 					continue;
773 773
 				}
774 774
 			} else {
775
-				$remaining = min( $ticket->qty(), $least_datetime->reg_limit() );
775
+				$remaining = min($ticket->qty(), $least_datetime->reg_limit());
776 776
 			}
777 777
 
778 778
 			//if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts.
779
-			if ( $remaining == INF ) {
779
+			if ($remaining == INF) {
780 780
 				return INF;
781 781
 			}
782 782
 
783 783
 			//multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum"
784 784
 			//also include the sum of all the datetime reg limits on the ticket for breaking ties.
785
-			$ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes );
785
+			$ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes);
786 786
 			$ticket_sums[$ticket->ID()]['datetime_sums'] = 0;
787
-			foreach ( $datetimes as $datetime ) {
788
-				if ( $datetime->reg_limit() === INF ) {
787
+			foreach ($datetimes as $datetime) {
788
+				if ($datetime->reg_limit() === INF) {
789 789
 					$ticket_sums[$ticket->ID()]['datetime_sums'] = INF;
790 790
 				} else {
791
-					$ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
791
+					$ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
792 792
 				}
793 793
 				$datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
794 794
 			}
@@ -799,66 +799,66 @@  discard block
 block discarded – undo
799 799
 		//ticket quantity by the number of datetimes on the ticket).  For tie-breakers, then the next sort is based on the
800 800
 		//ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not
801 801
 		//$current_total_available ) for the datetimes on the ticket.
802
-		usort( $ticket_sums, function( $a, $b ) {
803
-			if ( $a['sum'] == $b['sum'] ) {
804
-				if ( $a['datetime_sums'] == $b['datetime_sums'] ) {
802
+		usort($ticket_sums, function($a, $b) {
803
+			if ($a['sum'] == $b['sum']) {
804
+				if ($a['datetime_sums'] == $b['datetime_sums']) {
805 805
 					return 0;
806 806
 				}
807 807
 
808 808
 				return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1;
809 809
 			}
810
-			return ( $a['sum'] < $b['sum'] ) ? -1 : 1;
810
+			return ($a['sum'] < $b['sum']) ? -1 : 1;
811 811
 		});
812 812
 
813 813
 		//now let's loop through the sorted tickets and simulate sellouts
814
-		foreach ( $ticket_sums as $ticket_info ) {
815
-			$datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) );
814
+		foreach ($ticket_sums as $ticket_info) {
815
+			$datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC')));
816 816
 			//need to sort these $datetimes by remaining (only if $current_total_available)
817 817
 			//setup datetimes for simulation
818 818
 			$ticket_datetimes_remaining = array();
819
-			foreach( $datetimes as $datetime ) {
819
+			foreach ($datetimes as $datetime) {
820 820
 				$ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()];
821 821
 				$ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime;
822 822
 			}
823
-			usort( $ticket_datetimes_remaining, function( $a, $b ) {
824
-				if ( $a['rem'] == $b['rem'] ) {
823
+			usort($ticket_datetimes_remaining, function($a, $b) {
824
+				if ($a['rem'] == $b['rem']) {
825 825
 					return 0;
826 826
 				}
827
-				return ( $a['rem'] < $b['rem'] ) ? -1 : 1;
827
+				return ($a['rem'] < $b['rem']) ? -1 : 1;
828 828
 			});
829 829
 
830 830
 
831 831
 			//get the remaining on the first datetime (which should be the one with the least remaining) and that is
832 832
 			//what we add to the spaces_available running total.  Then we need to decrease the remaining on our datetime tracker.
833
-			$lowest_datetime = reset( $ticket_datetimes_remaining );
833
+			$lowest_datetime = reset($ticket_datetimes_remaining);
834 834
 
835 835
 			//need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket.
836 836
 			// If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already
837 837
 			// been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue
838 838
 			// to the next ticket.
839
-			$remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() );
839
+			$remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining());
840 840
 
841 841
 			//if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all
842 842
 			//tickets have a quantity.  So we don't have to track datetimes, we can just use ticket quantities for total
843 843
 			//available.
844
-			if ( $remaining === INF ) {
844
+			if ($remaining === INF) {
845 845
 				$spaces_available += $ticket_info['ticket']->qty();
846 846
 				continue;
847 847
 			}
848 848
 
849 849
 			//if ticket has sold amounts then we also need to add that (but only if doing live counts)
850
-			if ( $current_total_available ) {
850
+			if ($current_total_available) {
851 851
 				$spaces_available += $ticket_info['ticket']->sold();
852 852
 			}
853 853
 
854
-			if ( $remaining <= 0 ) {
854
+			if ($remaining <= 0) {
855 855
 				continue;
856 856
 			} else {
857 857
 				$spaces_available += $remaining;
858 858
 			}
859 859
 
860 860
 			//loop through the datetimes and sell them out!
861
-			foreach ( $ticket_datetimes_remaining as $datetime_info ) {
861
+			foreach ($ticket_datetimes_remaining as $datetime_info) {
862 862
 				$datetime_limits[$datetime_info['datetime']->ID()] += - $remaining;
863 863
 			}
864 864
 		}
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param  bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event
874 874
 	 * @return boolean
875 875
 	 */
876
-	public function is_sold_out( $actual = FALSE ) {
877
-		if ( !$actual ) {
876
+	public function is_sold_out($actual = FALSE) {
877
+		if ( ! $actual) {
878 878
 			return $this->status() == EEM_Event::sold_out;
879 879
 		}
880 880
 		else {
@@ -912,36 +912,36 @@  discard block
 block discarded – undo
912 912
 	 * @param bool $reset
913 913
 	 * @return bool | string - based on EE_Datetime active constants or FALSE if error.
914 914
 	 */
915
-	public function get_active_status( $reset = FALSE ) {
915
+	public function get_active_status($reset = FALSE) {
916 916
 		// if the active status has already been set, then just use that value (unless we are resetting it)
917
-		if ( ! empty( $this->_active_status ) && ! $reset ) {
917
+		if ( ! empty($this->_active_status) && ! $reset) {
918 918
 			return $this->_active_status;
919 919
 		}
920 920
 		//first check if event id is present on this object
921
-		if ( ! $this->ID() ) {
921
+		if ( ! $this->ID()) {
922 922
 			return FALSE;
923 923
 		}
924 924
 		//first get all datetimes ordered by date
925
-		$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
925
+		$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
926 926
 		//next loop through $datetimes and setup status array
927 927
 		$status_array = array();
928
-		foreach ( $datetimes as $datetime ) {
929
-			if ( $datetime instanceof EE_Datetime ) {
928
+		foreach ($datetimes as $datetime) {
929
+			if ($datetime instanceof EE_Datetime) {
930 930
 				$status_array[] = $datetime->get_active_status();
931 931
 			}
932 932
 		}
933 933
 		//now we can conditionally determine status
934
-		if ( $this->status() == 'publish' ) {
935
-			if ( in_array( EE_Datetime::active, $status_array ) ) {
934
+		if ($this->status() == 'publish') {
935
+			if (in_array(EE_Datetime::active, $status_array)) {
936 936
 				$this->_active_status = EE_Datetime::active;
937 937
 			} else {
938
-				if ( in_array( EE_Datetime::upcoming, $status_array ) ) {
938
+				if (in_array(EE_Datetime::upcoming, $status_array)) {
939 939
 					$this->_active_status = EE_Datetime::upcoming;
940 940
 				} else {
941
-					if ( in_array( EE_Datetime::expired, $status_array ) ) {
941
+					if (in_array(EE_Datetime::expired, $status_array)) {
942 942
 						$this->_active_status = EE_Datetime::expired;
943 943
 					} else {
944
-						if ( in_array( EE_Datetime::sold_out, $status_array ) ) {
944
+						if (in_array(EE_Datetime::sold_out, $status_array)) {
945 945
 							$this->_active_status = EE_Datetime::sold_out;
946 946
 						} else {
947 947
 							$this->_active_status = EE_Datetime::expired; //catchall
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 				}
951 951
 			}
952 952
 		} else {
953
-			switch ( $this->status() ) {
953
+			switch ($this->status()) {
954 954
 				case EEM_Event::sold_out :
955 955
 					$this->_active_status = EE_Datetime::sold_out;
956 956
 					break;
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
 	 * @param boolean $echo     whether to return (FALSE), or echo out the result (TRUE)
977 977
 	 * @return mixed void|string
978 978
 	 */
979
-	public function pretty_active_status( $echo = TRUE ) {
979
+	public function pretty_active_status($echo = TRUE) {
980 980
 		$active_status = $this->get_active_status();
981
-		$status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>';
982
-		if ( $echo ) {
981
+		$status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>';
982
+		if ($echo) {
983 983
 			echo $status;
984 984
 		} else {
985 985
 			return $status;
@@ -993,12 +993,12 @@  discard block
 block discarded – undo
993 993
 	 */
994 994
 	public function get_number_of_tickets_sold() {
995 995
 		$tkt_sold = 0;
996
-		if ( !$this->ID() ) {
996
+		if ( ! $this->ID()) {
997 997
 			return 0;
998 998
 		}
999
-		$datetimes = $this->get_many_related( 'Datetime' );
1000
-		foreach ( $datetimes as $datetime ) {
1001
-			$tkt_sold += $datetime->get( 'DTT_sold' );
999
+		$datetimes = $this->get_many_related('Datetime');
1000
+		foreach ($datetimes as $datetime) {
1001
+			$tkt_sold += $datetime->get('DTT_sold');
1002 1002
 		}
1003 1003
 		return $tkt_sold;
1004 1004
 	}
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 	 * @return int
1012 1012
 	 */
1013 1013
 	public function get_count_of_all_registrations() {
1014
-		return EEM_Event::instance()->count_related( $this, 'Registration' );
1014
+		return EEM_Event::instance()->count_related($this, 'Registration');
1015 1015
 	}
1016 1016
 
1017 1017
 
@@ -1021,9 +1021,9 @@  discard block
 block discarded – undo
1021 1021
 	 * @return EE_Ticket
1022 1022
 	 */
1023 1023
 	public function get_ticket_with_earliest_start_time() {
1024
-		$where[ 'Datetime.EVT_ID' ] = $this->ID();
1025
-		$query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) );
1026
-		return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params );
1024
+		$where['Datetime.EVT_ID'] = $this->ID();
1025
+		$query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1026
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1027 1027
 	}
1028 1028
 
1029 1029
 
@@ -1033,9 +1033,9 @@  discard block
 block discarded – undo
1033 1033
 	 * @return EE_Ticket
1034 1034
 	 */
1035 1035
 	public function get_ticket_with_latest_end_time() {
1036
-		$where[ 'Datetime.EVT_ID' ] = $this->ID();
1037
-		$query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) );
1038
-		return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params );
1036
+		$where['Datetime.EVT_ID'] = $this->ID();
1037
+		$query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1038
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1039 1039
 	}
1040 1040
 
1041 1041
 
@@ -1047,11 +1047,11 @@  discard block
 block discarded – undo
1047 1047
 	public function tickets_on_sale() {
1048 1048
 		$earliest_ticket = $this->get_ticket_with_earliest_start_time();
1049 1049
 		$latest_ticket = $this->get_ticket_with_latest_end_time();
1050
-		if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) {
1050
+		if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) {
1051 1051
 			return FALSE;
1052 1052
 		}
1053 1053
 		//check on sale for these two tickets.
1054
-		if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) {
1054
+		if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) {
1055 1055
 			return TRUE;
1056 1056
 		}
1057 1057
 		return FALSE;
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	 * @return string
1066 1066
 	 */
1067 1067
 	public function get_permalink() {
1068
-		if ( $this->external_url() ) {
1068
+		if ($this->external_url()) {
1069 1069
 			return $this->external_url();
1070 1070
 		}
1071 1071
 		else {
@@ -1080,10 +1080,10 @@  discard block
 block discarded – undo
1080 1080
 	 * @param array $query_params like EEM_Base::get_all
1081 1081
 	 * @return EE_Term
1082 1082
 	 */
1083
-	public function first_event_category( $query_params = array() ) {
1084
-		$query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories';
1085
-		$query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID();
1086
-		return EEM_Term::instance()->get_one( $query_params );
1083
+	public function first_event_category($query_params = array()) {
1084
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1085
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1086
+		return EEM_Term::instance()->get_one($query_params);
1087 1087
 	}
1088 1088
 
1089 1089
 
@@ -1093,10 +1093,10 @@  discard block
 block discarded – undo
1093 1093
 	 * @param array $query_params
1094 1094
 	 * @return EE_Term[]
1095 1095
 	 */
1096
-	public function get_all_event_categories( $query_params = array() ) {
1097
-		$query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories';
1098
-		$query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID();
1099
-		return EEM_Term::instance()->get_all( $query_params );
1096
+	public function get_all_event_categories($query_params = array()) {
1097
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1098
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1099
+		return EEM_Term::instance()->get_all($query_params);
1100 1100
 	}
1101 1101
 
1102 1102
 	/**
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
 	 * @param array $query_params @see EEM_Base::get_all
1105 1105
 	 * @return EE_Question_Group[]
1106 1106
 	 */
1107
-	public function question_groups($query_params = array()){
1108
-		$query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' ));
1107
+	public function question_groups($query_params = array()) {
1108
+		$query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1109 1109
 		return $this->get_many_related('Question_Group', $query_params);
1110 1110
 	}
1111 1111
 
Please login to merge, or discard this patch.