Completed
Branch FET-9783-command-bus (ec950d)
by
unknown
1399:29 queued 1385:17
created
core/db_models/EEM_Attendee.model.php 4 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 
106 106
 
107 107
 	/**
108
-	*		retrieve  a single attendee from db via their ID
109
-	*
110
-	* 		@access		public
111
-	* 		@param		$ATT_ID
112
-	*		@return 		mixed		array on success, FALSE on fail
108
+	 *		retrieve  a single attendee from db via their ID
109
+	 *
110
+	 * 		@access		public
111
+	 * 		@param		$ATT_ID
112
+	 *		@return 		mixed		array on success, FALSE on fail
113 113
 	 * 		@deprecated
114
-	*/
114
+	 */
115 115
 	public function get_attendee_by_ID( $ATT_ID = FALSE ) {
116 116
 		// retrieve a particular EE_Attendee
117 117
 		return $this->get_one_by_ID( $ATT_ID );
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 
122 122
 
123 123
 	/**
124
-	*		retrieve  a single attendee from db via their ID
125
-	*
126
-	* 		@access		public
127
-	* 		@param		array $where_cols_n_values
128
-	*		@return 		mixed		array on success, FALSE on fail
129
-	*/
124
+	 *		retrieve  a single attendee from db via their ID
125
+	 *
126
+	 * 		@access		public
127
+	 * 		@param		array $where_cols_n_values
128
+	 *		@return 		mixed		array on success, FALSE on fail
129
+	 */
130 130
 	public function get_attendee( $where_cols_n_values = array() ) {
131 131
 
132 132
 		if ( empty( $where_cols_n_values )) {
@@ -174,20 +174,20 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 	/**
177
-             * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
178
-             * EE_Attendee objects.
179
-             *
180
-             * @since    4.3.0
181
-             * @param  array $ids array of EE_Registration ids
182
-             * @return  EE_Attendee[]
183
-             */
184
-            public function get_array_of_contacts_from_reg_ids( $ids ) {
185
-                $ids = (array) $ids;
186
-                $_where = array(
187
-                    'Registration.REG_ID' => array( 'in', $ids )
188
-                    );
189
-                return $this->get_all( array( $_where ) );
190
-            }
177
+	 * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
178
+	 * EE_Attendee objects.
179
+	 *
180
+	 * @since    4.3.0
181
+	 * @param  array $ids array of EE_Registration ids
182
+	 * @return  EE_Attendee[]
183
+	 */
184
+			public function get_array_of_contacts_from_reg_ids( $ids ) {
185
+				$ids = (array) $ids;
186
+				$_where = array(
187
+					'Registration.REG_ID' => array( 'in', $ids )
188
+					);
189
+				return $this->get_all( array( $_where ) );
190
+			}
191 191
 
192 192
 
193 193
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
2
+require_once (EE_MODELS.'EEM_Base.model.php');
3 3
 
4 4
 /**
5 5
  *
@@ -21,60 +21,60 @@  discard block
 block discarded – undo
21 21
 	 * Please instead use the EEM_Attendee::system_question_* constants
22 22
 	 * @deprecated
23 23
 	 */
24
-	const fname_question_id=1;
24
+	const fname_question_id = 1;
25 25
 
26 26
 	/**
27 27
 	 * @deprecated
28 28
 	 */
29
-	const lname_question_id=2;
29
+	const lname_question_id = 2;
30 30
 
31 31
 
32 32
 	/**
33 33
 	 * @deprecated
34 34
 	 */
35
-	const email_question_id=3;
35
+	const email_question_id = 3;
36 36
 
37 37
 
38 38
 	/**
39 39
 	 * @deprecated
40 40
 	 */
41
-	const address_question_id=4;
41
+	const address_question_id = 4;
42 42
 
43 43
 
44 44
 	/**
45 45
 	 * @deprecated
46 46
 	 */
47
-	const address2_question_id=5;
47
+	const address2_question_id = 5;
48 48
 
49 49
 
50 50
 	/**
51 51
 	 * @deprecated
52 52
 	 */
53
-	const city_question_id=6;
53
+	const city_question_id = 6;
54 54
 
55 55
 
56 56
 	/**
57 57
 	 * @deprecated
58 58
 	 */
59
-	const state_question_id=7;
59
+	const state_question_id = 7;
60 60
 
61 61
 
62 62
 	/**
63 63
 	 * @deprecated
64 64
 	 */
65
-	const country_question_id=8;
65
+	const country_question_id = 8;
66 66
 
67 67
 
68 68
 	/**
69 69
 	 * @deprecated
70 70
 	 */
71
-	const zip_question_id=9;
71
+	const zip_question_id = 9;
72 72
 
73 73
 
74 74
 	/**
75 75
 	 * @deprecated
76 76
 	 */
77
-	const phone_question_id=10;
77
+	const phone_question_id = 10;
78 78
 
79 79
 	/**
80 80
 	 * When looking for questions that correspond to attendee fields,
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 * @access protected
120 120
 	 * @param null $timezone
121 121
 	 */
122
-	protected function __construct( $timezone = NULL ) {
123
-		$this->singular_item = __('Attendee','event_espresso');
124
-		$this->plural_item = __('Attendees','event_espresso');
122
+	protected function __construct($timezone = NULL) {
123
+		$this->singular_item = __('Attendee', 'event_espresso');
124
+		$this->plural_item = __('Attendees', 'event_espresso');
125 125
 		$this->_tables = array(
126 126
 			'Attendee_CPT'=> new EE_Primary_Table('posts', 'ID'),
127 127
 			'Attendee_Meta'=>new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID')
@@ -135,37 +135,37 @@  discard block
 block discarded – undo
135 135
 				'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, time()),
136 136
 				'ATT_short_bio'=>new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")),
137 137
 				'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, time()),
138
-				'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false ),
138
+				'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false),
139 139
 				'ATT_parent'=>new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), false, 0),
140
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'),// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
140
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'), // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
141 141
 				'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish')
142 142
 			),
143 143
 			'Attendee_Meta'=>array(
144
-				'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID','event_espresso'), false),
144
+				'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), false),
145 145
 				'ATT_ID_fk'=>new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false),
146
-				'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name','event_espresso'), true, ''),
147
-				'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name','event_espresso'), true, ''),
148
-				'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1','event_espresso'), true, ''),
149
-				'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2','event_espresso'), true, ''),
150
-				'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City','event_espresso'), true, ''),
151
-				'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State','event_espresso'), true,0,'State'),
152
-				'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country','event_espresso'), true,'','Country'),
153
-				'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code','event_espresso'), true, ''),
154
-				'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address','event_espresso'), true, ''),
155
-				'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone','event_espresso'), true, '')
146
+				'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''),
147
+				'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''),
148
+				'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''),
149
+				'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''),
150
+				'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''),
151
+				'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'),
152
+				'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'),
153
+				'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''),
154
+				'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''),
155
+				'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '')
156 156
 			));
157 157
 		$this->_model_relations = array(
158 158
 			'Registration'=>new EE_Has_Many_Relation(),
159 159
 			'State'=>new EE_Belongs_To_Relation(),
160 160
 			'Country'=>new EE_Belongs_To_Relation(),
161
-			'Event'=>new EE_HABTM_Relation('Registration', FALSE ),
161
+			'Event'=>new EE_HABTM_Relation('Registration', FALSE),
162 162
 			'WP_User' => new EE_Belongs_To_Relation(),
163
-			'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletion of attendees even if they have messages in the queue for them.
163
+			'Message' => new EE_Has_Many_Any_Relation(false) //allow deletion of attendees even if they have messages in the queue for them.
164 164
 		);
165 165
 		require_once('strategies/EE_CPT_Where_Conditions.strategy.php');
166 166
 		$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_attendees', 'ATTM_ID');
167 167
 		$this->_caps_slug = 'contacts';
168
-		parent::__construct( $timezone );
168
+		parent::__construct($timezone);
169 169
 
170 170
 	}
171 171
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @param string $system_question_string
176 176
 	 * @return string|null if not found
177 177
 	 */
178
-	public function get_attendee_field_for_system_question( $system_question_string ) {
179
-		return isset( $this->_system_question_to_attendee_field_name[ $system_question_string ] ) ? $this->_system_question_to_attendee_field_name[ $system_question_string ] : null;
178
+	public function get_attendee_field_for_system_question($system_question_string) {
179
+		return isset($this->_system_question_to_attendee_field_name[$system_question_string]) ? $this->_system_question_to_attendee_field_name[$system_question_string] : null;
180 180
 	}
181 181
 
182 182
 
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	 * @param EE_Transaction/int $transaction_id_or_obj EE_Transaction or its ID
188 188
 	 * @return EE_Attendee[]
189 189
 	 */
190
-	public function get_attendees_for_transaction( $transaction_id_or_obj ){
191
-		return $this->get_all( array( array(
190
+	public function get_attendees_for_transaction($transaction_id_or_obj) {
191
+		return $this->get_all(array(array(
192 192
 			  'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction ? $transaction_id_or_obj->ID() : $transaction_id_or_obj
193 193
 		  )));
194 194
 	}
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 	*		@return 		mixed		array on success, FALSE on fail
204 204
 	 * 		@deprecated
205 205
 	*/
206
-	public function get_attendee_by_ID( $ATT_ID = FALSE ) {
206
+	public function get_attendee_by_ID($ATT_ID = FALSE) {
207 207
 		// retrieve a particular EE_Attendee
208
-		return $this->get_one_by_ID( $ATT_ID );
208
+		return $this->get_one_by_ID($ATT_ID);
209 209
 	}
210 210
 
211 211
 
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
 	* 		@param		array $where_cols_n_values
219 219
 	*		@return 		mixed		array on success, FALSE on fail
220 220
 	*/
221
-	public function get_attendee( $where_cols_n_values = array() ) {
221
+	public function get_attendee($where_cols_n_values = array()) {
222 222
 
223
-		if ( empty( $where_cols_n_values )) {
223
+		if (empty($where_cols_n_values)) {
224 224
 			return FALSE;
225 225
 		}
226
-		$attendee = $this->get_all( array($where_cols_n_values ));
227
-		if ( ! empty( $attendee )) {
228
-			return array_shift( $attendee );
226
+		$attendee = $this->get_all(array($where_cols_n_values));
227
+		if ( ! empty($attendee)) {
228
+			return array_shift($attendee);
229 229
 		} else {
230 230
 			return FALSE;
231 231
 		}
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 	 * @param array $where_cols_n_values
242 242
 	 * @return bool|mixed
243 243
 	 */
244
-	public function find_existing_attendee( $where_cols_n_values = NULL ) {
244
+	public function find_existing_attendee($where_cols_n_values = NULL) {
245 245
 		// search by combo of first and last names plus the email address
246
-		$attendee_data_keys = array( 'ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email );
246
+		$attendee_data_keys = array('ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email);
247 247
 		// no search params means attendee object already exists.
248
-		$where_cols_n_values = is_array( $where_cols_n_values ) && ! empty( $where_cols_n_values ) ? $where_cols_n_values : $attendee_data_keys;
248
+		$where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values : $attendee_data_keys;
249 249
 		$valid_data = TRUE;
250 250
 		// check for required values
251
-		$valid_data = isset( $where_cols_n_values['ATT_fname'] ) && ! empty( $where_cols_n_values['ATT_fname'] ) ? $valid_data : FALSE;
252
-		$valid_data = isset( $where_cols_n_values['ATT_lname'] ) && ! empty( $where_cols_n_values['ATT_lname'] ) ? $valid_data : FALSE;
253
-		$valid_data = isset( $where_cols_n_values['ATT_email'] ) && ! empty( $where_cols_n_values['ATT_email'] ) ? $valid_data : FALSE;
251
+		$valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) ? $valid_data : FALSE;
252
+		$valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) ? $valid_data : FALSE;
253
+		$valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) ? $valid_data : FALSE;
254 254
 
255
-		if ( $valid_data ) {
256
-			$attendee = $this->get_attendee( $where_cols_n_values );
257
-			if ( $attendee instanceof EE_Attendee ) {
255
+		if ($valid_data) {
256
+			$attendee = $this->get_attendee($where_cols_n_values);
257
+			if ($attendee instanceof EE_Attendee) {
258 258
 				return $attendee;
259 259
 			}
260 260
 		}
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
              * @param  array $ids array of EE_Registration ids
273 273
              * @return  EE_Attendee[]
274 274
              */
275
-            public function get_array_of_contacts_from_reg_ids( $ids ) {
275
+            public function get_array_of_contacts_from_reg_ids($ids) {
276 276
                 $ids = (array) $ids;
277 277
                 $_where = array(
278
-                    'Registration.REG_ID' => array( 'in', $ids )
278
+                    'Registration.REG_ID' => array('in', $ids)
279 279
                     );
280
-                return $this->get_all( array( $_where ) );
280
+                return $this->get_all(array($_where));
281 281
             }
282 282
 
283 283
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@
 block discarded – undo
257 257
 	* 		@param	int	$TXN_ID
258 258
 	* 		@param    int		$ATT_ID
259 259
 	* 		@param    int		$att_nmbr 	in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required
260
-	*		@return 		mixed		array on success, FALSE on fail
260
+	*		@return 		EE_Base_Class|null		array on success, FALSE on fail
261 261
 	*/
262 262
 	public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) {
263 263
 		return $this->get_one(array(
Please login to merge, or discard this patch.
core/db_models/EEM_CPT_Base.model.php 2 patches
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
119 119
 		if($field){
120 120
 			return $field->get_name();
121
-		}else{
121
+		} else{
122 122
 			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
123 123
 		}
124 124
 	}
@@ -193,14 +193,16 @@  discard block
 block discarded – undo
193 193
 	public function get_meta_table_fields( $all = FALSE ) {
194 194
 		$all_fields = $fields_to_return = array();
195 195
 		foreach ( $this->_tables as $alias => $table_obj ) {
196
-			if ( $table_obj instanceof EE_Secondary_Table )
197
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
196
+			if ( $table_obj instanceof EE_Secondary_Table ) {
197
+							$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
198
+			}
198 199
 		}
199 200
 
200 201
 		if ( !$all ) {
201 202
 			foreach ( $all_fields as $name => $obj ) {
202
-				if ( $obj instanceof EE_DB_Only_Field_Base )
203
-					continue;
203
+				if ( $obj instanceof EE_DB_Only_Field_Base ) {
204
+									continue;
205
+				}
204 206
 				$fields_to_return[] = $name;
205 207
 			}
206 208
 		} else {
@@ -248,7 +250,7 @@  discard block
 block discarded – undo
248 250
 				'parent'=>$parent_term_taxonomy_id
249 251
 			));
250 252
 			$term_taxonomy->save();
251
-		}else{
253
+		} else{
252 254
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
253 255
 			$term_taxonomy->save();
254 256
 		}
@@ -366,7 +368,7 @@  discard block
 block discarded – undo
366 368
 		if( ! $has_all_necessary_fields_for_table){
367 369
 
368 370
 			return $this->get_one_by_ID($post['ID']);
369
-		}else{
371
+		} else{
370 372
 			return $this->instantiate_class_from_array_or_object($post);
371 373
 		}
372 374
 	}
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('EE_Event_Category_Taxonomy','espresso_event_category');
2
+define('EE_Event_Category_Taxonomy', 'espresso_event_category');
3 3
 /**
4 4
  *
5 5
  * EEM_CPT_Base
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 				Mike Nelson
17 17
  *
18 18
  */
19
-abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{
19
+abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base {
20 20
 
21 21
 	/**
22 22
 	 * @var string post_status_publish - the wp post status for published cpts
@@ -69,55 +69,55 @@  discard block
 block discarded – undo
69 69
 	 * @param string $timezone
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	protected function __construct( $timezone = NULL ){
72
+	protected function __construct($timezone = NULL) {
73 73
 
74 74
 		//adds a relationship to Term_Taxonomy for all these models. For this to work
75 75
 		//Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly
76 76
 		//eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry
77 77
 		//with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value
78 78
 		//must also be new EE_HABTM_Relation('Term_Relationship');
79
-		$this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship');
79
+		$this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship');
80 80
 		$primary_table_name = NULL;
81 81
 		//add  the common _status field to all CPT primary tables.
82
-		foreach ( $this->_tables as $alias => $table_obj ) {
83
-			if ( $table_obj instanceof EE_Primary_Table ) {
82
+		foreach ($this->_tables as $alias => $table_obj) {
83
+			if ($table_obj instanceof EE_Primary_Table) {
84 84
 				$primary_table_name = $alias;
85 85
 			}
86 86
 		}
87 87
 		//set default wp post statuses if child has not already set.
88
-		if ( ! isset( $this->_fields[$primary_table_name]['status'] )) {
88
+		if ( ! isset($this->_fields[$primary_table_name]['status'])) {
89 89
 			$this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft');
90 90
 		}
91
-		if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){
92
-			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, '');
91
+		if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) {
92
+			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, '');
93 93
 		}
94
-		if( ! isset( $this->_fields[$primary_table_name]['pinged'])){
95
-			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, '');
94
+		if ( ! isset($this->_fields[$primary_table_name]['pinged'])) {
95
+			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, '');
96 96
 		}
97 97
 
98
-		if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){
99
-			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open');
98
+		if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) {
99
+			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open');
100 100
 		}
101 101
 
102
-		if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){
102
+		if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) {
103 103
 			$this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open');
104 104
 		}
105 105
 
106
-		if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){
107
-			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, '');
106
+		if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) {
107
+			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, '');
108 108
 		}
109
-		if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) {
109
+		if ( ! isset($this->_model_relations['Post_Meta'])) {
110 110
 			//don't block deletes though because we want to maintain the current behaviour
111
-			$this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false );
111
+			$this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false);
112 112
 		}
113
-		if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){
113
+		if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
114 114
 			//nothing was set during child constructor, so set default
115
-			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() );
115
+			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type());
116 116
 		}
117
-		if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) {
117
+		if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
118 118
 			//nothing was set during child constructor, so set default
119 119
 			//it's ok for child classes to specify this, but generally this is more DRY
120
-			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() );
120
+			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type());
121 121
 		}
122 122
 		parent::__construct($timezone);
123 123
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function public_event_stati() {
132 132
 		// @see wp-includes/post.php
133
-		return get_post_stati( array( 'public' => TRUE ));
133
+		return get_post_stati(array('public' => TRUE));
134 134
 	}
135 135
 
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return string
142 142
 	 * @throws EE_Error
143 143
 	 */
144
-	public function deleted_field_name(){
144
+	public function deleted_field_name() {
145 145
 		throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso")));
146 146
 	}
147 147
 
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 * @return string
153 153
 	 * @throws EE_Error
154 154
 	 */
155
-	public function post_status_field_name(){
155
+	public function post_status_field_name() {
156 156
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
157
-		if($field){
157
+		if ($field) {
158 158
 			return $field->get_name();
159
-		}else{
160
-			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
159
+		} else {
160
+			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
161 161
 		}
162 162
 	}
163 163
 
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param array $query_params like EEM_Base::get_all's $query_params
169 169
 	 * @return array like EEM_Base::get_all's $query_params
170 170
 	 */
171
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
172
-		$post_status_field_name=$this->post_status_field_name();
173
-		$query_params[0][$post_status_field_name]=self::post_status_trashed;
171
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
172
+		$post_status_field_name = $this->post_status_field_name();
173
+		$query_params[0][$post_status_field_name] = self::post_status_trashed;
174 174
 		return $query_params;
175 175
 	}
176 176
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param array $query_params
182 182
 	 * @return array
183 183
 	 */
184
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
185
-		$query_params[ 'default_where_conditions' ] = 'minimum';
184
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
185
+		$query_params['default_where_conditions'] = 'minimum';
186 186
 		return $query_params;
187 187
 	}
188 188
 
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 	 * @param array $query_params like EEM_Base::get_all
195 195
 	 * @return boolean success
196 196
 	 */
197
-	function delete_or_restore($delete=true,$query_params = array()){
198
-		$post_status_field_name=$this->post_status_field_name();
197
+	function delete_or_restore($delete = true, $query_params = array()) {
198
+		$post_status_field_name = $this->post_status_field_name();
199 199
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
200 200
 		$new_status = $delete ? self::post_status_trashed : 'draft';
201
-		if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) {
201
+		if ($this->update(array($post_status_field_name=>$new_status), $query_params)) {
202 202
 			return TRUE;
203 203
 		} else {
204 204
 			return FALSE;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function meta_table() {
217 217
 		$meta_table = $this->_get_other_tables();
218
-		$meta_table = reset( $meta_table );
218
+		$meta_table = reset($meta_table);
219 219
 		return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL;
220 220
 	}
221 221
 
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 	 * @param  bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields.  Defaults to false (no db only fields)
228 228
 	 * @return array
229 229
 	 */
230
-	public function get_meta_table_fields( $all = FALSE ) {
230
+	public function get_meta_table_fields($all = FALSE) {
231 231
 		$all_fields = $fields_to_return = array();
232
-		foreach ( $this->_tables as $alias => $table_obj ) {
233
-			if ( $table_obj instanceof EE_Secondary_Table )
234
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
232
+		foreach ($this->_tables as $alias => $table_obj) {
233
+			if ($table_obj instanceof EE_Secondary_Table)
234
+				$all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields);
235 235
 		}
236 236
 
237
-		if ( !$all ) {
238
-			foreach ( $all_fields as $name => $obj ) {
239
-				if ( $obj instanceof EE_DB_Only_Field_Base )
237
+		if ( ! $all) {
238
+			foreach ($all_fields as $name => $obj) {
239
+				if ($obj instanceof EE_DB_Only_Field_Base)
240 240
 					continue;
241 241
 				$fields_to_return[] = $name;
242 242
 			}
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 	 * @param int $parent_term_taxonomy_id
260 260
 	 * @return EE_Term_Taxonomy
261 261
 	 */
262
-	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){
262
+	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) {
263 263
 		//create term
264
-		require_once( EE_MODELS . 'EEM_Term.model.php');
264
+		require_once(EE_MODELS.'EEM_Term.model.php');
265 265
 		//first, check for a term by the same name or slug
266 266
 		$category_slug = sanitize_title($category_name);
267
-		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug))));
268
-		if( ! $term ){
267
+		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug))));
268
+		if ( ! $term) {
269 269
 			$term = EE_Term::new_instance(array(
270 270
 				'name'=>$category_name,
271 271
 				'slug'=>$category_slug
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 			$term->save();
274 274
 		}
275 275
 		//make sure there's a term-taxonomy entry too
276
-		require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php');
277
-		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy)));
276
+		require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php');
277
+		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy)));
278 278
 		/** @var $term_taxonomy EE_Term_Taxonomy */
279
-		if( ! $term_taxonomy ){
279
+		if ( ! $term_taxonomy) {
280 280
 			$term_taxonomy = EE_Term_Taxonomy::new_instance(array(
281 281
 				'term_id'=>$term->ID(),
282 282
 				'taxonomy'=>EE_Event_Category_Taxonomy,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				'parent'=>$parent_term_taxonomy_id
286 286
 			));
287 287
 			$term_taxonomy->save();
288
-		}else{
288
+		} else {
289 289
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
290 290
 			$term_taxonomy->save();
291 291
 		}
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
 	 * @param string $category_name name of the event category (term)
301 301
 	 * @return bool
302 302
 	 */
303
-	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){
303
+	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) {
304 304
 		//find the term_taxonomy by that name
305
-		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy)));
305
+		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy)));
306 306
 		/** @var $term_taxonomy EE_Term_Taxonomy */
307
-		if( $term_taxonomy ){
307
+		if ($term_taxonomy) {
308 308
 			$term_taxonomy->set_count($term_taxonomy->count() - 1);
309 309
 			$term_taxonomy->save();
310 310
 		}
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 * @param string|array $attr Optional. Query string or array of attributes.
325 325
 	 * @return string HTML image element
326 326
 	 */
327
-	public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) {
328
-		return get_the_post_thumbnail( $id, $size, $attr );
327
+	public function get_feature_image($id, $size = 'thumbnail', $attr = '') {
328
+		return get_the_post_thumbnail($id, $size, $attr);
329 329
 	}
330 330
 
331 331
 
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 * @global array $wp_post_statuses set in wp core for storing all the post stati
339 339
 	 * @return array
340 340
 	 */
341
-	public function get_post_statuses(){
341
+	public function get_post_statuses() {
342 342
 		global $wp_post_statuses;
343 343
 		$statuses = array();
344
-		foreach($wp_post_statuses as $post_status => $args_object){
344
+		foreach ($wp_post_statuses as $post_status => $args_object) {
345 345
 			$statuses[$post_status] = $args_object->label;
346 346
 		}
347 347
 		return $statuses;
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	public function get_status_array() {
357 357
 		$statuses = $this->get_post_statuses();
358 358
 		//first the global filter
359
-		$statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses );
359
+		$statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses);
360 360
 		//now the class specific filter
361
-		$statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses );
361
+		$statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses);
362 362
 		return $statuses;
363 363
 	}
364 364
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	public function get_custom_post_statuses() {
372 372
 		$new_stati = array();
373
-		foreach ( $this->_custom_stati as $status => $props ) {
373
+		foreach ($this->_custom_stati as $status => $props) {
374 374
 			$new_stati[$status] = $props['label'];
375 375
 		}
376 376
 		return $new_stati;
@@ -386,24 +386,24 @@  discard block
 block discarded – undo
386 386
 	 * @param WP_Post|array $post
387 387
 	 * @return EE_CPT_Base
388 388
 	 */
389
-	public function instantiate_class_from_post_object_orig($post){
390
-		$post = (array)$post;
389
+	public function instantiate_class_from_post_object_orig($post) {
390
+		$post = (array) $post;
391 391
 		$has_all_necessary_fields_for_table = true;
392 392
 		//check if the post has fields on the meta table already
393
-		foreach($this->_get_other_tables() as $table_obj){
393
+		foreach ($this->_get_other_tables() as $table_obj) {
394 394
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
395
-			foreach($fields_for_that_table as $field_obj){
396
-				if( ! isset($post[$field_obj->get_table_column()])
397
-					&& ! isset($post[$field_obj->get_qualified_column()])){
395
+			foreach ($fields_for_that_table as $field_obj) {
396
+				if ( ! isset($post[$field_obj->get_table_column()])
397
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
398 398
 					$has_all_necessary_fields_for_table = false;
399 399
 				}
400 400
 			}
401 401
 		}
402 402
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
403
-		if( ! $has_all_necessary_fields_for_table){
403
+		if ( ! $has_all_necessary_fields_for_table) {
404 404
 
405 405
 			return $this->get_one_by_ID($post['ID']);
406
-		}else{
406
+		} else {
407 407
 			return $this->instantiate_class_from_array_or_object($post);
408 408
 		}
409 409
 	}
@@ -414,30 +414,30 @@  discard block
 block discarded – undo
414 414
 	 * @param null $post
415 415
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class
416 416
 	 */
417
-	public function instantiate_class_from_post_object( $post = NULL ){
418
-		if ( empty( $post )) {
417
+	public function instantiate_class_from_post_object($post = NULL) {
418
+		if (empty($post)) {
419 419
 			global $post;
420 420
 		}
421
-		$post = (array)$post;
421
+		$post = (array) $post;
422 422
 		$tables_needing_to_be_queried = array();
423 423
 		//check if the post has fields on the meta table already
424
-		foreach($this->get_tables() as $table_obj){
424
+		foreach ($this->get_tables() as $table_obj) {
425 425
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
426
-			foreach($fields_for_that_table as $field_obj){
427
-				if( ! isset($post[$field_obj->get_table_column()])
428
-					&& ! isset($post[$field_obj->get_qualified_column()])){
426
+			foreach ($fields_for_that_table as $field_obj) {
427
+				if ( ! isset($post[$field_obj->get_table_column()])
428
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
429 429
 					$tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj;
430 430
 				}
431 431
 			}
432 432
 		}
433 433
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
434
-		if( $tables_needing_to_be_queried){
435
-			if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){
434
+		if ($tables_needing_to_be_queried) {
435
+			if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) {
436 436
 				//so we're only missing data from a secondary table. Well that's not too hard to query for
437 437
 				$table_to_query = reset($tables_needing_to_be_queried);
438
-				$missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A ));
439
-				if ( ! empty( $missing_data )) {
440
-					$post = array_merge( $post, $missing_data );
438
+				$missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A));
439
+				if ( ! empty($missing_data)) {
440
+					$post = array_merge($post, $missing_data);
441 441
 				}
442 442
 			} else {
443 443
 				return $this->get_one_by_ID($post['ID']);
@@ -454,15 +454,15 @@  discard block
 block discarded – undo
454 454
 	 * @throws EE_Error
455 455
 	 * @return string
456 456
 	 */
457
-	public function post_type(){
457
+	public function post_type() {
458 458
 		$post_type_field = NULL;
459
-		foreach($this->field_settings(true) as $field_obj){
460
-			if($field_obj instanceof EE_WP_Post_Type_Field){
461
-				$post_type_field = $field_obj;break;
459
+		foreach ($this->field_settings(true) as $field_obj) {
460
+			if ($field_obj instanceof EE_WP_Post_Type_Field) {
461
+				$post_type_field = $field_obj; break;
462 462
 			}
463 463
 		}
464
-		if($post_type_field == NULL){
465
-			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this)));
464
+		if ($post_type_field == NULL) {
465
+			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this)));
466 466
 		}
467 467
 		return $post_type_field->get_default_value();
468 468
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Checkin.model.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * ------------------------------------------------------------------------
25 25
  */
26
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
27
-require_once ( EE_CLASSES . 'EE_Checkin.class.php' );
26
+require_once (EE_MODELS.'EEM_Base.model.php');
27
+require_once (EE_CLASSES.'EE_Checkin.class.php');
28 28
 
29 29
 class EEM_Checkin extends EEM_Base {
30 30
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 	 * 		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
41 41
 	 * 		@return void
42 42
 	 */
43
-	protected function __construct( $timezone = NULL ) {
44
-		$this->singular_item = __('Check-In','event_espresso');
45
-		$this->plural_item = __('Check-Ins','event_espresso');
43
+	protected function __construct($timezone = NULL) {
44
+		$this->singular_item = __('Check-In', 'event_espresso');
45
+		$this->plural_item = __('Check-Ins', 'event_espresso');
46 46
 
47 47
 		$this->_tables = array(
48
-			'Checkin'=>new EE_Primary_Table('esp_checkin','CHK_ID')
48
+			'Checkin'=>new EE_Primary_Table('esp_checkin', 'CHK_ID')
49 49
 		);
50 50
 		$this->_fields = array(
51 51
 			'Checkin'=> array(
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', 'Registration Id', false, 0, 'Registration'),
54 54
 				'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', 'Datetime Id', false, 0, 'Datetime'),
55 55
 				'CHK_in'=>new EE_Boolean_Field('CHK_in', 'Whether a person has checked in or checked out', false, true),
56
-				'CHK_timestamp'=>new EE_Datetime_Field('CHK_timestamp', __('When the row was modified','event_espresso'), false, time(), $timezone )
56
+				'CHK_timestamp'=>new EE_Datetime_Field('CHK_timestamp', __('When the row was modified', 'event_espresso'), false, time(), $timezone)
57 57
 			)
58 58
 		);
59 59
 		$this->_model_relations = array(
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			'Datetime'=>new EE_Belongs_To_Relation()
62 62
 		);
63 63
 		$this->_model_chain_to_wp_user = 'Registration.Event';
64
-		parent::__construct( $timezone );
64
+		parent::__construct($timezone);
65 65
 
66 66
 	}
67 67
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Country.model.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 	/**
86
-	*		_get_countries
87
-	*
88
-	* 		@access		public
89
-	*		@return 		array
90
-	*/
86
+	 *		_get_countries
87
+	 *
88
+	 * 		@access		public
89
+	 *		@return 		array
90
+	 */
91 91
 	public function get_all_countries() {
92 92
 		if ( ! self::$_all_countries ) {
93 93
 			self::$_all_countries = $this->get_all( array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 )));
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	*		_get_countries
100
-	*		Gets and caches the list of active countries. If you know the list of active countries
101
-	*		has changed during this request, first use EEM_Country::reset() to flush the cache
102
-	* 		@access		public
103
-	*		@return 		array
104
-	*/
99
+	 *		_get_countries
100
+	 *		Gets and caches the list of active countries. If you know the list of active countries
101
+	 *		has changed during this request, first use EEM_Country::reset() to flush the cache
102
+	 * 		@access		public
103
+	 *		@return 		array
104
+	 */
105 105
 	public function get_all_active_countries() {
106 106
 		if ( ! self::$_active_countries ) {
107 107
 			self::$_active_countries =  $this->get_all( array( array( 'CNT_active' => TRUE ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 )));
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
 	 * Resets the country
37 37
 	 * @return EEM_Country
38 38
 	 */
39
-	public static function reset( $timezone = NULL ){
39
+	public static function reset($timezone = NULL) {
40 40
 		self::$_active_countries = NULL;
41 41
 		self::$_all_countries = NULL;
42
-		return parent::reset( $timezone );
42
+		return parent::reset($timezone);
43 43
 	}
44 44
 
45
-	protected function __construct( $timezone = NULL ){
46
-		$this->singular_item = __('Country','event_espresso');
47
-		$this->plural_item = __('Countries','event_espresso');
45
+	protected function __construct($timezone = NULL) {
46
+		$this->singular_item = __('Country', 'event_espresso');
47
+		$this->plural_item = __('Countries', 'event_espresso');
48 48
 
49 49
 
50 50
 		$this->_tables = array(
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
 		);
53 53
 		$this->_fields = array(
54 54
 			'Country'=>array(
55
-				'CNT_active' => new EE_Boolean_Field('CNT_active', __('Country Appears in Dropdown Select Lists','event_espresso'), false, true),
56
-				'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', __('Country ISO Code','event_espresso')),
57
-				'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', __('Country ISO3 Code','event_espresso'), false,''),
58
-				'RGN_ID'=>new EE_Integer_Field('RGN_ID', __('Region ID','event_espresso'), false,0),//should be a foreign key, but no region table exists yet
59
-				'CNT_name'=>new EE_Plain_Text_Field('CNT_name', __('Country Name','event_espresso'), false,''),
60
-				'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', __('Country Currency Code','event_espresso'), false),
61
-				'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', __('Currency Name Singular','event_espresso'), false),
62
-				'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', __('Currency Name Plural','event_espresso'), false),
63
-				'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', __('Currency Sign','event_espresso'), false),
64
-				'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', __('Currency Sign Before Number','event_espresso'), false, true),
65
-				'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2),
66
-				'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', __('Currency Decimal Mark','event_espresso'), false, '.'),
67
-				'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', __('Currency Thousands Seperator','event_espresso'), false, ','),
68
-				'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', __('Country Telephone Code','event_espresso'), false, ''),
69
-				'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', __('Country is Member of EU','event_espresso'), false, false)
55
+				'CNT_active' => new EE_Boolean_Field('CNT_active', __('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
56
+				'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso')),
57
+				'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', __('Country ISO3 Code', 'event_espresso'), false, ''),
58
+				'RGN_ID'=>new EE_Integer_Field('RGN_ID', __('Region ID', 'event_espresso'), false, 0), //should be a foreign key, but no region table exists yet
59
+				'CNT_name'=>new EE_Plain_Text_Field('CNT_name', __('Country Name', 'event_espresso'), false, ''),
60
+				'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', __('Country Currency Code', 'event_espresso'), false),
61
+				'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', __('Currency Name Singular', 'event_espresso'), false),
62
+				'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', __('Currency Name Plural', 'event_espresso'), false),
63
+				'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', __('Currency Sign', 'event_espresso'), false),
64
+				'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', __('Currency Sign Before Number', 'event_espresso'), false, true),
65
+				'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
66
+				'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', __('Currency Decimal Mark', 'event_espresso'), false, '.'),
67
+				'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', __('Currency Thousands Seperator', 'event_espresso'), false, ','),
68
+				'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', __('Country Telephone Code', 'event_espresso'), false, ''),
69
+				'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', __('Country is Member of EU', 'event_espresso'), false, false)
70 70
 			));
71 71
 		$this->_model_relations = array(
72 72
 			'Attendee'=>new EE_Has_Many_Relation(),
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 			'Venue'=>new EE_Has_Many_Relation(),
75 75
 		);
76 76
 		//only anyone to view, but only those with the default role can do anything
77
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
77
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
78 78
 
79
-		parent::__construct( $timezone );
79
+		parent::__construct($timezone);
80 80
 	}
81 81
 
82 82
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	*		@return 		array
90 90
 	*/
91 91
 	public function get_all_countries() {
92
-		if ( ! self::$_all_countries ) {
93
-			self::$_all_countries = $this->get_all( array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 )));
92
+		if ( ! self::$_all_countries) {
93
+			self::$_all_countries = $this->get_all(array('order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array(0, 99999)));
94 94
 		}
95 95
 		return self::$_all_countries;
96 96
 	}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	*		@return 		array
104 104
 	*/
105 105
 	public function get_all_active_countries() {
106
-		if ( ! self::$_active_countries ) {
107
-			self::$_active_countries =  $this->get_all( array( array( 'CNT_active' => TRUE ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 )));
106
+		if ( ! self::$_active_countries) {
107
+			self::$_active_countries = $this->get_all(array(array('CNT_active' => TRUE), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array(0, 99999)));
108 108
 		}
109 109
 		return self::$_active_countries;
110 110
 	}
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 	 * @param string $country_ISO
115 115
 	 * @return string
116 116
 	 */
117
-	public function get_country_name_by_ISO( $country_ISO ){
118
-		if( isset( self::$_all_countries[ $country_ISO ] ) &&
119
-				self::$_all_countries[ $country_ISO ] instanceof EE_Country ){
120
-			return self::$_all_countries[ $country_ISO ]->name();
117
+	public function get_country_name_by_ISO($country_ISO) {
118
+		if (isset(self::$_all_countries[$country_ISO]) &&
119
+				self::$_all_countries[$country_ISO] instanceof EE_Country) {
120
+			return self::$_all_countries[$country_ISO]->name();
121 121
 		}
122
-		$names = $this->get_col( array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name' );
123
-		if( is_array( $names ) && ! empty( $names ) ){
124
-			return reset( $names );
125
-		}else{
122
+		$names = $this->get_col(array(array('CNT_ISO' => $country_ISO), 'limit' => 1), 'CNT_name');
123
+		if (is_array($names) && ! empty($names)) {
124
+			return reset($names);
125
+		} else {
126 126
 			return '';
127 127
 		}
128 128
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * EEH_URL helper
4 6
  * Helper class for URL-related PHP functions
@@ -62,7 +64,7 @@  discard block
 block discarded – undo
62 64
 				isset($results['response']['code']) &&
63 65
 				$results['response']['code'] == '200'){
64 66
 			return true;
65
-		}else{
67
+		} else{
66 68
 			return false;
67 69
 		}
68 70
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,32 +25,32 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Currency extends EEM_Base{
28
+class EEM_Currency extends EEM_Base {
29 29
 		// private instance of the Attendee object
30 30
 	protected static $_instance = NULL;
31 31
 
32
-	protected function __construct( $timezone = NULL ) {
33
-		$this->singular_item = __('Currency','event_espresso');
34
-		$this->plural_item = __('Currencies','event_espresso');
32
+	protected function __construct($timezone = NULL) {
33
+		$this->singular_item = __('Currency', 'event_espresso');
34
+		$this->plural_item = __('Currencies', 'event_espresso');
35 35
 		$this->_tables = array(
36 36
 			'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code')
37 37
 		);
38 38
 		$this->_fields = array(
39 39
 			'Currency'=>array(
40
-				'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency COde','event_espresso')),
41
-				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular','event_espresso'), false),
42
-				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural','event_espresso'), false),
43
-				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign','event_espresso'), false),
44
-				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2),
45
-				'CUR_active'=>new EE_Boolean_Field('CUR_active', __("Active?", 'event_espresso'), false,true),
40
+				'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency COde', 'event_espresso')),
41
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
42
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
43
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
44
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
45
+				'CUR_active'=>new EE_Boolean_Field('CUR_active', __("Active?", 'event_espresso'), false, true),
46 46
 			));
47 47
 		$this->_model_relations = array(
48 48
 			'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
49 49
 		);
50 50
 		//this model is generally available for reading
51
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
51
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
52 52
 
53
-		parent::__construct( $timezone );
53
+		parent::__construct($timezone);
54 54
 	}
55 55
 
56 56
 	/**
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 * @param array $query_params see EEM_Base::get_all
60 60
 	 * @return EE_Currency[]
61 61
 	 */
62
-	public function get_all_active($query_params = array()){
62
+	public function get_all_active($query_params = array()) {
63 63
 		$query_params[0]['CUR_active'] = true;
64
-		if( ! isset($query_params['order_by'])){
65
-			$query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
64
+		if ( ! isset($query_params['order_by'])) {
65
+			$query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC');
66 66
 		}
67 67
 		return $this->get_all($query_params);
68 68
 	}
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
 	 * @param EE_PMT_Base $payment_method_type
72 72
 	 * @return EE_Currency[]
73 73
 	 */
74
-	public function get_all_currencies_usable_by($payment_method_type){
75
-		if($payment_method_type instanceof EE_PMT_Base &&
76
-				$payment_method_type->get_gateway()){
74
+	public function get_all_currencies_usable_by($payment_method_type) {
75
+		if ($payment_method_type instanceof EE_PMT_Base &&
76
+				$payment_method_type->get_gateway()) {
77 77
 			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
78
-		}else{
78
+		} else {
79 79
 			$currencies_supported = EE_Gateway::all_currencies_supported;
80 80
 		}
81
-		if($currencies_supported == EE_Gateway::all_currencies_supported || empty( $currencies_supported ) ) {
81
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
82 82
 			$currencies = $this->get_all_active();
83
-		}else{
84
-			$currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
83
+		} else {
84
+			$currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported))));
85 85
 		}
86 86
 		return $currencies;
87 87
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if (!defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('No direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -84,7 +85,7 @@  discard block
 block discarded – undo
84 85
 	public function is_valid() {
85 86
 		if(count($this->_validation_errors)){
86 87
 			return false;
87
-		}else{
88
+		} else{
88 89
 			return true;
89 90
 		}
90 91
 	}
@@ -113,7 +114,7 @@  discard block
 block discarded – undo
113 114
 		if($message_or_object instanceof EE_Validation_Error){
114 115
 			$validation_error= $message_or_object;
115 116
 			$validation_error->set_form_section($this);
116
-		}else{
117
+		} else{
117 118
 			$validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception);
118 119
 		}
119 120
 		$this->_validation_errors[] = $validation_error;
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,22 +25,22 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Currency_Payment_Method extends EEM_Base{
28
+class EEM_Currency_Payment_Method extends EEM_Base {
29 29
 	// private instance of the Attendee object
30 30
 	protected static $_instance = NULL;
31 31
 
32 32
 
33
-	protected function __construct( $timezone = NULL ) {
34
-		$this->singular_item = __('Currency Usable by Payment Method','event_espresso');
35
-		$this->plural_item = __('Currencies Usable by Payment Methods','event_espresso');
33
+	protected function __construct($timezone = NULL) {
34
+		$this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
35
+		$this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
36 36
 		$this->_tables = array(
37
-			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method','CPM_ID')
37
+			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
38 38
 		);
39 39
 		$this->_fields = array(
40 40
 			'Currency_Payment_Method'=>array(
41
-				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID','event_espresso')),
42
-				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code','event_espresso'), false, 0, 'Currency'),
43
-				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID','event_espresso'), false, 0, 'Payment_Method')
41
+				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
42
+				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, 0, 'Currency'),
43
+				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
44 44
 			)
45 45
 		);
46 46
 		$this->_model_relations = array(
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 			'Payment_Method'=>new EE_Belongs_To_Relation()
49 49
 		);
50 50
 		//this model is generally available for reading
51
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
51
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
52 52
 		$this->_caps_slug = 'payment_methods';
53
-		parent::__construct( $timezone );
53
+		parent::__construct($timezone);
54 54
 	}
55 55
 }
56 56
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 /**
6 7
  * Event Espresso
7 8
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime.model.php 4 patches
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
@@ -191,7 +193,7 @@  discard block
 block discarded – undo
191 193
 		$results =  $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
192 194
 		if($results){
193 195
 			return array_shift($results);
194
-		}else{
196
+		} else{
195 197
 			return NULL;
196 198
 		}
197 199
 	}
@@ -318,7 +320,7 @@  discard block
 block discarded – undo
318 320
 		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
319 321
 		if($results){
320 322
 			return array_shift($results);
321
-		}else{
323
+		} else{
322 324
 			return null;
323 325
 		}
324 326
 	}
@@ -351,7 +353,9 @@  discard block
 block discarded – undo
351 353
 					break;
352 354
 
353 355
 			case 'expired' :
354
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
356
+				if ( isset( $where_params['Event.status'] ) ) {
357
+					unset( $where_params['Event.status'] );
358
+				}
355 359
 				//get events to exclude
356 360
 				$exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) );
357 361
 				//first get all events that have datetimes where its not expired.
@@ -378,7 +382,9 @@  discard block
 block discarded – undo
378 382
 				break;
379 383
 
380 384
 			case 'inactive' :
381
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
385
+				if ( isset( $where_params['Event.status'] ) ) {
386
+					unset( $where_params['Event.status'] );
387
+				}
382 388
 				if ( isset( $where_params['OR'] ) ) {
383 389
 					$where_params['AND']['OR'] = $where_params['OR'];
384 390
 				}
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 
76 76
 
77 77
 	/**
78
-	*		create new blank datetime
79
-	*
80
-	* 		@access		public
81
-	*		@return 		EE_Datetime[]		array on success, FALSE on fail
82
-	*/
78
+	 *		create new blank datetime
79
+	 *
80
+	 * 		@access		public
81
+	 *		@return 		EE_Datetime[]		array on success, FALSE on fail
82
+	 */
83 83
 	public function create_new_blank_datetime() {
84 84
 		$blank_datetime = EE_Datetime::new_instance(
85 85
 			array(
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
 
102 102
 	/**
103
-	*		get event start date from db
104
-	*
105
-	* 		@access		public
106
-	* 		@param		int 			$EVT_ID
107
-	*		@return 		EE_Datetime[]		array on success, FALSE on fail
108
-	*/
103
+	 *		get event start date from db
104
+	 *
105
+	 * 		@access		public
106
+	 * 		@param		int 			$EVT_ID
107
+	 *		@return 		EE_Datetime[]		array on success, FALSE on fail
108
+	 */
109 109
 	public function get_all_event_dates( $EVT_ID = 0 ) {
110 110
 		if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0
111 111
 			return $this->create_new_blank_datetime();
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 		/**
253
-	 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
254
-	 * only by start date
255
-	 * @param int $TKT_ID
256
-	 * @param boolean $include_expired
257
-	 * @param boolean $include_deleted
258
-	 * @param int $limit
259
-	 * @return EE_Datetime[]
260
-	 */
253
+		 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
254
+		 * only by start date
255
+		 * @param int $TKT_ID
256
+		 * @param boolean $include_expired
257
+		 * @param boolean $include_deleted
258
+		 * @param int $limit
259
+		 * @return EE_Datetime[]
260
+		 */
261 261
 	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){
262 262
 		//sanitize TKT_ID
263 263
 		$TKT_ID =  intval( $TKT_ID );
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -443,7 +443,7 @@
 block discarded – undo
443 443
 	/**
444 444
 	 * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
445 445
 	 *
446
-	 * @param  array $stati_to_include        If included you can restrict the statuses we return counts for by including the stati
446
+	 * @param  string[] $stati_to_include        If included you can restrict the statuses we return counts for by including the stati
447 447
 	 *                               you want counts for as values in the array.  An empty array returns counts for all valid
448 448
 	 *                               stati.
449 449
 	 * @param  array  $query_params  If included can be used to refine the conditions for returning the count (i.e. only for
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Datetime.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Datetime.class.php');
26 26
 
27 27
 class EEM_Datetime extends EEM_Soft_Delete_Base {
28 28
 
@@ -35,27 +35,27 @@  discard block
 block discarded – undo
35 35
 	 *		@access private
36 36
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
37 37
 	 */
38
-	protected function __construct( $timezone ) {
39
-		$this->singular_item = __('Datetime','event_espresso');
40
-		$this->plural_item = __('Datetimes','event_espresso');
38
+	protected function __construct($timezone) {
39
+		$this->singular_item = __('Datetime', 'event_espresso');
40
+		$this->plural_item = __('Datetimes', 'event_espresso');
41 41
 
42 42
 		$this->_tables = array(
43 43
 			'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID')
44 44
 		);
45 45
 		$this->_fields = array(
46 46
 			'Datetime'=>array(
47
-				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')),
48
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
47
+				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')),
48
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
49 49
 				'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''),
50 50
 				'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''),
51
-				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ),
52
-				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ),
53
-				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF),
54
-				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ),
55
-				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false),
51
+				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone),
52
+				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone),
53
+				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF),
54
+				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0),
55
+				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false),
56 56
 				'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0),
57
-				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ),
58
-				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ),
57
+				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0),
58
+				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false),
59 59
 			));
60 60
 		$this->_model_relations = array(
61 61
 			'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'),
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		);
65 65
 		$this->_model_chain_to_wp_user = 'Event';
66 66
 		//this model is generally available for reading
67
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' );
68
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
69
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
70
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit );
71
-		parent::__construct( $timezone );
67
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
68
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
69
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
70
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
71
+		parent::__construct($timezone);
72 72
 	}
73 73
 
74 74
 
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 	public function create_new_blank_datetime() {
84 84
 		$blank_datetime = EE_Datetime::new_instance(
85 85
 			array(
86
-				'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30),
87
-				'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30),
86
+				'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30),
87
+				'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30),
88 88
 				'DTT_order' => 1,
89 89
 				'DTT_reg_limit' => EE_INF
90 90
 			),
91 91
 			$this->_timezone
92 92
 		);
93
-		$blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) );
94
-		$blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) );
95
-		return array( $blank_datetime );
93
+		$blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone));
94
+		$blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone));
95
+		return array($blank_datetime);
96 96
 	}
97 97
 
98 98
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	* 		@param		int 			$EVT_ID
107 107
 	*		@return 		EE_Datetime[]		array on success, FALSE on fail
108 108
 	*/
109
-	public function get_all_event_dates( $EVT_ID = 0 ) {
110
-		if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0
109
+	public function get_all_event_dates($EVT_ID = 0) {
110
+		if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
111 111
 			return $this->create_new_blank_datetime();
112 112
 		}
113
-		$results =  $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
113
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
114 114
 
115
-		if ( empty( $results ) ) {
115
+		if (empty($results)) {
116 116
 			return $this->create_new_blank_datetime();
117 117
 		}
118 118
 
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 	 *                        	the given number
134 134
 	 * @return EE_Datetime[]
135 135
 	 */
136
-	public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL  ) {
136
+	public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) {
137 137
 
138 138
 		//sanitize EVT_ID
139
-		$EVT_ID = intval( $EVT_ID );
139
+		$EVT_ID = intval($EVT_ID);
140 140
 
141 141
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
142
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
143
-		$where_params = array( 'Event.EVT_ID' => $EVT_ID );
142
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
143
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
144 144
 
145
-		$query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' );
145
+		$query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none');
146 146
 
147
-		if( ! $include_expired){
148
-			$query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) );
147
+		if ( ! $include_expired) {
148
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
149 149
 		}
150
-		if( $include_deleted){
151
-			$query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE ));
150
+		if ($include_deleted) {
151
+			$query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE));
152 152
 		}
153 153
 
154
-		$result = $this->get_all( $query_params );
155
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
154
+		$result = $this->get_all($query_params);
155
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
156 156
 		return $result;
157 157
 	}
158 158
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * @param int $limit
168 168
 	 * @return EE_Datetime[]
169 169
 	 */
170
-	public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){
171
-		return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID),
170
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) {
171
+		return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID),
172 172
 			'limit'=>$limit,
173 173
 			'order_by'=>array('DTT_EVT_start'=>'ASC'),
174 174
 			'default_where_conditions' => 'none'));
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param boolean $include_deleted
184 184
 	 * @return EE_Datetime
185 185
 	 */
186
-	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){
187
-		$results =  $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
188
-		if($results){
186
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) {
187
+		$results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
188
+		if ($results) {
189 189
 			return array_shift($results);
190
-		}else{
190
+		} else {
191 191
 			return NULL;
192 192
 		}
193 193
 	}
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 * @param bool $try_to_exclude_deleted
202 202
 	 * @return \EE_Datetime
203 203
 	 */
204
-	public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){
205
-		if($try_to_exclude_expired){
206
-			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false);
207
-			if($non_expired){
204
+	public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) {
205
+		if ($try_to_exclude_expired) {
206
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
207
+			if ($non_expired) {
208 208
 				return $non_expired;
209 209
 			}
210 210
 		}
211
-		if($try_to_exclude_deleted){
211
+		if ($try_to_exclude_deleted) {
212 212
 			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
213
-			if($expired_even){
213
+			if ($expired_even) {
214 214
 				return $expired_even;
215 215
 			}
216 216
 		}
@@ -229,23 +229,23 @@  discard block
 block discarded – undo
229 229
 	 * @param int $limit
230 230
 	 * @return EE_Datetime[]
231 231
 	 */
232
-	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){
232
+	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
233 233
 		//sanitize EVT_ID
234
-		$EVT_ID = intval( $EVT_ID );
234
+		$EVT_ID = intval($EVT_ID);
235 235
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
236
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
237
-		$query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
238
-		if( ! $include_expired){
239
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
236
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
237
+		$query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
238
+		if ( ! $include_expired) {
239
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
240 240
 		}
241
-		if( $include_deleted){
242
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
241
+		if ($include_deleted) {
242
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
243 243
 		}
244
-		if($limit){
244
+		if ($limit) {
245 245
 			$query_params['limit'] = $limit;
246 246
 		}
247
-		$result = $this->get_all( $query_params );
248
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
247
+		$result = $this->get_all($query_params);
248
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
249 249
 		return $result;
250 250
 	}
251 251
 
@@ -258,23 +258,23 @@  discard block
 block discarded – undo
258 258
 	 * @param int $limit
259 259
 	 * @return EE_Datetime[]
260 260
 	 */
261
-	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){
261
+	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
262 262
 		//sanitize TKT_ID
263
-		$TKT_ID =  intval( $TKT_ID );
263
+		$TKT_ID = intval($TKT_ID);
264 264
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
265
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
266
-		$query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
267
-		if( ! $include_expired){
268
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
265
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
266
+		$query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
267
+		if ( ! $include_expired) {
268
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
269 269
 		}
270
-		if( $include_deleted){
271
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
270
+		if ($include_deleted) {
271
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
272 272
 		}
273
-		if($limit){
273
+		if ($limit) {
274 274
 			$query_params['limit'] = $limit;
275 275
 		}
276
-		$result = $this->get_all( $query_params );
277
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
276
+		$result = $this->get_all($query_params);
277
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
278 278
 		return $result;
279 279
 	}
280 280
 
@@ -290,24 +290,24 @@  discard block
 block discarded – undo
290 290
 	 *                                  that number
291 291
 	 * @return EE_Datetime[]
292 292
 	 */
293
-	public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) {
293
+	public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
294 294
 		//sanitize id.
295
-		$TKT_ID =  intval( $TKT_ID );
295
+		$TKT_ID = intval($TKT_ID);
296 296
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
297
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
298
-		$where_params = array( 'Ticket.TKT_ID' => $TKT_ID );
299
-		$query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) );
300
-		if( ! $include_expired){
301
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
297
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
298
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
299
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
300
+		if ( ! $include_expired) {
301
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
302 302
 		}
303
-		if( $include_deleted){
304
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
303
+		if ($include_deleted) {
304
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
305 305
 		}
306
-		if($limit){
306
+		if ($limit) {
307 307
 			$query_params['limit'] = $limit;
308 308
 		}
309
-		$result = $this->get_all( $query_params );
310
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
309
+		$result = $this->get_all($query_params);
310
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
311 311
 		return $result;
312 312
 	}
313 313
 
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	 * @param int $EVT_ID
319 319
 	 * @return EE_Datetime
320 320
 	 */
321
-	public function get_most_important_datetime_for_event($EVT_ID){
321
+	public function get_most_important_datetime_for_event($EVT_ID) {
322 322
 		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
323
-		if($results){
323
+		if ($results) {
324 324
 			return array_shift($results);
325
-		}else{
325
+		} else {
326 326
 			return null;
327 327
 		}
328 328
 	}
@@ -341,77 +341,77 @@  discard block
 block discarded – undo
341 341
 	 * 			- inactive = Events that are either not published.
342 342
 	 * @return wpdb results array
343 343
 	 */
344
-	public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) {
345
-		$current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' );
346
-		$current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' );
344
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '') {
345
+		$current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
346
+		$current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end');
347 347
 
348
-		switch ( $evt_active_status ) {
348
+		switch ($evt_active_status) {
349 349
 			case 'upcoming' :
350 350
 					$where_params['Event.status'] = 'publish';
351 351
 					//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
352
-					if ( isset( $where_params['DTT_EVT_start'] ) ) {
352
+					if (isset($where_params['DTT_EVT_start'])) {
353 353
 						$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
354 354
 					}
355
-					$where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start );
355
+					$where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
356 356
 					break;
357 357
 
358 358
 			case 'expired' :
359
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
359
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
360 360
 				//get events to exclude
361
-				$exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) );
361
+				$exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end)));
362 362
 				//first get all events that have datetimes where its not expired.
363
-				$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' );
364
-				$event_ids = array_keys( $event_ids );
363
+				$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID');
364
+				$event_ids = array_keys($event_ids);
365 365
 
366
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
366
+				if (isset($where_params['DTT_EVT_end'])) {
367 367
 					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
368 368
 				}
369
-				$where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end );
370
-				$where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids );
369
+				$where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end);
370
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
371 371
 				break;
372 372
 
373 373
 			case 'active' :
374 374
 				$where_params['Event.status'] = 'publish';
375
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
375
+				if (isset($where_params['DTT_EVT_start'])) {
376 376
 					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
377 377
 				}
378
-				if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
378
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
379 379
 					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
380 380
 				}
381
-				$where_params['DTT_EVT_start'] = array('<',  $current_time_for_DTT_EVT_start );
382
-				$where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end );
381
+				$where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
382
+				$where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end);
383 383
 				break;
384 384
 
385 385
 			case 'inactive' :
386
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
387
-				if ( isset( $where_params['OR'] ) ) {
386
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
387
+				if (isset($where_params['OR'])) {
388 388
 					$where_params['AND']['OR'] = $where_params['OR'];
389 389
 				}
390
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
390
+				if (isset($where_params['DTT_EVT_end'])) {
391 391
 					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
392
-					unset( $where_params['DTT_EVT_end'] );
392
+					unset($where_params['DTT_EVT_end']);
393 393
 				}
394 394
 
395
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
395
+				if (isset($where_params['DTT_EVT_start'])) {
396 396
 					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
397
-					unset( $where_params['DTT_EVT_start'] );
397
+					unset($where_params['DTT_EVT_start']);
398 398
 				}
399
-				$where_params['AND']['Event.status'] = array( '!=', 'publish' );
399
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
400 400
 				break;
401 401
 		}
402 402
 
403 403
 		$query_params[0] = $where_params;
404 404
 		$query_params['group_by'] = array('dtt_year', 'dtt_month');
405
-		$query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' );
405
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
406 406
 
407
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' );
407
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start');
408 408
 
409 409
 		$columns_to_select = array(
410
-			'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'),
411
-			'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'),
412
-			'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s')
410
+			'dtt_year' => array('YEAR('.$query_interval.')', '%s'),
411
+			'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'),
412
+			'dtt_month_num' => array('MONTH('.$query_interval.')', '%s')
413 413
 			);
414
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
414
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
415 415
 	}
416 416
 
417 417
 	/**
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	 * for the tickets for each datetime)
420 420
 	 * @param EE_Datetime[] $datetimes
421 421
 	 */
422
-	public function update_sold($datetimes){
423
-		foreach($datetimes as $datetime){
422
+	public function update_sold($datetimes) {
423
+		foreach ($datetimes as $datetime) {
424 424
 			$datetime->update_sold();
425 425
 		}
426 426
 	}
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 	 * @param array $query_params
436 436
 	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO tickets attached to datetime then FALSE is returned.
437 437
 	 */
438
-	public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) {
439
-		$datetime = $this->get_one_by_ID( $DTT_ID );
440
-		if ( $datetime instanceof EE_Datetime ) {
441
-			return $datetime->tickets_remaining( $query_params );
438
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) {
439
+		$datetime = $this->get_one_by_ID($DTT_ID);
440
+		if ($datetime instanceof EE_Datetime) {
441
+			return $datetime->tickets_remaining($query_params);
442 442
 		}
443 443
 		return 0;
444 444
 	}
@@ -460,36 +460,36 @@  discard block
 block discarded – undo
460 460
 	 *                EE_Datetime::upcoming
461 461
 	 *                EE_Datetime::expired
462 462
 	 */
463
-	public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) {
463
+	public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) {
464 464
 		//only accept where conditions for this query.
465
-		$_where = isset( $query_params[0] ) ? $query_params[0] : array();
465
+		$_where = isset($query_params[0]) ? $query_params[0] : array();
466 466
 		$status_query_args = array(
467 467
 				EE_Datetime::active => array_merge(
468 468
 						$_where,
469
-						array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) )
469
+						array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
470 470
 				),
471 471
 				EE_Datetime::upcoming => array_merge(
472 472
 						$_where,
473
-						array( 'DTT_EVT_start' => array( '>', time() ) )
473
+						array('DTT_EVT_start' => array('>', time()))
474 474
 				),
475 475
 				EE_Datetime::expired => array_merge(
476 476
 						$_where,
477
-						array( 'DTT_EVT_end' => array('<', time() ) )
477
+						array('DTT_EVT_end' => array('<', time()))
478 478
 				)
479 479
 		);
480 480
 
481
-		if ( ! empty( $stati_to_include ) ) {
482
-			foreach( array_keys( $status_query_args ) as $status ) {
483
-				if ( ! in_array( $status, $stati_to_include ) ) {
484
-					unset( $status_query_args[$status] );
481
+		if ( ! empty($stati_to_include)) {
482
+			foreach (array_keys($status_query_args) as $status) {
483
+				if ( ! in_array($status, $stati_to_include)) {
484
+					unset($status_query_args[$status]);
485 485
 				}
486 486
 			}
487 487
 		}
488 488
 
489 489
 		//loop through and query counts for each stati.
490 490
 		$status_query_results = array();
491
-		foreach( $status_query_args as $status => $status_where_conditions ) {
492
-			$status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true );
491
+		foreach ($status_query_args as $status => $status_where_conditions) {
492
+			$status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true);
493 493
 		}
494 494
 
495 495
 		return $status_query_results;
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 	 * @param array $query_params
504 504
 	 * @return int
505 505
 	 */
506
-	public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) {
507
-		$count = $this->get_datetime_counts_by_status( array( $status ), $query_params );
508
-		return ! empty( $count[$status] ) ? $count[$status] : 0;
506
+	public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) {
507
+		$count = $this->get_datetime_counts_by_status(array($status), $query_params);
508
+		return ! empty($count[$status]) ? $count[$status] : 0;
509 509
 	}
510 510
 
511 511
 
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime_Ticket.model.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Datetime_Ticket.class.php' );
24
+require_once (EE_MODELS.'EEM_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Datetime_Ticket.class.php');
26 26
 
27 27
 class EEM_Datetime_Ticket extends EEM_Base {
28 28
 
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
38 38
 	 *		@return void
39 39
 	 */
40
-	protected function __construct( $timezone ) {
41
-		$this->singular_item = __('Datetime Ticket','event_espresso');
42
-		$this->plural_item = __('Datetime Tickets','event_espresso');
40
+	protected function __construct($timezone) {
41
+		$this->singular_item = __('Datetime Ticket', 'event_espresso');
42
+		$this->plural_item = __('Datetime Tickets', 'event_espresso');
43 43
 
44 44
 		$this->_tables = array(
45 45
 			'Datetime_Ticket'=> new EE_Primary_Table('esp_datetime_ticket', 'DTK_ID')
46 46
 		);
47 47
 		$this->_fields = array(
48 48
 			'Datetime_Ticket'=>array(
49
-				'DTK_ID'=>new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID','event_espresso')),
50
-				'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime','event_espresso'), false, 0, 'Datetime' ),
51
-				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket','event_espresso'), false, 0, 'Ticket' )
49
+				'DTK_ID'=>new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID', 'event_espresso')),
50
+				'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime', 'event_espresso'), false, 0, 'Datetime'),
51
+				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket', 'event_espresso'), false, 0, 'Ticket')
52 52
 			));
53 53
 		$this->_model_relations = array(
54 54
 			'Ticket'=>new EE_Belongs_To_Relation(),
55 55
 			'Datetime'=>new EE_Belongs_To_Relation()
56 56
 		);
57 57
 		//this model is generally available for reading
58
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Datetime.Event' );
59
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Datetime.Event' );
60
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Datetime.Event' );
61
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Datetime.Event', EEM_Base::caps_edit );
62
-		parent::__construct( $timezone );
58
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Datetime.Event');
59
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Datetime.Event');
60
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Datetime.Event');
61
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Datetime.Event', EEM_Base::caps_edit);
62
+		parent::__construct($timezone);
63 63
 	}
64 64
 } //end EEM_Datetime_Ticket class
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Event.model.php 3 patches
Braces   +6 added lines, -3 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
 require_once( EE_MODELS . 'EEM_CPT_Base.model.php');
3 5
 /**
4 6
  *
@@ -349,8 +351,9 @@  discard block
 block discarded – undo
349 351
 			 	$questions[ $qg->ID() ] = $qg->model_field_array();
350 352
 			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
351 353
 			 	foreach ( $qsts as $qst ) {
352
-			 		if ( $qst->is_system_question() )
353
-			 			continue;
354
+			 		if ( $qst->is_system_question() ) {
355
+			 					 			continue;
356
+			 		}
354 357
 			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
355 358
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
356 359
 			 		$qst_name = $qstn_id = $qst->ID();
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
 	/**
182
-	*		get_question_groups
183
-	*
184
-	* 		@access		public
185
-	*		@return 		array
186
-	*/
182
+	 *		get_question_groups
183
+	 *
184
+	 * 		@access		public
185
+	 *		@return 		array
186
+	 */
187 187
 	public function get_all_question_groups() {
188 188
 		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
189 189
 			array( 'QSG_deleted' => FALSE ),
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 
198 198
 
199 199
 	/**
200
-	*		get_question_groups
201
-	*
202
-	* 		@access		public
203
-	* 		@param		int $EVT_ID
204
-	*		@return 		array
205
-	*/
200
+	 *		get_question_groups
201
+	 *
202
+	 * 		@access		public
203
+	 * 		@param		int $EVT_ID
204
+	 *		@return 		array
205
+	 */
206 206
 	public function get_all_event_question_groups( $EVT_ID = 0 ) {
207 207
 		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
208 208
 			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
@@ -218,13 +218,13 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
 	/**
221
-	*		get_question_groups
222
-	*
223
-	* 		@access		public
224
-	* 		@param		int $EVT_ID
225
-	* 		@param		boolean	$for_primary_attendee
226
-	*		@return 		array
227
-	*/
221
+	 *		get_question_groups
222
+	 *
223
+	 * 		@access		public
224
+	 * 		@param		int $EVT_ID
225
+	 * 		@param		boolean	$for_primary_attendee
226
+	 *		@return 		array
227
+	 */
228 228
 	public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) {
229 229
 		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
230 230
 			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 
242 242
 
243 243
 	/**
244
-	*		get_question_groups
245
-	*
246
-	* 		@access		public
247
-	* 		@param		int $EVT_ID
248
-	* 		@param		EE_Registration 	$registration
249
-	*		@return 		array
250
-	*/
244
+	 *		get_question_groups
245
+	 *
246
+	 * 		@access		public
247
+	 * 		@param		int $EVT_ID
248
+	 * 		@param		EE_Registration 	$registration
249
+	 *		@return 		array
250
+	 */
251 251
 	public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) {
252 252
 
253 253
 		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
 
276 276
 
277 277
 	/**
278
-	*		get_question_target_db_column
279
-	*
280
-	* 		@access		public
281
-	* 		@param		string		$QSG_IDs  csv list of $QSG IDs
282
-	*		@return 		array
283
-	*/
278
+	 *		get_question_target_db_column
279
+	 *
280
+	 * 		@access		public
281
+	 * 		@param		string		$QSG_IDs  csv list of $QSG IDs
282
+	 *		@return 		array
283
+	 */
284 284
 	public function get_questions_in_groups( $QSG_IDs = '' ) {
285 285
 
286 286
 		if ( empty( $QSG_IDs )) {
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
 
307 307
 
308 308
 	/**
309
-	*		get_options_for_question
310
-	*
311
-	* 		@access		public
312
-	* 		@param		string		$QST_IDs  csv list of $QST IDs
313
-	*		@return 		array
314
-	*/
309
+	 *		get_options_for_question
310
+	 *
311
+	 * 		@access		public
312
+	 * 		@param		string		$QST_IDs  csv list of $QST IDs
313
+	 *		@return 		array
314
+	 */
315 315
 	public function get_options_for_question( $QST_IDs ) {
316 316
 
317 317
 		if ( empty( $QST_IDs )) {
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 
397 397
 
398 398
 	/**
399
-	*		_get_question_target_db_column
400
-	*
401
-	* 		@access		private
402
-	* 		@param		$QST
403
-	*		@return 		string		string
404
-	*/
399
+	 *		_get_question_target_db_column
400
+	 *
401
+	 * 		@access		private
402
+	 * 		@param		$QST
403
+	 *		@return 		string		string
404
+	 */
405 405
 	private function _generate_question_input_name( $QST ) {
406 406
 
407 407
 		if ( $QST->QST_system ) {
Please login to merge, or discard this patch.
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once( EE_MODELS . 'EEM_CPT_Base.model.php');
2
+require_once(EE_MODELS.'EEM_CPT_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * EEM_Event Model
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author				Michael Nelson, Brent Christensen
12 12
  *
13 13
  */
14
-class EEM_Event  extends EEM_CPT_Base{
14
+class EEM_Event  extends EEM_CPT_Base {
15 15
 
16 16
 	/**
17 17
 	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the event
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * @param string $timezone
52 52
 	 * @return EEM_Event
53 53
 	 */
54
-	public static function instance( $timezone = NULL ){
54
+	public static function instance($timezone = NULL) {
55 55
 
56 56
 		// check if instance of EEM_Event already exists
57
-		if ( ! self::$_instance instanceof EEM_Event ) {
57
+		if ( ! self::$_instance instanceof EEM_Event) {
58 58
 			// instantiate Espresso_model
59
-			self::$_instance = new self( $timezone );
59
+			self::$_instance = new self($timezone);
60 60
 		}
61 61
 		//we might have a timezone set, let set_timezone decide what to do with it
62
-		self::$_instance->set_timezone( $timezone );
62
+		self::$_instance->set_timezone($timezone);
63 63
 		// EEM_Event object
64 64
 		return self::$_instance;
65 65
 	}
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 	 * @param string $timezone
71 71
 	 * @return EEM_Event
72 72
 	 */
73
-	protected function __construct($timezone = null){
73
+	protected function __construct($timezone = null) {
74 74
 
75
-		EE_Registry::instance()->load_model( 'Registration' );
75
+		EE_Registry::instance()->load_model('Registration');
76 76
 
77
-		$this->singular_item = __('Event','event_espresso');
78
-		$this->plural_item = __('Events','event_espresso');
77
+		$this->singular_item = __('Event', 'event_espresso');
78
+		$this->plural_item = __('Events', 'event_espresso');
79 79
 
80 80
 		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
81 81
 		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
@@ -89,57 +89,57 @@  discard block
 block discarded – undo
89 89
 			array(
90 90
 				EEM_Event::cancelled => array(
91 91
 					'label' => __('Cancelled', 'event_espresso'),
92
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE )
92
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE)
93 93
 				),
94 94
 				EEM_Event::postponed => array(
95 95
 					'label' => __('Postponed', 'event_espresso'),
96
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE )
96
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE)
97 97
 				),
98 98
 				EEM_Event::sold_out => array(
99 99
 					'label' => __('Sold Out', 'event_espresso'),
100
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE )
100
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE)
101 101
 				)
102 102
 			)
103 103
 		);
104 104
 
105
-		self::$_default_reg_status = empty( self::$_default_reg_status ) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
105
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
106 106
 
107 107
 		$this->_tables = array(
108
-			'Event_CPT'=>new EE_Primary_Table( 'posts','ID' ),
109
-			'Event_Meta'=> new EE_Secondary_Table( 'esp_event_meta', 'EVTM_ID', 'EVT_ID' )
108
+			'Event_CPT'=>new EE_Primary_Table('posts', 'ID'),
109
+			'Event_Meta'=> new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID')
110 110
 		);
111 111
 
112 112
 		$this->_fields = array(
113 113
 			'Event_CPT'=>array(
114
-				'EVT_ID'=>new EE_Primary_Key_Int_Field( 'ID', __( 'Post ID for Event','event_espresso' )),
115
-				'EVT_name'=>new EE_Plain_Text_Field( 'post_title', __( 'Event Name','event_espresso' ), FALSE, '' ),
116
-				'EVT_desc'=>new EE_Post_Content_Field( 'post_content', __( 'Event Description', 'event_espresso' ), FALSE, '' ),
117
-				'EVT_slug'=>new EE_Slug_Field( 'post_name', __( 'Event Slug', 'event_espresso' ), FALSE, '' ),
118
-				'EVT_created'=>new EE_Datetime_Field( 'post_date', __( 'Date/Time Event Created', 'event_espresso' ), FALSE, time()),
119
-				'EVT_short_desc'=>new EE_Simple_HTML_Field( 'post_excerpt', __( 'Event Short Description', 'event_espresso' ), FALSE,'' ),
120
-				'EVT_modified'=>new EE_Datetime_Field( 'post_modified', __( 'Date/Time Event Modified', 'event_espresso' ), FALSE, time()),
121
-				'EVT_wp_user'=>new EE_WP_User_Field( 'post_author', __( 'Event Creator ID', 'event_espresso'), FALSE),
122
-				'parent'=>new EE_Integer_Field( 'post_parent', __( 'Event Parent ID', 'event_espresso' ), FALSE, 0 ),
123
-				'EVT_order'=>new EE_Integer_Field( 'menu_order', __( 'Event Menu Order', 'event_espresso' ), FALSE, 1 ),
124
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'),// EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
-				'status' => new EE_WP_Post_Status_Field( 'post_status', __( 'Event Status', 'event_espresso' ), FALSE, 'draft', $this->_custom_stati )
114
+				'EVT_ID'=>new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')),
115
+				'EVT_name'=>new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''),
116
+				'EVT_desc'=>new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''),
117
+				'EVT_slug'=>new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''),
118
+				'EVT_created'=>new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, time()),
119
+				'EVT_short_desc'=>new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''),
120
+				'EVT_modified'=>new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), FALSE, time()),
121
+				'EVT_wp_user'=>new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), FALSE),
122
+				'parent'=>new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), FALSE, 0),
123
+				'EVT_order'=>new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1),
124
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'), // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
+				'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati)
126 126
 			),
127 127
 			'Event_Meta'=>array(
128
-				'EVTM_ID'=> new EE_DB_Only_Float_Field( 'EVTM_ID', __( 'Event Meta Row ID','event_espresso' ), FALSE ),
129
-				'EVT_ID_fk'=>new EE_DB_Only_Int_Field( 'EVT_ID', __( 'Foreign key to Event ID from Event Meta table', 'event_espresso' ), FALSE ),
130
-				'EVT_display_desc'=>new EE_Boolean_Field( 'EVT_display_desc', __( 'Display Description Flag', 'event_espresso' ), FALSE, 1 ),
131
-				'EVT_display_ticket_selector'=>new EE_Boolean_Field( 'EVT_display_ticket_selector', __( 'Display Ticket Selector Flag', 'event_espresso' ), FALSE, 1 ),
132
-				'EVT_visible_on'=>new EE_Datetime_Field( 'EVT_visible_on', __( 'Event Visible Date', 'event_espresso' ), TRUE, time()),
133
-				'EVT_additional_limit'=>new EE_Integer_Field( 'EVT_additional_limit', __( 'Limit of Additional Registrations on Same Transaction', 'event_espresso' ), TRUE, 10 ),
128
+				'EVTM_ID'=> new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE),
129
+				'EVT_ID_fk'=>new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE),
130
+				'EVT_display_desc'=>new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1),
131
+				'EVT_display_ticket_selector'=>new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1),
132
+				'EVT_visible_on'=>new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, time()),
133
+				'EVT_additional_limit'=>new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10),
134 134
 				'EVT_default_registration_status'=>new EE_Enum_Text_Field(
135
-					'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
135
+					'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
136 136
 				),
137
-				'EVT_member_only'=>new EE_Boolean_Field( 'EVT_member_only', __( 'Member-Only Event Flag', 'event_espresso' ), FALSE, FALSE ),
138
-				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __( 'Event Phone Number', 'event_espresso' ), FALSE ),
139
-				'EVT_allow_overflow'=>new EE_Boolean_Field(  'EVT_allow_overflow', __( 'Allow Overflow on Event', 'event_espresso' ), FALSE, FALSE ),
140
-				'EVT_timezone_string'=>new EE_Plain_Text_Field( 'EVT_timezone_string', __( 'Timezone (name) for Event times', 'event_espresso' ), FALSE ),
141
-				'EVT_external_URL'=>new EE_Plain_Text_Field( 'EVT_external_URL', __( 'URL of Event Page if hosted elsewhere', 'event_espresso' ), TRUE ),
142
-				'EVT_donations'=>new EE_Boolean_Field( 'EVT_donations', __( 'Accept Donations?', 'event_espresso' ), FALSE, FALSE )
137
+				'EVT_member_only'=>new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE),
138
+				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE),
139
+				'EVT_allow_overflow'=>new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE),
140
+				'EVT_timezone_string'=>new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE),
141
+				'EVT_external_URL'=>new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE),
142
+				'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE)
143 143
 
144 144
 			));
145 145
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			'WP_User' => new EE_Belongs_To_Relation(),
155 155
 		);
156 156
 		//this model is generally available for reading
157
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
158
-		parent::__construct( $timezone );
157
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
158
+		parent::__construct($timezone);
159 159
 	}
160 160
 
161 161
 
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	/**
164 164
 	 * @param string $default_reg_status
165 165
 	 */
166
-	public static function set_default_reg_status( $default_reg_status ) {
166
+	public static function set_default_reg_status($default_reg_status) {
167 167
 		self::$_default_reg_status = $default_reg_status;
168 168
 		//if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default.
169
-		if ( self::$_instance instanceof EEM_Event ) {
169
+		if (self::$_instance instanceof EEM_Event) {
170 170
 			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field(
171
-				'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), false, $default_reg_status, EEM_Registration::reg_status_array()
171
+				'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), false, $default_reg_status, EEM_Registration::reg_status_array()
172 172
 			);
173
-			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize( 'Event_Meta', 'EVT_default_registration_status', 'EEM_Event' );
173
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', 'EVT_default_registration_status', 'EEM_Event');
174 174
 		}
175 175
 	}
176 176
 
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	*		@return 		array
184 184
 	*/
185 185
 	public function get_all_question_groups() {
186
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
187
-			array( 'QSG_deleted' => FALSE ),
188
-			'order_by' => array( 'QSG_order' => 'ASC' )
186
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
187
+			array('QSG_deleted' => FALSE),
188
+			'order_by' => array('QSG_order' => 'ASC')
189 189
 		));
190 190
 	}
191 191
 
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	* 		@param		int $EVT_ID
202 202
 	*		@return 		array
203 203
 	*/
204
-	public function get_all_event_question_groups( $EVT_ID = 0 ) {
205
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
206
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
204
+	public function get_all_event_question_groups($EVT_ID = 0) {
205
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
206
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
207 207
 			return FALSE;
208 208
 		}
209
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
210
-			array( 'EVT_ID' => $EVT_ID )
209
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
210
+			array('EVT_ID' => $EVT_ID)
211 211
 		));
212 212
 	}
213 213
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	* 		@param		boolean	$for_primary_attendee
224 224
 	*		@return 		array
225 225
 	*/
226
-	public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) {
227
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
228
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
226
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = TRUE) {
227
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
228
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
229 229
 			return FALSE;
230 230
 		}
231
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
232
-			array( 'EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee )
231
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
232
+			array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee)
233 233
 		));
234 234
 	}
235 235
 
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	* 		@param		EE_Registration 	$registration
247 247
 	*		@return 		array
248 248
 	*/
249
-	public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) {
249
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) {
250 250
 
251
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
252
-			EE_Error::add_error( __( 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
251
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
252
+			EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
253 253
 			return FALSE;
254 254
 		}
255 255
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			'QSG_deleted' => FALSE
260 260
 		);
261 261
 
262
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
262
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
263 263
 			$where_params,
264 264
 			'order_by' => array('QSG_order' => 'ASC')
265 265
 		));
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	* 		@param		string		$QSG_IDs  csv list of $QSG IDs
280 280
 	*		@return 		array
281 281
 	*/
282
-	public function get_questions_in_groups( $QSG_IDs = '' ) {
282
+	public function get_questions_in_groups($QSG_IDs = '') {
283 283
 
284
-		if ( empty( $QSG_IDs )) {
285
-			EE_Error::add_error( __( 'An error occurred. No Question Group IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
284
+		if (empty($QSG_IDs)) {
285
+			EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
286 286
 			return FALSE;
287 287
 		}
288 288
 
289
-		return EE_Registry::instance()->load_model( 'Question' )->get_all( array(
289
+		return EE_Registry::instance()->load_model('Question')->get_all(array(
290 290
 			array(
291
-				'Question_Group.QSG_ID' => array( 'IN', $QSG_IDs ),
291
+				'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
292 292
 				'QST_deleted' => FALSE,
293 293
 				'QST_admin_only' => is_admin()
294 294
 			),
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 	* 		@param		string		$QST_IDs  csv list of $QST IDs
311 311
 	*		@return 		array
312 312
 	*/
313
-	public function get_options_for_question( $QST_IDs ) {
313
+	public function get_options_for_question($QST_IDs) {
314 314
 
315
-		if ( empty( $QST_IDs )) {
316
-			EE_Error::add_error( __( 'An error occurred. No Question IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
315
+		if (empty($QST_IDs)) {
316
+			EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
317 317
 			return FALSE;
318 318
 		}
319 319
 
320
-		return EE_Registry::instance()->load_model( 'Question_Option' )->get_all( array(
320
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(array(
321 321
 			array(
322
-				'Question.QST_ID' => array( 'IN', $QST_IDs ),
322
+				'Question.QST_ID' => array('IN', $QST_IDs),
323 323
 				'QSO_deleted' => FALSE
324 324
 			),
325 325
 			'order_by' => 'QSO_ID'
@@ -338,46 +338,46 @@  discard block
 block discarded – undo
338 338
 	 * @throws EE_Error
339 339
 	 * @return 	array
340 340
 	 */
341
-	public function assemble_array_of_groups_questions_and_options( EE_Registration $registration, $EVT_ID = 0 ) {
341
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) {
342 342
 
343
-		if ( empty( $EVT_ID ) ) {
344
-			throw new EE_Error( __( 'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso' ) );
343
+		if (empty($EVT_ID)) {
344
+			throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso'));
345 345
 		}
346 346
 
347 347
 		$questions = array();
348 348
 
349 349
 		// get all question groups for event
350
-		$qgs = $this->get_question_groups_for_event( $EVT_ID, $registration );
351
-		if ( !empty( $qgs ) ) {
352
-			foreach ( $qgs as $qg ) {
350
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
351
+		if ( ! empty($qgs)) {
352
+			foreach ($qgs as $qg) {
353 353
 			 	$qsts = $qg->questions();
354
-			 	$questions[ $qg->ID() ] = $qg->model_field_array();
355
-			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
356
-			 	foreach ( $qsts as $qst ) {
357
-			 		if ( $qst->is_system_question() )
354
+			 	$questions[$qg->ID()] = $qg->model_field_array();
355
+			 	$questions[$qg->ID()]['QSG_questions'] = array();
356
+			 	foreach ($qsts as $qst) {
357
+			 		if ($qst->is_system_question())
358 358
 			 			continue;
359
-			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
359
+			 		$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID())));
360 360
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
361 361
 			 		$qst_name = $qstn_id = $qst->ID();
362 362
 			 		$ans_id = $answer->ID();
363
-			 		$qst_name = !empty( $ans_id ) ?  '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
363
+			 		$qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
364 364
 			 		$input_name = '';
365
-			 		$input_id = sanitize_key( $qst->display_text() );
365
+			 		$input_id = sanitize_key($qst->display_text());
366 366
 			 		$input_class = '';
367 367
 			 		$questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
368
-		 			$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn' . $input_name . $qst_name;
369
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
370
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
371
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
372
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
373
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
368
+		 			$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name;
369
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
370
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
371
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
372
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
373
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
374 374
 					//leave responses as-is, don't convert stuff into html entities please!
375
-					$questions[ $qg->ID() ][ 'QSG_questions'][ $qst->ID() ][ 'htmlentities' ] = false;
376
-					if ( $qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN' ) {
377
-						$QSOs = $qst->options(TRUE,$answer->value());
378
-						if ( is_array( $QSOs ) ) {
379
-							foreach ( $QSOs as $QSO_ID => $QSO ) {
380
-								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
375
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false;
376
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
377
+						$QSOs = $qst->options(TRUE, $answer->value());
378
+						if (is_array($QSOs)) {
379
+							foreach ($QSOs as $QSO_ID => $QSO) {
380
+								$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
381 381
 							}
382 382
 						}
383 383
 					}
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 	* 		@param		$QST
402 402
 	*		@return 		string		string
403 403
 	*/
404
-	private function _generate_question_input_name( $QST ) {
404
+	private function _generate_question_input_name($QST) {
405 405
 
406
-		if ( $QST->QST_system ) {
406
+		if ($QST->QST_system) {
407 407
 			$qst_name = $QST->QST_system;
408 408
 /*			switch( $QST->QST_system ) {
409 409
 
@@ -470,36 +470,36 @@  discard block
 block discarded – undo
470 470
 	 * @param bool    $count whether to return the count or not (default FALSE)
471 471
 	 * @return array 	EE_Event objects
472 472
 	 */
473
-	public function get_active_events( $query_params, $count = FALSE ) {
474
-		if ( array_key_exists( 0, $query_params ) ) {
473
+	public function get_active_events($query_params, $count = FALSE) {
474
+		if (array_key_exists(0, $query_params)) {
475 475
 			$where_params = $query_params[0];
476
-			unset( $query_params[0] );
476
+			unset($query_params[0]);
477 477
 		} else {
478 478
 			$where_params = array();
479 479
 		}
480 480
 
481 481
 		//if we have count make sure we don't include group by
482
-		if ( $count && isset( $query_params['group_by'] ) ) {
483
-			unset( $query_params['group_by'] );
482
+		if ($count && isset($query_params['group_by'])) {
483
+			unset($query_params['group_by']);
484 484
 		}
485 485
 
486 486
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
487 487
 		$where_params['status'] = 'publish';
488 488
 		//if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
489
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
490
-			$where_params['Datetime.DTT_EVT_start******'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
489
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
490
+			$where_params['Datetime.DTT_EVT_start******'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
491 491
 		} else {
492
-			$where_params['Datetime.DTT_EVT_start'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
492
+			$where_params['Datetime.DTT_EVT_start'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
493 493
 		}
494 494
 
495
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
496
-			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
495
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
496
+			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
497 497
 		} else {
498
-			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
498
+			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
499 499
 		}
500 500
 		$query_params[0] = $where_params;
501 501
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
502
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
502
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
503 503
 	}
504 504
 
505 505
 
@@ -514,30 +514,30 @@  discard block
 block discarded – undo
514 514
 	 * @param bool    $count whether to return the count or not (default FALSE)
515 515
 	 * @return array               EE_Event objects
516 516
 	 */
517
-	public function get_upcoming_events( $query_params, $count = FALSE ) {
518
-		if ( array_key_exists( 0, $query_params ) ) {
517
+	public function get_upcoming_events($query_params, $count = FALSE) {
518
+		if (array_key_exists(0, $query_params)) {
519 519
 			$where_params = $query_params[0];
520
-			unset( $query_params[0] );
520
+			unset($query_params[0]);
521 521
 		} else {
522 522
 			$where_params = array();
523 523
 		}
524 524
 
525 525
 		//if we have count make sure we don't include group by
526
-		if ( $count && isset( $query_params['group_by'] ) ) {
527
-			unset( $query_params['group_by'] );
526
+		if ($count && isset($query_params['group_by'])) {
527
+			unset($query_params['group_by']);
528 528
 		}
529 529
 
530 530
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
531 531
 		$where_params['status'] = 'publish';
532 532
 		//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
533
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
534
-			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
533
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
534
+			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
535 535
 		} else {
536
-			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
536
+			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
537 537
 		}
538 538
 		$query_params[0] = $where_params;
539 539
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
540
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
540
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
541 541
 	}
542 542
 
543 543
 
@@ -549,56 +549,56 @@  discard block
 block discarded – undo
549 549
 	 * @param bool    $count whether to return the count or not (default FALSE)
550 550
 	 * @return array 	EE_Event objects
551 551
 	 */
552
-	public function get_expired_events( $query_params, $count = FALSE ) {
552
+	public function get_expired_events($query_params, $count = FALSE) {
553 553
 
554
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
554
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
555 555
 
556 556
 		//if we have count make sure we don't include group by
557
-		if ( $count && isset( $query_params['group_by'] ) ) {
558
-			unset( $query_params['group_by'] );
557
+		if ($count && isset($query_params['group_by'])) {
558
+			unset($query_params['group_by']);
559 559
 		}
560 560
 
561 561
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
562
-		if ( isset( $where_params['status'] ) ) {
563
-			unset( $where_params['status'] );
562
+		if (isset($where_params['status'])) {
563
+			unset($where_params['status']);
564 564
 		}
565 565
 		$exclude_query = $query_params;
566
-		if ( isset( $exclude_query[0] ) ) {
567
-			unset( $exclude_query[0] );
566
+		if (isset($exclude_query[0])) {
567
+			unset($exclude_query[0]);
568 568
 		}
569
-		$exclude_query[0] = array( 'Datetime.DTT_EVT_end' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) );
569
+		$exclude_query[0] = array('Datetime.DTT_EVT_end' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')));
570 570
 		//first get all events that have datetimes where its not expired.
571
-		$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Event_CPT.ID' );
572
-		$event_ids = array_keys( $event_ids );
571
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
572
+		$event_ids = array_keys($event_ids);
573 573
 
574 574
 		//if we have any additional query_params, let's add them to the 'AND' condition
575 575
 		$and_condition = array(
576
-			'Datetime.DTT_EVT_end' => array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ),
577
-			'EVT_ID' =>  array( 'NOT IN', $event_ids )
576
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
577
+			'EVT_ID' =>  array('NOT IN', $event_ids)
578 578
 			);
579 579
 
580
-		if ( isset( $where_params['OR'] ) ) {
580
+		if (isset($where_params['OR'])) {
581 581
 			$and_condition['OR'] = $where_params['OR'];
582
-			unset( $where_params['OR'] );
582
+			unset($where_params['OR']);
583 583
 		}
584 584
 
585
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
585
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
586 586
 			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
587
-			unset( $where_params['Datetime.DTT_EVT_end'] );
587
+			unset($where_params['Datetime.DTT_EVT_end']);
588 588
 		}
589 589
 
590
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
590
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
591 591
 			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
592
-			unset( $where_params['Datetime.DTT_EVT_start'] );
592
+			unset($where_params['Datetime.DTT_EVT_start']);
593 593
 		}
594 594
 
595 595
 		//merge remaining $where params with the and conditions.
596
-		$and_condtion = array_merge( $and_condition, $where_params );
596
+		$and_condtion = array_merge($and_condition, $where_params);
597 597
 
598 598
 		$where_params['AND'] = $and_condition;
599 599
 		$query_params[0] = $where_params;
600 600
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
601
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
601
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
602 602
 	}
603 603
 
604 604
 
@@ -609,40 +609,40 @@  discard block
 block discarded – undo
609 609
 	 * @param  boolean $count        whether to return the count or not (default FALSE)
610 610
 	 * @return EE_Event[]            array of EE_Event objects
611 611
 	 */
612
-	public function get_inactive_events( $query_params, $count = FALSE ) {
613
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
612
+	public function get_inactive_events($query_params, $count = FALSE) {
613
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
614 614
 
615 615
 		//let's add in specific query_params for inactive events.
616
-		if ( isset( $where_params['status'] ) ) {
617
-			unset( $where_params['status'] );
616
+		if (isset($where_params['status'])) {
617
+			unset($where_params['status']);
618 618
 		}
619 619
 
620 620
 		//if we have count make sure we don't include group by
621
-		if ( $count && isset( $query_params['group_by'] ) ) {
622
-			unset( $query_params['group_by'] );
621
+		if ($count && isset($query_params['group_by'])) {
622
+			unset($query_params['group_by']);
623 623
 		}
624 624
 
625 625
 		//if we have any additional query_params, let's add them to the 'AND' condition
626
-		$where_params['AND']['status'] = array( '!=', 'publish' );
626
+		$where_params['AND']['status'] = array('!=', 'publish');
627 627
 
628
-		if ( isset( $where_params['OR'] ) ) {
628
+		if (isset($where_params['OR'])) {
629 629
 			$where_params['AND']['OR'] = $where_params['OR'];
630
-			unset( $where_params['OR'] );
630
+			unset($where_params['OR']);
631 631
 		}
632 632
 
633
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
633
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
634 634
 			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
635
-			unset( $where_params['Datetime.DTT_EVT_end'] );
635
+			unset($where_params['Datetime.DTT_EVT_end']);
636 636
 		}
637 637
 
638
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
638
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
639 639
 			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
640
-			unset( $where_params['Datetime.DTT_EVT_start'] );
640
+			unset($where_params['Datetime.DTT_EVT_start']);
641 641
 		}
642 642
 
643 643
 		$query_params[0] = $where_params;
644 644
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
645
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
645
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
646 646
 	}
647 647
 
648 648
 
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships because we don't want to override any existing global default prices but instead insert NEW prices that get attached to the event.
651 651
 	 * See parent for param descriptions
652 652
 	 */
653
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
653
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
654 654
 
655
-		if ( $relationName == 'Price' ) {
655
+		if ($relationName == 'Price') {
656 656
 			//let's get the PRC object for the given ID to make sure that we aren't dealing with a default
657 657
 			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
658 658
 			//if EVT_ID = 0, then this is a default
659
-			if ( $prc_chk->get('EVT_ID') == 0 ) {
659
+			if ($prc_chk->get('EVT_ID') == 0) {
660 660
 				//let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
661 661
 				$prc_chk->set('PRC_ID', 0);
662 662
 			}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		}
667 667
 
668 668
 		//otherwise carry on as normal
669
-		return parent::add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query);
669
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
670 670
 	}
671 671
 
672 672
 
Please login to merge, or discard this patch.